Ticket #2862: 2862_12.patch

File 2862_12.patch, 13.9 KB (added by Martin Kou, 15 years ago)
  • _source/lang/en.js

     
    574574                title : 'About CKEditor',
    575575                moreInfo : 'For licensing information please visit our web site:',
    576576                copy : 'Copyright © $1. All rights reserved.'
    577         }
     577        },
     578
     579        maximize : 'Maximize'
    578580};
  • _source/plugins/sourcearea/plugin.js

     
    2929                                                                holderElement.setStyle( 'position', 'relative' );
    3030
    3131                                                        // Create the source area <textarea>.
    32                                                         textarea = new CKEDITOR.dom.element( 'textarea' );
     32                                                        editor.textarea = textarea = new CKEDITOR.dom.element( 'textarea' );
    3333                                                        textarea.setAttributes(
    3434                                                                {
    3535                                                                        dir : 'ltr',
     
    127127
    128128                                                unload : function( holderElement )
    129129                                                {
    130                                                         textarea = null;
     130                                                        editor.textarea = textarea = null;
    131131
    132132                                                        if ( onResize )
    133133                                                                editor.removeListener( 'resize', onResize );
  • _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(function()
     7{
     8        function protectFormStyles( formElement )
     9        {
     10                if ( !formElement || formElement.type != CKEDITOR.NODE_ELEMENT || formElement.getName() != 'form' )
     11                        return [];
     12
     13                var hijackRecord = [];
     14                var hijackNames = [ 'style', 'className' ];
     15                for ( var i = 0 ; i < hijackNames.length ; i++ )
     16                {
     17                        var name = hijackNames[i];
     18                        var $node = formElement.$.elements.namedItem( name );
     19                        if ( $node )
     20                        {
     21                                var hijackNode = new CKEDITOR.dom.element( $node );
     22                                hijackRecord.push( [ hijackNode, hijackNode.nextSibling ] );
     23                                hijackNode.remove();
     24                        }
     25                }
     26
     27                return hijackRecord;
     28        }
     29
     30        function restoreFormStyles( formElement, hijackRecord )
     31        {
     32                if ( !formElement || formElement.type != CKEDITOR.NODE_ELEMENT || formElement.getName() != 'form' )
     33                        return;
     34
     35                if ( hijackRecord.length > 0 )
     36                {
     37                        for ( var i = hijackRecord.length - 1 ; i >= 0 ; i-- )
     38                        {
     39                                var node = hijackRecord[i][0];
     40                                var sibling = hijackRecord[i][1];
     41                                if ( sibling )
     42                                        node.insertBefore( sibling );
     43                                else
     44                                        node.appendTo( formElement );
     45                        }
     46                }
     47        }
     48
     49        function saveStyles( element, isInsideEditor )
     50        {
     51                var data = protectFormStyles( element );
     52                var retval = {};
     53
     54                var $element = element.$;
     55
     56                if ( !isInsideEditor )
     57                {
     58                        retval[ 'class' ] = $element.className || '';
     59                        $element.className = '';
     60                }
     61
     62                retval.inline = $element.style.cssText || '';
     63                if ( isInsideEditor )
     64                        $element.style.cssText = '';
     65                else            // Reset any external styles that might interfere. (#2474)
     66                        $element.style.cssText = 'position: static; overflow: visible';
     67
     68                restoreFormStyles( data );
     69                return retval;
     70        }
     71
     72        function restoreStyles( element, savedStyles )
     73        {
     74                var data = protectFormStyles( element );
     75                var $element = element.$;
     76                if ( 'class' in savedStyles )
     77                        $element.className = savedStyles[ 'class' ];
     78                if ( 'inline' in savedStyles )
     79                        $element.style.cssText = savedStyles.inline;
     80                restoreFormStyles( data );
     81        }
     82
     83        function getResizeHandler( mainWindow, editor )
     84        {
     85                return function()
     86                {
     87                        var viewPaneSize = mainWindow.getViewPaneSize();
     88                        editor.resize( viewPaneSize.width, viewPaneSize.height );
     89                };
     90        }
     91
     92        CKEDITOR.plugins.add( 'maximize',
     93        {
     94                init : function( editor )
     95                {
     96                        var lang = editor.lang;
     97                        var mainDocument = CKEDITOR.document;
     98                        var mainWindow = mainDocument.getWindow();
     99
     100                        // Saved selection and scroll position for the editing area.
     101                        var savedSelection;
     102                        var savedScroll;
     103
     104                        // Saved scroll position for the outer window.
     105                        var outerScroll;
     106
     107                        // Saved resize handler function.
     108                        var resizeHandler = getResizeHandler( mainWindow, editor );
     109
     110                        editor.addCommand( 'maximize',
     111                                {
     112                                        modes : { wysiwyg : 1, source : 1 },
     113
     114                                        exec : function()
     115                                        {
     116                                                var container = editor.container.getChild( [ 0, 0 ] );
     117                                                var contents = mainDocument.getById( 'cke_contents_' + editor.name );
     118
     119                                                // Save current selection and scroll position in editing area.
     120                                                if ( editor.mode == 'wysiwyg' )
     121                                                {
     122                                                        savedSelection = editor.getSelection().getRanges();
     123                                                        savedScroll = editor.window.getScrollPosition();
     124                                                }
     125                                                else
     126                                                {
     127                                                        var $textarea = editor.textarea.$;
     128                                                        savedSelection = !CKEDITOR.env.ie && [ $textarea.selectionStart, $textarea.selectionEnd ];
     129                                                        savedScroll = [ $textarea.scrollLeft, $textarea.scrollTop ];
     130                                                }
     131                                               
     132                                                if ( this.state == CKEDITOR.TRISTATE_OFF )              // Go fullscreen if the state is off.
     133                                                {
     134                                                        // Add event handler for resizing.
     135                                                        mainWindow.on( 'resize', resizeHandler );
     136                                                       
     137                                                        // Save the scroll bar position.
     138                                                        outerScroll = mainWindow.getScrollPosition();
     139
     140                                                        // Save and reset the styles for the entire node tree.
     141                                                        var currentNode = editor.container;
     142                                                        while ( ( currentNode = currentNode.getParent() ) )
     143                                                        {
     144                                                                currentNode.setCustomData( 'maximize_saved_styles', saveStyles( currentNode ) );
     145                                                                currentNode.setStyle( 'z-index', editor.config.baseFloatZIndex - 1 );
     146                                                        }
     147                                                        contents.setCustomData( 'maximize_saved_styles', saveStyles( contents, true ) );
     148                                                        container.setCustomData( 'maximize_saved_styles', saveStyles( container, true ) );
     149
     150                                                        // Hide scroll bars.
     151                                                        if ( CKEDITOR.env.ie )
     152                                                        {
     153                                                                mainDocument.$.documentElement.style.overflow =
     154                                                                        mainDocument.getBody().$.style.overflow = 'hidden';
     155                                                        }
     156                                                        else
     157                                                        {
     158                                                                mainDocument.getBody().setStyles(
     159                                                                        {
     160                                                                                overflow : 'hidden',
     161                                                                                width : '0px',
     162                                                                                height : '0px'
     163                                                                        } );
     164                                                        }
     165
     166                                                        // Scroll to the top left.
     167                                                        mainWindow.$.scrollTo( 0, 0 );
     168
     169                                                        // Resize and move to top left.
     170                                                        var viewPaneSize = mainWindow.getViewPaneSize();
     171                                                        container.setStyle( 'position', 'absolute' );
     172                                                        container.$.offsetLeft;                 // SAFARI BUG: See #2066.
     173                                                        container.setStyles(
     174                                                                {
     175                                                                        'z-index' : editor.config.baseFloatZIndex - 1,
     176                                                                        left : '0px',
     177                                                                        top : '0px'
     178                                                                } );
     179                                                        editor.resize( viewPaneSize.width, viewPaneSize.height );
     180
     181                                                        // Still not top left? Fix it. (Bug #174)
     182                                                        var offset = container.getDocumentPosition();
     183                                                        container.setStyles(
     184                                                                {
     185                                                                        left : ( -1 * offset.x ) + 'px',
     186                                                                        top : ( -1 * offset.y ) + 'px'
     187                                                                } );
     188
     189                                                        // Set borders in non IE browsers to cover up background.
     190                                                        if ( !CKEDITOR.env.ie )
     191                                                        {
     192                                                                container.setStyles(
     193                                                                        {
     194                                                                                'border-right' : '9999px solid white',
     195                                                                                'border-bottom' : '9999px solid white',
     196                                                                                'background-color' : 'white'
     197                                                                        } );
     198                                                        }
     199                                                }
     200                                                else if ( this.state == CKEDITOR.TRISTATE_ON )  // Restore from fullscreen if the state is on.
     201                                                {
     202                                                        // Remove event handler for resizing.
     203                                                        mainWindow.removeListener( 'resize', resizeHandler );
     204
     205                                                        // Restore CSS styles for the entire node tree.
     206                                                        var editorElements = [ contents, container ];
     207                                                        for ( var i = 0 ; i < editorElements.length ; i++ )
     208                                                        {
     209                                                                restoreStyles( editorElements[i], editorElements[i].getCustomData( 'maximize_saved_styles' ) );
     210                                                                editorElements[i].removeCustomData( 'maximize_saved_styles' );
     211                                                        }
     212                                                        var currentNode = editor.container;
     213                                                        while ( ( currentNode = currentNode.getParent() ) )
     214                                                        {
     215                                                                restoreStyles( currentNode, currentNode.getCustomData( 'maximize_saved_styles' ) );
     216                                                                currentNode.removeCustomData( 'maximize_saved_styles' );
     217                                                        }
     218
     219                                                        // Restore the window scroll position.
     220                                                        mainWindow.$.scrollTo( outerScroll.x, outerScroll.y );
     221
     222                                                        // Emit a resize event, because this time the size is modified in
     223                                                        // restoreStyles.
     224                                                        editor.fire( 'resize' );
     225                                                }
     226
     227                                                this.toggleState();
     228
     229                                                // Restore selection and scroll position in editing area.
     230                                                if ( editor.mode == 'wysiwyg' )
     231                                                {
     232                                                        editor.getSelection().selectRanges( savedSelection );
     233                                                        editor.window.$.scrollTo( savedScroll.x, savedScroll.y );
     234                                                }
     235                                                else
     236                                                {
     237                                                        if ( savedSelection )
     238                                                        {
     239                                                                $textarea.selectionStart = savedSelection[0];
     240                                                                $textarea.selectionEnd = savedSelection[1];
     241                                                        }
     242                                                        $textarea.scrollLeft = savedScroll[0];
     243                                                        $textarea.scrollTop = savedScroll[1];
     244                                                }
     245
     246                                                savedSelection = savedScroll = null;
     247                                        }
     248                                } );
     249
     250                        editor.ui.addButton( 'Maximize',
     251                                {
     252                                        label : lang.maximize,
     253                                        command : 'maximize'
     254                                } );
     255                }
     256        } );
     257})();
  • _source/plugins/toolbar/plugin.js

     
    4646                }
    4747        };
    4848
    49         var collapserFn = CKEDITOR.tools.addFunction(
    50                 function( collapser )
    51                 {
    52                         var toolbox = collapser.getPrevious();
    53 
    54                         if ( toolbox.isVisible() )
    55                         {
    56                                 toolbox.hide();
    57                                 collapser.addClass( 'cke_toolbox_collapser_min' );
    58                         }
    59                         else
    60                         {
    61                                 toolbox.show();
    62                                 collapser.removeClass( 'cke_toolbox_collapser_min' );
    63                         }
    64                 });
    65 
    6649        CKEDITOR.plugins.add( 'toolbar',
    6750        {
    6851                init : function( editor )
    6952                {
     53                        var collapserFn = CKEDITOR.tools.addFunction(
     54                                function( collapser )
     55                                {
     56                                        var toolbox = collapser.getPrevious();
     57                                        var contents = CKEDITOR.document.getById( 'cke_contents_' + editor.name );
     58                                        var topArea = CKEDITOR.document.getById( 'cke_top_' + editor.name );
     59                                        var contentHeight = parseInt( contents.$.style.height, 10 );
     60                                        var previousHeight = topArea.$.offsetHeight;
     61
     62                                        if ( toolbox.isVisible() )
     63                                        {
     64                                                toolbox.hide();
     65                                                collapser.addClass( 'cke_toolbox_collapser_min' );
     66                                        }
     67                                        else
     68                                        {
     69                                                toolbox.show();
     70                                                collapser.removeClass( 'cke_toolbox_collapser_min' );
     71                                        }
     72
     73                                        var dy = topArea.$.offsetHeight - previousHeight;
     74                                        contents.setStyle( 'height', ( contentHeight - dy ) + 'px' );
     75                                } );
     76
    7077                        var itemKeystroke = function( item, keystroke )
    7178                        {
    7279                                switch ( keystroke )
     
    276283        '/',
    277284        ['Styles','Format','Font','FontSize'],
    278285        ['TextColor','BGColor'],
    279         ['ShowBlocks','-','About']
     286        ['Maximize', 'ShowBlocks','-','About']
    280287];
    281288
    282289/**
  • _source/themes/default/theme.js

     
    163163                ( this._[ spacePrefix ] = CKEDITOR.document.getById( spacePrefix + '_' + this.name ) );
    164164        return space;
    165165};
     166
     167CKEDITOR.editor.prototype.resize = function( width, height, isContentHeight )
     168{
     169        var numberRegex = /^\d+$/;
     170        if ( numberRegex.test( width ) )
     171                width += 'px';
     172
     173        var contents = CKEDITOR.document.getById( 'cke_contents_' + this.name );
     174        var outer = contents.getAscendant( 'table' );
     175
     176        // Resize the width first.
     177        outer.setStyle( 'width', width );
     178
     179        // Get the height delta between the outer table and the content area.
     180        // If we're setting the content area's height, then we don't need the delta.
     181        var delta = isContentHeight ? 0 : ( outer.$.offsetHeight || 0 ) - ( contents.$.clientHeight || 0 );
     182       
     183        // Resize the height.
     184        contents.setStyle( 'height', ( height - delta ) + 'px' );
     185
     186        // Emit a resize event.
     187        this.fire( 'resize' );
     188};
  • _source/skins/office2003/icons.css

     
    301301{
    302302        background-position: 0 -736px;
    303303}
     304
     305.cke_skin_office2003 .cke_button_maximize .cke_icon
     306{
     307        background-position: 0 -1040px;
     308}
  • _source/skins/v2/icons.css

     
    301301{
    302302        background-position: 0 -736px;
    303303}
     304
     305.cke_skin_v2 .cke_button_maximize .cke_icon
     306{
     307        background-position: 0 -1040px;
     308}
  • _source/core/config.js

     
    150150         * config.plugins = 'basicstyles,button,htmldataprocessor,toolbar,wysiwygarea';
    151151         */
    152152
    153         plugins : 'about,basicstyles,blockquote,button,clipboard,colorbutton,contextmenu,elementspath,enterkey,entities,find,flash,font,format,forms,horizontalrule,htmldataprocessor,image,indent,justify,keystrokes,link,list,newpage,pagebreak,pastefromword,pastetext,preview,print,removeformat,save,smiley,showblocks,sourcearea,stylescombo,table,tabletools,specialchar,tab,templates,toolbar,undo,wysiwygarea,wsc',
     153        plugins : 'about,basicstyles,blockquote,button,clipboard,colorbutton,contextmenu,elementspath,enterkey,entities,find,flash,font,format,forms,horizontalrule,htmldataprocessor,image,indent,justify,keystrokes,link,list,maximize,newpage,pagebreak,pastefromword,pastetext,preview,print,removeformat,save,smiley,showblocks,sourcearea,stylescombo,table,tabletools,specialchar,tab,templates,toolbar,undo,wysiwygarea,wsc',
    154154
    155155        /**
    156156         * The editor tabindex value.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy