libs/cbi: Optimized Comboboxes
authorSteven Barth <steven@midlink.org>
Mon, 4 Aug 2008 17:35:44 +0000 (17:35 +0000)
committerSteven Barth <steven@midlink.org>
Mon, 4 Aug 2008 17:35:44 +0000 (17:35 +0000)
i18n/english/luasrc/i18n/cbi.en.lua
i18n/german/luasrc/i18n/cbi.de.lua
libs/cbi/htdocs/luci-static/resources/cbi.js

index ca1285d0a942b574e38c4db523afd1cf0ea99cb6..012d7c5f6b0b16914b0dc61ca4c52d4e65996c62 100644 (file)
@@ -4,5 +4,5 @@ cbi_invalid = "Error: Invalid input value"
 cbi_addopt = "-- Additional Field --"
 cbi_optional = " (optional)"
 cbi_sectempty = "This section contains no values yet"
-cbi_manual = "-- manual --"
+cbi_manual = "-- custom --"
 cbi_select = "-- Please choose --"
index f34cb59b5de1398d6a2be8c22651ab02a2802d8f..f2ed5ecd245af5bbededc76a07de900c450e4b0c 100644 (file)
@@ -3,5 +3,5 @@ cbi_del = "Eintrag entfernen"
 cbi_invalid = "Error: Ungültige Eingabe"
 cbi_addopt = "-- Zusätzliches Feld --"
 cbi_sectempty = "Diese Sektion enthält noch keine Einträge"
-cbi_manual = "-- manuell --"
+cbi_manual = "-- benutzerdefiniert --"
 cbi_select = "-- Bitte auswählen --"
\ No newline at end of file
index 38e27d8f437612d6df1b5bd341cbc016b10b45c6..7cb2f7c1dc41bd752080fa74ba263d625477ea61 100644 (file)
@@ -60,46 +60,50 @@ function cbi_bind(obj, type, callback, mode) {
 
 function cbi_combobox(id, values, def, man) {
        var obj = document.getElementById(id)
-       if (obj.value == "" || values[obj.value]) {
-               var sel = document.createElement("select")
-               obj.parentNode.appendChild(sel)
+       var sel = document.createElement("select");
+       obj.parentNode.appendChild(sel);
 
-               if (obj.value == "") {
-                       var optdef = document.createElement("option")
-                       optdef.value = ""
-                       optdef.appendChild(document.createTextNode(def))
-                       sel.appendChild(optdef)
-               }
-
-               for (var i in values) {
-                       var opt = document.createElement("option")
-                       opt.value = i
+       if (obj.value == "") {
+               var optdef = document.createElement("option");
+               optdef.value = "";
+               optdef.appendChild(document.createTextNode(def));
+               sel.appendChild(optdef);
+       } else if (!values[obj.value]) {
+               var opt = document.createElement("option");
+               opt.value = obj.value;
+               opt.selected = "selected";
+               opt.appendChild(document.createTextNode(obj.value));
+               sel.appendChild(opt);   
+       }
 
-                       if (obj.value == i) {
-                               opt.selected = "selected"
-                       }
+       for (var i in values) {
+               var opt = document.createElement("option");
+               opt.value = i;
 
-                       opt.appendChild(document.createTextNode(values[i]))
-                       sel.appendChild(opt)
+               if (obj.value == i) {
+                       opt.selected = "selected";
                }
 
-               var optman = document.createElement("option")
-               optman.value = ""
-               optman.appendChild(document.createTextNode(man))
-               sel.appendChild(optman)
+               opt.appendChild(document.createTextNode(values[i]));
+               sel.appendChild(opt);
+       }
+
+       var optman = document.createElement("option");
+       optman.value = "";
+       optman.appendChild(document.createTextNode(man));
+       sel.appendChild(optman);
 
-               obj.style.display = "none"
+       obj.style.display = "none";
 
-               cbi_bind(sel, "change", function() {
-                       obj.value = sel.options[sel.selectedIndex].value
+       cbi_bind(sel, "change", function() {
+               obj.value = sel.options[sel.selectedIndex].value;
 
-                       if (sel.selectedIndex == sel.options.length - 1) {
-                               obj.style.display = "inline"
-                               sel.parentNode.removeChild(sel)
-                               obj.focus()
-                       }
-               })
-       }
+               if (sel.selectedIndex == sel.options.length - 1) {
+                       obj.style.display = "inline";
+                       sel.parentNode.removeChild(sel);
+                       obj.focus();
+               }
+       })
 }
 
 function cbi_combobox_init(id, values, def, man) {