forked from wp-plugins/mqtranslate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mqtranslate.js
752 lines (699 loc) · 19.4 KB
/
mqtranslate.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
/* this is the developer version of qtranslate.min.js before it is minimized */
/*
//debuging tools, do not check in
var cc=0;
function c(v){ ++cc; console.log('== '+cc+': '+v); }
function ct(v){ c(v); console.trace(); }
*/
qtrans_split = function(text)
{
var result = new Object;
for(var i=0; i<qTranslateConfig.enabled_languages.length; ++i)
{
var lang=qTranslateConfig.enabled_languages[i];
result[lang] = '';
}
var split_regex = /(<!--:[a-z]{2}-->|<!--:-->|\[:[a-z]{2}\])/gi;
var blocks = text.xsplit(split_regex);
if(!qtrans_isArray(blocks))
return result;
if(blocks.length==1){//no language separator found, enter it to all languages
var b=blocks[0];
for(var j=0; j<qTranslateConfig.enabled_languages.length; ++j){
var lang=qTranslateConfig.enabled_languages[j];
result[lang] += b;
}
return result;
}
var clang_regex=/<!--:([a-z]{2})-->/gi;
var c_end_regex=/<!--:-->/g;
var blang_regex=/\[:([a-z]{2})\]/gi;
lang = false;
for(var i = 0;i<blocks.length;++i){
var b=blocks[i];
//c('blocks['+i+']='+b);
if(!b.length) continue;
matches = clang_regex.exec(b); clang_regex.lastIndex=0;
if(matches!=null){
lang = matches[1];
continue;
}
matches = c_end_regex.exec(b); c_end_regex.lastIndex=0;
if(matches!=null){
lang = false;
continue;
}
matches = blang_regex.exec(b); blang_regex.lastIndex=0;
if(matches!=null){
lang = matches[1];
continue;
}
if(!lang) continue;
result[lang] += b;
lang = false;
}
return result;
}
/*
qtrans_split = function(text)
{
var result = new Object;
for(var i=0; i<qTranslateConfig.enabled_languages.length; ++i)
{
var lang=qTranslateConfig.enabled_languages[i];
result[lang] = '';
}
var split_regex_c = /(<!--.*?-->)/gi;
var blocks = text.xsplit(split_regex_c);
//c('qtrans_split: blocks='+blocks);
if(!qtrans_isArray(blocks))
return result;
var lang_begin_regex, lang_end_regex;
if(blocks.length>1){//there are matches, if the first block is empty
lang_begin_regex = /<!--:([a-z]{2})-->/gi;
lang_end_regex = /<!--:-->/gi;
}else{
var split_regex_b = /(\[:[a-z]{2}\])/gi;
blocks = text.xsplit(split_regex_b);
if(!qtrans_isArray(blocks))
return result;
lang_begin_regex = /\[:([a-z]{2})\]/gi;
}
if(!blocks.length) return result;
if(blocks.length==1){//no language separator found, enter it to all languages
var b=blocks[0];
for(var j=0; j<qTranslateConfig.enabled_languages.length; j++){
var lang=qTranslateConfig.enabled_languages[j];
result[lang] += b;
}
}else{
var matches;
var lang = false;
for(var i = 0;i<blocks.length;++i){
var b=blocks[i];
//c('blocks['+i+']='+b);
if(!b.length) continue;
if ((matches = lang_begin_regex.exec(b)) != null){
lang = matches[1];
}else if(lang_end_regex && lang_end_regex.test(b)){
lang = false;
}else if(lang){
result[lang] += b;
lang = false;
}//else skip garbage which tinyMCE adds sometimes
}
}
var morenextpage_regex = /(<!--more-->|<!--nextpage-->)+$/gi;
for(var i = 0;i<result.length;++i){
result[i] = result[i].replace(morenextpage_regex,'');
}
return result;
}
*/
qtrans_allthesame = function(texts)
{
if(qTranslateConfig.enabled_languages.length==0) return '';
var text = '';
//take first not empty
for(var i=0; i<qTranslateConfig.enabled_languages.length; ++i)
{
var lang=qTranslateConfig.enabled_languages[i];
var t = texts[lang];
if ( !t || t=='' ) continue;
text = t;
break;
}
for(var i=0; i<qTranslateConfig.enabled_languages.length; ++i)
{
var lang=qTranslateConfig.enabled_languages[i];
var t = texts[lang];
if ( !t || t=='' ) continue;
if(t!=text) return null;
}
return text;
}
//"_c" stands for "comment"
qtrans_join_c = function(texts)
{
var text = qtrans_allthesame(texts);
if (text != null) return text;
text = '';
for(var i=0; i<qTranslateConfig.enabled_languages.length; ++i)
{
var lang=qTranslateConfig.enabled_languages[i];
var t = texts[lang];
if ( !t || t=='' ) continue;
text += '<!--:'+lang+'-->';
text += t;
text += '<!--:-->';
}
return text;
}
//"b" stands for "bracket"
qtrans_join_b = function(texts)
{
var text = qtrans_allthesame(texts);
if (text != null) return text;
text = '';
for(var i=0; i<qTranslateConfig.enabled_languages.length; ++i)
{
var lang=qTranslateConfig.enabled_languages[i];
var t = texts[lang];
if ( !t || t=='' ) continue;
text += '[:'+lang+']';
text += t;
}
return text;
}
function qtrans_get_cookie(cname)
{
var nm = cname + "=";
var ca = document.cookie.split(';');
//c('ca='+ca);
for(var i=0; i<ca.length; ++i){
var s = ca[i];
var sa = s.split('=');
if(sa[0].trim()!=cname) continue;
if(ca.length<2) continue;
return sa[1].trim();
}
return '';
}
String.prototype.xsplit = function(_regEx){
// Most browsers can do this properly, so let them work, they'll do it faster
if ('a~b'.split(/(~)/).length === 3){ return this.split(_regEx); }
if (!_regEx.global)
{ _regEx = new RegExp(_regEx.source, 'g' + (_regEx.ignoreCase ? 'i' : '')); }
// IE (and any other browser that can't capture the delimiter)
// will, unfortunately, have to be slowed down
var start = 0, arr=[];
var result;
while((result = _regEx.exec(this)) != null){
arr.push(this.slice(start, result.index));
if(result.length > 1) arr.push(result[1]);
start = _regEx.lastIndex;
}
if(start < this.length) arr.push(this.slice(start));
if(start == this.length) arr.push(''); //delim at the end
return arr;
};
function qtrans_isArray(obj){ return obj.constructor.toString().indexOf('Array') >= 0; }
function qtrans_ce(tagName, props, pNode, isFirst)
{
var el= document.createElement(tagName);
if (props)
{
for(prop in props)
{
//try
{
el[prop]=props[prop];
}
//catch(err)
{
//Handle errors here
}
}
}
if (pNode)
{
if (isFirst && pNode.firstChild)
{
pNode.insertBefore(el, pNode.firstChild);
}
else
{
pNode.appendChild(el);
}
}
return el;
}
var qTranslate=function()
{
function ge(id){ return document.getElementById(id); }
var activeLanguage=qtrans_get_cookie('wp_qtrans_edit_language');
if(!activeLanguage)
activeLanguage=qTranslateConfig.language;
var contentHooks={};
function updateFusedValueH(id,value)
{
var h=contentHooks[id];
var lang=languageSwitch.getActiveLanguage();
//var morenextpage_regex = /(<!--more-->|<!--nextpage-->)+$/gi;
//h.contents[lang]=value.replace(morenextpage_regex,'');
h.contents[lang]=value;
if(h.separator==='<'){
h.mlContentField.value = qtrans_join_c(h.contents);
}else{
h.mlContentField.value = qtrans_join_b(h.contents);
}
//updateFusedValueC(h.mlContentField, value, h.contents, languageSwitch.getActiveLanguage());
}
function addContentHook(inpField,form,separator)
{
if(!inpField) return;
var h=contentHooks[inpField.id]={};
h.contentField=inpField;
h.contents=qtrans_split(inpField.value);
h.mlContentField=qtrans_ce('input', {name: inpField.name, className: 'hidden', value: inpField.value}, form, true);
if(!separator){
if(inpField.tagName==='TEXTAREA')
separator='<';
else
separator='[';
}
h.separator=separator;
inpField.name+='_edit';
inpField.value=h.contents[activeLanguage];
//c('addContentHookC:inpField.value='+inpField.value);
inpField.onblur=function(){ updateFusedValueH(this.id,this.value); }
}
function addContentHookC(inpField,form)
{
addContentHook(inpField,form,'<');
}
function addContentHookB(inpField,form)
{
addContentHook(inpField,form,'[');
}
function tagEdit()
{
// Get fields
var isAjaxForm=!!ge('tag-name');
var prefix, formId;
if (isAjaxForm)
{
prefix='tag-';
formId='addtag';
}
else
{
prefix='';
formId='edittag';
}
var nameField=ge(prefix+'name');
var form=ge(formId);
if(!form || !nameField){
//alert('mqTranslate cannot hook into the tag editor.\nPlease, report this incident to the developers.');
return false;
}
var adminLanguage=qTranslateConfig.language;
build_translator=function(langF,langT)
{
var translator={};
for(var key in qTranslateConfig.term_name){
var nms = qTranslateConfig.term_name[key];
var nmF=nms[langF];
var nmT=nms[langT];
if(!nmF || !nmT){
var nmD=nms[qTranslateConfig.default_language];
if(!nmD) continue;
if(!nmF) nmF=nmD+'('+qTranslateConfig.default_language+')';
if(!nmT) nmT=nmD+'('+qTranslateConfig.default_language+')';
}
translator[nmF]=nmT;
}
return translator;
}
var theList=ge('the-list');
hideQuickEdit=function()
{
if(!theList) return;
var rows=theList.getElementsByTagName('TR');
for(var r=0; r<rows.length; r++)
{
var tr=rows[r];
var td=tr.getElementsByTagName('TD')[0];
var items=td.getElementsByClassName('inline');
for(var i=0; i<items.length; ++i)
{
var e=items[i];
e.style.display='none';
}
}
}
hideQuickEdit();
//var nameFields={};
updateNames=function(langF,langT)
{
if(!theList) return;
var rows=theList.getElementsByTagName('TR');
for(var r=0; r<rows.length; r++)
{
var dnm, tr=rows[r];
var td=tr.getElementsByTagName('TD')[0];
var divs=td.getElementsByTagName('DIV');
for(var d=0; d<divs.length; d++)
{
var e=divs[d];
if(e.className!=='name')
continue;
dnm=e.innerHTML;
break;
}
if(adminLanguage!=qTranslateConfig.default_language){
var translator=build_translator(adminLanguage,qTranslateConfig.default_language);
dnm=translator[dnm];
}
var nms=qTranslateConfig.term_name[dnm]||{};
var nmF = nms[langF]||'';
var nmT = nms[langT]||'';
var items=td.getElementsByClassName('row-title');
for(var i=0; i<items.length; ++i)
{
var e=items[i];
if(nmF)
e.innerHTML = e.innerHTML.replace(nmF,nmT);
else
e.innerHTML += nmT;
}
}
}
var tagCloud=document.getElementsByClassName('tagcloud')[0];
updateTagCloud=function(langF,langT)
{
if(!tagCloud) return;
var items=tagCloud.getElementsByTagName('A');
if(!items.length) return;
var translator=build_translator(langF,langT);
for(var i=0; i<items.length; ++i)
{
var e=items[i];
var nmF=e.innerHTML;
var nmT=translator[nmF];
if(!nmT) continue;
e.innerHTML=nmT;
}
}
updateNamesAndTagCloud=function(langF,langT)
{
updateNames(langF,langT);
updateTagCloud(langF,langT);
}
if(adminLanguage!==activeLanguage)
updateNamesAndTagCloud(adminLanguage,activeLanguage);
// Swap fields
var newNameField=qtrans_ce('input', {name: nameField.name, className: 'hidden', value: nameField.value}, form, true);
nameField.name='';
// Load text
var names = qTranslateConfig.term_name[nameField.value] || {};
if (activeLanguage !== qTranslateConfig.default_language){
nameField.value=names[activeLanguage] || '';
}
editinline_activated=function()
{
//c('editinline_activated:'+this.innerHTML);
return true;
}
var editinlines=document.getElementsByClassName('editinline');
//c('editinlines.length='+editinlines.length);
for(var i=0; i<editinlines.length; ++i)
{
var e=editinlines[i];
if(e.tagName!=='A') continue;
e.addEventListener( 'click', editinline_activated);
}
onTabSwitch=function()
{
if(activeLanguage === this.lang) return;
nameField.value=names[this.lang] || '';
updateNamesAndTagCloud(activeLanguage,this.lang);
activeLanguage = this.lang;
}
var langs=qTranslateConfig.enabled_languages;
var newNameFields={};
for(var i=0; i<langs.length; ++i)
{
var lang=langs[i];
newNameFields[lang]=qtrans_ce('input', {name: 'qtrans_term_'+lang, className: 'hidden', value: name[lang] || ''}, form, true);
}
// Add listeners for fields change
nameField.onblur=function()
{
var lang=languageSwitch.getActiveLanguage();
newNameFields[lang].value=this.value;
names[lang]=this.value;
if (lang === qTranslateConfig.default_language)
{
newNameField.value=this.value;
}
};
return true;
}
function postEdit()
{
var form=ge('post');
if(!form) return false;
var titleField=ge('title');
if(titleField) addContentHookC(titleField,form);
var wpEditorAreas=form.getElementsByClassName('wp-editor-area');
for(var i=0; i<wpEditorAreas.length; ++i){
var wpEditorArea=wpEditorAreas[i];
addContentHookC(wpEditorArea,form);
}
var captionField=ge('attachment_caption');
if(captionField) addContentHookC(captionField,form);
//c('qTranslateConfig.custom_fields.length='+qTranslateConfig.custom_fields.length);
for(var i=0; i<qTranslateConfig.custom_fields.length; ++i){
var id=qTranslateConfig.custom_fields[i];
var sep;
if(id.indexOf('<')==0 || id.indexOf('[')==0){
sep=id.substring(0,1);
id=id.substring(1);
}
var f=ge(id);
addContentHook(f,form,sep);
}
for(var i=0; i<qTranslateConfig.custom_field_classes.length; ++i){
var nm=qTranslateConfig.custom_field_classes[i];
var sep;
if(nm.indexOf('<')==0 || nm.indexOf('[')==0){
sep=nm.substring(0,1);
nm=nm.substring(1);
}
var fields=form.getElementsByClassName(nm);
for(var j=0; j<fields.length; ++j){
f=fields[j];
addContentHook(f,form,sep);
}
}
var alttextField=ge('attachment_alt');
if(alttextField) addContentHookB(alttextField,form);
//var post_name_field=ge('post_name');
//if (post_name_field) addContentHookB(post_name_field,form);
// Slug
function convertURL(url,lang)
{
switch (qTranslateConfig.url_mode.toString())
{
case '1':
if (url.search){
url.search+="&lang="+lang;
}else{
url.search="?lang="+lang;
}
break;
case '2':
var homepath=qTranslateConfig.url_info_home;
var i=url.pathname.indexOf(homepath);
url.pathname=homepath+lang+url.pathname.substring(i+homepath.length-1);
break;
case '3':
url.host=lang+'.'+url.host;
break;
}
}
var btnViewPostA;//a node of 'View Page/Post' link.
var origUrl, langUrl;
var slugSamplePermalink;//'sample-permalink' node
var origSamplePermalink;
function setSlugLanguage(lang)
{
if(!btnViewPostA){
var btnViewPost=ge('view-post-btn');
if (!btnViewPost || !btnViewPost.children.length) return;
btnViewPostA=btnViewPost.children[0];
if(btnViewPostA.tagName != 'A') return;
origUrl=btnViewPostA.href;
langUrl=qtrans_ce('a',{});
}
langUrl.href=origUrl;
convertURL(langUrl,lang);
btnViewPostA.href=langUrl.href;
var btnPreviewAction=ge('preview-action');
if (btnPreviewAction && btnPreviewAction.children.length)
{
btnPreviewAction.children[0].href=langUrl.href;
}
if(qTranslateConfig.url_mode!=1){//!QTX_URL_QUERY
if(!slugSamplePermalink){
var slugEl=ge('sample-permalink');
if (slugEl && slugEl.childNodes.length){
slugSamplePermalink=slugEl.childNodes[0];//span
origSamplePermalink=slugSamplePermalink.nodeValue;
//var slugEdit=ge('editable-post-name');
}
}
if(slugSamplePermalink){
langUrl.href=origSamplePermalink;
convertURL(langUrl,lang);
slugSamplePermalink.nodeValue=langUrl.href;
}
}
}
setSlugLanguage(activeLanguage);
onTabSwitch=function()
{
for(var key in contentHooks){
var h=contentHooks[key];
h.contentField.value=h.contents[this.lang];
}
if(alttextField){
alttextField.value=alttexts[this.lang];
}
setSlugLanguage(this.lang);
if (!window.tinyMCE) return;
for(var i=0; i<tinyMCE.editors.length; ++i){
var ed=tinyMCE.editors[i];
var h=contentHooks[ed.id];
if(!h) continue;
ed.setContent(h.contentField.value);//, {format: 'raw'}
}
}
function setEditorHooks(e)
{
//window.onbeforeunload = function(){};
var id = e.id;
//c('setEditorHooks: id='+id);
if (!id) return;
var h=contentHooks[id];
if(h.mce) return;
h.mce=e;
e.getBody().addEventListener('blur',function(){ updateFusedValueH(e.id, e.getContent());});
//c('h.contentField.value='+h.contentField.value);
//e.setContent(h.contentField.value);
}
// Add listeners for fields change
window.addEventListener('load', function(){
if (!window.tinyMCE){
//alert('mqTranslate error: !window.tinyMCE. Please report this incident to the developers.');
return;
}
for(var i=0; i<tinyMCE.editors.length; ++i){
var ed=tinyMCE.editors[i];
setEditorHooks(ed);
}
for(var key in contentHooks){
var h=contentHooks[key];
if(h.mce) continue;
if(h.contentField.tagName!=='TEXTAREA') continue;
tinyMCEPreInit.mceInit[key].init_instance_callback=function(ed){ setEditorHooks(ed); }
}
});
return true;
}
function optionsEdit()
{
var forms=document.getElementsByTagName('FORM');
if(!forms.length) return false;
var form=forms[0];
addContentHookB(ge('blogname'),form);
addContentHookB(ge('blogdescription'),form);
onTabSwitch=function()
{
for(var key in contentHooks){
var h=contentHooks[key];
h.contentField.value=h.contents[this.lang];
}
}
return true;
}
setLangCookie=function()
{
document.cookie='wp_qtrans_edit_language='+this.lang;
}
var matches = location.pathname.match(/(\/wp-admin\/([^\/]*))$/);
switch(matches && matches[1])
{
case "/wp-admin/post.php":
case "/wp-admin/post-new.php":
if(!postEdit()) return;
break;
case "/wp-admin/edit-tags.php":
if(!tagEdit()) return;
break;
case "/wp-admin/options-general.php":
if(location.search.indexOf('page=')>=0) return;
if(!optionsEdit()) return;
break;
default: return;
}
var langSwitchWrap=qtrans_ce('ul', {className: 'qtrans-lang-switch-wrap wp-ui-primary'});
{
var w=document.getElementsByClassName('wrap')[0];
var f=w.getElementsByTagName('form')[0];
f.parentNode.insertBefore(langSwitchWrap, f);
languageSwitch=new LanguageSwitch(langSwitchWrap,activeLanguage);
languageSwitch.onSwitch(onTabSwitch);
languageSwitch.onSwitch(setLangCookie);
}
}
function LanguageSwitch(target,initial_language)
{
var langs=qTranslateConfig.enabled_languages, langNames=qTranslateConfig.language_name, activeLanguage=initial_language;
var editableLangs = qTranslateConfig.editable_languages || langs;
var visibleLangs = qTranslateConfig.visible_languages || new Array();
var tabSwitches={};
var onTabSwitch=[];
function switchTab()
{
var tabSwitch=this;
if (!tabSwitch.lang){
alert('mqTranslate: This should not have happened: Please, report this incident to the developers: !tabSwitch.lang');
return;
}
if ( activeLanguage === tabSwitch.lang ){
return;
}
if (activeLanguage)
tabSwitches[activeLanguage].classList.remove('wp-ui-highlight');
activeLanguage=tabSwitch.lang;
tabSwitch.classList.add('wp-ui-highlight');
for(var i=0; i<onTabSwitch.length; ++i)
{
onTabSwitch[i].call(this);
}
}
location.pathname.indexOf();
for(var i=0; i<langs.length; ++i)
{
var lang=langs[i];
var langName = langNames[lang];
var editableIndex = editableLangs.indexOf(lang);
if (editableIndex < 0) {
if (visibleLangs.indexOf(lang) < 0)
continue;
langName += ' (Read Only)';
}
//var flags_location=qTranslateConfig.WP_CONTENT_URL+qTranslateConfig.flag_location;
var flag_location=qTranslateConfig.flag_location;
var tabSwitch=qtrans_ce ('li', {lang: lang, className: 'qtrans-lang-switch', onclick: switchTab }, target );
qtrans_ce('img', {src: flag_location+qTranslateConfig.flag[lang]}, tabSwitch);
qtrans_ce('span', {innerHTML: langName}, tabSwitch);
tabSwitches[lang]=tabSwitch;
if ( activeLanguage == lang )
tabSwitch.classList.add('wp-ui-highlight');
}
this.getActiveLanguage=function()
{
return activeLanguage;
}
this.onSwitch=function(callback)
{
if (typeof callback==='function')
{
onTabSwitch.push(callback);
}
}
}
new qTranslate;