diff --git a/javascript/LangSelector.js b/javascript/LangSelector.js new file mode 100755 index 00000000..e2e72452 --- /dev/null +++ b/javascript/LangSelector.js @@ -0,0 +1,79 @@ +var _TRANSLATING_LANG = null; +LangSelector = Class.create(); +LangSelector.prototype = { + + initialize: function() { + this.selector = $('LangSelector'); + //this.selector.addEventListener("click", this.a, null); + + if(this.selector) this.selector.holder = this; + if(this.selector.selectedIndex != 0) { + this.showlangtree(); + _TRANSLATING_LANG = this.selector.value; + } + }, + + destroy: function() { + if(this.selector) this.selector.holder = null; + this.selector = null; + }, + + onshow: function() { + if(this.selector.value) this.showlangtree(); + }, + + onchange: function() { + if (this.selector.value != _TRANSLATING_LANG) { + if (this.selector.selectedIndex != 0) _TRANSLATING_LANG = this.selector.value; + else _TRANSLATING_LANG = null; + this.showlangtree(); + } + }, + + selectValue: function(lang) { + this.selector.value = lang; + if (this.selector.value != lang) { + var newLang = document.createElement('option'); + newLang.text = lang; + newLang.value = lang; + try { + this.selector.add(newLang, null); // standards compliant + } catch(ex) { + this.selector.add(newLang); // IE only + } + this.selector.value = lang; + } + }, + + showlangtree: function() { + $('sitetree').innerHTML='