1 /** 2 * Constructs a new Control. 3 * @class Represents an abstract Class for controls. The Control class is the base class for all graphical controls in WSO2Vis. 4 * @constructor 5 * @param {string} canvas the name of the HTML element (ex: div) where the graphical control should be drawn. 6 */ 7 wso2vis.c.Control = function(canvas) { 8 this.attr = []; 9 this.canvas(canvas); 10 11 this.dp = null; 12 wso2vis.environment.controls.push(this); 13 14 id = wso2vis.environment.controls.length - 1; 15 this.getID = function() {return id;} 16 }; 17 18 /** 19 * @private Defines and registers a property method for the property with the given name. 20 * @param {string} name the property name. 21 */ 22 wso2vis.c.Control.prototype.property = function(name) { 23 wso2vis.c.Control.prototype[name] = function(v) { 24 if (arguments.length) { 25 this.attr[name] = v; 26 return this; 27 } 28 return this.attr[name]; 29 }; 30 31 return this; 32 }; 33 34 /* Define all properties. */ 35 wso2vis.c.Control.prototype.property("canvas"); 36 37 /** 38 * Creates the graphical control. 39 */ 40 wso2vis.c.Control.prototype.create = function() { 41 }; 42 43 /** 44 * Loads the graphical control inside the given HTML element (ex: div). 45 */ 46 wso2vis.c.Control.prototype.load = function() { 47 var divEl = document.getElementById(this.canvas()); 48 divEl.innerHTML = this.create(); 49 }; 50 51 /** 52 * Unloads the graphical control from the given HTML element (ex: div). 53 */ 54 wso2vis.c.Control.prototype.unload = function() { 55 var divEl = document.getElementById(this.canvas()); 56 divEl.innerHTML = ""; 57 }; 58 59