Dotclear


Ignore:
Timestamp:
12/17/14 11:40:49 (11 years ago)
Author:
Nicolas <nikrou77@…>
Branch:
2.7
Message:

Load wanted editor for each context
Closes #2011, Closes #2014

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/dcLegacyEditor/js/_post_editor.js

    r2751 r2856  
    11$(function() { 
    22     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     } 
    37 
    4      // Get document format and prepare toolbars 
    5      var formatField = $('#post_format').get(0); 
    6      var last_post_format = $(formatField).val(); 
    7      $(formatField).change(function() { 
    8           if (this.value!='dcLegacyEditor') { return;} 
     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;} 
    915 
    10           var post_format = this.value; 
     16               var post_format = this.value; 
    1117 
    12           // Confirm post format change 
    13           if (window.confirm(dotclear.msg.confirm_change_post_format_noconvert)) { 
    14                excerptTb.switchMode(post_format); 
    15                contentTb.switchMode(post_format); 
    16                last_post_format = $(this).val(); 
    17           } else { 
    18                // Restore last format if change cancelled 
     18               // Confirm post format change 
     19               if (window.confirm(dotclear.msg.confirm_change_post_format_noconvert)) { 
     20                    excerptTb.switchMode(post_format); 
     21                    contentTb.switchMode(post_format); 
     22                    last_post_format = $(this).val(); 
     23               } else { 
     24                    // Restore last format if change cancelled 
    1925               $(this).val(last_post_format); 
    20           } 
     26               } 
     27 
     28               $('.format_control > *').addClass('hide'); 
     29               $('.format_control:not(.control_no_'+post_format+') > *').removeClass('hide'); 
     30          }); 
     31 
     32          var excerptTb = new jsToolBar(document.getElementById('post_excerpt')); 
     33          var contentTb = new jsToolBar(document.getElementById('post_content')); 
     34          excerptTb.context = contentTb.context = 'post'; 
    2135 
    2236          $('.format_control > *').addClass('hide'); 
    23           $('.format_control:not(.control_no_'+post_format+') > *').removeClass('hide'); 
    24      }); 
     37          $('.format_control:not(.control_no_'+last_post_format+') > *').removeClass('hide'); 
     38     } 
    2539 
    26      var excerptTb = new jsToolBar(document.getElementById('post_excerpt')); 
    27      var contentTb = new jsToolBar(document.getElementById('post_content')); 
    28      excerptTb.context = contentTb.context = 'post'; 
    29  
    30      $('.format_control > *').addClass('hide'); 
    31      $('.format_control:not(.control_no_'+last_post_format+') > *').removeClass('hide'); 
    32  
    33      if ($('#comment_content').length>0) { 
    34           var commentTb = new jsToolBar(document.getElementById('comment_content')); 
    35           commentTb.draw('xhtml'); 
     40     if (dotclear.legacy_editor_tags_context[dotclear.legacy_editor_context].indexOf('#comment_content')!==-1) { 
     41          if ($('#comment_content').length>0) { 
     42               var commentTb = new jsToolBar(document.getElementById('comment_content')); 
     43               commentTb.draw('xhtml'); 
     44          } 
    3645     } 
    3746 
     
    103112 
    104113          // Load toolbars 
    105           contentTb.switchMode(formatField.value); 
    106           excerptTb.switchMode(formatField.value); 
     114          if (contentTb!==undefined && excerptTb!==undefined) { 
     115               contentTb.switchMode(formatField.value); 
     116               excerptTb.switchMode(formatField.value); 
     117          } 
    107118 
    108119          // Check unsaved changes before XHTML conversion 
Note: See TracChangeset for help on using the changeset viewer.

Sites map