1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 17:47:59 +01:00

Cleanup liberator.open a bit; could probably use a bit more.

This commit is contained in:
Kris Maglione
2009-10-31 17:28:35 -04:00
parent 83ef6a7a93
commit d880d4afcb
5 changed files with 26 additions and 22 deletions

View File

@@ -78,12 +78,11 @@ release: $(XPI) $(RDF)
# This is not for you!
dist: $(XPI)
@echo DIST $(XPI) $(GOOGLE)
[ -n "$(featured)" ] && labels="$$labels,Featured"; \
proj=$$(echo -n $(NAME) | sed 's/\(.\).*/\1/' | tr a-z A-Z); \
proj="$$proj$$(echo $(NAME) | sed 's/.//')"; \
[ -z "$$summary" ] && summary="$$proj $(VERSION) Release"; \
\
labels=$$(echo -n "$$labels,Project-$$proj" | sed 's/^,*//g'); \
labels="Project-$$proj,$(labels)"; \
[ -n "$(featured)" ] && labels="$$labels,Featured"; \
\
IFS=,; for l in $$(echo $$labels); do \
set -- "$$@" --form-string "label=$$l"; \

View File

@@ -166,8 +166,7 @@ function Browser() //{{{
function ()
{
let homepages = gHomeButton.getHomePage();
liberator.open(homepages, /\bhomepage\b/.test(options["activate"]) ?
liberator.NEW_TAB : liberator.NEW_BACKGROUND_TAB);
liberator.open(homepages, { from: "homepage", where: liberator.NEW_TAB });
});
mappings.add([modes.NORMAL], ["gu"],

View File

@@ -427,7 +427,7 @@ function Buffer() //{{{
{
let url = util.readFromClipboard();
if (url)
liberator.open(url, options.get("activate").has("paste") ? liberator.NEW_TAB : liberator.NEW_BACKGROUND_TAB);
liberator.open(url, { from: "activate", where: liberator.NEW_TAB });
else
liberator.beep();
});

View File

@@ -1562,7 +1562,7 @@ const liberator = (function () //{{{
* tabs.
* @returns {boolean}
*/
open: function (urls, where, force)
open: function (urls, params, force)
{
// convert the string to an array of converted URLs
// -> see util.stringToURLArray for more details
@@ -1587,22 +1587,31 @@ const liberator = (function () //{{{
commandline.input("This will open " + urls.length + " new tabs. Would you like to continue? (yes/[no]) ",
function (resp) {
if (resp && resp.match(/^y(es)?$/i))
liberator.open(urls, where, true);
liberator.open(urls, params, true);
});
return true;
}
let flags = 0;
if (where && !(where instanceof Array))
{
if (params instanceof Array)
params = { where: params };
for (let [opt, flag] in Iterator({ replace: "REPLACE_HISTORY", hide: "BYPASS_HISTORY" }))
if (where[opt])
if (params[opt])
flags |= Ci.nsIWebNavigation["LOAD_FLAGS_" + flag];
if ("from" in where)
where = (options["newtab"] && options.get("newtab").has("all", where.from))
? liberator.NEW_TAB : liberator.CURRENT_TAB;
else
where = where.where || liberator.CURRENT_TAB;
let where = params.where || liberator.CURRENT_TAB;
if ("from" in params && liberator.has("tabs"))
{
if (!('where' in params) && options.get("newtab").has("all", params.from))
where = liberator.NEW_BACKGROUND_TAB;
if (options.get("activate").has("all", params.from))
{
if (where == liberator.NEW_TAB)
where = liberator.NEW_BACKGROUND_TAB;
else if (where == liberator.NEW_BACKGROUND_TAB)
where = liberator.NEW_TAB;
}
}
if (urls.length == 0)

View File

@@ -551,13 +551,10 @@ function Tabs() //{{{
args = args.string;
let where = special ? liberator.NEW_TAB : liberator.NEW_BACKGROUND_TAB;
if (/\btabopen\b/.test(options["activate"]))
where = special ? liberator.NEW_BACKGROUND_TAB : liberator.NEW_TAB;
if (args)
liberator.open(args, where);
liberator.open(args, { from: "tabopen", where: where });
else
liberator.open("about:blank", where);
liberator.open("about:blank", { from: "tabopen", where: where });
},
{
bang: true,