[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 | if (!document.getElementById) { return; } |
---|
[1525] | 54 | |
---|
[0] | 55 | if (document.getElementById('edit-entry')) |
---|
| 56 | { |
---|
| 57 | // Get document format and prepare toolbars |
---|
| 58 | var formatField = $('#post_format').get(0); |
---|
[1256] | 59 | var last_post_format = $(formatField).val(); |
---|
[0] | 60 | $(formatField).change(function() { |
---|
[1256] | 61 | // Confirm post format change |
---|
| 62 | if(window.confirm(dotclear.msg.confirm_change_post_format_noconvert)){ |
---|
| 63 | excerptTb.switchMode(this.value); |
---|
| 64 | contentTb.switchMode(this.value); |
---|
| 65 | last_post_format = $(this).val(); |
---|
| 66 | }else{ |
---|
| 67 | // Restore last format if change cancelled |
---|
| 68 | $(this).val(last_post_format); |
---|
| 69 | } |
---|
[2556] | 70 | |
---|
[1812] | 71 | $('.format_control > *').addClass('hide'); |
---|
[1830] | 72 | $('.format_control:not(.control_no_'+$(this).val()+') > *').removeClass('hide'); |
---|
[0] | 73 | }); |
---|
[1525] | 74 | |
---|
[0] | 75 | var excerptTb = new jsToolBar(document.getElementById('post_excerpt')); |
---|
| 76 | var contentTb = new jsToolBar(document.getElementById('post_content')); |
---|
| 77 | excerptTb.context = contentTb.context = 'post'; |
---|
| 78 | } |
---|
[1525] | 79 | |
---|
[0] | 80 | if (document.getElementById('comment_content')) { |
---|
| 81 | var commentTb = new jsToolBar(document.getElementById('comment_content')); |
---|
[2556] | 82 | commentTb.draw('xhtml'); |
---|
[0] | 83 | } |
---|
[1525] | 84 | |
---|
[0] | 85 | // Post preview |
---|
| 86 | $('#post-preview').modalWeb($(window).width()-40,$(window).height()-40); |
---|
[1525] | 87 | |
---|
[0] | 88 | // Tabs events |
---|
| 89 | $('#edit-entry').onetabload(function() { |
---|
| 90 | dotclear.hideLockable(); |
---|
[1525] | 91 | |
---|
[0] | 92 | // Add date picker |
---|
| 93 | var post_dtPick = new datePicker($('#post_dt').get(0)); |
---|
| 94 | post_dtPick.img_top = '1.5em'; |
---|
| 95 | post_dtPick.draw(); |
---|
[1525] | 96 | |
---|
[0] | 97 | // Confirm post deletion |
---|
| 98 | $('input[name="delete"]').click(function() { |
---|
[1606] | 99 | return window.confirm(dotclear.msg.confirm_delete_post); |
---|
[0] | 100 | }); |
---|
[1525] | 101 | |
---|
[1812] | 102 | // Markup validator |
---|
[1830] | 103 | var v = $('<div class="format_control"><p><a id="a-validator"></a></p><div/>').get(0); |
---|
| 104 | $('.format_control').before(v); |
---|
[1812] | 105 | var a = $('#a-validator').get(0); |
---|
| 106 | a.href = '#'; |
---|
| 107 | a.className = 'button '; |
---|
| 108 | $(a).click(function() { |
---|
[2556] | 109 | |
---|
[1813] | 110 | excerpt_content = $('#post_excerpt').css('display') != 'none' ? $('#post_excerpt').val() : $('#excerpt-area iframe').contents().find('body').html(); |
---|
[2531] | 111 | post_content = $('#post_content').css('display') != 'none' ? $('#post_content').val() : $('#content-area iframe').contents().find('body').html(); |
---|
[2556] | 112 | |
---|
[1812] | 113 | var params = { |
---|
| 114 | xd_check: dotclear.nonce, |
---|
| 115 | f: 'validatePostMarkup', |
---|
[1813] | 116 | excerpt: excerpt_content, |
---|
| 117 | content: post_content, |
---|
[1812] | 118 | format: $('#post_format').get(0).value, |
---|
| 119 | lang: $('#post_lang').get(0).value |
---|
| 120 | }; |
---|
| 121 | |
---|
| 122 | $.post('services.php',params,function(data) { |
---|
| 123 | if ($(data).find('rsp').attr('status') != 'ok') { |
---|
| 124 | alert($(data).find('rsp message').text()); |
---|
| 125 | return false; |
---|
| 126 | } |
---|
[2556] | 127 | |
---|
[1832] | 128 | $('.message, .success, .error, .warning-msg').remove(); |
---|
[1812] | 129 | |
---|
| 130 | if ($(data).find('valid').text() == 1) { |
---|
| 131 | var p = document.createElement('p'); |
---|
| 132 | p.id = 'markup-validator'; |
---|
[2556] | 133 | |
---|
[1830] | 134 | $(p).addClass('success'); |
---|
[1812] | 135 | $(p).text(dotclear.msg.xhtml_valid); |
---|
[1813] | 136 | $('#entry-content h3').after(p); |
---|
[2101] | 137 | $(p).backgroundFade({sColor: dotclear.fadeColor.beginValidatorMsg, eColor: dotclear.fadeColor.endValidatorMsg, steps: 50},function() { |
---|
| 138 | $(this).backgroundFade({sColor: dotclear.fadeColor.endValidatorMsg, eColor: dotclear.fadeColor.beginValidatorMsg}); |
---|
| 139 | }); |
---|
[1812] | 140 | } else { |
---|
| 141 | var div = document.createElement('div'); |
---|
| 142 | div.id = 'markup-validator'; |
---|
[2556] | 143 | |
---|
[1812] | 144 | $(div).addClass('error'); |
---|
| 145 | $(div).html('<p><strong>' + dotclear.msg.xhtml_not_valid + '</strong></p>' + $(data).find('errors').text()); |
---|
[1813] | 146 | $('#entry-content h3').after(div); |
---|
[2109] | 147 | $(div).backgroundFade({sColor: dotclear.fadeColor.beginValidatorErr,eColor: dotclear.fadeColor.endValidatorErr, steps: 50},function() { |
---|
| 148 | $(this).backgroundFade({sColor: dotclear.fadeColor.endValidatorErr, eColor: dotclear.fadeColor.beginValidatorErr}); |
---|
| 149 | }); |
---|
| 150 | } |
---|
[2101] | 151 | |
---|
[1832] | 152 | if ( $('#post_excerpt').text() != excerpt_content || $('#post_content').text() != post_content ) { |
---|
| 153 | var pn = document.createElement('p'); |
---|
| 154 | $(pn).addClass('warning-msg'); |
---|
| 155 | $(pn).text(dotclear.msg.warning_validate_no_save_content); |
---|
| 156 | $('#entry-content h3').after(pn); |
---|
| 157 | } |
---|
[1812] | 158 | |
---|
| 159 | return false; |
---|
| 160 | }); |
---|
| 161 | |
---|
| 162 | return false; |
---|
| 163 | }); |
---|
| 164 | |
---|
| 165 | a.appendChild(document.createTextNode(dotclear.msg.xhtml_validator)); |
---|
[2556] | 166 | |
---|
[1812] | 167 | $('.format_control > *').addClass('hide'); |
---|
[1830] | 168 | $('.format_control:not(.control_no_'+last_post_format+') > *').removeClass('hide'); |
---|
[1812] | 169 | |
---|
[0] | 170 | // Hide some fields |
---|
| 171 | $('#notes-area label').toggleWithLegend($('#notes-area').children().not('label'),{ |
---|
[1699] | 172 | user_pref: 'dcx_post_notes', |
---|
[1606] | 173 | legend_click:true, |
---|
[1562] | 174 | hide: $('#post_notes').val() == '' |
---|
[0] | 175 | }); |
---|
[1606] | 176 | $('#post_lang').parent().children('label').toggleWithLegend($('#post_lang'),{ |
---|
[1699] | 177 | user_pref: 'dcx_post_lang', |
---|
[1606] | 178 | legend_click: true |
---|
| 179 | }); |
---|
| 180 | $('#post_password').parent().children('label').toggleWithLegend($('#post_password'),{ |
---|
[1699] | 181 | user_pref: 'dcx_post_password', |
---|
[1606] | 182 | legend_click: true, |
---|
[1562] | 183 | hide: $('#post_password').val() == '' |
---|
[0] | 184 | }); |
---|
[1606] | 185 | $('#post_status').parent().children('label').toggleWithLegend($('#post_status'),{ |
---|
[1699] | 186 | user_pref: 'dcx_post_status', |
---|
[1606] | 187 | legend_click: true |
---|
[1392] | 188 | }); |
---|
[1606] | 189 | $('#post_dt').parent().children('label').toggleWithLegend($('#post_dt').parent().children().not('label'),{ |
---|
[1699] | 190 | user_pref: 'dcx_post_dt', |
---|
[1606] | 191 | legend_click: true |
---|
[1392] | 192 | }); |
---|
[1619] | 193 | $('#label_format').toggleWithLegend($('#label_format').parent().children().not('#label_format'),{ |
---|
[1699] | 194 | user_pref: 'dcx_post_format', |
---|
[1606] | 195 | legend_click: true |
---|
[1392] | 196 | }); |
---|
[1935] | 197 | $('#label_cat_id').toggleWithLegend($('#label_cat_id').parent().children().not('#label_cat_id'),{ |
---|
| 198 | user_pref: 'dcx_cat_id', |
---|
[1606] | 199 | legend_click: true |
---|
[1392] | 200 | }); |
---|
[1936] | 201 | $('#create_cat').toggleWithLegend($('#create_cat').parent().children().not('#create_cat'),{ |
---|
| 202 | // no cookie on new category as we don't use this every day |
---|
| 203 | legend_click: true |
---|
| 204 | }); |
---|
[1711] | 205 | $('#label_comment_tb').toggleWithLegend($('#label_comment_tb').parent().children().not('#label_comment_tb'),{ |
---|
[1717] | 206 | user_pref: 'dcx_comment_tb', |
---|
[1711] | 207 | legend_click: true |
---|
| 208 | }); |
---|
[1606] | 209 | $('#post_url').parent().children('label').toggleWithLegend($('#post_url').parent().children().not('label'),{ |
---|
[1699] | 210 | user_pref: 'post_url', |
---|
[1606] | 211 | legend_click: true |
---|
[1392] | 212 | }); |
---|
[0] | 213 | // We load toolbar on excerpt only when it's ready |
---|
| 214 | $('#excerpt-area label').toggleWithLegend($('#excerpt-area').children().not('label'),{ |
---|
[1699] | 215 | user_pref: 'dcx_post_excerpt', |
---|
[1638] | 216 | legend_click: true, |
---|
[0] | 217 | hide: $('#post_excerpt').val() == '' |
---|
| 218 | }); |
---|
[1525] | 219 | |
---|
[0] | 220 | // Load toolbars |
---|
| 221 | contentTb.switchMode(formatField.value); |
---|
[1515] | 222 | excerptTb.switchMode(formatField.value); |
---|
[1562] | 223 | |
---|
[0] | 224 | // Replace attachment remove links by a POST form submit |
---|
| 225 | $('a.attachment-remove').click(function() { |
---|
| 226 | this.href = ''; |
---|
| 227 | var m_name = $(this).parents('ul').find('li:first>a').attr('title'); |
---|
| 228 | if (window.confirm(dotclear.msg.confirm_remove_attachment.replace('%s',m_name))) { |
---|
| 229 | var f = $('#attachment-remove-hide').get(0); |
---|
| 230 | f.elements['media_id'].value = this.id.substring(11); |
---|
| 231 | f.submit(); |
---|
| 232 | } |
---|
| 233 | return false; |
---|
| 234 | }); |
---|
[1525] | 235 | |
---|
[0] | 236 | // Check unsaved changes before XHTML conversion |
---|
| 237 | var excerpt = $('#post_excerpt').val(); |
---|
| 238 | var content = $('#post_content').val(); |
---|
| 239 | $('#convert-xhtml').click(function() { |
---|
| 240 | if (excerpt != $('#post_excerpt').val() || content != $('#post_content').val()) { |
---|
| 241 | return window.confirm(dotclear.msg.confirm_change_post_format); |
---|
[1525] | 242 | } |
---|
[0] | 243 | }); |
---|
| 244 | }); |
---|
[1525] | 245 | |
---|
[0] | 246 | $('#comments').onetabload(function() { |
---|
[2531] | 247 | $.expandContent({ |
---|
| 248 | lines:$('#form-comments .comments-list tr.line'), |
---|
| 249 | callback:dotclear.viewCommentContent |
---|
[0] | 250 | }); |
---|
[2089] | 251 | $('#form-comments .checkboxes-helpers').each(function() { |
---|
| 252 | dotclear.checkboxesHelpers(this); |
---|
| 253 | }); |
---|
| 254 | |
---|
| 255 | dotclear.commentsActionsHelper(); |
---|
| 256 | }); |
---|
| 257 | |
---|
| 258 | $('#trackbacks').onetabload(function() { |
---|
[2531] | 259 | $.expandContent({ |
---|
| 260 | lines:$('#form-trackbacks .comments-list tr.line'), |
---|
| 261 | callback:dotclear.viewCommentContent |
---|
[2089] | 262 | }); |
---|
| 263 | $('#form-trackbacks .checkboxes-helpers').each(function() { |
---|
[0] | 264 | dotclear.checkboxesHelpers(this); |
---|
| 265 | }); |
---|
[1525] | 266 | |
---|
[0] | 267 | dotclear.commentsActionsHelper(); |
---|
| 268 | }); |
---|
[1525] | 269 | |
---|
[0] | 270 | $('#add-comment').onetabload(function() { |
---|
| 271 | commentTb.draw('xhtml'); |
---|
| 272 | }); |
---|
| 273 | }); |
---|