Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ Some functionalities are also available when you're using original pdf viewer, b
| settings.tabsMRUOrder | true | Whether to list opened tabs in order of most recently used beneath Omnibar. |
| settings.historyMUOrder | true | Whether to list history in order of most used beneath Omnibar. |
| settings.newTabPosition | 'default' | Where to new tab. ["left", "right", "first", "last", "default"] |
| settings.newTabPositionOmnibar | 'default' | Where to new tab when opening from the Omnibar. Set to "newTabPosition" (the default) to use the same behavior as the `newTabPosition` setting above. ["left", "right", "first", "last", "default", "newTabPosition"] |
| settings.interceptedErrors | [] | Indicates for which errors Surfingkeys will show error page, so that you could use Surfingkeys on those error pages. For example, ["*"] to show error page for all errors, or ["net::ERR_NAME_NOT_RESOLVED"] to show error page only for ERR_NAME_NOT_RESOLVED, please refer to [net_error_list.h](https://github.com/adobe/chromium/blob/master/net/base/net_error_list.h) for complete error list. |
| settings.enableEmojiInsertion | false | Whether to turn on Emoji completion in Insert mode. |
| settings.startToShowEmoji | 2 | How many characters are needed after colon to show emoji suggestion. |
Expand Down
12 changes: 11 additions & 1 deletion src/background/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ function start(browser) {
repeatThreshold: 99,
tabsMRUOrder: true,
newTabPosition: 'default',
newTabPositionOmnibar: 'newTabPosition',
showTabIndices: false,
interceptedErrors: []
};
Expand Down Expand Up @@ -1083,9 +1084,18 @@ function start(browser) {
}

function openUrlInNewTab(currentTab, url, message) {
let tabPositionConfKey = message.tabPositionConfKey || "newTabPosition";
let tabPosition = message.tabPosition;

if (tabPositionConfKey !== "newTabPosition" && conf[tabPositionConfKey] === "newTabPosition") {
tabPositionConfKey = "newTabPosition";
}

tabPosition = tabPosition || conf[tabPositionConfKey];

var newTabPosition;
if (currentTab) {
switch (conf.newTabPosition) {
switch (tabPosition) {
case 'left':
newTabPosition = currentTab.index;
break;
Expand Down
3 changes: 2 additions & 1 deletion src/content_scripts/common/hints.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ div.hint-scrollable {
tabbed: tabbed,
active: active
},
url: getHref(element)
url: getHref(element),
tabPositionConfKey: "newTabPosition"
});
} else {
self.mouseoutLastElement();
Expand Down
5 changes: 3 additions & 2 deletions src/content_scripts/common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ function constructSearchURL(se, word) {
* btn.click();
* }, {domain: /youtube.com/i});
*/
function tabOpenLink(str, simultaneousness) {
function tabOpenLink(str, simultaneousness, tabPosition) {
simultaneousness = simultaneousness || 5;

var urls;
Expand All @@ -745,7 +745,8 @@ function tabOpenLink(str, simultaneousness) {
tab: {
tabbed: true
},
url: url
url: url,
tabPosition: tabPosition
});
});
// queue the left for later opening when there is one tab closed.
Expand Down
31 changes: 31 additions & 0 deletions src/content_scripts/common/visual.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ function createVisual(clipboard, hints) {
state = 0,
status = ['', 'Caret', 'Range'],
mark_template = document.createElement("div"),
current_mark_template = document.createElement("div"),
cursor = document.createElement("div");
cursor.className = "surfingkeys_cursor";
cursor.style.zIndex = 2147483299;
Expand Down Expand Up @@ -480,6 +481,15 @@ function createVisual(clipboard, hints) {
};

function select(found) {
for (let el of document.getElementsByClassName("surfingkeys_match_mark")) {
let positionStyles = _getMarkPositionStyles(el)
el.setAttribute("style", mark_template.getAttribute("style"))
_setMarkPositionStyles(el, positionStyles)
}
let positionStyles = _getMarkPositionStyles(found[2][0])
found[2][0].setAttribute("style", current_mark_template.getAttribute("style"))
_setMarkPositionStyles(found[2][0], positionStyles)

self.hideCursor();
if (selection.anchorNode && state === 2) {
selection.extend(found[0], found[1]);
Expand All @@ -489,6 +499,26 @@ function createVisual(clipboard, hints) {
self.showCursor();
}

function _getMarkPositionStyles(mark) {
let ret = {}
ret.position = mark.style.position;
ret.zIndex = mark.style.zIndex;
ret.left = mark.style.left;
ret.top = mark.style.top;
ret.width = mark.style.width;
ret.height = mark.style.height;
return ret;
}

function _setMarkPositionStyles(mark, styles) {
mark.style.position = styles.position;
mark.style.zIndex = styles.zIndex;
mark.style.left = styles.left;
mark.style.top = styles.top;
mark.style.width = styles.width;
mark.style.height = styles.height;
}

function modifySelection() {
var sel = self.map_node.meta.annotation.split(" ");
var alter = (state === 2) ? "extend" : "move";
Expand Down Expand Up @@ -810,6 +840,7 @@ function createVisual(clipboard, hints) {

cursor.setAttribute('style', _style.cursor || '');
mark_template.setAttribute('style', _style.marks || '');
current_mark_template.setAttribute('style', _style.current_mark || '');
};
return self;
}
Expand Down
3 changes: 2 additions & 1 deletion src/content_scripts/ui/omnibar.js
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,8 @@ function createOmnibar(front, clipboard) {
tabbed: this.tabbed,
active: this.activeTab
},
url: url
url: url,
tabPositionConfKey: "newTabPositionOmnibar"
});
}
return this.activeTab;
Expand Down