-
+ 7C3C4B55C51D91AB842AC90CE93AF4326272BE0BE9F8350619F92A402EB8266067C2ADA83F67D0FFE182143886909F0CE3D143EF2E24C25110FA4CDEFE6506CBmp-wp/wp-includes/js/jquery/jquery.table-hotkeys.js(0 . 0)(1 . 93)
102403 (function($){
102404 $.fn.filter_visible = function(depth) {
102405 depth = depth || 3;
102406 var is_visible = function() {
102407 var p = $(this);
102408 for(i=0; i<depth-1; ++i) {
102409 if (!p.is(':visible')) return false;
102410 p = p.parent();
102411 }
102412 return true;
102413 }
102414 return this.filter(is_visible);
102415 };
102416 $.table_hotkeys = function(table, keys, opts) {
102417 opts = $.extend($.table_hotkeys.defaults, opts);
102418 var selected_class = opts.class_prefix + opts.selected_suffix;
102419 var destructive_class = opts.class_prefix + opts.destructive_suffix;
102420 var set_current_row = function (tr) {
102421 if ($.table_hotkeys.current_row) $.table_hotkeys.current_row.removeClass(selected_class);
102422 tr.addClass(selected_class);
102423 tr[0].scrollIntoView(false);
102424 $.table_hotkeys.current_row = tr;
102425 };
102426 var adjacent_row_callback = function(which) {
102427 if (!adjacent_row(which) && $.isFunction(opts[which+'_page_link_cb'])) {
102428 opts[which+'_page_link_cb']();
102429 }
102430 };
102431 var get_adjacent_row = function(which) {
102432 if (!$.table_hotkeys.current_row) {
102433 var first_row = get_first_row();
102434 $.table_hotkeys.current_row = first_row;
102435 return first_row[0];
102436 }
102437 var method = 'prev' == which? $.fn.prevAll : $.fn.nextAll;
102438 return method.call($.table_hotkeys.current_row, opts.cycle_expr).filter_visible()[0];
102439 };
102440 var adjacent_row = function(which) {
102441 var adj = get_adjacent_row(which);
102442 if (!adj) return false;
102443 set_current_row($(adj));
102444 return true;
102445 };
102446 var prev_row = function() { return adjacent_row('prev'); };
102447 var next_row = function() { return adjacent_row('next'); };
102448 var check = function() {
102449 $(opts.checkbox_expr, $.table_hotkeys.current_row).each(function() {
102450 this.checked = !this.checked;
102451 });
102452 };
102453 var get_first_row = function() {
102454 return $(opts.cycle_expr, table).filter_visible().eq(opts.start_row_index);
102455 };
102456 var get_last_row = function() {
102457 var rows = $(opts.cycle_expr, table).filter_visible();
102458 return rows.eq(rows.length-1);
102459 };
102460 var make_key_callback = function(expr) {
102461 return function() {
102462 if ( null == $.table_hotkeys.current_row ) return false;
102463 var clickable = $(expr, $.table_hotkeys.current_row);
102464 if (!clickable.length) return false;
102465 if (clickable.is('.'+destructive_class)) next_row() || prev_row();
102466 clickable.click();
102467 }
102468 };
102469 var first_row = get_first_row();
102470 if (!first_row.length) return;
102471 if (opts.highlight_first)
102472 set_current_row(first_row);
102473 else if (opts.highlight_last)
102474 set_current_row(get_last_row());
102475 jQuery.hotkeys.add(opts.prev_key, opts.hotkeys_opts, function() {return adjacent_row_callback('prev')});
102476 jQuery.hotkeys.add(opts.next_key, opts.hotkeys_opts, function() {return adjacent_row_callback('next')});
102477 jQuery.hotkeys.add(opts.mark_key, opts.hotkeys_opts, check);
102478 jQuery.each(keys, function() {
102479 if ($.isFunction(this[1])) {
102480 var callback = this[1];
102481 var key = this[0];
102482 jQuery.hotkeys.add(key, opts.hotkeys_opts, function(event) { return callback(event, $.table_hotkeys.current_row); });
102483 } else {
102484 var key = this;
102485 jQuery.hotkeys.add(key, opts.hotkeys_opts, make_key_callback('.'+opts.class_prefix+key));
102486 }
102487 });
102488
102489 };
102490 $.table_hotkeys.current_row = null;
102491 $.table_hotkeys.defaults = {cycle_expr: 'tr', class_prefix: 'vim-', selected_suffix: 'current',
102492 destructive_suffix: 'destructive', hotkeys_opts: {disableInInput: true, type: 'keypress'},
102493 checkbox_expr: ':checkbox', next_key: 'j', prev_key: 'k', mark_key: 'x',
102494 start_row_index: 2, highlight_first: false, highlight_last: false, next_page_link_cb: false, prev_page_link_cb: false};
102495 })(jQuery);