| 1 | dotclear.viewPostContent = function(line,action) { |
|---|
| 2 | var action = action || 'toggle'; |
|---|
| 3 | var postId = $(line).attr('id').substr(1); |
|---|
| 4 | var tr = document.getElementById('pe'+postId); |
|---|
| 5 | |
|---|
| 6 | if ( !tr && ( action == 'toggle' || action == 'open' ) ) { |
|---|
| 7 | tr = document.createElement('tr'); |
|---|
| 8 | tr.id = 'pe'+postId; |
|---|
| 9 | var td = document.createElement('td'); |
|---|
| 10 | td.colSpan = 8; |
|---|
| 11 | td.className = 'expand'; |
|---|
| 12 | tr.appendChild(td); |
|---|
| 13 | |
|---|
| 14 | // Get post content |
|---|
| 15 | $.get('services.php',{f:'getPostById', id: postId, post_type: ''},function(data) { |
|---|
| 16 | var rsp = $(data).children('rsp')[0]; |
|---|
| 17 | |
|---|
| 18 | if (rsp.attributes[0].value == 'ok') { |
|---|
| 19 | var post = $(rsp).find('post_display_content').text(); |
|---|
| 20 | var post_excerpt = $(rsp).find('post_display_excerpt').text(); |
|---|
| 21 | var res = ''; |
|---|
| 22 | |
|---|
| 23 | if (post) { |
|---|
| 24 | if (post_excerpt) { |
|---|
| 25 | res += post_excerpt + '<hr />'; |
|---|
| 26 | } |
|---|
| 27 | res += post; |
|---|
| 28 | $(td).append(res); |
|---|
| 29 | } |
|---|
| 30 | } else { |
|---|
| 31 | alert($(rsp).find('message').text()); |
|---|
| 32 | } |
|---|
| 33 | }); |
|---|
| 34 | |
|---|
| 35 | $(line).addClass('expand'); |
|---|
| 36 | line.parentNode.insertBefore(tr,line.nextSibling); |
|---|
| 37 | } |
|---|
| 38 | else if (tr && tr.style.display == 'none' && ( action == 'toggle' || action == 'open' ) ) |
|---|
| 39 | { |
|---|
| 40 | $(tr).css('display', 'table-row'); |
|---|
| 41 | $(line).addClass('expand'); |
|---|
| 42 | } |
|---|
| 43 | else if (tr && tr.style.display != 'none' && ( action == 'toggle' || action == 'close' ) ) |
|---|
| 44 | { |
|---|
| 45 | $(tr).css('display', 'none'); |
|---|
| 46 | $(line).removeClass('expand'); |
|---|
| 47 | } |
|---|
| 48 | }; |
|---|
| 49 | |
|---|
| 50 | $(function() { |
|---|
| 51 | $('#pageslist tr.line').prepend('<td class="expander"></td>'); |
|---|
| 52 | $('#form-entries tr:not(.line) th:first').attr('colspan',4); |
|---|
| 53 | $.expandContent({ |
|---|
| 54 | line:$('#form-entries tr:not(.line)'), |
|---|
| 55 | lines:$('#form-entries tr.line'), |
|---|
| 56 | callback:dotclear.viewPostContent |
|---|
| 57 | }); |
|---|
| 58 | $('.checkboxes-helpers').each(function() { |
|---|
| 59 | p = $('<p></p>'); |
|---|
| 60 | $(this).prepend(p); |
|---|
| 61 | dotclear.checkboxesHelpers(p); |
|---|
| 62 | }); |
|---|
| 63 | $('#pageslist td input[type=checkbox]').enableShiftClick(); |
|---|
| 64 | |
|---|
| 65 | $("#pageslist tr.line td:not(.expander)").mousedown(function(){ |
|---|
| 66 | $('#pageslist tr.line').each(function() { |
|---|
| 67 | var td = this.firstChild; |
|---|
| 68 | dotclear.viewPostContent(td.firstChild,td.firstChild.line,'close'); |
|---|
| 69 | }); |
|---|
| 70 | $('#pageslist tr:not(.line)').remove(); |
|---|
| 71 | }); |
|---|
| 72 | |
|---|
| 73 | $("#pageslist").sortable({ |
|---|
| 74 | cursor:'move', |
|---|
| 75 | stop: function( event, ui ) { |
|---|
| 76 | $("#pageslist tr td input.position").each(function(i) { |
|---|
| 77 | $(this).val(i+1); |
|---|
| 78 | }); |
|---|
| 79 | } |
|---|
| 80 | }); |
|---|
| 81 | $("#pageslist tr").hover(function () { |
|---|
| 82 | $(this).css({'cursor':'move'}); |
|---|
| 83 | }, function () { |
|---|
| 84 | $(this).css({'cursor':'auto'}); |
|---|
| 85 | }); |
|---|
| 86 | $("#pageslist tr td input.position").hide(); |
|---|
| 87 | $("#pageslist tr td.handle").addClass('handler'); |
|---|
| 88 | |
|---|
| 89 | $("form input[type=submit]").click(function() { |
|---|
| 90 | $("input[type=submit]", $(this).parents("form")).removeAttr("clicked"); |
|---|
| 91 | $(this).attr("clicked", "true"); |
|---|
| 92 | }) |
|---|
| 93 | |
|---|
| 94 | $('#form-entries').submit(function() { |
|---|
| 95 | var action = $(this).find('select[name="action"]').val(); |
|---|
| 96 | var checked = false; |
|---|
| 97 | if ($("input[name=reorder][clicked=true]").val()) { |
|---|
| 98 | return true; |
|---|
| 99 | } |
|---|
| 100 | $(this).find('input[name="entries[]"]').each(function() { |
|---|
| 101 | if (this.checked) { |
|---|
| 102 | checked = true; |
|---|
| 103 | } |
|---|
| 104 | }); |
|---|
| 105 | |
|---|
| 106 | if (!checked) { return false; } |
|---|
| 107 | |
|---|
| 108 | if (action == 'delete') { |
|---|
| 109 | return window.confirm(dotclear.msg.confirm_delete_posts.replace('%s',$('input[name="entries[]"]:checked').size())); |
|---|
| 110 | } |
|---|
| 111 | |
|---|
| 112 | return true; |
|---|
| 113 | }); |
|---|
| 114 | }); |
|---|