"use strict";
var __reflect = (this && this.__reflect) || function (p, c, t) {
    p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t;
};
var __extends = this && this.__extends || function __extends(t, e) { 
 function r() { 
 this.constructor = t;
}
for (var i in e) e.hasOwnProperty(i) && (t[i] = e[i]);
r.prototype = e.prototype, t.prototype = new r();
};
Object.defineProperty(exports, "__esModule", { value: true });
var ComponentBase_1 = require("../components/ComponentBase");
var Loading_1 = require("../loading/Loading");
var Panel = (function (_super) {
    __extends(Panel, _super);
    function Panel(data, hasMask) {
        if (hasMask === void 0) { hasMask = true; }
        var _this = _super.call(this, data) || this;
        _this.hasMask = hasMask;
        return _this;
    }
    /**
     *
     * @param hasColor true 有颜色  false为没有颜色
     */
    Panel.prototype.setMask = function () {
        if (!this.pMask) {
            var rate = document.body.clientHeight / document.body.clientWidth;
            this.pMask = new egret.Shape();
            this.pMask.graphics.beginFill(0, 0.8);
            this.pMask.graphics.drawRect(0, 0, 750, 750 * rate);
            this.pMask.graphics.endFill();
            this.addChildAt(this.pMask, 0);
            this.pMask.touchEnabled = false;
        }
    };
    Panel.prototype.setShowAct = function () {
        var _this = this;
        this.alpha = 0;
        // this.y = document.body.clientHeight;
        // this.scaleY = 0;
        egret.Tween.get(this).to({ alpha: 1 }, 300).call(function () {
            _this.onShowActComplete();
        });
    };
    /**@virtual */
    Panel.prototype.onShowActComplete = function () { };
    Panel.prototype.initEvents = function () {
        var _this = this;
        if (this.closeBtns && this.closeBtns.length > 0) {
            this.closeBtns.forEach(function (btn) { if (btn)
                btn.addEventListener(egret.TouchEvent.TOUCH_TAP, _this.onTouchTap, _this); });
        }
        if (this.confirmBtns && this.confirmBtns.length > 0) {
            this.confirmBtns.forEach(function (btn) { if (btn)
                btn.addEventListener(egret.TouchEvent.TOUCH_TAP, _this.onTouchTap, _this); });
        }
        if (this.creditsOutBtns && this.creditsOutBtns.length > 0) {
            this.creditsOutBtns.forEach(function (btn) { if (btn)
                btn.addEventListener(egret.TouchEvent.TOUCH_TAP, _this.creditsOut, _this); });
        }
    };
    Panel.prototype.removeEvents = function () {
        var _this = this;
        if (this.closeBtns && this.closeBtns.length > 0) {
            this.closeBtns.forEach(function (btn) { if (btn)
                btn.removeEventListener(egret.TouchEvent.TOUCH_TAP, _this.onTouchTap, _this); });
        }
        if (this.confirmBtns && this.confirmBtns.length > 0) {
            this.confirmBtns.forEach(function (btn) { if (btn)
                btn.removeEventListener(egret.TouchEvent.TOUCH_TAP, _this.onTouchTap, _this); });
        }
        if (this.creditsOutBtns && this.creditsOutBtns.length > 0) {
            this.creditsOutBtns.forEach(function (btn) { if (btn)
                btn.removeEventListener(egret.TouchEvent.TOUCH_TAP, _this.creditsOut, _this); });
        }
    };
    Panel.prototype.onSkinComplete = function () {
        _super.prototype.onSkinComplete.call(this);
        Loading_1.default.instace.hide();
        this.setMask();
        if (!this.hasMask) {
            this.pMask.alpha = 0;
        }
        console.log('this.pMask' + this.hasMask);
        this.setShowAct();
    };
    Object.defineProperty(Panel.prototype, "closeBtns", {
        get: function () { return [this['closeBtn']]; },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Panel.prototype, "confirmBtns", {
        get: function () { return [this['confirmBtn']]; },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Panel.prototype, "creditsOutBtns", {
        get: function () { return [this['creditsOutBtn']]; },
        enumerable: true,
        configurable: true
    });
    Panel.prototype.onTouchTap = function () {
        this.hidePanel();
    };
    Panel.prototype.hidePanel = function () {
        this.destroy();
        this.dispatchEvent(new egret.Event('onDestroy'));
    };
    Panel.prototype.creditsOut = function () {
        this.destroy();
        this.dispatchEvent(new egret.Event('onCreditsOut'));
    };
    return Panel;
}(ComponentBase_1.default));
exports.default = Panel;
__reflect(Panel.prototype, "\"c:/Users/duiba/Documents/zhonghe_answer/egret/src/views/Panel\".Panel");
//# sourceMappingURL=Panel.js.map