mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
5b80a0c1d1
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@65802 467b73ca-7a2a-4603-9d3b-597d59a354a9
74 lines
1.6 KiB
JavaScript
Executable File
74 lines
1.6 KiB
JavaScript
Executable File
var _TRANSLATING_LANG = null;
|
|
|
|
/**
|
|
*
|
|
*/
|
|
LangSelectorClass = Class.create();
|
|
LangSelectorClass.prototype = {
|
|
|
|
initialize: function() {
|
|
if(this.selectedIndex != 0) {
|
|
this.showlangtree();
|
|
_TRANSLATING_LANG = this.value;
|
|
}
|
|
},
|
|
|
|
onshow: function() {
|
|
if(this.value) this.showlangtree();
|
|
},
|
|
|
|
onchange: function(e, val) {
|
|
if(this.value != _TRANSLATING_LANG) {
|
|
_TRANSLATING_LANG = this.value;
|
|
this.showlangtree();
|
|
}
|
|
},
|
|
|
|
selectValue: function(lang) {
|
|
this.value = lang;
|
|
if(this.value != lang) {
|
|
var newLang = document.createElement('option');
|
|
newLang.text = lang;
|
|
newLang.value = lang;
|
|
try {
|
|
this.add(newLang, null); // standards compliant
|
|
} catch(ex) {
|
|
this.add(newLang); // IE only
|
|
}
|
|
this.value = lang;
|
|
}
|
|
},
|
|
|
|
showlangtree: function() {
|
|
if(this.value) {
|
|
$('sitetree').innerHTML=' <img src="cms/images/network-save.gif> loading...';
|
|
new Ajax.Request('admin/switchlanguage/' + this.value, {
|
|
method : 'post',
|
|
onSuccess: Ajax.Evaluator,
|
|
onFailure : Ajax.Evaluator
|
|
});
|
|
}
|
|
}
|
|
};
|
|
LangSelectorClass.applyTo('#LangSelector');
|
|
|
|
/**
|
|
*
|
|
*/
|
|
TranslatorCreator = Class.create();
|
|
TranslatorCreator.prototype = {
|
|
|
|
onSelectionChanged: function(selectedNode) {
|
|
if(_TRANSLATING_LANG && Element.hasClassName(selectedNode,'untranslated')) {
|
|
$start = confirm('Would you like to start a translation for this page?');
|
|
if($start) Element.removeClassName(selectedNode,'untranslated');
|
|
return $start;
|
|
}
|
|
},
|
|
|
|
initialize: function() {
|
|
$('sitetree').observeMethod('SelectionChanged', this.onSelectionChanged.bind(this));
|
|
}
|
|
|
|
}
|
|
TranslatorCreator.applyTo('#LangSelector_holder'); |