-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslideshow.js
92 lines (80 loc) · 2.53 KB
/
slideshow.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Generated by CoffeeScript 1.12.7
(function() {
var Application, Utils,
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
window.DEMO = window.DEMO || {};
Utils = {
'transform': Modernizr.prefixed('transform').replace(/([A-Z])/g, (function(_this) {
return function(str, m1) {
return '-' + m1.toLowerCase();
};
})(this)).replace(/^ms-/, '-ms-'),
'translate': (function(_this) {
return function(x, y) {
var tran, vals;
tran = Modernizr.csstransforms3d ? 'translate3d' : 'translate';
vals = Modernizr.csstransforms3d ? '(' + x + ', ' + y + ', 0)' : '(' + x + ', ' + y + ')';
return tran + vals;
};
})(this)
};
Application = (function() {
function Application() {
this.update = bind(this.update, this);
this.next = bind(this.next, this);
this.previous = bind(this.previous, this);
this.onKeyup = bind(this.onKeyup, this);
DEMO.utils = Utils;
this.$doc = $(document);
this.$roller = $('.roller');
this.$step = $('#steps li');
this.$title = $('#titles li');
this.min = 0;
this.max = this.$step.length - 1;
this.active_index = 0;
this.$step.eq(this.active_index).addClass('active');
this.$title.eq(this.active_index).addClass('active');
this.observe();
}
Application.prototype.observe = function() {
return this.$doc.on('keyup', this.onKeyup);
};
Application.prototype.onKeyup = function(e) {
var kc;
kc = e.keyCode;
if (kc === 38) {
e.preventDefault();
this.previous();
}
if (kc === 40) {
e.preventDefault();
return this.next();
}
};
Application.prototype.previous = function() {
if (this.active_index > this.min) {
this.active_index--;
return this.update();
}
};
Application.prototype.next = function() {
if (this.active_index < this.max) {
this.active_index++;
return this.update();
}
};
Application.prototype.update = function() {
var y;
y = -(this.active_index * 100);
this.$roller.css(DEMO.utils.transform, DEMO.utils.translate(0, y + "%"));
this.$step.removeClass('active');
this.$title.removeClass('active');
this.$step.eq(this.active_index).addClass('active');
return this.$title.eq(this.active_index).addClass('active');
};
return Application;
})();
$(function() {
return DEMO.instance = new Application();
});
}).call(this);