| 1 | dotclear.viewCommentContent = function(line,action) { |
|---|
| 2 | var commentId = $(line).attr('id').substr(1); |
|---|
| 3 | var tr = document.getElementById('ce'+commentId); |
|---|
| 4 | |
|---|
| 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); |
|---|
| 12 | |
|---|
| 13 | // Get comment content |
|---|
| 14 | $.get('services.php',{f:'getCommentById',id: commentId},function(data) { |
|---|
| 15 | var rsp = $(data).children('rsp')[0]; |
|---|
| 16 | |
|---|
| 17 | if (rsp.attributes[0].value == 'ok') { |
|---|
| 18 | var comment = $(rsp).find('comment_display_content').text(); |
|---|
| 19 | |
|---|
| 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(); |
|---|
| 26 | |
|---|
| 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 | }); |
|---|
| 36 | |
|---|
| 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 |
|---|
| 54 | $preview_url = $('#post-preview').attr('href'); |
|---|
| 55 | if ($preview_url) { |
|---|
| 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)) { |
|---|
| 64 | // Open preview in a modal iframe |
|---|
| 65 | $('#post-preview').magnificPopup({ |
|---|
| 66 | type:'iframe', |
|---|
| 67 | iframe: { |
|---|
| 68 | patterns: { |
|---|
| 69 | dotclear_preview: { |
|---|
| 70 | index: $preview_url, |
|---|
| 71 | src: $preview_url |
|---|
| 72 | } |
|---|
| 73 | } |
|---|
| 74 | } |
|---|
| 75 | }); |
|---|
| 76 | } else { |
|---|
| 77 | // Open preview on antother window |
|---|
| 78 | $('#post-preview').click(function(e) { |
|---|
| 79 | e.preventDefault(); |
|---|
| 80 | window.open($(this).attr('href')); |
|---|
| 81 | }); |
|---|
| 82 | } |
|---|
| 83 | } |
|---|
| 84 | |
|---|
| 85 | // Tabs events |
|---|
| 86 | $('#edit-entry').onetabload(function() { |
|---|
| 87 | dotclear.hideLockable(); |
|---|
| 88 | |
|---|
| 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(); |
|---|
| 93 | |
|---|
| 94 | // Confirm post deletion |
|---|
| 95 | $('input[name="delete"]').click(function() { |
|---|
| 96 | return window.confirm(dotclear.msg.confirm_delete_post); |
|---|
| 97 | }); |
|---|
| 98 | |
|---|
| 99 | // Hide some fields |
|---|
| 100 | $('#notes-area label').toggleWithLegend($('#notes-area').children().not('label'),{ |
|---|
| 101 | user_pref: 'dcx_post_notes', |
|---|
| 102 | legend_click:true, |
|---|
| 103 | hide: $('#post_notes').val() == '' |
|---|
| 104 | }); |
|---|
| 105 | $('#post_lang').parent().children('label').toggleWithLegend($('#post_lang'),{ |
|---|
| 106 | user_pref: 'dcx_post_lang', |
|---|
| 107 | legend_click: true |
|---|
| 108 | }); |
|---|
| 109 | $('#post_password').parent().children('label').toggleWithLegend($('#post_password'),{ |
|---|
| 110 | user_pref: 'dcx_post_password', |
|---|
| 111 | legend_click: true, |
|---|
| 112 | hide: $('#post_password').val() == '' |
|---|
| 113 | }); |
|---|
| 114 | $('#post_status').parent().children('label').toggleWithLegend($('#post_status'),{ |
|---|
| 115 | user_pref: 'dcx_post_status', |
|---|
| 116 | legend_click: true |
|---|
| 117 | }); |
|---|
| 118 | $('#post_dt').parent().children('label').toggleWithLegend($('#post_dt').parent().children().not('label'),{ |
|---|
| 119 | user_pref: 'dcx_post_dt', |
|---|
| 120 | legend_click: true |
|---|
| 121 | }); |
|---|
| 122 | $('#label_format').toggleWithLegend($('#label_format').parent().children().not('#label_format'),{ |
|---|
| 123 | user_pref: 'dcx_post_format', |
|---|
| 124 | legend_click: true |
|---|
| 125 | }); |
|---|
| 126 | $('#label_cat_id').toggleWithLegend($('#label_cat_id').parent().children().not('#label_cat_id'),{ |
|---|
| 127 | user_pref: 'dcx_cat_id', |
|---|
| 128 | legend_click: true |
|---|
| 129 | }); |
|---|
| 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 | }); |
|---|
| 134 | $('#label_comment_tb').toggleWithLegend($('#label_comment_tb').parent().children().not('#label_comment_tb'),{ |
|---|
| 135 | user_pref: 'dcx_comment_tb', |
|---|
| 136 | legend_click: true |
|---|
| 137 | }); |
|---|
| 138 | $('#post_url').parent().children('label').toggleWithLegend($('#post_url').parent().children().not('label'),{ |
|---|
| 139 | user_pref: 'post_url', |
|---|
| 140 | legend_click: true |
|---|
| 141 | }); |
|---|
| 142 | // We load toolbar on excerpt only when it's ready |
|---|
| 143 | $('#excerpt-area label').toggleWithLegend($('#excerpt-area').children().not('label'),{ |
|---|
| 144 | user_pref: 'dcx_post_excerpt', |
|---|
| 145 | legend_click: true, |
|---|
| 146 | hide: $('#post_excerpt').val() == '' |
|---|
| 147 | }); |
|---|
| 148 | |
|---|
| 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 | }); |
|---|
| 161 | |
|---|
| 162 | $('#comments').onetabload(function() { |
|---|
| 163 | $.expandContent({ |
|---|
| 164 | lines:$('#form-comments .comments-list tr.line'), |
|---|
| 165 | callback:dotclear.viewCommentContent |
|---|
| 166 | }); |
|---|
| 167 | $('#form-comments .checkboxes-helpers').each(function() { |
|---|
| 168 | dotclear.checkboxesHelpers(this); |
|---|
| 169 | }); |
|---|
| 170 | |
|---|
| 171 | dotclear.commentsActionsHelper(); |
|---|
| 172 | }); |
|---|
| 173 | |
|---|
| 174 | $('#trackbacks').onetabload(function() { |
|---|
| 175 | $.expandContent({ |
|---|
| 176 | lines:$('#form-trackbacks .comments-list tr.line'), |
|---|
| 177 | callback:dotclear.viewCommentContent |
|---|
| 178 | }); |
|---|
| 179 | $('#form-trackbacks .checkboxes-helpers').each(function() { |
|---|
| 180 | dotclear.checkboxesHelpers(this); |
|---|
| 181 | }); |
|---|
| 182 | |
|---|
| 183 | dotclear.commentsActionsHelper(); |
|---|
| 184 | }); |
|---|
| 185 | |
|---|
| 186 | $('#add-comment').onetabload(function() { |
|---|
| 187 | commentTb.draw('xhtml'); |
|---|
| 188 | }); |
|---|
| 189 | }); |
|---|