materialize-rails 0.97.5.custom1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +63 -0
- data/Rakefile +1 -0
- data/lib/materialize-rails.rb +25 -0
- data/lib/materialize-rails/engine.rb +14 -0
- data/lib/materialize-rails/version.rb +3 -0
- data/materialize-rails.gemspec +25 -0
- data/vendor/assets/fonts/materialize/material-design-icons/LICENSE.txt +428 -0
- data/vendor/assets/fonts/materialize/material-design-icons/Material-Design-Icons.eot +0 -0
- data/vendor/assets/fonts/materialize/material-design-icons/Material-Design-Icons.svg +769 -0
- data/vendor/assets/fonts/materialize/material-design-icons/Material-Design-Icons.ttf +0 -0
- data/vendor/assets/fonts/materialize/material-design-icons/Material-Design-Icons.woff +0 -0
- data/vendor/assets/fonts/materialize/material-design-icons/Material-Design-Icons.woff2 +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Bold.eot +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Bold.ttf +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Bold.woff +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Bold.woff2 +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Light.eot +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Light.ttf +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Light.woff +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Light.woff2 +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Medium.eot +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Medium.ttf +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Medium.woff +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Medium.woff2 +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Regular.eot +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Regular.ttf +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Regular.woff +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Regular.woff2 +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Thin.eot +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Thin.ttf +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Thin.woff +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Thin.woff2 +0 -0
- data/vendor/assets/javascripts/materialize.js +30 -0
- data/vendor/assets/javascripts/materialize/animation.js +9 -0
- data/vendor/assets/javascripts/materialize/buttons.js +91 -0
- data/vendor/assets/javascripts/materialize/cards.js +29 -0
- data/vendor/assets/javascripts/materialize/carousel.js +350 -0
- data/vendor/assets/javascripts/materialize/character_counter.js +59 -0
- data/vendor/assets/javascripts/materialize/chips.js +9 -0
- data/vendor/assets/javascripts/materialize/collapsible.js +137 -0
- data/vendor/assets/javascripts/materialize/date_picker/picker.date.js +1430 -0
- data/vendor/assets/javascripts/materialize/date_picker/picker.js +1123 -0
- data/vendor/assets/javascripts/materialize/dropdown.js +228 -0
- data/vendor/assets/javascripts/materialize/forms.js +581 -0
- data/vendor/assets/javascripts/materialize/global.js +45 -0
- data/vendor/assets/javascripts/materialize/hammer.min.js +1 -0
- data/vendor/assets/javascripts/materialize/initial.js +11 -0
- data/vendor/assets/javascripts/materialize/jquery.easing.1.3.js +205 -0
- data/vendor/assets/javascripts/materialize/jquery.hammer.js +33 -0
- data/vendor/assets/javascripts/materialize/leanModal.js +178 -0
- data/vendor/assets/javascripts/materialize/materialbox.js +269 -0
- data/vendor/assets/javascripts/materialize/parallax.js +58 -0
- data/vendor/assets/javascripts/materialize/pushpin.js +62 -0
- data/vendor/assets/javascripts/materialize/scrollFire.js +44 -0
- data/vendor/assets/javascripts/materialize/scrollspy.js +285 -0
- data/vendor/assets/javascripts/materialize/sideNav.js +315 -0
- data/vendor/assets/javascripts/materialize/slider.js +321 -0
- data/vendor/assets/javascripts/materialize/tabs.js +129 -0
- data/vendor/assets/javascripts/materialize/toasts.js +136 -0
- data/vendor/assets/javascripts/materialize/tooltip.js +203 -0
- data/vendor/assets/javascripts/materialize/transitions.js +154 -0
- data/vendor/assets/javascripts/materialize/velocity.min.js +5 -0
- data/vendor/assets/javascripts/materialize/waves.js +338 -0
- data/vendor/assets/stylesheets/components/_buttons.scss +181 -0
- data/vendor/assets/stylesheets/components/_cards.scss +134 -0
- data/vendor/assets/stylesheets/components/_carousel.scss +34 -0
- data/vendor/assets/stylesheets/components/_chips.scss +27 -0
- data/vendor/assets/stylesheets/components/_collapsible.scss +85 -0
- data/vendor/assets/stylesheets/components/_color.scss +412 -0
- data/vendor/assets/stylesheets/components/_dropdown.scss +57 -0
- data/vendor/assets/stylesheets/components/_form.scss +918 -0
- data/vendor/assets/stylesheets/components/_global.scss +766 -0
- data/vendor/assets/stylesheets/components/_grid.scss +146 -0
- data/vendor/assets/stylesheets/components/_icons-material-design.scss +3263 -0
- data/vendor/assets/stylesheets/components/_materialbox.scss +42 -0
- data/vendor/assets/stylesheets/components/_mixins.scss +5 -0
- data/vendor/assets/stylesheets/components/_modal.scss +90 -0
- data/vendor/assets/stylesheets/components/_navbar.scss +171 -0
- data/vendor/assets/stylesheets/components/_normalize.scss +427 -0
- data/vendor/assets/stylesheets/components/_prefixer.scss +384 -0
- data/vendor/assets/stylesheets/components/_preloader.scss +334 -0
- data/vendor/assets/stylesheets/components/_roboto.scss +49 -0
- data/vendor/assets/stylesheets/components/_sideNav.scss +112 -0
- data/vendor/assets/stylesheets/components/_slider.scss +92 -0
- data/vendor/assets/stylesheets/components/_table_of_contents.scss +33 -0
- data/vendor/assets/stylesheets/components/_tabs.scss +56 -0
- data/vendor/assets/stylesheets/components/_toast.scss +65 -0
- data/vendor/assets/stylesheets/components/_tooltip.scss +33 -0
- data/vendor/assets/stylesheets/components/_typography.scss +61 -0
- data/vendor/assets/stylesheets/components/_variables.scss +161 -0
- data/vendor/assets/stylesheets/components/_waves.scss +173 -0
- data/vendor/assets/stylesheets/components/date_picker/_default.date.scss +435 -0
- data/vendor/assets/stylesheets/components/date_picker/_default.scss +201 -0
- data/vendor/assets/stylesheets/components/date_picker/_default.time.scss +125 -0
- data/vendor/assets/stylesheets/materialize.scss +40 -0
- metadata +199 -0
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,30 @@
|
|
1
|
+
//= require ./materialize/initial
|
2
|
+
//= require ./materialize/jquery.easing.1.3
|
3
|
+
//= require ./materialize/animation
|
4
|
+
//= require ./materialize/velocity.min
|
5
|
+
//= require ./materialize/hammer.min
|
6
|
+
//= require ./materialize/jquery.hammer
|
7
|
+
//= require ./materialize/global
|
8
|
+
//= require ./materialize/collapsible
|
9
|
+
//= require ./materialize/dropdown
|
10
|
+
//= require ./materialize/leanModal
|
11
|
+
//= require ./materialize/materialbox
|
12
|
+
//= require ./materialize/parallax
|
13
|
+
//= require ./materialize/tabs
|
14
|
+
//= require ./materialize/tooltip
|
15
|
+
//= require ./materialize/waves
|
16
|
+
//= require ./materialize/toasts
|
17
|
+
//= require ./materialize/sideNav
|
18
|
+
//= require ./materialize/scrollspy
|
19
|
+
//= require ./materialize/forms
|
20
|
+
//= require ./materialize/slider
|
21
|
+
//= require ./materialize/cards
|
22
|
+
//= require ./materialize/chips
|
23
|
+
//= require ./materialize/pushpin
|
24
|
+
//= require ./materialize/buttons
|
25
|
+
//= require ./materialize/transitions
|
26
|
+
//= require ./materialize/scrollFire
|
27
|
+
//= require ./materialize/date_picker/picker
|
28
|
+
//= require ./materialize/date_picker/picker.date
|
29
|
+
//= require ./materialize/character_counter
|
30
|
+
//= require ./materialize/carousel.js
|
@@ -0,0 +1,91 @@
|
|
1
|
+
(function ($) {
|
2
|
+
$(document).ready(function() {
|
3
|
+
|
4
|
+
// jQuery reverse
|
5
|
+
$.fn.reverse = [].reverse;
|
6
|
+
|
7
|
+
// Hover behaviour: make sure this doesn't work on .click-to-toggle FABs!
|
8
|
+
$(document).on('mouseenter.fixedActionBtn', '.fixed-action-btn:not(.click-to-toggle)', function(e) {
|
9
|
+
var $this = $(this);
|
10
|
+
openFABMenu($this);
|
11
|
+
});
|
12
|
+
$(document).on('mouseleave.fixedActionBtn', '.fixed-action-btn:not(.click-to-toggle)', function(e) {
|
13
|
+
var $this = $(this);
|
14
|
+
closeFABMenu($this);
|
15
|
+
});
|
16
|
+
|
17
|
+
// Toggle-on-click behaviour.
|
18
|
+
$(document).on('click.fixedActionBtn', '.fixed-action-btn.click-to-toggle > a', function(e) {
|
19
|
+
var $this = $(this);
|
20
|
+
var $menu = $this.parent();
|
21
|
+
if ($menu.hasClass('active')) {
|
22
|
+
closeFABMenu($menu);
|
23
|
+
} else {
|
24
|
+
openFABMenu($menu);
|
25
|
+
}
|
26
|
+
});
|
27
|
+
|
28
|
+
});
|
29
|
+
|
30
|
+
$.fn.extend({
|
31
|
+
openFAB: function() {
|
32
|
+
openFABMenu($(this));
|
33
|
+
},
|
34
|
+
closeFAB: function() {
|
35
|
+
closeFABMenu($(this));
|
36
|
+
}
|
37
|
+
});
|
38
|
+
|
39
|
+
|
40
|
+
var openFABMenu = function (btn) {
|
41
|
+
$this = btn;
|
42
|
+
if ($this.hasClass('active') === false) {
|
43
|
+
|
44
|
+
// Get direction option
|
45
|
+
var horizontal = $this.hasClass('horizontal');
|
46
|
+
var offsetY, offsetX;
|
47
|
+
|
48
|
+
if (horizontal === true) {
|
49
|
+
offsetX = 40;
|
50
|
+
} else {
|
51
|
+
offsetY = 40;
|
52
|
+
}
|
53
|
+
|
54
|
+
$this.addClass('active');
|
55
|
+
$this.find('ul .btn-floating').velocity(
|
56
|
+
{ scaleY: ".4", scaleX: ".4", translateY: offsetY + 'px', translateX: offsetX + 'px'},
|
57
|
+
{ duration: 0 });
|
58
|
+
|
59
|
+
var time = 0;
|
60
|
+
$this.find('ul .btn-floating').reverse().each( function () {
|
61
|
+
$(this).velocity(
|
62
|
+
{ opacity: "1", scaleX: "1", scaleY: "1", translateY: "0", translateX: '0'},
|
63
|
+
{ duration: 80, delay: time });
|
64
|
+
time += 40;
|
65
|
+
});
|
66
|
+
}
|
67
|
+
};
|
68
|
+
|
69
|
+
var closeFABMenu = function (btn) {
|
70
|
+
$this = btn;
|
71
|
+
// Get direction option
|
72
|
+
var horizontal = $this.hasClass('horizontal');
|
73
|
+
var offsetY, offsetX;
|
74
|
+
|
75
|
+
if (horizontal === true) {
|
76
|
+
offsetX = 40;
|
77
|
+
} else {
|
78
|
+
offsetY = 40;
|
79
|
+
}
|
80
|
+
|
81
|
+
$this.removeClass('active');
|
82
|
+
var time = 0;
|
83
|
+
$this.find('ul .btn-floating').velocity("stop", true);
|
84
|
+
$this.find('ul .btn-floating').velocity(
|
85
|
+
{ opacity: "0", scaleX: ".4", scaleY: ".4", translateY: offsetY + 'px', translateX: offsetX + 'px'},
|
86
|
+
{ duration: 80 }
|
87
|
+
);
|
88
|
+
};
|
89
|
+
|
90
|
+
|
91
|
+
}( jQuery ));
|
@@ -0,0 +1,29 @@
|
|
1
|
+
(function ($) {
|
2
|
+
$(document).ready(function() {
|
3
|
+
|
4
|
+
$(document).on('click.card', '.card', function (e) {
|
5
|
+
if ($(this).find('> .card-reveal').length) {
|
6
|
+
if ($(e.target).is($('.card-reveal .card-title')) || $(e.target).is($('.card-reveal .card-title i'))) {
|
7
|
+
// Make Reveal animate down and display none
|
8
|
+
$(this).find('.card-reveal').velocity(
|
9
|
+
{translateY: 0}, {
|
10
|
+
duration: 225,
|
11
|
+
queue: false,
|
12
|
+
easing: 'easeInOutQuad',
|
13
|
+
complete: function() { $(this).css({ display: 'none'}); }
|
14
|
+
}
|
15
|
+
);
|
16
|
+
}
|
17
|
+
else if ($(e.target).is($('.card .activator')) ||
|
18
|
+
$(e.target).is($('.card .activator i')) ) {
|
19
|
+
$(e.target).closest('.card').css('overflow', 'hidden');
|
20
|
+
$(this).find('.card-reveal').css({ display: 'block'}).velocity("stop", false).velocity({translateY: '-100%'}, {duration: 300, queue: false, easing: 'easeInOutQuad'});
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
$('.card-reveal').closest('.card').css('overflow', 'hidden');
|
25
|
+
|
26
|
+
});
|
27
|
+
|
28
|
+
});
|
29
|
+
}( jQuery ));
|
@@ -0,0 +1,350 @@
|
|
1
|
+
(function ($) {
|
2
|
+
|
3
|
+
var methods = {
|
4
|
+
|
5
|
+
init : function(options) {
|
6
|
+
var defaults = {
|
7
|
+
time_constant: 200, // ms
|
8
|
+
dist: -100, // zoom scale TODO: make this more intuitive as an option
|
9
|
+
shift: 0, // spacing for center image
|
10
|
+
padding: 0, // Padding between non center items
|
11
|
+
full_width: false // Change to full width styles
|
12
|
+
};
|
13
|
+
options = $.extend(defaults, options);
|
14
|
+
|
15
|
+
return this.each(function() {
|
16
|
+
|
17
|
+
var images, offset, center, pressed, dim, count,
|
18
|
+
reference, referenceY, amplitude, target, velocity,
|
19
|
+
xform, frame, timestamp, ticker, dragged, vertical_dragged;
|
20
|
+
|
21
|
+
// Initialize
|
22
|
+
var view = $(this);
|
23
|
+
// Don't double initialize.
|
24
|
+
if (view.hasClass('initialized')) {
|
25
|
+
return true;
|
26
|
+
}
|
27
|
+
|
28
|
+
// Options
|
29
|
+
if (options.full_width) {
|
30
|
+
options.dist = 0;
|
31
|
+
imageHeight = view.find('.carousel-item img').first().load(function(){
|
32
|
+
view.css('height', $(this).height());
|
33
|
+
});
|
34
|
+
}
|
35
|
+
|
36
|
+
view.addClass('initialized');
|
37
|
+
pressed = false;
|
38
|
+
offset = target = 0;
|
39
|
+
images = [];
|
40
|
+
item_width = view.find('.carousel-item').first().innerWidth();
|
41
|
+
dim = item_width * 2 + options.padding;
|
42
|
+
|
43
|
+
view.find('.carousel-item').each(function () {
|
44
|
+
images.push($(this)[0]);
|
45
|
+
});
|
46
|
+
|
47
|
+
count = images.length;
|
48
|
+
|
49
|
+
|
50
|
+
function setupEvents() {
|
51
|
+
if (typeof window.ontouchstart !== 'undefined') {
|
52
|
+
view[0].addEventListener('touchstart', tap);
|
53
|
+
view[0].addEventListener('touchmove', drag);
|
54
|
+
view[0].addEventListener('touchend', release);
|
55
|
+
}
|
56
|
+
view[0].addEventListener('mousedown', tap);
|
57
|
+
view[0].addEventListener('mousemove', drag);
|
58
|
+
view[0].addEventListener('mouseup', release);
|
59
|
+
view[0].addEventListener('click', click);
|
60
|
+
}
|
61
|
+
|
62
|
+
function xpos(e) {
|
63
|
+
// touch event
|
64
|
+
if (e.targetTouches && (e.targetTouches.length >= 1)) {
|
65
|
+
return e.targetTouches[0].clientX;
|
66
|
+
}
|
67
|
+
|
68
|
+
// mouse event
|
69
|
+
return e.clientX;
|
70
|
+
}
|
71
|
+
|
72
|
+
function ypos(e) {
|
73
|
+
// touch event
|
74
|
+
if (e.targetTouches && (e.targetTouches.length >= 1)) {
|
75
|
+
return e.targetTouches[0].clientY;
|
76
|
+
}
|
77
|
+
|
78
|
+
// mouse event
|
79
|
+
return e.clientY;
|
80
|
+
}
|
81
|
+
|
82
|
+
function wrap(x) {
|
83
|
+
return (x >= count) ? (x % count) : (x < 0) ? wrap(count + (x % count)) : x;
|
84
|
+
}
|
85
|
+
|
86
|
+
function scroll(x) {
|
87
|
+
var i, half, delta, dir, tween, el, alignment, xTranslation;
|
88
|
+
|
89
|
+
offset = (typeof x === 'number') ? x : offset;
|
90
|
+
center = Math.floor((offset + dim / 2) / dim);
|
91
|
+
delta = offset - center * dim;
|
92
|
+
dir = (delta < 0) ? 1 : -1;
|
93
|
+
tween = -dir * delta * 2 / dim;
|
94
|
+
|
95
|
+
if (!options.full_width) {
|
96
|
+
alignment = 'translateX(' + (view[0].clientWidth - item_width) / 2 + 'px) ';
|
97
|
+
alignment += 'translateY(' + (view[0].clientHeight - item_width) / 2 + 'px)';
|
98
|
+
} else {
|
99
|
+
alignment = 'translateX(0)';
|
100
|
+
}
|
101
|
+
|
102
|
+
// center
|
103
|
+
el = images[wrap(center)];
|
104
|
+
el.style[xform] = alignment +
|
105
|
+
' translateX(' + (-delta / 2) + 'px)' +
|
106
|
+
' translateX(' + (dir * options.shift * tween * i) + 'px)' +
|
107
|
+
' translateZ(' + (options.dist * tween) + 'px)';
|
108
|
+
el.style.zIndex = 0;
|
109
|
+
if (options.full_width) { tweenedOpacity = 1; }
|
110
|
+
else { tweenedOpacity = 1 - 0.2 * tween; }
|
111
|
+
el.style.opacity = tweenedOpacity;
|
112
|
+
half = count >> 1;
|
113
|
+
|
114
|
+
for (i = 1; i <= half; ++i) {
|
115
|
+
// right side
|
116
|
+
if (options.full_width) {
|
117
|
+
zTranslation = options.dist;
|
118
|
+
tweenedOpacity = (i === half && delta < 0) ? 1 - tween : 1;
|
119
|
+
} else {
|
120
|
+
zTranslation = options.dist * (i * 2 + tween * dir);
|
121
|
+
tweenedOpacity = 1 - 0.2 * (i * 2 + tween * dir);
|
122
|
+
}
|
123
|
+
el = images[wrap(center + i)];
|
124
|
+
el.style[xform] = alignment +
|
125
|
+
' translateX(' + (options.shift + (dim * i - delta) / 2) + 'px)' +
|
126
|
+
' translateZ(' + zTranslation + 'px)';
|
127
|
+
el.style.zIndex = -i;
|
128
|
+
el.style.opacity = tweenedOpacity;
|
129
|
+
|
130
|
+
|
131
|
+
// left side
|
132
|
+
if (options.full_width) {
|
133
|
+
zTranslation = options.dist;
|
134
|
+
tweenedOpacity = (i === half && delta > 0) ? 1 - tween : 1;
|
135
|
+
} else {
|
136
|
+
zTranslation = options.dist * (i * 2 - tween * dir);
|
137
|
+
tweenedOpacity = 1 - 0.2 * (i * 2 - tween * dir);
|
138
|
+
}
|
139
|
+
el = images[wrap(center - i)];
|
140
|
+
el.style[xform] = alignment +
|
141
|
+
' translateX(' + (-options.shift + (-dim * i - delta) / 2) + 'px)' +
|
142
|
+
' translateZ(' + zTranslation + 'px)';
|
143
|
+
el.style.zIndex = -i;
|
144
|
+
el.style.opacity = tweenedOpacity;
|
145
|
+
}
|
146
|
+
|
147
|
+
// center
|
148
|
+
el = images[wrap(center)];
|
149
|
+
el.style[xform] = alignment +
|
150
|
+
' translateX(' + (-delta / 2) + 'px)' +
|
151
|
+
' translateX(' + (dir * options.shift * tween) + 'px)' +
|
152
|
+
' translateZ(' + (options.dist * tween) + 'px)';
|
153
|
+
el.style.zIndex = 0;
|
154
|
+
if (options.full_width) { tweenedOpacity = 1; }
|
155
|
+
else { tweenedOpacity = 1 - 0.2 * tween; }
|
156
|
+
el.style.opacity = tweenedOpacity;
|
157
|
+
}
|
158
|
+
|
159
|
+
function track() {
|
160
|
+
var now, elapsed, delta, v;
|
161
|
+
|
162
|
+
now = Date.now();
|
163
|
+
elapsed = now - timestamp;
|
164
|
+
timestamp = now;
|
165
|
+
delta = offset - frame;
|
166
|
+
frame = offset;
|
167
|
+
|
168
|
+
v = 1000 * delta / (1 + elapsed);
|
169
|
+
velocity = 0.8 * v + 0.2 * velocity;
|
170
|
+
}
|
171
|
+
|
172
|
+
function autoScroll() {
|
173
|
+
var elapsed, delta;
|
174
|
+
|
175
|
+
if (amplitude) {
|
176
|
+
elapsed = Date.now() - timestamp;
|
177
|
+
delta = amplitude * Math.exp(-elapsed / options.time_constant);
|
178
|
+
if (delta > 2 || delta < -2) {
|
179
|
+
scroll(target - delta);
|
180
|
+
requestAnimationFrame(autoScroll);
|
181
|
+
} else {
|
182
|
+
scroll(target);
|
183
|
+
}
|
184
|
+
}
|
185
|
+
}
|
186
|
+
|
187
|
+
function click(e) {
|
188
|
+
// Disable clicks if carousel was dragged.
|
189
|
+
if (dragged) {
|
190
|
+
e.preventDefault();
|
191
|
+
e.stopPropagation();
|
192
|
+
return false;
|
193
|
+
|
194
|
+
} else if (!options.full_width) {
|
195
|
+
var clickedIndex = $(e.target).closest('.carousel-item').index();
|
196
|
+
var diff = (center % count) - clickedIndex;
|
197
|
+
|
198
|
+
// Account for wraparound.
|
199
|
+
if (diff < 0) {
|
200
|
+
if (Math.abs(diff + count) < Math.abs(diff)) { diff += count; }
|
201
|
+
|
202
|
+
} else if (diff > 0) {
|
203
|
+
if (Math.abs(diff - count) < diff) { diff -= count; }
|
204
|
+
}
|
205
|
+
|
206
|
+
// Call prev or next accordingly.
|
207
|
+
if (diff < 0) {
|
208
|
+
$(this).trigger('carouselNext', [Math.abs(diff)]);
|
209
|
+
|
210
|
+
} else if (diff > 0) {
|
211
|
+
$(this).trigger('carouselPrev', [diff]);
|
212
|
+
}
|
213
|
+
}
|
214
|
+
}
|
215
|
+
|
216
|
+
function tap(e) {
|
217
|
+
pressed = true;
|
218
|
+
dragged = false;
|
219
|
+
vertical_dragged = false;
|
220
|
+
reference = xpos(e);
|
221
|
+
referenceY = ypos(e);
|
222
|
+
|
223
|
+
velocity = amplitude = 0;
|
224
|
+
frame = offset;
|
225
|
+
timestamp = Date.now();
|
226
|
+
clearInterval(ticker);
|
227
|
+
ticker = setInterval(track, 100);
|
228
|
+
|
229
|
+
}
|
230
|
+
|
231
|
+
function drag(e) {
|
232
|
+
var x, delta, deltaY;
|
233
|
+
if (pressed) {
|
234
|
+
x = xpos(e);
|
235
|
+
y = ypos(e);
|
236
|
+
delta = reference - x;
|
237
|
+
deltaY = Math.abs(referenceY - y);
|
238
|
+
if (deltaY < 30 && !vertical_dragged) {
|
239
|
+
// If vertical scrolling don't allow dragging.
|
240
|
+
if (delta > 2 || delta < -2) {
|
241
|
+
dragged = true;
|
242
|
+
reference = x;
|
243
|
+
scroll(offset + delta);
|
244
|
+
}
|
245
|
+
|
246
|
+
} else if (dragged) {
|
247
|
+
// If dragging don't allow vertical scroll.
|
248
|
+
e.preventDefault();
|
249
|
+
e.stopPropagation();
|
250
|
+
return false;
|
251
|
+
|
252
|
+
} else {
|
253
|
+
// Vertical scrolling.
|
254
|
+
vertical_dragged = true;
|
255
|
+
}
|
256
|
+
}
|
257
|
+
|
258
|
+
if (dragged) {
|
259
|
+
// If dragging don't allow vertical scroll.
|
260
|
+
e.preventDefault();
|
261
|
+
e.stopPropagation();
|
262
|
+
return false;
|
263
|
+
}
|
264
|
+
}
|
265
|
+
|
266
|
+
function release(e) {
|
267
|
+
pressed = false;
|
268
|
+
|
269
|
+
clearInterval(ticker);
|
270
|
+
target = offset;
|
271
|
+
if (velocity > 10 || velocity < -10) {
|
272
|
+
amplitude = 0.9 * velocity;
|
273
|
+
target = offset + amplitude;
|
274
|
+
}
|
275
|
+
target = Math.round(target / dim) * dim;
|
276
|
+
amplitude = target - offset;
|
277
|
+
timestamp = Date.now();
|
278
|
+
requestAnimationFrame(autoScroll);
|
279
|
+
|
280
|
+
e.preventDefault();
|
281
|
+
e.stopPropagation();
|
282
|
+
return false;
|
283
|
+
}
|
284
|
+
|
285
|
+
xform = 'transform';
|
286
|
+
['webkit', 'Moz', 'O', 'ms'].every(function (prefix) {
|
287
|
+
var e = prefix + 'Transform';
|
288
|
+
if (typeof document.body.style[e] !== 'undefined') {
|
289
|
+
xform = e;
|
290
|
+
return false;
|
291
|
+
}
|
292
|
+
return true;
|
293
|
+
});
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
window.onresize = scroll;
|
298
|
+
|
299
|
+
setupEvents();
|
300
|
+
scroll(offset);
|
301
|
+
|
302
|
+
$(this).on('carouselNext', function(e, n) {
|
303
|
+
if (n === undefined) {
|
304
|
+
n = 1;
|
305
|
+
}
|
306
|
+
target = offset + dim * n;
|
307
|
+
if (offset !== target) {
|
308
|
+
amplitude = target - offset;
|
309
|
+
timestamp = Date.now();
|
310
|
+
requestAnimationFrame(autoScroll);
|
311
|
+
}
|
312
|
+
});
|
313
|
+
|
314
|
+
$(this).on('carouselPrev', function(e, n) {
|
315
|
+
if (n === undefined) {
|
316
|
+
n = 1;
|
317
|
+
}
|
318
|
+
target = offset - dim * n;
|
319
|
+
if (offset !== target) {
|
320
|
+
amplitude = target - offset;
|
321
|
+
timestamp = Date.now();
|
322
|
+
requestAnimationFrame(autoScroll);
|
323
|
+
}
|
324
|
+
});
|
325
|
+
|
326
|
+
});
|
327
|
+
|
328
|
+
|
329
|
+
|
330
|
+
},
|
331
|
+
next : function(n) {
|
332
|
+
$(this).trigger('carouselNext', [n]);
|
333
|
+
},
|
334
|
+
prev : function(n) {
|
335
|
+
$(this).trigger('carouselPrev', [n]);
|
336
|
+
},
|
337
|
+
};
|
338
|
+
|
339
|
+
|
340
|
+
$.fn.carousel = function(methodOrOptions) {
|
341
|
+
if ( methods[methodOrOptions] ) {
|
342
|
+
return methods[ methodOrOptions ].apply( this, Array.prototype.slice.call( arguments, 1 ));
|
343
|
+
} else if ( typeof methodOrOptions === 'object' || ! methodOrOptions ) {
|
344
|
+
// Default to "init"
|
345
|
+
return methods.init.apply( this, arguments );
|
346
|
+
} else {
|
347
|
+
$.error( 'Method ' + methodOrOptions + ' does not exist on jQuery.carousel' );
|
348
|
+
}
|
349
|
+
}; // Plugin end
|
350
|
+
}( jQuery ));
|