Ticket #4667: 4667.2.patch
File 4667.2.patch, 13.1 KB (added by , 13 years ago) |
---|
-
editor/_source/internals/fckscayt.js
28 28 ? true : false ; 29 29 var scaytEnable = false; 30 30 var scaytReady = false; 31 var savedID; 32 var uiTabs = []; 31 33 32 34 function ScaytEngineLoad( callback ) 33 35 { … … 41 43 { 42 44 window.scayt = top.scayt ; 43 45 InitScayt() ; 44 var ScaytCombobox = FCKToolbarItems.LoadedItems[ 'ScaytCombobox' ] ;45 ScaytCombobox && ScaytCombobox.SetEnabled( scyt_control && scyt_control.disabled ) ;46 46 InitSetup() ; 47 47 }; 48 48 … … 66 66 CKEDITOR._djScaytConfig = 67 67 { 68 68 baseUrl : scaytConfigBaseUrl, 69 initingScayt : false, // flag, if it is set to true, SCAYT files haven't been loaded yet 70 afterScaytInitQueue: [], // queue for loading few SCAYT instances 69 71 addOnLoad : function() 70 72 { 71 73 init(); 74 CKEDITOR._djScaytConfig.initingScayt=false; // SCAYT files were already loaded, first instance initialized 75 for ( var i = 0 ; i < CKEDITOR._djScaytConfig.afterScaytInitQueue.length ; i++ ) { // execute initializing of othe SCAYT instances in the queue 76 try { CKEDITOR._djScaytConfig.afterScaytInitQueue[i].call() ; } 77 catch(err) {} 78 } 79 CKEDITOR._djScaytConfig.afterScaytInitQueue=[]; 72 80 }, 73 81 isDebug : false 74 82 }; … … 77 85 if ( callback ) 78 86 scaytOnLoad.push( callback ) ; 79 87 88 CKEDITOR._djScaytConfig.initingScayt=true; // begin to load SCAYT files 80 89 DoLoadScript( scaytUrl ) ; 81 90 } 82 91 … … 110 119 var top = FCK.EditorWindow.parent.parent; 111 120 oParams.srcNodeRef = FCK.EditingArea.IFrame; // Get the iframe. 112 121 // syntax : AppName.AppVersion@AppRevision 113 //oParams.assocApp = "FCKEDITOR." + FCKeditorAPI.Varsion + "@" + FCKeditorAPI.VersionBuild; 114 oParams.customerid = FCK.Config.ScaytCustomerid ; 115 oParams.customDictionaryName = FCK.Config.ScaytCustomDictionaryName ; 116 oParams.userDictionaryName = FCK.Config.ScaytUserDictionaryName ; 117 oParams.defLang = FCK.Config.ScaytDefLang ; 118 122 oParams.assocApp = "FCKEDITOR." + FCKeditorAPI.Version + "@" + FCKeditorAPI.VersionBuild; 123 oParams.customerid = FCK.Config.ScaytCustomerid || '1:WvF0D4-UtPqN1-43nkD4-NKvUm2-daQqk3-LmNiI-z7Ysb4-mwry24-T8YrS3-Q2tpq2'; 124 oParams.userDictionaryName = FCK.Config.ScaytUserDictionaryName || ''; 125 oParams.customDictionaryIds = FCK.Config.ScaytCustomDictionaryIds || ''; 126 oParams.sLang = FCK.Config.ScaytsLang || FCK.Config.ScaytDefLang ; 127 128 if (savedID) { // Create a scayt_control with id specified if we already have one 129 oParams.id = savedID; 130 savedID = ""; 131 } 132 119 133 var scayt = top.scayt; 120 134 var scayt_control = window.scayt_control = new scayt( oParams ) ; 121 135 } … … 126 140 127 141 var scayt_control = window.scayt_control ; 128 142 129 if ( scayt_control)143 if ( typeof scayt_control != 'undefined' ) 130 144 { 131 145 scayt_control.setDisabled( false ) ; 132 146 scaytReady = true; 133 147 scaytEnable = !scayt_control.disabled ; 134 148 135 149 // set default scayt status 136 var ScaytCombobox = FCKToolbarItems. LoadedItems[ 'ScaytCombobox' ];137 ScaytCombobox && ScaytCombobox. Enable() ;150 var ScaytCombobox = FCKToolbarItems.GetItem( 'SpellCheck' ); 151 ScaytCombobox && ScaytCombobox.Command.Enable() ; 138 152 ShowScaytState() ; 139 } 153 154 FCKScayt.scayt_ui_tabs = uiTabs; 140 155 141 for ( var i = 0 ; i < scaytOnLoad.length ; i++ ) 142 { 143 try 156 for ( var i = 0 ; i < scaytOnLoad.length ; i++ ) 144 157 { 145 scaytOnLoad[i].call( this ) ; 158 try 159 { 160 scaytOnLoad[i].call( this ) ; 161 } 162 catch(err) 163 {} 146 164 } 147 catch(err)148 {}149 165 } 150 166 } 151 167 … … 162 178 { 163 179 case 'Options' : 164 180 case 'Langs' : 181 case 'Dictionary' : 165 182 case 'About' : 166 183 if ( isEngineLoaded && scaytReady && !scaytEnable ) 167 184 { … … 247 264 248 265 if ( scaytEnable ) 249 266 { 250 bItem.style.opacity = '1';267 setElementOpacity(bItem,1); 251 268 dNode.innerHTML = GetStatusLabel() ; 252 269 } 253 270 else 254 271 { 255 bItem.style.opacity = '0.5';272 setElementOpacity(bItem,0.5); 256 273 dNode.innerHTML = GetStatusLabel() ; 257 274 } 258 275 } … … 282 299 ToolbarScaytComboBox.prototype.CreateItems = function() 283 300 { 284 301 this._Combo.AddItem( 'Trigger', '<b>Enable SCAYT</b>' ); 285 this._Combo.AddItem( 'Options', FCKLang.ScaytTitleOptions || "Options" ); 286 this._Combo.AddItem( 'Langs', FCKLang.ScaytTitleLangs || "Languages"); 287 this._Combo.AddItem( 'About', FCKLang.ScaytTitleAbout || "About"); 302 if (uiTabs[0]) 303 this._Combo.AddItem( 'Options', FCKLang.ScaytTitleOptions || "Options" ); 304 if (uiTabs[1]) 305 this._Combo.AddItem( 'Langs', FCKLang.ScaytTitleLangs || "Languages"); 306 if (uiTabs[2]) 307 this._Combo.AddItem( 'Dictionary', FCKLang.ScaytTitleDict || "Dictionaries"); 308 this._Combo.AddItem( 'About', FCKLang.ScaytTitleAbout || "About"); 288 309 } 289 310 290 311 // Label shown in the toolbar. … … 334 355 } 335 356 } 336 357 } 358 359 // functions to set opacity of an element properly in all browsers 360 function setElementOpacity(elem, nOpacity) 361 { 362 var opacityProp = getOpacityProperty(); 363 364 if (!elem || !opacityProp) return; 365 366 if (opacityProp=="filter") // Internet Exploder 5.5+ 367 { 368 nOpacity *= 100; 369 370 var oAlpha = elem.filters['DXImageTransform.Microsoft.alpha'] || elem.filters.alpha; 371 if (oAlpha) oAlpha.opacity = nOpacity; 372 else elem.style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity="+nOpacity+")"; 373 } 374 else 375 elem.style[opacityProp] = nOpacity; 376 } 337 377 378 function getOpacityProperty() 379 { 380 if (typeof document.body.style.opacity == 'string') // CSS3 compliant (Moz 1.7+, Safari 1.2+, Opera 9) 381 return 'opacity'; 382 else if (typeof document.body.style.MozOpacity == 'string') // Mozilla 1.6, Firefox 0.8 383 return 'MozOpacity'; 384 else if (typeof document.body.style.KhtmlOpacity == 'string') // Konqueror 3.1, Safari 1.1 385 return 'KhtmlOpacity'; 386 else if (document.body.filters && navigator.appVersion.match(/MSIE ([\d.]+);/)[1]>=5.5) // Internet Exploder 5.5+ 387 return 'filter'; 388 389 return false; 390 } 391 338 392 // Register context menu listeners. 339 393 function InitSetup() 340 394 { … … 360 414 if ( !suggestions || !suggestions.length ) 361 415 return; 362 416 363 menu.AddSeparator() ;364 365 417 var maxSuggestions = FCK.Config.ScaytMaxSuggestions || 5 ; 366 418 var suggAveCount = ( maxSuggestions == -1 ) ? suggestions.length : maxSuggestions ; 419 var mmode = FCK.Config.ScaytContextCommands || 'all'; 420 421 mmode = mmode.split("|"); 422 mmode = { 423 all: false, 424 off: false, 425 asis: mmode, 426 isin: function(s){ 427 if (this.off) 428 return false; 429 if (this.all) 430 return true; 367 431 432 return this.is(s); 433 }, 434 is: function(s){ 435 for (var i = 0, l = this.asis.length; i < l; i++) { 436 if (this.asis[i] == s) return true; 437 } 438 return false; 439 } 440 }; 441 442 if (mmode.is("off")) { 443 mmode.off = true; 444 mmode.all = false; 445 } 446 if (mmode.is("all")) { 447 mmode.off = false; 448 mmode.all = true; 449 } 450 451 menu.AddSeparator() ; 452 368 453 for ( var i = 0 ; i < suggAveCount ; i += 1 ) 369 454 { 370 455 if ( suggestions[i] ) … … 376 461 } 377 462 } 378 463 379 menu.AddSeparator() ; 464 if (mmode.off !== true) { 465 menu.AddSeparator() ; 466 var o = {}; 467 o.node = node; 468 469 if (mmode.isin('add')) { 470 o.action = 'Add Word'; 471 menu.AddItem( 'ScaytContext', 'Add Word', null, false, o ); 472 } 473 if (mmode.isin('ignore')) { 474 o.action = 'Ignore'; 475 menu.AddItem( 'ScaytContext', 'Ignore', null, false, o ); 476 } 380 477 381 menu.AddItem( 'ScaytContext', 'Ignore', null, false, { 'action' : 'Ignore', 'node' : node } ); 382 menu.AddItem( 'ScaytContext', 'Ignore All', null, false, { 'action' : 'Ignore All', 'node' : node } ); 383 menu.AddItem( 'ScaytContext', 'Add Word', null, false, { 'action' : 'Add Word', 'node' : node } ); 478 if (mmode.isin('ignoreall')) { 479 o.action = 'Ignore All'; 480 menu.AddItem( 'ScaytContext', 'Ignore All', null, false, o ); 481 } 482 } 384 483 try 385 484 { 386 485 if (scaytReady && scaytEnable) … … 405 504 { 406 505 if ( FCKConfig.SpellChecker == 'SCAYT' ) 407 506 { 408 if ( !isEngineLoaded && FCK.Config.ScaytAutoStartup ) 409 ScaytEngineLoad() ; 507 // put loading other instances of FCKeditor into a queue until all SCAYT files will be loaded and SCAYT initialized 508 if (FCK.EditMode == FCK_EDITMODE_WYSIWYG && typeof(FCK.EditorWindow.parent.parent.window.CKEDITOR) != "undefined" && FCK.EditorWindow.parent.parent.window.CKEDITOR._djScaytConfig.initingScayt) { 509 FCK.EditorWindow.parent.parent.window.CKEDITOR._djScaytConfig.afterScaytInitQueue.push(function () { 510 if ( !isEngineLoaded && FCK.Config.ScaytAutoStartup ) 511 ScaytEngineLoad() ; 512 513 if ( FCK.EditMode == FCK_EDITMODE_WYSIWYG && isEngineLoaded && scaytReady ) { 514 createScaytControl(); 515 var scayt_control = window.scayt_control; 516 var agt = navigator.userAgent.toLowerCase(); 517 var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1)); 518 if (is_ie) { 519 scayt_control.disabled = !scaytEnable; 520 scaytEnable = !scayt_control.disabled; 521 } 522 else { 523 var ScaytCombobox = FCKToolbarItems.GetItem( 'SpellCheck' ); 524 ScaytCombobox && ScaytCombobox.Command.SetEnabled( scaytEnable ) ; 525 } 526 } 527 528 ShowScaytState() ; 529 }); 530 return; 531 } 532 else { 533 if ( !isEngineLoaded && FCK.Config.ScaytAutoStartup ) 534 ScaytEngineLoad() ; 535 536 if ( FCK.EditMode == FCK_EDITMODE_WYSIWYG && isEngineLoaded && scaytReady ) { 537 createScaytControl(); 538 var scayt_control = window.scayt_control; 539 //restore SCAYT state 540 var ScaytCombobox = FCKToolbarItems.GetItem( 'SpellCheck' ); 541 ScaytCombobox && ScaytCombobox.Command.SetEnabled( scaytEnable ) ; 542 } 410 543 411 if ( FCK.EditMode == FCK_EDITMODE_WYSIWYG && isEngineLoaded && scaytReady ) 412 createScaytControl(); 413 414 ShowScaytState() ; 544 ShowScaytState() ; 545 } 415 546 } 416 547 } ) ; 417 548 418 549 FCK.Events.AttachEvent( 'OnBeforeGetData', function() 419 550 { 420 scaytReady && window.scayt_control.reset(); 551 if (scaytReady) { 552 //save ID for restoring control in future, reset and destroy control when entering "Source mode" 553 savedID = window.scayt_control.id; 554 window.scayt_control.reset(); 555 window.scayt_control.destroy(true); 556 } 421 557 } ) ; 422 558 423 FCK.Events.AttachEvent( 'OnAfterGetData', function()424 {425 scaytReady && window.scayt_control.refresh();426 } ) ;427 428 559 // ### 429 560 // The main object that holds the SCAYT interaction in the code. 430 561 FCKScayt = … … 441 572 442 573 CreateToolbarItem : function() 443 574 { 444 return new ToolbarScaytComboBox() ; 575 var tabs = FCK.Config.ScaytUiTabs || "1,1,1"; 576 tabs = tabs.split(','); 577 578 for (var i=0,l=3; i<l; i++){ 579 uiTabs.push( parseInt(tabs[i],2) ); 580 } 581 uiTabs[uiTabs.length] = 1; 582 583 return new ToolbarScaytComboBox() ; 445 584 } 446 585 } ; 447 586 })() ; -
editor/dialog/fck_scayt.html
38 38 var fckLang; 39 39 var chosed_lang; 40 40 var options; 41 var tabs = scayt_control.uiTags || [1,1,0,1]; 41 var uiTabs = oEditor.FCKScayt.scayt_ui_tabs; 42 var tabs = uiTabs || scayt_control.uiTags; 42 43 var userDicActive = tabs[2] == 1; 43 44 var captions; 44 45 var dic_buttons = [ … … 286 287 if (!scayt) throw "SCAYT is undefined"; 287 288 if (!scayt_control) throw "SCAYT_CONTROL is undefined"; 288 289 289 // show alowed tabs290 tabs = scayt_control.uiTags || [1,1,1,0];291 292 293 290 sLang = scayt_control.getLang(); 294 291 fckLang = "en"; 295 292 options = scayt_control.option();