
cc.Class({
    extends: cc.Component,

    properties: {

        content: cc.Node,

        // titleText: cc.RichText,
        // subTitleLabel: cc.Label,

        levelNumAfterText: cc.RichText,
        levelNameAfterText: cc.RichText,

        confirmNode: cc.Node,
        confirmText: cc.Node,
    },

    onLoad() {
        let self = this;
        this.confirmNode.on(cc.Node.EventType.TOUCH_END, () => {
            self.close();
        });
    },

    show(parent, title, subTitle, level, levelName, callback) {
        this.callback = callback;
        // this.titleText.string = this.outlineString(title, '#ffffff');

        // this.subTitleLabel.string = subTitle;


        this.levelNumAfterText.string = this.outlineString(level, '#584A47');
        this.levelNameAfterText.string = this.outlineString(levelName, '#ffffff');

        this.node.parent = parent;

        this.content.scaleX = 0;
        this.content.scaleY = 0;
        this.content.runAction(cc.scaleTo(0.35, 1, 1).easing(cc.easeBackOut()));
    },

    close() {
        let cb = this.callback
        let finish = cc.callFunc(() => {
            cb && cb();
            this.node.destroy();
        }, this);
        let sq = cc.sequence(cc.scaleTo(0.2, 0, 0).easing(cc.easeBackIn()), finish)
        this.content.runAction(sq);
    },

    outlineString(text, color) {
        return '<outline color=' + color + ' width=2><b>' + text + '</b></outline>';
    },


    onDestory() {
        this.confirmNode.off(cc.Node.EventType.TOUCH_END, this);
    }

});
