changeset 5 | 5e2f62d02dcd |
parent 0 | d970ebf37754 |
child 18 | be944660c56a |
4:346c88efed21 | 5:5e2f62d02dcd |
---|---|
6 for(i=0; i<depth-1; ++i) { |
6 for(i=0; i<depth-1; ++i) { |
7 if (!p.is(':visible')) return false; |
7 if (!p.is(':visible')) return false; |
8 p = p.parent(); |
8 p = p.parent(); |
9 } |
9 } |
10 return true; |
10 return true; |
11 } |
11 }; |
12 return this.filter(is_visible); |
12 return this.filter(is_visible); |
13 }; |
13 }; |
14 $.table_hotkeys = function(table, keys, opts) { |
14 $.table_hotkeys = function(table, keys, opts) { |
15 opts = $.extend($.table_hotkeys.defaults, opts); |
15 opts = $.extend($.table_hotkeys.defaults, opts); |
16 var selected_class, destructive_class, set_current_row, adjacent_row_callback, get_adjacent_row, adjacent_row, prev_row, next_row, check, get_first_row, get_last_row, make_key_callback, first_row; |
16 var selected_class, destructive_class, set_current_row, adjacent_row_callback, get_adjacent_row, adjacent_row, prev_row, next_row, check, get_first_row, get_last_row, make_key_callback, first_row; |
17 |
17 |
18 selected_class = opts.class_prefix + opts.selected_suffix; |
18 selected_class = opts.class_prefix + opts.selected_suffix; |
19 destructive_class = opts.class_prefix + opts.destructive_suffix |
19 destructive_class = opts.class_prefix + opts.destructive_suffix; |
20 set_current_row = function (tr) { |
20 set_current_row = function (tr) { |
21 if ($.table_hotkeys.current_row) $.table_hotkeys.current_row.removeClass(selected_class); |
21 if ($.table_hotkeys.current_row) $.table_hotkeys.current_row.removeClass(selected_class); |
22 tr.addClass(selected_class); |
22 tr.addClass(selected_class); |
23 tr[0].scrollIntoView(false); |
23 tr[0].scrollIntoView(false); |
24 $.table_hotkeys.current_row = tr; |
24 $.table_hotkeys.current_row = tr; |
64 if ( null == $.table_hotkeys.current_row ) return false; |
64 if ( null == $.table_hotkeys.current_row ) return false; |
65 var clickable = $(expr, $.table_hotkeys.current_row); |
65 var clickable = $(expr, $.table_hotkeys.current_row); |
66 if (!clickable.length) return false; |
66 if (!clickable.length) return false; |
67 if (clickable.is('.'+destructive_class)) next_row() || prev_row(); |
67 if (clickable.is('.'+destructive_class)) next_row() || prev_row(); |
68 clickable.click(); |
68 clickable.click(); |
69 } |
69 }; |
70 }; |
70 }; |
71 first_row = get_first_row(); |
71 first_row = get_first_row(); |
72 if (!first_row.length) return; |
72 if (!first_row.length) return; |
73 if (opts.highlight_first) |
73 if (opts.highlight_first) |
74 set_current_row(first_row); |
74 set_current_row(first_row); |
75 else if (opts.highlight_last) |
75 else if (opts.highlight_last) |
76 set_current_row(get_last_row()); |
76 set_current_row(get_last_row()); |
77 $.hotkeys.add(opts.prev_key, opts.hotkeys_opts, function() {return adjacent_row_callback('prev')}); |
77 $.hotkeys.add(opts.prev_key, opts.hotkeys_opts, function() {return adjacent_row_callback('prev');}); |
78 $.hotkeys.add(opts.next_key, opts.hotkeys_opts, function() {return adjacent_row_callback('next')}); |
78 $.hotkeys.add(opts.next_key, opts.hotkeys_opts, function() {return adjacent_row_callback('next');}); |
79 $.hotkeys.add(opts.mark_key, opts.hotkeys_opts, check); |
79 $.hotkeys.add(opts.mark_key, opts.hotkeys_opts, check); |
80 $.each(keys, function() { |
80 $.each(keys, function() { |
81 var callback, key; |
81 var callback, key; |
82 |
82 |
83 if ($.isFunction(this[1])) { |
83 if ($.isFunction(this[1])) { |