From 3192810aacd8a59df533ca9cc3944c7d2e6169da Mon Sep 17 00:00:00 2001 From: piro Date: Thu, 20 Aug 2009 08:03:45 +0000 Subject: [PATCH] =?UTF-8?q?=E7=B8=A6=E5=9E=8B=E3=82=B9=E3=83=A9=E3=82=A4?= =?UTF-8?q?=E3=83=80=E3=83=BC=E3=81=AB=E3=81=97=E3=81=A6=E3=81=BF=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@4962 599a83e7-65a4-db11-8015-0010dcdd6dc2 --- content/treestyletab/config.js | 58 +++++++++++++++----------- content/treestyletab/config.xul | 72 +++++++++++++++++++++------------ 2 files changed, 82 insertions(+), 48 deletions(-) diff --git a/content/treestyletab/config.js b/content/treestyletab/config.js index 211733b1..d11ba714 100644 --- a/content/treestyletab/config.js +++ b/content/treestyletab/config.js @@ -37,9 +37,9 @@ function init() var gDropLinksOnRadioSet, gGroupBookmarkRadioSet, - gOpenLinkInTabRadio, - gLoadLocationBarToNewTabRadio, - gLoadLocationBarToChildTabRadio, + gOpenLinkInTabScale, + gLoadLocationBarToNewTabScale, + gLoadLocationBarToChildTabScale, gLastStateIsVertical; var gTabbarPlacePositionInitialized = false; @@ -58,22 +58,22 @@ function initTabPane() 'openGroupBookmark-deck' ); - gOpenLinkInTabRadio = new RadioScaleSet( + gOpenLinkInTabScale = new ScaleSet( ['extensions.treestyletab.openOuterLinkInNewTab', 'extensions.treestyletab.openAnyLinkInNewTab'], - 'openLinkInNewTab-radio', + 'openLinkInNewTab-scale', 'openLinkInNewTab-labels' ); - gLoadLocationBarToNewTabRadio = new RadioScaleSet( + gLoadLocationBarToNewTabScale = new ScaleSet( ['extensions.treestyletab.urlbar.loadDifferentDomainToNewTab', 'extensions.treestyletab.urlbar.loadSameDomainToNewTab'], - 'loadLocationBarToNewTab-radio', + 'loadLocationBarToNewTab-scale', 'loadLocationBarToNewTab-labels' ); - gLoadLocationBarToChildTabRadio = new RadioScaleSet( + gLoadLocationBarToChildTabScale = new ScaleSet( ['extensions.treestyletab.urlbar.loadSameDomainToNewTab.asChild', 'extensions.treestyletab.urlbar.loadDifferentDomainToNewTab.asChild'], - 'loadLocationBarToChildTab-radio', + 'loadLocationBarToChildTab-scale', 'loadLocationBarToChildTab-labels' ); @@ -246,58 +246,70 @@ function updateCloseRootBehaviorCheck() -function RadioScaleSet(aPrefs, aRadio, aLabelsDeck) +function ScaleSet(aPrefs, aScale, aLabelsContainer) { this.prefs = aPrefs.map(document.getElementById, document); - this.radio = document.getElementById(aRadio); + this.scale = document.getElementById(aScale); + this.labels = Array.slice(document.getElementById(aLabelsContainer).getElementsByTagName('label')); - this.radio.value = this.prefs[1].value ? 2 : + this.scale.value = this.prefs[1].value ? 2 : this.prefs[0].value ? 1 : 0 ; + this.updateLabels(); } -RadioScaleSet.prototype = { +ScaleSet.prototype = { onChange : function() { var value = this.value; this.prefs[0].value = value > 0; this.prefs[1].value = value > 1; + this.updateLabels(); }, set value(aValue) { - this.radio.value = aValue; + this.scale.value = aValue; this.onChange(); return aValue; }, get value() { - return parseInt(this.radio.value); + return parseInt(this.scale.value); }, set disabled(aDisabled) { if (aDisabled) { - this.radio.setAttribute('disabled', true); - Array.slice(this.radio.childNodes).forEach(function(aNode) { + this.scale.setAttribute('disabled', true); + this.labels.forEach(function(aNode) { aNode.setAttribute('disabled', true); }); } else { - this.radio.removeAttribute('disabled'); - Array.slice(this.radio.childNodes).forEach(function(aNode) { - aNode.removeAttribute('disabled'); - }); + this.scale.removeAttribute('disabled'); + this.updateLabels(); } }, get disabled() { - return this.radio.getAttribute('disabled') == 'true'; + return this.scale.getAttribute('disabled') == 'true'; + }, + + updateLabels : function() + { + this.labels.forEach(function(aLabel, aIndex) { + if (aIndex == this.value) + aLabel.removeAttribute('disabled'); + else + aLabel.setAttribute('disabled', true); + }, this); }, destroy : function() { this.prefs = null; - this.radio = null; + this.scale = null; + this.labels = null; } }; diff --git a/content/treestyletab/config.xul b/content/treestyletab/config.xul index 9ee044f9..32bcd145 100644 --- a/content/treestyletab/config.xul +++ b/content/treestyletab/config.xul @@ -352,35 +352,57 @@ - - - - - + + + + + - - - - - - - - + - - - - + min="0" + max="2" + style="height:4em;" + onchange=" + gLoadLocationBarToNewTabScale.onChange(); + gLoadLocationBarToChildTabScale.disabled = gLoadLocationBarToNewTabScale.value == 0; + "/> + + + + + + + +