maxmertkit-rails 0.0.1
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.
- data/.gitignore +17 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +65 -0
- data/Rakefile +1 -0
- data/lib/maxmertkit-rails/engine.rb +9 -0
- data/lib/maxmertkit-rails/version.rb +5 -0
- data/lib/maxmertkit-rails.rb +8 -0
- data/maxmertkit-rails.gemspec +19 -0
- data/vendor/assets/fonts/fontawesome/fontawesome-webfont.eot +0 -0
- data/vendor/assets/fonts/fontawesome/fontawesome-webfont.svg +255 -0
- data/vendor/assets/fonts/fontawesome/fontawesome-webfont.ttf +0 -0
- data/vendor/assets/fonts/fontawesome/fontawesome-webfont.woff +0 -0
- data/vendor/assets/fonts/zocial/zocial-regular-webfont.eot +0 -0
- data/vendor/assets/fonts/zocial/zocial-regular-webfont.svg +151 -0
- data/vendor/assets/fonts/zocial/zocial-regular-webfont.ttf +0 -0
- data/vendor/assets/fonts/zocial/zocial-regular-webfont.woff +0 -0
- data/vendor/assets/javascript/libs/easing.js +205 -0
- data/vendor/assets/javascript/libs/html5shiv.js +298 -0
- data/vendor/assets/javascript/libs/imagesLoaded.js +3 -0
- data/vendor/assets/javascript/libs/modernizr.js +4 -0
- data/vendor/assets/javascript/maxmertkit.affix.js +85 -0
- data/vendor/assets/javascript/maxmertkit.button.js +182 -0
- data/vendor/assets/javascript/maxmertkit.carousel.js +688 -0
- data/vendor/assets/javascript/maxmertkit.js +112 -0
- data/vendor/assets/javascript/maxmertkit.modal.js +301 -0
- data/vendor/assets/javascript/maxmertkit.notify.js +186 -0
- data/vendor/assets/javascript/maxmertkit.popup.js +396 -0
- data/vendor/assets/javascript/maxmertkit.scrollspy.js +107 -0
- data/vendor/assets/javascript/maxmertkit.tabs.js +228 -0
- data/vendor/assets/stylesheet/_init.scss +240 -0
- data/vendor/assets/stylesheet/_mixins.scss +218 -0
- data/vendor/assets/stylesheet/animations/_keyframes.scss +2914 -0
- data/vendor/assets/stylesheet/classes/_object.scss +14 -0
- data/vendor/assets/stylesheet/maxmertkit-animation.scss +146 -0
- data/vendor/assets/stylesheet/maxmertkit-components.scss +25 -0
- data/vendor/assets/stylesheet/maxmertkit.scss +14 -0
- data/vendor/assets/stylesheet/modificators/__methods.scss +116 -0
- data/vendor/assets/stylesheet/modificators/_size.scss +208 -0
- data/vendor/assets/stylesheet/modificators/_status.scss +195 -0
- data/vendor/assets/stylesheet/themes/_basic.scss +330 -0
- data/vendor/assets/stylesheet/widgets/_arrow.scss +74 -0
- data/vendor/assets/stylesheet/widgets/_badge.scss +15 -0
- data/vendor/assets/stylesheet/widgets/_button.scss +131 -0
- data/vendor/assets/stylesheet/widgets/_caret.scss +34 -0
- data/vendor/assets/stylesheet/widgets/_carousel.scss +146 -0
- data/vendor/assets/stylesheet/widgets/_dropdown.scss +116 -0
- data/vendor/assets/stylesheet/widgets/_form.scss +327 -0
- data/vendor/assets/stylesheet/widgets/_group.scss +245 -0
- data/vendor/assets/stylesheet/widgets/_icon.scss +92 -0
- data/vendor/assets/stylesheet/widgets/_label.scss +4 -0
- data/vendor/assets/stylesheet/widgets/_menu.scss +283 -0
- data/vendor/assets/stylesheet/widgets/_modal.scss +172 -0
- data/vendor/assets/stylesheet/widgets/_notify.scss +190 -0
- data/vendor/assets/stylesheet/widgets/_progressbar.scss +70 -0
- data/vendor/assets/stylesheet/widgets/_table.scss +270 -0
- data/vendor/assets/stylesheet/widgets/_tabs.scss +211 -0
- data/vendor/assets/stylesheet/widgets/_toolbar.scss +118 -0
- data/vendor/assets/stylesheet/widgets/_tooltip.scss +19 -0
- metadata +104 -0
@@ -0,0 +1,688 @@
|
|
1
|
+
;(function ( $, window, document, undefined ) {
|
2
|
+
var _name = 'carousel'
|
3
|
+
, _defaults = {
|
4
|
+
enabled: true
|
5
|
+
, theme: 'info'
|
6
|
+
, itemSelector: '.js-carousel-item'
|
7
|
+
, itemAnimation: 'css' // if true – jquery animation, if string – name of jquery or css animation
|
8
|
+
, controlSelector: '.js-carousel-control'
|
9
|
+
, navigationSelector: '#js-carousel-nav'
|
10
|
+
, hideControlsDistance: 200 // if 0 – always show controls
|
11
|
+
|
12
|
+
, autoSlide: 15000 // im ms, if 0 – no autoscroll
|
13
|
+
|
14
|
+
, imageFill: true // Fill image by width and height of carousel
|
15
|
+
, imageFillAnimationInterval: 20000 // im ms, if 0 – no img scroll
|
16
|
+
, imageFillAnimation: true // if true – animate by jquery, else – name jquery animation. NO CSS animation (to stop animation in any time)
|
17
|
+
, imageFillMouseMove: false
|
18
|
+
, imageFillMouseMoveDelay: 5000
|
19
|
+
|
20
|
+
, captionAnimation: 'blurIn' // if true – animate by jquery, else – name of css animation
|
21
|
+
, captionAnimationDelay: 1000 // in ms, interval between several captions show animation
|
22
|
+
}
|
23
|
+
|
24
|
+
Carousel = function(element, options) {
|
25
|
+
var me = this;
|
26
|
+
|
27
|
+
this.name = _name;
|
28
|
+
this.element = element;
|
29
|
+
this.options = $.extend({}, _defaults, options);
|
30
|
+
this.active = 0;
|
31
|
+
|
32
|
+
this._setOptions( this.options );
|
33
|
+
|
34
|
+
this.init();
|
35
|
+
}
|
36
|
+
|
37
|
+
Carousel.prototype = new $.kit();
|
38
|
+
Carousel.prototype.constructor = Carousel;
|
39
|
+
|
40
|
+
Carousel.prototype.enable = function() {
|
41
|
+
var me = this;
|
42
|
+
|
43
|
+
me.__setOption( 'enabled', true )
|
44
|
+
}
|
45
|
+
|
46
|
+
Carousel.prototype.disable = function() {
|
47
|
+
var me = this;
|
48
|
+
|
49
|
+
me.__setOption( 'enabled', false )
|
50
|
+
}
|
51
|
+
|
52
|
+
Carousel.prototype.__setOption = function ( key_, value_ ) {
|
53
|
+
var me = this;
|
54
|
+
var $me = $(me.element);
|
55
|
+
|
56
|
+
switch( key_ ) {
|
57
|
+
|
58
|
+
case 'enabled':
|
59
|
+
if( ! value_ ) {
|
60
|
+
clearInterval( me.timer );
|
61
|
+
me.clearImageSlide();
|
62
|
+
}
|
63
|
+
break;
|
64
|
+
|
65
|
+
case 'controlSelector':
|
66
|
+
// Remove old controls events
|
67
|
+
me.controls && me.controls.length > 0 && $.each( me.controls, function( index_, control_ ) { control_.off( '.' + me.name ) });
|
68
|
+
|
69
|
+
// Find new controls
|
70
|
+
me.controls = $( value_ ).map( function( index_, control_ ) {
|
71
|
+
// Check if in 'href' is id of our carousel
|
72
|
+
if( $(control_).attr( 'href' ).replace(/#/g, '') === $me.attr( 'id' ) ) {
|
73
|
+
|
74
|
+
// Create new click event
|
75
|
+
$(control_).on( 'click.' + me.name, function( event_ ) {
|
76
|
+
|
77
|
+
// Use data-slide to find out where to slide. It should be 'prev' or 'next'
|
78
|
+
me.options.enabled && $(this).data( 'slide' ) && me[ $(this).data( 'slide' ) ]();
|
79
|
+
|
80
|
+
event_.preventDefault();
|
81
|
+
});
|
82
|
+
|
83
|
+
return $(control_);
|
84
|
+
}
|
85
|
+
});
|
86
|
+
|
87
|
+
break;
|
88
|
+
|
89
|
+
case 'navigationSelector':
|
90
|
+
me.nav && me.nav.length > 0 && $.each( me.nav, function( index_, nav_ ) { nav_.off( '.' + me.name ) });
|
91
|
+
me.nav = $( value_ ).map( function( index_, item_ ) {
|
92
|
+
for( var i = 0; i < me.items.length; i++ )
|
93
|
+
$(item_).append('<i></i>')
|
94
|
+
|
95
|
+
$(item_).addClass( '-' + me.options.theme + '-' );
|
96
|
+
|
97
|
+
$(item_).on( 'click.' + me.name, function( event_ ) {
|
98
|
+
if( me.options.enabled && $(event_.target).is('i') ) {
|
99
|
+
me.active = $(event_.target).index();
|
100
|
+
me.to();
|
101
|
+
}
|
102
|
+
});
|
103
|
+
|
104
|
+
return $(item_);
|
105
|
+
});
|
106
|
+
break;
|
107
|
+
|
108
|
+
case 'itemSelector':
|
109
|
+
// Get an array of items
|
110
|
+
me.items = $me.find( value_ ).map( function( index_, item_ ) { return $(item_) });
|
111
|
+
break;
|
112
|
+
|
113
|
+
case 'hideControlsDistance':
|
114
|
+
value_ && value_ > 0 && $me.off( 'mousemove.' + me.name ) && $me.on( 'mousemove.' + me.name, function( event_ ) { $.proxy( me.trackMouseControls( event_ ), me ) });
|
115
|
+
break;
|
116
|
+
|
117
|
+
case 'autoSlide':
|
118
|
+
clearInterval( me.timer );
|
119
|
+
if( value_ > 0) me.timer = setInterval( $.proxy(me.next, me), value_ );
|
120
|
+
break;
|
121
|
+
|
122
|
+
case 'imageFill':
|
123
|
+
if( value_ ) {
|
124
|
+
$me.addClass('-carousel-imageFill');
|
125
|
+
$me.imagesLoaded( function() {
|
126
|
+
var carouselHeight = $me.innerHeight()
|
127
|
+
, carouselWidth = $me.innerWidth();
|
128
|
+
|
129
|
+
$.each(me.items, function( index_, item_ ) {
|
130
|
+
var image_ = item_.find(' > img ')
|
131
|
+
, imageWidth = $(image_).width()
|
132
|
+
, imageHeight = $(image_).height()
|
133
|
+
, aspectRatio = imageWidth / imageHeight;
|
134
|
+
|
135
|
+
item_.css({ height: '100%' });
|
136
|
+
|
137
|
+
$(image_).css({ position: 'absolute', top: 0, left: 0, maxHeight: 'none', maxWidth: 'none' });
|
138
|
+
|
139
|
+
carouselWidth / carouselHeight < aspectRatio ?
|
140
|
+
$(image_).css({ width: 'auto', height: '100%' }) :
|
141
|
+
$(image_).css({ width: '100%', height: 'auto' }) ;
|
142
|
+
});
|
143
|
+
});
|
144
|
+
}
|
145
|
+
break;
|
146
|
+
|
147
|
+
case 'imageFillAnimation':
|
148
|
+
if( value_ ) $me.on( 'slide.' + me.name, $.proxy( me.imageSlide, me ) );
|
149
|
+
break;
|
150
|
+
|
151
|
+
case 'imageFillMouseMove':
|
152
|
+
$me.off( 'mouseenter.mousecontrol.' + me.name );
|
153
|
+
$me.off( 'mouseleave.mousecontrol.' + me.name );
|
154
|
+
if( value_ ) $me.on( 'mousemove.mousecontrol.' + me.name, $.proxy( me.imageSlideByMouse, me ) );
|
155
|
+
if( value_ ) $me.on( 'mouseleave.mousecontrol.' + me.name, $.proxy( me.imageSlide, me ) );
|
156
|
+
break;
|
157
|
+
|
158
|
+
case 'captionAnimation':
|
159
|
+
$me.on( 'slide.' + me.name, function() {
|
160
|
+
me.items[ me.active ].find('.-carousel-caption').each( function( index_, caption_ ) {
|
161
|
+
$(caption_).find('div').each( function( index__, captionPart_ ) {
|
162
|
+
if( typeof value_ === 'boolean' )
|
163
|
+
$(captionPart_).fadeIn();
|
164
|
+
|
165
|
+
if( typeof value_ === 'string' ) {
|
166
|
+
$(captionPart_).addClass('-mx-' + value_);
|
167
|
+
setTimeout(function(){
|
168
|
+
$(captionPart_).addClass('-mx-start');
|
169
|
+
}, me.options.captionAnimationDelay * (index__ + 1))
|
170
|
+
}
|
171
|
+
});
|
172
|
+
});
|
173
|
+
});
|
174
|
+
break;
|
175
|
+
}
|
176
|
+
me.options[ key_ ] = value_;
|
177
|
+
}
|
178
|
+
|
179
|
+
Carousel.prototype.init = function() {
|
180
|
+
var me = this
|
181
|
+
, $me = $(me.element);
|
182
|
+
|
183
|
+
$me.show().animate( {opacity: 1 });
|
184
|
+
me.imageSlide();
|
185
|
+
|
186
|
+
// Set autoscroll. Always check mouseenter and mouseleave, because autoSlide can change any time.
|
187
|
+
$me.on( 'mouseenter.' + me.name, function() {
|
188
|
+
if( me.options.autoSlide > 0 ) clearInterval( me.timer );
|
189
|
+
});
|
190
|
+
|
191
|
+
$me.on( 'mouseleave.' + me.name, function( event_ ) {
|
192
|
+
if( me.options.autoSlide > 0 ) me.timer = setInterval( $.proxy(me.next, me), me.options.autoSlide );
|
193
|
+
$me.find( me.options.controlSelector ).each( function( index_, control_ ) { $(control_).fadeOut(100) });
|
194
|
+
});
|
195
|
+
|
196
|
+
me.to();
|
197
|
+
}
|
198
|
+
|
199
|
+
// If we need to update items without change 'itemSelector' option
|
200
|
+
Carousel.prototype.update = function() {
|
201
|
+
var me = this;
|
202
|
+
me.__setOption( 'itemSelector', me.options.itemSelector );
|
203
|
+
}
|
204
|
+
|
205
|
+
Carousel.prototype.next = function() {
|
206
|
+
var me = this;
|
207
|
+
|
208
|
+
var clearSliders = me.clearImageSlide();
|
209
|
+
|
210
|
+
clearSliders.done(function() {
|
211
|
+
me.active !== undefined && me.active + 1 === me.items.length ?
|
212
|
+
me.active = 0 :
|
213
|
+
me.active++;
|
214
|
+
|
215
|
+
me.to();
|
216
|
+
});
|
217
|
+
}
|
218
|
+
|
219
|
+
Carousel.prototype.prev = function() {
|
220
|
+
var me = this;
|
221
|
+
|
222
|
+
var clearSliders = me.clearImageSlide();
|
223
|
+
|
224
|
+
clearSliders.done(function() {
|
225
|
+
me.active !== undefined && me.active - 1 < 0 ?
|
226
|
+
me.active = me.items.length - 1 :
|
227
|
+
me.active--;
|
228
|
+
|
229
|
+
me.to();
|
230
|
+
});
|
231
|
+
}
|
232
|
+
|
233
|
+
Carousel.prototype.to = function( number_ ) {
|
234
|
+
var me = this
|
235
|
+
, $me = $(me.element)
|
236
|
+
, carouselWidth = $me.innerWidth();
|
237
|
+
|
238
|
+
if(number_) me.active = number_;
|
239
|
+
|
240
|
+
var offsetMove = me.active * -carouselWidth;
|
241
|
+
|
242
|
+
typeof me.options.itemAnimation == 'boolean' ?
|
243
|
+
me.items[0].animate({ marginLeft: offsetMove }) :
|
244
|
+
$.easing && me.options.itemAnimation in $.easing ?
|
245
|
+
me.items[0].animate({ marginLeft: offsetMove }, { easing: me.options.itemAnimation }) :
|
246
|
+
me.items[0].css({ marginLeft: offsetMove });
|
247
|
+
|
248
|
+
me.nav && me.nav.length > 0 && $.each( me.nav, function( index_, nav_ ) {
|
249
|
+
$(nav_).find('._active_').removeClass( '_active_' );
|
250
|
+
$(nav_).find('i').eq(me.active).addClass(' _active_ ');
|
251
|
+
});
|
252
|
+
|
253
|
+
$me.trigger( 'slide.' + me.name );
|
254
|
+
}
|
255
|
+
|
256
|
+
Carousel.prototype.trackMouseControls = function( event_ ) {
|
257
|
+
var me = this
|
258
|
+
, $me = $(me.element)
|
259
|
+
, x = event_.pageX - $me.offset().left
|
260
|
+
, carouselWidth = $me.width();
|
261
|
+
|
262
|
+
// We should hide only controls inside slider!!! Not good to use find every time, but...
|
263
|
+
$me.find( me.options.controlSelector ).each( function( index_, control_ ) {
|
264
|
+
// Just in case check if in href if id of our carousel
|
265
|
+
if( me.options.enabled && $(control_).attr( 'href' ).replace(/#/g, '') === $me.attr( 'id' ) )
|
266
|
+
if( $( control_ ).data('slide') === 'prev' )
|
267
|
+
me.options.hideControlsDistance > x ?
|
268
|
+
$( control_ ).fadeIn(100) :
|
269
|
+
$( control_ ).fadeOut(100)
|
270
|
+
else
|
271
|
+
me.options.hideControlsDistance > carouselWidth - x ?
|
272
|
+
$( control_ ).fadeIn(100) :
|
273
|
+
$( control_ ).fadeOut(100);
|
274
|
+
});
|
275
|
+
|
276
|
+
}
|
277
|
+
|
278
|
+
Carousel.prototype.imageSlide = function() {
|
279
|
+
var me = this
|
280
|
+
, $me = $(me.element)
|
281
|
+
, carouselHeight = $me.innerHeight()
|
282
|
+
, carouselWidth = $me.innerWidth();
|
283
|
+
|
284
|
+
if( me.options.enabled && me.options.imageFillAnimation ) {
|
285
|
+
$me.imagesLoaded( function() {
|
286
|
+
var img = $( me.items[ me.active ].find( 'img' )[0] )
|
287
|
+
, imgWidth = img.width()
|
288
|
+
, imgHeight = img.height()
|
289
|
+
, heightDelta = carouselHeight - imgHeight
|
290
|
+
, widthDelta = carouselWidth - imgWidth;
|
291
|
+
|
292
|
+
typeof me.options.imageFillAnimation === 'boolean' ?
|
293
|
+
img.animate({ top: heightDelta, left: widthDelta }, me.options.imageFillAnimationInterval) :
|
294
|
+
$.easing && me.options.imageFillAnimation in $.easing &&
|
295
|
+
img.animate({ top: heightDelta, left: widthDelta }, { duration: me.options.imageFillAnimationInterval, easing: me.options.imageFillAnimation });
|
296
|
+
});
|
297
|
+
}
|
298
|
+
}
|
299
|
+
|
300
|
+
Carousel.prototype.clearImageSlide = function() {
|
301
|
+
var me = this
|
302
|
+
, $me = $(me.element)
|
303
|
+
, finished = new $.Deferred();
|
304
|
+
|
305
|
+
me.options.imageFillAnimation ?
|
306
|
+
me.items.each( function( index_, item_ ) {
|
307
|
+
index_ !== me.active && item_.find('img').stop().css({ top: 0, left: 0 });
|
308
|
+
|
309
|
+
me.options.captionAnimation && index_ !== me.active && item_.find('.-carousel-caption').each( function( index_, caption_ ) {
|
310
|
+
$(caption_).find('div').each( function( index__, captionPart_ ) {
|
311
|
+
if( typeof me.options.captionAnimation === 'boolean' )
|
312
|
+
$(captionPart_).hide();
|
313
|
+
if( typeof me.options.captionAnimation === 'string' ) {
|
314
|
+
// debugger;
|
315
|
+
$(captionPart_).removeClass('-mx-start ' + me.options.captionAnimation);
|
316
|
+
}
|
317
|
+
});
|
318
|
+
});
|
319
|
+
|
320
|
+
index_ === me.items.length - 1 && finished.resolve();
|
321
|
+
}) :
|
322
|
+
finished.resolve();
|
323
|
+
|
324
|
+
return finished.promise();
|
325
|
+
}
|
326
|
+
|
327
|
+
Carousel.prototype.imageSlideByMouse = function( event_ ) {
|
328
|
+
var me = this
|
329
|
+
, $me = $(me.element);
|
330
|
+
|
331
|
+
me.options.enabled && $me.imagesLoaded( function() {
|
332
|
+
var x = event_.pageX - $me.offset().left
|
333
|
+
, y = event_.pageY - $me.offset().top
|
334
|
+
, img = me.items[ me.active ].find('img')
|
335
|
+
, imgWidth = img.width()
|
336
|
+
, imgHeight = img.height()
|
337
|
+
, carouselWidth = $me.innerWidth()
|
338
|
+
, carouselHeight = $me.innerHeight()
|
339
|
+
, deltaX = carouselWidth - imgWidth
|
340
|
+
, deltaY = carouselHeight - imgHeight
|
341
|
+
, percentX = x * 100 / carouselWidth
|
342
|
+
, percentY = y * 100 / carouselHeight;
|
343
|
+
|
344
|
+
img.stop().css({ top: percentY * deltaY / 100, left: percentX * deltaX / 100 });
|
345
|
+
});
|
346
|
+
}
|
347
|
+
|
348
|
+
$.fn[_name] = function( options_ ) {
|
349
|
+
return this.each(function() {
|
350
|
+
if( ! $.data( this, 'kit-' + _name ) ) {
|
351
|
+
$.data( this, 'kit-' + _name, new Carousel( this, options_ ) );
|
352
|
+
}
|
353
|
+
else {
|
354
|
+
typeof options_ === 'object' ? $.data( this, 'kit-' + _name )._setOptions( options_ ) :
|
355
|
+
typeof options_ === 'string' && options_.charAt(0) !== '_' ? $.data( this, 'kit-' + _name )[ options_ ] : $.error( 'What do you want to do?' );
|
356
|
+
}
|
357
|
+
});
|
358
|
+
}
|
359
|
+
|
360
|
+
})( jQuery, window, document );
|
361
|
+
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
// ;(function ( $, window, document, undefined ) {
|
368
|
+
|
369
|
+
// var _name = 'carousel'
|
370
|
+
// , _defaults = {
|
371
|
+
// navigation: false
|
372
|
+
// , navigationPlacement: undefined
|
373
|
+
// , theme: 'info'
|
374
|
+
|
375
|
+
// , itemSelector: '.js-carousel-item'
|
376
|
+
// , controlSelector: '.js-carousel-control'
|
377
|
+
// , hideControls: true
|
378
|
+
// , hideControlsDistance: 200
|
379
|
+
// , animation: true
|
380
|
+
|
381
|
+
// , slideshow: true
|
382
|
+
// , interval: 15000
|
383
|
+
|
384
|
+
// , imageFill: false
|
385
|
+
// , imageShowAnimation: true
|
386
|
+
// , imageShowInterval: 20000
|
387
|
+
|
388
|
+
// , captionAnimation: 'blurIn'
|
389
|
+
// , captionAnimationDelay: 1000
|
390
|
+
// }
|
391
|
+
|
392
|
+
// Carousel = function(element, options) {
|
393
|
+
// var me = this;
|
394
|
+
|
395
|
+
// this.name = _name;
|
396
|
+
|
397
|
+
// this.element = element;
|
398
|
+
// this.controls = $([]);
|
399
|
+
|
400
|
+
// this.active = 0;
|
401
|
+
// this.options = $.extend({}, _defaults, options);
|
402
|
+
|
403
|
+
// this._setOptions( this.options );
|
404
|
+
|
405
|
+
// this.init();
|
406
|
+
// }
|
407
|
+
|
408
|
+
// Carousel.prototype = new $.kit();
|
409
|
+
// Carousel.prototype.constructor = Carousel;
|
410
|
+
|
411
|
+
// Carousel.prototype.__setOption = function ( key_, value_ ) {
|
412
|
+
// var me = this;
|
413
|
+
// var $me = $(me.element);
|
414
|
+
// switch( key_ ) {
|
415
|
+
|
416
|
+
// case 'controlSelector':
|
417
|
+
// var _controls = $(document).find( value_ );
|
418
|
+
// me.controls.length > 0 &&
|
419
|
+
// me.controls.each( function( index_, control_ ) {
|
420
|
+
// control_.off( 'click.' + me.name);
|
421
|
+
// });
|
422
|
+
// me.controls = $([]);
|
423
|
+
// _controls.each( function( index_, item_ ) {
|
424
|
+
// $(document).find( $(item_).attr( 'href' ) )[0] === $(me.element)[0] && me.controls.push( $(item_) ) ;
|
425
|
+
// });
|
426
|
+
// me.controls.each( function( index_, control_ ) {
|
427
|
+
// control_.fadeOut();
|
428
|
+
// control_.on( 'click.' + me.name, function( event_ ) { event_.preventDefault() });
|
429
|
+
// });
|
430
|
+
// break;
|
431
|
+
|
432
|
+
// case 'hideControls':
|
433
|
+
// $me.off( 'mousemove.' + me.name ) && value_ && $me.on( 'mousemove.' + me.name, function( event_ ) { $.proxy( me.trackMouse( event_ ), me) } );
|
434
|
+
// break;
|
435
|
+
|
436
|
+
// case 'itemSelector':
|
437
|
+
// me.items = $me.find( value_ );
|
438
|
+
// me.images = $.map( me.items, function( item_ ) { return $(item_).find( '> img' )[0] });
|
439
|
+
// me.captions = $.map( me.items, function( item_ ) { return $(item_).find( '.-carousel-caption > div' ) });
|
440
|
+
// me.navigation.html($.map( me.items, function( item_ ) { return $('<i></i>')}) );
|
441
|
+
// break;
|
442
|
+
|
443
|
+
// case 'imageFill':
|
444
|
+
// $me.imagesLoaded( function() {
|
445
|
+
// if( value_ && me.images ) {
|
446
|
+
// var carouselHeight = $me.innerHeight()
|
447
|
+
// , carouselWidth = $me.innerWidth();
|
448
|
+
|
449
|
+
// $me.on( 'mousemove.' + me.name, function( event_ ) { $.proxy( me.trackMouse( event_ ), me) } );
|
450
|
+
|
451
|
+
// $me.addClass( '-carousel-imageFill' );
|
452
|
+
|
453
|
+
// $.each( me.items, function( index_, item_ ) {
|
454
|
+
// $(item_).css({height: '100%'});
|
455
|
+
// });
|
456
|
+
|
457
|
+
// $.each(me.images, function( index_, image_ ) {
|
458
|
+
// var imageWidth = $(image_).width()
|
459
|
+
// , imageHeight = $(image_).height()
|
460
|
+
// , aspectRatio = imageWidth / imageHeight;
|
461
|
+
|
462
|
+
// $(image_).css({ position: 'absolute', top: 0, left: 0 });
|
463
|
+
|
464
|
+
// carouselWidth / carouselHeight < aspectRatio ?
|
465
|
+
// $(image_).css({ width: 'auto', height: '100%' }) :
|
466
|
+
// $(image_).css({ width: '100%', height: 'auto' }) ;
|
467
|
+
|
468
|
+
// });
|
469
|
+
// }
|
470
|
+
// });
|
471
|
+
// break;
|
472
|
+
|
473
|
+
// case 'captionAnimation':
|
474
|
+
// switch( value_ ) {
|
475
|
+
// case 'blurIn':
|
476
|
+
// $.each( me.captions, function( index_, caption_ ) {
|
477
|
+
// $.each( caption_, function( index__, caption__ ) {
|
478
|
+
// $(caption__).addClass('-mx-blurIn');
|
479
|
+
// });
|
480
|
+
// });
|
481
|
+
// break;
|
482
|
+
// }
|
483
|
+
// break;
|
484
|
+
|
485
|
+
// case 'theme':
|
486
|
+
// $me.removeClass( '-' + me.options.theme + '-' );
|
487
|
+
// $me.addClass( '-' + value_ + '-' );
|
488
|
+
// me.navigation.addClass( '-' + value_ + '-' )
|
489
|
+
// break;
|
490
|
+
|
491
|
+
// case 'enabled':
|
492
|
+
// value_ === true ? $me.removeClass( '-disabled-' ) : $me.addClass( '-disabled-' );
|
493
|
+
// break;
|
494
|
+
|
495
|
+
// case 'navigation':
|
496
|
+
// if( typeof value_ === 'boolean' ) {
|
497
|
+
// me.navigation = $('<div class="-carousel-nav"></div>');
|
498
|
+
// me.navigation.hide();
|
499
|
+
// $(me.element).append( me.navigation );
|
500
|
+
// }
|
501
|
+
|
502
|
+
// if( typeof value_ === 'string' ) {
|
503
|
+
// me.navigation = $( value_ );
|
504
|
+
// me.navigation.hide();
|
505
|
+
// }
|
506
|
+
|
507
|
+
// me.navigation.on( 'click.' + this.name, function( event_ ) {
|
508
|
+
// if( $(event_.target).is('i') ) {
|
509
|
+
// var _oldActive = me.active;
|
510
|
+
// me.active = $(event_.target).index();
|
511
|
+
// me.slideAnimate( _oldActive );
|
512
|
+
// }
|
513
|
+
// });
|
514
|
+
|
515
|
+
// value_ && me.navigation.fadeIn();
|
516
|
+
// break;
|
517
|
+
|
518
|
+
// case 'navigationPlacement':
|
519
|
+
// value_ && $me.addClass( '_' + value_ + '_' );
|
520
|
+
// break;
|
521
|
+
|
522
|
+
// case 'slideshow':
|
523
|
+
// if( value_ ) {
|
524
|
+
// me.slideshow = setInterval( function() { $.proxy( me.setActive('next'), me ) }, me.options.interval );
|
525
|
+
// $me.on( 'mouseenter', function() { clearInterval( me.slideshow ) });
|
526
|
+
// $me.on( 'mouseleave', function() { me.slideshow = setInterval( function() { $.proxy( me.setActive('next'), me ) }, me.options.interval ); } );
|
527
|
+
// }
|
528
|
+
// break;
|
529
|
+
// }
|
530
|
+
|
531
|
+
// me.options[ key_ ] = value_;
|
532
|
+
// }
|
533
|
+
|
534
|
+
// Carousel.prototype.init = function() {
|
535
|
+
// var me = this
|
536
|
+
// , $me = $(me.element);
|
537
|
+
|
538
|
+
// $me.on( 'addItem', me.__setOption( 'itemSelector', me.options.itemSelector ) );
|
539
|
+
// // TODO: Check if it works
|
540
|
+
|
541
|
+
// $me.on( 'click.' + me.name, function() {
|
542
|
+
// for( var i = 0; i < me.controls.length; i++ ) {
|
543
|
+
// me.controls[i].is(':visible') && me.slide( me.controls[i] );
|
544
|
+
// }
|
545
|
+
// });
|
546
|
+
|
547
|
+
// setTimeout($.proxy(me.slideAnimate, me), 200);
|
548
|
+
// $me.imagesLoaded( function() { $me.animate({ opacity: 1 }) });
|
549
|
+
// }
|
550
|
+
|
551
|
+
// Carousel.prototype.trackMouse = function( event_ ) {
|
552
|
+
// var me = this
|
553
|
+
// , $me = $(me.element)
|
554
|
+
// , x = event_.pageX - $me.offset().left
|
555
|
+
// , carouselWidth = $me.width()
|
556
|
+
// , prev = $.map( me.controls, function( control_ ) { if( control_.data('slide') === 'prev' ) return control_; })[0]
|
557
|
+
// , next = $.map( me.controls, function( control_ ) { if( control_.data('slide') === 'next' ) return control_; })[0];
|
558
|
+
|
559
|
+
// me.options.hideControlsDistance > x ?
|
560
|
+
// prev.fadeIn() :
|
561
|
+
// prev.fadeOut();
|
562
|
+
|
563
|
+
// me.options.hideControlsDistance > carouselWidth - x ?
|
564
|
+
// next.fadeIn() :
|
565
|
+
// next.fadeOut();
|
566
|
+
// }
|
567
|
+
|
568
|
+
// Carousel.prototype.slide = function( control_ ) {
|
569
|
+
// var me = this
|
570
|
+
// , $me = $(me.element)
|
571
|
+
// , _btn = $(control_)
|
572
|
+
// , _direction = _btn.data( 'slide' );
|
573
|
+
|
574
|
+
// me.setActive( _direction );
|
575
|
+
// }
|
576
|
+
|
577
|
+
// Carousel.prototype.setActive = function( direction_ ) {
|
578
|
+
// var me = this
|
579
|
+
// , $me = $(me.element)
|
580
|
+
// , _oldActive = me.active;
|
581
|
+
|
582
|
+
// if( direction_ === 'next' )
|
583
|
+
// me.active === me.items.length-1 ? me.active = 0 : me.active++;
|
584
|
+
// if( direction_ === 'prev' )
|
585
|
+
// me.active === 0 ? me.active = me.items.length-1 : me.active--;
|
586
|
+
|
587
|
+
// me.slideAnimate( _oldActive );
|
588
|
+
// }
|
589
|
+
|
590
|
+
// Carousel.prototype.slideAnimate = function( from_ ) {
|
591
|
+
// var me = this
|
592
|
+
// , $me = $(me.element);
|
593
|
+
|
594
|
+
// // Fist – if animation is in $.easing (HIGH priority)
|
595
|
+
// if( $.easing && me.options.animation in $.easing ) {
|
596
|
+
// $(me.items.eq(0)).animate({ marginLeft: me.active * -100 + '%' }, me.startImageShowAnimation(from_) );
|
597
|
+
// }
|
598
|
+
// // Second – if animation and csstransitions are available
|
599
|
+
// else if( me.options.animation && Modernizr.csstransitions ) {
|
600
|
+
// $(me.items.eq(0)).css({ marginLeft: me.active * -100 + '%' });
|
601
|
+
// me.startImageShowAnimation(from_);
|
602
|
+
// }
|
603
|
+
// // Third – if only animation is available
|
604
|
+
// else if( me.options.animation ) {
|
605
|
+
// $(me.items.eq(0)).animate({ marginLeft: me.active * -100 + '%' }, me.startImageShowAnimation(from_) );
|
606
|
+
// }
|
607
|
+
|
608
|
+
// me.navigation.find('._active_').removeClass('_active_');
|
609
|
+
// me.navigation.find('i').eq( me.active ).addClass('_active_');
|
610
|
+
// }
|
611
|
+
|
612
|
+
// Carousel.prototype.startImageShowAnimation = function( old_ ) {
|
613
|
+
// var me = this
|
614
|
+
// , $me = $(me.element)
|
615
|
+
// , oldImage = $(me.images[ old_ ])
|
616
|
+
// , image = $(me.images[ me.active ])
|
617
|
+
// , deltaHeight = $me.innerHeight() - image.height()
|
618
|
+
// , deltaWidth = $me.innerWidth() - image.width();
|
619
|
+
|
620
|
+
|
621
|
+
// setTimeout(function(){
|
622
|
+
// oldImage && oldImage.stop().css({ top:0, left:0 });
|
623
|
+
// old_ && $.each( me.captions[ old_ ], function( index__, caption__ ) {
|
624
|
+
// switch( me.options.captionAnimation ) {
|
625
|
+
// case true:
|
626
|
+
// setTimeout(function(){
|
627
|
+
// $(caption__).stop().animate({opacity:0});
|
628
|
+
// }, me.options.captionAnimationDelay * (index__ + 1));
|
629
|
+
// break;
|
630
|
+
|
631
|
+
// case 'blurIn':
|
632
|
+
// setTimeout(function(){
|
633
|
+
// $(caption__).removeClass( '-mx-start' );
|
634
|
+
// }, me.options.captionAnimationDelay * (index__ + 1));
|
635
|
+
// break;
|
636
|
+
// }
|
637
|
+
// });
|
638
|
+
// }, 1000);
|
639
|
+
|
640
|
+
// me.options.imageFill && me.options.imageShowAnimation && $me.imagesLoaded( function() {
|
641
|
+
|
642
|
+
// switch( me.options.imageShowAnimation ) {
|
643
|
+
// case 'scrollDown':
|
644
|
+
// image.addClass('-mx-scrollDown').css({ top: deltaHeight, left: deltaWidth });
|
645
|
+
// break;
|
646
|
+
|
647
|
+
// case 'scrollDown-fast':
|
648
|
+
// image.addClass('-mx-scrollDown-fast').css({ top: deltaHeight, left: deltaWidth });
|
649
|
+
// break;
|
650
|
+
|
651
|
+
// case true:
|
652
|
+
// image.animate({ top: deltaHeight, left: deltaWidth }, me.options.imageShowInterval);
|
653
|
+
// break;
|
654
|
+
// }
|
655
|
+
// });
|
656
|
+
|
657
|
+
|
658
|
+
// $.each( me.captions[ me.active ], function( index__, caption__ ) {
|
659
|
+
// switch( me.options.captionAnimation ) {
|
660
|
+
// case true:
|
661
|
+
// setTimeout(function(){
|
662
|
+
// $(caption__).animate({opacity:1});
|
663
|
+
// }, me.options.captionAnimationDelay * (index__ + 1));
|
664
|
+
// break;
|
665
|
+
|
666
|
+
// case 'blurIn':
|
667
|
+
// setTimeout(function(){
|
668
|
+
// $(caption__).addClass( '-mx-start' );
|
669
|
+
// }, me.options.captionAnimationDelay * (index__ + 1));
|
670
|
+
// break;
|
671
|
+
// }
|
672
|
+
// });
|
673
|
+
|
674
|
+
// }
|
675
|
+
|
676
|
+
// $.fn[_name] = function( options_ ) {
|
677
|
+
// return this.each(function() {
|
678
|
+
// if( ! $.data( this, 'kit-' + _name ) ) {
|
679
|
+
// $.data( this, 'kit-' + _name, new Carousel( this, options_ ) );
|
680
|
+
// }
|
681
|
+
// else {
|
682
|
+
// typeof options_ === 'object' ? $.data( this, 'kit-' + _name )._setOptions( options_ ) :
|
683
|
+
// typeof options_ === 'string' && options_.charAt(0) !== '_' ? $.data( this, 'kit-' + _name )[ options_ ] : $.error( 'What do you want to do?' );
|
684
|
+
// }
|
685
|
+
// });
|
686
|
+
// }
|
687
|
+
|
688
|
+
// })( jQuery, window, document );
|