1(function($, window, document, i, undefined) { 2 'use strict'; 3 var pluginName = "responsiveSlides", 4 dataKey = "plugin_" + pluginName; 5 var debounce = function(func, wait, immediate) { 6 var timeout; 7 var args; 8 return function() { 9 var context = this, 10 args = arguments; 11 var later = function() { 12 timeout = null; 13 if (!immediate) func.apply(context, args) 14 } 15 var callNow = immediate && !timeout; 16 clearTimeout(timeout); 17 timeout = setTimeout(func, wait || 200); 18 if (callNow) func.apply(context, args) 19 } 20 }; 21 var calculateAspectRatioFit = function(srcWidth, srcHeight, maxWidth, maxHeight) { 22 var ratio = Math.max(maxWidth / srcWidth, maxHeight / srcHeight); 23 return { 24 width: srcWidth * ratio, 25 height: srcHeight * ratio 26 } 27 } 28 var stripWhiteSpace = function(string) { 29 return string.replace(/\s/g, '') 30 }; 31 var Plugin = function(element, options) { 32 this.element = element; 33 this.slides = element.children(); 34 this.options = { 35 "timeout": 5000, 36 "speed": 500, 37 "nav": !0, 38 "navigation": !1, 39 "thumbnails": !1, 40 "pause": !0, 41 "random": !1, 42 "namespace": "callbacks", 43 "animation": "fadeOut", 44 "thumbnailSize": 60, 45 "maxHeight": 0, 46 "imageSize": "", 47 "carouselType": null, 48 "carouselWidth": 0 49 }; 50 this.init(options) 51 }; 52 Plugin.prototype = { 53 init: function(options) { 54 var options = $.extend(this.options, options), 55 model = new this.Model(this.element, this.slides, options), 56 view = new this.View(model, this.slides), 57 controller = new this.Controller(model, view); 58 return this 59 } 60 }; 61 Plugin.prototype.Model = function(element, slides, options) { 62 this.element = element; 63 this.slides = slides; 64 this.options = options; 65 this.length = slides.length; 66 this.width = element.width(); 67 this.parentWidth = element.parent().width(); 68 this.totalWidth = this.width * this.length; 69 this.index = 0; 70 this.images = this.slides.find("img"); 71 this.imagesLoaded = 0; 72 this.visible = { 73 "display": "block", 74 "float": "left", 75 "position": "relative", 76 "opacity": 1, 77 }; 78 this.hidden = { 79 "display": "block", 80 "float": "left", 81 "position": "absolute", 82 "opacity": 0 83 }; 84 this.fadeTime = parseFloat(this.options.speed), this.waitTime = parseFloat(this.options.timeout), this.animationType = "doCSSAnimation", this.thumbMargin = 0; 85 this.namespaceIdx = this.options.namespace + i; 86 this.visibleClass = this.namespaceIdx + "_on"; 87 this.visibleClassString = this.namespaceIdx + "_on " + this.options.namespace + "_visible"; 88 this.hiddenClassString = this.options.namespace + "_hidden"; 89 this.activeClass = this.options.namespace + "_here"; 90 this.slideClassPrefix = this.options.namespace + i + "_s"; 91 this.navClass = this.options.namespace + "_nav"; 92 this.navClassIdx = this.namespaceIdx + "_nav"; 93 this.loader = element.parent().prev(".loaderwrapper"); 94 this.navigation = $("<ul class='" + this.options.namespace + "_tabs " + this.namespaceIdx + "_tabs' />"); 95 //this.prevBtn = $("<span class='ion-ios-arrow-left " + this.navClassIdx + " " + this.navClass + " prev'></span>"); 96 //this.nextBtn = $("<span class='ion-ios-arrow-right " + this.navClassIdx + " " + this.navClass + " next'></span>"); 97 this.nextBtn = $('<span class="ion-ios-arrow-right callbacks_nav next" tabindex="0" role="button"><span class="sr-only">Next</span></span>'); 98 this.pauseBtn = $('<span class="ion-ios-pause callbacks_nav pause" tabindex="0" role="button"><span class="sr-only">
98Pause</span></span>'); 99 this.prevBtn = $('<span class="ion-ios-arrow-left callbacks_nav prev" tabindex="0" role="button"><span class="sr-only">Previous</span></span>'); 100 this.thumbnailContainer = $("<ul class='thumbnailcontainer'></ul>"); 101 this.thumbnailWrapper = $("<ul class='" + "thumbnailswrapper " + this.options.namespace + i + "_thumbnails'></ul>").css("height", this.options.thumbnailSize).appendTo(this.thumbnailContainer); 102 this.thumbnailNavLeft = $("<li class='thumbnailsroller thumbnailleft ion-chevron-left'></li>").appendTo(this.thumbnailContainer); 103 this.thumbnailNavRight = $("<li class='thumbnailsroller thumbnailright ion-chevron-right'></li>").appendTo(this.thumbnailContainer); 104 this.offsetLeft = element.offset().left; 105 this.offsetRight = element.offset().left + this.width; 106 this.slidesToShow = 0; 107 this.scrollAmount = 0; 108 this.hasCaption = element.parent().children().find(".ezcaption").length; 109 this.maxHeight = options.maxHeight > 0 ? options.maxHeight : parseFloat(element.css("maxHeight")); 110 this.thumbnailSize = parseFloat(this.options.thumbnailSize); 111 this.currentTabPosition = 0; 112 this.thumbsTotalWidth = parseFloat((this.thumbnailSize * this.length) + this.length); 113 this.thumbsPerSlide = parseFloat(Math.floor(this.element.width() / (this.thumbnailSize))); 114 this.built = !1, this.isReady = !1, this.animating = !1, this.touchable = !1, this.animating = !1, this.transitionSupport = !1; 115 this.thumbClicked = !1, this.thumbnailAnimating = !1, this.isCarousel = !1; 116 this.tabs, this.timer, this.lastScrollAmount, this.startInterval, this.buildInterval, this.thumbnailTimer = null, this.carouselData = {}; 117 return this 118 }; 119 Plugin.prototype.Model.prototype = { 120 indexData: function(idx) { 121 var data = { 122 right: idx + 1 < this.length ? idx + 1 : 0, 123 left: idx === 0 ? this.length - 1 : idx - 1 124 } 125 return data 126 }, 127 next: function() { 128 return this.index + 1 < this.length ? this.index + 1 : 0 129 }, 130 prev: function() { 131 return this.index === 0 ? this.length - 1 : this.index - 1 132 }, 133 getDirection: function(idx) { 134 if (this.index == this.length - 1 && idx == 0) { 135 return "right" 136 } else if (this.index == 0 && idx == this.length - 1) { 137 return "left" 138 } else if (this.index < idx) { 139 return "right" 140 } else if (this.index > idx) { 141 return "left" 142 } 143 }, 144 loadImages: function() { 145 ++this.imagesLoaded 146 }, 147 determineSlidesToShow: function() { 148 var src = this.slides.eq(0).find("img")[0].src; 149 var newImg = new Image(); 150 newImg.src = src; 151 this.carouselData.originalWidth = newImg.width; 152 this.carouselData.originalHeight = newImg.height; 153 this.carouselData.originalRatio = newImg.height / newImg.width; 154 this.carouselData.slidesToShow = Math.ceil(this.width / newImg.width); 155 this.carouselData.slideWidth = parseFloat(this.element.parent().width() / this.carouselData.slidesToShow).toFixed(3); 156 if (this.parentWidth <= newImg.width && this.options.carouselWidth >= this.parentWidth) { 157 this.element.addClass("ezcarousel-noeffect"); 158 this.options.carouselType = "normal"; 159 this.carouselData.slidesToShow = 1 160 } 161 if (this.options.carouselWidth) { 162 if (this.width <= this.options.carouselWidth) { 163 this.options.carouselWidth = this.width 164 } 165 this.carouselData.slideWidth = this.options.carouselWidth; 166 this.carouselData.slidesToShow = Math.ceil(this.width / this.options.carouselWidth) 167 } 168 if (this.options.carouselType == "center") { 169 if (this.options.carouselWidth) {
170 var ratio = newImg.height / newImg.width; 171 this.carouselData.centerWidth = this.options.carouselWidth * .8; 172 this.carouselData.centerHeight = (this.options.carouselWidth) * ratio; 173 this.carouselData.slideWidth = this.carouselData.centerWidth 174 } else { 175 this.carouselData.centerHeight = newImg.height * .8; 176 this.carouselData.centerWidth = newImg.width * .8; 177 this.carouselData.slideWidth = this.carouselData.centerWidth 178 } 179 this.carouselData.slidesToShow = Math.ceil(this.width / this.carouselData.centerWidth); 180 if (this.carouselData.slidesToShow % 2 == 0) { 181 this.carouselData.slidesToShow = this.carouselData.slidesToShow + 1 182 } 183 } 184 return { 185 width: newImg.width, 186 height: newImg.height 187 } 188 }, 189 setCarouselData: function() { 190 this.carouselData.elementWidth = this.carouselData.numberOfSlides * this.carouselData.slideWidth; 191 this.carouselData.startPoint = -(Math.ceil(this.carouselData.slidesToShow / 2) * this.carouselData.slideWidth).toFixed(3); 192 this.carouselData.endPoint = -(this.carouselData.elementWidth - (this.carouselData.slideWidth * (this.carouselData.slidesToShow + (Math.ceil(this.carouselData.slidesToShow / 2))))).toFixed(3); 193 this.carouselData.currentPoint = this.carouselData.startPoint; 194 this.carouselData.endSlide = this.length - 1; 195 this.carouselData.startSlide = 0; 196 if (this.options.carouselWidth > 0 || this.options.carouselType == "center") { 197 var elWidth = this.element.width(); 198 var widthToUse = this.options.carouselType == "center" ? this.carouselData.centerWidth : this.carouselData.slideWidth; 199 var offset = (elWidth - widthToUse) / 2 200 this.carouselData.startPoint = -(widthToUse * this.carouselData.slidesToShow) + offset; 201 this.carouselData.currentPoint = this.carouselData.startPoint; 202 this.carouselData.endPoint = this.carouselData.startPoint - (this.carouselData.slideWidth * (this.length - 1)) 203 } 204 this.carouselData.carouselSlides = this.element.find("li") 205 }, 206 supportsTouch: function() { 207 this.touchable = 'ontouchstart' in window || navigator.maxTouchPoints || window.DocumentTouch && document instanceof DocumentTouch || 'ontouchstart' in document.documentElement ? !0 : !1; 208 return this 209 }, 210 checkForCSSTransitions: function() { 211 var self = this; 212 var docBody = document.body || document.documentElement; 213 var styles = docBody.style; 214 var prop = "transition"; 215 if (typeof styles[prop] === "string") { 216 self.transitionSupport = !0; 217 return !0 218 } 219 vendor = ["Moz", "Webkit", "Khtml", "O", "ms"]; 220 prop = prop.charAt(0).toUpperCase() + prop.substr(1); 221 var i; 222 for (i = 0; i < vendor.length; i++) { 223 if (typeof styles[vendor[i] + prop] === "string") { 224 self.transitionSupport = !0; 225 return !0 226 } 227 } 228 self.animationType = "doJSAnimation"; 229 self.transitionSupport = !1; 230 return !1 231 }, 232 setCSSTransitions: function() { 233 var m = this; 234 var animation = m.options.animation; 235 if (m.transitionSupport) { 236 if (animation == "slideTop") { 237 m.visible = $.extend({}, { 238 "transform": "translateY(0%)", 239 "zIndex": 2 240 }, m.visible); 241 m.hidden = $.extend(m.hidden, { 242 "zIndex": 1, 243 "transform": "translateY(-100%)", 244 }, m.hidden) 245 } else if (animation == "slideLeft") { 246 m.visible = $.extend({}, { 247 "transform": "translateX(0%)", 248 "zIndex": 2 249 }, m.visible); 250 m.hidden = $.extend(m.hidden, { 251 "zIndex": 1, 252 "transform": "translateX(-100%)", 253 }, m.hidden) 254 } else { 255 m.visible = m.visible; 256 m.hidden = m.hidden 257 } 258 } else { 259 if (animation == "slideLeft") { 260 m.visibleLeft = 0; 261 m.hiddenLeft = -m.width 262 } else if (animation == "slideTop") { 263 m.visibleTop = 0; 264 m.hiddenTop = -m.maxHeight ? -m.maxHeight : -m.slides.height() 265 } else { 266 m.visibleOpacity = 1; 267 m.hiddenOpacity = 0 268 } 269 } 270 }, 271 } 272 Plugin.prototype.View = function(model, slides) { 273 this.model = model; 274 this.slides = slides; 275 return this 276 }; 277 Plugin.prototype.View.prototype = { 278 arrangeSlides: function() { 279 var m = this.model; 280 var cd = m.carouselData; 281 if (m.options.animation == "swipe" || m.options.carouselType !== null) { 282 m.visible = $.extend({}, { 283 "overflow": "hidden", 284 "transition": "none" 285 }, m.visible); 286 m.determineSlidesToShow(); 287 $(this.slides).css(m.visible); 288 this.addSlideData(); 289 this.buildInfiniteMode(-cd.slidesToShow, m.length); 290 cd.numberOfSlides = m.length + (cd.slidesToShow * 2); 291 m.setCarouselData(); 292 m.carouselData.clonedSlides = m.element.find("li.rs-clone"); 293 cd.clonedSlides.css("height", cd.centerHeight); 294 m.slides.css("height", cd.centerHeight); 295 this.carouselStructure(); 296 if (m.options.carouselType == "center") this.carouselCenter(); 297 m.isCarousel = !0 298 } else { 299 $(this.slides).css(m.hidden); 300 this.slides.eq(0).css(m.visible); 301 this.addAnimationClasses(0) 302 } 303 return this 304 }, 305 buildInfiniteMode: function(leftIndex, rightIndex) { 306 var self = this; 307 var m = this.model; 308 var cd = m.carouselData; 309 var leftClones = []; 310 var rightClones = []; 311 for (var i = 0; i < m.slides.length; i++) { 312 if (i < cd.slidesToShow) { 313 rightClones.push($(self.slides[i]).clone().attr("id", "").removeClass(m.visibleClass).addClass("rs-clone").attr("data-ez-index", r
313ightIndex)); 314 rightIndex++ 315 } 316 if (i > m.length - 1 - cd.slidesToShow) { 317 leftClones.push($(m.slides[i]).clone().attr("id", "").removeClass(m.visibleClass).addClass("rs-clone").attr("data-ez-index", leftIndex)); 318 leftIndex++ 319 } 320 } 321 m.element.prepend(leftClones); 322 m.element.append(rightClones) 323 }, 324 carouselCenter: function() { 325 var m = this.model; 326 var cd = m.carouselData; 327 m.element.css("height", m.options.maxHeight); 328 cd.clonedSlides.css("top", (m.options.maxHeight - cd.centerHeight) / 2); 329 m.slides.css("top", (m.options.maxHeight - cd.centerHeight) / 2) 330 }, 331 carouselStructure: function() { 332 var m = this.model; 333 var cd = m.carouselData; 334 var autoWidth = m.options.carouselWidth > 0 ? "ezcarousel-centerwidth" : ""; 335 m.element.addClass("ezcarousel ezcarousel-" + m.options.carouselType + " " + "ezcarousel-centerwidth"); 336 m.element.css({ 337 "width": cd.elementWidth, 338 "transition": "none" 339 }); 340 cd.carouselSlides.css("width", cd.slideWidth); 341 this.stretchAndFill(cd.slideWidth); 342 if (m.transitionSupport) { 343 m.element.css("transform", "translate(" + cd.startPoint + "px)") 344 } else { 345 m.element.css("left", cd.startPoint + "px") 346 } 347 }, 348 addNamespace: function() { 349 var self = this, 350 m = this.model, 351 o = this.model.options; 352 m.element.attr("id", m.namespaceIdx); 353 m.element.addClass(o.namespace, m.namespaceIdx); 354 this.slides.each(function(i) { 355 $(this).attr("id", m.namespaceIdx + "_s" + i) 356 }); 357 this.slides.eq(0).addClass(m.visibleClassString); 358 return this 359 }, 360 addSlideData: function() { 361 this.slides.each(function(i) { 362 $(this).attr("data-ez-index", i); 363 $(this).attr("data-ez-original", i) 364 }); 365 return this 366 }, 367 randomize: function() { 368 var m = this.model; 369 if (m.options.random === !0) { 370 this.slides.sort(function() { 371 return (Math.round(Math.random()) - 0.5) 372 }); 373 m.element.empty().append(this.slides) 374 } 375 return this 376 }, 377 setImageSize: function() { 378 var m = this.model; 379 if (m.options.imageSize == "actual") { 380 m.element.css("lineHeight", m.maxHeight + "px").addClass("actualsize"); 381 m.slides.addClass("actualsizeli").find("img").addClass("actualsizeimg") 382 } else if ((m.options.imageSize == "stretchfill" && m.maxHeight > 0)) { 383 this.stretchAndFill() 384 } 385 return this 386 }, 387 addTransitions: function(element, transitionProperty, time) { 388 var m = this.model; 389 var time = time || m.fadeTime; 390 if (m.transitionSupport) { 391 $(element).css({ 392 "-webkit-transition": transitionProperty + " " + time + "ms ease-in-out", 393 "-moz-transition": transitionProperty + " " + time + "ms ease-in-out", 394 "-o-transition": transitionProperty + " " + time + "ms ease-in-out", 395 "transition": transitionProperty + " " + time + "ms ease-in-out" 396 }) 397 } 398 return this 399 }, 400 stretchAndFill: function(width) { 401 var self = this; 402 var m = this.model; 403 var maxHeight = m.maxHeight || m.options.maxHeight || parseFloat(m.element.css("maxHeight")); 404 if (m.options.carouselType == "center") { 405 maxHeight = m.carouselData.centerHeight 406 } 407 $("#" + m.element.attr("id") + " li").find("img").each(function(i) { 408 $(this).css("minHeight", maxHeight); 409 var parent = $(this).closest("li"); 410 parent.css({ 411 "overflow": "hidden", 412 "opacity": 1 413 }); 414 $(this).addClass("stretchfill"); 415 var horizontalDiff = width ? $(this).width() - width : $(this).width() - parent.width(); 416 var verticalDiff = $(this).height() - parent.height(); 417 if (horizontalDiff <= 0 || verticalDiff <= 0) { 418 var imgClass = ($(this).width() / $(this).height() > 1) ? 'wide' : 'tall'; 419 $(this).removeClass("stretchfill"); 420 $(this).addClass(imgClass); 421 var imgHeight = $(this)[0].clientHeight; 422 var imgWidth = $(this)[0].clientWidth; 423 var parentWidth = width ? Math.ceil(width) : parent.width(); 424 var aspect = calculateAspectRatioFit(imgWidth, imgHeight, parentWidth, maxHeight); 425 var roundedHeight = Math.round(aspect.height); 426 var roundedWidth = Math.round(aspect.width); 427 $(this).css("height", roundedHeight + "px"); 428 $(this).css("width", roundedWidth + "px"); 429 verticalDiff = aspect.height - maxHeight; 430 horizontalDiff = aspect.width - parentWidth 431 } else { 432 if (m.options.carouselType == "center") { 433 $(this).css({ 434 "max-width": "100%", 435 }); 436 verticalDiff = 0; 437 horizontalDiff = 0 438 } 439 } 440 $(this).css("top", (-verticalDiff / 2)); 441 $(this).css("left", (-horizontalDiff / 2)) 442 }); 443 return this 444 }, 445 buildNavigation: function() { 446 var m = this.model; 447 m.element.after(m.prevBtn); 448 m.element.after(m.pauseBtn); 449 m.element.after(m.nextBtn); 450 if (m.options.thumbnails) { 451 m.prevBtn.css("top", "calc(50% - 60px)"); 452 m.nextBtn.css("top", "calc(50% - 60px)") 453 } 454 return this 455 }, 456 buildPager: function() { 457 var self = this; 458 var m = this.model; 459 var markup = []; 460 var distIncr = 0; 461 m.slides.each(function(i) { 462 var n = i + 1; 463 if (m.options.navigation) { 464 markup += "<li class='" + m.slideClassPrefix + (i + 1) + "'>" + "<a href='#' class='" + m.slideClassPrefix + n + "'>" + "<span class='pager-dot'></span>" + "</a>" + "</li>" 465 } 466 if (m.options.thumbnails) { 467 var image = $(m.slides[i]).find("img"); 468 var ratio = calculateAspectRatioFit($(image).width(), $(image).height(), m.thumbnailSize, m.thumbnailSize); 469 markup += "<li class='callbacks_thumbnails' style='left:" + distIncr + "px;
469 width:" + m.thumbnailSize + "px;height:" + m.thumbnailSize + "px'>" + "<a href='#' class='" + m.slideClassPrefix + n + "'>" + "<img style='height:" + Math.round(parseFloat(ratio.height)) + "px;width:" + Math.round(parseFloat(ratio.width)) + "px' src='" + $(this).find("img")[0].src + "' alt='" + $(this).find("img").attr("alt") + " - Thumbnail" + "'>" + "</a>" + "</li>" 470 } 471 distIncr += (m.options.thumbnailSize + m.thumbMargin) 472 }); 473 if (m.options.thumbnails) { 474 m.thumbnailWrapper.append(markup); 475 m.element.after(m.thumbnailContainer); 476 m.tabs = m.thumbnailWrapper.find('a'); 477 this.thumbnailContainerScroll(); 478 if (m.slides.length * m.thumbnailSize < m.thumbsPerSlide * m.thumbnailSize) { 479 m.thumbnailNavLeft.css("display", "none"); 480 m.thumbnailNavRight.css("display", "none") 481 } 482 } else if (m.options.navigation) { 483 if (m.hasCaption) { 484 m.navigation.addClass("hascaption") 485 } 486 m.navigation.append(markup); 487 m.element.after(m.navigation); 488 m.tabs = m.navigation.find('a') 489 } 490 return this 491 }, 492 formatCaptions: function() { 493 var self = this; 494 var m = this.model; 495 var captionWrapper, captionTitleLength, captionDescriptionLength; 496 m.slides.each(function(i) { 497 captionWrapper = $(this).find(".ezcaptionwrapper"); 498 captionTitleLength = stripWhiteSpace(captionWrapper.find(".ezcaptiontitle").text()).length; 499 captionDescriptionLength = stripWhiteSpace(captionWrapper.find(".ezcaption").text()).length; 500 if (captionTitleLength == 0 && captionDescriptionLength == 0) captionWrapper.hide() 501 }) 502 }, 503 setUpJsAnimations: function() { 504 var m = this.model; 505 if (!m.transitionSupport) { 506 if (m.options.animation != "carousel") { 507 if (m.options.animation == "slideLeft") m.slides.css("left", m.hiddenLeft).eq(0).css("left", m.visibleLeft); 508 else if (m.options.animation == "slideTop") m.slides.css("top", m.hiddenTop).eq(0).css("top", m.visibleTop); 509 else m.slides.css("opacity", m.hiddenOpacity).eq(0).css("opacity", m.visibleOpacity) 510 } 511 } 512 return this 513 }, 514 jsAnimations: function(index, idx) { 515 var m = this.model; 516 var animations = {}; 517 var slideAnimation = function(prop, amountIn, amountOut) { 518 var outAnim = { 519 opacity: 0 520 }; 521 var inAnim = { 522 opacity: 1 523 }; 524 outAnim[prop] = amountOut; 525 inAnim[prop] = amountIn; 526 m.slides.eq(index).animate(outAnim, m.fadeTime); 527 m.slides.eq(idx).animate(inAnim, m.fadeTime); 528 m.slides.each(function(i) { 529 if (i != index && i != idx) { 530 $(this).css(prop, amountOut) 531 } 532 }); 533 }; 534 animations.slideLeft = function() { 535 slideAnimation("left", 0, m.hiddenLeft) 536 } 537 animations.slideTop = function() { 538 slideAnimation("top", 0, m.hiddenTop) 539 } 540 animations.fadeOut = function() { 541 slideAnimation("opacity", 1, m.hiddenOpacity) 542 } 543 return animations 544 }, 545 removeLoader: function() { 546 var self = this; 547 var m = this.model; 548 m.loader.remove(); 549 m.element.closest('.delay .callbacks_container').css("opacity", 1); 550 m.element.closest('.ezrotatorwrapper').removeClass('delay') 551 }, 552 slideTo: function(idx) { 553 var self = this; 554 var m = this.model; 555 var indexData = m.indexData(idx); 556 var leftSlide = indexData.left; 557 var rightSlide = indexData.right; 558 if (m.options.thumbnails) { 559 this.thumbScrollTracker(idx) 560 } 561 if (!m.isCarousel) { 562 this[m.animationType](idx, leftSlide, rightSlide) 563 } 564 m.index = idx; 565 indexData = m.indexData(m.index); 566 m.currentLeftSlide = m.slides.eq(leftSlide); 567 m.currentRightSlide = m.slides.eq(rightSlide); 568 m.thumbClicked = !1; 569 }, 570 addAnimationClasses: function(idx) { 571 var m = this.model; 572 var indexData = m.indexData(idx); 573 m.slides.removeClass(m.visibleClassString).eq(idx).addClass(m.visibleClassString); 574 m.slides.removeClass(m.options.namespace + "_next").eq(indexData.right).addClass(m.options.namespace + "_next"); 575 m.slides.removeClass(m.options.namespace + "_prev").eq(indexData.left).addClass(m.options.namespace + "_prev") 576 }, 577 addClassToCopiedSlides: function(idx) { 578 var m = this.model; 579 var cd = m.carouselData; 580 cd.clonedSlides.each(function() { 581 if (parseInt($(this).attr("data-ez-original")) == idx) { 582 $(this).addClass(m.visibleClassString) 583 } else { 584 $(this).removeClass(m.visibleClassString) 585 } 586 }) 587 }, 588 doCSSAnimation: function(idx, left, right) { 589 var m = this.model; 590 this.addAnimationClasses(idx); 591 m.slides.css(m.hidden).eq(idx).css(m.visible) 592 }, 593 doJSAnimation: function(idx, left, right) { 594 var m = this.model; 595 var jsAnimations = this.jsAnimations(m.index, idx); 596 this.addAnimationClasses(idx); 597 jsAnimations[m.options.animation]() 598 }, 599 scrollCarousel: function(idx, direction) { 600 var m = this.model; 601 var cd = m.carouselData; 602 cd.currentPoint = parseFloat(cd.currentPoint); 603 if (m.animating == !1) { 604 this.addAnimationClasses(idx); 605 this.addClassToCopiedSlides(idx); 606 m.animating = !0; 607 if (direction == "+") { 608 cd.currentPoint -= parseFloat(cd.slideWidth);
609 if (idx === cd.startSlide) { 610 m.carouselEnd = !0 611 } 612 this.animateCarousel(idx, cd.currentPoint); 613 this.carouselTimer(idx, cd.endSlide, cd.startSlide) 614 } else { 615 cd.currentPoint += parseFloat(cd.slideWidth); 616 if (idx == cd.endSlide) { 617 m.carouselBegin = !0 618 } 619 this.animateCarousel(idx, cd.currentPoint); 620 this.carouselTimer(idx, cd.endSlide, cd.startSlide) 621 } 622 m.index = idx; 623 var indexData = m.indexData(m.index) 624 } else { 625 return !1 626 } 627 }, 628 animateCarousel: function(idx, amount) { 629 var m = this.model; 630 var transitionProperty = "translate3d(" + amount + "px,0,0)"; 631 if (!m.transitionSupport) { 632 transitionProperty = amount + "px"; 633 m.element.animate({ 634 "left": transitionProperty 635 }, m.fadeTime) 636 } else { 637 m.element.css({ 638 "transition": "all " + m.fadeTime + "ms ease-in-out", 639 "transform": transitionProperty 640 }) 641 } 642 }, 643 carouselReset: function(amount, resetVar) { 644 var m = this.model; 645 var cd = m.carouselData; 646 m[resetVar] = !1; 647 var transitionProperty = "translate3d(" + amount + "px,0,0)"; 648 if (!m.transitionSupport) { 649 transitionProperty = amount + "px"; 650 m.element.css({ 651 "left": transitionProperty 652 }) 653 } else { 654 m.element.css({ 655 "transition": "none", 656 "transform": transitionProperty 657 }) 658 } 659 cd.currentPoint = amount 660 }, 661 carouselTimer: function(idx, startIndex, endIndex) { 662 var self = this; 663 var m = this.model; 664 var cd = m.carouselData; 665 var animatingTimer = setTimeout(function() { 666 if (m.carouselEnd) { 667 self.carouselReset(cd.startPoint, "carouselEnd") 668 } else if (m.carouselBegin) { 669 self.carouselReset(cd.endPoint, "carouselBegin") 670 } 671 m.animating = !1; 672 clearTimeout(animatingTimer) 673 }, m.fadeTime + 100) 674 }, 675 selectTab: function(idx) { 676 var m = this.model; 677 m.tabs.closest("li").removeClass(m.activeClass).eq(idx).addClass(m.activeClass); 678 return this 679 }, 680 thumbScrollTracker: function(idx) { 681 var m = this.model; 682 if (m.length >= m.thumbsPerSlide) { 683 m.currentTabPosition = $(m.tabs[idx]).offset().left + $(m.tabs[idx]).width(); 684 if (m.currentTabPosition >= m.offsetRight && m.currentTabPosition <= m.offsetRight + m.thumbnailSize) { 685 this.scrollThumbnails(500, "+") 686 } else if (m.index > idx && idx != 0 && m.index != m.length - 1) { 687 if (m.currentTabPosition <= m.offsetLeft && m.currentTabPosition >= m.offsetLeft - m.thumbnailSize) { 688 this.scrollThumbnails(500, "-") 689 } 690 } else if (m.index == m.length - 1 && idx == 0 && !m.thumbClicked) { 691 this.scrollThumbnails(500, "+") 692 } else if (m.index == 0 && idx == m.length - 1 && !m.thumbClicked) { 693 this.scrollThumbnails(500, "-") 694 } 695 } 696 }, 697 thumbnailContainerScroll: function() { 698 var m = this.model; 699 var currentLeft = m.thumbnailWrapper.position().left; 700 m.scrollAmount = parseFloat($(m.tabs[Math.round(m.thumbsPerSlide / 2)]).parent().css("left")); 701 m.lastScrollAmount = m.thumbsTotalWidth + m.length - m.slides.width(); 702 var atEnd = 0;
703 this.scrollThumbnails = function(speed, direction) { 704 if (direction == "+") { 705 currentLeft -= m.scrollAmount; 706 if (Math.abs(currentLeft) > m.lastScrollAmount) { 707 currentLeft = currentLeft + m.scrollAmount; 708 var difference = currentLeft + m.lastScrollAmount; 709 currentLeft -= difference 710 } 711 if (Math.abs(currentLeft) == m.lastScrollAmount) { 712 if (atEnd == 1) { 713 currentLeft = 0; 714 atEnd = 0 715 } else atEnd += 1 716 } 717 if (m.transitionSupport) { 718 m.thumbnailWrapper.css({ 719 transform: "translateX(" + currentLeft + "px)", 720 transition: "all " + speed + "ms ease" 721 }) 722 } else { 723 m.thumbnailWrapper.animate({ 724 "left": currentLeft + "px" 725 }, speed) 726 } 727 } 728 if (direction == "-") { 729 if (currentLeft == 0) { 730 currentLeft -= m.lastScrollAmount; 731 atEnd = 1 732 } else currentLeft += m.scrollAmount; 733 if (currentLeft > 0) currentLeft = 0; 734 if (m.transitionSupport) { 735 m.thumbnailWrapper.css({ 736 transform: "translateX(" + currentLeft + "px)", 737 transition: "all " + speed + "ms ease" 738 }) 739 } else { 740 m.thumbnailWrapper.animate({ 741 "left": currentLeft + "px" 742 }, speed) 743 } 744 } 745 } 746 }, 747 enableSwipe: function() { 748 var self = this; 749 var m = this.model; 750 if (m.touchable) { 751 var x = 0, 752 minXMove = 30, 753 xMove = 0, 754 xDiff = 0, 755 isMoving = !1; 756 this.handleTouchStart = function(evt) { 757 isMoving = !0; 758 x = evt.originalEvent.touches[0].clientX 759 }; 760 this.handleTouchMove = function(evt) { 761 if (isMoving) { 762 xMove = evt.originalEvent.touches[0].clientX; 763 xDiff = x - xMove 764 } 765 }; 766 this.handleTouchEnd = function(evt, leftFunction, rightFunction) { 767 isMoving = !1; 768 if (Math.abs(xDiff) >= minXMove) { 769 if (xDiff > 0) { 770 leftFunction() 771 } else { 772 rightFunction() 773 } 774 } 775 xMove = null; 776 xDiff = null 777 } 778 } 779 } 780 } 781 Plugin.prototype.Controller = function(model, view) { 782 var self = this; 783 this.model = model; 784 this.view = view; 785 model.element.css("maxHeight", model.maxHeight); 786 model.checkForCSSTransitions(); 787 model.images.each(function() { 788 var image = $(this)[0]; 789 var interval = setInterval(function() { 790 if (image.complete) { 791 clearInterval(interval); 792 self.model.imagesLoaded++ 793 } 794 }, 300); 795 }); 796 this.waitForImagesToLoad(); 797 return this 798 }; 799 Plugin.prototype.Controller.prototype = { 800 waitForImagesToLoad: function() { 801 var self = this; 802 var m = this.model; 803 var v = this.view; 804 if ($(window).width() <= 700) {} 805 m.startInterval = setInterval(function() { 806 if (m.imagesLoaded == m.length) { 807 clearInterval(m.startInterval); 808 v.setImageSize(); 809 v.formatCaptions(); 810 m.setCSSTransitions(); 811 m.supportsTouch(); 812 v.randomize().addNamespace().arrangeSlides().buildNavigation().buildPager(); 813 v.setUpJsAnimations(); 814 m.built = !0; 815 self.waitToFinishBuild() 816 } 817 }, 200) 818 }, 819 waitToFinishBuild: function() { 820 var self = this; 821 var m = this.model; 822 m.buildInterval = setInterval(function() { 823 if (self.model.built) { 824 clearInterval(m.buildInterval); 825 self.view.addTransitions(self.model.slides, "all").removeLoader(); 826 if (self.model.options.carouselType || self.model.options.animation == "swipe") { 827 self.view.addTransitions(self.model.element, "all") 828 }; 829 self.view.enableSwipe(); 830 self.bindUIActions(); 831 self.model.isReady = !0 832 } 833 }, 200) 834 }, 835 bindUIActions: function() { 836 var self = this; 837 var m = this.model; 838 var v = this.view; 839 if (m.options.thumbnails || m.options.navigation) { 840 this.model.tabs.on("click", function(e) { 841 e.preventDefault(); 842 self.navigationClick(this, e) 843 }).eq(0).closest("li").addClass(m.activeClass) 844 } 845 if (m.options.auto) { 846 this.startCycle() 847 } 848 $(m.prevBtn).on("click", function(e) { 849 e.preventDefault(); 850 self._previous(); 851 }); 852 $(m.nextBtn).on("click", function(e) { 853 e.preventDefault(e); 854 self._next(); 855 }); 856 857 $(m.pauseBtn).on("click", function(){ 858 if(m.options.auto){ 859 $(this).removeClass('ion-ios-pause'); 860 $(this).addClass('ion-ios-play'); 861 $(this).find('.sr-only').html("Play"); 862 $("#sr-notification").html( "carousel paused" ); 863 } else { 864 $(this).removeClass('ion-ios-play'); 865 $(this).addClass('ion-ios-pause'); 866 $(this).find('.sr-only').html("Pause"); 867 $("#sr-notification").html( "carousel played" ); 868 } 869 m.options.auto = !m.options.auto 870 }); 871 872 // when enter or arrow keys is pressed 873 $(m.nextBtn).on("keyup", function(e){ 874 if (e.which == 13) { 875 self._next(); 876 //clearTimeout(that.interval); 877 } 878 if (e.which == 37) { 879 m.pauseBtn.focus(); 880 } 881 }); 882 $(m.pauseBtn).on("keyup", function(e){ 883 if (e.which == 13) { 884 if(m.options.auto){ 885 $(this).removeClass('ion-ios-pause'); 886 $(this).addClass('ion-ios-play'); 887 $(this).find('.sr-only').html("Play"); 888 clearInterval(m.timer); 889 $("#sr-notification").html( "carousel paused" ); 890 } else { 891 $(this).removeClass('ion-ios-play'); 892 $(this).addClass('ion-ios-pause'); 893 $(this).find('.sr-only').html("Pause"); 894 self.startCycle(); 895 $("#sr-notification").html( "carousel played" ); 896 } 897 m.options.auto = !m.options.auto 898 } 899 if (e.which == 37) { 900 m.prevBtn.focus(); 901 } 902 if (e.which == 39) { 903 m.nextBtn.focus(); 904 } 905 }); 906 $(m.prevBtn).on("keyup", function(e){ 907 if (e.which == 13) { 908 self._previous(); 909 //clearTimeout(that.interval); 910 } 911 if (e.which == 39) { 912 that.pauseBtn.focus(); 913 } 914 }); 915 916 m.thumbnailNavLeft.on("click", function(e) { 917 e.preventDefault();
918 v.scrollThumbnails(500, "-") 919 }); 920 m.thumbnailNavRight.on("click", function(e) { 921 e.preventDefault(); 922 v.scrollThumbnails(500, "+") 923 }); 924 $(m.slides).on("touchstart", function(e) { 925 v.handleTouchStart(e) 926 }); 927 $(m.slides).on("touchmove", function(e) { 928 v.handleTouchMove(e) 929 }); 930 $(m.slides).on("touchend", function(e) { 931 v.handleTouchEnd(e, function() { 932 return self._next() 933 }, function() { 934 return self._previous() 935 }) 936 }); 937 $(m.thumbnailWrapper).on("touchstart", function(e) { 938 v.handleTouchStart(e) 939 }); 940 $(m.thumbnailWrapper).on("touchmove", function(e) { 941 v.handleTouchMove(e) 942 }); 943 $(m.thumbnailWrapper).on("touchend", function(e) { 944 v.handleTouchEnd(e, function() { 945 return v.scrollThumbnails(500, "+") 946 }, function() { 947 return v.scrollThumbnails(500, "-") 948 }) 949 }); 950 this.initPauseOnHover(); 951 return this 952 }, 953 _previous: function() { 954 var self = this; 955 var m = this.model; 956 var v = this.view; 957 var idx = m.prev(); 958 if (m.options.navigation || m.options.thumbnails) { 959 v.selectTab(idx) 960 } 961 if (m.isCarousel) { 962 v.scrollCarousel(idx, "-") 963 } else { 964 v.slideTo(idx) 965 } 966 this.restartCycle(); 967 m.thumbClicked = !1 968 $("#sr-notification").html( $(v.slides[idx]).find("img").attr('alt') ); 969 }, 970 _next: function() { 971 var self = this; 972 var m = this.model; 973 var v = this.view; 974 var idx = m.next(); 975 if (m.options.navigation || m.options.thumbnails) { 976 v.selectTab(idx) 977 } 978 if (m.isCarousel) { 979 v.scrollCarousel(idx, "+") 980 } else { 981 v.slideTo(idx) 982 } 983 this.restartCycle(); 984 m.thumbClicked = !1; 985 $("#sr-notification").html( $(v.slides[idx]).find("img").attr('alt') ); 986 }, 987 navigationClick: function(element, event) { 988 event.preventDefault(); 989 var self = this; 990 var m = this.model; 991 var v = this.view; 992 var currentTabIdx = $(m.tabs).index(element); 993 var idx = m.indexData(currentTabIdx).next; 994 if (m.index === currentTabIdx || $("." + m.visibleClass).queue('fx').length) { 995 return 996 } 997 m.thumbClicked = !0; 998 v.selectTab(currentTabIdx); 999 v.slideTo(currentTabIdx); 1000 this.restartCycle() 1001 }, 1002 initPauseOnHover: function() { 1003 var m = this.model; 1004 var self = this; 1005 if (m.options.pause) { 1006 m.element.hover(function() { 1007 clearInterval(m.timer) 1008 }, function() { 1009 self.restartCycle() 1010 }) 1011 } 1012 }, 1013 startCycle: function() { 1014 var self = this; 1015 var m = this.model; 1016 var v = this.view; 1017 m.timer = setInterval(function() { 1018 m.slides.stop(!0, !0); 1019 var idx = m.next(); 1020 if (m.options.navigation || m.options.thumbnails) { 1021 v.selectTab(idx) 1022 } 1023 if (m.isCarousel) { 1024 v.scrollCarousel(idx, "+") 1025 } else { 1026 v.slideTo(idx) 1027 } 1028 // $("#sr-notification").html( $(v.slides[idx]).find("img").attr('alt') ); 1029 }, m.waitTime) 1030 }, 1031 restartCycle: function() { 1032 var self = this; 1033 var m = this.model; 1034 if (m.options.auto || m.options.thumbnails || m.options.navigation) { 1035 clearInterval(m.timer); 1036 this.startCycle() 1037 } 1038 }, 1039 } 1040 $.fn[pluginName] = function(options) { 1041 var plugin = this.data(dataKey); 1042 if (plugin instanceof Plugin) { 1043 if (typeof options !== 'undefined') { 1044 plugin.init(options) 1045 } 1046 } else { 1047 i++; 1048 plugin = new Plugin(this, options); 1049 this.data(dataKey, plugin) 1050 } 1051 return plugin 1052 } 1053}(jQuery, window, document, 0)); 1054(function($, window, document, i, undefined) { 1055 "use strict"; 1056 var pluginName = "ezSlideshow", 1057 defaults = { 1058 speed: 500, 1059 namespace: "callbacks" 1060 }, 1061 animationType = "doCSSAnimation", 1062 transitionSupport = !0, 1063 calculateAspectRatioFit = function(srcWidth, srcHeight, maxWidth, maxHeight) { 1064 var ratio = Math.max(maxWidth / srcWidth, maxHeight / srcHeight); 1065 return { 1066 width: srcWidth * ratio, 1067 height: srcHeight * ratio 1068 } 1069 },
1070 stripWhiteSpace = function(string) { 1071 return string.replace(/\s/g, '') 1072 }, 1073 debounce = function(func, wait, immediate) { 1074 var timeout; 1075 var args; 1076 return function() { 1077 var context = this, 1078 args = arguments; 1079 var later = function() { 1080 timeout = null; 1081 if (!immediate) func.apply(context, args) 1082 } 1083 var callNow = immediate && !timeout; 1084 clearTimeout(timeout); 1085 timeout = setTimeout(func, wait || 200); 1086 if (callNow) func.apply(context, args) 1087 } 1088 }; 1089 (function() { 1090 var docBody = document.body || document.documentElement; 1091 var styles = docBody.style; 1092 var prop = "transition"; 1093 if (typeof styles[prop] === "string") { 1094 transitionSupport = !0; 1095 return !0 1096 } 1097 vendor = ["Moz", "Webkit", "Khtml", "O", "ms"]; 1098 prop = prop.charAt(0).toUpperCase() + prop.substr(1); 1099 var i; 1100 for (i = 0; i < vendor.length; i++) { 1101 if (typeof styles[vendor[i] + prop] === "string") { 1102 transitionSupport = !0; 1103 return !0 1104 } 1105 } 1106 animationType = "doJSAnimation"; 1107 transitionSupport = !1; 1108 return !1 1109 })(); 1110 1111 function Plugin(element, options) { 1112 this.element = element; 1113 this.$element = $(element); 1114 this.wrapper = this.$element.parent().parent(); 1115 this.loader = this.wrapper.find(".loaderwrapper"); 1116 this.options = $.extend({}, defaults, options); 1117 this._defaults = defaults; 1118 this._name = pluginName; 1119 this.namespaceIdx = this.options.namespace + i; 1120 this.slideClassPrefix = this.options.namespace + i + "_s"; 1121 this.animationType = "doCSSAnimation"; 1122 this.transitionSupport = transitionSupport; 1123 this.slides = this.$element.find("li"); 1124 this.links = this.$element.find("a"); 1125 this.length = this.slides.length; 1126 this.width = this.$element.width(); 1127 this.busy = !1; 1128 this.index = 0; 1129 this.imagesLoaded = 0; 1130 this.fadeTime = this.options.speed; 1131 this.i = i; 1132 this.interval = null; 1133 this.thumbnailSize = 60; 1134 this.thumbMargin = 0; 1135 this.currentTabPosition = 0; 1136 this.offsetLeft = this.$element.offset().left; 1137 this.offsetRight = this.$element.offset().left + this.width; 1138 this.thumbsTotalWidth = parseFloat((this.thumbnailSize * this.length) + this.length); 1139 this.thumbsPerSlide = parseFloat(Math.floor(this.width / (this.thumbnailSize))); 1140 this.thumbnailWrapperTranslate = 0; 1141 this.thumbClicked = !1; 1142 this.scrollAmount = 0; 1143 this.hasCaption = this.$element.parent().children().find(".ezcaptionwrapper").length; 1144 this.init() 1145 } 1146 $.extend(Plugin.prototype, { 1147 init: function() { 1148 var self = this; 1149 this.prepareForLoad(); 1150 this.randomize(); 1151 this.buildNavigation(); 1152 this.buildPager(); 1153 this.hideEmptyCaptions(); 1154 this.pauseOnHover(); 1155 if (this.options.maxHeight == 0) this.$element.css("maxHeight", "none"); 1156 for (var i = 0; i < this.links.length; i++) { 1157 var link = $(this.links[i]).addClass("imageWrapper"); 1158 var url = link.attr("href"); 1159 var target = link.attr("target") || ""; 1160 link.replaceWith("<span class='imageWrapper' data-href='" + url + "' data-target='" + target + "'></span>") 1161 } 1162 if (this.options.thumbnails) { 1163 this.loader.css("display", "block"); 1164 this.loadAllImages((function() { 1165 self.loader.css("display", "none"); 1166 self.wrapper.find(".loaderwrapper").remove(); 1167 self.$element.css("opacity", 1); 1168 self[self.animationType](self.slides.eq(0)) 1169 self.buildThumbnails(); 1170 self.addTransition(self.slides, "all"); 1171 self.startCycle(); 1172 self.wrapper.removeClass("delay") 1173 })) 1174 } else { 1175 this.wrapper.removeClass("delay"); 1176 this.lazyLoadImage(this.slides[0], function(slide) { 1177 self.afterImageLazyLoaded(slide); 1178 if (self.options.imageSize != "stretchfill") { 1179 self.$element.css({ 1180 height: "auto" 1181 }) 1182 } 1183 setTimeout(function() { 1184 self.addTransition(self.slides, "all") 1185 }, 200) 1186 }); 1187 this.startCycle() 1188 } 1189 }, 1190 prepareForLoad: function() { 1191 this.$element.css({ 1192 maxHeight: this.options.maxHeight, 1193 height: this.options.maxHeight 1194 }).addClass(this.options.namespace); 1195 //this.slides.find("a").attr("aria-label", "hidden") 1196 }, 1197 lazyLoadImage: function(slide, callback) { 1198 var self = this; 1199 this.busy = !0; 1200 this.loader.css("display", "block"); 1201 var self = this; 1202 var src = $(slide).attr("data-lazy"); 1203 var alt = $(slide).attr("data-alt"); 1204 $(slide).removeAttr("data-lazy").removeAttr("data-alt"); 1205 var imageWrapper = $(slide).find(".imageWrapper"); 1206 if (imageWrapper.attr("data-href") != "javascript:void(0)") { 1207 imageWrapper.replaceWith("<a href='" + imageWrapper.attr("data-href") + "' target='" + imageWrapper.attr("data-target") + "' class='imageWrapper'></a>"); 1208 } 1209 var image = new Image(); 1210 image.onload = function() { 1211 $(slide).find(".imageWrapper").append(image); 1212 if (callback && typeof callback === "function") callback.call(self, slide); 1213 self.busy = !1; 1214 self.loader.css("display", "none") 1215 } 1216 image.onerror = function() { 1217 if (callback && typeof callback === "function") callback.call(self, slide); 1218 self.busy = !1; 1219 self.loader.css("display", "none") 1220 } 1221 image.src = src; 1222 if (alt) { 1223 image.alt = alt; 1224 } else { 1225 image.alt = ""; 1226 } 1227 var newImageWrapper = $(slide).find(".imageWrapper"); 1228 var title = $(slide).find(".ezcaptiontitle").attr('id'); 1229 var caption = $(slide).find(".ezcaption").attr('id'); 1230 1231 // ADA screen reader additions 1232 if(newImageWrapper.attr('target') !== ""){ 1233 // newImageWrapper.append("<span class='sr-only'>Opens new window</span>"); 1234 newImageWrapper.attr('aria-describedby',title + ' ' + caption); 1235 } 1236 }, 1237 loadAllImages: function(callback) { 1238 var self = this;
1239 this.loader = $('<div class="loaderwrapper ezloaderwrapper"><div class="ezloaderbkg"><div class="ezCSSloader"></div></div></div>'); 1240 this.imagesLoadedInterval = setInterval(function() { 1241 if (self.length == self.imagesLoaded) { 1242 if (callback && typeof callback === "function") callback(); 1243 clearInterval(self.imagesLoadedInterval) 1244 } 1245 }, 300); 1246 this.$element.css("opacity", 0); 1247 this.slides.each(function(i) { 1248 var slide = $(this); 1249 var src = slide.attr("data-lazy"); 1250 var alt = slide.attr("data-alt"); 1251 $(slide).removeAttr("data-lazy").removeAttr("data-alt"); 1252 var imageWrapper = $(slide).find(".imageWrapper"); 1253 if (imageWrapper.attr("data-href") != "javascript:void(0)") { 1254 imageWrapper.replaceWith("<a href='" + imageWrapper.attr("data-href") + "' target='" + imageWrapper.attr("data-target") + "' class='imageWrapper'></a>"); 1255 } 1256 var image = new Image(); 1257 image.onload = function() { 1258 slide.find(".imageWrapper").append(image); 1259 if (self.options.imageSize == "actual") self.makeImageActualSize(slide); 1260 if (self.options.imageSize == "stretchfill") self.stretchAndFillImage(slide); 1261 self.imagesLoaded++ 1262 } 1263 image.src = src; 1264 if (alt) { 1265 image.alt = alt; 1266 } else { 1267 image.alt = ""; 1268 } 1269 }) 1270 }, 1271 afterImageLazyLoaded: function(slide) { 1272 if (this.options.imageSize == "actual") this.makeImageActualSize(slide); 1273 if (this.options.imageSize == "stretchfill") this.stretchAndFillImage(slide); 1274 this[this.animationType](slide) 1275 }, 1276 slideTo: function(slide, index) { 1277 if (this.options.thumbnails) { 1278 this.thumbScrollTracker(index) 1279 } 1280 this.index = parseInt(index); 1281 if (slide.attr("data-lazy")) { 1282 this.lazyLoadImage(slide, this.afterImageLazyLoaded) 1283 } else { 1284 this[this.animationType](slide) 1285 } 1286 this.thumbClicked = !1 1287 /* 1288 if( slide.find("img").attr("alt") ) { 1289 $("#sr-notification").html( slide.find("img").attr("alt") ); 1290 } 1291 */ 1292 }, 1293 updateNavigation: function() { 1294 if (this.options.navigation) { 1295 this.goToPager(this.index, !0) 1296 } 1297 if (this.options.thumbnails) { 1298 this.goToThumbnail(this.index, !0) 1299 } 1300 }, 1301 doCSSAnimation: function(slide) { 1302 $(this.slides).removeClass("active ezsVisible").addClass("ezsHidden ez" + this.options.animation); 1303 $(slide).addClass("active ezsVisible ez" + this.options.animation).removeClass("ezsHidden") 1304 }, 1305 doJSAnimation: function(slide) { 1306 console.log(slide) 1307 }, 1308 addTransition: function(element, transitionProperty, time, easing) { 1309 var time = time || this.fadeTime; 1310 var easing = easing || "ease-in-out"; 1311 if (this.transitionSupport) { 1312 $(element).css({ 1313 "-webkit-transition": transitionProperty + " " + time + "ms " + easing, 1314 "-moz-transition": transitionProperty + " " + time + "ms " + easing, 1315 "-o-transition": transitionProperty + " " + time + "ms " + easing, 1316 "transition": transitionProperty + " " + time + "ms " + easing 1317 }) 1318 } 1319 return this 1320 }, 1321 buildNavigation: function() { 1322 var that = this; 1323 this.prevBtn = $('<span class="ion-ios-arrow-left callbacks_nav prev" tabindex="0" role="button"><span class="sr-only">Previous</span></span>'); 1324 this.pauseBtn = $('<span class="ion-ios-pause callbacks_nav pause" tabindex="0" role="button"><span class="sr-only">
1324Pause</span></span>'); 1325 this.nextBtn = $('<span class="ion-ios-arrow-right callbacks_nav next" tabindex="0" role="button"><span class="sr-only">Next</span></span>'); 1326 this.$element.append(this.prevBtn).append(this.pauseBtn).append(this.nextBtn); 1327 this.nextBtn.on("click", this.goToNextSlide.bind(this)); 1328 this.pauseBtn.on("click", function(){ 1329 if(that.options.auto){ 1330 $(this).removeClass('ion-ios-pause'); 1331 $(this).addClass('ion-ios-play'); 1332 $(this).find('.sr-only').html("Play"); 1333 $("#sr-notification").html( "gallery paused" ); 1334 } else { 1335 $(this).removeClass('ion-ios-play'); 1336 $(this).addClass('ion-ios-pause'); 1337 $(this).find('.sr-only').html("Pause"); 1338 $("#sr-notification").html( "gallery played" ); 1339 } 1340 that.options.auto = !that.options.auto 1341 }); 1342 this.prevBtn.on("click", this.goToPrevSlide.bind(this)); 1343 1344 // when image link is focused 1345 /* 1346 $(this.slides).on('focusin', function(e){ 1347 clearTimeout(that.interval); 1348 }); 1349 */ 1350 1351 // when enter or arrow keys is pressed 1352 this.nextBtn.on("keyup", function(e){ 1353 if (e.which == 13) { 1354 that.goToNextSlide(); 1355 //clearTimeout(that.interval); 1356 } 1357 if (e.which == 37) { 1358 that.pauseBtn.focus(); 1359 } 1360 }); 1361 this.pauseBtn.on("keyup", function(e){ 1362 if (e.which == 13) { 1363 if(that.options.auto){ 1364 $(this).removeClass('ion-ios-pause'); 1365 $(this).addClass('ion-ios-play'); 1366 $(this).find('.sr-only').html("Play"); 1367 clearTimeout(that.interval); 1368 $("#sr-notification").html( "gallery paused" ); 1369 1370 } else { 1371 $(this).removeClass('ion-ios-play'); 1372 $(this).addClass('ion-ios-pause'); 1373 $(this).find('.sr-only').html("Pause"); 1374 setTimeout(function(){ 1375 that.restartCycle(); 1376 }, 0); 1377 $("#sr-notification").html( "gallery played" ); 1378 } 1379 that.options.auto = !that.options.auto 1380 } 1381 if (e.which == 37) { 1382 that.prevBtn.focus(); 1383 } 1384 if (e.which == 39) { 1385 that.nextBtn.focus(); 1386 } 1387 }); 1388 this.prevBtn.on("keyup", function(e){ 1389 if (e.which == 13) { 1390 that.goToPrevSlide(); 1391 //clearTimeout(that.interval); 1392 } 1393 if (e.which == 39) { 1394 that.pauseBtn.focus(); 1395 } 1396 }); 1397 1398 /* 1399 this.nextBtn.on('focusin', function(){ 1400 clearTimeout(that.interval); 1401 }); 1402 1403 this.nextBtn.on('focusout', function(){ 1404 that.restartCycle(); 1405 }); 1406 1407 this.pauseBtn.on('focusin', function(){ 1408 clearTimeout(that.interval); 1409 }); 1410 1411 this.pauseBtn.on('focusout', function(){ 1412 that.restartCycle(); 1413 }); 1414 1415 this.prevBtn.on('focusin', function(){ 1416 clearTimeout(that.interval); 1417 }); 1418 1419 this.prevBtn.on('focusout', function(){ 1420 that.restartCycle(); 1421 }); 1422 */ 1423 }, 1424 buildPager: function() { 1425 if (this.options.navigation) { 1426 var self = this; 1427 var markup = []; 1428 this.navigation = $("<ul class='" + this.options.namespace + "_tabs " + this.namespaceIdx + "_tabs' />"); 1429 this.slides.each(function(i) { 1430 var n = i + 1; 1431 markup += "<li class='" + self.slideClassPrefix + (i + 1) + "'>" + "<span class='" + self.slideClassPrefix + n + "' aria-label='hidden' data-index='" + (n - 1) + "'>" + "<span class='pager-dot'></span>" + "</span>" + "</li>" 1432 }); 1433 this.navigation.append(markup); 1434 this.navigation.find("li").eq(0).find("span > span").addClass("pager-active"); 1435 this.$element.after(this.navigation); 1436 this.bindPagerClick(); 1437 if (this.hasCaption) { 1438 this.navigation.addClass("hascaption") 1439 } 1440 } 1441 }, 1442 buildThumbnails: function() { 1443 if (this.options.thumbnails) { 1444 var distIncr = 0; 1445 var markup = []; 1446 var self = this; 1447 this.thumbnailContainer = $("<ul class='thumbnailcontainer'></ul>"); 1448 this.thumbnailWrapper = $("<ul class='" + "thumbnailswrapper " + this.options.namespace + i + "_thumbnails'></ul>").css("height", this.thumbnailSize).appendTo(this.thumbnailContainer); 1449 this.thumbnailNavLeft = $("<li class='thumbnailsroller thumbnailleft ion-chevron-left'></li>").appendTo(this.thumbnailContainer); 1450 this.thumbnailNavRight = $("<li class='thumbnailsroller thumbnailright ion-chevron-right'></li>").appendTo(this.thumbnailContainer); 1451 this.slides.each(function(i) { 1452 var n = i + 1; 1453 var image = $(this).find("img"); 1454 var ratio = calculateAspectRatioFit($(image).width(), $(image).height(), self.thumbnailSize, self.thumbnailSize); 1455 markup += "<li class='callbacks_thumbnails' style='left:" + distIncr + "px;
1455 width:" + self.thumbnailSize + "px;height:" + self.thumbnailSize + "px'>" + "<span class='" + self.slideClassPrefix + n + "' aria-label='hidden' data-index='" + i + "'>" + "<img style='height:" + Math.round(parseFloat(ratio.height)) + "px;width:" + Math.round(parseFloat(ratio.width)) + "px' src='" + image[0].src + "' alt='" + image.attr("alt") + " - Thumbnail" + "'>" + "</span>" + "</li>"; 1456 distIncr += (self.thumbnailSize + self.thumbMargin) 1457 }); 1458 this.thumbnailWrapper.append(markup); 1459 this.tabs = this.thumbnailWrapper.find('span'); 1460 this.tabs.eq(0).closest("li").addClass("callbacks_here"); 1461 this.$element.after(this.thumbnailContainer); 1462 if (this.length * this.thumbnailSize < this.thumbsPerSlide * this.thumbnailSize) { 1463 this.thumbnailNavLeft.css("display", "none"); 1464 this.thumbnailNavRight.css("display", "none") 1465 } 1466 this.thumbnailContainerScroll(); 1467 this.bindThumbnailClick(); 1468 this.thumbnailNavLeft.on("click", function(e) { 1469 e.preventDefault(); 1470 self.scrollThumbnails(500, "-") 1471 }); 1472 this.thumbnailNavRight.on("click", function(e) { 1473 e.preventDefault(); 1474 self.scrollThumbnails(500, "+") 1475 }) 1476 } 1477 }, 1478 bindPagerClick: function() { 1479 var self = this; 1480 this.navigation.find("li > span").on("click", function(e) { 1481 e.preventDefault(); 1482 var index = $(this).attr("data-index"); 1483 self.goToPager(index) 1484 }) 1485 }, 1486 bindThumbnailClick: function() { 1487 var self = this; 1488 this.thumbnailWrapper.find("span").on("click", function(e) { 1489 e.preventDefault(); 1490 var index = $(this).attr("data-index"); 1491 self.thumbClicked = !0; 1492 self.goToThumbnail(index) 1493 }) 1494 }, 1495 goToPager: function(index, manual) { 1496 var pager = this.navigation.find("li").eq(index); 1497 var slide = this.slides.eq(index); 1498 this.navigation.find("span").removeClass("pager-active"); 1499 pager.find("span").addClass("pager-active"); 1500 if (!manual) this.slideTo(slide, index); 1501 this.restartCycle() 1502 }, 1503 goToThumbnail: function(index, manual) { 1504 var thumbnail = this.thumbnailWrapper.find("li").eq(index); 1505 var slide = this.slides.eq(index); 1506 this.thumbnailWrapper.find("li").removeClass("callbacks_here"); 1507 thumbnail.closest("li").addClass("callbacks_here"); 1508 if (!manual) this.slideTo(slide, index); 1509 this.restartCycle() 1510 }, 1511 goToNextSlide: function() { 1512 var index = (this.index + 1) < this.length ? this.index + 1 : 0; 1513 var slide = this.slides.eq(index); 1514 this.thumbClicked = !1; 1515 this.slideTo(slide, index); 1516 if( slide.find("img").attr("alt") ) { 1517 $("#sr-notification").html( slide.find("img").attr("alt") ); 1518 } 1519 this.updateNavigation(); 1520 this.restartCycle() 1521 }, 1522 goToPrevSlide: function() { 1523 var index = (this.index === 0) ? this.length - 1 : this.index - 1; 1524 var slide = this.slides.eq(index); 1525 this.thumbClicked = !1; 1526 this.slideTo(slide, index); 1527 if( slide.find("img").attr("alt") ) { 1528 $("#sr-notification").html( slide.find("img").attr("alt") ); 1529 } 1530 this.updateNavigation(); 1531 this.restartCycle() 1532 }, 1533 makeImageActualSize: function(slide) { 1534 this.$element.css("lineHeight", this.options.maxHeight + "px").addClass("actualsize"); 1535 $(slide).addClass("actualsizeli").find("img").addClass("actualsizeimg") 1536 }, 1537 stretchAndFillImage: function(slide) { 1538 var maxHeight = parseFloat(this.options.maxHeight) || parseFloat(this.$element.css("maxHeight")); 1539 var $slide = $(slide); 1540 var slideWidth = $slide.outerWidth(!0); 1541 var slideHeight = $slide.outerHeight(!0); 1542 var image = $slide.find("img"); 1543 if (!image.length) return; 1544 image.addClass("stretchfill"); 1545 var imageWidth = $(image).width(); 1546 var imageHeight = $(image).height(); 1547 var horizontalOffset = imageWidth - slideWidth; 1548 var verticalOffset = imageHeight - slideHeight; 1549 if (horizontalOffset <= 0 || verticalOffset <= 0) { 1550 var imgClass = (imageWidth / imageHeight > 1) ? 'wide' : 'tall'; 1551 image.removeClass("stretchfill").addClass(imgClass); 1552 var imgHeight = image[0].clientHeight; 1553 var imgWidth = image[0].clientWidth; 1554 var aspect = calculateAspectRatioFit(imgWidth, imgHeight, slideWidth, maxHeight); 1555 var roundedHeight = Math.round(aspect.height); 1556 var roundedWidth = Math.round(aspect.width); 1557 $(image).css("height", roundedHeight + "px"); 1558 $(image).css("width", roundedWidth + "px"); 1559 verticalOffset = aspect.height - maxHeight; 1560 horizontalOffset = aspect.width - slideWidth 1561 } 1562 $(image).css("top", (-verticalOffset / 2)); 1563 $(image).css("left", (-horizontalOffset / 2)) 1564 }, 1565 hideEmptyCaptions: function() { 1566 var captionWrapper, captionTitleLength, captionDescriptionLength; 1567 this.slides.each(function(i) { 1568 captionWrapper = $(this).find(".ezcaptionwrapper"); 1569 captionTitleLength = stripWhiteSpace(captionWrapper.find(".ezcaptiontitle").text()).length; 1570 captionDescriptionLength = stripWhiteSpace(captionWrapper.find(".ezcaption").text()).length; 1571 if (captionTitleLength == 0 && captionDescriptionLength == 0) captionWrapper.hide() 1572 }) 1573 }, 1574 randomize: function() { 1575 if (this.options.random) { 1576 this.slides.sort(function() { 1577 return (Math.round(Math.random()) - 0.5) 1578 }); 1579 this.$element.empty().append(this.slides) 1580 } 1581 return this 1582 }, 1583 startCycle: function() { 1584 var self = this; 1585 if (this.options.auto) { 1586 this.interval = setInterval(function() { 1587 var index = (self.index + 1) < self.length ? self.index + 1 : 0; 1588 var slide = self.slides.eq(index); 1589 self.slideTo(slide, index); 1590 self.updateNavigation() 1591 }, this.options.timeout) 1592 } 1593 }, 1594 restartCycle: function() { 1595 clearInterval(this.interval); 1596 this.startCycle() 1597 }, 1598 thumbScrollTracker: function(idx) { 1599 if (this.length >= this.thumbsPerSlide) { 1600 this.currentTabPosition = $(this.tabs[idx]).offset().left + $(this.tabs[idx]).width(); 1601 if (this.currentTabPosition >= this.offsetRight && this.currentTabPosition <= this.offsetRight + this.thumbnailSize) {
1602 this.scrollThumbnails(500, "+") 1603 } else if (this.index > idx && idx != 0 && this.index != this.length - 1) { 1604 if (this.currentTabPosition <= this.offsetLeft && this.currentTabPosition >= this.offsetLeft - this.thumbnailSize) { 1605 this.scrollThumbnails(500, "-") 1606 } 1607 } else if (this.index == this.length - 1 && idx == 0 && !this.thumbClicked) { 1608 this.scrollThumbnails(500, "+") 1609 } else if (this.index == 0 && idx == this.length - 1 && !this.thumbClicked) { 1610 this.scrollThumbnails(500, "-") 1611 } 1612 } 1613 }, 1614 thumbnailContainerScroll: function() { 1615 var currentLeft = this.thumbnailWrapper.position().left; 1616 this.scrollAmount = parseFloat($(this.tabs[Math.round(this.thumbsPerSlide / 2)]).parent().css("left")); 1617 this.lastScrollAmount = this.thumbsTotalWidth + this.length - this.slides.width(); 1618 var atEnd = 0; 1619 this.scrollThumbnails = function(speed, direction) { 1620 if (direction == "+") { 1621 currentLeft -= this.scrollAmount; 1622 if (Math.abs(currentLeft) > this.lastScrollAmount) { 1623 currentLeft = currentLeft + this.scrollAmount; 1624 var difference = currentLeft + this.lastScrollAmount; 1625 currentLeft -= difference 1626 } 1627 if (Math.abs(currentLeft) == this.lastScrollAmount) { 1628 if (atEnd == 1) { 1629 currentLeft = 0; 1630 atEnd = 0 1631 } else atEnd += 1 1632 } 1633 if (this.transitionSupport) { 1634 this.thumbnailWrapper.css({ 1635 transform: "translateX(" + currentLeft + "px)", 1636 transition: "all " + speed + "ms ease" 1637 }) 1638 } else { 1639 this.thumbnailWrapper.animate({ 1640 "left": currentLeft + "px" 1641 }, speed) 1642 } 1643 } 1644 if (direction == "-") { 1645 if (currentLeft == 0) { 1646 currentLeft -= this.lastScrollAmount; 1647 atEnd = 1 1648 } else currentLeft += this.scrollAmount; 1649 if (currentLeft > 0) currentLeft = 0; 1650 if (this.transitionSupport) { 1651 this.thumbnailWrapper.css({ 1652 transform: "translateX(" + currentLeft + "px)", 1653 transition: "all " + speed + "ms ease" 1654 }) 1655 } else { 1656 this.thumbnailWrapper.animate({ 1657 "left": currentLeft + "px" 1658 }, speed) 1659 } 1660 } 1661 } 1662 }, 1663 pauseOnHover: function() { 1664 var self = this; 1665 this.$element.hover(function() { 1666 clearTimeout(self.interval) 1667 }, function() { 1668 self.restartCycle() 1669 }) 1670 } 1671 }); 1672 $.fn[pluginName] = function(options) { 1673 return this.each(function() { 1674 if (!$.data(this, "plugin_" + pluginName)) { 1675 i++; 1676 $.data(this, "plugin_" + pluginName, new Plugin(this, options)) 1677 } 1678 }) 1679 } 1680})(jQuery, window, document, 0)
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.