all files / amd/components/forms/ pickadateAttribute.js

95.35% Statements 41/43
80.65% Branches 25/31
91.67% Functions 11/12
97.37% Lines 37/38
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57                                        
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;
    Iif (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) Eif (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) {
    Eif (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
define(["require", "exports", "aurelia-framework", "aurelia-dependency-injection", "./../../config"], function (require, exports, aurelia_framework_1, aurelia_dependency_injection_1, config_1) {
    "use strict";
 
    var PickADateAttribute = function () {
        function PickADateAttribute(element) {
            this.element = element;
            this.options = "{}";
        }
        PickADateAttribute.prototype.attached = function () {
            this.element.classList.add("datepicker");
            $(this.element).pickadate(JSON.parse(this.options));
            this.picker = $(this.element).pickadate("picker");
            this.element.addEventListener("focus", this.openFunction.bind(this));
            $(this.picker).on({ "set": this.onSet.bind(this) });
        };
        PickADateAttribute.prototype.detached = function () {
            this.element.classList.remove("datepicker");
            this.element.removeEventListener("focus", this.openFunction);
            if (this.picker) {
                $(this.picker).stop();
            }
        };
        PickADateAttribute.prototype.onSet = function (value) {
            this.fireEvent(this.element, "input");
        };
        PickADateAttribute.prototype.valueChanged = function (newValue) {
            this.picker.set("select", newValue);
        };
        PickADateAttribute.prototype.openFunction = function () {
            this.picker.open();
        };
        PickADateAttribute.prototype.createEvent = function (name) {
            var event = document.createEvent("Event");
            event.initEvent(name, true, true);
            return event;
        };
        PickADateAttribute.prototype.fireEvent = function (element, name) {
            element.dispatchEvent(this.createEvent(name));
        };
        __decorate([aurelia_framework_1.bindable(), __metadata('design:type', Object)], PickADateAttribute.prototype, "options", void 0);
        PickADateAttribute = __decorate([aurelia_framework_1.customAttribute(config_1.config.pickadate), aurelia_dependency_injection_1.inject(Element), __metadata('design:paramtypes', [HTMLElement])], PickADateAttribute);
        return PickADateAttribute;
    }();
    exports.PickADateAttribute = PickADateAttribute;
});
 
//# sourceMappingURL=pickadateAttribute.js.map