]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | Ext.define('Admin.view.profile.Timeline', {\r |
2 | extend: 'Ext.DataView',\r | |
3 | xtype: 'profiletimeline',\r | |
4 | \r | |
5 | cls: 'timeline-items-wrap',\r | |
6 | \r | |
7 | scrollable: false,\r | |
8 | \r | |
9 | bind: '{userTimeline}',\r | |
10 | \r | |
11 | itemSelector: '.timeline-item',\r | |
12 | \r | |
13 | itemTpl: [\r | |
14 | '<div class="timeline-item{userId:this.cls(values,parent[xindex-2],xindex-1,xcount)}">' +\r | |
15 | '{date:this.epoch(values,parent[xindex-2],xindex-1,xcount)}' +\r | |
16 | '<div class="profile-pic-wrap">' +\r | |
17 | '<img src="resources/images/user-profile/{userId}.png" alt="Smiley face">' +\r | |
18 | '<div>{date:this.elapsed} ago</div>' +\r | |
19 | '</div>' +\r | |
20 | '<tpl if="notificationType == \'image_sharing\'">' +\r | |
21 | '<div class="line-wrap">' +\r | |
22 | '<div class="contents-wrap">' +\r | |
23 | '<div class="shared-by"><a href="#">{name}</a> shared an image</div>' +\r | |
24 | '<img src="resources/images/img2.jpg" class="shared-img" alt="Smiley face">' +\r | |
25 | '</div>' +\r | |
26 | '</div>' +\r | |
27 | '<tpl elseif="notificationType == \'job_meeting\'">' +\r | |
28 | '<div class="line-wrap">' +\r | |
29 | '<div class="contents-wrap">' +\r | |
30 | '<div class="job-meeting"><a href="#">Job Meeting</a></div>' +\r | |
31 | '<div>{content}</div>' +\r | |
32 | '</div>' +\r | |
33 | '</div>' +\r | |
34 | '<tpl elseif="notificationType == \'comment_reply\'">' +\r | |
35 | '<div class="line-wrap">' +\r | |
36 | '<div class="contents-wrap">' +\r | |
37 | '<div class="shared-by"><a href="#">{name}</a> commented on The Article</div>' +\r | |
38 | '<div class="article-comment"><span class="x-fa fa-quote-left"></span>{content}</div>' +\r | |
39 | '</div>' +\r | |
40 | '</div>' +\r | |
41 | '<tpl elseif="notificationType == \'new_follower\'">' +\r | |
42 | '<div class="line-wrap">' +\r | |
43 | '<div class="contents-wrap">' +\r | |
44 | '<div class="followed-by">' +\r | |
45 | '<img src="resources/images/user-profile/10.png" alt="Smiley face">' +\r | |
46 | '<div class="followed-by-inner"><a href="#">{name}</a> followed you.</div>' +\r | |
47 | '</div>' +\r | |
48 | '</div>' +\r | |
49 | '</div>' +\r | |
50 | '<tpl elseif="notificationType == \'comment\'">' +\r | |
51 | '<div class="line-wrap">' +\r | |
52 | '<div class="contents-wrap">' +\r | |
53 | '<div class="shared-by"><a href="#">Lorem ipsum dolor sit amet</a></div>' +\r | |
54 | '<div>{content}</div>' +\r | |
55 | '</div>' +\r | |
56 | '</div>' +\r | |
57 | '<tpl elseif="notificationType == \'like\'">' +\r | |
58 | '<div class="line-wrap">' +\r | |
59 | '<div class="contents-wrap">' +\r | |
60 | '<div class="followed-by">' +\r | |
61 | '<img src="resources/images/user-profile/1.png" alt="Smiley face">' +\r | |
62 | '<div class="followed-by-inner"><a href="#">{name}</a> Like The Article.</div>' +\r | |
63 | '</div>' +\r | |
64 | '</div>' +\r | |
65 | '</tpl>' +\r | |
66 | '</div>',\r | |
67 | {\r | |
68 | cls: function (value, record, previous, index, count) {\r | |
69 | var cls = '';\r | |
70 | \r | |
71 | if (!index) {\r | |
72 | cls += ' timeline-item-first';\r | |
73 | }\r | |
74 | if (index + 1 === count) {\r | |
75 | cls += ' timeline-item-last';\r | |
76 | }\r | |
77 | \r | |
78 | return cls;\r | |
79 | },\r | |
80 | \r | |
81 | elapsed: function (value) {\r | |
82 | var now = Date.now();\r | |
83 | now = +new Date('2015/08/23 21:15:00'); // 9:15 PM (For demo only)\r | |
84 | \r | |
85 | var seconds = Math.floor((now - value) / 1000),\r | |
86 | minutes = Math.floor(seconds / 60),\r | |
87 | hours = Math.floor(minutes / 60),\r | |
88 | days = Math.floor(hours / 24),\r | |
89 | weeks = Math.floor(days / 7),\r | |
90 | months = Math.floor(days / 30),\r | |
91 | years = Math.floor(days / 365),\r | |
92 | ret;\r | |
93 | \r | |
94 | months %= 12;\r | |
95 | weeks %= 52;\r | |
96 | days %= 365;\r | |
97 | hours %= 24;\r | |
98 | minutes %= 60;\r | |
99 | seconds %= 60;\r | |
100 | \r | |
101 | if (years) {\r | |
102 | ret = this.part(years, 'Year');\r | |
103 | ret += this.part(months, 'Month', ' ');\r | |
104 | } else if (months) {\r | |
105 | ret = this.part(months, 'Month');\r | |
106 | ret += this.part(days, 'Day', ' ');\r | |
107 | } else if (weeks) {\r | |
108 | ret = this.part(weeks, 'Week');\r | |
109 | ret += this.part(days, 'Day', ' ');\r | |
110 | } else if (days) {\r | |
111 | ret = this.part(days, 'Day');\r | |
112 | ret += this.part(hours, 'Hour', ' ');\r | |
113 | } else if (hours) {\r | |
114 | ret = this.part(hours, 'Hour');\r | |
115 | } else if (minutes) {\r | |
116 | ret = this.part(minutes, ' Minute');\r | |
117 | } else {\r | |
118 | ret = this.part(seconds, 'Second');\r | |
119 | }\r | |
120 | \r | |
121 | return ret;\r | |
122 | },\r | |
123 | \r | |
124 | epoch: function (value, record, previous, index, count) {\r | |
125 | var previousValue = previous &&\r | |
126 | (previous.isModel ? previous.data : previous)['date'];\r | |
127 | \r | |
128 | // TODO use previousValue and value to determine "Yesterday", "Last week",\r | |
129 | // "Last month", etc...\r | |
130 | \r | |
131 | if (index === 4) {\r | |
132 | return '<div class="timeline-epoch">Yesterday</div>';\r | |
133 | }\r | |
134 | \r | |
135 | return '';\r | |
136 | },\r | |
137 | \r | |
138 | part: function (value, type, gap) {\r | |
139 | var ret = value ? (gap || '') + value + ' ' + type : '';\r | |
140 | if (value > 1) {\r | |
141 | ret += 's';\r | |
142 | }\r | |
143 | return ret;\r | |
144 | }\r | |
145 | }\r | |
146 | ]\r | |
147 | });\r |