let win = services.focus.focusedWindow;
if (!win || win == window || util.topWindow(win) != window)
- return window.content
+ return window.content;
if (win.top == window)
return win;
return win.top;
services.contentPrefs.getPref(this.uri, pref,
sanitizer.getContext(this.win), callback);
else
- services.contentPrefs.getPref(uri, pref, callback);
+ services.contentPrefs.getPref(this.uri, pref, callback);
},
/**
*/
get zoomLevel() {
let v = this.contentViewer;
- return v[v.textZoom == 1 ? "fullZoom" : "textZoom"] * 100
+ return v[v.textZoom == 1 ? "fullZoom" : "textZoom"] * 100;
},
set zoomLevel(value) { this.setZoom(value, this.fullZoom); },
* vertical percentages. See {@link Buffer.scrollToPercent} for
* parameters.
*/
- scrollToPercent: function scrollToPercent(horizontal, vertical)
- Buffer.scrollToPercent(this.findScrollable(0, vertical == null), horizontal, vertical),
+ scrollToPercent: function scrollToPercent(horizontal, vertical, dir)
+ Buffer.scrollToPercent(this.findScrollable(dir || 0, vertical == null), horizontal, vertical),
/**
* Scrolls the currently active element to the given horizontal and
let distance = reverse ? function (rect) -rect.top : function (rect) rect.top;
let elems = [[e, distance(e.getBoundingClientRect())] for (e in path.matcher(this.focusedFrame.document))]
.filter(function (e) e[1] > FUDGE)
- .sort(function (a, b) a[1] - b[1])
+ .sort(function (a, b) a[1] - b[1]);
if (offScreen && !reverse)
elems = elems.filter(function (e) e[1] > this, this.topWindow.innerHeight);
showPageInfo: function showPageInfo(verbose, sections) {
let { commandline, dactyl, options } = this.modules;
- let self = this;
-
// Ctrl-g single line output
if (!verbose) {
let file = this.win.location.pathname.split("/").pop() || _("buffer.noName");
let info = template.map(
(sections || options["pageinfo"])
- .map(function (opt) Buffer.pageInfo[opt].action.call(self)),
+ .map((opt) => Buffer.pageInfo[opt].action.call(this)),
function (res) res && iter(res).join(", ") || undefined,
", ").join("");
return;
}
- let list = template.map(sections || options["pageinfo"], function (option) {
+ let list = template.map(sections || options["pageinfo"], (option) => {
let { action, title } = Buffer.pageInfo[option];
- return template.table(title, action.call(self, true));
+ return template.table(title, action.call(this, true));
}, ["br"]);
commandline.commandOutput(list);
let ext = uri.fileExtension || "txt";
if (doc.contentType)
- ext = services.mime.getPrimaryExtension(doc.contentType, ext);
+ try {
+ ext = services.mime.getPrimaryExtension(doc.contentType, ext);
+ }
+ catch (e) {}
if (!isString(doc))
return io.withTempFiles(function (temp) {
* Updates the zoom level of this buffer from a content preference.
*/
updateZoom: util.wrapCallback(function updateZoom() {
- let self = this;
let uri = this.uri;
if (prefs.get("browser.zoom.siteSpecific")) {
- this.getPref("dactyl.content.full-zoom", function (val) {
- if (val != null && uri.equals(self.uri) && val != prefs.get("browser.zoom.full"))
- [self.contentViewer.textZoom, self.contentViewer.fullZoom] =
- [self.contentViewer.fullZoom, self.contentViewer.textZoom];
+ this.getPref("dactyl.content.full-zoom", (val) => {
+ if (val != null && uri.equals(this.uri) && val != prefs.get("browser.zoom.full"))
+ [this.contentViewer.textZoom, this.contentViewer.fullZoom] =
+ [this.contentViewer.fullZoom, this.contentViewer.textZoom];
});
}
}),
get scrollRightMax() this.win.scrollMaxY,
get scrollLeft() this.win.scrollX,
- set scrollLeft(val) { this.win.scrollTo(val, this.win.scrollY) },
+ set scrollLeft(val) { this.win.scrollTo(val, this.win.scrollY); },
get scrollTop() this.win.scrollY,
- set scrollTop(val) { this.win.scrollTo(this.win.scrollX, val) }
+ set scrollTop(val) { this.win.scrollTo(this.win.scrollX, val); }
};
return elem;
},
return elem[pos] > 0;
let max = pos + "Max";
- if (max in elem && pos > 0)
- return elem[pos] < elem[max];
+ if (max in elem) {
+ if (elem[pos] < elem[max])
+ return true;
+ if (dir > 0)
+ return false;
+ return elem[pos] > 0;
+ }
let style = DOM(elem).style;
let borderSize = Math.round(parseFloat(style[border1]) + parseFloat(style[border2]));
return {
x: elem.scrollLeft && elem.scrollLeft / this._exWidth(node),
y: elem.scrollTop / parseFloat(style.lineHeight)
- }
+ };
},
_exWidth: function _exWidth(elem) {
const BRANCH = "printer_" + PRINTER + ".";
const BRANCHES = ["print.", BRANCH, "print." + BRANCH];
function set(pref, value) {
- BRANCHES.forEach(function (branch) { prefs.set(branch + pref, value) });
+ BRANCHES.forEach(function (branch) { prefs.set(branch + pref, value); });
}
prefs.withContext(function () {
mappings.add([modes.NORMAL],
["<C-a>", "<increment-url-path>"], "Increment last number in URL",
- function (args) { buffer.incrementURL(Math.max(args.count, 1)); },
+ function ({ count }) { buffer.incrementURL(Math.max(count, 1)); },
{ count: true });
mappings.add([modes.NORMAL],
["<C-x>", "<decrement-url-path>"], "Decrement last number in URL",
- function (args) { buffer.incrementURL(-Math.max(args.count, 1)); },
+ function ({ count }) { buffer.incrementURL(-Math.max(count, 1)); },
{ count: true });
mappings.add([modes.NORMAL], ["gu", "<open-parent-path>"],
"Go to parent directory",
- function (args) { buffer.climbUrlPath(Math.max(args.count, 1)); },
+ function ({ count }) { buffer.climbUrlPath(Math.max(count, 1)); },
{ count: true });
mappings.add([modes.NORMAL], ["gU", "<open-root-path>"],
mappings.add([modes.COMMAND], [".", "<repeat-key>"],
"Repeat the last key event",
- function (args) {
+ function ({ count }) {
if (mappings.repeat) {
- for (let i in util.interruptibleRange(0, Math.max(args.count, 1), 100))
+ for (let i in util.interruptibleRange(0, Math.max(count, 1), 100))
mappings.repeat();
}
},
// scrolling
mappings.add([modes.NORMAL], ["j", "<Down>", "<C-e>", "<scroll-down-line>"],
"Scroll document down",
- function (args) { buffer.scrollVertical("lines", Math.max(args.count, 1)); },
+ function ({ count }) { buffer.scrollVertical("lines", Math.max(count, 1)); },
{ count: true });
mappings.add([modes.NORMAL], ["k", "<Up>", "<C-y>", "<scroll-up-line>"],
"Scroll document up",
- function (args) { buffer.scrollVertical("lines", -Math.max(args.count, 1)); },
+ function ({ count }) { buffer.scrollVertical("lines", -Math.max(count, 1)); },
{ count: true });
mappings.add([modes.NORMAL], dactyl.has("mail") ? ["h", "<scroll-left-column>"] : ["h", "<Left>", "<scroll-left-column>"],
"Scroll document to the left",
- function (args) { buffer.scrollHorizontal("columns", -Math.max(args.count, 1)); },
+ function ({ count }) { buffer.scrollHorizontal("columns", -Math.max(count, 1)); },
{ count: true });
mappings.add([modes.NORMAL], dactyl.has("mail") ? ["l", "<scroll-right-column>"] : ["l", "<Right>", "<scroll-right-column>"],
"Scroll document to the right",
- function (args) { buffer.scrollHorizontal("columns", Math.max(args.count, 1)); },
+ function ({ count }) { buffer.scrollHorizontal("columns", Math.max(count, 1)); },
{ count: true });
mappings.add([modes.NORMAL], ["0", "^", "<scroll-begin>"],
mappings.add([modes.NORMAL], ["gg", "<Home>", "<scroll-top>"],
"Go to the top of the document",
- function (args) { buffer.scrollToPercent(null, args.count != null ? args.count : 0); },
+ function ({ count }) { buffer.scrollToPercent(null, count != null ? count : 0,
+ count != null ? 0 : -1); },
{ count: true });
mappings.add([modes.NORMAL], ["G", "<End>", "<scroll-bottom>"],
"Go to the end of the document",
- function (args) {
- if (args.count)
+ function ({ count }) {
+ if (count)
var elem = options.get("linenumbers")
.getLine(buffer.focusedFrame.document,
- args.count);
+ count);
if (elem)
elem.scrollIntoView(true);
- else if (args.count)
- buffer.scrollToPosition(null, args.count);
+ else if (count)
+ buffer.scrollToPosition(null, count);
else
- buffer.scrollToPercent(null, 100);
+ buffer.scrollToPercent(null, 100, 1);
},
{ count: true });
mappings.add([modes.NORMAL], ["%", "<scroll-percent>"],
"Scroll to {count} percent of the document",
- function (args) {
- dactyl.assert(args.count > 0 && args.count <= 100);
- buffer.scrollToPercent(null, args.count);
+ function ({ count }) {
+ dactyl.assert(count > 0 && count <= 100);
+ buffer.scrollToPercent(null, count);
},
{ count: true });
mappings.add([modes.NORMAL], ["<C-d>", "<scroll-down>"],
"Scroll window downwards in the buffer",
- function (args) { buffer._scrollByScrollSize(args.count, true); },
+ function ({ count }) { buffer._scrollByScrollSize(count, true); },
{ count: true });
mappings.add([modes.NORMAL], ["<C-u>", "<scroll-up>"],
"Scroll window upwards in the buffer",
- function (args) { buffer._scrollByScrollSize(args.count, false); },
+ function ({ count }) { buffer._scrollByScrollSize(count, false); },
{ count: true });
mappings.add([modes.NORMAL], ["<C-b>", "<PageUp>", "<S-Space>", "<scroll-up-page>"],
"Scroll up a full page",
- function (args) { buffer.scrollVertical("pages", -Math.max(args.count, 1)); },
+ function ({ count }) { buffer.scrollVertical("pages", -Math.max(count, 1)); },
{ count: true });
mappings.add([modes.NORMAL], ["<Space>"],
"Scroll down a full page",
- function (args) {
+ function ({ count }) {
if (isinstance((services.focus.focusedWindow || buffer.win).document.activeElement,
[Ci.nsIDOMHTMLInputElement,
Ci.nsIDOMHTMLButtonElement,
Ci.nsIDOMXULButtonElement]))
return Events.PASS;
- buffer.scrollVertical("pages", Math.max(args.count, 1));
+ buffer.scrollVertical("pages", Math.max(count, 1));
},
{ count: true });
mappings.add([modes.NORMAL], ["<C-f>", "<PageDown>", "<scroll-down-page>"],
"Scroll down a full page",
- function (args) { buffer.scrollVertical("pages", Math.max(args.count, 1)); },
+ function ({ count }) { buffer.scrollVertical("pages", Math.max(count, 1)); },
{ count: true });
mappings.add([modes.NORMAL], ["]f", "<previous-frame>"],
"Focus next frame",
- function (args) { buffer.shiftFrameFocus(Math.max(args.count, 1)); },
+ function ({ count }) { buffer.shiftFrameFocus(Math.max(count, 1)); },
{ count: true });
mappings.add([modes.NORMAL], ["[f", "<next-frame>"],
"Focus previous frame",
- function (args) { buffer.shiftFrameFocus(-Math.max(args.count, 1)); },
+ function ({ count }) { buffer.shiftFrameFocus(-Math.max(count, 1)); },
{ count: true });
mappings.add([modes.NORMAL], ["["],
"Jump to the previous element as defined by 'jumptags'",
- function (args) { buffer.findJump(args.arg, args.count, true); },
+ function ({ arg, count }) { buffer.findJump(arg, count, true); },
{ arg: true, count: true });
mappings.add([modes.NORMAL], ["g]"],
"Jump to the next off-screen element as defined by 'jumptags'",
- function (args) { buffer.findJump(args.arg, args.count, false, true); },
+ function ({ arg, count }) { buffer.findJump(arg, count, false, true); },
{ arg: true, count: true });
mappings.add([modes.NORMAL], ["]"],
"Jump to the next element as defined by 'jumptags'",
- function (args) { buffer.findJump(args.arg, args.count, false); },
+ function ({ arg, count }) { buffer.findJump(arg, count, false); },
{ arg: true, count: true });
mappings.add([modes.NORMAL], ["{"],
"Jump to the previous paragraph",
- function (args) { buffer.findJump("p", args.count, true); },
+ function ({ count }) { buffer.findJump("p", count, true); },
{ count: true });
mappings.add([modes.NORMAL], ["}"],
"Jump to the next paragraph",
- function (args) { buffer.findJump("p", args.count, false); },
+ function ({ count }) { buffer.findJump("p", count, false); },
{ count: true });
mappings.add([modes.NORMAL], ["]]", "<next-page>"],
"Follow the link labeled 'next' or '>' if it exists",
- function (args) {
- buffer.findLink("next", options["nextpattern"], (args.count || 1) - 1, true);
+ function ({ count }) {
+ buffer.findLink("next", options["nextpattern"], (count || 1) - 1, true);
},
{ count: true });
mappings.add([modes.NORMAL], ["[[", "<previous-page>"],
"Follow the link labeled 'prev', 'previous' or '<' if it exists",
- function (args) {
- buffer.findLink("prev", options["previouspattern"], (args.count || 1) - 1, true);
+ function ({ count }) {
+ buffer.findLink("prev", options["previouspattern"], (count || 1) - 1, true);
},
{ count: true });
mappings.add([modes.NORMAL], ["gi", "<focus-input>"],
"Focus last used input field",
- function (args) {
+ function ({ count }) {
let elem = buffer.lastInputField;
- if (args.count >= 1 || !elem || !events.isContentNode(elem)) {
+ if (count >= 1 || !elem || !events.isContentNode(elem)) {
let xpath = ["frame", "iframe", "input", "xul:textbox", "textarea[not(@disabled) and not(@readonly)]"];
let frames = buffer.allFrames(null, true);
});
dactyl.assert(elements.length > 0);
- elem = elements[Math.constrain(args.count, 1, elements.length) - 1];
+ elem = elements[Math.constrain(count, 1, elements.length) - 1];
}
buffer.focusElement(elem);
DOM(elem).scrollIntoView();
// zooming
mappings.add([modes.NORMAL], ["zi", "+", "<text-zoom-in>"],
"Enlarge text zoom of current web page",
- function (args) { buffer.zoomIn(Math.max(args.count, 1), false); },
+ function ({ count }) { buffer.zoomIn(Math.max(count, 1), false); },
{ count: true });
mappings.add([modes.NORMAL], ["zm", "<text-zoom-more>"],
"Enlarge text zoom of current web page by a larger amount",
- function (args) { buffer.zoomIn(Math.max(args.count, 1) * 3, false); },
+ function ({ count }) { buffer.zoomIn(Math.max(count, 1) * 3, false); },
{ count: true });
mappings.add([modes.NORMAL], ["zo", "-", "<text-zoom-out>"],
"Reduce text zoom of current web page",
- function (args) { buffer.zoomOut(Math.max(args.count, 1), false); },
+ function ({ count }) { buffer.zoomOut(Math.max(count, 1), false); },
{ count: true });
mappings.add([modes.NORMAL], ["zr", "<text-zoom-reduce>"],
"Reduce text zoom of current web page by a larger amount",
- function (args) { buffer.zoomOut(Math.max(args.count, 1) * 3, false); },
+ function ({ count }) { buffer.zoomOut(Math.max(count, 1) * 3, false); },
{ count: true });
mappings.add([modes.NORMAL], ["zz", "<text-zoom>"],
"Set text zoom value of current web page",
- function (args) { buffer.setZoom(args.count > 1 ? args.count : 100, false); },
+ function ({ count }) { buffer.setZoom(count > 1 ? count : 100, false); },
{ count: true });
mappings.add([modes.NORMAL], ["ZI", "zI", "<full-zoom-in>"],
"Enlarge full zoom of current web page",
- function (args) { buffer.zoomIn(Math.max(args.count, 1), true); },
+ function ({ count }) { buffer.zoomIn(Math.max(count, 1), true); },
{ count: true });
mappings.add([modes.NORMAL], ["ZM", "zM", "<full-zoom-more>"],
"Enlarge full zoom of current web page by a larger amount",
- function (args) { buffer.zoomIn(Math.max(args.count, 1) * 3, true); },
+ function ({ count }) { buffer.zoomIn(Math.max(count, 1) * 3, true); },
{ count: true });
mappings.add([modes.NORMAL], ["ZO", "zO", "<full-zoom-out>"],
"Reduce full zoom of current web page",
- function (args) { buffer.zoomOut(Math.max(args.count, 1), true); },
+ function ({ count }) { buffer.zoomOut(Math.max(count, 1), true); },
{ count: true });
mappings.add([modes.NORMAL], ["ZR", "zR", "<full-zoom-reduce>"],
"Reduce full zoom of current web page by a larger amount",
- function (args) { buffer.zoomOut(Math.max(args.count, 1) * 3, true); },
+ function ({ count }) { buffer.zoomOut(Math.max(count, 1) * 3, true); },
{ count: true });
mappings.add([modes.NORMAL], ["zZ", "<full-zoom>"],
"Set full zoom value of current web page",
- function (args) { buffer.setZoom(args.count > 1 ? args.count : 100, true); },
+ function ({ count }) { buffer.setZoom(count > 1 ? count : 100, true); },
{ count: true });
// page info
});
Buffer.addPageInfoSection("s", "Security", function (verbose) {
- let { statusline } = this.modules
+ let { statusline } = this.modules;
let identity = this.topWindow.gIdentityHandler;
endModule();
-// vim: set fdm=marker sw=4 ts=4 et ft=javascript:
+// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: