Ticket #2862: 2862_4.patch

File 2862_4.patch, 13.9 KB (added by Garry Yao, 15 years ago)
  • _source/plugins/toolbar/plugin.js

     
    215215                'Subscript', 'Superscript', '-',
    216216                'SelectAll', 'RemoveFormat', '-',
    217217                'Link', 'Unlink', 'Anchor', '-',
    218                 'Table', 'Smiley', 'HorizontalRule', 'SpecialChar', 'PageBreak'
     218                'Table', 'Smiley', 'HorizontalRule', 'SpecialChar', 'PageBreak', '-',
     219                'Maximize'
    219220        ]
    220221];
  • _source/plugins/selection/plugin.js

     
    147147        {
    148148                delete this._.selectionPreviousPath;
    149149        };
    150 
     150       
     151        /**
     152         * Force firing of the 'selectionChange' event.
     153         */
     154        CKEDITOR.editor.prototype.forceSelectionCheck = checkSelectionChange;
     155       
    151156        /**
    152157         * Gets the current selection from the document.
    153158         * @returns {CKEDITOR.dom.selection} A selection object.
  • _source/plugins/editingblock/plugin.js

     
    102103         * // Switch to "source" view.
    103104         * CKEDITOR.instances.editor1.setMode( 'source' );
    104105         */
    105         CKEDITOR.editor.prototype.setMode = function( mode )
     106        CKEDITOR.editor.prototype.setMode = function( mode, isReload, reloadData)
    106107        {
    107108                var data,
    108109                        holderElement = this.getThemeSpace( 'contents' ),
     
    111112                // Unload the previous mode.
    112113                if ( this.mode )
    113114                {
    114                         if ( mode == this.mode )
     115                        if ( !isReload && ( mode == this.mode ) )
    115116                                return;
    116 
     117                               
    117118                        var currentMode = getMode( this );
    118                         data = currentMode.getData();
     119                        if ( !isReload )
     120                                data = currentMode.getData();
     121                        else
     122                                data = reloadData;
     123                               
    119124                        currentMode.unload( holderElement );
    120125                        this.mode = '';
    121126                }
  • _source/plugins/sourcearea/plugin.js

     
    6868
    6969                                                        // Set the <textarea> value.
    7070                                                        this.loadData( data );
    71 
     71                                                        editor.editarea = textarea;
    7272                                                        editor.mode = 'source';
    7373                                                        editor.fire( 'mode' );
    7474                                                },
  • _source/plugins/maximize/plugin.js

     
     1/*
     2Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
     3For licensing, see LICENSE.html or http://ckeditor.com/license
     4*/
     5
     6/**
     7 * @fileOverview The "maximize" plugin. Enable it will make the editor chrome
     8 *               being maximized and fullfill the view size. Disable it restore
     9 *               editor chrome into original size.
     10 */
     11
     12( function()
     13{
     14        var body = CKEDITOR.document.getBody();
     15       
     16        //Only one editor instance is allowed to be full screen at a time.
     17        var hasMaximized = false;
     18       
     19        function maximizeCommand(editor)
     20        {
     21                this.editor = editor;
     22                // elements along with styles.
     23                this.savedAttributes = [];
     24                // Keep track of the need-to-restore data
     25                this.restore =
     26                {
     27                        // document content
     28                        content : '',
     29                        // selection range bookmark
     30                        bookmark : null,
     31                        // editor focus state
     32                        focus : false,
     33                        // scrollbar position
     34                        scroll : null
     35                };
     36                // Whether pending the restoring due to asynchroniz loading of
     37                // content.
     38                this.restorePending = false;
     39        }
     40       
     41        maximizeCommand.prototype =
     42        {
     43                /**
     44                 * Save the css style of the element for later restoring.
     45                 *
     46                 * @param {CKEDITOR.dom.element}        element
     47                 */
     48                saveStyles : function ( element )
     49                {
     50                        this.savedAttributes.push( {
     51                                element : element,
     52                                attributes : {
     53                                        'class' : element.getAttribute( 'class' ),
     54                                        'style' : element.getAttribute( 'style' )
     55                                }
     56                        } );
     57                },
     58               
     59                /**
     60                 * Restore the saved attributes for elements
     61                 */
     62                restoreAllStyles : function ()
     63                {
     64                        var i = 0, l = this.savedAttributes.length, attrs, element;
     65                        var attrName, attribute;
     66                        for ( ; i < l ; i++ )
     67                        {
     68                                attrs = this.savedAttributes[ i ].attributes;
     69                                element = this.savedAttributes[ i ].element;
     70
     71                                for ( attrName in attrs )
     72                                {
     73                                        if ( attrs[ attrName ] )
     74                                                element.setAttribute( attrName, attrs[ attrName ] );
     75                                        else
     76                                                element.removeAttribute( attrName );
     77                                }
     78                        }
     79                },
     80               
     81                /**
     82                 * Alter the element style while keep record of the original styles.
     83                 */
     84                changeStyle : function ( element, styles )
     85                {
     86                        this.saveStyles( element );
     87                        element.setStyles( styles );
     88                },
     89               
     90               
     91                /**
     92                 * Lift the whole editor to became the first child of body element, OR
     93                 * restore the editor to it's original position.
     94                 * @param {Boolean} isRestore
     95                 */
     96                moveEditor : function ( isRestore )
     97                {
     98                        var container = this.editor.container;
     99
     100                        if ( isRestore )
     101                        {
     102                                // place right after the remembered previous sibling.
     103                                container
     104                                        .insertAfter( this.lastPreviousSibling );
     105                        }
     106                        else
     107                        {
     108                                this.lastPreviousSibling = this.editor.container.getPrevious();
     109                                body.append( this.editor.container, true );
     110                        }
     111                },
     112               
     113                saveSelection : function ()
     114                {
     115                        if ( this.editor.mode == 'wysiwyg' )
     116                        {
     117                                var editorFocus = this.editor.focusManager.hasFocus;
     118                               
     119                                // IE failed to create selection on editor blur
     120                                if ( CKEDITOR.env.ie && !editorFocus )
     121                                        return;
     122                                       
     123                                var sel = this.editor.document.getSelection();
     124                                if ( sel )
     125                                {
     126                                        this.restore.bookmark = sel.createBookmarks( true );
     127                                        this.restore.focus = editorFocus;
     128                                }
     129                        }
     130                },
     131               
     132                restoreSelection : function ()
     133                {
     134                        if ( this.restore.bookmark && !this.restorePending )
     135                        {
     136                                var sel = this.editor.document.getSelection();
     137                                if ( sel )
     138                                {
     139                                        sel.selectBookmarks( this.restore.bookmark );
     140                                       
     141                                        if ( this.restore.focus )
     142                                        {
     143                                                this.editor.focus();
     144                                                this.editor.forceNextSelectionCheck();
     145                                        }
     146                                        else
     147                                                this.editor.forceSelectionCheck();
     148                                               
     149                                        delete this.restore.focus;
     150                                        delete this.restore.bookmark;
     151                                }
     152                        }
     153                },
     154               
     155                saveContent : function ()
     156                {
     157                        // Kludge: Fix for Gecko and Webkit bug of iframe reloads when moved
     158                        // around the DOM tree.
     159                        if ( this.editor.mode == 'wysiwyg' && !CKEDITOR.env.ie )
     160                        {
     161                                // Get the dirty content along with bookmark
     162                                this.restore.content = this.editor.getSnapshot();
     163                                this.restorePending = true;
     164                        }
     165                },
     166               
     167                restoreContent : function ()
     168                {
     169                        if ( this.restore.content )
     170                        {
     171                                this.editor.on( 'mode', function()
     172                                {
     173                                        this.restorePending = false;
     174                                        this.restoreScrollPosition();
     175                                        this.restoreSelection();
     176                                        this.editor.removeListener( 'mode', arguments.callee );
     177                                        delete this.restore.content;
     178                                }, this );
     179
     180                                // reload document content
     181                                this.editor.setMode( 'wysiwyg', true, this.restore.content );
     182                        }
     183                },
     184               
     185                getEditorElement : function()
     186                {
     187                        var element = ( this.editor.mode == 'wysiwyg' ) ?
     188                                this.editor.document.$.documentElement
     189                                : this.editor.editarea;
     190
     191                        return element.$ || element;
     192                },
     193               
     194                saveScrollPosition : function ( )
     195                {
     196                        if ( CKEDITOR.env.ie && this.editor.mode == 'wysiwyg' )
     197                                return;
     198                        var element = this.getEditorElement();
     199                        this.restore.scroll =
     200                        {
     201                                'element' : element,
     202                                'left' : element.scrollLeft + element.clientWidth,
     203                                'top' : element.scrollTop + element.clientHeight
     204                        };
     205                },
     206               
     207                restoreScrollPosition : function ()
     208                {
     209                        if ( this.restore.scroll && !this.restorePending )
     210                        {
     211                                var element = this.getEditorElement();
     212                                var translatedScroll =
     213                                {
     214                                        'left' :  this.restore.scroll.left - element.clientWidth ,
     215                                        'top' :  this.restore.scroll.top - element.clientHeight
     216                                };
     217                                element.scrollLeft = translatedScroll.left;
     218                                element.scrollTop = translatedScroll.top;
     219
     220                                delete this.restore.scroll;
     221                        }
     222                },
     223               
     224                save: function()
     225                {
     226                        this.saveSelection();
     227                        this.saveContent();
     228                        this.saveScrollPosition();
     229                },
     230               
     231                recover : function()
     232                {
     233                        this.restoreContent();
     234                        this.restoreScrollPosition();
     235                        this.restoreSelection();
     236                },
     237               
     238                exec : function( editor )
     239                {
     240                       
     241                        if( this.state == CKEDITOR.TRISTATE_ON || !hasMaximized )
     242                        {
     243                                this.save();
     244                               
     245                                if ( this.state == CKEDITOR.TRISTATE_ON )
     246                                {
     247                                        this.moveEditor( true );
     248                                        this.restoreAllStyles();
     249                                        hasMaximized = false;
     250                                }
     251                                else
     252                                {
     253                                        this.moveEditor();
     254                                        // fix IE and Opera viewport scrolling
     255                                        if ( CKEDITOR.env.ie || CKEDITOR.env.opera )
     256                                        {
     257                                                var view = new CKEDITOR.dom.element(
     258                                                CKEDITOR.document.$.documentElement );
     259                                                this.changeStyle( view, {
     260                                                        'overflow' :'hidden'
     261                                                } );
     262                                        }
     263                                       
     264                                        this.changeStyle( body, {
     265                                                'top' : '0px',
     266                                                'left' : '0px',
     267                                                'height' : '100%',
     268                                                'width' : '100%',
     269                                                'overflow' : 'hidden',
     270                                                'position' : 'absolute',
     271                                                'margin' : '0px'
     272                                        } );
     273                                       
     274                                        if ( CKEDITOR.env.webkit )
     275                                        {
     276                                                this.changeStyle( editor.container, {
     277                                                        'position' : 'absolute',
     278                                                        'height' : '100%',
     279                                                        'width' : '100%',
     280                                                        'z-index' : '10'
     281                                                } );
     282                                        }
     283                               
     284                                        this.changeStyle( editor.container.getFirst(), {
     285                                                'width' : '100%',
     286                                                // Kludge: Fix IE and Opera table over-height on fit parent.
     287                                                'height' : ( ( CKEDITOR.env.ie &&
     288                                                        CKEDITOR.document.$.compatMode != 'BackCompat' )
     289                                                || CKEDITOR.env.opera ) ? '90%' : '100%',
     290                                                'z-index' : '10'
     291                                        } );
     292                                       
     293                                        // Fix IE 'source' mode bug of #2764
     294                                        if( editor.mode == 'source' && CKEDITOR.env.ie )
     295                                        {
     296                                                var element = this.editor.editarea;
     297                                                this.changeStyle( element , {
     298                                                        'width' : element.getParent().$.clientWidth,
     299                                                        'height' : element.getParent().$.clientHeight
     300                                                } );
     301                                        }
     302                                       
     303                                        hasMaximized = true;
     304                                }
     305                        }
     306                       
     307                        this.recover();
     308                        // refresh command state
     309                        this.toggleState();
     310                }
     311        };
     312       
     313        CKEDITOR.plugins.add( 'maximize',
     314        {
     315                requires : [ 'editingblock' ],
     316
     317                init : function( editor )
     318                {
     319                        editor.addCommand( 'maximize', new maximizeCommand( editor ) );
     320                        editor.ui.addButton( 'Maximize', {
     321                                label : editor.lang.maximize,
     322                                command : 'maximize'
     323                        } );
     324                       
     325                        if(editor.config.startupMaximize)
     326                        {
     327                                editor.on( 'mode', function()
     328                                {
     329                                        // defer the execution to avoid DUP event registration in
     330                                        // event-handler.
     331                                        setTimeout( function()
     332                                        {
     333                                                editor.getCommand( 'maximize' ).exec();
     334                                        }, 0 );
     335                                       
     336                                        editor.removeListener( 'mode', arguments.callee );
     337                                });
     338                        }
     339                }
     340        });
     341       
     342})();
     343
     344CKEDITOR.config.startupMaximize = false;
  • _source/skins/default/toolbar.css

     
    310310{
    311311        background-position: 0 -880px;
    312312}
     313.cke_skin_default a.cke_button_maximize .cke_icon
     314{
     315        background-position: 0 -1040px;
     316}
    313317
    314318.cke_skin_default a.cke_button_numberedlist .cke_icon
    315319{
  • _source/core/dom/element.js

     
    379379
    380380                                                        return tabIndex;
    381381                                                        break;
     382                                                       
     383                                                case 'style' :
     384                                                        return this.$.style.cssText;
    382385                                        }
    383386
    384387                                        return standard.call( this, name );
     
    846849                                {
    847850                                        if ( name == 'class' )
    848851                                                name = 'className';
     852                                        else if ( name === 'style' )
     853                                        {
     854                                                if(this.$.style)
     855                                                        this.$.style.cssText = ' ';
     856                                                return;
     857                                        }
    849858                                        standard.call( this, name );
    850859                                };
    851860                        }
  • _source/core/command.js

     
    3434                this.fire( 'state' );
    3535
    3636                return true;
     37        },
     38        /*
     39         * Toggle the current state of command and refresh.
     40         */
     41        toggleState : function()
     42        {
     43                this.setState( this.state === CKEDITOR.TRISTATE_ON ?
     44                                CKEDITOR.TRISTATE_OFF
     45                                : CKEDITOR.TRISTATE_ON );
    3746        }
    3847}
    3948
  • _source/core/config.js

     
    147147         * config.plugins = 'basicstyles,button,htmldataprocessor,toolbar,wysiwygarea';
    148148         */
    149149
    150         plugins : 'basicstyles,button,elementspath,horizontalrule,htmldataprocessor,keystrokes,newpage,pagebreak,preview,removeformat,smiley,indent,link,list,justify,blockquote,sourcearea,table,specialchar,tab,toolbar,wysiwygarea',
     150        plugins : 'basicstyles,button,elementspath,horizontalrule,htmldataprocessor,keystrokes,newpage,pagebreak,preview,removeformat,smiley,indent,link,list,justify,blockquote,sourcearea,table,specialchar,tab,toolbar,wysiwygarea,maximize',
    151151
    152152        /**
    153153         * The theme to be used to build the UI.
  • _source/lang/en.js

     
    4343        horizontalrule  : 'Insert Horizontal Line',
    4444        pagebreak               : 'Insert Page Break',
    4545        unlink                  : 'Unlink',
     46        maximize                        : 'Maximize',
    4647
    4748        // Common messages and labels.
    4849        common :
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy