UNPKG

@angular-jz/jz

Version:

jim jz

120 lines 5.34 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 utility_1 = require("../../utility"); var JZDatePickerComponent = /** @class */ (function () { function JZDatePickerComponent() { this.format = 'yyyy-mm-dd'; this.placeholder = '请选择时间'; this.showIcon = true; this.propagateChange = function (_) { }; } JZDatePickerComponent_1 = JZDatePickerComponent; JZDatePickerComponent.prototype.ngOnInit = function () { var me = this; $(this.input.nativeElement).on('changeDate', function ($event) { var newValue = $event.date; me._value = newValue; me.propagateChange(me.value); }); $(this.input.nativeElement).on('blur', function ($event) { var newValueString = $(me.input.nativeElement).val(); if (!newValueString || !utility_1.DateUtility.isDate(newValueString)) { $(me.input.nativeElement).val(""); me._value = null; me.propagateChange(me.value); } }); }; JZDatePickerComponent.prototype.ngOnDestroy = function () { $(this.input.nativeElement).off('changeDate'); $(this.input.nativeElement).off('blue'); }; JZDatePickerComponent.prototype.ngAfterViewInit = function () { $(this.input.nativeElement).datepicker({ todayBtn: "linked", keyboardNavigation: false, forceParse: false, calendarWeeks: true, autoclose: true, format: this.format }); }; Object.defineProperty(JZDatePickerComponent.prototype, "value", { get: function () { //return $(this.checkbox.nativeElement).val(); return this._value; }, set: function (value) { if (this._value != value) { this._value = value; this.propagateChange(this.value); //if (value) $(this.checkbox.nativeElement).iCheck('check'); //else $(this.checkbox.nativeElement).iCheck('uncheck'); //$(this.select.nativeElement).val(this._value); //$(this.select.nativeElement).trigger('change'); $(this.input.nativeElement).val(utility_1.DateUtility.formatDate(this._value, this.format)); $(this.input.nativeElement).datepicker('update'); } }, enumerable: true, configurable: true }); JZDatePickerComponent.prototype.writeValue = function (value) { this.value = value; }; JZDatePickerComponent.prototype.registerOnChange = function (fn) { this.propagateChange = fn; }; JZDatePickerComponent.prototype.registerOnTouched = function (fn) { }; JZDatePickerComponent.prototype.show = function () { $(this.input.nativeElement).datepicker('show'); }; __decorate([ core_1.ViewChild('input'), __metadata("design:type", core_1.ElementRef) ], JZDatePickerComponent.prototype, "input", void 0); __decorate([ core_1.Input(), __metadata("design:type", String) ], JZDatePickerComponent.prototype, "format", void 0); __decorate([ core_1.Input(), __metadata("design:type", String) ], JZDatePickerComponent.prototype, "placeholder", void 0); __decorate([ core_1.Input(), __metadata("design:type", Boolean) ], JZDatePickerComponent.prototype, "showIcon", void 0); __decorate([ core_1.Input(), __metadata("design:type", Object) ], JZDatePickerComponent.prototype, "_value", void 0); JZDatePickerComponent = JZDatePickerComponent_1 = __decorate([ core_1.Component({ selector: 'jz-date-picker', templateUrl: './jz-date-picker.component.html', providers: [{ provide: forms_1.NG_VALUE_ACCESSOR, /* tslint:disable */ useExisting: core_1.forwardRef(function () { return JZDatePickerComponent_1; }), /* tslint:enable */ multi: true }], }) ], JZDatePickerComponent); return JZDatePickerComponent; var JZDatePickerComponent_1; }()); exports.JZDatePickerComponent = JZDatePickerComponent; //# sourceMappingURL=jz-date-picker.component.js.map