diff options
Diffstat (limited to 'public/bower_components/jvectormap/src/abstract-canvas-element.js')
-rw-r--r-- | public/bower_components/jvectormap/src/abstract-canvas-element.js | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/public/bower_components/jvectormap/src/abstract-canvas-element.js b/public/bower_components/jvectormap/src/abstract-canvas-element.js new file mode 100644 index 0000000..de8d30d --- /dev/null +++ b/public/bower_components/jvectormap/src/abstract-canvas-element.js @@ -0,0 +1,93 @@ +/** + * Implements abstract vector canvas. + * @constructor + * @param {HTMLElement} container Container to put element to. + * @param {Number} width Width of canvas. + * @param {Number} height Height of canvas. + */ +jvm.AbstractCanvasElement = function(container, width, height){ + this.container = container; + this.setSize(width, height); + this.rootElement = new jvm[this.classPrefix+'GroupElement'](); + this.node.appendChild( this.rootElement.node ); + this.container.appendChild(this.node); +} + +/** + * Add element to the certain group inside of the canvas. + * @param {HTMLElement} element Element to add to canvas. + * @param {HTMLElement} group Group to add element into or into root group if not provided. + */ +jvm.AbstractCanvasElement.prototype.add = function(element, group){ + group = group || this.rootElement; + group.add(element); + element.canvas = this; +} + +/** + * Create path and add it to the canvas. + * @param {Object} config Parameters of path to create. + * @param {Object} style Styles of the path to create. + * @param {HTMLElement} group Group to add path into. + */ +jvm.AbstractCanvasElement.prototype.addPath = function(config, style, group){ + var el = new jvm[this.classPrefix+'PathElement'](config, style); + + this.add(el, group); + return el; +}; + +/** + * Create circle and add it to the canvas. + * @param {Object} config Parameters of path to create. + * @param {Object} style Styles of the path to create. + * @param {HTMLElement} group Group to add circle into. + */ +jvm.AbstractCanvasElement.prototype.addCircle = function(config, style, group){ + var el = new jvm[this.classPrefix+'CircleElement'](config, style); + + this.add(el, group); + return el; +}; + +/** + * Create circle and add it to the canvas. + * @param {Object} config Parameters of path to create. + * @param {Object} style Styles of the path to create. + * @param {HTMLElement} group Group to add circle into. + */ +jvm.AbstractCanvasElement.prototype.addImage = function(config, style, group){ + var el = new jvm[this.classPrefix+'ImageElement'](config, style); + + this.add(el, group); + return el; +}; + +/** + * Create text and add it to the canvas. + * @param {Object} config Parameters of path to create. + * @param {Object} style Styles of the path to create. + * @param {HTMLElement} group Group to add circle into. + */ +jvm.AbstractCanvasElement.prototype.addText = function(config, style, group){ + var el = new jvm[this.classPrefix+'TextElement'](config, style); + + this.add(el, group); + return el; +}; + +/** + * Add group to the another group inside of the canvas. + * @param {HTMLElement} group Group to add circle into or root group if not provided. + */ +jvm.AbstractCanvasElement.prototype.addGroup = function(parentGroup){ + var el = new jvm[this.classPrefix+'GroupElement'](); + + if (parentGroup) { + parentGroup.node.appendChild(el.node); + } else { + this.node.appendChild(el.node); + } + el.canvas = this; + return el; +};
\ No newline at end of file |