Ticket #5438: 5438_2.patch

File 5438_2.patch, 10.6 KB (added by WebSpellChecker.net, 14 years ago)
  • _source/plugins/scayt/plugin.js

     
    4141                        // Get the iframe.
    4242                        oParams.srcNodeRef = editor.document.getWindow().$.frameElement;
    4343                        // syntax : AppName.AppVersion@AppRevision
    44                         oParams.assocApp  = "CKEDITOR." + CKEDITOR.version + "@" + CKEDITOR.revision;
    45                         oParams.customerid = editor.config.scayt_customerid  || "1:WvF0D4-UtPqN1-43nkD4-NKvUm2-daQqk3-LmNiI-z7Ysb4-mwry24-T8YrS3-Q2tpq2";
     44                        oParams.assocApp  = 'CKEDITOR.' + CKEDITOR.version + '@' + CKEDITOR.revision;
     45                        oParams.customerid = editor.config.scayt_customerid  || '1:WvF0D4-UtPqN1-43nkD4-NKvUm2-daQqk3-LmNiI-z7Ysb4-mwry24-T8YrS3-Q2tpq2';
    4646                        oParams.customDictionaryIds = editor.config.scayt_customDictionaryIds || '';
    4747                        oParams.userDictionaryName = editor.config.scayt_userDictionaryName || '';
    48                         oParams.sLang = editor.config.scayt_sLang || "en_US";
     48                        oParams.sLang = editor.config.scayt_sLang || 'en_US';
    4949
    5050                        oParams.onBeforeChange = function()
    5151                        {
     
    6161                                        oParams[ k ] = scayt_custom_params[ k ];
    6262                                }
    6363                        }
    64                        
     64                        // needs for restoring a specific scayt control settings
    6565                        if ( scayt_control_id )
    6666                                oParams.id = scayt_control_id;
    67                        
     67
    6868                        var scayt_control = new window.scayt( oParams );
    6969
    7070                        // Copy config.
     
    117117                        {
    118118                                if ( (ev.data.name == 'source' ||  ev.data.name == 'newpage') && editor.mode == 'wysiwyg' )
    119119                                {
    120                                         var scayt_instanse = plugin.getScayt( editor );
    121                                         if ( scayt_instanse )
     120                                        var scayt_instance = plugin.getScayt( editor );
     121                                        if ( scayt_instance )
    122122                                        {
    123                                                 scayt_paused = scayt_instanse.paused = !scayt_instanse.disabled;
    124                                                 scayt_control_id = scayt_instanse.id;
    125                                                 scayt_instanse.destroy( true );
     123                                                scayt_paused = scayt_instance.paused = !scayt_instance.disabled;
     124                                                // store a control id for restore a specific scayt control settings
     125                                                scayt_control_id = scayt_instance.id;
     126                                                scayt_instance.destroy( true );
    126127                                                delete plugin.instances[ editor.name ];
    127128                                        }
    128129                                }
    129130                        });
    130131
    131 
    132                 editor.on( 'destroy', function()
     132                editor.on( 'destroy', function( ev )
    133133                        {
    134                                 scayt_control_id = scayt_instanse.id;
    135                                 plugin.getScayt( editor ).destroy( true );
     134                                var editor = ev.editor,
     135                                        scayt_instance = plugin.getScayt( editor );
     136                                // store a control id for restore a specific scayt control settings
     137                                scayt_control_id = scayt_instance.id;
     138                                scayt_instance.destroy( true );
     139                                delete plugin.instances[ editor.name ];
    136140                        });
     141
    137142                // Listen to data manipulation to reflect scayt markup.
    138143                editor.on( 'afterSetData', function()
    139144                        {
    140145                                if ( plugin.isScaytEnabled( editor ) ) {
    141                                         window.setTimeout( function(){ plugin.getScayt( editor ).refresh() }, 10 );
     146                                        window.setTimeout( function(){ plugin.getScayt( editor ).refresh(); }, 10 );
    142147                                }
    143148                        });
    144149
     
    154159                                                editor.getSelection().unlock( true );
    155160
    156161                                        // Swallow any SCAYT engine errors.
    157                                         window.setTimeout( function(){ scayt_instance.refresh() }, 10 );
     162                                        window.setTimeout( function(){ scayt_instance.refresh(); }, 10 );
    158163                                }
    159164                        }, this, null, 50 );
    160165
    161166                editor.on( 'insertHtml', function()
    162167                        {
    163 
    164168                                var scayt_instance = plugin.getScayt( editor );
    165169                                if ( plugin.isScaytEnabled( editor ) )
    166170                                {
     
    170174                                                editor.getSelection().unlock( true );
    171175
    172176                                        // Swallow any SCAYT engine errors.
    173                                        
    174                                         window.setTimeout( function(){ scayt_instance.refresh() },10 );
    175                                        
     177                                        window.setTimeout( function(){ scayt_instance.refresh(); },10 );
    176178                                }
    177179                        }, this, null, 50 );
    178180
     
    186188
    187189                var dataProcessor = editor.dataProcessor,
    188190                        htmlFilter = dataProcessor && dataProcessor.htmlFilter;
     191
    189192                if ( htmlFilter )
    190193                {
    191194                        htmlFilter.addRules(
     
    224227                },
    225228                isScaytEnabled : function( editor )
    226229                {
    227                         var scayt_instanse = this.getScayt( editor );
    228                         return ( scayt_instanse ) ? scayt_instanse.disabled === false : false;
     230                        var scayt_instance = this.getScayt( editor );
     231                        return ( scayt_instance ) ? scayt_instance.disabled === false : false;
    229232                },
    230233                loadEngine : function( editor )
    231234                {
     
    244247                                },
    245248                                this,
    246249                                null,
    247                                 0 
     250                                0
    248251                        );      // First to run.
    249252
    250253                        this.engineLoaded = -1; // Loading in progress.
     
    253256                        var protocol = document.location.protocol;
    254257                        // Default to 'http' for unknown.
    255258                        protocol = protocol.search( /https?:/) != -1? protocol : 'http:';
    256                         var baseUrl  = "svc.spellchecker.net/spellcheck31/lf/scayt/scayt22.js";
     259                        var baseUrl  = 'svc.spellchecker.net/spellcheck31/lf/scayt/scayt22.js';
    257260
    258                         var scaytUrl  =  editor.config.scayt_srcUrl || ( protocol + "//" + baseUrl );
    259                         var scaytConfigBaseUrl =  plugin.parseUrl( scaytUrl ).path +  "/";
     261                        var scaytUrl  =  editor.config.scayt_srcUrl || ( protocol + '//' + baseUrl );
     262                        var scaytConfigBaseUrl =  plugin.parseUrl( scaytUrl ).path +  '/';
    260263
    261264                        CKEDITOR._djScaytConfig =
    262265                        {
     
    265268                                [
    266269                                        function()
    267270                                        {
    268                                                 CKEDITOR.fireOnce( "scaytReady" );
     271                                                CKEDITOR.fireOnce( 'scaytReady' );
    269272                                        }
    270273                                ],
    271274                                isDebug: false
     
    365368                        // Add Options dialog.
    366369                        CKEDITOR.dialog.add( commandName, CKEDITOR.getUrl( this.path + 'dialogs/options.js' ) );
    367370                        // read ui tags
    368                         var confuiTabs = editor.config.scayt_uiTabs || "1,1,1";
     371                        var confuiTabs = editor.config.scayt_uiTabs || '1,1,1';
    369372                        var uiTabs =[];
    370                         // string tp array convert
    371                         confuiTabs = confuiTabs.split(",");
    372                         // check array length ! allwaays must be 3 filled with 1 or 0
     373                        // string to array convert
     374                        confuiTabs = confuiTabs.split( ',' );
     375                        // check array length ! always must be 3 filled with 1 or 0
    373376                        for (var i=0,l=3; i<l; i++)
    374377                        {
    375                                 var flag = parseInt(confuiTabs[i] || "1" ,10);
    376                                 uiTabs.push(  flag );
     378                                var flag = parseInt(confuiTabs[i] || '1' ,10);
     379                                uiTabs.push( flag );
    377380                        }
    378381
    379382                        var menuGroup = 'scaytButton';
     
    381384                        // combine menu items to render
    382385                        var uiMuneItems = {};
    383386
    384                         // allways added
     387                        // always added
    385388                        uiMuneItems.scaytToggle =
    386389                                {
    387390                                        label : editor.lang.scayt.enable,
     
    423426                                                editor.openDialog( commandName );
    424427                                        }
    425428                                };
    426                         // allways added
     429                        // always added
    427430                        uiMuneItems.scaytAbout =
    428431                                {
    429432                                        label : editor.lang.scayt.about,
     
    436439                                }
    437440                        ;
    438441
    439                         uiTabs[3] = 1; // about us tab is allways on
     442                        uiTabs[3] = 1; // about us tab is always on
    440443                        plugin.uiTabs = uiTabs;
    441444
    442445                        editor.addMenuItems( uiMuneItems );
     
    480483
    481484                                                var scayt_control = plugin.getScayt( editor ),
    482485                                                        node = scayt_control.getScaytNode();
    483                                                
     486
    484487                                                if ( !node )
    485488                                                        return null;
    486489
     
    508511                                                moreSuggestions = {};           // Reset items.
    509512                                                mainSuggestions = {};
    510513
    511                                                 var moreSuggestionsUnable = editor.config.scayt_moreSuggestions || "on";
     514                                                var moreSuggestionsUnable = editor.config.scayt_moreSuggestions || 'on';
    512515                                                var moreSuggestionsUnableAdded = false;
    513516
    514517                                                var maxSuggestions = editor.config.scayt_maxSuggestions;
    515518                                                ( typeof maxSuggestions != 'number' ) && ( maxSuggestions = 5 );
    516519                                                !maxSuggestions && ( maxSuggestions = items_suggestion.length );
    517520
    518                                                 var contextCommands = editor.config.scayt_contextCommands || "all";
    519                                                 contextCommands = contextCommands.split("|");
     521                                                var contextCommands = editor.config.scayt_contextCommands || 'all';
     522                                                contextCommands = contextCommands.split( '|' );
    520523
    521524                                                for ( var i = 0, l = items_suggestion.length; i < l; i += 1 )
    522525                                                {
     
    538541                                                                _r[ commandName ] = CKEDITOR.TRISTATE_OFF;
    539542                                                                mainSuggestions[ commandName ] = CKEDITOR.TRISTATE_OFF;
    540543                                                        }
    541                                                         else if ( moreSuggestionsUnable == "on" )
     544                                                        else if ( moreSuggestionsUnable == 'on' )
    542545                                                        {
    543546                                                                addButtonCommand( editor, 'button_' + commandName, items_suggestion[i],
    544547                                                                        commandName, exec, 'scayt_moresuggest', i + 1 );
     
    547550                                                        }
    548551                                                }
    549552
    550                                                 if ( moreSuggestionsUnableAdded ){
    551                                                         // Rgister the More suggestions group;
     553                                                if ( moreSuggestionsUnableAdded )
     554                                                {
     555                                                        // Register the More suggestions group;
    552556                                                        editor.addMenuItem( 'scayt_moresuggest',
    553557                                                        {
    554558                                                                label : editor.lang.scayt.moreSuggestions,
     
    560564                                                                }
    561565                                                        });
    562566                                                        mainSuggestions[ 'scayt_moresuggest' ] = CKEDITOR.TRISTATE_OFF;
    563 
    564567                                                }
    565568
    566                                                 if ( in_array( "all",contextCommands )  || in_array("ignore",contextCommands)  )
     569                                                if ( in_array( 'all', contextCommands )  || in_array( 'ignore', contextCommands)  )
    567570                                                {
    568571                                                        var ignore_command = {
    569572                                                                exec: function(){
    570573                                                                        scayt_control.ignore( node );
    571574                                                                }
    572575                                                        };
    573                                                         addButtonCommand(editor, 'ignore', editor.lang.scayt.ignore, 'scayt_ignore', ignore_command, 'scayt_control', 1);
    574                                                         mainSuggestions['scayt_ignore'] = CKEDITOR.TRISTATE_OFF;
     576                                                        addButtonCommand( editor, 'ignore', editor.lang.scayt.ignore, 'scayt_ignore', ignore_command, 'scayt_control', 1 );
     577                                                        mainSuggestions[ 'scayt_ignore' ] = CKEDITOR.TRISTATE_OFF;
    575578                                                }
    576579
    577                                                 if ( in_array( "all",contextCommands )  || in_array("ignoreall",contextCommands) )
     580                                                if ( in_array( 'all', contextCommands )  || in_array( 'ignoreall', contextCommands ) )
    578581                                                {
    579582                                                        var ignore_all_command = {
    580583                                                                exec: function(){
     
    585588                                                        mainSuggestions['scayt_ignore_all'] = CKEDITOR.TRISTATE_OFF;
    586589                                                }
    587590
    588                                                 if ( in_array( "all",contextCommands )  || in_array("add",contextCommands) )
     591                                                if ( in_array( 'all', contextCommands )  || in_array( 'add', contextCommands ) )
    589592                                                {
    590593                                                        var addword_command = {
    591594                                                                exec: function(){
     
    664667 */
    665668
    666669/**
    667  * Sets the customer ID for SCAYT. Required for migration from free version 
     670 * Sets the customer ID for SCAYT. Required for migration from free version
    668671 * with banner to paid version.
    669672 * @name CKEDITOR.config.scayt_customerid
    670673 * @type String
     
    740743
    741744/**
    742745 * Links SCAYT to custom dictionaries. It's a string containing dictionary ids
    743  * separared by commas (","). Available only for licensed version. 
     746 * separared by commas (","). Available only for licensed version.
    744747 * Further details at http://wiki.spellchecker.net/doku.php?id=custom_dictionary_support .
    745748 * @name CKEDITOR.config.scayt_customDictionaryIds
    746749 * @type String
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy