Ticket #7084: 7084_2.patch

File 7084_2.patch, 17.6 KB (added by Wiktor Walc, 13 years ago)
  • _source/plugins/scayt/dialogs/options.js

     
    88        var firstLoad = true,
    99                captions,
    1010                doc = CKEDITOR.document,
    11                 tags = [],
     11                editorName = editor.name,
     12                tags = CKEDITOR.plugins.scayt.getUiTabs( editor ),
    1213                i,
    1314                contents = [],
    1415                userDicActive = 0,
    1516                dic_buttons = [
    1617                        // [0] contains buttons for creating
    17                         "dic_create,dic_restore",
     18                        "dic_create_" + editorName + ",dic_restore_" + editorName,
    1819                        // [1] contains buton for manipulation
    19                         "dic_rename,dic_delete"
     20                        "dic_rename_" + editorName + ",dic_delete_" + editorName
    2021                ],
    2122                optionsIds = [ 'mixedCase', 'mixedWithDigits', 'allCaps', 'ignoreDomainNames' ];
    2223
     
    2425
    2526        function getBOMAllOptions()
    2627        {
    27                  return document.forms.optionsbar["options"];
     28                if (typeof document.forms["optionsbar_" + editorName] != "undefined")
     29                        return document.forms["optionsbar_" + editorName]["options"];
     30                return [];
    2831        }
    2932        function getBOMAllLangs()
    3033        {
    31                  return document.forms.languagesbar["scayt_lang"];
     34                if (typeof document.forms["languagesbar_" + editorName] != "undefined")
     35                        return document.forms["languagesbar_" + editorName]["scayt_lang"];
     36                return [];
    3237        }
    3338
    3439        function setCheckedValue( radioObj, newValue )
     
    5863                                                {
    5964                                                        type : 'html',
    6065                                                        id : 'options',
    61                                                         html :  '<form name="optionsbar"><div class="inner_options">' +
     66                                                        html :  '<form name="optionsbar_' + editorName + '"><div class="inner_options">' +
    6267                                                                        '       <div class="messagebox"></div>' +
    6368                                                                        '       <div style="display:none;">' +
    64                                                                         '               <input type="checkbox" name="options"  id="allCaps" />' +
    65                                                                         '               <label for="allCaps" id="label_allCaps"></label>' +
     69                                                                        '               <input type="checkbox" name="options"  id="allCaps_' + editorName + '" />' +
     70                                                                        '               <label for="allCaps" id="label_allCaps_' + editorName + '"></label>' +
    6671                                                                        '       </div>' +
    6772                                                                        '       <div style="display:none;">' +
    68                                                                         '               <input name="options" type="checkbox"  id="ignoreDomainNames" />' +
    69                                                                         '               <label for="ignoreDomainNames" id="label_ignoreDomainNames"></label>' +
     73                                                                        '               <input name="options" type="checkbox"  id="ignoreDomainNames_' + editorName + '" />' +
     74                                                                        '               <label for="ignoreDomainNames" id="label_ignoreDomainNames_' + editorName + '"></label>' +
    7075                                                                        '       </div>' +
    7176                                                                        '       <div style="display:none;">' +
    72                                                                         '       <input name="options" type="checkbox"  id="mixedCase" />' +
    73                                                                         '               <label for="mixedCase" id="label_mixedCase"></label>' +
     77                                                                        '       <input name="options" type="checkbox"  id="mixedCase_' + editorName + '" />' +
     78                                                                        '               <label for="mixedCase" id="label_mixedCase_' + editorName + '"></label>' +
    7479                                                                        '       </div>' +
    7580                                                                        '       <div style="display:none;">' +
    76                                                                         '               <input name="options" type="checkbox"  id="mixedWithDigits" />' +
    77                                                                         '               <label for="mixedWithDigits" id="label_mixedWithDigits"></label>' +
     81                                                                        '               <input name="options" type="checkbox"  id="mixedWithDigits_' + editorName + '" />' +
     82                                                                        '               <label for="mixedWithDigits" id="label_mixedWithDigits_' + editorName + '"></label>' +
    7883                                                                        '       </div>' +
    7984                                                                        '</div></form>'
    8085                                                }
     
    8792                                                {
    8893                                                        type : 'html',
    8994                                                        id : 'langs',
    90                                                         html :  '<form name="languagesbar"><div class="inner_langs">' +
     95                                                        html :  '<form name="languagesbar_' + editorName + '"><div class="inner_langs">' +
    9196                                                                        '       <div class="messagebox"></div>  ' +
    92                                                                         '   <div style="float:left;width:45%;margin-left:5px;" id="scayt_lcol" ></div>' +
    93                                                                         '   <div style="float:left;width:45%;margin-left:15px;" id="scayt_rcol"></div>' +
     97                                                                        '   <div style="float:left;width:45%;margin-left:5px;" id="scayt_lcol_' + editorName + '" ></div>' +
     98                                                                        '   <div style="float:left;width:45%;margin-left:15px;" id="scayt_rcol_' + editorName + '"></div>' +
    9499                                                                        '</div></form>'
    95100                                                }
    96101                                        ]
     
    103108                                                        type : 'html',
    104109                                                        style: '',
    105110                                                        id : 'dictionaries',
    106                                                         html :  '<form name="dictionarybar"><div class="inner_dictionary" style="text-align:left; white-space:normal; width:320px; overflow: hidden;">' +
    107                                                                         '       <div style="margin:5px auto; width:80%;white-space:normal; overflow:hidden;" id="dic_message"> </div>' +
     111                                                        html :  '<form name="dictionarybar_' + editorName + '"><div class="inner_dictionary" style="text-align:left; white-space:normal; width:320px; overflow: hidden;">' +
     112                                                                        '       <div style="margin:5px auto; width:80%;white-space:normal; overflow:hidden;" id="dic_message_' + editorName + '"> </div>' +
    108113                                                                        '       <div style="margin:5px auto; width:80%;white-space:normal;"> ' +
    109114                                                                        '       <span class="cke_dialog_ui_labeled_label" >Dictionary name</span><br>'+
    110115                                                                        '               <span class="cke_dialog_ui_labeled_content" >'+
    111116                                                                        '                       <div class="cke_dialog_ui_input_text">'+
    112                                                                         '                               <input id="dic_name" type="text" class="cke_dialog_ui_input_text"/>'+
     117                                                                        '                               <input id="dic_name_' + editorName + '" type="text" class="cke_dialog_ui_input_text"/>'+
    113118                                                                        '               </div></span></div>'+
    114119                                                                        '               <div style="margin:5px auto; width:80%;white-space:normal;">'+
    115                                                                         '                       <a style="display:none;" class="cke_dialog_ui_button" href="javascript:void(0)" id="dic_create">'+
     120                                                                        '                       <a style="display:none;" class="cke_dialog_ui_button" href="javascript:void(0)" id="dic_create_' + editorName + '">'+
    116121                                                                        '                               </a>' +
    117                                                                         '                       <a  style="display:none;" class="cke_dialog_ui_button" href="javascript:void(0)" id="dic_delete">'+
     122                                                                        '                       <a  style="display:none;" class="cke_dialog_ui_button" href="javascript:void(0)" id="dic_delete_' + editorName + '">'+
    118123                                                                        '                               </a>' +
    119                                                                         '                       <a  style="display:none;" class="cke_dialog_ui_button" href="javascript:void(0)" id="dic_rename">'+
     124                                                                        '                       <a  style="display:none;" class="cke_dialog_ui_button" href="javascript:void(0)" id="dic_rename_' + editorName + '">'+
    120125                                                                        '                               </a>' +
    121                                                                         '                       <a  style="display:none;" class="cke_dialog_ui_button" href="javascript:void(0)" id="dic_restore">'+
     126                                                                        '                       <a  style="display:none;" class="cke_dialog_ui_button" href="javascript:void(0)" id="dic_restore_' + editorName + '">'+
    122127                                                                        '                               </a>' +
    123128                                                                        '               </div>' +
    124                                                                         '       <div style="margin:5px auto; width:95%;white-space:normal;" id="dic_info"></div>' +
     129                                                                        '       <div style="margin:5px auto; width:95%;white-space:normal;" id="dic_info_' + editorName + '"></div>' +
    125130                                                                        '</div></form>'
    126131                                                }
    127132                                        ]
     
    134139                                                        type : 'html',
    135140                                                        id : 'about',
    136141                                                        style : 'margin: 5px 5px;',
    137                                                         html : '<div id="scayt_about"></div>'
     142                                                        html : '<div id="scayt_about_' + editorName + '"></div>'
    138143                                                }
    139144                                        ]
    140145                                }
     
    149154                        var dialog = this;
    150155                        dialog.data = editor.fire( 'scaytDialog', {} );
    151156                        dialog.options = dialog.data.scayt_control.option();
    152                         dialog.sLang = dialog.data.scayt_control.sLang;
    153 
     157                        dialog.chosed_lang = dialog.sLang = dialog.data.scayt_control.sLang;
     158                       
    154159                        if ( !dialog.data || !dialog.data.scayt || !dialog.data.scayt_control )
    155160                        {
    156161                                alert( 'Error loading application service' );
     
    180185                {
    181186                        var scayt_control =  this.data.scayt_control;
    182187                        scayt_control.option( this.options );
    183                         // Setup languge if it was changed.
     188                        // Setup language if it was changed.
    184189                        var csLang = this.chosed_lang;
    185190                        scayt_control.setLang( csLang );
    186191                        scayt_control.refresh();
     
    198203
    199204        var scayt_control = CKEDITOR.plugins.scayt.getScayt( editor );
    200205
    201         tags = CKEDITOR.plugins.scayt.uiTabs;
    202 
    203         for ( i in tags )
     206        for ( var i = 0; i < tags.length; i++ )
    204207        {
    205208                if ( tags[ i ] == 1 )
    206209                        contents[ contents.length ] = tags_contents[ i ];
     
    208211        if ( tags[2] == 1 )
    209212                userDicActive = 1;
    210213
    211 
    212214        var init_with_captions = function()
    213215        {
    214216                var dialog = this,
    215217                        lang_list = dialog.data.scayt.getLangList(),
    216                         buttons = [ 'dic_create', 'dic_delete', 'dic_rename', 'dic_restore' ],
     218                        buttonCaptions = [ 'dic_create', 'dic_delete', 'dic_rename', 'dic_restore' ],
     219                        buttonIds = [],
     220                        langList = [],
    217221                        labels = optionsIds,
    218222                        i;
    219223
    220224                // Add buttons titles
    221225                if ( userDicActive )
    222226                {
    223                         for ( i = 0; i < buttons.length; i++ )
     227                        for ( i = 0; i < buttonCaptions.length; i++ )
    224228                        {
    225                                 var button = buttons[ i ];
    226                                 doc.getById( button ).setHtml( '<span class="cke_dialog_ui_button">' + captions[ 'button_' + button]  +'</span>' );
     229                                buttonIds[ i ] = buttonCaptions[ i ] + "_" + editorName;
     230                                doc.getById( buttonIds[ i ] ).setHtml( '<span class="cke_dialog_ui_button">' + captions[ 'button_' + buttonCaptions[ i ]]  +'</span>' );
    227231                        }
    228                         doc.getById( 'dic_info' ).setHtml( captions[ 'dic_info' ] );
     232                        doc.getById( 'dic_info_' + editorName ).setHtml( captions[ 'dic_info' ] );
    229233                }
    230234
    231 
    232235                // Fill options and dictionary labels.
    233236                if ( tags[0] == 1 )
    234237                {
    235238                        for ( i in labels )
    236239                        {
    237                                 var label = 'label_' + labels[ i ],
    238                                         labelElement = doc.getById( label );
    239 
     240                                var labelCaption = 'label_' + labels[ i ],
     241                                        labelId = labelCaption + '_' + editorName,
     242                                        labelElement = doc.getById( labelId );
     243                               
    240244                                if (  'undefined' != typeof labelElement
    241                                    && 'undefined' != typeof captions[ label ]
     245                                   && 'undefined' != typeof captions[ labelCaption ]
    242246                                   && 'undefined' != typeof dialog.options[labels[ i ]] )
    243247                                {
    244                                         labelElement.setHtml( captions[ label ] );
     248                                        labelElement.setHtml( captions[ labelCaption ] );
    245249                                        var labelParent = labelElement.getParent();
    246250                                        labelParent.$.style.display = "block";
    247251                                }
     
    252256                                '<p>' + captions[ 'version' ] + window.scayt.getAboutInfo().version.toString() + '</p>' +
    253257                                '<p>' + captions[ 'about_throwt_copy' ] + '</p>';
    254258
    255                 doc.getById( 'scayt_about' ).setHtml( about );
     259                doc.getById( 'scayt_about_' + editorName ).setHtml( about );
    256260
    257261                // Create languages tab.
    258262                var createOption = function( option, list )
     
    286290                        };
    287291                };
    288292
    289                 var langList = [];
    290293                if ( tags[1] ==1 )
    291294                {
    292295                        for ( i in lang_list.rtl )
     
    300303                                        return ( lang2.lang > lang1.lang ) ? -1 : 1 ;
    301304                                });
    302305
    303                         var fieldL = doc.getById( 'scayt_lcol' ),
    304                                 fieldR = doc.getById( 'scayt_rcol' );
     306                        var fieldL = doc.getById( 'scayt_lcol_' + editorName ),
     307                                fieldR = doc.getById( 'scayt_rcol_' + editorName );
    305308                        for ( i=0; i < langList.length; i++ )
    306309                        {
    307310                                var field = ( i < langList.length / 2 ) ? fieldL : fieldR;
     
    403406
    404407                function onDicButtonClick( ev )
    405408                {
    406                         var dic_name = doc.getById('dic_name').getValue();
     409                        var dic_name = doc.getById('dic_name_' + editorName).getValue();
    407410                        if ( !dic_name )
    408411                        {
    409412                                dic_error_message(" Dictionary name should not be empty. ");
    410413                                return false;
    411414                        }
    412415                        try{
    413                                 var el = id = ev.data.getTarget().getParent();
    414                                 var id = el.getId();
     416                                var el = ev.data.getTarget().getParent();
     417                                var id = /(dic_\w+)_[\w\d]+/.exec(el.getId())[1];
    415418                                dic[ id ].apply( null, [ el, dic_name, dic_buttons ] );
    416419                        }
    417420                        catch(err)
     
    452455                                {
    453456                                        opto[k].checked = false;
    454457                                        //alert (opto[k].removeAttribute)
    455                                         if ( dialog.options[ i ] == 1 )
     458                                        if ( dialog.options[ i.split("_")[0] ] == 1 )
    456459                                        {
    457460                                                opto[k].checked = true;
    458461                                        }
     
    463466                                        {
    464467                                                checkbox.on( 'click', function()
    465468                                                {
    466                                                         dialog.options[ this.getId() ] = this.$.checked ? 1 : 0 ;
     469                                                        dialog.options[ this.getId().split("_")[0] ] = this.$.checked ? 1 : 0 ;
    467470                                                });
    468471                                        }
    469472                                }
     
    487490                                        hide_dic_buttons( dic_buttons[0] + ',' + dic_buttons[1] );
    488491                                        if ( dic_name )
    489492                                        {
    490                                                 doc.getById( 'dic_name' ).setValue(dic_name);
     493                                                doc.getById( 'dic_name_' + editorName ).setValue(dic_name);
    491494                                                display_dic_buttons( dic_buttons[1] );
    492495                                        }
    493496                                        else
     
    496499                                },
    497500                                function()
    498501                                {
    499                                         doc.getById( 'dic_name' ).setValue("");
     502                                        doc.getById( 'dic_name_' + editorName ).setValue("");
    500503                                });
    501504                        dic_success_message("");
    502505                }
     
    505508
    506509        function dic_error_message( m )
    507510        {
    508                 doc.getById('dic_message').setHtml('<span style="color:red;">' + m + '</span>' );
     511                doc.getById('dic_message_' + editorName).setHtml('<span style="color:red;">' + m + '</span>' );
    509512        }
    510513        function dic_success_message( m )
    511514        {
    512                 doc.getById('dic_message').setHtml('<span style="color:blue;">' + m + '</span>') ;
     515                doc.getById('dic_message_' + editorName).setHtml('<span style="color:blue;">' + m + '</span>') ;
    513516        }
    514517        function display_dic_buttons( sIds )
    515518        {
     
    527530        }
    528531        function set_dic_name( dic_name )
    529532        {
    530                 doc.getById('dic_name').$.value= dic_name;
     533                doc.getById('dic_name_' + editorName).$.value= dic_name;
    531534        }
    532535
    533536        return dialogDefiniton;
  • _source/plugins/scayt/plugin.js

     
    9595
    9696                        plugin.instances[ editor.name ] = scayt_control;
    9797
    98                         //window.scayt.uiTags
    99                         var menuGroup = 'scaytButton';
    100                         var uiTabs = window.scayt.uiTags;
    101                         var fTabs  = [];
    102 
    103                         for ( var i = 0, l=4; i < l; i++ )
    104                             fTabs.push( uiTabs[i] && plugin.uiTabs[i] );
    105 
    106                         plugin.uiTabs = fTabs;
    10798                        try {
    10899                                scayt_control.setDisabled( plugin.isPaused( editor ) === false );
    109100                        } catch (e) {}
     
    356347                        var scayt_instance = this.getScayt( editor );
    357348                        return ( scayt_instance ) ? scayt_instance.disabled === false : false;
    358349                },
     350                getUiTabs : function( editor )
     351                {
     352                        var uiTabs = [];
     353                       
     354                        // read UI tabs value from config
     355                        var configUiTabs = editor.config.scayt_uiTabs || "1,1,1";
     356                       
     357                        // convert string to array
     358                        configUiTabs = configUiTabs.split( ',' );
     359                       
     360                        // "About us" should be always shown for standard config
     361                        configUiTabs[3] = "1";
     362                       
     363                        for ( var i = 0; i < 4; i++ ) {
     364                                uiTabs[i] = (typeof window.scayt != "undefined" && typeof window.scayt.uiTags != "undefined")
     365                                                                ? (parseInt(configUiTabs[i],10) && window.scayt.uiTags[i])
     366                                                                : parseInt(configUiTabs[i],10);
     367                        }
     368                        return uiTabs;
     369                },
    359370                loadEngine : function( editor )
    360371                {
    361372                        // SCAYT doesn't work with Firefox2, Opera and AIR.
     
    528539
    529540                        // Add Options dialog.
    530541                        CKEDITOR.dialog.add( commandName, CKEDITOR.getUrl( this.path + 'dialogs/options.js' ) );
    531                         // read ui tags
    532                         var confuiTabs = editor.config.scayt_uiTabs || '1,1,1';
    533                         var uiTabs =[];
    534                         // string to array convert
    535                         confuiTabs = confuiTabs.split( ',' );
    536                         // check array length ! always must be 3 filled with 1 or 0
    537                         for ( var i=0, l=3; i < l; i++ )
    538                         {
    539                                 var flag = parseInt( confuiTabs[i] || '1', 10 );
    540                                 uiTabs.push( flag );
    541                         }
    542 
     542               
     543                        var uiTabs = plugin.getUiTabs( editor );
     544                       
    543545                        var menuGroup = 'scaytButton';
    544546                        editor.addMenuGroup( menuGroup );
    545547                        // combine menu items to render
    546                         var uiMuneItems = {};
     548                        var uiMenuItems = {};
    547549
    548550                        var lang = editor.lang.scayt;
    549551
    550552                        // always added
    551                         uiMuneItems.scaytToggle =
     553                        uiMenuItems.scaytToggle =
    552554                                {
    553555                                        label : lang.enable,
    554556                                        command : commandName,
     
    556558                                };
    557559
    558560                        if ( uiTabs[0] == 1 )
    559                                 uiMuneItems.scaytOptions =
     561                                uiMenuItems.scaytOptions =
    560562                                {
    561563                                        label : lang.options,
    562564                                        group : menuGroup,
     
    568570                                };
    569571
    570572                        if ( uiTabs[1] == 1 )
    571                                 uiMuneItems.scaytLangs =
     573                                uiMenuItems.scaytLangs =
    572574                                {
    573575                                        label : lang.langs,
    574576                                        group : menuGroup,
     
    579581                                        }
    580582                                };
    581583                        if ( uiTabs[2] == 1 )
    582                                 uiMuneItems.scaytDict =
     584                                uiMenuItems.scaytDict =
    583585                                {
    584586                                        label : lang.dictionariesTab,
    585587                                        group : menuGroup,
     
    590592                                        }
    591593                                };
    592594                        // always added
    593                         uiMuneItems.scaytAbout =
     595                        uiMenuItems.scaytAbout =
    594596                                {
    595597                                        label : editor.lang.scayt.about,
    596598                                        group : menuGroup,
     
    600602                                                editor.openDialog( commandName );
    601603                                        }
    602604                                };
     605               
     606                        editor.addMenuItems( uiMenuItems );
    603607
    604                         uiTabs[3] = 1; // about us tab is always on
    605                         plugin.uiTabs = uiTabs;
    606 
    607                         editor.addMenuItems( uiMuneItems );
    608 
    609608                                editor.ui.add( 'Scayt', CKEDITOR.UI_MENUBUTTON,
    610609                                        {
    611610                                                label : lang.title,
     
    625624                                                        var isEnabled = plugin.isScaytEnabled( editor );
    626625
    627626                                                        editor.getMenuItem( 'scaytToggle' ).label = lang[ isEnabled ? 'disable' : 'enable' ];
    628 
     627                                                       
     628                                                        var uiTabs = plugin.getUiTabs( editor );
     629                                                       
    629630                                                        return {
    630631                                                                scaytToggle  : CKEDITOR.TRISTATE_OFF,
    631                                                                 scaytOptions : isEnabled && plugin.uiTabs[0] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED,
    632                                                                 scaytLangs   : isEnabled && plugin.uiTabs[1] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED,
    633                                                                 scaytDict    : isEnabled && plugin.uiTabs[2] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED,
    634                                                                 scaytAbout   : isEnabled && plugin.uiTabs[3] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED
     632                                                                scaytOptions : isEnabled && uiTabs[0] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED,
     633                                                                scaytLangs   : isEnabled && uiTabs[1] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED,
     634                                                                scaytDict    : isEnabled && uiTabs[2] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED,
     635                                                                scaytAbout   : isEnabled && uiTabs[3] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED
    635636                                                        };
    636637                                                }
    637638                                        });
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy