david-PC\david
2018-06-12 cc7f57619fd09f68582b748a3580402717b84c50
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
 
    // ================================Loading===================================//
    Loading = $.fm.LoadingClass = Control.subClass({
        template: [
            '<div class="loading_mask" style="display: none" align="center">',
                '<div id="area" class="loading_area" align="center">',
                    '<div class="loading_image"></div>',
                '</div>',
            '</div>'
        ],
        itemTemplate: '<div class="loading_text"></div>',
        itemList: {},
    
        init: function(options) {
            options = options ? options : {};
            Control.call(this, options);
            this.canvas = $(window.top.window.document.body);
            
            this.createEl();
        },
        
        createEl: function() {
            var el = this.el = $(this.template.join(""));
            this.area = $("#area", el);
            this.canvas.append(this.el);
        },
        
        show: function (code, text) {
            text = text || code;
            code = code || "item";
            
            var item = this.itemList[code];
            
            if (!item) {
                item = this.itemList[code] = $(this.itemTemplate);
                this.area.append(item);
            }
            
            item.html(text);
            this.el.show();
        },
        
        hide: function(code) {
            if (code) {
                var item = this.itemList[code];
                if (item) {
                    item.remove();
                }
                
                for (var n in this.itemList) {
                    return;
                }
                
                this.el.hide();
                return;
            }
            
            this.el.hide();
            
            for (var n in this.itemList) {
                var item = this.itemList[n];
                if (item.remove) {
                    item.remove();
                }
            }
            this.itemList = {};
        }
    });        
    
    Loading.show = function(code, text) {
        var instance = window.top.window.Loading.instance || this.instance;
        
        if (!instance) {
            instance = this.instance = new $.fm.LoadingClass();
        }
        
        instance.show(code, text);
    };
    
    Loading.hide = function(code) {
        var instance = window.top.window.Loading.instance || this.instance;
        
        if (!instance) {
            instance = this.instance = new $.fm.LoadingClass();
        }
        
        instance.hide(code);
    };
 
    $(window.document).ready(function() {
        Loading.hide();
    });