aboutsummaryrefslogtreecommitdiff
path: root/src/content/presenters
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/presenters')
-rw-r--r--src/content/presenters/ConsoleFramePresenter.ts4
-rw-r--r--src/content/presenters/FindPresenter.ts8
-rw-r--r--src/content/presenters/FocusPresenter.ts8
-rw-r--r--src/content/presenters/FollowPresenter.ts32
-rw-r--r--src/content/presenters/Hint.ts12
-rw-r--r--src/content/presenters/NavigationPresenter.ts4
-rw-r--r--src/content/presenters/ScrollPresenter.ts50
7 files changed, 59 insertions, 59 deletions
diff --git a/src/content/presenters/ConsoleFramePresenter.ts b/src/content/presenters/ConsoleFramePresenter.ts
index 62db2bb..63c78fb 100644
--- a/src/content/presenters/ConsoleFramePresenter.ts
+++ b/src/content/presenters/ConsoleFramePresenter.ts
@@ -6,7 +6,7 @@ export default interface ConsoleFramePresenter {
export class ConsoleFramePresenterImpl implements ConsoleFramePresenter {
initialize(): void {
- let iframe = document.createElement('iframe');
+ const iframe = document.createElement('iframe');
iframe.src = browser.runtime.getURL('build/console.html');
iframe.id = 'vimvixen-console-frame';
iframe.className = 'vimvixen-console-frame';
@@ -14,7 +14,7 @@ export class ConsoleFramePresenterImpl implements ConsoleFramePresenter {
}
blur(): void {
- let ele = document.getElementById('vimvixen-console-frame');
+ const ele = document.getElementById('vimvixen-console-frame');
if (!ele) {
throw new Error('console frame not created');
}
diff --git a/src/content/presenters/FindPresenter.ts b/src/content/presenters/FindPresenter.ts
index f171d2f..98d8088 100644
--- a/src/content/presenters/FindPresenter.ts
+++ b/src/content/presenters/FindPresenter.ts
@@ -26,13 +26,13 @@ declare var window: MyWindow;
export class FindPresenterImpl implements FindPresenter {
find(keyword: string, backwards: boolean): boolean {
- let caseSensitive = false;
- let wrapScan = true;
+ const caseSensitive = false;
+ const wrapScan = true;
// NOTE: aWholeWord dows not implemented, and aSearchInFrames does not work
// because of same origin policy
- let found = window.find(keyword, caseSensitive, backwards, wrapScan);
+ const found = window.find(keyword, caseSensitive, backwards, wrapScan);
if (found) {
return found;
}
@@ -42,7 +42,7 @@ export class FindPresenterImpl implements FindPresenter {
}
clearSelection(): void {
- let sel = window.getSelection();
+ const sel = window.getSelection();
if (sel) {
sel.removeAllRanges();
}
diff --git a/src/content/presenters/FocusPresenter.ts b/src/content/presenters/FocusPresenter.ts
index 7e20cd6..842c41e 100644
--- a/src/content/presenters/FocusPresenter.ts
+++ b/src/content/presenters/FocusPresenter.ts
@@ -6,10 +6,10 @@ export default interface FocusPresenter {
export class FocusPresenterImpl implements FocusPresenter {
focusFirstElement(): boolean {
- let inputTypes = ['email', 'number', 'search', 'tel', 'text', 'url'];
- let inputSelector = inputTypes.map(type => `input[type=${type}]`).join(',');
- let targets = window.document.querySelectorAll(inputSelector + ',textarea');
- let target = Array.from(targets).find(doms.isVisible);
+ const inputTypes = ['email', 'number', 'search', 'tel', 'text', 'url'];
+ const inputSelector = inputTypes.map(type => `input[type=${type}]`).join(',');
+ const targets = window.document.querySelectorAll(inputSelector + ',textarea');
+ const target = Array.from(targets).find(doms.isVisible);
if (target instanceof HTMLInputElement) {
target.focus();
return true;
diff --git a/src/content/presenters/FollowPresenter.ts b/src/content/presenters/FollowPresenter.ts
index 0132621..fef8140 100644
--- a/src/content/presenters/FollowPresenter.ts
+++ b/src/content/presenters/FollowPresenter.ts
@@ -23,12 +23,12 @@ const inViewport = (
viewSize: Size,
framePosition: Point,
): boolean => {
- let {
+ const {
top, left, bottom, right
} = doms.viewportRect(element);
- let doc = win.document;
- let frameWidth = doc.documentElement.clientWidth;
- let frameHeight = doc.documentElement.clientHeight;
+ const doc = win.document;
+ const frameWidth = doc.documentElement.clientWidth;
+ const frameHeight = doc.documentElement.clientHeight;
if (right < 0 || bottom < 0 || top > frameHeight || left > frameWidth) {
// out of frame
@@ -47,10 +47,10 @@ const isAriaHiddenOrAriaDisabled = (win: Window, element: Element): boolean => {
if (!element || win.document.documentElement === element) {
return false;
}
- for (let attr of ['aria-hidden', 'aria-disabled']) {
- let value = element.getAttribute(attr);
+ for (const attr of ['aria-hidden', 'aria-disabled']) {
+ const value = element.getAttribute(attr);
if (value !== null) {
- let hidden = value.toLowerCase();
+ const hidden = value.toLowerCase();
if (hidden === '' || hidden === 'true') {
return true;
}
@@ -79,15 +79,15 @@ export class FollowPresenterImpl implements FollowPresenter {
}
getTargetCount(viewSize: Size, framePosition: Point): number {
- let targets = this.getTargets(viewSize, framePosition);
+ const targets = this.getTargets(viewSize, framePosition);
return targets.length;
}
createHints(viewSize: Size, framePosition: Point, tags: string[]): void {
- let targets = this.getTargets(viewSize, framePosition);
- let min = Math.min(targets.length, tags.length);
+ const targets = this.getTargets(viewSize, framePosition);
+ const min = Math.min(targets.length, tags.length);
for (let i = 0; i < min; ++i) {
- let target = targets[i];
+ const target = targets[i];
if (target instanceof HTMLAnchorElement ||
target instanceof HTMLAreaElement) {
this.hints.push(new LinkHint(target, tags[i]));
@@ -98,8 +98,8 @@ export class FollowPresenterImpl implements FollowPresenter {
}
filterHints(prefix: string): void {
- let shown = this.hints.filter(h => h.getTag().startsWith(prefix));
- let hidden = this.hints.filter(h => !h.getTag().startsWith(prefix));
+ const shown = this.hints.filter(h => h.getTag().startsWith(prefix));
+ const hidden = this.hints.filter(h => !h.getTag().startsWith(prefix));
shown.forEach(h => h.show());
hidden.forEach(h => h.hide());
@@ -115,9 +115,9 @@ export class FollowPresenterImpl implements FollowPresenter {
}
private getTargets(viewSize: Size, framePosition: Point): HTMLElement[] {
- let all = window.document.querySelectorAll(TARGET_SELECTOR);
- let filtered = Array.prototype.filter.call(all, (element: HTMLElement) => {
- let style = window.getComputedStyle(element);
+ const all = window.document.querySelectorAll(TARGET_SELECTOR);
+ const filtered = Array.prototype.filter.call(all, (element: HTMLElement) => {
+ const style = window.getComputedStyle(element);
// AREA's 'display' in Browser style is 'none'
return (element.tagName === 'AREA' || style.display !== 'none') &&
diff --git a/src/content/presenters/Hint.ts b/src/content/presenters/Hint.ts
index 60c0f4c..44b8185 100644
--- a/src/content/presenters/Hint.ts
+++ b/src/content/presenters/Hint.ts
@@ -6,7 +6,7 @@ interface Point {
}
const hintPosition = (element: Element): Point => {
- let { left, top, right, bottom } = doms.viewportRect(element);
+ const { left, top, right, bottom } = doms.viewportRect(element);
if (element.tagName !== 'AREA') {
return { x: left, y: top };
@@ -26,15 +26,15 @@ export default abstract class Hint {
constructor(target: HTMLElement, tag: string) {
this.tag = tag;
- let doc = target.ownerDocument;
+ const doc = target.ownerDocument;
if (doc === null) {
throw new TypeError('ownerDocument is null');
}
- let { x, y } = hintPosition(target);
- let { scrollX, scrollY } = window;
+ const { x, y } = hintPosition(target);
+ const { scrollX, scrollY } = window;
- let hint = doc.createElement('span');
+ const hint = doc.createElement('span');
hint.className = 'vimvixen-hint';
hint.textContent = tag;
hint.style.left = x + scrollX + 'px';
@@ -95,7 +95,7 @@ export class InputHint extends Hint {
}
activate(): void {
- let target = this.target;
+ const target = this.target;
switch (target.tagName.toLowerCase()) {
case 'input':
switch ((target as HTMLInputElement).type) {
diff --git a/src/content/presenters/NavigationPresenter.ts b/src/content/presenters/NavigationPresenter.ts
index 11d96ec..951e62a 100644
--- a/src/content/presenters/NavigationPresenter.ts
+++ b/src/content/presenters/NavigationPresenter.ts
@@ -49,7 +49,7 @@ export class NavigationPresenterImpl implements NavigationPresenter {
// Code common to linkPrev and linkNext which navigates to the specified page.
private linkRel(rel: 'prev' | 'next'): void {
- let link = selectLast<HTMLLinkElement>(`link[rel~=${rel}][href]`);
+ const link = selectLast<HTMLLinkElement>(`link[rel~=${rel}][href]`);
if (link) {
window.location.href = link.href;
return;
@@ -57,7 +57,7 @@ export class NavigationPresenterImpl implements NavigationPresenter {
const pattern = REL_PATTERN[rel];
- let a = selectLast<HTMLAnchorElement>(`a[rel~=${rel}][href]`) ||
+ const a = selectLast<HTMLAnchorElement>(`a[rel~=${rel}][href]`) ||
// `innerText` is much slower than `textContent`, but produces much better
// (i.e. less unexpected) results
selectLast('a[href]', lnk => pattern.test(lnk.innerText));
diff --git a/src/content/presenters/ScrollPresenter.ts b/src/content/presenters/ScrollPresenter.ts
index e83f172..387ab62 100644
--- a/src/content/presenters/ScrollPresenter.ts
+++ b/src/content/presenters/ScrollPresenter.ts
@@ -8,7 +8,7 @@ let scrolling = false;
let lastTimeoutId: number | null = null;
const isScrollableStyle = (element: Element): boolean => {
- let { overflowX, overflowY } = window.getComputedStyle(element);
+ const { overflowX, overflowY } = window.getComputedStyle(element);
return !(overflowX !== 'scroll' && overflowX !== 'auto' &&
overflowY !== 'scroll' && overflowY !== 'auto');
};
@@ -27,9 +27,9 @@ const findScrollable = (element: Element): Element | null => {
return element;
}
- let children = Array.from(element.children).filter(doms.isVisible);
- for (let child of children) {
- let scrollable = findScrollable(child);
+ const children = Array.from(element.children).filter(doms.isVisible);
+ for (const child of children) {
+ const scrollable = findScrollable(child);
if (scrollable) {
return scrollable;
}
@@ -44,7 +44,7 @@ const scrollTarget = () => {
if (isOverflowed(window.document.body)) {
return window.document.body;
}
- let target = findScrollable(window.document.documentElement);
+ const target = findScrollable(window.document.documentElement);
if (target) {
return target;
}
@@ -79,8 +79,8 @@ class Scroller {
}
scrollBy(x: number, y: number): void {
- let left = this.element.scrollLeft + x;
- let top = this.element.scrollTop + y;
+ const left = this.element.scrollLeft + x;
+ const top = this.element.scrollTop + y;
this.scrollTo(left, top);
}
@@ -110,12 +110,12 @@ export default interface ScrollPresenter {
export class ScrollPresenterImpl {
getScroll(): Point {
- let target = scrollTarget();
+ const target = scrollTarget();
return { x: target.scrollLeft, y: target.scrollTop };
}
scrollVertically(count: number, smooth: boolean): void {
- let target = scrollTarget();
+ const target = scrollTarget();
let delta = SCROLL_DELTA_Y * count;
if (scrolling) {
delta = SCROLL_DELTA_Y * count * 4;
@@ -124,7 +124,7 @@ export class ScrollPresenterImpl {
}
scrollHorizonally(count: number, smooth: boolean): void {
- let target = scrollTarget();
+ const target = scrollTarget();
let delta = SCROLL_DELTA_X * count;
if (scrolling) {
delta = SCROLL_DELTA_X * count * 4;
@@ -133,8 +133,8 @@ export class ScrollPresenterImpl {
}
scrollPages(count: number, smooth: boolean): void {
- let target = scrollTarget();
- let height = target.clientHeight;
+ const target = scrollTarget();
+ const height = target.clientHeight;
let delta = height * count;
if (scrolling) {
delta = height * count;
@@ -143,35 +143,35 @@ export class ScrollPresenterImpl {
}
scrollTo(x: number, y: number, smooth: boolean): void {
- let target = scrollTarget();
+ const target = scrollTarget();
new Scroller(target, smooth).scrollTo(x, y);
}
scrollToTop(smooth: boolean): void {
- let target = scrollTarget();
- let x = target.scrollLeft;
- let y = 0;
+ const target = scrollTarget();
+ const x = target.scrollLeft;
+ const y = 0;
new Scroller(target, smooth).scrollTo(x, y);
}
scrollToBottom(smooth: boolean): void {
- let target = scrollTarget();
- let x = target.scrollLeft;
- let y = target.scrollHeight;
+ const target = scrollTarget();
+ const x = target.scrollLeft;
+ const y = target.scrollHeight;
new Scroller(target, smooth).scrollTo(x, y);
}
scrollToHome(smooth: boolean): void {
- let target = scrollTarget();
- let x = 0;
- let y = target.scrollTop;
+ const target = scrollTarget();
+ const x = 0;
+ const y = target.scrollTop;
new Scroller(target, smooth).scrollTo(x, y);
}
scrollToEnd(smooth: boolean): void {
- let target = scrollTarget();
- let x = target.scrollWidth;
- let y = target.scrollTop;
+ const target = scrollTarget();
+ const x = target.scrollWidth;
+ const y = target.scrollTop;
new Scroller(target, smooth).scrollTo(x, y);
}
}