Ticket #7643: table-hotkeys-edit-bulk-and-strip.diff
| File table-hotkeys-edit-bulk-and-strip.diff, 4.4 KB (added by nbachiyski, 5 years ago) |
|---|
-
wp-includes/js/jquery/jquery.table-hotkeys.js
64 64 clickable.click(); 65 65 } 66 66 }; 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 else75 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 };82 67 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) 85 70 set_current_row(first_row); 86 } else if (opts.highlight_last) {71 else if (opts.highlight_last) 87 72 set_current_row(get_last_row()); 88 };89 73 jQuery.hotkeys.add(opts.prev_key, opts.hotkeys_opts, function() {return adjacent_row_callback('prev')}); 90 74 jQuery.hotkeys.add(opts.next_key, opts.hotkeys_opts, function() {return adjacent_row_callback('next')}); 91 75 jQuery.hotkeys.add(opts.mark_key, opts.hotkeys_opts, check); 92 76 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 } 95 85 }); 96 86 97 87 }; … … 99 89 $.table_hotkeys.defaults = {cycle_expr: 'tr', class_prefix: 'vim-', selected_suffix: 'current', 100 90 destructive_suffix: 'destructive', hotkeys_opts: {disableInInput: true, type: 'keypress'}, 101 91 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: f unction() {}, 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}; 103 93 })(jQuery); -
wp-admin/js/edit-comments.js
243 243 if (l.length) 244 244 window.location = l[0].href.replace(/\&hotkeys_highlight_(first|last)=1/g, '')+'&hotkeys_highlight_'+first_last+'=1'; 245 245 } 246 }; 247 var edit_comment = function(event, current_row) { 248 window.location = $('span.edit a', current_row).attr('href'); 249 }; 250 var toggle_all = function() { 251 var master_checkbox = $('form#comments-form .check-column :checkbox:first'); 252 master_checkbox.attr('checked', master_checkbox.attr('checked')? '' : 'checked'); 253 checkAll('form#comments-form'); 246 254 } 247 $.table_hotkeys($('table.widefat'), ['a', 'u', 's', 'd', 'r'], 248 { highlight_first: adminCommentsL10n.hotkeys_highlight_first, 249 highlight_last: adminCommentsL10n.hotkeys_highlight_last, 250 prev_page_link_cb: make_hotkeys_redirect('prev'), 251 next_page_link_cb: make_hotkeys_redirect('next'), 255 var make_bulk = function(value) { 256 return function(event, _) { 257 $('option[value='+value+']').attr('selected', 'selected'); 258 $('form#comments-form')[0].submit(); 252 259 } 260 }; 261 $.table_hotkeys($('table.widefat'),['a', 'u', 's', 'd', 'r', ['e', edit_comment], 262 ['shift+a', make_bulk('approve')], ['shift+s', make_bulk('markspam')], 263 ['shift+d', make_bulk('delete')], ['shift+x', toggle_all]], 264 {highlight_first: adminCommentsL10n.hotkeys_highlight_first, highlight_last: adminCommentsL10n.hotkeys_highlight_last, 265 prev_page_link_cb: make_hotkeys_redirect('prev'), next_page_link_cb: make_hotkeys_redirect('next')} 253 266 ); 254 267 } 255 268 }); -
wp-admin/js/forms.js
23 23 $( 'thead :checkbox' ).click( function() { 24 24 checkAll( $(this).parents( 'form:first' ) ); 25 25 } ); 26 } ); 27 No newline at end of file 26 } );