slider => radiogroup

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@4961 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2009-08-20 06:33:45 +00:00
parent 46a577ba5f
commit a6831ad860
2 changed files with 48 additions and 68 deletions

View File

@ -37,9 +37,9 @@ function init()
var gDropLinksOnRadioSet,
gGroupBookmarkRadioSet,
gOpenLinkInTabScale,
gLoadLocationBarToNewTabScale,
gLoadLocationBarToChildTabScale,
gOpenLinkInTabRadio,
gLoadLocationBarToNewTabRadio,
gLoadLocationBarToChildTabRadio,
gLastStateIsVertical;
var gTabbarPlacePositionInitialized = false;
@ -58,22 +58,22 @@ function initTabPane()
'openGroupBookmark-deck'
);
gOpenLinkInTabScale = new ScaleSet(
gOpenLinkInTabRadio = new RadioScaleSet(
['extensions.treestyletab.openOuterLinkInNewTab',
'extensions.treestyletab.openAnyLinkInNewTab'],
'openLinkInNewTab-scale',
'openLinkInNewTab-radio',
'openLinkInNewTab-labels'
);
gLoadLocationBarToNewTabScale = new ScaleSet(
gLoadLocationBarToNewTabRadio = new RadioScaleSet(
['extensions.treestyletab.urlbar.loadDifferentDomainToNewTab',
'extensions.treestyletab.urlbar.loadSameDomainToNewTab'],
'loadLocationBarToNewTab-scale',
'loadLocationBarToNewTab-radio',
'loadLocationBarToNewTab-labels'
);
gLoadLocationBarToChildTabScale = new ScaleSet(
gLoadLocationBarToChildTabRadio = new RadioScaleSet(
['extensions.treestyletab.urlbar.loadSameDomainToNewTab.asChild',
'extensions.treestyletab.urlbar.loadDifferentDomainToNewTab.asChild'],
'loadLocationBarToChildTab-scale',
'loadLocationBarToChildTab-radio',
'loadLocationBarToChildTab-labels'
);
@ -246,62 +246,58 @@ function updateCloseRootBehaviorCheck()
function ScaleSet(aPrefs, aScale, aLabelsDeck)
function RadioScaleSet(aPrefs, aRadio, aLabelsDeck)
{
this.prefs = aPrefs.map(document.getElementById, document);
this.scale = document.getElementById(aScale);
this.labels = document.getElementById(aLabelsDeck);
this.radio = document.getElementById(aRadio);
this.scale.value = this.prefs[1].value ? 2 :
this.radio.value = this.prefs[1].value ? 2 :
this.prefs[0].value ? 1 :
0 ;
this.labels.selectedIndex = this.scale.value;
}
ScaleSet.prototype = {
RadioScaleSet.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.radio.value = aValue;
this.onChange();
return aValue;
},
get value()
{
return parseInt(this.scale.value);
return parseInt(this.radio.value);
},
set disabled(aDisabled)
{
if (aDisabled) {
this.scale.setAttribute('disabled', true);
Array.slice(this.labels.childNodes).forEach(function(aNode) {
this.radio.setAttribute('disabled', true);
Array.slice(this.radio.childNodes).forEach(function(aNode) {
aNode.setAttribute('disabled', true);
});
}
else {
this.scale.removeAttribute('disabled');
Array.slice(this.labels.childNodes).forEach(function(aNode) {
this.radio.removeAttribute('disabled');
Array.slice(this.radio.childNodes).forEach(function(aNode) {
aNode.removeAttribute('disabled');
});
}
},
get disabled()
{
return this.scale.getAttribute('disabled') == 'true';
return this.radio.getAttribute('disabled') == 'true';
},
destroy : function()
{
this.prefs = null;
this.scale = null;
this.labels = null;
this.radio = null;
}
};

View File

@ -344,6 +344,7 @@
<tabbox orient="vertical">
<tabs>
<tab label="&config.tabs.context.tab;"/>
<tab label="&config.tabs.context.tab;"/>
<tab label="&config.tabs.restriction.tab;"/>
</tabs>
@ -351,56 +352,39 @@
<tabpanel orient="vertical">
<groupbox>
<caption label="&config.link.caption;"/>
<hbox align="center">
<label class="scale-label" value="&config.scale.min;" control="openLinkInNewTab-scale"/>
<scale id="openLinkInNewTab-scale"
orient="horizontal"
min="0"
max="2"
onchange="gOpenLinkInTabScale.onChange();"/>
<label class="scale-label" value="&config.scale.max;" control="openLinkInNewTab-scale"/>
<deck id="openLinkInNewTab-labels">
<label value="&config.link.none;" control="openLinkInNewTab-scale"/>
<label value="&config.link.outer;" control="openLinkInNewTab-scale"/>
<label value="&config.link.any;" control="openLinkInNewTab-scale"/>
</deck>
</hbox>
<radiogroup id="openLinkInNewTab-radio"
orient="vertical"
oncommand="gOpenLinkInTabRadio.onChange();">
<radio value="0" label="&config.link.none;"/>
<radio value="1" label="&config.link.outer;"/>
<radio value="2" label="&config.link.any;"/>
</radiogroup>
</groupbox>
<groupbox>
<caption label="&config.urlbar.caption;"/>
<hbox align="center">
<label class="scale-label" value="&config.scale.min;" control="loadLocationBarToNewTab-scale"/>
<scale id="loadLocationBarToNewTab-scale"
orient="horizontal"
min="0"
max="2"
onchange="
gLoadLocationBarToNewTabScale.onChange();
gLoadLocationBarToChildTabScale.disabled = gLoadLocationBarToNewTabScale.value == 0;
"/>
<label class="scale-label" value="&config.scale.max;" control="loadLocationBarToNewTab-scale"/>
<deck id="loadLocationBarToNewTab-labels">
<label value="&config.urlbar.none;" control="loadLocationBarToNewTab-scale"/>
<label value="&config.urlbar.outer;" control="loadLocationBarToNewTab-scale"/>
<label value="&config.urlbar.any;" control="loadLocationBarToNewTab-scale"/>
</deck>
</hbox>
<radiogroup id="loadLocationBarToNewTab-radio"
orient="vertical"
oncommand="
gLoadLocationBarToNewTabRadio.onChange();
gLoadLocationBarToChildTabRadio.disabled = gLoadLocationBarToNewTabRadio.value == 0;
">
<radio value="0" label="&config.urlbar.none;"/>
<radio value="1" label="&config.urlbar.outer;"/>
<radio value="2" label="&config.urlbar.any;"/>
</radiogroup>
<hbox align="center">
<spacer style="width:1em;"/>
<label class="scale-label" value="&config.scale.min;" control="loadLocationBarToChildTab-scale"/>
<scale id="loadLocationBarToChildTab-scale"
orient="horizontal"
min="0"
max="2"
onchange="gLoadLocationBarToChildTabScale.onChange();"/>
<label class="scale-label" value="&config.scale.max;" control="loadLocationBarToChildTab-scale"/>
<deck id="loadLocationBarToChildTab-labels">
<label value="&config.urlbar.asChild.none;" control="loadLocationBarToChildTab-scale"/>
<label value="&config.urlbar.asChild.inner;" control="loadLocationBarToChildTab-scale"/>
<label value="&config.urlbar.asChild.any;" control="loadLocationBarToChildTab-scale"/>
</deck>
<radiogroup id="loadLocationBarToChildTab-radio"
orient="vertical"
oncommand="gLoadLocationBarToChildTabRadio.onChange();">
<radio value="0" label="&config.urlbar.asChild.none;"/>
<radio value="1" label="&config.urlbar.asChild.inner;"/>
<radio value="2" label="&config.urlbar.asChild.any;"/>
</radiogroup>
</hbox>
</groupbox>
</tabpanel>
<tabpanel orient="vertical">
<groupbox>
<caption align="center">
<label value="&config.dropLinksOnTab.caption;"/>