Ticket #5145: 5145_7.patch

File 5145_7.patch, 11.6 KB (added by WebSpellChecker.net, 14 years ago)
  • _source/plugins/scayt/plugin.js

     
    1010
    1111(function()
    1212{
     13 
    1314        var commandName         = 'scaytcheck',
    1415                openPage                = '',
    15                 scayt_paused    = null;
     16                scayt_paused    = null,
     17                scayt_control_id = null;
    1618
    1719        // Checks if a value exists in an array
    1820        function in_array(needle, haystack)
     
    3739                {
    3840                        // Initialise Scayt instance.
    3941                        var oParams = {};
    40                         oParams.srcNodeRef = editor.document.getWindow().$.frameElement;                // Get the iframe.
     42                        // Get the iframe.
     43                        oParams.srcNodeRef = editor.document.getWindow().$.frameElement;
    4144                        // syntax : AppName.AppVersion@AppRevision
    4245                        oParams.assocApp  = "CKEDITOR." + CKEDITOR.version + "@" + CKEDITOR.revision;
    4346                        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 || '';
    4649                        oParams.sLang = editor.config.scayt_sLang || "en_US";
    47 
    48                         if ( CKEDITOR._scaytParams )
     50                       
     51                        if ( CKEDITOR._.scaytParams )
    4952                        {
    50                                 for ( var k in CKEDITOR._scaytParams )
     53                                for ( var k in CKEDITOR._.scaytParams )
    5154                                {
    52                                         oParams[ k ] = CKEDITOR._scaytParams[ k ];
     55                                        oParams[ k ] = CKEDITOR._.scaytParams[ k ];
    5356                                }
    5457                        }
    55 
     58                       
     59                        if ( scayt_control_id )
     60                                oParams.id = scayt_control_id;
     61                       
    5662                        var scayt_control = new window.scayt( oParams );
    5763
    5864                        // Copy config.
     
    7278                        var fTabs  = [];
    7379
    7480                        for (var i = 0,l=4; i<l; i++)
    75                                 fTabs.push( uiTabs[i] && plugin.uiTabs[i] );
     81                            fTabs.push( uiTabs[i] && plugin.uiTabs[i] );
    7682
    7783                        plugin.uiTabs = fTabs;
    7884                        try {
     
    109115                                        if ( scayt_instanse )
    110116                                        {
    111117                                                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];
    114121                                        }
    115122                                }
    116123                        });
     
    118125
    119126                editor.on( 'destroy', function()
    120127                        {
    121                                 plugin.getScayt( editor ).destroy();
     128                                scayt_control_id = scayt_instanse.id;
     129                                plugin.getScayt( editor ).destroy(true);
    122130                        });
    123131                // Listen to data manipulation to reflect scayt markup.
    124132                editor.on( 'afterSetData', function()
    125133                        {
    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                                }
    128137                        });
    129138
    130139                // Reload spell-checking for current word after insertion completed.
     
    139148                                                editor.getSelection().unlock( true );
    140149
    141150                                        // Swallow any SCAYT engine errors.
    142                                         try{
    143                                                 scayt_instance.refresh();
    144                                         }catch( er )
    145                                         {}
     151                                        window.setTimeout(function(){scayt_instance.refresh()},10);
     152                                       
    146153                                }
    147154                        }, this, null, 50 );
    148155
     
    158165                                                editor.getSelection().unlock( true );
    159166
    160167                                        // 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                                       
    165171                                }
    166172                        }, this, null, 50 );
    167173
     
    218224                },
    219225                loadEngine : function( editor )
    220226                {
     227                        if (CKEDITOR.env.opera)
     228                                return;
    221229                        if ( this.engineLoaded === true )
    222230                                return onEngineLoad.apply( editor );    // Add new instance.
    223231                        else if ( this.engineLoaded == -1 )                     // We are waiting.
     
    230238                                },
    231239                                this,
    232240                                null,
    233                                 0 );    // First to run.
     241                                0
     242                        );      // First to run.
    234243
    235244                        this.engineLoaded = -1; // Loading in progress.
    236245
     
    238247                        var protocol = document.location.protocol;
    239248                        // Default to 'http' for unknown.
    240249                        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";
    242251
    243252                        var scaytUrl  =  editor.config.scayt_srcUrl || ( protocol + "//" + baseUrl );
    244253                        var scaytConfigBaseUrl =  plugin.parseUrl( scaytUrl ).path +  "/";
     
    355364                        // string tp array convert
    356365                        confuiTabs = confuiTabs.split(",");
    357366                        // 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                        {
    359369                                var flag = parseInt(confuiTabs[i] || "1" ,10);
    360370                                uiTabs.push(  flag  );
    361371                        }
     
    457467                        // If the "contextmenu" plugin is loaded, register the listeners.
    458468                        if ( editor.contextMenu && editor.addMenuItems )
    459469                        {
    460                                 editor.contextMenu.addListener( function( element )
     470                                editor.contextMenu.addListener( function( )
    461471                                        {
    462                                                 if ( !( plugin.isScaytEnabled( editor ) && element ) )
     472                                                if (!plugin.isScaytEnabled(editor))
    463473                                                        return null;
    464474
    465475                                                var scayt_control = plugin.getScayt( editor ),
    466                                                         word = scayt_control.getWord( element.$ );
     476                                                        node = scayt_control.getScaytNode();
     477                                               
     478                                                if (!node)
     479                                                        return null;
    467480
    468                                                 if ( !word )
     481                                                        word = scayt_control.getWord( node );
     482
     483                                                if (!word)
    469484                                                        return null;
    470485
    471486                                                var sLang = scayt_control.getLang(),
    472487                                                        _r = {},
    473488                                                        items_suggestion = window.scayt.getSuggestion( word, sLang );
    474                                                 if (!items_suggestion || !items_suggestion.length )
     489                                                if (!items_suggestion || !items_suggestion.length)
    475490                                                        return null;
    476491                                                // Remove unused commands and menuitems
    477492                                                for ( i in moreSuggestions )
     
    508523                                                                                        scayt_control.replace(el, s);
    509524                                                                                }
    510525                                                                        };
    511                                                                 })( element.$, items_suggestion[i] );
     526                                                                })( node, items_suggestion[i] );
    512527
    513528                                                        if ( i < maxSuggestions )
    514529                                                        {
     
    546561                                                {
    547562                                                        var ignore_command = {
    548563                                                                exec: function(){
    549                                                                         scayt_control.ignore(element.$);
     564                                                                        scayt_control.ignore(node);
    550565                                                                }
    551566                                                        };
    552567                                                        addButtonCommand(editor, 'ignore', editor.lang.scayt.ignore, 'scayt_ignore', ignore_command, 'scayt_control', 1);
     
    557572                                                {
    558573                                                        var ignore_all_command = {
    559574                                                                exec: function(){
    560                                                                         scayt_control.ignoreAll(element.$);
     575                                                                        scayt_control.ignoreAll(node);
    561576                                                                }
    562577                                                        };
    563578                                                        addButtonCommand(editor, 'ignore_all', editor.lang.scayt.ignoreAll, 'scayt_ignore_all', ignore_all_command, 'scayt_control', 2);
     
    568583                                                {
    569584                                                        var addword_command = {
    570585                                                                exec: function(){
    571                                                                         window.scayt.addWordToUserDictionary(element.$);
     586                                                                        window.scayt.addWordToUserDictionary(node);
    572587                                                                }
    573588                                                        };
    574589                                                        addButtonCommand(editor, 'add_word', editor.lang.scayt.addWord, 'scayt_add_word', addword_command, 'scayt_control', 3);
     
    591606                                        command.setState( plugin.isScaytEnabled( editor ) ? CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF );
    592607                                };
    593608                                editor.on( 'showScaytState', showInitialState );
    594 
    595609                                plugin.loadEngine( editor );
    596610                        }
    597611                }
    598612        });
    599613})();
    600614
    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
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy