define(["require", "exports"], function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.RESET_DELAY = 2000;
    exports.OPTIMISTIC_COLOR = 'green';
    exports.OPTIMISTIC_ICON = 'success';
    /**
     * Controller holding the application-logic for <button-component>
     */
    var ButtonController = /** @class */ (function () {
        function ButtonController($window, $timeout) {
            this.$window = $window;
            this.$timeout = $timeout;
            this.disabled = false;
            this.resetDelay = exports.RESET_DELAY;
        }
        ButtonController.prototype.setStateSuccess = function () {
            this.iconBefore = this.icon;
            this.colorBefore = this.color;
            this.disabledBefore = this.disabled;
            this.icon = exports.OPTIMISTIC_ICON;
            this.color = exports.OPTIMISTIC_COLOR;
            this.disabled = true;
        };
        ButtonController.prototype.resetState = function () {
            this.icon = this.iconBefore;
            this.color = this.colorBefore;
            this.disabled = this.disabledBefore;
        };
        ButtonController.prototype.clickHandler = function () {
            var _this = this;
            if (!this.link) {
                if (this.optimistic === 'true') {
                    this.setStateSuccess();
                    this.$timeout(function () {
                        _this.resetState();
                    }, this.resetDelay);
                }
            }
            else {
                this.$window.location.href = this.link;
            }
        };
        return ButtonController;
    }());
    exports.ButtonController = ButtonController;
});
//# sourceMappingURL=button.controller.js.map