Dotclear

Changeset 2856:b9ae6bf9bd6e


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

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

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • admin/js/_index.js

    r2614 r2856  
    22     var f = $('#quick-entry'); 
    33     if (f.length > 0) { 
    4           if ($.isFunction('jsToolBar')) { 
     4          if (typeof(jsToolBar)!==undefined) { 
    55               var contentTb = new jsToolBar($('#post_content',f)[0]); 
    66               contentTb.switchMode($('#post_format',f).val()); 
  • admin/post.php

    r2854 r2856  
    377377 
    378378$admin_post_behavior = ''; 
    379 if ($post_editor && !empty($post_editor[$post_format])) { 
    380      $admin_post_behavior = $core->callBehavior('adminPostEditor', $post_editor[$post_format], 'post', array('#post_excerpt','#post_content,#comment_content')); 
     379if ($post_editor) { 
     380    $p_edit = $c_edit = ''; 
     381    if (!empty($post_editor[$post_format])) { 
     382        $p_edit = $post_editor[$post_format]; 
     383    } 
     384    if (!empty($post_editor['xhtml'])) { 
     385        $c_edit = $post_editor['xhtml']; 
     386    } 
     387    if ($p_edit == $c_edit) { 
     388        $admin_post_behavior .= $core->callBehavior('adminPostEditor', 
     389            $p_edit,'post',array('#post_excerpt','#post_content','#comment_content')); 
     390    } else { 
     391        $admin_post_behavior .= $core->callBehavior('adminPostEditor', 
     392            $p_edit,'post',array('#post_excerpt','#post_content')); 
     393        $admin_post_behavior .= $core->callBehavior('adminPostEditor', 
     394            $c_edit,'comment',array('#comment_content')); 
     395    } 
    381396} 
    382397 
  • plugins/dcLegacyEditor/inc/dc.legacy.editor.behaviors.php

    r2854 r2856  
    2222     * @param tags     <b>array</b>  array of ids to inject editor 
    2323     */ 
    24     public static function adminPostEditor($editor='',$context='',array $tags=array()) { 
     24     public static function adminPostEditor($editor='',$context='',array $tags=array()) { 
    2525          if (empty($editor) || $editor!='dcLegacyEditor') {return;} 
    26  
    27         // context and tags are not used for dcLegacyEditor 
    2826 
    2927          return 
    3028               self::jsToolBar(). 
    31                dcPage::jsLoad(self::$p_url.'/js/_post_editor.js'); 
     29               dcPage::jsLoad(self::$p_url.'/js/_post_editor.js'). 
     30               '<script type="text/javascript">'."\n". 
     31               "//<![CDATA[\n". 
     32               dcPage::jsVar('dotclear.legacy_editor_context', $context). 
     33               'dotclear.legacy_editor_tags_context = '.sprintf('{%s:["%s"]};'."\n", $context, implode('","', $tags)). 
     34               "\n//]]>\n". 
     35               "</script>\n"; 
    3236     } 
    3337 
     
    5761          if (isset($GLOBALS['core']->auth) && $GLOBALS['core']->auth->getOption('enable_wysiwyg')) { 
    5862               $res .= '<script type="text/javascript" src="'.self::$p_url.'/js/jsToolBar/jsToolBar.wysiwyg.js"></script>'; 
    59           } 
     63        } 
    6064 
    6165          $res .= 
  • 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 
  • plugins/pages/page.php

    r2854 r2856  
    285285 
    286286$admin_post_behavior = ''; 
    287 if ($post_editor && !empty($post_editor[$post_format])) { 
    288      $admin_post_behavior = $core->callBehavior('adminPostEditor', $post_editor[$post_format], 'page', array('#post_excerpt','#post_content')); 
     287if ($post_editor) { 
     288     $p_edit = $c_edit = ''; 
     289     if (!empty($post_editor[$post_format])) { 
     290          $p_edit = $post_editor[$post_format]; 
     291     } 
     292     if (!empty($post_editor['xhtml'])) { 
     293          $c_edit = $post_editor['xhtml']; 
     294     } 
     295     if ($p_edit == $c_edit) { 
     296          $admin_post_behavior .= $core->callBehavior('adminPostEditor', 
     297               $p_edit,'page',array('#post_excerpt','#post_content','#comment_content')); 
     298     } else { 
     299          $admin_post_behavior .= $core->callBehavior('adminPostEditor', 
     300               $p_edit,'page',array('#post_excerpt','#post_content')); 
     301          $admin_post_behavior .= $core->callBehavior('adminPostEditor', 
     302               $c_edit,'comment',array('#comment_content')); 
     303     } 
    289304} 
    290305 
Note: See TracChangeset for help on using the changeset viewer.

Sites map