Changeset 3709:c88e69474c34 for plugins/dcLegacyEditor/js/_post_editor.js
- Timestamp:
- 02/18/18 18:16:29 (8 years ago)
- Branch:
- default
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/dcLegacyEditor/js/_post_editor.js
r3666 r3709 1 /*global $, dotclear, jsToolBar */ 2 'use strict'; 3 1 4 $(function() { 2 if ($('#edit-entry').length == 0) { return; } 3 if (dotclear.legacy_editor_context === undefined || 4 dotclear.legacy_editor_tags_context[dotclear.legacy_editor_context] === undefined) { 5 return; 6 } 5 if ($('#edit-entry').length == 0) { 6 return; 7 } 8 if (dotclear.legacy_editor_context === undefined || 9 dotclear.legacy_editor_tags_context[dotclear.legacy_editor_context] === undefined) { 10 return; 11 } 7 12 8 if ((dotclear.legacy_editor_tags_context[dotclear.legacy_editor_context].indexOf('#post_content') !== -1) && 9 (dotclear.legacy_editor_tags_context[dotclear.legacy_editor_context].indexOf('#post_excerpt') !== -1)) { 10 // Get document format and prepare toolbars 11 var formatField = $('#post_format').get(0); 12 var last_post_format = $(formatField).val(); 13 $(formatField).change(function() { 14 if (this.value != 'dcLegacyEditor') { return; } 13 if ((dotclear.legacy_editor_tags_context[dotclear.legacy_editor_context].indexOf('#post_content') !== -1) && 14 (dotclear.legacy_editor_tags_context[dotclear.legacy_editor_context].indexOf('#post_excerpt') !== -1)) { 15 // Get document format and prepare toolbars 16 var formatField = $('#post_format').get(0); 17 var last_post_format = $(formatField).val(); 18 $(formatField).change(function() { 19 if (this.value != 'dcLegacyEditor') { 20 return; 21 } 15 22 16 23 var post_format = this.value; 17 24 18 19 20 21 22 23 24 25 26 25 // Confirm post format change 26 if (window.confirm(dotclear.msg.confirm_change_post_format_noconvert)) { 27 excerptTb.switchMode(post_format); 28 contentTb.switchMode(post_format); 29 last_post_format = $(this).val(); 30 } else { 31 // Restore last format if change cancelled 32 $(this).val(last_post_format); 33 } 27 34 28 29 30 35 $('.format_control > *').addClass('hide'); 36 $('.format_control:not(.control_no_' + post_format + ') > *').removeClass('hide'); 37 }); 31 38 32 33 34 39 var excerptTb = new jsToolBar(document.getElementById('post_excerpt')); 40 var contentTb = new jsToolBar(document.getElementById('post_content')); 41 excerptTb.context = contentTb.context = 'post'; 35 42 36 37 38 43 $('.format_control > *').addClass('hide'); 44 $('.format_control:not(.control_no_' + last_post_format + ') > *').removeClass('hide'); 45 } 39 46 40 41 42 43 44 45 47 if (dotclear.legacy_editor_tags_context[dotclear.legacy_editor_context].indexOf('#comment_content') !== -1) { 48 if ($('#comment_content').length > 0) { 49 var commentTb = new jsToolBar(document.getElementById('comment_content')); 50 commentTb.draw('xhtml'); 51 } 52 } 46 53 47 54 $('#edit-entry').onetabload(function() { 48 55 49 50 51 52 56 // Remove required attribut from #post_content in XHTML mode as textarea is not more focusable 57 if (formatField.value == 'xhtml') { 58 $('#post_content').removeAttr('required'); 59 } 53 60 54 55 56 57 58 61 // Load toolbars 62 if (contentTb !== undefined && excerptTb !== undefined) { 63 contentTb.switchMode(formatField.value); 64 excerptTb.switchMode(formatField.value); 65 } 59 66 60 61 62 63 64 65 66 67 68 67 // Check unsaved changes before XHTML conversion 68 var excerpt = $('#post_excerpt').val(); 69 var content = $('#post_content').val(); 70 $('#convert-xhtml').click(function() { 71 if (excerpt != $('#post_excerpt').val() || content != $('#post_content').val()) { 72 return window.confirm(dotclear.msg.confirm_change_post_format); 73 } 74 }); 75 }); 69 76 });
Note: See TracChangeset
for help on using the changeset viewer.