Dotclear

source: admin/js/_plugins.js @ 2292:422a205a97df

Revision 2292:422a205a97df, 6.8 KB checked in by Anne Kozlika <kozlika@…>, 12 years ago (diff)

Présentation des infos complémentaires pour les plugins. Suppression de l'intitulé "Aide", placement des deux listes de détails. Alignement des icônes.
(+ nettoyage de l'image search pour transparence)

Line 
1dotclear.moduleExpander = function(line) {
2        var td = line.firstChild;
3       
4        var img = document.createElement('img');
5        img.src = dotclear.img_plus_src;
6        img.alt = dotclear.img_plus_alt;
7        img.className = 'expand';
8        $(img).css('cursor','pointer');
9        img.line = line;
10        img.onclick = function() { dotclear.viewModuleContent(this,this.line); };
11       
12        td.insertBefore(img,td.firstChild);
13};
14
15dotclear.modulesExpander = function(line,lines) {
16        var td = line.firstChild;
17
18        var img = document.createElement('img');
19        img.src = dotclear.img_plus_src;
20        img.alt = dotclear.img_plus_alt;
21        img.className = 'expand';
22        $(img).css('cursor','pointer');
23        img.lines = lines;
24        img.onclick = function() { dotclear.viewModulesContent(this,this.lines); };
25
26        td.insertBefore(img,td.firstChild);
27};
28
29dotclear.viewModulesContent = function(img,lines) {
30       
31        action = 'toggle';
32
33        if (img.alt == dotclear.img_plus_alt) {
34                img.src = dotclear.img_minus_src;
35                img.alt = dotclear.img_minus_alt;
36                action = 'open';
37        } else {
38                img.src = dotclear.img_plus_src;
39                img.alt = dotclear.img_plus_alt;
40                action = 'close';
41        }
42       
43        lines.each(function() {
44                var td = this.firstChild;
45                dotclear.viewModuleContent(td.firstChild,td.firstChild.line,action);
46        });
47};
48
49dotclear.viewModuleContent = function(img,line,action) {
50
51        var action = action || 'toggle';
52          var cols = $('td',$(line)).length
53        var sp = line.id.split('_m_');
54          var listId=sp[0];
55          var moduleId= sp[1];
56
57        var tr = document.getElementById('pe'+moduleId);
58       
59          if ( !tr && ( action == 'toggle' || action == 'open' ) ) {
60                tr = document.createElement('tr');
61                tr.id = 'pe'+moduleId;
62
63                var td = document.createElement('td');
64                td.colSpan = cols;
65                td.className = 'expand';
66                tr.appendChild(td);
67               
68                img.src = dotclear.img_minus_src;
69                img.alt = dotclear.img_minus_alt;
70               
71                // Get post content
72                $.get('services.php',{f:'getModuleById', id: moduleId, list: listId},function(data) {
73                        var rsp = $(data).children('rsp')[0];
74                       
75                        if (rsp.attributes[0].value == 'ok') {
76                                var author = $(rsp).find('author').text();
77                                var details = $(rsp).find('details').text();
78                                var support = $(rsp).find('support').text();
79                                        var box = document.createElement('div');
80                                var bloc = document.createElement('ul');
81                                bloc.className = "mod-more";
82                               
83                                if (author) {
84                                        $(bloc).append($('<li class="module-author">'+dotclear.msg.module_author+' '+author+'</li>'));
85                                }
86                                if (details) {
87                                        var dd = '';
88                                        dd += '<a class="module-details" href="'+details+'">'+dotclear.msg.module_details+'</a>';
89                                        if (support) {
90                                                dd += ' - ';
91                                                dd += '<a class="module-support" href="'+support+'">'+dotclear.msg.module_support+'</a>';
92                                        }
93                                        $(bloc).append($('<li>'+dd+'</li>'));
94                                }
95
96                                $(td).append($(box).append(bloc));
97                               
98                                var section = $(rsp).find('section').text();
99                                var tags = $(rsp).find('tags').text();
100                               
101                    var boxb = document.createElement('div');
102                                var blocb = document.createElement('ul');
103                                blocb.className = "mod-more";
104                               
105                                if (section) {
106                                        $(blocb).append($('<li class="module-section">'+dotclear.msg.module_section+' '+section+'</li>'));
107                                }
108                                if (tags) {
109                                        $(blocb).append($('<li class="module-tags">'+dotclear.msg.module_tags+' '+tags+'</li>'));
110                                }
111                                $(td).append($(boxb).append(blocb));
112                        } else {
113                                alert($(rsp).find('message').text());
114                        }
115                });
116               
117                $(line).addClass('expand');
118                line.parentNode.insertBefore(tr,line.nextSibling);
119        }
120        else if (tr && tr.style.display == 'none' && ( action == 'toggle' || action == 'open' ) )
121        {
122                $(tr).css('display', 'table-row');
123                $(line).addClass('expand');
124                img.src = dotclear.img_minus_src;
125                img.alt = dotclear.img_minus_alt;
126        }
127        else if (tr && tr.style.display != 'none' && ( action == 'toggle' || action == 'close' ) )
128        {
129                $(tr).css('display', 'none');
130                $(line).removeClass('expand');
131                img.src = dotclear.img_plus_src;
132                img.alt = dotclear.img_plus_alt;
133        }
134       
135        parentTable = $(line).parents('table');
136        if( parentTable.find('tr.expand').length == parentTable.find('tr.line').length ) {
137                img = parentTable.find('tr:not(.line) th:first img');
138                img.attr('src',dotclear.img_minus_src);
139                img.attr('alt',dotclear.img_minus_alt);
140        }
141       
142        if( parentTable.find('tr.expand').length == 0 ) {
143                img = parentTable.find('tr:not(.line) th:first img');
144                img.attr('src',dotclear.img_plus_src);
145                img.attr('alt',dotclear.img_plus_alt);
146        }
147       
148};
149
150
151$(function() {
152/*
153     // expand all modules lines
154     $('table.modules.expandable tr:not(.line)').each(function() {
155          dotclear.modulesExpander(this,$('table.modules.expandable tr.line'));
156     });
157*/
158     // expand a module line
159     $('table.modules.expandable tr.line').each(function() {
160          dotclear.moduleExpander(this);
161     });
162
163     // confirm module deletion
164     $('div.module-actions form input[type=submit][name=delete]').click(function() {
165          var module_id = $('input[name=module]',$(this).parent()).val();
166          return window.confirm(dotclear.msg.confirm_delete_plugin.replace('%s',module_id));
167     });
168});
Note: See TracBrowser for help on using the repository browser.

Sites map