Show
Ignore:
Timestamp:
09/04/08 17:53:14 (3 months ago)
Author:
ryan
Message:

Bulk action hot keys for comments. Props nbachiyski. see #7643

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-includes/js/jquery/jquery.table-hotkeys.js

    r8794 r8804  
    6565            } 
    6666        }; 
    67         var make_key_expr = function(elem) { 
    68             if (typeof elem.key == 'string') { 
    69                 key = elem.key; 
    70                 if (typeof elem.expr == 'string') 
    71                     expr = elem.expr; 
    72                 else if (typeof elem.suffix == 'string') 
    73                     expr = '.'+opts.class_prefix+elem.suffix; 
    74                 else 
    75                     expr = '.'+opts.class_prefix+elem.key; 
    76             } else { 
    77                 key = elem; 
    78                 expr = '.'+opts.class_prefix+elem; 
    79             } 
    80             return {key: key, expr: expr}; 
    81         }; 
    8267        var first_row = get_first_row(); 
    83         if (!first_row.length) return; 
    84         if (opts.highlight_first) { 
     68        if (!first_row.length) return;      
     69        if (opts.highlight_first) 
    8570            set_current_row(first_row); 
    86         } else if (opts.highlight_last) { 
     71        else if (opts.highlight_last) 
    8772            set_current_row(get_last_row()); 
    88         }; 
    8973        jQuery.hotkeys.add(opts.prev_key, opts.hotkeys_opts, function() {return adjacent_row_callback('prev')}); 
    9074        jQuery.hotkeys.add(opts.next_key, opts.hotkeys_opts, function() {return adjacent_row_callback('next')}); 
    9175        jQuery.hotkeys.add(opts.mark_key, opts.hotkeys_opts, check); 
    9276        jQuery.each(keys, function() { 
    93             var key_expr = make_key_expr(this); 
    94             jQuery.hotkeys.add(key_expr.key, opts.hotkeys_opts, make_key_callback(key_expr.expr)); 
     77            if ($.isFunction(this[1])) { 
     78                var callback = this[1]; 
     79                var key = this[0]; 
     80                jQuery.hotkeys.add(key, opts.hotkeys_opts, function(event) { return callback(event, $.table_hotkeys.current_row); }); 
     81            } else { 
     82                var key = this; 
     83                jQuery.hotkeys.add(key, opts.hotkeys_opts, make_key_callback('.'+opts.class_prefix+key)); 
     84            } 
    9585        }); 
    9686         
     
    10090        destructive_suffix: 'destructive', hotkeys_opts: {disableInInput: true, type: 'keypress'}, 
    10191        checkbox_expr: ':checkbox', next_key: 'j', prev_key: 'k', mark_key: 'x', 
    102         start_row_index: 1, highlight_first: false, highlight_last: false, next_page_link_cb: function() {}, prev_page_link_cb: function() {}}; 
     92        start_row_index: 1, highlight_first: false, highlight_last: false, next_page_link_cb: false, prev_page_link_cb: false}; 
    10393})(jQuery);