Last active
May 11, 2016 17:49
-
-
Save satyr/236927 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function cmd_toggle_autohide(){ | |
displayMessage(toggleAutoHide(context.chromeWindow.gUbiquity), this); | |
} | |
function toggleAutoHide(U){ | |
var p = U.msgPanel, nah = noAutoHide(p), b = nah !== 'on'; | |
p.setAttribute('noautohide', b); | |
p[(b ? 'add' : 'remove') +'EventListener']('keydown', manualHide, false); | |
return nah; | |
} | |
function noAutoHide(p){ | |
return p.getAttribute('noautohide') === 'true' ? 'on' : 'off'; | |
} | |
function manualHide(e){ | |
if(e.keyCode !== e.DOM_VK_ESCAPE) return; | |
e.preventDefault(); | |
e.stopPropagation(); | |
this.hidePopup(); | |
} | |
CmdUtils.onUbiquityLoad(toggleAutoHide); | |
$.extend(cmd_toggle_autohide, { | |
icon: 'chrome://ubiquity/skin/icons/favicon.ico', | |
author: 'satyr', license: 'MIT', | |
}).__defineGetter__('description', function tah_desc(){ | |
var U = (context.chromeWindow || Utils.currentChromeWindow).gUbiquity; | |
return ((U ? 'Turns '+ noAutoHide(U.msgPanel).bold() : 'Toggles') + | |
" the auto-hiding behavior of Ubiquity panel."); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment