1(function ($) { 2 $.fn.mobilyslider = function (options) { 3 var defaults = { 4 content: ".sliderContent", 5 children: "div", 6 transition: "horizontal", 7 animationSpeed: 300, 8 autoplay: false, 9 autoplaySpeed: 3000, 10 pauseOnHover: false, 11 bullets: true, 12 arrows: true, 13 arrowsHide: true, 14 prev: "prev", 15 next: "next", 16 animationStart: function () {}, 17 animationComplete: function () {} 18 }; 19 var sets = $.extend({}, defaults, options); 20 return this.each(function () { 21 var $t = $(this), 22 item = $t.children(sets.content).children(sets.children), 23 l = item.length - 1, 24 w = item.width(), 25 h = item.height(), 26 step = 0, 27 play, bullets, arrows, z, active, bullet; 28 var slider = { 29 init: function () { 30 slider.data(); 31 if (sets.bullets) { 32 slider.bullets.create() 33 } 34 if (sets.arrows) { 35 slider.arrows.create() 36 } 37 if (sets.autoplay) { 38 slider.autoplay() 39 } 40 slider.triggers() 41 }, 42 data: function () { 43 item.each(function (i) { 44 $(this).css("z-index", -(i - l)) 45 }); 46 if (sets.transition == "fade") { 47 item.hide().eq(0).show() 48 } 49 }, 50 zindex: { 51 prev: function () { 52 step == l ? item.eq(0).css("z-index", l + 3) : item.css("z-index", l + 1); 53 item.eq(step).css("z-index", l + 4).next(item).css("z-index", l + 2) 54 }, 55 next: function () { 56 item.css("z-index", l + 1).eq(step).css("z-index", l + 3).prev(item).css("z-index", l + 2) 57 }, 58 bullets: function () { 59 item.css("z-index", l + 1).eq(active).css("z-index", l + 2); 60 item.eq(step).css("z-index", l + 3) 61 }, 62 trigger: function () { 63 if (z == 1) { 64 slider.zindex.next() 65 } else { 66 if (z == -1) { 67 slider.zindex.prev() 68 } else { 69 if (z == 0) { 70 slider.zindex.bullets() 71 } 72 } 73 } 74 } 75 }, 76 slide: { 77 left: function (sign) { 78 sets.animationStart.call(this); 79 item.stop(true, true).eq(step).animate({ 80 left: sign + "=" + w 81 }, sets.animationSpeed, function () { 82 slider.zindex.trigger() 83 }).animate({ 84 left: 0 85 }, sets.animationSpeed + 200, function () { 86 sets.animationComplete.call(this) 87 }) 88 }, 89 top: function (sign) { 90 sets.animationStart.call(this); 91 item.stop(true, true).eq(step).animate({ 92 top: sign + "=" + h 93 }, sets.animationSpeed, function () { 94 slider.zindex.trigger() 95 }).animate({ 96 top: 0 97 }, sets.animationSpeed + 200, function () { 98 sets.animationComplete.call(this) 99 }) 100 }, 101 fade: function () { 102 sets.animationStart.call(this); 103 item.stop(true, true).fadeOut(sets.animationSpeed).eq(step).fadeIn(sets.animationSpeed, function () { 104 sets.animationComplete.call(this) 105 }) 106 } 107 }, 108 animation: { 109 previous: function () { 110 step == 0 ? step = l : step--; 111 z = -1; 112 switch (sets.transition) { 113 case "horizontal": 114 slider.slide.left("-"); 115 break; 116 case "vertical": 117 slider.slide.top("+"); 118 break; 119 case "fade": 120 slider.slide.fade(); 121 break 122 } 123 }, 124 next: function () { 125 step == l ? step = 0 : step++; 126 z = 1; 127 switch (sets.transition) { 128 case "horizontal": 129 slider.slide.left("+"); 130 break; 131 case "vertical": 132 slider.slide.top("-"); 133 break; 134 case "fade": 135 slider.slide.fade(); 136 break 137 } 138 } 139 }, 140 autoplay: function () { 141 play = setInterval(function () { 142 slider.animation.next(); 143 if (sets.bullets) { 144 setTimeout(function () { 145 slider.bullets.update() 146 }, sets.animationSpeed + 300) 147 } 148 }, sets.autoplaySpeed) 149 }, 150 pause: function () { 151 clearInterval(play) 152 }, 153 bullets: { 154 create: function () { 155 $t.append($("<div />").addClass("sliderBullets")); 156 bullets = $t.find(".sliderBullets"); 157 for (i = 0; i <= l; i++) { 158 bullets.append($("<a />").attr({ 159 href: "#", 160 rel: i 161 }).text(i)) 162 } 163 }, 164 trigger: function () { 165 bullet = bullets.find("a"); 166 bullet.eq(0).addClass("active"); 167 bullet.click(function () { 168 var b = $(this), 169 rel = b.attr("rel"); 170 active = bullet.filter(".active").attr("rel"); 171 step = rel; 172 sign = rel > active ? "+" : "-"; 173 z = 0; 174 if (!b.hasClass("active")) { 175 switch (sets.transition) { 176 case "horizontal": 177 slider.slide.left(sign); 178 break; 179 case "vertical": 180 slider.slide.top(sign); 181 break; 182 case "fade": 183 slider.slide.fade(); 184 break 185 } 186 } 187 bullet.removeClass("active"); 188 b.addClass("active"); 189 return false 190 }) 191 }, 192 update: function () { 193 bullet.removeClass("active").eq(step).addClass("active") 194 } 195 }, 196 arrows: { 197 create: function () { 198 $t.append($("<div />").addClass("sliderArrows"));
199 arrows = $t.find(".sliderArrows"); 200 arrows.append($("<a />").attr("href", "#").addClass(sets.prev).text("Previous")); 201 arrows.append($("<a />").attr("href", "#").addClass(sets.next).text("Next")) 202 }, 203 trigger: function () { 204 arrows.find("." + sets.prev).click(function () { 205 slider.animation.previous(); 206 if (sets.bullets) { 207 slider.bullets.update() 208 } 209 return false 210 }); 211 arrows.find("." + sets.next).click(function () { 212 slider.animation.next(); 213 if (sets.bullets) { 214 slider.bullets.update() 215 } 216 return false 217 }); 218 if (sets.arrowsHide) { 219 arrows.hide(); 220 $t.hover(function () { 221 arrows.show() 222 }, function () { 223 arrows.hide() 224 }) 225 } 226 } 227 }, 228 triggers: function () { 229 if (sets.arrows) { 230 slider.arrows.trigger() 231 } 232 if (sets.bullets) { 233 slider.bullets.trigger() 234 } 235 if (sets.pauseOnHover) { 236 $t.hover(function () { 237 slider.pause() 238 }, function () { 239 slider.autoplay() 240 }) 241 } 242 } 243 }; 244 slider.init() 245 }) 246 } 247}(jQuery)); 248 249$(function(){ 250 var siteW=$(window).width()-4; 251 252 var sliderH=500; 253 if (siteW<1200) { 254 sliderH=Math.ceil((siteW*450/1200)); 255 } 256 $('.sliderContent').css('height',sliderH+'px'); 257 258 259 $('.slider').mobilyslider({ 260 transition: 'fade', 261 animationSpeed: 500, 262 autoplay: true, 263 autoplaySpeed: 3000, 264 pauseOnHover: true, 265 bullets: true 266 }); 267});
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.