JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.5.3
[ckeditor.git] / _source / plugins / scayt / dialogs / options.js
index ca7d53f..3bd9916 100644 (file)
@@ -8,15 +8,16 @@ CKEDITOR.dialog.add( 'scaytcheck', function( editor )
        var firstLoad = true,\r
                captions,\r
                doc = CKEDITOR.document,\r
-               tags = [],\r
+               editorName = editor.name,\r
+               tags = CKEDITOR.plugins.scayt.getUiTabs( editor ),\r
                i,\r
                contents = [],\r
                userDicActive = 0,\r
                dic_buttons = [\r
                        // [0] contains buttons for creating\r
-                       "dic_create,dic_restore",\r
+                       "dic_create_" + editorName + ",dic_restore_" + editorName,\r
                        // [1] contains buton for manipulation\r
-                       "dic_rename,dic_delete"\r
+                       "dic_rename_" + editorName + ",dic_delete_" + editorName\r
                ],\r
                optionsIds = [ 'mixedCase', 'mixedWithDigits', 'allCaps', 'ignoreDomainNames' ];\r
 \r
@@ -24,11 +25,15 @@ CKEDITOR.dialog.add( 'scaytcheck', function( editor )
 \r
        function getBOMAllOptions()\r
        {\r
-                return document.forms.optionsbar["options"];\r
+               if (typeof document.forms["optionsbar_" + editorName] != "undefined")\r
+                       return document.forms["optionsbar_" + editorName]["options"];\r
+               return [];\r
        }\r
        function getBOMAllLangs()\r
        {\r
-                return document.forms.languagesbar["scayt_lang"];\r
+               if (typeof document.forms["languagesbar_" + editorName] != "undefined")\r
+                       return document.forms["languagesbar_" + editorName]["scayt_lang"];\r
+               return [];\r
        }\r
 \r
        function setCheckedValue( radioObj, newValue )\r
@@ -58,23 +63,23 @@ CKEDITOR.dialog.add( 'scaytcheck', function( editor )
                                                {\r
                                                        type : 'html',\r
                                                        id : 'options',\r
-                                                       html :  '<form name="optionsbar"><div class="inner_options">' +\r
+                                                       html :  '<form name="optionsbar_' + editorName + '"><div class="inner_options">' +\r
                                                                        '       <div class="messagebox"></div>' +\r
                                                                        '       <div style="display:none;">' +\r
-                                                                       '               <input type="checkbox" name="options"  id="allCaps" />' +\r
-                                                                       '               <label for="allCaps" id="label_allCaps"></label>' +\r
+                                                                       '               <input type="checkbox" name="options"  id="allCaps_' + editorName + '" />' +\r
+                                                                       '               <label for="allCaps" id="label_allCaps_' + editorName + '"></label>' +\r
                                                                        '       </div>' +\r
                                                                        '       <div style="display:none;">' +\r
-                                                                       '               <input name="options" type="checkbox"  id="ignoreDomainNames" />' +\r
-                                                                       '               <label for="ignoreDomainNames" id="label_ignoreDomainNames"></label>' +\r
+                                                                       '               <input name="options" type="checkbox"  id="ignoreDomainNames_' + editorName + '" />' +\r
+                                                                       '               <label for="ignoreDomainNames" id="label_ignoreDomainNames_' + editorName + '"></label>' +\r
                                                                        '       </div>' +\r
                                                                        '       <div style="display:none;">' +\r
-                                                                       '       <input name="options" type="checkbox"  id="mixedCase" />' +\r
-                                                                       '               <label for="mixedCase" id="label_mixedCase"></label>' +\r
+                                                                       '       <input name="options" type="checkbox"  id="mixedCase_' + editorName + '" />' +\r
+                                                                       '               <label for="mixedCase" id="label_mixedCase_' + editorName + '"></label>' +\r
                                                                        '       </div>' +\r
                                                                        '       <div style="display:none;">' +\r
-                                                                       '               <input name="options" type="checkbox"  id="mixedWithDigits" />' +\r
-                                                                       '               <label for="mixedWithDigits" id="label_mixedWithDigits"></label>' +\r
+                                                                       '               <input name="options" type="checkbox"  id="mixedWithDigits_' + editorName + '" />' +\r
+                                                                       '               <label for="mixedWithDigits" id="label_mixedWithDigits_' + editorName + '"></label>' +\r
                                                                        '       </div>' +\r
                                                                        '</div></form>'\r
                                                }\r
@@ -87,10 +92,10 @@ CKEDITOR.dialog.add( 'scaytcheck', function( editor )
                                                {\r
                                                        type : 'html',\r
                                                        id : 'langs',\r
-                                                       html :  '<form name="languagesbar"><div class="inner_langs">' +\r
+                                                       html :  '<form name="languagesbar_' + editorName + '"><div class="inner_langs">' +\r
                                                                        '       <div class="messagebox"></div>  ' +\r
-                                                                       '   <div style="float:left;width:45%;margin-left:5px;" id="scayt_lcol" ></div>' +\r
-                                                                       '   <div style="float:left;width:45%;margin-left:15px;" id="scayt_rcol"></div>' +\r
+                                                                       '   <div style="float:left;width:45%;margin-left:5px;" id="scayt_lcol_' + editorName + '" ></div>' +\r
+                                                                       '   <div style="float:left;width:45%;margin-left:15px;" id="scayt_rcol_' + editorName + '"></div>' +\r
                                                                        '</div></form>'\r
                                                }\r
                                        ]\r
@@ -103,25 +108,25 @@ CKEDITOR.dialog.add( 'scaytcheck', function( editor )
                                                        type : 'html',\r
                                                        style: '',\r
                                                        id : 'dictionaries',\r
-                                                       html :  '<form name="dictionarybar"><div class="inner_dictionary" style="text-align:left; white-space:normal; width:320px; overflow: hidden;">' +\r
-                                                                       '       <div style="margin:5px auto; width:80%;white-space:normal; overflow:hidden;" id="dic_message"> </div>' +\r
+                                                       html :  '<form name="dictionarybar_' + editorName + '"><div class="inner_dictionary" style="text-align:left; white-space:normal; width:320px; overflow: hidden;">' +\r
+                                                                       '       <div style="margin:5px auto; width:80%;white-space:normal; overflow:hidden;" id="dic_message_' + editorName + '"> </div>' +\r
                                                                        '       <div style="margin:5px auto; width:80%;white-space:normal;"> ' +\r
                                                                        '       <span class="cke_dialog_ui_labeled_label" >Dictionary name</span><br>'+\r
                                                                        '               <span class="cke_dialog_ui_labeled_content" >'+\r
                                                                        '                       <div class="cke_dialog_ui_input_text">'+\r
-                                                                       '                               <input id="dic_name" type="text" class="cke_dialog_ui_input_text"/>'+\r
+                                                                       '                               <input id="dic_name_' + editorName + '" type="text" class="cke_dialog_ui_input_text"/>'+\r
                                                                        '               </div></span></div>'+\r
                                                                        '               <div style="margin:5px auto; width:80%;white-space:normal;">'+\r
-                                                                       '                       <a style="display:none;" class="cke_dialog_ui_button" href="javascript:void(0)" id="dic_create">'+\r
+                                                                       '                       <a style="display:none;" class="cke_dialog_ui_button" href="javascript:void(0)" id="dic_create_' + editorName + '">'+\r
                                                                        '                               </a>' +\r
-                                                                       '                       <a  style="display:none;" class="cke_dialog_ui_button" href="javascript:void(0)" id="dic_delete">'+\r
+                                                                       '                       <a  style="display:none;" class="cke_dialog_ui_button" href="javascript:void(0)" id="dic_delete_' + editorName + '">'+\r
                                                                        '                               </a>' +\r
-                                                                       '                       <a  style="display:none;" class="cke_dialog_ui_button" href="javascript:void(0)" id="dic_rename">'+\r
+                                                                       '                       <a  style="display:none;" class="cke_dialog_ui_button" href="javascript:void(0)" id="dic_rename_' + editorName + '">'+\r
                                                                        '                               </a>' +\r
-                                                                       '                       <a  style="display:none;" class="cke_dialog_ui_button" href="javascript:void(0)" id="dic_restore">'+\r
+                                                                       '                       <a  style="display:none;" class="cke_dialog_ui_button" href="javascript:void(0)" id="dic_restore_' + editorName + '">'+\r
                                                                        '                               </a>' +\r
                                                                        '               </div>' +\r
-                                                                       '       <div style="margin:5px auto; width:95%;white-space:normal;" id="dic_info"></div>' +\r
+                                                                       '       <div style="margin:5px auto; width:95%;white-space:normal;" id="dic_info_' + editorName + '"></div>' +\r
                                                                        '</div></form>'\r
                                                }\r
                                        ]\r
@@ -134,7 +139,7 @@ CKEDITOR.dialog.add( 'scaytcheck', function( editor )
                                                        type : 'html',\r
                                                        id : 'about',\r
                                                        style : 'margin: 5px 5px;',\r
-                                                       html : '<div id="scayt_about"></div>'\r
+                                                       html : '<div id="scayt_about_' + editorName + '"></div>'\r
                                                }\r
                                        ]\r
                                }\r
