whyclj
2019-10-29 1c0469e45346d464e0c5672ee68f9ecd4fb6be7c
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
// 查询内容为空是提示内容
function NoContent() {
    this.cont = $('body'); // 容器
    this.ht = $(document).height();   // 容器的高度
    this.wd = $(document).width();    // 容器的宽度
}
NoContent.prototype.showNoContent = function(str, fadeout) {
    this.ht = $(document).height();   // 容器的高度
    this.wd = $(document).width();    // 容器的宽度
    if(str == undefined) {
        str = '暂无查询数据!';
    }
    this.cont.css('position', 'relative');
    var noCont = $('<div class="no-cont"></div>');   // 提示框的容器
    var noContHd = $('<div class="no-cont-hd"></div>'); // 提示框的头部
    var noContTxt = $('<div class="no-cont-txt"></div>');   // 提示框的内容
 
    // 给提示框的头部添加信息
    var hdSpan = $('<span>系统提示</span>');
    var out = $('<a href="javascript:noContent.hideNoContent();"><img src="image/out.gif" alt="关闭"></a>');
    noContHd.append(out);
    noContHd.append(hdSpan);
    
    // 给提示框添加内容
    var txt  = $('<div class="no-txt">'+str+'</div>');
    noContTxt.append(txt);
 
    // 创建遮罩层
    var mask = $('<div class="no-cont-mask"></div>');
    mask.css({
        'position': 'fixed',
        'top': 0,
        'left': 0,
        'z-index': '999998',
        'width': '100%',
        'height': this.ht+'px',
        'background-color': '#000',
        'filter':'alpha(opacity=10)', /*IE滤镜,透明度50%*/
        '-moz-opacity':0.1,    /*Firefox私有,透明度50%*/
        'opacity':0.1    /*其他,透明度50%*/
    });
    this.cont.append(mask);
 
    noCont.append(noContHd);
    noCont.append(noContTxt);
    this.cont.append(noCont);
    noCont.draggable();    // 依赖于jquery-ui.js
    
    var _this = this;
    if(fadeout) {
        setTimeout(_this.hideNoContent.bind(_this), 2000);
    }
};
 
NoContent.prototype.hideNoContent = function(container) {
    if(container != undefined) {
        this.cont = container;    // 重新定义容器
    }
    this.cont.find('.no-cont').remove();
    this.cont.find('.no-cont-mask').remove();
};
 
var noContent = new NoContent();