2007-09-16 18:30:26 +02:00
|
|
|
var _TRANSLATING_LANG = null;
|
2007-09-25 23:58:42 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2007-09-16 18:30:26 +02:00
|
|
|
LangSelector = Class.create();
|
|
|
|
LangSelector.prototype = {
|
|
|
|
|
|
|
|
initialize: function() {
|
2007-09-25 23:58:42 +02:00
|
|
|
if(this.selectedIndex != 0) {
|
2007-09-16 18:30:26 +02:00
|
|
|
this.showlangtree();
|
2007-09-25 23:58:42 +02:00
|
|
|
_TRANSLATING_LANG = this.value;
|
2007-09-16 18:30:26 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onshow: function() {
|
2007-09-25 23:58:42 +02:00
|
|
|
if(this.value) this.showlangtree();
|
2007-09-16 18:30:26 +02:00
|
|
|
},
|
|
|
|
|
2007-09-25 23:58:42 +02:00
|
|
|
onchange: function(e, val) {
|
|
|
|
if(this.value != _TRANSLATING_LANG) {
|
|
|
|
_TRANSLATING_LANG = this.value;
|
2007-09-16 18:30:26 +02:00
|
|
|
this.showlangtree();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
selectValue: function(lang) {
|
2007-09-25 23:58:42 +02:00
|
|
|
this.value = lang;
|
|
|
|
if(this.value != lang) {
|
2007-09-16 18:30:26 +02:00
|
|
|
var newLang = document.createElement('option');
|
|
|
|
newLang.text = lang;
|
|
|
|
newLang.value = lang;
|
|
|
|
try {
|
2007-09-25 23:58:42 +02:00
|
|
|
this.add(newLang, null); // standards compliant
|
2007-09-16 18:30:26 +02:00
|
|
|
} catch(ex) {
|
2007-09-25 23:58:42 +02:00
|
|
|
this.add(newLang); // IE only
|
2007-09-16 18:30:26 +02:00
|
|
|
}
|
2007-09-25 23:58:42 +02:00
|
|
|
this.value = lang;
|
2007-09-16 18:30:26 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
showlangtree: function() {
|
2007-09-25 23:58:42 +02:00
|
|
|
if(this.value) {
|
|
|
|
$('sitetree').innerHTML=' <img src="cms/images/network-save.gif> loading...';
|
|
|
|
new Ajax.Request('admin/switchlanguage/' + this.value, {
|
2007-09-16 18:30:26 +02:00
|
|
|
method : 'post',
|
|
|
|
onSuccess: Ajax.Evaluator,
|
|
|
|
onFailure : Ajax.Evaluator
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
LangSelector.applyTo('#LangSelector');
|
|
|
|
|
2007-09-25 23:58:42 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2007-09-16 18:30:26 +02:00
|
|
|
TranslatorCreator = Class.create();
|
|
|
|
TranslatorCreator.prototype = {
|
|
|
|
|
|
|
|
onSelectionChanged: function(selectedNode) {
|
2007-09-25 23:58:42 +02:00
|
|
|
if(_TRANSLATING_LANG && Element.hasClassName(selectedNode,'untranslated')) {
|
2007-09-16 18:30:26 +02:00
|
|
|
$start = confirm('Would you like to start a translation for this page?');
|
2007-09-25 23:58:42 +02:00
|
|
|
if($start) Element.removeClassName(selectedNode,'untranslated');
|
2007-09-16 18:30:26 +02:00
|
|
|
return $start;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
initialize: function() {
|
|
|
|
$('sitetree').observeMethod('SelectionChanged', this.onSelectionChanged.bind(this));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
TranslatorCreator.applyTo('#LangSelector_holder');
|