1 define(function(require) {
4 var _ = require('libs/underscore'),
5 wlxml = require('wlxml/wlxml');
8 var ElementsRegister = function(BaseType) {
10 this.BaseType = BaseType;
13 _.extend(ElementsRegister.prototype, {
14 createCanvasElementType: function(elementPrototype) {
16 var Constructor = function() {
17 register.BaseType.apply(this, Array.prototype.slice.call(arguments, 0));
19 Constructor.prototype = elementPrototype;
22 register: function(params) {
23 params.klass = params.klass || '';
24 params.prototype = params.prototype || Object.create({});
26 this._register[params.tag] = this._register[params.tag] || {};
27 this._register[params.tag][params.klass] = this.createCanvasElementType(params.prototype);
29 getElement: function(params) {
30 params.klass = params.klass || '';
32 if(this._register[params.tag]) {
33 wlxml.getClassHierarchy(params.klass).reverse().some(function(klass) {
34 Factory = this._register[params.tag][klass];
41 Factory = this.BaseType;
48 return ElementsRegister;