[2527] | 1 | dotclear.viewPostContent = function(line,action) { |
---|
[1884] | 2 | var action = action || 'toggle'; |
---|
[2527] | 3 | var postId = $(line).attr('id').substr(1); |
---|
[1882] | 4 | var tr = document.getElementById('pe'+postId); |
---|
[2566] | 5 | |
---|
[1884] | 6 | if ( !tr && ( action == 'toggle' || action == 'open' ) ) { |
---|
[1882] | 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); |
---|
[2566] | 13 | |
---|
[1882] | 14 | // Get post content |
---|
| 15 | $.get('services.php',{f:'getPostById', id: postId, post_type: ''},function(data) { |
---|
| 16 | var rsp = $(data).children('rsp')[0]; |
---|
[2566] | 17 | |
---|
[1882] | 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 = ''; |
---|
[2566] | 22 | |
---|
[1882] | 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 | }); |
---|
[2566] | 34 | |
---|
[1884] | 35 | $(line).addClass('expand'); |
---|
[1882] | 36 | line.parentNode.insertBefore(tr,line.nextSibling); |
---|
| 37 | } |
---|
[1884] | 38 | else if (tr && tr.style.display == 'none' && ( action == 'toggle' || action == 'open' ) ) |
---|
[1882] | 39 | { |
---|
[1884] | 40 | $(tr).css('display', 'table-row'); |
---|
| 41 | $(line).addClass('expand'); |
---|
[1882] | 42 | } |
---|
[1884] | 43 | else if (tr && tr.style.display != 'none' && ( action == 'toggle' || action == 'close' ) ) |
---|
[1882] | 44 | { |
---|
[1884] | 45 | $(tr).css('display', 'none'); |
---|
| 46 | $(line).removeClass('expand'); |
---|
[1882] | 47 | } |
---|
| 48 | }; |
---|
| 49 | |
---|
| 50 | $(function() { |
---|
[1884] | 51 | $('#pageslist tr.line').prepend('<td class="expander"></td>'); |
---|
[1882] | 52 | $('#form-entries tr:not(.line) th:first').attr('colspan',4); |
---|
[2531] | 53 | $.expandContent({ |
---|
| 54 | line:$('#form-entries tr:not(.line)'), |
---|
| 55 | lines:$('#form-entries tr.line'), |
---|
| 56 | callback:dotclear.viewPostContent |
---|
[1882] | 57 | }); |
---|
| 58 | $('.checkboxes-helpers').each(function() { |
---|
| 59 | p = $('<p></p>'); |
---|
| 60 | $(this).prepend(p); |
---|
| 61 | dotclear.checkboxesHelpers(p); |
---|
| 62 | }); |
---|
[1884] | 63 | $('#pageslist td input[type=checkbox]').enableShiftClick(); |
---|
[2566] | 64 | |
---|
[1884] | 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 | }); |
---|
[2566] | 72 | |
---|
[1882] | 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'); |
---|
[2566] | 88 | |
---|
[2058] | 89 | $("form input[type=submit]").click(function() { |
---|
| 90 | $("input[type=submit]", $(this).parents("form")).removeAttr("clicked"); |
---|
| 91 | $(this).attr("clicked", "true"); |
---|
| 92 | }) |
---|
[2566] | 93 | |
---|
[2058] | 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 | }); |
---|
[1882] | 114 | }); |
---|