1(function($){ 2$.fn.verticalSlider=function(options){ 3'use strict'; 4 5 var slider=this, 6 inner=$('.vertical-inner'), 7 height=0, 8 length=inner.find('.slide').length, 9 innerTop=0, 10 totalHeight=0, 11 winWidth=$(window).width(); 12 13 14 var defaults={ 15 16 index:1, 17 itemDistance:15, // each item distance between them as padding. 18 animateTime:300, 19 animateType:'linear', 20 slideTop:'.vertical-top', 21 slideBottom:'.vertical-bottom', 22 23 }; 24 25 26 options=$.extend(defaults,options); 27 28 29 30 inner.find('.slide').css({ 31 32 paddingTop:options.itemDistance, 33 paddingBottom:options.itemDistance 34 35 }); 36 37 38 39 inner.find('.slide').each(function(){ 40 41 totalHeight+=$(this).outerHeight(); 42 43 }); 44 45 46 47 48 function add_class(opt){ 49 50 inner.find('.slide').removeClass('active-vertical'); 51 52 inner.find('.slide').eq(opt).addClass('active-vertical'); 53 54 } 55 56 add_class(options.index); 57 58 59 60 function activeHeight(opt){ 61 62 height=inner.find('.slide').eq(opt).outerHeight(); 63 64 slider.height(height); 65 66 } 67 68 activeHeight(options.index); 69 70 71 72 73 function innerPosition(opt){ 74 75 innerTop=0; 76 77 $('.slide').eq(opt).prevAll('.slide').each(function(){ 78 79 innerTop=$(this).outerHeight()+innerTop; 80 81 inner.css('marginTop',-innerTop+'px'); 82 83 }); 84 85 } 86 87 innerPosition(options.index); 88 89 90 91 function setSlide(opt){ 92 93 var innerTop=0; 94 95 inner.find('.slide').eq(opt).prevAll('.slide').each(function(){ 96 97 innerTop=$(this).outerHeight()+innerTop; 98 99 }); 100 101 inner.animate({ 102 103 marginTop:-innerTop 104 105 },options.animateTime,options.animateType); 106 107 } 108 109 110 111 112 $(window).resize(function(){ 113 114 activeHeight(options.index); 115 116 innerPosition(options.index); 117 118 }); 119 120 121 122 $(options.slideBottom).click(function(){ 123 124 if(options.index<length-1){ 125 126 options.index++; 127 128 setSlide(options.index); 129 130 activeHeight(options.index); 131 132 add_class(options.index); 133 134 } 135 136 }); 137 138 139 140 $(options.slideTop).click(function(){ 141 142 if(options.index>0){ 143 144 options.index--; 145 146 setSlide(options.index); 147 148 activeHeight(options.index); 149 150 add_class(options.index); 151 152 } 153 154 }); 155 156} 157 158 159 160})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.