ref: refs/heads/master
commit b2a746a8bc27f024a1ef276ffe6d61a6fc0d2d5d
Author: Martin Vidner
Date: Thu Nov 5 10:40:20 2009 +0100
Switch tabs before focusing an input field during validation (bnc#551775).
---
plugins/network/app/views/network/index.html.erb | 25 ++++++++++++++++++---
1 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/plugins/network/app/views/network/index.html.erb b/plugins/network/app/views/network/index.html.erb
index db0da6a..4447207 100644
--- a/plugins/network/app/views/network/index.html.erb
+++ b/plugins/network/app/views/network/index.html.erb
@@ -20,6 +20,23 @@
// $(this)[0].disabled = abool;
// });
}
+ // Sets a focus to a fieldID, switching to its tab first.
+ // fieldID is like "default_route"
+ function focus_tabbed(fieldID) {
+ // show its fieldset and save ID
+ var fsID = $("#"+fieldID).closest('fieldset').attr('id');
+ $("#"+fsID).show()
+ // hide all other fieldsets
+ $("#"+fsID).siblings('fieldset').hide();
+ // Remove highlighting from tabs
+ $('.tab-nav').find('a').removeClass('selected');
+ var className = fsID
+ // highlight its tab
+ $('.'+className).addClass('selected');
+ // focus at last
+ $("#"+fieldID).focus();
+ }
+
<% end -%>
<% javascript_tag do -%>
function validIP(ip) {
@@ -37,18 +54,18 @@
if ($("#conf_mode")[0].value == "static") {
say_bad = "<%= _("Invalid IP address format. The correct one is nnn.nnn.nnn.nnn for nnn between 0 and 255.") %>"
if (! validIP($("#ip")[0].value)) {
- $("#ip").focus();
+ focus_tabbed("ip");
alert (say_bad);
return false;
}
netmask = $("#netmask")[0].value;
if (!validPrefix(netmask) && ! validMask(netmask)) {
- $("#netmask").focus();
+ focus_tabbed("netmask");
alert (say_bad);
return false;
}
if (! validIP($("#default_route")[0].value)) {
- $("#default_route").focus();
+ focus_tabbed("default_route");
alert (say_bad);
return false;
}
@@ -144,4 +161,4 @@
disabled = <%= write_disabled %> || value != "static";
disable_static_config(disabled);
})
-<% end -%>
\ No newline at end of file
+<% end -%>
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org