Ticket #7084: 7084_2.patch
File 7084_2.patch, 17.6 KB (added by , 13 years ago) |
---|
-
_source/plugins/scayt/dialogs/options.js
8 8 var firstLoad = true, 9 9 captions, 10 10 doc = CKEDITOR.document, 11 tags = [], 11 editorName = editor.name, 12 tags = CKEDITOR.plugins.scayt.getUiTabs( editor ), 12 13 i, 13 14 contents = [], 14 15 userDicActive = 0, 15 16 dic_buttons = [ 16 17 // [0] contains buttons for creating 17 "dic_create ,dic_restore",18 "dic_create_" + editorName + ",dic_restore_" + editorName, 18 19 // [1] contains buton for manipulation 19 "dic_rename ,dic_delete"20 "dic_rename_" + editorName + ",dic_delete_" + editorName 20 21 ], 21 22 optionsIds = [ 'mixedCase', 'mixedWithDigits', 'allCaps', 'ignoreDomainNames' ]; 22 23 … … 24 25 25 26 function getBOMAllOptions() 26 27 { 27 return document.forms.optionsbar["options"]; 28 if (typeof document.forms["optionsbar_" + editorName] != "undefined") 29 return document.forms["optionsbar_" + editorName]["options"]; 30 return []; 28 31 } 29 32 function getBOMAllLangs() 30 33 { 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 []; 32 37 } 33 38 34 39 function setCheckedValue( radioObj, newValue ) … … 58 63 { 59 64 type : 'html', 60 65 id : 'options', 61 html : '<form name="optionsbar "><div class="inner_options">' +66 html : '<form name="optionsbar_' + editorName + '"><div class="inner_options">' + 62 67 ' <div class="messagebox"></div>' + 63 68 ' <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>' + 66 71 ' </div>' + 67 72 ' <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>' + 70 75 ' </div>' + 71 76 ' <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>' + 74 79 ' </div>' + 75 80 ' <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>' + 78 83 ' </div>' + 79 84 '</div></form>' 80 85 } … … 87 92 { 88 93 type : 'html', 89 94 id : 'langs', 90 html : '<form name="languagesbar "><div class="inner_langs">' +95 html : '<form name="languagesbar_' + editorName + '"><div class="inner_langs">' + 91 96 ' <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>' + 94 99 '</div></form>' 95 100 } 96 101 ] … … 103 108 type : 'html', 104 109 style: '', 105 110 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>' + 108 113 ' <div style="margin:5px auto; width:80%;white-space:normal;"> ' + 109 114 ' <span class="cke_dialog_ui_labeled_label" >Dictionary name</span><br>'+ 110 115 ' <span class="cke_dialog_ui_labeled_content" >'+ 111 116 ' <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"/>'+ 113 118 ' </div></span></div>'+ 114 119 ' <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 + '">'+ 116 121 ' </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 + '">'+ 118 123 ' </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 + '">'+ 120 125 ' </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 + '">'+ 122 127 ' </a>' + 123 128 ' </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>' + 125 130 '</div></form>' 126 131 } 127 132 ] … … 134 139 type : 'html', 135 140 id : 'about', 136 141 style : 'margin: 5px 5px;', 137 html : '<div id="scayt_about "></div>'142 html : '<div id="scayt_about_' + editorName + '"></div>' 138 143 } 139 144 ] 140 145 } … … 149 154 var dialog = this; 150 155 dialog.data = editor.fire( 'scaytDialog', {} ); 151 156 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 154 159 if ( !dialog.data || !dialog.data.scayt || !dialog.data.scayt_control ) 155 160 { 156 161 alert( 'Error loading application service' ); … … 180 185 { 181 186 var scayt_control = this.data.scayt_control; 182 187 scayt_control.option( this.options ); 183 // Setup langu ge if it was changed.188 // Setup language if it was changed. 184 189 var csLang = this.chosed_lang; 185 190 scayt_control.setLang( csLang ); 186 191 scayt_control.refresh(); … … 198 203 199 204 var scayt_control = CKEDITOR.plugins.scayt.getScayt( editor ); 200 205 201 tags = CKEDITOR.plugins.scayt.uiTabs; 202 203 for ( i in tags ) 206 for ( var i = 0; i < tags.length; i++ ) 204 207 { 205 208 if ( tags[ i ] == 1 ) 206 209 contents[ contents.length ] = tags_contents[ i ]; … … 208 211 if ( tags[2] == 1 ) 209 212 userDicActive = 1; 210 213 211 212 214 var init_with_captions = function() 213 215 { 214 216 var dialog = this, 215 217 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 = [], 217 221 labels = optionsIds, 218 222 i; 219 223 220 224 // Add buttons titles 221 225 if ( userDicActive ) 222 226 { 223 for ( i = 0; i < button s.length; i++ )227 for ( i = 0; i < buttonCaptions.length; i++ ) 224 228 { 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>' ); 227 231 } 228 doc.getById( 'dic_info ').setHtml( captions[ 'dic_info' ] );232 doc.getById( 'dic_info_' + editorName ).setHtml( captions[ 'dic_info' ] ); 229 233 } 230 234 231 232 235 // Fill options and dictionary labels. 233 236 if ( tags[0] == 1 ) 234 237 { 235 238 for ( i in labels ) 236 239 { 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 240 244 if ( 'undefined' != typeof labelElement 241 && 'undefined' != typeof captions[ label ]245 && 'undefined' != typeof captions[ labelCaption ] 242 246 && 'undefined' != typeof dialog.options[labels[ i ]] ) 243 247 { 244 labelElement.setHtml( captions[ label ] );248 labelElement.setHtml( captions[ labelCaption ] ); 245 249 var labelParent = labelElement.getParent(); 246 250 labelParent.$.style.display = "block"; 247 251 } … … 252 256 '<p>' + captions[ 'version' ] + window.scayt.getAboutInfo().version.toString() + '</p>' + 253 257 '<p>' + captions[ 'about_throwt_copy' ] + '</p>'; 254 258 255 doc.getById( 'scayt_about ').setHtml( about );259 doc.getById( 'scayt_about_' + editorName ).setHtml( about ); 256 260 257 261 // Create languages tab. 258 262 var createOption = function( option, list ) … … 286 290 }; 287 291 }; 288 292 289 var langList = [];290 293 if ( tags[1] ==1 ) 291 294 { 292 295 for ( i in lang_list.rtl ) … … 300 303 return ( lang2.lang > lang1.lang ) ? -1 : 1 ; 301 304 }); 302 305 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 ); 305 308 for ( i=0; i < langList.length; i++ ) 306 309 { 307 310 var field = ( i < langList.length / 2 ) ? fieldL : fieldR; … … 403 406 404 407 function onDicButtonClick( ev ) 405 408 { 406 var dic_name = doc.getById('dic_name ').getValue();409 var dic_name = doc.getById('dic_name_' + editorName).getValue(); 407 410 if ( !dic_name ) 408 411 { 409 412 dic_error_message(" Dictionary name should not be empty. "); 410 413 return false; 411 414 } 412 415 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]; 415 418 dic[ id ].apply( null, [ el, dic_name, dic_buttons ] ); 416 419 } 417 420 catch(err) … … 452 455 { 453 456 opto[k].checked = false; 454 457 //alert (opto[k].removeAttribute) 455 if ( dialog.options[ i ] == 1 )458 if ( dialog.options[ i.split("_")[0] ] == 1 ) 456 459 { 457 460 opto[k].checked = true; 458 461 } … … 463 466 { 464 467 checkbox.on( 'click', function() 465 468 { 466 dialog.options[ this.getId() ] = this.$.checked ? 1 : 0 ;469 dialog.options[ this.getId().split("_")[0] ] = this.$.checked ? 1 : 0 ; 467 470 }); 468 471 } 469 472 } … … 487 490 hide_dic_buttons( dic_buttons[0] + ',' + dic_buttons[1] ); 488 491 if ( dic_name ) 489 492 { 490 doc.getById( 'dic_name ').setValue(dic_name);493 doc.getById( 'dic_name_' + editorName ).setValue(dic_name); 491 494 display_dic_buttons( dic_buttons[1] ); 492 495 } 493 496 else … … 496 499 }, 497 500 function() 498 501 { 499 doc.getById( 'dic_name ').setValue("");502 doc.getById( 'dic_name_' + editorName ).setValue(""); 500 503 }); 501 504 dic_success_message(""); 502 505 } … … 505 508 506 509 function dic_error_message( m ) 507 510 { 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>' ); 509 512 } 510 513 function dic_success_message( m ) 511 514 { 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>') ; 513 516 } 514 517 function display_dic_buttons( sIds ) 515 518 { … … 527 530 } 528 531 function set_dic_name( dic_name ) 529 532 { 530 doc.getById('dic_name ').$.value= dic_name;533 doc.getById('dic_name_' + editorName).$.value= dic_name; 531 534 } 532 535 533 536 return dialogDefiniton; -
_source/plugins/scayt/plugin.js
95 95 96 96 plugin.instances[ editor.name ] = scayt_control; 97 97 98 //window.scayt.uiTags99 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;107 98 try { 108 99 scayt_control.setDisabled( plugin.isPaused( editor ) === false ); 109 100 } catch (e) {} … … 356 347 var scayt_instance = this.getScayt( editor ); 357 348 return ( scayt_instance ) ? scayt_instance.disabled === false : false; 358 349 }, 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 }, 359 370 loadEngine : function( editor ) 360 371 { 361 372 // SCAYT doesn't work with Firefox2, Opera and AIR. … … 528 539 529 540 // Add Options dialog. 530 541 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 543 545 var menuGroup = 'scaytButton'; 544 546 editor.addMenuGroup( menuGroup ); 545 547 // combine menu items to render 546 var uiM uneItems = {};548 var uiMenuItems = {}; 547 549 548 550 var lang = editor.lang.scayt; 549 551 550 552 // always added 551 uiM uneItems.scaytToggle =553 uiMenuItems.scaytToggle = 552 554 { 553 555 label : lang.enable, 554 556 command : commandName, … … 556 558 }; 557 559 558 560 if ( uiTabs[0] == 1 ) 559 uiM uneItems.scaytOptions =561 uiMenuItems.scaytOptions = 560 562 { 561 563 label : lang.options, 562 564 group : menuGroup, … … 568 570 }; 569 571 570 572 if ( uiTabs[1] == 1 ) 571 uiM uneItems.scaytLangs =573 uiMenuItems.scaytLangs = 572 574 { 573 575 label : lang.langs, 574 576 group : menuGroup, … … 579 581 } 580 582 }; 581 583 if ( uiTabs[2] == 1 ) 582 uiM uneItems.scaytDict =584 uiMenuItems.scaytDict = 583 585 { 584 586 label : lang.dictionariesTab, 585 587 group : menuGroup, … … 590 592 } 591 593 }; 592 594 // always added 593 uiM uneItems.scaytAbout =595 uiMenuItems.scaytAbout = 594 596 { 595 597 label : editor.lang.scayt.about, 596 598 group : menuGroup, … … 600 602 editor.openDialog( commandName ); 601 603 } 602 604 }; 605 606 editor.addMenuItems( uiMenuItems ); 603 607 604 uiTabs[3] = 1; // about us tab is always on605 plugin.uiTabs = uiTabs;606 607 editor.addMenuItems( uiMuneItems );608 609 608 editor.ui.add( 'Scayt', CKEDITOR.UI_MENUBUTTON, 610 609 { 611 610 label : lang.title, … … 625 624 var isEnabled = plugin.isScaytEnabled( editor ); 626 625 627 626 editor.getMenuItem( 'scaytToggle' ).label = lang[ isEnabled ? 'disable' : 'enable' ]; 628 627 628 var uiTabs = plugin.getUiTabs( editor ); 629 629 630 return { 630 631 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_DISABLED632 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 635 636 }; 636 637 } 637 638 });