From 70fa4230268a422d0b7eef1ea223ca5cc1c14646 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 18 Feb 2021 21:51:18 +0300 Subject: initial for RIP prototype/scriptaculous --- js/common.js | 135 ++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 105 insertions(+), 30 deletions(-) (limited to 'js/common.js') diff --git a/js/common.js b/js/common.js index fb5cc6531..982bb94a7 100755 --- a/js/common.js +++ b/js/common.js @@ -3,35 +3,117 @@ /* global dijit, __, App, Ajax */ /* eslint-disable no-new */ -/* error reporting shim */ -// TODO: deprecated; remove -/* function exception_error(e, e_compat, filename, lineno, colno) { - if (typeof e == "string") - e = e_compat; +Element.prototype.hasClassName = function(className) { + dojo.hasClass(this, className); +}; + +Element.prototype.addClassName = function(className) { + dojo.addClass(this, className); +}; + +Element.prototype.removeClassName = function(className) { + dojo.removeClass(this, className); +}; + +Element.prototype.setStyle = function(args) { + Object.keys(args).forEach((k) => { + this.style[k] = args[k]; + }); +}; + +Element.prototype.show = function() { + this.style.display = ""; +}; + +Element.prototype.hide = function() { + this.style.display = "none"; +}; + +Element.prototype.toggle = function() { + if (this.visible()) + this.show(); + else + this.hide(); +}; + +Element.prototype.visible = function() { + // TODO: should we actually check for offsetWidth/offsetHeight == 0? + return this.style.display != "none"; +} + +Element.visible = function(elem) { + if (typeof elem == "string") + elem = document.getElementById(elem); + + return elem.visible(); +} + +Element.show = function(elem) { + if (typeof elem == "string") + elem = document.getElementById(elem); + + return elem.show(); +} + +Element.hide = function(elem) { + if (typeof elem == "string") + elem = document.getElementById(elem); + + return elem.hide(); +} + +Element.toggle = function(elem) { + if (typeof elem == "string") + elem = document.getElementById(elem); + + return elem.toggle(); +} - App.Error.report(e, {filename: filename, lineno: lineno, colno: colno}); -} */ +Element.hasClassName = function (id, className) { + return document.getElementById(id).hasClassName(className); +} /* xhr shorthand helpers */ /* exported xhrPost */ -function xhrPost(url, params, complete) { +function xhrPost(url, params = {}, complete = undefined) { console.log("xhrPost:", params); return new Promise((resolve, reject) => { - new Ajax.Request(url, { - parameters: params, - onComplete: function(reply) { - if (complete != undefined) complete(reply); - - resolve(reply); - } - }); + if (typeof __csrf_token != "undefined") + params = {...params, ...{csrf_token: __csrf_token}}; + + dojo.xhrPost({url: url, + postData: dojo.objectToQuery(params), + handleAs: "text", + error: function(error) { + reject(error); + }, + load: function(data, ioargs) { + if (complete != undefined) + complete(ioargs.xhr); + + resolve(ioargs.xhr) + }}); }); } +Array.prototype.remove = function(s) { + for (let i=0; i < this.length; i++) { + if (s == this[i]) this.splice(i, 1); + } +}; + +Array.prototype.uniq = function() { + return this.filter((v, i, a) => a.indexOf(v) === i); +}; + +String.prototype.stripTags = function() { + return this.replace(/<\w+(\s+("[^"]*"|'[^']*'|[^>])+)?(\/)?>|<\/\w+>/gi, ''); +} + /* exported xhrJson */ -function xhrJson(url, params, complete) { +function xhrJson(url, params = {}, complete = undefined) { return new Promise((resolve, reject) => xhrPost(url, params).then((reply) => { let obj = null; @@ -48,13 +130,6 @@ function xhrJson(url, params, complete) { })); } -/* add method to remove element from array */ -Array.prototype.remove = function(s) { - for (let i=0; i < this.length; i++) { - if (s == this[i]) this.splice(i, 1); - } -}; - /* common helpers not worthy of separate Dojo modules */ /* exported Lists */ @@ -70,8 +145,8 @@ const Lists = { checked ? row.addClassName("Selected") : row.removeClassName("Selected"); }, select: function(elemId, selected) { - $(elemId).select("li").each((row) => { - const checkNode = row.select(".dijitCheckBox,input[type=checkbox]")[0]; + $(elemId).querySelectorAll("li").forEach((row) => { + const checkNode = row.querySelector(".dijitCheckBox,input[type=checkbox]"); if (checkNode) { const widget = dijit.getEnclosingWidget(checkNode); @@ -101,8 +176,8 @@ const Tables = { }, select: function(elemId, selected) { - $(elemId).select("tr").each((row) => { - const checkNode = row.select(".dijitCheckBox,input[type=checkbox]")[0]; + $(elemId).querySelector("tr").forEach((row) => { + const checkNode = row.querySelector(".dijitCheckBox,input[type=checkbox]"); if (checkNode) { const widget = dijit.getEnclosingWidget(checkNode); @@ -119,7 +194,7 @@ const Tables = { getSelected: function(elemId) { const rv = []; - $(elemId).select("tr").each((row) => { + $(elemId).querySelector("tr").forEach((row) => { if (row.hasClassName("Selected")) { // either older prefix-XXX notation or separate attribute const rowId = row.getAttribute("data-row-id") || row.id.replace(/^[A-Z]*?-/, ""); @@ -173,7 +248,7 @@ const Notify = { kind = kind || this.KIND_GENERIC; keep = keep || false; - const notify = $("notify"); + const notify = App.byId("notify"); window.clearTimeout(this.timeout); -- cgit v1.2.3 From f77c17c6f00d37ac535f065589335e801824641b Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 18 Feb 2021 22:05:06 +0300 Subject: add Element toggleClassName --- js/common.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'js/common.js') diff --git a/js/common.js b/js/common.js index 982bb94a7..95eaa3e36 100755 --- a/js/common.js +++ b/js/common.js @@ -15,6 +15,14 @@ Element.prototype.removeClassName = function(className) { dojo.removeClass(this, className); }; +Element.prototype.toggleClassName = function(className) { + if (this.hasClassName(className)) + this.removeClassName(className); + else + this.addClassName(className); +}; + + Element.prototype.setStyle = function(args) { Object.keys(args).forEach((k) => { this.style[k] = args[k]; -- cgit v1.2.3 From e61e7c8356b86dfa1b89c7ae2ef78c8020c54d90 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 18 Feb 2021 22:14:40 +0300 Subject: compat shim fixes --- js/common.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'js/common.js') diff --git a/js/common.js b/js/common.js index 95eaa3e36..49a6dc0b7 100755 --- a/js/common.js +++ b/js/common.js @@ -4,22 +4,24 @@ /* eslint-disable no-new */ Element.prototype.hasClassName = function(className) { - dojo.hasClass(this, className); + return dojo.hasClass(this, className); }; Element.prototype.addClassName = function(className) { - dojo.addClass(this, className); + return dojo.addClass(this, className); }; Element.prototype.removeClassName = function(className) { - dojo.removeClass(this, className); + return dojo.removeClass(this, className); }; Element.prototype.toggleClassName = function(className) { + console.log(this, className); + if (this.hasClassName(className)) - this.removeClassName(className); + return this.removeClassName(className); else - this.addClassName(className); + return this.addClassName(className); }; @@ -77,8 +79,11 @@ Element.toggle = function(elem) { return elem.toggle(); } -Element.hasClassName = function (id, className) { - return document.getElementById(id).hasClassName(className); +Element.hasClassName = function (elem, className) { + if (typeof elem == "string") + elem = document.getElementById(elem); + + return elem.hasClassName(className); } /* xhr shorthand helpers */ -- cgit v1.2.3 From 89fd9ec8c32863043e8a2385a6b2ef68fe984366 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 18 Feb 2021 22:15:54 +0300 Subject: compat shim fixes --- js/common.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/common.js') diff --git a/js/common.js b/js/common.js index 49a6dc0b7..74353c123 100755 --- a/js/common.js +++ b/js/common.js @@ -41,9 +41,9 @@ Element.prototype.hide = function() { Element.prototype.toggle = function() { if (this.visible()) - this.show(); - else this.hide(); + else + this.show(); }; Element.prototype.visible = function() { -- cgit v1.2.3 From b6c3dde1cca77fd6e024b5ddc56dd25e600353ba Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 18 Feb 2021 22:26:00 +0300 Subject: add $/423 shims --- js/common.js | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'js/common.js') diff --git a/js/common.js b/js/common.js index 74353c123..9275bd09f 100755 --- a/js/common.js +++ b/js/common.js @@ -3,6 +3,17 @@ /* global dijit, __, App, Ajax */ /* eslint-disable no-new */ +function $(id) { + console.warn("FIXME: please use App.getById() or document.getElementById() instead of $():", id); + return document.getElementById(id); +} + +function $$(query) { + console.warn("FIXME: please use App.findAll() or document.querySelectorAll() instead of $():", query); + return document.querySelectorAll(query); +} + + Element.prototype.hasClassName = function(className) { return dojo.hasClass(this, className); }; -- cgit v1.2.3 From d57e7eaa98b8669837d6ccb98d6f7d0d739f52e8 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 19 Feb 2021 06:40:35 +0300 Subject: move stuff in common.js around a bit --- js/common.js | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'js/common.js') diff --git a/js/common.js b/js/common.js index 9275bd09f..1adf5d56e 100755 --- a/js/common.js +++ b/js/common.js @@ -27,8 +27,6 @@ Element.prototype.removeClassName = function(className) { }; Element.prototype.toggleClassName = function(className) { - console.log(this, className); - if (this.hasClassName(className)) return this.removeClassName(className); else @@ -97,6 +95,20 @@ Element.hasClassName = function (elem, className) { return elem.hasClassName(className); } +Array.prototype.remove = function(s) { + for (let i=0; i < this.length; i++) { + if (s == this[i]) this.splice(i, 1); + } +}; + +Array.prototype.uniq = function() { + return this.filter((v, i, a) => a.indexOf(v) === i); +}; + +String.prototype.stripTags = function() { + return this.replace(/<\w+(\s+("[^"]*"|'[^']*'|[^>])+)?(\/)?>|<\/\w+>/gi, ''); +} + /* xhr shorthand helpers */ /* exported xhrPost */ @@ -122,20 +134,6 @@ function xhrPost(url, params = {}, complete = undefined) { }); } -Array.prototype.remove = function(s) { - for (let i=0; i < this.length; i++) { - if (s == this[i]) this.splice(i, 1); - } -}; - -Array.prototype.uniq = function() { - return this.filter((v, i, a) => a.indexOf(v) === i); -}; - -String.prototype.stripTags = function() { - return this.replace(/<\w+(\s+("[^"]*"|'[^']*'|[^>])+)?(\/)?>|<\/\w+>/gi, ''); -} - /* exported xhrJson */ function xhrJson(url, params = {}, complete = undefined) { return new Promise((resolve, reject) => -- cgit v1.2.3 From 00310d2d23dd459c17b3f6e86a127de348b330f8 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 19 Feb 2021 06:58:50 +0300 Subject: cleanup some unused code, fix App.byId() invoked by wrong name --- js/common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/common.js') diff --git a/js/common.js b/js/common.js index 1adf5d56e..6dd5713df 100755 --- a/js/common.js +++ b/js/common.js @@ -4,7 +4,7 @@ /* eslint-disable no-new */ function $(id) { - console.warn("FIXME: please use App.getById() or document.getElementById() instead of $():", id); + console.warn("FIXME: please use App.byId() or document.getElementById() instead of $():", id); return document.getElementById(id); } -- cgit v1.2.3 From bec35200e97adabf4880a92bad40ec5bbe4848d1 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 19 Feb 2021 07:29:21 +0300 Subject: fix some eslint-related stuff --- js/common.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'js/common.js') diff --git a/js/common.js b/js/common.js index 6dd5713df..a5e1e503a 100755 --- a/js/common.js +++ b/js/common.js @@ -1,6 +1,6 @@ 'use strict'; -/* global dijit, __, App, Ajax */ +/* global dijit, __, App, dojo, __csrf_token */ /* eslint-disable no-new */ function $(id) { @@ -111,6 +111,8 @@ String.prototype.stripTags = function() { /* xhr shorthand helpers */ +// TODO: this should become xhr { Post: ..., Json: ... } + /* exported xhrPost */ function xhrPost(url, params = {}, complete = undefined) { console.log("xhrPost:", params); @@ -144,6 +146,7 @@ function xhrJson(url, params = {}, complete = undefined) { obj = JSON.parse(reply.responseText); } catch (e) { console.error("xhrJson", e, reply); + reject(e); } if (complete != undefined) complete(obj); -- cgit v1.2.3 From d26269865f633e36ab1eb1280550cbcc70dd8a4d Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 19 Feb 2021 07:43:05 +0300 Subject: use .closest() instead of .up() to lookup parent by selector --- js/common.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/common.js') diff --git a/js/common.js b/js/common.js index a5e1e503a..f96ac8da4 100755 --- a/js/common.js +++ b/js/common.js @@ -164,7 +164,7 @@ const Lists = { // account for dojo checkboxes elem = elem.domNode || elem; - const row = elem.up("li"); + const row = elem.closest("li"); if (row) checked ? row.addClassName("Selected") : row.removeClassName("Selected"); @@ -194,7 +194,7 @@ const Tables = { const checked = elem.domNode ? elem.attr("checked") : elem.checked; elem = elem.domNode || elem; - const row = elem.up("tr"); + const row = elem.closest("tr"); if (row) checked ? row.addClassName("Selected") : row.removeClassName("Selected"); -- cgit v1.2.3 From f645120641cdcd42506401c2942ad8c080b69a02 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 19 Feb 2021 07:54:44 +0300 Subject: table helpers: don't try to iterate over a single element --- js/common.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/common.js') diff --git a/js/common.js b/js/common.js index f96ac8da4..7cbe1287b 100755 --- a/js/common.js +++ b/js/common.js @@ -201,7 +201,7 @@ const Tables = { }, select: function(elemId, selected) { - $(elemId).querySelector("tr").forEach((row) => { + $(elemId).querySelectorAll("tr").forEach((row) => { const checkNode = row.querySelector(".dijitCheckBox,input[type=checkbox]"); if (checkNode) { const widget = dijit.getEnclosingWidget(checkNode); @@ -219,7 +219,7 @@ const Tables = { getSelected: function(elemId) { const rv = []; - $(elemId).querySelector("tr").forEach((row) => { + $(elemId).querySelectorAll("tr").forEach((row) => { if (row.hasClassName("Selected")) { // either older prefix-XXX notation or separate attribute const rowId = row.getAttribute("data-row-id") || row.id.replace(/^[A-Z]*?-/, ""); -- cgit v1.2.3 From dba6dce3b332f1c7cfb60e3411c6b85c01be7471 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 19 Feb 2021 10:15:36 +0300 Subject: add element fadeout/fadein and a shorter xhr helper --- js/common.js | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 74 insertions(+), 3 deletions(-) (limited to 'js/common.js') diff --git a/js/common.js b/js/common.js index 7cbe1287b..dbe1ae3c3 100755 --- a/js/common.js +++ b/js/common.js @@ -3,13 +3,15 @@ /* global dijit, __, App, dojo, __csrf_token */ /* eslint-disable no-new */ +/* exported $ */ function $(id) { console.warn("FIXME: please use App.byId() or document.getElementById() instead of $():", id); return document.getElementById(id); } +/* exported $$ */ function $$(query) { - console.warn("FIXME: please use App.findAll() or document.querySelectorAll() instead of $():", query); + console.warn("FIXME: please use App.findAll() or document.querySelectorAll() instead of $$():", query); return document.querySelectorAll(query); } @@ -55,6 +57,34 @@ Element.prototype.toggle = function() { this.show(); }; +// https://gist.github.com/alirezas/c4f9f43e9fe1abba9a4824dd6fc60a55 +Element.prototype.fadeOut = function() { + this.style.opacity = 1; + const self = this; + + (function fade() { + if ((self.style.opacity -= 0.1) < 0) { + self.style.display = "none"; + } else { + requestAnimationFrame(fade); + } + }()); +}; + +Element.prototype.fadeIn = function(display){ + this.style.opacity = 0; + this.style.display = display || "block"; + const self = this; + + (function fade() { + let val = parseFloat(self.style.opacity); + if (!((val += 0.1) > 1)) { + self.style.opacity = val; + requestAnimationFrame(fade); + } + }()); +}; + Element.prototype.visible = function() { // TODO: should we actually check for offsetWidth/offsetHeight == 0? return this.style.display != "none"; @@ -109,9 +139,50 @@ String.prototype.stripTags = function() { return this.replace(/<\w+(\s+("[^"]*"|'[^']*'|[^>])+)?(\/)?>|<\/\w+>/gi, ''); } -/* xhr shorthand helpers */ +/* exported xhr */ + +const xhr = { + post: function(url, params = {}, complete = undefined) { + console.log("xhr.post:", params); + + return new Promise((resolve, reject) => { + if (typeof __csrf_token != "undefined") + params = {...params, ...{csrf_token: __csrf_token}}; + + dojo.xhrPost({url: url, + postData: dojo.objectToQuery(params), + handleAs: "text", + error: function(error) { + reject(error); + }, + load: function(data, ioargs) { + if (complete != undefined) + complete(data, ioargs.xhr); + + resolve(data) + }} + ); + }); + }, + json: function(url, params = {}, complete = undefined) { + return new Promise((resolve, reject) => + this.post(url, params).then((data) => { + let obj = null; + + try { + obj = JSON.parse(data); + } catch (e) { + console.error("xhr.json", e, xhr); + reject(e); + } + + if (complete != undefined) complete(obj); -// TODO: this should become xhr { Post: ..., Json: ... } + resolve(obj); + } + )); + } +}; /* exported xhrPost */ function xhrPost(url, params = {}, complete = undefined) { -- cgit v1.2.3 From 6b43b788d909ce20f07f29f9f3ccd2f6a8715616 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 19 Feb 2021 10:22:00 +0300 Subject: migrate xhrJson invocations to the new helper --- js/common.js | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'js/common.js') diff --git a/js/common.js b/js/common.js index dbe1ae3c3..f3fcdd905 100755 --- a/js/common.js +++ b/js/common.js @@ -143,7 +143,7 @@ String.prototype.stripTags = function() { const xhr = { post: function(url, params = {}, complete = undefined) { - console.log("xhr.post:", params); + console.log('xhr.post', '>>>', params); return new Promise((resolve, reject) => { if (typeof __csrf_token != "undefined") @@ -156,6 +156,8 @@ const xhr = { reject(error); }, load: function(data, ioargs) { + //console.log('xhr.post', '<<<', data, ioargs); + if (complete != undefined) complete(data, ioargs.xhr); @@ -176,6 +178,8 @@ const xhr = { reject(e); } + console.log('xhr.json', '<<<', obj); + if (complete != undefined) complete(obj); resolve(obj); @@ -209,21 +213,7 @@ function xhrPost(url, params = {}, complete = undefined) { /* exported xhrJson */ function xhrJson(url, params = {}, complete = undefined) { - return new Promise((resolve, reject) => - xhrPost(url, params).then((reply) => { - let obj = null; - - try { - obj = JSON.parse(reply.responseText); - } catch (e) { - console.error("xhrJson", e, reply); - reject(e); - } - - if (complete != undefined) complete(obj); - - resolve(obj); - })); + return xhr.json(url, params, complete); } /* common helpers not worthy of separate Dojo modules */ -- cgit v1.2.3 From bb4e4282f46824308aebc2eaeac29fa29f8687ad Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 19 Feb 2021 11:28:14 +0300 Subject: migrate a bunch of xhrPost invocations --- js/common.js | 1 - 1 file changed, 1 deletion(-) (limited to 'js/common.js') diff --git a/js/common.js b/js/common.js index f3fcdd905..1c9a0453c 100755 --- a/js/common.js +++ b/js/common.js @@ -140,7 +140,6 @@ String.prototype.stripTags = function() { } /* exported xhr */ - const xhr = { post: function(url, params = {}, complete = undefined) { console.log('xhr.post', '>>>', params); -- cgit v1.2.3 From 660a1bbe011fef5f0fa6bb0af43521fed7598cc7 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 19 Feb 2021 13:44:56 +0300 Subject: * switch to xhr.post() almost everywhere * call App.handlerpcjson() automatically on json request (if possible) * show net/log indicators in prefs --- js/common.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'js/common.js') diff --git a/js/common.js b/js/common.js index 1c9a0453c..e88b62602 100755 --- a/js/common.js +++ b/js/common.js @@ -155,7 +155,7 @@ const xhr = { reject(error); }, load: function(data, ioargs) { - //console.log('xhr.post', '<<<', data, ioargs); + console.log('xhr.post', '<<<', ioargs.xhr); if (complete != undefined) complete(data, ioargs.xhr); @@ -179,6 +179,9 @@ const xhr = { console.log('xhr.json', '<<<', obj); + if (obj && typeof App != "undefined") + App.handleRpcJson(obj); + if (complete != undefined) complete(obj); resolve(obj); -- cgit v1.2.3 From d445530fa08cdbe2088150a3e7d23596eab9b142 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 19 Feb 2021 17:15:22 +0300 Subject: format note on the client --- js/common.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/common.js') diff --git a/js/common.js b/js/common.js index e88b62602..e616c70ba 100755 --- a/js/common.js +++ b/js/common.js @@ -71,9 +71,9 @@ Element.prototype.fadeOut = function() { }()); }; -Element.prototype.fadeIn = function(display){ +Element.prototype.fadeIn = function(display = undefined){ this.style.opacity = 0; - this.style.display = display || "block"; + this.style.display = display == undefined ? "block" : display; const self = this; (function fade() { -- cgit v1.2.3 From cf249d7e8c55542ca6383b430ec77f07401e96ea Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 19 Feb 2021 19:29:43 +0300 Subject: modify classname helpers to use element.classList; fix feed debugger & share--get --- js/common.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'js/common.js') diff --git a/js/common.js b/js/common.js index e616c70ba..6e8168357 100755 --- a/js/common.js +++ b/js/common.js @@ -17,15 +17,15 @@ function $$(query) { Element.prototype.hasClassName = function(className) { - return dojo.hasClass(this, className); + return this.classList.contains(className); }; Element.prototype.addClassName = function(className) { - return dojo.addClass(this, className); + return this.classList.add(className); }; Element.prototype.removeClassName = function(className) { - return dojo.removeClass(this, className); + return this.classList.remove(className); }; Element.prototype.toggleClassName = function(className) { -- cgit v1.2.3 From da97b29dbe7ac923fae5a0cddee141716d1da3e5 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 20 Feb 2021 21:07:28 +0300 Subject: prevent filter selected text dialog from opening in wrong order --- js/common.js | 22 ---------------------- 1 file changed, 22 deletions(-) (limited to 'js/common.js') diff --git a/js/common.js b/js/common.js index 6e8168357..01fe321f7 100755 --- a/js/common.js +++ b/js/common.js @@ -401,25 +401,3 @@ const Notify = { } }; -// http://stackoverflow.com/questions/6251937/how-to-get-selecteduser-highlighted-text-in-contenteditable-element-and-replac -/* exported getSelectionText */ -function getSelectionText() { - let text = ""; - - if (typeof window.getSelection != "undefined") { - const sel = window.getSelection(); - if (sel.rangeCount) { - const container = document.createElement("div"); - for (let i = 0, len = sel.rangeCount; i < len; ++i) { - container.appendChild(sel.getRangeAt(i).cloneContents()); - } - text = container.innerHTML; - } - } else if (typeof document.selection != "undefined") { - if (document.selection.type == "Text") { - text = document.selection.createRange().textText; - } - } - - return text.stripTags(); -} -- cgit v1.2.3 From 9e56896bd428114ff9bfd979c2d4ff8d93f99485 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 21 Feb 2021 10:34:28 +0300 Subject: Element visible: check for offsetHeight/offsetWidth --- js/common.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'js/common.js') diff --git a/js/common.js b/js/common.js index 6e8168357..e85862990 100755 --- a/js/common.js +++ b/js/common.js @@ -86,8 +86,7 @@ Element.prototype.fadeIn = function(display = undefined){ }; Element.prototype.visible = function() { - // TODO: should we actually check for offsetWidth/offsetHeight == 0? - return this.style.display != "none"; + return this.style.display != "none" && this.offsetHeight != 0 && this.offsetWidth != 0; } Element.visible = function(elem) { -- cgit v1.2.3 From 8d2e3c2528e67f8650c122f014364a34bf690d2a Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 23 Feb 2021 22:26:07 +0300 Subject: drop errors.php and simplify error handling --- js/common.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'js/common.js') diff --git a/js/common.js b/js/common.js index df1bf8690..670ee1b30 100755 --- a/js/common.js +++ b/js/common.js @@ -179,7 +179,10 @@ const xhr = { console.log('xhr.json', '<<<', obj); if (obj && typeof App != "undefined") - App.handleRpcJson(obj); + if (!App.handleRpcJson(obj)) { + reject(obj); + return; + } if (complete != undefined) complete(obj); -- cgit v1.2.3