summaryrefslogtreecommitdiff
path: root/assets/js/core/dom.js
diff options
context:
space:
mode:
Diffstat (limited to 'assets/js/core/dom.js')
-rw-r--r--assets/js/core/dom.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/assets/js/core/dom.js b/assets/js/core/dom.js
index 33039285..20510d44 100644
--- a/assets/js/core/dom.js
+++ b/assets/js/core/dom.js
@@ -10,6 +10,14 @@ KB.dom = function (tag) {
return this;
};
+ this.data = function (attribute, value) {
+ if (arguments.length === 1) {
+ return element.dataset[attribute];
+ }
+ element.dataset[attribute] = value;
+ return this;
+ };
+
this.hide = function () {
element.style.display = 'none';
return this;
@@ -30,6 +38,11 @@ KB.dom = function (tag) {
return this;
};
+ this.style = function(attribute, value) {
+ element.style[attribute] = value;
+ return this;
+ };
+
this.on = function (eventName, callback) {
element.addEventListener(eventName, function (e) {
e.preventDefault();
@@ -43,6 +56,10 @@ KB.dom = function (tag) {
return this.on('click', callback);
};
+ this.mouseover = function (callback) {
+ return this.on('mouseover', callback);
+ };
+
this.change = function (callback) {
return this.on('change', callback);
};
@@ -96,6 +113,11 @@ KB.dom = function (tag) {
return this;
};
+ this.remove = function () {
+ element.parentNode.removeChild(element);
+ return this;
+ };
+
this.parent = function (selector) {
for (; element && element !== document; element = element.parentNode) {
if (element.matches(selector)) {