サブツリーをまとめてブックマークする機能を追加
git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@3117 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
parent
e76b527acd
commit
4cb16dae24
@ -174,6 +174,9 @@
|
||||
<preference id="extensions.treestyletab.show.context-menu-tabbarPosition"
|
||||
name="extensions.treestyletab.show.context-menu-tabbarPosition"
|
||||
type="bool"/>
|
||||
<preference id="extensions.treestyletab.show.context-item-bookmarkTabSubTree"
|
||||
name="extensions.treestyletab.show.context-item-bookmarkTabSubTree"
|
||||
type="bool"/>
|
||||
</preferences>
|
||||
|
||||
<vbox>
|
||||
@ -207,6 +210,11 @@
|
||||
preference="extensions.treestyletab.show.context-menu-tabbarPosition"
|
||||
label="&context.tabbarPosition.label;"/>
|
||||
</hbox>
|
||||
<hbox align="center">
|
||||
<checkbox id="extensions.treestyletab.show.context-item-bookmarkTabSubTree-check"
|
||||
preference="extensions.treestyletab.show.context-item-bookmarkTabSubTree"
|
||||
label="&context.bookmarkTabSubTree.label;"/>
|
||||
</hbox>
|
||||
</groupbox>
|
||||
<checkbox id="extensions.treestyletab.show.openSelectionLinks-check"
|
||||
preference="extensions.treestyletab.show.openSelectionLinks"
|
||||
|
@ -1360,7 +1360,7 @@ catch(e) {
|
||||
));
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
destroy : function()
|
||||
{
|
||||
window.removeEventListener('unload', this, false);
|
||||
@ -1564,7 +1564,7 @@ catch(e) {
|
||||
}
|
||||
},
|
||||
|
||||
showHideRemoveSubTreeMenuItem : function(aMenuItem, aTabs)
|
||||
showHideSubTreeMenuItem : function(aMenuItem, aTabs)
|
||||
{
|
||||
if (!aMenuItem ||
|
||||
aMenuItem.getAttribute('hidden') == 'true' ||
|
||||
@ -1586,7 +1586,7 @@ catch(e) {
|
||||
},
|
||||
|
||||
/* Commands */
|
||||
|
||||
|
||||
removeTabSubTree : function(aTabOrTabs, aOnlyChildren)
|
||||
{
|
||||
var tabs = aTabOrTabs;
|
||||
@ -1624,7 +1624,7 @@ catch(e) {
|
||||
b.removeTab(tabs[i]);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
cleanUpTabsArray : function(aTabs)
|
||||
{
|
||||
var b = this.getTabBrowserFromChild(aTabs[0]);
|
||||
@ -1641,6 +1641,81 @@ catch(e) {
|
||||
return aTabs;
|
||||
},
|
||||
|
||||
bookmarkTabSubTree : function(aTabOrTabs)
|
||||
{
|
||||
var tabs = aTabOrTabs;
|
||||
if (!(tabs instanceof Array)) {
|
||||
tabs = [aTabOrTabs];
|
||||
}
|
||||
|
||||
var b = this.getTabBrowserFromChild(tabs[0]);
|
||||
var bookmarkedTabs = [];
|
||||
for (var i = 0, maxi = tabs.length; i < maxi; i++)
|
||||
{
|
||||
bookmarkedTabs.push(tabs[i]);
|
||||
bookmarkedTabs = bookmarkedTabs.concat(b.treeStyleTab.getDescendantTabs(tabs[i]));
|
||||
}
|
||||
|
||||
if ('MultipleTabService' in window &&
|
||||
'addBookmarkFor' in MultipleTabService) {
|
||||
MultipleTabService.addBookmarkFor(bookmarkedTabs);
|
||||
}
|
||||
|
||||
this._addBookmarkFor(bookmarkedTabs);
|
||||
},
|
||||
|
||||
_addBookmarkFor : function(aTabs) // from Multiple Tab Handler
|
||||
{
|
||||
if (!aTabs) return;
|
||||
|
||||
var b = this.getTabBrowserFromChild(aTabs[0]);
|
||||
|
||||
if ('PlacesUIUtils' in window || 'PlacesUtils' in window) { // Firefox 3
|
||||
var utils = 'PlacesUIUtils' in window ? PlacesUIUtils : PlacesUtils ;
|
||||
utils.showMinimalAddMultiBookmarkUI(Array.slice(aTabs).map(function(aTab) {
|
||||
return aTab.linkedBrowser.currentURI;
|
||||
}));
|
||||
return;
|
||||
}
|
||||
|
||||
var currentTabInfo;
|
||||
var tabsInfo = Array.slice(aTabs).map(function(aTab) {
|
||||
var webNav = aTab.linkedBrowser.webNavigation;
|
||||
var url = webNav.currentURI.spec;
|
||||
var name = '';
|
||||
var charSet, description;
|
||||
try {
|
||||
var doc = webNav.document;
|
||||
name = doc.title || url;
|
||||
charSet = doc.characterSet;
|
||||
description = BookmarksUtils.getDescriptionFromDocument(doc);
|
||||
}
|
||||
catch (e) {
|
||||
name = url;
|
||||
}
|
||||
return {
|
||||
name : name,
|
||||
url : url,
|
||||
charset : charSet,
|
||||
description : description
|
||||
};
|
||||
});
|
||||
|
||||
window.openDialog(
|
||||
'chrome://browser/content/bookmarks/addBookmark2.xul',
|
||||
'',
|
||||
BROWSER_ADD_BM_FEATURES,
|
||||
(aTabs.length == 1 ?
|
||||
tabsInfo[0] :
|
||||
{
|
||||
name : gNavigatorBundle.getString('bookmarkAllTabsDefault'),
|
||||
bBookmarkAllTabs : true,
|
||||
objGroup : tabsInfo
|
||||
}
|
||||
)
|
||||
);
|
||||
},
|
||||
|
||||
openSelectionLinks : function()
|
||||
{
|
||||
var links = this.getSelectionLinks();
|
||||
|
@ -88,6 +88,12 @@
|
||||
type="radio" value="bottom"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
|
||||
|
||||
<menuitem id="context-item-bookmarkTabSubTree"
|
||||
label="&context.bookmarkTabSubTree.label;"
|
||||
accesskey="&context.bookmarkTabSubTree.accesskey;"
|
||||
oncommand="TreeStyleTabService.bookmarkTabSubTree(TreeStyleTabService.getTabBrowserFromChild(this).mContextTab);"/>
|
||||
</data>
|
||||
</window>
|
||||
|
||||
|
@ -18,6 +18,7 @@ TreeStyleTabBrowser.prototype = {
|
||||
kMENUITEM_AUTOHIDE : 'context-item-toggleAutoHide',
|
||||
kMENUITEM_FIXED : 'context-item-toggleFixed',
|
||||
kMENUITEM_POSITION : 'context-menu-tabbarPosition',
|
||||
kMENUITEM_BOOKMARKSUBTREE : 'context-item-bookmarkTabSubTree',
|
||||
|
||||
mTabBrowser : null,
|
||||
|
||||
@ -445,6 +446,14 @@ TreeStyleTabBrowser.prototype = {
|
||||
item.setAttribute('id', item.getAttribute('id')+suffix);
|
||||
tabContext.appendChild(item);
|
||||
});
|
||||
|
||||
var item = document.getElementById(aSelf.kMENUITEM_BOOKMARKSUBTREE).cloneNode(true);
|
||||
item.setAttribute('id', item.getAttribute('id')+suffix);
|
||||
var refNodes = tabContext.getElementsByAttribute('command', 'Browser:BookmarkAllTabs');
|
||||
if (refNodes && refNodes.length)
|
||||
tabContext.insertBefore(item, refNodes[0].nextSibling || refNodes[0]);
|
||||
else
|
||||
tabContext.appendChild(item);
|
||||
}, 0, this);
|
||||
|
||||
var allTabPopup = document.getAnonymousElementByAttribute(b.mTabContainer, 'anonid', 'alltabs-popup');
|
||||
@ -1662,7 +1671,7 @@ TreeStyleTabBrowser.prototype = {
|
||||
item.removeAttribute('hidden');
|
||||
else
|
||||
item.setAttribute('hidden', true);
|
||||
this.showHideRemoveSubTreeMenuItem(item, [b.mContextTab]);
|
||||
this.showHideSubTreeMenuItem(item, [b.mContextTab]);
|
||||
|
||||
item = this.evaluateXPath(
|
||||
'descendant::xul:menuitem[starts-with(@id, "'+this.kMENUITEM_REMOVECHILDREN+'")]',
|
||||
@ -1673,7 +1682,7 @@ TreeStyleTabBrowser.prototype = {
|
||||
item.removeAttribute('hidden');
|
||||
else
|
||||
item.setAttribute('hidden', true);
|
||||
this.showHideRemoveSubTreeMenuItem(item, [b.mContextTab]);
|
||||
this.showHideSubTreeMenuItem(item, [b.mContextTab]);
|
||||
|
||||
// collapse/expand all
|
||||
sep = this.evaluateXPath(
|
||||
@ -1803,6 +1812,18 @@ TreeStyleTabBrowser.prototype = {
|
||||
else {
|
||||
sep.setAttribute('hidden', true);
|
||||
}
|
||||
|
||||
// bookmark
|
||||
item = this.evaluateXPath(
|
||||
'descendant::xul:menuitem[starts-with(@id, "'+this.kMENUITEM_BOOKMARKSUBTREE+'")]',
|
||||
aEvent.currentTarget,
|
||||
XPathResult.FIRST_ORDERED_NODE_TYPE
|
||||
).singleNodeValue;
|
||||
if (this.getTreePref('show.'+this.kMENUITEM_BOOKMARKSUBTREE))
|
||||
item.removeAttribute('hidden');
|
||||
else
|
||||
item.setAttribute('hidden', true);
|
||||
this.showHideSubTreeMenuItem(item, [b.mContextTab]);
|
||||
},
|
||||
|
||||
initAllTabsPopup : function(aEvent)
|
||||
|
@ -47,6 +47,7 @@ pref("extensions.treestyletab.show.context-item-expandAllSubtree", true);
|
||||
pref("extensions.treestyletab.show.context-item-toggleAutoHide", true);
|
||||
pref("extensions.treestyletab.show.context-item-toggleFixed", true);
|
||||
pref("extensions.treestyletab.show.context-menu-tabbarPosition", true);
|
||||
pref("extensions.treestyletab.show.context-item-bookmarkTabSubTree", true);
|
||||
|
||||
pref("extensions.treestyletab.openOuterLinkInNewTab", false);
|
||||
pref("extensions.treestyletab.openAnyLinkInNewTab", false);
|
||||
|
@ -135,3 +135,5 @@
|
||||
<!ENTITY context.toggleFixed.accesskey "f">
|
||||
<!ENTITY context.tabbarPosition.label "Position">
|
||||
<!ENTITY context.tabbarPosition.accesskey "p">
|
||||
<!ENTITY context.bookmarkTabSubTree.label "Bookmark this Tree...">
|
||||
<!ENTITY context.bookmarkTabSubTree.accesskey "t">
|
||||
|
@ -135,3 +135,5 @@
|
||||
<!ENTITY context.toggleFixed.accesskey "f">
|
||||
<!ENTITY context.tabbarPosition.label "Position">
|
||||
<!ENTITY context.tabbarPosition.accesskey "p">
|
||||
<!ENTITY context.bookmarkTabSubTree.label "Bookmark this Tree...">
|
||||
<!ENTITY context.bookmarkTabSubTree.accesskey "t">
|
||||
|
@ -135,3 +135,5 @@
|
||||
<!ENTITY context.toggleFixed.accesskey "f">
|
||||
<!ENTITY context.tabbarPosition.label "Posición">
|
||||
<!ENTITY context.tabbarPosition.accesskey "p">
|
||||
<!ENTITY context.bookmarkTabSubTree.label "Bookmark this Tree...">
|
||||
<!ENTITY context.bookmarkTabSubTree.accesskey "t">
|
||||
|
@ -135,3 +135,5 @@
|
||||
<!ENTITY context.toggleFixed.accesskey "h">
|
||||
<!ENTITY context.tabbarPosition.label "Posiziona">
|
||||
<!ENTITY context.tabbarPosition.accesskey "p">
|
||||
<!ENTITY context.bookmarkTabSubTree.label "Bookmark this Tree...">
|
||||
<!ENTITY context.bookmarkTabSubTree.accesskey "t">
|
||||
|
@ -133,3 +133,5 @@
|
||||
<!ENTITY context.toggleFixed.accesskey "f">
|
||||
<!ENTITY context.tabbarPosition.label "タブバーの位置">
|
||||
<!ENTITY context.tabbarPosition.accesskey "p">
|
||||
<!ENTITY context.bookmarkTabSubTree.label "このサブツリーをブックマーク...">
|
||||
<!ENTITY context.bookmarkTabSubTree.accesskey "t">
|
||||
|
@ -135,3 +135,5 @@
|
||||
<!ENTITY context.toggleFixed.accesskey "f">
|
||||
<!ENTITY context.tabbarPosition.label "位置">
|
||||
<!ENTITY context.tabbarPosition.accesskey "p">
|
||||
<!ENTITY context.bookmarkTabSubTree.label "Bookmark this Tree...">
|
||||
<!ENTITY context.bookmarkTabSubTree.accesskey "t">
|
||||
|
@ -130,3 +130,5 @@
|
||||
<!ENTITY context.toggleFixed.accesskey "f">
|
||||
<!ENTITY context.tabbarPosition.label "分頁工具列的位置">
|
||||
<!ENTITY context.tabbarPosition.accesskey "p">
|
||||
<!ENTITY context.bookmarkTabSubTree.label "Bookmark this Tree...">
|
||||
<!ENTITY context.bookmarkTabSubTree.accesskey "t">
|
||||
|
Loading…
x
Reference in New Issue
Block a user