summaryrefslogtreecommitdiff
path: root/assets/js/core
diff options
context:
space:
mode:
Diffstat (limited to 'assets/js/core')
-rw-r--r--assets/js/core/base.js14
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) {