(function (window, document, $, undefined) { "use strict"; window.console = window.console || { info: function (stuff) {} }; // If there's no jQuery, bbcbox can't work // ========================================= if (!$) { return; } // Check if bbcbox is already initialized // ======================================== if ($.fn.bbcbox) { console.info("bbcbox already initialized"); return; } // Private default settings // ======================== var defaults = { // Close existing modals // Set this to false if you do not need to stack multiple instances closeExisting: false, // Enable infinite gallery navigation loop: false, // Horizontal space between slides gutter: 50, // Enable keyboard navigation keyboard: true, // Should allow caption to overlap the content preventCaptionOverlap: true, // Should display navigation arrows at the screen edges arrows: true, // Should display counter at the top left corner infobar: true, // Should display close button (using `btnTpl.smallBtn` template) over the content // Can be true, false, "auto" // If "auto" - will be automatically enabled for "html", "inline" or "ajax" items smallBtn: "auto", // Should display toolbar (buttons at the top) // Can be true, false, "auto" // If "auto" - will be automatically hidden if "smallBtn" is enabled toolbar: "auto", // What buttons should appear in the top right corner. // Buttons will be created using templates from `btnTpl` option // and they will be placed into toolbar (class="bbcbox-toolbar"` element) buttons: [ "zoom", //"share", "slideShow", //"fullScreen", //"download", "thumbs", "close" ], // Detect "idle" time in seconds idleTime: 3, // Disable right-click and use simple image protection for images protect: false, // Shortcut to make content "modal" - disable keyboard navigtion, hide buttons, etc modal: false, image: { // Wait for images to load before displaying // true - wait for image to load and then display; // false - display thumbnail and load the full-sized image over top, // requires predefined image dimensions (`data-width` and `data-height` attributes) preload: false }, ajax: { // Object containing settings for ajax request settings: { // This helps to indicate that request comes from the modal // Feel free to change naming data: { bbcbox: true } } }, iframe: { // Iframe template tpl: '', // Preload iframe before displaying it // This allows to calculate iframe content width and height // (note: Due to "Same Origin Policy", you can't get cross domain data). preload: true, // Custom CSS styling for iframe wrapping element // You can use this to set custom iframe dimensions css: {}, // Iframe tag attributes attr: { scrolling: "auto" } }, // For HTML5 video only video: { tpl: '", format: "", // custom video format autoStart: true }, // Default content type if cannot be detected automatically defaultType: "image", // Open/close animation type // Possible values: // false - disable // "zoom" - zoom images from/to thumbnail // "fade" // "zoom-in-out" // animationEffect: "zoom", // Duration in ms for open/close animation animationDuration: 366, // Should image change opacity while zooming // If opacity is "auto", then opacity will be changed if image and thumbnail have different aspect ratios zoomOpacity: "auto", // Transition effect between slides // // Possible values: // false - disable // "fade' // "slide' // "circular' // "tube' // "zoom-in-out' // "rotate' // transitionEffect: "fade", // Duration in ms for transition animation transitionDuration: 366, // Custom CSS class for slide element slideClass: "", // Custom CSS class for layout baseClass: "", // Base template for layout baseTpl: '", // baseTpl : '', // Loading indicator template spinnerTpl: '
', // Error message template errorTpl: '

{{ERROR}}

', btnTpl: { download: '' + '' + "", zoom: '", close: '", // Arrows arrowLeft: '", arrowRight: '", // This small close button will be appended to your html/inline/ajax content by default, // if "smallBtn" option is not set to false smallBtn: '" }, // Container is injected into this element parentEl: "body", // Hide browser vertical scrollbars; use at your own risk hideScrollbar: true, // Focus handling // ============== // Try to focus on the first focusable element after opening autoFocus: true, // Put focus back to active element after closing backFocus: true, // Do not let user to focus on element outside modal content trapFocus: true, // Module specific options // ======================= fullScreen: { autoStart: false }, // Set `touch: false` to disable panning/swiping touch: { vertical: true, // Allow to drag content vertically momentum: true // Continue movement after releasing mouse/touch when panning }, // Hash value when initializing manually, // set `false` to disable hash change hash: null, // Customize or add new media types // Example: /* media : { youtube : { params : { autoplay : 0 } } } */ media: {}, slideShow: { autoStart: false, speed: 3000 }, thumbs: { autoStart: false, // Display thumbnails on opening hideOnClose: true, // Hide thumbnail grid when closing animation starts parentEl: ".bbcbox-container", // Container is injected into this element axis: "y" // Vertical (y) or horizontal (x) scrolling }, // Use mousewheel to navigate gallery // If 'auto' - enabled for images only wheel: "auto", // Callbacks //========== // See Documentation/API/Events for more information // Example: /* afterShow: function( instance, current ) { console.info( 'Clicked element:' ); console.info( current.opts.$orig ); } */ onInit: $.noop, // When instance has been initialized beforeLoad: $.noop, // Before the content of a slide is being loaded afterLoad: $.noop, // When the content of a slide is done loading beforeShow: $.noop, // Before open animation starts afterShow: $.noop, // When content is done loading and animating beforeClose: $.noop, // Before the instance attempts to close. Return false to cancel the close. afterClose: $.noop, // After instance has been closed onActivate: $.noop, // When instance is brought to front onDeactivate: $.noop, // When other instance has been activated // Interaction // =========== // Use options below to customize taken action when user clicks or double clicks on the bbcbox area, // each option can be string or method that returns value. // // Possible values: // "close" - close instance // "next" - move to next gallery item // "nextOrClose" - move to next gallery item or close if gallery has only one item // "toggleControls" - show/hide controls // "zoom" - zoom image (if loaded) // false - do nothing // Clicked on the content clickContent: function (current, event) { return current.type === "image" ? "zoom" : false; }, // Clicked on the slide clickSlide: "close", // Clicked on the background (backdrop) element; // if you have not changed the layout, then most likely you need to use `clickSlide` option clickOutside: "close", // Same as previous two, but for double click dblclickContent: false, dblclickSlide: false, dblclickOutside: false, // Custom options when mobile device is detected // ============================================= mobile: { preventCaptionOverlap: false, idleTime: false, clickContent: function (current, event) { return current.type === "image" ? "toggleControls" : false; }, clickSlide: function (current, event) { return current.type === "image" ? "toggleControls" : "close"; }, dblclickContent: function (current, event) { return current.type === "image" ? "zoom" : false; }, dblclickSlide: function (current, event) { return current.type === "image" ? "zoom" : false; } }, // Internationalization // ==================== lang: "cn", i18n: { cn: { CLOSE: "关闭", NEXT: "下一页", PREV: "上一页", ERROR: "请求内容失败。
请稍后再试。", PLAY_START: "开启轮播", PLAY_STOP: "暂停轮播", FULL_SCREEN: "全屏", THUMBS: "缩略图", DOWNLOAD: "下载", ZOOM: "放大" } } }; // Few useful variables and methods // ================================ var $W = $(window); var $D = $(document); var called = 0; // Check if an object is a jQuery object and not a native JavaScript object // ======================================================================== var isQuery = function (obj) { return obj && obj.hasOwnProperty && obj instanceof $; }; // Handle multiple browsers for "requestAnimationFrame" and "cancelAnimationFrame" // =============================================================================== var requestAFrame = (function () { return ( window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || // if all else fails, use setTimeout function (callback) { return window.setTimeout(callback, 1000 / 60); } ); })(); var cancelAFrame = (function () { return ( window.cancelAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame || window.oCancelAnimationFrame || function (id) { window.clearTimeout(id); } ); })(); // Detect the supported transition-end event property name // ======================================================= var transitionEnd = (function () { var el = document.createElement("fakeelement"), t; var transitions = { transition: "transitionend", OTransition: "oTransitionEnd", MozTransition: "transitionend", WebkitTransition: "webkitTransitionEnd" }; for (t in transitions) { if (el.style[t] !== undefined) { return transitions[t]; } } return "transitionend"; })(); // Force redraw on an element. // This helps in cases where the browser doesn't redraw an updated element properly // ================================================================================ var forceRedraw = function ($el) { return $el && $el.length && $el[0].offsetHeight; }; // Exclude array (`buttons`) options from deep merging // =================================================== var mergeOpts = function (opts1, opts2) { var rez = $.extend(true, {}, opts1, opts2); $.each(opts2, function (key, value) { if ($.isArray(value)) { rez[key] = value; } }); return rez; }; // How much of an element is visible in viewport // ============================================= var inViewport = function (elem) { var elemCenter, rez; if (!elem || elem.ownerDocument !== document) { return false; } $(".bbcbox-container").css("pointer-events", "none"); elemCenter = { x: elem.getBoundingClientRect().left + elem.offsetWidth / 2, y: elem.getBoundingClientRect().top + elem.offsetHeight / 2 }; rez = document.elementFromPoint(elemCenter.x, elemCenter.y) === elem; $(".bbcbox-container").css("pointer-events", ""); return rez; }; // Class definition // ================ var bbcbox = function (content, opts, index) { var self = this; self.opts = mergeOpts({ index: index }, $.bbcbox.defaults); if ($.isPlainObject(opts)) { self.opts = mergeOpts(self.opts, opts); } if ($.bbcbox.isMobile) { self.opts = mergeOpts(self.opts, self.opts.mobile); } self.id = self.opts.id || ++called; self.currIndex = parseInt(self.opts.index, 10) || 0; self.prevIndex = null; self.prevPos = null; self.currPos = 0; self.firstRun = true; // All group items self.group = []; // Existing slides (for current, next and previous gallery items) self.slides = {}; // Create group elements self.addContent(content); if (!self.group.length) { return; } self.init(); }; $.extend(bbcbox.prototype, { // Create DOM structure // ==================== init: function () { var self = this, firstItem = self.group[self.currIndex], firstItemOpts = firstItem.opts, $container, buttonStr; if (firstItemOpts.closeExisting) { $.bbcbox.close(true); } // Hide scrollbars // =============== $("body").addClass("bbcbox-active"); if ( !$.bbcbox.getInstance() && firstItemOpts.hideScrollbar !== false && !$.bbcbox.isMobile && document.body.scrollHeight > window.innerHeight ) { $("head").append( '" ); $("body").addClass("compensate-for-scrollbar"); } // Build html markup and set references // ==================================== // Build html code for buttons and insert into main template buttonStr = ""; $.each(firstItemOpts.buttons, function (index, value) { buttonStr += firstItemOpts.btnTpl[value] || ""; }); // Create markup from base template, it will be initially hidden to // avoid unnecessary work like painting while initializing is not complete $container = $( self.translate( self, firstItemOpts.baseTpl .replace("{{buttons}}", buttonStr) .replace("{{arrows}}", firstItemOpts.btnTpl.arrowLeft + firstItemOpts.btnTpl.arrowRight) ) ) .attr("id", "bbcbox-container-" + self.id) .addClass(firstItemOpts.baseClass) .data("bbcbox", self) .appendTo(firstItemOpts.parentEl); // Create object holding references to jQuery wrapped nodes self.$refs = { container: $container }; ["bg", "inner", "infobar", "toolbar", "stage", "caption", "navigation"].forEach(function (item) { self.$refs[item] = $container.find(".bbcbox-" + item); }); self.trigger("onInit"); // Enable events, deactive previous instances self.activate(); // Build slides, load and reveal content self.jumpTo(self.currIndex); }, // Simple i18n support - replaces object keys found in template // with corresponding values // ============================================================ translate: function (obj, str) { var arr = obj.opts.i18n[obj.opts.lang] || obj.opts.i18n.en; return str.replace(/\{\{(\w+)\}\}/g, function (match, n) { return arr[n] === undefined ? match : arr[n]; }); }, // Populate current group with fresh content // Check if each object has valid type and content // =============================================== addContent: function (content) { var self = this, items = $.makeArray(content), thumbs; $.each(items, function (i, item) { var obj = {}, opts = {}, $item, type, found, src, srcParts; // Step 1 - Make sure we have an object // ==================================== if ($.isPlainObject(item)) { // We probably have manual usage here, something like // $.bbcbox.open( [ { src : "image.jpg", type : "image" } ] ) obj = item; opts = item.opts || item; } else if ($.type(item) === "object" && $(item).length) { // Here we probably have jQuery collection returned by some selector $item = $(item); // Support attributes like `data-options='{"touch" : false}'` and `data-touch='false'` opts = $item.data() || {}; opts = $.extend(true, {}, opts, opts.options); // Here we store clicked element opts.$orig = $item; obj.src = self.opts.src || opts.src || $item.attr("href"); // Assume that simple syntax is used, for example: // `$.bbcbox.open( $("#test"), {} );` if (!obj.type && !obj.src) { obj.type = "inline"; obj.src = item; } } else { // Assume we have a simple html code, for example: // $.bbcbox.open( '

Hi!

