Project

General

Profile

Download (5.93 KB) Statistics
| Branch: | Revision:

git_sitools_idoc / Module_ProjectTimeline_sitools2 / WeekTimeline.js @ 20ff13ec

1
Ext.namespace('sitools.user.modules.weekTimeline');
2
sitools.user.modules.weekTimeline.createWeek= function (list){
3
        var date=new Date(list[0].date);
4
        switch(list[0].day){
5
                case "Monday":
6
                        this.firstday=list[0].daynum;
7
                        this.firstdate=date;
8
                break;
9
            case "Tuesday":
10
                    this.firstday=list[0].daynum-1.0;
11
                    this.firstdate=new Date(date-24*60*60*1000);
12
                break;
13
            case "Wednesday":
14
                    this.firstday=list[0].daynum-2.0;
15
                    this.firstdate=new Date(date-2*24*60*60*1000);
16
                break;
17
            case "Thursday":
18
                    this.firstday=list[0].daynum-3.0;
19
                    this.firstdate=new Date(date-3*24*60*60*1000);
20
                break;
21
            case "Friday":
22
                    this.firstday=list[0].daynum-4.0;
23
                    this.firstdate=new Date(date-4*24*60*60*1000);
24
                break;
25
            case "Saturday":
26
                    this.firstday=list[0].daynum-5.0;
27
                    this.firstdate=new Date(date-5*24*60*60*1000);
28
                break;
29
            case "Sunday":
30
                    this.firstday=list[0].daynum-6.0;
31
                    this.firstdate=new Date(date-6*24*60*60*1000);
32
                break;
33
        }
34
        this.lastday=this.firstday+6.0;
35
        this.lastdate=new Date();
36
        this.lastdate.setFullYear(this.firstdate.getFullYear());
37
        this.lastdate.setMonth(this.firstdate.getMonth());
38
        this.lastdate.setDate(this.firstdate.getDate()+6);
39
        this.text="";
40
        this.activities=new Array();
41
        for(var i=0;i<list.length;i++){
42
                this.activities.push(new sitools.user.modules.timeline.createActivity(list[i]));
43
                if(i==0){
44
                        this.text=this.text+list[i].text+"<br/>";
45
                }else{
46
                        if(list[i].text!=list[i-1].text){
47
                                this.text=this.text+list[i].text+"<br/>";
48
                        }
49
                }
50
                
51
        }
52
        this.getFirstday=getFirstday;
53
        function getFirstday(){
54
                return this.firstday;
55
        }
56
        this.getLastday=getLastday;
57
        function getLastday(){
58
                return this.lastday;
59
        }
60
        this.getFirstdate=getFirstdate;
61
        function getFirstdate(){
62
                return this.firstdate;
63
        }
64
        this.getLastdate=getLastdate;
65
        function getLastdate(){
66
                return this.lastdate;
67
        }
68
        this.getText=getText;
69
        function getText(){
70
                return this.text;
71
        }
72
        this.getActivities=getActivities;
73
        function getActivities(){
74
                return this.activities;
75
        }
76
}
77
sitools.user.modules.weekTimeline.prepareWeekTimeline= function (s,list){
78
        var appendTo = Ext.get(s);
79
        var container = Ext.get(Ext.DomHelper.append(appendTo,'<div id="timeline" align="center" class="timeline"></div>'));
80
        container=Ext.get(Ext.DomHelper.append(container,"<ul id='lineul' class='timeline'/>"));
81
        sitools.user.modules.weekTimeline.showActivity(list,container);
82
}
83
sitools.user.modules.weekTimeline.addWeekTimeline=function (list){
84
        var container = Ext.get('lineul');
85
        sitools.user.modules.weekTimeline.showActivity(list,container);
86
}
87
sitools.user.modules.weekTimeline.showActivity= function (weekList, ulObj){
88
        var count=0;
89
        for(var i=0; i<weekList.length;i++){
90
                if(count%2!=1){
91
                        var liObj = Ext.DomHelper.append(ulObj, "<li/>");
92
                }else{
93
                        var liObj = Ext.DomHelper.append(ulObj, "<li class='alt'/>");
94
                }
95
                var monday=weekList[i].getFirstdate().toDateString().split(" ");
96
                var sunday=weekList[i].getLastdate().toDateString().split(" ");
97
                Ext.DomHelper.append(liObj, 
98
                                "<div class='monday'>"+monday[1]+" "+monday[2]+" "+monday[3]+" -</div>"
99
                                +"<div class='sunday'>- "+sunday[1]+" "+sunday[2]+" "+sunday[3]+"</div>"
100
                                +"<div class='weeknumber'><strong>W "+(weekList[i].getFirstday()-40343.0)/7+"</strong></div>"
101
                                );
102
                var contentObj=Ext.DomHelper.append(liObj,"<div class='preview' />");
103
                var activities=weekList[i].getActivities();
104
                var preObj=Ext.DomHelper.append(contentObj,"<pre class='nodata' onclick='sitools.user.modules.weekTimeline.viewDetail(this.parentNode);' style='height:200px;'></pre>");
105
                var preObj=Ext.DomHelper.append(preObj,"<div class='activity_name'></div>");
106
                for(var j=0;j<activities.length;j++){
107
                        if(j==0){
108
                                if(activities[j].haveData()){
109
                                        Ext.DomHelper.append(preObj,"<div style='color:#F7FE2E'>"+activities[j].getText()+"</div>");
110
                                }else{
111
                                        Ext.DomHelper.append(preObj,"<div>"+activities[j].getText()+"</div>");
112
                                }
113
                        }else{
114
                                if(activities[j].getText()!=activities[j-1].getText()){
115
                                        if(activities[j].haveData()){
116
                                                Ext.DomHelper.append(preObj,"<div style='color:#F7FE2E'>"+activities[j].getText()+"</div>");
117
                                        }else{
118
                                                Ext.DomHelper.append(preObj,"<div>"+activities[j].getText()+"</div>");
119
                                        }
120
                                }
121
                        }
122
                }
123
                Ext.DomHelper.append(contentObj,"<div class='detail_button' onclick='sitools.user.modules.weekTimeline.viewDetail(this.parentNode);'><div class='img_detail'></div></div>");
124
                var detailObj=Ext.DomHelper.append(liObj,"<div class='detail' style='display:none;' />");
125
                var detailUlObj=Ext.get(Ext.DomHelper.append(detailObj,"<ul class='timeline' />"));
126
                 var ruler1="<div class='ruler ruler1'>00:00:00</div>";
127
                 var ruler2="<div class='ruler ruler2'>06:00:00</div>";
128
                 var ruler3="<div class='ruler ruler3'>12:00:00</div>";
129
                 var ruler4="<div class='ruler ruler4'>18:00:00</div>";
130
                 var ruler5="<div class='ruler ruler5'>24:00:00</div>";
131
                Ext.DomHelper.append(detailUlObj,ruler1);
132
                Ext.DomHelper.append(detailUlObj,ruler2);
133
                Ext.DomHelper.append(detailUlObj,ruler3);
134
                Ext.DomHelper.append(detailUlObj,ruler4);
135
                Ext.DomHelper.append(detailUlObj,ruler5);
136
                sitools.user.modules.timeline.showActivity(weekList[i].getActivities(),detailUlObj);
137
                Ext.DomHelper.append(detailObj,"<div class='close_button' onclick='sitools.user.modules.weekTimeline.backtoweek(this.parentNode);'><div class='img_close'></div></div>");
138
                
139
                count++;
140
                
141
        }
142
}
143

    
144
sitools.user.modules.weekTimeline.back=function(o){
145
        o.parentNode.parentNode.scrollIntoView();
146
        
147
}
148

    
149
sitools.user.modules.weekTimeline.viewDetail=function(o){
150
        //Ext.get(o).hide();
151
        o.style.display="none";
152
        //o.nextSibling.style.display="block";
153
        Ext.get(o.nextSibling).slideIn('t', {duration: 0.5 });
154
        
155
}
156
sitools.user.modules.weekTimeline.backtoweek=function(o){
157
        //Ext.get(o).slideOut('t',{duration: 0.5});
158
        o.style.display="none";        
159
        //o.previousSibling.style.display="block";
160
        Ext.get(o.previousSibling).slideIn('t', {duration: 0.3 });
161
}
162

    
163

    
164

    
165

    
166

    
167

    
168

    
169

    
170

    
171

    
172

    
173

    
174

    
175

    
176

    
177

    
178

    
179

    
180

    
181

    
182

    
183

    
184

    
185

    
186

    
187

    
188

    
189

    
190

    
191

    
192

    
193

    
194

    
195

    
196

    
197

    
198