Ticket #5438: 5438.patch

File 5438.patch, 10.4 KB (added by Alfonso Martínez de Lizarrondo, 14 years ago)

Proposed patch

  • _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
    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                                                scayt_control_id = scayt_instance.id;
     125                                                scayt_instance.destroy( true );
    126126                                                delete plugin.instances[ editor.name ];
    127127                                        }
    128128                                }
    129129                        });
    130130
     131                editor.on( 'destroy', function( ev )
     132                        {
     133                                var editor = ev.editor,
     134                                        scayt_instance = plugin.getScayt( editor );
    131135
    132                 editor.on( 'destroy', function()
    133                         {
    134                                 scayt_control_id = scayt_instanse.id;
    135                                 plugin.getScayt( editor ).destroy( true );
     136                                scayt_control_id = null;
     137                                scayt_instance.destroy( true );
     138                                delete plugin.instances[ editor.name ];
    136139                        });
     140
    137141                // Listen to data manipulation to reflect scayt markup.
    138142                editor.on( 'afterSetData', function()
    139143                        {
    140144                                if ( plugin.isScaytEnabled( editor ) ) {
    141                                         window.setTimeout( function(){ plugin.getScayt( editor ).refresh() }, 10 );
     145                                        window.setTimeout( function(){ plugin.getScayt( editor ).refresh(); }, 10 );
    142146                                }
    143147                        });
    144148
     
    154158                                                editor.getSelection().unlock( true );
    155159
    156160                                        // Swallow any SCAYT engine errors.
    157                                         window.setTimeout( function(){ scayt_instance.refresh() }, 10 );
     161                                        window.setTimeout( function(){ scayt_instance.refresh(); }, 10 );
    158162                                }
    159163                        }, this, null, 50 );
    160164
    161165                editor.on( 'insertHtml', function()
    162166                        {
    163 
    164167                                var scayt_instance = plugin.getScayt( editor );
    165168                                if ( plugin.isScaytEnabled( editor ) )
    166169                                {
     
    170173                                                editor.getSelection().unlock( true );
    171174
    172175                                        // Swallow any SCAYT engine errors.
    173                                        
    174                                         window.setTimeout( function(){ scayt_instance.refresh() },10 );
    175                                        
     176                                        window.setTimeout( function(){ scayt_instance.refresh(); },10 );
    176177                                }
    177178                        }, this, null, 50 );
    178179
     
    186187
    187188                var dataProcessor = editor.dataProcessor,
    188189                        htmlFilter = dataProcessor && dataProcessor.htmlFilter;
     190
    189191                if ( htmlFilter )
    190192                {
    191193                        htmlFilter.addRules(
     
    224226                },
    225227                isScaytEnabled : function( editor )
    226228                {
    227                         var scayt_instanse = this.getScayt( editor );
    228                         return ( scayt_instanse ) ? scayt_instanse.disabled === false : false;
     229                        var scayt_instance = this.getScayt( editor );
     230                        return ( scayt_instance ) ? scayt_instance.disabled === false : false;
    229231                },
    230232                loadEngine : function( editor )
    231233                {
     
    244246                                },
    245247                                this,
    246248                                null,
    247                                 0 
     249                                0
    248250                        );      // First to run.
    249251
    250252                        this.engineLoaded = -1; // Loading in progress.
     
    253255                        var protocol = document.location.protocol;
    254256                        // Default to 'http' for unknown.
    255257                        protocol = protocol.search( /https?:/) != -1? protocol : 'http:';
    256                         var baseUrl  = "svc.spellchecker.net/spellcheck31/lf/scayt/scayt22.js";
     258                        var baseUrl  = 'svc.spellchecker.net/spellcheck31/lf/scayt/scayt22.js';
    257259
    258                         var scaytUrl  =  editor.config.scayt_srcUrl || ( protocol + "//" + baseUrl );
    259                         var scaytConfigBaseUrl =  plugin.parseUrl( scaytUrl ).path +  "/";
     260                        var scaytUrl  =  editor.config.scayt_srcUrl || ( protocol + '//' + baseUrl );
     261                        var scaytConfigBaseUrl =  plugin.parseUrl( scaytUrl ).path +  '/';
    260262
    261263                        CKEDITOR._djScaytConfig =
    262264                        {
     
    265267                                [
    266268                                        function()
    267269                                        {
    268                                                 CKEDITOR.fireOnce( "scaytReady" );
     270                                                CKEDITOR.fireOnce( 'scaytReady' );
    269271                                        }
    270272                                ],
    271273                                isDebug: false
     
    365367                        // Add Options dialog.
    366368                        CKEDITOR.dialog.add( commandName, CKEDITOR.getUrl( this.path + 'dialogs/options.js' ) );
    367369                        // read ui tags
    368                         var confuiTabs = editor.config.scayt_uiTabs || "1,1,1";
     370                        var confuiTabs = editor.config.scayt_uiTabs || '1,1,1';
    369371                        var uiTabs =[];
    370                         // string tp array convert
    371                         confuiTabs = confuiTabs.split(",");
    372                         // check array length ! allwaays must be 3 filled with 1 or 0
     372                        // string to array convert
     373                        confuiTabs = confuiTabs.split( ',' );
     374                        // check array length ! always must be 3 filled with 1 or 0
    373375                        for (var i=0,l=3; i<l; i++)
    374376                        {
    375                                 var flag = parseInt(confuiTabs[i] || "1" ,10);
    376                                 uiTabs.push(  flag );
     377                                var flag = parseInt(confuiTabs[i] || '1' ,10);
     378                                uiTabs.push( flag );
    377379                        }
    378380
    379381                        var menuGroup = 'scaytButton';
     
    381383                        // combine menu items to render
    382384                        var uiMuneItems = {};
    383385
    384                         // allways added
     386                        // always added
    385387                        uiMuneItems.scaytToggle =
    386388                                {
    387389                                        label : editor.lang.scayt.enable,
     
    423425                                                editor.openDialog( commandName );
    424426                                        }
    425427                                };
    426                         // allways added
     428                        // always added
    427429                        uiMuneItems.scaytAbout =
    428430                                {
    429431                                        label : editor.lang.scayt.about,
     
    436438                                }
    437439                        ;
    438440
    439                         uiTabs[3] = 1; // about us tab is allways on
     441                        uiTabs[3] = 1; // about us tab is always on
    440442                        plugin.uiTabs = uiTabs;
    441443
    442444                        editor.addMenuItems( uiMuneItems );
     
    480482
    481483                                                var scayt_control = plugin.getScayt( editor ),
    482484                                                        node = scayt_control.getScaytNode();
    483                                                
     485
    484486                                                if ( !node )
    485487                                                        return null;
    486488
     
    508510                                                moreSuggestions = {};           // Reset items.
    509511                                                mainSuggestions = {};
    510512
    511                                                 var moreSuggestionsUnable = editor.config.scayt_moreSuggestions || "on";
     513                                                var moreSuggestionsUnable = editor.config.scayt_moreSuggestions || 'on';
    512514                                                var moreSuggestionsUnableAdded = false;
    513515
    514516                                                var maxSuggestions = editor.config.scayt_maxSuggestions;
    515517                                                ( typeof maxSuggestions != 'number' ) && ( maxSuggestions = 5 );
    516518                                                !maxSuggestions && ( maxSuggestions = items_suggestion.length );
    517519
    518                                                 var contextCommands = editor.config.scayt_contextCommands || "all";
    519                                                 contextCommands = contextCommands.split("|");
     520                                                var contextCommands = editor.config.scayt_contextCommands || 'all';
     521                                                contextCommands = contextCommands.split( '|' );
    520522
    521523                                                for ( var i = 0, l = items_suggestion.length; i < l; i += 1 )
    522524                                                {
     
    538540                                                                _r[ commandName ] = CKEDITOR.TRISTATE_OFF;
    539541                                                                mainSuggestions[ commandName ] = CKEDITOR.TRISTATE_OFF;
    540542                                                        }
    541                                                         else if ( moreSuggestionsUnable == "on" )
     543                                                        else if ( moreSuggestionsUnable == 'on' )
    542544                                                        {
    543545                                                                addButtonCommand( editor, 'button_' + commandName, items_suggestion[i],
    544546                                                                        commandName, exec, 'scayt_moresuggest', i + 1 );
     
    547549                                                        }
    548550                                                }
    549551
    550                                                 if ( moreSuggestionsUnableAdded ){
    551                                                         // Rgister the More suggestions group;
     552                                                if ( moreSuggestionsUnableAdded )
     553                                                {
     554                                                        // Register the More suggestions group;
    552555                                                        editor.addMenuItem( 'scayt_moresuggest',
    553556                                                        {
    554557                                                                label : editor.lang.scayt.moreSuggestions,
     
    560563                                                                }
    561564                                                        });
    562565                                                        mainSuggestions[ 'scayt_moresuggest' ] = CKEDITOR.TRISTATE_OFF;
    563 
    564566                                                }
    565567
    566                                                 if ( in_array( "all",contextCommands )  || in_array("ignore",contextCommands)  )
     568                                                if ( in_array( 'all', contextCommands )  || in_array( 'ignore', contextCommands)  )
    567569                                                {
    568570                                                        var ignore_command = {
    569571                                                                exec: function(){
    570572                                                                        scayt_control.ignore( node );
    571573                                                                }
    572574                                                        };
    573                                                         addButtonCommand(editor, 'ignore', editor.lang.scayt.ignore, 'scayt_ignore', ignore_command, 'scayt_control', 1);
    574                                                         mainSuggestions['scayt_ignore'] = CKEDITOR.TRISTATE_OFF;
     575                                                        addButtonCommand( editor, 'ignore', editor.lang.scayt.ignore, 'scayt_ignore', ignore_command, 'scayt_control', 1 );
     576                                                        mainSuggestions[ 'scayt_ignore' ] = CKEDITOR.TRISTATE_OFF;
    575577                                                }
    576578
    577                                                 if ( in_array( "all",contextCommands )  || in_array("ignoreall",contextCommands) )
     579                                                if ( in_array( 'all', contextCommands )  || in_array( 'ignoreall', contextCommands ) )
    578580                                                {
    579581                                                        var ignore_all_command = {
    580582                                                                exec: function(){
     
    585587                                                        mainSuggestions['scayt_ignore_all'] = CKEDITOR.TRISTATE_OFF;
    586588                                                }
    587589
    588                                                 if ( in_array( "all",contextCommands )  || in_array("add",contextCommands) )
     590                                                if ( in_array( 'all', contextCommands )  || in_array( 'add', contextCommands ) )
    589591                                                {
    590592                                                        var addword_command = {
    591593                                                                exec: function(){
     
    664666 */
    665667
    666668/**
    667  * Sets the customer ID for SCAYT. Required for migration from free version 
     669 * Sets the customer ID for SCAYT. Required for migration from free version
    668670 * with banner to paid version.
    669671 * @name CKEDITOR.config.scayt_customerid
    670672 * @type String
     
    740742
    741743/**
    742744 * Links SCAYT to custom dictionaries. It's a string containing dictionary ids
    743  * separared by commas (","). Available only for licensed version. 
     745 * separared by commas (","). Available only for licensed version.
    744746 * Further details at http://wiki.spellchecker.net/doku.php?id=custom_dictionary_support .
    745747 * @name CKEDITOR.config.scayt_customDictionaryIds
    746748 * @type String
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy