X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fluci2%2Fui.git;a=blobdiff_plain;f=luci2%2Fhtdocs%2Fluci2%2Fluci2.js;h=c6c13a101d65b1360390010b69b39b5b16efbb5f;hp=00365ae2cc593533ad3b1115a92cfcf469494e31;hb=1bcb587b9fbd9c513a7f60e6cb6de22eb564e79e;hpb=8f18cd5ef6869ab434fbe0fb002cb97fd34d3543
diff --git a/luci2/htdocs/luci2/luci2.js b/luci2/htdocs/luci2/luci2.js
index 00365ae..c6c13a1 100644
--- a/luci2/htdocs/luci2/luci2.js
+++ b/luci2/htdocs/luci2/luci2.js
@@ -5489,7 +5489,7 @@ function LuCI2()
var s = $('')
.addClass('form-control');
- if (this.options.optional)
+ if (this.options.optional && !this.has_empty)
$('')
.attr('value', '')
.text(_luci2.tr('-- Please choose --'))
@@ -5512,6 +5512,9 @@ function LuCI2()
if (!this.choices)
this.choices = [ ];
+ if (k == '')
+ this.has_empty = true;
+
this.choices.push([k, v || k]);
return this;
}
@@ -5586,10 +5589,7 @@ function LuCI2()
{
ev.data.select.hide();
ev.data.input.show().focus();
-
- var v = ev.data.input.val();
- ev.data.input.val(' ');
- ev.data.input.val(v);
+ ev.data.input.val('');
}
else if (self.options.optional && s.selectedIndex == 0)
{
@@ -5599,6 +5599,8 @@ function LuCI2()
{
ev.data.input.val(ev.data.select.val());
}
+
+ ev.stopPropagation();
},
_blur: function(ev)
@@ -5609,7 +5611,7 @@ function LuCI2()
ev.data.select.empty();
- if (self.options.optional)
+ if (self.options.optional && !self.has_empty)
$('')
.attr('value', '')
.text(_luci2.tr('-- please choose --'))
@@ -5639,7 +5641,7 @@ function LuCI2()
.appendTo(ev.data.select);
ev.data.input.hide();
- ev.data.select.val(val).show().focus();
+ ev.data.select.val(val).show().blur();
},
_enter: function(ev)
@@ -5658,17 +5660,19 @@ function LuCI2()
.attr('id', this.id(sid));
var t = $('')
+ .addClass('form-control')
.attr('type', 'text')
.hide()
.appendTo(d);
var s = $('')
+ .addClass('form-control')
.appendTo(d);
var evdata = {
self: this,
- input: this.validator(sid, t),
- select: this.validator(sid, s)
+ input: t,
+ select: s
};
s.change(evdata, this._change);
@@ -5678,6 +5682,9 @@ function LuCI2()
t.val(this.ucivalue(sid));
t.blur();
+ this.validator(sid, t);
+ this.validator(sid, s);
+
return d;
},
@@ -5686,6 +5693,9 @@ function LuCI2()
if (!this.choices)
this.choices = [ ];
+ if (k == '')
+ this.has_empty = true;
+
this.choices.push([k, v || k]);
return this;
},