1 /** 2 * The top-level WSO2Vis namespace. All public methods and fields should be 3 * registered on this object. Note that core wso2vis source is surrounded by an 4 * anonymous function, so any other declared globals will not be visible outside 5 * of core methods. This also allows multiple versions of WSO2Vis to coexist, 6 * since each version will see their own <tt>wso2vis</tt> namespace. 7 * 8 * @namespace The top-level wso2vis namespace, <tt>wso2vis</tt>. 9 */ 10 var wso2vis = {}; 11 12 /** 13 * @namespace wso2vis namespace for Providers, <tt>wso2vis.p</tt>. 14 */ 15 wso2vis.p = {}; 16 17 /** 18 * @namespace wso2vis namespace for Filters, <tt>wso2vis.f</tt>. 19 */ 20 wso2vis.f = {}; 21 22 /** 23 * @namespace wso2vis namespace for Filter Forms, <tt>wso2vis.f.form</tt>. 24 */ 25 wso2vis.f.form = {}; 26 27 /** 28 * @namespace wso2vis namespace for Subscribers, <tt>wso2vis.s</tt>. 29 */ 30 wso2vis.s = {}; 31 32 /** 33 * @namespace wso2vis namespace for Subscriber Charts, <tt>wso2vis.s.chart</tt>. 34 */ 35 wso2vis.s.chart = {}; 36 37 /** 38 * @namespace wso2vis namespace for Subscriber Protovis Charts, <tt>wso2vis.s.chart.protovis</tt>. 39 */ 40 wso2vis.s.chart.protovis = {}; 41 42 /** 43 * @namespace wso2vis namespace for Subscriber Raphael Charts, <tt>wso2vis.s.chart.raphael</tt>. 44 */ 45 wso2vis.s.chart.raphael = {}; 46 47 /** 48 * @namespace wso2vis namespace for Subscriber Infovis Charts, <tt>wso2vis.s.chart.raphael</tt>. 49 */ 50 wso2vis.s.chart.infovis = {}; 51 52 /** 53 * @namespace wso2vis namespace for Subscriber composite Charts, <tt>wso2vis.s.chart.composite</tt>. 54 */ 55 wso2vis.s.chart.composite = {}; 56 57 /** 58 * @namespace wso2vis namespace for Subscriber Forms, <tt>wso2vis.s.form</tt>. 59 */ 60 wso2vis.s.form = {}; 61 62 /** 63 * @namespace wso2vis namespace for Subscriber Gauges, <tt>wso2vis.s.gauge</tt>. 64 */ 65 wso2vis.s.gauge = {}; 66 67 /** 68 * @namespace wso2vis namespace for Subscriber Raphael Charts, <tt>wso2vis.s.chart.raphael</tt>. 69 */ 70 wso2vis.s.gauge.raphael = {}; 71 72 /** 73 * @namespace wso2vis namespace for Utility Components, <tt>wso2vis.u</tt>. 74 */ 75 wso2vis.u = {}; 76 77 /** 78 * @namespace wso2vis namespace for utility functions, <tt>wso2vis.util</tt>. 79 */ 80 wso2vis.util = {}; 81 82 /** 83 * @namespace wso2vis namespace for Adaptors, <tt>wso2vis.a</tt>. 84 */ 85 wso2vis.a = {}; 86 87 /** 88 * @namespace wso2vis namespace for controls, <tt>wso2vis.c</tt>. 89 */ 90 wso2vis.c = {}; 91 92 wso2vis.ctrls = {}; 93 94 /** 95 * @namespace wso2vis namespace for user defined custom functions, <tt>wso2vis.fn</tt>. 96 */ 97 wso2vis.fn = {}; 98 99 /** 100 * WSO2Vis major and minor version numbers. 101 * 102 * @namespace WSO2Vis major and minor version numbers. 103 */ 104 wso2vis.version = { 105 /** 106 * The major version number. 107 * 108 * @type number 109 * @constant 110 */ 111 major: 0, 112 113 /** 114 * The minor version number. 115 * 116 * @type number 117 * @constant 118 */ 119 minor: 1 120 }; 121 122 /** 123 * WSO2Vis environment. All data providers, filters and charts are registred in the environment. 124 * @namespace wso2vis namespace for environment variables, <tt>wso2vis.environment</tt>. 125 */ 126 wso2vis.environment = { 127 /** 128 * providers array 129 */ 130 providers: [], 131 132 /** 133 * filters array 134 */ 135 filters: [], 136 137 /** 138 * charts array 139 */ 140 charts: [], 141 142 /** 143 * dialogs array 144 */ 145 dialogs: [], 146 147 /** 148 * subscribers array 149 */ 150 subscribers: [], 151 152 /** 153 * adapters array 154 */ 155 adapters: [], 156 157 /** 158 * controls array 159 */ 160 controls: [], 161 162 /** 163 * gauges array 164 */ 165 gauges: [] 166 167 }; 168 169 wso2vis.fn.getProviderFromID = function(id) { 170 if ((id >= 0) && (wso2vis.environment.providers.length > id)) { 171 return wso2vis.environment.providers[id]; 172 } 173 return null; 174 }; 175 176 wso2vis.fn.getFilterFromID = function(id) { 177 if ((id >= 0) && (wso2vis.environment.filters.length > id)) { 178 return wso2vis.environment.filters[id]; 179 } 180 return null; 181 }; 182 183 wso2vis.fn.getChartFromID = function(id) { 184 if ((id >= 0) && (wso2vis.environment.charts.length > id)) { 185 return wso2vis.environment.charts[id]; 186 } 187 return null; 188 }; 189 190 wso2vis.fn.getDialogFromID = function(id) { 191 if ((id >= 0) && (wso2vis.environment.dialogs.length > id)) { 192 return wso2vis.environment.dialogs[id]; 193 } 194 return null; 195 }; 196 197 wso2vis.fn.getElementFromID = function(id) { 198 if ((id >= 0) && (wso2vis.environment.elements.length > id)) { 199 return wso2vis.environment.elements[id]; 200 } 201 return null; 202 }; 203 204 wso2vis.fn.getAdapterFromID = function(id) { 205 if ((id >= 0) && (wso2vis.environment.adapters.length > id)) { 206 return wso2vis.environment.adapters[id]; 207 } 208 return null; 209 }; 210 211 wso2vis.fn.getControlFromID = function(id) { 212 if ((id >= 0) && (wso2vis.environment.controls.length > id)) { 213 return wso2vis.environment.controls[id]; 214 } 215 return null; 216 }; 217 218 wso2vis.fn.getGaugeFromID = function(id) { 219 if ((id >= 0) && (wso2vis.environment.gauges.length > id)) { 220 return wso2vis.environment.gauges[id]; 221 } 222 return null; 223 }; 224 225 wso2vis.fn.traverseToDataField = function (object, dataFieldArray) { 226 var a = object; 227 for (var i = 0; i < dataFieldArray.length; i++) { 228 a = a[dataFieldArray[i]]; 229 } 230 return a; 231 }; 232 233 wso2vis.fn.traverseNKillLeaf = function (object, dataFieldArray) { 234 var a = object; 235 for (var i = 0; i < dataFieldArray.length; i++) { 236 if (i == dataFieldArray.length - 1) { 237 delete a[dataFieldArray[i]]; 238 } 239 else { 240 a = a[dataFieldArray[i]]; 241 } 242 } 243 }; 244 245 /* using "Parasitic Combination Inheritance" */ 246 wso2vis.extend = function(subc, superc /*, overrides*/) { 247 if (!superc||!subc) { 248 throw new Error("extend failed, please check that " + 249 "all dependencies are included."); 250 } 251 var F = function() {}/*, i*/; 252 F.prototype=superc.prototype; 253 subc.prototype=new F(); 254 subc.prototype.constructor=subc; 255 subc.superclass=superc.prototype; 256 if (superc.prototype.constructor == Object.prototype.constructor) { 257 superc.prototype.constructor=superc; 258 } 259 260 /* Lets worry about the following later 261 if (overrides) { 262 for (i in overrides) { 263 if (L.hasOwnProperty(overrides, i)) { 264 subc.prototype[i]=overrides[i]; 265 } 266 } 267 268 L._IEEnumFix(subc.prototype, overrides); 269 } */ 270 }; 271 272 wso2vis.initialize = function() { 273 wso2vis.environment.tooltip = new wso2vis.c.Tooltip(); 274 }; 275 276 277