From db83ce8dc33352ca05f7739f99b79da1c25a0ccf Mon Sep 17 00:00:00 2001 From: tophf Date: Sun, 9 Apr 2017 21:33:17 +0300 Subject: [PATCH] demote getClickedStyle* to its local usage scope --- .eslintrc | 2 -- dom.js | 10 ---------- popup.js | 14 +++++++++++--- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/.eslintrc b/.eslintrc index fa044597..e81cbc5d 100644 --- a/.eslintrc +++ b/.eslintrc @@ -36,8 +36,6 @@ globals: tDocLoader: false # dom.js onDOMready: false - getClickedStyleId: false - getClickedStyleElement: false scrollElementIntoView: false animateElement: false $: false diff --git a/dom.js b/dom.js index 5c4b50a0..2214fa82 100644 --- a/dom.js +++ b/dom.js @@ -25,16 +25,6 @@ function onDOMready() { } -function getClickedStyleId(event) { - return (getClickedStyleElement(event) || {}).styleId; -} - - -function getClickedStyleElement(event) { - return event.target.closest('.entry'); -} - - function scrollElementIntoView(element) { // align to the top/bottom of the visible area if wasn't visible const bounds = element.getBoundingClientRect(); diff --git a/popup.js b/popup.js index d891a7b5..bacb1316 100644 --- a/popup.js +++ b/popup.js @@ -238,6 +238,14 @@ function createStyleElement({ Object.assign(handleEvent, { + getClickedStyleId(event) { + return (handleEvent.getClickedStyleElement(event) || {}).styleId; + }, + + getClickedStyleElement(event) { + return event.target.closest('.entry'); + }, + name(event) { this.checkbox.click(); event.preventDefault(); @@ -245,13 +253,13 @@ Object.assign(handleEvent, { toggle(event) { saveStyle({ - id: getClickedStyleId(event), + id: handleEvent.getClickedStyleId(event), enabled: this.type == 'checkbox' ? this.checked : this.matches('.enable'), }); }, delete(event) { - const id = getClickedStyleId(event); + const id = handleEvent.getClickedStyleId(event); const box = $('#confirm'); box.dataset.display = true; box.style.cssText = ''; @@ -281,7 +289,7 @@ Object.assign(handleEvent, { }, indicator(event) { - const entry = getClickedStyleElement(event); + const entry = handleEvent.getClickedStyleElement(event); const info = template.regexpProblemExplanation.cloneNode(true); $$('#' + info.id).forEach(el => el.remove()); $$('a', info).forEach(el => (el.onclick = handleEvent.openURLandHide));