Skip to content

Instantly share code, notes, and snippets.

@evansolomon
Last active December 10, 2015 06:08
Show Gist options
  • Save evansolomon/4392118 to your computer and use it in GitHub Desktop.
Save evansolomon/4392118 to your computer and use it in GitHub Desktop.
Close Debug Bar with escape key
// Generated by CoffeeScript 1.4.0
(function() {
(function($) {
return $(function() {
var db;
db = window.wpDebugBar;
return $(document).keydown(function(event) {
var _ref, _ref1;
if (((_ref = db.body) != null ? _ref.hasClass('debug-bar-visible') : void 0) && 27 === event.keyCode) {
return (_ref1 = db.actions) != null ? _ref1.close() : void 0;
}
});
});
})(jQuery);
}).call(this);
( ( $ ) ->
$ ->
# Short reference to the debug bar object
db = window.wpDebugBar
# Close the debug bar with escape when its open
$( document ).keydown ( event ) ->
db.actions?.close() if db.body?.hasClass( 'debug-bar-visible' ) and 27 == event.keyCode
) jQuery
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment