This repository has been archived by the owner on Feb 28, 2019. It is now read-only.
/
the-dashboard.js
65 lines (58 loc) · 1.62 KB
/
the-dashboard.js
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
if (Meteor.isClient) {
// define global tab is focused variable
tabIsFocused = true;
Packery = {
options: {
itemSelector: '.module',
gutter: 15,
stamp: '.stamp',
percentPosition: true
},
init: function() {
Meteor.setTimeout(function(){
$('.home-wrapper').packery(this.options);
}, 100);
},
layout: function(){
var $grid = $('.home-wrapper').packery(this.options);
Meteor.setTimeout(function(){
$grid.packery('layout');
}, 100);
},
destroy: function(){
var $grid = $('.home-wrapper').packery(this.options);
$grid.packery('destroy');
}
};
// helper to convert objects to arrays for use in blaze templates
UI.registerHelper("arrayify", function(obj){
result = [];
for (var key in obj){
result.push({name:key,value:obj[key]});
}
return result;
});
// format time
UI.registerHelper('formatTime', function(time, formatting) {
if(formatting) {
return moment(time).format(formatting);
}
});
// format date
UI.registerHelper('dateToday', function() {
return moment().format('DD MMM YY');
});
// conver minutes to hours
UI.registerHelper('minutesToHours', function(time){
if (time) {
return time / 60;
}
});
// add global event listener to window to check if window is in focus
window.addEventListener('focus', function() {
tabIsFocused = true;
},false);
window.addEventListener('blur', function() {
tabIsFocused = false;
},false);
}