Skip to content

Commit

Permalink
Merge branch 'cleanup' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
ithinc committed Feb 25, 2014
2 parents 7401cde + c0be13b commit bbc25e9
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 18 deletions.
13 changes: 5 additions & 8 deletions chrome/content/preferences.xul
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@
<preference id="highlightCurrent" name="extensions.tabutils.highlightCurrent" type="bool" onchange="onHighlightEnabled('Current');" suggest="true"/>
<preference id="highlightUnread" name="extensions.tabutils.highlightUnread" type="bool" onchange="onHighlightEnabled('Unread');" suggest="true"/>
<preference id="highlightRead" name="extensions.tabutils.highlightRead" type="bool" onchange="onHighlightEnabled('Read');"/>
<preference id="highlightUnloaded" name="extensions.tabutils.highlightUnloaded" type="bool" onchange="onHighlightEnabled('Unloaded');"/>
<preference id="highlightUnloaded" name="extensions.tabutils.highlightUnloaded" type="bool" onchange="onHighlightEnabled('Unloaded');" suggest="true"/>
<preference id="highlightSelected" name="extensions.tabutils.highlightSelected" type="bool" onchange="onHighlightEnabled('Selected');"/>
<preference id="styleCurrent" name="extensions.tabutils.styles.current" type="string" onchange="onHighlightStyle('Current');"/>
<preference id="styleUnread" name="extensions.tabutils.styles.unread" type="string" onchange="onHighlightStyle('Unread');"/>
Expand Down Expand Up @@ -1437,20 +1437,17 @@
}
function onPaneLoad(aPane) { //Bug 687356
Array.forEach(aPane.getElementsByTagName('tabbox'), function(tabbox, index) {
tabbox.selectedIndex = aPane.getAttribute('lastSelected').split(",")[index];
});
aPane._inited = true;
let tabbox = aPane.getElementsByTagName('tabbox')[0];
if (tabbox)
tabbox.selectedIndex = aPane.getAttribute('lastSelected');
}
function onPaneSelect(aPane) {
if(!aPane._inited)
return;
let tabbox = aPane.getElementsByTagName('tabbox')[0];
if (tabbox)
aPane.setAttribute('lastSelected', tabbox.selectedIndex);
aPane.setAttribute('lastSelected', [tabbox.selectedIndex for (tabbox of aPane.getElementsByTagName('tabbox'))].join());
}
]]>
</script>
Expand Down
27 changes: 21 additions & 6 deletions chrome/content/tabutils-st.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,21 @@ tabutils._stackTabs = function() {
return;
});

gBrowser.isSiblingTab = function isSiblingTab(aTab, bTab) {
return aTab.hasAttribute("group") &&
aTab.getAttribute("group") == bTab.getAttribute("group") &&
!aTab.hidden && !bTab.hidden;
};

