Dotclear

source: admin/js/_posts_list.js @ 1639:0c068f3e0f8e

Revision 1639:0c068f3e0f8e, 3.6 KB checked in by Lepeltier kévin, 11 years ago (diff)

Ticket #1550 : fléche Plier/déplier général impose son état aux autres lignes.
Et inversement.

Line 
1dotclear.postExpander = 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.viewPostContent(this,this.line); };
11     
12     td.insertBefore(img,td.firstChild);
13};
14
15dotclear.postsExpander = 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.viewPostsContent(this,this.lines); };
25
26     td.insertBefore(img,td.firstChild);
27};
28
29dotclear.viewPostsContent = 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.viewPostContent(td.firstChild,td.firstChild.line,action);
46     });
47};
48
49dotclear.viewPostContent = function(img,line,action) {
50     
51     var action = action || 'toggle';
52     var postId = line.id.substr(1);
53     var tr = document.getElementById('pe'+postId);
54     
55     if ( !tr && ( action == 'toggle' || action == 'open' ) ) {
56          tr = document.createElement('tr');
57          tr.id = 'pe'+postId;
58          var td = document.createElement('td');
59          td.colSpan = 8;
60          td.className = 'expand';
61          tr.appendChild(td);
62         
63          img.src = dotclear.img_minus_src;
64          img.alt = dotclear.img_minus_alt;
65         
66          // Get post content
67          $.get('services.php',{f:'getPostById', id: postId, post_type: ''},function(data) {
68               var rsp = $(data).children('rsp')[0];
69               
70               if (rsp.attributes[0].value == 'ok') {
71                    var post = $(rsp).find('post_display_content').text();
72                    var post_excerpt = $(rsp).find('post_display_excerpt').text();
73                    var res = '';
74                   
75                    if (post) {
76                         if (post_excerpt) {
77                              res += post_excerpt + '<hr />';
78                         }
79                         res += post;
80                         $(td).append(res);
81                    }
82               } else {
83                    alert($(rsp).find('message').text());
84               }
85          });
86         
87          $(line).addClass('expand');
88          line.parentNode.insertBefore(tr,line.nextSibling);
89     }
90     else if (tr.style.display == 'none' && ( action == 'toggle' || action == 'open' ) )
91     {
92          $(tr).css('display', 'table-row');
93          $(line).addClass('expand');
94          img.src = dotclear.img_minus_src;
95          img.alt = dotclear.img_minus_alt;
96     }
97     else if (tr.style.display != 'none' && ( action == 'toggle' || action == 'close' ) )
98     {
99          $(tr).css('display', 'none');
100          $(line).removeClass('expand');
101          img.src = dotclear.img_plus_src;
102          img.alt = dotclear.img_plus_alt;
103     }
104     
105     parentTable = $(line).parents('table');
106     if( parentTable.find('tr.expand').length == parentTable.find('tr.line').length ) {
107          img = parentTable.find('tr:not(.line) th:first img');
108          img.attr('src',dotclear.img_minus_src);
109          img.attr('alt',dotclear.img_minus_alt);
110     }
111     
112     if( parentTable.find('tr.expand').length == 0 ) {
113          img = parentTable.find('tr:not(.line) th:first img');
114          img.attr('src',dotclear.img_plus_src);
115          img.attr('alt',dotclear.img_plus_alt);
116     }
117     
118};
119
120$(function() {
121     // Entry type switcher
122     $('#type').change(function() {
123          this.form.submit();
124     });
125
126     $('#form-entries tr:not(.line)').each(function() {
127          dotclear.postsExpander(this,$('#form-entries tr.line'));
128     });
129     $('#form-entries tr.line').each(function() {
130          dotclear.postExpander(this);
131     });
132     $('.checkboxes-helpers').each(function() {
133          dotclear.checkboxesHelpers(this);
134     });
135     $('#form-entries td input[type=checkbox]').enableShiftClick();
136     dotclear.postsActionsHelper();
137});
Note: See TracBrowser for help on using the repository browser.

Sites map