1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-04-04 23:23:32 +02:00

Merge pull request #128 from ntnn/treestyletabs.js

Treestyletabs.js
This commit is contained in:
dkearns
2016-01-09 16:04:26 +11:00

View File

@@ -27,17 +27,24 @@ var INFO = [
// pass true to close, false to open // pass true to close, false to open
function fold_collapse_expand_target(tab, collapse, children = false) { function fold_collapse_expand_target(tab, collapse, children = false) {
if (children) { if (children) {
let childs = TreeStyleTabService.getDescendantTabs(tab); let children = TreeStyleTabService.getDescendantTabs(tab);
for (let x in childs) { for (let x in children) {
gBrowser.treeStyleTab.collapseExpandSubtree(childs[x], collapse); gBrowser.treeStyleTab.collapseExpandSubtree(children[x], collapse);
} }
} }
gBrowser.treeStyleTab.collapseExpandSubtree(tab, collapse); gBrowser.treeStyleTab.collapseExpandSubtree(tab, collapse);
} }
function fold_collapse_expand(collapse, children = false) { function fold_collapse_expand(collapse, children = false) {
let tab = gBrowser.tabContainer.selectedItem;
if (!TreeStyleTabService.hasChildTabs(tab)) {
let tab = TreeStyleTabService.getParentTab(tab);
collapse = TreeStyleTabService.isSubtreeCollapsed(tab);
}
fold_collapse_expand_target( fold_collapse_expand_target(
gBrowser.tabContainer.selectedItem, tab,
collapse, collapse,
children children
); );
@@ -50,8 +57,8 @@ function fold_collapse_expand_toggle(children = false) {
); );
} }
function create_command_and_mapping(command, description, funcref, mapping) { function create_command_and_mapping(command, description, funcref, mapping, command_option = {}) {
group.commands.add([command], description, funcref, {}, true ); group.commands.add([command], description, funcref, command_option, true );
if (mapping != "") if (mapping != "")
group.mappings.add([modes.NORMAL], [mapping], description, funcref); group.mappings.add([modes.NORMAL], [mapping], description, funcref);
} }
@@ -156,8 +163,58 @@ create_command_and_mapping(
"tabchildopen", "tabchildopen",
"Open one or more URLs in a new child tab", "Open one or more URLs in a new child tab",
function (args) { function (args) {
TreeStyleTabService.readyToOpenChildTab(); let tab = gBrowser.tabContainer.selectedItem;
dactyl.open(args, { where: dactyl.NEW_TAB }); TreeStyleTabService.readyToOpenChildTab(tab, true);
dactyl.open(args[0] || "about:blank",
{ from: "tabopen", where: dactyl.NEW_TAB, background: args.bang });
TreeStyleTabService.stopToOpenChildTab();
},
"",
{
bang: true,
completer: function (context) {
completion.url(context);
},
domains: function (args) {
return commands.get("open").domains(args);
},
literal: 0,
privateData: true
}
);
create_command_and_mapping(
"tabbartoggle",
"Toggle tab bar",
function () {
gBrowser.treeStyleTab.tabbarShown=!gBrowser.treeStyleTab.tabbarShown;
}, },
"" ""
); );
create_command_and_mapping(
"tabclosechildren",
"Close children of current tab",
function () {
let tab = gBrowser.tabContainer.selectedItem;
let children = TreeStyleTabService.getDescendantTabs(tab);
for (let child in children) {
config.removeTab(children[child]);
}
},
""
)
create_command_and_mapping(
"tabclosewithchildren",
"Close children and current tab",
function () {
let tab = gBrowser.tabContainer.selectedItem;
let children = TreeStyleTabService.getDescendantTabs(tab);
for (let child in children) {
config.removeTab(children[child]);
}
config.removeTab(tab);
},
""
)