summaryrefslogtreecommitdiff
path: root/web/js/tools.js
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2018-11-06 06:35:23 +0300
committerDevaev Maxim <[email protected]>2018-11-06 06:35:23 +0300
commiteb476ffdd2442e17cf07ad769a9b82d86cdc5eb1 (patch)
tree608cccd08ec1d0e230089117bcad6188faefd491 /web/js/tools.js
parentf0ae427d8e4bbd82653abdb8e2aef8ffe32fc732 (diff)
better sliders
Diffstat (limited to 'web/js/tools.js')
-rw-r--r--web/js/tools.js28
1 files changed, 27 insertions, 1 deletions
diff --git a/web/js/tools.js b/web/js/tools.js
index 068032ac..22ef0a28 100644
--- a/web/js/tools.js
+++ b/web/js/tools.js
@@ -36,12 +36,38 @@ var tools = new function() {
};
};
+ this.setOnUpSlider = function(el, delay, display_callback, execute_callback) {
+ el.execution_timer = null;
+ el.activated = false;
+
+ var clear_timer = function() {
+ if (el.execution_timer) {
+ clearTimeout(el.execution_timer);
+ el.execution_timer = null;
+ }
+ };
+
+ el.oninput = el.onchange = () => display_callback(el.value);
+
+ el.onmousedown = el.ontouchstart = function() {
+ clear_timer();
+ el.activated = true;
+ };
+
+ el.onmouseup = el.ontouchend = function(event) {
+ event.preventDefault();
+ clear_timer();
+ el.execution_timer = setTimeout(function() {
+ execute_callback(el.value);
+ }, delay);
+ };
+ };
+
this.debug = function(...args) {
if (__debug) {
console.log("LOG/DEBUG", ...args); // eslint-disable-line no-console
}
};
-
this.info = (...args) => console.log("LOG/INFO", ...args); // eslint-disable-line no-console
this.error = (...args) => console.error("LOG/ERROR", ...args); // eslint-disable-line no-console