diff options
author | c0ffeeartc | 2015-02-08 00:55:17 +0200 |
---|---|---|
committer | c0ffeeartc | 2015-02-08 00:55:17 +0200 |
commit | 709756a927e29d968fdd8b83724c2aad2efcc78f (patch) | |
tree | e48ed21483089d98a6296a4a478133623ddc6e93 /tinymenu.js | |
parent | b6c292395551bb1b2be3599a0a59fd739c155f14 (diff) | |
download | vimperator-plugins-709756a927e29d968fdd8b83724c2aad2efcc78f.tar.bz2 |
close all submenus on closing child, removed icon
Pressing escape with second popup being open didn't close main parent, and made main parent unresponsively hang. So I had to hack it to close all popups when any child menu popup closes.
Before hacking I didn't even know there was an icon in plugin, since I can't see and test it in Ubuntu 14.04, Firefox 35.0, I removed it.
Now it works through `:opentinymenu` command, and closes all submenus if any child gets closed.
Diffstat (limited to 'tinymenu.js')
-rw-r--r-- | tinymenu.js | 52 |
1 files changed, 8 insertions, 44 deletions
diff --git a/tinymenu.js b/tinymenu.js index d25179b..0b4ae02 100644 --- a/tinymenu.js +++ b/tinymenu.js @@ -9,9 +9,7 @@ var PLUGIN_INFO = xml` <license>MPL 1.1/GPL 2.0/LGPL 2.1</license> <version>0.2</version> <detail><![CDATA[ -append statusbar's menuicon like Tiny Menu [ https://addons.mozilla.org/firefox/addon/1455 ]. - -thx icon id:tnx. +open statusbar menu like Tiny Menu [ https://addons.mozilla.org/firefox/addon/1455 ] through ':opentinymenu' command. == Commands == :opentinymenu: @@ -20,63 +18,29 @@ thx icon id:tnx. </VimperatorPlugin>`; (function() { - if (!liberator.plugins.tinymenu) + if (!liberator.plugins.tinymenu) { liberator.plugins.tinymenu = {}; + } let tinymenu = liberator.plugins.tinymenu; - if (tinymenu.menu) return; - let p = function(msg) { - Application.console.log(msg); - }; + if (tinymenu.popup) return; - const ICON = 'data:image/png;base64,'+ - 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK'+ - '6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAGiSURBVHja'+ - 'jFPLSsNQEJ30kZK+Nkk3zUoQuhKErK0gCHHlN5SCUFoImEU3LgVBiFAQhIIf4UIo'+ - 'CIJ/oO3KbWm7aLorJTQg9UxsYxKi7cDhPuaec+femRFqtRpFrAJcAMfA4XrvHXgD'+ - 'usBn8HAqQr4ErlVVlXK5HEmS5G06jqMtFgttPB43sLwC7qICIvCkKIpeKpUok8mE'+ - 'VLPZrIdisSjZtm3NZrNTbJ8D7kbgFkQdN5Miy/SfqeUyffT7OoRusDRZ4ABoleFg'+ - 'O6pWyTTNEMmyrNB6atsEAQPTRxao4+akIAg/zumU2u12mIC9oCUSCWIO/qTOAjre'+ - '5js1TYsNvdls/qapUqFCocBTnQX2RFEMHTYMI7TudDoeKWjpdNr7klTcbUzYZusn'+ - 'J1lg6LrufjB1cRFEDRwehizQm8/nraDALhGAw8MLC3RHo1FDlmU/E9siWK1WhAx8'+ - 'bdI4AB4mk0mLC2mXCHCWh3vmCutm8ksZNR9L4iwsl0suIEIp96KlzD9yBoffTPl8'+ - 'PthMHhFhO38108bY8YyD3M4nkXZ+jWvnbwEGAKqdlwtH3ubkAAAAAElFTkSuQmCC'; - - if (!tinymenu.popup) { let menus = Array.slice(document.getElementById('main-menubar').childNodes); let popup = document.createElement('menupopup'); menus.reverse().forEach(function(elem) popup.appendChild(elem.cloneNode(true))); - popup.setAttribute('id', 'gimperator-tinymenu-popup'); + popup.setAttribute('id', 'vimperator-tinymenu-popup'); tinymenu.popup = popup; - } - - if (!tinymenu.menu) { - let menu = document.createElement('statusbarpanel'); - menu.setAttribute('id', 'vimperator-tinymenu'); - menu.setAttribute('class','statusbarpanel-iconic'); - menu.setAttribute('src', ICON); - tinymenu.menu = menu; - } - - let menu = tinymenu.menu; - let popup = tinymenu.popup; - menu.addEventListener('click', function(event) { - if (popup.state == 'closed') - popup.openPopup(menu, 'before_end', 0, 0, false, true); - }, false); + popup.addEventListener( 'popuphidden' , function(event) { popup.hidePopup(); } , false); commands.addUserCommand( ['opentinymenu'], 'Open the tiny menu ', function () { - popup.openPopup(menu, 'before_end', 0, 0, false, true); + popup.openPopup(document.getElementById('status-bar'), 'before_end', 0, 0, false, true); }, - true - ); + true); - //document.getElementById('status-bar').insertBefore(menu, document.getElementById('security-button').nextSibling); document.getElementById('status-bar').appendChild(popup); - document.getElementById('status-bar').appendChild(menu); })(); |