aboutsummaryrefslogtreecommitdiff
path: root/p/scripts/category.js
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2021-10-21 11:44:03 +0200
committerGravatar GitHub <noreply@github.com> 2021-10-21 11:44:03 +0200
commitb438d8bb3d4b3dea6d28d0b0c73da9393c9d8299 (patch)
treefe3c9550c2f3cd46edefae7ceda56407c80d8e36 /p/scripts/category.js
parentcfd625c5596f2ce20ab4341bb04ddb263552e417 (diff)
ESLint upgrade from JSHint (#3906)
* ESLint upgrade from JSHint * commit corresponding package.json * `npm run fix` for automatic JS and CSS fixes * Keep JSHint config for now
Diffstat (limited to 'p/scripts/category.js')
-rw-r--r--p/scripts/category.js194
1 files changed, 97 insertions, 97 deletions
diff --git a/p/scripts/category.js b/p/scripts/category.js
index 2a24bc47d..e75c04571 100644
--- a/p/scripts/category.js
+++ b/p/scripts/category.js
@@ -1,16 +1,15 @@
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0
-"use strict";
+'use strict';
/* globals context */
-/* jshint esversion:6, strict:global */
-var loading = false,
- dnd_successful = false;
+let loading = false;
+let dnd_successful = false;
function dragend_process(t) {
t.setAttribute('draggable', 'false');
if (loading) {
- setTimeout(function() {
+ setTimeout(function () {
dragend_process(t);
}, 50);
return;
@@ -25,13 +24,14 @@ function dragend_process(t) {
t.remove();
if (p.childElementCount <= 1) {
- p.insertAdjacentHTML('afterbegin', '<li class="item feed disabled" dropzone="move"><div class="alert-warn">' + context.i18n.category_empty + '</div></li>');
+ p.insertAdjacentHTML('afterbegin',
+ '<li class="item feed disabled" dropzone="move"><div class="alert-warn">' + context.i18n.category_empty + '</div></li>');
}
}
}
-var dragFeedId = '',
- dragHtml = '';
+let dragFeedId = '';
+let dragHtml = '';
function init_draggable() {
if (!window.context) {
@@ -42,99 +42,99 @@ function init_draggable() {
return;
}
- const draggable = '[draggable="true"]',
- dropzone = '[dropzone="move"]',
- dropSection = document.querySelector('.drop-section');
-
- dropSection.ondragstart = function(ev) {
- const li = ev.target.closest ? ev.target.closest(draggable) : null;
- if (li) {
- const drag = ev.target.closest('[draggable]');
- ev.dataTransfer.effectAllowed = 'move';
- dragHtml = drag.outerHTML;
- dragFeedId = drag.getAttribute('data-feed-id');
- ev.dataTransfer.setData('text', dragFeedId);
- drag.style.opacity = 0.3;
- dnd_successful = false;
- }
- };
+ const draggable = '[draggable="true"]';
+ const dropzone = '[dropzone="move"]';
+ const dropSection = document.querySelector('.drop-section');
+
+ dropSection.ondragstart = function (ev) {
+ const li = ev.target.closest ? ev.target.closest(draggable) : null;
+ if (li) {
+ const drag = ev.target.closest('[draggable]');
+ ev.dataTransfer.effectAllowed = 'move';
+ dragHtml = drag.outerHTML;
+ dragFeedId = drag.getAttribute('data-feed-id');
+ ev.dataTransfer.setData('text', dragFeedId);
+ drag.style.opacity = 0.3;
+ dnd_successful = false;
+ }
+ };
- dropSection.ondragend = function(ev) {
- const li = ev.target.closest ? ev.target.closest(draggable) : null;
- if (li) {
- dragend_process(li);
- }
- };
+ dropSection.ondragend = function (ev) {
+ const li = ev.target.closest ? ev.target.closest(draggable) : null;
+ if (li) {
+ dragend_process(li);
+ }
+ };
- dropSection.ondragenter = function(ev) {
- const li = ev.target.closest ? ev.target.closest(dropzone) : null;
- if (li) {
- li.classList.add('drag-hover');
- return false;
- }
- };
-
- dropSection.onddragleave = function(ev) {
- const li = ev.target.closest ? ev.target.closest(dropzone) : null;
- if (li) {
- const scroll_top = document.documentElement.scrollTop,
- top = li.offsetTop,
- left = li.offsetLeft,
- right = left + li.clientWidth,
- bottom = top + li.clientHeight,
- mouse_x = ev.screenX,
- mouse_y = ev.clientY + scroll_top;
-
- if (left <= mouse_x && mouse_x <= right &&
+ dropSection.ondragenter = function (ev) {
+ const li = ev.target.closest ? ev.target.closest(dropzone) : null;
+ if (li) {
+ li.classList.add('drag-hover');
+ return false;
+ }
+ };
+
+ dropSection.onddragleave = function (ev) {
+ const li = ev.target.closest ? ev.target.closest(dropzone) : null;
+ if (li) {
+ const scroll_top = document.documentElement.scrollTop;
+ const top = li.offsetTop;
+ const left = li.offsetLeft;
+ const right = left + li.clientWidth;
+ const bottom = top + li.clientHeight;
+ const mouse_x = ev.screenX;
+ const mouse_y = ev.clientY + scroll_top;
+
+ if (left <= mouse_x && mouse_x <= right &&
top <= mouse_y && mouse_y <= bottom) {
- // HACK because dragleave is triggered when hovering children!
- return;
- }
- li.classList.remove('drag-hover');
+ // HACK because dragleave is triggered when hovering children!
+ return;
}
- };
+ li.classList.remove('drag-hover');
+ }
+ };
- dropSection.ondragover = function(ev) {
- const li = ev.target.closest ? ev.target.closest(dropzone) : null;
- if (li) {
- ev.dataTransfer.dropEffect = "move";
- return false;
- }
- };
-
- dropSection.ondrop = function(ev) {
- const li = ev.target.closest ? ev.target.closest(dropzone) : null;
- if (li) {
- loading = true;
-
- const req = new XMLHttpRequest();
- req.open('POST', './?c=feed&a=move', true);
- req.responseType = 'json';
- req.onload = function (e) {
- if (this.status == 200) {
- li.insertAdjacentHTML('afterend', dragHtml);
- if (li.classList.contains('disabled')) {
- li.remove();
- }
- dnd_successful = true;
- }
- };
- req.onloadend = function (e) {
- loading = false;
- dragFeedId = '';
- dragHtml = '';
- };
- req.setRequestHeader('Content-Type', 'application/json');
- req.send(JSON.stringify({
- f_id: dragFeedId,
- c_id: li.parentElement.getAttribute('data-cat-id'),
- _csrf: context.csrf,
- }));
-
- li.classList.remove('drag-hover');
- return false;
- }
- };
+ dropSection.ondragover = function (ev) {
+ const li = ev.target.closest ? ev.target.closest(dropzone) : null;
+ if (li) {
+ ev.dataTransfer.dropEffect = 'move';
+ return false;
+ }
+ };
+
+ dropSection.ondrop = function (ev) {
+ const li = ev.target.closest ? ev.target.closest(dropzone) : null;
+ if (li) {
+ loading = true;
+
+ const req = new XMLHttpRequest();
+ req.open('POST', './?c=feed&a=move', true);
+ req.responseType = 'json';
+ req.onload = function (e) {
+ if (this.status == 200) {
+ li.insertAdjacentHTML('afterend', dragHtml);
+ if (li.classList.contains('disabled')) {
+ li.remove();
+ }
+ dnd_successful = true;
+ }
+ };
+ req.onloadend = function (e) {
+ loading = false;
+ dragFeedId = '';
+ dragHtml = '';
+ };
+ req.setRequestHeader('Content-Type', 'application/json');
+ req.send(JSON.stringify({
+ f_id: dragFeedId,
+ c_id: li.parentElement.getAttribute('data-cat-id'),
+ _csrf: context.csrf,
+ }));
+
+ li.classList.remove('drag-hover');
+ return false;
+ }
+ };
}
function archiving() {
@@ -143,7 +143,7 @@ function archiving() {
if (e.target.id === 'use_default_purge_options') {
slider.querySelectorAll('.archiving').forEach(function (element) {
element.hidden = e.target.checked;
- if (!e.target.checked) element.style.visibility = 'visible'; //Help for Edge 44
+ if (!e.target.checked) element.style.visibility = 'visible'; // Help for Edge 44
});
}
});