[1882] | 1 | dotclear.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 | |
---|
| 15 | dotclear.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 | |
---|
| 29 | dotclear.viewPostsContent = function(img,lines) { |
---|
[1884] | 30 | |
---|
| 31 | action = 'toggle'; |
---|
[1882] | 32 | |
---|
| 33 | if (img.alt == dotclear.img_plus_alt) { |
---|
| 34 | img.src = dotclear.img_minus_src; |
---|
| 35 | img.alt = dotclear.img_minus_alt; |
---|
[1884] | 36 | action = 'open'; |
---|
[1882] | 37 | } else { |
---|
| 38 | img.src = dotclear.img_plus_src; |
---|
| 39 | img.alt = dotclear.img_plus_alt; |
---|
[1884] | 40 | action = 'close'; |
---|
[1882] | 41 | } |
---|
[1884] | 42 | |
---|
| 43 | lines.each(function() { |
---|
| 44 | var td = this.firstChild; |
---|
| 45 | dotclear.viewPostContent(td.firstChild,td.firstChild.line,action); |
---|
| 46 | }); |
---|
[1882] | 47 | }; |
---|
| 48 | |
---|
[1884] | 49 | dotclear.viewPostContent = function(img,line,action) { |
---|
| 50 | |
---|
| 51 | var action = action || 'toggle'; |
---|
[1882] | 52 | var postId = line.id.substr(1); |
---|
| 53 | var tr = document.getElementById('pe'+postId); |
---|
| 54 | |
---|
[1884] | 55 | if ( !tr && ( action == 'toggle' || action == 'open' ) ) { |
---|
[1882] | 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 | |
---|
[1884] | 87 | $(line).addClass('expand'); |
---|
[1882] | 88 | line.parentNode.insertBefore(tr,line.nextSibling); |
---|
| 89 | } |
---|
[1884] | 90 | else if (tr && tr.style.display == 'none' && ( action == 'toggle' || action == 'open' ) ) |
---|
[1882] | 91 | { |
---|
[1884] | 92 | $(tr).css('display', 'table-row'); |
---|
| 93 | $(line).addClass('expand'); |
---|
[1882] | 94 | img.src = dotclear.img_minus_src; |
---|
| 95 | img.alt = dotclear.img_minus_alt; |
---|
| 96 | } |
---|
[1884] | 97 | else if (tr && tr.style.display != 'none' && ( action == 'toggle' || action == 'close' ) ) |
---|
[1882] | 98 | { |
---|
[1884] | 99 | $(tr).css('display', 'none'); |
---|
| 100 | $(line).removeClass('expand'); |
---|
[1882] | 101 | img.src = dotclear.img_plus_src; |
---|
| 102 | img.alt = dotclear.img_plus_alt; |
---|
| 103 | } |
---|
[1884] | 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 | |
---|
[1882] | 118 | }; |
---|
| 119 | |
---|
| 120 | $(function() { |
---|
| 121 | |
---|
[1884] | 122 | $('#pageslist tr.line').prepend('<td class="expander"></td>'); |
---|
[1882] | 123 | $('#form-entries tr:not(.line) th:first').attr('colspan',4); |
---|
| 124 | $('#form-entries tr:not(.line)').each(function() { |
---|
| 125 | dotclear.postsExpander(this,$('#form-entries tr.line')); |
---|
| 126 | }); |
---|
[1884] | 127 | $('#pageslist tr.line').each(function() { |
---|
[1882] | 128 | dotclear.postExpander(this); |
---|
| 129 | }); |
---|
| 130 | $('.checkboxes-helpers').each(function() { |
---|
| 131 | p = $('<p></p>'); |
---|
| 132 | $(this).prepend(p); |
---|
| 133 | dotclear.checkboxesHelpers(p); |
---|
| 134 | }); |
---|
[1884] | 135 | $('#pageslist td input[type=checkbox]').enableShiftClick(); |
---|
| 136 | |
---|
| 137 | $("#pageslist tr.line td:not(.expander)").mousedown(function(){ |
---|
| 138 | $('#pageslist tr.line').each(function() { |
---|
| 139 | var td = this.firstChild; |
---|
| 140 | dotclear.viewPostContent(td.firstChild,td.firstChild.line,'close'); |
---|
| 141 | }); |
---|
| 142 | $('#pageslist tr:not(.line)').remove(); |
---|
| 143 | }); |
---|
[1882] | 144 | |
---|
| 145 | $("#pageslist").sortable({ |
---|
| 146 | cursor:'move', |
---|
| 147 | stop: function( event, ui ) { |
---|
| 148 | $("#pageslist tr td input.position").each(function(i) { |
---|
| 149 | $(this).val(i+1); |
---|
| 150 | }); |
---|
| 151 | } |
---|
| 152 | }); |
---|
| 153 | $("#pageslist tr").hover(function () { |
---|
| 154 | $(this).css({'cursor':'move'}); |
---|
| 155 | }, function () { |
---|
| 156 | $(this).css({'cursor':'auto'}); |
---|
| 157 | }); |
---|
| 158 | $("#pageslist tr td input.position").hide(); |
---|
| 159 | $("#pageslist tr td.handle").addClass('handler'); |
---|
[2058] | 160 | |
---|
| 161 | $("form input[type=submit]").click(function() { |
---|
| 162 | $("input[type=submit]", $(this).parents("form")).removeAttr("clicked"); |
---|
| 163 | $(this).attr("clicked", "true"); |
---|
| 164 | }) |
---|
| 165 | |
---|
| 166 | $('#form-entries').submit(function() { |
---|
| 167 | var action = $(this).find('select[name="action"]').val(); |
---|
| 168 | var checked = false; |
---|
| 169 | if ($("input[name=reorder][clicked=true]").val()) { |
---|
| 170 | return true; |
---|
| 171 | } |
---|
| 172 | $(this).find('input[name="entries[]"]').each(function() { |
---|
| 173 | if (this.checked) { |
---|
| 174 | checked = true; |
---|
| 175 | } |
---|
| 176 | }); |
---|
| 177 | |
---|
| 178 | if (!checked) { return false; } |
---|
| 179 | |
---|
| 180 | if (action == 'delete') { |
---|
| 181 | return window.confirm(dotclear.msg.confirm_delete_posts.replace('%s',$('input[name="entries[]"]:checked').size())); |
---|
| 182 | } |
---|
| 183 | |
---|
| 184 | return true; |
---|
| 185 | }); |
---|
[1882] | 186 | }); |
---|