diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-12-10 11:36:22 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-12-10 11:36:22 -0500 |
commit | c0049ed7e6459b234e69b763e82baca349763a4b (patch) | |
tree | 8d2ddb30656d60358048c1166b697ae7d9662db5 /assets/js/core | |
parent | 67d01951f5a0a8e2201707162c1f7454f26ac798 (diff) |
Rewrite project creation component in vanilla js
Diffstat (limited to 'assets/js/core')
-rw-r--r-- | assets/js/core/base.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/assets/js/core/base.js b/assets/js/core/base.js index 4ea3ffc2..07ddf99b 100644 --- a/assets/js/core/base.js +++ b/assets/js/core/base.js @@ -5,6 +5,7 @@ var KB = { http: {}, listeners: { clicks: {}, + changes: {}, internals: {} } }; @@ -31,6 +32,10 @@ KB.onClick = function (selector, callback) { this.listeners.clicks[selector] = callback; }; +KB.onChange = function (selector, callback) { + this.listeners.changes[selector] = callback; +}; + KB.listen = function () { var self = this; @@ -43,7 +48,16 @@ KB.listen = function () { } } + function onChange(e) { + for (var selector in self.listeners.changes) { + if (self.listeners.changes.hasOwnProperty(selector) && e.target.matches(selector)) { + self.listeners.changes[selector](e.target); + } + } + } + document.addEventListener('click', onClick, false); + document.addEventListener('change', onChange, false); }; KB.component = function (name, object) { |