demote getClickedStyle* to its local usage scope

This commit is contained in:
tophf 2017-04-09 21:33:17 +03:00
parent eb0c57d716
commit db83ce8dc3
3 changed files with 11 additions and 15 deletions

View File

@ -36,8 +36,6 @@ globals:
tDocLoader: false
# dom.js
onDOMready: false
getClickedStyleId: false
getClickedStyleElement: false
scrollElementIntoView: false
animateElement: false
$: false

10
dom.js
View File

@ -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();

View File

@ -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));