' ); obj = { type: "html", src: item + "" }; } // Each gallery object has full collection of options obj.opts = $.extend(true, {}, self.opts, opts); // Do not merge buttons array if ($.isArray(opts.buttons)) { obj.opts.buttons = opts.buttons; } if ($.bbcbox.isMobile && obj.opts.mobile) { obj.opts = mergeOpts(obj.opts, obj.opts.mobile); } // Step 2 - Make sure we have content type, if not - try to guess // ============================================================== type = obj.type || obj.opts.type; src = obj.src || ""; if (!type && src) { if ((found = src.match(/\.(mp4|mov|ogv|webm)((\?|#).*)?$/i))) { type = "video"; if (!obj.opts.video.format) { obj.opts.video.format = "video/" + (found[1] === "ogv" ? "ogg" : found[1]); } } else if (src.match(/(^data:image\/[a-z0-9+\/=]*,)|(\.(jp(e|g|eg)|gif|png|bmp|webp|svg|ico)((\?|#).*)?$)/i)) { type = "image"; } else if (src.match(/\.(pdf)((\?|#).*)?$/i)) { type = "iframe"; obj = $.extend(true, obj, { contentType: "pdf", opts: { iframe: { preload: false } } }); } else if (src.charAt(0) === "#") { type = "inline"; } } if (type) { obj.type = type; } else { self.trigger("objectNeedsType", obj); } if (!obj.contentType) { obj.contentType = $.inArray(obj.type, ["html", "inline", "ajax"]) > -1 ? "html" : obj.type; } // Step 3 - Some adjustments // ========================= obj.index = self.group.length; if (obj.opts.smallBtn == "auto") { obj.opts.smallBtn = $.inArray(obj.type, ["html", "inline", "ajax"]) > -1; } if (obj.opts.toolbar === "auto") { obj.opts.toolbar = !obj.opts.smallBtn; } // Find thumbnail image, check if exists and if is in the viewport obj.$thumb = obj.opts.$thumb || null; if (obj.opts.$trigger && obj.index === self.opts.index) { obj.$thumb = obj.opts.$trigger.find("img:first"); if (obj.$thumb.length) { obj.opts.$orig = obj.opts.$trigger; } } if (!(obj.$thumb && obj.$thumb.length) && obj.opts.$orig) { obj.$thumb = obj.opts.$orig.find("img:first"); } if (obj.$thumb && !obj.$thumb.length) { obj.$thumb = null; } obj.thumb = obj.opts.thumb || (obj.$thumb ? obj.$thumb[0].src : null); // "caption" is a "special" option, it can be used to customize caption per gallery item if ($.type(obj.opts.caption) === "function") { obj.opts.caption = obj.opts.caption.apply(item, [self, obj]); } if ($.type(self.opts.caption) === "function") { obj.opts.caption = self.opts.caption.apply(item, [self, obj]); } // Make sure we have caption as a string or jQuery object if (!(obj.opts.caption instanceof $)) { obj.opts.caption = obj.opts.caption === undefined ? "" : obj.opts.caption + ""; } // Check if url contains "filter" used to filter the content // Example: "ajax.html #something" if (obj.type === "ajax") { srcParts = src.split(/\s+/, 2); if (srcParts.length > 1) { obj.src = srcParts.shift(); obj.opts.filter = srcParts.shift(); } } // Hide all buttons and disable interactivity for modal items if (obj.opts.modal) { obj.opts = $.extend(true, obj.opts, { trapFocus: true, // Remove buttons infobar: 0, toolbar: 0, smallBtn: 0, // Disable keyboard navigation keyboard: 0, // Disable some modules slideShow: 0, fullScreen: 0, thumbs: 0, touch: 0, // Disable click event handlers clickContent: false, clickSlide: false, clickOutside: false, dblclickContent: false, dblclickSlide: false, dblclickOutside: false }); } // Step 4 - Add processed object to group // ====================================== self.group.push(obj); }); // Update controls if gallery is already opened if (Object.keys(self.slides).length) { self.updateControls(); // Update thumbnails, if needed thumbs = self.Thumbs; if (thumbs && thumbs.isActive) { thumbs.create(); thumbs.focus(); } } }, // Attach an event handler functions for: // - navigation buttons // - browser scrolling, resizing; // - focusing // - keyboard // - detecting inactivity // ====================================== addEvents: function () { var self = this; self.removeEvents(); // Make navigation elements clickable // ================================== self.$refs.container .on("click.bbc-close", "[data-bbcbox-close]", function (e) { e.stopPropagation(); e.preventDefault(); self.close(e); }) .on("touchstart.bbc-prev click.bbc-prev", "[data-bbcbox-prev]", function (e) { e.stopPropagation(); e.preventDefault(); self.previous(); }) .on("touchstart.bbc-next click.bbc-next", "[data-bbcbox-next]", function (e) { e.stopPropagation(); e.preventDefault(); self.next(); }) .on("click.bbc", "[data-bbcbox-zoom]", function (e) { // Click handler for zoom button self[self.isScaledDown() ? "scaleToActual" : "scaleToFit"](); }); // Handle page scrolling and browser resizing // ========================================== $W.on("orientationchange.bbc resize.bbc", function (e) { if (e && e.originalEvent && e.originalEvent.type === "resize") { if (self.requestId) { cancelAFrame(self.requestId); } self.requestId = requestAFrame(function () { self.update(e); }); } else { if (self.current && self.current.type === "iframe") { self.$refs.stage.hide(); } setTimeout( function () { self.$refs.stage.show(); self.update(e); }, $.bbcbox.isMobile ? 600 : 250 ); } }); $D.on("keydown.bbc", function (e) { var instance = $.bbcbox ? $.bbcbox.getInstance() : null, current = instance.current, keycode = e.keyCode || e.which; // Trap keyboard focus inside of the modal // ======================================= if (keycode == 9) { if (current.opts.trapFocus) { self.focus(e); } return; } // Enable keyboard navigation // ========================== if (!current.opts.keyboard || e.ctrlKey || e.altKey || e.shiftKey || $(e.target).is("input,textarea,video,audio,select")) { return; } // Backspace and Esc keys if (keycode === 8 || keycode === 27) { e.preventDefault(); self.close(e); return; } // Left arrow and Up arrow if (keycode === 37 || keycode === 38) { e.preventDefault(); self.previous(); return; } // Righ arrow and Down arrow if (keycode === 39 || keycode === 40) { e.preventDefault(); self.next(); return; } self.trigger("afterKeydown", e, keycode); }); // Hide controls after some inactivity period if (self.group[self.currIndex].opts.idleTime) { self.idleSecondsCounter = 0; $D.on( "mousemove.bbc-idle mouseleave.bbc-idle mousedown.bbc-idle touchstart.bbc-idle touchmove.bbc-idle scroll.bbc-idle keydown.bbc-idle", function (e) { self.idleSecondsCounter = 0; if (self.isIdle) { self.showControls(); } self.isIdle = false; } ); self.idleInterval = window.setInterval(function () { self.idleSecondsCounter++; if (self.idleSecondsCounter >= self.group[self.currIndex].opts.idleTime && !self.isDragging) { self.isIdle = true; self.idleSecondsCounter = 0; self.hideControls(); } }, 1000); } }, // Remove events added by the core // =============================== removeEvents: function () { var self = this; $W.off("orientationchange.bbc resize.bbc"); $D.off("keydown.bbc .bbc-idle"); this.$refs.container.off(".bbc-close .bbc-prev .bbc-next"); if (self.idleInterval) { window.clearInterval(self.idleInterval); self.idleInterval = null; } }, // Change to previous gallery item // =============================== previous: function (duration) { return this.jumpTo(this.currPos - 1, duration); }, // Change to next gallery item // =========================== next: function (duration) { return this.jumpTo(this.currPos + 1, duration); }, // Switch to selected gallery item // =============================== jumpTo: function (pos, duration) { var self = this, groupLen = self.group.length, firstRun, isMoved, loop, current, previous, slidePos, stagePos, prop, diff; if (self.isDragging || self.isClosing || (self.isAnimating && self.firstRun)) { return; } // Should loop? pos = parseInt(pos, 10); loop = self.current ? self.current.opts.loop : self.opts.loop; if (!loop && (pos < 0 || pos >= groupLen)) { return false; } // Check if opening for the first time; this helps to speed things up firstRun = self.firstRun = !Object.keys(self.slides).length; // Create slides previous = self.current; self.prevIndex = self.currIndex; self.prevPos = self.currPos; current = self.createSlide(pos); if (groupLen > 1) { if (loop || current.index < groupLen - 1) { self.createSlide(pos + 1); } if (loop || current.index > 0) { self.createSlide(pos - 1); } } self.current = current; self.currIndex = current.index; self.currPos = current.pos; self.trigger("beforeShow", firstRun); self.updateControls(); // Validate duration length current.forcedDuration = undefined; if ($.isNumeric(duration)) { current.forcedDuration = duration; } else { duration = current.opts[firstRun ? "animationDuration" : "transitionDuration"]; } duration = parseInt(duration, 10); // Check if user has swiped the slides or if still animating isMoved = self.isMoved(current); // Make sure current slide is visible current.$slide.addClass("bbcbox-slide--current"); // Fresh start - reveal container, current slide and start loading content if (firstRun) { if (current.opts.animationEffect && duration) { self.$refs.container.css("transition-duration", duration + "ms"); } self.$refs.container.addClass("bbcbox-is-open").trigger("focus"); // Attempt to load content into slide // This will later call `afterLoad` -> `revealContent` self.loadSlide(current); self.preload("image"); return; } // Get actual slide/stage positions (before cleaning up) slidePos = $.bbcbox.getTranslate(previous.$slide); stagePos = $.bbcbox.getTranslate(self.$refs.stage); // Clean up all slides $.each(self.slides, function (index, slide) { $.bbcbox.stop(slide.$slide, true); }); if (previous.pos !== current.pos) { previous.isComplete = false; } previous.$slide.removeClass("bbcbox-slide--complete bbcbox-slide--current"); // If slides are out of place, then animate them to correct position if (isMoved) { // Calculate horizontal swipe distance diff = slidePos.left - (previous.pos * slidePos.width + previous.pos * previous.opts.gutter); $.each(self.slides, function (index, slide) { slide.$slide.removeClass("bbcbox-animated").removeClass(function (index, className) { return (className.match(/(^|\s)bbcbox-fx-\S+/g) || []).join(" "); }); // Make sure that each slide is in equal distance // This is mostly needed for freshly added slides, because they are not yet positioned var leftPos = slide.pos * slidePos.width + slide.pos * slide.opts.gutter; $.bbcbox.setTranslate(slide.$slide, { top: 0, left: leftPos - stagePos.left + diff }); if (slide.pos !== current.pos) { slide.$slide.addClass("bbcbox-slide--" + (slide.pos > current.pos ? "next" : "previous")); } // Redraw to make sure that transition will start forceRedraw(slide.$slide); // Animate the slide $.bbcbox.animate( slide.$slide, { top: 0, left: (slide.pos - current.pos) * slidePos.width + (slide.pos - current.pos) * slide.opts.gutter }, duration, function () { slide.$slide .css({ transform: "", opacity: "" }) .removeClass("bbcbox-slide--next bbcbox-slide--previous"); if (slide.pos === self.currPos) { self.complete(); } } ); }); } else if (duration && current.opts.transitionEffect) { // Set transition effect for previously active slide prop = "bbcbox-animated bbcbox-fx-" + current.opts.transitionEffect; previous.$slide.addClass("bbcbox-slide--" + (previous.pos > current.pos ? "next" : "previous")); $.bbcbox.animate( previous.$slide, prop, duration, function () { previous.$slide.removeClass(prop).removeClass("bbcbox-slide--next bbcbox-slide--previous"); }, false ); } if (current.isLoaded) { self.revealContent(current); } else { self.loadSlide(current); } self.preload("image"); }, // Create new "slide" element // These are gallery items that are actually added to DOM // ======================================================= createSlide: function (pos) { var self = this, $slide, index; index = pos % self.group.length; index = index < 0 ? self.group.length + index : index; if (!self.slides[pos] && self.group[index]) { $slide = $('
').appendTo(self.$refs.stage); self.slides[pos] = $.extend(true, {}, self.group[index], { pos: pos, $slide: $slide, isLoaded: false }); self.updateSlide(self.slides[pos]); } return self.slides[pos]; }, // Scale image to the actual size of the image; // x and y values should be relative to the slide // ============================================== scaleToActual: function (x, y, duration) { var self = this, current = self.current, $content = current.$content, canvasWidth = $.bbcbox.getTranslate(current.$slide).width, canvasHeight = $.bbcbox.getTranslate(current.$slide).height, newImgWidth = current.width, newImgHeight = current.height, imgPos, posX, posY, scaleX, scaleY; if (self.isAnimating || self.isMoved() || !$content || !(current.type == "image" && current.isLoaded && !current.hasError)) { return; } self.isAnimating = true; $.bbcbox.stop($content); x = x === undefined ? canvasWidth * 0.5 : x; y = y === undefined ? canvasHeight * 0.5 : y; imgPos = $.bbcbox.getTranslate($content); imgPos.top -= $.bbcbox.getTranslate(current.$slide).top; imgPos.left -= $.bbcbox.getTranslate(current.$slide).left; scaleX = newImgWidth / imgPos.width; scaleY = newImgHeight / imgPos.height; // Get center position for original image posX = canvasWidth * 0.5 - newImgWidth * 0.5; posY = canvasHeight * 0.5 - newImgHeight * 0.5; // Make sure image does not move away from edges if (newImgWidth > canvasWidth) { posX = imgPos.left * scaleX - (x * scaleX - x); if (posX > 0) { posX = 0; } if (posX < canvasWidth - newImgWidth) { posX = canvasWidth - newImgWidth; } } if (newImgHeight > canvasHeight) { posY = imgPos.top * scaleY - (y * scaleY - y); if (posY > 0) { posY = 0; } if (posY < canvasHeight - newImgHeight) { posY = canvasHeight - newImgHeight; } } self.updateCursor(newImgWidth, newImgHeight); $.bbcbox.animate( $content, { top: posY, left: posX, scaleX: scaleX, scaleY: scaleY }, duration || 366, function () { self.isAnimating = false; } ); // Stop slideshow if (self.SlideShow && self.SlideShow.isActive) { self.SlideShow.stop(); } }, // Scale image to fit inside parent element // ======================================== scaleToFit: function (duration) { var self = this, current = self.current, $content = current.$content, end; if (self.isAnimating || self.isMoved() || !$content || !(current.type == "image" && current.isLoaded && !current.hasError)) { return; } self.isAnimating = true; $.bbcbox.stop($content); end = self.getFitPos(current); self.updateCursor(end.width, end.height); $.bbcbox.animate( $content, { top: end.top, left: end.left, scaleX: end.width / $content.width(), scaleY: end.height / $content.height() }, duration || 366, function () { self.isAnimating = false; } ); }, // Calculate image size to fit inside viewport // =========================================== getFitPos: function (slide) { var self = this, $content = slide.$content, $slide = slide.$slide, width = slide.width || slide.opts.width, height = slide.height || slide.opts.height, maxWidth, maxHeight, minRatio, aspectRatio, rez = {}; if (!slide.isLoaded || !$content || !$content.length) { return false; } maxWidth = $.bbcbox.getTranslate(self.$refs.stage).width; maxHeight = $.bbcbox.getTranslate(self.$refs.stage).height; maxWidth -= parseFloat($slide.css("paddingLeft")) + parseFloat($slide.css("paddingRight")) + parseFloat($content.css("marginLeft")) + parseFloat($content.css("marginRight")); maxHeight -= parseFloat($slide.css("paddingTop")) + parseFloat($slide.css("paddingBottom")) + parseFloat($content.css("marginTop")) + parseFloat($content.css("marginBottom")); if (!width || !height) { width = maxWidth; height = maxHeight; } minRatio = Math.min(1, maxWidth / width, maxHeight / height); width = minRatio * width; height = minRatio * height; // Adjust width/height to precisely fit into container if (width > maxWidth - 0.5) { width = maxWidth; } if (height > maxHeight - 0.5) { height = maxHeight; } if (slide.type === "image") { rez.top = Math.floor((maxHeight - height) * 0.5) + parseFloat($slide.css("paddingTop")); rez.left = Math.floor((maxWidth - width) * 0.5) + parseFloat($slide.css("paddingLeft")); } else if (slide.contentType === "video") { // Force aspect ratio for the video // "I say the whole world must learn of our peaceful ways… by force!" aspectRatio = slide.opts.width && slide.opts.height ? width / height : slide.opts.ratio || 16 / 9; if (height > width / aspectRatio) { height = width / aspectRatio; } else if (width > height * aspectRatio) { width = height * aspectRatio; } } rez.width = width; rez.height = height; return rez; }, // Update content size and position for all slides // ============================================== update: function (e) { var self = this; $.each(self.slides, function (key, slide) { self.updateSlide(slide, e); }); }, // Update slide content position and size // ====================================== updateSlide: function (slide, e) { var self = this, $content = slide && slide.$content, width = slide.width || slide.opts.width, height = slide.height || slide.opts.height, $slide = slide.$slide; // First, prevent caption overlap, if needed self.adjustCaption(slide); // Then resize content to fit inside the slide if ($content && (width || height || slide.contentType === "video") && !slide.hasError) { $.bbcbox.stop($content); $.bbcbox.setTranslate($content, self.getFitPos(slide)); if (slide.pos === self.currPos) { self.isAnimating = false; self.updateCursor(); } } // Then some adjustments self.adjustLayout(slide); if ($slide.length) { $slide.trigger("refresh"); if (slide.pos === self.currPos) { self.$refs.toolbar .add(self.$refs.navigation.find(".bbcbox-button--arrow_right")) .toggleClass("compensate-for-scrollbar", $slide.get(0).scrollHeight > $slide.get(0).clientHeight); } } self.trigger("onUpdate", slide, e); }, // Horizontally center slide // ========================= centerSlide: function (duration) { var self = this, current = self.current, $slide = current.$slide; if (self.isClosing || !current) { return; } $slide.siblings().css({ transform: "", opacity: "" }); $slide .parent() .children() .removeClass("bbcbox-slide--previous bbcbox-slide--next"); $.bbcbox.animate( $slide, { top: 0, left: 0, opacity: 1 }, duration === undefined ? 0 : duration, function () { // Clean up $slide.css({ transform: "", opacity: "" }); if (!current.isComplete) { self.complete(); } }, false ); }, // Check if current slide is moved (swiped) // ======================================== isMoved: function (slide) { var current = slide || this.current, slidePos, stagePos; if (!current) { return false; } stagePos = $.bbcbox.getTranslate(this.$refs.stage); slidePos = $.bbcbox.getTranslate(current.$slide); return ( !current.$slide.hasClass("bbcbox-animated") && (Math.abs(slidePos.top - stagePos.top) > 0.5 || Math.abs(slidePos.left - stagePos.left) > 0.5) ); }, // Update cursor style depending if content can be zoomed // ====================================================== updateCursor: function (nextWidth, nextHeight) { var self = this, current = self.current, $container = self.$refs.container, canPan, isZoomable; if (!current || self.isClosing || !self.Guestures) { return; } $container.removeClass("bbcbox-is-zoomable bbcbox-can-zoomIn bbcbox-can-zoomOut bbcbox-can-swipe bbcbox-can-pan"); canPan = self.canPan(nextWidth, nextHeight); isZoomable = canPan ? true : self.isZoomable(); $container.toggleClass("bbcbox-is-zoomable", isZoomable); $("[data-bbcbox-zoom]").prop("disabled", !isZoomable); if (canPan) { $container.addClass("bbcbox-can-pan"); } else if ( isZoomable && (current.opts.clickContent === "zoom" || ($.isFunction(current.opts.clickContent) && current.opts.clickContent(current) == "zoom")) ) { $container.addClass("bbcbox-can-zoomIn"); } else if (current.opts.touch && (current.opts.touch.vertical || self.group.length > 1) && current.contentType !== "video") { $container.addClass("bbcbox-can-swipe"); } }, // Check if current slide is zoomable // ================================== isZoomable: function () { var self = this, current = self.current, fitPos; // Assume that slide is zoomable if: // - image is still loading // - actual size of the image is smaller than available area if (current && !self.isClosing && current.type === "image" && !current.hasError) { if (!current.isLoaded) { return true; } fitPos = self.getFitPos(current); if (fitPos && (current.width > fitPos.width || current.height > fitPos.height)) { return true; } } return false; }, // Check if current image dimensions are smaller than actual // ========================================================= isScaledDown: function (nextWidth, nextHeight) { var self = this, rez = false, current = self.current, $content = current.$content; if (nextWidth !== undefined && nextHeight !== undefined) { rez = nextWidth < current.width && nextHeight < current.height; } else if ($content) { rez = $.bbcbox.getTranslate($content); rez = rez.width < current.width && rez.height < current.height; } return rez; }, // Check if image dimensions exceed parent element // =============================================== canPan: function (nextWidth, nextHeight) { var self = this, current = self.current, pos = null, rez = false; if (current.type === "image" && (current.isComplete || (nextWidth && nextHeight)) && !current.hasError) { rez = self.getFitPos(current); if (nextWidth !== undefined && nextHeight !== undefined) { pos = { width: nextWidth, height: nextHeight }; } else if (current.isComplete) { pos = $.bbcbox.getTranslate(current.$content); } if (pos && rez) { rez = Math.abs(pos.width - rez.width) > 1.5 || Math.abs(pos.height - rez.height) > 1.5; } } return rez; }, // Load content into the slide // =========================== loadSlide: function (slide) { var self = this, type, $slide, ajaxLoad; if (slide.isLoading || slide.isLoaded) { return; } slide.isLoading = true; if (self.trigger("beforeLoad", slide) === false) { slide.isLoading = false; return false; } type = slide.type; $slide = slide.$slide; $slide .off("refresh") .trigger("onReset") .addClass(slide.opts.slideClass); // Create content depending on the type switch (type) { case "image": self.setImage(slide); break; case "iframe": self.setIframe(slide); break; case "html": self.setContent(slide, slide.src || slide.content); break; case "video": self.setContent( slide, slide.opts.video.tpl .replace(/\{\{src\}\}/gi, slide.src) .replace("{{format}}", slide.opts.videoFormat || slide.opts.video.format || "") .replace("{{poster}}", slide.thumb || "") ); break; case "inline": if ($(slide.src).length) { self.setContent(slide, $(slide.src)); } else { self.setError(slide); } break; case "ajax": self.showLoading(slide); ajaxLoad = $.ajax( $.extend({}, slide.opts.ajax.settings, { url: slide.src, success: function (data, textStatus) { if (textStatus === "success") { self.setContent(slide, data); } }, error: function (jqXHR, textStatus) { if (jqXHR && textStatus !== "abort") { self.setError(slide); } } }) ); $slide.one("onReset", function () { ajaxLoad.abort(); }); break; default: self.setError(slide); break; } return true; }, // Use thumbnail image, if possible // ================================ setImage: function (slide) { var self = this, ghost; // Check if need to show loading icon setTimeout(function () { var $img = slide.$image; if (!self.isClosing && slide.isLoading && (!$img || !$img.length || !$img[0].complete) && !slide.hasError) { self.showLoading(slide); } }, 50); //Check if image has srcset self.checkSrcset(slide); // This will be wrapper containing both ghost and actual image slide.$content = $('
') .addClass("bbcbox-is-hidden") .appendTo(slide.$slide.addClass("bbcbox-slide--image")); // If we have a thumbnail, we can display it while actual image is loading // Users will not stare at black screen and actual image will appear gradually if (slide.opts.preload !== false && slide.opts.width && slide.opts.height && slide.thumb) { slide.width = slide.opts.width; slide.height = slide.opts.height; ghost = document.createElement("img"); ghost.onerror = function () { $(this).remove(); slide.$ghost = null; }; ghost.onload = function () { self.afterLoad(slide); }; slide.$ghost = $(ghost) .addClass("bbcbox-image") .appendTo(slide.$content) .attr("src", slide.thumb); } // Start loading actual image self.setBigImage(slide); }, // Check if image has srcset and get the source // ============================================ checkSrcset: function (slide) { var srcset = slide.opts.srcset || slide.opts.image.srcset, found, temp, pxRatio, windowWidth; // If we have "srcset", then we need to find first matching "src" value. // This is necessary, because when you set an src attribute, the browser will preload the image // before any javascript or even CSS is applied. if (srcset) { pxRatio = window.devicePixelRatio || 1; windowWidth = window.innerWidth * pxRatio; temp = srcset.split(",").map(function (el) { var ret = {}; el.trim() .split(/\s+/) .forEach(function (el, i) { var value = parseInt(el.substring(0, el.length - 1), 10); if (i === 0) { return (ret.url = el); } if (value) { ret.value = value; ret.postfix = el[el.length - 1]; } }); return ret; }); // Sort by value temp.sort(function (a, b) { return a.value - b.value; }); // Ok, now we have an array of all srcset values for (var j = 0; j < temp.length; j++) { var el = temp[j]; if ((el.postfix === "w" && el.value >= windowWidth) || (el.postfix === "x" && el.value >= pxRatio)) { found = el; break; } } // If not found, take the last one if (!found && temp.length) { found = temp[temp.length - 1]; } if (found) { slide.src = found.url; // If we have default width/height values, we can calculate height for matching source if (slide.width && slide.height && found.postfix == "w") { slide.height = (slide.width / slide.height) * found.value; slide.width = found.value; } slide.opts.srcset = srcset; } } }, // Create full-size image // ====================== setBigImage: function (slide) { var self = this, img = document.createElement("img"), $img = $(img); slide.$image = $img .one("error", function () { self.setError(slide); }) .one("load", function () { var sizes; if (!slide.$ghost) { self.resolveImageSlideSize(slide, this.naturalWidth, this.naturalHeight); self.afterLoad(slide); } if (self.isClosing) { return; } if (slide.opts.srcset) { sizes = slide.opts.sizes; if (!sizes || sizes === "auto") { sizes = (slide.width / slide.height > 1 && $W.width() / $W.height() > 1 ? "100" : Math.round((slide.width / slide.height) * 100)) + "vw"; } $img.attr("sizes", sizes).attr("srcset", slide.opts.srcset); } // Hide temporary image after some delay if (slide.$ghost) { setTimeout(function () { if (slide.$ghost && !self.isClosing) { slide.$ghost.hide(); } }, Math.min(300, Math.max(1000, slide.height / 1600))); } self.hideLoading(slide); }) .addClass("bbcbox-image") .attr("src", slide.src) .appendTo(slide.$content); if ((img.complete || img.readyState == "complete") && $img.naturalWidth && $img.naturalHeight) { $img.trigger("load"); } else if (img.error) { $img.trigger("error"); } }, // Computes the slide size from image size and maxWidth/maxHeight // ============================================================== resolveImageSlideSize: function (slide, imgWidth, imgHeight) { var maxWidth = parseInt(slide.opts.width, 10), maxHeight = parseInt(slide.opts.height, 10); // Sets the default values from the image slide.width = imgWidth; slide.height = imgHeight; if (maxWidth > 0) { slide.width = maxWidth; slide.height = Math.floor((maxWidth * imgHeight) / imgWidth); } if (maxHeight > 0) { slide.width = Math.floor((maxHeight * imgWidth) / imgHeight); slide.height = maxHeight; } }, // Create iframe wrapper, iframe and bindings // ========================================== setIframe: function (slide) { var self = this, opts = slide.opts.iframe, $slide = slide.$slide, $iframe; slide.$content = $('
') .css(opts.css) .appendTo($slide); $slide.addClass("bbcbox-slide--" + slide.contentType); slide.$iframe = $iframe = $(opts.tpl.replace(/\{rnd\}/g, new Date().getTime())) .attr(opts.attr) .appendTo(slide.$content); if (opts.preload) { self.showLoading(slide); // Unfortunately, it is not always possible to determine if iframe is successfully loaded // (due to browser security policy) $iframe.on("load.bbc error.bbc", function (e) { this.isReady = 1; slide.$slide.trigger("refresh"); self.afterLoad(slide); }); // Recalculate iframe content size // =============================== $slide.on("refresh.bbc", function () { var $content = slide.$content, frameWidth = opts.css.width, frameHeight = opts.css.height, $contents, $body; if ($iframe[0].isReady !== 1) { return; } try { $contents = $iframe.contents(); $body = $contents.find("body"); } catch (ignore) {} // Calculate content dimensions, if it is accessible if ($body && $body.length && $body.children().length) { // Avoid scrolling to top (if multiple instances) $slide.css("overflow", "visible"); $content.css({ width: "100%", "max-width": "100%", height: "9999px" }); if (frameWidth === undefined) { frameWidth = Math.ceil(Math.max($body[0].clientWidth, $body.outerWidth(true))); } $content.css("width", frameWidth ? frameWidth : "").css("max-width", ""); if (frameHeight === undefined) { frameHeight = Math.ceil(Math.max($body[0].clientHeight, $body.outerHeight(true))); } $content.css("height", frameHeight ? frameHeight : ""); $slide.css("overflow", "auto"); } $content.removeClass("bbcbox-is-hidden"); }); } else { self.afterLoad(slide); } $iframe.attr("src", slide.src); // Remove iframe if closing or changing gallery item $slide.one("onReset", function () { // This helps IE not to throw errors when closing try { $(this) .find("iframe") .hide() .unbind() .attr("src", "//about:blank"); } catch (ignore) {} $(this) .off("refresh.bbc") .empty(); slide.isLoaded = false; slide.isRevealed = false; }); }, // Wrap and append content to the slide // ====================================== setContent: function (slide, content) { var self = this; if (self.isClosing) { return; } self.hideLoading(slide); if (slide.$content) { $.bbcbox.stop(slide.$content); } slide.$slide.empty(); // If content is a jQuery object, then it will be moved to the slide. // The placeholder is created so we will know where to put it back. if (isQuery(content) && content.parent().length) { // Make sure content is not already moved to bbcbox if (content.hasClass("bbcbox-content") || content.parent().hasClass("bbcbox-content")) { content.parents(".bbcbox-slide").trigger("onReset"); } // Create temporary element marking original place of the content slide.$placeholder = $("
") .hide() .insertAfter(content); // Make sure content is visible content.css("display", "inline-block"); } else if (!slide.hasError) { // If content is just a plain text, try to convert it to html if ($.type(content) === "string") { content = $("
") .append($.trim(content)) .contents(); } // If "filter" option is provided, then filter content if (slide.opts.filter) { content = $("
") .html(content) .find(slide.opts.filter); } } slide.$slide.one("onReset", function () { // Pause all html5 video/audio $(this) .find("video,audio") .trigger("pause"); // Put content back if (slide.$placeholder) { slide.$placeholder.after(content.removeClass("bbcbox-content").hide()).remove(); slide.$placeholder = null; } // Remove custom close button if (slide.$smallBtn) { slide.$smallBtn.remove(); slide.$smallBtn = null; } // Remove content and mark slide as not loaded if (!slide.hasError) { $(this).empty(); slide.isLoaded = false; slide.isRevealed = false; } }); $(content).appendTo(slide.$slide); if ($(content).is("video,audio")) { $(content).addClass("bbcbox-video"); $(content).wrap("
"); slide.contentType = "video"; slide.opts.width = slide.opts.width || $(content).attr("width"); slide.opts.height = slide.opts.height || $(content).attr("height"); } slide.$content = slide.$slide .children() .filter("div,form,main,video,audio,article,.bbcbox-content") .first(); slide.$content.siblings().hide(); // Re-check if there is a valid content // (in some cases, ajax response can contain various elements or plain text) if (!slide.$content.length) { slide.$content = slide.$slide .wrapInner("
") .children() .first(); } slide.$content.addClass("bbcbox-content"); slide.$slide.addClass("bbcbox-slide--" + slide.contentType); self.afterLoad(slide); }, // Display error message // ===================== setError: function (slide) { slide.hasError = true; slide.$slide .trigger("onReset") .removeClass("bbcbox-slide--" + slide.contentType) .addClass("bbcbox-slide--error"); slide.contentType = "html"; this.setContent(slide, this.translate(slide, slide.opts.errorTpl)); if (slide.pos === this.currPos) { this.isAnimating = false; } }, // Show loading icon inside the slide // ================================== showLoading: function (slide) { var self = this; slide = slide || self.current; if (slide && !slide.$spinner) { slide.$spinner = $(self.translate(self, self.opts.spinnerTpl)) .appendTo(slide.$slide) .hide() .fadeIn("fast"); } }, // Remove loading icon from the slide // ================================== hideLoading: function (slide) { var self = this; slide = slide || self.current; if (slide && slide.$spinner) { slide.$spinner.stop().remove(); delete slide.$spinner; } }, // Adjustments after slide content has been loaded // =============================================== afterLoad: function (slide) { var self = this; if (self.isClosing) { return; } slide.isLoading = false; slide.isLoaded = true; self.trigger("afterLoad", slide); self.hideLoading(slide); // Add small close button if (slide.opts.smallBtn && (!slide.$smallBtn || !slide.$smallBtn.length)) { slide.$smallBtn = $(self.translate(slide, slide.opts.btnTpl.smallBtn)).appendTo(slide.$content); } // Disable right click if (slide.opts.protect && slide.$content && !slide.hasError) { slide.$content.on("contextmenu.bbc", function (e) { if (e.button == 2) { e.preventDefault(); } return true; }); // Add fake element on top of the image // This makes a bit harder for user to select image if (slide.type === "image") { $('
').appendTo(slide.$content); } } self.adjustCaption(slide); self.adjustLayout(slide); if (slide.pos === self.currPos) { self.updateCursor(); } self.revealContent(slide); }, // Prevent caption overlap, // fix css inconsistency across browsers // ===================================== adjustCaption: function (slide) { var self = this, current = slide || self.current, caption = current.opts.caption, preventOverlap = current.opts.preventCaptionOverlap, $caption = self.$refs.caption, $clone, captionH = false; $caption.toggleClass("bbcbox-caption--separate", preventOverlap); if (preventOverlap && caption && caption.length) { if (current.pos !== self.currPos) { $clone = $caption.clone().appendTo($caption.parent()); $clone .children() .eq(0) .empty() .html(caption); captionH = $clone.outerHeight(true); $clone.empty().remove(); } else if (self.$caption) { captionH = self.$caption.outerHeight(true); } current.$slide.css("padding-bottom", captionH || ""); } }, // Simple hack to fix inconsistency across browsers, described here (affects Edge, too): // https://bugzilla.mozilla.org/show_bug.cgi?id=748518 // ==================================================================================== adjustLayout: function (slide) { var self = this, current = slide || self.current, scrollHeight, marginBottom, inlinePadding, actualPadding; if (current.isLoaded && current.opts.disableLayoutFix !== true) { current.$content.css("margin-bottom", ""); // If we would always set margin-bottom for the content, // then it would potentially break vertical align if (current.$content.outerHeight() > current.$slide.height() + 0.5) { inlinePadding = current.$slide[0].style["padding-bottom"]; actualPadding = current.$slide.css("padding-bottom"); if (parseFloat(actualPadding) > 0) { scrollHeight = current.$slide[0].scrollHeight; current.$slide.css("padding-bottom", 0); if (Math.abs(scrollHeight - current.$slide[0].scrollHeight) < 1) { marginBottom = actualPadding; } current.$slide.css("padding-bottom", inlinePadding); } } current.$content.css("margin-bottom", marginBottom); } }, // Make content visible // This method is called right after content has been loaded or // user navigates gallery and transition should start // ============================================================ revealContent: function (slide) { var self = this, $slide = slide.$slide, end = false, start = false, isMoved = self.isMoved(slide), isRevealed = slide.isRevealed, effect, effectClassName, duration, opacity; slide.isRevealed = true; effect = slide.opts[self.firstRun ? "animationEffect" : "transitionEffect"]; duration = slide.opts[self.firstRun ? "animationDuration" : "transitionDuration"]; duration = parseInt(slide.forcedDuration === undefined ? duration : slide.forcedDuration, 10); if (isMoved || slide.pos !== self.currPos || !duration) { effect = false; } // Check if can zoom if (effect === "zoom") { if (slide.pos === self.currPos && duration && slide.type === "image" && !slide.hasError && (start = self.getThumbPos(slide))) { end = self.getFitPos(slide); } else { effect = "fade"; } } // Zoom animation // ============== if (effect === "zoom") { self.isAnimating = true; end.scaleX = end.width / start.width; end.scaleY = end.height / start.height; // Check if we need to animate opacity opacity = slide.opts.zoomOpacity; if (opacity == "auto") { opacity = Math.abs(slide.width / slide.height - start.width / start.height) > 0.1; } if (opacity) { start.opacity = 0.1; end.opacity = 1; } // Draw image at start position $.bbcbox.setTranslate(slide.$content.removeClass("bbcbox-is-hidden"), start); forceRedraw(slide.$content); // Start animation $.bbcbox.animate(slide.$content, end, duration, function () { self.isAnimating = false; self.complete(); }); return; } self.updateSlide(slide); // Simply show content if no effect // ================================ if (!effect) { slide.$content.removeClass("bbcbox-is-hidden"); if (!isRevealed && isMoved && slide.type === "image" && !slide.hasError) { slide.$content.hide().fadeIn("fast"); } if (slide.pos === self.currPos) { self.complete(); } return; } // Prepare for CSS transiton // ========================= $.bbcbox.stop($slide); //effectClassName = "bbcbox-animated bbcbox-slide--" + (slide.pos >= self.prevPos ? "next" : "previous") + " bbcbox-fx-" + effect; effectClassName = "bbcbox-slide--" + (slide.pos >= self.prevPos ? "next" : "previous") + " bbcbox-animated bbcbox-fx-" + effect; $slide.addClass(effectClassName).removeClass("bbcbox-slide--current"); //.addClass(effectClassName); slide.$content.removeClass("bbcbox-is-hidden"); // Force reflow forceRedraw($slide); if (slide.type !== "image") { slide.$content.hide().show(0); } $.bbcbox.animate( $slide, "bbcbox-slide--current", duration, function () { $slide.removeClass(effectClassName).css({ transform: "", opacity: "" }); if (slide.pos === self.currPos) { self.complete(); } }, true ); }, // Check if we can and have to zoom from thumbnail //================================================ getThumbPos: function (slide) { var rez = false, $thumb = slide.$thumb, thumbPos, btw, brw, bbw, blw; if (!$thumb || !inViewport($thumb[0])) { return false; } thumbPos = $.bbcbox.getTranslate($thumb); btw = parseFloat($thumb.css("border-top-width") || 0); brw = parseFloat($thumb.css("border-right-width") || 0); bbw = parseFloat($thumb.css("border-bottom-width") || 0); blw = parseFloat($thumb.css("border-left-width") || 0); rez = { top: thumbPos.top + btw, left: thumbPos.left + blw, width: thumbPos.width - brw - blw, height: thumbPos.height - btw - bbw, scaleX: 1, scaleY: 1 }; return thumbPos.width > 0 && thumbPos.height > 0 ? rez : false; }, // Final adjustments after current gallery item is moved to position // and it`s content is loaded // ================================================================== complete: function () { var self = this, current = self.current, slides = {}, $el; if (self.isMoved() || !current.isLoaded) { return; } if (!current.isComplete) { current.isComplete = true; current.$slide.siblings().trigger("onReset"); self.preload("inline"); // Trigger any CSS transiton inside the slide forceRedraw(current.$slide); current.$slide.addClass("bbcbox-slide--complete"); // Remove unnecessary slides $.each(self.slides, function (key, slide) { if (slide.pos >= self.currPos - 1 && slide.pos <= self.currPos + 1) { slides[slide.pos] = slide; } else if (slide) { $.bbcbox.stop(slide.$slide); slide.$slide.off().remove(); } }); self.slides = slides; } self.isAnimating = false; self.updateCursor(); self.trigger("afterShow"); // Autoplay first html5 video/audio if (!!current.opts.video.autoStart) { current.$slide .find("video,audio") .filter(":visible:first") .trigger("play") .one("ended", function () { if (Document.exitFullscreen) { Document.exitFullscreen(); } else if (this.webkitExitFullscreen) { this.webkitExitFullscreen(); } self.next(); }); } // Try to focus on the first focusable element if (current.opts.autoFocus && current.contentType === "html") { // Look for the first input with autofocus attribute $el = current.$content.find("input[autofocus]:enabled:visible:first"); if ($el.length) { $el.trigger("focus"); } else { self.focus(null, true); } } // Avoid jumping current.$slide.scrollTop(0).scrollLeft(0); }, // Preload next and previous slides // ================================ preload: function (type) { var self = this, prev, next; if (self.group.length < 2) { return; } next = self.slides[self.currPos + 1]; prev = self.slides[self.currPos - 1]; if (prev && prev.type === type) { self.loadSlide(prev); } if (next && next.type === type) { self.loadSlide(next); } }, // Try to find and focus on the first focusable element // ==================================================== focus: function (e, firstRun) { var self = this, focusableStr = [ "a[href]", "area[href]", 'input:not([disabled]):not([type="hidden"]):not([aria-hidden])', "select:not([disabled]):not([aria-hidden])", "textarea:not([disabled]):not([aria-hidden])", "button:not([disabled]):not([aria-hidden])", "iframe", "object", "embed", "video", "audio", "[contenteditable]", '[tabindex]:not([tabindex^="-"])' ].join(","), focusableItems, focusedItemIndex; if (self.isClosing) { return; } if (e || !self.current || !self.current.isComplete) { // Focus on any element inside bbcbox focusableItems = self.$refs.container.find("*:visible"); } else { // Focus inside current slide focusableItems = self.current.$slide.find("*:visible" + (firstRun ? ":not(.bbcbox-close-small)" : "")); } focusableItems = focusableItems.filter(focusableStr).filter(function () { return $(this).css("visibility") !== "hidden" && !$(this).hasClass("disabled"); }); if (focusableItems.length) { focusedItemIndex = focusableItems.index(document.activeElement); if (e && e.shiftKey) { // Back tab if (focusedItemIndex < 0 || focusedItemIndex == 0) { e.preventDefault(); focusableItems.eq(focusableItems.length - 1).trigger("focus"); } } else { // Outside or Forward tab if (focusedItemIndex < 0 || focusedItemIndex == focusableItems.length - 1) { if (e) { e.preventDefault(); } focusableItems.eq(0).trigger("focus"); } } } else { self.$refs.container.trigger("focus"); } }, // Activates current instance - brings container to the front and enables keyboard, // notifies other instances about deactivating // ================================================================================= activate: function () { var self = this; // Deactivate all instances $(".bbcbox-container").each(function () { var instance = $(this).data("bbcbox"); // Skip self and closing instances if (instance && instance.id !== self.id && !instance.isClosing) { instance.trigger("onDeactivate"); instance.removeEvents(); instance.isVisible = false; } }); self.isVisible = true; if (self.current || self.isIdle) { self.update(); self.updateControls(); } self.trigger("onActivate"); self.addEvents(); }, // Start closing procedure // This will start "zoom-out" animation if needed and clean everything up afterwards // ================================================================================= close: function (e, d) { var self = this, current = self.current, effect, duration, $content, domRect, opacity, start, end; var done = function () { self.cleanUp(e); }; if (self.isClosing) { return false; } self.isClosing = true; // If beforeClose callback prevents closing, make sure content is centered if (self.trigger("beforeClose", e) === false) { self.isClosing = false; requestAFrame(function () { self.update(); }); return false; } // Remove all events // If there are multiple instances, they will be set again by "activate" method self.removeEvents(); $content = current.$content; effect = current.opts.animationEffect; duration = $.isNumeric(d) ? d : effect ? current.opts.animationDuration : 0; current.$slide.removeClass("bbcbox-slide--complete bbcbox-slide--next bbcbox-slide--previous bbcbox-animated"); if (e !== true) { $.bbcbox.stop(current.$slide); } else { effect = false; } // Remove other slides current.$slide .siblings() .trigger("onReset") .remove(); // Trigger animations if (duration) { self.$refs.container .removeClass("bbcbox-is-open") .addClass("bbcbox-is-closing") .css("transition-duration", duration + "ms"); } // Clean up self.hideLoading(current); self.hideControls(true); self.updateCursor(); // Check if possible to zoom-out if ( effect === "zoom" && !($content && duration && current.type === "image" && !self.isMoved() && !current.hasError && (end = self.getThumbPos(current))) ) { effect = "fade"; } if (effect === "zoom") { $.bbcbox.stop($content); domRect = $.bbcbox.getTranslate($content); start = { top: domRect.top, left: domRect.left, scaleX: domRect.width / end.width, scaleY: domRect.height / end.height, width: end.width, height: end.height }; // Check if we need to animate opacity opacity = current.opts.zoomOpacity; if (opacity == "auto") { opacity = Math.abs(current.width / current.height - end.width / end.height) > 0.1; } if (opacity) { end.opacity = 0; } $.bbcbox.setTranslate($content, start); forceRedraw($content); $.bbcbox.animate($content, end, duration, done); return true; } if (effect && duration) { $.bbcbox.animate( current.$slide.addClass("bbcbox-slide--previous").removeClass("bbcbox-slide--current"), "bbcbox-animated bbcbox-fx-" + effect, duration, done ); } else { // If skip animation if (e === true) { setTimeout(done, duration); } else { done(); } } return true; }, // Final adjustments after removing the instance // ============================================= cleanUp: function (e) { var self = this, instance, $focus = self.current.opts.$orig, x, y; self.current.$slide.trigger("onReset"); self.$refs.container.empty().remove(); self.trigger("afterClose", e); // Place back focus if (!!self.current.opts.backFocus) { if (!$focus || !$focus.length || !$focus.is(":visible")) { $focus = self.$trigger; } if ($focus && $focus.length) { x = window.scrollX; y = window.scrollY; $focus.trigger("focus"); $("html, body") .scrollTop(y) .scrollLeft(x); } } self.current = null; // Check if there are other instances instance = $.bbcbox.getInstance(); if (instance) { instance.activate(); } else { $("body").removeClass("bbcbox-active compensate-for-scrollbar"); $("#bbcbox-style-noscroll").remove(); } }, // Call callback and trigger an event // ================================== trigger: function (name, slide) { var args = Array.prototype.slice.call(arguments, 1), self = this, obj = slide && slide.opts ? slide : self.current, rez; if (obj) { args.unshift(obj); } else { obj = self; } args.unshift(self); if ($.isFunction(obj.opts[name])) { rez = obj.opts[name].apply(obj, args); } if (rez === false) { return rez; } if (name === "afterClose" || !self.$refs) { $D.trigger(name + ".bbc", args); } else { self.$refs.container.trigger(name + ".bbc", args); } }, // Update infobar values, navigation button states and reveal caption // ================================================================== updateControls: function () { var self = this, current = self.current, index = current.index, $container = self.$refs.container, $caption = self.$refs.caption, caption = current.opts.caption; // Recalculate content dimensions current.$slide.trigger("refresh"); // Set caption if (caption && caption.length) { self.$caption = $caption; $caption .children() .eq(0) .html(caption); } else { self.$caption = null; } if (!self.hasHiddenControls && !self.isIdle) { self.showControls(); } // Update info and navigation elements $container.find("[data-bbcbox-count]").html(self.group.length); $container.find("[data-bbcbox-index]").html(index + 1); $container.find("[data-bbcbox-prev]").prop("disabled", !current.opts.loop && index <= 0); $container.find("[data-bbcbox-next]").prop("disabled", !current.opts.loop && index >= self.group.length - 1); if (current.type === "image") { // Re-enable buttons; update download button source $container .find("[data-bbcbox-zoom]") .show() .end() .find("[data-bbcbox-download]") .attr("href", current.opts.image.src || current.src) .show(); } else if (current.opts.toolbar) { $container.find("[data-bbcbox-download],[data-bbcbox-zoom]").hide(); } // Make sure focus is not on disabled button/element if ($(document.activeElement).is(":hidden,[disabled]")) { self.$refs.container.trigger("focus"); } }, // Hide toolbar and caption // ======================== hideControls: function (andCaption) { var self = this, arr = ["infobar", "toolbar", "nav"]; if (andCaption || !self.current.opts.preventCaptionOverlap) { arr.push("caption"); } this.$refs.container.removeClass( arr .map(function (i) { return "bbcbox-show-" + i; }) .join(" ") ); this.hasHiddenControls = true; }, showControls: function () { var self = this, opts = self.current ? self.current.opts : self.opts, $container = self.$refs.container; self.hasHiddenControls = false; self.idleSecondsCounter = 0; $container .toggleClass("bbcbox-show-toolbar", !!(opts.toolbar && opts.buttons)) .toggleClass("bbcbox-show-infobar", !!(opts.infobar && self.group.length > 1)) .toggleClass("bbcbox-show-caption", !!self.$caption) .toggleClass("bbcbox-show-nav", !!(opts.arrows && self.group.length > 1)) .toggleClass("bbcbox-is-modal", !!opts.modal); }, // Toggle toolbar and caption // ========================== toggleControls: function () { if (this.hasHiddenControls) { this.showControls(); } else { this.hideControls(); } } }); $.bbcbox = { version: "3.5.7", defaults: defaults, // Get current instance and execute a command. // // Examples of usage: // // $instance = $.bbcbox.getInstance(); // $.bbcbox.getInstance().jumpTo( 1 ); // $.bbcbox.getInstance( 'jumpTo', 1 ); // $.bbcbox.getInstance( function() { // console.info( this.currIndex ); // }); // ====================================================== getInstance: function (command) { var instance = $('.bbcbox-container:not(".bbcbox-is-closing"):last').data("bbcbox"), args = Array.prototype.slice.call(arguments, 1); if (instance instanceof bbcbox) { if ($.type(command) === "string") { instance[command].apply(instance, args); } else if ($.type(command) === "function") { command.apply(instance, args); } return instance; } return false; }, // Create new instance // =================== open: function (items, opts, index) { return new bbcbox(items, opts, index); }, // Close current or all instances // ============================== close: function (all) { var instance = this.getInstance(); if (instance) { instance.close(); // Try to find and close next instance if (all === true) { this.close(all); } } }, // Close all instances and unbind all events // ========================================= destroy: function () { this.close(true); $D.add("body").off("click.bbc-start", "**"); }, // Try to detect mobile devices // ============================ isMobile: /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent), // Detect if 'translate3d' support is available // ============================================ use3d: (function () { var div = document.createElement("div"); return ( window.getComputedStyle && window.getComputedStyle(div) && window.getComputedStyle(div).getPropertyValue("transform") && !(document.documentMode && document.documentMode < 11) ); })(), // Helper function to get current visual state of an element // returns array[ top, left, horizontal-scale, vertical-scale, opacity ] // ===================================================================== getTranslate: function ($el) { var domRect; if (!$el || !$el.length) { return false; } domRect = $el[0].getBoundingClientRect(); return { top: domRect.top || 0, left: domRect.left || 0, width: domRect.width, height: domRect.height, opacity: parseFloat($el.css("opacity")) }; }, // Shortcut for setting "translate3d" properties for element // Can set be used to set opacity, too // ======================================================== setTranslate: function ($el, props) { var str = "", css = {}; if (!$el || !props) { return; } if (props.left !== undefined || props.top !== undefined) { str = (props.left === undefined ? $el.position().left : props.left) + "px, " + (props.top === undefined ? $el.position().top : props.top) + "px"; if (this.use3d) { str = "translate3d(" + str + ", 0px)"; } else { str = "translate(" + str + ")"; } } if (props.scaleX !== undefined && props.scaleY !== undefined) { str += " scale(" + props.scaleX + ", " + props.scaleY + ")"; } else if (props.scaleX !== undefined) { str += " scaleX(" + props.scaleX + ")"; } if (str.length) { css.transform = str; } if (props.opacity !== undefined) { css.opacity = props.opacity; } if (props.width !== undefined) { css.width = props.width; } if (props.height !== undefined) { css.height = props.height; } return $el.css(css); }, // Simple CSS transition handler // ============================= animate: function ($el, to, duration, callback, leaveAnimationName) { var self = this, from; if ($.isFunction(duration)) { callback = duration; duration = null; } self.stop($el); from = self.getTranslate($el); $el.on(transitionEnd, function (e) { // Skip events from child elements and z-index change if (e && e.originalEvent && (!$el.is(e.originalEvent.target) || e.originalEvent.propertyName == "z-index")) { return; } self.stop($el); if ($.isNumeric(duration)) { $el.css("transition-duration", ""); } if ($.isPlainObject(to)) { if (to.scaleX !== undefined && to.scaleY !== undefined) { self.setTranslate($el, { top: to.top, left: to.left, width: from.width * to.scaleX, height: from.height * to.scaleY, scaleX: 1, scaleY: 1 }); } } else if (leaveAnimationName !== true) { $el.removeClass(to); } if ($.isFunction(callback)) { callback(e); } }); if ($.isNumeric(duration)) { $el.css("transition-duration", duration + "ms"); } // Start animation by changing CSS properties or class name if ($.isPlainObject(to)) { if (to.scaleX !== undefined && to.scaleY !== undefined) { delete to.width; delete to.height; if ($el.parent().hasClass("bbcbox-slide--image")) { $el.parent().addClass("bbcbox-is-scaling"); } } $.bbcbox.setTranslate($el, to); } else { $el.addClass(to); } // Make sure that `transitionend` callback gets fired $el.data( "timer", setTimeout(function () { $el.trigger(transitionEnd); }, duration + 33) ); }, stop: function ($el, callCallback) { if ($el && $el.length) { clearTimeout($el.data("timer")); if (callCallback) { $el.trigger(transitionEnd); } $el.off(transitionEnd).css("transition-duration", ""); $el.parent().removeClass("bbcbox-is-scaling"); } } }; // Default click handler for "bbcboxed" links // ============================================ function _run(e, opts) { var items = [], index = 0, $target, value, instance; // Avoid opening multiple times if (e && e.isDefaultPrevented()) { return; } e.preventDefault(); opts = opts || {}; if (e && e.data) { opts = mergeOpts(e.data.options, opts); } $target = opts.$target || $(e.currentTarget).trigger("blur"); instance = $.bbcbox.getInstance(); if (instance && instance.$trigger && instance.$trigger.is($target)) { return; } if (opts.selector) { items = $(opts.selector); } else { // Get all related items and find index for clicked one value = $target.attr("data-bbcbox") || ""; if (value) { items = e.data ? e.data.items : []; items = items.length ? items.filter('[data-bbcbox="' + value + '"]') : $('[data-bbcbox="' + value + '"]'); } else { items = [$target]; } } index = $(items).index($target); // Sometimes current item can not be found if (index < 0) { index = 0; } instance = $.bbcbox.open(items, opts, index); // Save last active element instance.$trigger = $target; } // Create a jQuery plugin // ====================== $.fn.bbcbox = function (options) { var selector; options = options || {}; selector = options.selector || false; if (selector) { // Use body element instead of document so it executes first $("body") .off("click.bbc-start", selector) .on("click.bbc-start", selector, { options: options }, _run); } else { this.off("click.bbc-start").on( "click.bbc-start", { items: this, options: options }, _run ); } return this; }; // Self initializing plugin for all elements having `data-bbcbox` attribute // ========================================================================== $D.on("click.bbc-start", "[data-bbcbox]", _run); // Enable "trigger elements" // ========================= $D.on("click.bbc-start", "[data-bbcbox-trigger]", function (e) { $('[data-bbcbox="' + $(this).attr("data-bbcbox-trigger") + '"]') .eq($(this).attr("data-bbcbox-index") || 0) .trigger("click.bbc-start", { $trigger: $(this) }); }); // Track focus event for better accessibility styling // ================================================== (function () { var buttonStr = ".bbcbox-button", focusStr = "bbcbox-focus", $pressed = null; $D.on("mousedown mouseup focus blur", buttonStr, function (e) { switch (e.type) { case "mousedown": $pressed = $(this); break; case "mouseup": $pressed = null; break; case "focusin": $(buttonStr).removeClass(focusStr); if (!$(this).is($pressed) && !$(this).is("[disabled]")) { $(this).addClass(focusStr); } break; case "focusout": $(buttonStr).removeClass(focusStr); break; } }); })(); })(window, document, jQuery); // ========================================================================== // // Media // Adds additional media type support // // ========================================================================== (function ($) { "use strict"; // Object containing properties for each media type var defaults = { youtube: { matcher: /(youtube\.com|youtu\.be|youtube\-nocookie\.com)\/(watch\?(.*&)?v=|v\/|u\/|embed\/?)?(videoseries\?list=(.*)|[\w-]{11}|\?listType=(.*)&list=(.*))(.*)/i, params: { autoplay: 1, autohide: 1, fs: 1, rel: 0, hd: 1, wmode: "transparent", enablejsapi: 1, html5: 1 }, paramPlace: 8, type: "iframe", url: "https://www.youtube-nocookie.com/embed/$4", thumb: "https://img.youtube.com/vi/$4/hqdefault.jpg" }, vimeo: { matcher: /^.+vimeo.com\/(.*\/)?([\d]+)(.*)?/, params: { autoplay: 1, hd: 1, show_title: 1, show_byline: 1, show_portrait: 0, fullscreen: 1 }, paramPlace: 3, type: "iframe", url: "//player.vimeo.com/video/$2" }, instagram: { matcher: /(instagr\.am|instagram\.com)\/p\/([a-zA-Z0-9_\-]+)\/?/i, type: "image", url: "//$1/p/$2/media/?size=l" }, // Examples: // http://maps.google.com/?ll=48.857995,2.294297&spn=0.007666,0.021136&t=m&z=16 // https://www.google.com/maps/@37.7852006,-122.4146355,14.65z // https://www.google.com/maps/@52.2111123,2.9237542,6.61z?hl=en // https://www.google.com/maps/place/Googleplex/@37.4220041,-122.0833494,17z/data=!4m5!3m4!1s0x0:0x6c296c66619367e0!8m2!3d37.4219998!4d-122.0840572 gmap_place: { matcher: /(maps\.)?google\.([a-z]{2,3}(\.[a-z]{2})?)\/(((maps\/(place\/(.*)\/)?\@(.*),(\d+.?\d+?)z))|(\?ll=))(.*)?/i, type: "iframe", url: function (rez) { return ( "//maps.google." + rez[2] + "/?ll=" + (rez[9] ? rez[9] + "&z=" + Math.floor(rez[10]) + (rez[12] ? rez[12].replace(/^\//, "&") : "") : rez[12] + "").replace(/\?/, "&") + "&output=" + (rez[12] && rez[12].indexOf("layer=c") > 0 ? "svembed" : "embed") ); } }, // Examples: // https://www.google.com/maps/search/Empire+State+Building/ // https://www.google.com/maps/search/?api=1&query=centurylink+field // https://www.google.com/maps/search/?api=1&query=47.5951518,-122.3316393 gmap_search: { matcher: /(maps\.)?google\.([a-z]{2,3}(\.[a-z]{2})?)\/(maps\/search\/)(.*)/i, type: "iframe", url: function (rez) { return "//maps.google." + rez[2] + "/maps?q=" + rez[5].replace("query=", "q=").replace("api=1", "") + "&output=embed"; } } }; // Formats matching url to final form var format = function (url, rez, params) { if (!url) { return; } params = params || ""; if ($.type(params) === "object") { params = $.param(params, true); } $.each(rez, function (key, value) { url = url.replace("$" + key, value || ""); }); if (params.length) { url += (url.indexOf("?") > 0 ? "&" : "?") + params; } return url; }; $(document).on("objectNeedsType.bbc", function (e, instance, item) { var url = item.src || "", type = false, media, thumb, rez, params, urlParams, paramObj, provider; media = $.extend(true, {}, defaults, item.opts.media); // Look for any matching media type $.each(media, function (providerName, providerOpts) { rez = url.match(providerOpts.matcher); if (!rez) { return; } type = providerOpts.type; provider = providerName; paramObj = {}; if (providerOpts.paramPlace && rez[providerOpts.paramPlace]) { urlParams = rez[providerOpts.paramPlace]; if (urlParams[0] == "?") { urlParams = urlParams.substring(1); } urlParams = urlParams.split("&"); for (var m = 0; m < urlParams.length; ++m) { var p = urlParams[m].split("=", 2); if (p.length == 2) { paramObj[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " ")); } } } params = $.extend(true, {}, providerOpts.params, item.opts[providerName], paramObj); url = $.type(providerOpts.url) === "function" ? providerOpts.url.call(this, rez, params, item) : format(providerOpts.url, rez, params); thumb = $.type(providerOpts.thumb) === "function" ? providerOpts.thumb.call(this, rez, params, item) : format(providerOpts.thumb, rez); if (providerName === "youtube") { url = url.replace(/&t=((\d+)m)?(\d+)s/, function (match, p1, m, s) { return "&start=" + ((m ? parseInt(m, 10) * 60 : 0) + parseInt(s, 10)); }); } else if (providerName === "vimeo") { url = url.replace("&%23", "#"); } return false; }); // If it is found, then change content type and update the url if (type) { if (!item.opts.thumb && !(item.opts.$thumb && item.opts.$thumb.length)) { item.opts.thumb = thumb; } if (type === "iframe") { item.opts = $.extend(true, item.opts, { iframe: { preload: false, attr: { scrolling: "no" } } }); } $.extend(item, { type: type, src: url, origSrc: item.src, contentSource: provider, contentType: type === "image" ? "image" : provider == "gmap_place" || provider == "gmap_search" ? "map" : "video" }); } else if (url) { item.type = item.opts.defaultType; } }); // Load YouTube/Video API on request to detect when video finished playing var VideoAPILoader = { youtube: { src: "https://www.youtube.com/iframe_api", class: "YT", loading: false, loaded: false }, vimeo: { src: "https://player.vimeo.com/api/player.js", class: "Vimeo", loading: false, loaded: false }, load: function (vendor) { var _this = this, script; if (this[vendor].loaded) { setTimeout(function () { _this.done(vendor); }); return; } if (this[vendor].loading) { return; } this[vendor].loading = true; script = document.createElement("script"); script.type = "text/javascript"; script.src = this[vendor].src; if (vendor === "youtube") { window.onYouTubeIframeAPIReady = function () { _this[vendor].loaded = true; _this.done(vendor); }; } else { script.onload = function () { _this[vendor].loaded = true; _this.done(vendor); }; } document.body.appendChild(script); }, done: function (vendor) { var instance, $el, player; if (vendor === "youtube") { delete window.onYouTubeIframeAPIReady; } instance = $.bbcbox.getInstance(); if (instance) { $el = instance.current.$content.find("iframe"); if (vendor === "youtube" && YT !== undefined && YT) { player = new YT.Player($el.attr("id"), { events: { onStateChange: function (e) { if (e.data == 0) { instance.next(); } } } }); } else if (vendor === "vimeo" && Vimeo !== undefined && Vimeo) { player = new Vimeo.Player($el); player.on("ended", function () { instance.next(); }); } } } }; $(document).on({ "afterShow.bbc": function (e, instance, current) { if (instance.group.length > 1 && (current.contentSource === "youtube" || current.contentSource === "vimeo")) { VideoAPILoader.load(current.contentSource); } } }); })(jQuery); // ========================================================================== // // Guestures // Adds touch guestures, handles click and tap events // // ========================================================================== (function (window, document, $) { "use strict"; var requestAFrame = (function () { return ( window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || // if all else fails, use setTimeout function (callback) { return window.setTimeout(callback, 1000 / 60); } ); })(); var cancelAFrame = (function () { return ( window.cancelAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame || window.oCancelAnimationFrame || function (id) { window.clearTimeout(id); } ); })(); var getPointerXY = function (e) { var result = []; e = e.originalEvent || e || window.e; e = e.touches && e.touches.length ? e.touches : e.changedTouches && e.changedTouches.length ? e.changedTouches : [e]; for (var key in e) { if (e[key].pageX) { result.push({ x: e[key].pageX, y: e[key].pageY }); } else if (e[key].clientX) { result.push({ x: e[key].clientX, y: e[key].clientY }); } } return result; }; var distance = function (point2, point1, what) { if (!point1 || !point2) { return 0; } if (what === "x") { return point2.x - point1.x; } else if (what === "y") { return point2.y - point1.y; } return Math.sqrt(Math.pow(point2.x - point1.x, 2) + Math.pow(point2.y - point1.y, 2)); }; var isClickable = function ($el) { if ( $el.is('a,area,button,[role="button"],input,label,select,summary,textarea,video,audio,iframe') || $.isFunction($el.get(0).onclick) || $el.data("selectable") ) { return true; } // Check for attributes like data-bbcbox-next or data-bbcbox-close for (var i = 0, atts = $el[0].attributes, n = atts.length; i < n; i++) { if (atts[i].nodeName.substr(0, 14) === "data-bbcbox-") { return true; } } return false; }; var hasScrollbars = function (el) { var overflowY = window.getComputedStyle(el)["overflow-y"], overflowX = window.getComputedStyle(el)["overflow-x"], vertical = (overflowY === "scroll" || overflowY === "auto") && el.scrollHeight > el.clientHeight, horizontal = (overflowX === "scroll" || overflowX === "auto") && el.scrollWidth > el.clientWidth; return vertical || horizontal; }; var isScrollable = function ($el) { var rez = false; while (true) { rez = hasScrollbars($el.get(0)); if (rez) { break; } $el = $el.parent(); if (!$el.length || $el.hasClass("bbcbox-stage") || $el.is("body")) { break; } } return rez; }; var Guestures = function (instance) { var self = this; self.instance = instance; self.$bg = instance.$refs.bg; self.$stage = instance.$refs.stage; self.$container = instance.$refs.container; self.destroy(); self.$container.on("touchstart.bbc.touch mousedown.bbc.touch", $.proxy(self, "ontouchstart")); }; Guestures.prototype.destroy = function () { var self = this; self.$container.off(".bbc.touch"); $(document).off(".bbc.touch"); if (self.requestId) { cancelAFrame(self.requestId); self.requestId = null; } if (self.tapped) { clearTimeout(self.tapped); self.tapped = null; } }; Guestures.prototype.ontouchstart = function (e) { var self = this, $target = $(e.target), instance = self.instance, current = instance.current, $slide = current.$slide, $content = current.$content, isTouchDevice = e.type == "touchstart"; // Do not respond to both (touch and mouse) events if (isTouchDevice) { self.$container.off("mousedown.bbc.touch"); } // Ignore right click if (e.originalEvent && e.originalEvent.button == 2) { return; } // Ignore taping on links, buttons, input elements if (!$slide.length || !$target.length || isClickable($target) || isClickable($target.parent())) { return; } // Ignore clicks on the scrollbar if (!$target.is("img") && e.originalEvent.clientX > $target[0].clientWidth + $target.offset().left) { return; } // Ignore clicks while zooming or closing if (!current || instance.isAnimating || current.$slide.hasClass("bbcbox-animated")) { e.stopPropagation(); e.preventDefault(); return; } self.realPoints = self.startPoints = getPointerXY(e); if (!self.startPoints.length) { return; } // Allow other scripts to catch touch event if "touch" is set to false if (current.touch) { e.stopPropagation(); } self.startEvent = e; self.canTap = true; self.$target = $target; self.$content = $content; self.opts = current.opts.touch; self.isPanning = false; self.isSwiping = false; self.isZooming = false; self.isScrolling = false; self.canPan = instance.canPan(); self.startTime = new Date().getTime(); self.distanceX = self.distanceY = self.distance = 0; self.canvasWidth = Math.round($slide[0].clientWidth); self.canvasHeight = Math.round($slide[0].clientHeight); self.contentLastPos = null; self.contentStartPos = $.bbcbox.getTranslate(self.$content) || { top: 0, left: 0 }; self.sliderStartPos = $.bbcbox.getTranslate($slide); // Since position will be absolute, but we need to make it relative to the stage self.stagePos = $.bbcbox.getTranslate(instance.$refs.stage); self.sliderStartPos.top -= self.stagePos.top; self.sliderStartPos.left -= self.stagePos.left; self.contentStartPos.top -= self.stagePos.top; self.contentStartPos.left -= self.stagePos.left; $(document) .off(".bbc.touch") .on(isTouchDevice ? "touchend.bbc.touch touchcancel.bbc.touch" : "mouseup.bbc.touch mouseleave.bbc.touch", $.proxy(self, "ontouchend")) .on(isTouchDevice ? "touchmove.bbc.touch" : "mousemove.bbc.touch", $.proxy(self, "ontouchmove")); if ($.bbcbox.isMobile) { document.addEventListener("scroll", self.onscroll, true); } // Skip if clicked outside the sliding area if (!(self.opts || self.canPan) || !($target.is(self.$stage) || self.$stage.find($target).length)) { if ($target.is(".bbcbox-image")) { e.preventDefault(); } if (!($.bbcbox.isMobile && $target.parents(".bbcbox-caption").length)) { return; } } self.isScrollable = isScrollable($target) || isScrollable($target.parent()); // Check if element is scrollable and try to prevent default behavior (scrolling) if (!($.bbcbox.isMobile && self.isScrollable)) { e.preventDefault(); } // One finger or mouse click - swipe or pan an image if (self.startPoints.length === 1 || current.hasError) { if (self.canPan) { $.bbcbox.stop(self.$content); self.isPanning = true; } else { self.isSwiping = true; } self.$container.addClass("bbcbox-is-grabbing"); } // Two fingers - zoom image if (self.startPoints.length === 2 && current.type === "image" && (current.isLoaded || current.$ghost)) { self.canTap = false; self.isSwiping = false; self.isPanning = false; self.isZooming = true; $.bbcbox.stop(self.$content); self.centerPointStartX = (self.startPoints[0].x + self.startPoints[1].x) * 0.5 - $(window).scrollLeft(); self.centerPointStartY = (self.startPoints[0].y + self.startPoints[1].y) * 0.5 - $(window).scrollTop(); self.percentageOfImageAtPinchPointX = (self.centerPointStartX - self.contentStartPos.left) / self.contentStartPos.width; self.percentageOfImageAtPinchPointY = (self.centerPointStartY - self.contentStartPos.top) / self.contentStartPos.height; self.startDistanceBetweenFingers = distance(self.startPoints[0], self.startPoints[1]); } }; Guestures.prototype.onscroll = function (e) { var self = this; self.isScrolling = true; document.removeEventListener("scroll", self.onscroll, true); }; Guestures.prototype.ontouchmove = function (e) { var self = this; // Make sure user has not released over iframe or disabled element if (e.originalEvent.buttons !== undefined && e.originalEvent.buttons === 0) { self.ontouchend(e); return; } if (self.isScrolling) { self.canTap = false; return; } self.newPoints = getPointerXY(e); if (!(self.opts || self.canPan) || !self.newPoints.length || !self.newPoints.length) { return; } if (!(self.isSwiping && self.isSwiping === true)) { e.preventDefault(); } self.distanceX = distance(self.newPoints[0], self.startPoints[0], "x"); self.distanceY = distance(self.newPoints[0], self.startPoints[0], "y"); self.distance = distance(self.newPoints[0], self.startPoints[0]); // Skip false ontouchmove events (Chrome) if (self.distance > 0) { if (self.isSwiping) { self.onSwipe(e); } else if (self.isPanning) { self.onPan(); } else if (self.isZooming) { self.onZoom(); } } }; Guestures.prototype.onSwipe = function (e) { var self = this, instance = self.instance, swiping = self.isSwiping, left = self.sliderStartPos.left || 0, angle; // If direction is not yet determined if (swiping === true) { // We need at least 10px distance to correctly calculate an angle if (Math.abs(self.distance) > 10) { self.canTap = false; if (instance.group.length < 2 && self.opts.vertical) { self.isSwiping = "y"; } else if (instance.isDragging || self.opts.vertical === false || (self.opts.vertical === "auto" && $(window).width() > 800)) { self.isSwiping = "x"; } else { angle = Math.abs((Math.atan2(self.distanceY, self.distanceX) * 180) / Math.PI); self.isSwiping = angle > 45 && angle < 135 ? "y" : "x"; } if (self.isSwiping === "y" && $.bbcbox.isMobile && self.isScrollable) { self.isScrolling = true; return; } instance.isDragging = self.isSwiping; // Reset points to avoid jumping, because we dropped first swipes to calculate the angle self.startPoints = self.newPoints; $.each(instance.slides, function (index, slide) { var slidePos, stagePos; $.bbcbox.stop(slide.$slide); slidePos = $.bbcbox.getTranslate(slide.$slide); stagePos = $.bbcbox.getTranslate(instance.$refs.stage); slide.$slide .css({ transform: "", opacity: "", "transition-duration": "" }) .removeClass("bbcbox-animated") .removeClass(function (index, className) { return (className.match(/(^|\s)bbcbox-fx-\S+/g) || []).join(" "); }); if (slide.pos === instance.current.pos) { self.sliderStartPos.top = slidePos.top - stagePos.top; self.sliderStartPos.left = slidePos.left - stagePos.left; } $.bbcbox.setTranslate(slide.$slide, { top: slidePos.top - stagePos.top, left: slidePos.left - stagePos.left }); }); // Stop slideshow if (instance.SlideShow && instance.SlideShow.isActive) { instance.SlideShow.stop(); } } return; } // Sticky edges if (swiping == "x") { if ( self.distanceX > 0 && (self.instance.group.length < 2 || (self.instance.current.index === 0 && !self.instance.current.opts.loop)) ) { left = left + Math.pow(self.distanceX, 0.8); } else if ( self.distanceX < 0 && (self.instance.group.length < 2 || (self.instance.current.index === self.instance.group.length - 1 && !self.instance.current.opts.loop)) ) { left = left - Math.pow(-self.distanceX, 0.8); } else { left = left + self.distanceX; } } self.sliderLastPos = { top: swiping == "x" ? 0 : self.sliderStartPos.top + self.distanceY, left: left }; if (self.requestId) { cancelAFrame(self.requestId); self.requestId = null; } self.requestId = requestAFrame(function () { if (self.sliderLastPos) { $.each(self.instance.slides, function (index, slide) { var pos = slide.pos - self.instance.currPos; $.bbcbox.setTranslate(slide.$slide, { top: self.sliderLastPos.top, left: self.sliderLastPos.left + pos * self.canvasWidth + pos * slide.opts.gutter }); }); self.$container.addClass("bbcbox-is-sliding"); } }); }; Guestures.prototype.onPan = function () { var self = this; // Prevent accidental movement (sometimes, when tapping casually, finger can move a bit) if (distance(self.newPoints[0], self.realPoints[0]) < ($.bbcbox.isMobile ? 10 : 5)) { self.startPoints = self.newPoints; return; } self.canTap = false; self.contentLastPos = self.limitMovement(); if (self.requestId) { cancelAFrame(self.requestId); } self.requestId = requestAFrame(function () { $.bbcbox.setTranslate(self.$content, self.contentLastPos); }); }; // Make panning sticky to the edges Guestures.prototype.limitMovement = function () { var self = this; var canvasWidth = self.canvasWidth; var canvasHeight = self.canvasHeight; var distanceX = self.distanceX; var distanceY = self.distanceY; var contentStartPos = self.contentStartPos; var currentOffsetX = contentStartPos.left; var currentOffsetY = contentStartPos.top; var currentWidth = contentStartPos.width; var currentHeight = contentStartPos.height; var minTranslateX, minTranslateY, maxTranslateX, maxTranslateY, newOffsetX, newOffsetY; if (currentWidth > canvasWidth) { newOffsetX = currentOffsetX + distanceX; } else { newOffsetX = currentOffsetX; } newOffsetY = currentOffsetY + distanceY; // Slow down proportionally to traveled distance minTranslateX = Math.max(0, canvasWidth * 0.5 - currentWidth * 0.5); minTranslateY = Math.max(0, canvasHeight * 0.5 - currentHeight * 0.5); maxTranslateX = Math.min(canvasWidth - currentWidth, canvasWidth * 0.5 - currentWidth * 0.5); maxTranslateY = Math.min(canvasHeight - currentHeight, canvasHeight * 0.5 - currentHeight * 0.5); // -> if (distanceX > 0 && newOffsetX > minTranslateX) { newOffsetX = minTranslateX - 1 + Math.pow(-minTranslateX + currentOffsetX + distanceX, 0.8) || 0; } // <- if (distanceX < 0 && newOffsetX < maxTranslateX) { newOffsetX = maxTranslateX + 1 - Math.pow(maxTranslateX - currentOffsetX - distanceX, 0.8) || 0; } // \/ if (distanceY > 0 && newOffsetY > minTranslateY) { newOffsetY = minTranslateY - 1 + Math.pow(-minTranslateY + currentOffsetY + distanceY, 0.8) || 0; } // /\ if (distanceY < 0 && newOffsetY < maxTranslateY) { newOffsetY = maxTranslateY + 1 - Math.pow(maxTranslateY - currentOffsetY - distanceY, 0.8) || 0; } return { top: newOffsetY, left: newOffsetX }; }; Guestures.prototype.limitPosition = function (newOffsetX, newOffsetY, newWidth, newHeight) { var self = this; var canvasWidth = self.canvasWidth; var canvasHeight = self.canvasHeight; if (newWidth > canvasWidth) { newOffsetX = newOffsetX > 0 ? 0 : newOffsetX; newOffsetX = newOffsetX < canvasWidth - newWidth ? canvasWidth - newWidth : newOffsetX; } else { // Center horizontally newOffsetX = Math.max(0, canvasWidth / 2 - newWidth / 2); } if (newHeight > canvasHeight) { newOffsetY = newOffsetY > 0 ? 0 : newOffsetY; newOffsetY = newOffsetY < canvasHeight - newHeight ? canvasHeight - newHeight : newOffsetY; } else { // Center vertically newOffsetY = Math.max(0, canvasHeight / 2 - newHeight / 2); } return { top: newOffsetY, left: newOffsetX }; }; Guestures.prototype.onZoom = function () { var self = this; // Calculate current distance between points to get pinch ratio and new width and height var contentStartPos = self.contentStartPos; var currentWidth = contentStartPos.width; var currentHeight = contentStartPos.height; var currentOffsetX = contentStartPos.left; var currentOffsetY = contentStartPos.top; var endDistanceBetweenFingers = distance(self.newPoints[0], self.newPoints[1]); var pinchRatio = endDistanceBetweenFingers / self.startDistanceBetweenFingers; var newWidth = Math.floor(currentWidth * pinchRatio); var newHeight = Math.floor(currentHeight * pinchRatio); // This is the translation due to pinch-zooming var translateFromZoomingX = (currentWidth - newWidth) * self.percentageOfImageAtPinchPointX; var translateFromZoomingY = (currentHeight - newHeight) * self.percentageOfImageAtPinchPointY; // Point between the two touches var centerPointEndX = (self.newPoints[0].x + self.newPoints[1].x) / 2 - $(window).scrollLeft(); var centerPointEndY = (self.newPoints[0].y + self.newPoints[1].y) / 2 - $(window).scrollTop(); // And this is the translation due to translation of the centerpoint // between the two fingers var translateFromTranslatingX = centerPointEndX - self.centerPointStartX; var translateFromTranslatingY = centerPointEndY - self.centerPointStartY; // The new offset is the old/current one plus the total translation var newOffsetX = currentOffsetX + (translateFromZoomingX + translateFromTranslatingX); var newOffsetY = currentOffsetY + (translateFromZoomingY + translateFromTranslatingY); var newPos = { top: newOffsetY, left: newOffsetX, scaleX: pinchRatio, scaleY: pinchRatio }; self.canTap = false; self.newWidth = newWidth; self.newHeight = newHeight; self.contentLastPos = newPos; if (self.requestId) { cancelAFrame(self.requestId); } self.requestId = requestAFrame(function () { $.bbcbox.setTranslate(self.$content, self.contentLastPos); }); }; Guestures.prototype.ontouchend = function (e) { var self = this; var swiping = self.isSwiping; var panning = self.isPanning; var zooming = self.isZooming; var scrolling = self.isScrolling; self.endPoints = getPointerXY(e); self.dMs = Math.max(new Date().getTime() - self.startTime, 1); self.$container.removeClass("bbcbox-is-grabbing"); $(document).off(".bbc.touch"); document.removeEventListener("scroll", self.onscroll, true); if (self.requestId) { cancelAFrame(self.requestId); self.requestId = null; } self.isSwiping = false; self.isPanning = false; self.isZooming = false; self.isScrolling = false; self.instance.isDragging = false; if (self.canTap) { return self.onTap(e); } self.speed = 100; // Speed in px/ms self.velocityX = (self.distanceX / self.dMs) * 0.5; self.velocityY = (self.distanceY / self.dMs) * 0.5; if (panning) { self.endPanning(); } else if (zooming) { self.endZooming(); } else { self.endSwiping(swiping, scrolling); } return; }; Guestures.prototype.endSwiping = function (swiping, scrolling) { var self = this, ret = false, len = self.instance.group.length, distanceX = Math.abs(self.distanceX), canAdvance = swiping == "x" && len > 1 && ((self.dMs > 130 && distanceX > 10) || distanceX > 50), speedX = 300; self.sliderLastPos = null; // Close if swiped vertically / navigate if horizontally if (swiping == "y" && !scrolling && Math.abs(self.distanceY) > 50) { // Continue vertical movement $.bbcbox.animate( self.instance.current.$slide, { top: self.sliderStartPos.top + self.distanceY + self.velocityY * 150, opacity: 0 }, 200 ); ret = self.instance.close(true, 250); } else if (canAdvance && self.distanceX > 0) { ret = self.instance.previous(speedX); } else if (canAdvance && self.distanceX < 0) { ret = self.instance.next(speedX); } if (ret === false && (swiping == "x" || swiping == "y")) { self.instance.centerSlide(200); } self.$container.removeClass("bbcbox-is-sliding"); }; // Limit panning from edges // ======================== Guestures.prototype.endPanning = function () { var self = this, newOffsetX, newOffsetY, newPos; if (!self.contentLastPos) { return; } if (self.opts.momentum === false || self.dMs > 350) { newOffsetX = self.contentLastPos.left; newOffsetY = self.contentLastPos.top; } else { // Continue movement newOffsetX = self.contentLastPos.left + self.velocityX * 500; newOffsetY = self.contentLastPos.top + self.velocityY * 500; } newPos = self.limitPosition(newOffsetX, newOffsetY, self.contentStartPos.width, self.contentStartPos.height); newPos.width = self.contentStartPos.width; newPos.height = self.contentStartPos.height; $.bbcbox.animate(self.$content, newPos, 366); }; Guestures.prototype.endZooming = function () { var self = this; var current = self.instance.current; var newOffsetX, newOffsetY, newPos, reset; var newWidth = self.newWidth; var newHeight = self.newHeight; if (!self.contentLastPos) { return; } newOffsetX = self.contentLastPos.left; newOffsetY = self.contentLastPos.top; reset = { top: newOffsetY, left: newOffsetX, width: newWidth, height: newHeight, scaleX: 1, scaleY: 1 }; // Reset scalex/scaleY values; this helps for perfomance and does not break animation $.bbcbox.setTranslate(self.$content, reset); if (newWidth < self.canvasWidth && newHeight < self.canvasHeight) { self.instance.scaleToFit(150); } else if (newWidth > current.width || newHeight > current.height) { self.instance.scaleToActual(self.centerPointStartX, self.centerPointStartY, 150); } else { newPos = self.limitPosition(newOffsetX, newOffsetY, newWidth, newHeight); $.bbcbox.animate(self.$content, newPos, 150); } }; Guestures.prototype.onTap = function (e) { var self = this; var $target = $(e.target); var instance = self.instance; var current = instance.current; var endPoints = (e && getPointerXY(e)) || self.startPoints; var tapX = endPoints[0] ? endPoints[0].x - $(window).scrollLeft() - self.stagePos.left : 0; var tapY = endPoints[0] ? endPoints[0].y - $(window).scrollTop() - self.stagePos.top : 0; var where; var process = function (prefix) { var action = current.opts[prefix]; if ($.isFunction(action)) { action = action.apply(instance, [current, e]); } if (!action) { return; } switch (action) { case "close": instance.close(self.startEvent); break; case "toggleControls": instance.toggleControls(); break; case "next": instance.next(); break; case "nextOrClose": if (instance.group.length > 1) { instance.next(); } else { instance.close(self.startEvent); } break; case "zoom": if (current.type == "image" && (current.isLoaded || current.$ghost)) { if (instance.canPan()) { instance.scaleToFit(); } else if (instance.isScaledDown()) { instance.scaleToActual(tapX, tapY); } else if (instance.group.length < 2) { instance.close(self.startEvent); } } break; } }; // Ignore right click if (e.originalEvent && e.originalEvent.button == 2) { return; } // Skip if clicked on the scrollbar if (!$target.is("img") && tapX > $target[0].clientWidth + $target.offset().left) { return; } // Check where is clicked if ($target.is(".bbcbox-bg,.bbcbox-inner,.bbcbox-outer,.bbcbox-container")) { where = "Outside"; } else if ($target.is(".bbcbox-slide")) { where = "Slide"; } else if ( instance.current.$content && instance.current.$content .find($target) .addBack() .filter($target).length ) { where = "Content"; } else { return; } // Check if this is a double tap if (self.tapped) { // Stop previously created single tap clearTimeout(self.tapped); self.tapped = null; // Skip if distance between taps is too big if (Math.abs(tapX - self.tapX) > 50 || Math.abs(tapY - self.tapY) > 50) { return this; } // OK, now we assume that this is a double-tap process("dblclick" + where); } else { // Single tap will be processed if user has not clicked second time within 300ms // or there is no need to wait for double-tap self.tapX = tapX; self.tapY = tapY; if (current.opts["dblclick" + where] && current.opts["dblclick" + where] !== current.opts["click" + where]) { self.tapped = setTimeout(function () { self.tapped = null; if (!instance.isAnimating) { process("click" + where); } }, 500); } else { process("click" + where); } } return this; }; $(document) .on("onActivate.bbc", function (e, instance) { if (instance && !instance.Guestures) { instance.Guestures = new Guestures(instance); } }) .on("beforeClose.bbc", function (e, instance) { if (instance && instance.Guestures) { instance.Guestures.destroy(); } }); })(window, document, jQuery); // ========================================================================== // // SlideShow // Enables slideshow functionality // // Example of usage: // $.bbcbox.getInstance().SlideShow.start() // // ========================================================================== (function (document, $) { "use strict"; $.extend(true, $.bbcbox.defaults, { btnTpl: { slideShow: '" }, slideShow: { autoStart: false, speed: 3000, progress: true } }); var SlideShow = function (instance) { this.instance = instance; this.init(); }; $.extend(SlideShow.prototype, { timer: null, isActive: false, $button: null, init: function () { var self = this, instance = self.instance, opts = instance.group[instance.currIndex].opts.slideShow; self.$button = instance.$refs.toolbar.find("[data-bbcbox-play]").on("click", function () { self.toggle(); }); if (instance.group.length < 2 || !opts) { self.$button.hide(); } else if (opts.progress) { self.$progress = $('
').appendTo(instance.$refs.inner); } }, set: function (force) { var self = this, instance = self.instance, current = instance.current; // Check if reached last element if (current && (force === true || current.opts.loop || instance.currIndex < instance.group.length - 1)) { if (self.isActive && current.contentType !== "video") { if (self.$progress) { $.bbcbox.animate(self.$progress.show(), { scaleX: 1 }, current.opts.slideShow.speed); } self.timer = setTimeout(function () { if (!instance.current.opts.loop && instance.current.index == instance.group.length - 1) { instance.jumpTo(0); } else { instance.next(); } }, current.opts.slideShow.speed); } } else { self.stop(); instance.idleSecondsCounter = 0; instance.showControls(); } }, clear: function () { var self = this; clearTimeout(self.timer); self.timer = null; if (self.$progress) { self.$progress.removeAttr("style").hide(); } }, start: function () { var self = this, current = self.instance.current; if (current) { self.$button .attr("title", (current.opts.i18n[current.opts.lang] || current.opts.i18n.en).PLAY_STOP) .removeClass("bbcbox-button--play") .addClass("bbcbox-button--pause"); self.isActive = true; if (current.isComplete) { self.set(true); } self.instance.trigger("onSlideShowChange", true); } }, stop: function () { var self = this, current = self.instance.current; self.clear(); self.$button .attr("title", (current.opts.i18n[current.opts.lang] || current.opts.i18n.en).PLAY_START) .removeClass("bbcbox-button--pause") .addClass("bbcbox-button--play"); self.isActive = false; self.instance.trigger("onSlideShowChange", false); if (self.$progress) { self.$progress.removeAttr("style").hide(); } }, toggle: function () { var self = this; if (self.isActive) { self.stop(); } else { self.start(); } } }); $(document).on({ "onInit.bbc": function (e, instance) { if (instance && !instance.SlideShow) { instance.SlideShow = new SlideShow(instance); } }, "beforeShow.bbc": function (e, instance, current, firstRun) { var SlideShow = instance && instance.SlideShow; if (firstRun) { if (SlideShow && current.opts.slideShow.autoStart) { SlideShow.start(); } } else if (SlideShow && SlideShow.isActive) { SlideShow.clear(); } }, "afterShow.bbc": function (e, instance, current) { var SlideShow = instance && instance.SlideShow; if (SlideShow && SlideShow.isActive) { SlideShow.set(); } }, "afterKeydown.bbc": function (e, instance, current, keypress, keycode) { var SlideShow = instance && instance.SlideShow; // "P" or Spacebar if (SlideShow && current.opts.slideShow && (keycode === 80 || keycode === 32) && !$(document.activeElement).is("button,a,input")) { keypress.preventDefault(); SlideShow.toggle(); } }, "beforeClose.bbc onDeactivate.bbc": function (e, instance) { var SlideShow = instance && instance.SlideShow; if (SlideShow) { SlideShow.stop(); } } }); // Page Visibility API to pause slideshow when window is not active $(document).on("visibilitychange", function () { var instance = $.bbcbox.getInstance(), SlideShow = instance && instance.SlideShow; if (SlideShow && SlideShow.isActive) { if (document.hidden) { SlideShow.clear(); } else { SlideShow.set(); } } }); })(document, jQuery); // ========================================================================== // // FullScreen // Adds fullscreen functionality // // ========================================================================== (function (document, $) { "use strict"; // Collection of methods supported by user browser var fn = (function () { var fnMap = [ ["requestFullscreen", "exitFullscreen", "fullscreenElement", "fullscreenEnabled", "fullscreenchange", "fullscreenerror"], // new WebKit [ "webkitRequestFullscreen", "webkitExitFullscreen", "webkitFullscreenElement", "webkitFullscreenEnabled", "webkitfullscreenchange", "webkitfullscreenerror" ], // old WebKit (Safari 5.1) [ "webkitRequestFullScreen", "webkitCancelFullScreen", "webkitCurrentFullScreenElement", "webkitCancelFullScreen", "webkitfullscreenchange", "webkitfullscreenerror" ], [ "mozRequestFullScreen", "mozCancelFullScreen", "mozFullScreenElement", "mozFullScreenEnabled", "mozfullscreenchange", "mozfullscreenerror" ], ["msRequestFullscreen", "msExitFullscreen", "msFullscreenElement", "msFullscreenEnabled", "MSFullscreenChange", "MSFullscreenError"] ]; var ret = {}; for (var i = 0; i < fnMap.length; i++) { var val = fnMap[i]; if (val && val[1] in document) { for (var j = 0; j < val.length; j++) { ret[fnMap[0][j]] = val[j]; } return ret; } } return false; })(); if (fn) { var FullScreen = { request: function (elem) { elem = elem || document.documentElement; elem[fn.requestFullscreen](elem.ALLOW_KEYBOARD_INPUT); }, exit: function () { document[fn.exitFullscreen](); }, toggle: function (elem) { elem = elem || document.documentElement; if (this.isFullscreen()) { this.exit(); } else { this.request(elem); } }, isFullscreen: function () { return Boolean(document[fn.fullscreenElement]); }, enabled: function () { return Boolean(document[fn.fullscreenEnabled]); } }; $.extend(true, $.bbcbox.defaults, { btnTpl: { fullScreen: '" }, fullScreen: { autoStart: false } }); $(document).on(fn.fullscreenchange, function () { var isFullscreen = FullScreen.isFullscreen(), instance = $.bbcbox.getInstance(); if (instance) { // If image is zooming, then force to stop and reposition properly if (instance.current && instance.current.type === "image" && instance.isAnimating) { instance.isAnimating = false; instance.update(true, true, 0); if (!instance.isComplete) { instance.complete(); } } instance.trigger("onFullscreenChange", isFullscreen); instance.$refs.container.toggleClass("bbcbox-is-fullscreen", isFullscreen); instance.$refs.toolbar .find("[data-bbcbox-fullscreen]") .toggleClass("bbcbox-button--fsenter", !isFullscreen) .toggleClass("bbcbox-button--fsexit", isFullscreen); } }); } $(document).on({ "onInit.bbc": function (e, instance) { var $container; if (!fn) { instance.$refs.toolbar.find("[data-bbcbox-fullscreen]").remove(); return; } if (instance && instance.group[instance.currIndex].opts.fullScreen) { $container = instance.$refs.container; $container.on("click.bbc-fullscreen", "[data-bbcbox-fullscreen]", function (e) { e.stopPropagation(); e.preventDefault(); FullScreen.toggle(); }); if (instance.opts.fullScreen && instance.opts.fullScreen.autoStart === true) { FullScreen.request(); } // Expose API instance.FullScreen = FullScreen; } else if (instance) { instance.$refs.toolbar.find("[data-bbcbox-fullscreen]").hide(); } }, "afterKeydown.bbc": function (e, instance, current, keypress, keycode) { // "F" if (instance && instance.FullScreen && keycode === 70) { keypress.preventDefault(); instance.FullScreen.toggle(); } }, "beforeClose.bbc": function (e, instance) { if (instance && instance.FullScreen && instance.$refs.container.hasClass("bbcbox-is-fullscreen")) { FullScreen.exit(); } } }); })(document, jQuery); // ========================================================================== // // Thumbs // Displays thumbnails in a grid // // ========================================================================== (function (document, $) { "use strict"; var CLASS = "bbcbox-thumbs", CLASS_ACTIVE = CLASS + "-active"; // Make sure there are default values $.bbcbox.defaults = $.extend( true, { btnTpl: { thumbs: '" }, thumbs: { autoStart: false, // Display thumbnails on opening hideOnClose: true, // Hide thumbnail grid when closing animation starts parentEl: ".bbcbox-container", // Container is injected into this element axis: "y" // Vertical (y) or horizontal (x) scrolling } }, $.bbcbox.defaults ); var BbcThumbs = function (instance) { this.init(instance); }; $.extend(BbcThumbs.prototype, { $button: null, $grid: null, $list: null, isVisible: false, isActive: false, init: function (instance) { var self = this, group = instance.group, enabled = 0; self.instance = instance; self.opts = group[instance.currIndex].opts.thumbs; instance.Thumbs = self; self.$button = instance.$refs.toolbar.find("[data-bbcbox-thumbs]"); // Enable thumbs if at least two group items have thumbnails for (var i = 0, len = group.length; i < len; i++) { if (group[i].thumb) { enabled++; } if (enabled > 1) { break; } } if (enabled > 1 && !!self.opts) { self.$button.removeAttr("style").on("click", function () { self.toggle(); }); self.isActive = true; } else { self.$button.hide(); } }, create: function () { var self = this, instance = self.instance, parentEl = self.opts.parentEl, list = [], src; if (!self.$grid) { // Create main element self.$grid = $('
').appendTo( instance.$refs.container .find(parentEl) .addBack() .filter(parentEl) ); // Add "click" event that performs gallery navigation self.$grid.on("click", "a", function () { instance.jumpTo($(this).attr("data-index")); }); } // Build the list if (!self.$list) { self.$list = $('
').appendTo(self.$grid); } $.each(instance.group, function (i, item) { src = item.thumb; if (!src && item.type === "image") { src = item.src; } list.push( '" ); }); self.$list[0].innerHTML = list.join(""); if (self.opts.axis === "x") { // Set fixed width for list element to enable horizontal scrolling self.$list.width( parseInt(self.$grid.css("padding-right"), 10) + instance.group.length * self.$list .children() .eq(0) .outerWidth(true) ); } }, focus: function (duration) { var self = this, $list = self.$list, $grid = self.$grid, thumb, thumbPos; if (!self.instance.current) { return; } thumb = $list .children() .removeClass(CLASS_ACTIVE) .filter('[data-index="' + self.instance.current.index + '"]') .addClass(CLASS_ACTIVE); thumbPos = thumb.position(); // Check if need to scroll to make current thumb visible if (self.opts.axis === "y" && (thumbPos.top < 0 || thumbPos.top > $list.height() - thumb.outerHeight())) { $list.stop().animate({ scrollTop: $list.scrollTop() + thumbPos.top }, duration ); } else if ( self.opts.axis === "x" && (thumbPos.left < $grid.scrollLeft() || thumbPos.left > $grid.scrollLeft() + ($grid.width() - thumb.outerWidth())) ) { $list .parent() .stop() .animate({ scrollLeft: thumbPos.left }, duration ); } }, update: function () { var that = this; that.instance.$refs.container.toggleClass("bbcbox-show-thumbs", this.isVisible); if (that.isVisible) { if (!that.$grid) { that.create(); } that.instance.trigger("onThumbsShow"); that.focus(0); } else if (that.$grid) { that.instance.trigger("onThumbsHide"); } // Update content position that.instance.update(); }, hide: function () { this.isVisible = false; this.update(); }, show: function () { this.isVisible = true; this.update(); }, toggle: function () { this.isVisible = !this.isVisible; this.update(); } }); $(document).on({ "onInit.bbc": function (e, instance) { var Thumbs; if (instance && !instance.Thumbs) { Thumbs = new BbcThumbs(instance); if (Thumbs.isActive && Thumbs.opts.autoStart === true) { Thumbs.show(); } } }, "beforeShow.bbc": function (e, instance, item, firstRun) { var Thumbs = instance && instance.Thumbs; if (Thumbs && Thumbs.isVisible) { Thumbs.focus(firstRun ? 0 : 250); } }, "afterKeydown.bbc": function (e, instance, current, keypress, keycode) { var Thumbs = instance && instance.Thumbs; // "G" if (Thumbs && Thumbs.isActive && keycode === 71) { keypress.preventDefault(); Thumbs.toggle(); } }, "beforeClose.bbc": function (e, instance) { var Thumbs = instance && instance.Thumbs; if (Thumbs && Thumbs.isVisible && Thumbs.opts.hideOnClose !== false) { Thumbs.$grid.hide(); } } }); })(document, jQuery); // ========================================================================== // // Hash // Enables linking to each modal // // ========================================================================== (function (window, document, $) { "use strict"; // Simple $.escapeSelector polyfill (for jQuery prior v3) if (!$.escapeSelector) { $.escapeSelector = function (sel) { var rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g; var fcssescape = function (ch, asCodePoint) { if (asCodePoint) { // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER if (ch === "\0") { return "\uFFFD"; } // Control characters and (dependent upon position) numbers get escaped as code points return ch.slice(0, -1) + "\\" + ch.charCodeAt(ch.length - 1).toString(16) + " "; } // Other potentially-special ASCII characters get backslash-escaped return "\\" + ch; }; return (sel + "").replace(rcssescape, fcssescape); }; } // Get info about gallery name and current index from url function parseUrl() { var hash = window.location.hash.substr(1), rez = hash.split("-"), index = rez.length > 1 && /^\+?\d+$/.test(rez[rez.length - 1]) ? parseInt(rez.pop(-1), 10) || 1 : 1, gallery = rez.join("-"); return { hash: hash, /* Index is starting from 1 */ index: index < 1 ? 1 : index, gallery: gallery }; } // Trigger click evnt on links to open new bbcbox instance function triggerFromUrl(url) { if (url.gallery !== "") { // If we can find element matching 'data-bbcbox' atribute, // then triggering click event should start bbcbox $("[data-bbcbox='" + $.escapeSelector(url.gallery) + "']") .eq(url.index - 1) .focus() .trigger("click.bbc-start"); } } // Get gallery name from current instance function getGalleryID(instance) { var opts, ret; if (!instance) { return false; } opts = instance.current ? instance.current.opts : instance.opts; ret = opts.hash || (opts.$orig ? opts.$orig.data("bbcbox") || opts.$orig.data("bbcbox-trigger") : ""); return ret === "" ? false : ret; } // Start when DOM becomes ready $(function () { // Check if user has disabled this module if ($.bbcbox.defaults.hash === false) { return; } // Update hash when opening/closing bbcbox $(document).on({ "onInit.bbc": function (e, instance) { var url, gallery; if (instance.group[instance.currIndex].opts.hash === false) { return; } url = parseUrl(); gallery = getGalleryID(instance); // Make sure gallery start index matches index from hash if (gallery && url.gallery && gallery == url.gallery) { instance.currIndex = url.index - 1; } }, "beforeShow.bbc": function (e, instance, current, firstRun) { var gallery; if (!current || current.opts.hash === false) { return; } // Check if need to update window hash gallery = getGalleryID(instance); if (!gallery) { return; } // Variable containing last hash value set by bbcbox // It will be used to determine if bbcbox needs to close after hash change is detected instance.currentHash = gallery + (instance.group.length > 1 ? "-" + (current.index + 1) : ""); // If current hash is the same (this instance most likely is opened by hashchange), then do nothing if (window.location.hash === "#" + instance.currentHash) { return; } if (firstRun && !instance.origHash) { instance.origHash = window.location.hash; } if (instance.hashTimer) { clearTimeout(instance.hashTimer); } // Update hash instance.hashTimer = setTimeout(function () { if ("replaceState" in window.history) { window.history[firstRun ? "pushState" : "replaceState"]({}, document.title, window.location.pathname + window.location.search + "#" + instance.currentHash ); if (firstRun) { instance.hasCreatedHistory = true; } } else { window.location.hash = instance.currentHash; } instance.hashTimer = null; }, 300); }, "beforeClose.bbc": function (e, instance, current) { if (!current || current.opts.hash === false) { return; } clearTimeout(instance.hashTimer); // Goto previous history entry if (instance.currentHash && instance.hasCreatedHistory) { window.history.back(); } else if (instance.currentHash) { if ("replaceState" in window.history) { window.history.replaceState({}, document.title, window.location.pathname + window.location.search + (instance.origHash || "")); } else { window.location.hash = instance.origHash; } } instance.currentHash = null; } }); // Check if need to start/close after url has changed $(window).on("hashchange.bbc", function () { var url = parseUrl(), fb = null; // Find last bbcbox instance that has "hash" $.each( $(".bbcbox-container") .get() .reverse(), function (index, value) { var tmp = $(value).data("bbcbox"); if (tmp && tmp.currentHash) { fb = tmp; return false; } } ); if (fb) { // Now, compare hash values if (fb.currentHash !== url.gallery + "-" + url.index && !(url.index === 1 && fb.currentHash == url.gallery)) { fb.currentHash = null; fb.close(); } } else if (url.gallery !== "") { triggerFromUrl(url); } }); // Check current hash and trigger click event on matching element to start bbcbox, if needed setTimeout(function () { if (!$.bbcbox.getInstance()) { triggerFromUrl(parseUrl()); } }, 50); }); })(window, document, jQuery); // ========================================================================== // // Wheel // Basic mouse weheel support for gallery navigation // // ========================================================================== (function (document, $) { "use strict"; var prevTime = new Date().getTime(); $(document).on({ "onInit.bbc": function (e, instance, current) { instance.$refs.stage.on("mousewheel DOMMouseScroll wheel MozMousePixelScroll", function (e) { var current = instance.current, currTime = new Date().getTime(); if (instance.group.length < 2 || current.opts.wheel === false || (current.opts.wheel === "auto" && current.type !== "image")) { return; } e.preventDefault(); e.stopPropagation(); if (current.$slide.hasClass("bbcbox-animated")) { return; } e = e.originalEvent || e; if (currTime - prevTime < 250) { return; } prevTime = currTime; instance[(-e.deltaY || -e.deltaX || e.wheelDelta || -e.detail) < 0 ? "next" : "previous"](); }); } }); })(document, jQuery); // Step 1: Create jQuery plugin // ============================ $.fn.bbcMorph = function( opts ) { var Morphing = function( $btn, opts ) { var self = this; self.opts = $.extend({ animationEffect : false, infobar : false, buttons : ['close'], smallBtn : false, touch : false, baseClass : 'bbcbox-morphing', afterClose : function() { self.close(); } }, opts); self.init( $btn ); }; Morphing.prototype.init = function( $btn ) { var self = this; self.$btn = $btn.addClass('morphing-btn'); self.$clone = $('
') .hide() .insertAfter( $btn ); // Add wrapping element and set initial width used for positioning $btn.wrap( '' ).on('click', function(e) { e.preventDefault(); self.start(); }); }; Morphing.prototype.start = function() { var self = this; if ( self.$btn.hasClass('morphing-btn_circle') ) { return; } // Set initial width, because it is not possible to start CSS transition from "auto" // console.log(self, self.$btn) self.$btn.width( self.$btn.width() ).parent().width( self.$btn.outerWidth() ); self.$btn.off('.fm').on("transitionend.fm webkitTransitionEnd.fm oTransitionEnd.fm MSTransitionEnd.fm", function(e) { console.log(e) self.$btn.off('.fm'); self.animateBg(); }).addClass('morphing-btn_circle'); }; Morphing.prototype.animateBg = function() { var self = this; self.scaleBg(); self.$clone.show(); // Trigger repaint self.$clone[0].offsetHeight; self.$clone.off('.fm').on("transitionend.fm webkitTransitionEnd.fm oTransitionEnd.fm MSTransitionEnd.fm", function(e) { self.$clone.off('.fm'); self.complete(); }).addClass('morphing-btn-clone_visible'); }; Morphing.prototype.scaleBg = function() { var self = this; var $clone = self.$clone; var scale = self.getScale(); var $btn = self.$btn; var pos = $btn.offset(); // console.log($btn) $clone.css({ top : pos.top + $btn.outerHeight() * 0.5 - ( $btn.outerHeight() * scale * 0.5 ) - $(window).scrollTop(), left : pos.left + $btn.outerWidth() * 0.5 - ( $btn.outerWidth() * scale * 0.5 ) - $(window).scrollLeft(), width : $btn.outerWidth() * scale, height : $btn.outerHeight() * scale, transform : 'scale(' + ( 1 / scale ) + ')' }); }; Morphing.prototype.getScale = function() { var $btn = this.$btn, radius = $btn.outerWidth() * 0.5, left = $btn.offset().left + radius - $(window).scrollLeft(), top = $btn.offset().top + radius - $(window).scrollTop(), windowW = $(window).width(), windowH = $(window).height(); var maxDistHor = ( left > windowW / 2 ) ? left : ( windowW - left ), maxDistVert = ( top > windowH / 2 ) ? top : ( windowH - top ); return Math.ceil(Math.sqrt( Math.pow( maxDistHor, 2 ) + Math.pow( maxDistVert, 2 ) ) / radius ); }; Morphing.prototype.complete = function() { var self = this; var $btn = self.$btn; $.bbcbox.open({ src : $btn.data('src') || $btn.attr('href') }, self.opts); $(window).on('resize.fm', function() { //self.scaleBg(); }); }; Morphing.prototype.close = function() { var self = this; var $clone = self.$clone; self.scaleBg(); $clone.one('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function(e) { $clone.hide(); self.$btn.removeClass('morphing-btn_circle'); }); $clone.removeClass('morphing-btn-clone_visible'); $(window).off('resize.fm'); }; // Init this.each(function() { var $this = $(this); if ( !$this.data("morphing") ) { $this.data( "morphing", new Morphing( $this, opts ) ); } }); return this; }; // Step 2: Start using it! // ======================= $("[data-morphing]").bbcMorph({ hash : 'morphing' }); /** * Swiper 7.3.4 * Most modern mobile touch slider and framework with hardware accelerated transitions * https://swiperjs.com * * Copyright 2014-2021 Vladimir Kharlampidi * * Released under the MIT License * * Released on: December 22, 2021 */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Swiper=t()}(this,(function(){"use strict";function e(e){return null!==e&&"object"==typeof e&&"constructor"in e&&e.constructor===Object}function t(s={},a={}){Object.keys(a).forEach((i=>{void 0===s[i]?s[i]=a[i]:e(a[i])&&e(s[i])&&Object.keys(a[i]).length>0&&t(s[i],a[i])}))}const s={body:{},addEventListener(){},removeEventListener(){},activeElement:{blur(){},nodeName:""},querySelector:()=>null,querySelectorAll:()=>[],getElementById:()=>null,createEvent:()=>({initEvent(){}}),createElement:()=>({children:[],childNodes:[],style:{},setAttribute(){},getElementsByTagName:()=>[]}),createElementNS:()=>({}),importNode:()=>null,location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""}};function a(){const e="undefined"!=typeof document?document:{};return t(e,s),e}const i={document:s,navigator:{userAgent:""},location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""},history:{replaceState(){},pushState(){},go(){},back(){}},CustomEvent:function(){return this},addEventListener(){},removeEventListener(){},getComputedStyle:()=>({getPropertyValue:()=>""}),Image(){},Date(){},screen:{},setTimeout(){},clearTimeout(){},matchMedia:()=>({}),requestAnimationFrame:e=>"undefined"==typeof setTimeout?(e(),null):setTimeout(e,0),cancelAnimationFrame(e){"undefined"!=typeof setTimeout&&clearTimeout(e)}};function r(){const e="undefined"!=typeof window?window:{};return t(e,i),e}class n extends Array{constructor(e){super(...e||[]),function(e){const t=e.__proto__;Object.defineProperty(e,"__proto__",{get:()=>t,set(e){t.__proto__=e}})}(this)}}function l(e=[]){const t=[];return e.forEach((e=>{Array.isArray(e)?t.push(...l(e)):t.push(e)})),t}function o(e,t){return Array.prototype.filter.call(e,t)}function d(e,t){const s=r(),i=a();let l=[];if(!t&&e instanceof n)return e;if(!e)return new n(l);if("string"==typeof e){const s=e.trim();if(s.indexOf("<")>=0&&s.indexOf(">")>=0){let e="div";0===s.indexOf("e.split(" "))));return this.forEach((e=>{e.classList.add(...t)})),this},removeClass:function(...e){const t=l(e.map((e=>e.split(" "))));return this.forEach((e=>{e.classList.remove(...t)})),this},hasClass:function(...e){const t=l(e.map((e=>e.split(" "))));return o(this,(e=>t.filter((t=>e.classList.contains(t))).length>0)).length>0},toggleClass:function(...e){const t=l(e.map((e=>e.split(" "))));this.forEach((e=>{t.forEach((t=>{e.classList.toggle(t)}))}))},attr:function(e,t){if(1===arguments.length&&"string"==typeof e)return this[0]?this[0].getAttribute(e):void 0;for(let s=0;s=0;e-=1){const s=n[e];a&&s.listener===a||a&&s.listener&&s.listener.dom7proxy&&s.listener.dom7proxy===a?(r.removeEventListener(t,s.proxyListener,i),n.splice(e,1)):a||(r.removeEventListener(t,s.proxyListener,i),n.splice(e,1))}}}return this},trigger:function(...e){const t=r(),s=e[0].split(" "),a=e[1];for(let i=0;it>0)),i.dispatchEvent(s),i.dom7EventData=[],delete i.dom7EventData}}}return this},transitionEnd:function(e){const t=this;return e&&t.on("transitionend",(function s(a){a.target===this&&(e.call(this,a),t.off("transitionend",s))})),this},outerWidth:function(e){if(this.length>0){if(e){const e=this.styles();return this[0].offsetWidth+parseFloat(e.getPropertyValue("margin-right"))+parseFloat(e.getPropertyValue("margin-left"))}return this[0].offsetWidth}return null},outerHeight:function(e){if(this.length>0){if(e){const e=this.styles();return this[0].offsetHeight+parseFloat(e.getPropertyValue("margin-top"))+parseFloat(e.getPropertyValue("margin-bottom"))}return this[0].offsetHeight}return null},styles:function(){const e=r();return this[0]?e.getComputedStyle(this[0],null):{}},offset:function(){if(this.length>0){const e=r(),t=a(),s=this[0],i=s.getBoundingClientRect(),n=t.body,l=s.clientTop||n.clientTop||0,o=s.clientLeft||n.clientLeft||0,d=s===e?e.scrollY:s.scrollTop,c=s===e?e.scrollX:s.scrollLeft;return{top:i.top+d-l,left:i.left+c-o}}return null},css:function(e,t){const s=r();let a;if(1===arguments.length){if("string"!=typeof e){for(a=0;a{e.apply(t,[t,s])})),this):this},html:function(e){if(void 0===e)return this[0]?this[0].innerHTML:null;for(let t=0;tt-1)return d([]);if(e<0){const s=t+e;return d(s<0?[]:[this[s]])}return d([this[e]])},append:function(...e){let t;const s=a();for(let a=0;a=0;i-=1)this[s].insertBefore(a.childNodes[i],this[s].childNodes[0])}else if(e instanceof n)for(i=0;i0?e?this[0].nextElementSibling&&d(this[0].nextElementSibling).is(e)?d([this[0].nextElementSibling]):d([]):this[0].nextElementSibling?d([this[0].nextElementSibling]):d([]):d([])},nextAll:function(e){const t=[];let s=this[0];if(!s)return d([]);for(;s.nextElementSibling;){const a=s.nextElementSibling;e?d(a).is(e)&&t.push(a):t.push(a),s=a}return d(t)},prev:function(e){if(this.length>0){const t=this[0];return e?t.previousElementSibling&&d(t.previousElementSibling).is(e)?d([t.previousElementSibling]):d([]):t.previousElementSibling?d([t.previousElementSibling]):d([])}return d([])},prevAll:function(e){const t=[];let s=this[0];if(!s)return d([]);for(;s.previousElementSibling;){const a=s.previousElementSibling;e?d(a).is(e)&&t.push(a):t.push(a),s=a}return d(t)},parent:function(e){const t=[];for(let s=0;s6&&(i=i.split(", ").map((e=>e.replace(",","."))).join(", ")),n=new s.WebKitCSSMatrix("none"===i?"":i)):(n=l.MozTransform||l.OTransform||l.MsTransform||l.msTransform||l.transform||l.getPropertyValue("transform").replace("translate(","matrix(1, 0, 0, 1,"),a=n.toString().split(",")),"x"===t&&(i=s.WebKitCSSMatrix?n.m41:16===a.length?parseFloat(a[12]):parseFloat(a[4])),"y"===t&&(i=s.WebKitCSSMatrix?n.m42:16===a.length?parseFloat(a[13]):parseFloat(a[5])),i||0}function m(e){return"object"==typeof e&&null!==e&&e.constructor&&"Object"===Object.prototype.toString.call(e).slice(8,-1)}function f(...e){const t=Object(e[0]),s=["__proto__","constructor","prototype"];for(let i=1;is.indexOf(e)<0));for(let s=0,a=e.length;si?"next":"prev",c=(e,t)=>"next"===d&&e>=t||"prev"===d&&e<=t,p=()=>{n=(new Date).getTime(),null===l&&(l=n);const r=Math.max(Math.min((n-l)/o,1),0),d=.5-Math.cos(r*Math.PI)/2;let u=i+d*(t-i);if(c(u,t)&&(u=t),e.wrapperEl.scrollTo({[s]:u}),c(u,t))return e.wrapperEl.style.overflow="hidden",e.wrapperEl.style.scrollSnapType="",setTimeout((()=>{e.wrapperEl.style.overflow="",e.wrapperEl.scrollTo({[s]:u})})),void a.cancelAnimationFrame(e.cssModeFrameID);e.cssModeFrameID=a.requestAnimationFrame(p)};p()}let w,b,x;function y(){return w||(w=function(){const e=r(),t=a();return{smoothScroll:t.documentElement&&"scrollBehavior"in t.documentElement.style,touch:!!("ontouchstart"in e||e.DocumentTouch&&t instanceof e.DocumentTouch),passiveListener:function(){let t=!1;try{const s=Object.defineProperty({},"passive",{get(){t=!0}});e.addEventListener("testPassiveListener",null,s)}catch(e){}return t}(),gestures:"ongesturestart"in e}}()),w}function E(e={}){return b||(b=function({userAgent:e}={}){const t=y(),s=r(),a=s.navigator.platform,i=e||s.navigator.userAgent,n={ios:!1,android:!1},l=s.screen.width,o=s.screen.height,d=i.match(/(Android);?[\s\/]+([\d.]+)?/);let c=i.match(/(iPad).*OS\s([\d_]+)/);const p=i.match(/(iPod)(.*OS\s([\d_]+))?/),u=!c&&i.match(/(iPhone\sOS|iOS)\s([\d_]+)/),h="Win32"===a;let m="MacIntel"===a;return!c&&m&&t.touch&&["1024x1366","1366x1024","834x1194","1194x834","834x1112","1112x834","768x1024","1024x768","820x1180","1180x820","810x1080","1080x810"].indexOf(`${l}x${o}`)>=0&&(c=i.match(/(Version)\/([\d.]+)/),c||(c=[0,1,"13_0_0"]),m=!1),d&&!h&&(n.os="android",n.android=!0),(c||u||p)&&(n.os="ios",n.ios=!0),n}(e)),b}function T(){return x||(x=function(){const e=r();return{isSafari:function(){const t=e.navigator.userAgent.toLowerCase();return t.indexOf("safari")>=0&&t.indexOf("chrome")<0&&t.indexOf("android")<0}(),isWebView:/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(e.navigator.userAgent)}}()),x}Object.keys(c).forEach((e=>{Object.defineProperty(d.fn,e,{value:c[e],writable:!0})}));var C={on(e,t,s){const a=this;if("function"!=typeof t)return a;const i=s?"unshift":"push";return e.split(" ").forEach((e=>{a.eventsListeners[e]||(a.eventsListeners[e]=[]),a.eventsListeners[e][i](t)})),a},once(e,t,s){const a=this;if("function"!=typeof t)return a;function i(...s){a.off(e,i),i.__emitterProxy&&delete i.__emitterProxy,t.apply(a,s)}return i.__emitterProxy=t,a.on(e,i,s)},onAny(e,t){const s=this;if("function"!=typeof e)return s;const a=t?"unshift":"push";return s.eventsAnyListeners.indexOf(e)<0&&s.eventsAnyListeners[a](e),s},offAny(e){const t=this;if(!t.eventsAnyListeners)return t;const s=t.eventsAnyListeners.indexOf(e);return s>=0&&t.eventsAnyListeners.splice(s,1),t},off(e,t){const s=this;return s.eventsListeners?(e.split(" ").forEach((e=>{void 0===t?s.eventsListeners[e]=[]:s.eventsListeners[e]&&s.eventsListeners[e].forEach(((a,i)=>{(a===t||a.__emitterProxy&&a.__emitterProxy===t)&&s.eventsListeners[e].splice(i,1)}))})),s):s},emit(...e){const t=this;if(!t.eventsListeners)return t;let s,a,i;"string"==typeof e[0]||Array.isArray(e[0])?(s=e[0],a=e.slice(1,e.length),i=t):(s=e[0].events,a=e[0].data,i=e[0].context||t),a.unshift(i);return(Array.isArray(s)?s:s.split(" ")).forEach((e=>{t.eventsAnyListeners&&t.eventsAnyListeners.length&&t.eventsAnyListeners.forEach((t=>{t.apply(i,[e,...a])})),t.eventsListeners&&t.eventsListeners[e]&&t.eventsListeners[e].forEach((e=>{e.apply(i,a)}))})),t}};function $({swiper:e,runCallbacks:t,direction:s,step:a}){const{activeIndex:i,previousIndex:r}=e;let n=s;if(n||(n=i>r?"next":i0)return;if(n.isTouched&&n.isMoved)return;!!l.noSwipingClass&&""!==l.noSwipingClass&&p.target&&p.target.shadowRoot&&e.path&&e.path[0]&&(h=d(e.path[0]));const m=l.noSwipingSelector?l.noSwipingSelector:`.${l.noSwipingClass}`,f=!(!p.target||!p.target.shadowRoot);if(l.noSwiping&&(f?function(e,t=this){return function t(s){return s&&s!==a()&&s!==r()?(s.assignedSlot&&(s=s.assignedSlot),s.closest(e)||t(s.getRootNode().host)):null}(t)}(m,p.target):h.closest(m)[0]))return void(t.allowClick=!0);if(l.swipeHandler&&!h.closest(l.swipeHandler)[0])return;o.currentX="touchstart"===p.type?p.targetTouches[0].pageX:p.pageX,o.currentY="touchstart"===p.type?p.targetTouches[0].pageY:p.pageY;const g=o.currentX,v=o.currentY,w=l.edgeSwipeDetection||l.iOSEdgeSwipeDetection,b=l.edgeSwipeThreshold||l.iOSEdgeSwipeThreshold;if(w&&(g<=b||g>=i.innerWidth-b)){if("prevent"!==w)return;e.preventDefault()}if(Object.assign(n,{isTouched:!0,isMoved:!1,allowTouchCallbacks:!0,isScrolling:void 0,startMoving:void 0}),o.startX=g,o.startY=v,n.touchStartTime=u(),t.allowClick=!0,t.updateSize(),t.swipeDirection=void 0,l.threshold>0&&(n.allowThresholdMove=!1),"touchstart"!==p.type){let e=!0;h.is(n.focusableElements)&&(e=!1),s.activeElement&&d(s.activeElement).is(n.focusableElements)&&s.activeElement!==h[0]&&s.activeElement.blur();const a=e&&t.allowTouchMove&&l.touchStartPreventDefault;!l.touchStartForcePreventDefault&&!a||h[0].isContentEditable||p.preventDefault()}t.emit("touchStart",p)}function M(e){const t=a(),s=this,i=s.touchEventsData,{params:r,touches:n,rtlTranslate:l,enabled:o}=s;if(!o)return;let c=e;if(c.originalEvent&&(c=c.originalEvent),!i.isTouched)return void(i.startMoving&&i.isScrolling&&s.emit("touchMoveOpposite",c));if(i.isTouchEvent&&"touchmove"!==c.type)return;const p="touchmove"===c.type&&c.targetTouches&&(c.targetTouches[0]||c.changedTouches[0]),h="touchmove"===c.type?p.pageX:c.pageX,m="touchmove"===c.type?p.pageY:c.pageY;if(c.preventedByNestedSwiper)return n.startX=h,void(n.startY=m);if(!s.allowTouchMove)return s.allowClick=!1,void(i.isTouched&&(Object.assign(n,{startX:h,startY:m,currentX:h,currentY:m}),i.touchStartTime=u()));if(i.isTouchEvent&&r.touchReleaseOnEdges&&!r.loop)if(s.isVertical()){if(mn.startY&&s.translate>=s.minTranslate())return i.isTouched=!1,void(i.isMoved=!1)}else if(hn.startX&&s.translate>=s.minTranslate())return;if(i.isTouchEvent&&t.activeElement&&c.target===t.activeElement&&d(c.target).is(i.focusableElements))return i.isMoved=!0,void(s.allowClick=!1);if(i.allowTouchCallbacks&&s.emit("touchMove",c),c.targetTouches&&c.targetTouches.length>1)return;n.currentX=h,n.currentY=m;const f=n.currentX-n.startX,g=n.currentY-n.startY;if(s.params.threshold&&Math.sqrt(f**2+g**2)=25&&(e=180*Math.atan2(Math.abs(g),Math.abs(f))/Math.PI,i.isScrolling=s.isHorizontal()?e>r.touchAngle:90-e>r.touchAngle)}if(i.isScrolling&&s.emit("touchMoveOpposite",c),void 0===i.startMoving&&(n.currentX===n.startX&&n.currentY===n.startY||(i.startMoving=!0)),i.isScrolling)return void(i.isTouched=!1);if(!i.startMoving)return;s.allowClick=!1,!r.cssMode&&c.cancelable&&c.preventDefault(),r.touchMoveStopPropagation&&!r.nested&&c.stopPropagation(),i.isMoved||(r.loop&&!r.cssMode&&s.loopFix(),i.startTranslate=s.getTranslate(),s.setTransition(0),s.animating&&s.$wrapperEl.trigger("webkitTransitionEnd transitionend"),i.allowMomentumBounce=!1,!r.grabCursor||!0!==s.allowSlideNext&&!0!==s.allowSlidePrev||s.setGrabCursor(!0),s.emit("sliderFirstMove",c)),s.emit("sliderMove",c),i.isMoved=!0;let v=s.isHorizontal()?f:g;n.diff=v,v*=r.touchRatio,l&&(v=-v),s.swipeDirection=v>0?"prev":"next",i.currentTranslate=v+i.startTranslate;let w=!0,b=r.resistanceRatio;if(r.touchReleaseOnEdges&&(b=0),v>0&&i.currentTranslate>s.minTranslate()?(w=!1,r.resistance&&(i.currentTranslate=s.minTranslate()-1+(-s.minTranslate()+i.startTranslate+v)**b)):v<0&&i.currentTranslatei.startTranslate&&(i.currentTranslate=i.startTranslate),s.allowSlidePrev||s.allowSlideNext||(i.currentTranslate=i.startTranslate),r.threshold>0){if(!(Math.abs(v)>r.threshold||i.allowThresholdMove))return void(i.currentTranslate=i.startTranslate);if(!i.allowThresholdMove)return i.allowThresholdMove=!0,n.startX=n.currentX,n.startY=n.currentY,i.currentTranslate=i.startTranslate,void(n.diff=s.isHorizontal()?n.currentX-n.startX:n.currentY-n.startY)}r.followFinger&&!r.cssMode&&((r.freeMode&&r.freeMode.enabled&&s.freeMode||r.watchSlidesProgress)&&(s.updateActiveIndex(),s.updateSlidesClasses()),s.params.freeMode&&r.freeMode.enabled&&s.freeMode&&s.freeMode.onTouchMove(),s.updateProgress(i.currentTranslate),s.setTranslate(i.currentTranslate))}function P(e){const t=this,s=t.touchEventsData,{params:a,touches:i,rtlTranslate:r,slidesGrid:n,enabled:l}=t;if(!l)return;let o=e;if(o.originalEvent&&(o=o.originalEvent),s.allowTouchCallbacks&&t.emit("touchEnd",o),s.allowTouchCallbacks=!1,!s.isTouched)return s.isMoved&&a.grabCursor&&t.setGrabCursor(!1),s.isMoved=!1,void(s.startMoving=!1);a.grabCursor&&s.isMoved&&s.isTouched&&(!0===t.allowSlideNext||!0===t.allowSlidePrev)&&t.setGrabCursor(!1);const d=u(),c=d-s.touchStartTime;if(t.allowClick){const e=o.path||o.composedPath&&o.composedPath();t.updateClickedSlide(e&&e[0]||o.target),t.emit("tap click",o),c<300&&d-s.lastClickTime<300&&t.emit("doubleTap doubleClick",o)}if(s.lastClickTime=u(),p((()=>{t.destroyed||(t.allowClick=!0)})),!s.isTouched||!s.isMoved||!t.swipeDirection||0===i.diff||s.currentTranslate===s.startTranslate)return s.isTouched=!1,s.isMoved=!1,void(s.startMoving=!1);let h;if(s.isTouched=!1,s.isMoved=!1,s.startMoving=!1,h=a.followFinger?r?t.translate:-t.translate:-s.currentTranslate,a.cssMode)return;if(t.params.freeMode&&a.freeMode.enabled)return void t.freeMode.onTouchEnd({currentPos:h});let m=0,f=t.slidesSizesGrid[0];for(let e=0;e=n[e]&&h=n[e]&&(m=e,f=n[n.length-1]-n[n.length-2])}const g=(h-n[m])/f,v=ma.longSwipesMs){if(!a.longSwipes)return void t.slideTo(t.activeIndex);"next"===t.swipeDirection&&(g>=a.longSwipesRatio?t.slideTo(m+v):t.slideTo(m)),"prev"===t.swipeDirection&&(g>1-a.longSwipesRatio?t.slideTo(m+v):t.slideTo(m))}else{if(!a.shortSwipes)return void t.slideTo(t.activeIndex);t.navigation&&(o.target===t.navigation.nextEl||o.target===t.navigation.prevEl)?o.target===t.navigation.nextEl?t.slideTo(m+v):t.slideTo(m):("next"===t.swipeDirection&&t.slideTo(m+v),"prev"===t.swipeDirection&&t.slideTo(m))}}function k(){const e=this,{params:t,el:s}=e;if(s&&0===s.offsetWidth)return;t.breakpoints&&e.setBreakpoint();const{allowSlideNext:a,allowSlidePrev:i,snapGrid:r}=e;e.allowSlideNext=!0,e.allowSlidePrev=!0,e.updateSize(),e.updateSlides(),e.updateSlidesClasses(),("auto"===t.slidesPerView||t.slidesPerView>1)&&e.isEnd&&!e.isBeginning&&!e.params.centeredSlides?e.slideTo(e.slides.length-1,0,!1,!0):e.slideTo(e.activeIndex,0,!1,!0),e.autoplay&&e.autoplay.running&&e.autoplay.paused&&e.autoplay.run(),e.allowSlidePrev=i,e.allowSlideNext=a,e.params.watchOverflow&&r!==e.snapGrid&&e.checkOverflow()}function z(e){const t=this;t.enabled&&(t.allowClick||(t.params.preventClicks&&e.preventDefault(),t.params.preventClicksPropagation&&t.animating&&(e.stopPropagation(),e.stopImmediatePropagation())))}function O(){const e=this,{wrapperEl:t,rtlTranslate:s,enabled:a}=e;if(!a)return;let i;e.previousTranslate=e.translate,e.isHorizontal()?e.translate=-t.scrollLeft:e.translate=-t.scrollTop,-0===e.translate&&(e.translate=0),e.updateActiveIndex(),e.updateSlidesClasses();const r=e.maxTranslate()-e.minTranslate();i=0===r?0:(e.translate-e.minTranslate())/r,i!==e.progress&&e.updateProgress(s?-e.translate:e.translate),e.emit("setTranslate",e.translate,!1)}let I=!1;function L(){}const A=(e,t)=>{const s=a(),{params:i,touchEvents:r,el:n,wrapperEl:l,device:o,support:d}=e,c=!!i.nested,p="on"===t?"addEventListener":"removeEventListener",u=t;if(d.touch){const t=!("touchstart"!==r.start||!d.passiveListener||!i.passiveListeners)&&{passive:!0,capture:!1};n[p](r.start,e.onTouchStart,t),n[p](r.move,e.onTouchMove,d.passiveListener?{passive:!1,capture:c}:c),n[p](r.end,e.onTouchEnd,t),r.cancel&&n[p](r.cancel,e.onTouchEnd,t)}else n[p](r.start,e.onTouchStart,!1),s[p](r.move,e.onTouchMove,c),s[p](r.end,e.onTouchEnd,!1);(i.preventClicks||i.preventClicksPropagation)&&n[p]("click",e.onClick,!0),i.cssMode&&l[p]("scroll",e.onScroll),i.updateOnWindowResize?e[u](o.ios||o.android?"resize orientationchange observerUpdate":"resize observerUpdate",k,!0):e[u]("observerUpdate",k,!0)};const D=(e,t)=>e.grid&&t.grid&&t.grid.rows>1;var G={init:!0,direction:"horizontal",touchEventsTarget:"wrapper",initialSlide:0,speed:300,cssMode:!1,updateOnWindowResize:!0,resizeObserver:!0,nested:!1,createElements:!1,enabled:!0,focusableElements:"input, select, option, textarea, button, video, label",width:null,height:null,preventInteractionOnTransition:!1,userAgent:null,url:null,edgeSwipeDetection:!1,edgeSwipeThreshold:20,autoHeight:!1,setWrapperSize:!1,virtualTranslate:!1,effect:"slide",breakpoints:void 0,breakpointsBase:"window",spaceBetween:0,slidesPerView:1,slidesPerGroup:1,slidesPerGroupSkip:0,slidesPerGroupAuto:!1,centeredSlides:!1,centeredSlidesBounds:!1,slidesOffsetBefore:0,slidesOffsetAfter:0,normalizeSlideIndex:!0,centerInsufficientSlides:!1,watchOverflow:!0,roundLengths:!1,touchRatio:1,touchAngle:45,simulateTouch:!0,shortSwipes:!0,longSwipes:!0,longSwipesRatio:.5,longSwipesMs:300,followFinger:!0,allowTouchMove:!0,threshold:0,touchMoveStopPropagation:!1,touchStartPreventDefault:!0,touchStartForcePreventDefault:!1,touchReleaseOnEdges:!1,uniqueNavElements:!0,resistance:!0,resistanceRatio:.85,watchSlidesProgress:!1,grabCursor:!1,preventClicks:!0,preventClicksPropagation:!0,slideToClickedSlide:!1,preloadImages:!0,updateOnImagesReady:!0,loop:!1,loopAdditionalSlides:0,loopedSlides:null,loopFillGroupWithBlank:!1,loopPreventsSlide:!0,allowSlidePrev:!0,allowSlideNext:!0,swipeHandler:null,noSwiping:!0,noSwipingClass:"swiper-no-swiping",noSwipingSelector:null,passiveListeners:!0,containerModifierClass:"swiper-",slideClass:"swiper-slide",slideBlankClass:"swiper-slide-invisible-blank",slideActiveClass:"swiper-slide-active",slideDuplicateActiveClass:"swiper-slide-duplicate-active",slideVisibleClass:"swiper-slide-visible",slideDuplicateClass:"swiper-slide-duplicate",slideNextClass:"swiper-slide-next",slideDuplicateNextClass:"swiper-slide-duplicate-next",slidePrevClass:"swiper-slide-prev",slideDuplicatePrevClass:"swiper-slide-duplicate-prev",wrapperClass:"swiper-wrapper",runCallbacksOnInit:!0,_emitClasses:!1};function N(e,t){return function(s={}){const a=Object.keys(s)[0],i=s[a];"object"==typeof i&&null!==i?(["navigation","pagination","scrollbar"].indexOf(a)>=0&&!0===e[a]&&(e[a]={auto:!0}),a in e&&"enabled"in i?(!0===e[a]&&(e[a]={enabled:!0}),"object"!=typeof e[a]||"enabled"in e[a]||(e[a].enabled=!0),e[a]||(e[a]={enabled:!1}),f(t,s)):f(t,s)):f(t,s)}}const B={eventsEmitter:C,update:{updateSize:function(){const e=this;let t,s;const a=e.$el;t=void 0!==e.params.width&&null!==e.params.width?e.params.width:a[0].clientWidth,s=void 0!==e.params.height&&null!==e.params.height?e.params.height:a[0].clientHeight,0===t&&e.isHorizontal()||0===s&&e.isVertical()||(t=t-parseInt(a.css("padding-left")||0,10)-parseInt(a.css("padding-right")||0,10),s=s-parseInt(a.css("padding-top")||0,10)-parseInt(a.css("padding-bottom")||0,10),Number.isNaN(t)&&(t=0),Number.isNaN(s)&&(s=0),Object.assign(e,{width:t,height:s,size:e.isHorizontal()?t:s}))},updateSlides:function(){const e=this;function t(t){return e.isHorizontal()?t:{width:"height","margin-top":"margin-left","margin-bottom ":"margin-right","margin-left":"margin-top","margin-right":"margin-bottom","padding-left":"padding-top","padding-right":"padding-bottom",marginRight:"marginBottom"}[t]}function s(e,s){return parseFloat(e.getPropertyValue(t(s))||0)}const a=e.params,{$wrapperEl:i,size:r,rtlTranslate:n,wrongRTL:l}=e,o=e.virtual&&a.virtual.enabled,d=o?e.virtual.slides.length:e.slides.length,c=i.children(`.${e.params.slideClass}`),p=o?e.virtual.slides.length:c.length;let u=[];const h=[],m=[];let f=a.slidesOffsetBefore;"function"==typeof f&&(f=a.slidesOffsetBefore.call(e));let v=a.slidesOffsetAfter;"function"==typeof v&&(v=a.slidesOffsetAfter.call(e));const w=e.snapGrid.length,b=e.slidesGrid.length;let x=a.spaceBetween,y=-f,E=0,T=0;if(void 0===r)return;"string"==typeof x&&x.indexOf("%")>=0&&(x=parseFloat(x.replace("%",""))/100*r),e.virtualSize=-x,n?c.css({marginLeft:"",marginBottom:"",marginTop:""}):c.css({marginRight:"",marginBottom:"",marginTop:""}),a.centeredSlides&&a.cssMode&&(g(e.wrapperEl,"--swiper-centered-offset-before",""),g(e.wrapperEl,"--swiper-centered-offset-after",""));const C=a.grid&&a.grid.rows>1&&e.grid;let $;C&&e.grid.initSlides(p);const S="auto"===a.slidesPerView&&a.breakpoints&&Object.keys(a.breakpoints).filter((e=>void 0!==a.breakpoints[e].slidesPerView)).length>0;for(let i=0;i1&&u.push(e.virtualSize-r)}if(0===u.length&&(u=[0]),0!==a.spaceBetween){const s=e.isHorizontal()&&n?"marginLeft":t("marginRight");c.filter(((e,t)=>!a.cssMode||t!==c.length-1)).css({[s]:`${x}px`})}if(a.centeredSlides&&a.centeredSlidesBounds){let e=0;m.forEach((t=>{e+=t+(a.spaceBetween?a.spaceBetween:0)})),e-=a.spaceBetween;const t=e-r;u=u.map((e=>e<0?-f:e>t?t+v:e))}if(a.centerInsufficientSlides){let e=0;if(m.forEach((t=>{e+=t+(a.spaceBetween?a.spaceBetween:0)})),e-=a.spaceBetween,e{u[s]=e-t})),h.forEach(((e,s)=>{h[s]=e+t}))}}if(Object.assign(e,{slides:c,snapGrid:u,slidesGrid:h,slidesSizesGrid:m}),a.centeredSlides&&a.cssMode&&!a.centeredSlidesBounds){g(e.wrapperEl,"--swiper-centered-offset-before",-u[0]+"px"),g(e.wrapperEl,"--swiper-centered-offset-after",e.size/2-m[m.length-1]/2+"px");const t=-e.snapGrid[0],s=-e.slidesGrid[0];e.snapGrid=e.snapGrid.map((e=>e+t)),e.slidesGrid=e.slidesGrid.map((e=>e+s))}p!==d&&e.emit("slidesLengthChange"),u.length!==w&&(e.params.watchOverflow&&e.checkOverflow(),e.emit("snapGridLengthChange")),h.length!==b&&e.emit("slidesGridLengthChange"),a.watchSlidesProgress&&e.updateSlidesOffset()},updateAutoHeight:function(e){const t=this,s=[],a=t.virtual&&t.params.virtual.enabled;let i,r=0;"number"==typeof e?t.setTransition(e):!0===e&&t.setTransition(t.params.speed);const n=e=>a?t.slides.filter((t=>parseInt(t.getAttribute("data-swiper-slide-index"),10)===e))[0]:t.slides.eq(e)[0];if("auto"!==t.params.slidesPerView&&t.params.slidesPerView>1)if(t.params.centeredSlides)t.visibleSlides.each((e=>{s.push(e)}));else for(i=0;it.slides.length&&!a)break;s.push(n(e))}else s.push(n(t.activeIndex));for(i=0;ir?e:r}r&&t.$wrapperEl.css("height",`${r}px`)},updateSlidesOffset:function(){const e=this,t=e.slides;for(let s=0;s=0&&p1&&u<=t.size||p<=0&&u>=t.size)&&(t.visibleSlides.push(l),t.visibleSlidesIndexes.push(e),a.eq(e).addClass(s.slideVisibleClass)),l.progress=i?-d:d,l.originalProgress=i?-c:c}t.visibleSlides=d(t.visibleSlides)},updateProgress:function(e){const t=this;if(void 0===e){const s=t.rtlTranslate?-1:1;e=t&&t.translate&&t.translate*s||0}const s=t.params,a=t.maxTranslate()-t.minTranslate();let{progress:i,isBeginning:r,isEnd:n}=t;const l=r,o=n;0===a?(i=0,r=!0,n=!0):(i=(e-t.minTranslate())/a,r=i<=0,n=i>=1),Object.assign(t,{progress:i,isBeginning:r,isEnd:n}),(s.watchSlidesProgress||s.centeredSlides&&s.autoHeight)&&t.updateSlidesProgress(e),r&&!l&&t.emit("reachBeginning toEdge"),n&&!o&&t.emit("reachEnd toEdge"),(l&&!r||o&&!n)&&t.emit("fromEdge"),t.emit("progress",i)},updateSlidesClasses:function(){const e=this,{slides:t,params:s,$wrapperEl:a,activeIndex:i,realIndex:r}=e,n=e.virtual&&s.virtual.enabled;let l;t.removeClass(`${s.slideActiveClass} ${s.slideNextClass} ${s.slidePrevClass} ${s.slideDuplicateActiveClass} ${s.slideDuplicateNextClass} ${s.slideDuplicatePrevClass}`),l=n?e.$wrapperEl.find(`.${s.slideClass}[data-swiper-slide-index="${i}"]`):t.eq(i),l.addClass(s.slideActiveClass),s.loop&&(l.hasClass(s.slideDuplicateClass)?a.children(`.${s.slideClass}:not(.${s.slideDuplicateClass})[data-swiper-slide-index="${r}"]`).addClass(s.slideDuplicateActiveClass):a.children(`.${s.slideClass}.${s.slideDuplicateClass}[data-swiper-slide-index="${r}"]`).addClass(s.slideDuplicateActiveClass));let o=l.nextAll(`.${s.slideClass}`).eq(0).addClass(s.slideNextClass);s.loop&&0===o.length&&(o=t.eq(0),o.addClass(s.slideNextClass));let d=l.prevAll(`.${s.slideClass}`).eq(0).addClass(s.slidePrevClass);s.loop&&0===d.length&&(d=t.eq(-1),d.addClass(s.slidePrevClass)),s.loop&&(o.hasClass(s.slideDuplicateClass)?a.children(`.${s.slideClass}:not(.${s.slideDuplicateClass})[data-swiper-slide-index="${o.attr("data-swiper-slide-index")}"]`).addClass(s.slideDuplicateNextClass):a.children(`.${s.slideClass}.${s.slideDuplicateClass}[data-swiper-slide-index="${o.attr("data-swiper-slide-index")}"]`).addClass(s.slideDuplicateNextClass),d.hasClass(s.slideDuplicateClass)?a.children(`.${s.slideClass}:not(.${s.slideDuplicateClass})[data-swiper-slide-index="${d.attr("data-swiper-slide-index")}"]`).addClass(s.slideDuplicatePrevClass):a.children(`.${s.slideClass}.${s.slideDuplicateClass}[data-swiper-slide-index="${d.attr("data-swiper-slide-index")}"]`).addClass(s.slideDuplicatePrevClass)),e.emitSlidesClasses()},updateActiveIndex:function(e){const t=this,s=t.rtlTranslate?t.translate:-t.translate,{slidesGrid:a,snapGrid:i,params:r,activeIndex:n,realIndex:l,snapIndex:o}=t;let d,c=e;if(void 0===c){for(let e=0;e=a[e]&&s=a[e]&&s=a[e]&&(c=e);r.normalizeSlideIndex&&(c<0||void 0===c)&&(c=0)}if(i.indexOf(s)>=0)d=i.indexOf(s);else{const e=Math.min(r.slidesPerGroupSkip,c);d=e+Math.floor((c-e)/r.slidesPerGroup)}if(d>=i.length&&(d=i.length-1),c===n)return void(d!==o&&(t.snapIndex=d,t.emit("snapIndexChange")));const p=parseInt(t.slides.eq(c).attr("data-swiper-slide-index")||c,10);Object.assign(t,{snapIndex:d,realIndex:p,previousIndex:n,activeIndex:c}),t.emit("activeIndexChange"),t.emit("snapIndexChange"),l!==p&&t.emit("realIndexChange"),(t.initialized||t.params.runCallbacksOnInit)&&t.emit("slideChange")},updateClickedSlide:function(e){const t=this,s=t.params,a=d(e).closest(`.${s.slideClass}`)[0];let i,r=!1;if(a)for(let e=0;eo?o:a&&e=o.length&&(g=o.length-1),(p||l.initialSlide||0)===(c||0)&&s&&r.emit("beforeSlideChangeStart");const w=-o[g];if(r.updateProgress(w),l.normalizeSlideIndex)for(let e=0;e=s&&t=s&&t=s&&(n=e)}if(r.initialized&&n!==p){if(!r.allowSlideNext&&wr.translate&&w>r.maxTranslate()&&(p||0)!==n)return!1}let b;if(b=n>p?"next":n{r.wrapperEl.style.scrollSnapType="",r._swiperImmediateVirtual=!1}))}else{if(!r.support.smoothScroll)return v({swiper:r,targetPosition:s,side:e?"left":"top"}),!0;h.scrollTo({[e?"left":"top"]:s,behavior:"smooth"})}return!0}return r.setTransition(t),r.setTranslate(w),r.updateActiveIndex(n),r.updateSlidesClasses(),r.emit("beforeTransitionStart",t,a),r.transitionStart(s,b),0===t?r.transitionEnd(s,b):r.animating||(r.animating=!0,r.onSlideToWrapperTransitionEnd||(r.onSlideToWrapperTransitionEnd=function(e){r&&!r.destroyed&&e.target===this&&(r.$wrapperEl[0].removeEventListener("transitionend",r.onSlideToWrapperTransitionEnd),r.$wrapperEl[0].removeEventListener("webkitTransitionEnd",r.onSlideToWrapperTransitionEnd),r.onSlideToWrapperTransitionEnd=null,delete r.onSlideToWrapperTransitionEnd,r.transitionEnd(s,b))}),r.$wrapperEl[0].addEventListener("transitionend",r.onSlideToWrapperTransitionEnd),r.$wrapperEl[0].addEventListener("webkitTransitionEnd",r.onSlideToWrapperTransitionEnd)),!0},slideToLoop:function(e=0,t=this.params.speed,s=!0,a){const i=this;let r=e;return i.params.loop&&(r+=i.loopedSlides),i.slideTo(r,t,s,a)},slideNext:function(e=this.params.speed,t=!0,s){const a=this,{animating:i,enabled:r,params:n}=a;if(!r)return a;let l=n.slidesPerGroup;"auto"===n.slidesPerView&&1===n.slidesPerGroup&&n.slidesPerGroupAuto&&(l=Math.max(a.slidesPerViewDynamic("current",!0),1));const o=a.activeIndexc(e)));let h=n[u.indexOf(p)-1];if(void 0===h&&i.cssMode){let e;n.forEach(((t,s)=>{p>=t&&(e=s)})),void 0!==e&&(h=n[e>0?e-1:e])}let m=0;return void 0!==h&&(m=l.indexOf(h),m<0&&(m=a.activeIndex-1),"auto"===i.slidesPerView&&1===i.slidesPerGroup&&i.slidesPerGroupAuto&&(m=m-a.slidesPerViewDynamic("previous",!0)+1,m=Math.max(m,0))),a.slideTo(m,e,t,s)},slideReset:function(e=this.params.speed,t=!0,s){return this.slideTo(this.activeIndex,e,t,s)},slideToClosest:function(e=this.params.speed,t=!0,s,a=.5){const i=this;let r=i.activeIndex;const n=Math.min(i.params.slidesPerGroupSkip,r),l=n+Math.floor((r-n)/i.params.slidesPerGroup),o=i.rtlTranslate?i.translate:-i.translate;if(o>=i.snapGrid[l]){const e=i.snapGrid[l];o-e>(i.snapGrid[l+1]-e)*a&&(r+=i.params.slidesPerGroup)}else{const e=i.snapGrid[l-1];o-e<=(i.snapGrid[l]-e)*a&&(r-=i.params.slidesPerGroup)}return r=Math.max(r,0),r=Math.min(r,i.slidesGrid.length-1),i.slideTo(r,e,t,s)},slideToClickedSlide:function(){const e=this,{params:t,$wrapperEl:s}=e,a="auto"===t.slidesPerView?e.slidesPerViewDynamic():t.slidesPerView;let i,r=e.clickedIndex;if(t.loop){if(e.animating)return;i=parseInt(d(e.clickedSlide).attr("data-swiper-slide-index"),10),t.centeredSlides?re.slides.length-e.loopedSlides+a/2?(e.loopFix(),r=s.children(`.${t.slideClass}[data-swiper-slide-index="${i}"]:not(.${t.slideDuplicateClass})`).eq(0).index(),p((()=>{e.slideTo(r)}))):e.slideTo(r):r>e.slides.length-a?(e.loopFix(),r=s.children(`.${t.slideClass}[data-swiper-slide-index="${i}"]:not(.${t.slideDuplicateClass})`).eq(0).index(),p((()=>{e.slideTo(r)}))):e.slideTo(r)}else e.slideTo(r)}},loop:{loopCreate:function(){const e=this,t=a(),{params:s,$wrapperEl:i}=e,r=i.children().length>0?d(i.children()[0].parentNode):i;r.children(`.${s.slideClass}.${s.slideDuplicateClass}`).remove();let n=r.children(`.${s.slideClass}`);if(s.loopFillGroupWithBlank){const e=s.slidesPerGroup-n.length%s.slidesPerGroup;if(e!==s.slidesPerGroup){for(let a=0;an.length&&(e.loopedSlides=n.length);const l=[],o=[];n.each(((t,s)=>{const a=d(t);s=n.length-e.loopedSlides&&l.push(t),a.attr("data-swiper-slide-index",s)}));for(let e=0;e=0;e-=1)r.prepend(d(l[e].cloneNode(!0)).addClass(s.slideDuplicateClass))},loopFix:function(){const e=this;e.emit("beforeLoopFix");const{activeIndex:t,slides:s,loopedSlides:a,allowSlidePrev:i,allowSlideNext:r,snapGrid:n,rtlTranslate:l}=e;let o;e.allowSlidePrev=!0,e.allowSlideNext=!0;const d=-n[t]-e.getTranslate();if(t=s.length-a){o=-s.length+t+a,o+=a;e.slideTo(o,0,!1,!0)&&0!==d&&e.setTranslate((l?-e.translate:e.translate)-d)}e.allowSlidePrev=i,e.allowSlideNext=r,e.emit("loopFix")},loopDestroy:function(){const{$wrapperEl:e,params:t,slides:s}=this;e.children(`.${t.slideClass}.${t.slideDuplicateClass},.${t.slideClass}.${t.slideBlankClass}`).remove(),s.removeAttr("data-swiper-slide-index")}},grabCursor:{setGrabCursor:function(e){const t=this;if(t.support.touch||!t.params.simulateTouch||t.params.watchOverflow&&t.isLocked||t.params.cssMode)return;const s="container"===t.params.touchEventsTarget?t.el:t.wrapperEl;s.style.cursor="move",s.style.cursor=e?"-webkit-grabbing":"-webkit-grab",s.style.cursor=e?"-moz-grabbin":"-moz-grab",s.style.cursor=e?"grabbing":"grab"},unsetGrabCursor:function(){const e=this;e.support.touch||e.params.watchOverflow&&e.isLocked||e.params.cssMode||(e["container"===e.params.touchEventsTarget?"el":"wrapperEl"].style.cursor="")}},events:{attachEvents:function(){const e=this,t=a(),{params:s,support:i}=e;e.onTouchStart=S.bind(e),e.onTouchMove=M.bind(e),e.onTouchEnd=P.bind(e),s.cssMode&&(e.onScroll=O.bind(e)),e.onClick=z.bind(e),i.touch&&!I&&(t.addEventListener("touchstart",L),I=!0),A(e,"on")},detachEvents:function(){A(this,"off")}},breakpoints:{setBreakpoint:function(){const e=this,{activeIndex:t,initialized:s,loopedSlides:a=0,params:i,$el:r}=e,n=i.breakpoints;if(!n||n&&0===Object.keys(n).length)return;const l=e.getBreakpoint(n,e.params.breakpointsBase,e.el);if(!l||e.currentBreakpoint===l)return;const o=(l in n?n[l]:void 0)||e.originalParams,d=D(e,i),c=D(e,o),p=i.enabled;d&&!c?(r.removeClass(`${i.containerModifierClass}grid ${i.containerModifierClass}grid-column`),e.emitContainerClasses()):!d&&c&&(r.addClass(`${i.containerModifierClass}grid`),(o.grid.fill&&"column"===o.grid.fill||!o.grid.fill&&"column"===i.grid.fill)&&r.addClass(`${i.containerModifierClass}grid-column`),e.emitContainerClasses());const u=o.direction&&o.direction!==i.direction,h=i.loop&&(o.slidesPerView!==i.slidesPerView||u);u&&s&&e.changeDirection(),f(e.params,o);const m=e.params.enabled;Object.assign(e,{allowTouchMove:e.params.allowTouchMove,allowSlideNext:e.params.allowSlideNext,allowSlidePrev:e.params.allowSlidePrev}),p&&!m?e.disable():!p&&m&&e.enable(),e.currentBreakpoint=l,e.emit("_beforeBreakpoint",o),h&&s&&(e.loopDestroy(),e.loopCreate(),e.updateSlides(),e.slideTo(t-a+e.loopedSlides,0,!1)),e.emit("breakpoint",o)},getBreakpoint:function(e,t="window",s){if(!e||"container"===t&&!s)return;let a=!1;const i=r(),n="window"===t?i.innerHeight:s.clientHeight,l=Object.keys(e).map((e=>{if("string"==typeof e&&0===e.indexOf("@")){const t=parseFloat(e.substr(1));return{value:n*t,point:e}}return{value:e,point:e}}));l.sort(((e,t)=>parseInt(e.value,10)-parseInt(t.value,10)));for(let e=0;es}else e.isLocked=1===e.snapGrid.length;!0===s.allowSlideNext&&(e.allowSlideNext=!e.isLocked),!0===s.allowSlidePrev&&(e.allowSlidePrev=!e.isLocked),t&&t!==e.isLocked&&(e.isEnd=!1),t!==e.isLocked&&e.emit(e.isLocked?"lock":"unlock")}},classes:{addClasses:function(){const e=this,{classNames:t,params:s,rtl:a,$el:i,device:r,support:n}=e,l=function(e,t){const s=[];return e.forEach((e=>{"object"==typeof e?Object.keys(e).forEach((a=>{e[a]&&s.push(t+a)})):"string"==typeof e&&s.push(t+e)})),s}(["initialized",s.direction,{"pointer-events":!n.touch},{"free-mode":e.params.freeMode&&s.freeMode.enabled},{autoheight:s.autoHeight},{rtl:a},{grid:s.grid&&s.grid.rows>1},{"grid-column":s.grid&&s.grid.rows>1&&"column"===s.grid.fill},{android:r.android},{ios:r.ios},{"css-mode":s.cssMode},{centered:s.cssMode&&s.centeredSlides}],s.containerModifierClass);t.push(...l),i.addClass([...t].join(" ")),e.emitContainerClasses()},removeClasses:function(){const{$el:e,classNames:t}=this;e.removeClass(t.join(" ")),this.emitContainerClasses()}},images:{loadImage:function(e,t,s,a,i,n){const l=r();let o;function c(){n&&n()}d(e).parent("picture")[0]||e.complete&&i?c():t?(o=new l.Image,o.onload=c,o.onerror=c,a&&(o.sizes=a),s&&(o.srcset=s),t&&(o.src=t)):c()},preloadImages:function(){const e=this;function t(){null!=e&&e&&!e.destroyed&&(void 0!==e.imagesLoaded&&(e.imagesLoaded+=1),e.imagesLoaded===e.imagesToLoad.length&&(e.params.updateOnImagesReady&&e.update(),e.emit("imagesReady")))}e.imagesToLoad=e.$el.find("img");for(let s=0;s1){const e=[];return d(s.el).each((t=>{const a=f({},s,{el:t});e.push(new H(a))})),e}const a=this;a.__swiper__=!0,a.support=y(),a.device=E({userAgent:s.userAgent}),a.browser=T(),a.eventsListeners={},a.eventsAnyListeners=[],a.modules=[...a.__modules__],s.modules&&Array.isArray(s.modules)&&a.modules.push(...s.modules);const i={};a.modules.forEach((e=>{e({swiper:a,extendParams:N(s,i),on:a.on.bind(a),once:a.once.bind(a),off:a.off.bind(a),emit:a.emit.bind(a)})}));const r=f({},G,i);return a.params=f({},r,X,s),a.originalParams=f({},a.params),a.passedParams=f({},s),a.params&&a.params.on&&Object.keys(a.params.on).forEach((e=>{a.on(e,a.params.on[e])})),a.params&&a.params.onAny&&a.onAny(a.params.onAny),a.$=d,Object.assign(a,{enabled:a.params.enabled,el:t,classNames:[],slides:d(),slidesGrid:[],snapGrid:[],slidesSizesGrid:[],isHorizontal:()=>"horizontal"===a.params.direction,isVertical:()=>"vertical"===a.params.direction,activeIndex:0,realIndex:0,isBeginning:!0,isEnd:!1,translate:0,previousTranslate:0,progress:0,velocity:0,animating:!1,allowSlideNext:a.params.allowSlideNext,allowSlidePrev:a.params.allowSlidePrev,touchEvents:function(){const e=["touchstart","touchmove","touchend","touchcancel"],t=["pointerdown","pointermove","pointerup"];return a.touchEventsTouch={start:e[0],move:e[1],end:e[2],cancel:e[3]},a.touchEventsDesktop={start:t[0],move:t[1],end:t[2]},a.support.touch||!a.params.simulateTouch?a.touchEventsTouch:a.touchEventsDesktop}(),touchEventsData:{isTouched:void 0,isMoved:void 0,allowTouchCallbacks:void 0,touchStartTime:void 0,isScrolling:void 0,currentTranslate:void 0,startTranslate:void 0,allowThresholdMove:void 0,focusableElements:a.params.focusableElements,lastClickTime:u(),clickTimeout:void 0,velocities:[],allowMomentumBounce:void 0,isTouchEvent:void 0,startMoving:void 0},allowClick:!0,allowTouchMove:a.params.allowTouchMove,touches:{startX:0,startY:0,currentX:0,currentY:0,diff:0},imagesToLoad:[],imagesLoaded:0}),a.emit("_swiper"),a.params.init&&a.init(),a}enable(){const e=this;e.enabled||(e.enabled=!0,e.params.grabCursor&&e.setGrabCursor(),e.emit("enable"))}disable(){const e=this;e.enabled&&(e.enabled=!1,e.params.grabCursor&&e.unsetGrabCursor(),e.emit("disable"))}setProgress(e,t){const s=this;e=Math.min(Math.max(e,0),1);const a=s.minTranslate(),i=(s.maxTranslate()-a)*e+a;s.translateTo(i,void 0===t?0:t),s.updateActiveIndex(),s.updateSlidesClasses()}emitContainerClasses(){const e=this;if(!e.params._emitClasses||!e.el)return;const t=e.el.className.split(" ").filter((t=>0===t.indexOf("swiper")||0===t.indexOf(e.params.containerModifierClass)));e.emit("_containerClasses",t.join(" "))}getSlideClasses(e){const t=this;return e.className.split(" ").filter((e=>0===e.indexOf("swiper-slide")||0===e.indexOf(t.params.slideClass))).join(" ")}emitSlidesClasses(){const e=this;if(!e.params._emitClasses||!e.el)return;const t=[];e.slides.each((s=>{const a=e.getSlideClasses(s);t.push({slideEl:s,classNames:a}),e.emit("_slideClass",s,a)})),e.emit("_slideClasses",t)}slidesPerViewDynamic(e="current",t=!1){const{params:s,slides:a,slidesGrid:i,slidesSizesGrid:r,size:n,activeIndex:l}=this;let o=1;if(s.centeredSlides){let e,t=a[l].swiperSlideSize;for(let s=l+1;sn&&(e=!0));for(let s=l-1;s>=0;s-=1)a[s]&&!e&&(t+=a[s].swiperSlideSize,o+=1,t>n&&(e=!0))}else if("current"===e)for(let e=l+1;e=0;e-=1){i[l]-i[e]1)&&e.isEnd&&!e.params.centeredSlides?e.slideTo(e.slides.length-1,0,!1,!0):e.slideTo(e.activeIndex,0,!1,!0),i||a()),s.watchOverflow&&t!==e.snapGrid&&e.checkOverflow(),e.emit("update")}changeDirection(e,t=!0){const s=this,a=s.params.direction;return e||(e="horizontal"===a?"vertical":"horizontal"),e===a||"horizontal"!==e&&"vertical"!==e||(s.$el.removeClass(`${s.params.containerModifierClass}${a}`).addClass(`${s.params.containerModifierClass}${e}`),s.emitContainerClasses(),s.params.direction=e,s.slides.each((t=>{"vertical"===e?t.style.width="":t.style.height=""})),s.emit("changeDirection"),t&&s.update()),s}mount(e){const t=this;if(t.mounted)return!0;const s=d(e||t.params.el);if(!(e=s[0]))return!1;e.swiper=t;const i=()=>`.${(t.params.wrapperClass||"").trim().split(" ").join(".")}`;let r=(()=>{if(e&&e.shadowRoot&&e.shadowRoot.querySelector){const t=d(e.shadowRoot.querySelector(i()));return t.children=e=>s.children(e),t}return s.children(i())})();if(0===r.length&&t.params.createElements){const e=a().createElement("div");r=d(e),e.className=t.params.wrapperClass,s.append(e),s.children(`.${t.params.slideClass}`).each((e=>{r.append(e)}))}return Object.assign(t,{$el:s,el:e,$wrapperEl:r,wrapperEl:r[0],mounted:!0,rtl:"rtl"===e.dir.toLowerCase()||"rtl"===s.css("direction"),rtlTranslate:"horizontal"===t.params.direction&&("rtl"===e.dir.toLowerCase()||"rtl"===s.css("direction")),wrongRTL:"-webkit-box"===r.css("display")}),!0}init(e){const t=this;if(t.initialized)return t;return!1===t.mount(e)||(t.emit("beforeInit"),t.params.breakpoints&&t.setBreakpoint(),t.addClasses(),t.params.loop&&t.loopCreate(),t.updateSize(),t.updateSlides(),t.params.watchOverflow&&t.checkOverflow(),t.params.grabCursor&&t.enabled&&t.setGrabCursor(),t.params.preloadImages&&t.preloadImages(),t.params.loop?t.slideTo(t.params.initialSlide+t.loopedSlides,0,t.params.runCallbacksOnInit,!1,!0):t.slideTo(t.params.initialSlide,0,t.params.runCallbacksOnInit,!1,!0),t.attachEvents(),t.initialized=!0,t.emit("init"),t.emit("afterInit")),t}destroy(e=!0,t=!0){const s=this,{params:a,$el:i,$wrapperEl:r,slides:n}=s;return void 0===s.params||s.destroyed||(s.emit("beforeDestroy"),s.initialized=!1,s.detachEvents(),a.loop&&s.loopDestroy(),t&&(s.removeClasses(),i.removeAttr("style"),r.removeAttr("style"),n&&n.length&&n.removeClass([a.slideVisibleClass,a.slideActiveClass,a.slideNextClass,a.slidePrevClass].join(" ")).removeAttr("style").removeAttr("data-swiper-slide-index")),s.emit("destroy"),Object.keys(s.eventsListeners).forEach((e=>{s.off(e)})),!1!==e&&(s.$el[0].swiper=null,function(e){const t=e;Object.keys(t).forEach((e=>{try{t[e]=null}catch(e){}try{delete t[e]}catch(e){}}))}(s)),s.destroyed=!0),null}static extendDefaults(e){f(X,e)}static get extendedDefaults(){return X}static get defaults(){return G}static installModule(e){H.prototype.__modules__||(H.prototype.__modules__=[]);const t=H.prototype.__modules__;"function"==typeof e&&t.indexOf(e)<0&&t.push(e)}static use(e){return Array.isArray(e)?(e.forEach((e=>H.installModule(e))),H):(H.installModule(e),H)}}function Y(e,t,s,i){const r=a();return e.params.createElements&&Object.keys(i).forEach((a=>{if(!s[a]&&!0===s.auto){let n=e.$el.children(`.${i[a]}`)[0];n||(n=r.createElement("div"),n.className=i[a],e.$el.append(n)),s[a]=n,t[a]=n}})),s}function W(e=""){return`.${e.trim().replace(/([\.:!\/])/g,"\\$1").replace(/ /g,".")}`}function R(e){const t=this,{$wrapperEl:s,params:a}=t;if(a.loop&&t.loopDestroy(),"object"==typeof e&&"length"in e)for(let t=0;t=l)return void s.appendSlide(t);let o=n>e?n+1:n;const d=[];for(let t=l-1;t>=e;t-=1){const e=s.slides.eq(t);e.remove(),d.unshift(e)}if("object"==typeof t&&"length"in t){for(let e=0;ee?n+t.length:n}else a.append(t);for(let e=0;e{if(s.params.effect!==t)return;s.classNames.push(`${s.params.containerModifierClass}${t}`),l&&l()&&s.classNames.push(`${s.params.containerModifierClass}3d`);const e=n?n():{};Object.assign(s.params,e),Object.assign(s.originalParams,e)})),a("setTranslate",(()=>{s.params.effect===t&&i()})),a("setTransition",((e,a)=>{s.params.effect===t&&r(a)}))}function U(e,t){return e.transformEl?t.find(e.transformEl).css({"backface-visibility":"hidden","-webkit-backface-visibility":"hidden"}):t}function K({swiper:e,duration:t,transformEl:s,allSlides:a}){const{slides:i,activeIndex:r,$wrapperEl:n}=e;if(e.params.virtualTranslate&&0!==t){let t,l=!1;t=a?s?i.find(s):i:s?i.eq(r).find(s):i.eq(r),t.transitionEnd((()=>{if(l)return;if(!e||e.destroyed)return;l=!0,e.animating=!1;const t=["webkitTransitionEnd","transitionend"];for(let e=0;e
`),i.append(r)),r}Object.keys(B).forEach((e=>{Object.keys(B[e]).forEach((t=>{H.prototype[t]=B[e][t]}))})),H.use([function({swiper:e,on:t,emit:s}){const a=r();let i=null;const n=()=>{e&&!e.destroyed&&e.initialized&&(s("beforeResize"),s("resize"))},l=()=>{e&&!e.destroyed&&e.initialized&&s("orientationchange")};t("init",(()=>{e.params.resizeObserver&&void 0!==a.ResizeObserver?e&&!e.destroyed&&e.initialized&&(i=new ResizeObserver((t=>{const{width:s,height:a}=e;let i=s,r=a;t.forEach((({contentBoxSize:t,contentRect:s,target:a})=>{a&&a!==e.el||(i=s?s.width:(t[0]||t).inlineSize,r=s?s.height:(t[0]||t).blockSize)})),i===s&&r===a||n()})),i.observe(e.el)):(a.addEventListener("resize",n),a.addEventListener("orientationchange",l))})),t("destroy",(()=>{i&&i.unobserve&&e.el&&(i.unobserve(e.el),i=null),a.removeEventListener("resize",n),a.removeEventListener("orientationchange",l)}))},function({swiper:e,extendParams:t,on:s,emit:a}){const i=[],n=r(),l=(e,t={})=>{const s=new(n.MutationObserver||n.WebkitMutationObserver)((e=>{if(1===e.length)return void a("observerUpdate",e[0]);const t=function(){a("observerUpdate",e[0])};n.requestAnimationFrame?n.requestAnimationFrame(t):n.setTimeout(t,0)}));s.observe(e,{attributes:void 0===t.attributes||t.attributes,childList:void 0===t.childList||t.childList,characterData:void 0===t.characterData||t.characterData}),i.push(s)};t({observer:!1,observeParents:!1,observeSlideChildren:!1}),s("init",(()=>{if(e.params.observer){if(e.params.observeParents){const t=e.$el.parents();for(let e=0;e{i.forEach((e=>{e.disconnect()})),i.splice(0,i.length)}))}]);const J=[function({swiper:e,extendParams:t,on:s}){let a;function i(t,s){const a=e.params.virtual;if(a.cache&&e.virtual.cache[s])return e.virtual.cache[s];const i=a.renderSlide?d(a.renderSlide.call(e,t,s)):d(`
${t}
`);return i.attr("data-swiper-slide-index")||i.attr("data-swiper-slide-index",s),a.cache&&(e.virtual.cache[s]=i),i}function r(t){const{slidesPerView:s,slidesPerGroup:a,centeredSlides:r}=e.params,{addSlidesBefore:n,addSlidesAfter:l}=e.params.virtual,{from:o,to:d,slides:c,slidesGrid:p,offset:u}=e.virtual;e.params.cssMode||e.updateActiveIndex();const h=e.activeIndex||0;let m,f,g;m=e.rtlTranslate?"right":e.isHorizontal()?"left":"top",r?(f=Math.floor(s/2)+a+l,g=Math.floor(s/2)+a+n):(f=s+(a-1)+l,g=a+n);const v=Math.max((h||0)-g,0),w=Math.min((h||0)+f,c.length-1),b=(e.slidesGrid[v]||0)-(e.slidesGrid[0]||0);function x(){e.updateSlides(),e.updateProgress(),e.updateSlidesClasses(),e.lazy&&e.params.lazy.enabled&&e.lazy.load()}if(Object.assign(e.virtual,{from:v,to:w,offset:b,slidesGrid:e.slidesGrid}),o===v&&d===w&&!t)return e.slidesGrid!==p&&b!==u&&e.slides.css(m,`${b}px`),void e.updateProgress();if(e.params.virtual.renderExternal)return e.params.virtual.renderExternal.call(e,{offset:b,from:v,to:w,slides:function(){const e=[];for(let t=v;t<=w;t+=1)e.push(c[t]);return e}()}),void(e.params.virtual.renderExternalUpdate&&x());const y=[],E=[];if(t)e.$wrapperEl.find(`.${e.params.slideClass}`).remove();else for(let t=o;t<=d;t+=1)(tw)&&e.$wrapperEl.find(`.${e.params.slideClass}[data-swiper-slide-index="${t}"]`).remove();for(let e=0;e=v&&e<=w&&(void 0===d||t?E.push(e):(e>d&&E.push(e),e{e.$wrapperEl.append(i(c[t],t))})),y.sort(((e,t)=>t-e)).forEach((t=>{e.$wrapperEl.prepend(i(c[t],t))})),e.$wrapperEl.children(".swiper-slide").css(m,`${b}px`),x()}t({virtual:{enabled:!1,slides:[],cache:!0,renderSlide:null,renderExternal:null,renderExternalUpdate:!0,addSlidesBefore:0,addSlidesAfter:0}}),e.virtual={cache:{},from:void 0,to:void 0,slides:[],offset:0,slidesGrid:[]},s("beforeInit",(()=>{e.params.virtual.enabled&&(e.virtual.slides=e.params.virtual.slides,e.classNames.push(`${e.params.containerModifierClass}virtual`),e.params.watchSlidesProgress=!0,e.originalParams.watchSlidesProgress=!0,e.params.initialSlide||r())})),s("setTranslate",(()=>{e.params.virtual.enabled&&(e.params.cssMode&&!e._immediateVirtual?(clearTimeout(a),a=setTimeout((()=>{r()}),100)):r())})),s("init update resize",(()=>{e.params.virtual.enabled&&e.params.cssMode&&g(e.wrapperEl,"--swiper-virtual-size",`${e.virtualSize}px`)})),Object.assign(e.virtual,{appendSlide:function(t){if("object"==typeof t&&"length"in t)for(let s=0;s{const a=t[e],r=a.attr("data-swiper-slide-index");r&&a.attr("data-swiper-slide-index",parseInt(r,10)+i),s[parseInt(e,10)+i]=a})),e.virtual.cache=s}r(!0),e.slideTo(a,0)},removeSlide:function(t){if(null==t)return;let s=e.activeIndex;if(Array.isArray(t))for(let a=t.length-1;a>=0;a-=1)e.virtual.slides.splice(t[a],1),e.params.virtual.cache&&delete e.virtual.cache[t[a]],t[a]0&&0===e.$el.parents(`.${e.params.slideActiveClass}`).length)return;const a=e.$el,i=a[0].clientWidth,r=a[0].clientHeight,n=l.innerWidth,o=l.innerHeight,d=e.$el.offset();s&&(d.left-=e.$el[0].scrollLeft);const c=[[d.left,d.top],[d.left+i,d.top],[d.left,d.top+r],[d.left+i,d.top+r]];for(let e=0;e=0&&s[0]<=n&&s[1]>=0&&s[1]<=o){if(0===s[0]&&0===s[1])continue;t=!0}}if(!t)return}e.isHorizontal()?((d||c||p||u)&&(a.preventDefault?a.preventDefault():a.returnValue=!1),((c||u)&&!s||(d||p)&&s)&&e.slideNext(),((d||p)&&!s||(c||u)&&s)&&e.slidePrev()):((d||c||h||m)&&(a.preventDefault?a.preventDefault():a.returnValue=!1),(c||m)&&e.slideNext(),(d||h)&&e.slidePrev()),i("keyPress",r)}}function c(){e.keyboard.enabled||(d(n).on("keydown",o),e.keyboard.enabled=!0)}function p(){e.keyboard.enabled&&(d(n).off("keydown",o),e.keyboard.enabled=!1)}e.keyboard={enabled:!1},t({keyboard:{enabled:!1,onlyInViewport:!0,pageUpDown:!0}}),s("init",(()=>{e.params.keyboard.enabled&&c()})),s("destroy",(()=>{e.keyboard.enabled&&p()})),Object.assign(e.keyboard,{enable:c,disable:p})},function({swiper:e,extendParams:t,on:s,emit:a}){const i=r();let n;t({mousewheel:{enabled:!1,releaseOnEdges:!1,invert:!1,forceToAxis:!1,sensitivity:1,eventsTarget:"container",thresholdDelta:null,thresholdTime:null}}),e.mousewheel={enabled:!1};let l,o=u();const c=[];function h(){e.enabled&&(e.mouseEntered=!0)}function m(){e.enabled&&(e.mouseEntered=!1)}function f(t){return!(e.params.mousewheel.thresholdDelta&&t.delta=6&&u()-o<60||(t.direction<0?e.isEnd&&!e.params.loop||e.animating||(e.slideNext(),a("scroll",t.raw)):e.isBeginning&&!e.params.loop||e.animating||(e.slidePrev(),a("scroll",t.raw)),o=(new i.Date).getTime(),!1)))}function g(t){let s=t,i=!0;if(!e.enabled)return;const r=e.params.mousewheel;e.params.cssMode&&s.preventDefault();let o=e.$el;if("container"!==e.params.mousewheel.eventsTarget&&(o=d(e.params.mousewheel.eventsTarget)),!e.mouseEntered&&!o[0].contains(s.target)&&!r.releaseOnEdges)return!0;s.originalEvent&&(s=s.originalEvent);let h=0;const m=e.rtlTranslate?-1:1,g=function(e){let t=0,s=0,a=0,i=0;return"detail"in e&&(s=e.detail),"wheelDelta"in e&&(s=-e.wheelDelta/120),"wheelDeltaY"in e&&(s=-e.wheelDeltaY/120),"wheelDeltaX"in e&&(t=-e.wheelDeltaX/120),"axis"in e&&e.axis===e.HORIZONTAL_AXIS&&(t=s,s=0),a=10*t,i=10*s,"deltaY"in e&&(i=e.deltaY),"deltaX"in e&&(a=e.deltaX),e.shiftKey&&!a&&(a=i,i=0),(a||i)&&e.deltaMode&&(1===e.deltaMode?(a*=40,i*=40):(a*=800,i*=800)),a&&!t&&(t=a<1?-1:1),i&&!s&&(s=i<1?-1:1),{spinX:t,spinY:s,pixelX:a,pixelY:i}}(s);if(r.forceToAxis)if(e.isHorizontal()){if(!(Math.abs(g.pixelX)>Math.abs(g.pixelY)))return!0;h=-g.pixelX*m}else{if(!(Math.abs(g.pixelY)>Math.abs(g.pixelX)))return!0;h=-g.pixelY}else h=Math.abs(g.pixelX)>Math.abs(g.pixelY)?-g.pixelX*m:-g.pixelY;if(0===h)return!0;r.invert&&(h=-h);let v=e.getTranslate()+h*r.sensitivity;if(v>=e.minTranslate()&&(v=e.minTranslate()),v<=e.maxTranslate()&&(v=e.maxTranslate()),i=!!e.params.loop||!(v===e.minTranslate()||v===e.maxTranslate()),i&&e.params.nested&&s.stopPropagation(),e.params.freeMode&&e.params.freeMode.enabled){const t={time:u(),delta:Math.abs(h),direction:Math.sign(h)},i=l&&t.time=e.minTranslate()&&(o=e.minTranslate()),o<=e.maxTranslate()&&(o=e.maxTranslate()),e.setTransition(0),e.setTranslate(o),e.updateProgress(),e.updateActiveIndex(),e.updateSlidesClasses(),(!d&&e.isBeginning||!u&&e.isEnd)&&e.updateSlidesClasses(),e.params.freeMode.sticky){clearTimeout(n),n=void 0,c.length>=15&&c.shift();const s=c.length?c[c.length-1]:void 0,a=c[0];if(c.push(t),s&&(t.delta>s.delta||t.direction!==s.direction))c.splice(0);else if(c.length>=15&&t.time-a.time<500&&a.delta-t.delta>=1&&t.delta<=6){const s=h>0?.8:.2;l=t,c.splice(0),n=p((()=>{e.slideToClosest(e.params.speed,!0,void 0,s)}),0)}n||(n=p((()=>{l=t,c.splice(0),e.slideToClosest(e.params.speed,!0,void 0,.5)}),500))}if(i||a("scroll",s),e.params.autoplay&&e.params.autoplayDisableOnInteraction&&e.autoplay.stop(),o===e.minTranslate()||o===e.maxTranslate())return!0}}else{const s={time:u(),delta:Math.abs(h),direction:Math.sign(h),raw:t};c.length>=2&&c.shift();const a=c.length?c[c.length-1]:void 0;if(c.push(s),a?(s.direction!==a.direction||s.delta>a.delta||s.time>a.time+150)&&f(s):f(s),function(t){const s=e.params.mousewheel;if(t.direction<0){if(e.isEnd&&!e.params.loop&&s.releaseOnEdges)return!0}else if(e.isBeginning&&!e.params.loop&&s.releaseOnEdges)return!0;return!1}(s))return!0}return s.preventDefault?s.preventDefault():s.returnValue=!1,!1}function v(t){let s=e.$el;"container"!==e.params.mousewheel.eventsTarget&&(s=d(e.params.mousewheel.eventsTarget)),s[t]("mouseenter",h),s[t]("mouseleave",m),s[t]("wheel",g)}function w(){return e.params.cssMode?(e.wrapperEl.removeEventListener("wheel",g),!0):!e.mousewheel.enabled&&(v("on"),e.mousewheel.enabled=!0,!0)}function b(){return e.params.cssMode?(e.wrapperEl.addEventListener(event,g),!0):!!e.mousewheel.enabled&&(v("off"),e.mousewheel.enabled=!1,!0)}s("init",(()=>{!e.params.mousewheel.enabled&&e.params.cssMode&&b(),e.params.mousewheel.enabled&&w()})),s("destroy",(()=>{e.params.cssMode&&w(),e.mousewheel.enabled&&b()})),Object.assign(e.mousewheel,{enable:w,disable:b})},function({swiper:e,extendParams:t,on:s,emit:a}){function i(t){let s;return t&&(s=d(t),e.params.uniqueNavElements&&"string"==typeof t&&s.length>1&&1===e.$el.find(t).length&&(s=e.$el.find(t))),s}function r(t,s){const a=e.params.navigation;t&&t.length>0&&(t[s?"addClass":"removeClass"](a.disabledClass),t[0]&&"BUTTON"===t[0].tagName&&(t[0].disabled=s),e.params.watchOverflow&&e.enabled&&t[e.isLocked?"addClass":"removeClass"](a.lockClass))}function n(){if(e.params.loop)return;const{$nextEl:t,$prevEl:s}=e.navigation;r(s,e.isBeginning),r(t,e.isEnd)}function l(t){t.preventDefault(),e.isBeginning&&!e.params.loop||e.slidePrev()}function o(t){t.preventDefault(),e.isEnd&&!e.params.loop||e.slideNext()}function c(){const t=e.params.navigation;if(e.params.navigation=Y(e,e.originalParams.navigation,e.params.navigation,{nextEl:"swiper-button-next",prevEl:"swiper-button-prev"}),!t.nextEl&&!t.prevEl)return;const s=i(t.nextEl),a=i(t.prevEl);s&&s.length>0&&s.on("click",o),a&&a.length>0&&a.on("click",l),Object.assign(e.navigation,{$nextEl:s,nextEl:s&&s[0],$prevEl:a,prevEl:a&&a[0]}),e.enabled||(s&&s.addClass(t.lockClass),a&&a.addClass(t.lockClass))}function p(){const{$nextEl:t,$prevEl:s}=e.navigation;t&&t.length&&(t.off("click",o),t.removeClass(e.params.navigation.disabledClass)),s&&s.length&&(s.off("click",l),s.removeClass(e.params.navigation.disabledClass))}t({navigation:{nextEl:null,prevEl:null,hideOnClick:!1,disabledClass:"swiper-button-disabled",hiddenClass:"swiper-button-hidden",lockClass:"swiper-button-lock"}}),e.navigation={nextEl:null,$nextEl:null,prevEl:null,$prevEl:null},s("init",(()=>{c(),n()})),s("toEdge fromEdge lock unlock",(()=>{n()})),s("destroy",(()=>{p()})),s("enable disable",(()=>{const{$nextEl:t,$prevEl:s}=e.navigation;t&&t[e.enabled?"removeClass":"addClass"](e.params.navigation.lockClass),s&&s[e.enabled?"removeClass":"addClass"](e.params.navigation.lockClass)})),s("click",((t,s)=>{const{$nextEl:i,$prevEl:r}=e.navigation,n=s.target;if(e.params.navigation.hideOnClick&&!d(n).is(r)&&!d(n).is(i)){if(e.pagination&&e.params.pagination&&e.params.pagination.clickable&&(e.pagination.el===n||e.pagination.el.contains(n)))return;let t;i?t=i.hasClass(e.params.navigation.hiddenClass):r&&(t=r.hasClass(e.params.navigation.hiddenClass)),a(!0===t?"navigationShow":"navigationHide"),i&&i.toggleClass(e.params.navigation.hiddenClass),r&&r.toggleClass(e.params.navigation.hiddenClass)}})),Object.assign(e.navigation,{update:n,init:c,destroy:p})},function({swiper:e,extendParams:t,on:s,emit:a}){const i="swiper-pagination";let r;t({pagination:{el:null,bulletElement:"span",clickable:!1,hideOnClick:!1,renderBullet:null,renderProgressbar:null,renderFraction:null,renderCustom:null,progressbarOpposite:!1,type:"bullets",dynamicBullets:!1,dynamicMainBullets:1,formatFractionCurrent:e=>e,formatFractionTotal:e=>e,bulletClass:`${i}-bullet`,bulletActiveClass:`${i}-bullet-active`,modifierClass:`${i}-`,currentClass:`${i}-current`,totalClass:`${i}-total`,hiddenClass:`${i}-hidden`,progressbarFillClass:`${i}-progressbar-fill`,progressbarOppositeClass:`${i}-progressbar-opposite`,clickableClass:`${i}-clickable`,lockClass:`${i}-lock`,horizontalClass:`${i}-horizontal`,verticalClass:`${i}-vertical`}}),e.pagination={el:null,$el:null,bullets:[]};let n=0;function l(){return!e.params.pagination.el||!e.pagination.el||!e.pagination.$el||0===e.pagination.$el.length}function o(t,s){const{bulletActiveClass:a}=e.params.pagination;t[s]().addClass(`${a}-${s}`)[s]().addClass(`${a}-${s}-${s}`)}function c(){const t=e.rtl,s=e.params.pagination;if(l())return;const i=e.virtual&&e.params.virtual.enabled?e.virtual.slides.length:e.slides.length,c=e.pagination.$el;let p;const u=e.params.loop?Math.ceil((i-2*e.loopedSlides)/e.params.slidesPerGroup):e.snapGrid.length;if(e.params.loop?(p=Math.ceil((e.activeIndex-e.loopedSlides)/e.params.slidesPerGroup),p>i-1-2*e.loopedSlides&&(p-=i-2*e.loopedSlides),p>u-1&&(p-=u),p<0&&"bullets"!==e.params.paginationType&&(p=u+p)):p=void 0!==e.snapIndex?e.snapIndex:e.activeIndex||0,"bullets"===s.type&&e.pagination.bullets&&e.pagination.bullets.length>0){const a=e.pagination.bullets;let i,l,u;if(s.dynamicBullets&&(r=a.eq(0)[e.isHorizontal()?"outerWidth":"outerHeight"](!0),c.css(e.isHorizontal()?"width":"height",r*(s.dynamicMainBullets+4)+"px"),s.dynamicMainBullets>1&&void 0!==e.previousIndex&&(n+=p-e.previousIndex,n>s.dynamicMainBullets-1?n=s.dynamicMainBullets-1:n<0&&(n=0)),i=p-n,l=i+(Math.min(a.length,s.dynamicMainBullets)-1),u=(l+i)/2),a.removeClass(["","-next","-next-next","-prev","-prev-prev","-main"].map((e=>`${s.bulletActiveClass}${e}`)).join(" ")),c.length>1)a.each((e=>{const t=d(e),a=t.index();a===p&&t.addClass(s.bulletActiveClass),s.dynamicBullets&&(a>=i&&a<=l&&t.addClass(`${s.bulletActiveClass}-main`),a===i&&o(t,"prev"),a===l&&o(t,"next"))}));else{const t=a.eq(p),r=t.index();if(t.addClass(s.bulletActiveClass),s.dynamicBullets){const t=a.eq(i),n=a.eq(l);for(let e=i;e<=l;e+=1)a.eq(e).addClass(`${s.bulletActiveClass}-main`);if(e.params.loop)if(r>=a.length-s.dynamicMainBullets){for(let e=s.dynamicMainBullets;e>=0;e-=1)a.eq(a.length-e).addClass(`${s.bulletActiveClass}-main`);a.eq(a.length-s.dynamicMainBullets-1).addClass(`${s.bulletActiveClass}-prev`)}else o(t,"prev"),o(n,"next");else o(t,"prev"),o(n,"next")}}if(s.dynamicBullets){const i=Math.min(a.length,s.dynamicMainBullets+4),n=(r*i-r)/2-u*r,l=t?"right":"left";a.css(e.isHorizontal()?l:"top",`${n}px`)}}if("fraction"===s.type&&(c.find(W(s.currentClass)).text(s.formatFractionCurrent(p+1)),c.find(W(s.totalClass)).text(s.formatFractionTotal(u))),"progressbar"===s.type){let t;t=s.progressbarOpposite?e.isHorizontal()?"vertical":"horizontal":e.isHorizontal()?"horizontal":"vertical";const a=(p+1)/u;let i=1,r=1;"horizontal"===t?i=a:r=a,c.find(W(s.progressbarFillClass)).transform(`translate3d(0,0,0) scaleX(${i}) scaleY(${r})`).transition(e.params.speed)}"custom"===s.type&&s.renderCustom?(c.html(s.renderCustom(e,p+1,u)),a("paginationRender",c[0])):a("paginationUpdate",c[0]),e.params.watchOverflow&&e.enabled&&c[e.isLocked?"addClass":"removeClass"](s.lockClass)}function p(){const t=e.params.pagination;if(l())return;const s=e.virtual&&e.params.virtual.enabled?e.virtual.slides.length:e.slides.length,i=e.pagination.$el;let r="";if("bullets"===t.type){let a=e.params.loop?Math.ceil((s-2*e.loopedSlides)/e.params.slidesPerGroup):e.snapGrid.length;e.params.freeMode&&e.params.freeMode.enabled&&!e.params.loop&&a>s&&(a=s);for(let s=0;s`;i.html(r),e.pagination.bullets=i.find(W(t.bulletClass))}"fraction"===t.type&&(r=t.renderFraction?t.renderFraction.call(e,t.currentClass,t.totalClass):` / `,i.html(r)),"progressbar"===t.type&&(r=t.renderProgressbar?t.renderProgressbar.call(e,t.progressbarFillClass):``,i.html(r)),"custom"!==t.type&&a("paginationRender",e.pagination.$el[0])}function u(){e.params.pagination=Y(e,e.originalParams.pagination,e.params.pagination,{el:"swiper-pagination"});const t=e.params.pagination;if(!t.el)return;let s=d(t.el);0!==s.length&&(e.params.uniqueNavElements&&"string"==typeof t.el&&s.length>1&&(s=e.$el.find(t.el),s.length>1&&(s=s.filter((t=>d(t).parents(".swiper")[0]===e.el)))),"bullets"===t.type&&t.clickable&&s.addClass(t.clickableClass),s.addClass(t.modifierClass+t.type),s.addClass(t.modifierClass+e.params.direction),"bullets"===t.type&&t.dynamicBullets&&(s.addClass(`${t.modifierClass}${t.type}-dynamic`),n=0,t.dynamicMainBullets<1&&(t.dynamicMainBullets=1)),"progressbar"===t.type&&t.progressbarOpposite&&s.addClass(t.progressbarOppositeClass),t.clickable&&s.on("click",W(t.bulletClass),(function(t){t.preventDefault();let s=d(this).index()*e.params.slidesPerGroup;e.params.loop&&(s+=e.loopedSlides),e.slideTo(s)})),Object.assign(e.pagination,{$el:s,el:s[0]}),e.enabled||s.addClass(t.lockClass))}function h(){const t=e.params.pagination;if(l())return;const s=e.pagination.$el;s.removeClass(t.hiddenClass),s.removeClass(t.modifierClass+t.type),s.removeClass(t.modifierClass+e.params.direction),e.pagination.bullets&&e.pagination.bullets.removeClass&&e.pagination.bullets.removeClass(t.bulletActiveClass),t.clickable&&s.off("click",W(t.bulletClass))}s("init",(()=>{u(),p(),c()})),s("activeIndexChange",(()=>{(e.params.loop||void 0===e.snapIndex)&&c()})),s("snapIndexChange",(()=>{e.params.loop||c()})),s("slidesLengthChange",(()=>{e.params.loop&&(p(),c())})),s("snapGridLengthChange",(()=>{e.params.loop||(p(),c())})),s("destroy",(()=>{h()})),s("enable disable",(()=>{const{$el:t}=e.pagination;t&&t[e.enabled?"removeClass":"addClass"](e.params.pagination.lockClass)})),s("lock unlock",(()=>{c()})),s("click",((t,s)=>{const i=s.target,{$el:r}=e.pagination;if(e.params.pagination.el&&e.params.pagination.hideOnClick&&r.length>0&&!d(i).hasClass(e.params.pagination.bulletClass)){if(e.navigation&&(e.navigation.nextEl&&i===e.navigation.nextEl||e.navigation.prevEl&&i===e.navigation.prevEl))return;const t=r.hasClass(e.params.pagination.hiddenClass);a(!0===t?"paginationShow":"paginationHide"),r.toggleClass(e.params.pagination.hiddenClass)}})),Object.assign(e.pagination,{render:p,update:c,init:u,destroy:h})},function({swiper:e,extendParams:t,on:s,emit:i}){const r=a();let n,l,o,c,u=!1,h=null,m=null;function f(){if(!e.params.scrollbar.el||!e.scrollbar.el)return;const{scrollbar:t,rtlTranslate:s,progress:a}=e,{$dragEl:i,$el:r}=t,n=e.params.scrollbar;let d=l,c=(o-l)*a;s?(c=-c,c>0?(d=l-c,c=0):-c+l>o&&(d=o+c)):c<0?(d=l+c,c=0):c+l>o&&(d=o-c),e.isHorizontal()?(i.transform(`translate3d(${c}px, 0, 0)`),i[0].style.width=`${d}px`):(i.transform(`translate3d(0px, ${c}px, 0)`),i[0].style.height=`${d}px`),n.hide&&(clearTimeout(h),r[0].style.opacity=1,h=setTimeout((()=>{r[0].style.opacity=0,r.transition(400)}),1e3))}function g(){if(!e.params.scrollbar.el||!e.scrollbar.el)return;const{scrollbar:t}=e,{$dragEl:s,$el:a}=t;s[0].style.width="",s[0].style.height="",o=e.isHorizontal()?a[0].offsetWidth:a[0].offsetHeight,c=e.size/(e.virtualSize+e.params.slidesOffsetBefore-(e.params.centeredSlides?e.snapGrid[0]:0)),l="auto"===e.params.scrollbar.dragSize?o*c:parseInt(e.params.scrollbar.dragSize,10),e.isHorizontal()?s[0].style.width=`${l}px`:s[0].style.height=`${l}px`,a[0].style.display=c>=1?"none":"",e.params.scrollbar.hide&&(a[0].style.opacity=0),e.params.watchOverflow&&e.enabled&&t.$el[e.isLocked?"addClass":"removeClass"](e.params.scrollbar.lockClass)}function v(t){return e.isHorizontal()?"touchstart"===t.type||"touchmove"===t.type?t.targetTouches[0].clientX:t.clientX:"touchstart"===t.type||"touchmove"===t.type?t.targetTouches[0].clientY:t.clientY}function w(t){const{scrollbar:s,rtlTranslate:a}=e,{$el:i}=s;let r;r=(v(t)-i.offset()[e.isHorizontal()?"left":"top"]-(null!==n?n:l/2))/(o-l),r=Math.max(Math.min(r,1),0),a&&(r=1-r);const d=e.minTranslate()+(e.maxTranslate()-e.minTranslate())*r;e.updateProgress(d),e.setTranslate(d),e.updateActiveIndex(),e.updateSlidesClasses()}function b(t){const s=e.params.scrollbar,{scrollbar:a,$wrapperEl:r}=e,{$el:l,$dragEl:o}=a;u=!0,n=t.target===o[0]||t.target===o?v(t)-t.target.getBoundingClientRect()[e.isHorizontal()?"left":"top"]:null,t.preventDefault(),t.stopPropagation(),r.transition(100),o.transition(100),w(t),clearTimeout(m),l.transition(0),s.hide&&l.css("opacity",1),e.params.cssMode&&e.$wrapperEl.css("scroll-snap-type","none"),i("scrollbarDragStart",t)}function x(t){const{scrollbar:s,$wrapperEl:a}=e,{$el:r,$dragEl:n}=s;u&&(t.preventDefault?t.preventDefault():t.returnValue=!1,w(t),a.transition(0),r.transition(0),n.transition(0),i("scrollbarDragMove",t))}function y(t){const s=e.params.scrollbar,{scrollbar:a,$wrapperEl:r}=e,{$el:n}=a;u&&(u=!1,e.params.cssMode&&(e.$wrapperEl.css("scroll-snap-type",""),r.transition("")),s.hide&&(clearTimeout(m),m=p((()=>{n.css("opacity",0),n.transition(400)}),1e3)),i("scrollbarDragEnd",t),s.snapOnRelease&&e.slideToClosest())}function E(t){const{scrollbar:s,touchEventsTouch:a,touchEventsDesktop:i,params:n,support:l}=e,o=s.$el[0],d=!(!l.passiveListener||!n.passiveListeners)&&{passive:!1,capture:!1},c=!(!l.passiveListener||!n.passiveListeners)&&{passive:!0,capture:!1};if(!o)return;const p="on"===t?"addEventListener":"removeEventListener";l.touch?(o[p](a.start,b,d),o[p](a.move,x,d),o[p](a.end,y,c)):(o[p](i.start,b,d),r[p](i.move,x,d),r[p](i.end,y,c))}function T(){const{scrollbar:t,$el:s}=e;e.params.scrollbar=Y(e,e.originalParams.scrollbar,e.params.scrollbar,{el:"swiper-scrollbar"});const a=e.params.scrollbar;if(!a.el)return;let i=d(a.el);e.params.uniqueNavElements&&"string"==typeof a.el&&i.length>1&&1===s.find(a.el).length&&(i=s.find(a.el));let r=i.find(`.${e.params.scrollbar.dragClass}`);0===r.length&&(r=d(`
`),i.append(r)),Object.assign(t,{$el:i,el:i[0],$dragEl:r,dragEl:r[0]}),a.draggable&&e.params.scrollbar.el&&E("on"),i&&i[e.enabled?"removeClass":"addClass"](e.params.scrollbar.lockClass)}function C(){e.params.scrollbar.el&&E("off")}t({scrollbar:{el:null,dragSize:"auto",hide:!1,draggable:!1,snapOnRelease:!0,lockClass:"swiper-scrollbar-lock",dragClass:"swiper-scrollbar-drag"}}),e.scrollbar={el:null,dragEl:null,$el:null,$dragEl:null},s("init",(()=>{T(),g(),f()})),s("update resize observerUpdate lock unlock",(()=>{g()})),s("setTranslate",(()=>{f()})),s("setTransition",((t,s)=>{!function(t){e.params.scrollbar.el&&e.scrollbar.el&&e.scrollbar.$dragEl.transition(t)}(s)})),s("enable disable",(()=>{const{$el:t}=e.scrollbar;t&&t[e.enabled?"removeClass":"addClass"](e.params.scrollbar.lockClass)})),s("destroy",(()=>{C()})),Object.assign(e.scrollbar,{updateSize:g,setTranslate:f,init:T,destroy:C})},function({swiper:e,extendParams:t,on:s}){t({parallax:{enabled:!1}});const a=(t,s)=>{const{rtl:a}=e,i=d(t),r=a?-1:1,n=i.attr("data-swiper-parallax")||"0";let l=i.attr("data-swiper-parallax-x"),o=i.attr("data-swiper-parallax-y");const c=i.attr("data-swiper-parallax-scale"),p=i.attr("data-swiper-parallax-opacity");if(l||o?(l=l||"0",o=o||"0"):e.isHorizontal()?(l=n,o="0"):(o=n,l="0"),l=l.indexOf("%")>=0?parseInt(l,10)*s*r+"%":l*s*r+"px",o=o.indexOf("%")>=0?parseInt(o,10)*s+"%":o*s+"px",null!=p){const e=p-(p-1)*(1-Math.abs(s));i[0].style.opacity=e}if(null==c)i.transform(`translate3d(${l}, ${o}, 0px)`);else{const e=c-(c-1)*(1-Math.abs(s));i.transform(`translate3d(${l}, ${o}, 0px) scale(${e})`)}},i=()=>{const{$el:t,slides:s,progress:i,snapGrid:r}=e;t.children("[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]").each((e=>{a(e,i)})),s.each(((t,s)=>{let n=t.progress;e.params.slidesPerGroup>1&&"auto"!==e.params.slidesPerView&&(n+=Math.ceil(s/2)-i*(r.length-1)),n=Math.min(Math.max(n,-1),1),d(t).find("[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]").each((e=>{a(e,n)}))}))};s("beforeInit",(()=>{e.params.parallax.enabled&&(e.params.watchSlidesProgress=!0,e.originalParams.watchSlidesProgress=!0)})),s("init",(()=>{e.params.parallax.enabled&&i()})),s("setTranslate",(()=>{e.params.parallax.enabled&&i()})),s("setTransition",((t,s)=>{e.params.parallax.enabled&&((t=e.params.speed)=>{const{$el:s}=e;s.find("[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]").each((e=>{const s=d(e);let a=parseInt(s.attr("data-swiper-parallax-duration"),10)||t;0===t&&(a=0),s.transition(a)}))})(s)}))},function({swiper:e,extendParams:t,on:s,emit:a}){const i=r();t({zoom:{enabled:!1,maxRatio:3,minRatio:1,toggle:!0,containerClass:"swiper-zoom-container",zoomedSlideClass:"swiper-slide-zoomed"}}),e.zoom={enabled:!1};let n,l,o,c=1,p=!1;const u={$slideEl:void 0,slideWidth:void 0,slideHeight:void 0,$imageEl:void 0,$imageWrapEl:void 0,maxRatio:3},m={isTouched:void 0,isMoved:void 0,currentX:void 0,currentY:void 0,minX:void 0,minY:void 0,maxX:void 0,maxY:void 0,width:void 0,height:void 0,startX:void 0,startY:void 0,touchesStart:{},touchesCurrent:{}},f={x:void 0,y:void 0,prevPositionX:void 0,prevPositionY:void 0,prevTime:void 0};let g=1;function v(e){if(e.targetTouches.length<2)return 1;const t=e.targetTouches[0].pageX,s=e.targetTouches[0].pageY,a=e.targetTouches[1].pageX,i=e.targetTouches[1].pageY;return Math.sqrt((a-t)**2+(i-s)**2)}function w(t){const s=e.support,a=e.params.zoom;if(l=!1,o=!1,!s.gestures){if("touchstart"!==t.type||"touchstart"===t.type&&t.targetTouches.length<2)return;l=!0,u.scaleStart=v(t)}u.$slideEl&&u.$slideEl.length||(u.$slideEl=d(t.target).closest(`.${e.params.slideClass}`),0===u.$slideEl.length&&(u.$slideEl=e.slides.eq(e.activeIndex)),u.$imageEl=u.$slideEl.find(`.${a.containerClass}`).eq(0).find("picture, img, svg, canvas, .swiper-zoom-target").eq(0),u.$imageWrapEl=u.$imageEl.parent(`.${a.containerClass}`),u.maxRatio=u.$imageWrapEl.attr("data-swiper-zoom")||a.maxRatio,0!==u.$imageWrapEl.length)?(u.$imageEl&&u.$imageEl.transition(0),p=!0):u.$imageEl=void 0}function b(t){const s=e.support,a=e.params.zoom,i=e.zoom;if(!s.gestures){if("touchmove"!==t.type||"touchmove"===t.type&&t.targetTouches.length<2)return;o=!0,u.scaleMove=v(t)}u.$imageEl&&0!==u.$imageEl.length?(s.gestures?i.scale=t.scale*c:i.scale=u.scaleMove/u.scaleStart*c,i.scale>u.maxRatio&&(i.scale=u.maxRatio-1+(i.scale-u.maxRatio+1)**.5),i.scalem.touchesStart.x))return void(m.isTouched=!1);if(!e.isHorizontal()&&(Math.floor(m.minY)===Math.floor(m.startY)&&m.touchesCurrent.ym.touchesStart.y))return void(m.isTouched=!1)}t.cancelable&&t.preventDefault(),t.stopPropagation(),m.isMoved=!0,m.currentX=m.touchesCurrent.x-m.touchesStart.x+m.startX,m.currentY=m.touchesCurrent.y-m.touchesStart.y+m.startY,m.currentXm.maxX&&(m.currentX=m.maxX-1+(m.currentX-m.maxX+1)**.8),m.currentYm.maxY&&(m.currentY=m.maxY-1+(m.currentY-m.maxY+1)**.8),f.prevPositionX||(f.prevPositionX=m.touchesCurrent.x),f.prevPositionY||(f.prevPositionY=m.touchesCurrent.y),f.prevTime||(f.prevTime=Date.now()),f.x=(m.touchesCurrent.x-f.prevPositionX)/(Date.now()-f.prevTime)/2,f.y=(m.touchesCurrent.y-f.prevPositionY)/(Date.now()-f.prevTime)/2,Math.abs(m.touchesCurrent.x-f.prevPositionX)<2&&(f.x=0),Math.abs(m.touchesCurrent.y-f.prevPositionY)<2&&(f.y=0),f.prevPositionX=m.touchesCurrent.x,f.prevPositionY=m.touchesCurrent.y,f.prevTime=Date.now(),u.$imageWrapEl.transform(`translate3d(${m.currentX}px, ${m.currentY}px,0)`)}}function E(){const t=e.zoom;u.$slideEl&&e.previousIndex!==e.activeIndex&&(u.$imageEl&&u.$imageEl.transform("translate3d(0,0,0) scale(1)"),u.$imageWrapEl&&u.$imageWrapEl.transform("translate3d(0,0,0)"),t.scale=1,c=1,u.$slideEl=void 0,u.$imageEl=void 0,u.$imageWrapEl=void 0)}function T(t){const s=e.zoom,a=e.params.zoom;if(u.$slideEl||(t&&t.target&&(u.$slideEl=d(t.target).closest(`.${e.params.slideClass}`)),u.$slideEl||(e.params.virtual&&e.params.virtual.enabled&&e.virtual?u.$slideEl=e.$wrapperEl.children(`.${e.params.slideActiveClass}`):u.$slideEl=e.slides.eq(e.activeIndex)),u.$imageEl=u.$slideEl.find(`.${a.containerClass}`).eq(0).find("picture, img, svg, canvas, .swiper-zoom-target").eq(0),u.$imageWrapEl=u.$imageEl.parent(`.${a.containerClass}`)),!u.$imageEl||0===u.$imageEl.length||!u.$imageWrapEl||0===u.$imageWrapEl.length)return;let r,n,l,o,p,h,f,g,v,w,b,x,y,E,T,C,$,S;e.params.cssMode&&(e.wrapperEl.style.overflow="hidden",e.wrapperEl.style.touchAction="none"),u.$slideEl.addClass(`${a.zoomedSlideClass}`),void 0===m.touchesStart.x&&t?(r="touchend"===t.type?t.changedTouches[0].pageX:t.pageX,n="touchend"===t.type?t.changedTouches[0].pageY:t.pageY):(r=m.touchesStart.x,n=m.touchesStart.y),s.scale=u.$imageWrapEl.attr("data-swiper-zoom")||a.maxRatio,c=u.$imageWrapEl.attr("data-swiper-zoom")||a.maxRatio,t?($=u.$slideEl[0].offsetWidth,S=u.$slideEl[0].offsetHeight,l=u.$slideEl.offset().left+i.scrollX,o=u.$slideEl.offset().top+i.scrollY,p=l+$/2-r,h=o+S/2-n,v=u.$imageEl[0].offsetWidth,w=u.$imageEl[0].offsetHeight,b=v*s.scale,x=w*s.scale,y=Math.min($/2-b/2,0),E=Math.min(S/2-x/2,0),T=-y,C=-E,f=p*s.scale,g=h*s.scale,fT&&(f=T),gC&&(g=C)):(f=0,g=0),u.$imageWrapEl.transition(300).transform(`translate3d(${f}px, ${g}px,0)`),u.$imageEl.transition(300).transform(`translate3d(0,0,0) scale(${s.scale})`)}function C(){const t=e.zoom,s=e.params.zoom;u.$slideEl||(e.params.virtual&&e.params.virtual.enabled&&e.virtual?u.$slideEl=e.$wrapperEl.children(`.${e.params.slideActiveClass}`):u.$slideEl=e.slides.eq(e.activeIndex),u.$imageEl=u.$slideEl.find(`.${s.containerClass}`).eq(0).find("picture, img, svg, canvas, .swiper-zoom-target").eq(0),u.$imageWrapEl=u.$imageEl.parent(`.${s.containerClass}`)),u.$imageEl&&0!==u.$imageEl.length&&u.$imageWrapEl&&0!==u.$imageWrapEl.length&&(e.params.cssMode&&(e.wrapperEl.style.overflow="",e.wrapperEl.style.touchAction=""),t.scale=1,c=1,u.$imageWrapEl.transition(300).transform("translate3d(0,0,0)"),u.$imageEl.transition(300).transform("translate3d(0,0,0) scale(1)"),u.$slideEl.removeClass(`${s.zoomedSlideClass}`),u.$slideEl=void 0)}function $(t){const s=e.zoom;s.scale&&1!==s.scale?C():T(t)}function S(){const t=e.support;return{passiveListener:!("touchstart"!==e.touchEvents.start||!t.passiveListener||!e.params.passiveListeners)&&{passive:!0,capture:!1},activeListenerWithCapture:!t.passiveListener||{passive:!1,capture:!0}}}function M(){return`.${e.params.slideClass}`}function P(t){const{passiveListener:s}=S(),a=M();e.$wrapperEl[t]("gesturestart",a,w,s),e.$wrapperEl[t]("gesturechange",a,b,s),e.$wrapperEl[t]("gestureend",a,x,s)}function k(){n||(n=!0,P("on"))}function z(){n&&(n=!1,P("off"))}function O(){const t=e.zoom;if(t.enabled)return;t.enabled=!0;const s=e.support,{passiveListener:a,activeListenerWithCapture:i}=S(),r=M();s.gestures?(e.$wrapperEl.on(e.touchEvents.start,k,a),e.$wrapperEl.on(e.touchEvents.end,z,a)):"touchstart"===e.touchEvents.start&&(e.$wrapperEl.on(e.touchEvents.start,r,w,a),e.$wrapperEl.on(e.touchEvents.move,r,b,i),e.$wrapperEl.on(e.touchEvents.end,r,x,a),e.touchEvents.cancel&&e.$wrapperEl.on(e.touchEvents.cancel,r,x,a)),e.$wrapperEl.on(e.touchEvents.move,`.${e.params.zoom.containerClass}`,y,i)}function I(){const t=e.zoom;if(!t.enabled)return;const s=e.support;t.enabled=!1;const{passiveListener:a,activeListenerWithCapture:i}=S(),r=M();s.gestures?(e.$wrapperEl.off(e.touchEvents.start,k,a),e.$wrapperEl.off(e.touchEvents.end,z,a)):"touchstart"===e.touchEvents.start&&(e.$wrapperEl.off(e.touchEvents.start,r,w,a),e.$wrapperEl.off(e.touchEvents.move,r,b,i),e.$wrapperEl.off(e.touchEvents.end,r,x,a),e.touchEvents.cancel&&e.$wrapperEl.off(e.touchEvents.cancel,r,x,a)),e.$wrapperEl.off(e.touchEvents.move,`.${e.params.zoom.containerClass}`,y,i)}Object.defineProperty(e.zoom,"scale",{get:()=>g,set(e){if(g!==e){const t=u.$imageEl?u.$imageEl[0]:void 0,s=u.$slideEl?u.$slideEl[0]:void 0;a("zoomChange",e,t,s)}g=e}}),s("init",(()=>{e.params.zoom.enabled&&O()})),s("destroy",(()=>{I()})),s("touchStart",((t,s)=>{e.zoom.enabled&&function(t){const s=e.device;u.$imageEl&&0!==u.$imageEl.length&&(m.isTouched||(s.android&&t.cancelable&&t.preventDefault(),m.isTouched=!0,m.touchesStart.x="touchstart"===t.type?t.targetTouches[0].pageX:t.pageX,m.touchesStart.y="touchstart"===t.type?t.targetTouches[0].pageY:t.pageY))}(s)})),s("touchEnd",((t,s)=>{e.zoom.enabled&&function(){const t=e.zoom;if(!u.$imageEl||0===u.$imageEl.length)return;if(!m.isTouched||!m.isMoved)return m.isTouched=!1,void(m.isMoved=!1);m.isTouched=!1,m.isMoved=!1;let s=300,a=300;const i=f.x*s,r=m.currentX+i,n=f.y*a,l=m.currentY+n;0!==f.x&&(s=Math.abs((r-m.currentX)/f.x)),0!==f.y&&(a=Math.abs((l-m.currentY)/f.y));const o=Math.max(s,a);m.currentX=r,m.currentY=l;const d=m.width*t.scale,c=m.height*t.scale;m.minX=Math.min(u.slideWidth/2-d/2,0),m.maxX=-m.minX,m.minY=Math.min(u.slideHeight/2-c/2,0),m.maxY=-m.minY,m.currentX=Math.max(Math.min(m.currentX,m.maxX),m.minX),m.currentY=Math.max(Math.min(m.currentY,m.maxY),m.minY),u.$imageWrapEl.transition(o).transform(`translate3d(${m.currentX}px, ${m.currentY}px,0)`)}()})),s("doubleTap",((t,s)=>{!e.animating&&e.params.zoom.enabled&&e.zoom.enabled&&e.params.zoom.toggle&&$(s)})),s("transitionEnd",(()=>{e.zoom.enabled&&e.params.zoom.enabled&&E()})),s("slideChange",(()=>{e.zoom.enabled&&e.params.zoom.enabled&&e.params.cssMode&&E()})),Object.assign(e.zoom,{enable:O,disable:I,in:T,out:C,toggle:$})},function({swiper:e,extendParams:t,on:s,emit:a}){t({lazy:{checkInView:!1,enabled:!1,loadPrevNext:!1,loadPrevNextAmount:1,loadOnTransitionStart:!1,scrollingElement:"",elementClass:"swiper-lazy",loadingClass:"swiper-lazy-loading",loadedClass:"swiper-lazy-loaded",preloaderClass:"swiper-lazy-preloader"}}),e.lazy={};let i=!1,n=!1;function l(t,s=!0){const i=e.params.lazy;if(void 0===t)return;if(0===e.slides.length)return;const r=e.virtual&&e.params.virtual.enabled?e.$wrapperEl.children(`.${e.params.slideClass}[data-swiper-slide-index="${t}"]`):e.slides.eq(t),n=r.find(`.${i.elementClass}:not(.${i.loadedClass}):not(.${i.loadingClass})`);!r.hasClass(i.elementClass)||r.hasClass(i.loadedClass)||r.hasClass(i.loadingClass)||n.push(r[0]),0!==n.length&&n.each((t=>{const n=d(t);n.addClass(i.loadingClass);const o=n.attr("data-background"),c=n.attr("data-src"),p=n.attr("data-srcset"),u=n.attr("data-sizes"),h=n.parent("picture");e.loadImage(n[0],c||o,p,u,!1,(()=>{if(null!=e&&e&&(!e||e.params)&&!e.destroyed){if(o?(n.css("background-image",`url("${o}")`),n.removeAttr("data-background")):(p&&(n.attr("srcset",p),n.removeAttr("data-srcset")),u&&(n.attr("sizes",u),n.removeAttr("data-sizes")),h.length&&h.children("source").each((e=>{const t=d(e);t.attr("data-srcset")&&(t.attr("srcset",t.attr("data-srcset")),t.removeAttr("data-srcset"))})),c&&(n.attr("src",c),n.removeAttr("data-src"))),n.addClass(i.loadedClass).removeClass(i.loadingClass),r.find(`.${i.preloaderClass}`).remove(),e.params.loop&&s){const t=r.attr("data-swiper-slide-index");if(r.hasClass(e.params.slideDuplicateClass)){l(e.$wrapperEl.children(`[data-swiper-slide-index="${t}"]:not(.${e.params.slideDuplicateClass})`).index(),!1)}else{l(e.$wrapperEl.children(`.${e.params.slideDuplicateClass}[data-swiper-slide-index="${t}"]`).index(),!1)}}a("lazyImageReady",r[0],n[0]),e.params.autoHeight&&e.updateAutoHeight()}})),a("lazyImageLoad",r[0],n[0])}))}function o(){const{$wrapperEl:t,params:s,slides:a,activeIndex:i}=e,r=e.virtual&&s.virtual.enabled,o=s.lazy;let c=s.slidesPerView;function p(e){if(r){if(t.children(`.${s.slideClass}[data-swiper-slide-index="${e}"]`).length)return!0}else if(a[e])return!0;return!1}function u(e){return r?d(e).attr("data-swiper-slide-index"):d(e).index()}if("auto"===c&&(c=0),n||(n=!0),e.params.watchSlidesProgress)t.children(`.${s.slideVisibleClass}`).each((e=>{l(r?d(e).attr("data-swiper-slide-index"):d(e).index())}));else if(c>1)for(let e=i;e1||o.loadPrevNextAmount&&o.loadPrevNextAmount>1){const e=o.loadPrevNextAmount,t=c,s=Math.min(i+t+Math.max(e,t),a.length),r=Math.max(i-Math.max(t,e),0);for(let e=i+c;e0&&l(u(e));const a=t.children(`.${s.slidePrevClass}`);a.length>0&&l(u(a))}}function c(){const t=r();if(!e||e.destroyed)return;const s=e.params.lazy.scrollingElement?d(e.params.lazy.scrollingElement):d(t),a=s[0]===t,n=a?t.innerWidth:s[0].offsetWidth,l=a?t.innerHeight:s[0].offsetHeight,p=e.$el.offset(),{rtlTranslate:u}=e;let h=!1;u&&(p.left-=e.$el[0].scrollLeft);const m=[[p.left,p.top],[p.left+e.width,p.top],[p.left,p.top+e.height],[p.left+e.width,p.top+e.height]];for(let e=0;e=0&&t[0]<=n&&t[1]>=0&&t[1]<=l){if(0===t[0]&&0===t[1])continue;h=!0}}const f=!("touchstart"!==e.touchEvents.start||!e.support.passiveListener||!e.params.passiveListeners)&&{passive:!0,capture:!1};h?(o(),s.off("scroll",c,f)):i||(i=!0,s.on("scroll",c,f))}s("beforeInit",(()=>{e.params.lazy.enabled&&e.params.preloadImages&&(e.params.preloadImages=!1)})),s("init",(()=>{e.params.lazy.enabled&&(e.params.lazy.checkInView?c():o())})),s("scroll",(()=>{e.params.freeMode&&e.params.freeMode.enabled&&!e.params.freeMode.sticky&&o()})),s("scrollbarDragMove resize _freeModeNoMomentumRelease",(()=>{e.params.lazy.enabled&&(e.params.lazy.checkInView?c():o())})),s("transitionStart",(()=>{e.params.lazy.enabled&&(e.params.lazy.loadOnTransitionStart||!e.params.lazy.loadOnTransitionStart&&!n)&&(e.params.lazy.checkInView?c():o())})),s("transitionEnd",(()=>{e.params.lazy.enabled&&!e.params.lazy.loadOnTransitionStart&&(e.params.lazy.checkInView?c():o())})),s("slideChange",(()=>{const{lazy:t,cssMode:s,watchSlidesProgress:a,touchReleaseOnEdges:i,resistanceRatio:r}=e.params;t.enabled&&(s||a&&(i||0===r))&&o()})),Object.assign(e.lazy,{load:o,loadInSlide:l})},function({swiper:e,extendParams:t,on:s}){function a(e,t){const s=function(){let e,t,s;return(a,i)=>{for(t=-1,e=a.length;e-t>1;)s=e+t>>1,a[s]<=i?t=s:e=s;return e}}();let a,i;return this.x=e,this.y=t,this.lastIndex=e.length-1,this.interpolate=function(e){return e?(i=s(this.x,e),a=i-1,(e-this.x[a])*(this.y[i]-this.y[a])/(this.x[i]-this.x[a])+this.y[a]):0},this}function i(){e.controller.control&&e.controller.spline&&(e.controller.spline=void 0,delete e.controller.spline)}t({controller:{control:void 0,inverse:!1,by:"slide"}}),e.controller={control:void 0},s("beforeInit",(()=>{e.controller.control=e.params.controller.control})),s("update",(()=>{i()})),s("resize",(()=>{i()})),s("observerUpdate",(()=>{i()})),s("setTranslate",((t,s,a)=>{e.controller.control&&e.controller.setTranslate(s,a)})),s("setTransition",((t,s,a)=>{e.controller.control&&e.controller.setTransition(s,a)})),Object.assign(e.controller,{setTranslate:function(t,s){const i=e.controller.control;let r,n;const l=e.constructor;function o(t){const s=e.rtlTranslate?-e.translate:e.translate;"slide"===e.params.controller.by&&(!function(t){e.controller.spline||(e.controller.spline=e.params.loop?new a(e.slidesGrid,t.slidesGrid):new a(e.snapGrid,t.snapGrid))}(t),n=-e.controller.spline.interpolate(-s)),n&&"container"!==e.params.controller.by||(r=(t.maxTranslate()-t.minTranslate())/(e.maxTranslate()-e.minTranslate()),n=(s-e.minTranslate())*r+t.minTranslate()),e.params.controller.inverse&&(n=t.maxTranslate()-n),t.updateProgress(n),t.setTranslate(n,e),t.updateActiveIndex(),t.updateSlidesClasses()}if(Array.isArray(i))for(let e=0;e{s.updateAutoHeight()})),s.$wrapperEl.transitionEnd((()=>{i&&(s.params.loop&&"slide"===e.params.controller.by&&s.loopFix(),s.transitionEnd())})))}if(Array.isArray(i))for(r=0;r0&&(e.isBeginning?(p(s),n(s)):(u(s),r(s))),t&&t.length>0&&(e.isEnd?(p(t),n(t)):(u(t),r(t)))}function f(){return e.pagination&&e.pagination.bullets&&e.pagination.bullets.length}function g(){return f()&&e.params.pagination.clickable}const v=(e,t,s)=>{r(e),"BUTTON"!==e[0].tagName&&(l(e,"button"),e.on("keydown",h)),c(e,s),function(e,t){e.attr("aria-controls",t)}(e,t)};function w(){const t=e.params.a11y;e.$el.append(a);const s=e.$el;t.containerRoleDescriptionMessage&&o(s,t.containerRoleDescriptionMessage),t.containerMessage&&c(s,t.containerMessage);const i=e.$wrapperEl,r=i.attr("id")||`swiper-wrapper-${function(e=16){return"x".repeat(e).replace(/x/g,(()=>Math.round(16*Math.random()).toString(16)))}(16)}`,n=e.params.autoplay&&e.params.autoplay.enabled?"off":"polite";var p;p=r,i.attr("id",p),function(e,t){e.attr("aria-live",t)}(i,n),t.itemRoleDescriptionMessage&&o(d(e.slides),t.itemRoleDescriptionMessage),l(d(e.slides),t.slideRole);const u=e.params.loop?e.slides.filter((t=>!t.classList.contains(e.params.slideDuplicateClass))).length:e.slides.length;let m,f;e.slides.each(((s,a)=>{const i=d(s),r=e.params.loop?parseInt(i.attr("data-swiper-slide-index"),10):a;c(i,t.slideLabelMessage.replace(/\{\{index\}\}/,r+1).replace(/\{\{slidesLength\}\}/,u))})),e.navigation&&e.navigation.$nextEl&&(m=e.navigation.$nextEl),e.navigation&&e.navigation.$prevEl&&(f=e.navigation.$prevEl),m&&m.length&&v(m,r,t.nextSlideMessage),f&&f.length&&v(f,r,t.prevSlideMessage),g()&&e.pagination.$el.on("keydown",W(e.params.pagination.bulletClass),h)}s("beforeInit",(()=>{a=d(``)})),s("afterInit",(()=>{e.params.a11y.enabled&&(w(),m())})),s("toEdge",(()=>{e.params.a11y.enabled&&m()})),s("fromEdge",(()=>{e.params.a11y.enabled&&m()})),s("paginationUpdate",(()=>{e.params.a11y.enabled&&function(){const t=e.params.a11y;f()&&e.pagination.bullets.each((s=>{const a=d(s);e.params.pagination.clickable&&(r(a),e.params.pagination.renderBullet||(l(a,"button"),c(a,t.paginationBulletMessage.replace(/\{\{index\}\}/,a.index()+1)))),a.is(`.${e.params.pagination.bulletActiveClass}`)?a.attr("aria-current","true"):a.removeAttr("aria-current")}))}()})),s("destroy",(()=>{e.params.a11y.enabled&&function(){let t,s;a&&a.length>0&&a.remove(),e.navigation&&e.navigation.$nextEl&&(t=e.navigation.$nextEl),e.navigation&&e.navigation.$prevEl&&(s=e.navigation.$prevEl),t&&t.off("keydown",h),s&&s.off("keydown",h),g()&&e.pagination.$el.off("keydown",W(e.params.pagination.bulletClass),h)}()}))},function({swiper:e,extendParams:t,on:s}){t({history:{enabled:!1,root:"",replaceState:!1,key:"slides"}});let a=!1,i={};const n=e=>e.toString().replace(/\s+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+/,"").replace(/-+$/,""),l=e=>{const t=r();let s;s=e?new URL(e):t.location;const a=s.pathname.slice(1).split("/").filter((e=>""!==e)),i=a.length;return{key:a[i-2],value:a[i-1]}},o=(t,s)=>{const i=r();if(!a||!e.params.history.enabled)return;let l;l=e.params.url?new URL(e.params.url):i.location;const o=e.slides.eq(s);let d=n(o.attr("data-history"));if(e.params.history.root.length>0){let s=e.params.history.root;"/"===s[s.length-1]&&(s=s.slice(0,s.length-1)),d=`${s}/${t}/${d}`}else l.pathname.includes(t)||(d=`${t}/${d}`);const c=i.history.state;c&&c.value===d||(e.params.history.replaceState?i.history.replaceState({value:d},null,d):i.history.pushState({value:d},null,d))},d=(t,s,a)=>{if(s)for(let i=0,r=e.slides.length;i{i=l(e.params.url),d(e.params.speed,e.paths.value,!1)};s("init",(()=>{e.params.history.enabled&&(()=>{const t=r();if(e.params.history){if(!t.history||!t.history.pushState)return e.params.history.enabled=!1,void(e.params.hashNavigation.enabled=!0);a=!0,i=l(e.params.url),(i.key||i.value)&&(d(0,i.value,e.params.runCallbacksOnInit),e.params.history.replaceState||t.addEventListener("popstate",c))}})()})),s("destroy",(()=>{e.params.history.enabled&&(()=>{const t=r();e.params.history.replaceState||t.removeEventListener("popstate",c)})()})),s("transitionEnd _freeModeNoMomentumRelease",(()=>{a&&o(e.params.history.key,e.activeIndex)})),s("slideChange",(()=>{a&&e.params.cssMode&&o(e.params.history.key,e.activeIndex)}))},function({swiper:e,extendParams:t,emit:s,on:i}){let n=!1;const l=a(),o=r();t({hashNavigation:{enabled:!1,replaceState:!1,watchState:!1}});const c=()=>{s("hashChange");const t=l.location.hash.replace("#","");if(t!==e.slides.eq(e.activeIndex).attr("data-hash")){const s=e.$wrapperEl.children(`.${e.params.slideClass}[data-hash="${t}"]`).index();if(void 0===s)return;e.slideTo(s)}},p=()=>{if(n&&e.params.hashNavigation.enabled)if(e.params.hashNavigation.replaceState&&o.history&&o.history.replaceState)o.history.replaceState(null,null,`#${e.slides.eq(e.activeIndex).attr("data-hash")}`||""),s("hashSet");else{const t=e.slides.eq(e.activeIndex),a=t.attr("data-hash")||t.attr("data-history");l.location.hash=a||"",s("hashSet")}};i("init",(()=>{e.params.hashNavigation.enabled&&(()=>{if(!e.params.hashNavigation.enabled||e.params.history&&e.params.history.enabled)return;n=!0;const t=l.location.hash.replace("#","");if(t){const s=0;for(let a=0,i=e.slides.length;a{e.params.hashNavigation.enabled&&e.params.hashNavigation.watchState&&d(o).off("hashchange",c)})),i("transitionEnd _freeModeNoMomentumRelease",(()=>{n&&p()})),i("slideChange",(()=>{n&&e.params.cssMode&&p()}))},function({swiper:e,extendParams:t,on:s,emit:i}){let r;function n(){const t=e.slides.eq(e.activeIndex);let s=e.params.autoplay.delay;t.attr("data-swiper-autoplay")&&(s=t.attr("data-swiper-autoplay")||e.params.autoplay.delay),clearTimeout(r),r=p((()=>{let t;e.params.autoplay.reverseDirection?e.params.loop?(e.loopFix(),t=e.slidePrev(e.params.speed,!0,!0),i("autoplay")):e.isBeginning?e.params.autoplay.stopOnLastSlide?o():(t=e.slideTo(e.slides.length-1,e.params.speed,!0,!0),i("autoplay")):(t=e.slidePrev(e.params.speed,!0,!0),i("autoplay")):e.params.loop?(e.loopFix(),t=e.slideNext(e.params.speed,!0,!0),i("autoplay")):e.isEnd?e.params.autoplay.stopOnLastSlide?o():(t=e.slideTo(0,e.params.speed,!0,!0),i("autoplay")):(t=e.slideNext(e.params.speed,!0,!0),i("autoplay")),(e.params.cssMode&&e.autoplay.running||!1===t)&&n()}),s)}function l(){return void 0===r&&(!e.autoplay.running&&(e.autoplay.running=!0,i("autoplayStart"),n(),!0))}function o(){return!!e.autoplay.running&&(void 0!==r&&(r&&(clearTimeout(r),r=void 0),e.autoplay.running=!1,i("autoplayStop"),!0))}function d(t){e.autoplay.running&&(e.autoplay.paused||(r&&clearTimeout(r),e.autoplay.paused=!0,0!==t&&e.params.autoplay.waitForTransition?["transitionend","webkitTransitionEnd"].forEach((t=>{e.$wrapperEl[0].addEventListener(t,u)})):(e.autoplay.paused=!1,n())))}function c(){const t=a();"hidden"===t.visibilityState&&e.autoplay.running&&d(),"visible"===t.visibilityState&&e.autoplay.paused&&(n(),e.autoplay.paused=!1)}function u(t){e&&!e.destroyed&&e.$wrapperEl&&t.target===e.$wrapperEl[0]&&(["transitionend","webkitTransitionEnd"].forEach((t=>{e.$wrapperEl[0].removeEventListener(t,u)})),e.autoplay.paused=!1,e.autoplay.running?n():o())}function h(){e.params.autoplay.disableOnInteraction?o():d(),["transitionend","webkitTransitionEnd"].forEach((t=>{e.$wrapperEl[0].removeEventListener(t,u)}))}function m(){e.params.autoplay.disableOnInteraction||(e.autoplay.paused=!1,n())}e.autoplay={running:!1,paused:!1},t({autoplay:{enabled:!1,delay:3e3,waitForTransition:!0,disableOnInteraction:!0,stopOnLastSlide:!1,reverseDirection:!1,pauseOnMouseEnter:!1}}),s("init",(()=>{if(e.params.autoplay.enabled){l();a().addEventListener("visibilitychange",c),e.params.autoplay.pauseOnMouseEnter&&(e.$el.on("mouseenter",h),e.$el.on("mouseleave",m))}})),s("beforeTransitionStart",((t,s,a)=>{e.autoplay.running&&(a||!e.params.autoplay.disableOnInteraction?e.autoplay.pause(s):o())})),s("sliderFirstMove",(()=>{e.autoplay.running&&(e.params.autoplay.disableOnInteraction?o():d())})),s("touchEnd",(()=>{e.params.cssMode&&e.autoplay.paused&&!e.params.autoplay.disableOnInteraction&&n()})),s("destroy",(()=>{e.$el.off("mouseenter",h),e.$el.off("mouseleave",m),e.autoplay.running&&o();a().removeEventListener("visibilitychange",c)})),Object.assign(e.autoplay,{pause:d,run:n,start:l,stop:o})},function({swiper:e,extendParams:t,on:s}){t({thumbs:{swiper:null,multipleActiveThumbs:!0,autoScrollOffset:0,slideThumbActiveClass:"swiper-slide-thumb-active",thumbsContainerClass:"swiper-thumbs"}});let a=!1,i=!1;function r(){const t=e.thumbs.swiper;if(!t)return;const s=t.clickedIndex,a=t.clickedSlide;if(a&&d(a).hasClass(e.params.thumbs.slideThumbActiveClass))return;if(null==s)return;let i;if(i=t.params.loop?parseInt(d(t.clickedSlide).attr("data-swiper-slide-index"),10):s,e.params.loop){let t=e.activeIndex;e.slides.eq(t).hasClass(e.params.slideDuplicateClass)&&(e.loopFix(),e._clientLeft=e.$wrapperEl[0].clientLeft,t=e.activeIndex);const s=e.slides.eq(t).prevAll(`[data-swiper-slide-index="${i}"]`).eq(0).index(),a=e.slides.eq(t).nextAll(`[data-swiper-slide-index="${i}"]`).eq(0).index();i=void 0===s?a:void 0===a?s:a-t1?a:o:a-oe.previousIndex?"next":"prev"}else n=e.realIndex,l=n>e.previousIndex?"next":"prev";r&&(n+="next"===l?i:-1*i),s.visibleSlidesIndexes&&s.visibleSlidesIndexes.indexOf(n)<0&&(s.params.centeredSlides?n=n>o?n-Math.floor(a/2)+1:n+Math.floor(a/2)-1:n>o&&s.params.slidesPerGroup,s.slideTo(n,t?0:void 0))}let n=1;const l=e.params.thumbs.slideThumbActiveClass;if(e.params.slidesPerView>1&&!e.params.centeredSlides&&(n=e.params.slidesPerView),e.params.thumbs.multipleActiveThumbs||(n=1),n=Math.floor(n),s.slides.removeClass(l),s.params.loop||s.params.virtual&&s.params.virtual.enabled)for(let t=0;t{const{thumbs:t}=e.params;t&&t.swiper&&(n(),l(!0))})),s("slideChange update resize observerUpdate",(()=>{e.thumbs.swiper&&l()})),s("setTransition",((t,s)=>{const a=e.thumbs.swiper;a&&a.setTransition(s)})),s("beforeDestroy",(()=>{const t=e.thumbs.swiper;t&&i&&t&&t.destroy()})),Object.assign(e.thumbs,{init:n,update:l})},function({swiper:e,extendParams:t,emit:s,once:a}){t({freeMode:{enabled:!1,momentum:!0,momentumRatio:1,momentumBounce:!0,momentumBounceRatio:1,momentumVelocityRatio:1,sticky:!1,minimumVelocity:.02}}),Object.assign(e,{freeMode:{onTouchMove:function(){const{touchEventsData:t,touches:s}=e;0===t.velocities.length&&t.velocities.push({position:s[e.isHorizontal()?"startX":"startY"],time:t.touchStartTime}),t.velocities.push({position:s[e.isHorizontal()?"currentX":"currentY"],time:u()})},onTouchEnd:function({currentPos:t}){const{params:i,$wrapperEl:r,rtlTranslate:n,snapGrid:l,touchEventsData:o}=e,d=u()-o.touchStartTime;if(t<-e.minTranslate())e.slideTo(e.activeIndex);else if(t>-e.maxTranslate())e.slides.length1){const t=o.velocities.pop(),s=o.velocities.pop(),a=t.position-s.position,r=t.time-s.time;e.velocity=a/r,e.velocity/=2,Math.abs(e.velocity)150||u()-t.time>300)&&(e.velocity=0)}else e.velocity=0;e.velocity*=i.freeMode.momentumVelocityRatio,o.velocities.length=0;let t=1e3*i.freeMode.momentumRatio;const d=e.velocity*t;let c=e.translate+d;n&&(c=-c);let p,h=!1;const m=20*Math.abs(e.velocity)*i.freeMode.momentumBounceRatio;let f;if(ce.minTranslate())i.freeMode.momentumBounce?(c-e.minTranslate()>m&&(c=e.minTranslate()+m),p=e.minTranslate(),h=!0,o.allowMomentumBounce=!0):c=e.minTranslate(),i.loop&&i.centeredSlides&&(f=!0);else if(i.freeMode.sticky){let t;for(let e=0;e-c){t=e;break}c=Math.abs(l[t]-c){e.loopFix()})),0!==e.velocity){if(t=n?Math.abs((-c-e.translate)/e.velocity):Math.abs((c-e.translate)/e.velocity),i.freeMode.sticky){const s=Math.abs((n?-c:c)-e.translate),a=e.slidesSizesGrid[e.activeIndex];t=s{e&&!e.destroyed&&o.allowMomentumBounce&&(s("momentumBounce"),e.setTransition(i.speed),setTimeout((()=>{e.setTranslate(p),r.transitionEnd((()=>{e&&!e.destroyed&&e.transitionEnd()}))}),0))}))):e.velocity?(s("_freeModeNoMomentumRelease"),e.updateProgress(c),e.setTransition(t),e.setTranslate(c),e.transitionStart(!0,e.swipeDirection),e.animating||(e.animating=!0,r.transitionEnd((()=>{e&&!e.destroyed&&e.transitionEnd()})))):e.updateProgress(c),e.updateActiveIndex(),e.updateSlidesClasses()}else{if(i.freeMode.sticky)return void e.slideToClosest();i.freeMode&&s("_freeModeNoMomentumRelease")}(!i.freeMode.momentum||d>=i.longSwipesMs)&&(e.updateProgress(),e.updateActiveIndex(),e.updateSlidesClasses())}}}})},function({swiper:e,extendParams:t}){let s,a,i;t({grid:{rows:1,fill:"column"}}),e.grid={initSlides:t=>{const{slidesPerView:r}=e.params,{rows:n,fill:l}=e.params.grid;a=s/n,i=Math.floor(t/n),s=Math.floor(t/n)===t/n?t:Math.ceil(t/n)*n,"auto"!==r&&"row"===l&&(s=Math.max(s,r*n))},updateSlide:(t,r,n,l)=>{const{slidesPerGroup:o,spaceBetween:d}=e.params,{rows:c,fill:p}=e.params.grid;let u,h,m;if("row"===p&&o>1){const e=Math.floor(t/(o*c)),a=t-c*o*e,i=0===e?o:Math.min(Math.ceil((n-e*c*o)/c),o);m=Math.floor(a/i),h=a-m*i+e*o,u=h+m*s/c,r.css({"-webkit-order":u,order:u})}else"column"===p?(h=Math.floor(t/c),m=t-h*c,(h>i||h===i&&m===c-1)&&(m+=1,m>=c&&(m=0,h+=1))):(m=Math.floor(t/a),h=t-m*a);r.css(l("margin-top"),0!==m?d&&`${d}px`:"")},updateWrapperSize:(t,a,i)=>{const{spaceBetween:r,centeredSlides:n,roundLengths:l}=e.params,{rows:o}=e.params.grid;if(e.virtualSize=(t+r)*s,e.virtualSize=Math.ceil(e.virtualSize/o)-r,e.$wrapperEl.css({[i("width")]:`${e.virtualSize+r}px`}),n){a.splice(0,a.length);const t=[];for(let s=0;s{const{slides:t}=e,s=e.params.fadeEffect;for(let a=0;a{const{transformEl:s}=e.params.fadeEffect;(s?e.slides.find(s):e.slides).transition(t),K({swiper:e,duration:t,transformEl:s,allSlides:!0})},overwriteParams:()=>({slidesPerView:1,slidesPerGroup:1,watchSlidesProgress:!0,spaceBetween:0,virtualTranslate:!e.params.cssMode})})},function({swiper:e,extendParams:t,on:s}){t({cubeEffect:{slideShadows:!0,shadow:!0,shadowOffset:20,shadowScale:.94}}),F({effect:"cube",swiper:e,on:s,setTranslate:()=>{const{$el:t,$wrapperEl:s,slides:a,width:i,height:r,rtlTranslate:n,size:l,browser:o}=e,c=e.params.cubeEffect,p=e.isHorizontal(),u=e.virtual&&e.params.virtual.enabled;let h,m=0;c.shadow&&(p?(h=s.find(".swiper-cube-shadow"),0===h.length&&(h=d('
'),s.append(h)),h.css({height:`${i}px`})):(h=t.find(".swiper-cube-shadow"),0===h.length&&(h=d('
'),t.append(h))));for(let e=0;e-1&&(m=90*s+90*o,n&&(m=90*-s-90*o)),t.transform(v),c.slideShadows){let e=p?t.find(".swiper-slide-shadow-left"):t.find(".swiper-slide-shadow-top"),s=p?t.find(".swiper-slide-shadow-right"):t.find(".swiper-slide-shadow-bottom");0===e.length&&(e=d(`
`),t.append(e)),0===s.length&&(s=d(`
`),t.append(s)),e.length&&(e[0].style.opacity=Math.max(-o,0)),s.length&&(s[0].style.opacity=Math.max(o,0))}}if(s.css({"-webkit-transform-origin":`50% 50% -${l/2}px`,"transform-origin":`50% 50% -${l/2}px`}),c.shadow)if(p)h.transform(`translate3d(0px, ${i/2+c.shadowOffset}px, ${-i/2}px) rotateX(90deg) rotateZ(0deg) scale(${c.shadowScale})`);else{const e=Math.abs(m)-90*Math.floor(Math.abs(m)/90),t=1.5-(Math.sin(2*e*Math.PI/360)/2+Math.cos(2*e*Math.PI/360)/2),s=c.shadowScale,a=c.shadowScale/t,i=c.shadowOffset;h.transform(`scale3d(${s}, 1, ${a}) translate3d(0px, ${r/2+i}px, ${-r/2/a}px) rotateX(-90deg)`)}const f=o.isSafari||o.isWebView?-l/2:0;s.transform(`translate3d(0px,0,${f}px) rotateX(${e.isHorizontal()?0:m}deg) rotateY(${e.isHorizontal()?-m:0}deg)`)},setTransition:t=>{const{$el:s,slides:a}=e;a.transition(t).find(".swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left").transition(t),e.params.cubeEffect.shadow&&!e.isHorizontal()&&s.find(".swiper-cube-shadow").transition(t)},perspective:()=>!0,overwriteParams:()=>({slidesPerView:1,slidesPerGroup:1,watchSlidesProgress:!0,resistanceRatio:0,spaceBetween:0,centeredSlides:!1,virtualTranslate:!0})})},function({swiper:e,extendParams:t,on:s}){t({flipEffect:{slideShadows:!0,limitRotation:!0,transformEl:null}}),F({effect:"flip",swiper:e,on:s,setTranslate:()=>{const{slides:t,rtlTranslate:s}=e,a=e.params.flipEffect;for(let i=0;i{const{transformEl:s}=e.params.flipEffect;(s?e.slides.find(s):e.slides).transition(t).find(".swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left").transition(t),K({swiper:e,duration:t,transformEl:s})},perspective:()=>!0,overwriteParams:()=>({slidesPerView:1,slidesPerGroup:1,watchSlidesProgress:!0,spaceBetween:0,virtualTranslate:!e.params.cssMode})})},function({swiper:e,extendParams:t,on:s}){t({coverflowEffect:{rotate:50,stretch:0,depth:100,scale:1,modifier:1,slideShadows:!0,transformEl:null}}),F({effect:"coverflow",swiper:e,on:s,setTranslate:()=>{const{width:t,height:s,slides:a,slidesSizesGrid:i}=e,r=e.params.coverflowEffect,n=e.isHorizontal(),l=e.translate,o=n?t/2-l:s/2-l,d=n?r.rotate:-r.rotate,c=r.depth;for(let e=0,t=a.length;e0?l:0),s.length&&(s[0].style.opacity=-l>0?-l:0)}}},setTransition:t=>{const{transformEl:s}=e.params.coverflowEffect;(s?e.slides.find(s):e.slides).transition(t).find(".swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left").transition(t)},perspective:()=>!0,overwriteParams:()=>({watchSlidesProgress:!0})})},function({swiper:e,extendParams:t,on:s}){t({creativeEffect:{transformEl:null,limitProgress:1,shadowPerProgress:!1,progressMultiplier:1,perspective:!0,prev:{translate:[0,0,0],rotate:[0,0,0],opacity:1,scale:1},next:{translate:[0,0,0],rotate:[0,0,0],opacity:1,scale:1}}});const a=e=>"string"==typeof e?e:`${e}px`;F({effect:"creative",swiper:e,on:s,setTranslate:()=>{const{slides:t,$wrapperEl:s,slidesSizesGrid:i}=e,r=e.params.creativeEffect,{progressMultiplier:n}=r,l=e.params.centeredSlides;if(l){const t=i[0]/2-e.params.slidesOffsetBefore||0;s.transform(`translateX(calc(50% - ${t}px))`)}for(let s=0;s0&&(f=r.prev,m=!0),u.forEach(((e,t)=>{u[t]=`calc(${e}px + (${a(f.translate[t])} * ${Math.abs(d*n)}))`})),h.forEach(((e,t)=>{h[t]=f.rotate[t]*Math.abs(d*n)})),i[0].style.zIndex=-Math.abs(Math.round(o))+t.length;const g=u.join(", "),v=`rotateX(${h[0]}deg) rotateY(${h[1]}deg) rotateZ(${h[2]}deg)`,w=c<0?`scale(${1+(1-f.scale)*c*n})`:`scale(${1-(1-f.scale)*c*n})`,b=c<0?1+(1-f.opacity)*c*n:1-(1-f.opacity)*c*n,x=`translate3d(${g}) ${v} ${w}`;if(m&&f.shadow||!m){let e=i.children(".swiper-slide-shadow");if(0===e.length&&f.shadow&&(e=Z(r,i)),e.length){const t=r.shadowPerProgress?d*(1/r.limitProgress):d;e[0].style.opacity=Math.min(Math.max(Math.abs(t),0),1)}}const y=U(r,i);y.transform(x).css({opacity:b}),f.origin&&y.css("transform-origin",f.origin)}},setTransition:t=>{const{transformEl:s}=e.params.creativeEffect;(s?e.slides.find(s):e.slides).transition(t).find(".swiper-slide-shadow").transition(t),K({swiper:e,duration:t,transformEl:s,allSlides:!0})},perspective:()=>e.params.creativeEffect.perspective,overwriteParams:()=>({watchSlidesProgress:!0,virtualTranslate:!e.params.cssMode})})},function({swiper:e,extendParams:t,on:s}){t({cardsEffect:{slideShadows:!0,transformEl:null}}),F({effect:"cards",swiper:e,on:s,setTranslate:()=>{const{slides:t,activeIndex:s}=e,a=e.params.cardsEffect,{startTranslate:i,isTouched:r}=e.touchEventsData,n=e.translate;for(let l=0;l0&&c<1&&(r||e.params.cssMode)&&n-1&&(r||e.params.cssMode)&&n>i;if(w||b){const e=(1-Math.abs((Math.abs(c)-.5)/.5))**.5;g+=-28*c*e,f+=-.5*e,v+=96*e,h=-25*e*Math.abs(c)+"%"}if(u=c<0?`calc(${u}px + (${v*Math.abs(c)}%))`:c>0?`calc(${u}px + (-${v*Math.abs(c)}%))`:`${u}px`,!e.isHorizontal()){const e=h;h=u,u=e}const x=`\n translate3d(${u}, ${h}, ${m}px)\n rotateZ(${g}deg)\n scale(${c<0?""+(1+(1-f)*c):""+(1-(1-f)*c)})\n `;if(a.slideShadows){let e=o.find(".swiper-slide-shadow");0===e.length&&(e=Z(a,o)),e.length&&(e[0].style.opacity=Math.min(Math.max((Math.abs(c)-.5)/.5,0),1))}o[0].style.zIndex=-Math.abs(Math.round(d))+t.length;U(a,o).transform(x)}},setTransition:t=>{const{transformEl:s}=e.params.cardsEffect;(s?e.slides.find(s):e.slides).transition(t).find(".swiper-slide-shadow").transition(t),K({swiper:e,duration:t,transformEl:s})},perspective:()=>!0,overwriteParams:()=>({watchSlidesProgress:!0,virtualTranslate:!e.params.cssMode})})}];return H.use(J),H})); //# sourceMappingURL=swiper-bundle.min.js.map (function($) { "use strict"; var BBCSwiper = function (element, options = {}) { this.$el = $(element) this.options = Object.assign(this.$el.data(),options) this.ID = this.$el.attr('id') || 'swiper-'+ $.bbc.helper.createId(6) this.swiper = {} this.hasVideo = false this.init() } BBCSwiper.prototype.init = function() { this.initVideo() this.initOptions() this.initSwiper() } BBCSwiper.prototype.initOptions = function() { var options = this.options var sw = this.$el var self = this if(options.arrow == true) { delete options.arrow options.navigation = { nextEl: ".swiper-button-next", prevEl: ".swiper-button-prev", } this.$el.append('
') } if(options.autoplay) { options.autoplay = { delay: options.timeout || 5000, disableOnInteraction: false } } if(options.swiperBreakpoints) { options.breakpoints = { } for (let i=0,item; item = options.swiperBreakpoints[i]; i++) { if(item.breakpoints == 0) { if(item.margin) { options.spaceBetween = parseInt(item.margin) } if(item.center == 1) { options.centeredSlides = true } if(item.cols) { options.slidesPerView = parseInt(item.cols) } }else{ options.breakpoints[item.breakpoints] = {} if(item.margin) { options.breakpoints[item.breakpoints].spaceBetween = parseInt(item.margin) } if(item.center == 1) { options.breakpoints[item.breakpoints].centeredSlides = true }else{ options.breakpoints[item.breakpoints].centeredSlides = false } if(item.cols) { options.breakpoints[item.breakpoints].slidesPerView = parseInt(item.cols) } } } delete options.swiperBreakpoints } options.grabCursor = true if(options.type == 'creative') { options.effect = 'creative' options.parallax = true switch(options.effectType) { case 0: options.creativeEffect = { prev: { shadow: true, opacity: 0, }, next: { shadow: true, opacity: 0, }, } break; case 1: options.creativeEffect = { prev: { shadow: true, translate: ["-100%", 0, 0], }, next: { shadow: true, translate: ["100%", 0, 0], }, } break; case 2: options.creativeEffect = { prev: { shadow: true, translate: [0, 0, -800], rotate: [180, 0, 0], }, next: { shadow: true, translate: [0, 0, -800], rotate: [-180, 0, 0], }, } break; case 3: options.creativeEffect = { prev: { shadow: true, translate: [0, 0, -400], }, next: { translate: ["100%", 0, 0], }, } break; case 4: options.creativeEffect = { prev: { shadow: true, origin: "left center", translate: ["-5%", 0, -200], rotate: [0, 100, 0], }, next: { origin: "right center", translate: ["5%", 0, -200], rotate: [0, -100, 0], }, } break; case 5: options.creativeEffect = { prev: { shadow: true, translate: ["-120%", 0, -500], }, next: { shadow: true, translate: ["120%", 0, -500], }, } break; } delete options.type } if(options.dots == true) { delete options.dots if(!this.$el.find('.swiper-pagination').length) this.$el.append('
') let timer = '' if(options.timer && options.autoplay) { this.$el.find('.swiper-pagination').addClass('swiper-pagination-timer') timer = '' } options.pagination = { el: ".swiper-pagination", clickable: true, renderBullet: function (index, className) { return ''+timer+''; } } } if(this.hasVideo) { this.options.on = { afterInit: function(e) { self.playVideo(e) self.initBullet(e) self.addNextBulletClass(e) } } } this.options = options } BBCSwiper.prototype.playVideo = function(e) { var $video = this.$el.find('.swiper-slide-active video') if($video.length && !$video.prop('loop')) { $video.each(function(){ this.currentTime = 0 }) e.autoplay.stop() $video.trigger('play') } } BBCSwiper.prototype.addNextBulletClass = function(e) { if(this.options.pagination) { this.$el.find('.swiper-pagination-bullet-timer').removeClass('active') this.$el.find('.swiper-pagination-bullet-next').removeClass('swiper-pagination-bullet-next') var $active_bullet = this.$el.find('.swiper-pagination-bullet-active') if($active_bullet.next().length) $active_bullet.next().addClass('swiper-pagination-bullet-next') else this.$el.find('.swiper-pagination-bullet:first-child').addClass('swiper-pagination-bullet-next') var idx = $active_bullet.data('index') setTimeout(() => { $active_bullet.children('.swiper-pagination-bullet-timer').addClass('active') }, 1); } } BBCSwiper.prototype.initBullet = function(e) { if(this.options.pagination) { var $bullet = this.$el.find('.swiper-pagination-bullet') this.total_bullets = $bullet.length $bullet.attr('data-total',this.total_bullets) } } BBCSwiper.prototype.initVideo = function() { var $video = this.$el.find('[data-video]') if($video.length) this.hasVideo = true if($(window).width() > 768 && $video.length) { $video.each(function(){ var src = $(this).data('video') var loop = $(this).data('loop') ? 'autoplay loop' : '' $(this).closest('.swiper-slide').addClass('swiper-has-video') $(this).html(` `) }) } } BBCSwiper.prototype.initSwiper = function() { var self = this this.swiper = new Swiper(`#${this.ID}`,this.options) if(this.hasVideo) { var sw = this.swiper this.$el.find('video').on('ended',function(){ if(!$(this).prop('loop')) { sw.slideNext() sw.autoplay.start() } }) this.swiper.on('slideChangeTransitionEnd',function(sw){ self.playVideo(sw) self.addNextBulletClass(sw) }) } } var old = $.fn.BBCSwiper $.fn.BBCSwiper = function (option) { var args = Array.prototype.slice.call(arguments, 1), result this.each(function () { var $this = $(this) var data = $this.data('bbc.swiper') var options = $.extend({}, BBCSwiper.DEFAULTS, $this.data(), typeof option == 'object' && option) if (!data) $this.data('bbc.swiper', (data = new BBCSwiper(this, options))) if (typeof option == 'string') result = data[option].apply(data, args) if (typeof result != 'undefined') return false }) return result ? result : this } $.fn.BBCSwiper.Constructor = BBCSwiper // BBCSwiper NO CONFLICT // ================= $.fn.BBCSwiper.noConflict = function () { $.fn.BBCSwiper = old return this } $(document).ready(function(){ $('.js-swiper-creative').BBCSwiper() }) })(window.jQuery)