Ticket #5145: 5145_7.patch
File 5145_7.patch, 11.6 KB (added by , 13 years ago) |
---|
-
_source/plugins/scayt/plugin.js
10 10 11 11 (function() 12 12 { 13 13 14 var commandName = 'scaytcheck', 14 15 openPage = '', 15 scayt_paused = null; 16 scayt_paused = null, 17 scayt_control_id = null; 16 18 17 19 // Checks if a value exists in an array 18 20 function in_array(needle, haystack) … … 37 39 { 38 40 // Initialise Scayt instance. 39 41 var oParams = {}; 40 oParams.srcNodeRef = editor.document.getWindow().$.frameElement; // Get the iframe. 42 // Get the iframe. 43 oParams.srcNodeRef = editor.document.getWindow().$.frameElement; 41 44 // syntax : AppName.AppVersion@AppRevision 42 45 oParams.assocApp = "CKEDITOR." + CKEDITOR.version + "@" + CKEDITOR.revision; 43 46 oParams.customerid = editor.config.scayt_customerid || "1:WvF0D4-UtPqN1-43nkD4-NKvUm2-daQqk3-LmNiI-z7Ysb4-mwry24-T8YrS3-Q2tpq2"; 44 oParams.customDictionaryIds = editor.config.scayt_customDictionaryIds ;45 oParams.userDictionaryName = editor.config.scayt_userDictionaryName ;47 oParams.customDictionaryIds = editor.config.scayt_customDictionaryIds || ''; 48 oParams.userDictionaryName = editor.config.scayt_userDictionaryName || ''; 46 49 oParams.sLang = editor.config.scayt_sLang || "en_US"; 47 48 if ( CKEDITOR._ scaytParams )50 51 if ( CKEDITOR._.scaytParams ) 49 52 { 50 for ( var k in CKEDITOR._ scaytParams )53 for ( var k in CKEDITOR._.scaytParams ) 51 54 { 52 oParams[ k ] = CKEDITOR._ scaytParams[ k ];55 oParams[ k ] = CKEDITOR._.scaytParams[ k ]; 53 56 } 54 57 } 55 58 59 if ( scayt_control_id ) 60 oParams.id = scayt_control_id; 61 56 62 var scayt_control = new window.scayt( oParams ); 57 63 58 64 // Copy config. … … 72 78 var fTabs = []; 73 79 74 80 for (var i = 0,l=4; i<l; i++) 75 81 fTabs.push( uiTabs[i] && plugin.uiTabs[i] ); 76 82 77 83 plugin.uiTabs = fTabs; 78 84 try { … … 109 115 if ( scayt_instanse ) 110 116 { 111 117 scayt_paused = scayt_instanse.paused = !scayt_instanse.disabled; 112 scayt_instanse.destroy(); 113 delete plugin.instances[ editor.name ]; 118 scayt_control_id = scayt_instanse.id; 119 scayt_instanse.destroy(true); 120 delete plugin.instances[editor.name]; 114 121 } 115 122 } 116 123 }); … … 118 125 119 126 editor.on( 'destroy', function() 120 127 { 121 plugin.getScayt( editor ).destroy(); 128 scayt_control_id = scayt_instanse.id; 129 plugin.getScayt( editor ).destroy(true); 122 130 }); 123 131 // Listen to data manipulation to reflect scayt markup. 124 132 editor.on( 'afterSetData', function() 125 133 { 126 if ( plugin.isScaytEnabled( editor ) ) 127 plugin.getScayt( editor ).refresh(); 134 if (plugin.isScaytEnabled(editor)) { 135 window.setTimeout(function(){plugin.getScayt(editor).refresh()},10); 136 } 128 137 }); 129 138 130 139 // Reload spell-checking for current word after insertion completed. … … 139 148 editor.getSelection().unlock( true ); 140 149 141 150 // Swallow any SCAYT engine errors. 142 try{ 143 scayt_instance.refresh(); 144 }catch( er ) 145 {} 151 window.setTimeout(function(){scayt_instance.refresh()},10); 152 146 153 } 147 154 }, this, null, 50 ); 148 155 … … 158 165 editor.getSelection().unlock( true ); 159 166 160 167 // Swallow any SCAYT engine errors. 161 try{ 162 scayt_instance.refresh(); 163 }catch( er ) 164 {} 168 169 window.setTimeout(function(){scayt_instance.refresh()},10); 170 165 171 } 166 172 }, this, null, 50 ); 167 173 … … 218 224 }, 219 225 loadEngine : function( editor ) 220 226 { 227 if (CKEDITOR.env.opera) 228 return; 221 229 if ( this.engineLoaded === true ) 222 230 return onEngineLoad.apply( editor ); // Add new instance. 223 231 else if ( this.engineLoaded == -1 ) // We are waiting. … … 230 238 }, 231 239 this, 232 240 null, 233 0 ); // First to run. 241 0 242 ); // First to run. 234 243 235 244 this.engineLoaded = -1; // Loading in progress. 236 245 … … 238 247 var protocol = document.location.protocol; 239 248 // Default to 'http' for unknown. 240 249 protocol = protocol.search( /https?:/) != -1? protocol : 'http:'; 241 var baseUrl = "svc.spellchecker.net/spellcheck3 /lf/scayt/scayt21.js";250 var baseUrl = "svc.spellchecker.net/spellcheck31/lf/scayt/scayt22.js"; 242 251 243 252 var scaytUrl = editor.config.scayt_srcUrl || ( protocol + "//" + baseUrl ); 244 253 var scaytConfigBaseUrl = plugin.parseUrl( scaytUrl ).path + "/"; … … 355 364 // string tp array convert 356 365 confuiTabs = confuiTabs.split(","); 357 366 // check array length ! allwaays must be 3 filled with 1 or 0 358 for (var i=0,l=3; i<l; i++){ 367 for (var i=0,l=3; i<l; i++) 368 { 359 369 var flag = parseInt(confuiTabs[i] || "1" ,10); 360 370 uiTabs.push( flag ); 361 371 } … … 457 467 // If the "contextmenu" plugin is loaded, register the listeners. 458 468 if ( editor.contextMenu && editor.addMenuItems ) 459 469 { 460 editor.contextMenu.addListener( function( element)470 editor.contextMenu.addListener( function( ) 461 471 { 462 if ( !( plugin.isScaytEnabled( editor ) && element ) )472 if (!plugin.isScaytEnabled(editor)) 463 473 return null; 464 474 465 475 var scayt_control = plugin.getScayt( editor ), 466 word = scayt_control.getWord( element.$ ); 476 node = scayt_control.getScaytNode(); 477 478 if (!node) 479 return null; 467 480 468 if ( !word ) 481 word = scayt_control.getWord( node ); 482 483 if (!word) 469 484 return null; 470 485 471 486 var sLang = scayt_control.getLang(), 472 487 _r = {}, 473 488 items_suggestion = window.scayt.getSuggestion( word, sLang ); 474 if (!items_suggestion || !items_suggestion.length )489 if (!items_suggestion || !items_suggestion.length) 475 490 return null; 476 491 // Remove unused commands and menuitems 477 492 for ( i in moreSuggestions ) … … 508 523 scayt_control.replace(el, s); 509 524 } 510 525 }; 511 })( element.$, items_suggestion[i] );526 })( node, items_suggestion[i] ); 512 527 513 528 if ( i < maxSuggestions ) 514 529 { … … 546 561 { 547 562 var ignore_command = { 548 563 exec: function(){ 549 scayt_control.ignore( element.$);564 scayt_control.ignore(node); 550 565 } 551 566 }; 552 567 addButtonCommand(editor, 'ignore', editor.lang.scayt.ignore, 'scayt_ignore', ignore_command, 'scayt_control', 1); … … 557 572 { 558 573 var ignore_all_command = { 559 574 exec: function(){ 560 scayt_control.ignoreAll( element.$);575 scayt_control.ignoreAll(node); 561 576 } 562 577 }; 563 578 addButtonCommand(editor, 'ignore_all', editor.lang.scayt.ignoreAll, 'scayt_ignore_all', ignore_all_command, 'scayt_control', 2); … … 568 583 { 569 584 var addword_command = { 570 585 exec: function(){ 571 window.scayt.addWordToUserDictionary( element.$);586 window.scayt.addWordToUserDictionary(node); 572 587 } 573 588 }; 574 589 addButtonCommand(editor, 'add_word', editor.lang.scayt.addWord, 'scayt_add_word', addword_command, 'scayt_control', 3); … … 591 606 command.setState( plugin.isScaytEnabled( editor ) ? CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF ); 592 607 }; 593 608 editor.on( 'showScaytState', showInitialState ); 594 595 609 plugin.loadEngine( editor ); 596 610 } 597 611 } 598 612 }); 599 613 })(); 600 614 601 // TODO: Documentation 602 // CKEDITOR.config.scayt_maxSuggestions 603 // CKEDITOR.config.scayt_autoStartup 615 /** 616 * If enabled (true), turns on SCAYT automatically after loading the editor. 617 * @name CKEDITOR.config.scayt_autoStartup 618 * @type Boolean 619 * @default false 620 * @example 621 * config.scayt_autoStartup = true; 622 */ 623 624 /** 625 * Defines the number of SCAYT suggestions to show in the main context menu. 626 * The possible values are: 627 * <ul> 628 * <li>0 (zero): All suggestions are displayed in the main context menu.</li> 629 * <li>Positive number: The maximum number of suggestions to shown in context 630 * menu. Other entries will be shown in "More Suggestions" sub-menu.</li> 631 * <li>Negative number: No suggestions are shown in the main context menu. All 632 * entries will be listed in the "Suggestions" sub-menu.</li> 633 * </ul> 634 * @name CKEDITOR.config.scayt_maxSuggestions 635 * @type Number 636 * @default 5 637 * @example 638 * // Display only three suggestions in the main context menu. 639 * config.scayt_maxSuggestions = 3; 640 * @example 641 * // Do not show the suggestions directly. 642 * config.scayt_maxSuggestions = -1; 643 */ 644 645 /** 646 * Sets the customer ID for SCAYT. Required for migration from free version 647 * with banner to paid version. 648 * @name CKEDITOR.config.scayt_customerid 649 * @type String 650 * @default '' 651 * @example 652 * // Load SCAYT using my customer ID. 653 * config.scayt_customerid = 'your-encrypted-customer-id'; 654 */ 655 656 /** 657 * Enables/disables the "More Suggestions" sub-menu in the context menu. 658 * The possible values are "on" or "off". 659 * @name CKEDITOR.config.scayt_moreSuggestions 660 * @type String 661 * @default 'on' 662 * @example 663 * // Disables the "More Suggestions" sub-menu. 664 * config.scayt_moreSuggestions = 'off'; 665 */ 666 667 /** 668 * Customizes the display of SCAYT context menu commands ("Add Word", "Ignore" 669 * and "Ignore All"). It must be a string with one or more of the following 670 * words separated by a pipe ("|"): 671 * <ul> 672 * <li>"off": disables all options.</li> 673 * <li>"all": enables all options.</li> 674 * <li>"ignore": enables the "Ignore" option.</li> 675 * <li>"ignoreall": enables the "Ignore All" option.</li> 676 * <li>"add": enables the "Add Word" option.</li> 677 * </ul> 678 * @name CKEDITOR.config.scayt_contextCommands 679 * @type String 680 * @default 'all' 681 * @example 682 * // Show only "Add Word" and "Ignore All" in the context menu. 683 * config.scayt_contextCommands = 'add|ignoreall'; 684 */ 685 686 /** 687 * Sets the default spellchecking language for SCAYT. 688 * @name CKEDITOR.config.scayt_sLang 689 * @type String 690 * @default 'en_US' 691 * @example 692 * // Sets SCAYT to German. 693 * config.scayt_sLang = 'de_DE'; 694 */ 695 696 /** 697 * Sets the visibility of the SCAYT tabs in the settings dialog and toolbar 698 * button. The value must contain a "1" (enabled) or "0" (disabled) number for 699 * each of the following entries, in this precise order, separated by a 700 * comma (","): "Options", "Languages" and "Dictionary". 701 * @name CKEDITOR.config.scayt_uiTabs 702 * @type String 703 * @default '1,1,1' 704 * @example 705 * // Hide the "Languages" tab. 706 * config.scayt_uiTabs = '1,0,1'; 707 */ 708 709 710 /** 711 * Set the URL to SCAYT core. Required to switch to licensed version of SCAYT application. 712 * Further details at http://wiki.spellchecker.net/doku.php?id=3rd:wysiwyg:fckeditor:wscckf3l . 713 * @name CKEDITOR.config.scayt_srcUrl 714 * @type String 715 * @default '' 716 * @example 717 * config.scayt_srcUrl = "http://my-host/spellcheck/lf/scayt/scayt.js"; 718 */ 719 720 /** 721 * Links SCAYT to custom dictionaries. It's a string containing dictionary ids 722 * separared by commas (","). Available only for licensed version. 723 * Further details at http://wiki.spellchecker.net/doku.php?id=custom_dictionary_support . 724 * @name CKEDITOR.config.scayt_customDictionaryIds 725 * @type String 726 * @default '' 727 * @example 728 * config.scayt_customDictionaryIds = '3021,3456,3478"'; 729 */ 730 731 /** 732 * Makes it possible to activate a custom dictionary on SCAYT. The user 733 * dictionary name must be used. Available only for licensed version. 734 * @name CKEDITOR.config.scayt_userDictionaryName 735 * @type String 736 * @default '' 737 * @example 738 * config.scayt_userDictionaryName = 'MyDictionary'; 739 */ 740