window.open()で開かれたタブを親子関係に組み入れるようにした
git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@1218 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
parent
33de904ff8
commit
a1622ea528
@ -15,24 +15,24 @@
|
||||
|
||||
<prefpane id="prefpane-general" label="&config.tabs.general;">
|
||||
<preferences>
|
||||
<preference id="extensions.treestyletab."
|
||||
name="extensions.treestyletab."
|
||||
<preference id="browser.link.open_newwindow.restriction"
|
||||
name="browser.link.open_newwindow.restriction"
|
||||
type="int"/>
|
||||
</preferences>
|
||||
<groupbox>
|
||||
<caption label="&config..caption;"/>
|
||||
<caption label="&config.jsopen.caption;"/>
|
||||
<vbox>
|
||||
<radiogroup id="extensions.treestyletab.-radiogroup"
|
||||
preference="extensions.treestyletab."
|
||||
<radiogroup id="browser.link.open_newwindow.restriction-radiogroup"
|
||||
preference="browser.link.open_newwindow.restriction"
|
||||
orient="vertical">
|
||||
<radio value="0" label="&config..default;"/>
|
||||
<radio value="1" label="&config..;"/>
|
||||
<radio value="2" label="&config..;"/>
|
||||
<radio value="2" label="&config.jsopen.default;"/>
|
||||
<radio value="0" label="&config.jsopen.forcetab;"/>
|
||||
</radiogroup>
|
||||
</vbox>
|
||||
</groupbox>
|
||||
</prefpane>
|
||||
|
||||
<!--
|
||||
<prefpane id="prefpane-selection-menu" label="&config.tabs.selectionMenu;">
|
||||
<preferences id="prefpane-selection-menu-preferences">
|
||||
<preference id="extensions.treestyletab."
|
||||
@ -48,6 +48,7 @@
|
||||
</vbox>
|
||||
</groupbox>
|
||||
</prefpane>
|
||||
-->
|
||||
|
||||
</prefwindow>
|
||||
|
||||
|
@ -4,7 +4,7 @@ var TreeStyleTabService = {
|
||||
kID : 'treestyletab-id',
|
||||
kCHILDREN : 'treestyletab-children',
|
||||
|
||||
levelMargin : 16,
|
||||
levelMargin : 12,
|
||||
|
||||
NSResolver : {
|
||||
lookupNamespaceURI : function(aPrefix)
|
||||
@ -78,8 +78,26 @@ var TreeStyleTabService = {
|
||||
return (target.localName == 'tab') ? target : null ;
|
||||
},
|
||||
|
||||
getTabFromFrame : function(aFrame, aTabBrowser)
|
||||
{
|
||||
var b = aTabBrowser || this.browser;
|
||||
var docShell = aFrame.top
|
||||
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.getInterface(Components.interfaces.nsIWebNavigation)
|
||||
.QueryInterface(Components.interfaces.nsIDocShell);
|
||||
var tabs = b.mTabContainer.childNodes;
|
||||
for (var i = 0, maxi = tabs.length; i < maxi; i++)
|
||||
{
|
||||
if (tabs[i].linkedBrowser.docShell == docShell)
|
||||
return tabs[i];
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
getTabBrowserFromChildren : function(aTab)
|
||||
{
|
||||
if (!aTab) return null;
|
||||
|
||||
if (aTab.__treestyletab__linkedTabBrowser)
|
||||
return aTab.__treestyletab__linkedTabBrowser;
|
||||
|
||||
@ -180,6 +198,27 @@ var TreeStyleTabService = {
|
||||
this.addPrefListener(this);
|
||||
this.observe(null, 'nsPref:changed', 'extensions.treestyletab.');
|
||||
|
||||
|
||||
eval('window.nsBrowserAccess.prototype.openURI = '+
|
||||
window.nsBrowserAccess.prototype.openURI.toSource().replace(
|
||||
/switch\s*\(aWhere\)/,
|
||||
<><![CDATA[
|
||||
if (aOpener &&
|
||||
aWhere == Components.interfaces.nsIBrowserDOMWindow.OPEN_NEWTAB) {
|
||||
var ownerBrowser = ('SplitBrowser' in window) ? TreeStyleTabService.getTabBrowserFromChildren(SplitBrowser.getSubBrowserAndBrowserFromFrame(aOpener.top).browser) : gBrowser ;
|
||||
var parentTab = TreeStyleTabService.getTabFromFrame(aOpener, ownerBrowser);
|
||||
|
||||
ownerBrowser.__treestyletab__readyToAdoptNewTab = true;
|
||||
ownerBrowser.__treestyletab__parentTab = parentTab.getAttribute(TreeStyleTabService.kID);
|
||||
}
|
||||
switch(aWhere)
|
||||
]]></>
|
||||
)
|
||||
);
|
||||
window.QueryInterface(Components.interfaces.nsIDOMChromeWindow).browserDOMWindow = null;
|
||||
window.QueryInterface(Components.interfaces.nsIDOMChromeWindow).browserDOMWindow = new nsBrowserAccess();
|
||||
|
||||
|
||||
this.initTabBrowser(gBrowser);
|
||||
},
|
||||
|
||||
@ -261,6 +300,8 @@ var TreeStyleTabService = {
|
||||
this.destroyTabBrowser(gBrowser);
|
||||
|
||||
window.removeEventListener('unload', this, false);
|
||||
|
||||
var appcontent = document.getElementById('appcontent');
|
||||
appcontent.removeEventListener('SubBrowserAdded', this, false);
|
||||
appcontent.removeEventListener('SubBrowserRemoveRequest', this, false);
|
||||
|
||||
|
@ -1,2 +1,5 @@
|
||||
pref("browser.link.open_newwindow.restriction", 0);
|
||||
|
||||
|
||||
pref("extensions.treestyletab@piro.sakura.ne.jp.name", "chrome://treestyletab/locale/treestyletab.properties");
|
||||
pref("extensions.treestyletab@piro.sakura.ne.jp.description", "chrome://treestyletab/locale/treestyletab.properties");
|
||||
|
@ -2,3 +2,7 @@
|
||||
|
||||
<!ENTITY config.tabs.general "General">
|
||||
|
||||
<!ENTITY config.jsopen.caption "New Window opened from Scripts in Webpages">
|
||||
<!ENTITY config.jsopen.default "Open as Window when it have special width, height, etc. (default)">
|
||||
<!ENTITY config.jsopen.forcetab "Open as Tab instead of Window anyway">
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
<!ENTITY config.title "ツリー型タブの設定">
|
||||
|
||||
<!ENTITY config.tabs.general "全般">
|
||||
|
||||
<!ENTITY config.jsopen.caption "スクリプトで開かれるウィンドウの制御">
|
||||
<!ENTITY config.jsopen.default "大きさや位置を指定されたウィンドウはウィンドウとして開く(初期値)">
|
||||
<!ENTITY config.jsopen.forcetab "スクリプトで開かれるウィンドウはすべてタブで開く">
|
||||
|
Loading…
x
Reference in New Issue
Block a user