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.
172 lines • 7.42 kB
JavaScript
"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 SituationComponent; }),
multi: true
};
var SituationComponent = (function () {
function SituationComponent() {
this.withoutneutral = false;
this.valuechange = new core_1.EventEmitter();
this._value = '';
this._onTouchedCallback = noop;
this._onChangeCallback = noop;
}
Object.defineProperty(SituationComponent.prototype, "value", {
get: function () {
if (!this._value) {
return 0;
}
return this._value;
},
set: function (v) {
if (v !== this._value) {
if (this.withoutneutral && v === 3) {
v = 2;
}
this._value = v;
this._onChangeCallback(v);
this.checkActive();
}
},
enumerable: true,
configurable: true
});
;
SituationComponent.prototype.onTouched = function () {
this._onTouchedCallback();
};
SituationComponent.prototype.writeValue = function (value) {
this._value = value;
this.checkActive();
};
SituationComponent.prototype.registerOnChange = function (fn) {
this._onChangeCallback = fn;
};
SituationComponent.prototype.registerOnTouched = function (fn) {
this._onTouchedCallback = fn;
};
SituationComponent.prototype.labelClick = function () {
this.value++;
if (this.value === 4) {
this.value = 0;
}
this.checkActive();
};
SituationComponent.prototype.directclick = function (v) {
if (this.withoutneutral && v === 3) {
v = 2;
}
this.value = v;
this.checkActive();
this.valuechange.emit(v);
};
SituationComponent.prototype.checkActive = function () {
if (this.withoutneutral) {
switch (this._value) {
case 0:
this.activeclass0 = 'situation_active';
this.activeclass1 = undefined;
this.activeclass2 = undefined;
this.activeclass3 = undefined;
break;
case 1:
this.activeclass1 = 'situation_active situation_emotion_sad';
this.activeclass2 = undefined;
this.activeclass3 = undefined;
this.activeclass0 = undefined;
break;
case 2:
this.activeclass3 = 'situation_active situation_emotion_happy';
this.activeclass0 = undefined;
this.activeclass1 = undefined;
this.activeclass2 = undefined;
break;
default:
this.activeclass0 = 'situation_active';
this.activeclass1 = undefined;
this.activeclass2 = undefined;
this.activeclass3 = undefined;
}
}
else {
switch (this._value) {
case 0:
this.activeclass0 = 'situation_active';
this.activeclass1 = undefined;
this.activeclass2 = undefined;
this.activeclass3 = undefined;
break;
case 1:
this.activeclass1 = 'situation_active situation_emotion_sad';
this.activeclass2 = undefined;
this.activeclass3 = undefined;
this.activeclass0 = undefined;
break;
case 2:
this.activeclass2 = 'situation_active situation_emotion_neutral';
this.activeclass3 = undefined;
this.activeclass0 = undefined;
this.activeclass1 = undefined;
break;
case 3:
this.activeclass3 = 'situation_active situation_emotion_happy';
this.activeclass0 = undefined;
this.activeclass1 = undefined;
this.activeclass2 = undefined;
break;
default:
this.activeclass0 = 'situation_active';
this.activeclass1 = undefined;
this.activeclass2 = undefined;
this.activeclass3 = undefined;
}
}
};
SituationComponent.prototype.ngOnInit = function () {
var _this = this;
if (!this.value) {
this.value = 0;
}
setTimeout(function () {
_this.directclick(_this.value);
}, 5);
this.checkActive();
};
__decorate([
core_1.Input(),
__metadata("design:type", String)
], SituationComponent.prototype, "label", void 0);
__decorate([
core_1.Input(),
__metadata("design:type", Boolean)
], SituationComponent.prototype, "withoutneutral", void 0);
__decorate([
core_1.Output(),
__metadata("design:type", Object)
], SituationComponent.prototype, "valuechange", void 0);
SituationComponent = __decorate([
core_1.Component({
selector: 'md-situation',
template: "\n <div class=\"situation_content\"><div class=\"situation_emotions\"><span class=\"first situation_emotion icon-special-char-questionmark activeclass\" [ngClass]=\"activeclass0\" (click)=\"directclick(0)\"></span><span class=\"second situation_emotion icon-emoticon-sad activeclass\" [ngClass]=\"activeclass1\" (click)=\"directclick(1)\"></span><span class=\"third situation_emotion icon-emoticon-neutral activeclass\" *ngIf=\"!withoutneutral\" [ngClass]=\"activeclass2\" (click)=\"directclick(2)\"></span><span class=\"fourth situation_emotion icon-emoticon-happy activeclass\" [ngClass]=\"activeclass3\" (click)=\"directclick(3)\"></span></div><div class=\"situation_label\"><span class=\"situationlabel\" (click)=\"labelClick()\">{{ label }}</span></div></div>\n ",
encapsulation: core_1.ViewEncapsulation.None,
providers: [CUSTOM_INPUT_CONTROL_VALUE_ACCESSOR]
})
], SituationComponent);
return SituationComponent;
}());
exports.SituationComponent = SituationComponent;
//# sourceMappingURL=situation.component.js.map