初期状態ではラジオボタンを隠す

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@4818 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2009-07-27 08:32:45 +00:00
parent 79cecd42c9
commit b938a0906e
2 changed files with 126 additions and 40 deletions

View File

@ -8,23 +8,23 @@ var Prefs = Components
var gGroupBookmarkRadio, var gGroupBookmarkRadio,
gGroupBookmarkUnderParent, gGroupBookmarkUnderParent,
gGroupBookmarkPref, gGroupBookmarkBehaviorPref,
gGroupBookmarkReplace; gGroupBookmarkReplacePref;
function ensureGroupBookmarkItems() function ensureGroupBookmarkItems()
{ {
if (gGroupBookmarkPref) return; if (gGroupBookmarkBehaviorPref) return;
gGroupBookmarkRadio = document.getElementById('openGroupBookmark-radiogroup'); gGroupBookmarkRadio = document.getElementById('openGroupBookmark-radiogroup');
gGroupBookmarkPref = document.getElementById('extensions.treestyletab.openGroupBookmark.behavior'); gGroupBookmarkUnderParent = document.getElementById('openGroupBookmark.underParent-check');
gGroupBookmarkUnderParent = document.getElementById('openGroupBookmark.underParent-check'); gGroupBookmarkBehaviorPref = document.getElementById('extensions.treestyletab.openGroupBookmark.behavior');
var bookmarkReplaceKey = 'browser.tabs.loadFolderAndReplace'; var bookmarkReplaceKey = 'browser.tabs.loadFolderAndReplace';
gGroupBookmarkReplace = document.getElementById(bookmarkReplaceKey); gGroupBookmarkReplacePref = document.getElementById(bookmarkReplaceKey);
try { try {
gGroupBookmarkReplace.value = Prefs.getBoolPref(bookmarkReplaceKey); gGroupBookmarkReplacePref.value = Prefs.getBoolPref(bookmarkReplaceKey);
} }
catch(e) { catch(e) {
Prefs.setBoolPref(bookmarkReplaceKey, gGroupBookmarkReplace.value != 'false'); Prefs.setBoolPref(bookmarkReplaceKey, gGroupBookmarkReplacePref.value != 'false');
} }
} }
@ -35,7 +35,9 @@ function init()
} }
var gOpenLinkInTabScale, var gDropLinksOnRadioSet,
gGroupBookmarkRadioSet,
gOpenLinkInTabScale,
gLoadLocationBarToNewTabScale, gLoadLocationBarToNewTabScale,
gLoadLocationBarToChildTabScale, gLoadLocationBarToChildTabScale,
gLastStateIsVertical; gLastStateIsVertical;
@ -43,6 +45,19 @@ var gTabbarPlacePositionInitialized = false;
function initTabPane() function initTabPane()
{ {
gDropLinksOnTabRadioSet = new RadioSet(
'extensions.treestyletab.dropLinksOnTab.behavior',
'dropLinksOnTab-radiogroup',
'dropLinksOnTab-check',
'dropLinksOnTab-deck'
);
gGroupBookmarkRadioSet = new RadioSet(
'extensions.treestyletab.openGroupBookmark.behavior',
'openGroupBookmark-radiogroup',
'openGroupBookmark-check',
'openGroupBookmark-deck'
);
gOpenLinkInTabScale = new ScaleSet( gOpenLinkInTabScale = new ScaleSet(
['extensions.treestyletab.openOuterLinkInNewTab', ['extensions.treestyletab.openOuterLinkInNewTab',
'extensions.treestyletab.openAnyLinkInNewTab'], 'extensions.treestyletab.openAnyLinkInNewTab'],
@ -76,7 +91,7 @@ function initTabPane()
gLastStateIsVertical = gLastStateIsVertical == 'left' || gLastStateIsVertical == 'right'; gLastStateIsVertical = gLastStateIsVertical == 'left' || gLastStateIsVertical == 'right';
} }
function onSyncGroupBookmarkRadioToPref() function onSyncGroupBookmarkUIToPref()
{ {
ensureGroupBookmarkItems(); ensureGroupBookmarkItems();
var behavior = parseInt(gGroupBookmarkRadio.value); var behavior = parseInt(gGroupBookmarkRadio.value);
@ -90,14 +105,14 @@ function onSyncGroupBookmarkRadioToPref()
return behavior; return behavior;
} }
function onSyncPrefToGroupBookmarkRadio() function onSyncGroupBookmarkPrefToUI()
{ {
ensureGroupBookmarkItems(); ensureGroupBookmarkItems();
var behavior = gGroupBookmarkPref.value & 1 ? 1 : var behavior = gGroupBookmarkBehaviorPref.value & 1 ? 1 :
gGroupBookmarkPref.value & 2 ? 2 : gGroupBookmarkBehaviorPref.value & 2 ? 2 :
gGroupBookmarkPref.value & 4 ? 4 : gGroupBookmarkBehaviorPref.value & 4 ? 4 :
0; 0;
gGroupBookmarkUnderParent.checked = gGroupBookmarkPref.value & 256 ? true : false ; gGroupBookmarkUnderParent.checked = gGroupBookmarkBehaviorPref.value & 256 ? true : false ;
return behavior; return behavior;
} }
@ -282,3 +297,55 @@ ScaleSet.prototype = {
this.labels = null; this.labels = null;
} }
}; };
function RadioSet(aPref, aRadio, aCheck, aDeck)
{
this.pref = document.getElementById(aPref);
this.radio = document.getElementById(aRadio);
this.check = document.getElementById(aCheck);
this.deck = document.getElementById(aDeck);
this.backup = this.value || 1;
if (this.value == 0) {
this.check.checked = true;
this.deck.selectedIndex = 0;
}
else {
this.check.checked = false;
this.deck.selectedIndex = 1;
}
}
RadioSet.prototype = {
onChange : function(aDontUpdatePref)
{
if (this.checked) {
this.backup = this.value;
this.deck.selectedIndex = 0;
this.value = 0;
}
else {
this.deck.selectedIndex = 1;
this.value = this.backup;
}
if (!aDontUpdatePref)
this.pref.value = this.value;
},
get checked()
{
return this.check.checked;
},
set checked(aValue)
{
return this.check.checked = aValue;
},
get value()
{
return parseInt(this.radio.value);
},
set value(aValue)
{
return this.radio.value = aValue;
}
};

