public_html/js
Aleksander Machniak
machniak at kolabsys.com
Tue Jul 2 12:51:15 CEST 2013
public_html/js/kolab_admin.js | 60 +++++++++++++++++++++++-------------------
1 file changed, 34 insertions(+), 26 deletions(-)
New commits:
commit 5ce6595a60ad67281da58cf7c06fecb4b158d199
Author: Aleksander Machniak <alec at alec.pl>
Date: Tue Jul 2 12:50:05 2013 +0200
Fix infinite loop in domain selector when rollower list contains
one element, small improvements in Up/Down arrow keys handling (Bug #2005)
diff --git a/public_html/js/kolab_admin.js b/public_html/js/kolab_admin.js
index f3281fd..b5bc376 100644
--- a/public_html/js/kolab_admin.js
+++ b/public_html/js/kolab_admin.js
@@ -1030,6 +1030,12 @@ function kolab_admin()
if (e.which == 13)
e.preventDefault();
})
+ .keydown(function(e) {
+ // block Up/Down arrow keys,
+ // in Firefox Up arrow moves cursor left
+ if (e.which == 38 || e.which == 40)
+ e.preventDefault();
+ })
.keyup(function(e) {
// filtering
var s = this.value,
@@ -1048,36 +1054,38 @@ function kolab_admin()
// UP/Down arrows
else if (e.which == 38 || e.which == 40) {
options = options.not(':hidden');
- var selected = options.filter('.selected');
-
- if (!selected.length) {
- if (e.which == 40) // Down key
- options.first().addClass('selected').parent().get(0).scrollTop = 0;
- }
- else {
- var focused = selected[e.which == 40 ? 'next' : 'prev']();
- while (focused.length && focused.is(':hidden'))
- focused = selected[e.which == 40 ? 'next' : 'prev']();
+ if (options.length <= 1)
+ return;
- if (!focused.length)
- focused = options[e.which == 40 ? 'first' : 'last']();
+ var focused,
+ selected = options.filter('.selected'),
+ index = options.index(selected);
- if (focused.length) {
- selected.removeClass('selected');
- focused.addClass('selected');
-
- var parent = focused.parent(),
- parent_height = parent.height(),
- parent_top = parent.get(0).scrollTop,
- top = focused.offset().top - parent.offset().top,
- height = focused.height();
+ if (e.which == 40) {
+ if (!(focused = options.get(index+1)))
+ focused = options.get(index-1);
+ }
+ else {
+ if (!(focused = options.get(index-1)))
+ focused = options.get(index+1);
+ }
- if (top < 0)
- parent.get(0).scrollTop = 0;
- else if (top >= parent_height)
- parent.get(0).scrollTop = top - parent_height + height + parent_top;
- }
+ if (focused) {
+ focused = $(focused);
+ selected.removeClass('selected');
+ focused.addClass('selected');
+
+ var parent = focused.parent(),
+ parent_height = parent.height(),
+ parent_top = parent.get(0).scrollTop,
+ top = focused.offset().top - parent.offset().top,
+ height = focused.height();
+
+ if (top < 0)
+ parent.get(0).scrollTop = 0;
+ else if (top >= parent_height)
+ parent.get(0).scrollTop = top - parent_height + height + parent_top;
}
return;
More information about the commits
mailing list