aboutsummaryrefslogtreecommitdiffhomepage
path: root/public/bower_components/jvectormap/src/abstract-element.js
diff options
context:
space:
mode:
authorMarvin Borner2018-07-13 19:06:45 +0200
committerMarvin Borner2018-07-13 19:06:45 +0200
commit6fcfb7c04d32e1c8b26a312295bf7ac3ec2d2ad7 (patch)
treedbc87ef16fa01d5d99116de283592b8fe5e02944 /public/bower_components/jvectormap/src/abstract-element.js
parentdfd839f27146df0ad0494e11734fc7d310c70ebf (diff)
Fixed many permissions and began admin interface
Diffstat (limited to 'public/bower_components/jvectormap/src/abstract-element.js')
-rw-r--r--public/bower_components/jvectormap/src/abstract-element.js73
1 files changed, 73 insertions, 0 deletions
diff --git a/public/bower_components/jvectormap/src/abstract-element.js b/public/bower_components/jvectormap/src/abstract-element.js
new file mode 100644
index 0000000..e393491
--- /dev/null
+++ b/public/bower_components/jvectormap/src/abstract-element.js
@@ -0,0 +1,73 @@
+/**
+ * Basic wrapper for DOM element.
+ * @constructor
+ * @param {String} name Tag name of the element
+ * @param {Object} config Set of parameters to initialize element with
+ */
+jvm.AbstractElement = function(name, config){
+ /**
+ * Underlying DOM element
+ * @type {DOMElement}
+ * @private
+ */
+ this.node = this.createElement(name);
+
+ /**
+ * Name of underlying element
+ * @type {String}
+ * @private
+ */
+ this.name = name;
+
+ /**
+ * Internal store of attributes
+ * @type {Object}
+ * @private
+ */
+ this.properties = {};
+
+ if (config) {
+ this.set(config);
+ }
+};
+
+/**
+ * Set attribute of the underlying DOM element.
+ * @param {String} name Name of attribute
+ * @param {Number|String} config Set of parameters to initialize element with
+ */
+jvm.AbstractElement.prototype.set = function(property, value){
+ var key;
+
+ if (typeof property === 'object') {
+ for (key in property) {
+ this.properties[key] = property[key];
+ this.applyAttr(key, property[key]);
+ }
+ } else {
+ this.properties[property] = value;
+ this.applyAttr(property, value);
+ }
+};
+
+/**
+ * Returns value of attribute.
+ * @param {String} name Name of attribute
+ */
+jvm.AbstractElement.prototype.get = function(property){
+ return this.properties[property];
+};
+
+/**
+ * Applies attribute value to the underlying DOM element.
+ * @param {String} name Name of attribute
+ * @param {Number|String} config Value of attribute to apply
+ * @private
+ */
+jvm.AbstractElement.prototype.applyAttr = function(property, value){
+ this.node.setAttribute(property, value);
+};
+
+jvm.AbstractElement.prototype.remove = function(){
+ jvm.$(this.node).remove();
+}; \ No newline at end of file