Ticket #3028: 3028_heavy.patch

File 3028_heavy.patch, 5.7 KB (added by Artur Formella, 14 years ago)
  • _source/plugins/editingblock/plugin.js

     
    4040                        editor.on( 'uiReady', function()
    4141                                {
    4242                                        editor.setMode( editor.config.startupMode );
    43 
    44                                         if ( editor.config.startupFocus )
    45                                                 editor.focus();
    4643                                });
    4744
    4845                        editor.on( 'afterSetData', function()
     
    9895                                        // Do that once only.
    9996                                        event.removeListener();
    10097
     98                                        if ( editor.config.startupFocus )
     99                                                editor.focus();
     100
    101101                                        // Grab editor focus if the editor container is focused. (#3104)
    102102                                        editor.container.on( 'focus', function()
    103103                                                {
    104104                                                        editor.focus();
    105105                                                });
    106106
     107                                        if ( editor.config.onLoad )
     108                                                editor.config.onLoad( editor );
     109
    107110                                        // Fire instanceReady for both the editor and CKEDITOR.
    108111                                        editor.fireOnce( 'instanceReady' );
    109112                                        CKEDITOR.fire( 'instanceReady', null, editor );
  • _source/plugins/sourcearea/plugin.js

     
    1818
    1919                editor.on( 'editingBlockReady', function()
    2020                        {
    21                                 var textarea;
     21                                var textarea,
     22                                        checkFocusTimes = editor.config.startupMode == 'source' ? 10 : 0;               // Check startup focus 10 times.
    2223
    2324                                editor.addMode( 'source',
    2425                                        {
     
    7374                                                        // Set the <textarea> value.
    7475                                                        this.loadData( data );
    7576
    76                                                         var keystrokeHandler = editor.keystrokeHandler;
    77                                                         if ( keystrokeHandler )
    78                                                                 keystrokeHandler.attach( textarea );
     77                                                        var addHandlers = function( )
     78                                                        {
     79                                                                textarea.on( 'blur', function()
     80                                                                        {
     81                                                                                editor.focusManager.blur();
     82                                                                        });
    7983
    80                                                         editor.mode = 'source';
    81                                                         editor.fire( 'mode' );
     84                                                                textarea.on( 'focus', function()
     85                                                                        {
     86                                                                                editor.focusManager.focus();
     87                                                                        } );
     88                                                        }
     89                                                        if ( CKEDITOR.env.ie )
     90                                                                addHandlers();
     91                                                       
     92                                                        var textareaReady = function()
     93                                                        {
     94                                                                var keystrokeHandler = editor.keystrokeHandler;
     95                                                                if ( keystrokeHandler )
     96                                                                        keystrokeHandler.attach( textarea );
     97
     98                                                                if ( !CKEDITOR.env.ie )
     99                                                                        addHandlers();
     100
     101                                                                editor.mode = 'source';
     102                                                                editor.fire( 'mode' );
     103                                                        };
     104
     105                                                        if ( checkFocusTimes > 0 )              // Only once, if startupFocus is set.
     106                                                        {
     107                                                                // Check if the startup focus was set. If so - fire 'mode' event.
     108                                                                var checkFocus = function()
     109                                                                {
     110                                                                        if ( checkFocusTimes <= 0 || !editor.config.startupFocus )              // Element is ready
     111                                                                        {
     112                                                                                textarea.$.blur();              // Startup focus is set in 'mode' listener.
     113                                                                                textareaReady();
     114                                                                        }
     115                                                                        else
     116                                                                        {
     117                                                                                try     {textarea.$.focus();}catch ( e ){}                      // Use 'try' due to IE bug.
     118
     119                                                                                checkFocusTimes--;
     120                                                                                setTimeout( checkFocus,  200 );
     121                                                                        }
     122                                                                };
     123
     124                                                                textarea.on( 'focus', function( event )
     125                                                                {
     126                                                                        checkFocusTimes = 0;
     127                                                                        event.removeListener();
     128                                                                }, textarea );
     129
     130                                                                checkFocus();
     131                                                        }
     132                                                        else
     133                                                                textareaReady();
    82134                                                },
    83135
    84136                                                loadData : function( data )
  • _source/plugins/wysiwygarea/plugin.js

     
    102102                                                iframe,
    103103                                                isLoadingData,
    104104                                                isPendingFocus,
    105                                                 fireMode;
     105                                                fireMode,
     106                                                checkFocusTimes = editor.config.startupMode == 'wysiwyg' ? 10 : 0;              // Check startup focus 10 times.
    106107
    107108                                        // The following information is needed for IE only.
    108109                                        var isCustomDomain = CKEDITOR.env.ie && document.domain != window.location.hostname;
     
    224225                                                domWindow       = editor.window         = new CKEDITOR.dom.window( domWindow );
    225226                                                domDocument     = editor.document       = new CKEDITOR.dom.document( domDocument );
    226227
    227                                                 var focusTarget = ( CKEDITOR.env.ie || CKEDITOR.env.safari ) ?
     228                                                var focusTarget = ( CKEDITOR.env.ie || CKEDITOR.env.webkit ) ?
    228229                                                                domWindow : domDocument;
    229230
    230231                                                focusTarget.on( 'blur', function()
     
    247248                                                if ( editor.contextMenu )
    248249                                                        editor.contextMenu.addTarget( domDocument );
    249250
    250                                                 if ( fireMode )
     251                                                isLoadingData = false;
     252
     253                                                var documentReady = function()
    251254                                                {
    252                                                         editor.mode = 'wysiwyg';
    253                                                         editor.fire( 'mode' );
    254                                                         fireMode = false;
    255                                                 }
     255                                                        if ( fireMode )
     256                                                        {
     257                                                                editor.mode = 'wysiwyg';
     258                                                                editor.fire( 'mode' );
     259                                                                fireMode = false;
     260                                                        }
    256261
    257                                                 isLoadingData = false;
     262                                                        if ( isPendingFocus )
     263                                                                editor.focus();
     264                                                };
     265       
     266                                                if ( editor.config.startupFocus && ( CKEDITOR.env.ie || CKEDITOR.env.opera ) && checkFocusTimes > 0 )
     267                                                {
     268                                                        // #3028. Check if the startup focus was set. If so - element is ready.
     269                                                        var checkFocus = function()
     270                                                        {
     271                                                                if ( checkFocusTimes <= 0 )
     272                                                                        documentReady();
     273                                                                else
     274                                                                {
     275                                                                        editor.window.focus();
     276                                                                        checkFocusTimes--;
     277                                                                        setTimeout( checkFocus, 200 );
     278                                                                }
     279                                                        };
    258280
    259                                                 if ( isPendingFocus )
    260                                                         editor.focus();
     281                                                        focusTarget.on( 'focus', function( event )
     282                                                        {
     283                                                                checkFocusTimes = 0;
     284                                                                event.removeListener();
     285                                                        }, focusTarget );
     286
     287                                                        checkFocus();
     288                                                }
     289                                                else
     290                                                        documentReady();
    261291                                        };
    262292
    263293                                        editor.addMode( 'wysiwyg',
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy