1
81041
2019-10-18 cc4059f9f5a2cd6766f4d888bd35d19f3827a053
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// define class Popup
 
function Popup(param) {
    this.popup = param;
    this.height = this.popup.height();
}
 
Popup.prototype.showPopup = function() {
    var winHt = $(window).height();
    var popupMask = $('<div class="popup-mask"></div>');
    $('body').append(popupMask);
    $('.popup-mask').animate({height: winHt+"px"});
    this.centerPopup();
    this.popup.css('visibility', 'visible');
    //console.info('显示执行成功!!!');
};
 
Popup.prototype.centerPopup = function() {
    var winHt = $(window).height();
    this.height = this.popup.height();
    var marginTop = (winHt - this.height)/2;
    this.popup.css('top', marginTop + 'px');
};
 
Popup.prototype.hidePopup = function() {
    this.popup.css('top', -9999+'px');
    $('.popup-mask').animate({height:0},function() {
 
        $('.popup-mask').remove();
    });
    if(this.hideBack) {
        var callback = this.hideBack;
        callback();
    }
    
    //console.info('隐藏执行成功!!!');
};
 
//初始化popup
function initPopup(obj, errorStatus) {
    //console.info(errorStatus);
    var ele = obj.popup;
    var textList = ele.find('input[type=text]');
    var selectList = ele.find('select');
    ele.data().errorStatus = (errorStatus == undefined)?false:true;
    ele.data().attr = [];
    
    // 遍历文本框移除错误提示信息
    textList.each(function() {
        $(this).removeClass('error-data');
        $(this).next('i').removeClass('error-data');
        
        var tmp = {
            type: 'input',
            id: $(this).attr('id'),
            val: $(this).val()
        };
        
        ele.data().attr.push(tmp);
    });
    
    // 遍历下拉框
    selectList.each(function() {
        var tmp = {
            type: 'select',
            id: $(this).attr('id'),
            val: $(this).val()
        };
        
        ele.data().attr.push(tmp);
    });
    
    // 移除按钮不可点击状态
    ele.find('.status-change-btn').removeClass('whyc-btn-disabled');
    
    //console.info(ele.data().errorStatus);
    // 读取参数失败
    if(ele.data().errorStatus) {
        ele.find('.status-change-btn').addClass('whyc-btn-disabled');
    }
}
 
var popup = new Popup($('.popup').eq(0));
$('.popup').eq(0).find('.close').bind('click', function() {
    popup.hidePopup();    // 隐藏弹出框和遮罩层
});
$('[data-toggle="popup"]').click(function() {
    popup.showPopup();    // 显示弹出框和遮罩层
});
/*$('body').on('click', '.popup-mask', function() {
    popup.hidePopup();    // 隐藏弹出框和遮罩层
});*/
// 窗口大小改变
$(window).resize(function() {
    popup.hidePopup();    // 隐藏弹出框和遮罩层
});