Ticket #5720: 5720_3.patch
File 5720_3.patch, 4.8 KB (added by , 14 years ago) |
---|
-
_source/plugins/scayt/plugin.js
11 11 (function() 12 12 { 13 13 var commandName = 'scaytcheck', 14 openPage = '', 15 scayt_paused = null, 16 scayt_control_id = null; 14 openPage = ''; 15 17 16 18 17 // Checks if a value exists in an array 19 18 function in_array(needle, haystack) … … 55 54 this.addStyle( this.selectorCss(), 'padding-bottom: 2px !important;' ); 56 55 57 56 // Call scayt_control.focus when SCAYT loaded 58 // and only if editor has focus 59 if ( editor.focusManager.hasFocus )57 // and only if editor has focus and scayt control creates at first time (5720 ticket) 58 if ( editor.focusManager.hasFocus && !plugin.isControlRestored( editor ) ) 60 59 this.focus(); 61 60 62 61 }; … … 76 75 } 77 76 } 78 77 // needs for restoring a specific scayt control settings 79 if ( scayt_control_id)80 oParams.id = scayt_control_id;78 if ( plugin.getControlId(editor) ) 79 oParams.id = plugin.getControlId(editor); 81 80 82 81 var scayt_control = new window.scayt( oParams ); 83 82 … … 107 106 108 107 plugin.uiTabs = fTabs; 109 108 try { 110 scayt_control.setDisabled( scayt_paused=== false );109 scayt_control.setDisabled( plugin.isPaused(editor) === false ); 111 110 } catch (e) {} 112 111 113 112 editor.fire( 'showScaytState' ); … … 139 138 var scayt_instance = plugin.getScayt( editor ); 140 139 if ( scayt_instance ) 141 140 { 142 scayt_paused = scayt_instance.paused = !scayt_instance.disabled;141 plugin.setPaused(editor,!scayt_instance.disabled); 143 142 // store a control id for restore a specific scayt control settings 144 scayt_control_id = scayt_instance.id;143 plugin.setControlId( editor , scayt_instance.id ); 145 144 scayt_instance.destroy( true ); 146 145 delete plugin.instances[ editor.name ]; 147 146 } 148 147 } 148 // Catch on source mode switch off (5720 ticket) 149 else if ( ev.data.name == 'source' && editor.mode == 'source' ) 150 { 151 plugin.markControlRestore( editor ) 152 } 149 153 }); 150 154 151 155 editor.on( 'afterCommandExec', function( ev ) … … 163 167 scayt_instance = plugin.getScayt( editor ); 164 168 delete plugin.instances[ editor.name ]; 165 169 // store a control id for restore a specific scayt control settings 166 scayt_control_id = scayt_instance.id;170 plugin.setControlId(editor, scayt_instance.id); 167 171 scayt_instance.destroy( true ); 168 172 }); 169 173 … … 276 280 if ( editor.document ) 277 281 createInstance(); 278 282 }; 279 280 283 284 CKEDITOR.plugins.scayt = 281 285 { 282 286 engineLoaded : false, 283 287 instances : {}, 288 // Data storage for SCAYT control, based on editor instances 289 controlInfo : {}, 290 setControlInfo : function( editor, o ){ 291 if ( editor && editor.name && typeof (this.controlInfo[editor.name]) != 'object' ) 292 this.controlInfo[editor.name] = {}; 293 294 for ( var infoOpt in o) 295 this.controlInfo[editor.name][infoOpt] = o[infoOpt]; 296 }, 297 isControlRestored : function ( editor ){ 298 if ( editor && 299 editor.name && 300 this.controlInfo[editor.name] ) 301 return this.controlInfo[editor.name].restored ; 302 return false; 303 }, 304 markControlRestore : function ( editor ){ 305 this.setControlInfo(editor,{restored:true}); 306 }, 307 setControlId: function (editor, id) 308 { 309 this.setControlInfo(editor,{id:id}); 310 }, 311 getControlId: function (editor) 312 { 313 if ( editor && 314 editor.name && 315 this.controlInfo[editor.name] && 316 this.controlInfo[editor.name].id ) 317 return this.controlInfo[editor.name].id 318 return null; 319 }, 320 setPaused: function ( editor , bool ) 321 { 322 this.setControlInfo(editor,{paused:bool}); 323 }, 324 isPaused: function (editor){ 325 if ( editor && 326 editor.name && 327 this.controlInfo[editor.name] ) 328 return this.controlInfo[editor.name].paused ; 329 return undefined; 330 }, 284 331 getScayt : function( editor ) 285 332 { 286 333 return this.instances[ editor.name ]; … … 297 344 }, 298 345 loadEngine : function( editor ) 299 346 { 347 300 348 // SCAYT doesn't work with Opera. 301 349 if ( CKEDITOR.env.opera ) 302 350 return editor.fire( 'showScaytState' ); … … 305 353 return onEngineLoad.apply( editor ); // Add new instance. 306 354 else if ( this.engineLoaded == -1 ) // We are waiting. 307 355 return CKEDITOR.on( 'scaytReady', function(){ onEngineLoad.apply( editor ); } ); // Use function(){} to avoid rejection as duplicate. 308 356 309 357 CKEDITOR.on( 'scaytReady', onEngineLoad, editor ); 310 358 CKEDITOR.on( 'scaytReady', function() 311 359 { … … 739 787 elementsPathFilters.push( scaytFilter ); 740 788 741 789 editor.addRemoveFormatFilter && editor.addRemoveFormatFilter( scaytFilter ); 742 790 743 791 } 744 792 }); 745 793 })();