aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjez2011-01-31 10:37:29 +0800
committerjez2011-01-31 10:43:29 +0800
commit3f34de770e11b41183e914a7fd7e66a4ac877730 (patch)
tree9182f9066b1e64855568c995dd590e253e3907aa
parent761ce574cf63cd5cea299e1dad917a459c572cbf (diff)
parent35d58590b0e09e88c92ca3d49b5ba3b1ff622665 (diff)
downloadvimium-3f34de770e11b41183e914a7fd7e66a4ac877730.tar.bz2
Merge branch 'master' into filter-hints
Conflicts: CREDITS commands.js
-rw-r--r--CREDITS2
-rw-r--r--README.markdown49
-rw-r--r--background_page.html26
-rw-r--r--commands.js253
-rw-r--r--helpDialog.html42
-rw-r--r--options.html2
-rw-r--r--vimiumFrontend.js52
7 files changed, 292 insertions, 134 deletions
diff --git a/CREDITS b/CREDITS
index a83cb77f..2b88ed9e 100644
--- a/CREDITS
+++ b/CREDITS
@@ -7,6 +7,7 @@ Contributors:
akhilman
Bill Mill (github: llimllib)
Branden Rolston <brolston@gmail.com> (github: branden)
+ Christian Stefanescu (github: stchris)
ConradIrwin
drizzd
int3
@@ -20,5 +21,6 @@ Contributors:
Werner Laurensse (github: ab3)
Svein-Erik Larsen <feinom@gmail.com> (github: feinom)
Bill Casarin <jb@jb55.com> (github: jb55)
+ R.T. Lechow <rtlechow@gmail.com> (github: rtlechow)
Feel free to add real names in addition to GitHub usernames.
diff --git a/README.markdown b/README.markdown
index 3a9352ca..9b122f56 100644
--- a/README.markdown
+++ b/README.markdown
@@ -20,8 +20,8 @@ The Settings page can be found by clicking the Options button next to Vimium on
Keyboard Bindings
-----------------
-Modifier keys are specified as follows: <c-x>, <m-x>, <a-x> for ctrl+x, meta+x, and alt+x
-respectively.
+Modifier keys are specified as <c-x>, <m-x>, <a-x> for ctrl+x, meta+x, and alt+x
+respectively. You can change any of these shortcuts under "Advanced Options".
Navigating the current page:
h scroll left
@@ -34,23 +34,20 @@ Navigating the current page:
<c-u>, <c-y> scroll up a page
<c-f> scroll down a full page
<c-b> scroll up a full page
- zH scroll all the way left
- zL scroll all the way right
- f activate link hints mode to open in current tab
- F activate link hints mode to open in new tab
- <a-f> activate link hints mode to open multiple links in a new tab
+ f open a link in the current tab
+ F open a link in a new tab
r reload
gs view source
zi zoom in
zo zoom out
- / enter find mode -- type your search query and hit enter to search or esc to cancel
- n cycle forward to the next find match
- N cycle backward to the previous find match
i enter insert mode -- all commands will be ignored until you hit esc to exit
yy copy the current url to the clipboard
- gu go up one level in the URL hierarchy
gf cycle forward to the next frame
- gi focus the first (or n-th) text input box on the page
+
+Using find:
+ / enter find mode -- type your search query and hit enter to search or esc to cancel
+ n cycle forward to the next find match
+ N cycle backward to the previous find match
Navigating your history:
H go back in history
@@ -63,24 +60,37 @@ Manipulating tabs:
d close current tab
u restore closed tab (i.e. unwind the 'd' command)
+Additional advanced browsing commands:
+ ]] Follow the link labeled 'next' or '>'. Helpful for browsing paginated sites.
+ [[ Follow the link labeled 'previous' or '<'. Helpful for browsing paginated sites.
+ <a-f> open multiple links in a new tab
+ gi focus the first (or n-th) text input box on the page
+ gu go up one level in the URL hierarchy
+ zH scroll all the way left
+ zL scroll all the way right
+ z0 reset zoom to default value
+
+
Vimium supports command repetition so, for example, hitting '5t' will open 5 tabs in rapid succession. ESC (or
<c-[>) will clear any partial commands in the queue.
-Keys can be unmapped and remapped to different commands under Advanced Options.
Contributing
------------
-You'd like to fix a bug or implement a feature? Great! Check out the bugs on our issues tracker, or implement one of
-the suggestions there that have been tagged 'todo'. If you have a suggestion of your own, start a discussion on
-the issues tracker or on the [mailing list][list_url]. If it mirrors a similar feature in another browser or in Vim
-itself, let us know! Once you've picked something to work on, add a comment to the respective issue so others don't
-duplicate your effort.
+You'd like to fix a bug or implement a feature? Great! Check out the bugs on our issues tracker, or implement
+one of the suggestions there that have been tagged 'todo'. If you have a suggestion of your own, start a
+discussion on the issues tracker or on the [mailing list][list_url]. If it mirrors a similar feature in
+another browser or in Vim itself, let us know! Once you've picked something to work on, add a comment to the
+respective issue so others don't duplicate your effort.
When you're done, send us a pull request on Github. Feel free to include a change to the CREDITS file with your patch.
[list_url]: http://groups.google.com/group/vimium-dev?hl=en
+Some brief coding style guidelines: 1) follow the style already present in the file, 2) ensure your lines
+don't exceed 110 characters.
+
Release Notes
-------------
@@ -88,6 +98,9 @@ Release Notes
- Some sites are now excluded by default.
- View source (`gs`) now opens in a new tab.
+- Support for browsing paginated sites using `]]` and `[[` to go forward and backward respectively.
+- `z0` will reset the zoom level for the current page.
+- Many of the less-used commands are now marked as "advanced" and hidden in the help dialog by default, so that the core command set is more focused and approachable.
- Bugfixes.
1.21 (10/24/2010)
diff --git a/background_page.html b/background_page.html
index 106db28d..abb91677 100644
--- a/background_page.html
+++ b/background_page.html
@@ -196,11 +196,12 @@
var html = [];
for (var i = 0; i < commandGroups[group].length; i++) {
var command = commandGroups[group][i];
- bindings = (commandsToKey[command] || [""]).join(", ")
- if (showUnboundCommands || commandsToKey[command])
- {
- html.push("<tr><td>", escapeHtml(bindings),
- "</td><td>:</td><td>", availableCommands[command].description);
+ bindings = (commandsToKey[command] || [""]).join(", ");
+ if (showUnboundCommands || commandsToKey[command]) {
+ html.push(
+ "<tr class='" + (advancedCommands.indexOf(command) >= 0 ? "advanced" : "") + "'>",
+ "<td>", escapeHtml(bindings), "</td>",
+ "<td>:</td><td>", availableCommands[command].description);
if (showCommandNames)
html.push("<span class='commandName'>(" + command + ")</span>");
@@ -686,6 +687,21 @@
if (localStorage["keyMappings"])
parseCustomKeyMappings(localStorage["keyMappings"]);
+ // In version 1.22, we changed the mapping for "d" and "u" to be scroll page down/up instead of close
+ // and restore tab. For existing users, we want to preserve existing behavior for them by adding some
+ // custom key mappings on their behalf.
+ if (localStorage.previousVersion == "1.21") {
+ var customKeyMappings = localStorage["keyMappings"] || "";
+ if ((keyToCommandRegistry["d"] || {}).command == "scrollPageDown")
+ customKeyMappings += "\nmap d removeTab";
+ if ((keyToCommandRegistry["u"] || {}).command == "scrollPageUp")
+ customKeyMappings += "\nmap u restoreTab";
+ if (customKeyMappings != "") {
+ localStorage["keyMappings"] = customKeyMappings;
+ parseCustomKeyMappings(customKeyMappings);
+ }
+ }
+
populateValidFirstKeys();
populateSingleKeyCommands();
if (shouldShowUpgradeMessage())
diff --git a/commands.js b/commands.js
index ec35c569..de70a0a9 100644
--- a/commands.js
+++ b/commands.js
@@ -1,22 +1,28 @@
var availableCommands = {};
var keyToCommandRegistry = {};
-function addCommand(command, description, isBackgroundCommand, passCountToFunction) {
- if (availableCommands[command])
- {
+/*
+ * Registers a command, making it available to be optionally bound to a key.
+ * options:
+ * - background: whether this command needs to be run against the background page.
+ * - passCountToFunction: true if this command should have any digits which were typed prior to the
+ * command passed to it. This is used to implement e.g. "closing of 3 tabs".
+ */
+function addCommand(command, description, options) {
+ if (availableCommands[command]) {
console.log(command, "is already defined! Check commands.js for duplicates.");
return;
}
+ options = options || {};
availableCommands[command] = { description: description,
- isBackgroundCommand: isBackgroundCommand,
- passCountToFunction: passCountToFunction
+ isBackgroundCommand: options.background,
+ passCountToFunction: options.passCountToFunction
};
}
function mapKeyToCommand(key, command) {
- if (!availableCommands[command])
- {
+ if (!availableCommands[command]) {
console.log(command, "doesn't exist!");
return;
}
@@ -81,105 +87,131 @@ function parseCustomKeyMappings(customKeyMappings) {
function clearKeyMappingsAndSetDefaults() {
keyToCommandRegistry = {};
- mapKeyToCommand('?', 'showHelp');
- mapKeyToCommand('j', 'scrollDown');
- mapKeyToCommand('k', 'scrollUp');
- mapKeyToCommand('h', 'scrollLeft');
- mapKeyToCommand('l', 'scrollRight');
- mapKeyToCommand('gg', 'scrollToTop');
- mapKeyToCommand('G', 'scrollToBottom');
- mapKeyToCommand('zH', 'scrollToLeft');
- mapKeyToCommand('zL', 'scrollToRight');
- mapKeyToCommand('<c-e>', 'scrollDown');
- mapKeyToCommand('<c-y>', 'scrollUp');
- mapKeyToCommand('<c-d>', 'scrollPageDown');
- mapKeyToCommand('<c-u>', 'scrollPageUp');
- mapKeyToCommand('<c-f>', 'scrollFullPageDown');
- mapKeyToCommand('<c-b>', 'scrollFullPageUp');
- mapKeyToCommand('r', 'reload');
- mapKeyToCommand('gs', 'toggleViewSource');
-
- mapKeyToCommand('i', 'enterInsertMode');
-
- mapKeyToCommand('H', 'goBack');
- mapKeyToCommand('L', 'goForward');
- mapKeyToCommand('gu', 'goUp');
-
- mapKeyToCommand('zi', 'zoomIn');
- mapKeyToCommand('zo', 'zoomOut');
-
- mapKeyToCommand('gi', 'focusInput');
-
- mapKeyToCommand('f', 'linkHints.activateMode');
- mapKeyToCommand('F', 'linkHints.activateModeToOpenInNewTab');
- mapKeyToCommand('<a-f>', 'linkHints.activateModeWithQueue');
-
- mapKeyToCommand('/', 'enterFindMode');
- mapKeyToCommand('n', 'performFind');
- mapKeyToCommand('N', 'performBackwardsFind');
-
- mapKeyToCommand('yy', 'copyCurrentUrl');
-
- mapKeyToCommand('K', 'nextTab');
- mapKeyToCommand('J', 'previousTab');
- mapKeyToCommand('gt', 'nextTab');
- mapKeyToCommand('gT', 'previousTab');
-
- mapKeyToCommand('t', 'createTab');
- mapKeyToCommand('d', 'removeTab');
- mapKeyToCommand('u', 'restoreTab');
-
- mapKeyToCommand('gf', 'nextFrame');
+ var defaultKeyMappings = {
+ "?": "showHelp",
+ "j": "scrollDown",
+ "k": "scrollUp",
+ "h": "scrollLeft",
+ "l": "scrollRight",
+ "gg": "scrollToTop",
+ "G": "scrollToBottom",
+ "zH": "scrollToLeft",
+ "zL": "scrollToRight",
+ "<c-e>": "scrollDown",
+ "<c-y>": "scrollUp",
+
+ // scrollPageDown and scrollPageUp are mapped to two keys because they are very common actions so we
+ // want them to be mapped without a modifier key, but we also want to be faithful to Vim convention which
+ // has them on ctrl+D and ctrl+U.
+ "d": "scrollPageDown",
+ "u": "scrollPageUp",
+ "<c-d>": "scrollPageDown",
+ "<c-u>": "scrollPageUp",
+ "<c-f>": "scrollFullPageDown",
+ "<c-b>": "scrollFullPageUp",
+ "r": "reload",
+ "gs": "toggleViewSource",
+
+ "i": "enterInsertMode",
+
+ "H": "goBack",
+ "L": "goForward",
+ "gu": "goUp",
+
+ "zi": "zoomIn",
+ "zo": "zoomOut",
+ "z0": "zoomReset",
+
+ "gi": "focusInput",
+
+ "f": "activateLinkHintsMode",
+ "F": "activateLinkHintsModeToOpenInNewTab",
+ "<a-f>": "activateLinkHintsModeWithQueue",
+
+ "/": "enterFindMode",
+ "n": "performFind",
+ "N": "performBackwardsFind",
+
+ "[[": "goPrevious",
+ "]]": "goNext",
+
+ "yy": "copyCurrentUrl",
+
+ "K": "nextTab",
+ "J": "previousTab",
+ "gt": "nextTab",
+ "gT": "previousTab",
+
+ "t": "createTab",
+ "x": "removeTab",
+ "X": "restoreTab",
+
+ "gf": "nextFrame"
+ };
+
+ for (var key in defaultKeyMappings)
+ mapKeyToCommand(key, defaultKeyMappings[key]);
}
-// Navigating the current page:
-addCommand('showHelp', 'Show help', true);
-addCommand('scrollDown', 'Scroll down');
-addCommand('scrollUp', 'Scroll up');
-addCommand('scrollLeft', 'Scroll left');
-addCommand('scrollRight', 'Scroll right');
-addCommand('scrollToTop', 'Scroll to the top of the page');
-addCommand('scrollToBottom', 'Scroll to the bottom of the page');
-addCommand('scrollToLeft', 'Scroll to the left of the page');
-addCommand('scrollToRight', 'Scroll to the right of the page');
-addCommand('scrollPageDown', 'Scroll a page down');
-addCommand('scrollPageUp', 'Scroll a page up');
-addCommand('scrollFullPageDown', 'Scroll a full page down');
-addCommand('scrollFullPageUp', 'Scroll a full page up');
-
-addCommand('reload', 'Reload the page');
-addCommand('toggleViewSource', 'View page source');
-addCommand('zoomIn', 'Zoom in');
-addCommand('zoomOut', 'Zoom out');
-addCommand('copyCurrentUrl', 'Copy the current URL to the clipboard');
-
-addCommand('enterInsertMode', 'Enter insert mode');
-
-addCommand('focusInput', 'Focus the first (or n-th) text box on the page', false, true);
-
-addCommand('linkHints.activateMode', 'Enter link hints mode to open links in current tab');
-addCommand('linkHints.activateModeToOpenInNewTab', 'Enter link hints mode to open links in new tab');
-addCommand('linkHints.activateModeWithQueue', 'Enter link hints mode to open multiple links in a new tab');
-
-addCommand('enterFindMode', 'Enter find mode');
-addCommand('performFind', 'Cycle forward to the next find match');
-addCommand('performBackwardsFind', 'Cycle backward to the previous find match');
-
-// Navigating your history:
-addCommand('goBack', 'Go back in history');
-addCommand('goForward', 'Go forward in history');
-
-// Navigating the URL hierarchy
-addCommand('goUp', 'Go up the URL hierarchy', false, true);
-
-// Manipulating tabs:
-addCommand('nextTab', 'Go one tab right', true);
-addCommand('previousTab', 'Go one tab left', true);
-addCommand('createTab', 'Create new tab', true);
-addCommand('removeTab', 'Close current tab', true);
-addCommand('restoreTab', "Restore closed tab", true);
+// This is a mapping of: commandIdentifier => [description, options].
+var commandDescriptions = {
+ // Navigating the current page
+ showHelp: ["Show help", { background: true }],
+ scrollDown: ["Scroll down"],
+ scrollUp: ["Scroll up"],
+ scrollLeft: ["Scroll left"],
+ scrollRight: ["Scroll right"],
+ scrollToTop: ["Scroll to the top of the page"],
+ scrollToBottom: ["Scroll to the bottom of the page"],
+ scrollToLeft: ["Scroll all the way to the left"],
+
+ scrollToRight: ["Scroll all the way to the right"],
+ scrollPageDown: ["Scroll a page down"],
+ scrollPageUp: ["Scroll a page up"],
+ scrollFullPageDown: ["Scroll a full page down"],
+ scrollFullPageUp: ["Scroll a full page up"],
+
+ reload: ["Reload the page"],
+ toggleViewSource: ["View page source"],
+ zoomIn: ["Zoom in"],
+ zoomOut: ["Zoom out"],
+ zoomReset: ["Reset zoom to default value"],
+ copyCurrentUrl: ["Copy the current URL to the clipboard"],
+
+ enterInsertMode: ["Enter insert mode"],
+
+ focusInput: ["Focus the first (or n-th) text box on the page", { passCountToFunction: true }],
+
+ activateLinkHintsMode: ["Open a link in the current tab"],
+ activateLinkHintsModeToOpenInNewTab: ["Open a link in a new tab"],
+ activateLinkHintsModeWithQueue: ["Open multiple links in a new tab"],
+
+ enterFindMode: ["Enter find mode"],
+ performFind: ["Cycle forward to the next find match"],
+ performBackwardsFind: ["Cycle backward to the previous find match"],
+
+ goPrevious: ["Follow the link labeled previous or <"],
+ goNext: ["Follow the link labeled next or >"],
+
+ // Navigating your history
+ goBack: ["Go back in history"],
+ goForward: ["Go forward in history"],
+
+ // Navigating the URL hierarchy
+ goUp: ["Go up the URL hierarchy", { passCountToFunction: true }],
+
+ // Manipulating tabs
+ nextTab: ["Go one tab right", { background: true }],
+ previousTab: ["Go one tab left", { background: true }],
+ createTab: ["Create new tab", { background: true }],
+ removeTab: ["Close current tab", { background: true }],
+ restoreTab: ["Restore closed tab", { background: true }],
+
+ nextFrame: ["Cycle forward to the next frame on the page", { background: true }]
+};
-addCommand('nextFrame', "Cycle forward to the next frame on the page", true);
+for (var command in commandDescriptions)
+ addCommand(command, commandDescriptions[command][0], commandDescriptions[command][1]);
// An ordered listing of all available commands, grouped by type. This is the order they will
@@ -189,10 +221,11 @@ var commandGroups = {
["scrollDown", "scrollUp", "scrollLeft", "scrollRight",
"scrollToTop", "scrollToBottom", "scrollToLeft", "scrollToRight", "scrollPageDown",
"scrollPageUp", "scrollFullPageUp", "scrollFullPageDown",
- "reload", "toggleViewSource", "zoomIn", "zoomOut", "copyCurrentUrl", "goUp",
+ "reload", "toggleViewSource", "zoomIn", "zoomOut", "zoomReset", "copyCurrentUrl", "goUp",
"enterInsertMode", "focusInput",
- "linkHints.activateMode", "linkHints.activateModeToOpenInNewTab", "linkHints.activateModeWithQueue",
- "enterFindMode", "performFind", "performBackwardsFind", "nextFrame"],
+ "activateLinkHintsMode", "activateLinkHintsModeToOpenInNewTab", "activateLinkHintsModeWithQueue",
+ "goPrevious", "goNext", "nextFrame"],
+ findCommands: ["enterFindMode", "performFind", "performBackwardsFind"],
historyNavigation:
["goBack", "goForward"],
tabManipulation:
@@ -200,3 +233,11 @@ var commandGroups = {
misc:
["showHelp"]
};
+
+// Rarely used commands are not shown by default in the help dialog or in the README. The goal is to present
+// a focused, high-signal set of commands to the new and casual user. Only those truly hungry for more power
+// from Vimium will uncover these gems.
+var advancedCommands = [
+ "scrollToLeft", "scrollToRight",
+ "zoomReset", "goUp", "focusInput", "activateLinkHintsModeWithQueue",
+ "goPrevious", "goNext"]; \ No newline at end of file
diff --git a/helpDialog.html b/helpDialog.html
index ee35fc9b..c21c8b7b 100644
--- a/helpDialog.html
+++ b/helpDialog.html
@@ -55,9 +55,10 @@
font-weight:bold;
padding-top:3px;
}
- #vimiumHelpDialog .commandName {
- font-family:"courier new";
- }
+ #vimiumHelpDialog .commandName { font-family:"courier new"; }
+ /* Advanced commands are hidden by default until you show them. */
+ #vimiumHelpDialog .advanced { display: none; }
+ #vimiumHelpDialog .advanced td:nth-of-type(3) { color: #555; }
#vimiumHelpDialog .closeButton {
position:absolute;
right:10px;
@@ -79,7 +80,13 @@
cursor:default;
-webkit-user-select:none;
}
+ #vimiumHelpDialogFooter { position: relative; }
#vimiumHelpDialogFooter * { font-size:10px; }
+ #vimiumHelpDialogFooter .toggleAdvancedCommands {
+ position: absolute;
+ right: 2px;
+ top: -34px;
+ }
</style>
<!-- Note that the template placeholders (e.g. "pageNavigation") will be filled in by the background
@@ -95,6 +102,8 @@
</div>
<div class="vimiumColumn">
<table>
+ <tr><td></td><td></td><td class="vimiumHelpSectionTitle">Using find</td></tr>
+ {{findCommands}}
<tr><td></td><td></td><td class="vimiumHelpSectionTitle">Navigating history</td></tr>
{{historyNavigation}}
<tr><td></td><td></td><td class="vimiumHelpSectionTitle">Manipulating tabs</td></tr>
@@ -108,6 +117,8 @@
<div class="vimiumDivider"></div>
<div id="vimiumHelpDialogFooter">
+ <a href="#" class="toggleAdvancedCommands">Show advanced commands</a>
+
<div class="vimiumColumn">
Enjoying Vimium?
<a href="https://chrome.google.com/extensions/detail/dbepggeogbaibhgnhhndojpepiihcmeb">Leave us
@@ -118,4 +129,29 @@
<span>Version {{version}}</span><br/>
</div>
</div>
+
+ <script>
+ VimiumHelpDialog = {
+ init: function() {
+ this.dialogElement = document.getElementById("vimiumHelpDialog");
+ this.dialogElement.getElementsByClassName("toggleAdvancedCommands")[0].addEventListener("click",
+ VimiumHelpDialog.toggleAdvancedCommands, false);
+ },
+
+ /*
+ * Advanced commands are hidden by default so they don't overwhelm new and casual users.
+ */
+ toggleAdvancedCommands: function(event) {
+ event.preventDefault();
+ var advanced = VimiumHelpDialog.dialogElement.getElementsByClassName("advanced");
+ var shouldShow = (advanced[0].style.display == "" || advanced[0].style.display == "none");
+ VimiumHelpDialog.dialogElement.getElementsByClassName("toggleAdvancedCommands")[0].innerHTML =
+ shouldShow ? "Hide advanced commands" : "Show advanced commands";
+ for (var i = 0; i < advanced.length; i++)
+ advanced[i].style.display = (shouldShow ? "table-row" : "none");
+ }
+ };
+
+ VimiumHelpDialog.init();
+ </script>
</div>
diff --git a/options.html b/options.html
index 44b1d3e2..1724f51b 100644
--- a/options.html
+++ b/options.html
@@ -87,7 +87,7 @@
"userDefinedLinkHintCss", "keyMappings", "filterLinkHints"];
var postSaveHooks = {
- "keyMappings": function (value) {
+ keyMappings: function (value) {
backgroundPage = chrome.extension.getBackgroundPage();
backgroundPage.clearKeyMappingsAndSetDefaults();
backgroundPage.parseCustomKeyMappings(value);
diff --git a/vimiumFrontend.js b/vimiumFrontend.js
index 3ca5f6a2..c5b7bdf8 100644
--- a/vimiumFrontend.js
+++ b/vimiumFrontend.js
@@ -248,6 +248,11 @@ function zoomOut() {
saveZoomLevel(window.location.host, currentZoomLevel);
}
+function zoomReset() {
+ setPageZoomLevel(100, true);
+ saveZoomLevel(window.location.host, 100);
+}
+
function scrollToBottom() { window.scrollTo(window.pageXOffset, document.body.scrollHeight); }
function scrollToTop() { window.scrollTo(window.pageXOffset, 0); }
function scrollToLeft() { window.scrollTo(0, window.pageYOffset); }
@@ -569,6 +574,45 @@ function performBackwardsFind() {
findModeQueryHasResults = window.find(findModeQuery, false, true, true, false, true, false);
}
+function findAndFollowLink(linkStrings) {
+ for (i = 0; i < linkStrings.length; i++) {
+ var findModeQueryHasResults = window.find(linkStrings[i], false, true, true, false, true, false);
+ if (findModeQueryHasResults) {
+ var node = window.getSelection().anchorNode;
+ while (node.nodeName != 'BODY') {
+ if (node.nodeName == 'A') {
+ window.location = node.href;
+ return true;
+ }
+ node = node.parentNode;
+ }
+ }
+ }
+}
+
+function findAndFollowRel(value) {
+ var relTags = ['link', 'a', 'area'];
+ for (i = 0; i < relTags.length; i++) {
+ var elements = document.getElementsByTagName(relTags[i]);
+ for (j = 0; j < elements.length; j++) {
+ if (elements[j].hasAttribute('rel') && elements[j].rel == value) {
+ window.location = elements[j].href;
+ return true;
+ }
+ }
+ }
+}
+
+function goPrevious() {
+ var previousStrings = ["\bprev\b","\bprevious\b","\u00AB","<<","<"];
+ findAndFollowRel('prev') || findAndFollowLink(previousStrings);
+}
+
+function goNext() {
+ var nextStrings = ["\bnext\b","\u00BB",">>","\bmore\b",">"];
+ findAndFollowRel('next') || findAndFollowLink(nextStrings);
+}
+
function showFindModeHUDForQuery() {
if (findModeQueryHasResults || findModeQuery.length == 0)
HUD.show("/" + insertSpaces(findModeQuery));
@@ -610,12 +654,18 @@ function showHelpDialog(html, fid) {
isShowingHelpDialog = true;
var container = document.createElement("div");
container.id = "vimiumHelpDialogContainer";
+
+ document.body.appendChild(container);
+
container.innerHTML = html;
+ // This is necessary because innerHTML does not evaluate javascript embedded in <script> tags.
+ var scripts = Array.prototype.slice.call(container.getElementsByTagName("script"));
+ scripts.forEach(function(script) { eval(script.text); });
+
container.getElementsByClassName("closeButton")[0].addEventListener("click", hideHelpDialog, false);
container.getElementsByClassName("optionsPage")[0].addEventListener("click",
function() { chrome.extension.sendRequest({ handler: "openOptionsPageInNewTab" }); }, false);
- document.body.appendChild(container);
var dialog = document.getElementById("vimiumHelpDialog");
dialog.style.zIndex = "99999998";
var zoomFactor = currentZoomLevel / 100.0;