]> git.donarmstrong.com Git - dactyl.git/blobdiff - common/content/tabs.js
Imported Upstream version 1.1+hg7904
[dactyl.git] / common / content / tabs.js
index a7f038e3603b6c4004ed26b3d22aeabb2fa37f05..9bf588b92f54391400a58bd65092ba78e581a3b5 100644 (file)
@@ -1,6 +1,6 @@
 // Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
 // Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
-// Copyright (c) 2008-2013 Kris Maglione <maglione.k at Gmail>
+// Copyright (c) 2008-2014 Kris Maglione <maglione.k at Gmail>
 //
 // This work is licensed for reuse under an MIT license. Details are
 // given in the LICENSE.txt file included with this file.
@@ -27,7 +27,8 @@ var Tabs = Module("tabs", {
             config.tabStrip.collapsed = true;
 
         this.tabStyle = styles.system.add("tab-strip-hiding", config.styleableChrome,
-                                          (config.tabStrip.id ? "#" + config.tabStrip.id : ".tabbrowser-strip") +
+                                          (config.tabStrip.id ? "#" + config.tabStrip.id
+                                                              : ".tabbrowser-strip") +
                                               "{ visibility: collapse; }",
                                           false, true);
 
@@ -73,28 +74,26 @@ var Tabs = Module("tabs", {
 
     updateTabCount: function updateTabCount() {
         for (let [i, tab] in Iterator(this.visibleTabs)) {
-            if (dactyl.has("Gecko2")) {
-                let node = function node(class_) document.getAnonymousElementByAttribute(tab, "class", class_);
-                if (!node("dactyl-tab-number")) {
-                    let img = node("tab-icon-image");
-                    if (img) {
-                        let dom = DOM([
-                            ["xul:hbox", { highlight: "tab-number" },
-                                ["xul:label", { key: "icon", align: "center", highlight: "TabIconNumber",
-                                                class: "dactyl-tab-icon-number" }]],
-                            ["xul:hbox", { highlight: "tab-number" },
-                                ["html:div", { key: "label", highlight: "TabNumber",
-                                               class: "dactyl-tab-number" }]]],
-                            document).appendTo(img.parentNode);
-
-                        update(tab, {
-                            get dactylOrdinal() Number(dom.nodes.icon.value),
-                            set dactylOrdinal(i) {
-                                dom.nodes.icon.value = dom.nodes.label.textContent = i;
-                                this.setAttribute("dactylOrdinal", i);
-                            }
-                        });
-                    }
+            let node = function node(class_) document.getAnonymousElementByAttribute(tab, "class", class_);
+            if (!node("dactyl-tab-number")) {
+                let img = node("tab-icon-image");
+                if (img) {
+                    let dom = DOM([
+                        ["xul:hbox", { highlight: "tab-number" },
+                            ["xul:label", { key: "icon", align: "center", highlight: "TabIconNumber",
+                                            class: "dactyl-tab-icon-number" }]],
+                        ["xul:hbox", { highlight: "tab-number" },
+                            ["html:div", { key: "label", highlight: "TabNumber",
+                                           class: "dactyl-tab-number" }]]],
+                        document).appendTo(img.parentNode);
+
+                    update(tab, {
+                        get dactylOrdinal() Number(dom.nodes.icon.value),
+                        set dactylOrdinal(i) {
+                            dom.nodes.icon.value = dom.nodes.label.textContent = i;
+                            this.setAttribute("dactylOrdinal", i);
+                        }
+                    });
                 }
             }
             tab.dactylOrdinal = i + 1;
@@ -408,7 +407,7 @@ var Tabs = Module("tabs", {
      * @param {number} count How many tabs to remove.
      * @param {boolean} focusLeftTab Focus the tab to the left of the removed tab.
      */
-    remove: function remove(tab, count = 1, focusLeftTab = false) {
+    remove: function remove(tab, count=1, focusLeftTab=false) {
         let res = this.count > count;
 
         let tabs = this.visibleTabs;
@@ -427,11 +426,11 @@ var Tabs = Module("tabs", {
         if (focusLeftTab)
             tabs.slice(Math.max(0, index + 1 - count),
                        index + 1)
-                .forEach(config.closure.removeTab);
+                .forEach(config.bound.removeTab);
         else
             tabs.slice(index,
                        index + count)
-                .forEach(config.closure.removeTab);
+                .forEach(config.bound.removeTab);
         return res;
     },
 
@@ -551,7 +550,7 @@ var Tabs = Module("tabs", {
         if (matches)
             return tabs.select(this.allTabs[parseInt(matches[1], 10) - 1], false);
 
-        matches = array.nth(tabs.allTabs, t => (t.linkedBrowser.lastURI || {}).spec === buffer, 0);
+        matches = tabs.allTabs.find(t => (t.linkedBrowser.lastURI || {}).spec === buffer);
         if (matches)
             return tabs.select(matches, false);
 
@@ -1038,7 +1037,7 @@ var Tabs = Module("tabs", {
             tabs.getGroups();
             tabs[visible ? "visibleTabs" : "allTabs"].forEach(function (tab, i) {
                 let group = (tab.tabItem || tab._tabViewTabItem || defItem).parent || defItem.parent;
-                if (!Set.has(tabGroups, group.id))
+                if (!hasOwnProperty(tabGroups, group.id))
                     tabGroups[group.id] = [group.getTitle(), []];
 
                 group = tabGroups[group.id];
@@ -1114,7 +1113,7 @@ var Tabs = Module("tabs", {
         }
         for (let event in values(["TabMove", "TabOpen", "TabClose"]))
             events.listen(tabContainer, event, callback, false);
-        events.listen(tabContainer, "TabSelect", tabs.closure._onTabSelect, false);
+        events.listen(tabContainer, "TabSelect", tabs.bound._onTabSelect, false);
     },
     mappings: function initMappings() {
 
@@ -1224,7 +1223,7 @@ var Tabs = Module("tabs", {
                         tabs.tabStyle.enabled = false;
                     }
 
-                    if (value !== "multitab" || !dactyl.has("Gecko2"))
+                    if (value !== "multitab")
                         if (tabs.xulTabs)
                             tabs.xulTabs.visible = value !== "never";
                         else
@@ -1263,11 +1262,11 @@ var Tabs = Module("tabs", {
                     values: activateGroups,
                     has: Option.has.toggleAll,
                     setter: function (newValues) {
-                        let valueSet = Set(newValues);
+                        let valueSet = RealSet(newValues);
                         for (let group in values(activateGroups))
                             if (group[2])
                                 prefs.safeSet("browser.tabs." + group[2],
-                                              !(valueSet["all"] ^ valueSet[group[0]]),
+                                              !(valueSet.has("all") ^ valueSet.has(group[0])),
                                               _("option.safeSet", "activate"));
                         return newValues;
                     }