UNPKG

innotec-materials

Version:

Innotec Materials is an UI framework who's desgined for all products of Innotec GmbH. Innotec Materials is based on Angular 2 an bootstrap.

178 lines 7.35 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); var core_1 = require("@angular/core"); var forms_1 = require("@angular/forms"); var noop = function () { }; var CUSTOM_INPUT_CONTROL_VALUE_ACCESSOR = { provide: forms_1.NG_VALUE_ACCESSOR, useExisting: core_1.forwardRef(function () { return KeyValueComponent; }), multi: true }; var KeyValueComponent = (function () { function KeyValueComponent() { this.inputtype = 'text'; this.rows = 5; this.cols = 20; this.valuechange = new core_1.EventEmitter(); this.readonly = true; this.warningclass = ''; this._value = ''; this._onTouchedCallback = noop; this._onChangeCallback = noop; } Object.defineProperty(KeyValueComponent.prototype, "warning", { set: function (warning) { if (warning) { this.warningclass = ' warning'; } if (!warning) { this.warningclass = ''; } }, enumerable: true, configurable: true }); Object.defineProperty(KeyValueComponent.prototype, "value", { get: function () { if (!this._value) { return ''; } return this._value; }, set: function (v) { if (v !== this._value) { this._value = v; this._onChangeCallback(v); } }, enumerable: true, configurable: true }); ; KeyValueComponent.prototype.onTouched = function () { this._onTouchedCallback(); }; KeyValueComponent.prototype.writeValue = function (value) { this._value = value; }; KeyValueComponent.prototype.registerOnChange = function (fn) { this._onChangeCallback = fn; }; KeyValueComponent.prototype.registerOnTouched = function (fn) { this._onTouchedCallback = fn; }; KeyValueComponent.prototype.startedit = function () { if (this.editicon) { this.readonly = false; this.valueclass = 'value-show'; this.undoIconHide(false); } }; KeyValueComponent.prototype.finishedit = function () { this.valueclass = 'value-hide'; this.readonly = true; if (this.editicon) { this.valueclass = 'value-hide value-editable'; } if (this.value === '' || !this.value && this.editicon && !this.disabled) { this.valueclass = this.valueclass + ' emptyvalue'; } this.undoIconHide(true); this.valuechange.emit(this.value); }; KeyValueComponent.prototype.undoIconHide = function (hide) { var _this = this; if (hide) { this.undoIconHideTimer = setTimeout(function () { _this.undoclass = 'undo-hide'; }, 3000); } else { clearTimeout(this.undoIconHideTimer); this.undoIconHideTimer = 0; this.undoclass = 'undo-show'; } ; }; KeyValueComponent.prototype.undoedit = function () { this.value = this.originalValue; this.finishedit(); }; KeyValueComponent.prototype.ngOnInit = function () { var _this = this; this.valueclass = 'value-hide'; this.undoclass = 'undo-hide'; if (this.disabled) { this.editicon = ''; } if (this.editicon && !this.disabled) { this.valueclass = 'value-hide value-editable'; this.labelclass = 'label editable clickable'; } else { this.labelclass = 'label'; } setTimeout(function () { _this.originalValue = _this.value; if (_this.value === '' || !_this.value && _this.editicon && !_this.disabled) { _this.valueclass = _this.valueclass + ' emptyvalue'; } }, 0); }; __decorate([ core_1.Input(), __metadata("design:type", String) ], KeyValueComponent.prototype, "icon", void 0); __decorate([ core_1.Input(), __metadata("design:type", String) ], KeyValueComponent.prototype, "key", void 0); __decorate([ core_1.Input(), __metadata("design:type", String) ], KeyValueComponent.prototype, "editicon", void 0); __decorate([ core_1.Input(), __metadata("design:type", String) ], KeyValueComponent.prototype, "inputtype", void 0); __decorate([ core_1.Input(), __metadata("design:type", Object) ], KeyValueComponent.prototype, "rows", void 0); __decorate([ core_1.Input(), __metadata("design:type", Object) ], KeyValueComponent.prototype, "cols", void 0); __decorate([ core_1.Input(), __metadata("design:type", Boolean) ], KeyValueComponent.prototype, "disabled", void 0); __decorate([ core_1.Output(), __metadata("design:type", Object) ], KeyValueComponent.prototype, "valuechange", void 0); __decorate([ core_1.Input(), __metadata("design:type", Boolean), __metadata("design:paramtypes", [Boolean]) ], KeyValueComponent.prototype, "warning", null); KeyValueComponent = __decorate([ core_1.Component({ selector: 'key-value', template: "\n <div *ngIf=\"editicon\"><div class=\"label\" [class]=\"labelclass + warningclass\" (click)=\"startedit();\"><span *ngIf=\"icon\" [class]=\"icon\"></span><span *ngIf=\"editicon\" [class]=\"editicon\" style=\"cursor: pointer;\"></span>&nbsp;\n {{ key }}\u00A0</div><span class=\"icon-undo {{undoclass == 'undo-show' ? 'undo-show' : 'undo-hide'}}\" (click)=\"undoedit();\"></span><textarea *ngIf=\"inputtype === 'textarea'\" [(ngModel)]=\"value\" [class]=\"valueclass\" [rows]=\"rows\" [cols]=\"cols\" (blur)=\"finishedit();\" (click)=\"startedit();\"></textarea><input *ngIf=\"inputtype !== &quot;textarea&quot;\" [(ngModel)]=\"value\" [class]=\"valueclass\" [type]=\"inputtype\" (blur)=\"finishedit();\" (click)=\"startedit();\"/></div><div *ngIf=\"!editicon &amp;&amp; value\"><div class=\"label\" [class]=\"labelclass + warningclass\"><span [class]=\"icon\"></span>{{ key }}\u00A0<span [class]=\"editicon\"></span></div><div class=\"view\" [class]=\"valueclass\">{{ value }}</div></div>\n ", providers: [CUSTOM_INPUT_CONTROL_VALUE_ACCESSOR] }) ], KeyValueComponent); return KeyValueComponent; }()); exports.KeyValueComponent = KeyValueComponent; //# sourceMappingURL=key-value.component.js.map