materialize-sass 0.96.1 → 0.96.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/fonts/material-design-icons/Material-Design-Icons.eot +0 -0
- data/app/assets/fonts/material-design-icons/Material-Design-Icons.svg +760 -742
- data/app/assets/fonts/material-design-icons/Material-Design-Icons.ttf +0 -0
- data/app/assets/fonts/material-design-icons/Material-Design-Icons.woff +0 -0
- data/app/assets/fonts/material-design-icons/Material-Design-Icons.woff2 +0 -0
- data/app/assets/javascripts/materialize.js +4 -6022
- data/app/assets/javascripts/materialize/cards.js +1 -1
- data/app/assets/javascripts/materialize/character_counter.js +1 -1
- data/app/assets/javascripts/materialize/collapsible.js +6 -6
- data/app/assets/javascripts/materialize/dropdown.js +10 -10
- data/app/assets/javascripts/materialize/forms.js +29 -19
- data/app/assets/javascripts/materialize/global.js +7 -2
- data/app/assets/javascripts/materialize/init.js +3 -4
- data/app/assets/javascripts/materialize/leanModal.js +56 -31
- data/app/assets/javascripts/materialize/materialbox.js +10 -10
- data/app/assets/javascripts/materialize/scrollFire.js +3 -28
- data/app/assets/javascripts/materialize/sideNav.js +31 -54
- data/app/assets/javascripts/materialize/slider.js +246 -200
- data/app/assets/javascripts/materialize/tabs.js +9 -2
- data/app/assets/javascripts/materialize/toasts.js +7 -3
- data/app/assets/javascripts/materialize/tooltip.js +7 -7
- data/app/assets/javascripts/materialize/transitions.js +2 -2
- data/app/assets/stylesheets/materialize/components/_buttons.scss +6 -0
- data/app/assets/stylesheets/materialize/components/_collapsible.scss +4 -7
- data/app/assets/stylesheets/materialize/components/_color.scss +1 -1
- data/app/assets/stylesheets/materialize/components/_dropdown.scss +7 -5
- data/app/assets/stylesheets/materialize/components/_form.scss +43 -6
- data/app/assets/stylesheets/materialize/components/_global.scss +32 -25
- data/app/assets/stylesheets/materialize/components/_icons-material-design.scss +3231 -757
- data/app/assets/stylesheets/materialize/components/_modal.scss +7 -5
- data/app/assets/stylesheets/materialize/components/_navbar.scss +6 -5
- data/app/assets/stylesheets/materialize/components/_slider.scss +1 -1
- data/app/assets/stylesheets/materialize/components/_tabs.scss +5 -0
- data/app/assets/stylesheets/materialize/components/_tooltip.scss +1 -1
- data/app/assets/stylesheets/materialize/components/_typography.scss +1 -3
- data/app/assets/stylesheets/materialize/components/_variables.scss +2 -1
- data/app/assets/stylesheets/materialize/components/date_picker/_default.scss +5 -5
- data/lib/materialize-sass/engine.rb +1 -1
- data/lib/materialize-sass/version.rb +1 -1
- metadata +3 -3
@@ -4,11 +4,11 @@
|
|
4
4
|
|
5
5
|
return this.each(function() {
|
6
6
|
|
7
|
-
if ($(this).hasClass('
|
7
|
+
if ($(this).hasClass('initialized')) {
|
8
8
|
return;
|
9
9
|
}
|
10
10
|
|
11
|
-
$(this).addClass('
|
11
|
+
$(this).addClass('initialized');
|
12
12
|
|
13
13
|
var overlayActive = false;
|
14
14
|
var doneAnimating = true;
|
@@ -19,15 +19,15 @@
|
|
19
19
|
var originalWidth = 0;
|
20
20
|
var originalHeight = 0;
|
21
21
|
origin.wrap(placeholder);
|
22
|
-
|
23
|
-
|
22
|
+
|
23
|
+
|
24
24
|
origin.on('click', function(){
|
25
25
|
var placeholder = origin.parent('.material-placeholder');
|
26
26
|
var windowWidth = window.innerWidth;
|
27
27
|
var windowHeight = window.innerHeight;
|
28
28
|
var originalWidth = origin.width();
|
29
29
|
var originalHeight = origin.height();
|
30
|
-
|
30
|
+
|
31
31
|
|
32
32
|
// If already modal, return to original
|
33
33
|
if (doneAnimating === false) {
|
@@ -38,7 +38,7 @@
|
|
38
38
|
returnToOriginal();
|
39
39
|
return false;
|
40
40
|
}
|
41
|
-
|
41
|
+
|
42
42
|
|
43
43
|
// Set states
|
44
44
|
doneAnimating = false;
|
@@ -54,8 +54,8 @@
|
|
54
54
|
top: 0,
|
55
55
|
left: 0
|
56
56
|
});
|
57
|
-
|
58
|
-
|
57
|
+
|
58
|
+
|
59
59
|
|
60
60
|
// Set css on origin
|
61
61
|
origin.css({position: 'absolute', 'z-index': 1000})
|
@@ -83,7 +83,7 @@
|
|
83
83
|
$photo_caption.text(origin.data('caption'));
|
84
84
|
$('body').append($photo_caption);
|
85
85
|
$photo_caption.css({ "display": "inline" });
|
86
|
-
$photo_caption.velocity({opacity: 1}, {duration: inDuration, queue: false, easing: 'easeOutQuad'})
|
86
|
+
$photo_caption.velocity({opacity: 1}, {duration: inDuration, queue: false, easing: 'easeOutQuad'});
|
87
87
|
}
|
88
88
|
|
89
89
|
|
@@ -178,7 +178,7 @@
|
|
178
178
|
var windowHeight = window.innerHeight;
|
179
179
|
var originalWidth = origin.data('width');
|
180
180
|
var originalHeight = origin.data('height');
|
181
|
-
|
181
|
+
|
182
182
|
origin.velocity("stop", true);
|
183
183
|
$('#materialbox-overlay').velocity("stop", true);
|
184
184
|
$('.materialbox-caption').velocity("stop", true);
|
@@ -29,41 +29,16 @@
|
|
29
29
|
var elementOffset = currentElement.getBoundingClientRect().top + document.body.scrollTop;
|
30
30
|
|
31
31
|
if (windowScroll > (elementOffset + offset)) {
|
32
|
-
if (value.done
|
32
|
+
if (value.done !== true) {
|
33
33
|
var callbackFunc = new Function(callback);
|
34
34
|
callbackFunc();
|
35
35
|
value.done = true;
|
36
36
|
}
|
37
37
|
}
|
38
38
|
}
|
39
|
-
}
|
39
|
+
}
|
40
40
|
}
|
41
41
|
}, 100);
|
42
|
-
|
43
|
-
|
44
|
-
// $(window).scroll(function () {
|
45
|
-
// var windowScroll = $(window).scrollTop() + $(window).height();
|
46
|
-
|
47
|
-
// $.each( options, function( i, value ){
|
48
|
-
// var selector = value.selector,
|
49
|
-
// offset = value.offset,
|
50
|
-
// callback = value.callback;
|
51
|
-
|
52
|
-
// if ($(selector).length != 0) {
|
53
|
-
// var elementOffset = $(selector).offset().top;
|
54
|
-
|
55
|
-
// if (windowScroll > (elementOffset + offset)) {
|
56
|
-
// if (value.done != true) {
|
57
|
-
// var callbackFunc = new Function(callback);
|
58
|
-
// callbackFunc();
|
59
|
-
// value.done = true;
|
60
|
-
// }
|
61
|
-
// }
|
62
|
-
// }
|
63
|
-
|
64
|
-
// });
|
65
|
-
// });
|
66
|
-
|
67
|
-
}
|
42
|
+
};
|
68
43
|
|
69
44
|
})(jQuery);
|
@@ -1,45 +1,4 @@
|
|
1
1
|
(function ($) {
|
2
|
-
// left: 37, up: 38, right: 39, down: 40,
|
3
|
-
// spacebar: 32, pageup: 33, pagedown: 34, end: 35, home: 36
|
4
|
-
// var keys = [32, 33, 34, 35, 36, 37, 38, 39, 40];
|
5
|
-
|
6
|
-
// function preventDefault(e) {
|
7
|
-
// e = e || window.event;
|
8
|
-
// if (e.preventDefault)
|
9
|
-
// e.preventDefault();
|
10
|
-
// e.returnValue = false;
|
11
|
-
// }
|
12
|
-
|
13
|
-
// function keydown(e) {
|
14
|
-
// for (var i = keys.length; i--;) {
|
15
|
-
// if (e.keyCode === keys[i]) {
|
16
|
-
// preventDefault(e);
|
17
|
-
// return;
|
18
|
-
// }
|
19
|
-
// }
|
20
|
-
// }
|
21
|
-
|
22
|
-
// function wheel(e) {
|
23
|
-
// preventDefault(e);
|
24
|
-
// }
|
25
|
-
|
26
|
-
// function disable_scroll() {
|
27
|
-
// if (window.addEventListener) {
|
28
|
-
// window.addEventListener('DOMMouseScroll', wheel, false);
|
29
|
-
// }
|
30
|
-
// window.onmousewheel = document.onmousewheel = wheel;
|
31
|
-
// document.onkeydown = keydown;
|
32
|
-
// $('body').css({'overflow-y' : 'hidden'});
|
33
|
-
// }
|
34
|
-
|
35
|
-
// function enable_scroll() {
|
36
|
-
// if (window.removeEventListener) {
|
37
|
-
// window.removeEventListener('DOMMouseScroll', wheel, false);
|
38
|
-
// }
|
39
|
-
// window.onmousewheel = document.onmousewheel = document.onkeydown = null;
|
40
|
-
// $('body').css({'overflow-y' : ''});
|
41
|
-
|
42
|
-
// }
|
43
2
|
|
44
3
|
var methods = {
|
45
4
|
init : function(options) {
|
@@ -47,7 +6,7 @@
|
|
47
6
|
menuWidth: 240,
|
48
7
|
edge: 'left',
|
49
8
|
closeOnClick: false
|
50
|
-
}
|
9
|
+
};
|
51
10
|
options = $.extend(defaults, options);
|
52
11
|
|
53
12
|
$(this).each(function(){
|
@@ -75,7 +34,7 @@
|
|
75
34
|
|
76
35
|
// If fixed sidenav, bring menu out
|
77
36
|
if (menu_id.hasClass('fixed')) {
|
78
|
-
if (
|
37
|
+
if (window.innerWidth > 992) {
|
79
38
|
menu_id.css('left', 0);
|
80
39
|
}
|
81
40
|
}
|
@@ -85,7 +44,7 @@
|
|
85
44
|
$(window).resize( function() {
|
86
45
|
if (window.innerWidth > 992) {
|
87
46
|
// Close menu if window is resized bigger than 992 and user has fixed sidenav
|
88
|
-
if ($('#sidenav-overlay').css('opacity')
|
47
|
+
if ($('#sidenav-overlay').css('opacity') !== 0 && menuOut) {
|
89
48
|
removeMenu(true);
|
90
49
|
}
|
91
50
|
else {
|
@@ -104,7 +63,7 @@
|
|
104
63
|
}
|
105
64
|
|
106
65
|
// if closeOnClick, then add close event for all a tags in side sideNav
|
107
|
-
if (options.closeOnClick
|
66
|
+
if (options.closeOnClick === true) {
|
108
67
|
menu_id.on("click.itemclick", "a:not(.collapsible-header)", function(){
|
109
68
|
removeMenu();
|
110
69
|
});
|
@@ -113,6 +72,10 @@
|
|
113
72
|
function removeMenu(restoreNav) {
|
114
73
|
panning = false;
|
115
74
|
menuOut = false;
|
75
|
+
|
76
|
+
// Reenable scrolling
|
77
|
+
$('body').css('overflow', '');
|
78
|
+
|
116
79
|
$('#sidenav-overlay').velocity({opacity: 0}, {duration: 200, queue: false, easing: 'easeOutQuad',
|
117
80
|
complete: function() {
|
118
81
|
$(this).remove();
|
@@ -126,7 +89,7 @@
|
|
126
89
|
queue: false,
|
127
90
|
easing: 'easeOutCubic',
|
128
91
|
complete: function() {
|
129
|
-
if (restoreNav
|
92
|
+
if (restoreNav === true) {
|
130
93
|
// Restore Fixed sidenav
|
131
94
|
menu_id.removeAttr('style');
|
132
95
|
menu_id.css('width', options.menuWidth);
|
@@ -144,7 +107,7 @@
|
|
144
107
|
queue: false,
|
145
108
|
easing: 'easeOutCubic',
|
146
109
|
complete: function() {
|
147
|
-
if (restoreNav
|
110
|
+
if (restoreNav === true) {
|
148
111
|
// Restore Fixed sidenav
|
149
112
|
menu_id.removeAttr('style');
|
150
113
|
menu_id.css('width', options.menuWidth);
|
@@ -162,7 +125,7 @@
|
|
162
125
|
|
163
126
|
$('.drag-target').on('click', function(){
|
164
127
|
removeMenu();
|
165
|
-
})
|
128
|
+
});
|
166
129
|
|
167
130
|
$('.drag-target').hammer({
|
168
131
|
prevent_default: false
|
@@ -175,6 +138,9 @@
|
|
175
138
|
var y = e.gesture.center.y;
|
176
139
|
var velocityX = e.gesture.velocityX;
|
177
140
|
|
141
|
+
// Disable Scrolling
|
142
|
+
$('body').css('overflow', 'hidden');
|
143
|
+
|
178
144
|
// If overlay does not exist, create one and if it is clicked, close menu
|
179
145
|
if ($('#sidenav-overlay').length === 0) {
|
180
146
|
var overlay = $('<div id="sidenav-overlay"></div>');
|
@@ -200,11 +166,11 @@
|
|
200
166
|
}
|
201
167
|
else {
|
202
168
|
// Left Direction
|
203
|
-
if (x < (
|
169
|
+
if (x < (window.innerWidth - options.menuWidth / 2)) {
|
204
170
|
menuOut = true;
|
205
171
|
}
|
206
172
|
// Right Direction
|
207
|
-
else if (x >= (
|
173
|
+
else if (x >= (window.innerWidth - options.menuWidth / 2)) {
|
208
174
|
menuOut = false;
|
209
175
|
}
|
210
176
|
var rightPos = -1 *(x - options.menuWidth / 2);
|
@@ -219,17 +185,19 @@
|
|
219
185
|
|
220
186
|
|
221
187
|
// Percentage overlay
|
188
|
+
var overlayPerc;
|
222
189
|
if (options.edge === 'left') {
|
223
|
-
|
190
|
+
overlayPerc = x / options.menuWidth;
|
224
191
|
$('#sidenav-overlay').velocity({opacity: overlayPerc }, {duration: 50, queue: false, easing: 'easeOutQuad'});
|
225
192
|
}
|
226
193
|
else {
|
227
|
-
|
194
|
+
overlayPerc = Math.abs((x - window.innerWidth) / options.menuWidth);
|
228
195
|
$('#sidenav-overlay').velocity({opacity: overlayPerc }, {duration: 50, queue: false, easing: 'easeOutQuad'});
|
229
196
|
}
|
230
197
|
}
|
231
198
|
|
232
199
|
}).bind('panend', function(e) {
|
200
|
+
|
233
201
|
if (e.gesture.pointerType == "touch") {
|
234
202
|
var velocityX = e.gesture.velocityX;
|
235
203
|
panning = false;
|
@@ -241,6 +209,9 @@
|
|
241
209
|
$('.drag-target').css({width: '50%', right: 0, left: ''});
|
242
210
|
}
|
243
211
|
else if (!menuOut || velocityX > 0.3) {
|
212
|
+
// Enable Scrolling
|
213
|
+
$('body').css('overflow', '');
|
214
|
+
// Slide menu closed
|
244
215
|
menu_id.velocity({left: -1 * (options.menuWidth + 10)}, {duration: 200, queue: false, easing: 'easeOutQuad'});
|
245
216
|
$('#sidenav-overlay').velocity({opacity: 0 }, {duration: 200, queue: false, easing: 'easeOutQuad',
|
246
217
|
complete: function () {
|
@@ -256,6 +227,9 @@
|
|
256
227
|
$('.drag-target').css({width: '50%', right: '', left: 0});
|
257
228
|
}
|
258
229
|
else if (!menuOut || velocityX < -0.3) {
|
230
|
+
// Enable Scrolling
|
231
|
+
$('body').css('overflow', '');
|
232
|
+
// Slide menu closed
|
259
233
|
menu_id.velocity({right: -1 * (options.menuWidth + 10)}, {duration: 200, queue: false, easing: 'easeOutQuad'});
|
260
234
|
$('#sidenav-overlay').velocity({opacity: 0 }, {duration: 200, queue: false, easing: 'easeOutQuad',
|
261
235
|
complete: function () {
|
@@ -269,13 +243,16 @@
|
|
269
243
|
});
|
270
244
|
|
271
245
|
$this.click(function() {
|
272
|
-
if (menuOut
|
246
|
+
if (menuOut === true) {
|
273
247
|
menuOut = false;
|
274
248
|
panning = false;
|
275
249
|
removeMenu();
|
276
250
|
}
|
277
251
|
else {
|
278
252
|
|
253
|
+
// Disable Scrolling
|
254
|
+
$('body').css('overflow', 'hidden');
|
255
|
+
|
279
256
|
if (options.edge === 'left') {
|
280
257
|
$('.drag-target').css({width: '50%', right: 0, left: ''});
|
281
258
|
menu_id.velocity({left: 0}, {duration: 300, queue: false, easing: 'easeOutQuad'});
|
@@ -331,5 +308,5 @@
|
|
331
308
|
} else {
|
332
309
|
$.error( 'Method ' + methodOrOptions + ' does not exist on jQuery.tooltip' );
|
333
310
|
}
|
334
|
-
}; //
|
311
|
+
}; // Plugin end
|
335
312
|
}( jQuery ));
|
@@ -1,246 +1,274 @@
|
|
1
1
|
(function ($) {
|
2
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
|
-
|
3
|
+
var methods = {
|
4
|
+
|
5
|
+
init : function(options) {
|
6
|
+
var defaults = {
|
7
|
+
indicators: true,
|
8
|
+
height: 400,
|
9
|
+
transition: 500,
|
10
|
+
interval: 6000
|
11
|
+
};
|
12
|
+
options = $.extend(defaults, options);
|
13
|
+
console.log(options);
|
14
|
+
|
15
|
+
return this.each(function() {
|
16
|
+
|
17
|
+
// For each slider, we want to keep track of
|
18
|
+
// which slide is active and its associated content
|
19
|
+
var $this = $(this);
|
20
|
+
var $slider = $this.find('ul.slides').first();
|
21
|
+
var $slides = $slider.find('li');
|
22
|
+
var $active_index = $slider.find('.active').index();
|
23
|
+
var $active;
|
24
|
+
if ($active_index != -1) { $active = $slides.eq($active_index); }
|
25
|
+
|
26
|
+
// Transitions the caption depending on alignment
|
27
|
+
function captionTransition(caption, duration) {
|
28
|
+
if (caption.hasClass("center-align")) {
|
29
|
+
caption.velocity({opacity: 0, translateY: -100}, {duration: duration, queue: false});
|
30
|
+
}
|
31
|
+
else if (caption.hasClass("right-align")) {
|
32
|
+
caption.velocity({opacity: 0, translateX: 100}, {duration: duration, queue: false});
|
33
|
+
}
|
34
|
+
else if (caption.hasClass("left-align")) {
|
35
|
+
caption.velocity({opacity: 0, translateX: -100}, {duration: duration, queue: false});
|
36
|
+
}
|
33
37
|
}
|
34
|
-
}
|
35
38
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
39
|
+
// This function will transition the slide to any index of the next slide
|
40
|
+
function moveToSlide(index) {
|
41
|
+
if (index >= $slides.length) index = 0;
|
42
|
+
else if (index < 0) index = $slides.length -1;
|
40
43
|
|
41
|
-
|
44
|
+
$active_index = $slider.find('.active').index();
|
42
45
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
46
|
+
// Only do if index changes
|
47
|
+
if ($active_index != index) {
|
48
|
+
$active = $slides.eq($active_index);
|
49
|
+
$caption = $active.find('.caption');
|
47
50
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
51
|
+
$active.removeClass('active');
|
52
|
+
$active.velocity({opacity: 0}, {duration: options.transition, queue: false, easing: 'easeOutQuad',
|
53
|
+
complete: function() {
|
54
|
+
$slides.not('.active').velocity({opacity: 0, translateX: 0, translateY: 0}, {duration: 0, queue: false});
|
55
|
+
} });
|
56
|
+
captionTransition($caption, options.transition);
|
54
57
|
|
55
58
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
59
|
+
// Update indicators
|
60
|
+
if (options.indicators) {
|
61
|
+
$indicators.eq($active_index).removeClass('active');
|
62
|
+
}
|
60
63
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
+
$slides.eq(index).velocity({opacity: 1}, {duration: options.transition, queue: false, easing: 'easeOutQuad'});
|
65
|
+
$slides.eq(index).find('.caption').velocity({opacity: 1, translateX: 0, translateY: 0}, {duration: options.transition, delay: options.transition, queue: false, easing: 'easeOutQuad'});
|
66
|
+
$slides.eq(index).addClass('active');
|
64
67
|
|
65
68
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
+
// Update indicators
|
70
|
+
if (options.indicators) {
|
71
|
+
$indicators.eq(index).addClass('active');
|
72
|
+
}
|
69
73
|
}
|
70
74
|
}
|
71
|
-
}
|
72
75
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
+
console.log(options.height);
|
77
|
+
// Set height of slider
|
78
|
+
if (options.indicators) {
|
79
|
+
// Add height if indicators are present
|
80
|
+
$this.height(options.height + 40);
|
81
|
+
}
|
82
|
+
else {
|
83
|
+
$this.height(options.height);
|
84
|
+
}
|
76
85
|
$slider.height(options.height);
|
77
|
-
}
|
78
|
-
|
79
|
-
// Set initial positions of captions
|
80
|
-
$slides.find('.caption').each(function () {
|
81
|
-
captionTransition($(this), 0);
|
82
|
-
});
|
83
86
|
|
84
|
-
// Set initial dimensions of images
|
85
|
-
// $slides.find('img').each(function () {
|
86
|
-
// $(this).load(function () {
|
87
|
-
// if ($(this).width() < $(this).parent().width()) {
|
88
|
-
// $(this).css({width: '100%', height: 'auto'});
|
89
|
-
// }
|
90
|
-
// });
|
91
|
-
// });
|
92
|
-
|
93
|
-
// Move img src into background-image
|
94
|
-
$slides.find('img').each(function () {
|
95
|
-
$(this).css('background-image', 'url(' + $(this).attr('src') + ')' );
|
96
|
-
$(this).attr('src', 'data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==');
|
97
|
-
});
|
98
|
-
|
99
|
-
// dynamically add indicators
|
100
|
-
if (options.indicators) {
|
101
|
-
var $indicators = $('<ul class="indicators"></ul>');
|
102
|
-
$slides.each(function( index ) {
|
103
|
-
var $indicator = $('<li class="indicator-item"></li>');
|
104
|
-
|
105
|
-
// Handle clicks on indicators
|
106
|
-
$indicator.click(function () {
|
107
|
-
var $parent = $slider.parent();
|
108
|
-
var curr_index = $parent.find($(this)).index();
|
109
|
-
moveToSlide(curr_index);
|
110
87
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
$active_index = $slider.find('.active').index();
|
116
|
-
if ($slides.length == $active_index + 1) $active_index = 0; // loop to start
|
117
|
-
else $active_index += 1;
|
88
|
+
// Set initial positions of captions
|
89
|
+
$slides.find('.caption').each(function () {
|
90
|
+
captionTransition($(this), 0);
|
91
|
+
});
|
118
92
|
|
119
|
-
|
93
|
+
// Set initial dimensions of images
|
94
|
+
// $slides.find('img').each(function () {
|
95
|
+
// $(this).load(function () {
|
96
|
+
// if ($(this).width() < $(this).parent().width()) {
|
97
|
+
// $(this).css({width: '100%', height: 'auto'});
|
98
|
+
// }
|
99
|
+
// });
|
100
|
+
// });
|
101
|
+
|
102
|
+
// Move img src into background-image
|
103
|
+
$slides.find('img').each(function () {
|
104
|
+
$(this).css('background-image', 'url(' + $(this).attr('src') + ')' );
|
105
|
+
$(this).attr('src', 'data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==');
|
106
|
+
});
|
120
107
|
|
121
|
-
|
122
|
-
|
108
|
+
// dynamically add indicators
|
109
|
+
if (options.indicators) {
|
110
|
+
var $indicators = $('<ul class="indicators"></ul>');
|
111
|
+
$slides.each(function( index ) {
|
112
|
+
var $indicator = $('<li class="indicator-item"></li>');
|
113
|
+
|
114
|
+
// Handle clicks on indicators
|
115
|
+
$indicator.click(function () {
|
116
|
+
var $parent = $slider.parent();
|
117
|
+
var curr_index = $parent.find($(this)).index();
|
118
|
+
moveToSlide(curr_index);
|
119
|
+
|
120
|
+
// reset interval
|
121
|
+
clearInterval($interval);
|
122
|
+
$interval = setInterval(
|
123
|
+
function(){
|
124
|
+
$active_index = $slider.find('.active').index();
|
125
|
+
if ($slides.length == $active_index + 1) $active_index = 0; // loop to start
|
126
|
+
else $active_index += 1;
|
127
|
+
|
128
|
+
moveToSlide($active_index);
|
129
|
+
|
130
|
+
}, options.transition + options.interval
|
131
|
+
);
|
132
|
+
});
|
133
|
+
$indicators.append($indicator);
|
123
134
|
});
|
124
|
-
$
|
125
|
-
|
126
|
-
|
127
|
-
$indicators = $this.find('ul.indicators').find('li.indicator-item');
|
128
|
-
}
|
135
|
+
$this.append($indicators);
|
136
|
+
$indicators = $this.find('ul.indicators').find('li.indicator-item');
|
137
|
+
}
|
129
138
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
139
|
+
if ($active) {
|
140
|
+
$active.show();
|
141
|
+
}
|
142
|
+
else {
|
143
|
+
$slides.first().addClass('active').velocity({opacity: 1}, {duration: options.transition, queue: false, easing: 'easeOutQuad'});
|
135
144
|
|
136
|
-
|
137
|
-
|
145
|
+
$active_index = 0;
|
146
|
+
$active = $slides.eq($active_index);
|
138
147
|
|
139
|
-
|
140
|
-
|
141
|
-
|
148
|
+
// Update indicators
|
149
|
+
if (options.indicators) {
|
150
|
+
$indicators.eq($active_index).addClass('active');
|
151
|
+
}
|
142
152
|
}
|
143
|
-
}
|
144
153
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
154
|
+
// Adjust height to current slide
|
155
|
+
$active.find('img').each(function() {
|
156
|
+
$active.find('.caption').velocity({opacity: 1, translateX: 0, translateY: 0}, {duration: options.transition, queue: false, easing: 'easeOutQuad'});
|
157
|
+
});
|
149
158
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
159
|
+
// auto scroll
|
160
|
+
$interval = setInterval(
|
161
|
+
function(){
|
162
|
+
$active_index = $slider.find('.active').index();
|
163
|
+
moveToSlide($active_index + 1);
|
155
164
|
|
156
|
-
|
157
|
-
|
165
|
+
}, options.transition + options.interval
|
166
|
+
);
|
158
167
|
|
159
168
|
|
160
|
-
|
169
|
+
// HammerJS, Swipe navigation
|
161
170
|
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
171
|
+
// Touch Event
|
172
|
+
var panning = false;
|
173
|
+
var swipeLeft = false;
|
174
|
+
var swipeRight = false;
|
166
175
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
176
|
+
$this.hammer({
|
177
|
+
prevent_default: false
|
178
|
+
}).bind('pan', function(e) {
|
179
|
+
if (e.gesture.pointerType === "touch") {
|
171
180
|
|
172
|
-
|
173
|
-
|
181
|
+
// reset interval
|
182
|
+
clearInterval($interval);
|
174
183
|
|
175
|
-
|
176
|
-
|
177
|
-
|
184
|
+
var direction = e.gesture.direction;
|
185
|
+
var x = e.gesture.deltaX;
|
186
|
+
var velocityX = e.gesture.velocityX;
|
178
187
|
|
179
|
-
|
180
|
-
|
181
|
-
|
188
|
+
$curr_slide = $slider.find('.active');
|
189
|
+
$curr_slide.velocity({ translateX: x
|
190
|
+
}, {duration: 50, queue: false, easing: 'easeOutQuad'});
|
182
191
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
192
|
+
// Swipe Left
|
193
|
+
if (direction === 4 && (x > ($this.innerWidth() / 2) || velocityX < -0.65)) {
|
194
|
+
swipeRight = true;
|
195
|
+
}
|
196
|
+
// Swipe Right
|
197
|
+
else if (direction === 2 && (x < (-1 * $this.innerWidth() / 2) || velocityX > 0.65)) {
|
198
|
+
swipeLeft = true;
|
199
|
+
}
|
191
200
|
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
201
|
+
// Make Slide Behind active slide visible
|
202
|
+
var next_slide;
|
203
|
+
if (swipeLeft) {
|
204
|
+
next_slide = $curr_slide.next();
|
205
|
+
if (next_slide.length === 0) {
|
206
|
+
next_slide = $slides.first();
|
207
|
+
}
|
208
|
+
next_slide.velocity({ opacity: 1
|
209
|
+
}, {duration: 300, queue: false, easing: 'easeOutQuad'});
|
198
210
|
}
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
211
|
+
if (swipeRight) {
|
212
|
+
next_slide = $curr_slide.prev();
|
213
|
+
if (next_slide.length === 0) {
|
214
|
+
next_slide = $slides.last();
|
215
|
+
}
|
216
|
+
next_slide.velocity({ opacity: 1
|
217
|
+
}, {duration: 300, queue: false, easing: 'easeOutQuad'});
|
206
218
|
}
|
207
|
-
|
208
|
-
|
219
|
+
|
220
|
+
|
209
221
|
}
|
210
222
|
|
223
|
+
}).bind('panend', function(e) {
|
224
|
+
if (e.gesture.pointerType === "touch") {
|
211
225
|
|
212
|
-
|
226
|
+
$curr_slide = $slider.find('.active');
|
227
|
+
panning = false;
|
228
|
+
curr_index = $slider.find('.active').index();
|
213
229
|
|
214
|
-
|
215
|
-
|
230
|
+
if (!swipeRight && !swipeLeft) {
|
231
|
+
// Return to original spot
|
232
|
+
$curr_slide.velocity({ translateX: 0
|
233
|
+
}, {duration: 300, queue: false, easing: 'easeOutQuad'});
|
234
|
+
}
|
235
|
+
else if (swipeLeft) {
|
236
|
+
moveToSlide(curr_index + 1);
|
237
|
+
$curr_slide.velocity({translateX: -1 * $this.innerWidth() }, {duration: 300, queue: false, easing: 'easeOutQuad',
|
238
|
+
complete: function() {
|
239
|
+
$curr_slide.velocity({opacity: 0, translateX: 0}, {duration: 0, queue: false});
|
240
|
+
} });
|
241
|
+
}
|
242
|
+
else if (swipeRight) {
|
243
|
+
moveToSlide(curr_index - 1);
|
244
|
+
$curr_slide.velocity({translateX: $this.innerWidth() }, {duration: 300, queue: false, easing: 'easeOutQuad',
|
245
|
+
complete: function() {
|
246
|
+
$curr_slide.velocity({opacity: 0, translateX: 0}, {duration: 0, queue: false});
|
247
|
+
} });
|
248
|
+
}
|
249
|
+
swipeLeft = false;
|
250
|
+
swipeRight = false;
|
216
251
|
|
217
|
-
|
218
|
-
|
219
|
-
|
252
|
+
// Restart interval
|
253
|
+
clearInterval($interval);
|
254
|
+
$interval = setInterval(
|
255
|
+
function(){
|
256
|
+
$active_index = $slider.find('.active').index();
|
257
|
+
if ($slides.length == $active_index + 1) $active_index = 0; // loop to start
|
258
|
+
else $active_index += 1;
|
220
259
|
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
}
|
226
|
-
else if (swipeLeft) {
|
227
|
-
moveToSlide(curr_index + 1);
|
228
|
-
$curr_slide.velocity({translateX: -1 * $this.innerWidth() }, {duration: 300, queue: false, easing: 'easeOutQuad',
|
229
|
-
complete: function() {
|
230
|
-
$curr_slide.velocity({opacity: 0, translateX: 0}, {duration: 0, queue: false});
|
231
|
-
} });
|
232
|
-
}
|
233
|
-
else if (swipeRight) {
|
234
|
-
moveToSlide(curr_index - 1);
|
235
|
-
$curr_slide.velocity({translateX: $this.innerWidth() }, {duration: 300, queue: false, easing: 'easeOutQuad',
|
236
|
-
complete: function() {
|
237
|
-
$curr_slide.velocity({opacity: 0, translateX: 0}, {duration: 0, queue: false});
|
238
|
-
} });
|
260
|
+
moveToSlide($active_index);
|
261
|
+
|
262
|
+
}, options.transition + options.interval
|
263
|
+
);
|
239
264
|
}
|
240
|
-
|
241
|
-
swipeRight = false;
|
265
|
+
});
|
242
266
|
|
243
|
-
|
267
|
+
$this.on('sliderPause', function() {
|
268
|
+
clearInterval($interval);
|
269
|
+
});
|
270
|
+
|
271
|
+
$this.on('sliderStart', function() {
|
244
272
|
clearInterval($interval);
|
245
273
|
$interval = setInterval(
|
246
274
|
function(){
|
@@ -252,12 +280,30 @@
|
|
252
280
|
|
253
281
|
}, options.transition + options.interval
|
254
282
|
);
|
255
|
-
}
|
256
|
-
});
|
283
|
+
});
|
257
284
|
|
258
|
-
|
285
|
+
});
|
259
286
|
|
260
287
|
|
261
288
|
|
289
|
+
},
|
290
|
+
pause : function() {
|
291
|
+
$(this).trigger('sliderPause');
|
292
|
+
},
|
293
|
+
start : function() {
|
294
|
+
$(this).trigger('sliderStart');
|
295
|
+
}
|
262
296
|
};
|
263
|
-
|
297
|
+
|
298
|
+
|
299
|
+
$.fn.slider = function(methodOrOptions) {
|
300
|
+
if ( methods[methodOrOptions] ) {
|
301
|
+
return methods[ methodOrOptions ].apply( this, Array.prototype.slice.call( arguments, 1 ));
|
302
|
+
} else if ( typeof methodOrOptions === 'object' || ! methodOrOptions ) {
|
303
|
+
// Default to "init"
|
304
|
+
return methods.init.apply( this, arguments );
|
305
|
+
} else {
|
306
|
+
$.error( 'Method ' + methodOrOptions + ' does not exist on jQuery.tooltip' );
|
307
|
+
}
|
308
|
+
}; // Plugin end
|
309
|
+
}( jQuery ));
|