From 00c5f4b04ff4cb01d4f5f3be38750325ee4e8930 Mon Sep 17 00:00:00 2001 From: SHIMODA Hiroshi Date: Mon, 29 Nov 2010 19:36:13 +0900 Subject: [PATCH] update configuration UI --- content/treestyletab/config.js | 60 ++++++++++++-- content/treestyletab/config.xul | 95 ++++++++++++++++------ locale/en-US/treestyletab/treestyletab.dtd | 6 +- locale/ja/treestyletab/treestyletab.dtd | 6 +- 4 files changed, 133 insertions(+), 34 deletions(-) diff --git a/content/treestyletab/config.js b/content/treestyletab/config.js index 29f77b15..ab3840e5 100644 --- a/content/treestyletab/config.js +++ b/content/treestyletab/config.js @@ -195,7 +195,7 @@ function onSyncGroupBookmarkPrefToUI() } -function onChangeTabbarPosition(aOnChange) +function onChangeTabbarPosition() { var pos = document.getElementById('extensions.treestyletab.tabbar.position-radiogroup').value; var invertTab = document.getElementById('extensions.treestyletab.tabbar.invertTab-check'); @@ -216,24 +216,24 @@ function onChangeTabbarPosition(aOnChange) else invertClosebox.setAttribute('collapsed', true); - var indentCheckH = document.getElementById('extensions.treestyletab.enableSubtreeIndent.horizontal-check'); - var indentCheckV = document.getElementById('extensions.treestyletab.enableSubtreeIndent.vertical-check'); + var maxTreeLevelH = document.getElementById('maxTreeLevel-groupbox-horizontal'); + var maxTreeLevelV = document.getElementById('maxTreeLevel-groupbox-vertical'); var collapseCheckH = document.getElementById('extensions.treestyletab.allowSubtreeCollapseExpand.horizontal-check'); var collapseCheckV = document.getElementById('extensions.treestyletab.allowSubtreeCollapseExpand.vertical-check'); var hideAllTabsCheckH = document.getElementById('extensions.treestyletab.tabbar.hideAlltabsButton.horizontal-check'); var hideAllTabsCheckV = document.getElementById('extensions.treestyletab.tabbar.hideAlltabsButton.vertical-check'); if (pos == 'left' || pos == 'right') { - indentCheckH.setAttribute('collapsed', true); - indentCheckV.removeAttribute('collapsed'); + maxTreeLevelH.setAttribute('collapsed', true); + maxTreeLevelV.removeAttribute('collapsed'); collapseCheckH.setAttribute('collapsed', true); collapseCheckV.removeAttribute('collapsed'); hideAllTabsCheckH.setAttribute('collapsed', true); hideAllTabsCheckV.removeAttribute('collapsed'); } else { - indentCheckH.removeAttribute('collapsed'); - indentCheckV.setAttribute('collapsed', true); + maxTreeLevelH.removeAttribute('collapsed'); + maxTreeLevelV.setAttribute('collapsed', true); collapseCheckH.removeAttribute('collapsed'); collapseCheckV.setAttribute('collapsed', true); hideAllTabsCheckH.removeAttribute('collapsed'); @@ -243,6 +243,52 @@ function onChangeTabbarPosition(aOnChange) gTabbarPlacePositionInitialized = true; } +function onSyncMaxTreeLevelUIToPref(aTarget) +{ + var isHorizontal = aTarget.indexOf('horizontal') != -1; + aTarget = document.getElementById(aTarget); + if (aTarget.sync) + return; + aTarget.sync = true; + + var UIValue = parseInt(aTarget.value); + var prefValue = UIValue; + Array.slice(aTarget.getElementsByTagName('textbox')).forEach(function(aNode) { + if (aNode.getAttribute('max-tree-level-radio') == UIValue) { + aNode.removeAttribute('disabled'); + prefValue = parseInt(aNode.value); + } + else + aNode.setAttribute('disabled', true); + }); + aTarget.sync = false; + return prefValue; +} + +function onSyncMaxTreeLevelPrefToUI(aTarget) +{ + var isHorizontal = aTarget.indexOf('horizontal') != -1; + aTarget = document.getElementById(aTarget); + if (aTarget.sync) + return; + aTarget.sync = true; + + var pref = document.getElementById(aTarget.getAttribute('preference')); + var value = pref.value; + + var UIValue = Math.max(-1, Math.min(1, value)); + Array.slice(aTarget.getElementsByTagName('textbox')).forEach(function(aNode) { + if (aNode.getAttribute('max-tree-level-radio') == UIValue) { + aNode.removeAttribute('disabled'); + aNode.value = value; + } + else + aNode.setAttribute('disabled', true); + }); + aTarget.sync = false; + return UIValue; +} + var gAutoHideModeRadio, gAutoHideModeToggle, diff --git a/content/treestyletab/config.xul b/content/treestyletab/config.xul index ec12dd4f..f8572a35 100644 --- a/content/treestyletab/config.xul +++ b/content/treestyletab/config.xul @@ -24,12 +24,12 @@ - - + + @@ -121,26 +121,68 @@ - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -236,6 +278,9 @@ + diff --git a/locale/en-US/treestyletab/treestyletab.dtd b/locale/en-US/treestyletab/treestyletab.dtd index c9a90847..4bf3ec7c 100644 --- a/locale/en-US/treestyletab/treestyletab.dtd +++ b/locale/en-US/treestyletab/treestyletab.dtd @@ -15,7 +15,11 @@ - + + + + + diff --git a/locale/ja/treestyletab/treestyletab.dtd b/locale/ja/treestyletab/treestyletab.dtd index f60a803f..9b080001 100644 --- a/locale/ja/treestyletab/treestyletab.dtd +++ b/locale/ja/treestyletab/treestyletab.dtd @@ -15,7 +15,11 @@ - + + + + +