文字列やリンクのタブ上へのドロップの際の挙動を変更できるようにした

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@1267 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2007-10-21 15:02:58 +00:00
parent b9a4e45f68
commit d808aec575
5 changed files with 188 additions and 152 deletions

View File

@ -68,6 +68,9 @@
<preference id="browser.tabs.loadFolderAndReplace" <preference id="browser.tabs.loadFolderAndReplace"
name="browser.tabs.loadFolderAndReplace" name="browser.tabs.loadFolderAndReplace"
type="bool"/> type="bool"/>
<preference id="extensions.treestyletab.loadDroppedLinkToNewChildTab"
name="extensions.treestyletab.loadDroppedLinkToNewChildTab"
type="bool"/>
</preferences> </preferences>
<groupbox> <groupbox>
@ -98,6 +101,15 @@
<radio value="replace" label="&config.openGroupBookmarkAsTabSubTree.replace;"/> <radio value="replace" label="&config.openGroupBookmarkAsTabSubTree.replace;"/>
</radiogroup> </radiogroup>
</groupbox> </groupbox>
<groupbox>
<caption label="&config.loadDroppedLinkToNewChildTab.caption;"/>
<radiogroup id="extensions.treestyletab.loadDroppedLinkToNewChildTab-radiogroup"
preference="extensions.treestyletab.loadDroppedLinkToNewChildTab"
orient="vertical">
<radio value="false" label="&config.loadDroppedLinkToNewChildTab.load;"/>
<radio value="true" label="&config.loadDroppedLinkToNewChildTab.newTab;"/>
</radiogroup>
</groupbox>
</prefpane> </prefpane>
<prefpane id="prefpane-advanced" label="&config.tabs.advanced;"> <prefpane id="prefpane-advanced" label="&config.tabs.advanced;">

View File

