diff options
author | Devaev Maxim <[email protected]> | 2018-09-08 01:16:37 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2018-09-09 01:30:41 +0300 |
commit | 15981e62b52eefbf7ca8c7f24d20554ea7c9b4bf (patch) | |
tree | 17301fb258416956b80da735fe72c6ff041582cc /kvmd/web/js/tools.js | |
parent | 3a68c2ae1001f1207e639925d10d5f88f62d4430 (diff) |
touch improvements
Diffstat (limited to 'kvmd/web/js/tools.js')
-rw-r--r-- | kvmd/web/js/tools.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/kvmd/web/js/tools.js b/kvmd/web/js/tools.js index 67149085..76f27b7d 100644 --- a/kvmd/web/js/tools.js +++ b/kvmd/web/js/tools.js @@ -10,6 +10,25 @@ var tools = new function() { return http; }; + this.setOnClick = function(el, callback) { + el.onclick = el.ontouchend = function(event) { + event.preventDefault(); + callback(); + }; + }; + this.setOnDown = function(el, callback) { + el.onmousedown = el.ontouchstart = function(event) { + event.preventDefault(); + callback(); + }; + }; + this.setOnUp = function(el, callback) { + el.onmouseup = el.ontouchend = function(event) { + event.preventDefault(); + callback(); + }; + }; + this.debug = function(...args) { if (__debug) { console.log("LOG/DEBUG", ...args); // eslint-disable-line no-console |