View File

@ -402,32 +402,51 @@
</hbox> </hbox>
</groupbox> </groupbox>
<groupbox> <groupbox>
<caption label="&config.dropLinksOnTab.caption;"/> <caption align="center">
<radiogroup id="extensions.treestyletab.dropLinksOnTab.behavior-radiogroup" <label value="&config.dropLinksOnTab.caption;"/>
preference="extensions.treestyletab.dropLinksOnTab.behavior" <checkbox id="dropLinksOnTab-check"
orient="vertical"> label="&config.dropLinksOnTab.ask;"
<radio value="0" label="&config.dropLinksOnTab.ask;"/> oncommand="gDropLinksOnTabRadioSet.onChange();"/>
<radio value="1" label="&config.dropLinksOnTab.load;"/> </caption>
<radio value="2" label="&config.dropLinksOnTab.newTab;"/> <deck id="dropLinksOnTab-deck">
</radiogroup> <spacer flex="1"/>
<radiogroup id="dropLinksOnTab-radiogroup"
preference="extensions.treestyletab.dropLinksOnTab.behavior"
orient="vertical">
<radio value="0" collapsed="true"/>
<radio value="1" label="&config.dropLinksOnTab.load;"/>
<radio value="2" label="&config.dropLinksOnTab.newTab;"/>
</radiogroup>
</deck>
</groupbox> </groupbox>
<groupbox> <groupbox>
<caption label="&config.openGroupBookmark.caption;"/> <caption align="center">
<radiogroup id="openGroupBookmark-radiogroup" <label value="&config.openGroupBookmark.caption;"/>
orient="vertical" <checkbox id="openGroupBookmark-check"
onsynctopreference="return onSyncGroupBookmarkRadioToPref();" label="&config.openGroupBookmark.ask;"
onsyncfrompreference="return onSyncPrefToGroupBookmarkRadio();" oncommand="
preference="extensions.treestyletab.openGroupBookmark.behavior"> gGroupBookmarkRadioSet.onChange(true);
<radio value="0" label="&config.openGroupBookmark.ask;"/> gGroupBookmarkRadioSet.pref.value = onSyncGroupBookmarkUIToPref();
<hbox align="center"> "/>
<radio value="1" label="&config.openGroupBookmark.subtree;"/> </caption>
<checkbox id="openGroupBookmark.underParent-check" <deck id="openGroupBookmark-deck">
label="&config.openGroupBookmark.underParent;" <spacer flex="1"/>
oncommand="gGroupBookmarkPref.value = onSyncGroupBookmarkRadioToPref();"/> <radiogroup id="openGroupBookmark-radiogroup"
</hbox> orient="vertical"
<radio value="2" label="&config.openGroupBookmark.flat;"/> onsynctopreference="return onSyncGroupBookmarkUIToPref();"
<radio value="4" label="&config.openGroupBookmark.replace;"/> onsyncfrompreference="return onSyncGroupBookmarkPrefToUI();"
</radiogroup> preference="extensions.treestyletab.openGroupBookmark.behavior">
<radio value="0" collapsed="true"/>
<hbox align="center">
<radio value="1" label="&config.openGroupBookmark.subtree;"/>
<checkbox id="openGroupBookmark.underParent-check"
label="&config.openGroupBookmark.underParent;"
oncommand="gGroupBookmarkRadioSet.pref.value = onSyncGroupBookmarkUIToPref();"/>
</hbox>
<radio value="2" label="&config.openGroupBookmark.flat;"/>
<radio value="4" label="&config.openGroupBookmark.replace;"/>
</radiogroup>
</deck>
</groupbox> </groupbox>
</tabpanel> </tabpanel>
<tabpanel orient="vertical"> <tabpanel orient="vertical">