@ -304,142 +304,8 @@ var TreeStyleTabService = {
this.addPrefListener(this); this.addPrefListener(this);
this.observe(null, 'nsPref:changed', 'extensions.treestyletab.levelMargin'); this.observe(null, 'nsPref:changed', 'extensions.treestyletab.levelMargin');
eval('nsContextMenu.prototype.openLinkInTab = '+ this.overrideGlobalFunctions();
nsContextMenu.prototype.openLinkInTab.toSource().replace( this.overrideExtensions();
'{',
<><![CDATA[
{
TreeStyleTabService.readyToOpenChildTab(this.target.ownerDocument.defaultView);
]]></>
)
);
eval('nsContextMenu.prototype.openFrameInTab = '+
nsContextMenu.prototype.openFrameInTab.toSource().replace(
'{',
<><![CDATA[
{
TreeStyleTabService.readyToOpenChildTab(this.target.ownerDocument.defaultView);
]]></>
)
);
eval('window.handleLinkClick = '+
window.handleLinkClick.toSource().replace(
/openNewTabWith/g,
<><![CDATA[
TreeStyleTabService.readyToOpenChildTab(event.target.ownerDocument.defaultView);
openNewTabWith]]></>
)
);
eval('window.gotoHistoryIndex = '+
window.gotoHistoryIndex.toSource().replace(
/openUILinkIn/g,
<><![CDATA[
if (where == 'tab' || where == 'tabshifted')
TreeStyleTabService.readyToOpenChildTab();
openUILinkIn]]></>
)
);
eval('window.BrowserForward = '+
window.BrowserForward.toSource().replace(
/openUILinkIn/g,
<><![CDATA[
if (where == 'tab' || where == 'tabshifted')
TreeStyleTabService.readyToOpenChildTab();
openUILinkIn]]></>
)
);
eval('window.BrowserBack = '+
window.BrowserBack.toSource().replace(
/openUILinkIn/g,
<><![CDATA[
if (where == 'tab' || where == 'tabshifted')
TreeStyleTabService.readyToOpenChildTab();
openUILinkIn]]></>
)
);
eval('window.nsBrowserAccess.prototype.openURI = '+
window.nsBrowserAccess.prototype.openURI.toSource().replace(
/switch\s*\(aWhere\)/,
<><![CDATA[
if (aOpener &&
aWhere == Components.interfaces.nsIBrowserDOMWindow.OPEN_NEWTAB) {
TreeStyleTabService.readyToOpenChildTab(aOpener);
}
switch(aWhere)
]]></>
)
);
window.QueryInterface(Components.interfaces.nsIDOMChromeWindow).browserDOMWindow = null;
window.QueryInterface(Components.interfaces.nsIDOMChromeWindow).browserDOMWindow = new nsBrowserAccess();
eval('BookmarksCommand.openGroupBookmark = '+
BookmarksCommand.openGroupBookmark.toSource().replace(
'browser.addTab(uri);',
<><![CDATA[
var openedTab = browser.addTab(uri);
if (!TreeStyleTabService.getPref('browser.tabs.loadFolderAndReplace') &&
TreeStyleTabService.getPref('extensions.treestyletab.openGroupBookmarkAsTabSubTree') &&
!browser.__treestyletab__parentTab) {
TreeStyleTabService.readyToOpenChildTab(openedTab, true);
}
]]></>
).replace(
'if (index == index0)',
<><![CDATA[
TreeStyleTabService.stopToOpenChildTab(browser);
if (index == index0)]]></>
)
);
if ('MultipleTabService' in window) {
eval('MultipleTabService.showHideMenuItems = '+
MultipleTabService.showHideMenuItems.toSource().replace(
/var separators = /,
<><![CDATA[
(function(aPopup) {
var b;
var item;
var tabs;
if (aPopup.id == 'multipletab-selection-menu') {
b = MultipleTabService.browser;
item = document.getElementById(TreeStyleTabService.kMENUITEM_REMOVESUBTREE_SELECTION);
tabs = MultipleTabService.getSelectedTabs();
}
else { // context
b = TreeStyleTabService.getTabBrowserFromChildren(aPopup);
item = TreeStyleTabService.evaluateXPath(
'descendant::xul:menuitem[starts-with(@id, "'+TreeStyleTabService.kMENUITEM_REMOVESUBTREE_CONTEXT+'")]',
aPopup,
XPathResult.FIRST_ORDERED_NODE_TYPE
).singleNodeValue;
tabs = [b.mContextTab];
}
if (item.getAttribute('hidden') == 'true') return;
var hasSubTree = false;
for (var i = 0, maxi = tabs.length; i < maxi; i++)
{
if (!tabs[i].hasAttribute(TreeStyleTabService.kCHILDREN)) continue;
hasSubTree = true;
break;
}
if (hasSubTree)
item.removeAttribute('hidden');
else
item.setAttribute('hidden', true);
})(aPopup);
var separators = ]]></>
)
);
}
this.initTabBrowser(gBrowser); this.initTabBrowser(gBrowser);
}, },
@ -456,7 +322,7 @@ var TreeStyleTabService = {
aTabBrowser.mTabContainer.addEventListener('dblclick', this, true); aTabBrowser.mTabContainer.addEventListener('dblclick', this, true);
aTabBrowser.mTabContainer.addEventListener('mousedown', this, true); aTabBrowser.mTabContainer.addEventListener('mousedown', this, true);
aTabBrowser.mTabContainer.addEventListener('select', this, true); aTabBrowser.mTabContainer.addEventListener('select', this, true);
aTabBrowser.mPanelContainer.addEventListener('click', this, true); // aTabBrowser.mPanelContainer.addEventListener('click', this, true);
aTabBrowser.__treestyletab__levelMargin = -1; aTabBrowser.__treestyletab__levelMargin = -1;
@ -619,7 +485,8 @@ catch(e) {
'var tab = aEvent.target;', 'var tab = aEvent.target;',
<><![CDATA[ <><![CDATA[
var tab = aEvent.target; var tab = aEvent.target;
if (dropActionInfo.position != TreeStyleTabService.kDROP_ON) { if (TreeStyleTabService.getPref('extensions.treestyletab.loadDroppedLinkToNewChildTab') ||
dropActionInfo.position != TreeStyleTabService.kDROP_ON) {
TreeStyleTabService.processDropAction(dropActionInfo, this, this.loadOneTab(getShortcutOrURI(url), null, null, null, bgLoad, false)); TreeStyleTabService.processDropAction(dropActionInfo, this, this.loadOneTab(getShortcutOrURI(url), null, null, null, bgLoad, false));
return; return;
} }
@ -823,6 +690,150 @@ catch(e) {
} }
}, },
overrideGlobalFunctions : function()
{
eval('nsContextMenu.prototype.openLinkInTab = '+
nsContextMenu.prototype.openLinkInTab.toSource().replace(
'{',
<><![CDATA[
{
TreeStyleTabService.readyToOpenChildTab(this.target.ownerDocument.defaultView);
]]></>
)
);
eval('nsContextMenu.prototype.openFrameInTab = '+
nsContextMenu.prototype.openFrameInTab.toSource().replace(
'{',
<><![CDATA[
{
TreeStyleTabService.readyToOpenChildTab(this.target.ownerDocument.defaultView);
]]></>
)
);
eval('window.handleLinkClick = '+
window.handleLinkClick.toSource().replace(
/openNewTabWith/g,
<><![CDATA[
TreeStyleTabService.readyToOpenChildTab(event.target.ownerDocument.defaultView);
openNewTabWith]]></>
)
);
eval('window.gotoHistoryIndex = '+
window.gotoHistoryIndex.toSource().replace(
/openUILinkIn/g,
<><![CDATA[
if (where == 'tab' || where == 'tabshifted')
TreeStyleTabService.readyToOpenChildTab();
openUILinkIn]]></>
)
);
eval('window.BrowserForward = '+
window.BrowserForward.toSource().replace(
/openUILinkIn/g,
<><![CDATA[
if (where == 'tab' || where == 'tabshifted')
TreeStyleTabService.readyToOpenChildTab();
openUILinkIn]]></>
)
);
eval('window.BrowserBack = '+
window.BrowserBack.toSource().replace(
/openUILinkIn/g,
<><![CDATA[
if (where == 'tab' || where == 'tabshifted')
TreeStyleTabService.readyToOpenChildTab();
openUILinkIn]]></>
)
);
eval('window.nsBrowserAccess.prototype.openURI = '+
window.nsBrowserAccess.prototype.openURI.toSource().replace(
/switch\s*\(aWhere\)/,
<><![CDATA[
if (aOpener &&
aWhere == Components.interfaces.nsIBrowserDOMWindow.OPEN_NEWTAB) {
TreeStyleTabService.readyToOpenChildTab(aOpener);
}
switch(aWhere)
]]></>
)
);
window.QueryInterface(Components.interfaces.nsIDOMChromeWindow).browserDOMWindow = null;
window.QueryInterface(Components.interfaces.nsIDOMChromeWindow).browserDOMWindow = new nsBrowserAccess();
eval('BookmarksCommand.openGroupBookmark = '+
BookmarksCommand.openGroupBookmark.toSource().replace(
'browser.addTab(uri);',
<><![CDATA[
var openedTab = browser.addTab(uri);
if (!TreeStyleTabService.getPref('browser.tabs.loadFolderAndReplace') &&
TreeStyleTabService.getPref('extensions.treestyletab.openGroupBookmarkAsTabSubTree') &&
!browser.__treestyletab__parentTab) {
TreeStyleTabService.readyToOpenChildTab(openedTab, true);
}
]]></>
).replace(
'if (index == index0)',
<><![CDATA[
TreeStyleTabService.stopToOpenChildTab(browser);
if (index == index0)]]></>
)
);
},
overrideExtensions : function()
{
if ('MultipleTabService' in window) {
eval('MultipleTabService.showHideMenuItems = '+
MultipleTabService.showHideMenuItems.toSource().replace(
/var separators = /,
<><![CDATA[
(function(aPopup) {
var b;
var item;
var tabs;
if (aPopup.id == 'multipletab-selection-menu') {
b = MultipleTabService.browser;
item = document.getElementById(TreeStyleTabService.kMENUITEM_REMOVESUBTREE_SELECTION);
tabs = MultipleTabService.getSelectedTabs();
}
else { // context
b = TreeStyleTabService.getTabBrowserFromChildren(aPopup);
item = TreeStyleTabService.evaluateXPath(
'descendant::xul:menuitem[starts-with(@id, "'+TreeStyleTabService.kMENUITEM_REMOVESUBTREE_CONTEXT+'")]',
aPopup,
XPathResult.FIRST_ORDERED_NODE_TYPE
).singleNodeValue;
tabs = [b.mContextTab];
}
if (item.getAttribute('hidden') == 'true') return;
var hasSubTree = false;
for (var i = 0, maxi = tabs.length; i < maxi; i++)
{
if (!tabs[i].hasAttribute(TreeStyleTabService.kCHILDREN)) continue;
hasSubTree = true;
break;
}
if (hasSubTree)
item.removeAttribute('hidden');
else
item.setAttribute('hidden', true);
})(aPopup);
var separators = ]]></>
)
);
}
if ('autoHIDE' in window) {
}
},
destroy : function() destroy : function()
{ {
this.destroyTabBrowser(gBrowser); this.destroyTabBrowser(gBrowser);
@ -866,7 +877,7 @@ catch(e) {
aTabBrowser.mTabContainer.removeEventListener('dblclick', this, true); aTabBrowser.mTabContainer.removeEventListener('dblclick', this, true);
aTabBrowser.mTabContainer.removeEventListener('mousedown', this, true); aTabBrowser.mTabContainer.removeEventListener('mousedown', this, true);
aTabBrowser.mTabContainer.removeEventListener('select', this, true); aTabBrowser.mTabContainer.removeEventListener('select', this, true);
aTabBrowser.mPanelContainer.removeEventListener('click', this, true); // aTabBrowser.mPanelContainer.removeEventListener('click', this, true);
}, },
destroyTab : function(aTab, aTabBrowser) destroyTab : function(aTab, aTabBrowser)
@ -901,6 +912,7 @@ catch(e) {
this.onTabClick(aEvent); this.onTabClick(aEvent);
return; return;
} }
/*
var isMiddleClick = ( var isMiddleClick = (
aEvent.button == 1 || aEvent.button == 1 ||
aEvent.button == 0 && (aEvent.ctrlKey || aEvent.metaKey) aEvent.button == 0 && (aEvent.ctrlKey || aEvent.metaKey)
@ -914,6 +926,7 @@ catch(e) {
var b = this.getTabBrowserFromChildren(aEvent.currentTarget); var b = this.getTabBrowserFromChildren(aEvent.currentTarget);
this.readyToOpenChildTab(b.selectedTab); this.readyToOpenChildTab(b.selectedTab);
} }
*/
return; return;
case 'dblclick': case 'dblclick':

View File

@ -1,16 +1,19 @@
pref("extensions.treestyletab.tabbar.width", 200);
pref("extensions.treestyletab.tabbar.position", "left");
pref("extensions.treestyletab.tabbar.scroll.smooth", true);
pref("extensions.treestyletab.tabbar.scroll.timeout", 250);
pref("extensions.treestyletab.tabbar.style", "default");
pref("extensions.treestyletab.levelMargin", 12);
pref("extensions.treestyletab.openGroupBookmarkAsTabSubTree", true);
pref("extensions.treestyletab.loadDroppedLinkToNewChildTab", false);
pref("extensions.treestyletab.autoCollapseExpandSubTreeOnSelect", true); pref("extensions.treestyletab.autoCollapseExpandSubTreeOnSelect", true);
pref("extensions.treestyletab.collapseExpandSubTree.dblclick", false); pref("extensions.treestyletab.collapseExpandSubTree.dblclick", false);
pref("extensions.treestyletab.autoExpandSubTreeOnAppendChild", true); pref("extensions.treestyletab.autoExpandSubTreeOnAppendChild", true);
pref("extensions.treestyletab.attachChildrenToGrandParentOnRemoveTab", true); pref("extensions.treestyletab.attachChildrenToGrandParentOnRemoveTab", true);
// 0 = default, 1 = only visible tabs // 0 = default, 1 = only visible tabs
pref("extensions.treestyletab.focusMode", 1); pref("extensions.treestyletab.focusMode", 1);
pref("extensions.treestyletab.levelMargin", 12);
pref("extensions.treestyletab.tabbar.width", 200);
pref("extensions.treestyletab.tabbar.position", "left");
pref("extensions.treestyletab.tabbar.scroll.smooth", true);
pref("extensions.treestyletab.tabbar.scroll.timeout", 250);
pref("extensions.treestyletab.openGroupBookmarkAsTabSubTree", true);
pref("extensions.treestyletab.tabbar.style", "default");
pref("browser.link.open_newwindow.restriction", 0); pref("browser.link.open_newwindow.restriction", 0);

View File

@ -30,6 +30,10 @@
<!ENTITY config.openGroupBookmarkAsTabSubTree.flat "Open as separate tabs"> <!ENTITY config.openGroupBookmarkAsTabSubTree.flat "Open as separate tabs">
<!ENTITY config.openGroupBookmarkAsTabSubTree.replace "Replace all tabs to the pages in the folder (Firefox default)"> <!ENTITY config.openGroupBookmarkAsTabSubTree.replace "Replace all tabs to the pages in the folder (Firefox default)">
<!ENTITY config.loadDroppedLinkToNewChildTab.caption "Action for drag drop of links or URLs to existing tab">
<!ENTITY config.loadDroppedLinkToNewChildTab.load "Load link into the tab (Firefox default)">
<!ENTITY config.loadDroppedLinkToNewChildTab.newTab "Open link in a new child tab of the tab">
<!ENTITY config.tabs.advanced "Advanced"> <!ENTITY config.tabs.advanced "Advanced">

View File

@ -30,6 +30,10 @@
<!ENTITY config.openGroupBookmarkAsTabSubTree.flat "ばらばらのタブとして開く"> <!ENTITY config.openGroupBookmarkAsTabSubTree.flat "ばらばらのタブとして開く">
<!ENTITY config.openGroupBookmarkAsTabSubTree.replace "現在開いているすべてのタブをブックマークの内容で置き換えるFirefox初期状態"> <!ENTITY config.openGroupBookmarkAsTabSubTree.replace "現在開いているすべてのタブをブックマークの内容で置き換えるFirefox初期状態">
<!ENTITY config.loadDroppedLinkToNewChildTab.caption "リンクやURLをタブにドラッグドロップした時">
<!ENTITY config.loadDroppedLinkToNewChildTab.load "ドロップ先のタブの中に読み込むFirefox初期状態">
<!ENTITY config.loadDroppedLinkToNewChildTab.newTab "ドロップ先のタブのサブツリーに新しいタブを開く">
<!ENTITY config.tabs.advanced "詳細"> <!ENTITY config.tabs.advanced "詳細">