Ticket #4814: #4814.diff
File #4814.diff, 11.1 KB (added by , 14 years ago) |
---|
-
C:\www\home\spellclient.int\www\CKEditor
old new 12 12 { 13 13 var commandName = 'scaytcheck', 14 14 openPage = ''; 15 // Checks if a value exists in an array 16 function in_array(needle, haystack) 17 { 18 var found = false, key; 19 for (key in haystack) 20 { 21 if ((haystack[key] === needle) || ( haystack[key] == needle)) 22 { 23 found = true; 24 break; 25 } 26 } 27 return found; 28 } 15 29 16 30 var onEngineLoad = function() 17 31 { … … 24 38 oParams.srcNodeRef = editor.document.getWindow().$.frameElement; // Get the iframe. 25 39 // syntax : AppName.AppVersion@AppRevision 26 40 oParams.assocApp = "CKEDITOR." + CKEDITOR.version + "@" + CKEDITOR.revision; 27 28 oParams.customerid = editor.config.scayt_customerid || "1:11111111111111111111111111111111111111"; 29 oParams.customDictionaryName = editor.config.scayt_customDictionaryName; 41 oParams.customerid = editor.config.scayt_customerid || ""; 42 oParams.customDictionaryIds = editor.config.scayt_customDictionaryIds; 30 43 oParams.userDictionaryName = editor.config.scayt_userDictionaryName; 31 oParams. defLang = editor.scayt_defLang;44 oParams.sLang = editor.config.scayt_sLang || "en_US"; 32 45 33 46 if ( CKEDITOR._scaytParams ) 34 47 { … … 51 64 52 65 plugin.instances[ editor.name ] = scayt_control; 53 66 67 //window.scayt.uiTags 68 var menuGroup = 'scaytButton'; 69 var uiTabs = window.scayt.uiTags; 70 var fTabs = []; 71 72 for (var i = 0,l=4; i<l; i++) 73 fTabs.push( uiTabs[i] && plugin.uiTabs[i] ); 74 75 plugin.uiTabs = fTabs; 76 54 77 try { 55 scayt_control.setDisabled( scayt_control.paused === false ); // I really don't know why it causes JS error in IE78 scayt_control.setDisabled( scayt_control.paused === false ); 56 79 } catch (e) {} 57 80 editor.fire( 'showScaytState' ); 58 81 }; … … 90 113 } 91 114 }); 92 115 116 117 editor.on( 'destroy', function() 118 { 119 plugin.getScayt( editor ).destroy(); 120 }); 93 121 // Listen to data manipulation to reflect scayt markup. 94 122 editor.on( 'afterSetData', function() 95 123 { … … 116 144 } 117 145 }, this, null, 50 ); 118 146 147 editor.on( 'insertHtml', function() 148 { 149 150 var scayt_instance = plugin.getScayt( editor ); 151 if ( plugin.isScaytEnabled( editor ) ) 152 { 153 // Unlock the selection before reload, SCAYT will take 154 // care selection update. 155 if ( CKEDITOR.env.ie ) 156 editor.getSelection().unlock( true ); 157 158 // Swallow any SCAYT engine errors. 159 try{ 160 scayt_instance.refresh(); 161 }catch( er ) 162 {} 163 } 164 }, this, null, 50 ); 165 166 167 119 168 editor.on( 'scaytDialog', function( ev ) // Communication with dialog. 120 169 { 121 170 ev.data.djConfig = window.djConfig; … … 300 349 301 350 // Add Options dialog. 302 351 CKEDITOR.dialog.add( commandName, CKEDITOR.getUrl( this.path + 'dialogs/options.js' ) ); 352 // read ui tags 353 var confuiTabs = editor.config.scayt_uiTabs || "1,1,1"; 354 var uiTabs =[]; 355 // string tp array convert 356 confuiTabs = confuiTabs.split(","); 357 // check array length ! allwaays must be 3 filled with 1 or 0 358 for (var i=0,l=3; i<l; i++){ 359 var flag = parseInt(confuiTabs[i] || "1" ,10); 360 uiTabs.push( flag ); 361 } 362 303 363 304 364 var menuGroup = 'scaytButton'; 305 365 editor.addMenuGroup( menuGroup ); 306 editor.addMenuItems( 307 { 308 scaytToggle : 366 // combine menu items to render 367 var uiMuneItems = {}; 368 369 // allways added 370 uiMuneItems.scaytToggle = 309 371 { 310 372 label : editor.lang.scayt.enable, 311 373 command : commandName, 312 374 group : menuGroup 313 },375 }; 314 376 315 scaytOptions : 377 if (uiTabs[0] == 1) 378 uiMuneItems.scaytOptions = 316 379 { 317 380 label : editor.lang.scayt.options, 318 381 group : menuGroup, … … 321 384 openPage = 'options'; 322 385 editor.openDialog( commandName ); 323 386 } 324 },387 }; 325 388 326 scaytLangs : 389 if (uiTabs[1] == 1) 390 uiMuneItems.scaytLangs = 327 391 { 328 392 label : editor.lang.scayt.langs, 329 393 group : menuGroup, … … 332 396 openPage = 'langs'; 333 397 editor.openDialog( commandName ); 334 398 } 335 }, 336 337 scaytAbout : 399 }; 400 if (uiTabs[2] == 1) 401 uiMuneItems.scaytDict = 402 { 403 label : editor.lang.scayt.dictionariesTab, 404 group : menuGroup, 405 onClick : function() 406 { 407 openPage = 'dictionaries'; 408 editor.openDialog( commandName ); 409 } 410 }; 411 // allways added 412 uiMuneItems.scaytAbout = 338 413 { 339 414 label : editor.lang.scayt.about, 340 415 group : menuGroup, … … 344 419 editor.openDialog( commandName ); 345 420 } 346 421 } 347 }); 422 ; 423 424 uiTabs[3] = 1; // about us tab is allways on 425 plugin.uiTabs = uiTabs; 426 427 editor.addMenuItems( uiMuneItems ); 348 428 349 429 editor.ui.add( 'Scayt', CKEDITOR.UI_MENUBUTTON, 350 430 { … … 358 438 this.setState( command.state ); 359 439 }, 360 440 this); 441 361 442 }, 362 443 onMenu : function() 363 444 { … … 367 448 368 449 return { 369 450 scaytToggle : CKEDITOR.TRISTATE_OFF, 370 scaytOptions : isEnabled ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED, 371 scaytLangs : isEnabled ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED, 372 scaytAbout : isEnabled ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED 451 scaytOptions : isEnabled && plugin.uiTabs[0] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED, 452 scaytLangs : isEnabled && plugin.uiTabs[1] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED, 453 scaytDict : isEnabled && plugin.uiTabs[2] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED, 454 scaytAbout : isEnabled && plugin.uiTabs[3] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED 373 455 }; 374 456 } 375 457 }); … … 379 461 { 380 462 editor.contextMenu.addListener( function( element ) 381 463 { 464 382 465 if ( !( plugin.isScaytEnabled( editor ) && element ) ) 383 466 return null; 384 467 … … 394 477 if (!items_suggestion || !items_suggestion.length ) 395 478 return null; 396 479 // Remove unused commands and menuitems 480 397 481 for ( i in moreSuggestions ) 398 482 { 399 483 delete editor._.menuItems[ i ]; … … 407 491 moreSuggestions = {}; // Reset items. 408 492 mainSuggestions = {}; 409 493 410 var moreSuggestionsUnable = false; 494 var moreSuggestionsUnable = editor.config.scayt_moreSuggestions || "on"; 495 var moreSuggestionsUnableAdded = false; 496 var maxSuggestions = ( editor.config.scayt_maxSuggestions <= 0) 497 ? items_suggestion.length 498 : editor.config.scayt_maxSuggestions; 499 var contextCommands = editor.config.scayt_contextCommands || "all"; 500 contextCommands = contextCommands.split("|"); 411 501 412 502 for ( var i = 0, l = items_suggestion.length; i < l; i += 1 ) 413 503 { … … 422 512 }; 423 513 })( element.$, items_suggestion[i] ); 424 514 425 if ( i < editor.config.scayt_maxSuggestions )515 if ( i < maxSuggestions ) 426 516 { 427 517 addButtonCommand( editor, 'button_' + commandName, items_suggestion[i], 428 518 commandName, exec, 'scayt_suggest', i + 1 ); 429 519 _r[ commandName ] = CKEDITOR.TRISTATE_OFF; 430 520 mainSuggestions[ commandName ] = CKEDITOR.TRISTATE_OFF; 431 521 } 432 else 522 else if ( moreSuggestionsUnable == "on" ) 433 523 { 524 434 525 addButtonCommand( editor, 'button_' + commandName, items_suggestion[i], 435 526 commandName, exec, 'scayt_moresuggest', i + 1 ); 436 527 moreSuggestions[ commandName ] = CKEDITOR.TRISTATE_OFF; 437 moreSuggestionsUnable = true; 528 moreSuggestionsUnableAdded = true; 529 530 531 532 438 533 } 439 534 } 440 if ( moreSuggestionsUnable ) 535 536 if ( moreSuggestionsUnableAdded ){ 441 537 // Rgister the More suggestions group; 442 538 editor.addMenuItem( 'scayt_moresuggest', 443 539 { … … 449 545 return moreSuggestions; 450 546 } 451 547 }); 548 mainSuggestions[ 'scayt_moresuggest' ] = CKEDITOR.TRISTATE_OFF; 452 549 550 } 453 551 454 var ignore_command = 455 {456 exec: function()552 553 554 if ( in_array( "all",contextCommands ) || in_array("ignore",contextCommands) ) 457 555 { 556 var ignore_command = { 557 exec: function(){ 458 558 scayt_control.ignore( element.$ ); 459 559 } 460 560 }; 461 var ignore_all_command = 462 { 463 exec: function() 561 addButtonCommand(editor, 'ignore', editor.lang.scayt.ignore, 'scayt_ignore', ignore_command, 'scayt_control', 1); 562 mainSuggestions['scayt_ignore'] = CKEDITOR.TRISTATE_OFF; 563 } 564 565 if ( in_array( "all",contextCommands ) || in_array("ignoreall",contextCommands) ) 464 566 { 567 var ignore_all_command = { 568 exec: function(){ 465 569 scayt_control.ignoreAll( element.$ ); 466 570 } 467 571 }; 468 var addword_command = 469 { 470 exec: function() 572 addButtonCommand(editor, 'ignore_all', editor.lang.scayt.ignoreAll, 'scayt_ignore_all', ignore_all_command, 'scayt_control', 2); 573 mainSuggestions['scayt_ignore_all'] = CKEDITOR.TRISTATE_OFF; 574 } 575 576 if ( in_array( "all",contextCommands ) || in_array("add",contextCommands) ) 471 577 { 578 var addword_command = { 579 exec: function(){ 472 580 window.scayt.addWordToUserDictionary( element.$ ); 473 581 } 474 582 }; 475 476 addButtonCommand( editor, 'ignore', editor.lang.scayt.ignore, 477 'scayt_ignore', ignore_command, 'scayt_control', 1); 478 addButtonCommand( editor, 'ignore_all', editor.lang.scayt.ignoreAll, 479 'scayt_ignore_all', ignore_all_command, 'scayt_control', 2); 480 addButtonCommand( editor, 'add_word', editor.lang.scayt.addWord, 481 'scayt_add_word', addword_command, 'scayt_control', 3); 482 483 mainSuggestions[ 'scayt_moresuggest' ] = CKEDITOR.TRISTATE_OFF; 484 mainSuggestions[ 'scayt_ignore' ] = CKEDITOR.TRISTATE_OFF; 485 mainSuggestions[ 'scayt_ignore_all' ] = CKEDITOR.TRISTATE_OFF; 583 addButtonCommand(editor, 'add_word', editor.lang.scayt.addWord, 'scayt_add_word', addword_command, 'scayt_control', 3); 486 584 mainSuggestions[ 'scayt_add_word' ] = CKEDITOR.TRISTATE_OFF; 585 } 487 586 488 587 if ( scayt_control.fireOnContextMenu ) 489 588 scayt_control.fireOnContextMenu( editor ); … … 507 606 } 508 607 }); 509 608 })(); 510 511 CKEDITOR.config.scayt_maxSuggestions = 5; 512 CKEDITOR.config.scayt_autoStartup = false; 609 CKEDITOR.config.scayt_maxSuggestions = CKEDITOR.config.scayt_maxSuggestions || 5; 610 CKEDITOR.config.scayt_autoStartup = (typeof CKEDITOR.config.scayt_autoStartup !== 'undefined') ? CKEDITOR.config.scayt_autoStartup : false;