[2527] | 1 | dotclear.viewCommentContent = function(line,action) { |
---|
| 2 | var commentId = $(line).attr('id').substr(1); |
---|
[0] | 3 | var tr = document.getElementById('ce'+commentId); |
---|
[1525] | 4 | |
---|
[0] | 5 | if (!tr) { |
---|
| 6 | tr = document.createElement('tr'); |
---|
| 7 | tr.id = 'ce'+commentId; |
---|
| 8 | var td = document.createElement('td'); |
---|
| 9 | td.colSpan = 6; |
---|
| 10 | td.className = 'expand'; |
---|
| 11 | tr.appendChild(td); |
---|
[1525] | 12 | |
---|
[0] | 13 | // Get comment content |
---|
| 14 | $.get('services.php',{f:'getCommentById',id: commentId},function(data) { |
---|
| 15 | var rsp = $(data).children('rsp')[0]; |
---|
[1525] | 16 | |
---|
[0] | 17 | if (rsp.attributes[0].value == 'ok') { |
---|
| 18 | var comment = $(rsp).find('comment_display_content').text(); |
---|
[1525] | 19 | |
---|
[0] | 20 | if (comment) { |
---|
| 21 | $(td).append(comment); |
---|
| 22 | var comment_email = $(rsp).find('comment_email').text(); |
---|
| 23 | var comment_site = $(rsp).find('comment_site').text(); |
---|
| 24 | var comment_ip = $(rsp).find('comment_ip').text(); |
---|
| 25 | var comment_spam_disp = $(rsp).find('comment_spam_disp').text(); |
---|
[1525] | 26 | |
---|
[0] | 27 | $(td).append('<p><strong>' + dotclear.msg.website + |
---|
| 28 | '</strong> ' + comment_site + '<br />' + |
---|
| 29 | '<strong>' + dotclear.msg.email + '</strong> ' + |
---|
| 30 | comment_email + '<br />' + comment_spam_disp + '</p>'); |
---|
| 31 | } |
---|
| 32 | } else { |
---|
| 33 | alert($(rsp).find('message').text()); |
---|
| 34 | } |
---|
| 35 | }); |
---|
[1525] | 36 | |
---|
[0] | 37 | $(line).toggleClass('expand'); |
---|
| 38 | line.parentNode.insertBefore(tr,line.nextSibling); |
---|
| 39 | } |
---|
| 40 | else if (tr.style.display == 'none') |
---|
| 41 | { |
---|
| 42 | $(tr).toggle(); |
---|
| 43 | $(line).toggleClass('expand'); |
---|
| 44 | } |
---|
| 45 | else |
---|
| 46 | { |
---|
| 47 | $(tr).toggle(); |
---|
| 48 | $(line).toggleClass('expand'); |
---|
| 49 | } |
---|
| 50 | }; |
---|
| 51 | |
---|
| 52 | $(function() { |
---|
| 53 | // Post preview |
---|
[3139] | 54 | $preview_url = $('#post-preview').attr('href'); |
---|
[3200] | 55 | if ($preview_url) { |
---|
[3241] | 56 | |
---|
| 57 | // Make $preview_url absolute |
---|
| 58 | $a = document.createElement('a'); |
---|
| 59 | $a.href = $('#post-preview').attr('href'); |
---|
| 60 | $preview_url = $a.href; |
---|
| 61 | |
---|
| 62 | // Check if admin and blog have same protocol (ie not mixed-content) |
---|
| 63 | if (window.location.protocol == $preview_url.substring(0,window.location.protocol.length)) { |
---|
[3200] | 64 | // Open preview in a modal iframe |
---|
| 65 | $('#post-preview').modalWeb($(window).width()-40,$(window).height()-40); |
---|
[3241] | 66 | } else { |
---|
[3200] | 67 | // Open preview on antother window |
---|
| 68 | $('#post-preview').click(function(e) { |
---|
| 69 | e.preventDefault(); |
---|
| 70 | window.open($(this).attr('href')); |
---|
| 71 | }); |
---|
| 72 | } |
---|
[3139] | 73 | } |
---|
[1525] | 74 | |
---|
[0] | 75 | // Tabs events |
---|
| 76 | $('#edit-entry').onetabload(function() { |
---|
| 77 | dotclear.hideLockable(); |
---|
[1525] | 78 | |
---|
[0] | 79 | // Add date picker |
---|
| 80 | var post_dtPick = new datePicker($('#post_dt').get(0)); |
---|
| 81 | post_dtPick.img_top = '1.5em'; |
---|
| 82 | post_dtPick.draw(); |
---|
[1525] | 83 | |
---|
[0] | 84 | // Confirm post deletion |
---|
| 85 | $('input[name="delete"]').click(function() { |
---|
[1606] | 86 | return window.confirm(dotclear.msg.confirm_delete_post); |
---|
[0] | 87 | }); |
---|
[1525] | 88 | |
---|
[0] | 89 | // Hide some fields |
---|
| 90 | $('#notes-area label').toggleWithLegend($('#notes-area').children().not('label'),{ |
---|
[1699] | 91 | user_pref: 'dcx_post_notes', |
---|
[1606] | 92 | legend_click:true, |
---|
[1562] | 93 | hide: $('#post_notes').val() == '' |
---|
[0] | 94 | }); |
---|
[1606] | 95 | $('#post_lang').parent().children('label').toggleWithLegend($('#post_lang'),{ |
---|
[1699] | 96 | user_pref: 'dcx_post_lang', |
---|
[1606] | 97 | legend_click: true |
---|
| 98 | }); |
---|
| 99 | $('#post_password').parent().children('label').toggleWithLegend($('#post_password'),{ |
---|
[1699] | 100 | user_pref: 'dcx_post_password', |
---|
[1606] | 101 | legend_click: true, |
---|
[1562] | 102 | hide: $('#post_password').val() == '' |
---|
[0] | 103 | }); |
---|
[1606] | 104 | $('#post_status').parent().children('label').toggleWithLegend($('#post_status'),{ |
---|
[1699] | 105 | user_pref: 'dcx_post_status', |
---|
[1606] | 106 | legend_click: true |
---|
[1392] | 107 | }); |
---|
[1606] | 108 | $('#post_dt').parent().children('label').toggleWithLegend($('#post_dt').parent().children().not('label'),{ |
---|
[1699] | 109 | user_pref: 'dcx_post_dt', |
---|
[1606] | 110 | legend_click: true |
---|
[1392] | 111 | }); |
---|
[1619] | 112 | $('#label_format').toggleWithLegend($('#label_format').parent().children().not('#label_format'),{ |
---|
[1699] | 113 | user_pref: 'dcx_post_format', |
---|
[1606] | 114 | legend_click: true |
---|
[1392] | 115 | }); |
---|
[1935] | 116 | $('#label_cat_id').toggleWithLegend($('#label_cat_id').parent().children().not('#label_cat_id'),{ |
---|
| 117 | user_pref: 'dcx_cat_id', |
---|
[1606] | 118 | legend_click: true |
---|
[1392] | 119 | }); |
---|
[1936] | 120 | $('#create_cat').toggleWithLegend($('#create_cat').parent().children().not('#create_cat'),{ |
---|
| 121 | // no cookie on new category as we don't use this every day |
---|
| 122 | legend_click: true |
---|
| 123 | }); |
---|
[1711] | 124 | $('#label_comment_tb').toggleWithLegend($('#label_comment_tb').parent().children().not('#label_comment_tb'),{ |
---|
[1717] | 125 | user_pref: 'dcx_comment_tb', |
---|
[1711] | 126 | legend_click: true |
---|
| 127 | }); |
---|
[1606] | 128 | $('#post_url').parent().children('label').toggleWithLegend($('#post_url').parent().children().not('label'),{ |
---|
[1699] | 129 | user_pref: 'post_url', |
---|
[1606] | 130 | legend_click: true |
---|
[1392] | 131 | }); |
---|
[0] | 132 | // We load toolbar on excerpt only when it's ready |
---|
| 133 | $('#excerpt-area label').toggleWithLegend($('#excerpt-area').children().not('label'),{ |
---|
[1699] | 134 | user_pref: 'dcx_post_excerpt', |
---|
[1638] | 135 | legend_click: true, |
---|
[0] | 136 | hide: $('#post_excerpt').val() == '' |
---|
| 137 | }); |
---|
[1525] | 138 | |
---|
[0] | 139 | // Replace attachment remove links by a POST form submit |
---|
| 140 | $('a.attachment-remove').click(function() { |
---|
| 141 | this.href = ''; |
---|
| 142 | var m_name = $(this).parents('ul').find('li:first>a').attr('title'); |
---|
| 143 | if (window.confirm(dotclear.msg.confirm_remove_attachment.replace('%s',m_name))) { |
---|
| 144 | var f = $('#attachment-remove-hide').get(0); |
---|
| 145 | f.elements['media_id'].value = this.id.substring(11); |
---|
| 146 | f.submit(); |
---|
| 147 | } |
---|
| 148 | return false; |
---|
| 149 | }); |
---|
| 150 | }); |
---|
[1525] | 151 | |
---|
[0] | 152 | $('#comments').onetabload(function() { |
---|
[2531] | 153 | $.expandContent({ |
---|
| 154 | lines:$('#form-comments .comments-list tr.line'), |
---|
| 155 | callback:dotclear.viewCommentContent |
---|
[0] | 156 | }); |
---|
[2089] | 157 | $('#form-comments .checkboxes-helpers').each(function() { |
---|
| 158 | dotclear.checkboxesHelpers(this); |
---|
| 159 | }); |
---|
| 160 | |
---|
| 161 | dotclear.commentsActionsHelper(); |
---|
| 162 | }); |
---|
| 163 | |
---|
| 164 | $('#trackbacks').onetabload(function() { |
---|
[2531] | 165 | $.expandContent({ |
---|
| 166 | lines:$('#form-trackbacks .comments-list tr.line'), |
---|
| 167 | callback:dotclear.viewCommentContent |
---|
[2089] | 168 | }); |
---|
| 169 | $('#form-trackbacks .checkboxes-helpers').each(function() { |
---|
[0] | 170 | dotclear.checkboxesHelpers(this); |
---|
| 171 | }); |
---|
[1525] | 172 | |
---|
[0] | 173 | dotclear.commentsActionsHelper(); |
---|
| 174 | }); |
---|
[1525] | 175 | |
---|
[0] | 176 | $('#add-comment').onetabload(function() { |
---|
| 177 | commentTb.draw('xhtml'); |
---|
| 178 | }); |
---|
| 179 | }); |
---|