Class(function(extend, using, self){
    extend("pages/page");
    using("lib/jquery.min.js");

    var $btn = $(".btn-box button");
    var $btn0 = $btn.eq(0);
    var $btn1 = $btn.eq(1);
    var $ico = $('#div-ico');
    var $content = $(".c-alert-str");
    var $radio = $(".radio-box");
    var $count = $('#count-down');
    var btn_type = 0;

    self.input_error_ref = null;
    self.initPage = function () {
        var that = this;
        //Audio.InputErrorInfo.input_error_ref.log_trace("input-alert   start");
        that.bindInputInfo();
        //that.input_error_ref.log_trace("input-alert   end");
        $(window).on('keydown', function(e){
            if(e.keyCode == 13){
                that.input_error_ref.btn_ok_click();
            }
        });
        /*确定按钮*/
        $btn0.on("click", function () {
            that.input_error_ref.btn_ok_click();
        });
        /*取消按钮*/
        $btn1.on("click", function () {
            that.input_error_ref.btn_close_click();
        });
    }

    self.initEvent = function(){
        // 点击label，相邻兄弟节点checked改变状态
        $(document).delegate("label", "click", function () {
            var flag = $(this).prev().is(":checked");
            if (flag == true) {
                $(this).prev().prop('checked', false);
            } else {
                $(this).prev().prop('checked', true);
            }
        });
    }

    self.bindInputInfo = function () {
        var current_info = this.input_error_ref.get_current_tipsinfo();
        var tips_type = current_info.tipsType;
        btn_type = current_info.btnType;
        var never_show_type = current_info.nevershowType;
        var btn_on_name = current_info.btnOkName;
        var btn_cancel_name = current_info.btnCancelName;
        if (never_show_type == 1 || never_show_type == '1') {
            $radio.show();
        }
        var tips_str = current_info.tipsStr;
        var alert_width = current_info.width;
        var alert_height = current_info.height;
        var second = current_info.second;

        if(alert_width && alert_height){
            $(".popup-Box").css({width: alert_width, height: alert_height});
        }

        var str_length = this.toInt(tips_str.length);
        if (str_length < 10) {
            $ico.css("marginLeft", 60);
        }
        $content.text(tips_str);
        switch (tips_type) {
            case 0:
                $ico.removeClass().addClass("ico-succ");
                break;
            case 2:
                $ico.removeClass().addClass("ico-fail");
                break;
            case 1:
                $ico.removeClass().addClass("ico-warn");
                break;
        }
        if (btn_type == 0) {
            if (!this.isEmpty(btn_on_name)) {
                $btn0.text(btn_on_name);
            }
            $btn0.show();
            $btn1.hide();
        }
        if (btn_type == 1) {
            if (!this.isEmpty(btn_on_name)) {
                $btn0.text(btn_on_name);
            }
            if (!this.isEmpty(btn_cancel_name)) {
                $btn1.text(btn_cancel_name);
            }
            $btn0.show();
            $btn1.show();
        }

        // if count down
        if (second != 0) {
            setCountDown(parseInt(second));
        }
    }

    self.func(function(curData){
        var that = this;

//        that.addCall("get_nevershow_checked", function () {
//            return $("#sample-id-3").is(":checked");
//        });

        that.addCall("setCountDown", function (n) {
            $count.text(n);
            setTimeout(function () {
                if (n > 0) {
                    setCountDown(n - 1);
                } else {
                    that.input_error_ref.btn_ok_click();
                }
            }, 1000);
        });
        that.input_error_ref = curData; // window.tipswnd || {};

        that.sup().constructor(curData);

        that.initPage();
        that.initEvent();
    })

})



