UNPKG

mframejs

Version:
84 lines 3.66 kB
Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var exported_1 = require("../decorator/exported"); var exported_2 = require("../binding/exported"); var MiscAttributes = (function () { function MiscAttributes() { } MiscAttributes.prototype.created = function () { var _this = this; this.value = this.$attribute.value; this.name = this.$attribute.name.replace('.bind', ''); this.init = true; this.subscribeInternal = { name: this.name + 'Attribute(misc)', value: this.value, call: function (newValue, oldValue) { if (oldValue !== newValue || _this.init) { _this.init = false; switch (_this.name) { case 'readonly': if (newValue) { _this.$element.readOnly = newValue; } else { _this.$element.removeAttribute(_this.name); } break; case 'src': if (newValue) { _this.$element.src = newValue; } else { _this.$element.removeAttribute(_this.name); } break; case 'disabled': if (newValue) { _this.$element.disabled = newValue; } else { _this.$element.removeAttribute(_this.name); } break; case 'class': if (newValue) { _this.$element.className = newValue; } else { _this.$element.className = ''; } break; case 'show': if (newValue) { _this.$element.style['display'] = 'block'; } else { _this.$element.style['display'] = 'none'; } break; default: _this.$element.setAttribute(_this.name, newValue); } } } }; exported_2.BindingEngine.subscribeClassProperty(this.$bindingContext, this.value, this.subscribeInternal); }; MiscAttributes.prototype.detached = function () { exported_2.BindingEngine.unSubscribeClassProperty(this.$bindingContext, this.subscribeInternal); }; MiscAttributes.prototype.attached = function () { this.$element.removeAttribute(this.$attribute.name); }; MiscAttributes = tslib_1.__decorate([ exported_1.customAttribute('readonly.bind'), exported_1.customAttribute('disabled.bind'), exported_1.customAttribute('show.bind'), exported_1.customAttribute('class.bind'), exported_1.customAttribute('src.bind') ], MiscAttributes); return MiscAttributes; }()); exports.MiscAttributes = MiscAttributes; //# sourceMappingURL=miscAttribute.js.map