maxmertkit-rails 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -49,6 +49,11 @@ Add necessary javascript(s) files to app/assets/javascripts/application.js
49
49
  //= require maxmertkit.popup
50
50
  //= require maxmertkit.scrollspy
51
51
  //= require maxmertkit.tabs
52
+
53
+ //= require libs/easing
54
+ //= require libs/html5shiv
55
+ //= require libs/imagesLoaded
56
+ //= require libs/modernizr
52
57
  ```
53
58
 
54
59
  ## Thanks
@@ -1,5 +1,5 @@
1
1
  module Maxmertkit
2
2
  module Rails
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -8,8 +8,8 @@ Gem::Specification.new do |gem|
8
8
  gem.version = Maxmertkit::Rails::VERSION
9
9
  gem.authors = ["Viktor Tomilin"]
10
10
  gem.email = ["caballerosolar@gmail.com"]
11
- gem.description = ["Css framework based on widget-modifier coding style"]
12
- gem.summary = ["Css framework based on widget-modifier coding style"]
11
+ gem.description = "Css framework based on widget-modifier coding style"
12
+ gem.summary = "Css framework based on widget-modifier coding style"
13
13
  gem.homepage = "http://maxmert.com/"
14
14
 
15
15
  gem.files = `git ls-files`.split($/)
@@ -4,6 +4,8 @@
4
4
  , _defaults = {
5
5
  offset: 0 // Y
6
6
  , inside: 'parent'
7
+ , fixHorizontal: true
8
+ , enabled: true
7
9
  }
8
10
 
9
11
  Affix = function(element, options) {
@@ -27,6 +29,8 @@
27
29
 
28
30
  me.$window.on( 'scroll.' + me.name, $.proxy(me.checkPosition, this) );
29
31
  me.$window.on( 'click.' + me.name, $.proxy( function() { setTimeout( $.proxy(me.checkPosition, this) , 1 ) }, this ) );
32
+ if( me.options.fixHorizontal )
33
+ me.$window.on( 'resize.' + me.name, $.proxy(me.checkPositionHorizontal, this) );
30
34
 
31
35
  me.$parent = me.options.inside === 'parent' ? $me.parent() : $me.closest( me.options.inside );
32
36
  $me.css({ top: me.$parent.offset().top + me.options.offset });
@@ -51,22 +55,123 @@
51
55
  , $parentOffset = me.$parent.offset();
52
56
 
53
57
  var q = scrollTop + me.options.offset;
54
-
58
+
55
59
  if( q <= $parentOffset.top ) {
56
- $me.css({
57
- position: 'absolute',
58
- top: $parentOffset.top
59
- });
60
+ if( me.$parent.css('position') === 'relative' )
61
+ {
62
+ $me.css({
63
+ position: 'absolute',
64
+ top: 0,
65
+ bottom: 'auto'
66
+ });
67
+ }
68
+ else
69
+ {
70
+ $me.css({
71
+ position: 'absolute',
72
+ top: $parentOffset.top,
73
+ bottom: 'auto'
74
+ });
75
+ }
60
76
  } else if( $parentOffset.top + me.$parent.outerHeight() - height <= q && q >= $parentOffset.top ) {
61
- $me.css({
62
- position: 'absolute',
63
- top: $parentOffset.top + $parentHeight - height
64
- });
77
+ if( me.$parent.css('position') === 'relative' )
78
+ {
79
+ $me.css({
80
+ position: 'absolute',
81
+ top: 'auto',
82
+ bottom: 0
83
+ });
84
+ }
85
+ else
86
+ {
87
+ $me.css({
88
+ position: 'absolute',
89
+ top: $parentOffset.top + $parentHeight - height,
90
+ bottom: 'auto'
91
+ });
92
+ }
93
+
94
+
65
95
  } else {
66
- $me.css({
67
- position: 'fixed',
68
- top: offset
69
- });
96
+ if( $me.css('position') === 'absolute' && me.$parent.css('position') === 'relative' ) {
97
+
98
+ mewidth = $me.width();
99
+ if( ! $me.data('memargin') )
100
+ $me.data('memargin', parseFloat($me.css('margin-left')) + 1 );
101
+
102
+
103
+ $me.css({
104
+ position: 'fixed',
105
+ top: offset,
106
+ bottom: 'auto',
107
+ width: mewidth,
108
+ marginLeft: $me.data('memargin')
109
+ });
110
+
111
+ }
112
+ else
113
+ {
114
+ $me.css({
115
+ position: 'fixed',
116
+ top: offset,
117
+ bottom: 'auto'
118
+ });
119
+ }
120
+ }
121
+
122
+
123
+ if( $me.css('position') === 'absolute' && me.$parent.css('position') === 'relative' )
124
+ $me.css({left: 0})
125
+ else
126
+ // if( $me.css('position') === 'fixed' )
127
+ $me.css({left: $parentOffset.left})
128
+ }
129
+
130
+ Affix.prototype.isenable = function() {
131
+ return this.options.enabled;
132
+ }
133
+
134
+ Affix.prototype.checkPositionHorizontal = function() {
135
+ var me = this
136
+ , $me = $(me.element);
137
+
138
+ parentOffset = me.$parent.offset();
139
+
140
+ if( me.options.enabled === true ) {
141
+ if( $me.css('position') === 'absolute' && me.$parent.css('position') === 'relative' )
142
+ $me.css({left: 0})
143
+ else
144
+ // if( $me.css('position') === 'fixed' )
145
+ $me.css({left: parentOffset.left})
146
+ // else
147
+ }
148
+ }
149
+
150
+ Affix.prototype.__setOption = function( key_, value_ ) {
151
+ var me = this
152
+ , $me = $(me.element);
153
+
154
+ switch( key_ ) {
155
+ case 'enable':
156
+ if( value_ === false )
157
+ {
158
+ me.$window.off( 'scroll.' + me.name );
159
+ me.$window.off( 'click.' + me.name );
160
+ if( me.options.fixHorizontal )
161
+ me.$window.off( 'resize.' + me.name );
162
+ $me.css({ position: 'relative', top: 0, left: 0 });
163
+ $me.removeAttr('style');
164
+ this.options.enabled = false;
165
+ }
166
+ else
167
+ {
168
+ me.$window.on( 'scroll.' + me.name, $.proxy(me.checkPosition, this) );
169
+ me.$window.on( 'click.' + me.name, $.proxy( function() { setTimeout( $.proxy(me.checkPosition, this) , 1 ) }, this ) );
170
+ if( me.options.fixHorizontal )
171
+ me.$window.on( 'resize.' + me.name, $.proxy(me.checkPositionHorizontal, this) );
172
+ this.options.enabled = true;
173
+ }
174
+ break;
70
175
  }
71
176
  }
72
177
 
@@ -76,8 +181,12 @@
76
181
  $.data( this, 'kit-' + _name, new Affix( this, options_ ) );
77
182
  }
78
183
  else {
79
- typeof options_ === 'object' ? $.data( this, 'kit-' + _name )._setOptions( options_ ) :
184
+ if( typeof options_ === 'object' )
185
+ $.data( this, 'kit-' + _name )._setOptions( options_ )
186
+ else
187
+ {
80
188
  typeof options_ === 'string' && options_.charAt(0) !== '_' ? $.data( this, 'kit-' + _name )[ options_ ] : $.error( 'What do you want to do?' );
189
+ }
81
190
  }
82
191
  });
83
192
  }
@@ -357,332 +357,4 @@
357
357
  });
358
358
  }
359
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 );
360
+ })( jQuery, window, document );