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,396 @@
|
|
1
|
+
;(function ( $, window, document, undefined ) {
|
2
|
+
|
3
|
+
var _name = 'popup'
|
4
|
+
, _defaults = {
|
5
|
+
placement: 'top'
|
6
|
+
, offset: [0, 0]
|
7
|
+
, autoOpen: false
|
8
|
+
, template: '<div class="js-content"></div>'
|
9
|
+
, onlyOne: false
|
10
|
+
, content: null
|
11
|
+
, header: null
|
12
|
+
, trigger: 'click'
|
13
|
+
, delay: 0
|
14
|
+
|
15
|
+
, beforeOpen: $.noop()
|
16
|
+
, open: $.noop()
|
17
|
+
, ifOpenedOrNot: $.noop()
|
18
|
+
, ifNotOpened: $.noop()
|
19
|
+
, beforeClose: $.noop()
|
20
|
+
, close: $.noop()
|
21
|
+
, ifClosedOrNot: $.noop()
|
22
|
+
, ifNotClosed: $.noop()
|
23
|
+
}
|
24
|
+
|
25
|
+
Popup = function( element_, options_ ) {
|
26
|
+
// Don't need this string, if this constructor will do the same and more, than $.kit constructor.
|
27
|
+
// $.kit.apply( this, element_, options_ );
|
28
|
+
|
29
|
+
this.element = element_;
|
30
|
+
this.name = _name;
|
31
|
+
this.state = 'closed';
|
32
|
+
this.options = $.extend( {}, this.options, _defaults, options_ );
|
33
|
+
|
34
|
+
// Creating popup element by template
|
35
|
+
this.options.template.charAt(0) !== '.' && this.options.template.charAt(0) !== '#' ?
|
36
|
+
this.El = $(this.options.template) :
|
37
|
+
this.El = $( $(this.options.template).html() );
|
38
|
+
|
39
|
+
$('body').append( this.El );
|
40
|
+
// CSS manupulations just in case
|
41
|
+
this.El
|
42
|
+
.css({position: 'absolute', display: 'none'})
|
43
|
+
.find('.-arrow')
|
44
|
+
.css({opacity: 0});
|
45
|
+
|
46
|
+
this._setOptions( this.options );
|
47
|
+
|
48
|
+
// Create collection for other instances
|
49
|
+
if( typeof $.popup === 'undefined' )
|
50
|
+
$.popup = []
|
51
|
+
// Put this instance to the collection
|
52
|
+
if( this.element !== undefined )
|
53
|
+
$.popup.push( this.element );
|
54
|
+
|
55
|
+
// For delay before open
|
56
|
+
this.timeout = null;
|
57
|
+
|
58
|
+
this.init();
|
59
|
+
}
|
60
|
+
|
61
|
+
Popup.prototype = new $.kit();
|
62
|
+
Popup.prototype.constructor = Popup;
|
63
|
+
|
64
|
+
Popup.prototype.__setOption = function ( key_, value_ ) {
|
65
|
+
var me = this;
|
66
|
+
var $me = $(me.element);
|
67
|
+
switch( key_ ) {
|
68
|
+
|
69
|
+
case 'trigger':
|
70
|
+
var _events = value_.split(/[ ,]+/);
|
71
|
+
|
72
|
+
|
73
|
+
// me.options[key_]['in'] – for IE < 8
|
74
|
+
if( typeof me.options[key_]['in'] !== undefined )
|
75
|
+
$me.off( 'mouseenter.' + me.name, 'click.' + me.name );
|
76
|
+
|
77
|
+
if( typeof me.options[key_]['out'] !== undefined )
|
78
|
+
$me.off( 'mouseleave.' + me.name, 'click.' + me.name );
|
79
|
+
|
80
|
+
me.options[key_] = {
|
81
|
+
'in': _events[0]
|
82
|
+
, 'out': (_events[1] == undefined || _events[1] == '') ? _events[0] : _events[1]
|
83
|
+
};
|
84
|
+
|
85
|
+
switch( me.options[key_]['in'] ) {
|
86
|
+
case 'hover':
|
87
|
+
$me.on('mouseenter.' + me.name, function( event ) {
|
88
|
+
if( me.state === 'closed' )
|
89
|
+
me.open();
|
90
|
+
});
|
91
|
+
break;
|
92
|
+
|
93
|
+
default:
|
94
|
+
$me.on( me.options[key_]['in'] + '.' + me.name, function() {
|
95
|
+
if( me.state === 'closed' )
|
96
|
+
me.open();
|
97
|
+
});
|
98
|
+
}
|
99
|
+
|
100
|
+
switch( me.options[key_].out ) {
|
101
|
+
case 'hover':
|
102
|
+
$me.on('mouseleave.' + me.name, function( event ) {
|
103
|
+
me.close();
|
104
|
+
});
|
105
|
+
break;
|
106
|
+
|
107
|
+
default:
|
108
|
+
$me.on( me.options[key_].out + '.' + me.name, function() {
|
109
|
+
if( me.state == 'opened' )
|
110
|
+
me.close();
|
111
|
+
});
|
112
|
+
}
|
113
|
+
break;
|
114
|
+
|
115
|
+
case 'content':
|
116
|
+
if( value_ !== null )
|
117
|
+
me.El.find('.js-content').html(value_);
|
118
|
+
else
|
119
|
+
me.El.find('.js-content').html( $me.data('content') );
|
120
|
+
break;
|
121
|
+
|
122
|
+
case 'header':
|
123
|
+
if( value_ !== null )
|
124
|
+
me.El.find('.js-header').html(value_);
|
125
|
+
else
|
126
|
+
me.El.find('.js-header').html( $me.data('header') );
|
127
|
+
break;
|
128
|
+
|
129
|
+
case 'placement':
|
130
|
+
me.El.removeClass('_' + me.options.placement + '_')
|
131
|
+
me.El.addClass('_' + value_ + '_')
|
132
|
+
break;
|
133
|
+
|
134
|
+
case 'animation':
|
135
|
+
if( $.easing === undefined || !(value_ in $.easing) )
|
136
|
+
switch( value_ ) {
|
137
|
+
case 'scaleIn':
|
138
|
+
me.El.addClass('-mx-scaleIn');
|
139
|
+
break;
|
140
|
+
|
141
|
+
case 'growUp':
|
142
|
+
me.El.addClass('-mx-growUp');
|
143
|
+
break;
|
144
|
+
|
145
|
+
case 'rotateIn':
|
146
|
+
me.El.addClass('-mx-rotateIn');
|
147
|
+
break;
|
148
|
+
|
149
|
+
case 'dropIn':
|
150
|
+
me.El.addClass('-mx-dropIn');
|
151
|
+
break;
|
152
|
+
}
|
153
|
+
|
154
|
+
break;
|
155
|
+
|
156
|
+
}
|
157
|
+
|
158
|
+
if( key_ !== 'trigger' )
|
159
|
+
me.options[ key_ ] = value_;
|
160
|
+
}
|
161
|
+
|
162
|
+
Popup.prototype.init = function() {
|
163
|
+
var me = this;
|
164
|
+
|
165
|
+
if( me.options.autoOpen )
|
166
|
+
me.open()
|
167
|
+
}
|
168
|
+
|
169
|
+
Popup.prototype.open = function() {
|
170
|
+
var me = this;
|
171
|
+
var $me = $(me.element);
|
172
|
+
|
173
|
+
me.timeout = setTimeout(function(){
|
174
|
+
if( me.options.enabled === true && me.state !== 'opened' ) {
|
175
|
+
|
176
|
+
me.state = 'in';
|
177
|
+
|
178
|
+
if( me.options.beforeOpen !== undefined && (typeof me.options.beforeOpen === 'object' || typeof me.options.beforeOpen === 'function' )) {
|
179
|
+
|
180
|
+
try {
|
181
|
+
var deferred = me.options.beforeOpen.call( $me );
|
182
|
+
deferred
|
183
|
+
.done(function(){
|
184
|
+
me._open();
|
185
|
+
})
|
186
|
+
.fail(function(){
|
187
|
+
me.state = 'closed';
|
188
|
+
$me.trigger('ifNotOpened.' + me.name);
|
189
|
+
$me.trigger('ifOpenedOrNot.' + me.name);
|
190
|
+
})
|
191
|
+
} catch( e ) {
|
192
|
+
me._open();
|
193
|
+
}
|
194
|
+
|
195
|
+
}
|
196
|
+
else {
|
197
|
+
me._open();
|
198
|
+
}
|
199
|
+
}
|
200
|
+
}, me.options.delay)
|
201
|
+
}
|
202
|
+
|
203
|
+
Popup.prototype._open = function() {
|
204
|
+
var me = this;
|
205
|
+
var $me = $(me.element);
|
206
|
+
|
207
|
+
if( me.state === 'in' ) {
|
208
|
+
|
209
|
+
if( me.options.onlyOne )
|
210
|
+
|
211
|
+
$.each( me._getOtherInstanses( $.popup ), function() {
|
212
|
+
if( $.data( this, 'kit-' + me.name ).getState() === 'opened' )
|
213
|
+
$.data( this, 'kit-' + me.name ).close();
|
214
|
+
});
|
215
|
+
|
216
|
+
me._setPosition();
|
217
|
+
|
218
|
+
if( me.options.animation !== null && me.options.animation !== false )
|
219
|
+
{
|
220
|
+
me._openAnimation();
|
221
|
+
}
|
222
|
+
else
|
223
|
+
{
|
224
|
+
me.El.find('.-arrow').css({opacity: 1});
|
225
|
+
me.El.show();
|
226
|
+
}
|
227
|
+
|
228
|
+
me.state = 'opened';
|
229
|
+
$me.trigger('open.' + me.name);
|
230
|
+
}
|
231
|
+
|
232
|
+
$me.trigger('ifOpenedOrNot.' + me.name);
|
233
|
+
}
|
234
|
+
|
235
|
+
Popup.prototype._openAnimation = function() {
|
236
|
+
var me = this;
|
237
|
+
var $me = $(me.element);
|
238
|
+
|
239
|
+
if( $.easing !== undefined && (me.options.animation.split(/[ ,]+/)[1] in $.easing || me.options.animation.split(/[ ,]+/)[0] in $.easing) ) {
|
240
|
+
me.El.slideDown({
|
241
|
+
duration: me.options.animationDuration,
|
242
|
+
easing: me.options.animation.split(/[ ,]+/)[0],
|
243
|
+
complete: function(){
|
244
|
+
me.El.find('.-arrow').animate({opacity: 1});
|
245
|
+
}
|
246
|
+
});
|
247
|
+
}
|
248
|
+
else {
|
249
|
+
me.El.show();
|
250
|
+
this.El.find('.-arrow').css({opacity: 1});
|
251
|
+
if( Modernizr && Modernizr.csstransitions && Modernizr.csstransforms3d && Modernizr.cssanimations )
|
252
|
+
me.El.addClass('-mx-start');
|
253
|
+
}
|
254
|
+
}
|
255
|
+
|
256
|
+
Popup.prototype.close = function() {
|
257
|
+
var me = this;
|
258
|
+
var $me = $(me.element);
|
259
|
+
|
260
|
+
clearTimeout( me.timeout );
|
261
|
+
|
262
|
+
if( me.options.enabled === true && me.state !== 'closed' ) {
|
263
|
+
|
264
|
+
me.state = 'out';
|
265
|
+
|
266
|
+
if( me.options.beforeClose != undefined && (typeof me.options.beforeClose === 'object' || typeof me.options.beforeClose === 'function' ))
|
267
|
+
{
|
268
|
+
|
269
|
+
try {
|
270
|
+
var deferred = me.options.beforeClose.call( $me );
|
271
|
+
deferred
|
272
|
+
.done(function(){
|
273
|
+
me._close();
|
274
|
+
})
|
275
|
+
.fail(function(){
|
276
|
+
$me.trigger('ifNotClosed.' + me.name);
|
277
|
+
$me.trigger('ifClosedOrNot.' + me.name);
|
278
|
+
me.state = 'opened';
|
279
|
+
})
|
280
|
+
} catch( e ) {
|
281
|
+
me._close();
|
282
|
+
}
|
283
|
+
|
284
|
+
}
|
285
|
+
else {
|
286
|
+
me._close();
|
287
|
+
}
|
288
|
+
}
|
289
|
+
}
|
290
|
+
|
291
|
+
Popup.prototype._close = function() {
|
292
|
+
var me = this;
|
293
|
+
var $me = $(me.element);
|
294
|
+
|
295
|
+
if( me.state === 'out' ) {
|
296
|
+
|
297
|
+
if( me.options.animation === null )
|
298
|
+
me.El.hide();
|
299
|
+
else {
|
300
|
+
me._closeAnimation();
|
301
|
+
}
|
302
|
+
me.state = 'closed';
|
303
|
+
|
304
|
+
$me.trigger('close');
|
305
|
+
}
|
306
|
+
|
307
|
+
$me.trigger('ifClosedOrNot.' + me.name);
|
308
|
+
}
|
309
|
+
|
310
|
+
Popup.prototype._closeAnimation = function() {
|
311
|
+
var me = this;
|
312
|
+
var $me = $(me.element);
|
313
|
+
|
314
|
+
if( $.easing !== undefined && (me.options.animation.split(/[ ,]+/)[1] in $.easing || me.options.animation.split(/[ ,]+/)[0] in $.easing) ) {
|
315
|
+
me.El.slideUp({
|
316
|
+
duration: me.options.animationDuration,
|
317
|
+
easing: me.options.animation.split(/[ ,]+/)[1] !== undefined ? me.options.animation.split(/[ ,]+/)[1] : me.options.animation,
|
318
|
+
complete: function(){
|
319
|
+
me.El.find('.-arrow').animate({opacity: 0});
|
320
|
+
}
|
321
|
+
});
|
322
|
+
}
|
323
|
+
else {
|
324
|
+
if( Modernizr && Modernizr.csstransitions && Modernizr.csstransforms3d && Modernizr.cssanimations ) {
|
325
|
+
me.El.removeClass('-mx-start');
|
326
|
+
setTimeout(function(){
|
327
|
+
if ( me.state === 'closed' )
|
328
|
+
me.El.hide()
|
329
|
+
},1000)
|
330
|
+
}
|
331
|
+
else
|
332
|
+
me.El.hide();
|
333
|
+
}
|
334
|
+
}
|
335
|
+
|
336
|
+
Popup.prototype._setPosition = function() {
|
337
|
+
var me = this;
|
338
|
+
var $me = $(me.element);
|
339
|
+
|
340
|
+
var actualWidth = $me.outerWidth() ;
|
341
|
+
var actualHeight = $me.outerHeight() ;
|
342
|
+
var actualPosition = $me.offset();
|
343
|
+
var arrowSize = 8;
|
344
|
+
// console.log(actualPosition, $me.height(), actualHeight, parseInt($me.css('paddingTop')), parseInt($me.css('paddingBottom')));
|
345
|
+
|
346
|
+
var _zIndex = 1
|
347
|
+
, _position = 'absolute';
|
348
|
+
$.each( $me.parents(), function( index_, item_ ) {
|
349
|
+
if( $(item_).css('z-index') !== 'auto' && parseInt( $(item_).css('z-index')) > _zIndex )
|
350
|
+
_zIndex = $(item_).css('z-index') + 1;
|
351
|
+
if( $(item_).css('position') === 'fixed' )
|
352
|
+
_position = 'fixed';
|
353
|
+
});
|
354
|
+
if( _position === 'fixed' ) {
|
355
|
+
actualPosition.top = actualPosition.top - $(document).scrollTop();
|
356
|
+
}
|
357
|
+
me.El.css({'z-index': _zIndex, 'position': _position});
|
358
|
+
|
359
|
+
var pos = {}
|
360
|
+
|
361
|
+
switch( me.options.placement ) {
|
362
|
+
case 'top':
|
363
|
+
pos = { top: actualPosition.top - me.El.outerHeight() - arrowSize + me.options.offset[0], left: actualPosition.left + actualWidth / 2 - me.El.outerWidth() / 2 + me.options.offset[1] }
|
364
|
+
break;
|
365
|
+
|
366
|
+
case 'bottom':
|
367
|
+
pos = { top: actualPosition.top + actualHeight + arrowSize + me.options.offset[0], left: actualPosition.left + actualWidth / 2 - me.El.outerWidth() / 2 + me.options.offset[1] };
|
368
|
+
break;
|
369
|
+
|
370
|
+
case 'left':
|
371
|
+
pos = { top: actualPosition.top + actualHeight / 2 - me.El.outerHeight() / 2, left: actualPosition.left - me.El.outerWidth() - arrowSize + me.options.offset[1] }
|
372
|
+
break;
|
373
|
+
|
374
|
+
case 'right':
|
375
|
+
pos = { top: actualPosition.top + actualHeight / 2 - me.El.outerHeight() / 2, left: actualPosition.left + actualWidth + arrowSize + me.options.offset[1]}
|
376
|
+
break;
|
377
|
+
}
|
378
|
+
|
379
|
+
me.El.css(pos);
|
380
|
+
}
|
381
|
+
|
382
|
+
$.fn[_name] = function( options_ ) {
|
383
|
+
return this.each(function() {
|
384
|
+
if( ! $.data( this, 'kit-' + _name ) ) {
|
385
|
+
$.data( this, 'kit-' + _name, new Popup( this, options_ ) );
|
386
|
+
}
|
387
|
+
else {
|
388
|
+
typeof options_ === 'object' ? $.data( this, 'kit-' + _name )._setOptions( options_ ) :
|
389
|
+
typeof options_ === 'string' && options_.charAt(0) !== '_' ? $.data( this, 'kit-' + _name )[ options_ ] : $.error( 'What do you want to do?' );
|
390
|
+
}
|
391
|
+
});
|
392
|
+
}
|
393
|
+
|
394
|
+
|
395
|
+
|
396
|
+
})( jQuery, window, document );
|
@@ -0,0 +1,107 @@
|
|
1
|
+
;(function ( $, window, document, undefined ) {
|
2
|
+
|
3
|
+
var _name = 'scrollspy'
|
4
|
+
, _defaults = {
|
5
|
+
itemSelector: 'li',
|
6
|
+
offset: 2,
|
7
|
+
animation: true
|
8
|
+
}
|
9
|
+
|
10
|
+
Scrollspy = function(element, options) {
|
11
|
+
this.name = _name;
|
12
|
+
|
13
|
+
this.element = element;
|
14
|
+
this.options = $.extend({}, _defaults, options);
|
15
|
+
|
16
|
+
var process = $.proxy( this.process, this );
|
17
|
+
this.$scrollable = $(this.element).is('body') ? $(window) : $(this.element);
|
18
|
+
$(window).on( 'scroll.' + this.name, process );
|
19
|
+
|
20
|
+
this.init();
|
21
|
+
process();
|
22
|
+
}
|
23
|
+
|
24
|
+
Scrollspy.prototype = new $.kit();
|
25
|
+
Scrollspy.prototype.constructor = Scrollspy;
|
26
|
+
|
27
|
+
Scrollspy.prototype.init = function() {
|
28
|
+
var me = this,
|
29
|
+
$me = $(me.element);
|
30
|
+
|
31
|
+
me.refresh();
|
32
|
+
}
|
33
|
+
|
34
|
+
Scrollspy.prototype.refresh = function() {
|
35
|
+
var me = this
|
36
|
+
, $me = $(me.element)
|
37
|
+
, $targets;
|
38
|
+
|
39
|
+
me.targets = $([]);
|
40
|
+
me.offsets = $([]);
|
41
|
+
|
42
|
+
$targets = me.$scrollable
|
43
|
+
.find( me.options.itemSelector )
|
44
|
+
.map( function() {
|
45
|
+
var $el = $(this)
|
46
|
+
, href = $el.data('target') || $el.attr('href')
|
47
|
+
, $href = /^#\w/.test(href) && $(href);
|
48
|
+
|
49
|
+
return ( $href
|
50
|
+
&& $href.length
|
51
|
+
&& [[ $href.position().top, href ]] ) || null
|
52
|
+
})
|
53
|
+
.sort( function( a, b ) { return a[0] - b[0] } )
|
54
|
+
.each( function() {
|
55
|
+
me.offsets.push(this[0]);
|
56
|
+
me.targets.push(this[1]);
|
57
|
+
});
|
58
|
+
}
|
59
|
+
|
60
|
+
Scrollspy.prototype.process = function() {
|
61
|
+
var me = this
|
62
|
+
, $me = $(me.element)
|
63
|
+
, scrollTop = $(window).scrollTop() + me.options.offset
|
64
|
+
, i;
|
65
|
+
|
66
|
+
for( i = 0; i < me.offsets.length - 1; i++ ) {
|
67
|
+
if( scrollTop < me.offsets[0] )
|
68
|
+
me.activate( me.targets[0] );
|
69
|
+
if( me.offsets[i] < scrollTop && scrollTop <= me.offsets[i+1] )
|
70
|
+
me.activate( me.targets[i] );
|
71
|
+
if( scrollTop > me.offsets[i+1] )
|
72
|
+
me.activate( me.targets[i+1] );
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
Scrollspy.prototype.activate = function( target_ ) {
|
77
|
+
var me = this
|
78
|
+
, $me = $(me.element)
|
79
|
+
, selector
|
80
|
+
, active,
|
81
|
+
classes = me.options.animation ? '_active_ -mx-start' : '_active_';
|
82
|
+
|
83
|
+
me.active = target_;
|
84
|
+
|
85
|
+
$me
|
86
|
+
.find( '._active_' )
|
87
|
+
.removeClass( classes );
|
88
|
+
|
89
|
+
$( '[data-target="'+ target_ +'"]' )
|
90
|
+
.addClass( classes );
|
91
|
+
|
92
|
+
active = $('body').find( target_ ).trigger( 'activate' );
|
93
|
+
}
|
94
|
+
|
95
|
+
$.fn[_name] = function( options_ ) {
|
96
|
+
return this.each(function() {
|
97
|
+
if( ! $.data( this, 'kit-' + _name ) ) {
|
98
|
+
$.data( this, 'kit-' + _name, new Scrollspy( this, options_ ) );
|
99
|
+
}
|
100
|
+
else {
|
101
|
+
typeof options_ === 'object' ? $.data( this, 'kit-' + _name )._setOptions( options_ ) :
|
102
|
+
typeof options_ === 'string' && options_.charAt(0) !== '_' ? $.data( this, 'kit-' + _name )[ options_ ] : $.error( 'What do you want to do?' );
|
103
|
+
}
|
104
|
+
});
|
105
|
+
}
|
106
|
+
|
107
|
+
})( jQuery, window, document );
|