browser/base/content/browser-tabPreviews.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /*
michael@0 2 #ifdef 0
michael@0 3 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 6 #endif
michael@0 7 */
michael@0 8
michael@0 9 /**
michael@0 10 * Tab previews utility, produces thumbnails
michael@0 11 */
michael@0 12 var tabPreviews = {
michael@0 13 aspectRatio: 0.5625, // 16:9
michael@0 14
michael@0 15 get width() {
michael@0 16 delete this.width;
michael@0 17 return this.width = Math.ceil(screen.availWidth / 5.75);
michael@0 18 },
michael@0 19
michael@0 20 get height() {
michael@0 21 delete this.height;
michael@0 22 return this.height = Math.round(this.width * this.aspectRatio);
michael@0 23 },
michael@0 24
michael@0 25 init: function tabPreviews_init() {
michael@0 26 if (this._selectedTab)
michael@0 27 return;
michael@0 28 this._selectedTab = gBrowser.selectedTab;
michael@0 29
michael@0 30 gBrowser.tabContainer.addEventListener("TabSelect", this, false);
michael@0 31 gBrowser.tabContainer.addEventListener("SSTabRestored", this, false);
michael@0 32 },
michael@0 33
michael@0 34 get: function tabPreviews_get(aTab) {
michael@0 35 let uri = aTab.linkedBrowser.currentURI.spec;
michael@0 36
michael@0 37 if (aTab.__thumbnail_lastURI &&
michael@0 38 aTab.__thumbnail_lastURI != uri) {
michael@0 39 aTab.__thumbnail = null;
michael@0 40 aTab.__thumbnail_lastURI = null;
michael@0 41 }
michael@0 42
michael@0 43 if (aTab.__thumbnail)
michael@0 44 return aTab.__thumbnail;
michael@0 45
michael@0 46 if (aTab.getAttribute("pending") == "true") {
michael@0 47 let img = new Image;
michael@0 48 img.src = PageThumbs.getThumbnailURL(uri);
michael@0 49 return img;
michael@0 50 }
michael@0 51
michael@0 52 return this.capture(aTab, !aTab.hasAttribute("busy"));
michael@0 53 },
michael@0 54
michael@0 55 capture: function tabPreviews_capture(aTab, aStore) {
michael@0 56 var thumbnail = document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
michael@0 57 thumbnail.mozOpaque = true;
michael@0 58 thumbnail.height = this.height;
michael@0 59 thumbnail.width = this.width;
michael@0 60
michael@0 61 var ctx = thumbnail.getContext("2d");
michael@0 62 var win = aTab.linkedBrowser.contentWindow;
michael@0 63 var snippetWidth = win.innerWidth * .6;
michael@0 64 var scale = this.width / snippetWidth;
michael@0 65 ctx.scale(scale, scale);
michael@0 66 ctx.drawWindow(win, win.scrollX, win.scrollY,
michael@0 67 snippetWidth, snippetWidth * this.aspectRatio, "rgb(255,255,255)");
michael@0 68
michael@0 69 if (aStore &&
michael@0 70 aTab.linkedBrowser /* bug 795608: the tab may got removed while drawing the thumbnail */) {
michael@0 71 aTab.__thumbnail = thumbnail;
michael@0 72 aTab.__thumbnail_lastURI = aTab.linkedBrowser.currentURI.spec;
michael@0 73 }
michael@0 74
michael@0 75 return thumbnail;
michael@0 76 },
michael@0 77
michael@0 78 handleEvent: function tabPreviews_handleEvent(event) {
michael@0 79 switch (event.type) {
michael@0 80 case "TabSelect":
michael@0 81 if (this._selectedTab &&
michael@0 82 this._selectedTab.parentNode &&
michael@0 83 !this._pendingUpdate) {
michael@0 84 // Generate a thumbnail for the tab that was selected.
michael@0 85 // The timeout keeps the UI snappy and prevents us from generating thumbnails
michael@0 86 // for tabs that will be closed. During that timeout, don't generate other
michael@0 87 // thumbnails in case multiple TabSelect events occur fast in succession.
michael@0 88 this._pendingUpdate = true;
michael@0 89 setTimeout(function (self, aTab) {
michael@0 90 self._pendingUpdate = false;
michael@0 91 if (aTab.parentNode &&
michael@0 92 !aTab.hasAttribute("busy") &&
michael@0 93 !aTab.hasAttribute("pending"))
michael@0 94 self.capture(aTab, true);
michael@0 95 }, 2000, this, this._selectedTab);
michael@0 96 }
michael@0 97 this._selectedTab = event.target;
michael@0 98 break;
michael@0 99 case "SSTabRestored":
michael@0 100 this.capture(event.target, true);
michael@0 101 break;
michael@0 102 }
michael@0 103 }
michael@0 104 };
michael@0 105
michael@0 106 var tabPreviewPanelHelper = {
michael@0 107 opening: function (host) {
michael@0 108 host.panel.hidden = false;
michael@0 109
michael@0 110 var handler = this._generateHandler(host);
michael@0 111 host.panel.addEventListener("popupshown", handler, false);
michael@0 112 host.panel.addEventListener("popuphiding", handler, false);
michael@0 113
michael@0 114 host._prevFocus = document.commandDispatcher.focusedElement;
michael@0 115 },
michael@0 116 _generateHandler: function (host) {
michael@0 117 var self = this;
michael@0 118 return function (event) {
michael@0 119 if (event.target == host.panel) {
michael@0 120 host.panel.removeEventListener(event.type, arguments.callee, false);
michael@0 121 self["_" + event.type](host);
michael@0 122 }
michael@0 123 };
michael@0 124 },
michael@0 125 _popupshown: function (host) {
michael@0 126 if ("setupGUI" in host)
michael@0 127 host.setupGUI();
michael@0 128 },
michael@0 129 _popuphiding: function (host) {
michael@0 130 if ("suspendGUI" in host)
michael@0 131 host.suspendGUI();
michael@0 132
michael@0 133 if (host._prevFocus) {
michael@0 134 Cc["@mozilla.org/focus-manager;1"]
michael@0 135 .getService(Ci.nsIFocusManager)
michael@0 136 .setFocus(host._prevFocus, Ci.nsIFocusManager.FLAG_NOSCROLL);
michael@0 137 host._prevFocus = null;
michael@0 138 } else
michael@0 139 gBrowser.selectedBrowser.focus();
michael@0 140
michael@0 141 if (host.tabToSelect) {
michael@0 142 gBrowser.selectedTab = host.tabToSelect;
michael@0 143 host.tabToSelect = null;
michael@0 144 }
michael@0 145 }
michael@0 146 };
michael@0 147
michael@0 148 /**
michael@0 149 * Ctrl-Tab panel
michael@0 150 */
michael@0 151 var ctrlTab = {
michael@0 152 get panel () {
michael@0 153 delete this.panel;
michael@0 154 return this.panel = document.getElementById("ctrlTab-panel");
michael@0 155 },
michael@0 156 get showAllButton () {
michael@0 157 delete this.showAllButton;
michael@0 158 return this.showAllButton = document.getElementById("ctrlTab-showAll");
michael@0 159 },
michael@0 160 get previews () {
michael@0 161 delete this.previews;
michael@0 162 return this.previews = this.panel.getElementsByClassName("ctrlTab-preview");
michael@0 163 },
michael@0 164 get keys () {
michael@0 165 var keys = {};
michael@0 166 ["close", "find", "selectAll"].forEach(function (key) {
michael@0 167 keys[key] = document.getElementById("key_" + key)
michael@0 168 .getAttribute("key")
michael@0 169 .toLocaleLowerCase().charCodeAt(0);
michael@0 170 });
michael@0 171 delete this.keys;
michael@0 172 return this.keys = keys;
michael@0 173 },
michael@0 174 _selectedIndex: 0,
michael@0 175 get selected () this._selectedIndex < 0 ?
michael@0 176 document.activeElement :
michael@0 177 this.previews.item(this._selectedIndex),
michael@0 178 get isOpen () this.panel.state == "open" || this.panel.state == "showing" || this._timer,
michael@0 179 get tabCount () this.tabList.length,
michael@0 180 get tabPreviewCount () Math.min(this.previews.length - 1, this.tabCount),
michael@0 181 get canvasWidth () Math.min(tabPreviews.width,
michael@0 182 Math.ceil(screen.availWidth * .85 / this.tabPreviewCount)),
michael@0 183 get canvasHeight () Math.round(this.canvasWidth * tabPreviews.aspectRatio),
michael@0 184
michael@0 185 get tabList () {
michael@0 186 return this._recentlyUsedTabs;
michael@0 187 },
michael@0 188
michael@0 189 init: function ctrlTab_init() {
michael@0 190 if (!this._recentlyUsedTabs) {
michael@0 191 tabPreviews.init();
michael@0 192
michael@0 193 this._initRecentlyUsedTabs();
michael@0 194 this._init(true);
michael@0 195 }
michael@0 196 },
michael@0 197
michael@0 198 uninit: function ctrlTab_uninit() {
michael@0 199 this._recentlyUsedTabs = null;
michael@0 200 this._init(false);
michael@0 201 },
michael@0 202
michael@0 203 prefName: "browser.ctrlTab.previews",
michael@0 204 readPref: function ctrlTab_readPref() {
michael@0 205 var enable =
michael@0 206 gPrefService.getBoolPref(this.prefName) &&
michael@0 207 (!gPrefService.prefHasUserValue("browser.ctrlTab.disallowForScreenReaders") ||
michael@0 208 !gPrefService.getBoolPref("browser.ctrlTab.disallowForScreenReaders"));
michael@0 209
michael@0 210 if (enable)
michael@0 211 this.init();
michael@0 212 else
michael@0 213 this.uninit();
michael@0 214 },
michael@0 215 observe: function (aSubject, aTopic, aPrefName) {
michael@0 216 this.readPref();
michael@0 217 },
michael@0 218
michael@0 219 updatePreviews: function ctrlTab_updatePreviews() {
michael@0 220 for (let i = 0; i < this.previews.length; i++)
michael@0 221 this.updatePreview(this.previews[i], this.tabList[i]);
michael@0 222
michael@0 223 var showAllLabel = gNavigatorBundle.getString("ctrlTab.showAll.label");
michael@0 224 this.showAllButton.label =
michael@0 225 PluralForm.get(this.tabCount, showAllLabel).replace("#1", this.tabCount);
michael@0 226 this.showAllButton.hidden = !allTabs.canOpen;
michael@0 227 },
michael@0 228
michael@0 229 updatePreview: function ctrlTab_updatePreview(aPreview, aTab) {
michael@0 230 if (aPreview == this.showAllButton)
michael@0 231 return;
michael@0 232
michael@0 233 aPreview._tab = aTab;
michael@0 234
michael@0 235 if (aPreview.firstChild)
michael@0 236 aPreview.removeChild(aPreview.firstChild);
michael@0 237 if (aTab) {
michael@0 238 let canvasWidth = this.canvasWidth;
michael@0 239 let canvasHeight = this.canvasHeight;
michael@0 240 aPreview.appendChild(tabPreviews.get(aTab));
michael@0 241 aPreview.setAttribute("label", aTab.label);
michael@0 242 aPreview.setAttribute("tooltiptext", aTab.label);
michael@0 243 aPreview.setAttribute("crop", aTab.crop);
michael@0 244 aPreview.setAttribute("canvaswidth", canvasWidth);
michael@0 245 aPreview.setAttribute("canvasstyle",
michael@0 246 "max-width:" + canvasWidth + "px;" +
michael@0 247 "min-width:" + canvasWidth + "px;" +
michael@0 248 "max-height:" + canvasHeight + "px;" +
michael@0 249 "min-height:" + canvasHeight + "px;");
michael@0 250 if (aTab.image)
michael@0 251 aPreview.setAttribute("image", aTab.image);
michael@0 252 else
michael@0 253 aPreview.removeAttribute("image");
michael@0 254 aPreview.hidden = false;
michael@0 255 } else {
michael@0 256 aPreview.hidden = true;
michael@0 257 aPreview.removeAttribute("label");
michael@0 258 aPreview.removeAttribute("tooltiptext");
michael@0 259 aPreview.removeAttribute("image");
michael@0 260 }
michael@0 261 },
michael@0 262
michael@0 263 advanceFocus: function ctrlTab_advanceFocus(aForward) {
michael@0 264 let selectedIndex = Array.indexOf(this.previews, this.selected);
michael@0 265 do {
michael@0 266 selectedIndex += aForward ? 1 : -1;
michael@0 267 if (selectedIndex < 0)
michael@0 268 selectedIndex = this.previews.length - 1;
michael@0 269 else if (selectedIndex >= this.previews.length)
michael@0 270 selectedIndex = 0;
michael@0 271 } while (this.previews[selectedIndex].hidden);
michael@0 272
michael@0 273 if (this._selectedIndex == -1) {
michael@0 274 // Focus is already in the panel.
michael@0 275 this.previews[selectedIndex].focus();
michael@0 276 } else {
michael@0 277 this._selectedIndex = selectedIndex;
michael@0 278 }
michael@0 279
michael@0 280 if (this._timer) {
michael@0 281 clearTimeout(this._timer);
michael@0 282 this._timer = null;
michael@0 283 this._openPanel();
michael@0 284 }
michael@0 285 },
michael@0 286
michael@0 287 _mouseOverFocus: function ctrlTab_mouseOverFocus(aPreview) {
michael@0 288 if (this._trackMouseOver)
michael@0 289 aPreview.focus();
michael@0 290 },
michael@0 291
michael@0 292 pick: function ctrlTab_pick(aPreview) {
michael@0 293 if (!this.tabCount)
michael@0 294 return;
michael@0 295
michael@0 296 var select = (aPreview || this.selected);
michael@0 297
michael@0 298 if (select == this.showAllButton)
michael@0 299 this.showAllTabs();
michael@0 300 else
michael@0 301 this.close(select._tab);
michael@0 302 },
michael@0 303
michael@0 304 showAllTabs: function ctrlTab_showAllTabs(aPreview) {
michael@0 305 this.close();
michael@0 306 document.getElementById("Browser:ShowAllTabs").doCommand();
michael@0 307 },
michael@0 308
michael@0 309 remove: function ctrlTab_remove(aPreview) {
michael@0 310 if (aPreview._tab)
michael@0 311 gBrowser.removeTab(aPreview._tab);
michael@0 312 },
michael@0 313
michael@0 314 attachTab: function ctrlTab_attachTab(aTab, aPos) {
michael@0 315 if (aTab.closing)
michael@0 316 return;
michael@0 317
michael@0 318 if (aPos == 0)
michael@0 319 this._recentlyUsedTabs.unshift(aTab);
michael@0 320 else if (aPos)
michael@0 321 this._recentlyUsedTabs.splice(aPos, 0, aTab);
michael@0 322 else
michael@0 323 this._recentlyUsedTabs.push(aTab);
michael@0 324 },
michael@0 325
michael@0 326 detachTab: function ctrlTab_detachTab(aTab) {
michael@0 327 var i = this._recentlyUsedTabs.indexOf(aTab);
michael@0 328 if (i >= 0)
michael@0 329 this._recentlyUsedTabs.splice(i, 1);
michael@0 330 },
michael@0 331
michael@0 332 open: function ctrlTab_open() {
michael@0 333 if (this.isOpen)
michael@0 334 return;
michael@0 335
michael@0 336 document.addEventListener("keyup", this, true);
michael@0 337
michael@0 338 this.updatePreviews();
michael@0 339 this._selectedIndex = 1;
michael@0 340
michael@0 341 // Add a slight delay before showing the UI, so that a quick
michael@0 342 // "ctrl-tab" keypress just flips back to the MRU tab.
michael@0 343 this._timer = setTimeout(function (self) {
michael@0 344 self._timer = null;
michael@0 345 self._openPanel();
michael@0 346 }, 200, this);
michael@0 347 },
michael@0 348
michael@0 349 _openPanel: function ctrlTab_openPanel() {
michael@0 350 tabPreviewPanelHelper.opening(this);
michael@0 351
michael@0 352 this.panel.width = Math.min(screen.availWidth * .99,
michael@0 353 this.canvasWidth * 1.25 * this.tabPreviewCount);
michael@0 354 var estimateHeight = this.canvasHeight * 1.25 + 75;
michael@0 355 this.panel.openPopupAtScreen(screen.availLeft + (screen.availWidth - this.panel.width) / 2,
michael@0 356 screen.availTop + (screen.availHeight - estimateHeight) / 2,
michael@0 357 false);
michael@0 358 },
michael@0 359
michael@0 360 close: function ctrlTab_close(aTabToSelect) {
michael@0 361 if (!this.isOpen)
michael@0 362 return;
michael@0 363
michael@0 364 if (this._timer) {
michael@0 365 clearTimeout(this._timer);
michael@0 366 this._timer = null;
michael@0 367 this.suspendGUI();
michael@0 368 if (aTabToSelect)
michael@0 369 gBrowser.selectedTab = aTabToSelect;
michael@0 370 return;
michael@0 371 }
michael@0 372
michael@0 373 this.tabToSelect = aTabToSelect;
michael@0 374 this.panel.hidePopup();
michael@0 375 },
michael@0 376
michael@0 377 setupGUI: function ctrlTab_setupGUI() {
michael@0 378 this.selected.focus();
michael@0 379 this._selectedIndex = -1;
michael@0 380
michael@0 381 // Track mouse movement after a brief delay so that the item that happens
michael@0 382 // to be under the mouse pointer initially won't be selected unintentionally.
michael@0 383 this._trackMouseOver = false;
michael@0 384 setTimeout(function (self) {
michael@0 385 if (self.isOpen)
michael@0 386 self._trackMouseOver = true;
michael@0 387 }, 0, this);
michael@0 388 },
michael@0 389
michael@0 390 suspendGUI: function ctrlTab_suspendGUI() {
michael@0 391 document.removeEventListener("keyup", this, true);
michael@0 392
michael@0 393 Array.forEach(this.previews, function (preview) {
michael@0 394 this.updatePreview(preview, null);
michael@0 395 }, this);
michael@0 396 },
michael@0 397
michael@0 398 onKeyPress: function ctrlTab_onKeyPress(event) {
michael@0 399 var isOpen = this.isOpen;
michael@0 400
michael@0 401 if (isOpen) {
michael@0 402 event.preventDefault();
michael@0 403 event.stopPropagation();
michael@0 404 }
michael@0 405
michael@0 406 switch (event.keyCode) {
michael@0 407 case event.DOM_VK_TAB:
michael@0 408 if (event.ctrlKey && !event.altKey && !event.metaKey) {
michael@0 409 if (isOpen) {
michael@0 410 this.advanceFocus(!event.shiftKey);
michael@0 411 } else if (!event.shiftKey) {
michael@0 412 event.preventDefault();
michael@0 413 event.stopPropagation();
michael@0 414 let tabs = gBrowser.visibleTabs;
michael@0 415 if (tabs.length > 2) {
michael@0 416 this.open();
michael@0 417 } else if (tabs.length == 2) {
michael@0 418 let index = tabs[0].selected ? 1 : 0;
michael@0 419 gBrowser.selectedTab = tabs[index];
michael@0 420 }
michael@0 421 }
michael@0 422 }
michael@0 423 break;
michael@0 424 default:
michael@0 425 if (isOpen && event.ctrlKey) {
michael@0 426 if (event.keyCode == event.DOM_VK_DELETE) {
michael@0 427 this.remove(this.selected);
michael@0 428 break;
michael@0 429 }
michael@0 430 switch (event.charCode) {
michael@0 431 case this.keys.close:
michael@0 432 this.remove(this.selected);
michael@0 433 break;
michael@0 434 case this.keys.find:
michael@0 435 case this.keys.selectAll:
michael@0 436 this.showAllTabs();
michael@0 437 break;
michael@0 438 }
michael@0 439 }
michael@0 440 }
michael@0 441 },
michael@0 442
michael@0 443 removeClosingTabFromUI: function ctrlTab_removeClosingTabFromUI(aTab) {
michael@0 444 if (this.tabCount == 2) {
michael@0 445 this.close();
michael@0 446 return;
michael@0 447 }
michael@0 448
michael@0 449 this.updatePreviews();
michael@0 450
michael@0 451 if (this.selected.hidden)
michael@0 452 this.advanceFocus(false);
michael@0 453 if (this.selected == this.showAllButton)
michael@0 454 this.advanceFocus(false);
michael@0 455
michael@0 456 // If the current tab is removed, another tab can steal our focus.
michael@0 457 if (aTab.selected && this.panel.state == "open") {
michael@0 458 setTimeout(function (selected) {
michael@0 459 selected.focus();
michael@0 460 }, 0, this.selected);
michael@0 461 }
michael@0 462 },
michael@0 463
michael@0 464 handleEvent: function ctrlTab_handleEvent(event) {
michael@0 465 switch (event.type) {
michael@0 466 case "SSWindowStateReady":
michael@0 467 this._initRecentlyUsedTabs();
michael@0 468 break;
michael@0 469 case "TabAttrModified":
michael@0 470 // tab attribute modified (e.g. label, crop, busy, image, selected)
michael@0 471 for (let i = this.previews.length - 1; i >= 0; i--) {
michael@0 472 if (this.previews[i]._tab && this.previews[i]._tab == event.target) {
michael@0 473 this.updatePreview(this.previews[i], event.target);
michael@0 474 break;
michael@0 475 }
michael@0 476 }
michael@0 477 break;
michael@0 478 case "TabSelect":
michael@0 479 this.detachTab(event.target);
michael@0 480 this.attachTab(event.target, 0);
michael@0 481 break;
michael@0 482 case "TabOpen":
michael@0 483 this.attachTab(event.target, 1);
michael@0 484 break;
michael@0 485 case "TabClose":
michael@0 486 this.detachTab(event.target);
michael@0 487 if (this.isOpen)
michael@0 488 this.removeClosingTabFromUI(event.target);
michael@0 489 break;
michael@0 490 case "keypress":
michael@0 491 this.onKeyPress(event);
michael@0 492 break;
michael@0 493 case "keyup":
michael@0 494 if (event.keyCode == event.DOM_VK_CONTROL)
michael@0 495 this.pick();
michael@0 496 break;
michael@0 497 case "popupshowing":
michael@0 498 if (event.target.id == "menu_viewPopup")
michael@0 499 document.getElementById("menu_showAllTabs").hidden = !allTabs.canOpen;
michael@0 500 break;
michael@0 501 }
michael@0 502 },
michael@0 503
michael@0 504 _initRecentlyUsedTabs: function () {
michael@0 505 this._recentlyUsedTabs =
michael@0 506 Array.filter(gBrowser.tabs, tab => !tab.closing)
michael@0 507 .sort((tab1, tab2) => tab2.lastAccessed - tab1.lastAccessed);
michael@0 508 },
michael@0 509
michael@0 510 _init: function ctrlTab__init(enable) {
michael@0 511 var toggleEventListener = enable ? "addEventListener" : "removeEventListener";
michael@0 512
michael@0 513 window[toggleEventListener]("SSWindowStateReady", this, false);
michael@0 514
michael@0 515 var tabContainer = gBrowser.tabContainer;
michael@0 516 tabContainer[toggleEventListener]("TabOpen", this, false);
michael@0 517 tabContainer[toggleEventListener]("TabAttrModified", this, false);
michael@0 518 tabContainer[toggleEventListener]("TabSelect", this, false);
michael@0 519 tabContainer[toggleEventListener]("TabClose", this, false);
michael@0 520
michael@0 521 document[toggleEventListener]("keypress", this, false);
michael@0 522 gBrowser.mTabBox.handleCtrlTab = !enable;
michael@0 523
michael@0 524 // If we're not running, hide the "Show All Tabs" menu item,
michael@0 525 // as Shift+Ctrl+Tab will be handled by the tab bar.
michael@0 526 document.getElementById("menu_showAllTabs").hidden = !enable;
michael@0 527 document.getElementById("menu_viewPopup")[toggleEventListener]("popupshowing", this);
michael@0 528
michael@0 529 // Also disable the <key> to ensure Shift+Ctrl+Tab never triggers
michael@0 530 // Show All Tabs.
michael@0 531 var key_showAllTabs = document.getElementById("key_showAllTabs");
michael@0 532 if (enable)
michael@0 533 key_showAllTabs.removeAttribute("disabled");
michael@0 534 else
michael@0 535 key_showAllTabs.setAttribute("disabled", "true");
michael@0 536 }
michael@0 537 };
michael@0 538
michael@0 539
michael@0 540 /**
michael@0 541 * All Tabs menu
michael@0 542 */
michael@0 543 var allTabs = {
michael@0 544 get toolbarButton() document.getElementById("alltabs-button"),
michael@0 545 get canOpen() isElementVisible(this.toolbarButton),
michael@0 546
michael@0 547 open: function allTabs_open() {
michael@0 548 if (this.canOpen) {
michael@0 549 // Without setTimeout, the menupopup won't stay open when invoking
michael@0 550 // "View > Show All Tabs" and the menu bar auto-hides.
michael@0 551 setTimeout(function () {
michael@0 552 allTabs.toolbarButton.open = true;
michael@0 553 }, 0);
michael@0 554 }
michael@0 555 }
michael@0 556 };

mercurial