[0] | 1 | dotclear.commentExpander = function(line) { |
---|
| 2 | var td = line.firstChild; |
---|
| 3 | |
---|
| 4 | var img = document.createElement('img'); |
---|
| 5 | img.src = dotclear.img_plus_src; |
---|
| 6 | img.alt = dotclear.img_plus_alt; |
---|
| 7 | img.className = 'expand'; |
---|
| 8 | $(img).css('cursor','pointer'); |
---|
| 9 | img.line = line; |
---|
| 10 | img.onclick = function() { dotclear.viewCommentContent(this,this.line); }; |
---|
| 11 | |
---|
| 12 | td.insertBefore(img,td.firstChild); |
---|
| 13 | }; |
---|
| 14 | |
---|
| 15 | dotclear.viewCommentContent = function(img,line) { |
---|
| 16 | var commentId = line.id.substr(1); |
---|
| 17 | |
---|
| 18 | var tr = document.getElementById('ce'+commentId); |
---|
| 19 | |
---|
| 20 | if (!tr) { |
---|
| 21 | tr = document.createElement('tr'); |
---|
| 22 | tr.id = 'ce'+commentId; |
---|
| 23 | var td = document.createElement('td'); |
---|
| 24 | td.colSpan = 6; |
---|
| 25 | td.className = 'expand'; |
---|
| 26 | tr.appendChild(td); |
---|
| 27 | |
---|
| 28 | img.src = dotclear.img_minus_src; |
---|
| 29 | img.alt = dotclear.img_minus_alt; |
---|
| 30 | |
---|
| 31 | // Get comment content |
---|
| 32 | $.get('services.php',{f:'getCommentById',id: commentId},function(data) { |
---|
| 33 | var rsp = $(data).children('rsp')[0]; |
---|
| 34 | |
---|
| 35 | if (rsp.attributes[0].value == 'ok') { |
---|
| 36 | var comment = $(rsp).find('comment_display_content').text(); |
---|
| 37 | |
---|
| 38 | if (comment) { |
---|
| 39 | $(td).append(comment); |
---|
| 40 | var comment_email = $(rsp).find('comment_email').text(); |
---|
| 41 | var comment_site = $(rsp).find('comment_site').text(); |
---|
| 42 | var comment_ip = $(rsp).find('comment_ip').text(); |
---|
| 43 | var comment_spam_disp = $(rsp).find('comment_spam_disp').text(); |
---|
| 44 | |
---|
| 45 | $(td).append('<p><strong>' + dotclear.msg.website + |
---|
| 46 | '</strong> ' + comment_site + '<br />' + |
---|
| 47 | '<strong>' + dotclear.msg.email + '</strong> ' + |
---|
| 48 | comment_email + '<br />' + comment_spam_disp + '</p>'); |
---|
| 49 | } |
---|
| 50 | } else { |
---|
| 51 | alert($(rsp).find('message').text()); |
---|
| 52 | } |
---|
| 53 | }); |
---|
| 54 | |
---|
| 55 | $(line).toggleClass('expand'); |
---|
| 56 | line.parentNode.insertBefore(tr,line.nextSibling); |
---|
| 57 | } |
---|
| 58 | else if (tr.style.display == 'none') |
---|
| 59 | { |
---|
| 60 | $(tr).toggle(); |
---|
| 61 | $(line).toggleClass('expand'); |
---|
| 62 | img.src = dotclear.img_minus_src; |
---|
| 63 | img.alt = dotclear.img_minus_alt; |
---|
| 64 | } |
---|
| 65 | else |
---|
| 66 | { |
---|
| 67 | $(tr).toggle(); |
---|
| 68 | $(line).toggleClass('expand'); |
---|
| 69 | img.src = dotclear.img_plus_src; |
---|
| 70 | img.alt = dotclear.img_plus_alt; |
---|
| 71 | } |
---|
| 72 | }; |
---|
| 73 | |
---|
| 74 | $(function() { |
---|
| 75 | if (!document.getElementById) { return; } |
---|
| 76 | |
---|
| 77 | if (document.getElementById('edit-entry')) |
---|
| 78 | { |
---|
| 79 | // Get document format and prepare toolbars |
---|
| 80 | var formatField = $('#post_format').get(0); |
---|
| 81 | $(formatField).change(function() { |
---|
| 82 | excerptTb.switchMode(this.value); |
---|
| 83 | contentTb.switchMode(this.value); |
---|
| 84 | }); |
---|
| 85 | |
---|
| 86 | var excerptTb = new jsToolBar(document.getElementById('post_excerpt')); |
---|
| 87 | var contentTb = new jsToolBar(document.getElementById('post_content')); |
---|
| 88 | excerptTb.context = contentTb.context = 'post'; |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | if (document.getElementById('comment_content')) { |
---|
| 92 | var commentTb = new jsToolBar(document.getElementById('comment_content')); |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | // Post preview |
---|
| 96 | $('#post-preview').modalWeb($(window).width()-40,$(window).height()-40); |
---|
| 97 | |
---|
| 98 | // Tabs events |
---|
| 99 | $('#edit-entry').onetabload(function() { |
---|
| 100 | dotclear.hideLockable(); |
---|
| 101 | |
---|
| 102 | // Add date picker |
---|
| 103 | var post_dtPick = new datePicker($('#post_dt').get(0)); |
---|
| 104 | post_dtPick.img_top = '1.5em'; |
---|
| 105 | post_dtPick.draw(); |
---|
| 106 | |
---|
| 107 | // Confirm post deletion |
---|
| 108 | $('input[name="delete"]').click(function() { |
---|
| 109 | return window.confirm(dotclear.msg.confirm_delete_post); |
---|
| 110 | }); |
---|
| 111 | |
---|
| 112 | // Hide some fields |
---|
| 113 | $('#notes-area label').toggleWithLegend($('#notes-area').children().not('label'),{ |
---|
| 114 | cookie: 'dcx_post_notes', |
---|
| 115 | hide: $('#post_notes').val() == '' |
---|
| 116 | }); |
---|
| 117 | $('#post_lang').parent().toggleWithLegend($('#post_lang'),{ |
---|
| 118 | cookie: 'dcx_post_lang' |
---|
| 119 | }); |
---|
| 120 | $('#post_password').parent().toggleWithLegend($('#post_password'),{ |
---|
| 121 | cookie: 'dcx_post_password', |
---|
| 122 | hide: $('#post_password').val() == '' |
---|
| 123 | }); |
---|
| 124 | |
---|
| 125 | // We load toolbar on excerpt only when it's ready |
---|
| 126 | $('#excerpt-area label').toggleWithLegend($('#excerpt-area').children().not('label'),{ |
---|
| 127 | fn: function() { excerptTb.switchMode(formatField.value); }, |
---|
| 128 | cookie: 'dcx_post_excerpt', |
---|
| 129 | hide: $('#post_excerpt').val() == '' |
---|
| 130 | }); |
---|
| 131 | |
---|
| 132 | // Load toolbars |
---|
| 133 | contentTb.switchMode(formatField.value); |
---|
| 134 | |
---|
| 135 | // Replace attachment remove links by a POST form submit |
---|
| 136 | $('a.attachment-remove').click(function() { |
---|
| 137 | this.href = ''; |
---|
| 138 | var m_name = $(this).parents('ul').find('li:first>a').attr('title'); |
---|
| 139 | if (window.confirm(dotclear.msg.confirm_remove_attachment.replace('%s',m_name))) { |
---|
| 140 | var f = $('#attachment-remove-hide').get(0); |
---|
| 141 | f.elements['media_id'].value = this.id.substring(11); |
---|
| 142 | f.submit(); |
---|
| 143 | } |
---|
| 144 | return false; |
---|
| 145 | }); |
---|
| 146 | |
---|
| 147 | // Markup validator |
---|
| 148 | var h = document.createElement('h4'); |
---|
| 149 | var a = document.createElement('a'); |
---|
| 150 | a.href = '#'; |
---|
| 151 | $(a).click(function() { |
---|
| 152 | var params = { |
---|
| 153 | xd_check: dotclear.nonce, |
---|
| 154 | f: 'validatePostMarkup', |
---|
| 155 | excerpt: $('#post_excerpt').text(), |
---|
| 156 | content: $('#post_content').text(), |
---|
| 157 | format: $('#post_format').get(0).value, |
---|
| 158 | lang: $('#post_lang').get(0).value |
---|
| 159 | }; |
---|
| 160 | |
---|
| 161 | $.post('services.php',params,function(data) { |
---|
| 162 | if ($(data).find('rsp').attr('status') != 'ok') { |
---|
| 163 | alert($(data).find('rsp message').text()); |
---|
| 164 | return false; |
---|
| 165 | } |
---|
| 166 | |
---|
| 167 | if ($(data).find('valid').text() == 1) { |
---|
| 168 | var p = document.createElement('p'); |
---|
| 169 | p.id = 'markup-validator'; |
---|
| 170 | |
---|
| 171 | if ($('#markup-validator').length > 0) { |
---|
| 172 | $('#markup-validator').remove(); |
---|
| 173 | } |
---|
| 174 | |
---|
| 175 | $(p).addClass('message'); |
---|
| 176 | $(p).text(dotclear.msg.xhtml_valid); |
---|
| 177 | $(p).insertAfter(h); |
---|
| 178 | $(p).backgroundFade({sColor:'#666666',eColor:'#ffcc00',steps:50},function() { |
---|
| 179 | $(this).backgroundFade({sColor:'#ffcc00',eColor:'#666666'}); |
---|
| 180 | }); |
---|
| 181 | } else { |
---|
| 182 | var div = document.createElement('div'); |
---|
| 183 | div.id = 'markup-validator'; |
---|
| 184 | |
---|
| 185 | if ($('#markup-validator').length > 0) { |
---|
| 186 | $('#markup-validator').remove(); |
---|
| 187 | } |
---|
| 188 | |
---|
| 189 | $(div).addClass('error'); |
---|
| 190 | $(div).html('<p><strong>' + dotclear.msg.xhtml_not_valid + '</strong></p>' + $(data).find('errors').text()); |
---|
| 191 | $(div).insertAfter(h); |
---|
| 192 | $(div).backgroundFade({sColor:'#ffffff',eColor:'#ff9999',steps:50},function() { |
---|
| 193 | $(this).backgroundFade({sColor:'#ff9999',eColor:'#ffffff'}); |
---|
| 194 | }); |
---|
| 195 | } |
---|
| 196 | |
---|
| 197 | return false; |
---|
| 198 | }); |
---|
| 199 | |
---|
| 200 | return false; |
---|
| 201 | }); |
---|
| 202 | |
---|
| 203 | a.appendChild(document.createTextNode(dotclear.msg.xhtml_validator)); |
---|
| 204 | h.appendChild(a); |
---|
| 205 | $(h).appendTo('#entry-content'); |
---|
| 206 | |
---|
| 207 | // Check unsaved changes before XHTML conversion |
---|
| 208 | var excerpt = $('#post_excerpt').val(); |
---|
| 209 | var content = $('#post_content').val(); |
---|
| 210 | $('#convert-xhtml').click(function() { |
---|
| 211 | if (excerpt != $('#post_excerpt').val() || content != $('#post_content').val()) { |
---|
| 212 | return window.confirm(dotclear.msg.confirm_change_post_format); |
---|
| 213 | } |
---|
| 214 | }); |
---|
| 215 | }); |
---|
| 216 | |
---|
| 217 | $('#comments').onetabload(function() { |
---|
| 218 | $('.comments-list tr.line').each(function() { |
---|
| 219 | dotclear.commentExpander(this); |
---|
| 220 | }); |
---|
| 221 | $('.checkboxes-helpers').each(function() { |
---|
| 222 | dotclear.checkboxesHelpers(this); |
---|
| 223 | }); |
---|
| 224 | |
---|
| 225 | dotclear.commentsActionsHelper(); |
---|
| 226 | }); |
---|
| 227 | |
---|
| 228 | $('#add-comment').onetabload(function() { |
---|
| 229 | commentTb.draw('xhtml'); |
---|
| 230 | }); |
---|
| 231 | }); |
---|