1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
3
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
4
* Copyright (C) 2003-2010 Frederico Caldeira Knabben
8
* Licensed under the terms of any of the following licenses at your
11
* - GNU General Public License Version 2 or later (the "GPL")
12
* http://www.gnu.org/licenses/gpl.html
14
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
15
* http://www.gnu.org/licenses/lgpl.html
17
* - Mozilla Public License Version 1.1 or later (the "MPL")
18
* http://www.mozilla.org/MPL/MPL-1.1.html
24
<title>SCAYT Properties</title>
25
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
26
<meta content="noindex, nofollow" name="robots">
27
<script src="common/fck_dialog_common.js" type="text/javascript"></script>
28
<link type="text/css" href="fck_scayt/scayt_dialog.css" rel="stylesheet" />
29
<script type="text/javascript">
31
var dialog = window.parent ;
32
var oEditor = dialog.InnerDialogLoaded() ;
33
var FCKLang = oEditor.FCKLang;
34
var scayt = oEditor.scayt;
35
var scayt_control = oEditor.scayt_control;
41
var tabs = scayt_control.uiTags || [1,1,0,1];
42
var userDicActive = tabs[2] == 1;
45
// [0] contains buttons for creating
46
"dic_create,dic_restore",
47
// [1] contains buton for manipulation
48
"dic_rename,dic_delete"
54
var mergeObjs = function(obj1, obj2)
62
var removeWhitespaces = function( s )
64
s = s.replace( new RegExp("^ +| +$"), '' ) ;
68
var addEvent = function( el ,sEventName, fTodo )
70
if (el.addEventListener) {
71
el.addEventListener (sEventName,fTodo,false);
73
} else if (el.attachEvent) {
74
el.attachEvent ("on"+sEventName,fTodo);
77
el["on"+sEventName] = fTodo;
81
var getElementsByClassName = function (node,classname ,strTag) {
82
strTag = strTag || "*";
83
node = node || document;
84
if (node.getElementsByClassName)
85
return node.getElementsByClassName(classname);
87
var objColl = node.getElementsByTagName(strTag);
88
if (!objColl.length && strTag == "*" && node.all) objColl = node.all;
89
var arr = new Array();
90
var delim = classname.indexOf('|') != -1 ? '|' : ' ';
91
var arrClass = classname.split(delim);
92
for (var i = 0, j = objColl.length; i < j; i++) {
93
var arrObjClass = objColl[i].className.split(' ');
94
if (delim == ' ' && arrClass.length > arrObjClass.length) continue;
97
for ( var k = 0, l = arrObjClass.length ; k < l ; k++ )
99
for ( var m = 0, n = arrClass.length ; m < n ; m++ )
101
if ( arrClass[m] == arrObjClass[k] )
104
if ( ( delim == '|' && c == 1 ) || ( delim == ' ' && c == arrClass.length ) )
106
arr.push( objColl[i] ) ;
107
break comparisonLoop ;
116
var hasClassName = function ( sClassName, elem ) {
118
var aCnames = elem.className.split(/\s+/) || [];
119
for (var i=0, l=aCnames.length; i<l ; i++){
120
if (sClassName == aCnames[i])
127
addClass : function ( sClassName ) {
128
//console.info( sClassName, this.className, );
129
if ( hasClassName(sClassName , this) )
131
var s = removeWhitespaces(this.className + " " +sClassName);
136
removeClass : function ( sClassName ) {
137
var s = removeWhitespaces(this.className.replace(sClassName,""));
141
setStyle : function( oStyles )
143
for ( var style in oStyles )
145
this.style[style] = oStyles[style] ;
149
bindOnclick : function ( handler ) {
150
//addEvent( this, "click" , handler);
151
this.onclick = handler;
154
bindOnchange : function ( handler ) {
155
//addEvent( this, "change" , handler);
156
this.onchange = handler;
159
getAttr : function ( sAttrName )
164
return this[sAttrName];
166
setAttr : function ( sAttrName , attrVal )
168
if ( !sAttrName || !attrVal )
171
this[sAttrName] = attrVal;
175
remAttr : function ( sAttrName )
182
var singleCaller = function ( sMethod,args ) {
183
for ( var i=0, l=this.length; i<l ; i++ ){
184
var oItem = mergeObjs( single, this[i] );
185
oItem[sMethod].apply(this[i],args);
192
addClass : function ( sClassName ){
193
singleCaller.call(this, "addClass", [sClassName])
196
removeClass : function ( sClassName ) {
197
singleCaller.call(this, "removeClass", [sClassName])
200
setStyle : function ( oStyles ) {
201
singleCaller.call(this, "setStyle", [oStyles])
204
bindOnclick : function ( f ) {
205
singleCaller.call(this, "bindOnclick", [f])
208
bindOnchange : function ( f ) {
209
singleCaller.call(this, "bindOnchange", [f])
213
forEach : function ( fTodo ) {
215
for (var i=0, l=this.length; i<l ; i++){
216
fTodo.apply(this[i], [this[i],i ]);
225
this.byClass = function( sClassName ){
226
var o = getElementsByClassName(document, sClassName );
227
return o ? mergeObjs( collection, o ) : o;
230
this.byId = function( sId ){
231
var o = document.getElementById( sId );
232
return o ? mergeObjs( single, o ) : o;
235
this.gup = function ( name ){
236
name = name.replace( /[\[]/, '\\\[' ).replace( /[\]]/, '\\\]' ) ;
237
var regexS = '[\\?&]' + name + '=([^&#]*)' ;
238
var regex = new RegExp( regexS ) ;
239
var results = regex.exec( window.location.href ) ;
241
if( results == null )
244
return results[ 1 ] ;
246
this.wrap = function ( o ) {
247
return o ? mergeObjs( single, o ) : o;
249
this.forEach = function ( oScope, fTodo ){
250
collection.forEach.apply( oScope,[fTodo] );
257
// Add the dialog tabs.
258
tabs[0] == 1 && dialog.AddTab( 'options', 'Options' ) ;
259
tabs[1] == 1 && dialog.AddTab( 'langs', 'Languages' ) ;
260
tabs[2] == 1 && dialog.AddTab( 'dictionary', 'Dictionary' ) ;
261
tabs[3] == 1 && dialog.AddTab( 'about', 'About' ) ;
263
// Function called when a dialog tab is selected.
264
function OnDialogTabChange( tabCode )
266
ShowE('inner_options' , ( tabCode == 'options' ) ) ;
267
ShowE('inner_langs' , ( tabCode == 'langs' ) ) ;
268
ShowE('inner_dictionary' , ( tabCode == 'dictionary' ) ) ;
269
ShowE('inner_about' , ( tabCode == 'about' ) ) ;
276
window.onload = function()
278
// Things to do when the page is loaded.
280
if ( document.location.search.length )
281
dialog.SetSelectedTab( document.location.search.substr(1) ) ;
283
dialog.SetOkButton( true ) ;
286
if (!scayt) throw "SCAYT is undefined";
287
if (!scayt_control) throw "SCAYT_CONTROL is undefined";
290
tabs = scayt_control.uiTags || [1,1,1,0];
293
sLang = scayt_control.getLang();
295
options = scayt_control.option();
297
scayt.getCaption( fckLang, function( caps )
299
//console.info( "scayt.getCaption runned" )
302
//lang_list = scayt.getLangList();
303
lang_list = scayt.getLangList() ;//|| {ltr: {"en_US" : "English","en_GB" : "British English","pt_BR" : "Brazilian Portuguese","da_DK" : "Danish","nl_NL" : "Dutch","en_CA" : "English Canadian","fi_FI" : "Finnish","fr_FR" : "French","fr_CA" : "French Canadian","de_DE" : "German","el_GR" : "Greek","hu_HU" : "Hungarian","it_IT" : "Italian","nb_NO" : "Norwegian","pl_PL" : "Polish","pt_PT" : "Portuguese","ru_RU" : "Russian","es_ES" : "Spanish","sv_SE" : "Swedish","tr_TR" : "Turkish","uk_UA" : "Ukrainian","cy_GB" : "Welsh"},rtl: {"ar_EG" : "Arabic"}};
308
// ** animate options
309
get.byClass("_scayt_option").forEach(function(el,i){
311
if ('undefined' != typeof(options[el.name])) {
312
// *** set default values
314
if ( 1 == options[ el.name ] ){
315
//el.setAttribute("checked","true");
316
get.wrap(el).setAttr("checked" ,true)
317
//document.all_options[el.name].checked = "true";
319
//alert( options[ dojo.attr(el ,'name') ] + " el " )
321
//console.info(options)
323
get.wrap(el).bindOnclick( function(ev){
325
var that = get.wrap(this);
326
var isCheck = that.getAttr("checked");
327
//console.info(isCheck)
328
if ( isCheck == false ) {
330
//that.setAttr("checked",false);
331
options[ this.name ] = 0;
333
//that.setAttr("checked",true);
334
options[ this.name ] = 1;
336
//console.info(options)
342
// * Create languages tab
343
// ** convert langs obj to array
346
for (var k in lang_list.rtl){
349
chosed_lang = lang_list.rtl[k] + "::" + k;
350
lang_arr[lang_arr.length] = lang_list.rtl[k] + "::" + k;
353
for (var k in lang_list.ltr){
356
chosed_lang = lang_list.ltr[k] + "::" + k;
357
lang_arr[lang_arr.length] = lang_list.ltr[k] + "::" + k;
361
// ** find lang containers
363
var lcol = get.byId("lcolid");
364
var rcol = get.byId("rcolid");
365
// ** place langs in DOM
367
get.forEach(lang_arr , function( l , i ){
369
//console.info( l,i );
371
var l_arr = l.split('::');
372
var l_name = l_arr[0];
373
var l_code = l_arr[1];
374
var row = document.createElement('div');
376
row.className = "li";
377
// split langs on half
378
var col = ( i < lang_arr.length/2 ) ? lcol:rcol ;
382
col.appendChild(row);
383
var row_dom = get.byId( l_code )
384
row_dom.innerHTML = l_name;
386
var checkActiveLang = function( id ){
387
return chosed_lang.split("::")[1] == id;
390
row_dom.bindOnclick(function(ev){
392
if ( checkActiveLang(this.id) ) return false;
396
.removeClass("DarkBackground");
398
window.setTimeout( function (){ get.byId(elId).setStyle({opacity:"0.5",cursor:"no-drop"}); } ,300 );
400
get.byId(chosed_lang.split("::")[1])
401
.addClass("DarkBackground")
402
.removeClass("Button")
403
.setStyle({opacity:"1",cursor:"pointer"});
405
chosed_lang = this.innerHTML + "::" + this.id;
411
// select current lang
412
if (l == chosed_lang)
413
row_dom.addClass("Button").setStyle({opacity:"0.5",cursor:"no-drop"});
415
row_dom.addClass("DarkBackground").setStyle({opacity:"1"});
419
if ( userDicActive ){
432
var buttons = [ 'dic_create','dic_delete','dic_rename','dic_restore' ];
433
var labels = [ 'mixedCase','mixedWithDigits','allCaps','ignoreDomainNames' ];
436
function apllyCaptions ( )
440
// add missing captions
442
get.byClass("PopupTab").forEach(function(el,i){
445
el.style.display = "block";
447
el.innerHTML = captions['tab_'+el.id];
451
// Fill options labels.
454
var label = 'label_' + labels[ i ],
455
labelElement = document.getElementById( label );
457
if ( 'undefined' != typeof labelElement
458
&& 'undefined' != typeof captions[ label ] && captions[ label ] !== ""
459
&& 'undefined' != typeof options[labels[ i ]] )
461
labelElement.innerHTML = captions[ label ];
462
var labelParent = labelElement.parentNode;
463
labelParent.style.display = "block";
466
// fill dictionary section
467
for ( var i in buttons )
469
var button = buttons[ i ];
470
get.byId( button ).innerHTML = '<span>' + captions[ 'button_' + button] +'</span>' ;
472
get.byId("dname").innerHTML = captions['label_dname'];
473
get.byId( 'dic_info' ).innerHTML = captions[ 'dic_info' ];
476
var about = '<p>' + captions[ 'about_throwt_image' ] + '</p>'+
477
'<p>' + captions[ 'version' ] + scayt.version.toString() + '</p>' +
478
'<p>' + captions[ 'about_throwt_copy' ] + '</p>';
480
get.byId( 'scayt_about' ).innerHTML = about;
485
function initUserDictionary () {
487
scayt.getNameUserDictionary(
490
var dic_name = o.dname;
493
get.byId( 'dic_name' ).value = dic_name;
494
display_dic_buttons( dic_buttons[1] );
497
display_dic_buttons( dic_buttons[0] );
502
get.byId( 'dic_name' ).value("");
503
dic_error_message(captions["err_dic_enable"] || "Used dictionary are unaveilable now.")
507
dic_success_message("");
509
// ** bind event listeners
510
get.byClass("button").bindOnclick(function( ){
513
var dic_name = get.byId('dic_name').value ;
514
// check common dictionary rules
516
dic_error_message(" Dictionary name should not be empty. ");
520
window[this.id].apply( window, [this, dic_name, dic_buttons ] );
522
//console.info( typeof window[this.id], window[this.id].calle )
528
dic_create = function( el, dic_name , dic_buttons )
530
// comma separated button's ids include repeats if exists
531
var all_buttons = dic_buttons[0] + ',' + dic_buttons[1];
533
var err_massage = captions["err_dic_create"];
534
var suc_massage = captions["succ_dic_create"];
535
//console.info("--plugin ");
537
scayt.createUserDictionary(dic_name,
540
//console.info( "dic_create callback called with args" , arg );
541
hide_dic_buttons ( all_buttons );
542
display_dic_buttons ( dic_buttons[1] );
543
suc_massage = suc_massage.replace("%s" , arg.dname );
544
dic_success_message (suc_massage);
548
//console.info( "dic_create errorback called with args" , arg )
549
err_massage = err_massage.replace("%s" ,arg.dname );
550
dic_error_message ( err_massage + "( "+ (arg.message || "") +")");
555
dic_rename = function( el, dic_name , dic_buttons )
558
// try to rename dictionary
559
// @TODO: rename dict
560
//console.info ( captions["err_dic_rename"] )
561
var err_massage = captions["err_dic_rename"] || "";
562
var suc_massage = captions["succ_dic_rename"] || "";
563
scayt.renameUserDictionary(dic_name,
566
//console.info( "dic_rename callback called with args" , arg );
567
suc_massage = suc_massage.replace("%s" , arg.dname );
568
set_dic_name( dic_name );
569
dic_success_message ( suc_massage );
573
//console.info( "dic_rename errorback called with args" , arg )
574
err_massage = err_massage.replace("%s" , arg.dname );
575
set_dic_name( dic_name );
576
dic_error_message( err_massage + "( " + ( arg.message || "" ) + " )" );
580
dic_delete = function ( el, dic_name , dic_buttons )
582
var all_buttons = dic_buttons[0] + ',' + dic_buttons[1];
583
var err_massage = captions["err_dic_delete"];
584
var suc_massage = captions["succ_dic_delete"];
586
// try to delete dictionary
587
// @TODO: delete dict
588
scayt.deleteUserDictionary(
591
//console.info( "dic_delete callback " , dic_name ,arg );
592
suc_massage = suc_massage.replace("%s" , arg.dname );
593
hide_dic_buttons ( all_buttons );
594
display_dic_buttons ( dic_buttons[0] );
595
set_dic_name( "" ); // empty input field
596
dic_success_message( suc_massage );
600
//console.info( " dic_delete errorback called with args" , arg )
601
err_massage = err_massage.replace("%s" , arg.dname );
602
dic_error_message(err_massage);
606
dic_restore = dialog.dic_restore || function ( el, dic_name , dic_buttons )
608
// try to restore existing dictionary
609
var all_buttons = dic_buttons[0] + ',' + dic_buttons[1];
610
var err_massage = captions["err_dic_restore"];
611
var suc_massage = captions["succ_dic_restore"];
613
scayt.restoreUserDictionary(dic_name,
616
//console.info( "dic_restore callback called with args" , arg );
617
suc_massage = suc_massage.replace("%s" , arg.dname );
618
hide_dic_buttons ( all_buttons );
619
display_dic_buttons(dic_buttons[1]);
620
dic_success_message( suc_massage );
624
//console.info( " dic_restore errorback called with args" , arg )
625
err_massage = err_massage.replace("%s" , arg.dname );
626
dic_error_message( err_massage );
630
function dic_error_message( m )
635
get.byId('dic_message').innerHTML = '<span class="error">' + m + '</span>' ;
638
function dic_success_message( m )
643
get.byId('dic_message').innerHTML = '<span class="success">' + m + '</span>' ;
646
function display_dic_buttons ( sIds ){
647
sIds = new String( sIds );
648
get.forEach( sIds.split(','), function ( id,i) {
649
get.byId(id).setStyle({display:"inline"});
652
function hide_dic_buttons ( sIds ){
653
sIds = new String( sIds );
654
get.forEach( sIds.split(','), function ( id,i) {
655
get.byId(id).setStyle({display:"none"});
658
function set_dic_name ( dic_name ) {
659
get.byId('dic_name').value = dic_name;
661
function display_dic_tab () {
662
get.byId("dic_tab").style.display = "block";
667
// Things to do when the Ok button is clicked.
669
// set upp options if any was set
670
var o = scayt_control.option();
671
//console.info(options)
672
for ( var oN in options ) {
674
if ( o[oN] != options[oN] && c == 0){
675
//console.info( "set option " )
676
scayt_control.option( options );
680
//setup languge if it was change
681
var csLang = chosed_lang.split("::")[1];
682
if ( csLang && sLang != csLang ){
683
scayt_control.setLang( csLang );
684
//console.info(sLang+" -> "+csLang , scayt_control)
688
if ( c > 0 ) scayt_control.refresh();
690
return dialog.Cancel();
696
<body style="OVERFLOW: hidden" scroll="no">
697
<div class="tab_container" id="inner_options">
699
<ul id="scayt_options">
700
<li class="_scayt_options">
701
<input class="_scayt_option" type="checkbox" value="0" name="allCaps" />
702
<label for="allCaps" id="label_allCaps"></label>
705
<input class="_scayt_option" type="checkbox" value="0" name="ignoreDomainNames" />
706
<label for="ignoreDomainNames" id="label_ignoreDomainNames"></label>
709
<input class="_scayt_option" type="checkbox" value="0" name="mixedCase" />
710
<label for="mixedCase" id="label_mixedCase"></label>
713
<input class="_scayt_option" type="checkbox" value="0" name="mixedWithDigits" />
714
<label for="mixedWithDigits" id="label_mixedWithDigits"></label>
718
<div class="tab_container" id="inner_langs">
720
<div class="lcol" id="lcolid"></div>
721
<div class="rcol" id="rcolid"></div>
723
<div class="tab_container" id="inner_dictionary">
725
<div id="dic_message"></div>
726
<div id="_off_dic_tab" class="dictionary" >
727
<div style="padding-left:10px;">
728
<label id="dname" for="dname"></label>
729
<input type="text" size="14" maxlength="15" value="" id="dic_name" name="dic_name"/>
731
<div class="dic_buttons">
732
<a href="#" id="dic_create" class="button"> </a>
733
<a href="#" id="dic_delete" class="button"> </a>
734
<a href="#" id="dic_rename" class="button"> </a>
735
<a href="#" id="dic_restore" class="button"> </a>
738
<div id="dic_info"></div>
742
<div id="inner_about" class="tab_container">
743
<div id="scayt_about"></div>