UNPKG

simpleitjs-ui

Version:
114 lines (113 loc) 3.92 kB
"use strict"; /// <reference path="./node_modules/simpleitjs/dist/module.d.ts" /> /// <reference path="./node_modules/simpleitjs/dist/ajax.d.ts" /> var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __spreadArrays = (this && this.__spreadArrays) || function () { for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j]; return r; }; var ModuleClass; (function () { if (typeof window === "undefined") { ModuleClass = require('simpleitjs').Module; require('simpleitjs').Ajax; } else { var win = window; ModuleClass = win.SimpleJS.Module; } })(); var id = 0; var generateNxtId = function () { return id++; }; var UIModel = /** @class */ (function () { function UIModel() { this._id = generateNxtId(); } return UIModel; }()); var UIModuleOpts = /** @class */ (function (_super) { __extends(UIModuleOpts, _super); function UIModuleOpts(config) { if (config === void 0) { config = {}; } var _this = _super.call(this) || this; _this.name = config.name; _this.templateURL = config.templateURL; _this.templateSelector = config.templateSelector; _this.model = config.model || new UIModel(); return _this; } return UIModuleOpts; }(ModuleScope)); var SuperUI = /** @class */ (function (_super) { __extends(SuperUI, _super); function SuperUI(config) { if (config === void 0) { config = {}; } var _this = _super.call(this, config) || this; _this.Ajax = Module.get('Ajax'); return _this; } SuperUI.invoke = function (model) { var _a; var dependencies = []; for (var _i = 1; _i < arguments.length; _i++) { dependencies[_i - 1] = arguments[_i]; } console.log('Super class invoked'); if (model.templateURL) { (_a = model.Ajax) === null || _a === void 0 ? void 0 : _a.get(model.templateURL).then(function (strTemplate) { model.templateHTML = strTemplate; }); } return model; }; return SuperUI; }(UIModuleOpts)); var UIModule = /** @class */ (function (_super) { __extends(UIModule, _super); function UIModule(name, opts) { var dependencies = []; for (var _i = 2; _i < arguments.length; _i++) { dependencies[_i - 2] = arguments[_i]; } var _this = this; console.log('ui module initiated'); // const inst = new SuperUI(opts); var params = __spreadArrays([name], dependencies, [opts, SuperUI]); _this = _super.apply(this, params) || this; return _this; } return UIModule; }(ModuleClass)); if (typeof module != "undefined" && typeof module.exports != "undefined") { module.exports = { UIModule: UIModule, SuperUI: SuperUI, UIModel: UIModel }; } else if (typeof window != "undefined") { var win = window; win.SimpleJS = win.SimpleJS || {}; win.SimpleJS.UI = { UIModule: UIModule, SuperUI: SuperUI, UIModel: UIModel }; }