mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 00:17:58 +01:00
- code cleanup by removing old commented code
- merged zoom_in/to into vimperator.zoom()
This commit is contained in:
@@ -1155,11 +1155,11 @@ function Commands() //{{{
|
|||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultCommand(new Command(["zo[om]"],
|
addDefaultCommand(new Command(["zo[om]"],
|
||||||
zoom_to,
|
vimperator.zoom,
|
||||||
{
|
{
|
||||||
usage: ["zo[om] {value}"],
|
usage: ["zo[om] [+-]{value}[%]"],
|
||||||
short_help: "Set zoom value of the web page",
|
short_help: "Set zoom value of the web page",
|
||||||
help: "{value} can be between 25 and 500%. If it is omitted, zoom is reset to 100%."
|
help: "{value} can be an absolute value between 25 and 500% or a relative value if prefixed with - or +. If {value} is omitted, zoom is reset to 100%."
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
//}}}
|
//}}}
|
||||||
@@ -1334,76 +1334,6 @@ function scrollBufferAbsolute(horizontal, vertical)
|
|||||||
win.scrollTo(horiz, vert);
|
win.scrollTo(horiz, vert);
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////}}}
|
|
||||||
// zooming /////////////////////////////////////////////////////////////
|
|
||||||
/////////////////////////////////////////////////////////////////////{{{
|
|
||||||
|
|
||||||
/* also used to zoom out, when factor is negative */
|
|
||||||
function zoom_in(factor)
|
|
||||||
{
|
|
||||||
if (vimperator.input.count < 1)
|
|
||||||
vimperator.input.count = 1;
|
|
||||||
|
|
||||||
//ZoomManager.prototype.getInstance().enlarge();
|
|
||||||
var zoomMgr = ZoomManager.prototype.getInstance();
|
|
||||||
if (zoomMgr.textZoom == 25 && factor < 0)
|
|
||||||
{
|
|
||||||
vimperator.echoerr("Minimum zoom level of 25% reached");
|
|
||||||
vimperator.beep();
|
|
||||||
}
|
|
||||||
else if (zoomMgr.textZoom == 500 && factor > 0)
|
|
||||||
{
|
|
||||||
vimperator.echoerr("Maximum zoom level of 500% reached");
|
|
||||||
vimperator.beep();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var value = zoomMgr.textZoom + factor*vimperator.input.count*25;
|
|
||||||
if (value < 25) value = 25;
|
|
||||||
if (value > 500) value = 500;
|
|
||||||
|
|
||||||
zoomMgr.textZoom = value;
|
|
||||||
|
|
||||||
vimperator.hints.reshowHints();
|
|
||||||
|
|
||||||
vimperator.echo("Zoom value: " + value + "%");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//vimperator.zoom_to = function(value)
|
|
||||||
function zoom_to(value)
|
|
||||||
{
|
|
||||||
var zoomMgr = ZoomManager.prototype.getInstance();
|
|
||||||
value = parseInt(value);
|
|
||||||
if (!value || isNaN(value) || value <= 0)
|
|
||||||
value = 100;
|
|
||||||
|
|
||||||
// convert to int, if string was given
|
|
||||||
if (typeof value != "number")
|
|
||||||
{
|
|
||||||
oldval = value;
|
|
||||||
value = parseInt(oldval, 10);
|
|
||||||
if (isNaN(value))
|
|
||||||
{
|
|
||||||
vimperator.echoerr("Cannot convert " + oldval + " to a number");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value < 25 || value > 500)
|
|
||||||
{
|
|
||||||
vimperator.echoerr("Zoom value must be between 25% and 500%");
|
|
||||||
vimperator.beep();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
zoomMgr.textZoom = value;
|
|
||||||
|
|
||||||
vimperator.hints.reshowHints();
|
|
||||||
|
|
||||||
vimperator.echo("Zoom value: " + value + "%");
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////}}}
|
||||||
// DOM related helper functions ////////////////////////////////////////
|
// DOM related helper functions ////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|||||||
@@ -137,16 +137,9 @@ function Events() //{{{
|
|||||||
|
|
||||||
this.onKeyPress = function(event)
|
this.onKeyPress = function(event)
|
||||||
{
|
{
|
||||||
// alert(event)
|
|
||||||
// if (event.type != "keypress")
|
|
||||||
// return false;
|
|
||||||
// vimperator.logObject(event);
|
|
||||||
var key = event.toString()
|
var key = event.toString()
|
||||||
// alert(key);
|
|
||||||
if (!key)
|
if (!key)
|
||||||
return false;
|
return false;
|
||||||
// event.stopPropagation();
|
|
||||||
// event.preventDefault();
|
|
||||||
// sometimes the non-content area has focus, making our keys not work
|
// sometimes the non-content area has focus, making our keys not work
|
||||||
// if (event.target.id == "main-window")
|
// if (event.target.id == "main-window")
|
||||||
// alert("focusContent();");
|
// alert("focusContent();");
|
||||||
@@ -183,7 +176,6 @@ function Events() //{{{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// handle Escape-one-key mode (Ctrl-v)
|
// handle Escape-one-key mode (Ctrl-v)
|
||||||
if (vimperator.hasMode(vimperator.modes.ESCAPE_ONE_KEY) && !vimperator.hasMode(vimperator.modes.ESCAPE_ALL_KEYS))
|
if (vimperator.hasMode(vimperator.modes.ESCAPE_ONE_KEY) && !vimperator.hasMode(vimperator.modes.ESCAPE_ALL_KEYS))
|
||||||
{
|
{
|
||||||
@@ -222,7 +214,6 @@ function Events() //{{{
|
|||||||
// } }}}
|
// } }}}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// if Hit-a-hint mode is on, special handling of keys is required
|
// if Hit-a-hint mode is on, special handling of keys is required
|
||||||
// FIXME: total mess
|
// FIXME: total mess
|
||||||
if (vimperator.hasMode(vimperator.modes.HINTS))
|
if (vimperator.hasMode(vimperator.modes.HINTS))
|
||||||
@@ -236,7 +227,6 @@ function Events() //{{{
|
|||||||
{
|
{
|
||||||
if (map.always_active || vimperator.hints.currentState() == 1)
|
if (map.always_active || vimperator.hints.currentState() == 1)
|
||||||
{
|
{
|
||||||
//g_hint_mappings[i][1].call(this, event);
|
|
||||||
map.execute();
|
map.execute();
|
||||||
if (map.cancel_mode) // stop processing this event
|
if (map.cancel_mode) // stop processing this event
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,15 +26,11 @@ function Hints() //{{{
|
|||||||
{
|
{
|
||||||
const HINT_PREFIX = 'hah_hint_'; // prefix for the hint id
|
const HINT_PREFIX = 'hah_hint_'; // prefix for the hint id
|
||||||
|
|
||||||
// public accessors
|
|
||||||
//this.hintsVisible = function() { return isHahModeEnabled; };
|
|
||||||
this.hintedElements = function() { return hintedElems; };
|
this.hintedElements = function() { return hintedElems; };
|
||||||
this.currentState = function() { return state;};
|
this.currentState = function() { return state;};
|
||||||
this.setCurrentState = function(s) { state = s;};
|
this.setCurrentState = function(s) { state = s;};
|
||||||
//this.currentMode = function() { return hintmode;};
|
|
||||||
|
|
||||||
var isHahModeEnabled = false; // is typing mode on
|
var isHahModeEnabled = false; // is typing mode on
|
||||||
//var hintmode = HINT_MODE_QUICK;
|
|
||||||
var hintedElems = [];
|
var hintedElems = [];
|
||||||
var linkNumString = ""; // the typed link number is in this string
|
var linkNumString = ""; // the typed link number is in this string
|
||||||
var linkCount = 0;
|
var linkCount = 0;
|
||||||
@@ -45,16 +41,6 @@ function Hints() //{{{
|
|||||||
// each hint element is a clone of this element
|
// each hint element is a clone of this element
|
||||||
var hintElemSpan;
|
var hintElemSpan;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// configuration and initialization related functions
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// function load()
|
|
||||||
// {
|
|
||||||
// isHahModeEnabled = false;
|
|
||||||
// hintedElem = null;
|
|
||||||
// }
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// hint activating and loading related functions
|
// hint activating and loading related functions
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -101,17 +87,15 @@ function Hints() //{{{
|
|||||||
function genElemCoords(elem)
|
function genElemCoords(elem)
|
||||||
{
|
{
|
||||||
// NOTE: experiment for making the function faster, report problems
|
// NOTE: experiment for making the function faster, report problems
|
||||||
// -> does not work on www.orf.at with frames
|
// only works for FF3.0:
|
||||||
// try {
|
//var rect = elem.getBoundingClientRect();
|
||||||
// var box = window.content.document.getBoxObjectFor(elem);
|
//if (rect)
|
||||||
// elem.absoLeft = box.x;
|
//{
|
||||||
// elem.absoTop = box.y;
|
// elem.absoLeft = rect.left;
|
||||||
// elem.validCoord = elem.ownerDocument.validCoords;
|
// elem.absoTop = rect.top;
|
||||||
// } catch(e) {
|
|
||||||
// elem.absoLeft = 0;
|
|
||||||
// elem.absoTop = 0;
|
|
||||||
//}
|
//}
|
||||||
//return;
|
//return;
|
||||||
|
|
||||||
if (typeof(elem.validCoord) != "undefined")
|
if (typeof(elem.validCoord) != "undefined")
|
||||||
{
|
{
|
||||||
if (elem.validCoord == elem.ownerDocument.validCoords)
|
if (elem.validCoord == elem.ownerDocument.validCoords)
|
||||||
@@ -136,7 +120,7 @@ function Hints() //{{{
|
|||||||
{
|
{
|
||||||
if (!win)
|
if (!win)
|
||||||
{
|
{
|
||||||
win = window._content;
|
win = window.content;
|
||||||
linkCount = 0;
|
linkCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,7 +140,6 @@ function Hints() //{{{
|
|||||||
hintElemSpan.setAttribute('name', 'hah_hint');
|
hintElemSpan.setAttribute('name', 'hah_hint');
|
||||||
|
|
||||||
var hintContainer = doc.getElementById('hah_hints');
|
var hintContainer = doc.getElementById('hah_hints');
|
||||||
|
|
||||||
if (hintContainer == null)
|
if (hintContainer == null)
|
||||||
{
|
{
|
||||||
genHintContainer(doc);
|
genHintContainer(doc);
|
||||||
@@ -176,12 +159,11 @@ function Hints() //{{{
|
|||||||
genElemCoords(elem);
|
genElemCoords(elem);
|
||||||
|
|
||||||
// for extended hint mode, show all - even currently hidden - hints
|
// for extended hint mode, show all - even currently hidden - hints
|
||||||
//if (hintmode == HINT_MODE_QUICK && (elem.absoTop < area[1] || elem.absoTop > area[3] ||
|
//if (vimperator.hasMode(vimperator.modes.QUICK_HINT) && (elem.absoTop < area[1] || elem.absoTop > area[3] ||
|
||||||
if (vimperator.hasMode(vimperator.modes.QUICK_HINT) && (elem.absoTop < area[1] || elem.absoTop > area[3] ||
|
if ((elem.absoTop < area[1] || elem.absoTop > area[3] ||
|
||||||
elem.absoLeft > area[2] || elem.absoLeft < area[0]))
|
elem.absoLeft > area[2] || elem.absoLeft < area[0]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// XXX: what does that do
|
|
||||||
// if (elem.offsetWidth == 0 && elem.offsetHeight == 0)
|
// if (elem.offsetWidth == 0 && elem.offsetHeight == 0)
|
||||||
// continue;
|
// continue;
|
||||||
|
|
||||||
@@ -222,17 +204,10 @@ function Hints() //{{{
|
|||||||
if (!win)
|
if (!win)
|
||||||
win = window.content;
|
win = window.content;
|
||||||
|
|
||||||
//if (linkCount == 0 && hintmode != HINT_MODE_ALWAYS)
|
|
||||||
if (linkCount == 0 && !vimperator.hasMode(vimperator.modes.ALWAYS_HINT))
|
if (linkCount == 0 && !vimperator.hasMode(vimperator.modes.ALWAYS_HINT))
|
||||||
{
|
{
|
||||||
vimperator.beep();
|
vimperator.beep();
|
||||||
//alert('h');
|
|
||||||
this.disableHahMode(win);
|
this.disableHahMode(win);
|
||||||
//alert('g');
|
|
||||||
// setCurrentMode(MODE_NORMAL);
|
|
||||||
// linkNumString = '';
|
|
||||||
// hintedElems = [];
|
|
||||||
// isHahModeEnabled = false;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -409,9 +384,7 @@ function Hints() //{{{
|
|||||||
//function enableHahMode(event, mode)
|
//function enableHahMode(event, mode)
|
||||||
this.enableHahMode = function(mode)
|
this.enableHahMode = function(mode)
|
||||||
{
|
{
|
||||||
//setCurrentMode(mode);
|
|
||||||
vimperator.setMode(vimperator.modes.HINTS, mode);
|
vimperator.setMode(vimperator.modes.HINTS, mode);
|
||||||
//hintmode = mode;
|
|
||||||
state = 0;
|
state = 0;
|
||||||
linkCount = 0;
|
linkCount = 0;
|
||||||
linkNumString = '';
|
linkNumString = '';
|
||||||
@@ -438,14 +411,10 @@ function Hints() //{{{
|
|||||||
if(!isHahModeEnabled)
|
if(!isHahModeEnabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//setCurrentMode(MODE_NORMAL);
|
|
||||||
vimperator.setMode(vimperator.modes.NORMAL);
|
vimperator.setMode(vimperator.modes.NORMAL);
|
||||||
isHahModeEnabled = false;
|
isHahModeEnabled = false;
|
||||||
//hintmode = HINT_MODE_QUICK;
|
|
||||||
linkNumString = '';
|
linkNumString = '';
|
||||||
hintedElems = [];
|
hintedElems = [];
|
||||||
// if (!silent && vimperator.options["showmode"])
|
|
||||||
// vimperator.echo('');
|
|
||||||
|
|
||||||
removeHints(win);
|
removeHints(win);
|
||||||
return 0;
|
return 0;
|
||||||
@@ -519,7 +488,6 @@ function Hints() //{{{
|
|||||||
evt.initMouseEvent('click', true, true, view, 1, x+1, y+1, 0, 0, /*ctrl*/ new_tab, /*event.altKey*/0, /*event.shiftKey*/ new_window, /*event.metaKey*/ new_tab, 0, null);
|
evt.initMouseEvent('click', true, true, view, 1, x+1, y+1, 0, 0, /*ctrl*/ new_tab, /*event.altKey*/0, /*event.shiftKey*/ new_window, /*event.metaKey*/ new_tab, 0, null);
|
||||||
elem.dispatchEvent(evt);
|
elem.dispatchEvent(evt);
|
||||||
|
|
||||||
|
|
||||||
// for 'pure' open calls without a new tab or window it doesn't
|
// for 'pure' open calls without a new tab or window it doesn't
|
||||||
// make sense to open more hints in the current tab, open new tabs
|
// make sense to open more hints in the current tab, open new tabs
|
||||||
// for it
|
// for it
|
||||||
@@ -539,7 +507,11 @@ function Hints() //{{{
|
|||||||
{
|
{
|
||||||
tmp = elems[i].refElem.href;
|
tmp = elems[i].refElem.href;
|
||||||
if (typeof(tmp) != 'undefined' && tmp.length > 0)
|
if (typeof(tmp) != 'undefined' && tmp.length > 0)
|
||||||
loc += tmp + "\n";
|
{
|
||||||
|
if (i > 0)
|
||||||
|
loc += "\n";
|
||||||
|
loc += tmp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// disable the hints before we can echo() an information
|
// disable the hints before we can echo() an information
|
||||||
@@ -558,7 +530,11 @@ function Hints() //{{{
|
|||||||
{
|
{
|
||||||
tmp = elems[i].refElem.textContent;
|
tmp = elems[i].refElem.textContent;
|
||||||
if (typeof(tmp) != 'undefined' && tmp.length > 0)
|
if (typeof(tmp) != 'undefined' && tmp.length > 0)
|
||||||
loc += tmp + "\n";
|
{
|
||||||
|
if (i > 0)
|
||||||
|
loc += "\n";
|
||||||
|
loc += tmp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// disable the hints before we can echo() an information
|
// disable the hints before we can echo() an information
|
||||||
@@ -659,7 +635,8 @@ function Hints() //{{{
|
|||||||
|
|
||||||
function initDoc(event)
|
function initDoc(event)
|
||||||
{
|
{
|
||||||
// vimperator.echo("Content loaded");
|
// vimperator.echoerr("Content loaded");
|
||||||
|
|
||||||
doc = event.originalTarget;
|
doc = event.originalTarget;
|
||||||
genHintContainer(doc);
|
genHintContainer(doc);
|
||||||
isHahModeEnabled = false;
|
isHahModeEnabled = false;
|
||||||
@@ -678,7 +655,6 @@ function Hints() //{{{
|
|||||||
|
|
||||||
startCoordLoader(doc);
|
startCoordLoader(doc);
|
||||||
|
|
||||||
//if (hintmode == HINT_MODE_ALWAYS)
|
|
||||||
if (vimperator.hasMode(vimperator.modes.ALWAYS_HINT))
|
if (vimperator.hasMode(vimperator.modes.ALWAYS_HINT))
|
||||||
{
|
{
|
||||||
state = 0;
|
state = 0;
|
||||||
@@ -686,10 +662,11 @@ function Hints() //{{{
|
|||||||
linkNumString = '';
|
linkNumString = '';
|
||||||
isHahModeEnabled = true;
|
isHahModeEnabled = true;
|
||||||
|
|
||||||
|
setTimeout( function() {
|
||||||
createHints();
|
createHints();
|
||||||
showHints(null, 0);
|
showHints(null, 0);
|
||||||
|
}, 100);
|
||||||
}
|
}
|
||||||
// vimperator.echo("Done.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
window.document.addEventListener("DOMContentLoaded", initDoc, null);
|
window.document.addEventListener("DOMContentLoaded", initDoc, null);
|
||||||
|
|||||||
@@ -332,7 +332,7 @@ function Mappings() //{{{
|
|||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["b"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["b"],
|
||||||
function(args) { vimperator.commandline.open(":", "buffer ", vimperator.modes.EX); },
|
function() { vimperator.commandline.open(":", "buffer ", vimperator.modes.EX); },
|
||||||
{
|
{
|
||||||
short_help: "Open a prompt to switch buffers",
|
short_help: "Open a prompt to switch buffers",
|
||||||
help: "Typing the corresponding number opens switches to this buffer."
|
help: "Typing the corresponding number opens switches to this buffer."
|
||||||
@@ -369,7 +369,7 @@ function Mappings() //{{{
|
|||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["gH"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["gH"],
|
||||||
function(count) { vimperator.open("", vimperator.NEW_TAB); BrowserHome(); },
|
function() { vimperator.open("", vimperator.NEW_TAB); BrowserHome(); },
|
||||||
{
|
{
|
||||||
short_help: "Go home in a new tab",
|
short_help: "Go home in a new tab",
|
||||||
help: "Opens the homepage in a new tab."
|
help: "Opens the homepage in a new tab."
|
||||||
@@ -402,7 +402,7 @@ function Mappings() //{{{
|
|||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["gP"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["gP"],
|
||||||
function(count)
|
function()
|
||||||
{
|
{
|
||||||
vimperator.open(readFromClipboard(),
|
vimperator.open(readFromClipboard(),
|
||||||
vimperator.options["activate"].search(/\bpaste\b/) > -1 ?
|
vimperator.options["activate"].search(/\bpaste\b/) > -1 ?
|
||||||
@@ -476,28 +476,28 @@ function Mappings() //{{{
|
|||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["o"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["o"],
|
||||||
function(count) { vimperator.commandline.open(":", "open ", vimperator.modes.EX); },
|
function() { vimperator.commandline.open(":", "open ", vimperator.modes.EX); },
|
||||||
{
|
{
|
||||||
short_help: "Open one or more URLs in the current tab",
|
short_help: "Open one or more URLs in the current tab",
|
||||||
help: "See <code class=\"command\">:open</code> for more details."
|
help: "See <code class=\"command\">:open</code> for more details."
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["O"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["O"],
|
||||||
function(count) { vimperator.commandline.open(":", "open " + getCurrentLocation(), vimperator.modes.EX); },
|
function() { vimperator.commandline.open(":", "open " + getCurrentLocation(), vimperator.modes.EX); },
|
||||||
{
|
{
|
||||||
short_help: "Open one or more URLs in the current tab, based on current location",
|
short_help: "Open one or more URLs in the current tab, based on current location",
|
||||||
help: "Works like <code class=\"mapping\">o</code>, but preselects current URL in the <code class=\"command\">:open</code> query."
|
help: "Works like <code class=\"mapping\">o</code>, but preselects current URL in the <code class=\"command\">:open</code> query."
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["p", "<MiddleMouse>"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["p", "<MiddleMouse>"],
|
||||||
function(count) { vimperator.open(readFromClipboard()); },
|
function() { vimperator.open(readFromClipboard()); },
|
||||||
{
|
{
|
||||||
short_help: "Open (put) a URL based on the current clipboard contents in the current buffer",
|
short_help: "Open (put) a URL based on the current clipboard contents in the current buffer",
|
||||||
help: "You can also just select some non-URL text, and search for it with the default search engine or keyword (specified by the <code class=\"option\">'defsearch'</code> option) with <code class=\"mapping\">p</code>."
|
help: "You can also just select some non-URL text, and search for it with the default search engine or keyword (specified by the <code class=\"option\">'defsearch'</code> option) with <code class=\"mapping\">p</code>."
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["P"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["P"],
|
||||||
function(count)
|
function()
|
||||||
{
|
{
|
||||||
vimperator.open(readFromClipboard(),
|
vimperator.open(readFromClipboard(),
|
||||||
vimperator.options["activate"].search(/\bpaste\b/) > -1 ?
|
vimperator.options["activate"].search(/\bpaste\b/) > -1 ?
|
||||||
@@ -510,21 +510,21 @@ function Mappings() //{{{
|
|||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["r"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["r"],
|
||||||
function(count) { vimperator.tabs.reload(getBrowser().mCurrentTab, false); },
|
function() { vimperator.tabs.reload(getBrowser().mCurrentTab, false); },
|
||||||
{
|
{
|
||||||
short_help: "Reload",
|
short_help: "Reload",
|
||||||
help: "Forces reloading of the current page."
|
help: "Forces reloading of the current page."
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["R"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["R"],
|
||||||
function(count) { vimperator.tabs.reload(getBrowser().mCurrentTab, true); },
|
function() { vimperator.tabs.reload(getBrowser().mCurrentTab, true); },
|
||||||
{
|
{
|
||||||
short_help: "Reload while skipping the cache",
|
short_help: "Reload while skipping the cache",
|
||||||
help: "Forces reloading of the current page skipping the cache."
|
help: "Forces reloading of the current page skipping the cache."
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["t"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["t"],
|
||||||
function(count) { vimperator.commandline.open(":", "tabopen ", vimperator.modes.EX); },
|
function() { vimperator.commandline.open(":", "tabopen ", vimperator.modes.EX); },
|
||||||
{
|
{
|
||||||
short_help: "Open one or more URLs in a new tab",
|
short_help: "Open one or more URLs in a new tab",
|
||||||
help: "Like <code class=\"mapping\">o</code> but open URLs in a new tab.<br/>" +
|
help: "Like <code class=\"mapping\">o</code> but open URLs in a new tab.<br/>" +
|
||||||
@@ -532,7 +532,7 @@ function Mappings() //{{{
|
|||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["T"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["T"],
|
||||||
function(count) { vimperator.commandline.open(":", "tabopen " + getCurrentLocation(), vimperator.modes.EX); },
|
function() { vimperator.commandline.open(":", "tabopen " + getCurrentLocation(), vimperator.modes.EX); },
|
||||||
{
|
{
|
||||||
short_help: "Open one ore more URLs in a new tab, based on current location",
|
short_help: "Open one ore more URLs in a new tab, based on current location",
|
||||||
help: "Works like <code class=\"mapping\">t</code>, but preselects current URL in the <code class=\"command\">:tabopen</code> query."
|
help: "Works like <code class=\"mapping\">t</code>, but preselects current URL in the <code class=\"command\">:tabopen</code> query."
|
||||||
@@ -571,35 +571,39 @@ function Mappings() //{{{
|
|||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["zi", "+"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["zi", "+"],
|
||||||
function(count) { zoom_in(1); },
|
function(count) { vimperator.zoom("+" + (count > 0 ? count * 25 : 25) + "%"); },
|
||||||
{
|
{
|
||||||
short_help: "Zoom in current web page by 25%",
|
short_help: "Zoom in current web page by 25%",
|
||||||
help: "Currently no count supported."
|
help: "Currently no count supported.",
|
||||||
|
flags: Mappings.flags.COUNT
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["zI"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["zI"],
|
||||||
function(count) { zoom_in(4); },
|
function(count) { vimperator.zoom("+" + (count > 0 ? count * 100 : 100) + "%"); },
|
||||||
{
|
{
|
||||||
short_help: "Zoom in current web page by 100%",
|
short_help: "Zoom in current web page by 100%",
|
||||||
help: "Currently no count supported."
|
help: "Currently no count supported.",
|
||||||
|
flags: Mappings.flags.COUNT
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["zo", "-"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["zo", "-"],
|
||||||
function(count) { zoom_in(-1); },
|
function(count) { vimperator.zoom("-" + (count > 0 ? count * 25 : 25) + "%"); },
|
||||||
{
|
{
|
||||||
short_help: "Zoom out current web page by 25%",
|
short_help: "Zoom out current web page by 25%",
|
||||||
help: "Currently no count supported."
|
help: "Currently no count supported.",
|
||||||
|
flags: Mappings.flags.COUNT
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["zO"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["zO"],
|
||||||
function(count) { zoom_in(-4); },
|
function(count) { vimperator.zoom("-" + (count > 0 ? count * 100 : 100) + "%"); },
|
||||||
{
|
{
|
||||||
short_help: "Zoom out current web page by 100%",
|
short_help: "Zoom out current web page by 100%",
|
||||||
help: "Currently no count supported."
|
help: "Currently no count supported.",
|
||||||
|
flags: Mappings.flags.COUNT
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["zz"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["zz"],
|
||||||
zoom_to,
|
function(count) { vimperator.zoom(count > 0 ? "" + count + "%" : "100%"); },
|
||||||
{
|
{
|
||||||
short_help: "Set zoom value of the web page",
|
short_help: "Set zoom value of the web page",
|
||||||
help: "Zoom value can be between 25 and 500%. If it is omitted, zoom is reset to 100%.",
|
help: "Zoom value can be between 25 and 500%. If it is omitted, zoom is reset to 100%.",
|
||||||
@@ -607,14 +611,14 @@ function Mappings() //{{{
|
|||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["ZQ"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["ZQ"],
|
||||||
function(count) { vimperator.quit(false); },
|
function() { vimperator.quit(false); },
|
||||||
{
|
{
|
||||||
short_help: "Quit and don't save the session",
|
short_help: "Quit and don't save the session",
|
||||||
help: "Works like <code class=\"command\">:qall</code>."
|
help: "Works like <code class=\"command\">:qall</code>."
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["ZZ"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["ZZ"],
|
||||||
function(count) { vimperator.quit(true); },
|
function() { vimperator.quit(true); },
|
||||||
{
|
{
|
||||||
short_help: "Quit and save the session",
|
short_help: "Quit and save the session",
|
||||||
help: "Quit Vimperator, no matter how many tabs/windows are open. The session is stored.<br/>" +
|
help: "Quit Vimperator, no matter how many tabs/windows are open. The session is stored.<br/>" +
|
||||||
@@ -624,14 +628,14 @@ function Mappings() //{{{
|
|||||||
|
|
||||||
// scrolling commands
|
// scrolling commands
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["0", "^"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["0", "^"],
|
||||||
function(count) { scrollBufferAbsolute(0, -1); },
|
function() { scrollBufferAbsolute(0, -1); },
|
||||||
{
|
{
|
||||||
short_help: "Scroll to the absolute left of the document",
|
short_help: "Scroll to the absolute left of the document",
|
||||||
help: "Unlike in vim, <code class=\"mapping\">0</code> and <code class=\"mapping\">^</code> work exactly the same way."
|
help: "Unlike in vim, <code class=\"mapping\">0</code> and <code class=\"mapping\">^</code> work exactly the same way."
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["$"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["$"],
|
||||||
function(count) { scrollBufferAbsolute(100, -1); },
|
function() { scrollBufferAbsolute(100, -1); },
|
||||||
{
|
{
|
||||||
short_help: "Scroll to the absolute right of the document"
|
short_help: "Scroll to the absolute right of the document"
|
||||||
}
|
}
|
||||||
@@ -689,14 +693,14 @@ function Mappings() //{{{
|
|||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["<C-b>", "<C-u>", "<PageUp>", "<S-Space>"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["<C-b>", "<C-u>", "<PageUp>", "<S-Space>"],
|
||||||
function(count) { goDoCommand('cmd_scrollPageUp'); },
|
function() { goDoCommand('cmd_scrollPageUp'); },
|
||||||
{
|
{
|
||||||
short_help: "Scroll up a full page of the current document",
|
short_help: "Scroll up a full page of the current document",
|
||||||
help: "No count support for now."
|
help: "No count support for now."
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["<C-f>", "<C-d>", "<PageDown>", "<Space>"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["<C-f>", "<C-d>", "<PageDown>", "<Space>"],
|
||||||
function(count) { goDoCommand('cmd_scrollPageDown'); },
|
function() { goDoCommand('cmd_scrollPageDown'); },
|
||||||
{
|
{
|
||||||
short_help: "Scroll down a full page of the current document",
|
short_help: "Scroll down a full page of the current document",
|
||||||
help: "No count support for now."
|
help: "No count support for now."
|
||||||
@@ -760,7 +764,7 @@ function Mappings() //{{{
|
|||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["gU", "<C-BS>"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["gU", "<C-BS>"],
|
||||||
function(count) { vimperator.open("..."); },
|
function() { vimperator.open("..."); },
|
||||||
{
|
{
|
||||||
short_help: "Go to the root of the website",
|
short_help: "Go to the root of the website",
|
||||||
help: "<code class=\"mapping\">gU</code> on <code>http://www.example.com/dir1/dir2/file.htm</code> opens <code>http://www.example.com/</code>.<br/>" +
|
help: "<code class=\"mapping\">gU</code> on <code>http://www.example.com/dir1/dir2/file.htm</code> opens <code>http://www.example.com/</code>.<br/>" +
|
||||||
@@ -770,7 +774,7 @@ function Mappings() //{{{
|
|||||||
|
|
||||||
// hint managment
|
// hint managment
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["f"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["f"],
|
||||||
function(count) { vimperator.hints.enableHahMode(vimperator.modes.QUICK_HINT); },
|
function() { vimperator.hints.enableHahMode(vimperator.modes.QUICK_HINT); },
|
||||||
{
|
{
|
||||||
short_help: "Start QuickHint mode",
|
short_help: "Start QuickHint mode",
|
||||||
help: "In QuickHint mode, every hintable item (according to the <code class=\"option\">'hinttags'</code> XPath query) is assigned a label.<br/>" +
|
help: "In QuickHint mode, every hintable item (according to the <code class=\"option\">'hinttags'</code> XPath query) is assigned a label.<br/>" +
|
||||||
@@ -779,7 +783,7 @@ function Mappings() //{{{
|
|||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["F"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["F"],
|
||||||
function(count) { vimperator.hints.enableHahMode(vimperator.modes.ALWAYS_HINT); },
|
function() { vimperator.hints.enableHahMode(vimperator.modes.ALWAYS_HINT); },
|
||||||
{
|
{
|
||||||
short_help: "Start AlwaysHint mode",
|
short_help: "Start AlwaysHint mode",
|
||||||
help: "In AlwaysHint mode, every hintable item (according to the <code class=\"option\">'hinttags'</code> XPath query) is assigned a label.<br/>" +
|
help: "In AlwaysHint mode, every hintable item (according to the <code class=\"option\">'hinttags'</code> XPath query) is assigned a label.<br/>" +
|
||||||
@@ -789,7 +793,7 @@ function Mappings() //{{{
|
|||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, [";"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, [";"],
|
||||||
function(count) { vimperator.hints.enableHahMode(vimperator.modes.EXTENDED_HINT); },
|
function() { vimperator.hints.enableHahMode(vimperator.modes.EXTENDED_HINT); },
|
||||||
{
|
{
|
||||||
short_help: "Start ExtendedHint mode",
|
short_help: "Start ExtendedHint mode",
|
||||||
help: "ExtendedHint mode is useful, since in this mode you can yank link locations, or open them in a new window.<br/>" +
|
help: "ExtendedHint mode is useful, since in this mode you can yank link locations, or open them in a new window.<br/>" +
|
||||||
@@ -813,21 +817,21 @@ function Mappings() //{{{
|
|||||||
|
|
||||||
// search management
|
// search management
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["g/"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["g/"],
|
||||||
function(count) { vimperator.search.openSearchDialog(); },
|
function() { vimperator.search.openSearchDialog(); },
|
||||||
{
|
{
|
||||||
short_help: "Search forward for a pattern",
|
short_help: "Search forward for a pattern",
|
||||||
help: "Buggy on many sites, use / if you want a reliable search!"
|
help: "Buggy on many sites, use / if you want a reliable search!"
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["n"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["n"],
|
||||||
function(count) { vimperator.search.findNext(); },
|
function() { vimperator.search.findNext(); },
|
||||||
{
|
{
|
||||||
short_help: "Find next",
|
short_help: "Find next",
|
||||||
help: "Repeat the last \"/\" 1 time (until count is supported)."
|
help: "Repeat the last \"/\" 1 time (until count is supported)."
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["N"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["N"],
|
||||||
function(count) { vimperator.search.findPrevious(); },
|
function() { vimperator.search.findPrevious(); },
|
||||||
{
|
{
|
||||||
short_help: "Find previous",
|
short_help: "Find previous",
|
||||||
help: "Repeat the last \"/\" 1 time (until count is supported) in the opposite direction."
|
help: "Repeat the last \"/\" 1 time (until count is supported) in the opposite direction."
|
||||||
@@ -836,21 +840,21 @@ function Mappings() //{{{
|
|||||||
|
|
||||||
// vimperator management
|
// vimperator management
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["<F1>"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["<F1>"],
|
||||||
function(count) { vimperator.help(null); },
|
function() { vimperator.help(null); },
|
||||||
{
|
{
|
||||||
short_help: "Open help window",
|
short_help: "Open help window",
|
||||||
help: "The default section is shown, if you need help for a specific topic, try <code class=\"command\">:help <F1></code> (jumping to a specific section not implemented yet)."
|
help: "The default section is shown, if you need help for a specific topic, try <code class=\"command\">:help <F1></code> (jumping to a specific section not implemented yet)."
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, [":"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, [":"],
|
||||||
function(count) { vimperator.commandline.open(":", "", vimperator.modes.EX); },
|
function() { vimperator.commandline.open(":", "", vimperator.modes.EX); },
|
||||||
{
|
{
|
||||||
short_help: "Start command line mode",
|
short_help: "Start command line mode",
|
||||||
help: "In command line mode, you can perform extended commands, which may require arguments."
|
help: "In command line mode, you can perform extended commands, which may require arguments."
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["I"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["I"],
|
||||||
function(count) { vimperator.addMode(null, vimperator.modes.ESCAPE_ALL_KEYS); },
|
function() { vimperator.addMode(null, vimperator.modes.ESCAPE_ALL_KEYS); },
|
||||||
{
|
{
|
||||||
short_help: "Disable vimperator keys",
|
short_help: "Disable vimperator keys",
|
||||||
help: "Starts an 'ignorekeys' mode, where all keys except <code class=\"mapping\"><Esc></code> are passed to the next event handler.<br/>" +
|
help: "Starts an 'ignorekeys' mode, where all keys except <code class=\"mapping\"><Esc></code> are passed to the next event handler.<br/>" +
|
||||||
@@ -860,7 +864,7 @@ function Mappings() //{{{
|
|||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["<C-v>"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["<C-v>"],
|
||||||
function(count) { vimperator.addMode(null, vimperator.modes.ESCAPE_ONE_KEY); },
|
function() { vimperator.addMode(null, vimperator.modes.ESCAPE_ONE_KEY); },
|
||||||
{
|
{
|
||||||
short_help: "Escape next key",
|
short_help: "Escape next key",
|
||||||
help: "If you need to pass a certain key to a javascript form field or another extension prefix the key with <code class=\"mapping\"><C-v></code>.<br/>" +
|
help: "If you need to pass a certain key to a javascript form field or another extension prefix the key with <code class=\"mapping\"><C-v></code>.<br/>" +
|
||||||
|
|||||||
@@ -677,7 +677,42 @@ const vimperator = (function() //{{{
|
|||||||
if (Options.getFirefoxPref('dom.popup_allowed_events', 'change click dblclick mouseup reset submit')
|
if (Options.getFirefoxPref('dom.popup_allowed_events', 'change click dblclick mouseup reset submit')
|
||||||
== popup_allowed_events + " keypress")
|
== popup_allowed_events + " keypress")
|
||||||
Options.setFirefoxPref('dom.popup_allowed_events', popup_allowed_events);
|
Options.setFirefoxPref('dom.popup_allowed_events', popup_allowed_events);
|
||||||
|
},
|
||||||
|
|
||||||
|
// @param value MUST be a string, it can have the following form: "+20%", "200%", "-30"
|
||||||
|
// @return false if argument could not be parsed or zoom level too high
|
||||||
|
zoom: function(value)
|
||||||
|
{
|
||||||
|
if (typeof value != "string")
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var zoomMgr = ZoomManager.prototype.getInstance();
|
||||||
|
var new_zoom_value = 100;
|
||||||
|
|
||||||
|
var matches = value.match(/^\s*(\+|-)?(\d+)(%)?\s*/);
|
||||||
|
if (!matches || !matches[2])
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (matches[1] == "+")
|
||||||
|
new_zoom_value = zoomMgr.textZoom + parseInt(matches[2]);
|
||||||
|
else if (matches[1] == "-")
|
||||||
|
new_zoom_value = zoomMgr.textZoom - parseInt(matches[2]);
|
||||||
|
else
|
||||||
|
new_zoom_value = parseInt(matches[2]);
|
||||||
|
|
||||||
|
|
||||||
|
if (new_zoom_value < 25 || new_zoom_value > 500)
|
||||||
|
{
|
||||||
|
vimperator.echoerr("Zoom value must be between 25% and 500%");
|
||||||
|
vimperator.beep();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
zoomMgr.textZoom = new_zoom_value;
|
||||||
|
vimperator.hints.reshowHints();
|
||||||
|
vimperator.echo("Zoom value: " + new_zoom_value + "%");
|
||||||
|
}
|
||||||
|
|
||||||
} //}}}
|
} //}}}
|
||||||
})(); //}}}
|
})(); //}}}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user