Ticket #4667: 4667.patch

File 4667.patch, 13.3 KB (added by WebSpellChecker.net, 14 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                        for ( i=0, l = uiTabs.length; i<l ; i ++){
     155                uiTabs[i] = uiTabs[i] && scayt.uiTags[i];
     156            }
    140157
    141                 for ( var i = 0 ; i < scaytOnLoad.length ; i++ )
    142                 {
    143                         try
     158                        FCKScayt.scayt_ui_tabs = uiTabs;
     159
     160                        for ( var i = 0 ; i < scaytOnLoad.length ; i++ )
    144161                        {
    145                                 scaytOnLoad[i].call( this ) ;
     162                                try
     163                                {
     164                                        scaytOnLoad[i].call( this ) ;
     165                                }
     166                                catch(err)
     167                                {}
    146168                        }
    147                         catch(err)
    148                         {}
    149169                }
    150170        }
    151171
     
    162182                {
    163183                        case 'Options' :
    164184                        case 'Langs' :
     185                        case 'Dictionary' :
    165186                        case 'About' :
    166187                                if ( isEngineLoaded && scaytReady && !scaytEnable )
    167188                                {
     
    247268
    248269                if ( scaytEnable )
    249270                {
    250                         bItem.style.opacity = '1' ;
     271                        setElementOpacity(bItem,1);
    251272                        dNode.innerHTML = GetStatusLabel() ;
    252273                }
    253274                else
    254275                {
    255                         bItem.style.opacity = '0.5' ;
     276                        setElementOpacity(bItem,0.5);
    256277                        dNode.innerHTML = GetStatusLabel() ;
    257278                }
    258279        }
     
    282303        ToolbarScaytComboBox.prototype.CreateItems = function()
    283304        {
    284305                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");
     306        if (uiTabs[0])
     307            this._Combo.AddItem( 'Options', FCKLang.ScaytTitleOptions || "Options"  );
     308        if (uiTabs[1])
     309            this._Combo.AddItem( 'Langs', FCKLang.ScaytTitleLangs || "Languages");
     310        if (uiTabs[2])
     311            this._Combo.AddItem( 'Dictionary', FCKLang.ScaytTitleDict || "Dictionaries");
     312        this._Combo.AddItem( 'About', FCKLang.ScaytTitleAbout || "About");
    288313        }
    289314
    290315        // Label shown in the toolbar.
     
    334359                        }
    335360                }
    336361        }
     362       
     363        // functions to set opacity of an element properly in all browsers
     364        function setElementOpacity(elem, nOpacity)
     365        {
     366          var opacityProp = getOpacityProperty();
     367         
     368          if (!elem || !opacityProp) return;
     369         
     370          if (opacityProp=="filter")  // Internet Exploder 5.5+
     371          {
     372                nOpacity *= 100;
     373               
     374                var oAlpha = elem.filters['DXImageTransform.Microsoft.alpha'] || elem.filters.alpha;
     375                if (oAlpha) oAlpha.opacity = nOpacity;
     376                else elem.style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity="+nOpacity+")";
     377          }
     378          else
     379                elem.style[opacityProp] = nOpacity;
     380        }
    337381
     382        function getOpacityProperty()
     383        {
     384          if (typeof document.body.style.opacity == 'string') // CSS3 compliant (Moz 1.7+, Safari 1.2+, Opera 9)
     385                return 'opacity';
     386          else if (typeof document.body.style.MozOpacity == 'string') // Mozilla 1.6, Firefox 0.8
     387                return 'MozOpacity';
     388          else if (typeof document.body.style.KhtmlOpacity == 'string') // Konqueror 3.1, Safari 1.1
     389                return 'KhtmlOpacity';
     390          else if (document.body.filters && navigator.appVersion.match(/MSIE ([\d.]+);/)[1]>=5.5) // Internet Exploder 5.5+
     391                return 'filter';
     392
     393          return false;
     394        }
     395       
    338396        // Register context menu listeners.
    339397        function InitSetup()
    340398        {
     
    360418                                        if ( !suggestions || !suggestions.length )
    361419                                                return;
    362420
    363                                         menu.AddSeparator() ;
    364 
    365421                                        var maxSuggestions = FCK.Config.ScaytMaxSuggestions || 5 ;
    366422                                        var suggAveCount = ( maxSuggestions == -1 ) ? suggestions.length : maxSuggestions ;
     423                                        var mmode = FCK.Config.ScaytContextCommands || 'all';
     424                   
     425                    mmode = mmode.split("|");
     426                        mmode = {
     427                            all: false,
     428                            off: false,
     429                            asis: mmode,
     430                            isin: function(s){
     431                                if (this.off)
     432                                    return false;
     433                                if (this.all)
     434                                    return true;
    367435
     436                                return this.is(s);
     437                            },
     438                            is: function(s){
     439                                for (var i = 0, l = this.asis.length; i < l; i++)
     440                                    if (this.asis[i] == s)
     441                                        return true;
     442                                return false;
     443                            }
     444                        };
     445
     446                        if (mmode.is("off")) {
     447                            mmode.off = true;
     448                            mmode.all = false;
     449                        }
     450                        if (mmode.is("all")) {
     451                            mmode.off = false;
     452                            mmode.all = true;
     453                        }
     454
     455                    menu.AddSeparator() ;
     456                                       
    368457                                        for ( var i = 0 ; i < suggAveCount ; i += 1 )
    369458                                        {
    370459                                                if ( suggestions[i] )
     
    376465                                                }
    377466                                        }
    378467
    379                                         menu.AddSeparator() ;
     468                                        if (mmode.off !== true) {
     469                        menu.AddSeparator() ;
     470                        var o = {};
     471                            o.node = node;
     472                           
     473                        if (mmode.isin('add')) {
     474                            o.action = 'Add Word';
     475                            menu.AddItem( 'ScaytContext', 'Add Word', null, false, o );
     476                        }
     477                        if (mmode.isin('ignore')) {
     478                            o.action = 'Ignore';
     479                            menu.AddItem( 'ScaytContext', 'Ignore', null, false, o );
     480                        }
    380481
    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 } );
     482                        if (mmode.isin('ignoreall')) {
     483                            o.action = 'Ignore All';
     484                            menu.AddItem( 'ScaytContext', 'Ignore All', null, false, o );
     485                        }
     486                    }
    384487                                        try
    385488                                        {
    386489                                                if (scaytReady && scaytEnable)
     
    405508                {
    406509                        if ( FCKConfig.SpellChecker == 'SCAYT' )
    407510                        {
    408                                 if ( !isEngineLoaded && FCK.Config.ScaytAutoStartup )
    409                                         ScaytEngineLoad() ;
     511                                // put loading other instances of FCKeditor into a queue until all SCAYT files will be loaded and SCAYT initialized
     512                                if (FCK.EditMode == FCK_EDITMODE_WYSIWYG && typeof(FCK.EditorWindow.parent.parent.window.CKEDITOR) != "undefined" && FCK.EditorWindow.parent.parent.window.CKEDITOR._djScaytConfig.initingScayt) {
     513                                        FCK.EditorWindow.parent.parent.window.CKEDITOR._djScaytConfig.afterScaytInitQueue.push(function () {
     514                                                if ( !isEngineLoaded && FCK.Config.ScaytAutoStartup )
     515                                                        ScaytEngineLoad() ;
     516                                               
     517                                                if ( FCK.EditMode == FCK_EDITMODE_WYSIWYG && isEngineLoaded && scaytReady ) {
     518                                                        createScaytControl();
     519                                                        var scayt_control = window.scayt_control;
     520                                                        var agt = navigator.userAgent.toLowerCase();
     521                                                        var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
     522                                                        if (is_ie) {
     523                                                                scayt_control.disabled = !scaytEnable;
     524                                                                scaytEnable = !scayt_control.disabled;
     525                                                        }
     526                                                        else {
     527                                                                var ScaytCombobox = FCKToolbarItems.GetItem( 'SpellCheck' );
     528                                                                ScaytCombobox && ScaytCombobox.Command.SetEnabled( scaytEnable ) ;
     529                                                        }
     530                                                }
     531                                               
     532                                                ShowScaytState() ;
     533                                        });
     534                                        return;
     535                                }
     536                                else {
     537                                        if ( !isEngineLoaded && FCK.Config.ScaytAutoStartup )
     538                                                ScaytEngineLoad() ;
     539                                       
     540                                        if ( FCK.EditMode == FCK_EDITMODE_WYSIWYG && isEngineLoaded && scaytReady ) {
     541                                                createScaytControl();
     542                                                var scayt_control = window.scayt_control;
     543                                                //restore SCAYT state
     544                                                var agt = navigator.userAgent.toLowerCase();
     545                                                var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
     546                                                //needs this trick to work in IE
     547                                                if (is_ie) {
     548                                                        scayt_control.disabled = !scaytEnable;
     549                                                        scaytEnable = !scayt_control.disabled;
     550                                                }
     551                                                else {
     552                                                        var ScaytCombobox = FCKToolbarItems.GetItem( 'SpellCheck' );
     553                                                        ScaytCombobox && ScaytCombobox.Command.SetEnabled( scaytEnable ) ;
     554                                                }
     555                                        }
    410556
    411                                 if ( FCK.EditMode == FCK_EDITMODE_WYSIWYG && isEngineLoaded && scaytReady )
    412                                         createScaytControl();
    413 
    414                                 ShowScaytState() ;
     557                                        ShowScaytState() ;
     558                                }
    415559                        }
    416560                } ) ;
    417561
    418562        FCK.Events.AttachEvent( 'OnBeforeGetData', function()
    419563                {
    420                         scaytReady && window.scayt_control.reset();
     564                        if (scaytReady) {
     565                                //save ID for restoring control in future, reset and destroy control when entering "Source mode"
     566                                savedID = window.scayt_control.id;
     567                                window.scayt_control.reset();
     568                                window.scayt_control.destroy(true);
     569                        }
    421570                } ) ;
    422571
    423         FCK.Events.AttachEvent( 'OnAfterGetData', function()
    424                 {
    425                         scaytReady && window.scayt_control.refresh();
    426                 } ) ;
    427 
    428572        // ###
    429573        // The main object that holds the SCAYT interaction in the code.
    430574        FCKScayt =
     
    441585
    442586                CreateToolbarItem : function()
    443587                {
    444                         return new ToolbarScaytComboBox() ;
     588                        var tabs  = FCK.Config.ScaytUiTabs || "1,1,1";
     589            tabs = tabs.split(',');
     590
     591            for (var i=0,l=3; i<l; i++){
     592                var flag = parseInt(tabs[i] || "1");
     593                uiTabs.push(  flag   );
     594            }
     595            uiTabs[uiTabs.length] = 1;
     596
     597            return new ToolbarScaytComboBox() ;
    445598                }
    446599        } ;
    447600})() ;
  • 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 || [1,1,1,1];
    4243                        var     userDicActive = tabs[2] == 1;
    4344                        var     captions;
    4445                        var dic_buttons = [
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy