Ticket #6438: 6438_2.patch

File 6438_2.patch, 2.5 KB (added by Garry Yao, 13 years ago)
  • _source/plugins/selection/plugin.js

     
    155155                                                        {
    156156                                                                // Enable selections to be saved.
    157157                                                                saveEnabled = 1;
    158 
    159                                                                 saveSelection();
    160158                                                        });
    161159
    162160                                                body.on( 'beforedeactivate', function( evt )
     
    166164                                                                if ( evt.data.$.toElement )
    167165                                                                        return;
    168166
     167                                                                saveSelection();
     168
    169169                                                                // Disable selections from being saved.
    170170                                                                saveEnabled = 0;
    171171                                                                restoreEnabled = 1;
     
    215215                                                        });
    216216                                                }
    217217
    218                                                 var scroll;
    219                                                 // IE fires the "selectionchange" event when clicking
    220                                                 // inside a selection. We don't want to capture that.
    221                                                 body.on( 'mousedown', function( evt )
    222                                                 {
    223                                                         // IE scrolls document to top on right mousedown
    224                                                         // when editor has no focus, remember this scroll
    225                                                         // position and revert it before context menu opens. (#5778)
    226                                                         if ( evt.data.$.button == 2 )
    227                                                         {
    228                                                                 var sel = editor.document.$.selection;
    229                                                                 if ( sel.type == 'None' )
    230                                                                         scroll = editor.window.getScrollPosition();
    231                                                         }
    232                                                         disableSave();
    233                                                 });
    234 
    235                                                 body.on( 'mouseup',
    236                                                         function( evt )
    237                                                         {
    238                                                                 // Restore recorded scroll position when needed on right mouseup.
    239                                                                 if ( evt.data.$.button == 2 && scroll )
    240                                                                 {
    241                                                                         editor.document.$.documentElement.scrollLeft = scroll.x;
    242                                                                         editor.document.$.documentElement.scrollTop = scroll.y;
    243                                                                 }
    244                                                                 scroll = null;
    245 
    246                                                                 saveEnabled = 1;
    247                                                                 setTimeout( function()
    248                                                                         {
    249                                                                                 saveSelection( true );
    250                                                                         },
    251                                                                         0 );
    252                                                         });
    253 
    254                                                 body.on( 'keydown', disableSave );
    255                                                 body.on( 'keyup',
    256                                                         function()
    257                                                         {
    258                                                                 saveEnabled = 1;
    259                                                                 saveSelection();
    260                                                         });
    261 
    262 
    263                                                 // IE is the only to provide the "selectionchange"
    264                                                 // event.
    265                                                 doc.on( 'selectionchange', saveSelection );
    266 
    267218                                                function disableSave()
    268219                                                {
    269220                                                        saveEnabled = 0;
     
    311262
    312263                                                                savedRange = nativeSel && sel.getRanges()[ 0 ];
    313264
    314                                                                 checkSelectionChangeTimeout.call( editor );
    315265                                                        }
    316266                                                }
     267
     268                                                // IE is the only to provide the "selectionchange" event.
     269                                                doc.on( 'selectionchange', checkSelectionChangeTimeout, editor );
    317270                                        }
    318271                                        else
    319272                                        {
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy