module.exports = new Class({ basePath: null ,path: null ,moduleName: null ,callbacks: [] ,localeReady: false ,jsReady: false ,uiReady: false ,error: false ,ready: false ,initialize(basePath, path) { var absPath = basePath +'/'+ path; var aux = path.split('/'); var moduleName = aux[aux.length - 1]; Vn.Locale.load(absPath, this.onLocaleReady.bind(this)); Vn.includeJs(absPath +'/'+ moduleName +'.js', this.onJsReady.bind(this)); Vn.loadXml(absPath +'/ui.xml', this.onUiReady.bind(this)); this.basePath = basePath; this.path = path; this.moduleName = moduleName; } ,addCallback(callback) { if (!this.ready) this.callbacks.push(callback); else callback(this); } ,onLocaleReady() { this.localeReady = true; this.onReady(); } ,onJsReady(success) { this.jsReady = true; this.error = !success; this.onReady(); } ,onUiReady(success) { this.uiReady = true; this.error = !success; this.onReady(); } ,onReady() { if (!(this.localeReady && this.jsReady && this.uiReady)) return; this.ready = true; var klassName = this.toCamelCase(this.moduleName); try { this.klass = Hedera[klassName]; } catch (e) { this.error = true; console.error(e); } var callbacks = this.callbacks; this.callbacks = null; for (var i = 0; i < callbacks.length; i++) callbacks[i](this); } ,toCamelCase(dashedName) { var camelCase = dashedName.charAt(0).toUpperCase(); camelCase += dashedName.substr(1).replace(/\w-\w/g, function(token) { return token.charAt(0) + token.charAt(2).toUpperCase(); }); return camelCase; } });