mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-15 07:55:45 +01:00
Make further use of default parameters.
--HG-- extra : rebase_source : ab666bce7ed7e47c8f1e2bc4145f553da990d319
This commit is contained in:
@@ -628,10 +628,10 @@ var Bookmarks = Module("bookmarks", {
|
||||
},
|
||||
|
||||
completion: function initCompletion() {
|
||||
completion.bookmark = function bookmark(context, tags, extra) {
|
||||
completion.bookmark = function bookmark(context, tags, extra = {}) {
|
||||
context.title = ["Bookmark", "Title"];
|
||||
context.format = bookmarks.format;
|
||||
iter(extra || {}).forEach(function ([k, v]) {
|
||||
iter(extra).forEach(function ([k, v]) {
|
||||
if (v != null)
|
||||
context.filters.push(function (item) item.item[k] != null && this.matchString(v, item.item[k]));
|
||||
});
|
||||
|
||||
@@ -866,9 +866,7 @@ var CommandLine = Module("commandline", {
|
||||
* @... {string} default - The initial value that will be returned
|
||||
* if the user presses <CR> straightaway. @default ""
|
||||
*/
|
||||
input: function _input(prompt, callback, extra) {
|
||||
extra = extra || {};
|
||||
|
||||
input: function _input(prompt, callback, extra = {}) {
|
||||
CommandPromptMode(prompt, update({ onSubmit: callback }, extra)).open();
|
||||
},
|
||||
|
||||
@@ -1396,10 +1394,8 @@ var CommandLine = Module("commandline", {
|
||||
* @default {@link #selected}
|
||||
* @returns {object}
|
||||
*/
|
||||
getItem: function getItem(tuple) {
|
||||
tuple = tuple || this.selected;
|
||||
return tuple && tuple[0] && tuple[0].items[tuple[1]];
|
||||
},
|
||||
getItem: function getItem(tuple = this.selected)
|
||||
tuple && tuple[0] && tuple[0].items[tuple[1]],
|
||||
|
||||
/**
|
||||
* Returns a tuple representing the next item, at the given
|
||||
@@ -1510,11 +1506,10 @@ var CommandLine = Module("commandline", {
|
||||
* @default 1
|
||||
* @param {boolean} fromTab If true, this function was
|
||||
* called by {@link #tab}.
|
||||
* @default false
|
||||
* @private
|
||||
*/
|
||||
select: function select(idx, count, fromTab) {
|
||||
count = count || 1;
|
||||
|
||||
select: function select(idx, count = 1, fromTab = false) {
|
||||
switch (idx) {
|
||||
case this.UP:
|
||||
case this.DOWN:
|
||||
|
||||
@@ -538,13 +538,11 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
* @param {boolean} silent Whether the command should be echoed on the
|
||||
* command line.
|
||||
*/
|
||||
execute: function execute(str, modifiers, silent) {
|
||||
execute: function execute(str, modifiers = {}, silent = false) {
|
||||
// skip comments and blank lines
|
||||
if (/^\s*("|$)/.test(str))
|
||||
return;
|
||||
|
||||
modifiers = modifiers || {};
|
||||
|
||||
if (!silent)
|
||||
commands.lastCommand = str.replace(/^\s*:\s*/, "");
|
||||
let res = true;
|
||||
@@ -892,7 +890,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
* tabs.
|
||||
* @returns {boolean}
|
||||
*/
|
||||
open: function open(urls, params, force) {
|
||||
open: function open(urls, params = {}, force = false) {
|
||||
if (typeof urls == "string")
|
||||
urls = dactyl.parseURLs(urls);
|
||||
|
||||
@@ -903,7 +901,6 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
dactyl.open(urls, params, true);
|
||||
});
|
||||
|
||||
params = params || {};
|
||||
if (isString(params))
|
||||
params = { where: params };
|
||||
|
||||
@@ -1187,8 +1184,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
return [];
|
||||
}
|
||||
},
|
||||
wrapCallback: function wrapCallback(callback, self) {
|
||||
self = self || this;
|
||||
wrapCallback: function wrapCallback(callback, self = this) {
|
||||
let save = ["forceOpen"];
|
||||
let saved = save.map(p => dactyl[p]);
|
||||
return function wrappedCallback() {
|
||||
|
||||
@@ -212,8 +212,7 @@ var Events = Module("events", {
|
||||
/**
|
||||
* Wraps an event listener to ensure that errors are reported.
|
||||
*/
|
||||
wrapListener: function wrapListener(method, self) {
|
||||
self = self || this;
|
||||
wrapListener: function wrapListener(method, self = this) {
|
||||
method.wrapper = wrappedListener;
|
||||
wrappedListener.wrapped = method;
|
||||
function wrappedListener(event) {
|
||||
|
||||
@@ -12,11 +12,9 @@
|
||||
var HintSession = Class("HintSession", CommandMode, {
|
||||
get extendedMode() modes.HINTS,
|
||||
|
||||
init: function init(mode, opts) {
|
||||
init: function init(mode, opts = {}) {
|
||||
init.supercall(this);
|
||||
|
||||
opts = opts || {};
|
||||
|
||||
if (!opts.window)
|
||||
opts.window = modes.getStack(0).params.window;
|
||||
|
||||
@@ -1056,11 +1054,9 @@ var Hints = Module("hints", {
|
||||
return null;
|
||||
}, //}}}
|
||||
|
||||
open: function open(mode, opts) {
|
||||
open: function open(mode, opts = {}) {
|
||||
this._extendedhintCount = opts.count;
|
||||
|
||||
opts = opts || {};
|
||||
|
||||
mappings.pushCommand();
|
||||
commandline.input(["Normal", mode], null, {
|
||||
autocomplete: false,
|
||||
|
||||
@@ -13,9 +13,7 @@ var History = Module("history", {
|
||||
|
||||
get service() services.history,
|
||||
|
||||
get: function get(filter, maxItems, sort) {
|
||||
sort = sort || this.SORT_DEFAULT;
|
||||
|
||||
get: function get(filter, maxItems, sort = this.SORT_DEFAULT) {
|
||||
if (isString(filter))
|
||||
filter = { searchTerms: filter };
|
||||
|
||||
|
||||
@@ -187,9 +187,7 @@ var MapHive = Class("MapHive", Contexts.Hive, {
|
||||
* @param {Object} extra An optional extra configuration hash.
|
||||
* @optional
|
||||
*/
|
||||
add: function (modes, keys, description, action, extra) {
|
||||
extra = extra || {};
|
||||
|
||||
add: function (modes, keys, description, action, extra = {}) {
|
||||
modes = Array.concat(modes);
|
||||
if (!modes.every(util.identity))
|
||||
throw TypeError(/*L*/"Invalid modes: " + modes);
|
||||
@@ -814,9 +812,7 @@ var Mappings = Module("mappings", {
|
||||
});
|
||||
},
|
||||
completion: function initCompletion(dactyl, modules, window) {
|
||||
completion.userMapping = function userMapping(context, modes_, hive) {
|
||||
hive = hive || mappings.user;
|
||||
modes_ = modes_ || [modes.NORMAL];
|
||||
completion.userMapping = function userMapping(context, modes_ = [modes.NORMAL], hive = mappings.user) {
|
||||
context.keys = { text: function (m) m.names[0],
|
||||
description: function (m) m.description + ": " + m.action };
|
||||
context.completions = hive.iterate(modes_);
|
||||
|
||||
@@ -34,12 +34,10 @@ var Marks = Module("marks", {
|
||||
|
||||
get localURI() buffer.focusedFrame.document.documentURI.replace(/#.*/, ""),
|
||||
|
||||
Mark: function Mark(params) {
|
||||
Mark: function Mark(params = {}) {
|
||||
let win = buffer.focusedFrame;
|
||||
let doc = win.document;
|
||||
|
||||
params = params || {};
|
||||
|
||||
params.location = doc.documentURI.replace(/#.*/, ""),
|
||||
params.offset = buffer.scrollPosition;
|
||||
params.path = DOM(buffer.findScrollable(0, false)).xpath;
|
||||
|
||||
@@ -502,11 +502,10 @@ var Modes = Module("modes", {
|
||||
return StackElement;
|
||||
})(),
|
||||
cacheId: 0,
|
||||
boundProperty: function BoundProperty(desc) {
|
||||
boundProperty: function BoundProperty(desc = {}) {
|
||||
let id = this.cacheId++;
|
||||
let value;
|
||||
|
||||
desc = desc || {};
|
||||
return Class.Property(update({
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
|
||||
@@ -408,8 +408,7 @@ var Tabs = Module("tabs", {
|
||||
* @param {number} count How many tabs to remove.
|
||||
* @param {boolean} focusLeftTab Focus the tab to the left of the removed tab.
|
||||
*/
|
||||
remove: function remove(tab, count, focusLeftTab) {
|
||||
count = count || 1;
|
||||
remove: function remove(tab, count = 1, focusLeftTab = false) {
|
||||
let res = this.count > count;
|
||||
|
||||
let tabs = this.visibleTabs;
|
||||
|
||||
Reference in New Issue
Block a user