Project

General

Profile

Download (1.8 KB) Statistics
| Branch: | Revision:
1
define([
2
"dojo/_base/declare"
3
], function(declare){
4
    return declare('steam2.StatsChartLoader', null, {
5

    
6
    loaderURL: '/stabile/static/img/loader.gif',
7

    
8
    constructor: function(chart){
9
        var node = this.node = chart.node;
10

    
11
        this.loader = dojo.create('div', {
12
            className: 'loading', 
13
            innerHTML:dojo.replace('<img alt="..." src="{loader}" style="vertical-align:middle;position:relative;left:{left}px;top:{top}px" height="20px" />', {
14
                left: node.clientWidth / 2,
15
                top: node.clientHeight / 2,
16
                loader: this.loaderURL}),
17
            style: dojo.replace('display:none;height:{height};width:{width}', {
18
                height: node.style.height, 
19
                width: node.style.width })
20
        }, node, 'before');
21

    
22
        this.noDataNotifier = dojo.create('div', {
23
            innerHTML: '<div style="padding-top:' + node.clientHeight / 2 + 'px;text-align:center;">no data!</div>',
24
            style: dojo.replace('display:none;height:{height};width:{width}', {
25
                height: node.style.height, 
26
                width: node.style.width })
27
        }, node, 'before');
28

    
29

    
30
        dojo.connect(chart, 'loading', this, this.show);
31
        dojo.connect(chart, 'render' , this, this.hide);
32
        dojo.connect(chart, 'noData', this, this.noData);
33
    },
34

    
35
    show: function(){
36
        this.node.style.display = 'none';
37
        this.noDataNotifier.style.display = 'none';
38
        this.loader.style.display = '';
39
    },
40
                 
41
    hide: function(){
42
        this.loader.style.display = 'none';
43
        this.noDataNotifier.style.display = 'none';
44
        this.node.style.display = '';
45
    },
46

    
47
    noData: function(){
48
        this.loader.style.display = 'none';
49
        this.noDataNotifier.style.display = '';
50
    }
51
                 
52
});
53

    
54
});
55

    
(7-7/14)