-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
72 lines (61 loc) · 1.93 KB
/
app.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
66
67
68
69
70
71
72
jQuery(document).ready(function() {
"use strict";
var widgetDo = function() {
jQuery('body, #widget-left').toggleClass('open');
jQuery('.widget-button i').toggleClass('icon-arrow-right icon-arrow-left');
if (!jQuery('body').hasClass('open')) {
jQuery('#tweet').twittie({
username: 'renta4',
list: 'renta4',
dateFormat: '%b. %d, %Y',
template: '{{tweet}} <div class="date">{{date}}</div>',
count: 25,
loadingText: ''
});
}
};
jQuery('.widget-button').click(function() {
widgetDo();
});
jQuery('#tweet').twittie({
username: 'renta4',
list: 'renta4',
dateFormat: '%b. %d, %Y',
template: '{{tweet}} <div class="date">{{date}}</div>',
count: 25,
loadingText: ''
});
jQuery("body").swipe({
swipe: function(event, direction) {
if (direction === 'left' & jQuery('body').hasClass('open')) {
widgetDo();
}
if (direction === 'right' & !jQuery('body').hasClass('open')) {
widgetDo();
}
},
allowPageScroll: "vertical"
});
document.onkeydown = checkKey;
function checkKey(e) {
e = e || window.event;
if (e.keyCode == '38') {
// up arrow
jQuery("#tweet").animate({ scrollTop: 0 }, 1000);
e.stopPropagation();
}
else if (e.keyCode == '40') {
// down arrow
jQuery("#tweet").animate({ scrollTop: jQuery("#tweet").scrollTop() + jQuery(window).height() - 20 }, 1000);
e.stopPropagation();
}
else if (e.keyCode == '37' & jQuery('body').hasClass('open')) {
// left arrow
widgetDo();
}
else if (e.keyCode == '39' & !jQuery('body').hasClass('open')) {
// right arrow
widgetDo();
}
}
});