Dotclear

source: admin/js/_posts_list.js @ 1640:8a85e01f92b6

Revision 1640:8a85e01f92b6, 3.6 KB checked in by Lepeltier kévin, 12 years ago (diff)

Ticket #1550 : Petite correction, au cas ou les tr venez à disparaitre.

RevLine 
[0]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;
[1034]10     img.onclick = function() { dotclear.viewPostContent(this,this.line); };
[0]11     
12     td.insertBefore(img,td.firstChild);
13};
14
[1034]15dotclear.postsExpander = function(line,lines) {
[1033]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');
[1034]23     img.lines = lines;
24     img.onclick = function() { dotclear.viewPostsContent(this,this.lines); };
[1033]25
26     td.insertBefore(img,td.firstChild);
27};
28
[1034]29dotclear.viewPostsContent = function(img,lines) {
[1639]30     
31     action = 'toggle';
[1033]32
33     if (img.alt == dotclear.img_plus_alt) {
34          img.src = dotclear.img_minus_src;
35          img.alt = dotclear.img_minus_alt;
[1639]36          action = 'open';
[1033]37     } else {
38          img.src = dotclear.img_plus_src;
39          img.alt = dotclear.img_plus_alt;
[1639]40          action = 'close';
[1033]41     }
[1639]42     
43     lines.each(function() {
44          var td = this.firstChild;
45          dotclear.viewPostContent(td.firstChild,td.firstChild.line,action);
46     });
[1033]47};
48
[1639]49dotclear.viewPostContent = function(img,line,action) {
50     
51     var action = action || 'toggle';
[0]52     var postId = line.id.substr(1);
53     var tr = document.getElementById('pe'+postId);
54     
[1639]55     if ( !tr && ( action == 'toggle' || action == 'open' ) ) {
[0]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         
[1639]87          $(line).addClass('expand');
[0]88          line.parentNode.insertBefore(tr,line.nextSibling);
89     }
[1640]90     else if (tr && tr.style.display == 'none' && ( action == 'toggle' || action == 'open' ) )
[0]91     {
[1639]92          $(tr).css('display', 'table-row');
93          $(line).addClass('expand');
[0]94          img.src = dotclear.img_minus_src;
95          img.alt = dotclear.img_minus_alt;
96     }
[1640]97     else if (tr && tr.style.display != 'none' && ( action == 'toggle' || action == 'close' ) )
[0]98     {
[1639]99          $(tr).css('display', 'none');
100          $(line).removeClass('expand');
[0]101          img.src = dotclear.img_plus_src;
102          img.alt = dotclear.img_plus_alt;
103     }
[1639]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     
[0]118};
119
120$(function() {
[995]121     // Entry type switcher
122     $('#type').change(function() {
123          this.form.submit();
124     });
125
[1033]126     $('#form-entries tr:not(.line)').each(function() {
[1034]127          dotclear.postsExpander(this,$('#form-entries tr.line'));
[1033]128     });
[0]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