Skip to content

Instantly share code, notes, and snippets.

@satyr
Last active May 11, 2016 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save satyr/236927 to your computer and use it in GitHub Desktop.
Save satyr/236927 to your computer and use it in GitHub Desktop.
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