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

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,
gGroupBookmarkUnderParent,
gGroupBookmarkPref,
gGroupBookmarkReplace;
gGroupBookmarkBehaviorPref,
gGroupBookmarkReplacePref;
function ensureGroupBookmarkItems()
{
if (gGroupBookmarkPref) return;
if (gGroupBookmarkBehaviorPref) return;
gGroupBookmarkRadio = document.getElementById('openGroupBookmark-radiogroup');
gGroupBookmarkPref = document.getElementById('extensions.treestyletab.openGroupBookmark.behavior');
gGroupBookmarkUnderParent = document.getElementById('openGroupBookmark.underParent-check');
gGroupBookmarkRadio = document.getElementById('openGroupBookmark-radiogroup');
gGroupBookmarkUnderParent = document.getElementById('openGroupBookmark.underParent-check');
gGroupBookmarkBehaviorPref = document.getElementById('extensions.treestyletab.openGroupBookmark.behavior');
var bookmarkReplaceKey = 'browser.tabs.loadFolderAndReplace';
gGroupBookmarkReplace = document.getElementById(bookmarkReplaceKey);
gGroupBookmarkReplacePref = document.getElementById(bookmarkReplaceKey);
try {
gGroupBookmarkReplace.value = Prefs.getBoolPref(bookmarkReplaceKey);
gGroupBookmarkReplacePref.value = Prefs.getBoolPref(bookmarkReplaceKey);
}
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,
gLoadLocationBarToChildTabScale,
gLastStateIsVertical;
@ -43,6 +45,19 @@ var gTabbarPlacePositionInitialized = false;
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(
['extensions.treestyletab.openOuterLinkInNewTab',
'extensions.treestyletab.openAnyLinkInNewTab'],
@ -76,7 +91,7 @@ function initTabPane()
gLastStateIsVertical = gLastStateIsVertical == 'left' || gLastStateIsVertical == 'right';
}
function onSyncGroupBookmarkRadioToPref()
function onSyncGroupBookmarkUIToPref()
{
ensureGroupBookmarkItems();
var behavior = parseInt(gGroupBookmarkRadio.value);
@ -90,14 +105,14 @@ function onSyncGroupBookmarkRadioToPref()
return behavior;
}
function onSyncPrefToGroupBookmarkRadio()
function onSyncGroupBookmarkPrefToUI()
{
ensureGroupBookmarkItems();
var behavior = gGroupBookmarkPref.value & 1 ? 1 :
gGroupBookmarkPref.value & 2 ? 2 :
gGroupBookmarkPref.value & 4 ? 4 :
var behavior = gGroupBookmarkBehaviorPref.value & 1 ? 1 :
gGroupBookmarkBehaviorPref.value & 2 ? 2 :
gGroupBookmarkBehaviorPref.value & 4 ? 4 :
0;
gGroupBookmarkUnderParent.checked = gGroupBookmarkPref.value & 256 ? true : false ;
gGroupBookmarkUnderParent.checked = gGroupBookmarkBehaviorPref.value & 256 ? true : false ;
return behavior;
}
@ -282,3 +297,55 @@ ScaleSet.prototype = {
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>
</groupbox>
<groupbox>
<caption label="&config.dropLinksOnTab.caption;"/>
<radiogroup id="extensions.treestyletab.dropLinksOnTab.behavior-radiogroup"
preference="extensions.treestyletab.dropLinksOnTab.behavior"
orient="vertical">
<radio value="0" label="&config.dropLinksOnTab.ask;"/>
<radio value="1" label="&config.dropLinksOnTab.load;"/>
<radio value="2" label="&config.dropLinksOnTab.newTab;"/>
</radiogroup>
<caption align="center">
<label value="&config.dropLinksOnTab.caption;"/>
<checkbox id="dropLinksOnTab-check"
label="&config.dropLinksOnTab.ask;"
oncommand="gDropLinksOnTabRadioSet.onChange();"/>
</caption>
<deck id="dropLinksOnTab-deck">
<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>
<caption label="&config.openGroupBookmark.caption;"/>
<radiogroup id="openGroupBookmark-radiogroup"
orient="vertical"
onsynctopreference="return onSyncGroupBookmarkRadioToPref();"
onsyncfrompreference="return onSyncPrefToGroupBookmarkRadio();"
preference="extensions.treestyletab.openGroupBookmark.behavior">
<radio value="0" label="&config.openGroupBookmark.ask;"/>
<hbox align="center">
<radio value="1" label="&config.openGroupBookmark.subtree;"/>
<checkbox id="openGroupBookmark.underParent-check"
label="&config.openGroupBookmark.underParent;"
oncommand="gGroupBookmarkPref.value = onSyncGroupBookmarkRadioToPref();"/>
</hbox>
<radio value="2" label="&config.openGroupBookmark.flat;"/>
<radio value="4" label="&config.openGroupBookmark.replace;"/>
</radiogroup>
<caption align="center">
<label value="&config.openGroupBookmark.caption;"/>
<checkbox id="openGroupBookmark-check"
label="&config.openGroupBookmark.ask;"
oncommand="
gGroupBookmarkRadioSet.onChange(true);
gGroupBookmarkRadioSet.pref.value = onSyncGroupBookmarkUIToPref();
"/>
</caption>
<deck id="openGroupBookmark-deck">
<spacer flex="1"/>
<radiogroup id="openGroupBookmark-radiogroup"
orient="vertical"
onsynctopreference="return onSyncGroupBookmarkUIToPref();"
onsyncfrompreference="return onSyncGroupBookmarkPrefToUI();"
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>
</tabpanel>
<tabpanel orient="vertical">