@@ -149,7 +154,7 @@ CKEDITOR.dialog.add( 'scaytcheck', function( editor )
                        var dialog = this;\r
                        dialog.data = editor.fire( 'scaytDialog', {} );\r
                        dialog.options = dialog.data.scayt_control.option();\r
-                       dialog.sLang = dialog.data.scayt_control.sLang;\r
+                       dialog.chosed_lang = dialog.sLang = dialog.data.scayt_control.sLang;\r
 \r
                        if ( !dialog.data || !dialog.data.scayt || !dialog.data.scayt_control )\r
                        {\r
@@ -180,7 +185,7 @@ CKEDITOR.dialog.add( 'scaytcheck', function( editor )
                {\r
                        var scayt_control =  this.data.scayt_control;\r
                        scayt_control.option( this.options );\r
-                       // Setup languge if it was changed.\r
+                       // Setup language if it was changed.\r
                        var csLang = this.chosed_lang;\r
                        scayt_control.setLang( csLang );\r
                        scayt_control.refresh();\r
@@ -198,9 +203,7 @@ CKEDITOR.dialog.add( 'scaytcheck', function( editor )
 \r
        var scayt_control = CKEDITOR.plugins.scayt.getScayt( editor );\r
 \r
-       tags = CKEDITOR.plugins.scayt.uiTabs;\r
-\r
-       for ( i in tags )\r
+       for ( i = 0; i < tags.length; i++ )\r
        {\r
                if ( tags[ i ] == 1 )\r
                        contents[ contents.length ] = tags_contents[ i ];\r
@@ -208,40 +211,41 @@ CKEDITOR.dialog.add( 'scaytcheck', function( editor )
        if ( tags[2] == 1 )\r
                userDicActive = 1;\r
 \r
-\r
        var init_with_captions = function()\r
        {\r
                var dialog = this,\r
                        lang_list = dialog.data.scayt.getLangList(),\r
-                       buttons = [ 'dic_create', 'dic_delete', 'dic_rename', 'dic_restore' ],\r
+                       buttonCaptions = [ 'dic_create', 'dic_delete', 'dic_rename', 'dic_restore' ],\r
+                       buttonIds = [],\r
+                       langList = [],\r
                        labels = optionsIds,\r
                        i;\r
 \r
                // Add buttons titles\r
                if ( userDicActive )\r
                {\r
-                       for ( i = 0; i < buttons.length; i++ )\r
+                       for ( i = 0; i < buttonCaptions.length; i++ )\r
                        {\r
-                               var button = buttons[ i ];\r
-                               doc.getById( button ).setHtml( '<span class="cke_dialog_ui_button">' + captions[ 'button_' + button]  +'</span>' );\r
+                               buttonIds[ i ] = buttonCaptions[ i ] + "_" + editorName;\r
+                               doc.getById( buttonIds[ i ] ).setHtml( '<span class="cke_dialog_ui_button">' + captions[ 'button_' + buttonCaptions[ i ]]  +'</span>' );\r
                        }\r
-                       doc.getById( 'dic_info' ).setHtml( captions[ 'dic_info' ] );\r
+                       doc.getById( 'dic_info_' + editorName ).setHtml( captions[ 'dic_info' ] );\r
                }\r
 \r
-\r
                // Fill options and dictionary labels.\r
                if ( tags[0] == 1 )\r
                {\r
                        for ( i in labels )\r
                        {\r
-                               var label = 'label_' + labels[ i ],\r
-                                       labelElement = doc.getById( label );\r
+                               var labelCaption = 'label_' + labels[ i ],\r
+                                       labelId = labelCaption + '_' + editorName,\r
+                                       labelElement = doc.getById( labelId );\r
 \r
                                if (  'undefined' != typeof labelElement\r
-                                  && 'undefined' != typeof captions[ label ]\r
+                                  && 'undefined' != typeof captions[ labelCaption ]\r
                                   && 'undefined' != typeof dialog.options[labels[ i ]] )\r
                                {\r
-                                       labelElement.setHtml( captions[ label ] );\r
+                                       labelElement.setHtml( captions[ labelCaption ] );\r
                                        var labelParent = labelElement.getParent();\r
                                        labelParent.$.style.display = "block";\r
                                }\r
@@ -252,7 +256,7 @@ CKEDITOR.dialog.add( 'scaytcheck', function( editor )
                                '<p>' + captions[ 'version' ] + window.scayt.getAboutInfo().version.toString() + '</p>' +\r
                                '<p>' + captions[ 'about_throwt_copy' ] + '</p>';\r
 \r
-               doc.getById( 'scayt_about' ).setHtml( about );\r
+               doc.getById( 'scayt_about_' + editorName ).setHtml( about );\r
 \r
                // Create languages tab.\r
                var createOption = function( option, list )\r
@@ -286,7 +290,6 @@ CKEDITOR.dialog.add( 'scaytcheck', function( editor )
                        };\r
                };\r
 \r
-               var langList = [];\r
                if ( tags[1] ==1 )\r
                {\r
                        for ( i in lang_list.rtl )\r
@@ -300,8 +303,8 @@ CKEDITOR.dialog.add( 'scaytcheck', function( editor )
                                        return ( lang2.lang > lang1.lang ) ? -1 : 1 ;\r
                                });\r
 \r
-                       var fieldL = doc.getById( 'scayt_lcol' ),\r
-                               fieldR = doc.getById( 'scayt_rcol' );\r
+                       var fieldL = doc.getById( 'scayt_lcol_' + editorName ),\r
+                               fieldR = doc.getById( 'scayt_rcol_' + editorName );\r
                        for ( i=0; i < langList.length; i++ )\r
                        {\r
                                var field = ( i < langList.length / 2 ) ? fieldL : fieldR;\r
@@ -403,15 +406,15 @@ CKEDITOR.dialog.add( 'scaytcheck', function( editor )
 \r
                function onDicButtonClick( ev )\r
                {\r
-                       var dic_name = doc.getById('dic_name').getValue();\r
+                       var dic_name = doc.getById('dic_name_' + editorName).getValue();\r
                        if ( !dic_name )\r
                        {\r
                                dic_error_message(" Dictionary name should not be empty. ");\r
                                return false;\r
                        }\r
                        try{\r
-                               var el = id = ev.data.getTarget().getParent();\r
-                               var id = el.getId();\r
+                               var el = ev.data.getTarget().getParent();\r
+                               var id = /(dic_\w+)_[\w\d]+/.exec(el.getId())[1];\r
                                dic[ id ].apply( null, [ el, dic_name, dic_buttons ] );\r
                        }\r
                        catch(err)\r
@@ -452,7 +455,7 @@ CKEDITOR.dialog.add( 'scaytcheck', function( editor )
                                {\r
                                        opto[k].checked = false;\r
                                        //alert (opto[k].removeAttribute)\r
-                                       if ( dialog.options[ i ] == 1 )\r
+                                       if ( dialog.options[ i.split("_")[0] ] == 1 )\r
                                        {\r
                                                opto[k].checked = true;\r
                                        }\r
@@ -463,7 +466,7 @@ CKEDITOR.dialog.add( 'scaytcheck', function( editor )
                                        {\r
                                                checkbox.on( 'click', function()\r
                                                {\r
-                                                       dialog.options[ this.getId() ] = this.$.checked ? 1 : 0 ;\r
+                                                       dialog.options[ this.getId().split("_")[0] ] = this.$.checked ? 1 : 0 ;\r
                                                });\r
                                        }\r
                                }\r
@@ -487,7 +490,7 @@ CKEDITOR.dialog.add( 'scaytcheck', function( editor )
                                        hide_dic_buttons( dic_buttons[0] + ',' + dic_buttons[1] );\r
                                        if ( dic_name )\r
                                        {\r
-                                               doc.getById( 'dic_name' ).setValue(dic_name);\r
+                                               doc.getById( 'dic_name_' + editorName ).setValue(dic_name);\r
                                                display_dic_buttons( dic_buttons[1] );\r
                                        }\r
                                        else\r
@@ -496,7 +499,7 @@ CKEDITOR.dialog.add( 'scaytcheck', function( editor )
                                },\r
                                function()\r
                                {\r
-                                       doc.getById( 'dic_name' ).setValue("");\r
+                                       doc.getById( 'dic_name_' + editorName ).setValue("");\r
                                });\r
                        dic_success_message("");\r
                }\r
@@ -505,11 +508,11 @@ CKEDITOR.dialog.add( 'scaytcheck', function( editor )
 \r
        function dic_error_message( m )\r
        {\r
-               doc.getById('dic_message').setHtml('<span style="color:red;">' + m + '</span>' );\r
+               doc.getById('dic_message_' + editorName).setHtml('<span style="color:red;">' + m + '</span>' );\r
        }\r
        function dic_success_message( m )\r
        {\r
-               doc.getById('dic_message').setHtml('<span style="color:blue;">' + m + '</span>') ;\r
+               doc.getById('dic_message_' + editorName).setHtml('<span style="color:blue;">' + m + '</span>') ;\r
        }\r
        function display_dic_buttons( sIds )\r
        {\r
@@ -527,7 +530,7 @@ CKEDITOR.dialog.add( 'scaytcheck', function( editor )
        }\r
        function set_dic_name( dic_name )\r
        {\r
-               doc.getById('dic_name').$.value= dic_name;\r
+               doc.getById('dic_name_' + editorName).$.value= dic_name;\r
        }\r
 \r
        return dialogDefiniton;\r