1/*easyCarousel */ 2(function ($) { 3 $.fn.easyCarousel = function (o) { 4 o = $.extend({ 5 autoplay: false, 6 speed: 300, 7 pagination: true, 8 navigation: true, 9 mousewheel: true, 10 loop: true, 11 }, o || {}); 12 var d = $(this); 13 14 for (var i in o) { 15 if (d.data(i) !== undefined) { 16 o[i] = d.data(i); 17 } 18 } 19 w = d.innerWidth(); 20 var sbox = d.find(".carousel-scroll"), 21 item = d.find(".carousel-item"); 22 var current = 0; 23 var AnimeEnd = true; 24 var itemwidth = item.eq(0).innerWidth(); 25 var pageitem = Math.round(w / itemwidth); 26 var maxpage = item.length; 27 var duplicate = maxpage % pageitem ? pageitem + (pageitem - maxpage % pageitem) : pageitem + 1; 28 var initpos = itemwidth * duplicate; 29 30 31 32 if (o.loop) { 33 34 function duplicateItem() { 35 d.find(".duplicate-item").remove(); 36 37 var mod = duplicate; 38 39 if(duplicate >maxpage){ 40 sbox.append(item.clone().addClass("duplicate-item")); 41 sbox.prepend(item.clone().addClass("duplicate-item")); 42 mod = duplicate - maxpage; 43 } 44 if(pageitem > 1){ 45 sbox.append(item.clone().addClass("duplicate-item")); 46 } 47 var duplicateAfter = item.slice(0, mod).clone().addClass("duplicate-item"); 48 var duplicateBefore = item.slice(maxpage - mod, maxpage).clone().addClass("duplicate-item"); 49 50 sbox.append(duplicateAfter); 51 sbox.prepend(duplicateBefore); 52 } 53 54 duplicateItem(); 55 56 sbox.css({ 57 "transform": "translate3d(-" + (initpos) + "px, 0px, 0px)", 58 "transition-duration": "0ms" 59 }); 60 61 item.eq(0).addClass("active").siblings().removeClass("active"); 62 if(sbox.find(".duplicate-item .img-Lazy").length && typeof $.fn.scrollLoading =="function"){ 63 sbox.find(".duplicate-item .img-Lazy").scrollLoading({loading: true}); 64 } 65 } else { 66 initpos = 0; 67 item.eq(0).addClass("active").siblings().removeClass("active"); 68 } 69 70 71 var resizeOne = false; 72 73 $(window).resize(function () { 74 clearInterval(resizeOne); 75 resizeOne = setTimeout(function () { 76 w = d.innerWidth(); 77 itemwidth = item.eq(0).innerWidth(); 78 79 80 if (Math.round(w / itemwidth) != pageitem) { 81 pageitem = Math.round(w / itemwidth); 82 itemwidth = w/pageitem; 83 84 duplicate = maxpage % pageitem ? pageitem + (pageitem - maxpage % pageitem) : pageitem + 1; 85 86 if (o.loop) { 87 duplicateItem(); 88 } 89 }; 90 91 initpos = o.loop ? itemwidth * duplicate : 0; 92 93 sbox.css({ 94 "transform": "translate3d(-" + (current * itemwidth + initpos) + "px, 0px, 0px)", 95 "transition-duration": "0ms" 96 }); 97 98 item.eq(0).addClass("active").siblings().removeClass("active"); 99 100 if (!o.loop && o.navigation) { 101 if(current + pageitem > maxpage - 1){ 102 navnext.attr("disabled","disabled").attr("tabindex","-1");; 103 }else{ 104 navnext.removeAttr("disabled").attr("tabindex","0");; 105 } 106 } 107 108 }, 300) 109 }) 110 111 function carouselplay() { 112 if (AnimeEnd) { 113 AnimeEnd = false; 114 if (o.loop) { 115 sbox.css({ 116 "transform": "translate3d(-" + (current * itemwidth + initpos) + "px, 0px, 0px)", 117 "transition-duration": o.speed + "ms" 118 }); 119 item.eq(current).addClass("active").siblings().removeClass("active"); 120 121 if (current < 0 || current > maxpage - 1) { 122 123 current = Math.abs(maxpage - Math.abs(current)); 124 125 setTimeout(function () { 126 sbox.css({ 127 "transition-duration": "0ms", 128 "transform": "translate3d(-" + (current * itemwidth + initpos) + "px, 0px, 0px)", 129 }).delay(50).queue(function () { 130 $(this).css({ 131 "transition-duration": o.speed + "ms" 132 }).dequeue(); 133 }) 134 item.eq(current).addClass("active").siblings().removeClass("active"); 135 136 }, o.speed + 50) 137 138 } 139 } else { 140 current = Math.max(Math.min(current, maxpage - pageitem), 0) 141 sbox.css({ 142 "transform": "translate3d(-" + (current * itemwidth + initpos) + "px, 0px, 0px)", 143 "transition-duration": o.speed + "ms" 144 }); 145 item.eq(current).addClass("active").siblings().removeClass("active"); 146 } 147 148 if (o.pagination) { 149 pagination.find(".pagination-bullet").eq(Math.round(current / pageitem)).addClass("active").siblings().removeClass("active"); 150 } 151 152 if (!o.loop && o.navigation) { 153 154 navprev.removeAttr("disabled").attr("tabindex","0"); 155 navnext.removeAttr("disabled").attr("tabindex","0"); 156 157 if(current == 0){ 158 navprev.attr("disabled","disabled").attr("tabindex","-1"); 159 }if(current + pageitem > maxpage - 1){ 160 navnext.attr("disabled","disabled").attr("tabindex","-1"); 161 } 162 163 } 164 165 setTimeout(function () { 166 AnimeEnd = true; 167 }, o.speed + 100); 168 } 169 } 170 171 172 if (o.autoplay) { 173 o.autoplay = Math.max(o.speed, o.autoplay); 174 175 var setIntervalplay = setInterval(function () { 176 current = current + 1; 177 carouselplay(); 178 }, o.autoplay); 179 d.on("mouseenter", function () { 180 clearInterval(setIntervalplay); 181 }).on("mouseleave", function () { 182 setIntervalplay = setInterval(function () { 183 current = current + 1; 184 carouselplay(); 185 }, o.autoplay); 186 }) 187 document.addEventListener("visibilitychange", function() { 188 if (document.hidden) { 189 clearInterval(setIntervalplay); 190 }else{ 191 setIntervalplay = setInterval(function () { 192 current = current + 1; 193 carouselplay(); 194 }, o.autoplay); 195 } 196 }); 197 } 198 if (o.pagination) { 199 var pagination = $('<div class="carousel-pagination"></div>') 200 for (var p = 0;
200 p < Math.ceil(maxpage / pageitem); p++) { 201 pagination.append('<span class="pagination-bullet" tabindex="0" role="button" aria-label="'+GlobalAriaLabel["Gotoslide"]+' ' + (p + 1) + '"></span>') 202 } 203 d.append(pagination); 204 205 pagination.find(".pagination-bullet").on("click", function () { 206 current = $(this).index() * pageitem; 207 carouselplay(); 208 }).on("mousemove",function(event){event.stopPropagation();}).eq(Math.round(current / pageitem)).addClass("active"); 209 } 210 211 212 213 if (o.navigation) { 214 var navprev = $('<div class="carousel-navigation carousel-prev" tabindex="0" role="button" aria-label="'+GlobalAriaLabel["Previousslide"]+'"><span></span></div>'); 215 var navnext = $('<div class="carousel-navigation carousel-next" tabindex="0" role="button" aria-label="'+GlobalAriaLabel["Nextslide"]+'"><span></span></div>'); 216 d.append(navprev); 217 d.append(navnext); 218 219 navprev.on("click", function () { 220 if (AnimeEnd) { 221 current = current - 1; 222 carouselplay(); 223 } 224 }).on("mousemove",function(event){event.stopPropagation();}); 225 navnext.on("click", function () { 226 if (AnimeEnd) { 227 current = current + 1; 228 carouselplay(); 229 } 230 }).on("mousemove",function(event){event.stopPropagation();}); 231 if (!o.loop) { 232 if(current == 0){ 233 navprev.attr("disabled","disabled").attr("tabindex","-1");; 234 }if(current + pageitem > maxpage - 1){ 235 navnext.attr("disabled","disabled").attr("tabindex","-1");; 236 } 237 } 238 239 240 } 241 if (o.mousewheel) { 242 if (typeof $.fn.newMouse == "undefined") { 243 $.fn.newMouse = function (options) { 244 var defaults = { 245 mousedown: function () {}, 246 mouseup: function () {}, 247 mousemove: function () {} 248 } 249 var o = $.extend(defaults, options); 250 var e = $(this); 251 e[0].addEventListener('touchstart', touch, false); 252 e[0].addEventListener('touchmove', touch, false); 253 e[0].addEventListener('touchend', touch, false); 254 e[0].addEventListener('mousedown', touch, false); 255 e[0].addEventListener('mouseup', touch, false); 256 e[0].addEventListener('mousemove', touch, false); 257 e[0].addEventListener('mouseleave', touch, false); 258 var isdown = false, 259 startX = 0, 260 startY = 0, 261 endX = 0, 262 endY = 0; 263 264 function touch(event) { 265 var event = event || window.event; 266 switch (event.type) { 267 case "touchstart": 268 case "mousedown": 269 events = event.type == "mousedown" ? event : event.touches[0]; 270 isdown = true; 271 o.mousedown(); 272 break; 273 case "touchend": 274 case "mouseup": 275 case "mouseleave": 276 if (isdown) { 277 events = event.type != "touchend" ? event : event.changedTouches[0]; 278 isdown = false; 279 o.mouseup(); 280 } 281 break; 282 case "touchmove": 283 case "mousemove": 284 if (isdown) { 285 event.preventDefault(); 286 events = event.type == "mousemove" ? event : event.touches[0]; 287 o.mousemove(); 288 } 289 break; 290 } 291 } 292 } 293 } 294 var translateX = 0; 295 var drop = 0; 296 var speedTime = false; 297 298 d.newMouse({ 299 mousedown: function () { 300 if (AnimeEnd) { 301 speedTime = new Date(); 302 startX = events.clientX; 303 startY = events.clientY; 304 sbox.css({ 305 "transition-duration": "0ms" 306 }); 307 translateX = -current * itemwidth - initpos; 308 drop = 0; 309 310 } 311 }, 312 mousemove: function () { 313 if (AnimeEnd && speedTime) { 314 drop = events.clientX - startX; 315 sbox.css({ 316 "transform": "translate3d(" + (translateX + drop) + "px, 0px, 0px)", 317 "transition-duration": "0ms" 318 }); 319 } 320 d.addClass("mousemove"); 321 }, 322 mouseup: function () { 323 if (AnimeEnd && drop && speedTime) { 324 speedTime = speedTime ? new Date() - speedTime : 300; 325 current = speedTime > 200 ? current - Math.round(drop / itemwidth) : drop < 0 ? current + pageitem : current - pageitem ; 326 327 sbox.css({ 328 "transition-duration": o.speed + "ms" 329 }); 330 drop = 0; 331 translateX = 0; 332 speedTime = false; 333 carouselplay(); 334 } 335 d.removeClass("mousemove"); 336 }, 337 }) 338 339 d.append('<span class="drag"></span>'); 340 341 } 342 343 d.find(".carousel-navigation,.pagination-bullet").on("keydown", function (event) { 344 var e = event || window.event || arguments.callee.caller.arguments[0]; 345 var keycode = e.keyCode; 346 if (keycode == 13) { 347 $(this).click(); 348 } 349 }) 350 351 var focusin = true; 352 353 sbox.on("focusin",function(){ 354 d.trigger("mouseenter"); 355 if(focusin){ 356 if(sbox.find(":focus").offset().left<0){ 357 item.eq(current).find("a").trigger("focus"); 358 } 359 focusin = false; 360 } 361 362 }).on("focusout",function(event){ 363 setTimeout(function(){ 364 if(!sbox.find(":focus").length){ 365 d.trigger("mouseleave"); 366 focusin = true; 367 } 368 },16) 369 }) 370 371 372 373 } 374})(jQuery); 375 376var easyCarouselLauncher = function (mod) { 377 mod.each(function () { 378 var e = $(this); 379 e.easyCarousel(); 380 }) 381} 382 383$(document).ready(function () { 384 easyCarouselLauncher($(".easy-carousel"));
385})
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.