mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-21 10:37:59 +01:00
Reset progress indicator on location change.
This commit is contained in:
@@ -252,7 +252,7 @@ var AutoCommands = Module("autocommands", {
|
||||
"List of autocommand event names which should be ignored",
|
||||
"stringlist", "",
|
||||
{
|
||||
completer: function () Iterator(update({ all: "All Events" }, config.autocommands)),
|
||||
values: iter(update({ all: "All Events" }, config.autocommands)).toArray(),
|
||||
has: Option.has.toggleAll
|
||||
});
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ var Buffer = Module("buffer", {
|
||||
// This fires when the load event is initiated
|
||||
// only thrown for the current tab, not when another tab changes
|
||||
if (flags & Ci.nsIWebProgressListener.STATE_START) {
|
||||
statusline.updateProgress(0);
|
||||
statusline.progress = 0;
|
||||
|
||||
buffer._triggerLoadAutocmd("PageLoadPre", webProgress.DOMWindow.document);
|
||||
|
||||
@@ -307,7 +307,9 @@ var Buffer = Module("buffer", {
|
||||
},
|
||||
onProgressChange: function onProgressChange(webProgress, request, curSelfProgress, maxSelfProgress, curTotalProgress, maxTotalProgress) {
|
||||
onProgressChange.superapply(this, arguments);
|
||||
statusline.updateProgress(curTotalProgress / maxTotalProgress);
|
||||
if (webProgress.DOMWindow)
|
||||
webProgress.DOMWindow.dactylProgress = curTotalProgress / maxTotalProgress;
|
||||
statusline.progress = curTotalProgress / maxTotalProgress;
|
||||
},
|
||||
// happens when the users switches tabs
|
||||
onLocationChange: function onLocationChange(webProgress, request, uri) {
|
||||
@@ -316,10 +318,11 @@ var Buffer = Module("buffer", {
|
||||
delete mappings.hives;
|
||||
|
||||
statusline.updateUrl();
|
||||
statusline.progress = "";
|
||||
|
||||
let win = webProgress.DOMWindow;
|
||||
if (win && uri) {
|
||||
statusline.updateProgress(win);
|
||||
statusline.progress = win.dactylProgress;
|
||||
|
||||
let oldURI = webProgress.document.dactylURI;
|
||||
if (webProgress.document.dactylLoadIdx === webProgress.loadedTransIndex
|
||||
@@ -1924,7 +1927,7 @@ var Buffer = Module("buffer", {
|
||||
options.add(["pageinfo", "pa"],
|
||||
"Define which sections are shown by the :pageinfo command",
|
||||
"charlist", "gfm",
|
||||
{ completer: function (context) [[k, v[1]] for ([k, v] in Iterator(buffer.pageInfo))] });
|
||||
{ get values() [[k, v[1]] for ([k, v] in Iterator(buffer.pageInfo))] });
|
||||
|
||||
options.add(["scroll", "scr"],
|
||||
"Number of lines to scroll with <C-u> and <C-d> commands",
|
||||
@@ -1935,7 +1938,7 @@ var Buffer = Module("buffer", {
|
||||
"Where to show the destination of the link under the cursor",
|
||||
"string", "status",
|
||||
{
|
||||
completer: function (context) [
|
||||
values: [
|
||||
["", "Don't show link destinations"],
|
||||
["status", "Show link destinations in the status line"],
|
||||
["command", "Show link destinations in the command line"]
|
||||
|
||||
@@ -1559,8 +1559,8 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
"r" + [k for ([k, v] in iter(groups[1].opts))
|
||||
if (!document.getElementById(v[1][0]).collapsed)].join(""),
|
||||
|
||||
completer: function (context)
|
||||
array(groups).map(function (g) [[k, v[0]] for ([k, v] in Iterator(g.opts))]).flatten(),
|
||||
values: array(groups).map(function (g) [[k, v[0]] for ([k, v] in Iterator(g.opts))]).flatten(),
|
||||
|
||||
setter: function (value) {
|
||||
for (let group in values(groups))
|
||||
group.setter(value);
|
||||
|
||||
@@ -1181,7 +1181,7 @@ var Hints = Module("hints", {
|
||||
"The keys used to label and select hints",
|
||||
"string", "0123456789",
|
||||
{
|
||||
completer: function () [
|
||||
values: [
|
||||
["0123456789", "Numbers"],
|
||||
["asdfg;lkjh", "Home Row"]],
|
||||
validator: function (value) {
|
||||
@@ -1202,7 +1202,7 @@ var Hints = Module("hints", {
|
||||
"Change the behavior of <Return> in hint mode",
|
||||
"number", 0,
|
||||
{
|
||||
completer: function () [
|
||||
values: [
|
||||
["0", "Follow the first hint as soon as typed text uniquely identifies it. Follow the selected hint on <Return>."],
|
||||
["1", "Follow the selected hint on <Return>."],
|
||||
["2", "Follow the selected hint on <Return> only it's been <Tab>-selected."]
|
||||
@@ -1213,7 +1213,7 @@ var Hints = Module("hints", {
|
||||
"How hints are filtered",
|
||||
"stringlist", "contains",
|
||||
{
|
||||
completer: function (context) [
|
||||
values: [
|
||||
["contains", "The typed characters are split on whitespace. The resulting groups must all appear in the hint."],
|
||||
["custom", "Delegate to a custom function: dactyl.plugins.customHintMatcher(hintString)"],
|
||||
["firstletters", "Behaves like wordstartswith, but all groups must match a sequence of words."],
|
||||
@@ -1233,7 +1233,7 @@ var Hints = Module("hints", {
|
||||
"Which text is used to filter hints for input elements",
|
||||
"stringlist", "label,value",
|
||||
{
|
||||
completer: function (context) [
|
||||
values: [
|
||||
["value", "Match against the value of the input field"],
|
||||
["label", "Match against the text of a label for the input field, if one can be found"],
|
||||
["name", "Match against the name of the input field"]
|
||||
|
||||
@@ -163,10 +163,6 @@ var Option = Class("Option", {
|
||||
setValues: deprecated("Option#set", "set"),
|
||||
joinValues: deprecated("Option#stringify", "stringify"),
|
||||
parseValues: deprecated("Option#parse", "parse"),
|
||||
values: deprecated("Option#value", {
|
||||
get: function values() this.value,
|
||||
set: function values(val) this.value = val
|
||||
}),
|
||||
|
||||
/**
|
||||
* @property {value} The option's current value. The option's local value,
|
||||
@@ -283,7 +279,16 @@ var Option = Class("Option", {
|
||||
* @property {function(CompletionContext, Args)} This option's completer.
|
||||
* @see CompletionContext
|
||||
*/
|
||||
completer: null,
|
||||
completer: function (context) {
|
||||
if (this.values)
|
||||
context.completions = this.values;
|
||||
},
|
||||
|
||||
/**
|
||||
* @property {[[string, string]]} This option's possible values.
|
||||
* @see CompletionContext
|
||||
*/
|
||||
values: null,
|
||||
|
||||
/**
|
||||
* @property {function(host, values)} A function which should return a list
|
||||
@@ -340,7 +345,7 @@ var Option = Class("Option", {
|
||||
* when set.
|
||||
*/
|
||||
validator: function () {
|
||||
if (this.completer)
|
||||
if (this.values || this.completer !== Option.prototype.completer)
|
||||
return Option.validateCompleter.apply(this, arguments);
|
||||
return true;
|
||||
},
|
||||
@@ -601,13 +606,17 @@ var Option = Class("Option", {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
validateCompleter: function (values) {
|
||||
if (this.values)
|
||||
var acceptable = this.values;
|
||||
else {
|
||||
let context = CompletionContext("");
|
||||
let res = context.fork("", 0, this, this.completer);
|
||||
if (!res)
|
||||
res = context.allItems.items.map(function (item) [item.text]);
|
||||
acceptable = context.fork("", 0, this, this.completer);
|
||||
if (!acceptable)
|
||||
acceptable = context.allItems.items.map(function (item) [item.text]);
|
||||
}
|
||||
if (this.type == "regexpmap")
|
||||
return Array.concat(values).every(function (re) res.some(function (item) item[0] == re.result));
|
||||
return Array.concat(values).every(function (value) res.some(function (item) item[0] == value));
|
||||
return Array.concat(values).every(function (re) acceptable.some(function (item) item[0] == re.result));
|
||||
return Array.concat(values).every(function (value) acceptable.some(function (item) item[0] == value));
|
||||
},
|
||||
|
||||
validateXPath: function (values) {
|
||||
|
||||
@@ -979,7 +979,7 @@ var Tabs = Module("tabs", {
|
||||
config.tabbrowser.tabContainer._positionPinnedTabs();
|
||||
return value;
|
||||
},
|
||||
completer: function (context) [
|
||||
values: [
|
||||
["never", "Never show the tab bar"],
|
||||
["multitab", "Show the tab bar when there are multiple tabs"],
|
||||
["always", "Always show the tab bar"]
|
||||
@@ -1005,7 +1005,7 @@ var Tabs = Module("tabs", {
|
||||
"Define when newly created tabs are automatically activated",
|
||||
"stringlist", [g[0] for (g in values(activateGroups.slice(1))) if (!g[2] || !prefs.get("browser.tabs." + g[2]))].join(","),
|
||||
{
|
||||
completer: function (context) activateGroups,
|
||||
values: activateGroups,
|
||||
has: Option.has.toggleAll,
|
||||
setter: function (newValues) {
|
||||
let valueSet = set(newValues);
|
||||
@@ -1022,7 +1022,7 @@ var Tabs = Module("tabs", {
|
||||
"Define which commands should output in a new tab by default",
|
||||
"stringlist", "",
|
||||
{
|
||||
completer: function (context) [
|
||||
values: [
|
||||
["all", "All commands"],
|
||||
["addons", ":addo[ns] command"],
|
||||
["downloads", ":downl[oads] command"],
|
||||
@@ -1056,7 +1056,7 @@ var Tabs = Module("tabs", {
|
||||
"See 'popups' option.");
|
||||
return values;
|
||||
},
|
||||
completer: function (context) [
|
||||
values: [
|
||||
["tab", "Open popups in a new tab"],
|
||||
["window", "Open popups in a new window"],
|
||||
["resized", "Open resized popups in a new window"]
|
||||
|
||||
@@ -1015,7 +1015,7 @@ var Completion = Module("completion", {
|
||||
options: function (dactyl, modules, window) {
|
||||
const { completion, options } = modules;
|
||||
let wildmode = {
|
||||
completer: function (context) [
|
||||
values: [
|
||||
// Why do we need ""?
|
||||
// Because its description is useful during completion. --Kris
|
||||
["", "Complete only the first match"],
|
||||
@@ -1047,7 +1047,7 @@ var Completion = Module("completion", {
|
||||
options.add(["complete", "cpt"],
|
||||
"Items which are completed at the :open prompts",
|
||||
"charlist", config.defaults.complete == null ? "slf" : config.defaults.complete,
|
||||
{ completer: function (context) values(completion.urlCompleters) });
|
||||
{ get values() values(completion.urlCompleters) });
|
||||
|
||||
options.add(["wildanchor", "wia"],
|
||||
"Define which completion groups only match at the beginning of their text",
|
||||
@@ -1057,7 +1057,7 @@ var Completion = Module("completion", {
|
||||
"Completion case matching mode",
|
||||
"regexpmap", ".?:smart",
|
||||
{
|
||||
completer: function () [
|
||||
values: [
|
||||
["smart", "Case is significant when capital letters are typed"],
|
||||
["match", "Case is always significant"],
|
||||
["ignore", "Case is never significant"]
|
||||
|
||||
@@ -262,7 +262,7 @@ var RangeFinder = Module("rangefinder", {
|
||||
"Find case matching mode",
|
||||
"string", "smart",
|
||||
{
|
||||
completer: function () [
|
||||
values: [
|
||||
["smart", "Case is significant when capital letters are typed"],
|
||||
["match", "Case is always significant"],
|
||||
["ignore", "Case is never significant"]
|
||||
|
||||
@@ -562,7 +562,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
|
||||
"The default list of private items to sanitize",
|
||||
"stringlist", "all",
|
||||
{
|
||||
completer: function (value) values(sanitizer.itemMap),
|
||||
get values() values(sanitizer.itemMap),
|
||||
has: modules.Option.has.toggleAll,
|
||||
validator: function (values) values.length &&
|
||||
values.every(function (val) val === "all" || set.has(sanitizer.itemMap, val))
|
||||
@@ -573,7 +573,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
|
||||
"stringlist", "",
|
||||
{
|
||||
initialValue: true,
|
||||
completer: function () [i for (i in values(sanitizer.itemMap)) if (i.persistent || i.builtin)],
|
||||
get values() [i for (i in values(sanitizer.itemMap)) if (i.persistent || i.builtin)],
|
||||
getter: function () !sanitizer.runAtShutdown ? [] : [
|
||||
item.name for (item in values(sanitizer.itemMap))
|
||||
if (item.shouldSanitize(true))
|
||||
@@ -598,36 +598,37 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
|
||||
{
|
||||
completer: function (context) {
|
||||
context.compare = context.constructor.Sort.Unsorted;
|
||||
return [
|
||||
context.completions = this.values;
|
||||
},
|
||||
values: [
|
||||
["all", "Everything"],
|
||||
["session", "The current session"],
|
||||
["10m", "Last ten minutes"],
|
||||
["1h", "Past hour"],
|
||||
["1d", "Past day"],
|
||||
["1w", "Past week"]
|
||||
];
|
||||
},
|
||||
],
|
||||
validator: function (value) /^(a(ll)?|s(ession)|\d+[mhdw])$/.test(value)
|
||||
});
|
||||
|
||||
options.add(["cookies", "ck"],
|
||||
"The default mode for newly added cookie permissions",
|
||||
"stringlist", "session",
|
||||
{ completer: function (context) iter(Sanitizer.COMMANDS) });
|
||||
{ get values() iter(Sanitizer.COMMANDS) });
|
||||
|
||||
options.add(["cookieaccept", "ca"],
|
||||
"When to accept cookies",
|
||||
"string", "all",
|
||||
{
|
||||
PREF: "network.cookie.cookieBehavior",
|
||||
completer: function (context) [
|
||||
values: [
|
||||
["all", "Accept all cookies"],
|
||||
["samesite", "Accept all non-third-party cookies"],
|
||||
["none", "Accept no cookies"]
|
||||
],
|
||||
getter: function () (this.completer()[prefs.get(this.PREF)] || ["all"])[0],
|
||||
getter: function () (this.values[prefs.get(this.PREF)] || ["all"])[0],
|
||||
setter: function (val) {
|
||||
prefs.set(this.PREF, this.completer().map(function (i) i[0]).indexOf(val));
|
||||
prefs.set(this.PREF, this.values.map(function (i) i[0]).indexOf(val));
|
||||
return val;
|
||||
},
|
||||
initialValue: true,
|
||||
@@ -639,14 +640,14 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
|
||||
"string", "default", {
|
||||
PREF: "network.cookie.lifetimePolicy",
|
||||
PREF_DAYS: "network.cookie.lifetime.days",
|
||||
completer: function (context) [
|
||||
values: [
|
||||
["default", "The lifetime requested by the setter"],
|
||||
["prompt", "Always prompt for a lifetime"],
|
||||
["session", "The current session"]
|
||||
],
|
||||
getter: function () (this.completer()[prefs.get(this.PREF)] || [prefs.get(this.PREF_DAYS)])[0],
|
||||
getter: function () (this.values[prefs.get(this.PREF)] || [prefs.get(this.PREF_DAYS)])[0],
|
||||
setter: function (value) {
|
||||
let val = this.completer().map(function (i) i[0]).indexOf(value);
|
||||
let val = this.values.map(function (i) i[0]).indexOf(value);
|
||||
if (val > -1)
|
||||
prefs.set(this.PREF, val);
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user