Changeset 2313:ef1db3d7c388 for admin/js
- Timestamp:
- 10/08/13 15:27:39 (12 years ago)
- Branch:
- twig
- Parents:
- 1524:913f5a36bbb0 (diff), 2312:d01c85eaa37d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
admin/js/_post.js
r1492 r2313 1 1 dotclear.commentExpander = function(line) { 2 2 var td = line.firstChild; 3 3 4 4 var img = document.createElement('img'); 5 5 img.src = dotclear.img_plus_src; … … 9 9 img.line = line; 10 10 img.onclick = function() { dotclear.viewCommentContent(this,this.line); }; 11 11 12 12 td.insertBefore(img,td.firstChild); 13 13 }; … … 15 15 dotclear.viewCommentContent = function(img,line) { 16 16 var commentId = line.id.substr(1); 17 17 18 18 var tr = document.getElementById('ce'+commentId); 19 19 20 20 if (!tr) { 21 21 tr = document.createElement('tr'); … … 25 25 td.className = 'expand'; 26 26 tr.appendChild(td); 27 27 28 28 img.src = dotclear.img_minus_src; 29 29 img.alt = dotclear.img_minus_alt; 30 30 31 31 // Get comment content 32 32 $.get('services.php',{f:'getCommentById',id: commentId},function(data) { 33 33 var rsp = $(data).children('rsp')[0]; 34 34 35 35 if (rsp.attributes[0].value == 'ok') { 36 36 var comment = $(rsp).find('comment_display_content').text(); 37 37 38 38 if (comment) { 39 39 $(td).append(comment); … … 42 42 var comment_ip = $(rsp).find('comment_ip').text(); 43 43 var comment_spam_disp = $(rsp).find('comment_spam_disp').text(); 44 44 45 45 $(td).append('<p><strong>' + dotclear.msg.website + 46 46 '</strong> ' + comment_site + '<br />' + … … 52 52 } 53 53 }); 54 54 55 55 $(line).toggleClass('expand'); 56 56 line.parentNode.insertBefore(tr,line.nextSibling); … … 74 74 $(function() { 75 75 if (!document.getElementById) { return; } 76 76 77 77 if (document.getElementById('edit-entry')) 78 78 { 79 79 // Get document format and prepare toolbars 80 80 var formatField = $('#post_format').get(0); 81 var last_post_format = $(formatField).val(); 81 82 $(formatField).change(function() { 82 excerptTb.switchMode(this.value); 83 contentTb.switchMode(this.value); 84 }); 85 83 // Confirm post format change 84 if(window.confirm(dotclear.msg.confirm_change_post_format_noconvert)){ 85 excerptTb.switchMode(this.value); 86 contentTb.switchMode(this.value); 87 last_post_format = $(this).val(); 88 }else{ 89 // Restore last format if change cancelled 90 $(this).val(last_post_format); 91 } 92 93 $('.format_control > *').addClass('hide'); 94 $('.format_control:not(.control_no_'+$(this).val()+') > *').removeClass('hide'); 95 }); 96 86 97 var excerptTb = new jsToolBar(document.getElementById('post_excerpt')); 87 98 var contentTb = new jsToolBar(document.getElementById('post_content')); 88 99 excerptTb.context = contentTb.context = 'post'; 89 100 } 90 101 91 102 if (document.getElementById('comment_content')) { 92 103 var commentTb = new jsToolBar(document.getElementById('comment_content')); 93 104 } 94 105 95 106 // Post preview 96 107 $('#post-preview').modalWeb($(window).width()-40,$(window).height()-40); 97 108 98 109 // Tabs events 99 110 $('#edit-entry').onetabload(function() { 100 111 dotclear.hideLockable(); 101 112 102 113 // Add date picker 103 114 var post_dtPick = new datePicker($('#post_dt').get(0)); 104 115 post_dtPick.img_top = '1.5em'; 105 116 post_dtPick.draw(); 106 117 107 118 // Confirm post deletion 108 119 $('input[name="delete"]').click(function() { 109 return window.confirm(dotclear.msg.confirm_delete_post); 110 }); 120 return window.confirm(dotclear.msg.confirm_delete_post); 121 }); 122 123 // Markup validator 124 var v = $('<div class="format_control"><p><a id="a-validator"></a></p><div/>').get(0); 125 $('.format_control').before(v); 126 var a = $('#a-validator').get(0); 127 a.href = '#'; 128 a.className = 'button '; 129 $(a).click(function() { 130 131 excerpt_content = $('#post_excerpt').css('display') != 'none' ? $('#post_excerpt').val() : $('#excerpt-area iframe').contents().find('body').html(); 132 post_content = $('#post_content').css('display') != 'none' ? $('#post_content').val() : $('#content-area iframe').contents().find('body').html(); 133 134 var params = { 135 xd_check: dotclear.nonce, 136 f: 'validatePostMarkup', 137 excerpt: excerpt_content, 138 content: post_content, 139 format: $('#post_format').get(0).value, 140 lang: $('#post_lang').get(0).value 141 }; 142 143 $.post('services.php',params,function(data) { 144 if ($(data).find('rsp').attr('status') != 'ok') { 145 alert($(data).find('rsp message').text()); 146 return false; 147 } 148 149 $('.message, .success, .error, .warning-msg').remove(); 150 151 if ($(data).find('valid').text() == 1) { 152 var p = document.createElement('p'); 153 p.id = 'markup-validator'; 154 155 $(p).addClass('success'); 156 $(p).text(dotclear.msg.xhtml_valid); 157 $('#entry-content h3').after(p); 158 $(p).backgroundFade({sColor: dotclear.fadeColor.beginValidatorMsg, eColor: dotclear.fadeColor.endValidatorMsg, steps: 50},function() { 159 $(this).backgroundFade({sColor: dotclear.fadeColor.endValidatorMsg, eColor: dotclear.fadeColor.beginValidatorMsg}); 160 }); 161 } else { 162 var div = document.createElement('div'); 163 div.id = 'markup-validator'; 164 165 $(div).addClass('error'); 166 $(div).html('<p><strong>' + dotclear.msg.xhtml_not_valid + '</strong></p>' + $(data).find('errors').text()); 167 $('#entry-content h3').after(div); 168 $(div).backgroundFade({sColor: dotclear.fadeColor.beginValidatorErr,eColor: dotclear.fadeColor.endValidatorErr, steps: 50},function() { 169 $(this).backgroundFade({sColor: dotclear.fadeColor.endValidatorErr, eColor: dotclear.fadeColor.beginValidatorErr}); 170 }); 171 } 172 173 if ( $('#post_excerpt').text() != excerpt_content || $('#post_content').text() != post_content ) { 174 var pn = document.createElement('p'); 175 $(pn).addClass('warning-msg'); 176 $(pn).text(dotclear.msg.warning_validate_no_save_content); 177 $('#entry-content h3').after(pn); 178 } 179 180 return false; 181 }); 182 183 return false; 184 }); 185 186 a.appendChild(document.createTextNode(dotclear.msg.xhtml_validator)); 111 187 188 $('.format_control > *').addClass('hide'); 189 $('.format_control:not(.control_no_'+last_post_format+') > *').removeClass('hide'); 190 112 191 // Hide some fields 113 192 $('#notes-area label').toggleWithLegend($('#notes-area').children().not('label'),{ 114 cookie: 'dcx_post_notes', 193 user_pref: 'dcx_post_notes', 194 legend_click:true, 115 195 hide: $('#post_notes').val() == '' 116 196 }); 117 $('#new_cat').toggleWithLegend( 118 $('#new_cat').parent().children().not('#new_cat'), 119 {} // no cookie on new category as we don't use this every day 120 ); 121 $('#post_lang').parent().toggleWithLegend($('#post_lang'),{ 122 cookie: 'dcx_post_lang' 123 }); 124 $('#post_password').parent().toggleWithLegend($('#post_password'),{ 125 cookie: 'dcx_post_password', 197 $('#post_lang').parent().children('label').toggleWithLegend($('#post_lang'),{ 198 user_pref: 'dcx_post_lang', 199 legend_click: true 200 }); 201 $('#post_password').parent().children('label').toggleWithLegend($('#post_password'),{ 202 user_pref: 'dcx_post_password', 203 legend_click: true, 126 204 hide: $('#post_password').val() == '' 127 205 }); 128 $('#post_status').parent().toggleWithLegend($('#post_status'),{ 129 cookie: 'dcx_post_status' 130 }); 131 $('#post_dt').parent().toggleWithLegend($('#post_dt').parent().children().not('label'),{ 132 cookie: 'dcx_post_dt' 133 }); 134 $('#post_format').parent().toggleWithLegend($('#post_format').parent().children().not('label').add($('#post_format').parents('p').next()),{ 135 cookie: 'dcx_post_format' 136 }); 137 $('#cat_id').parent().toggleWithLegend($('#cat_id'),{ 138 cookie: 'cat_id' 139 }); 140 $('#post_url').parent().toggleWithLegend($('#post_url').parent().children().not('label'),{ 141 cookie: 'post_url' 206 $('#post_status').parent().children('label').toggleWithLegend($('#post_status'),{ 207 user_pref: 'dcx_post_status', 208 legend_click: true 209 }); 210 $('#post_dt').parent().children('label').toggleWithLegend($('#post_dt').parent().children().not('label'),{ 211 user_pref: 'dcx_post_dt', 212 legend_click: true 213 }); 214 $('#label_format').toggleWithLegend($('#label_format').parent().children().not('#label_format'),{ 215 user_pref: 'dcx_post_format', 216 legend_click: true 217 }); 218 $('#label_cat_id').toggleWithLegend($('#label_cat_id').parent().children().not('#label_cat_id'),{ 219 user_pref: 'dcx_cat_id', 220 legend_click: true 221 }); 222 $('#create_cat').toggleWithLegend($('#create_cat').parent().children().not('#create_cat'),{ 223 // no cookie on new category as we don't use this every day 224 legend_click: true 225 }); 226 $('#label_comment_tb').toggleWithLegend($('#label_comment_tb').parent().children().not('#label_comment_tb'),{ 227 user_pref: 'dcx_comment_tb', 228 legend_click: true 229 }); 230 $('#post_url').parent().children('label').toggleWithLegend($('#post_url').parent().children().not('label'),{ 231 user_pref: 'post_url', 232 legend_click: true 142 233 }); 143 234 // We load toolbar on excerpt only when it's ready 144 235 $('#excerpt-area label').toggleWithLegend($('#excerpt-area').children().not('label'),{ 145 fn: function() { excerptTb.switchMode(formatField.value); },146 cookie: 'dcx_post_excerpt',236 user_pref: 'dcx_post_excerpt', 237 legend_click: true, 147 238 hide: $('#post_excerpt').val() == '' 148 239 }); 149 240 150 241 // Load toolbars 151 242 contentTb.switchMode(formatField.value); 152 243 excerptTb.switchMode(formatField.value); 244 153 245 // Replace attachment remove links by a POST form submit 154 246 $('a.attachment-remove').click(function() { … … 162 254 return false; 163 255 }); 164 165 // Markup validator 166 var h = document.createElement('h4'); 167 var a = document.createElement('a'); 168 a.href = '#'; 169 a.className = 'button'; 170 $(a).click(function() { 171 var params = { 172 xd_check: dotclear.nonce, 173 f: 'validatePostMarkup', 174 excerpt: $('#post_excerpt').text(), 175 content: $('#post_content').text(), 176 format: $('#post_format').get(0).value, 177 lang: $('#post_lang').get(0).value 178 }; 179 180 $.post('services.php',params,function(data) { 181 if ($(data).find('rsp').attr('status') != 'ok') { 182 alert($(data).find('rsp message').text()); 183 return false; 184 } 185 186 if ($(data).find('valid').text() == 1) { 187 var p = document.createElement('p'); 188 p.id = 'markup-validator'; 189 190 if ($('#markup-validator').length > 0) { 191 $('#markup-validator').remove(); 192 } 193 194 $(p).addClass('message'); 195 $(p).text(dotclear.msg.xhtml_valid); 196 $(p).insertAfter(h); 197 $(p).backgroundFade({sColor:'#666666',eColor:'#ffcc00',steps:50},function() { 198 $(this).backgroundFade({sColor:'#ffcc00',eColor:'#666666'}); 199 }); 200 } else { 201 var div = document.createElement('div'); 202 div.id = 'markup-validator'; 203 204 if ($('#markup-validator').length > 0) { 205 $('#markup-validator').remove(); 206 } 207 208 $(div).addClass('error'); 209 $(div).html('<p><strong>' + dotclear.msg.xhtml_not_valid + '</strong></p>' + $(data).find('errors').text()); 210 $(div).insertAfter(h); 211 $(div).backgroundFade({sColor:'#ffffff',eColor:'#ff9999',steps:50},function() { 212 $(this).backgroundFade({sColor:'#ff9999',eColor:'#ffffff'}); 213 }); 214 } 215 216 return false; 217 }); 218 219 return false; 220 }); 221 222 a.appendChild(document.createTextNode(dotclear.msg.xhtml_validator)); 223 h.appendChild(a); 224 $(h).appendTo('#entry-content'); 225 256 226 257 // Check unsaved changes before XHTML conversion 227 258 var excerpt = $('#post_excerpt').val(); … … 230 261 if (excerpt != $('#post_excerpt').val() || content != $('#post_content').val()) { 231 262 return window.confirm(dotclear.msg.confirm_change_post_format); 232 } 233 }); 234 }); 235 263 } 264 }); 265 }); 266 236 267 $('#comments').onetabload(function() { 237 $(' .comments-list tr.line').each(function() {268 $('#form-comments .comments-list tr.line').each(function() { 238 269 dotclear.commentExpander(this); 239 270 }); 240 $(' .checkboxes-helpers').each(function() {271 $('#form-comments .checkboxes-helpers').each(function() { 241 272 dotclear.checkboxesHelpers(this); 242 273 }); 243 274 244 275 dotclear.commentsActionsHelper(); 245 276 }); 246 277 278 $('#trackbacks').onetabload(function() { 279 $('#form-trackbacks .comments-list tr.line').each(function() { 280 dotclear.commentExpander(this); 281 }); 282 $('#form-trackbacks .checkboxes-helpers').each(function() { 283 dotclear.checkboxesHelpers(this); 284 }); 285 286 dotclear.commentsActionsHelper(); 287 }); 288 247 289 $('#add-comment').onetabload(function() { 248 290 commentTb.draw('xhtml');
Note: See TracChangeset
for help on using the changeset viewer.