gBrowser.siblingTabsOf = function siblingTabsOf(aTab) {
if (typeof aTab == "string") {
let group = aTab;
return Array.filter(this.visibleTabs, function(aTab) aTab.getAttribute("group") == group);
}

if (aTab.hidden || aTab.closing)
return [];

let group = aTab.getAttribute("group");
let tabs = [aTab];
for (let tab = aTab; (tab = tab.nextSibling) && tab.getAttribute("group") == group && !tab.hidden;) {
Expand Down Expand Up @@ -95,6 +104,12 @@ tabutils._stackTabs = function() {
if (bTab.getAttribute("group-counter") == 1) {
bTab.setAttribute("group-collapsed", !options.expand && TU_getPref("extensions.tabutils.autoCollapseNewStack", true));
this.mTabContainer.mTabstrip.ensureElementIsVisible(bTab);

if (bTab.image)
Services.mozIColorAnalyzer.findRepresentativeColor(makeURI(bTab.image), function(success, color) {
if (success)
this.updateStack(bTab, {color: "#" + ("000000" + color.toString(16)).slice(-6)});
}.bind(this));
}

//must happen after "group" is set to avoid bypassing stack, and
Expand Down Expand Up @@ -381,8 +396,8 @@ tabutils._stackTabs = function() {
this.selectedTabs = selectedTabs;
}.bind(this), 0);
}
else if (aTab.getAttribute("group") == previousTab.getAttribute("group") || nextTab &&
aTab.getAttribute("group") == nextTab.getAttribute("group")) { // within stack
else if (this.isSiblingTab(previousTab, aTab) || nextTab &&
this.isSiblingTab(nextTab, aTab)) { // within stack
this.updateStack(aTab);
}
else { // off stack
Expand All @@ -391,9 +406,9 @@ tabutils._stackTabs = function() {
}

// Move into a stack
if (nextTab && nextTab.hasAttribute("group") &&
nextTab.getAttribute("group") != aTab.getAttribute("group") &&
nextTab.getAttribute("group") == previousTab.getAttribute("group")) {
if (nextTab &&
this.isSiblingTab(nextTab, previousTab) &&
!this.isSiblingTab(nextTab, aTab)) {
if (nextTab.hasAttribute("group-collapsed")) { // Move into a collapsed stack
setTimeout(function() { // bypass stack
if (ltr)
Expand All @@ -414,7 +429,7 @@ tabutils._stackTabs = function() {
if (this.isStackedTab(aTab)) {
if (aTab.selected) {
try {
this.selectedTab = this._tabsToSelect(this.siblingTabsOf(aTab)).next();
this.selectedTab = this._tabsToSelect(this.siblingTabsOf(aTab.getAttribute("group"))).next();
}
catch (e) {}
}
Expand Down
6 changes: 3 additions & 3 deletions chrome/content/tabutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ window.addEventListener("DOMContentLoaded", tabutils, false);
[
["@mozilla.org/browser/sessionstore;1", "nsISessionStore", "_ss", tabutils], // Bug 898732 [Fx26]
["@mozilla.org/docshell/urifixup;1", "nsIURIFixup"], // Bug 802026 [Fx20]
["@mozilla.org/places/colorAnalyzer;1", "mozIColorAnalyzer"],
["@mozilla.org/widget/clipboardhelper;1", "nsIClipboardHelper"],
["@mozilla.org/uuid-generator;1", "nsIUUIDGenerator"]
].forEach(function([aContract, aInterface, aName, aObject])
Expand Down Expand Up @@ -668,9 +669,8 @@ tabutils._tabOpeningOptions = function() {
this.detachTab(tab, true);
if (["_onDrop", "onxbldrop", "duplicateTabIn"].indexOf(arguments.callee.caller.name) == -1) {
if (TU_getPref("extensions.tabutils.openDuplicateNext", true)) {
if (this.isStackedTab(aTab) ||
TU_getPref("extensions.tabutils.autoStack", false))
this.attachTabTo(tab, aTab, {move: true, expand: true});
if (this.isStackedTab(aTab))
aTab = this.lastSiblingTabOf(aTab);
this.moveTabTo(tab, tab._tPos > aTab._tPos ? aTab._tPos + 1 : aTab._tPos);
}
if (!tabutils.gLoadAllInBackground && !TU_getPref("extensions.tabutils.loadDuplicateInBackground", false))
Expand Down
2 changes: 1 addition & 1 deletion defaults/preferences/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pref("extensions.tabutils.showAllTabs", false);
pref("extensions.tabutils.highlightCurrent", false);
pref("extensions.tabutils.highlightUnread", false);
pref("extensions.tabutils.highlightRead", false);
pref("extensions.tabutils.highlightUnloaded", true);
pref("extensions.tabutils.highlightUnloaded", false);
pref("extensions.tabutils.highlightSelected", true);
pref("extensions.tabutils.styles.current", '{"bold":true,"color":true,"colorCode":"blue"}');
pref("extensions.tabutils.styles.unread", '{"italic":true,"color":true,"colorCode":"red"}');
Expand Down

0 comments on commit bbc25e9

Please sign in to comment.