Ticket #4667: 4667.patch
File 4667.patch, 13.3 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 for ( i=0, l = uiTabs.length; i<l ; i ++){ 155 uiTabs[i] = uiTabs[i] && scayt.uiTags[i]; 156 } 140 157 141 for ( var i = 0 ; i < scaytOnLoad.length ; i++ )142 { 143 try158 FCKScayt.scayt_ui_tabs = uiTabs; 159 160 for ( var i = 0 ; i < scaytOnLoad.length ; i++ ) 144 161 { 145 scaytOnLoad[i].call( this ) ; 162 try 163 { 164 scaytOnLoad[i].call( this ) ; 165 } 166 catch(err) 167 {} 146 168 } 147 catch(err)148 {}149 169 } 150 170 } 151 171 … … 162 182 { 163 183 case 'Options' : 164 184 case 'Langs' : 185 case 'Dictionary' : 165 186 case 'About' : 166 187 if ( isEngineLoaded && scaytReady && !scaytEnable ) 167 188 { … … 247 268 248 269 if ( scaytEnable ) 249 270 { 250 bItem.style.opacity = '1';271 setElementOpacity(bItem,1); 251 272 dNode.innerHTML = GetStatusLabel() ; 252 273 } 253 274 else 254 275 { 255 bItem.style.opacity = '0.5';276 setElementOpacity(bItem,0.5); 256 277 dNode.innerHTML = GetStatusLabel() ; 257 278 } 258 279 } … … 282 303 ToolbarScaytComboBox.prototype.CreateItems = function() 283 304 { 284 305 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"); 306 if (uiTabs[0]) 307 this._Combo.AddItem( 'Options', FCKLang.ScaytTitleOptions || "Options" ); 308 if (uiTabs[1]) 309 this._Combo.AddItem( 'Langs', FCKLang.ScaytTitleLangs || "Languages"); 310 if (uiTabs[2]) 311 this._Combo.AddItem( 'Dictionary', FCKLang.ScaytTitleDict || "Dictionaries"); 312 this._Combo.AddItem( 'About', FCKLang.ScaytTitleAbout || "About"); 288 313 } 289 314 290 315 // Label shown in the toolbar. … … 334 359 } 335 360 } 336 361 } 362 363 // functions to set opacity of an element properly in all browsers 364 function setElementOpacity(elem, nOpacity) 365 { 366 var opacityProp = getOpacityProperty(); 367 368 if (!elem || !opacityProp) return; 369 370 if (opacityProp=="filter") // Internet Exploder 5.5+ 371 { 372 nOpacity *= 100; 373 374 var oAlpha = elem.filters['DXImageTransform.Microsoft.alpha'] || elem.filters.alpha; 375 if (oAlpha) oAlpha.opacity = nOpacity; 376 else elem.style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity="+nOpacity+")"; 377 } 378 else 379 elem.style[opacityProp] = nOpacity; 380 } 337 381 382 function getOpacityProperty() 383 { 384 if (typeof document.body.style.opacity == 'string') // CSS3 compliant (Moz 1.7+, Safari 1.2+, Opera 9) 385 return 'opacity'; 386 else if (typeof document.body.style.MozOpacity == 'string') // Mozilla 1.6, Firefox 0.8 387 return 'MozOpacity'; 388 else if (typeof document.body.style.KhtmlOpacity == 'string') // Konqueror 3.1, Safari 1.1 389 return 'KhtmlOpacity'; 390 else if (document.body.filters && navigator.appVersion.match(/MSIE ([\d.]+);/)[1]>=5.5) // Internet Exploder 5.5+ 391 return 'filter'; 392 393 return false; 394 } 395 338 396 // Register context menu listeners. 339 397 function InitSetup() 340 398 { … … 360 418 if ( !suggestions || !suggestions.length ) 361 419 return; 362 420 363 menu.AddSeparator() ;364 365 421 var maxSuggestions = FCK.Config.ScaytMaxSuggestions || 5 ; 366 422 var suggAveCount = ( maxSuggestions == -1 ) ? suggestions.length : maxSuggestions ; 423 var mmode = FCK.Config.ScaytContextCommands || 'all'; 424 425 mmode = mmode.split("|"); 426 mmode = { 427 all: false, 428 off: false, 429 asis: mmode, 430 isin: function(s){ 431 if (this.off) 432 return false; 433 if (this.all) 434 return true; 367 435 436 return this.is(s); 437 }, 438 is: function(s){ 439 for (var i = 0, l = this.asis.length; i < l; i++) 440 if (this.asis[i] == s) 441 return true; 442 return false; 443 } 444 }; 445 446 if (mmode.is("off")) { 447 mmode.off = true; 448 mmode.all = false; 449 } 450 if (mmode.is("all")) { 451 mmode.off = false; 452 mmode.all = true; 453 } 454 455 menu.AddSeparator() ; 456 368 457 for ( var i = 0 ; i < suggAveCount ; i += 1 ) 369 458 { 370 459 if ( suggestions[i] ) … … 376 465 } 377 466 } 378 467 379 menu.AddSeparator() ; 468 if (mmode.off !== true) { 469 menu.AddSeparator() ; 470 var o = {}; 471 o.node = node; 472 473 if (mmode.isin('add')) { 474 o.action = 'Add Word'; 475 menu.AddItem( 'ScaytContext', 'Add Word', null, false, o ); 476 } 477 if (mmode.isin('ignore')) { 478 o.action = 'Ignore'; 479 menu.AddItem( 'ScaytContext', 'Ignore', null, false, o ); 480 } 380 481 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 } ); 482 if (mmode.isin('ignoreall')) { 483 o.action = 'Ignore All'; 484 menu.AddItem( 'ScaytContext', 'Ignore All', null, false, o ); 485 } 486 } 384 487 try 385 488 { 386 489 if (scaytReady && scaytEnable) … … 405 508 { 406 509 if ( FCKConfig.SpellChecker == 'SCAYT' ) 407 510 { 408 if ( !isEngineLoaded && FCK.Config.ScaytAutoStartup ) 409 ScaytEngineLoad() ; 511 // put loading other instances of FCKeditor into a queue until all SCAYT files will be loaded and SCAYT initialized 512 if (FCK.EditMode == FCK_EDITMODE_WYSIWYG && typeof(FCK.EditorWindow.parent.parent.window.CKEDITOR) != "undefined" && FCK.EditorWindow.parent.parent.window.CKEDITOR._djScaytConfig.initingScayt) { 513 FCK.EditorWindow.parent.parent.window.CKEDITOR._djScaytConfig.afterScaytInitQueue.push(function () { 514 if ( !isEngineLoaded && FCK.Config.ScaytAutoStartup ) 515 ScaytEngineLoad() ; 516 517 if ( FCK.EditMode == FCK_EDITMODE_WYSIWYG && isEngineLoaded && scaytReady ) { 518 createScaytControl(); 519 var scayt_control = window.scayt_control; 520 var agt = navigator.userAgent.toLowerCase(); 521 var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1)); 522 if (is_ie) { 523 scayt_control.disabled = !scaytEnable; 524 scaytEnable = !scayt_control.disabled; 525 } 526 else { 527 var ScaytCombobox = FCKToolbarItems.GetItem( 'SpellCheck' ); 528 ScaytCombobox && ScaytCombobox.Command.SetEnabled( scaytEnable ) ; 529 } 530 } 531 532 ShowScaytState() ; 533 }); 534 return; 535 } 536 else { 537 if ( !isEngineLoaded && FCK.Config.ScaytAutoStartup ) 538 ScaytEngineLoad() ; 539 540 if ( FCK.EditMode == FCK_EDITMODE_WYSIWYG && isEngineLoaded && scaytReady ) { 541 createScaytControl(); 542 var scayt_control = window.scayt_control; 543 //restore SCAYT state 544 var agt = navigator.userAgent.toLowerCase(); 545 var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1)); 546 //needs this trick to work in IE 547 if (is_ie) { 548 scayt_control.disabled = !scaytEnable; 549 scaytEnable = !scayt_control.disabled; 550 } 551 else { 552 var ScaytCombobox = FCKToolbarItems.GetItem( 'SpellCheck' ); 553 ScaytCombobox && ScaytCombobox.Command.SetEnabled( scaytEnable ) ; 554 } 555 } 410 556 411 if ( FCK.EditMode == FCK_EDITMODE_WYSIWYG && isEngineLoaded && scaytReady ) 412 createScaytControl(); 413 414 ShowScaytState() ; 557 ShowScaytState() ; 558 } 415 559 } 416 560 } ) ; 417 561 418 562 FCK.Events.AttachEvent( 'OnBeforeGetData', function() 419 563 { 420 scaytReady && window.scayt_control.reset(); 564 if (scaytReady) { 565 //save ID for restoring control in future, reset and destroy control when entering "Source mode" 566 savedID = window.scayt_control.id; 567 window.scayt_control.reset(); 568 window.scayt_control.destroy(true); 569 } 421 570 } ) ; 422 571 423 FCK.Events.AttachEvent( 'OnAfterGetData', function()424 {425 scaytReady && window.scayt_control.refresh();426 } ) ;427 428 572 // ### 429 573 // The main object that holds the SCAYT interaction in the code. 430 574 FCKScayt = … … 441 585 442 586 CreateToolbarItem : function() 443 587 { 444 return new ToolbarScaytComboBox() ; 588 var tabs = FCK.Config.ScaytUiTabs || "1,1,1"; 589 tabs = tabs.split(','); 590 591 for (var i=0,l=3; i<l; i++){ 592 var flag = parseInt(tabs[i] || "1"); 593 uiTabs.push( flag ); 594 } 595 uiTabs[uiTabs.length] = 1; 596 597 return new ToolbarScaytComboBox() ; 445 598 } 446 599 } ; 447 600 })() ; -
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 || [1,1,1,1]; 42 43 var userDicActive = tabs[2] == 1; 43 44 var captions; 44 45 var dic_buttons = [