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

    self.kick_ref = null;
    self.other_info_flag = 1;
    self.input_flag = 1;
    self.initPage = function() {
        this.bindKickInfo();
    }
    self.bindKickInfo = function() {
        var info = this.kick_ref.get_user_info();
        $(".member-id").text(info.username);
        var group_flag = info.groupdisplay;
        var zone_flag =  info.zonedisplay;
        if(group_flag == false) {
            this.DisabledStatus("#c-group-name");
        }
        if(zone_flag == false) {
            this.DisabledStatus("#c-zone-name");
            $("#c-group-name").attr("checked", "checked");
            $("#c-zone-name").attr("disabled", "disabled");
        }
    }
    self.DisabledStatus = function(target) {
        var target = $(target);
        target.attr("disabled", "disabled");
        target.css("border","1px solid #969696").css("color", "#969696");
        target.next().css("color", "#969696");
    }
    self.SetDisableStatus = function() {
        if((this.input_flag == 1)  && (this.other_info_flag == 1)) {
            $(".popup-Box .btn-box .btn:first").css("background-color", "#00a2ff");
        } else{
            $(".popup-Box .btn-box .btn:first").css("background-color", "#C0C0C0");
        }
    }

    self.initEvent = function(){
        var that = this;
        /*确定按钮*/
        $(document).delegate(".btn-box button:eq(0)", "click", function () {
            var type = $("input[type='radio'][name='reason']:checked").val();
            var kick_l = parseInt($("#forbide_minute").val());
            if(kick_l <= 0) {
                return ;
            }
            if(type == 4) {
                var stopstring =  $("#txt").val().length;
                if(stopstring <= 0) {
                    return ;
                }
            }
            that.kick_ref.btn_ok_click();
        });

        /*取消按钮*/
        $(document).delegate(".btn-box button:eq(1)", "click", function () {
            that.kick_ref.btn_cancel_click();
        });


        $(document).delegate("#forbide_minute", "input", function () {
            var msg = $("#forbide_minute").val();
            if(msg > 0 && msg < 100) {
                that.input_flag = 1;
                that.SetDisableStatus();
            } else {
                that.input_flag = 0;
                that.SetDisableStatus();
            }
        });


        /*
         * 点击label，相邻兄弟节点checked改变状态
         */
        $(document).delegate("label", "click", function () {
            var flag = $(this).prev().is(":checked");
            var val = $(this).prev().val();
            if(val == 4) {
                var legth = $("#txt").val().length;
                if(legth <= 0) {
                    that.other_info_flag = 0;
                    that.SetDisableStatus();
                }
            } else {
                that.other_info_flag = 1;
                that.SetDisableStatus();
            }
            if(flag == false) {
                $(this).prev().prop('checked', true);
            }
        });



        /*
         * 点击radio-box，name为reason
         */
        $(document).delegate("input[type='radio'][name='reason']", "click", function () {
            var val = $(this).val();
            if(val == 4) {
                var legth = $("#txt").val().length;
                if(legth <= 0) {
                    that.other_info_flag = 0;
                    that.SetDisableStatus();
                }
            } else {
                that.other_info_flag = 1;
                that.SetDisableStatus();
            }
        });



        /*
         * 点击input值改变
         */
        $(document).delegate("#txt", "input", function () {
            var legth = $("#txt").val().length;
            if(legth <= 0) {
                that.other_info_flag = 0;
                that.SetDisableStatus();
            } else {
                that.other_info_flag = 1;
                that.SetDisableStatus();
            }
        });



        /* 替换输入的汉字 */
        $(document).delegate("#forbide_minute", "input", function () {
            var reg = /^[0-9]*$/;
            var str = this.value;
            var flag = reg.test(str);
            if(flag == false) {
                var ww = str.replace(/\D+/g,"");
                this.value = ww;
                return false;
            }
        });
    }

    self.func(function(curData){
        var that = this;
        that.addCall("send_kick_info", function () {
            var u_name = $(".member-id").text();
            var kicktime = that.toInt($("#forbide_minute").val());
            var kickcause = $("input[type='radio'][name='shot']:checked").val();
            var reason_target = $("input[type='radio'][name='reason']:checked");
            var reason_type = reason_target.val();
            var kickstring = '';
            if(reason_type == 4) {
                kickstring =  $("#txt").val();
            } else {
                kickstring = reason_target.next().text();
            }
            var text = "{ \"kickstring\":\"" + kickstring + "\",\"kicktime\":" +  kicktime + ",\"kickcause\":" + kickcause + "}";
            return that.formatData(text);
        });

        that.kick_ref = curData; //kickuserwnd;

        that.sup().constructor(curData);

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