Ticket #4667: 4667.2.patch

File 4667.2.patch, 13.1 KB (added by WebSpellChecker.net, 13 years ago)
  • editor/_source/internals/fckscayt.js

     
    2828                                                ? true : false ;
    2929        var scaytEnable = false;
    3030        var scaytReady  = false;
     31        var savedID;
     32        var uiTabs = [];
    3133
    3234        function ScaytEngineLoad( callback )
    3335        {
     
    4143                {
    4244                        window.scayt = top.scayt ;
    4345                        InitScayt() ;
    44                         var ScaytCombobox =  FCKToolbarItems.LoadedItems[ 'ScaytCombobox' ] ;
    45                         ScaytCombobox && ScaytCombobox.SetEnabled( scyt_control && scyt_control.disabled ) ;
    4646                        InitSetup() ;
    4747                };
    4848
     
    6666                CKEDITOR._djScaytConfig =
    6767                {
    6868                        baseUrl : scaytConfigBaseUrl,
     69                        initingScayt : false, // flag, if it is set to true, SCAYT files haven't been loaded yet
     70                        afterScaytInitQueue: [], // queue for loading few SCAYT instances
    6971                        addOnLoad : function()
    7072                        {
    7173                                init();
     74                                CKEDITOR._djScaytConfig.initingScayt=false; // SCAYT files were already loaded, first instance initialized
     75                                for ( var i = 0 ; i < CKEDITOR._djScaytConfig.afterScaytInitQueue.length ; i++ ) { // execute initializing of othe SCAYT instances in the queue
     76                                        try { CKEDITOR._djScaytConfig.afterScaytInitQueue[i].call() ; }
     77                                        catch(err) {}
     78                                }
     79                                CKEDITOR._djScaytConfig.afterScaytInitQueue=[];
    7280                        },
    7381                        isDebug : false
    7482                };
     
    7785                if ( callback )
    7886                        scaytOnLoad.push( callback ) ;
    7987
     88                CKEDITOR._djScaytConfig.initingScayt=true; // begin to load SCAYT files
    8089                DoLoadScript( scaytUrl ) ;
    8190        }
    8291
     
    110119                var top = FCK.EditorWindow.parent.parent;
    111120                oParams.srcNodeRef                              = FCK.EditingArea.IFrame;               // Get the iframe.
    112121                // syntax : AppName.AppVersion@AppRevision
    113                 //oParams.assocApp  = "FCKEDITOR." + FCKeditorAPI.Varsion + "@" + FCKeditorAPI.VersionBuild;
    114                 oParams.customerid                              = FCK.Config.ScaytCustomerid ;
    115                 oParams.customDictionaryName    = FCK.Config.ScaytCustomDictionaryName ;
    116                 oParams.userDictionaryName              = FCK.Config.ScaytUserDictionaryName ;
    117                 oParams.defLang                                 = FCK.Config.ScaytDefLang ;
    118 
     122                oParams.assocApp  = "FCKEDITOR." + FCKeditorAPI.Version + "@" + FCKeditorAPI.VersionBuild;
     123                oParams.customerid                              = FCK.Config.ScaytCustomerid || '1:WvF0D4-UtPqN1-43nkD4-NKvUm2-daQqk3-LmNiI-z7Ysb4-mwry24-T8YrS3-Q2tpq2';
     124                oParams.userDictionaryName              = FCK.Config.ScaytUserDictionaryName || '';
     125                oParams.customDictionaryIds     = FCK.Config.ScaytCustomDictionaryIds || '';
     126                oParams.sLang                               = FCK.Config.ScaytsLang || FCK.Config.ScaytDefLang ;
     127               
     128                if (savedID) {   // Create a scayt_control with id specified if we already have one
     129                        oParams.id = savedID;
     130                        savedID = "";
     131                }
     132               
    119133                var scayt = top.scayt;
    120134                var scayt_control = window.scayt_control = new scayt( oParams ) ;
    121135        }
     
    126140
    127141                var scayt_control = window.scayt_control ;
    128142
    129                 if ( scayt_control )
     143                if ( typeof scayt_control != 'undefined' )
    130144                {
    131145                        scayt_control.setDisabled( false ) ;
    132146                        scaytReady = true;
    133147                        scaytEnable = !scayt_control.disabled ;
    134148
    135149                        // set default scayt status
    136                         var ScaytCombobox = FCKToolbarItems.LoadedItems[ 'ScaytCombobox' ] ;
    137                         ScaytCombobox && ScaytCombobox.Enable() ;
     150                        var ScaytCombobox = FCKToolbarItems.GetItem( 'SpellCheck' );
     151                        ScaytCombobox && ScaytCombobox.Command.Enable() ;
    138152                        ShowScaytState() ;
    139                 }
     153                       
     154                        FCKScayt.scayt_ui_tabs = uiTabs;
    140155
    141                 for ( var i = 0 ; i < scaytOnLoad.length ; i++ )
    142                 {
    143                         try
     156                        for ( var i = 0 ; i < scaytOnLoad.length ; i++ )
    144157                        {
    145                                 scaytOnLoad[i].call( this ) ;
     158                                try
     159                                {
     160                                        scaytOnLoad[i].call( this ) ;
     161                                }
     162                                catch(err)
     163                                {}
    146164                        }
    147                         catch(err)
    148                         {}
    149165                }
    150166        }
    151167
     
    162178                {
    163179                        case 'Options' :
    164180                        case 'Langs' :
     181                        case 'Dictionary' :
    165182                        case 'About' :
    166183                                if ( isEngineLoaded && scaytReady && !scaytEnable )
    167184                                {
     
    247264
    248265                if ( scaytEnable )
    249266                {
    250                         bItem.style.opacity = '1' ;
     267                        setElementOpacity(bItem,1);
    251268                        dNode.innerHTML = GetStatusLabel() ;
    252269                }
    253270                else
    254271                {
    255                         bItem.style.opacity = '0.5' ;
     272                        setElementOpacity(bItem,0.5);
    256273                        dNode.innerHTML = GetStatusLabel() ;
    257274                }
    258275        }
     
    282299        ToolbarScaytComboBox.prototype.CreateItems = function()
    283300        {
    284301                this._Combo.AddItem( 'Trigger', '<b>Enable SCAYT</b>' );
    285                 this._Combo.AddItem( 'Options', FCKLang.ScaytTitleOptions || "Options"  );
    286                 this._Combo.AddItem( 'Langs', FCKLang.ScaytTitleLangs || "Languages");
    287                 this._Combo.AddItem( 'About', FCKLang.ScaytTitleAbout || "About");
     302        if (uiTabs[0])
     303            this._Combo.AddItem( 'Options', FCKLang.ScaytTitleOptions || "Options"  );
     304        if (uiTabs[1])
     305            this._Combo.AddItem( 'Langs', FCKLang.ScaytTitleLangs || "Languages");
     306        if (uiTabs[2])
     307            this._Combo.AddItem( 'Dictionary', FCKLang.ScaytTitleDict || "Dictionaries");
     308        this._Combo.AddItem( 'About', FCKLang.ScaytTitleAbout || "About");
    288309        }
    289310
    290311        // Label shown in the toolbar.
     
    334355                        }
    335356                }
    336357        }
     358       
     359        // functions to set opacity of an element properly in all browsers
     360        function setElementOpacity(elem, nOpacity)
     361        {
     362          var opacityProp = getOpacityProperty();
     363         
     364          if (!elem || !opacityProp) return;
     365         
     366          if (opacityProp=="filter")  // Internet Exploder 5.5+
     367          {
     368                nOpacity *= 100;
     369               
     370                var oAlpha = elem.filters['DXImageTransform.Microsoft.alpha'] || elem.filters.alpha;
     371                if (oAlpha) oAlpha.opacity = nOpacity;
     372                else elem.style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity="+nOpacity+")";
     373          }
     374          else
     375                elem.style[opacityProp] = nOpacity;
     376        }
    337377
     378        function getOpacityProperty()
     379        {
     380          if (typeof document.body.style.opacity == 'string') // CSS3 compliant (Moz 1.7+, Safari 1.2+, Opera 9)
     381                return 'opacity';
     382          else if (typeof document.body.style.MozOpacity == 'string') // Mozilla 1.6, Firefox 0.8
     383                return 'MozOpacity';
     384          else if (typeof document.body.style.KhtmlOpacity == 'string') // Konqueror 3.1, Safari 1.1
     385                return 'KhtmlOpacity';
     386          else if (document.body.filters && navigator.appVersion.match(/MSIE ([\d.]+);/)[1]>=5.5) // Internet Exploder 5.5+
     387                return 'filter';
     388
     389          return false;
     390        }
     391       
    338392        // Register context menu listeners.
    339393        function InitSetup()
    340394        {
     
    360414                                        if ( !suggestions || !suggestions.length )
    361415                                                return;
    362416
    363                                         menu.AddSeparator() ;
    364 
    365417                                        var maxSuggestions = FCK.Config.ScaytMaxSuggestions || 5 ;
    366418                                        var suggAveCount = ( maxSuggestions == -1 ) ? suggestions.length : maxSuggestions ;
     419                                        var mmode = FCK.Config.ScaytContextCommands || 'all';
     420                   
     421                    mmode = mmode.split("|");
     422                        mmode = {
     423                            all: false,
     424                            off: false,
     425                            asis: mmode,
     426                            isin: function(s){
     427                                if (this.off)
     428                                    return false;
     429                                if (this.all)
     430                                    return true;
    367431
     432                                return this.is(s);
     433                            },
     434                            is: function(s){
     435                                for (var i = 0, l = this.asis.length; i < l; i++) {
     436                                    if (this.asis[i] == s) return true;
     437                                                                }
     438                                return false;
     439                            }
     440                        };
     441
     442                        if (mmode.is("off")) {
     443                            mmode.off = true;
     444                            mmode.all = false;
     445                        }
     446                        if (mmode.is("all")) {
     447                            mmode.off = false;
     448                            mmode.all = true;
     449                        }
     450
     451                    menu.AddSeparator() ;
     452                                       
    368453                                        for ( var i = 0 ; i < suggAveCount ; i += 1 )
    369454                                        {
    370455                                                if ( suggestions[i] )
     
    376461                                                }
    377462                                        }
    378463
    379                                         menu.AddSeparator() ;
     464                                        if (mmode.off !== true) {
     465                        menu.AddSeparator() ;
     466                        var o = {};
     467                            o.node = node;
     468                           
     469                        if (mmode.isin('add')) {
     470                            o.action = 'Add Word';
     471                            menu.AddItem( 'ScaytContext', 'Add Word', null, false, o );
     472                        }
     473                        if (mmode.isin('ignore')) {
     474                            o.action = 'Ignore';
     475                            menu.AddItem( 'ScaytContext', 'Ignore', null, false, o );
     476                        }
    380477
    381                                         menu.AddItem( 'ScaytContext', 'Ignore', null, false, { 'action' : 'Ignore', 'node' : node } );
    382                                         menu.AddItem( 'ScaytContext', 'Ignore All', null, false, { 'action' : 'Ignore All', 'node' : node } );
    383                                         menu.AddItem( 'ScaytContext', 'Add Word', null, false, { 'action' : 'Add Word', 'node' : node } );
     478                        if (mmode.isin('ignoreall')) {
     479                            o.action = 'Ignore All';
     480                            menu.AddItem( 'ScaytContext', 'Ignore All', null, false, o );
     481                        }
     482                    }
    384483                                        try
    385484                                        {
    386485                                                if (scaytReady && scaytEnable)
     
    405504                {
    406505                        if ( FCKConfig.SpellChecker == 'SCAYT' )
    407506                        {
    408                                 if ( !isEngineLoaded && FCK.Config.ScaytAutoStartup )
    409                                         ScaytEngineLoad() ;
     507                                // put loading other instances of FCKeditor into a queue until all SCAYT files will be loaded and SCAYT initialized
     508                                if (FCK.EditMode == FCK_EDITMODE_WYSIWYG && typeof(FCK.EditorWindow.parent.parent.window.CKEDITOR) != "undefined" && FCK.EditorWindow.parent.parent.window.CKEDITOR._djScaytConfig.initingScayt) {
     509                                        FCK.EditorWindow.parent.parent.window.CKEDITOR._djScaytConfig.afterScaytInitQueue.push(function () {
     510                                                if ( !isEngineLoaded && FCK.Config.ScaytAutoStartup )
     511                                                        ScaytEngineLoad() ;
     512                                               
     513                                                if ( FCK.EditMode == FCK_EDITMODE_WYSIWYG && isEngineLoaded && scaytReady ) {
     514                                                        createScaytControl();
     515                                                        var scayt_control = window.scayt_control;
     516                                                        var agt = navigator.userAgent.toLowerCase();
     517                                                        var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
     518                                                        if (is_ie) {
     519                                                                scayt_control.disabled = !scaytEnable;
     520                                                                scaytEnable = !scayt_control.disabled;
     521                                                        }
     522                                                        else {
     523                                                                var ScaytCombobox = FCKToolbarItems.GetItem( 'SpellCheck' );
     524                                                                ScaytCombobox && ScaytCombobox.Command.SetEnabled( scaytEnable ) ;
     525                                                        }
     526                                                }
     527                                               
     528                                                ShowScaytState() ;
     529                                        });
     530                                        return;
     531                                }
     532                                else {
     533                                        if ( !isEngineLoaded && FCK.Config.ScaytAutoStartup )
     534                                                ScaytEngineLoad() ;
     535                                       
     536                                        if ( FCK.EditMode == FCK_EDITMODE_WYSIWYG && isEngineLoaded && scaytReady ) {
     537                                                createScaytControl();
     538                                                var scayt_control = window.scayt_control;
     539                                                //restore SCAYT state
     540                                                var ScaytCombobox = FCKToolbarItems.GetItem( 'SpellCheck' );
     541                                                ScaytCombobox && ScaytCombobox.Command.SetEnabled( scaytEnable ) ;
     542                                        }
    410543
    411                                 if ( FCK.EditMode == FCK_EDITMODE_WYSIWYG && isEngineLoaded && scaytReady )
    412                                         createScaytControl();
    413 
    414                                 ShowScaytState() ;
     544                                        ShowScaytState() ;
     545                                }
    415546                        }
    416547                } ) ;
    417548
    418549        FCK.Events.AttachEvent( 'OnBeforeGetData', function()
    419550                {
    420                         scaytReady && window.scayt_control.reset();
     551                        if (scaytReady) {
     552                                //save ID for restoring control in future, reset and destroy control when entering "Source mode"
     553                                savedID = window.scayt_control.id;
     554                                window.scayt_control.reset();
     555                                window.scayt_control.destroy(true);
     556                        }
    421557                } ) ;
    422558
    423         FCK.Events.AttachEvent( 'OnAfterGetData', function()
    424                 {
    425                         scaytReady && window.scayt_control.refresh();
    426                 } ) ;
    427 
    428559        // ###
    429560        // The main object that holds the SCAYT interaction in the code.
    430561        FCKScayt =
     
    441572
    442573                CreateToolbarItem : function()
    443574                {
    444                         return new ToolbarScaytComboBox() ;
     575                        var tabs  = FCK.Config.ScaytUiTabs || "1,1,1";
     576            tabs = tabs.split(',');
     577
     578            for (var i=0,l=3; i<l; i++){
     579                uiTabs.push(  parseInt(tabs[i],2) );
     580            }
     581            uiTabs[uiTabs.length] = 1;
     582
     583            return new ToolbarScaytComboBox() ;
    445584                }
    446585        } ;
    447586})() ;
  • editor/dialog/fck_scayt.html

     
    3838                        var     fckLang;
    3939            var chosed_lang;
    4040                        var options;
    41                         var     tabs = scayt_control.uiTags || [1,1,0,1];
     41                        var uiTabs = oEditor.FCKScayt.scayt_ui_tabs;
     42                        var     tabs = uiTabs || scayt_control.uiTags;
    4243                        var     userDicActive = tabs[2] == 1;
    4344                        var     captions;
    4445                        var dic_buttons = [
     
    286287                        if (!scayt) throw "SCAYT is undefined";
    287288                        if (!scayt_control) throw "SCAYT_CONTROL is undefined";
    288289
    289                                         // show alowed tabs
    290                                         tabs = scayt_control.uiTags || [1,1,1,0];
    291 
    292 
    293290                                        sLang = scayt_control.getLang();
    294291                        fckLang = "en";
    295292                                        options = scayt_control.option();
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy