aboutsummaryrefslogtreecommitdiffhomepage
path: root/public/bower_components/jvectormap/src/svg-image-element.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/bower_components/jvectormap/src/svg-image-element.js')
-rw-r--r--public/bower_components/jvectormap/src/svg-image-element.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/public/bower_components/jvectormap/src/svg-image-element.js b/public/bower_components/jvectormap/src/svg-image-element.js
new file mode 100644
index 0000000..a89f482
--- /dev/null
+++ b/public/bower_components/jvectormap/src/svg-image-element.js
@@ -0,0 +1,36 @@
+jvm.SVGImageElement = function(config, style){
+ jvm.SVGImageElement.parentClass.call(this, 'image', config, style);
+};
+
+jvm.inherits(jvm.SVGImageElement, jvm.SVGShapeElement);
+
+jvm.SVGImageElement.prototype.applyAttr = function(attr, value){
+ var that = this;
+
+ if (attr == 'image') {
+ jvm.whenImageLoaded(value).then(function(img){
+ that.node.setAttributeNS('http://www.w3.org/1999/xlink', 'href', value);
+ that.width = img[0].width;
+ that.height = img[0].height;
+ that.applyAttr('width', that.width);
+ that.applyAttr('height', that.height);
+
+ that.applyAttr('x', that.cx - that.width / 2);
+ that.applyAttr('y', that.cy - that.height / 2);
+
+ jvm.$(that.node).trigger('imageloaded', [img]);
+ });
+ } else if(attr == 'cx') {
+ this.cx = value;
+ if (this.width) {
+ this.applyAttr('x', value - this.width / 2);
+ }
+ } else if(attr == 'cy') {
+ this.cy = value;
+ if (this.height) {
+ this.applyAttr('y', value - this.height / 2);
+ }
+ } else {
+ jvm.SVGImageElement.parentClass.prototype.applyAttr.apply(this, arguments);
+ }
+}; \ No newline at end of file