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

View File

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