[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 |
---|
[3368] | 65 | $('#post-preview').magnificPopup({ |
---|
| 66 | type:'iframe', |
---|
| 67 | iframe: { |
---|
| 68 | patterns: { |
---|
[3483] | 69 | dotclear_preview: { |
---|
[3368] | 70 | index: $preview_url, |
---|
| 71 | src: $preview_url |
---|
| 72 | } |
---|
| 73 | } |
---|
| 74 | } |
---|
| 75 | }); |
---|
[3241] | 76 | } else { |
---|
[3200] | 77 | // Open preview on antother window |
---|
| 78 | $('#post-preview').click(function(e) { |
---|
| 79 | e.preventDefault(); |
---|
| 80 | window.open($(this).attr('href')); |
---|
| 81 | }); |
---|
| 82 | } |
---|
[3139] | 83 | } |
---|
[1525] | 84 | |
---|
[0] | 85 | // Tabs events |
---|
| 86 | $('#edit-entry').onetabload(function() { |
---|
| 87 | dotclear.hideLockable(); |
---|
[1525] | 88 | |
---|
[0] | 89 | // Add date picker |
---|
| 90 | var post_dtPick = new datePicker($('#post_dt').get(0)); |
---|
| 91 | post_dtPick.img_top = '1.5em'; |
---|
| 92 | post_dtPick.draw(); |
---|
[1525] | 93 | |
---|
[0] | 94 | // Confirm post deletion |
---|
| 95 | $('input[name="delete"]').click(function() { |
---|
[1606] | 96 | return window.confirm(dotclear.msg.confirm_delete_post); |
---|
[0] | 97 | }); |
---|
[1525] | 98 | |
---|
[0] | 99 | // Hide some fields |
---|
| 100 | $('#notes-area label').toggleWithLegend($('#notes-area').children().not('label'),{ |
---|
[1699] | 101 | user_pref: 'dcx_post_notes', |
---|
[1606] | 102 | legend_click:true, |
---|
[1562] | 103 | hide: $('#post_notes').val() == '' |
---|
[0] | 104 | }); |
---|
[1606] | 105 | $('#post_lang').parent().children('label').toggleWithLegend($('#post_lang'),{ |
---|
[1699] | 106 | user_pref: 'dcx_post_lang', |
---|
[1606] | 107 | legend_click: true |
---|
| 108 | }); |
---|
| 109 | $('#post_password').parent().children('label').toggleWithLegend($('#post_password'),{ |
---|
[1699] | 110 | user_pref: 'dcx_post_password', |
---|
[1606] | 111 | legend_click: true, |
---|
[1562] | 112 | hide: $('#post_password').val() == '' |
---|
[0] | 113 | }); |
---|
[1606] | 114 | $('#post_status').parent().children('label').toggleWithLegend($('#post_status'),{ |
---|
[1699] | 115 | user_pref: 'dcx_post_status', |
---|
[1606] | 116 | legend_click: true |
---|
[1392] | 117 | }); |
---|
[1606] | 118 | $('#post_dt').parent().children('label').toggleWithLegend($('#post_dt').parent().children().not('label'),{ |
---|
[1699] | 119 | user_pref: 'dcx_post_dt', |
---|
[1606] | 120 | legend_click: true |
---|
[1392] | 121 | }); |
---|
[1619] | 122 | $('#label_format').toggleWithLegend($('#label_format').parent().children().not('#label_format'),{ |
---|
[1699] | 123 | user_pref: 'dcx_post_format', |
---|
[1606] | 124 | legend_click: true |
---|
[1392] | 125 | }); |
---|
[1935] | 126 | $('#label_cat_id').toggleWithLegend($('#label_cat_id').parent().children().not('#label_cat_id'),{ |
---|
| 127 | user_pref: 'dcx_cat_id', |
---|
[1606] | 128 | legend_click: true |
---|
[1392] | 129 | }); |
---|
[1936] | 130 | $('#create_cat').toggleWithLegend($('#create_cat').parent().children().not('#create_cat'),{ |
---|
| 131 | // no cookie on new category as we don't use this every day |
---|
| 132 | legend_click: true |
---|
| 133 | }); |
---|
[1711] | 134 | $('#label_comment_tb').toggleWithLegend($('#label_comment_tb').parent().children().not('#label_comment_tb'),{ |
---|
[1717] | 135 | user_pref: 'dcx_comment_tb', |
---|
[1711] | 136 | legend_click: true |
---|
| 137 | }); |
---|
[1606] | 138 | $('#post_url').parent().children('label').toggleWithLegend($('#post_url').parent().children().not('label'),{ |
---|
[1699] | 139 | user_pref: 'post_url', |
---|
[1606] | 140 | legend_click: true |
---|
[1392] | 141 | }); |
---|
[0] | 142 | // We load toolbar on excerpt only when it's ready |
---|
| 143 | $('#excerpt-area label').toggleWithLegend($('#excerpt-area').children().not('label'),{ |
---|
[1699] | 144 | user_pref: 'dcx_post_excerpt', |
---|
[1638] | 145 | legend_click: true, |
---|
[0] | 146 | hide: $('#post_excerpt').val() == '' |
---|
| 147 | }); |
---|
[1525] | 148 | |
---|
[0] | 149 | // Replace attachment remove links by a POST form submit |
---|
| 150 | $('a.attachment-remove').click(function() { |
---|
| 151 | this.href = ''; |
---|
| 152 | var m_name = $(this).parents('ul').find('li:first>a').attr('title'); |
---|
| 153 | if (window.confirm(dotclear.msg.confirm_remove_attachment.replace('%s',m_name))) { |
---|
| 154 | var f = $('#attachment-remove-hide').get(0); |
---|
| 155 | f.elements['media_id'].value = this.id.substring(11); |
---|
| 156 | f.submit(); |
---|
| 157 | } |
---|
| 158 | return false; |
---|
| 159 | }); |
---|
| 160 | }); |
---|
[1525] | 161 | |
---|
[0] | 162 | $('#comments').onetabload(function() { |
---|
[2531] | 163 | $.expandContent({ |
---|
| 164 | lines:$('#form-comments .comments-list tr.line'), |
---|
| 165 | callback:dotclear.viewCommentContent |
---|
[0] | 166 | }); |
---|
[2089] | 167 | $('#form-comments .checkboxes-helpers').each(function() { |
---|
| 168 | dotclear.checkboxesHelpers(this); |
---|
| 169 | }); |
---|
| 170 | |
---|
| 171 | dotclear.commentsActionsHelper(); |
---|
| 172 | }); |
---|
| 173 | |
---|
| 174 | $('#trackbacks').onetabload(function() { |
---|
[2531] | 175 | $.expandContent({ |
---|
| 176 | lines:$('#form-trackbacks .comments-list tr.line'), |
---|
| 177 | callback:dotclear.viewCommentContent |
---|
[2089] | 178 | }); |
---|
| 179 | $('#form-trackbacks .checkboxes-helpers').each(function() { |
---|
[0] | 180 | dotclear.checkboxesHelpers(this); |
---|
| 181 | }); |
---|
[1525] | 182 | |
---|
[0] | 183 | dotclear.commentsActionsHelper(); |
---|
| 184 | }); |
---|
[1525] | 185 | |
---|
[0] | 186 | $('#add-comment').onetabload(function() { |
---|
| 187 | commentTb.draw('xhtml'); |
---|
| 188 | }); |
---|
| 189 | }); |
---|