From f4e2b0b2ed62e29991cb010c356c025c1f64208c Mon Sep 17 00:00:00 2001 From: piro Date: Fri, 24 Jul 2009 11:00:53 +0000 Subject: [PATCH] =?UTF-8?q?=E3=83=AD=E3=82=B1=E3=83=BC=E3=82=B7=E3=83=A7?= =?UTF-8?q?=E3=83=B3=E3=83=90=E3=83=BC=E3=81=8B=E3=82=89=E3=82=BF=E3=83=96?= =?UTF-8?q?=E3=82=92=E9=96=8B=E3=81=8F=E8=A8=AD=E5=AE=9A=E3=82=92scale?= =?UTF-8?q?=E3=81=AB?= 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@4807 599a83e7-65a4-db11-8015-0010dcdd6dc2 --- content/treestyletab/config.js | 101 +++++++++++++++++---- content/treestyletab/config.xul | 50 ++++++---- content/treestyletab/treestyletab.js | 19 +++- defaults/preferences/treestyletab.js | 3 +- locale/de-DE/treestyletab/treestyletab.dtd | 11 ++- locale/en-US/treestyletab/treestyletab.dtd | 11 ++- locale/es-ES/treestyletab/treestyletab.dtd | 11 ++- locale/it-IT/treestyletab/treestyletab.dtd | 11 ++- locale/ja/treestyletab/treestyletab.dtd | 11 ++- locale/pl-PL/treestyletab/treestyletab.dtd | 11 ++- locale/ru-RU/treestyletab/treestyletab.dtd | 11 ++- locale/zh-CN/treestyletab/treestyletab.dtd | 11 ++- locale/zh-TW/treestyletab/treestyletab.dtd | 11 ++- 13 files changed, 197 insertions(+), 75 deletions(-) diff --git a/content/treestyletab/config.js b/content/treestyletab/config.js index ec0da058..2b2ea57b 100644 --- a/content/treestyletab/config.js +++ b/content/treestyletab/config.js @@ -9,10 +9,9 @@ function init() } -var gOpenLinkInNewTabScale, - gOpenLinkInNewTabLabels, - gOuterLinkPref, - gAnyLinkPref, +var gOpenLinkInTabScale, + gLoadLocationBarToNewTabScale, + gLoadLocationBarToChildTabScale, gGroupBookmarkRadio, gGroupBookmarkTree, gGroupBookmarkReplace, @@ -21,14 +20,24 @@ var gTabbarPlacePositionInitialized = false; function initTabPane() { - gOuterLinkPref = document.getElementById('extensions.treestyletab.openOuterLinkInNewTab'); - gAnyLinkPref = document.getElementById('extensions.treestyletab.openAnyLinkInNewTab'); - gOpenLinkInNewTabScale = document.getElementById('openLinkInNewTab-scale'); - gOpenLinkInNewTabLabels = document.getElementById('openLinkInNewTab-labels'); - gOpenLinkInNewTabScale.value = gAnyLinkPref.value ? 2 : - gOuterLinkPref.value ? 1 : - 0 ; - gOpenLinkInNewTabLabels.selectedIndex = gOpenLinkInNewTabScale.value; + gOpenLinkInTabScale = new ScaleSet( + ['extensions.treestyletab.openOuterLinkInNewTab', + 'extensions.treestyletab.openAnyLinkInNewTab'], + 'openLinkInNewTab-scale', + 'openLinkInNewTab-labels' + ); + gLoadLocationBarToNewTabScale = new ScaleSet( + ['extensions.treestyletab.urlbar.loadDifferentDomainToNewTab', + 'extensions.treestyletab.urlbar.loadSameDomainToNewTab'], + 'loadLocationBarToNewTab-scale', + 'loadLocationBarToNewTab-labels' + ); + gLoadLocationBarToChildTabScale = new ScaleSet( + ['extensions.treestyletab.urlbar.loadSameDomainToNewTab.asChild', + 'extensions.treestyletab.urlbar.loadDifferentDomainToNewTab.asChild'], + 'loadLocationBarToChildTab-scale', + 'loadLocationBarToChildTab-labels' + ); gGroupBookmarkRadio = document.getElementById('openGroupBookmarkAsTabSubTree-radiogroup'); gGroupBookmarkTree = document.getElementById('extensions.treestyletab.openGroupBookmarkAsTabSubTree'); @@ -64,13 +73,6 @@ function initTabPane() gLastStateIsVertical = gLastStateIsVertical == 'left' || gLastStateIsVertical == 'right'; } -function onOpenLinkInNewTabScaleChange() -{ - gOuterLinkPref.value = gOpenLinkInNewTabScale.value == 1; - gAnyLinkPref.value = gOpenLinkInNewTabScale.value == 2; - gOpenLinkInNewTabLabels.selectedIndex = gOpenLinkInNewTabScale.value; -} - function onChangeGroupBookmarkRadio() { gGroupBookmarkTree.value = gGroupBookmarkRadio.value == 'subtree'; @@ -203,3 +205,64 @@ function updateCloseRootBehaviorCheck() else closeRootBehavior.setAttribute('disabled', true); } + + + +function ScaleSet(aPrefs, aScale, aLabelsDeck) +{ + this.prefs = aPrefs.map(document.getElementById, document); + this.scale = document.getElementById(aScale); + this.labels = document.getElementById(aLabelsDeck); + + this.scale.value = this.prefs[1].value ? 2 : + this.prefs[0].value ? 1 : + 0 ; + this.labels.selectedIndex = this.scale.value; +} +ScaleSet.prototype = { + onChange : function() + { + var value = this.value; + this.prefs[0].value = value > 0; + this.prefs[1].value = value > 1; + this.labels.selectedIndex = value; + }, + + set value(aValue) + { + this.scale.value = aValue; + this.onChange(); + return aValue; + }, + get value() + { + return parseInt(this.scale.value); + }, + + set disabled(aDisabled) + { + if (aDisabled) { + this.scale.setAttribute('disabled', true); + Array.slice(this.labels.childNodes).forEach(function(aNode) { + aNode.setAttribute('disabled', true); + }); + } + else { + this.scale.removeAttribute('disabled'); + Array.slice(this.labels.childNodes).forEach(function(aNode) { + aNode.removeAttribute('disabled'); + }); + } + }, + get disabled() + { + return this.scale.getAttribute('disabled') == 'true'; + }, + + destroy : function() + { + this.prefs = null; + this.scale = null; + this.labels = null; + } +}; diff --git a/content/treestyletab/config.xul b/content/treestyletab/config.xul index df14db78..0a936302 100644 --- a/content/treestyletab/config.xul +++ b/content/treestyletab/config.xul @@ -317,8 +317,11 @@ - + + onchange="gOpenLinkInTabScale.onChange();"/>