From 1c3c4912a717464191e4d6da9f08a208a0d084af Mon Sep 17 00:00:00 2001 From: piro Date: Sun, 28 Mar 2010 18:22:15 +0000 Subject: [PATCH] =?UTF-8?q?=E5=8D=B0=E5=88=B7=E3=83=97=E3=83=AC=E3=83=93?= =?UTF-8?q?=E3=83=A5=E3=83=BC=E3=81=A7=E3=82=BF=E3=83=96=E3=83=90=E3=83=BC?= =?UTF-8?q?=E3=81=AE=E3=83=97=E3=83=AC=E3=83=BC=E3=82=B9=E3=83=9B=E3=83=AB?= =?UTF-8?q?=E3=83=80=E3=83=BC=E3=81=8C=E6=AE=8B=E3=81=A3=E3=81=A6=E3=81=97?= =?UTF-8?q?=E3=81=BE=E3=81=A3=E3=81=A6=E3=81=84=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@6502 599a83e7-65a4-db11-8015-0010dcdd6dc2 --- content/treestyletab/treestyletab.css | 5 +- content/treestyletab/treestyletab.js | 35 +++++++-- content/treestyletab/treestyletabbrowser.js | 76 ++++++++++++------- .../treestyletabbrowser_autoHide.js | 28 +++---- .../treestyletabbrowser_tabbarDNDObserver.js | 2 +- ...treestyletabbrowser_tabpanelDNDObserver.js | 4 +- install.rdf | 2 +- modules/utils.js | 8 +- 8 files changed, 108 insertions(+), 52 deletions(-) diff --git a/content/treestyletab/treestyletab.css b/content/treestyletab/treestyletab.css index 40f4f1eb..19ac1682 100644 --- a/content/treestyletab/treestyletab.css +++ b/content/treestyletab/treestyletab.css @@ -25,7 +25,10 @@ .tabbrowser-strip[treestyletab-tabbar-autohide="hidden"]+splitter, tabbrowser:not([treestyletab-tabbar-autohide="hidden"]) .treestyletab-tabbar-toggler, #appcontent[ahFull="true"] .tabbrowser-strip[ahHIDE="true"]+splitter /* AutoHide */, -.tabbrowser-strip[treestyletab-tabbar-fixed="true"]+splitter { +.tabbrowser-strip[treestyletab-tabbar-fixed="true"]+splitter, +.tabbrowser-strip[treestyletab-print-preview="true"], +.tabbrowser-strip[treestyletab-print-preview="true"]+splitter, +#TabsToolbar[treestyletab-print-preview="true"] { visibility: collapse; } diff --git a/content/treestyletab/treestyletab.js b/content/treestyletab/treestyletab.js index 1b535581..2844d9df 100644 --- a/content/treestyletab/treestyletab.js +++ b/content/treestyletab/treestyletab.js @@ -685,8 +685,8 @@ catch(e) { onTabDrop : function TSTService_onTabDrop(aEvent) { - var b = this.getTabBrowserFromChild(aEvent.currentTarget); - var tabbar = b.mTabContainer; + var b = this.getTabBrowserFromChild(aEvent.currentTarget); + var tabbar = b.mTabContainer; var sv = b.treeStyleTab; var dt = aEvent.dataTransfer; @@ -721,7 +721,7 @@ catch(e) { window.setTimeout(function() { var newTabs = Array.slice(b.mTabContainer.childNodes).filter(function(aTab) { return beforeTabs.indexOf(aTab) < 0; - }); + }); if (newTabs.length) sv.attachTabTo(newTabs[0], dropActionInfo.target); }, 0); @@ -780,8 +780,8 @@ catch(e) { onTabDragEnd : function TSTService_onTabDragEnd(aEvent) { - var b = this.getTabBrowserFromChild(aEvent.currentTarget); - var tabbar = b.mTabContainer; + var b = this.getTabBrowserFromChild(aEvent.currentTarget); + var tabbar = b.mTabContainer; var sv = b.treeStyleTab; var dt = aEvent.dataTransfer; @@ -1121,6 +1121,17 @@ catch(e) { ) ); } + + if ('PrintUtils' in window) { + eval('PrintUtils.printPreview = '+PrintUtils.printPreview.toSource().replace( + '{', + '{ TreeStyleTabService.onPrintPreviewEnter();' + )); + eval('PrintUtils.exitPrintPreview = '+PrintUtils.exitPrintPreview.toSource().replace( + /(\}\)?)$/, + 'TreeStyleTabService.onPrintPreviewExit(); $1' + )); + } }, _splitFunctionNames : function TSTService__splitFunctionNames(aString) { @@ -1844,6 +1855,20 @@ catch(e) { return false; }, tearOffSubTreeFromRemote : function() { return this.tearOffSubtreeFromRemote.apply(this, arguments); }, // obsolete, for backward compatibility + + onPrintPreviewEnter : function TSTService_onPrintPreviewEnter() + { + var event = document.createEvent('Events'); + event.initEvent('TreeStyleTabPrintPreviewEntered', true, false); + document.documentElement.dispatchEvent(event); + }, + + onPrintPreviewExit : function TSTService_onPrintPreviewExit() + { + var event = document.createEvent('Events'); + event.initEvent('TreeStyleTabPrintPreviewExited', true, false); + document.documentElement.dispatchEvent(event); + }, observe : function TSTService_observe(aSubject, aTopic, aData) { diff --git a/content/treestyletab/treestyletabbrowser.js b/content/treestyletab/treestyletabbrowser.js index 20dcfb6d..9b0e60f9 100644 --- a/content/treestyletab/treestyletabbrowser.js +++ b/content/treestyletab/treestyletabbrowser.js @@ -85,7 +85,7 @@ TreeStyleTabBrowser.prototype = { { return this._tabStripPlaceHolder; }, - set tabStripPlaceHolder(value) + set tabStripPlaceHolder(value) { return (this._tabStripPlaceHolder = value); }, @@ -234,6 +234,9 @@ TreeStyleTabBrowser.prototype = { if (this.isFloating) window.addEventListener('resize', this, true); + window.addEventListener('TreeStyleTabPrintPreviewEntered', this, false); + window.addEventListener('TreeStyleTabPrintPreviewExited', this, false); + b.addEventListener('MultipleTabHandlerTabsClosing', this, false); @@ -894,7 +897,7 @@ TreeStyleTabBrowser.prototype = { document.getAnonymousElementByAttribute(b.mTabContainer, 'anonid', 'alltabs-button') ); - this.setTabbrowserAttribute(this.kRESIZING, null, b); + this.removeTabbrowserAttribute(this.kRESIZING, b); this.removeTabStripAttribute('width'); b.mPanelContainer.removeAttribute('width'); @@ -935,20 +938,20 @@ TreeStyleTabBrowser.prototype = { if (toolboxContainer) toolboxContainer.orient = 'vertical'; - this.setTabbrowserAttribute(this.kMODE, 'vertical', b); + this.setTabbrowserAttribute(this.kMODE, 'vertical'); this.setTabStripAttribute('width', this.getTreePref('tabbar.width')); this.removeTabStripAttribute('height'); b.mPanelContainer.removeAttribute('height'); if (pos == this.kTABBAR_RIGHT) { - this.setTabbrowserAttribute(this.kTABBAR_POSITION, 'right', b); + this.setTabbrowserAttribute(this.kTABBAR_POSITION, 'right'); if (this.getTreePref('tabbar.invertTab')) { - this.setTabbrowserAttribute(this.kTAB_INVERTED, 'true', b); + this.setTabbrowserAttribute(this.kTAB_INVERTED, 'true'); this.indentTarget = 'right'; } else { - this.setTabbrowserAttribute(this.kTAB_INVERTED, null, b); + this.removeTabbrowserAttribute(this.kTAB_INVERTED); this.indentTarget = 'left'; } delayedPostProcess = function(aSelf, aTabBrowser, aSplitter, aToggler) { @@ -965,8 +968,8 @@ TreeStyleTabBrowser.prototype = { }; } else { - this.setTabbrowserAttribute(this.kTABBAR_POSITION, 'left', b); - this.setTabbrowserAttribute(this.kTAB_INVERTED, null, b); + this.setTabbrowserAttribute(this.kTABBAR_POSITION, 'left'); + this.removeTabbrowserAttribute(this.kTAB_INVERTED); this.indentTarget = 'left'; delayedPostProcess = function(aSelf, aTabBrowser, aSplitter, aToggler) { indicator.setAttribute('ordinal', 1); @@ -1009,11 +1012,11 @@ TreeStyleTabBrowser.prototype = { if (toolboxContainer) toolboxContainer.orient = 'horizontal'; - this.setTabbrowserAttribute(this.kMODE, this.getTreePref('tabbar.multirow') ? 'multirow' : 'horizontal' , b); - this.setTabbrowserAttribute(this.kTAB_INVERTED, null, b); + this.setTabbrowserAttribute(this.kMODE, this.getTreePref('tabbar.multirow') ? 'multirow' : 'horizontal'); + this.removeTabbrowserAttribute(this.kTAB_INVERTED); if (pos == this.kTABBAR_BOTTOM) { - this.setTabbrowserAttribute(this.kTABBAR_POSITION, 'bottom', b); + this.setTabbrowserAttribute(this.kTABBAR_POSITION, 'bottom'); this.indentTarget = 'bottom'; delayedPostProcess = function(aSelf, aTabBrowser, aSplitter, aToggler) { indicator.setAttribute('ordinal', 1); @@ -1024,7 +1027,7 @@ TreeStyleTabBrowser.prototype = { }; } else { - this.setTabbrowserAttribute(this.kTABBAR_POSITION, 'top', b); + this.setTabbrowserAttribute(this.kTABBAR_POSITION, 'top'); this.indentTarget = 'top'; delayedPostProcess = function(aSelf, aTabBrowser, aSplitter, aToggler) { indicator.setAttribute('ordinal', 1); @@ -1111,19 +1114,19 @@ TreeStyleTabBrowser.prototype = { var orient; if (this.isVertical) { orient = 'vertical'; - this.setTabbrowserAttribute(this.kFIXED, this.getTreePref('tabbar.fixed.vertical') ? 'true' : null , b); + this.setTabbrowserAttribute(this.kFIXED, this.getTreePref('tabbar.fixed.vertical') ? 'true' : null); } else { orient = 'horizontal'; if (this.getTreePref('tabbar.fixed.horizontal')) { - this.setTabbrowserAttribute(this.kFIXED, true, b); + this.setTabbrowserAttribute(this.kFIXED, true); if (!this.isMultiRow()) { this.removeTabStripAttribute('height'); b.mPanelContainer.removeAttribute('height'); } } else { - this.setTabbrowserAttribute(this.kFIXED, null, b); + this.removeTabbrowserAttribute(this.kFIXED, b); this.setTabStripAttribute('height', this.getTreePref('tabbar.height')); } } @@ -1133,9 +1136,9 @@ TreeStyleTabBrowser.prototype = { aSelf.startRendering(); }, 0, this); - this.setTabbrowserAttribute(this.kINDENTED, this.getTreePref('enableSubtreeIndent.'+orient) ? 'true' : null , b); - this.setTabbrowserAttribute(this.kALLOW_COLLAPSE, this.getTreePref('allowSubtreeCollapseExpand.'+orient) ? 'true' : null , b); - this.setTabbrowserAttribute(this.kHIDE_ALLTABS, this.getTreePref('tabbar.hideAlltabsButton.'+orient) ? 'true' : null , b); + this.setTabbrowserAttribute(this.kINDENTED, this.getTreePref('enableSubtreeIndent.'+orient) ? 'true' : null); + this.setTabbrowserAttribute(this.kALLOW_COLLAPSE, this.getTreePref('allowSubtreeCollapseExpand.'+orient) ? 'true' : null); + this.setTabbrowserAttribute(this.kHIDE_ALLTABS, this.getTreePref('tabbar.hideAlltabsButton.'+orient) ? 'true' : null); this.updateAllTabsIndent(); }, @@ -1292,6 +1295,9 @@ TreeStyleTabBrowser.prototype = { if (this.isFloating) window.removeEventListener('resize', this, true); + window.removeEventListener('TreeStyleTabPrintPreviewEntered', this, false); + window.removeEventListener('TreeStyleTabPrintPreviewExited', this, false); + b.removeEventListener('MultipleTabHandlerTabsClosing', this, false); TreeStyleTabService.destroyTabDNDObserver(b); @@ -1407,14 +1413,14 @@ TreeStyleTabBrowser.prototype = { }, this); break; case 'extensions.treestyletab.tabbar.invertTabContents': - this.setTabbrowserAttribute(this.kTAB_CONTENTS_INVERTED, value , b); + this.setTabbrowserAttribute(this.kTAB_CONTENTS_INVERTED, value); tabs.forEach(function(aTab) { this.initTabContents(aTab); }, this); break; case 'extensions.treestyletab.tabbar.invertClosebox': - this.setTabbrowserAttribute(this.kCLOSEBOX_INVERTED, value , b); + this.setTabbrowserAttribute(this.kCLOSEBOX_INVERTED, value); tabs.forEach(function(aTab) { this.initTabContents(aTab); }, this); @@ -1424,10 +1430,10 @@ TreeStyleTabBrowser.prototype = { if (value) { if (/^(default|vertigo|mixed)$/.test(value)) value = 'square '+value; - this.setTabbrowserAttribute(this.kSTYLE, value , b); + this.setTabbrowserAttribute(this.kSTYLE, value); } else { - this.setTabbrowserAttribute(this.kSTYLE, null , b); + this.removeTabbrowserAttribute(this.kSTYLE); } value = this.getTreePref('twisty.style'); if (value != 'auto') { @@ -1449,11 +1455,11 @@ TreeStyleTabBrowser.prototype = { value = 'modern-black'; } } - this.setTabbrowserAttribute(this.kTWISTY_STYLE, value, b); + this.setTabbrowserAttribute(this.kTWISTY_STYLE, value); break; case 'extensions.treestyletab.showBorderForFirstTab': - this.setTabbrowserAttribute(this.kFIRSTTAB_BORDER, value , b); + this.setTabbrowserAttribute(this.kFIRSTTAB_BORDER, value); break; case 'extensions.treestyletab.enableSubtreeIndent.horizontal': @@ -1587,6 +1593,12 @@ TreeStyleTabBrowser.prototype = { return this.onResize(aEvent); + case 'TreeStyleTabPrintPreviewEntered': + return this.onTreeStyleTabPrintPreviewEntered(aEvent); + case 'TreeStyleTabPrintPreviewExited': + return this.onTreeStyleTabPrintPreviewExited(aEvent); + + case 'MultipleTabHandlerTabsClosing': if (!this.onTabsRemoving(aEvent)) aEvent.preventDefault(); @@ -2785,7 +2797,17 @@ TreeStyleTabBrowser.prototype = { items[i].style.paddingLeft = tabs[i].getAttribute(this.kNEST)+'em'; } }, - + + onTreeStyleTabPrintPreviewEntered : function TSTBrowser_onTreeStyleTabPrintPreviewEntered(aEvent) + { + this.setTabbrowserAttribute(this.kPRINT_PREVIEW, true); + }, + + onTreeStyleTabPrintPreviewExited : function TSTBrowser_onTreeStyleTabPrintPreviewExited(aEvent) + { + this.removeTabbrowserAttribute(this.kPRINT_PREVIEW); + }, + /* drag and drop */ get tabbarDNDObserver() @@ -3308,11 +3330,11 @@ TreeStyleTabBrowser.prototype = { if (this._treeViewEnabled) { let orient = this.isVertical ? 'vertical' : 'horizontal' ; if (this.getTreePref('allowSubtreeCollapseExpand.'+orient)) - this.setTabbrowserAttribute(this.kALLOW_COLLAPSE, true , this.browser); + this.setTabbrowserAttribute(this.kALLOW_COLLAPSE, true); this.updateTabsIndent(this.rootTabs, undefined, undefined, true); } else { - this.setTabbrowserAttribute(this.kALLOW_COLLAPSE, null , this.browser); + this.removeTabbrowserAttribute(this.kALLOW_COLLAPSE); this.getTabsArray(this.browser).forEach(function(aTab) { this.updateTabIndent(aTab, 0, this.indentTarget, true); }, this); diff --git a/content/treestyletab/treestyletabbrowser_autoHide.js b/content/treestyletab/treestyletabbrowser_autoHide.js index b15034f2..88cf095c 100644 --- a/content/treestyletab/treestyletabbrowser_autoHide.js +++ b/content/treestyletab/treestyletabbrowser_autoHide.js @@ -149,9 +149,9 @@ TreeStyleTabBrowserAutoHide.prototype = { this.updateTransparency(); sv.container.style.margin = 0; - sv.setTabbrowserAttribute(this.kAUTOHIDE, null, sv.mTabBrowser); - sv.setTabbrowserAttribute(this.kSTATE, null, sv.mTabBrowser); - sv.setTabbrowserAttribute(this.kTRANSPARENT, null, sv.mTabBrowser); + sv.removeTabbrowserAttribute(this.kAUTOHIDE); + sv.removeTabbrowserAttribute(this.kSTATE); + sv.removeTabbrowserAttribute(this.kTRANSPARENT); }, // fullscreen @@ -166,7 +166,7 @@ TreeStyleTabBrowserAutoHide.prototype = { if (this.mode != this.kMODE_DISABLED) { this.start(); var sv = this.mOwner; - sv.setTabbrowserAttribute('moz-collapsed', null, sv.mTabBrowser); + sv.removeTabbrowserAttribute('moz-collapsed'); } }, @@ -434,7 +434,7 @@ TreeStyleTabBrowserAutoHide.prototype = { window.setTimeout(function(aSelf) { if (aSelf.expanded) { - sv.setTabbrowserAttribute(aSelf.kAUTOHIDE, 'show', sv.mTabBrowser); + sv.setTabbrowserAttribute(aSelf.kAUTOHIDE, 'show'); aSelf.redrawContentArea(); } b.mTabContainer.adjustTabstrip(); @@ -481,7 +481,7 @@ TreeStyleTabBrowserAutoHide.prototype = { break; } - sv.setTabbrowserAttribute(this.kSTATE, this.kSTATE_EXPANDED, b); + sv.setTabbrowserAttribute(this.kSTATE, this.kSTATE_EXPANDED); switch (this.mode) { @@ -513,14 +513,14 @@ TreeStyleTabBrowserAutoHide.prototype = { switch (this.mode) { case this.kMODE_HIDE: - sv.setTabbrowserAttribute(this.kAUTOHIDE, 'hidden', b); - sv.setTabbrowserAttribute(this.kSTATE, this.kSTATE_HIDDEN, b); + sv.setTabbrowserAttribute(this.kAUTOHIDE, 'hidden'); + sv.setTabbrowserAttribute(this.kSTATE, this.kSTATE_HIDDEN); break; default: case this.kMODE_SHRINK: - sv.setTabbrowserAttribute(this.kAUTOHIDE, 'show', b); - sv.setTabbrowserAttribute(this.kSTATE, this.kSTATE_SHRUNKEN, b); + sv.setTabbrowserAttribute(this.kAUTOHIDE, 'show'); + sv.setTabbrowserAttribute(this.kSTATE, this.kSTATE_SHRUNKEN); if (pos == 'left' || pos == 'right') { sv.setTabStripAttribute('width', this.getTreePref('tabbar.shrunkenWidth')); sv.updateFloatingTabbar(); @@ -766,10 +766,10 @@ TreeStyleTabBrowserAutoHide.prototype = { if (pos != 'top' && this.mode != this.kMODE_DISABLED && style != this.kTRANSPARENT_STYLE[this.kTRANSPARENT_NONE]) { - sv.setTabbrowserAttribute(this.kTRANSPARENT, style, b); + sv.setTabbrowserAttribute(this.kTRANSPARENT, style); } else { - sv.setTabbrowserAttribute(this.kTRANSPARENT, null, b); + sv.removeTabbrowserAttribute(this.kTRANSPARENT); } }, @@ -942,7 +942,7 @@ TreeStyleTabBrowserAutoHide.prototype = { ) { this.isResizing = true; this.clearBG(); - sv.setTabbrowserAttribute(sv.kRESIZING, true, sv.mTabBrowser); + sv.setTabbrowserAttribute(sv.kRESIZING, true); /* canvasを非表示にしたのと同じタイミングでリサイズを行うと、 まだ内部的にcanvasの大きさが残ったままなので、その大きさ以下に タブバーの幅を縮められなくなる。手動でイベントを再送してやると @@ -986,7 +986,7 @@ TreeStyleTabBrowserAutoHide.prototype = { XPathResult.BOOLEAN_TYPE ).booleanValue) { this.isResizing = false; - sv.setTabbrowserAttribute(sv.kRESIZING, null, sv.mTabBrowser); + sv.removeTabbrowserAttribute(sv.kRESIZING); window.setTimeout(function(aSelf) { if (!aSelf.shouldRedraw) return; aSelf.redrawContentArea(); diff --git a/content/treestyletab/treestyletabbrowser_tabbarDNDObserver.js b/content/treestyletab/treestyletabbrowser_tabbarDNDObserver.js index a991eec1..81162d48 100644 --- a/content/treestyletab/treestyletabbrowser_tabbarDNDObserver.js +++ b/content/treestyletab/treestyletabbrowser_tabbarDNDObserver.js @@ -147,7 +147,7 @@ TreeStyleTabBrowserTabbarDNDObserver.prototype = { { window.setTimeout(function(aSelf) { aSelf.readyToEndDrag(); - aSelf.mOwner.setTabbrowserAttribute(aSelf.mOwner.kDROP_POSITION, null, aSelf.mOwner.mTabBrowser); + aSelf.mOwner.removeTabbrowserAttribute(aSelf.mOwner.kDROP_POSITION); }, 10, this); aEvent.stopPropagation(); }, diff --git a/content/treestyletab/treestyletabbrowser_tabpanelDNDObserver.js b/content/treestyletab/treestyletabbrowser_tabpanelDNDObserver.js index 9ac27aaf..320c8deb 100644 --- a/content/treestyletab/treestyletabbrowser_tabpanelDNDObserver.js +++ b/content/treestyletab/treestyletabbrowser_tabpanelDNDObserver.js @@ -10,7 +10,7 @@ TreeStyleTabBrowserTabpanelDNDObserver.prototype = { if (!this.canDrop(aEvent, aDragSession)) return; var sv = this.mOwner; if (sv.mTabBrowser.hasAttribute(sv.kDROP_POSITION)) - sv.setTabbrowserAttribute(sv.kDROP_POSITION, sv.kDROP_POSITION_UNKNOWN, sv.mTabBrowser); + sv.setTabbrowserAttribute(sv.kDROP_POSITION, sv.kDROP_POSITION_UNKNOWN); }, onDragOver : function TSTTabpanelDND_onDragOver(aEvent, aFlavour, aDragSession) @@ -20,7 +20,7 @@ TreeStyleTabBrowserTabpanelDNDObserver.prototype = { var position = this.getDropPosition(aEvent); if (position != 'center' && position != sv.mTabBrowser.getAttribute(sv.kTABBAR_POSITION)) - sv.setTabbrowserAttribute(sv.kDROP_POSITION, position, sv.mTabBrowser); + sv.setTabbrowserAttribute(sv.kDROP_POSITION, position); }, onDrop : function TSTTabpanelDND_onDrop(aEvent, aXferData, aDragSession) diff --git a/install.rdf b/install.rdf index c366fab2..1d2de092 100644 --- a/install.rdf +++ b/install.rdf @@ -5,7 +5,7 @@