Ticket #7280: 7280_maximize.patch

File 7280_maximize.patch, 8.2 KB (added by Jakub Ś, 13 years ago)
  • _samples/replacebycode.html

     
    6060
    6161                                // Replace the <textarea id="editor"> with an CKEditor
    6262                                // instance, using default configurations.
    63                                 CKEDITOR.replace( 'editor1' );
     63                                var editor = CKEDITOR.replace( 'editor1', {
     64                                        toolbar: 'Basic'                               
     65                                });
     66                               
     67                                editor.on( 'instanceReady', function(event){                                   
     68                                        var myToolbar = 'Basic';
     69                               
     70                                        event.editor.on( 'beforeMaximize', function(){                                         
     71                                                if(event.editor.getCommand( 'maximize' ).state == CKEDITOR.TRISTATE_ON && myToolbar != 'Basic') {//no maximize == baic toolbar
     72                                                        editor.setToolbar('Basic');
     73                                                        myToolbar = 'Basic';
     74                                                }else if(event.editor.getCommand( 'maximize' ).state == CKEDITOR.TRISTATE_OFF && myToolbar != 'Full') {//maximize is on == Full toolbar
     75                                                        editor.setToolbar('Full');
     76                                                        myToolbar = 'Full';
     77                                                }
     78                                        });
     79                                });
     80                               
    6481
    6582                        //]]>
    6683                        </script>
     
    84101                        </script>
    85102                </p>
    86103                <p>
    87                         <input type="submit" value="Submit" />
     104                        <input type="submit" value="Submit" />                 
    88105                </p>
    89106        </form>
    90107        <div id="footer">
  • _source/plugins/maximize/plugin.js

     
    160160                                        editorFocus : false,
    161161                                        exec : function()
    162162                                        {
     163                                                editor.fire( 'beforeMaximize' );                                               
    163164                                                var container = editor.container.getChild( 1 );
    164165                                                var contents = editor.getThemeSpace( 'contents' );
    165166
  • _source/plugins/panelbutton/plugin.js

     
    3232
    3333                        $ : function( definition )
    3434                        {
     35                                // Store/Restore a copy of the panel definition to allow switch toolbars
     36                                if ( definition.panel )
     37                                        definition.storedPanel = definition.panel;
     38                                else
     39                                        definition.panel = definition.storedPanel;
     40
    3541                                // We don't want the panel definition in this object.
    3642                                var panelDefinition = definition.panel;
    3743                                delete definition.panel;
  • _source/plugins/richcombo/plugin.js

     
    128128                                clickFn : clickFn
    129129                        };
    130130
    131                         function updateState()
     131                        instance.updateState = function()
    132132                        {
    133133                                var state = this.modes[ editor.mode ] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED;
    134134                                this.setState( editor.readOnly && !this.readOnly ? CKEDITOR.TRISTATE_DISABLED : state );
    135135                                this.setValue( '' );
    136136                        }
    137137
    138                         editor.on( 'mode', updateState, this );
     138                        editor.on( 'mode', instance.updateState, this );
    139139                        // If this combo is sensitive to readOnly state, update it accordingly.
    140                         !this.readOnly && editor.on( 'readOnly', updateState, this);
     140                        !this.readOnly && editor.on( 'readOnly', instance.updateState, this);
    141141
    142142                        var keyDownFn = CKEDITOR.tools.addFunction( function( ev, element )
    143143                                {
  • _source/plugins/toolbar/plugin.js

     
    169169                                {
    170170                                        if ( event.data.space == editor.config.toolbarLocation )
    171171                                        {
     172                                                event.data.html += generateToolbarHtml( editor );
     173                                        }
     174                                });
     175
     176                        var generateToolbarHtml = function ( editor )
     177                        {
    172178                                                editor.toolbox = new toolbox();
    173179
    174180                                                var labelId = CKEDITOR.tools.getNextId();
     
    377383                                                                                '</a>' );
    378384                                                }
    379385
    380                                                 event.data.html += output.join( '' );
    381                                         }
    382                                 });
     386                                return output.join( '' );
     387                        };
    383388
    384                         editor.on( 'destroy', function()
     389                        var destroyToolbar = function()
    385390                        {
    386391                                var toolbars, index = 0, i,
    387392                                                items, instance;
     
    394399                                                instance = items[ i ];
    395400                                                if ( instance.clickFn ) CKEDITOR.tools.removeFunction( instance.clickFn );
    396401                                                if ( instance.keyDownFn ) CKEDITOR.tools.removeFunction( instance.keyDownFn );
     402
     403                                                if ( instance.button && instance.button.command )
     404                                                {
     405                                                        var command = editor.getCommand( instance.button.command );
     406                                                        command.uiItems = [];
     407                                                }
     408
     409                                                if ( instance.updateState )
     410                                                {
     411                                                        this.removeListener( 'mode', instance.updateState );
     412                                                        this.removeListener( 'readOnly', instance.updateState );
     413                                                }
    397414                                        }
    398415                                }
    399                         });
     416                        };
    400417
     418                        editor.on( 'destroy', destroyToolbar );
     419
     420                        // Method to switch the currently used toolbar
     421                        editor.setToolbar = function( toolbar )
     422                        {
     423                                // Remove existing toolbar
     424                                destroyToolbar.call( this );
     425
     426                                // Set new one
     427                                this.config.toolbar = toolbar;
     428
     429                                // Create it
     430                                var toolbarLocation = this.config.toolbarLocation,
     431                                        space = document.getElementById( 'cke_' + toolbarLocation + '_' + this.name );
     432
     433                                space.innerHTML = generateToolbarHtml( this );
     434
     435                                // IE...
     436                                if ( CKEDITOR.env.ie )
     437                                {
     438                                        var table = space.parentNode.parentNode.parentNode;
     439                                        table.style.display = 'none';
     440                                        // Force refresh
     441                                        var h = table.scrollHeight;
     442                                        table.style.display = '';
     443                                }
     444                        };
     445
    401446                        editor.addCommand( 'toolbarFocus', commands.toolbarFocus );
    402447
    403448                        editor.ui.add( '-', CKEDITOR.UI_SEPARATOR, {} );
  • config.js

     
    88        // Define changes to default configuration here. For example:
    99        // config.language = 'fr';
    1010        // config.uiColor = '#AADC6E';
     11       
     12       
     13        config.toolbar_Full =
     14        [
     15                { name: 'document', items : [ 'Source','-','Save','NewPage','DocProps','Preview','Print','-','Templates' ] },
     16                { name: 'clipboard', items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] },
     17                { name: 'editing', items : [ 'Find','Replace','-','SelectAll','-','SpellChecker', 'Scayt' ] },
     18                { name: 'forms', items : [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton',
     19                        'HiddenField' ] },
     20                '/',
     21                { name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] },
     22                { name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote','CreateDiv',
     23                '-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl' ] },
     24                { name: 'links', items : [ 'Link','Unlink','Anchor' ] },
     25                { name: 'insert', items : [ 'Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe' ] },
     26                '/',
     27                { name: 'styles', items : [ 'Styles','Format','Font','FontSize' ] },
     28                { name: 'colors', items : [ 'TextColor','BGColor' ] },
     29                { name: 'tools', items : [ 'Maximize', 'ShowBlocks','-','About' ] }
     30        ];
     31         
     32        config.toolbar_Basic =
     33        [
     34                ['Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink','-','Maximize','About']
     35        ];
    1136};
     37
     38
     39// Set new Toolbar
     40CKEDITOR.editor.prototype.setToolbar = function( toolbar )
     41{
     42        // Destroy previous toolbar
     43        var toolbars, index = 0, i,
     44                        items, instance;
     45        toolbars = this.toolbox.toolbars;
     46        for ( ; index < toolbars.length; index++ )
     47        {
     48                items = toolbars[ index ].items;
     49                for ( i = 0; i < items.length; i++ )
     50                {
     51                        instance = items[ i ];
     52                        if ( instance.clickFn ) CKEDITOR.tools.removeFunction( instance.clickFn );
     53                        if ( instance.keyDownFn ) CKEDITOR.tools.removeFunction( instance.keyDownFn );
     54
     55                        if ( instance.index ) CKEDITOR.ui.button._.instances[ instance.index ] = null;
     56                }
     57        }
     58
     59        // Set new one
     60        this.config.toolbar = toolbar;
     61
     62        // create it
     63        var toolbarLocation = this.config.toolbarLocation,
     64                space = document.getElementById('cke_' + toolbarLocation + '_' + this.name),
     65                html = this.fire( 'themeSpace', { space : toolbarLocation, html : '' } ).html;
     66
     67        space.innerHTML = html;
     68}
     69
     70
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy