1/******/ (function(modules) { // webpackBootstrap 2/******/ // The module cache 3/******/ var installedModules = {}; 4/******/ 5/******/ // The require function 6/******/ function __webpack_require__(moduleId) { 7/******/ 8/******/ // Check if module is in cache 9/******/ if(installedModules[moduleId]) { 10/******/ return installedModules[moduleId].exports; 11/******/ } 12/******/ // Create a new module (and put it into the cache) 13/******/ var module = installedModules[moduleId] = { 14/******/ i: moduleId, 15/******/ l: false, 16/******/ exports: {} 17/******/ }; 18/******/ 19/******/ // Execute the module function 20/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 21/******/ 22/******/ // Flag the module as loaded 23/******/ module.l = true; 24/******/ 25/******/ // Return the exports of the module 26/******/ return module.exports; 27/******/ } 28/******/ 29/******/ 30/******/ // expose the modules object (__webpack_modules__) 31/******/ __webpack_require__.m = modules; 32/******/ 33/******/ // expose the module cache 34/******/ __webpack_require__.c = installedModules; 35/******/ 36/******/ // define getter function for harmony exports 37/******/ __webpack_require__.d = function(exports, name, getter) { 38/******/ if(!__webpack_require__.o(exports, name)) { 39/******/ Object.defineProperty(exports, name, { 40/******/ configurable: false, 41/******/ enumerable: true, 42/******/ get: getter 43/******/ }); 44/******/ } 45/******/ }; 46/******/ 47/******/ // getDefaultExport function for compatibility with non-harmony modules 48/******/ __webpack_require__.n = function(module) { 49/******/ var getter = module && module.__esModule ? 50/******/ function getDefault() { return module['default']; } : 51/******/ function getModuleExports() { return module; }; 52/******/ __webpack_require__.d(getter, 'a', getter); 53/******/ return getter; 54/******/ }; 55/******/ 56/******/ // Object.prototype.hasOwnProperty.call 57/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 58/******/ 59/******/ // __webpack_public_path__ 60/******/ __webpack_require__.p = "/wp-content/themes/plasticseurope-theme/dist/"; 61/******/ 62/******/ // Load entry module and return exports 63/******/ return __webpack_require__(__webpack_require__.s = 111); 64/******/ }) 65/************************************************************************/ 66/******/ ({ 67 68/***/ 111: 69/***/ (function(module, exports, __webpack_require__) { 70 71__webpack_require__(112); 72module.exports = __webpack_require__(121); 73 74 75/***/ }), 76 77/***/ 112: 78/***/ (function(module, __webpack_exports__, __webpack_require__) { 79 80"use strict"; 81Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); 82/* WEBPACK VAR INJECTION */(function(jQuery) {/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_jquery__ = __webpack_require__(3); 83/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_jquery___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_jquery__); 84/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_jquery_validation__ = __webpack_require__(113); 85/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_jquery_validation___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_jquery_validation__); 86/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_Router__ = __webpack_require__(114); 87/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__routes_common__ = __webpack_require__(116); 88/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__animated_counter__ = __webpack_require__(118); 89/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__routes_home__ = __webpack_require__(119); 90/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__routes_about__ = __webpack_require__(120); 91// import external dependencies 92 93 94 95// Import everything from autoload 96 97 98// import local dependencies 99 100 101 102 103 104 105/** Populate Router instance with DOM routes */ 106var routes = new __WEBPACK_IMPORTED_MODULE_2__util_Router__["a" /* default */]({ 107 // All pages 108 common: __WEBPACK_IMPORTED_MODULE_3__routes_common__["a" /* default */], 109 // Home page 110 home: __WEBPACK_IMPORTED_MODULE_5__routes_home__["a" /* default */], 111 // About Us page, note the change from about-us to aboutUs. 112 aboutUs: __WEBPACK_IMPORTED_MODULE_6__routes_about__["a" /* default */], 113}); 114 115// Load Events 116jQuery(document).ready(function () { return routes.loadEvents(); }); 117Object(__WEBPACK_IMPORTED_MODULE_4__animated_counter__["a" /* counterAnimations */])(); 118 119/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(3))) 120 121/***/ }), 122 123/***/ 113: 124/***/ (function(module, exports, __webpack_require__) { 125 126var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! 127 * jQuery Validation Plugin v1.22.1 128 * 129 * https://jqueryvalidation.org/ 130 * 131 * Copyright (c) 2026 Jörn Zaefferer 132 * Released under the MIT license 133 */ 134(function( factory ) { 135 if ( true ) { 136 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(3)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), 137 __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? 138 (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
139 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)
vendor: 55,013 bytes, lines 139-1918
139); 140 } else if (typeof module === "object" && module.exports) { 141 module.exports = factory( require( "jquery" ) ); 142 } else { 143 factory( jQuery ); 144 } 145}(function( $ ) { 146 147$.extend( $.fn, { 148 149 // https://jqueryvalidation.org/validate/ 150 validate: function( options ) { 151 152 // If nothing is selected, return nothing; can't chain anyway 153 if ( !this.length ) { 154 if ( options && options.debug && window.console ) { 155 console.warn( "Nothing selected, can't validate, returning nothing." ); 156 } 157 return; 158 } 159 160 // Check if a validator for this form was already created 161 var validator = $.data( this[ 0 ], "validator" ); 162 if ( validator ) { 163 return validator; 164 } 165 166 // Add novalidate tag if HTML5. 167 this.attr( "novalidate", "novalidate" ); 168 169 validator = new $.validator( options, this[ 0 ] ); 170 $.data( this[ 0 ], "validator", validator ); 171 172 if ( validator.settings.onsubmit ) { 173 174 this.on( "click.validate", ":submit", function( event ) { 175 176 // Track the used submit button to properly handle scripted 177 // submits later. 178 validator.submitButton = event.currentTarget; 179 180 // Allow suppressing validation by adding a cancel class to the submit button 181 if ( $( this ).hasClass( "cancel" ) ) { 182 validator.cancelSubmit = true; 183 } 184 185 // Allow suppressing validation by adding the html5 formnovalidate attribute to the submit button 186 if ( $( this ).attr( "formnovalidate" ) !== undefined ) { 187 validator.cancelSubmit = true; 188 } 189 } ); 190 191 // Validate the form on submit 192 this.on( "submit.validate", function( event ) { 193 if ( validator.settings.debug ) { 194 195 // Prevent form submit to be able to see console output 196 event.preventDefault(); 197 } 198 199 function handle() { 200 var hidden, result; 201 202 // Insert a hidden input as a replacement for the missing submit button 203 // The hidden input is inserted in two cases: 204 // - A user defined a `submitHandler` 205 // - There was a pending request due to `remote` method and `stopRequest()` 206 // was called to submit the form in case it's valid 207 if ( validator.submitButton && ( validator.settings.submitHandler || validator.formSubmitted ) ) { 208 hidden = $( "<input type='hidden'/>" ) 209 .attr( "name", validator.submitButton.name ) 210 .val( $( validator.submitButton ).val() ) 211 .appendTo( validator.currentForm ); 212 } 213 214 if ( validator.settings.submitHandler && !validator.settings.debug ) { 215 result = validator.settings.submitHandler.call( validator, validator.currentForm, event ); 216 if ( hidden ) { 217 218 // And clean up afterwards; thanks to no-block-scope, hidden can be referenced 219 hidden.remove(); 220 } 221 if ( result !== undefined ) { 222 return result; 223 } 224 return false; 225 } 226 return true; 227 } 228 229 // Prevent submit for invalid forms or custom submit handlers 230 if ( validator.cancelSubmit ) { 231 validator.cancelSubmit = false; 232 return handle(); 233 } 234 if ( validator.form() ) { 235 if ( validator.pendingRequest ) { 236 validator.formSubmitted = true; 237 return false; 238 } 239 return handle(); 240 } else { 241 validator.focusInvalid(); 242 return false; 243 } 244 } ); 245 } 246 247 return validator; 248 }, 249 250 // https://jqueryvalidation.org/valid/ 251 valid: function() { 252 var valid, validator, errorList; 253 254 if ( $( this[ 0 ] ).is( "form" ) ) { 255 valid = this.validate().form(); 256 } else { 257 errorList = []; 258 valid = true; 259 validator = $( this[ 0 ].form ).validate(); 260 this.each( function() { 261 valid = validator.element( this ) && valid; 262 if ( !valid ) { 263 errorList = errorList.concat( validator.errorList ); 264 } 265 } ); 266 validator.errorList = errorList; 267 } 268 return valid; 269 }, 270 271 // https://jqueryvalidation.org/rules/ 272 rules: function( command, argument ) { 273 var element = this[ 0 ], 274 isContentEditable = typeof this.attr( "contenteditable" ) !== "undefined" && this.attr( "contenteditable" ) !== "false", 275 settings, staticRules, existingRules, data, param, filtered; 276 277 // If nothing is selected, return empty object; can't chain anyway 278 if ( element == null ) { 279 return; 280 } 281 282 if ( !element.form && isContentEditable ) { 283 element.form = this.closest( "form" )[ 0 ]; 284 element.name = this.attr( "name" ); 285 } 286 287 if ( element.form == null ) { 288 return; 289 } 290 291 if ( command ) { 292 settings = $.data( element.form, "validator" ).settings; 293 staticRules = settings.rules; 294 existingRules = $.validator.staticRules( element ); 295 switch ( command ) { 296 case "add": 297 $.extend( existingRules, $.validator.normalizeRule( argument ) ); 298 299 // Remove messages from rules, but allow them to be set separately 300 delete existingRules.messages; 301 staticRules[ element.name ] = existingRules; 302 if ( argument.messages ) { 303 settings.messages[ element.name ] = $.extend( settings.messages[ element.name ], argument.messages ); 304 } 305 break; 306 case "remove": 307 if ( !argument ) { 308 delete staticRules[ element.name ]; 309 return existingRules; 310 } 311 filtered = {}; 312 $.each( argument.split( /\s/ ), function( index, method ) { 313 filtered[ method ] = existingRules[ method ]; 314 delete existingRules[ method ]; 315 } ); 316 return filtered; 317 } 318 } 319 320 data = $.validator.normalizeRules( 321 $.extend( 322 {}, 323 $.validator.classRules( element ), 324 $.validator.attributeRules( element ), 325 $.validator.dataRules( element ), 326 $.validator.staticRules( element ) 327 ), element ); 328 329 // Make sure required is at front 330 if ( data.required ) { 331 param = data.required; 332 delete data.required; 333 data = $.extend( { required: param }, data ); 334 } 335 336 // Make sure remote is at back 337 if ( data.remote ) { 338 param = data.remote; 339 delete data.remote; 340 data = $.extend( data, { remote: param } ); 341 } 342 343 return data; 344 } 345} ); 346 347// JQuery trim is deprecated, provide a trim method based on String.prototype.trim 348var trim = function( str ) { 349 350 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim#Polyfill 351 return str.replace( /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "" ); 352}; 353 354// Custom selectors 355$.extend( $.expr.pseudos || $.expr[ ":" ], { // '|| $.expr[ ":" ]' here enables backwards compatibility to jQuery 1.7. Can be removed when dropping jQ 1.7.x support 356 357 // https://jqueryvalidation.org/blank-selector/ 358 blank: function( a ) { 359 return !trim( "" + $( a ).val() ); 360 }, 361 362 // https://jqueryvalidation.org/filled-selector/ 363 filled: function( a ) { 364 var val = $( a ).val(); 365 return val !== null && !!trim( "" + val ); 366 }, 367 368 // https://jqueryvalidation.org/unchecked-selector/ 369 unchecked: function( a ) { 370 return !$( a ).prop( "checked" ); 371 } 372} ); 373 374// Constructor for validator 375$.validator = function( options, form ) { 376 this.settings = $.extend( true, {}, $.validator.defaults, options ); 377 this.currentForm = form; 378 this.init(); 379}; 380 381// https://jqueryvalidation.org/jQuery.validator.format/ 382$.validator.format = function( source, params ) { 383 if ( arguments.length === 1 ) { 384 return function() { 385 var args = $.makeArray( arguments ); 386 args.unshift( source ); 387 return $.validator.format.apply( this, args ); 388 }; 389 } 390 if ( params === undefined ) { 391 return source; 392 } 393 if ( arguments.length > 2 && params.constructor !== Array ) { 394 params = $.makeArray( arguments ).slice( 1 ); 395 } 396 if ( params.constructor !== Array ) { 397 params = [ params ]; 398 } 399 $.each( params, function( i, n ) { 400 source = source.replace( new RegExp( "\\{" + i + "\\}", "g" ), function() { 401 return n; 402 } ); 403 } ); 404 return source; 405}; 406 407$.extend( $.validator, { 408 409 defaults: { 410 messages: {}, 411 groups: {}, 412 rules: {}, 413 errorClass: "error", 414 pendingClass: "pending", 415 validClass: "valid", 416 errorElement: "label", 417 focusCleanup: false, 418 focusInvalid: true, 419 ariaDescribedByCleanup: false, 420 errorContainer: $( [] ), 421 errorLabelContainer: $( [] ), 422 onsubmit: true, 423 ignore: ":hidden", 424 ignoreTitle: false, 425 customElements: [], 426 onfocusin: function( element ) { 427 this.lastActive = element; 428 429 // Hide error label and remove error class on focus if enabled 430 if ( this.settings.focusCleanup ) { 431 if ( this.settings.unhighlight ) { 432 this.settings.unhighlight.call( this, element, this.settings.errorClass, this.settings.validClass ); 433 } 434 this.hideThese( this.errorsFor( element ) ); 435 } 436 }, 437 onfocusout: function( element ) { 438 if ( !this.checkable( element ) && ( element.name in this.submitted || !this.optional( element ) ) ) { 439 this.element( element ); 440 } 441 }, 442 onkeyup: function( element, event ) { 443 444 // Avoid revalidate the field when pressing one of the following keys 445 // Shift => 16 446 // Ctrl => 17 447 // Alt => 18 448 // Caps lock => 20 449 // End => 35 450 // Home => 36 451 // Left arrow => 37 452 // Up arrow => 38 453 // Right arrow => 39 454 // Down arrow => 40 455 // Insert => 45 456 // Num lock => 144 457 // AltGr key => 225 458 var excludedKeys = [ 459 16, 17, 18, 20, 35, 36, 37, 460 38, 39, 40, 45, 144, 225 461 ]; 462 463 if ( event.which === 9 && this.elementValue( element ) === "" || $.inArray( event.keyCode, excludedKeys ) !== -1 ) { 464 return; 465 } else if ( element.name in this.submitted || element.name in this.invalid ) { 466 this.element( element ); 467 } 468 }, 469 onclick: function( element ) { 470 471 // Click on selects, radiobuttons and checkboxes 472 if ( element.name in this.submitted ) { 473 this.element( element ); 474 475 // Or option elements, check parent select in that case 476 } else if ( element.parentNode.name in this.submitted ) { 477 this.element( element.parentNode ); 478 } 479 }, 480 highlight: function( element, errorClass, validClass ) { 481 if ( element.type === "radio" ) { 482 this.findByName( element.name ).addClass( errorClass ).removeClass( validClass ); 483 } else { 484 $( element ).addClass( errorClass ).removeClass( validClass ); 485 } 486 }, 487 unhighlight: function( element, errorClass, validClass ) { 488 if ( element.type === "radio" ) { 489 this.findByName( element.name ).removeClass( errorClass ).addClass( validClass ); 490 } else { 491 $( element ).removeClass( errorClass ).addClass( validClass ); 492 } 493 } 494 }, 495 496 // https://jqueryvalidation.org/jQuery.validator.setDefaults/ 497 setDefaults: function( settings ) { 498 $.extend( $.validator.defaults, settings ); 499 }, 500 501 messages: { 502 required: "This field is required.", 503 remote: "Please fix this field.", 504 email: "Please enter a valid email address.", 505 url: "Please enter a valid URL.", 506 date: "Please enter a valid date.", 507 dateISO: "Please enter a valid date (ISO).", 508 number: "Please enter a valid number.", 509 digits: "Please enter only digits.", 510 equalTo: "Please enter the same value again.", 511 maxlength: $.validator.format( "Please enter no more than {0} characters." ), 512 minlength: $.validator.format( "Please enter at least {0} characters." ), 513 rangelength: $.validator.format( "Please enter a value between {0} and {1} characters long." ), 514 range: $.validator.format( "Please enter a value between {0} and {1}." ), 515 max: $.validator.format( "Please enter a value less than or equal to {0}." ), 516 min: $.validator.format( "Please enter a value greater than or equal to {0}." ), 517 step: $.validator.format( "Please enter a multiple of {0}." ) 518 }, 519 520 autoCreateRanges: false, 521 522 prototype: { 523 524 init: function() { 525 this.labelContainer = $( this.settings.errorLabelContainer ); 526 this.errorContext = this.labelContainer.length && this.labelContainer || $( this.currentForm ); 527 this.containers = $( this.settings.errorContainer ).add( this.settings.errorLabelContainer ); 528 this.submitted = {}; 529 this.valueCache = {}; 530 this.pendingRequest = 0; 531 this.pending = {}; 532 this.invalid = {}; 533 this.reset(); 534 535 var currentForm = this.currentForm, 536 groups = ( this.groups = {} ), 537 rules; 538 $.each( this.settings.groups, function( key, value ) { 539 if ( typeof value === "string" ) { 540 value = value.split( /\s/ ); 541 } 542 $.each( value, function( index, name ) { 543 groups[ name ] = key; 544 } ); 545 } ); 546 rules = this.settings.rules; 547 $.each( rules, function( key, value ) { 548 rules[ key ] = $.validator.normalizeRule( value ); 549 } ); 550 551 function delegate( event ) { 552 var isContentEditable = typeof $( this ).attr( "contenteditable" ) !== "undefined" && $( this ).attr( "contenteditable" ) !== "false"; 553 554 // Set form expando on contenteditable 555 if ( !this.form && isContentEditable ) { 556 this.form = $( this ).closest( "form" )[ 0 ]; 557 this.name = $( this ).attr( "name" ); 558 } 559 560 // Ignore the element if it belongs to another form. This will happen mainly 561 // when setting the `form` attribute of an input to the id of another form. 562 if ( currentForm !== this.form ) { 563 return; 564 } 565 566 var validator = $.data( this.form, "validator" ), 567 eventType = "on" + event.type.replace( /^validate/, "" ), 568 settings = validator.settings; 569 if ( settings[ eventType ] && !$( this ).is( settings.ignore ) ) { 570 settings[ eventType ].call( validator, this, event ); 571 } 572 } 573 var focusListeners = [ ":text", "[type='password']", "[type='file']", "select", "textarea", "[type='number']", "[type='search']", 574 "[type='tel']", "[type='url']", "[type='email']", "[type='datetime']", "[type='date']", "[type='month']", 575 "[type='week']", "[type='time']", "[type='datetime-local']", "[type='range']", "[type='color']", 576 "[type='radio']", "[type='checkbox']", "[contenteditable]", "[type='button']" ]; 577 var clickListeners = [ "select", "option", "[type='radio']", "[type='checkbox']" ]; 578 $( this.currentForm ) 579 .on( "focusin.validate focusout.validate keyup.validate", focusListeners.concat( this.settings.customElements ).join( ", " ), delegate ) 580 581 // Support: Chrome, oldIE 582 // "select" is provided as event.target when clicking a option 583 .on( "click.validate", clickListeners.concat( this.settings.customElements ).join( ", " ), delegate ); 584 585 if ( this.settings.invalidHandler ) { 586 $( this.currentForm ).on( "invalid-form.validate", this.settings.invalidHandler ); 587 } 588 }, 589 590 // https://jqueryvalidation.org/Validator.form/ 591 form: function() { 592 this.checkForm(); 593 $.extend( this.submitted, this.errorMap ); 594 this.invalid = $.extend( {}, this.errorMap ); 595 if ( !this.valid() ) { 596 $( this.currentForm ).triggerHandler( "invalid-form", [ this ] ); 597 } 598 this.showErrors(); 599 return this.valid(); 600 }, 601 602 checkForm: function() { 603 this.prepareForm(); 604 for ( var i = 0, elements = ( this.currentElements = this.elements() ); elements[ i ]; i++ ) { 605 this.check( elements[ i ] ); 606 } 607 return this.valid(); 608 }, 609 610 // https://jqueryvalidation.org/Validator.element/ 611 element: function( element ) { 612 var cleanElement = this.clean( element ), 613 checkElement = this.validationTargetFor( cleanElement ), 614 v = this, 615 result = true, 616 rs, group; 617 618 if ( checkElement === undefined ) { 619 delete this.invalid[ cleanElement.name ]; 620 } else { 621 this.prepareElement( checkElement ); 622 this.currentElements = $( checkElement ); 623 624 // If this element is grouped, then validate all group elements already 625 // containing a value 626 group = this.groups[ checkElement.name ]; 627 if ( group ) { 628 $.each( this.groups, function( name, testgroup ) { 629 if ( testgroup === group && name !== checkElement.name ) { 630 cleanElement = v.validationTargetFor( v.clean( v.findByName( name ) ) ); 631 632 // Don't want to check fields if a user hasn't gotten to them yet 633 if ( cleanElement && cleanElement.name in v.invalid ) { 634 v.currentElements.pushStack( cleanElement ); 635 result = v.check( cleanElement ) && result; 636 } 637 } 638 } ); 639 } 640 641 rs = this.check( checkElement ) !== false; 642 result = result && rs; 643 if ( rs ) { 644 this.invalid[ checkElement.name ] = false; 645 } else { 646 this.invalid[ checkElement.name ] = true; 647 } 648 649 if ( !this.numberOfInvalids() ) { 650 651 // Hide error containers on last error 652 this.toHide = this.toHide.add( this.containers ); 653 } 654 this.showErrors(); 655 656 // Add aria-invalid status for screen readers 657 $( element ).attr( "aria-invalid", !rs ); 658 } 659 660 return result; 661 }, 662 663 // https://jqueryvalidation.org/Validator.showErrors/ 664 showErrors: function( errors ) { 665 if ( errors ) { 666 var validator = this; 667 668 // Add items to error list and map 669 $.extend( this.errorMap, errors ); 670 this.errorList = $.map( this.errorMap, function( message, name ) { 671 return { 672 message: message, 673 element: validator.findByName( name )[ 0 ] 674 }; 675 } ); 676 677 // Remove items from success list 678 this.successList = $.grep( this.successList, function( element ) { 679 return !( element.name in errors ); 680 } ); 681 } 682 if ( this.settings.showErrors ) { 683 this.settings.showErrors.call( this, this.errorMap, this.errorList ); 684 } else { 685 this.defaultShowErrors(); 686 } 687 }, 688 689 // https://jqueryvalidation.org/Validator.resetForm/ 690 resetForm: function() { 691 if ( $.fn.resetForm ) { 692 $( this.currentForm ).resetForm(); 693 } 694 this.invalid = {}; 695 this.submitted = {}; 696 this.prepareForm(); 697 this.hideErrors(); 698 var elements = this.elements() 699 .removeData( "previousValue" ) 700 .removeAttr( "aria-invalid" ); 701 702 this.resetElements( elements ); 703 }, 704 705 resetElements: function( elements ) { 706 var i; 707 708 if ( this.settings.unhighlight ) { 709 for ( i = 0; elements[ i ]; i++ ) { 710 this.settings.unhighlight.call( this, elements[ i ], 711 this.settings.errorClass, "" ); 712 this.findByName( elements[ i ].name ).removeClass( this.settings.validClass ); 713 } 714 } else { 715 elements 716 .removeClass( this.settings.errorClass ) 717 .removeClass( this.settings.validClass ); 718 } 719 }, 720 721 numberOfInvalids: function() { 722 return this.objectLength( this.invalid ); 723 }, 724 725 objectLength: function( obj ) { 726 /* jshint unused: false */ 727 var count = 0, 728 i; 729 for ( i in obj ) { 730 731 // This check allows counting elements with empty error 732 // message as invalid elements 733 if ( obj[ i ] !== undefined && obj[ i ] !== null && obj[ i ] !== false ) { 734 count++; 735 } 736 } 737 return count; 738 }, 739 740 hideErrors: function() { 741 this.hideThese( this.toHide ); 742 }, 743 addErrorAriaDescribedBy: function( element, error, updateGroupMembers ) { 744 updateGroupMembers = ( updateGroupMembers === undefined ) ? false : updateGroupMembers; 745 746 var errorID, v, group, 747 describedBy = $( element ).attr( "aria-describedby" ); 748 errorID = error.attr( "id" ); 749 750 // Respect existing non-error aria-describedby 751 if ( !describedBy ) { 752 describedBy = errorID; 753 } else if ( !describedBy.match( new RegExp( "\\b" + this.escapeCssMeta( errorID ) + "\\b" ) ) ) { 754 755 // Add to end of list if not already present 756 describedBy += " " + errorID; 757 } 758 759 $( element ).attr( "aria-describedby", describedBy ); 760 761 if ( updateGroupMembers ) { 762 763 // If this element is grouped, then assign to all elements in the same group 764 group = this.groups[ element.name ]; 765 if ( group ) { 766 v = this; 767 $.each( v.groups, function( name, testgroup ) { 768 if ( testgroup === group ) { 769 v.addErrorAriaDescribedBy( $( "[name='" + v.escapeCssMeta( name ) + "']", v.currentForm ), error, false ); 770 } 771 } ); 772 } 773 } 774 }, 775 776 removeErrorAriaDescribedBy: function( element, error ) { 777 778 var describedBy = $( element ).attr( "aria-describedby" ), 779 describedByIds = describedBy.split( " " ), 780 errorID = error.attr( "id" ), 781 ind = describedByIds.indexOf( errorID ); 782 783 if ( ind > -1 ) { 784 describedByIds.splice( ind, 1 ); 785 } 786 787 if ( describedByIds.length ) { 788 $( element ).attr( "aria-describedby", describedByIds.join( " " ) ); 789 } else { 790 $( element ).removeAttr( "aria-describedby" ); 791 } 792 793 }, 794 795 hideThese: function( errors ) { 796 797 for ( var i = 0; errors[ i ]; i++ ) { 798 var error = $( errors[ i ] ), 799 errorID = error.attr( "id" ) ? this.escapeCssMeta( error.attr( "id" ) ) : undefined, 800 element = ( errorID ) ? this.elements().filter( '[aria-describedby~="' + errorID + '"]' ) : []; 801 802 if ( this.settings.ariaDescribedByCleanup && element.length ) { 803 this.removeErrorAriaDescribedBy( element, error ); 804 } 805 806 if ( !error.is( this.containers ) ) { 807 error.text( "" ); 808 } 809 810 this.addWrapper( error ).hide(); 811 } 812 813 }, 814 815 valid: function() { 816 return this.size() === 0; 817 }, 818 819 size: function() { 820 return this.errorList.length; 821 }, 822 823 focusInvalid: function() { 824 if ( this.settings.focusInvalid ) { 825 try { 826 $( this.findLastActive() || this.errorList.length && this.errorList[ 0 ].element || [] ) 827 .filter( ":visible" ) 828 .trigger( "focus" ) 829 830 // Manually trigger focusin event; without it, focusin handler isn't called, findLastActive won't have anything to find 831 .trigger( "focusin" ); 832 } catch ( e ) { 833 834 // Ignore IE throwing errors when focusing hidden elements 835 } 836 } 837 }, 838 839 findLastActive: function() { 840 var lastActive = this.lastActive; 841 return lastActive && $.grep( this.errorList, function( n ) { 842 return n.element.name === lastActive.name; 843 } ).length === 1 && lastActive; 844 }, 845 846 elements: function() { 847 var validator = this, 848 rulesCache = {}, 849 selectors = [ "input", "select", "textarea", "[contenteditable]" ], 850 formId = this.currentForm.getAttribute( "id" ), 851 elements; 852 853 // Select all valid inputs inside the form (no submit or reset buttons) 854 elements = $( this.currentForm ) 855 .find( selectors.concat( this.settings.customElements ).join( ", " ) ) 856 .not( ":submit, :reset, :image, :disabled" ) 857 .not( this.settings.ignore ); 858 859 // If the form has an ID, also include elements outside the form that have 860 // a form attribute pointing to this form 861 if ( formId ) { 862 elements = elements.add( 863 $( selectors.concat( this.settings.customElements ).join( ", " ) ) 864 .filter( "[form='" + validator.escapeCssMeta( formId ) + "']" ) 865 .not( ":submit, :reset, :image, :disabled" ) 866 .not( this.settings.ignore ) 867 ); 868 } 869 870 return elements.filter( function() { 871 var name = this.name || $( this ).attr( "name" ); // For contenteditable 872 var isContentEditable = typeof $( this ).attr( "contenteditable" ) !== "undefined" && $( this ).attr( "contenteditable" ) !== "false"; 873 874 if ( !name && validator.settings.debug && window.console ) { 875 console.error( "%o has no name assigned", this ); 876 } 877 878 // Set form expando on contenteditable 879 if ( isContentEditable ) { 880 this.form = $( this ).closest( "form" )[ 0 ]; 881 this.name = name; 882 } 883 884 // Ignore elements that belong to other/nested forms 885 if ( this.form !== validator.currentForm ) { 886 return false; 887 } 888 889 // Select only the first element for each name, and only those with rules specified 890 if ( name in rulesCache || !validator.objectLength( $( this ).rules() ) ) { 891 return false; 892 } 893 894 rulesCache[ name ] = true; 895 return true; 896 } ); 897 }, 898 899 clean: function( selector ) { 900 return $( selector )[ 0 ]; 901 }, 902 903 errors: function() { 904 var errorClass = this.settings.errorClass.split( " " ).join( "." ); 905 return $( this.settings.errorElement + "." + errorClass, this.errorContext ); 906 }, 907 908 resetInternals: function() { 909 this.successList = []; 910 this.errorList = []; 911 this.errorMap = {}; 912 this.toShow = $( [] ); 913 this.toHide = $( [] ); 914 }, 915 916 reset: function() { 917 this.resetInternals(); 918 this.currentElements = $( [] ); 919 }, 920 921 prepareForm: function() { 922 this.reset(); 923 this.toHide = this.errors().add( this.containers ); 924 }, 925 926 prepareElement: function( element ) { 927 this.reset(); 928 this.toHide = this.errorsFor( element ); 929 }, 930 931 elementValue: function( element ) { 932 var $element = $( element ), 933 type = element.type, 934 isContentEditable = typeof $element.attr( "contenteditable" ) !== "undefined" && $element.attr( "contenteditable" ) !== "false", 935 val, idx; 936 937 if ( type === "radio" || type === "checkbox" ) { 938 return this.findByName( element.name ).filter( ":checked" ).val(); 939 } else if ( type === "number" && typeof element.validity !== "undefined" ) { 940 return element.validity.badInput ? "NaN" : $element.val(); 941 } 942 943 if ( isContentEditable ) { 944 val = $element.text(); 945 } else { 946 val = $element.val(); 947 } 948 949 if ( type === "file" ) { 950 951 // Modern browser (chrome & safari) 952 if ( val.substr( 0, 12 ) === "C:\\fakepath\\" ) { 953 return val.substr( 12 ); 954 } 955 956 // Legacy browsers 957 // Unix-based path 958 idx = val.lastIndexOf( "/" ); 959 if ( idx >= 0 ) { 960 return val.substr( idx + 1 ); 961 } 962 963 // Windows-based path 964 idx = val.lastIndexOf( "\\" ); 965 if ( idx >= 0 ) { 966 return val.substr( idx + 1 ); 967 } 968 969 // Just the file name 970 return val; 971 } 972 973 if ( typeof val === "string" ) { 974 return val.replace( /\r/g, "" ); 975 } 976 return val; 977 }, 978 979 check: function( element ) { 980 element = this.validationTargetFor( this.clean( element ) ); 981 982 var rules = $( element ).rules(), 983 rulesCount = $.map( rules, function( n, i ) { 984 return i; 985 } ).length, 986 dependencyMismatch = false, 987 val = this.elementValue( element ), 988 result, method, rule, normalizer; 989 990 // Abort any pending Ajax request from a previous call to this method. 991 this.abortRequest( element ); 992 993 // Prioritize the local normalizer defined for this element over the global one 994 // if the former exists, otherwise user the global one in case it exists. 995 if ( typeof rules.normalizer === "function" ) { 996 normalizer = rules.normalizer; 997 } else if ( typeof this.settings.normalizer === "function" ) { 998 normalizer = this.settings.normalizer; 999 } 1000 1001 // If normalizer is defined, then call it to retreive the changed value instead 1002 // of using the real one. 1003 // Note that `this` in the normalizer is `element`. 1004 if ( normalizer ) { 1005 val = normalizer.call( element, val ); 1006 1007 // Delete the normalizer from rules to avoid treating it as a pre-defined method. 1008 delete rules.normalizer; 1009 } 1010 1011 for ( method in rules ) { 1012 rule = { method: method, parameters: rules[ method ] }; 1013 try { 1014 result = $.validator.methods[ method ].call( this, val, element, rule.parameters ); 1015 1016 // If a method indicates that the field is optional and therefore valid, 1017 // don't mark it as valid when there are no other rules 1018 if ( result === "dependency-mismatch" && rulesCount === 1 ) { 1019 dependencyMismatch = true; 1020 continue; 1021 } 1022 dependencyMismatch = false; 1023 1024 if ( result === "pending" ) { 1025 this.toHide = this.toHide.not( this.errorsFor( element ) ); 1026 return; 1027 } 1028 1029 if ( !result ) { 1030 this.formatAndAdd( element, rule ); 1031 return false; 1032 } 1033 } catch ( e ) { 1034 if ( this.settings.debug && window.console ) { 1035 console.log( "Exception occurred when checking element " + element.id + ", check the '" + rule.method + "' method.", e ); 1036 } 1037 if ( e instanceof TypeError ) { 1038 e.message += ". Exception occurred when checking element " + element.id + ", check the '" + rule.method + "' method."; 1039 } 1040 1041 throw e; 1042 } 1043 } 1044 if ( dependencyMismatch ) { 1045 return; 1046 } 1047 if ( this.objectLength( rules ) ) { 1048 this.successList.push( element ); 1049 } 1050 return true; 1051 }, 1052 1053 // Return the custom message for the given element and validation method 1054 // specified in the element's HTML5 data attribute 1055 // return the generic message if present and no method specific message is present 1056 customDataMessage: function( element, method ) { 1057 return $( element ).data( "msg" + method.charAt( 0 ).toUpperCase() + 1058 method.substring( 1 ).toLowerCase() ) || $( element ).data( "msg" ); 1059 }, 1060 1061 // Return the custom message for the given element name and validation method 1062 customMessage: function( name, method ) { 1063 var m = this.settings.messages[ name ]; 1064 return m && ( m.constructor === String ? m : m[ method ] ); 1065 }, 1066 1067 // Return the first defined argument, allowing empty strings 1068 findDefined: function() { 1069 for ( var i = 0; i < arguments.length; i++ ) { 1070 if ( arguments[ i ] !== undefined ) { 1071 return arguments[ i ]; 1072 } 1073 } 1074 return undefined; 1075 }, 1076 1077 // The second parameter 'rule' used to be a string, and extended to an object literal 1078 // of the following form: 1079 // rule = { 1080 // method: "method name", 1081 // parameters: "the given method parameters" 1082 // } 1083 // 1084 // The old behavior still supported, kept to maintain backward compatibility with 1085 // old code, and will be removed in the next major release. 1086 defaultMessage: function( element, rule ) { 1087 if ( typeof rule === "string" ) { 1088 rule = { method: rule }; 1089 } 1090 1091 var message = this.findDefined( 1092 this.customMessage( element.name, rule.method ), 1093 this.customDataMessage( element, rule.method ), 1094 1095 // 'title' is never undefined, so handle empty string as undefined 1096 !this.settings.ignoreTitle && element.title || undefined, 1097 $.validator.messages[ rule.method ], 1098 "<strong>Warning: No message defined for " + element.name + "</strong>" 1099 ), 1100 theregex = /\$?\{(\d+)\}/g; 1101 if ( typeof message === "function" ) { 1102 message = message.call( this, rule.parameters, element ); 1103 } else if ( theregex.test( message ) ) { 1104 message = $.validator.format( message.replace( theregex, "{$1}" ), rule.parameters ); 1105 } 1106 1107 return message; 1108 }, 1109 1110 formatAndAdd: function( element, rule ) { 1111 var message = this.defaultMessage( element, rule ); 1112 1113 this.errorList.push( { 1114 message: message, 1115 element: element, 1116 method: rule.method 1117 } ); 1118 1119 this.errorMap[ element.name ] = message; 1120 this.submitted[ element.name ] = message; 1121 }, 1122 1123 addWrapper: function( toToggle ) { 1124 if ( this.settings.wrapper ) { 1125 toToggle = toToggle.add( toToggle.parent( this.settings.wrapper ) ); 1126 } 1127 return toToggle; 1128 }, 1129 1130 defaultShowErrors: function() { 1131 var i, elements, error; 1132 1133 for ( i = 0; this.errorList[ i ]; i++ ) { 1134 error = this.errorList[ i ]; 1135 if ( this.settings.highlight ) { 1136 this.settings.highlight.call( this, error.element, this.settings.errorClass, this.settings.validClass ); 1137 } 1138 this.showLabel( error.element, error.message ); 1139 } 1140 1141 if ( this.errorList.length ) { 1142 this.toShow = this.toShow.add( this.containers ); 1143 } 1144 1145 if ( this.settings.success ) { 1146 for ( i = 0; this.successList[ i ]; i++ ) { 1147 this.showLabel( this.successList[ i ] ); 1148 } 1149 } 1150 1151 if ( this.settings.unhighlight ) { 1152 for ( i = 0, elements = this.validElements(); elements[ i ]; i++ ) { 1153 this.settings.unhighlight.call( this, elements[ i ], this.settings.errorClass, this.settings.validClass ); 1154 } 1155 } 1156 1157 this.toHide = this.toHide.not( this.toShow ); 1158 this.hideErrors(); 1159 this.addWrapper( this.toShow ).show(); 1160 }, 1161 1162 validElements: function() { 1163 return this.currentElements.not( this.invalidElements() ); 1164 }, 1165 1166 invalidElements: function() { 1167 return $( this.errorList ).map( function() { 1168 return this.element; 1169 } ); 1170 }, 1171 1172 showLabel: function( element, message ) { 1173 var place, 1174 error = this.errorsFor( element ), 1175 elementID = this.idOrName( element ), 1176 describedBy = $( element ).attr( "aria-describedby" ); 1177 1178 if ( error.length ) { 1179 1180 // Non-label error exists but is not currently associated with element via aria-describedby 1181 if ( error.closest( "label[for='" + this.escapeCssMeta( elementID ) + "']" ).length === 0 && ( describedBy === undefined || describedBy.split( " " ).indexOf( error.attr( "id" ) ) === -1 ) ) { 1182 this.addErrorAriaDescribedBy( element, error, true ); 1183 } 1184 1185 // Refresh error/success class 1186 error.removeClass( this.settings.validClass ).addClass( this.settings.errorClass ); 1187 1188 // Replace message on existing label 1189 if ( this.settings && this.settings.escapeHtml ) { 1190 error.text( message || "" ); 1191 } else { 1192 error.html( message || "" ); 1193 } 1194 } else { 1195 1196 // Create error element 1197 error = $( "<" + this.settings.errorElement + ">" ) 1198 .attr( "id", elementID + "-error" ) 1199 .addClass( this.settings.errorClass ); 1200 1201 if ( this.settings && this.settings.escapeHtml ) { 1202 error.text( message || "" ); 1203 } else { 1204 error.html( message || "" ); 1205 } 1206 1207 // Maintain reference to the element to be placed into the DOM 1208 place = error; 1209 if ( this.settings.wrapper ) { 1210 1211 // Make sure the element is visible, even in IE 1212 // actually showing the wrapped element is handled elsewhere 1213 place = error.hide().show().wrap( "<" + this.settings.wrapper + "/>" ).parent(); 1214 } 1215 if ( this.labelContainer.length ) { 1216 this.labelContainer.append( place ); 1217 } else if ( this.settings.errorPlacement ) { 1218 this.settings.errorPlacement.call( this, place, $( element ) ); 1219 } else { 1220 place.insertAfter( element ); 1221 } 1222 1223 // Link error back to the element 1224 if ( error.is( "label" ) ) { 1225 1226 // If the error is a label, then associate using 'for' 1227 error.attr( "for", elementID ); 1228 1229 // If the element is not a child of an associated label, then it's necessary 1230 // to explicitly apply aria-describedby 1231 } else if ( error.parents( "label[for='" + this.escapeCssMeta( elementID ) + "']" ).length === 0 ) { 1232 this.addErrorAriaDescribedBy( element, error, true ); 1233 } 1234 } 1235 if ( !message && this.settings.success ) { 1236 error.text( "" ); 1237 if ( typeof this.settings.success === "string" ) { 1238 error.addClass( this.settings.success ); 1239 } else { 1240 this.settings.success( error, element ); 1241 } 1242 } 1243 this.toShow = this.toShow.add( error ); 1244 }, 1245 1246 errorsFor: function( element ) { 1247 var name = this.escapeCssMeta( this.idOrName( element ) ), 1248 describer = $( element ).attr( "aria-describedby" ), 1249 selector = "label[for='" + name + "'], label[for='" + name + "'] *"; 1250 1251 // 'aria-describedby' should directly reference the error element 1252 if ( describer ) { 1253 selector = selector + ", #" + this.escapeCssMeta( describer ) 1254 .replace( /\s+/g, ", #" ); 1255 } 1256 1257 // There may be hidden error elements not currently associated via aria-describedby (if ariaDescribedByCleanup is true) 1258 selector = selector + ", #" + name + "-error"; 1259 1260 return this 1261 .errors() 1262 .filter( selector ); 1263 }, 1264 1265 // See https://api.jquery.com/category/selectors/, for CSS 1266 // meta-characters that should be escaped in order to be used with JQuery 1267 // as a literal part of a name/id or any selector. 1268 escapeCssMeta: function( string ) { 1269 if ( string === undefined ) { 1270 return ""; 1271 } 1272 1273 return string.replace( /([\\!"#$%&'()*+,./:;<=>?@\[\]^`{|}~])/g, "\\$1" ); 1274 }, 1275 1276 idOrName: function( element ) { 1277 return this.groups[ element.name ] || ( this.checkable( element ) ? element.name : element.id || element.name ); 1278 }, 1279 1280 validationTargetFor: function( element ) { 1281 1282 // If radio/checkbox, validate first element in group instead 1283 if ( this.checkable( element ) ) { 1284 element = this.findByName( element.name ); 1285 } 1286 1287 // Always apply ignore filter 1288 return $( element ).not( this.settings.ignore )[ 0 ]; 1289 }, 1290 1291 checkable: function( element ) { 1292 return ( /radio|checkbox/i ).test( element.type ); 1293 }, 1294 1295 findByName: function( name ) { 1296 var formId = this.currentForm.getAttribute( "id" ), 1297 selector = "[name='" + this.escapeCssMeta( name ) + "']", 1298 elements = $( this.currentForm ).find( selector ); 1299 1300 // If the form has an ID, also include elements outside the form that have 1301 // a form attribute pointing to this form 1302 if ( formId ) { 1303 elements = elements.add( 1304 $( selector ) 1305 .filter( "[form='" + this.escapeCssMeta( formId ) + "']" ) 1306 ); 1307 } 1308 1309 return elements; 1310 }, 1311 1312 getLength: function( value, element ) { 1313 switch ( element.nodeName.toLowerCase() ) { 1314 case "select": 1315 return $( "option:selected", element ).length; 1316 case "input": 1317 if ( this.checkable( element ) ) { 1318 return this.findByName( element.name ).filter( ":checked" ).length; 1319 } 1320 } 1321 return value.length; 1322 }, 1323 1324 depend: function( param, element ) { 1325 return this.dependTypes[ typeof param ] ? this.dependTypes[ typeof param ]( param, element ) : true; 1326 }, 1327 1328 dependTypes: { 1329 "boolean": function( param ) { 1330 return param; 1331 }, 1332 "string": function( param, element ) { 1333 return !!$( param, element.form ).length; 1334 }, 1335 "function": function( param, element ) { 1336 return param( element ); 1337 } 1338 }, 1339 1340 optional: function( element ) { 1341 var val = this.elementValue( element ); 1342 return !$.validator.methods.required.call( this, val, element ) && "dependency-mismatch"; 1343 }, 1344 1345 elementAjaxPort: function( element ) { 1346 return "validate" + element.name; 1347 }, 1348 1349 startRequest: function( element ) { 1350 if ( !this.pending[ element.name ] ) { 1351 this.pendingRequest++; 1352 $( element ).addClass( this.settings.pendingClass ); 1353 this.pending[ element.name ] = true; 1354 } 1355 }, 1356 1357 stopRequest: function( element, valid ) { 1358 this.pendingRequest--; 1359 1360 // Sometimes synchronization fails, make sure pendingRequest is never < 0 1361 if ( this.pendingRequest < 0 ) { 1362 this.pendingRequest = 0; 1363 } 1364 delete this.pending[ element.name ]; 1365 $( element ).removeClass( this.settings.pendingClass ); 1366 if ( valid && this.pendingRequest === 0 && this.formSubmitted && this.form() && this.pendingRequest === 0 ) { 1367 $( this.currentForm ).trigger( "submit" ); 1368 1369 // Remove the hidden input that was used as a replacement for the 1370 // missing submit button. The hidden input is added by `handle()` 1371 // to ensure that the value of the used submit button is passed on 1372 // for scripted submits triggered by this method 1373 if ( this.submitButton ) { 1374 $( "input:hidden[name='" + this.submitButton.name + "']", this.currentForm ).remove(); 1375 } 1376 1377 this.formSubmitted = false; 1378 } else if ( !valid && this.pendingRequest === 0 && this.formSubmitted ) { 1379 $( this.currentForm ).triggerHandler( "invalid-form", [ this ] ); 1380 this.formSubmitted = false; 1381 } 1382 }, 1383 1384 abortRequest: function( element ) { 1385 var port; 1386 1387 if ( this.pending[ element.name ] ) { 1388 port = this.elementAjaxPort( element ); 1389 $.ajaxAbort( port ); 1390 1391 this.pendingRequest--; 1392 1393 // Sometimes synchronization fails, make sure pendingRequest is never < 0 1394 if ( this.pendingRequest < 0 ) { 1395 this.pendingRequest = 0; 1396 } 1397 1398 delete this.pending[ element.name ]; 1399 $( element ).removeClass( this.settings.pendingClass ); 1400 } 1401 }, 1402 1403 previousValue: function( element, method ) { 1404 method = typeof method === "string" && method || "remote"; 1405 1406 return $.data( element, "previousValue" ) || $.data( element, "previousValue", { 1407 old: null, 1408 valid: true, 1409 message: this.defaultMessage( element, { method: method } ) 1410 } ); 1411 }, 1412 1413 // Cleans up all forms and elements, removes validator-specific events 1414 destroy: function() { 1415 this.resetForm(); 1416 1417 $( this.currentForm ) 1418 .off( ".validate" ) 1419 .removeData( "validator" ) 1420 .find( ".validate-equalTo-blur" ) 1421 .off( ".validate-equalTo" ) 1422 .removeClass( "validate-equalTo-blur" ) 1423 .find( ".validate-lessThan-blur" ) 1424 .off( ".validate-lessThan" ) 1425 .removeClass( "validate-lessThan-blur" ) 1426 .find( ".validate-lessThanEqual-blur" ) 1427 .off( ".validate-lessThanEqual" ) 1428 .removeClass( "validate-lessThanEqual-blur" ) 1429 .find( ".validate-greaterThanEqual-blur" ) 1430 .off( ".validate-greaterThanEqual" ) 1431 .removeClass( "validate-greaterThanEqual-blur" ) 1432 .find( ".validate-greaterThan-blur" ) 1433 .off( ".validate-greaterThan" ) 1434 .removeClass( "validate-greaterThan-blur" ); 1435 } 1436 1437 }, 1438 1439 classRuleSettings: { 1440 required: { required: true }, 1441 email: { email: true }, 1442 url: { url: true }, 1443 date: { date: true }, 1444 dateISO: { dateISO: true }, 1445 number: { number: true }, 1446 digits: { digits: true }, 1447 creditcard: { creditcard: true } 1448 }, 1449 1450 addClassRules: function( className, rules ) { 1451 if ( className.constructor === String ) { 1452 this.classRuleSettings[ className ] = rules; 1453 } else { 1454 $.extend( this.classRuleSettings, className ); 1455 } 1456 }, 1457 1458 classRules: function( element ) { 1459 var rules = {}, 1460 classes = $( element ).attr( "class" ); 1461 1462 if ( classes ) { 1463 $.each( classes.split( " " ), function() { 1464 if ( this in $.validator.classRuleSettings ) { 1465 $.extend( rules, $.validator.classRuleSettings[ this ] ); 1466 } 1467 } ); 1468 } 1469 return rules; 1470 }, 1471 1472 normalizeAttributeRule: function( rules, type, method, value ) { 1473 1474 // Convert the value to a number for number inputs, and for text for backwards compability 1475 // allows type="date" and others to be compared as strings 1476 if ( /min|max|step/.test( method ) && ( type === null || /number|range|text/.test( type ) ) ) { 1477 value = Number( value ); 1478 1479 // Support Opera Mini, which returns NaN for undefined minlength 1480 if ( isNaN( value ) ) { 1481 value = undefined; 1482 } 1483 } 1484 1485 if ( value || value === 0 ) { 1486 rules[ method ] = value; 1487 } else if ( type === method && type !== "range" ) { 1488 1489 // Exception: the jquery validate 'range' method 1490 // does not test for the html5 'range' type 1491 rules[ type === "date" ? "dateISO" : method ] = true; 1492 } 1493 }, 1494 1495 attributeRules: function( element ) { 1496 var rules = {}, 1497 $element = $( element ), 1498 type = element.getAttribute( "type" ), 1499 method, value; 1500 1501 for ( method in $.validator.methods ) { 1502 1503 // Support for <input required> in both html5 and older browsers 1504 if ( method === "required" ) { 1505 value = element.getAttribute( method ); 1506 1507 // Some browsers return an empty string for the required attribute 1508 // and non-HTML5 browsers might have required="" markup 1509 if ( value === "" ) { 1510 value = true; 1511 } 1512 1513 // Force non-HTML5 browsers to return bool 1514 value = !!value; 1515 } else { 1516 value = $element.attr( method ); 1517 } 1518 1519 this.normalizeAttributeRule( rules, type, method, value ); 1520 } 1521 1522 // 'maxlength' may be returned as -1, 2147483647 ( IE ) and 524288 ( safari ) for text inputs 1523 if ( rules.maxlength && /-1|2147483647|524288/.test( rules.maxlength ) ) { 1524 delete rules.maxlength; 1525 } 1526 1527 return rules; 1528 }, 1529 1530 dataRules: function( element ) { 1531 var rules = {}, 1532 $element = $( element ), 1533 type = element.getAttribute( "type" ), 1534 method, value; 1535 1536 for ( method in $.validator.methods ) { 1537 value = $element.data( "rule" + method.charAt( 0 ).toUpperCase() + method.substring( 1 ).toLowerCase() ); 1538 1539 // Cast empty attributes like `data-rule-required` to `true` 1540 if ( value === "" ) { 1541 value = true; 1542 } 1543 1544 this.normalizeAttributeRule( rules, type, method, value ); 1545 } 1546 return rules; 1547 }, 1548 1549 staticRules: function( element ) { 1550 var rules = {}, 1551 validator = $.data( element.form, "validator" ); 1552 1553 if ( validator.settings.rules ) { 1554 rules = $.validator.normalizeRule( validator.settings.rules[ element.name ] ) || {}; 1555 } 1556 return rules; 1557 }, 1558 1559 normalizeRules: function( rules, element ) { 1560 1561 // Handle dependency check 1562 $.each( rules, function( prop, val ) { 1563 1564 // Ignore rule when param is explicitly false, eg. required:false 1565 if ( val === false ) { 1566 delete rules[ prop ]; 1567 return; 1568 } 1569 if ( val.param || val.depends ) { 1570 var keepRule = true; 1571 switch ( typeof val.depends ) { 1572 case "string": 1573 keepRule = !!$( val.depends, element.form ).length; 1574 break; 1575 case "function": 1576 keepRule = val.depends.call( element, element ); 1577 break; 1578 } 1579 if ( keepRule ) { 1580 rules[ prop ] = val.param !== undefined ? val.param : true; 1581 } else { 1582 $.data( element.form, "validator" ).resetElements( $( element ) ); 1583 delete rules[ prop ]; 1584 } 1585 } 1586 } ); 1587 1588 // Evaluate parameters 1589 $.each( rules, function( rule, parameter ) { 1590 rules[ rule ] = typeof parameter === "function" && rule !== "normalizer" ? parameter( element ) : parameter; 1591 } ); 1592 1593 // Clean number parameters 1594 $.each( [ "minlength", "maxlength" ], function() { 1595 if ( rules[ this ] ) { 1596 rules[ this ] = Number( rules[ this ] ); 1597 } 1598 } ); 1599 $.each( [ "rangelength", "range" ], function() { 1600 var parts; 1601 if ( rules[ this ] ) { 1602 if ( Array.isArray( rules[ this ] ) ) { 1603 rules[ this ] = [ Number( rules[ this ][ 0 ] ), Number( rules[ this ][ 1 ] ) ]; 1604 } else if ( typeof rules[ this ] === "string" ) { 1605 parts = rules[ this ].replace( /[\[\]]/g, "" ).split( /[\s,]+/ ); 1606 rules[ this ] = [ Number( parts[ 0 ] ), Number( parts[ 1 ] ) ]; 1607 } 1608 } 1609 } ); 1610 1611 if ( $.validator.autoCreateRanges ) { 1612 1613 // Auto-create ranges 1614 if ( rules.min != null && rules.max != null ) { 1615 rules.range = [ rules.min, rules.max ]; 1616 delete rules.min; 1617 delete rules.max; 1618 } 1619 if ( rules.minlength != null && rules.maxlength != null ) { 1620 rules.rangelength = [ rules.minlength, rules.maxlength ]; 1621 delete rules.minlength; 1622 delete rules.maxlength; 1623 } 1624 } 1625 1626 return rules; 1627 }, 1628 1629 // Converts a simple string to a {string: true} rule, e.g., "required" to {required:true} 1630 normalizeRule: function( data ) { 1631 if ( typeof data === "string" ) { 1632 var transformed = {}; 1633 $.each( data.split( /\s/ ), function() { 1634 transformed[ this ] = true; 1635 } ); 1636 data = transformed; 1637 } 1638 return data; 1639 }, 1640 1641 // https://jqueryvalidation.org/jQuery.validator.addMethod/ 1642 addMethod: function( name, method, message ) { 1643 $.validator.methods[ name ] = method; 1644 $.validator.messages[ name ] = message !== undefined ? message : $.validator.messages[ name ]; 1645 if ( method.length < 3 ) { 1646 $.validator.addClassRules( name, $.validator.normalizeRule( name ) ); 1647 } 1648 }, 1649 1650 // https://jqueryvalidation.org/jQuery.validator.methods/ 1651 methods: { 1652 1653 // https://jqueryvalidation.org/required-method/ 1654 required: function( value, element, param ) { 1655 1656 // Check if dependency is met 1657 if ( !this.depend( param, element ) ) { 1658 return "dependency-mismatch"; 1659 } 1660 if ( element.nodeName.toLowerCase() === "select" ) { 1661 1662 // Could be an array for select-multiple or a string, both are fine this way 1663 var val = $( element ).val(); 1664 return val && val.length > 0; 1665 } 1666 if ( this.checkable( element ) ) { 1667 return this.getLength( value, element ) > 0; 1668 } 1669 return value !== undefined && value !== null && value.length > 0; 1670 }, 1671 1672 // https://jqueryvalidation.org/email-method/ 1673 email: function( value, element ) { 1674 1675 // From https://html.spec.whatwg.org/multipage/forms.html#valid-e-mail-address 1676 // Retrieved 2014-01-14 1677 // If you have a problem with this implementation, report a bug against the above spec 1678 // Or use custom methods to implement your own email validation 1679 return this.optional( element ) || /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test( value ); 1680 }, 1681 1682 // https://jqueryvalidation.org/url-method/ 1683 url: function( value, element ) { 1684 1685 // Copyright (c) 2010-2013 Diego Perini, MIT licensed 1686 // https://gist.github.com/dperini/729294 1687 // see also https://mathiasbynens.be/demo/url-regex 1688 // modified to allow protocol-relative URLs 1689 return this.optional( element ) || /^(?:(?:(?:https?|ftp):)?\/\/)(?:(?:[^\]\[?\/<~#`!@$^&*()+=}|:";',>{ ]|%[0-9A-Fa-f]{2})+(?::(?:[^\]\[?\/<~#`!@$^&*()+=}|:";',>{ ]|%[0-9A-Fa-f]{2})*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?[a-z0-9\u00a1-\uffff]\.)+(?:[a-z\u00a1-\uffff]{2,}\.?))(?::\d{2,5})?(?:[/?#]\S*)?$/i.test( value ); 1690 }, 1691 1692 // https://jqueryvalidation.org/date-method/ 1693 date: ( function() { 1694 var called = false; 1695 1696 return function( value, element ) { 1697 if ( !called ) { 1698 called = true; 1699 if ( this.settings.debug && window.console ) { 1700 console.warn( 1701 "The `date` method is deprecated and will be removed in version '2.0.0'.\n" + 1702 "Please don't use it, since it relies on the Date constructor, which\n" + 1703 "behaves very differently across browsers and locales. Use `dateISO`\n" + 1704 "instead or one of the locale specific methods in `localizations/`\n" + 1705 "and `additional-methods.js`." 1706 ); 1707 } 1708 } 1709 1710 return this.optional( element ) || !/Invalid|NaN/.test( new Date( value ).toString() ); 1711 }; 1712 }() ), 1713 1714 // https://jqueryvalidation.org/dateISO-method/ 1715 dateISO: function( value, element ) { 1716 return this.optional( element ) || /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test( value ); 1717 }, 1718 1719 // https://jqueryvalidation.org/number-method/ 1720 number: function( value, element ) { 1721 return this.optional( element ) || /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:-?\.\d+)?$/.test( value ); 1722 }, 1723 1724 // https://jqueryvalidation.org/digits-method/ 1725 digits: function( value, element ) { 1726 return this.optional( element ) || /^\d+$/.test( value ); 1727 }, 1728 1729 // https://jqueryvalidation.org/minlength-method/ 1730 minlength: function( value, element, param ) { 1731 var length = Array.isArray( value ) ? value.length : this.getLength( value, element ); 1732 return this.optional( element ) || length >= param; 1733 }, 1734 1735 // https://jqueryvalidation.org/maxlength-method/ 1736 maxlength: function( value, element, param ) { 1737 var length = Array.isArray( value ) ? value.length : this.getLength( value, element ); 1738 return this.optional( element ) || length <= param; 1739 }, 1740 1741 // https://jqueryvalidation.org/rangelength-method/ 1742 rangelength: function( value, element, param ) { 1743 var length = Array.isArray( value ) ? value.length : this.getLength( value, element ); 1744 return this.optional( element ) || ( length >= param[ 0 ] && length <= param[ 1 ] ); 1745 }, 1746 1747 // https://jqueryvalidation.org/min-method/ 1748 min: function( value, element, param ) { 1749 return this.optional( element ) || value >= param; 1750 }, 1751 1752 // https://jqueryvalidation.org/max-method/ 1753 max: function( value, element, param ) { 1754 return this.optional( element ) || value <= param; 1755 }, 1756 1757 // https://jqueryvalidation.org/range-method/ 1758 range: function( value, element, param ) { 1759 return this.optional( element ) || ( value >= param[ 0 ] && value <= param[ 1 ] ); 1760 }, 1761 1762 // https://jqueryvalidation.org/step-method/ 1763 step: function( value, element, param ) { 1764 var type = $( element ).attr( "type" ), 1765 errorMessage = "Step attribute on input type " + type + " is not supported.", 1766 supportedTypes = [ "text", "number", "range" ], 1767 re = new RegExp( "\\b" + type + "\\b" ), 1768 notSupported = type && !re.test( supportedTypes.join() ), 1769 decimalPlaces = function( num ) { 1770 var match = ( "" + num ).match( /(?:\.(\d+))?$/ ); 1771 if ( !match ) { 1772 return 0; 1773 } 1774 1775 // Number of digits right of decimal point. 1776 return match[ 1 ] ? match[ 1 ].length : 0; 1777 }, 1778 toInt = function( num ) { 1779 return Math.round( num * Math.pow( 10, decimals ) ); 1780 }, 1781 valid = true, 1782 decimals; 1783 1784 // Works only for text, number and range input types 1785 // TODO find a way to support input types date, datetime, datetime-local, month, time and week 1786 if ( notSupported ) { 1787 throw new Error( errorMessage ); 1788 } 1789 1790 decimals = decimalPlaces( param ); 1791 1792 // Value can't have too many decimals 1793 if ( decimalPlaces( value ) > decimals || toInt( value ) % toInt( param ) !== 0 ) { 1794 valid = false; 1795 } 1796 1797 return this.optional( element ) || valid; 1798 }, 1799 1800 // https://jqueryvalidation.org/equalTo-method/ 1801 equalTo: function( value, element, param ) { 1802 1803 // Bind to the blur event of the target in order to revalidate whenever the target field is updated 1804 var target = $( param ); 1805 if ( this.settings.onfocusout && target.not( ".validate-equalTo-blur" ).length ) { 1806 target.addClass( "validate-equalTo-blur" ).on( "blur.validate-equalTo", function() { 1807 $( element ).valid(); 1808 } ); 1809 } 1810 return value === target.val(); 1811 }, 1812 1813 // https://jqueryvalidation.org/remote-method/ 1814 remote: function( value, element, param, method ) { 1815 if ( this.optional( element ) ) { 1816 return "dependency-mismatch"; 1817 } 1818 1819 method = typeof method === "string" && method || "remote"; 1820 1821 var previous = this.previousValue( element, method ), 1822 validator, data, optionDataString; 1823 1824 if ( !this.settings.messages[ element.name ] ) { 1825 this.settings.messages[ element.name ] = {}; 1826 } 1827 previous.originalMessage = previous.originalMessage || this.settings.messages[ element.name ][ method ]; 1828 this.settings.messages[ element.name ][ method ] = previous.message; 1829 1830 param = typeof param === "string" && { url: param } || param; 1831 optionDataString = $.param( $.extend( { data: value }, param.data ) ); 1832 if ( previous.valid !== null && previous.old === optionDataString ) { 1833 return previous.valid; 1834 } 1835 1836 previous.old = optionDataString; 1837 previous.valid = null; 1838 validator = this; 1839 this.startRequest( element ); 1840 data = {}; 1841 data[ element.name ] = value; 1842 $.ajax( $.extend( true, { 1843 mode: "abort", 1844 port: this.elementAjaxPort( element ), 1845 dataType: "json", 1846 data: data, 1847 context: validator.currentForm, 1848 success: function( response ) { 1849 var valid = response === true || response === "true", 1850 errors, message, submitted; 1851 1852 validator.settings.messages[ element.name ][ method ] = previous.originalMessage; 1853 if ( valid ) { 1854 submitted = validator.formSubmitted; 1855 validator.toHide = validator.errorsFor( element ); 1856 validator.formSubmitted = submitted; 1857 validator.successList.push( element ); 1858 validator.invalid[ element.name ] = false; 1859 validator.showErrors(); 1860 } else { 1861 errors = {}; 1862 message = response || validator.defaultMessage( element, { method: method, parameters: value } ); 1863 errors[ element.name ] = previous.message = message; 1864 validator.invalid[ element.name ] = true; 1865 validator.showErrors( errors ); 1866 } 1867 previous.valid = valid; 1868 validator.stopRequest( element, valid ); 1869 } 1870 }, param ) ); 1871 return "pending"; 1872 } 1873 } 1874 1875} ); 1876 1877// Ajax mode: abort 1878// usage: $.ajax({ mode: "abort"[, port: "uniqueport"]}); 1879// $.ajaxAbort( port ); 1880// if mode:"abort" is used, the previous request on that port (port can be undefined) is aborted via XMLHttpRequest.abort() 1881 1882var pendingRequests = {}, 1883 ajax; 1884 1885// Use a prefilter if available (1.5+) 1886if ( $.ajaxPrefilter ) { 1887 $.ajaxPrefilter( function( settings, _, xhr ) { 1888 var port = settings.port; 1889 if ( settings.mode === "abort" ) { 1890 $.ajaxAbort( port ); 1891 pendingRequests[ port ] = xhr; 1892 } 1893 } ); 1894} else { 1895 1896 // Proxy ajax 1897 ajax = $.ajax; 1898 $.ajax = function( settings ) { 1899 var mode = ( "mode" in settings ? settings : $.ajaxSettings ).mode, 1900 port = ( "port" in settings ? settings : $.ajaxSettings ).port; 1901 if ( mode === "abort" ) { 1902 $.ajaxAbort( port ); 1903 pendingRequests[ port ] = ajax.apply( this, arguments ); 1904 return pendingRequests[ port ]; 1905 } 1906 return ajax.apply( this, arguments ); 1907 }; 1908} 1909 1910// Abort the previous request without sending a new one 1911$.ajaxAbort = function( port ) { 1912 if ( pendingRequests[ port ] ) { 1913 pendingRequests[ port ].abort(); 1914 delete pendingRequests[ port ]; 1915 } 1916}; 1917return $; 1918}));
1918 1919 1920/***/ }), 1921 1922/***/ 114: 1923/***/ (function(module, __webpack_exports__, __webpack_require__) { 1924 1925"use strict"; 1926/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__camelCase__ = __webpack_require__(115); 1927 1928 1929/** 1930 * DOM-based Routing 1931 * 1932 * Based on {@link http://goo.gl/EUTi53|Markup-based Unobtrusive Comprehensive DOM-ready Execution} by Paul Irish 1933 * 1934 * The routing fires all common scripts, followed by the page specific scripts. 1935 * Add additional events for more control over timing e.g. a finalize event 1936 */ 1937var Router = function Router(routes) { 1938 this.routes = routes; 1939}; 1940 1941/** 1942 * Fire Router events 1943 * @param {string} route DOM-based route derived from body classes (`<body class="...">`) 1944 * @param {string} [event] Events on the route. By default, `init` and `finalize` events are called. 1945 * @param {string} [arg] Any custom argument to be passed to the event. 1946 */ 1947Router.prototype.fire = function fire (route, event, arg) { 1948 if ( event === void 0 ) event = 'init'; 1949 1950 document.dispatchEvent(new CustomEvent('routed', { 1951 bubbles: true, 1952 detail: { 1953 route: route, 1954 fn: event, 1955 }, 1956 })); 1957 1958 var fire = route !== '' && this.routes[route] && typeof this.routes[route][event] === 'function'; 1959 if (fire) { 1960 this.routes[route][event](arg); 1961 } 1962}; 1963 1964/** 1965 * Automatically load and fire Router events 1966 * 1967 * Events are fired in the following order: 1968 ** common init 1969 ** page-specific init 1970 ** page-specific finalize 1971 ** common finalize 1972 */ 1973Router.prototype.loadEvents = function loadEvents () { 1974 var this$1 = this; 1975 1976 // Fire common init JS 1977 this.fire('common'); 1978 1979 // Fire page-specific init JS, and then finalize JS 1980 document.body.className 1981 .toLowerCase() 1982 .replace(/-/g, '_') 1983 .split(/\s+/) 1984 .map(__WEBPACK_IMPORTED_MODULE_0__camelCase__["a" /* default */]) 1985 .forEach(function (className) { 1986 this$1.fire(className); 1987 this$1.fire(className, 'finalize'); 1988 }); 1989 1990 // Fire common finalize JS 1991 this.fire('common', 'finalize'); 1992}; 1993 1994/* harmony default export */ __webpack_exports__["a"] = (Router); 1995 1996 1997/***/ }), 1998 1999/***/ 115: 2000/***/ (function(module, __webpack_exports__, __webpack_require__) { 2001 2002"use strict"; 2003/** 2004 * the most terrible camelizer on the internet, guaranteed! 2005 * @param {string} str String that isn't camel-case, e.g., CAMeL_CaSEiS-harD 2006 * @return {string} String converted to camel-case, e.g., camelCaseIsHard 2007 */ 2008/* harmony default export */ __webpack_exports__["a"] = (function (str) { return ("" + (str.charAt(0).toLowerCase()) + (str.replace(/[\W_]/g, '|').split('|') 2009 .map(function (part) { return ("" + (part.charAt(0).toUpperCase()) + (part.slice(1))); }) 2010 .join('') 2011 .slice(1))); });; 2012 2013 2014/***/ }), 2015 2016/***/ 116: 2017/***/ (function(module, __webpack_exports__, __webpack_require__) { 2018 2019"use strict"; 2020/* WEBPACK VAR INJECTION */(function($) {/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_swiper_swiper_bundle__ = __webpack_require__(4); 2021/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_swiper_swiper_bundle___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_swiper_swiper_bundle__); 2022/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_sweetalert2__ = __webpack_require__(117); 2023/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_sweetalert2___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_sweetalert2__); 2024/* eslint-disable no-unused-vars, no-undef */ 2025 2026// import Swiper bundle with all modules installed 2027 2028 2029// import Sweet Alert 2030 2031 2032/* harmony default export */ __webpack_exports__["a"] = ({ 2033 init: function init() { 2034 // JavaScript to be fired on all pages 2035 // init Swiper: 2036 // var swiper = new Swiper('.mySwiper', { 2037 // navigation: { 2038 // nextEl: '.swiper-button-next', 2039 // prevEl: '.swiper-button-prev', 2040 // }, 2041 // }); 2042 2043 // Submit Newsletter Subscription 2044 function submitSubscriptionForm() { 2045 var data = $('#subscribe-form').serialize(); 2046 2047 $.ajax({ 2048 url : 'https://sheetdb.io/api/v1/4nd2sj6g6kjt0', 2049 data : data, // form data 2050 dataType : 'json', // this data type allows us to receive objects from the server 2051 type : 'POST', 2052 beforeSend : function(xhr){ 2053 $('#subscribe-form').attr('disabled'); 2054 $('#subscribe-form :input[type="submit"]').prop('disabled', true); 2055 }, 2056 success : function( data ){ 2057 $('#subscribe-form :input[type="submit"]').prop('disabled', false); 2058 $('#subscribe-notice').addClass('hidden'); 2059 $('#success-alert').removeClass('hidden'); 2060 setTimeout(function() { 2061 $('#subscribe-form :input[name="email"]').val(''); 2062 $('#success-alert').addClass('hidden'); 2063 $('#subscribe-notice').removeClass('hidden'); 2064 }, 3000); 2065 }, 2066 }); 2067 } 2068 2069 // Alert Newsletter Privacy Policy 2070 function showPrivacyPolicyAlert() { 2071 __WEBPACK_IMPORTED_MODULE_1_sweetalert2___default.a.fire({ 2072 title: 'At Plastics Europe we take privacy seriously', 2073 html: 'We collect your email address to send you our newsletter, and we do so on the basis of your consent. To know more on the way
2073we process your personal data, take a look at our <a href="https://legacy.plasticseurope.org/download_file/4384/0" target="_blank" style="font-weight:600;">Privacy Notice</a>. You can withdraw your consent at any time by clicking on the unsubscribe link at the bottom of our newsletter emails. If you have any questions about how we process your personal data, please contact us at <a href="mailto:[email protected]" style="font-weight:600;">[email protected]</a>', 2074 confirmButtonText: langvars.messagekey, 2075 buttonsStyling: false, 2076 }).then(function (result) { 2077 if (result.isConfirmed) { 2078 submitSubscriptionForm(); 2079 } 2080 }); 2081 } 2082 2083 $('#subscribe-form').validate({ 2084 rules: { 2085 shortdescription: 'required', 2086 sourceurl: 'required', 2087 }, 2088 messages: { 2089 shortdescription: 'Enter a short description. ', 2090 sourceurl: 'Enter a Source URL. ', 2091 }, 2092 errorElement: 'span', 2093 wrapper: 'div', 2094 errorLabelContainer: '.message', 2095 submitHandler: function(form) { 2096 showPrivacyPolicyAlert(); 2097 }, 2098 }); 2099 2100 // Region Switcher 2101 $('.region-switcher').on('change', function() { 2102 var region = $(this).val(); 2103 console.log(region); 2104 window.location.pathname = ('/' + region); 2105 console.log(window.location); 2106 }) 2107 2108 $( '.menu-item.has-submenu' ).each(function() { 2109 $( this ).on( 'mouseenter', function() { 2110 $(this).find('.submenu').addClass('is-open'); 2111 $(this).find('.submenu .content').removeClass('hidden'); 2112 } ); 2113 $( this ).on( 'mouseleave', function() { 2114 $(this).find('.submenu').removeClass('is-open'); 2115 $(this).find('.submenu .content').addClass('hidden'); 2116 } ); 2117 }); 2118 2119 // Mobile menu toggle 2120 $('.menu-toggle').on('touchstart click', function(e) { 2121 var target = $(this).data('target'); 2122 console.log(target); 2123 $(target).toggleClass('hidden'); 2124 $(this).find('svg').toggleClass('block'); 2125 $(this).find('svg').toggleClass('hidden'); 2126 e.preventDefault(); 2127 }); 2128 2129 // Mobile menu levels 2130 $('.open-submenu').on('touchstart click', function(e) { 2131 var target = $(this).data('target'); 2132 console.log(target); 2133 $(target).addClass('open'); 2134 e.preventDefault(); 2135 }); 2136 2137 $('.close-submenu').on('touchstart click', function(e) { 2138 var target = $(this).data('target'); 2139 console.log(target); 2140 $(target).removeClass('open'); 2141 e.preventDefault(); 2142 }); 2143 2144 // Search 2145 // Disable enter on Search 2146 function disableEnterKey(e) { 2147 var keyCode = e.keyCode || e.which; 2148 if (keyCode === 13) { 2149 e.preventDefault(); 2150 return false; 2151 } 2152 } 2153 2154 function showCloseIcon(elem) { 2155 if ($(elem).parent().find('.close-icon').hasClass('hidden')) { 2156 $(elem).parent().find('.close-icon').removeClass('hidden'); 2157 $(elem).parent().find('.search-icon').addClass('hidden'); 2158 } 2159 } 2160 2161 function showSearchIcon(elem) { 2162 if ($(elem).find('.search-icon').hasClass('hidden')) { 2163 $(elem).find('.search-icon').removeClass('hidden'); 2164 $(elem).find('.close-icon').addClass('hidden'); 2165 } 2166 } 2167 2168 function openSearchModal(){ 2169 $('#searchModal').removeClass('hidden'); 2170 $('body').addClass('overflow-hidden'); 2171 $('#searchModal').addClass('block'); 2172 $('#searchModal .search-input').val(''); 2173 $('#searchModal .search-input').focus(); 2174 } 2175 2176 function closeSearchModal(){ 2177 $('#searchModal .search-input').val(''); 2178 $('#searchModal').addClass('hidden'); 2179 $('body').removeClass('overflow-hidden'); 2180 $('#searchModal').removeClass('block'); 2181 $('#search-modal .search-input').val(''); 2182 // clear search field 2183 if ($('#searchModal .search-icon').hasClass('hidden')) { 2184 $('#searchModal .search-icon').removeClass('hidden'); 2185 $('#searchModal .close-icon').addClass('hidden'); 2186 } 2187 } 2188 2189 $('.search-form .close-icon').on('click', function () { 2190 var elem = $(this).parent(); 2191 $(this).parent().find('.search-input').val(''); 2192 showSearchIcon(elem); 2193 }) 2194 2195 function changeSearchCat(){
2196 // clear search field 2197 $('#search-field').val(''); 2198 var type = $('#resource-type').val(); 2199 $('#term-id').val(type); 2200 } 2201 2202 $('.search-input').on('keypress', function(e) { 2203 var elem = $(this); 2204 disableEnterKey(e); 2205 showCloseIcon(elem); 2206 }); 2207 2208 $('#open-search').on('click', function () { 2209 openSearchModal(); 2210 }) 2211 2212 $('.modalOverlay').on('click', function () { 2213 closeSearchModal(); 2214 }) 2215 2216 $('#resource-type').on('change', function () { 2217 changeSearchCat(); 2218 }) 2219 2220 var swiper = new __WEBPACK_IMPORTED_MODULE_0_swiper_swiper_bundle___default.a('.mySwiper', { 2221 autoHeight: true, 2222 grabCursor: true, 2223 // effect: 'creative', 2224 // creativeEffect: { 2225 // prev: { 2226 // shadow: true, 2227 // translate: [0, 0, -400], 2228 // }, 2229 // next: { 2230 // translate: ['100%', 0, 0], 2231 // }, 2232 // }, 2233 navigation: { 2234 nextEl: '.swiper-button-next', 2235 prevEl: '.swiper-button-prev', 2236 }, 2237 }); 2238 2239 var postsSwiperELS = document.querySelectorAll('.postsSwiper'); 2240 2241 var postsSwipers = new Map(); 2242 2243 function setupPostsSwiper() { 2244 if (!postsSwiperELS || postsSwiperELS.length === 0) { return; } 2245 2246 var isMobile = window.matchMedia('(max-width: 1024px)').matches; 2247 2248 if (isMobile) { 2249 postsSwiperELS.forEach(function(wrapperEl) { 2250 if (!postsSwipers.has(wrapperEl)) { 2251 wrapperEl.querySelectorAll('li.wp-block-post').forEach(function(item) { 2252 item.classList.add('swiper-slide', 'h-auto'); 2253 }); 2254 2255 var instance = new __WEBPACK_IMPORTED_MODULE_0_swiper_swiper_bundle___default.a(wrapperEl, { 2256 slidesPerView: 1.4, 2257 spaceBetween: 24, 2258 breakpoints: { 2259 800: { 2260 slidesPerView: 3.3, 2261 }, 2262 }, 2263 }); 2264 2265 postsSwipers.set(wrapperEl, instance); 2266 } 2267 }); 2268 } else { 2269 postsSwipers.forEach(function(instance, wrapperEl) { 2270 instance.destroy(true, true); 2271 postsSwipers.delete(wrapperEl); 2272 }); 2273 } 2274 } 2275 2276 setupPostsSwiper(); 2277 window.addEventListener('resize', setupPostsSwiper); 2278 2279 var groupSwiper = new __WEBPACK_IMPORTED_MODULE_0_swiper_swiper_bundle___default.a('.groupSwiper', { 2280 // slidesPerView: 2, 2281 // spaceBetween: 30, 2282 // slidesPerGroup: 2, 2283 // loop: true, 2284 // loopFillGroupWithBlank: true, 2285 pagination: { 2286 el: '.swiper-pagination', 2287 clickable: true, 2288 }, 2289 navigation: { 2290 nextEl: '.swiper-arrow-next', 2291 prevEl: '.swiper-arrow-prev', 2292 }, 2293 breakpoints: { 2294 1024: { 2295 slidesPerView: 2, 2296 spaceBetween: 30, 2297 slidesPerGroup: 2, 2298 }, 2299 }, 2300 }); 2301 2302 // Suggested block and .wp-block-post items hover 2303 $('.suggested-posts .grid-item, .wp-block-post').on('mouseenter', function() { 2304 var $card = $(this); 2305 var isPost = $card.hasClass('wp-block-post');
2306 var $overlay = $card.find('.overlay'); 2307 2308 if (isPost) { 2309 $overlay.removeClass('bg-white translate-y-48 md:translate-y-48 translate-y-1/2 h-1/2') 2310 .addClass('translate-y-0 bg-sky-900 h-full text-white'); 2311 2312 if ($overlay.length) { 2313 // 1) make links inside overlay white 2314 $overlay.find('a').addClass('text-white'); 2315 2316 // 2) get the URL from the title link (try inside overlay first, fallback to global title) 2317 var href = 2318 $card.find('.overlay .wp-block-post-title > a').attr('href') || 2319 $card.find('.wp-block-post-title > a').attr('href') || 2320 null; 2321 2322 if (href) { 2323 var alreadyWrapped = $overlay.parent().is('a.overlay-link'); 2324 var hasInnerLinks = $overlay.find('a').length > 0; 2325 2326 if (!alreadyWrapped && !hasInnerLinks) { 2327 // No nested anchors risk â wrap once 2328 $overlay.wrap($('<a/>', { class: 'overlay-link', href: href })); 2329 } else { 2330 // Overlay already contains anchors â don't nest <a>, 2331 // just make overlay act like a link when clicking non-link areas 2332 $overlay.css('cursor', 'pointer') 2333 .off('click.overlay') 2334 .on('click.overlay', function (e) { 2335 if (!$(e.target).closest('a').length) { 2336 window.location.href = href; 2337 } 2338 }); 2339 } 2340 } 2341 } 2342 } else { 2343 var bgColor = $card.find('.overlay').data('overlay'); 2344 $overlay.removeClass(bgColor).removeClass('translate-y-1/2 opacity-80') 2345 .addClass('translate-y-0 opacity-100 bg-mist-900'); 2346 } 2347 2348 $(this).find('.details').removeClass('translate-y-1/2 text-white'); 2349 $(this).find('.details').addClass('translate-y-0'); 2350 2351 $(this).find('.details > div').removeClass('h-1/2'); 2352 $(this).find('.details > div').addClass('h-full'); 2353 2354 $(this).find('.details .excerpt, .post-excerpt').removeClass('hidden opacity-0'); 2355 $(this).find('.details .excerpt, .post-excerpt').addClass('line-clamp-4 opacity-100'); 2356 }); 2357 2358 $('.suggested-posts .grid-item, .wp-block-post').on('mouseleave', function() { 2359 var $card = $(this); 2360 var isPost = $card.hasClass('wp-block-post');
2361 var $overlay = $card.find('.overlay'); 2362 2363 if (isPost) { 2364 $overlay.addClass('bg-white translate-y-48 md:translate-y-48 translate-y-1/2 h-1/2') 2365 .removeClass('translate-y-0 bg-sky-900 h-full text-white'); 2366 if ($overlay.length) { 2367 $overlay.find('a').removeClass('text-white'); 2368 } 2369 } else { 2370 var bgColor = $card.find('.overlay').data('overlay'); 2371 $overlay.addClass(bgColor).addClass('translate-y-1/2 opacity-80') 2372 .removeClass('translate-y-0 opacity-100 bg-mist-900'); 2373 } 2374 2375 $(this).find('.details').removeClass('translate-y-0'); 2376 $(this).find('.details').addClass('translate-y-1/2 text-white'); 2377 2378 $(this).find('.details > div').removeClass('h-full'); 2379 $(this).find('.details > div').addClass('h-1/2'); 2380 2381 $(this).find('.details .excerpt, .post-excerpt').removeClass('line-clamp-4 opacity-100'); 2382 $(this).find('.details .excerpt, .post-excerpt').addClass('hidden opacity-0'); 2383 }); 2384 2385 }, 2386 finalize: function finalize() { 2387 // JavaScript to be fired on all pages, after page specific JS is fired 2388 }, 2389}); 2390 2391/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(3))) 2392 2393/***/ }), 2394 2395/***/ 117: 2396/***/ (function(module, exports, __webpack_require__) { 2397 2398/*! 2399* sweetalert2 v11.26.24 2400* Released under the MIT License. 2401*/ 2402(function (global, factory) { 2403 true
vendor: 11,723 bytes, lines 2403-2799
2403 ? module.exports = factory() : 2404 typeof define === 'function' && define.amd ? define(factory) : 2405 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Sweetalert2 = factory()); 2406})(this, (function () { 'use strict'; 2407 2408 function _assertClassBrand(e, t, n) { 2409 if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; 2410 throw new TypeError("Private element is not present on this object"); 2411 } 2412 function _checkPrivateRedeclaration(e, t) { 2413 if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); 2414 } 2415 function _classPrivateFieldGet2(s, a) { 2416 return s.get(_assertClassBrand(s, a)); 2417 } 2418 function _classPrivateFieldInitSpec(e, t, a) { 2419 _checkPrivateRedeclaration(e, t), t.set(e, a); 2420 } 2421 function _classPrivateFieldSet2(s, a, r) { 2422 return s.set(_assertClassBrand(s, a), r), r; 2423 } 2424 2425 const RESTORE_FOCUS_TIMEOUT = 100; 2426 2427 /** @type {GlobalState} */ 2428 const globalState = {}; 2429 const focusPreviousActiveElement = () => { 2430 if (globalState.previousActiveElement instanceof HTMLElement) { 2431 globalState.previousActiveElement.focus(); 2432 globalState.previousActiveElement = null; 2433 } else if (document.body) { 2434 document.body.focus(); 2435 } 2436 }; 2437 2438 /** 2439 * Restore previous active (focused) element 2440 * 2441 * @param {boolean} returnFocus 2442 * @returns {Promise<void>} 2443 */ 2444 const restoreActiveElement = returnFocus => { 2445 return new Promise(resolve => { 2446 if (!returnFocus) { 2447 return resolve(); 2448 } 2449 const x = window.scrollX; 2450 const y = window.scrollY; 2451 globalState.restoreFocusTimeout = setTimeout(() => { 2452 focusPreviousActiveElement(); 2453 resolve(); 2454 }, RESTORE_FOCUS_TIMEOUT); // issues/900 2455 2456 window.scrollTo(x, y); 2457 }); 2458 }; 2459 2460 const swalPrefix = 'swal2-'; 2461 2462 /** 2463 * @typedef {Record<SwalClass, string>} SwalClasses 2464 */ 2465 2466 /** 2467 * @typedef {'success' | 'warning' | 'info' | 'question' | 'error'} SwalIcon 2468 * @typedef {Record<SwalIcon, string>} SwalIcons 2469 */ 2470 2471 /** @type {SwalClass[]} */ 2472 const classNames = ['container', 'shown', 'height-auto', 'iosfix', 'popup', 'modal', 'no-backdrop', 'no-transition', 'toast', 'toast-shown', 'show', 'hide', 'close', 'title', 'html-container', 'actions', 'confirm', 'deny', 'cancel', 'footer', 'icon', 'icon-content', 'image', 'input', 'file', 'range', 'select', 'radio', 'checkbox', 'label', 'textarea', 'inputerror', 'input-label', 'validation-message', 'progress-steps', 'active-progress-step', 'progress-step', 'progress-step-line', 'loader', 'loading', 'styled', 'top', 'top-start', 'top-end', 'top-left', 'top-right', 'center', 'center-start', 'center-end', 'center-left', 'center-right', 'bottom', 'bottom-start', 'bottom-end', 'bottom-left', 'bottom-right', 'grow-row', 'grow-column', 'grow-fullscreen', 'rtl', 'timer-progress-bar', 'timer-progress-bar-container', 'scrollbar-measure', 'icon-success', 'icon-warning', 'icon-info', 'icon-question', 'icon-error', 'draggable', 'dragging']; 2473 const swalClasses = classNames.reduce((acc, className) => { 2474 acc[className] = swalPrefix + className; 2475 return acc; 2476 }, /** @type {SwalClasses} */{}); 2477 2478 /** @type {SwalIcon[]} */ 2479 const icons = ['success', 'warning', 'info', 'question', 'error']; 2480 const iconTypes = icons.reduce((acc, icon) => { 2481 acc[icon] = swalPrefix + icon; 2482 return acc; 2483 }, /** @type {SwalIcons} */{}); 2484 2485 const consolePrefix = 'SweetAlert2:'; 2486 2487 /** 2488 * Capitalize the first letter of a string 2489 * 2490 * @param {string} str 2491 * @returns {string} 2492 */ 2493 const capitalizeFirstLetter = str => str.charAt(0).toUpperCase() + str.slice(1); 2494 2495 /** 2496 * Standardize console warnings 2497 * 2498 * @param {string | string[]} message 2499 */ 2500 const warn = message => { 2501 console.warn(`${consolePrefix} ${typeof message === 'object' ? message.join(' ') : message}`); 2502 }; 2503 2504 /** 2505 * Standardize console errors 2506 * 2507 * @param {string} message 2508 */ 2509 const error = message => { 2510 console.error(`${consolePrefix} ${message}`); 2511 }; 2512 2513 /** 2514 * Private global state for `warnOnce` 2515 * 2516 * @type {string[]} 2517 * @private 2518 */ 2519 const previousWarnOnceMessages = []; 2520 2521 /** 2522 * Show a console warning, but only if it hasn't already been shown 2523 * 2524 * @param {string} message 2525 */ 2526 const warnOnce = message => { 2527 if (!previousWarnOnceMessages.includes(message)) { 2528 previousWarnOnceMessages.push(message); 2529 warn(message); 2530 } 2531 }; 2532 2533 /** 2534 * Show a one-time console warning about deprecated params/methods 2535 * 2536 * @param {string} deprecatedParam 2537 * @param {string?} useInstead 2538 */ 2539 const warnAboutDeprecation = (deprecatedParam, useInstead = null) => { 2540 warnOnce(`"${deprecatedParam}" is deprecated and will be removed in the next major release.${useInstead ? ` Use "${useInstead}" instead.` : ''}`); 2541 }; 2542 2543 /** 2544 * If `arg` is a function, call it (with no arguments or context) and return the result. 2545 * Otherwise, just pass the value through 2546 * 2547 * @param {(() => *) | *} arg 2548 * @returns {*} 2549 */ 2550 const callIfFunction = arg => typeof arg === 'function' ? arg() : arg; 2551 2552 /** 2553 * @param {*} arg 2554 * @returns {boolean} 2555 */ 2556 const hasToPromiseFn = arg => arg && typeof arg.toPromise === 'function'; 2557 2558 /** 2559 * @param {*} arg 2560 * @returns {Promise<*>} 2561 */ 2562 const asPromise = arg => hasToPromiseFn(arg) ? arg.toPromise() : Promise.resolve(arg); 2563 2564 /** 2565 * @param {*} arg 2566 * @returns {boolean} 2567 */ 2568 const isPromise = arg => arg && Promise.resolve(arg) === arg; 2569 2570 /** 2571 * @returns {boolean} 2572 */ 2573 const isFirefox = () => navigator.userAgent.includes('Firefox'); 2574 2575 /** 2576 * Gets the popup container which contains the backdrop and the popup itself. 2577 * 2578 * @returns {HTMLElement | null} 2579 */ 2580 const getContainer = () => document.body.querySelector(`.${swalClasses.container}`); 2581 2582 /** 2583 * @param {string} selectorString 2584 * @returns {HTMLElement | null} 2585 */ 2586 const elementBySelector = selectorString => { 2587 const container = getContainer(); 2588 return container ? container.querySelector(selectorString) : null; 2589 }; 2590 2591 /** 2592 * @param {string} className 2593 * @returns {HTMLElement | null} 2594 */ 2595 const elementByClass = className => { 2596 return elementBySelector(`.${className}`); 2597 }; 2598 2599 /** 2600 * @returns {HTMLElement | null} 2601 */ 2602 const getPopup = () => elementByClass(swalClasses.popup); 2603 2604 /** 2605 * @returns {HTMLElement | null} 2606 */ 2607 const getIcon = () => elementByClass(swalClasses.icon); 2608 2609 /** 2610 * @returns {HTMLElement | null} 2611 */ 2612 const getIconContent = () => elementByClass(swalClasses['icon-content']); 2613 2614 /** 2615 * @returns {HTMLElement | null} 2616 */ 2617 const getTitle = () => elementByClass(swalClasses.title); 2618 2619 /** 2620 * @returns {HTMLElement | null} 2621 */ 2622 const getHtmlContainer = () => elementByClass(swalClasses['html-container']); 2623 2624 /** 2625 * @returns {HTMLElement | null} 2626 */ 2627 const getImage = () => elementByClass(swalClasses.image); 2628 2629 /** 2630 * @returns {HTMLElement | null} 2631 */ 2632 const getProgressSteps = () => elementByClass(swalClasses['progress-steps']); 2633 2634 /** 2635 * @returns {HTMLElement | null} 2636 */ 2637 const getValidationMessage = () => elementByClass(swalClasses['validation-message']); 2638 2639 /** 2640 * @returns {HTMLButtonElement | null} 2641 */ 2642 const getConfirmButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.confirm}`)); 2643 2644 /** 2645 * @returns {HTMLButtonElement | null} 2646 */ 2647 const getCancelButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.cancel}`)); 2648 2649 /** 2650 * @returns {HTMLButtonElement | null} 2651 */ 2652 const getDenyButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.deny}`)); 2653 2654 /** 2655 * @returns {HTMLElement | null} 2656 */ 2657 const getInputLabel = () => elementByClass(swalClasses['input-label']); 2658 2659 /** 2660 * @returns {HTMLElement | null} 2661 */ 2662 const getLoader = () => elementBySelector(`.${swalClasses.loader}`); 2663 2664 /** 2665 * @returns {HTMLElement | null} 2666 */ 2667 const getActions = () => elementByClass(swalClasses.actions); 2668 2669 /** 2670 * @returns {HTMLElement | null} 2671 */ 2672 const getFooter = () => elementByClass(swalClasses.footer); 2673 2674 /** 2675 * @returns {HTMLElement | null} 2676 */ 2677 const getTimerProgressBar = () => elementByClass(swalClasses['timer-progress-bar']); 2678 2679 /** 2680 * @returns {HTMLElement | null} 2681 */ 2682 const getCloseButton = () => elementByClass(swalClasses.close); 2683 2684 // https://github.com/jkup/focusable/blob/master/index.js 2685 const focusable = ` 2686 a[href], 2687 area[href], 2688 input:not([disabled]), 2689 select:not([disabled]), 2690 textarea:not([disabled]), 2691 button:not([disabled]), 2692 iframe, 2693 object, 2694 embed, 2695 [tabindex="0"], 2696 [contenteditable], 2697 audio[controls], 2698 video[controls], 2699 summary 2700`; 2701 /** 2702 * @returns {HTMLElement[]} 2703 */ 2704 const getFocusableElements = () => { 2705 const popup = getPopup(); 2706 if (!popup) { 2707 return []; 2708 } 2709 /** @type {NodeListOf<HTMLElement>} */ 2710 const focusableElementsWithTabindex = popup.querySelectorAll('[tabindex]:not([tabindex="-1"]):not([tabindex="0"])'); 2711 const focusableElementsWithTabindexSorted = Array.from(focusableElementsWithTabindex) 2712 // sort according to tabindex 2713 .sort((a, b) => { 2714 const tabindexA = parseInt(a.getAttribute('tabindex') || '0'); 2715 const tabindexB = parseInt(b.getAttribute('tabindex') || '0'); 2716 if (tabindexA > tabindexB) { 2717 return 1; 2718 } else if (tabindexA < tabindexB) { 2719 return -1; 2720 } 2721 return 0; 2722 }); 2723 2724 /** @type {NodeListOf<HTMLElement>} */ 2725 const otherFocusableElements = popup.querySelectorAll(focusable); 2726 const otherFocusableElementsFiltered = Array.from(otherFocusableElements).filter(el => el.getAttribute('tabindex') !== '-1'); 2727 return [...new Set(focusableElementsWithTabindexSorted.concat(otherFocusableElementsFiltered))].filter(el => isVisible$1(el)); 2728 }; 2729 2730 /** 2731 * @returns {boolean} 2732 */ 2733 const isModal = () => { 2734 return hasClass(document.body, swalClasses.shown) && !hasClass(document.body, swalClasses['toast-shown']) && !hasClass(document.body, swalClasses['no-backdrop']); 2735 }; 2736 2737 /** 2738 * @returns {boolean} 2739 */ 2740 const isToast = () => { 2741 const popup = getPopup(); 2742 if (!popup) { 2743 return false; 2744 } 2745 return hasClass(popup, swalClasses.toast); 2746 }; 2747 2748 /** 2749 * @returns {boolean} 2750 */ 2751 const isLoading = () => { 2752 const popup = getPopup(); 2753 if (!popup) { 2754 return false; 2755 } 2756 return popup.hasAttribute('data-loading'); 2757 }; 2758 2759 /** 2760 * Securely set innerHTML of an element 2761 * https://github.com/sweetalert2/sweetalert2/issues/1926 2762 * 2763 * @param {HTMLElement} elem 2764 * @param {string} html 2765 */ 2766 const setInnerHtml = (elem, html) => { 2767 elem.textContent = ''; 2768 if (html) { 2769 const parser = new DOMParser(); 2770 const parsed = parser.parseFromString(html, `text/html`); 2771 const head = parsed.querySelector('head'); 2772 if (head) { 2773 Array.from(head.childNodes).forEach(child => { 2774 elem.appendChild(child); 2775 }); 2776 } 2777 const body = parsed.querySelector('body'); 2778 if (body) { 2779 Array.from(body.childNodes).forEach(child => { 2780 if (child instanceof HTMLVideoElement || child instanceof HTMLAudioElement) { 2781 elem.appendChild(child.cloneNode(true)); // https://github.com/sweetalert2/sweetalert2/issues/2507 2782 } else { 2783 elem.appendChild(child); 2784 } 2785 }); 2786 } 2787 } 2788 }; 2789 2790 /** 2791 * @param {HTMLElement} elem 2792 * @param {string} className 2793 * @returns {boolean} 2794 */ 2795 const hasClass = (elem, className) => { 2796 if (!className) { 2797 return false; 2798 } 2799
vendor: 2,998 bytes, lines 2799-2890
2799const classList = className.split(/\s+/); 2800 for (let i = 0; i < classList.length; i++) { 2801 if (!elem.classList.contains(classList[i])) { 2802 return false; 2803 } 2804 } 2805 return true; 2806 }; 2807 2808 /** 2809 * @param {HTMLElement} elem 2810 * @param {SweetAlertOptions} params 2811 */ 2812 const removeCustomClasses = (elem, params) => { 2813 Array.from(elem.classList).forEach(className => { 2814 if (!Object.values(swalClasses).includes(className) && !Object.values(iconTypes).includes(className) && !Object.values(params.showClass || {}).includes(className)) { 2815 elem.classList.remove(className); 2816 } 2817 }); 2818 }; 2819 2820 /** 2821 * @param {HTMLElement} elem 2822 * @param {SweetAlertOptions} params 2823 * @param {string} className 2824 */ 2825 const applyCustomClass = (elem, params, className) => { 2826 removeCustomClasses(elem, params); 2827 if (!params.customClass) { 2828 return; 2829 } 2830 const customClass = params.customClass[(/** @type {keyof SweetAlertCustomClass} */className)]; 2831 if (!customClass) { 2832 return; 2833 } 2834 if (typeof customClass !== 'string' && !customClass.forEach) { 2835 warn(`Invalid type of customClass.${className}! Expected string or iterable object, got "${typeof customClass}"`); 2836 return; 2837 } 2838 addClass(elem, customClass); 2839 }; 2840 2841 /** 2842 * @param {HTMLElement} popup 2843 * @param {import('./renderers/renderInput').InputClass | SweetAlertInput} inputClass 2844 * @returns {HTMLInputElement | null} 2845 */ 2846 const getInput$1 = (popup, inputClass) => { 2847 if (!inputClass) { 2848 return null; 2849 } 2850 switch (inputClass) { 2851 case 'select': 2852 case 'textarea': 2853 case 'file': 2854 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses[inputClass]}`); 2855 case 'checkbox': 2856 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.checkbox} input`); 2857 case 'radio': 2858 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:checked`) || popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:first-child`); 2859 case 'range': 2860 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.range} input`); 2861 default: 2862 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.input}`); 2863 } 2864 }; 2865 2866 /** 2867 * @param {HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement} input 2868 */ 2869 const focusInput = input => { 2870 input.focus(); 2871 2872 // place cursor at end of text in text input 2873 if (input.type !== 'file') { 2874 // http://stackoverflow.com/a/2345915 2875 const val = input.value; 2876 input.value = ''; 2877 input.value = val; 2878 } 2879 }; 2880 2881 /** 2882 * @param {HTMLElement | HTMLElement[] | null} target 2883 * @param {string | string[] | readonly string[] | undefined} classList 2884 * @param {boolean} condition 2885 */ 2886 const toggleClass = (target, classList, condition) => { 2887 if (!target || !classList) { 2888 return; 2889 } 2890 const classes = typeof classList === 'string' ? classList.split(/\s+/).filter(
2890Boolean) : classList; 2891 const targets = Array.isArray(target) ? target : [target]; 2892 targets.forEach(elem => { 2893 classes.forEach(className => { 2894 if (condition) { 2895 elem.classList.add(className); 2896 } else { 2897 elem.classList.remove(className); 2898 } 2899 }); 2900 }); 2901 }; 2902 2903 /** 2904 * @param {HTMLElement | HTMLElement[] | null} target 2905 * @param {string | string[] | readonly string[] | undefined} classList 2906 */ 2907 const addClass = (target, classList) => { 2908 toggleClass(target, classList, true); 2909 }; 2910 2911 /** 2912 * @param {HTMLElement | HTMLElement[] | null} target 2913 * @param {string | string[] | readonly string[] | undefined} classList 2914 */ 2915 const removeClass = (target, classList) => { 2916 toggleClass(target, classList, false); 2917 }; 2918 2919 /** 2920 * Get direct child of an element by class name 2921 * 2922 * @param {HTMLElement} elem 2923 * @param {string} className 2924 * @returns {HTMLElement | undefined} 2925 */ 2926 const getDirectChildByClass = (elem, className) => { 2927 const children = Array.from(elem.children); 2928 for (let i = 0; i < children.length; i++) { 2929 const child = children[i]; 2930 if (child instanceof HTMLElement && hasClass(child, className)) { 2931 return child; 2932 } 2933 } 2934 }
vendor: 19,820 bytes, lines 2934-3594
2934; 2935 2936 /** 2937 * @param {HTMLElement} elem 2938 * @param {string} property 2939 * @param {string | number | null | undefined} value 2940 */ 2941 const applyNumericalStyle = (elem, property, value) => { 2942 if (value === `${parseInt(`${value}`)}`) { 2943 value = parseInt(value); 2944 } 2945 if (value || value === 0) { 2946 elem.style.setProperty(property, typeof value === 'number' ? `${value}px` : (/** @type {string} */value)); 2947 } else { 2948 elem.style.removeProperty(property); 2949 } 2950 }; 2951 2952 /** 2953 * @param {HTMLElement | null} elem 2954 * @param {string} display 2955 */ 2956 const show = (elem, display = 'flex') => { 2957 if (!elem) { 2958 return; 2959 } 2960 elem.style.display = display; 2961 }; 2962 2963 /** 2964 * @param {HTMLElement | null} elem 2965 */ 2966 const hide = elem => { 2967 if (!elem) { 2968 return; 2969 } 2970 elem.style.display = 'none'; 2971 }; 2972 2973 /** 2974 * @param {HTMLElement | null} elem 2975 * @param {string} display 2976 */ 2977 const showWhenInnerHtmlPresent = (elem, display = 'block') => { 2978 if (!elem) { 2979 return; 2980 } 2981 new MutationObserver(() => { 2982 toggle(elem, elem.innerHTML, display); 2983 }).observe(elem, { 2984 childList: true, 2985 subtree: true 2986 }); 2987 }; 2988 2989 /** 2990 * @param {HTMLElement} parent 2991 * @param {string} selector 2992 * @param {string} property 2993 * @param {string} value 2994 */ 2995 const setStyle = (parent, selector, property, value) => { 2996 /** @type {HTMLElement | null} */ 2997 const el = parent.querySelector(selector); 2998 if (el) { 2999 el.style.setProperty(property, value); 3000 } 3001 }; 3002 3003 /** 3004 * @param {HTMLElement} elem 3005 * @param {boolean | string | null | undefined} condition 3006 * @param {string} display 3007 */ 3008 const toggle = (elem, condition, display = 'flex') => { 3009 if (condition) { 3010 show(elem, display); 3011 } else { 3012 hide(elem); 3013 } 3014 }; 3015 3016 /** 3017 * borrowed from jquery $(elem).is(':visible') implementation 3018 * 3019 * @param {HTMLElement | null} elem 3020 * @returns {boolean} 3021 */ 3022 const isVisible$1 = elem => Boolean(elem && (elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length)); 3023 3024 /** 3025 * @returns {boolean} 3026 */ 3027 const allButtonsAreHidden = () => !isVisible$1(getConfirmButton()) && !isVisible$1(getDenyButton()) && !isVisible$1(getCancelButton()); 3028 3029 /** 3030 * @param {HTMLElement} elem 3031 * @returns {boolean} 3032 */ 3033 const isScrollable = elem => Boolean(elem.scrollHeight > elem.clientHeight); 3034 3035 /** 3036 * @param {HTMLElement} element 3037 * @param {HTMLElement} stopElement 3038 * @returns {boolean} 3039 */ 3040 const selfOrParentIsScrollable = (element, stopElement) => { 3041 let parent = /** @type {HTMLElement | null} */element; 3042 while (parent && parent !== stopElement) { 3043 if (isScrollable(parent)) { 3044 return true; 3045 } 3046 parent = parent.parentElement; 3047 } 3048 return false; 3049 }; 3050 3051 /** 3052 * borrowed from https://stackoverflow.com/a/46352119 3053 * 3054 * @param {HTMLElement} elem 3055 * @returns {boolean} 3056 */ 3057 const hasCssAnimation = elem => { 3058 const style = window.getComputedStyle(elem); 3059 const animDuration = parseFloat(style.getPropertyValue('animation-duration') || '0'); 3060 const transDuration = parseFloat(style.getPropertyValue('transition-duration') || '0'); 3061 return animDuration > 0 || transDuration > 0; 3062 }; 3063 3064 /** 3065 * @param {number} timer 3066 * @param {boolean} reset 3067 */ 3068 const animateTimerProgressBar = (timer, reset = false) => { 3069 const timerProgressBar = getTimerProgressBar(); 3070 if (!timerProgressBar) { 3071 return; 3072 } 3073 if (isVisible$1(timerProgressBar)) { 3074 if (reset) { 3075 timerProgressBar.style.transition = 'none'; 3076 timerProgressBar.style.width = '100%'; 3077 } 3078 setTimeout(() => { 3079 timerProgressBar.style.transition = `width ${timer / 1000}s linear`; 3080 timerProgressBar.style.width = '0%'; 3081 }, 10); 3082 } 3083 }; 3084 const stopTimerProgressBar = () => { 3085 const timerProgressBar = getTimerProgressBar(); 3086 if (!timerProgressBar) { 3087 return; 3088 } 3089 const timerProgressBarWidth = parseInt(window.getComputedStyle(timerProgressBar).width); 3090 timerProgressBar.style.removeProperty('transition'); 3091 timerProgressBar.style.width = '100%'; 3092 const timerProgressBarFullWidth = parseInt(window.getComputedStyle(timerProgressBar).width); 3093 const timerProgressBarPercent = timerProgressBarWidth / timerProgressBarFullWidth * 100; 3094 timerProgressBar.style.width = `${timerProgressBarPercent}%`; 3095 }; 3096 3097 /** 3098 * Detect Node env 3099 * 3100 * @returns {boolean} 3101 */ 3102 const isNodeEnv = () => typeof window === 'undefined' || typeof document === 'undefined'; 3103 3104 const sweetHTML = ` 3105 <div aria-labelledby="${swalClasses.title}" aria-describedby="${swalClasses['html-container']}" class="${swalClasses.popup}" tabindex="-1"> 3106 <button type="button" class="${swalClasses.close}"></button> 3107 <ul class="${swalClasses['progress-steps']}"></ul> 3108 <div class="${swalClasses.icon}"></div> 3109 <img class="${swalClasses.image}" /> 3110 <h2 class="${swalClasses.title}" id="${swalClasses.title}"></h2> 3111 <div class="${swalClasses['html-container']}" id="${swalClasses['html-container']}"></div> 3112 <input class="${swalClasses.input}" id="${swalClasses.input}" /> 3113 <input type="file" class="${swalClasses.file}" /> 3114 <div class="${swalClasses.range}"> 3115 <input type="range" /> 3116 <output></output> 3117 </div> 3118 <select class="${swalClasses.select}" id="${swalClasses.select}"></select> 3119 <div class="${swalClasses.radio}"></div> 3120 <label class="${swalClasses.checkbox}"> 3121 <input type="checkbox" id="${swalClasses.checkbox}" /> 3122 <span class="${swalClasses.label}"></span> 3123 </label> 3124 <textarea class="${swalClasses.textarea}" id="${swalClasses.textarea}"></textarea> 3125 <div class="${swalClasses['validation-message']}" id="${swalClasses['validation-message']}"></div> 3126 <div class="${swalClasses.actions}"> 3127 <div class="${swalClasses.loader}"></div> 3128 <button type="button" class="${swalClasses.confirm}"></button> 3129 <button type="button" class="${swalClasses.deny}"></button> 3130 <button type="button" class="${swalClasses.cancel}"></button> 3131 </div> 3132 <div class="${swalClasses.footer}"></div> 3133 <div class="${swalClasses['timer-progress-bar-container']}"> 3134 <div class="${swalClasses['timer-progress-bar']}"></div> 3135 </div> 3136 </div> 3137`.replace(/(^|\n)\s*/g, ''); 3138 3139 /** 3140 * @returns {boolean} 3141 */ 3142 const resetOldContainer = () => { 3143 const oldContainer = getContainer(); 3144 if (!oldContainer) { 3145 return false; 3146 } 3147 oldContainer.remove(); 3148 removeClass([document.documentElement, document.body], [swalClasses['no-backdrop'], swalClasses['toast-shown'], 3149 // @ts-ignore: 'has-column' is not defined in swalClasses but may be set dynamically 3150 swalClasses['has-column']]); 3151 return true; 3152 }; 3153 const resetValidationMessage$1 = () => { 3154 if (globalState.currentInstance) { 3155 globalState.currentInstance.resetValidationMessage(); 3156 } 3157 }; 3158 const addInputChangeListeners = () => { 3159 const popup = getPopup(); 3160 if (!popup) { 3161 return; 3162 } 3163 const input = getDirectChildByClass(popup, swalClasses.input); 3164 const file = getDirectChildByClass(popup, swalClasses.file); 3165 /** @type {HTMLInputElement | null} */ 3166 const range = popup.querySelector(`.${swalClasses.range} input`); 3167 /** @type {HTMLOutputElement | null} */ 3168 const rangeOutput = popup.querySelector(`.${swalClasses.range} output`); 3169 const select = getDirectChildByClass(popup, swalClasses.select); 3170 /** @type {HTMLInputElement | null} */ 3171 const checkbox = popup.querySelector(`.${swalClasses.checkbox} input`); 3172 const textarea = getDirectChildByClass(popup, swalClasses.textarea); 3173 if (input) { 3174 input.oninput = resetValidationMessage$1; 3175 } 3176 if (file) { 3177 file.onchange = resetValidationMessage$1; 3178 } 3179 if (select) { 3180 select.onchange = resetValidationMessage$1; 3181 } 3182 if (checkbox) { 3183 checkbox.onchange = resetValidationMessage$1; 3184 } 3185 if (textarea) { 3186 textarea.oninput = resetValidationMessage$1; 3187 } 3188 if (range && rangeOutput) { 3189 range.oninput = () => { 3190 resetValidationMessage$1(); 3191 rangeOutput.value = range.value; 3192 }; 3193 range.onchange = () => { 3194 resetValidationMessage$1(); 3195 rangeOutput.value = range.value; 3196 }; 3197 } 3198 }; 3199 3200 /** 3201 * @param {string | HTMLElement} target 3202 * @returns {HTMLElement} 3203 */ 3204 const getTarget = target => { 3205 if (typeof target === 'string') { 3206 const element = document.querySelector(target); 3207 if (!element) { 3208 throw new Error(`Target element "${target}" not found`); 3209 } 3210 return /** @type {HTMLElement} */element; 3211 } 3212 return target; 3213 }; 3214 3215 /** 3216 * @param {SweetAlertOptions} params 3217 */ 3218 const setupAccessibility = params => { 3219 const popup = getPopup(); 3220 if (!popup) { 3221 return; 3222 } 3223 popup.setAttribute('role', params.toast ? 'alert' : 'dialog'); 3224 popup.setAttribute('aria-live', params.toast ? 'polite' : 'assertive'); 3225 if (!params.toast) { 3226 popup.setAttribute('aria-modal', 'true'); 3227 } 3228 }; 3229 3230 /** 3231 * @param {HTMLElement} targetElement 3232 */ 3233 const setupRTL = targetElement => { 3234 if (window.getComputedStyle(targetElement).direction === 'rtl') { 3235 addClass(getContainer(), swalClasses.rtl); 3236 globalState.isRTL = true; 3237 } 3238 }; 3239 3240 /** 3241 * Add modal + backdrop to DOM 3242 * 3243 * @param {SweetAlertOptions} params 3244 */ 3245 const init = params => { 3246 // Clean up the old popup container if it exists 3247 const oldContainerExisted = resetOldContainer(); 3248 if (isNodeEnv()) { 3249 error('SweetAlert2 requires document to initialize'); 3250 return; 3251 } 3252 const container = document.createElement('div'); 3253 container.className = swalClasses.container; 3254 if (oldContainerExisted) { 3255 addClass(container, swalClasses['no-transition']); 3256 } 3257 setInnerHtml(container, sweetHTML); 3258 container.dataset['swal2Theme'] = params.theme; 3259 const targetElement = getTarget(params.target || 'body'); 3260 targetElement.appendChild(container); 3261 if (params.topLayer) { 3262 container.setAttribute('popover', ''); 3263 container.showPopover(); 3264 } 3265 setupAccessibility(params); 3266 setupRTL(targetElement); 3267 addInputChangeListeners(); 3268 }; 3269 3270 /** 3271 * @param {HTMLElement | object | string} param 3272 * @param {HTMLElement} target 3273 */ 3274 const parseHtmlToContainer = (param, target) => { 3275 // DOM element 3276 if (param instanceof HTMLElement) { 3277 target.appendChild(param); 3278 } 3279 3280 // Object 3281 else if (typeof param === 'object') { 3282 handleObject(param, target); 3283 } 3284 3285 // Plain string 3286 else if (param) { 3287 setInnerHtml(target, param); 3288 } 3289 }; 3290 3291 /** 3292 * @param {object} param 3293 * @param {HTMLElement} target 3294 */ 3295 const handleObject = (param, target) => { 3296 // JQuery element(s) 3297 if ('jquery' in param) { 3298 handleJqueryElem(target, param); 3299 } 3300 3301 // For other objects use their string representation 3302 else { 3303 setInnerHtml(target, param.toString()); 3304 } 3305 }; 3306 3307 /** 3308 * @param {HTMLElement} target 3309 * @param {any} elem 3310 */ 3311 const handleJqueryElem = (target, elem) => { 3312 target.textContent = ''; 3313 if (0 in elem) { 3314 for (let i = 0; i in elem; i++) { 3315 target.appendChild(elem[i].cloneNode(true)); 3316 } 3317 } else { 3318 target.appendChild(elem.cloneNode(true)); 3319 } 3320 }; 3321 3322 /** 3323 * @param {SweetAlert} instance 3324 * @param {SweetAlertOptions} params 3325 */ 3326 const renderActions = (instance, params) => { 3327 const actions = getActions(); 3328 const loader = getLoader(); 3329 if (!actions || !loader) { 3330 return; 3331 } 3332 3333 // Actions (buttons) wrapper 3334 if (!params.showConfirmButton && !params.showDenyButton && !params.showCancelButton) { 3335 hide(actions); 3336 } else { 3337 show(actions); 3338 } 3339 3340 // Custom class 3341 applyCustomClass(actions, params, 'actions'); 3342 3343 // Render all the buttons 3344 renderButtons(actions, loader, params); 3345 3346 // Loader 3347 setInnerHtml(loader, params.loaderHtml || ''); 3348 applyCustomClass(loader, params, 'loader'); 3349 }; 3350 3351 /** 3352 * @param {HTMLElement} actions 3353 * @param {HTMLElement} loader 3354 * @param {SweetAlertOptions} params 3355 */ 3356 function renderButtons(actions, loader, params) { 3357 const confirmButton = getConfirmButton(); 3358 const denyButton = getDenyButton(); 3359 const cancelButton = getCancelButton(); 3360 if (!confirmButton || !denyButton || !cancelButton) { 3361 return; 3362 } 3363 3364 // Render buttons 3365 renderButton(confirmButton, 'confirm', params); 3366 renderButton(denyButton, 'deny', params); 3367 renderButton(cancelButton, 'cancel', params); 3368 handleButtonsStyling(confirmButton, denyButton, cancelButton, params); 3369 if (params.reverseButtons) { 3370 if (params.toast) { 3371 actions.insertBefore(cancelButton, confirmButton); 3372 actions.insertBefore(denyButton, confirmButton); 3373 } else { 3374 actions.insertBefore(cancelButton, loader); 3375 actions.insertBefore(denyButton, loader); 3376 actions.insertBefore(confirmButton, loader); 3377 } 3378 } 3379 } 3380 3381 /** 3382 * @param {HTMLElement} confirmButton 3383 * @param {HTMLElement} denyButton 3384 * @param {HTMLElement} cancelButton 3385 * @param {SweetAlertOptions} params 3386 */ 3387 function handleButtonsStyling(confirmButton, denyButton, cancelButton, params) { 3388 if (!params.buttonsStyling) { 3389 removeClass([confirmButton, denyButton, cancelButton], swalClasses.styled); 3390 return; 3391 } 3392 addClass([confirmButton, denyButton, cancelButton], swalClasses.styled); 3393 3394 // Apply custom background colors and outline colors to action buttons 3395 /** @type {[HTMLElement, string, string | undefined][]} */ 3396 const buttons = [[confirmButton, 'confirm', params.confirmButtonColor], [denyButton, 'deny', params.denyButtonColor], [cancelButton, 'cancel', params.cancelButtonColor]]; 3397 buttons.forEach(([button, type, color]) => { 3398 if (color) { 3399 button.style.setProperty(`--swal2-${type}-button-background-color`, color); 3400 } 3401 applyOutlineColor(button); 3402 }); 3403 } 3404 3405 /** 3406 * @param {HTMLElement} button 3407 */ 3408 function applyOutlineColor(button) { 3409 const buttonStyle = window.getComputedStyle(button); 3410 if (buttonStyle.getPropertyValue('--swal2-action-button-focus-box-shadow')) { 3411 // If the button already has a custom outline color, no need to change it 3412 return; 3413 } 3414 const outlineColor = buttonStyle.backgroundColor.replace(/rgba?\((\d+), (\d+), (\d+).*/, 'rgba($1, $2, $3, 0.5)'); 3415 button.style.setProperty('--swal2-action-button-focus-box-shadow', buttonStyle.getPropertyValue('--swal2-outline').replace(/ rgba\(.*/, ` ${outlineColor}`)); 3416 } 3417 3418 /** 3419 * @param {HTMLElement} button 3420 * @param {'confirm' | 'deny' | 'cancel'} buttonType 3421 * @param {SweetAlertOptions} params 3422 */ 3423 function renderButton(button, buttonType, params) { 3424 const buttonName = /** @type {'Confirm' | 'Deny' | 'Cancel'} */capitalizeFirstLetter(buttonType); 3425 toggle(button, params[`show${buttonName}Button`], 'inline-block'); 3426 setInnerHtml(button, params[`${buttonType}ButtonText`] || ''); // Set caption text 3427 button.setAttribute('aria-label', params[`${buttonType}ButtonAriaLabel`] || ''); // ARIA label 3428 3429 // Add buttons custom classes 3430 button.className = swalClasses[buttonType]; 3431 applyCustomClass(button, params, `${buttonType}Button`); 3432 } 3433 3434 /** 3435 * @param {SweetAlert} instance 3436 * @param {SweetAlertOptions} params 3437 */ 3438 const renderCloseButton = (instance, params) => { 3439 const closeButton = getCloseButton(); 3440 if (!closeButton) { 3441 return; 3442 } 3443 setInnerHtml(closeButton, params.closeButtonHtml || ''); 3444 3445 // Custom class 3446 applyCustomClass(closeButton, params, 'closeButton'); 3447 toggle(closeButton, params.showCloseButton); 3448 closeButton.setAttribute('aria-label', params.closeButtonAriaLabel || ''); 3449 }; 3450 3451 /** 3452 * @param {SweetAlert} instance 3453 * @param {SweetAlertOptions} params 3454 */ 3455 const renderContainer = (instance, params) => { 3456 const container = getContainer(); 3457 if (!container) { 3458 return; 3459 } 3460 handleBackdropParam(container, params.backdrop); 3461 handlePositionParam(container, params.position); 3462 handleGrowParam(container, params.grow); 3463 3464 // Custom class 3465 applyCustomClass(container, params, 'container'); 3466 }; 3467 3468 /** 3469 * @param {HTMLElement} container 3470 * @param {SweetAlertOptions['backdrop']} backdrop 3471 */ 3472 function handleBackdropParam(container, backdrop) { 3473 if (typeof backdrop === 'string') { 3474 container.style.background = backdrop; 3475 } else if (!backdrop) { 3476 addClass([document.documentElement, document.body], swalClasses['no-backdrop']); 3477 } 3478 } 3479 3480 /** 3481 * @param {HTMLElement} container 3482 * @param {SweetAlertOptions['position']} position 3483 */ 3484 function handlePositionParam(container, position) { 3485 if (!position) { 3486 return; 3487 } 3488 if (position in swalClasses) { 3489 addClass(container, swalClasses[position]); 3490 } else { 3491 warn('The "position" parameter is not valid, defaulting to "center"'); 3492 addClass(container, swalClasses.center); 3493 } 3494 } 3495 3496 /** 3497 * @param {HTMLElement} container 3498 * @param {SweetAlertOptions['grow']} grow 3499 */ 3500 function handleGrowParam(container, grow) { 3501 if (!grow) { 3502 return; 3503 } 3504 addClass(container, swalClasses[`grow-${grow}`]); 3505 } 3506 3507 /** 3508 * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has. 3509 * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')` 3510 * This is the approach that Babel will probably take to implement private methods/fields 3511 * https://github.com/tc39/proposal-private-methods 3512 * https://github.com/babel/babel/pull/7555 3513 * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module* 3514 * then we can use that language feature. 3515 */ 3516 3517 var privateProps = { 3518 innerParams: new WeakMap(), 3519 domCache: new WeakMap(), 3520 focusedElement: new WeakMap() 3521 }; 3522 3523 /// <reference path="../../../../sweetalert2.d.ts"/> 3524 3525 3526 /** @type {InputClass[]} */ 3527 const inputClasses = ['input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea']; 3528 3529 /** 3530 * @param {SweetAlert} instance 3531 * @param {SweetAlertOptions} params 3532 */ 3533 const renderInput = (instance, params) => { 3534 const popup = getPopup(); 3535 if (!popup) { 3536 return; 3537 } 3538 const innerParams = privateProps.innerParams.get(instance); 3539 const rerender = !innerParams || params.input !== innerParams.input; 3540 inputClasses.forEach(inputClass => { 3541 const inputContainer = getDirectChildByClass(popup, swalClasses[inputClass]); 3542 if (!inputContainer) { 3543 return; 3544 } 3545 3546 // set attributes 3547 setAttributes(inputClass, params.inputAttributes); 3548 3549 // set class 3550 inputContainer.className = swalClasses[inputClass]; 3551 if (rerender) { 3552 hide(inputContainer); 3553 } 3554 }); 3555 if (params.input) { 3556 if (rerender) { 3557 showInput(params); 3558 } 3559 // set custom class 3560 setCustomClass(params); 3561 } 3562 }; 3563 3564 /** 3565 * @param {SweetAlertOptions} params 3566 */ 3567 const showInput = params => { 3568 if (!params.input) { 3569 return; 3570 } 3571 if (!renderInputType[params.input]) { 3572 error(`Unexpected type of input! Expected ${Object.keys(renderInputType).join(' | ')}, got "${params.input}"`); 3573 return; 3574 } 3575 const inputContainer = getInputContainer(params.input); 3576 if (!inputContainer) { 3577 return; 3578 } 3579 const input = renderInputType[params.input](inputContainer, params); 3580 show(inputContainer); 3581 3582 // input autofocus 3583 if (params.inputAutoFocus) { 3584 setTimeout(() => { 3585 focusInput(input); 3586 }); 3587 } 3588 }; 3589 3590 /** 3591 * @param {HTMLInputElement} input 3592 */ 3593 const removeAttributes = input => { 3594 for (
3594let i = 0; i < input.attributes.length; i++) { 3595 const attrName = input.attributes[i].name; 3596 if (!['id', 'type', 'value', 'style'].includes(attrName)) { 3597 input.removeAttribute(attrN
vendor: 11,542 bytes, lines 3597-3968
3597ame); 3598 } 3599 } 3600 }; 3601 3602 /** 3603 * @param {InputClass} inputClass 3604 * @param {SweetAlertOptions['inputAttributes']} inputAttributes 3605 */ 3606 const setAttributes = (inputClass, inputAttributes) => { 3607 const popup = getPopup(); 3608 if (!popup) { 3609 return; 3610 } 3611 const input = getInput$1(popup, inputClass); 3612 if (!input) { 3613 return; 3614 } 3615 removeAttributes(input); 3616 for (const attr in inputAttributes) { 3617 input.setAttribute(attr, inputAttributes[attr]); 3618 } 3619 }; 3620 3621 /** 3622 * @param {SweetAlertOptions} params 3623 */ 3624 const setCustomClass = params => { 3625 if (!params.input) { 3626 return; 3627 } 3628 const inputContainer = getInputContainer(params.input); 3629 if (inputContainer) { 3630 applyCustomClass(inputContainer, params, 'input'); 3631 } 3632 }; 3633 3634 /** 3635 * @param {HTMLInputElement | HTMLTextAreaElement} input 3636 * @param {SweetAlertOptions} params 3637 */ 3638 const setInputPlaceholder = (input, params) => { 3639 if (!input.placeholder && params.inputPlaceholder) { 3640 input.placeholder = params.inputPlaceholder; 3641 } 3642 }; 3643 3644 /** 3645 * @param {Input} input 3646 * @param {Input} prependTo 3647 * @param {SweetAlertOptions} params 3648 */ 3649 const setInputLabel = (input, prependTo, params) => { 3650 if (params.inputLabel) { 3651 const label = document.createElement('label'); 3652 const labelClass = swalClasses['input-label']; 3653 label.setAttribute('for', input.id); 3654 label.className = labelClass; 3655 if (typeof params.customClass === 'object') { 3656 addClass(label, params.customClass.inputLabel); 3657 } 3658 label.innerText = params.inputLabel; 3659 prependTo.insertAdjacentElement('beforebegin', label); 3660 } 3661 }; 3662 3663 /** 3664 * @param {SweetAlertInput} inputType 3665 * @returns {HTMLElement | undefined} 3666 */ 3667 const getInputContainer = inputType => { 3668 const popup = getPopup(); 3669 if (!popup) { 3670 return; 3671 } 3672 return getDirectChildByClass(popup, swalClasses[(/** @type {SwalClass} */inputType)] || swalClasses.input); 3673 }; 3674 3675 /** 3676 * @param {HTMLInputElement | HTMLOutputElement | HTMLTextAreaElement} input 3677 * @param {SweetAlertOptions['inputValue']} inputValue 3678 */ 3679 const checkAndSetInputValue = (input, inputValue) => { 3680 if (['string', 'number'].includes(typeof inputValue)) { 3681 input.value = `${inputValue}`; 3682 } else if (!isPromise(inputValue)) { 3683 warn(`Unexpected type of inputValue! Expected "string", "number" or "Promise", got "${typeof inputValue}"`); 3684 } 3685 }; 3686 3687 /** @type {Record<SweetAlertInput, (input: Input | HTMLElement, params: SweetAlertOptions) => Input>} */ 3688 const renderInputType = {}; 3689 3690 /** 3691 * @param {Input | HTMLElement} input 3692 * @param {SweetAlertOptions} params 3693 * @returns {Input} 3694 */ 3695 renderInputType.text = renderInputType.email = renderInputType.password = renderInputType.number = renderInputType.tel = renderInputType.url = renderInputType.search = renderInputType.date = renderInputType['datetime-local'] = renderInputType.time = renderInputType.week = renderInputType.month = /** @type {(input: Input | HTMLElement, params: SweetAlertOptions) => Input} */ 3696 (input, params) => { 3697 // oxfmt-ignore 3698 const inputElement = /** @type {HTMLInputElement} */input; 3699 checkAndSetInputValue(inputElement, params.inputValue); 3700 setInputLabel(inputElement, inputElement, params); 3701 setInputPlaceholder(inputElement, params); 3702 // oxfmt-ignore 3703 inputElement.type = /** @type {string} */params.input; 3704 return inputElement; 3705 }; 3706 3707 /** 3708 * @param {Input | HTMLElement} input 3709 * @param {SweetAlertOptions} params 3710 * @returns {Input} 3711 */ 3712 renderInputType.file = (input, params) => { 3713 const inputElement = /** @type {HTMLInputElement} */input; 3714 setInputLabel(inputElement, inputElement, params); 3715 setInputPlaceholder(inputElement, params); 3716 return inputElement; 3717 }; 3718 3719 /** 3720 * @param {Input | HTMLElement} range 3721 * @param {SweetAlertOptions} params 3722 * @returns {Input} 3723 */ 3724 renderInputType.range = (range, params) => { 3725 const rangeContainer = /** @type {HTMLElement} */range; 3726 const rangeInput = rangeContainer.querySelector('input'); 3727 const rangeOutput = rangeContainer.querySelector('output'); 3728 if (rangeInput) { 3729 checkAndSetInputValue(rangeInput, params.inputValue); 3730 rangeInput.type = /** @type {string} */params.input; 3731 setInputLabel(rangeInput, /** @type {Input} */range, params); 3732 } 3733 if (rangeOutput) { 3734 checkAndSetInputValue(rangeOutput, params.inputValue); 3735 } 3736 return /** @type {Input} */range; 3737 }; 3738 3739 /** 3740 * @param {Input | HTMLElement} select 3741 * @param {SweetAlertOptions} params 3742 * @returns {Input} 3743 */ 3744 renderInputType.select = (select, params) => { 3745 const selectElement = /** @type {HTMLSelectElement} */select; 3746 selectElement.textContent = ''; 3747 if (params.inputPlaceholder) { 3748 const placeholder = document.createElement('option'); 3749 setInnerHtml(placeholder, params.inputPlaceholder); 3750 placeholder.value = ''; 3751 placeholder.disabled = true; 3752 placeholder.selected = true; 3753 selectElement.appendChild(placeholder); 3754 } 3755 setInputLabel(selectElement, selectElement, params); 3756 return selectElement; 3757 }; 3758 3759 /** 3760 * @param {Input | HTMLElement} radio 3761 * @returns {Input} 3762 */ 3763 renderInputType.radio = radio => { 3764 const radioElement = /** @type {HTMLElement} */radio; 3765 radioElement.textContent = ''; 3766 return /** @type {Input} */radio; 3767 }; 3768 3769 /** 3770 * @param {Input | HTMLElement} checkboxContainer 3771 * @param {SweetAlertOptions} params 3772 * @returns {Input} 3773 */ 3774 renderInputType.checkbox = (checkboxContainer, params) => { 3775 const popup = getPopup(); 3776 if (!popup) { 3777 throw new Error('Popup not found'); 3778 } 3779 const checkbox = getInput$1(popup, 'checkbox'); 3780 if (!checkbox) { 3781 throw new Error('Checkbox input not found'); 3782 } 3783 checkbox.value = '1'; 3784 checkbox.checked = Boolean(params.inputValue); 3785 const containerElement = /** @type {HTMLElement} */checkboxContainer; 3786 const label = containerElement.querySelector('span'); 3787 if (label) { 3788 const placeholderOrLabel = params.inputPlaceholder || params.inputLabel; 3789 if (placeholderOrLabel) { 3790 setInnerHtml(label, placeholderOrLabel); 3791 } 3792 } 3793 return checkbox; 3794 }; 3795 3796 /** 3797 * @param {Input | HTMLElement} textarea 3798 * @param {SweetAlertOptions} params 3799 * @returns {Input} 3800 */ 3801 renderInputType.textarea = (textarea, params) => { 3802 const textareaElement = /** @type {HTMLTextAreaElement} */textarea; 3803 checkAndSetInputValue(textareaElement, params.inputValue); 3804 setInputPlaceholder(textareaElement, params); 3805 setInputLabel(textareaElement, textareaElement, params); 3806 3807 /** 3808 * @param {HTMLElement} el 3809 * @returns {number} 3810 */ 3811 const getMargin = el => parseInt(window.getComputedStyle(el).marginLeft) + parseInt(window.getComputedStyle(el).marginRight); 3812 3813 // https://github.com/sweetalert2/sweetalert2/issues/2291 3814 setTimeout(() => { 3815 // https://github.com/sweetalert2/sweetalert2/issues/1699 3816 if ('MutationObserver' in window) { 3817 const popup = getPopup(); 3818 if (!popup) { 3819 return; 3820 } 3821 const initialPopupWidth = parseInt(window.getComputedStyle(popup).width); 3822 const textareaResizeHandler = () => { 3823 // check if texarea is still in document (i.e. popup wasn't closed in the meantime) 3824 if (!document.body.contains(textareaElement)) { 3825 return; 3826 } 3827 const textareaWidth = textareaElement.offsetWidth + getMargin(textareaElement); 3828 const popupElement = getPopup(); 3829 if (popupElement) { 3830 if (textareaWidth > initialPopupWidth) { 3831 popupElement.style.width = `${textareaWidth}px`; 3832 } else { 3833 applyNumericalStyle(popupElement, 'width', params.width); 3834 } 3835 } 3836 }; 3837 new MutationObserver(textareaResizeHandler).observe(textareaElement, { 3838 attributes: true, 3839 attributeFilter: ['style'] 3840 }); 3841 } 3842 }); 3843 return textareaElement; 3844 }; 3845 3846 /** 3847 * @param {SweetAlert} instance 3848 * @param {SweetAlertOptions} params 3849 */ 3850 const renderContent = (instance, params) => { 3851 const htmlContainer = getHtmlContainer(); 3852 if (!htmlContainer) { 3853 return; 3854 } 3855 showWhenInnerHtmlPresent(htmlContainer); 3856 applyCustomClass(htmlContainer, params, 'htmlContainer'); 3857 3858 // Content as HTML 3859 if (params.html) { 3860 parseHtmlToContainer(params.html, htmlContainer); 3861 show(htmlContainer, 'block'); 3862 } 3863 3864 // Content as plain text 3865 else if (params.text) { 3866 htmlContainer.textContent = params.text; 3867 show(htmlContainer, 'block'); 3868 } 3869 3870 // No content 3871 else { 3872 hide(htmlContainer); 3873 } 3874 renderInput(instance, params); 3875 }; 3876 3877 /** 3878 * @param {SweetAlert} instance 3879 * @param {SweetAlertOptions} params 3880 */ 3881 const renderFooter = (instance, params) => { 3882 const footer = getFooter(); 3883 if (!footer) { 3884 return; 3885 } 3886 showWhenInnerHtmlPresent(footer); 3887 toggle(footer, Boolean(params.footer), 'block'); 3888 if (params.footer) { 3889 parseHtmlToContainer(params.footer, footer); 3890 } 3891 3892 // Custom class 3893 applyCustomClass(footer, params, 'footer'); 3894 }; 3895 3896 /** 3897 * @param {SweetAlert} instance 3898 * @param {SweetAlertOptions} params 3899 */ 3900 const renderIcon = (instance, params) => { 3901 const innerParams = privateProps.innerParams.get(instance); 3902 const icon = getIcon(); 3903 if (!icon) { 3904 return; 3905 } 3906 3907 // if the given icon already rendered, apply the styling without re-rendering the icon 3908 if (innerParams && params.icon === innerParams.icon) { 3909 // Custom or default content 3910 setContent(icon, params); 3911 applyStyles(icon, params); 3912 return; 3913 } 3914 if (!params.icon && !params.iconHtml) { 3915 hide(icon); 3916 return; 3917 } 3918 if (params.icon && Object.keys(iconTypes).indexOf(params.icon) === -1) { 3919 error(`Unknown icon! Expected "success", "error", "warning", "info" or "question", got "${params.icon}"`); 3920 hide(icon); 3921 return; 3922 } 3923 show(icon); 3924 3925 // Custom or default content 3926 setContent(icon, params); 3927 applyStyles(icon, params); 3928 3929 // Animate icon 3930 addClass(icon, params.showClass && params.showClass.icon); 3931 3932 // Re-adjust the success icon on system theme change 3933 const colorSchemeQueryList = window.matchMedia('(prefers-color-scheme: dark)'); 3934 colorSchemeQueryList.addEventListener('change', adjustSuccessIconBackgroundColor); 3935 }; 3936 3937 /** 3938 * @param {HTMLElement} icon 3939 * @param {SweetAlertOptions} params 3940 */ 3941 const applyStyles = (icon, params) => { 3942 for (const [iconType, iconClassName] of Object.entries(iconTypes)) { 3943 if (params.icon !== iconType) { 3944 removeClass(icon, iconClassName); 3945 } 3946 } 3947 addClass(icon, params.icon && iconTypes[params.icon]); 3948 3949 // Icon color 3950 setColor(icon, params); 3951 3952 // Success icon background color 3953 adjustSuccessIconBackgroundColor(); 3954 3955 // Custom class 3956 applyCustomClass(icon, params, 'icon'); 3957 }; 3958 3959 // Adjust success icon background color to match the popup background color 3960 const adjustSuccessIconBackgroundColor = () => { 3961 const popup = getPopup(); 3962 if (!popup) { 3963 return; 3964 } 3965 const popupBackgroundColor = window.getComputedStyle(popup).getPropertyValue('background-color'); 3966 /** @type {NodeListOf<HTMLElement>} */ 3967 const successIconParts = popup.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix'); 3968
vendor: 17,111 bytes, lines 3968-4536
3968for (let i = 0; i < successIconParts.length; i++) { 3969 successIconParts[i].style.backgroundColor = popupBackgroundColor; 3970 } 3971 }; 3972 3973 /** 3974 * 3975 * @param {SweetAlertOptions} params 3976 * @returns {string} 3977 */ 3978 const successIconHtml = params => ` 3979 ${params.animation ? '<div class="swal2-success-circular-line-left"></div>' : ''} 3980 <span class="swal2-success-line-tip"></span> <span class="swal2-success-line-long"></span> 3981 <div class="swal2-success-ring"></div> 3982 ${params.animation ? '<div class="swal2-success-fix"></div>' : ''} 3983 ${params.animation ? '<div class="swal2-success-circular-line-right"></div>' : ''} 3984`; 3985 const errorIconHtml = ` 3986 <span class="swal2-x-mark"> 3987 <span class="swal2-x-mark-line-left"></span> 3988 <span class="swal2-x-mark-line-right"></span> 3989 </span> 3990`; 3991 3992 /** 3993 * @param {HTMLElement} icon 3994 * @param {SweetAlertOptions} params 3995 */ 3996 const setContent = (icon, params) => { 3997 if (!params.icon && !params.iconHtml) { 3998 return; 3999 } 4000 let oldContent = icon.innerHTML; 4001 let newContent = ''; 4002 if (params.iconHtml) { 4003 newContent = iconContent(params.iconHtml); 4004 } else if (params.icon === 'success') { 4005 newContent = successIconHtml(params); 4006 oldContent = oldContent.replace(/ style=".*?"/g, ''); // undo adjustSuccessIconBackgroundColor() 4007 } else if (params.icon === 'error') { 4008 newContent = errorIconHtml; 4009 } else if (params.icon) { 4010 const defaultIconHtml = { 4011 question: '?', 4012 warning: '!', 4013 info: 'i' 4014 }; 4015 newContent = iconContent(defaultIconHtml[params.icon]); 4016 } 4017 if (oldContent.trim() !== newContent.trim()) { 4018 setInnerHtml(icon, newContent); 4019 } 4020 }; 4021 4022 /** 4023 * @param {HTMLElement} icon 4024 * @param {SweetAlertOptions} params 4025 */ 4026 const setColor = (icon, params) => { 4027 if (!params.iconColor) { 4028 return; 4029 } 4030 icon.style.color = params.iconColor; 4031 icon.style.borderColor = params.iconColor; 4032 for (const sel of ['.swal2-success-line-tip', '.swal2-success-line-long', '.swal2-x-mark-line-left', '.swal2-x-mark-line-right']) { 4033 setStyle(icon, sel, 'background-color', params.iconColor); 4034 } 4035 setStyle(icon, '.swal2-success-ring', 'border-color', params.iconColor); 4036 }; 4037 4038 /** 4039 * @param {string} content 4040 * @returns {string} 4041 */ 4042 const iconContent = content => `<div class="${swalClasses['icon-content']}">${content}</div>`; 4043 4044 /** 4045 * @param {SweetAlert} instance 4046 * @param {SweetAlertOptions} params 4047 */ 4048 const renderImage = (instance, params) => { 4049 const image = getImage(); 4050 if (!image) { 4051 return; 4052 } 4053 if (!params.imageUrl) { 4054 hide(image); 4055 return; 4056 } 4057 show(image, ''); 4058 4059 // Src, alt 4060 image.setAttribute('src', params.imageUrl); 4061 image.setAttribute('alt', params.imageAlt || ''); 4062 4063 // Width, height 4064 applyNumericalStyle(image, 'width', params.imageWidth); 4065 applyNumericalStyle(image, 'height', params.imageHeight); 4066 4067 // Class 4068 image.className = swalClasses.image; 4069 applyCustomClass(image, params, 'image'); 4070 }; 4071 4072 let dragging = false; 4073 let mousedownX = 0; 4074 let mousedownY = 0; 4075 let initialX = 0; 4076 let initialY = 0; 4077 4078 /** 4079 * @param {HTMLElement} popup 4080 */ 4081 const addDraggableListeners = popup => { 4082 popup.addEventListener('mousedown', down); 4083 document.body.addEventListener('mousemove', move); 4084 popup.addEventListener('mouseup', up); 4085 popup.addEventListener('touchstart', down); 4086 document.body.addEventListener('touchmove', move); 4087 popup.addEventListener('touchend', up); 4088 }; 4089 4090 /** 4091 * @param {HTMLElement} popup 4092 */ 4093 const removeDraggableListeners = popup => { 4094 popup.removeEventListener('mousedown', down); 4095 document.body.removeEventListener('mousemove', move); 4096 popup.removeEventListener('mouseup', up); 4097 popup.removeEventListener('touchstart', down); 4098 document.body.removeEventListener('touchmove', move); 4099 popup.removeEventListener('touchend', up); 4100 }; 4101 4102 /** 4103 * @param {MouseEvent | TouchEvent} event 4104 */ 4105 const down = event => { 4106 const popup = getPopup(); 4107 if (!popup) { 4108 return; 4109 } 4110 const icon = getIcon(); 4111 if (event.target === popup || icon && icon.contains(/** @type {HTMLElement} */event.target)) { 4112 dragging = true; 4113 const clientXY = getClientXY(event); 4114 mousedownX = clientXY.clientX; 4115 mousedownY = clientXY.clientY; 4116 initialX = parseInt(popup.style.insetInlineStart) || 0; 4117 initialY = parseInt(popup.style.insetBlockStart) || 0; 4118 addClass(popup, 'swal2-dragging'); 4119 } 4120 }; 4121 4122 /** 4123 * @param {MouseEvent | TouchEvent} event 4124 */ 4125 const move = event => { 4126 const popup = getPopup(); 4127 if (!popup) { 4128 return; 4129 } 4130 if (dragging) { 4131 let { 4132 clientX, 4133 clientY 4134 } = getClientXY(event); 4135 const deltaX = clientX - mousedownX; 4136 // In RTL mode, negate the horizontal delta since insetInlineStart refers to the right edge 4137 popup.style.insetInlineStart = `${initialX + (globalState.isRTL ? -deltaX : deltaX)}px`; 4138 popup.style.insetBlockStart = `${initialY + (clientY - mousedownY)}px`; 4139 } 4140 }; 4141 const up = () => { 4142 const popup = getPopup(); 4143 dragging = false; 4144 removeClass(popup, 'swal2-dragging'); 4145 }; 4146 4147 /** 4148 * @param {MouseEvent | TouchEvent} event 4149 * @returns {{ clientX: number, clientY: number }} 4150 */ 4151 const getClientXY = event => { 4152 const source = event.type.startsWith('touch') ? /** @type {TouchEvent} */event.touches[0] : (/** @type {MouseEvent} */event); 4153 return { 4154 clientX: source.clientX, 4155 clientY: source.clientY 4156 }; 4157 }; 4158 4159 /** 4160 * @param {SweetAlert} instance 4161 * @param {SweetAlertOptions} params 4162 */ 4163 const renderPopup = (instance, params) => { 4164 const container = getContainer(); 4165 const popup = getPopup(); 4166 if (!container || !popup) { 4167 return; 4168 } 4169 4170 // Width 4171 // https://github.com/sweetalert2/sweetalert2/issues/2170 4172 if (params.toast) { 4173 applyNumericalStyle(container, 'width', params.width); 4174 popup.style.width = '100%'; 4175 const loader = getLoader(); 4176 if (loader) { 4177 popup.insertBefore(loader, getIcon()); 4178 } 4179 } else { 4180 applyNumericalStyle(popup, 'width', params.width); 4181 } 4182 4183 // Padding 4184 applyNumericalStyle(popup, 'padding', params.padding); 4185 4186 // Color 4187 if (params.color) { 4188 popup.style.color = params.color; 4189 } 4190 4191 // Background 4192 if (params.background) { 4193 popup.style.background = params.background; 4194 } 4195 hide(getValidationMessage()); 4196 4197 // Classes 4198 addClasses$1(popup, params); 4199 if (params.draggable && !params.toast) { 4200 addClass(popup, swalClasses.draggable); 4201 addDraggableListeners(popup); 4202 } else { 4203 removeClass(popup, swalClasses.draggable); 4204 removeDraggableListeners(popup); 4205 } 4206 }; 4207 4208 /** 4209 * @param {HTMLElement} popup 4210 * @param {SweetAlertOptions} params 4211 */ 4212 const addClasses$1 = (popup, params) => { 4213 const showClass = params.showClass || {}; 4214 // Default Class + showClass when updating Swal.update({}) 4215 popup.className = `${swalClasses.popup} ${isVisible$1(popup) ? showClass.popup : ''}`; 4216 if (params.toast) { 4217 addClass([document.documentElement, document.body], swalClasses['toast-shown']); 4218 addClass(popup, swalClasses.toast); 4219 } else { 4220 addClass(popup, swalClasses.modal); 4221 } 4222 4223 // Custom class 4224 applyCustomClass(popup, params, 'popup'); 4225 // TODO: remove in the next major 4226 if (typeof params.customClass === 'string') { 4227 addClass(popup, params.customClass); 4228 } 4229 4230 // Icon class (#1842) 4231 if (params.icon) { 4232 addClass(popup, swalClasses[`icon-${params.icon}`]); 4233 } 4234 }; 4235 4236 /** 4237 * @param {SweetAlert} instance 4238 * @param {SweetAlertOptions} params 4239 */ 4240 const renderProgressSteps = (instance, params) => { 4241 const progressStepsContainer = getProgressSteps(); 4242 if (!progressStepsContainer) { 4243 return; 4244 } 4245 const { 4246 progressSteps, 4247 currentProgressStep 4248 } = params; 4249 if (!progressSteps || progressSteps.length === 0 || currentProgressStep === undefined) { 4250 hide(progressStepsContainer); 4251 return; 4252 } 4253 show(progressStepsContainer); 4254 progressStepsContainer.textContent = ''; 4255 if (currentProgressStep >= progressSteps.length) { 4256 warn('Invalid currentProgressStep parameter, it should be less than progressSteps.length ' + '(currentProgressStep like JS arrays starts from 0)'); 4257 } 4258 progressSteps.forEach((step, index) => { 4259 const stepEl = createStepElement(step); 4260 progressStepsContainer.appendChild(stepEl); 4261 if (index === currentProgressStep) { 4262 addClass(stepEl, swalClasses['active-progress-step']); 4263 } 4264 if (index !== progressSteps.length - 1) { 4265 const lineEl = createLineElement(params); 4266 progressStepsContainer.appendChild(lineEl); 4267 } 4268 }); 4269 }; 4270 4271 /** 4272 * @param {string} step 4273 * @returns {HTMLLIElement} 4274 */ 4275 const createStepElement = step => { 4276 const stepEl = document.createElement('li'); 4277 addClass(stepEl, swalClasses['progress-step']); 4278 setInnerHtml(stepEl, step); 4279 return stepEl; 4280 }; 4281 4282 /** 4283 * @param {SweetAlertOptions} params 4284 * @returns {HTMLLIElement} 4285 */ 4286 const createLineElement = params => { 4287 const lineEl = document.createElement('li'); 4288 addClass(lineEl, swalClasses['progress-step-line']); 4289 if (params.progressStepsDistance) { 4290 applyNumericalStyle(lineEl, 'width', params.progressStepsDistance); 4291 } 4292 return lineEl; 4293 }; 4294 4295 /** 4296 * @param {SweetAlert} instance 4297 * @param {SweetAlertOptions} params 4298 */ 4299 const renderTitle = (instance, params) => { 4300 const title = getTitle(); 4301 if (!title) { 4302 return; 4303 } 4304 showWhenInnerHtmlPresent(title); 4305 toggle(title, Boolean(params.title || params.titleText), 'block'); 4306 if (params.title) { 4307 parseHtmlToContainer(params.title, title); 4308 } 4309 if (params.titleText) { 4310 title.innerText = params.titleText; 4311 } 4312 4313 // Custom class 4314 applyCustomClass(title, params, 'title'); 4315 }; 4316 4317 /** 4318 * @param {SweetAlert} instance 4319 * @param {SweetAlertOptions} params 4320 */ 4321 const render = (instance, params) => { 4322 var _globalState$eventEmi; 4323 renderPopup(instance, params); 4324 renderContainer(instance, params); 4325 renderProgressSteps(instance, params); 4326 renderIcon(instance, params); 4327 renderImage(instance, params); 4328 renderTitle(instance, params); 4329 renderCloseButton(instance, params); 4330 renderContent(instance, params); 4331 renderActions(instance, params); 4332 renderFooter(instance, params); 4333 const popup = getPopup(); 4334 if (typeof params.didRender === 'function' && popup) { 4335 params.didRender(popup); 4336 } 4337 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('didRender', popup); 4338 }; 4339 4340 /* 4341 * Global function to determine if SweetAlert2 popup is shown 4342 */ 4343 const isVisible = () => { 4344 return isVisible$1(getPopup()); 4345 }; 4346 4347 /* 4348 * Global function to click 'Confirm' button 4349 */ 4350 const clickConfirm = () => { 4351 var _dom$getConfirmButton; 4352 return (_dom$getConfirmButton = getConfirmButton()) === null || _dom$getConfirmButton === void 0 ? void 0 : _dom$getConfirmButton.click(); 4353 }; 4354 4355 /* 4356 * Global function to click 'Deny' button 4357 */ 4358 const clickDeny = () => { 4359 var _dom$getDenyButton; 4360 return (_dom$getDenyButton = getDenyButton()) === null || _dom$getDenyButton === void 0 ? void 0 : _dom$getDenyButton.click(); 4361 }; 4362 4363 /* 4364 * Global function to click 'Cancel' button 4365 */ 4366 const clickCancel = () => { 4367 var _dom$getCancelButton; 4368 return (_dom$getCancelButton = getCancelButton()) === null || _dom$getCancelButton === void 0 ? void 0 : _dom$getCancelButton.click(); 4369 }; 4370 4371 /** @type {Record<DismissReason, DismissReason>} */ 4372 const DismissReason = Object.freeze({ 4373 cancel: 'cancel', 4374 backdrop: 'backdrop', 4375 close: 'close', 4376 esc: 'esc', 4377 timer: 'timer' 4378 }); 4379 4380 /** 4381 * @param {GlobalState} globalState 4382 */ 4383 const removeKeydownHandler = globalState => { 4384 if (globalState.keydownTarget && globalState.keydownHandlerAdded && globalState.keydownHandler) { 4385 const handler = /** @type {EventListenerOrEventListenerObject} */ 4386 /** @type {unknown} */globalState.keydownHandler; 4387 globalState.keydownTarget.removeEventListener('keydown', handler, { 4388 capture: globalState.keydownListenerCapture 4389 }); 4390 globalState.keydownHandlerAdded = false; 4391 } 4392 }; 4393 4394 /** 4395 * @param {GlobalState} globalState 4396 * @param {SweetAlertOptions} innerParams 4397 * @param {(dismiss: DismissReason) => void} dismissWith 4398 */ 4399 const addKeydownHandler = (globalState, innerParams, dismissWith) => { 4400 removeKeydownHandler(globalState); 4401 if (!innerParams.toast) { 4402 /** @type {(this: HTMLElement, event: KeyboardEvent) => void} */ 4403 const handler = e => keydownHandler(innerParams, e, dismissWith); 4404 globalState.keydownHandler = handler; 4405 const target = innerParams.keydownListenerCapture ? window : getPopup(); 4406 if (target) { 4407 globalState.keydownTarget = target; 4408 globalState.keydownListenerCapture = innerParams.keydownListenerCapture; 4409 const eventHandler = /** @type {EventListenerOrEventListenerObject} */ /** @type {unknown} */handler; 4410 globalState.keydownTarget.addEventListener('keydown', eventHandler, { 4411 capture: globalState.keydownListenerCapture 4412 }); 4413 globalState.keydownHandlerAdded = true; 4414 } 4415 } 4416 }; 4417 4418 /** 4419 * @param {number} index 4420 * @param {number} increment 4421 * @returns {boolean} shouldPreventDefault 4422 */ 4423 const setFocus = (index, increment) => { 4424 var _dom$getPopup; 4425 const focusableElements = getFocusableElements(); 4426 // search for visible elements and select the next possible match 4427 if (focusableElements.length) { 4428 index = index + increment; 4429 4430 // shift + tab when .swal2-popup is focused 4431 if (index === -2) { 4432 index = focusableElements.length - 1; 4433 } 4434 4435 // rollover to first item 4436 if (index === focusableElements.length) { 4437 index = 0; 4438 4439 // go to last item 4440 } else if (index === -1) { 4441 index = focusableElements.length - 1; 4442 } 4443 focusableElements[index].focus(); 4444 4445 // don't prevent default for iframes (Firefox fix) 4446 // https://github.com/sweetalert2/sweetalert2/issues/2931 4447 if (isFirefox() && focusableElements[index] instanceof HTMLIFrameElement) { 4448 return false; 4449 } 4450 return true; 4451 } 4452 // no visible focusable elements, focus the popup 4453 (_dom$getPopup = getPopup()) === null || _dom$getPopup === void 0 || _dom$getPopup.focus(); 4454 return true; 4455 }; 4456 const arrowKeysNextButton = ['ArrowRight', 'ArrowDown']; 4457 const arrowKeysPreviousButton = ['ArrowLeft', 'ArrowUp']; 4458 4459 /** 4460 * @param {SweetAlertOptions} innerParams 4461 * @param {KeyboardEvent} event 4462 * @param {(dismiss: DismissReason) => void} dismissWith 4463 */ 4464 const keydownHandler = (innerParams, event, dismissWith) => { 4465 if (!innerParams) { 4466 return; // This instance has already been destroyed 4467 } 4468 4469 // Ignore keydown during IME composition 4470 // https://developer.mozilla.org/en-US/docs/Web/API/Document/keydown_event#ignoring_keydown_during_ime_composition 4471 // https://github.com/sweetalert2/sweetalert2/issues/720 4472 // https://github.com/sweetalert2/sweetalert2/issues/2406 4473 if (event.isComposing || event.keyCode === 229) { 4474 return; 4475 } 4476 if (innerParams.stopKeydownPropagation) { 4477 event.stopPropagation(); 4478 } 4479 4480 // ENTER 4481 if (event.key === 'Enter') { 4482 handleEnter(event, innerParams); 4483 } 4484 4485 // TAB 4486 else if (event.key === 'Tab') { 4487 handleTab(event); 4488 } 4489 4490 // ARROWS - switch focus between buttons 4491 else if ([...arrowKeysNextButton, ...arrowKeysPreviousButton].includes(event.key)) { 4492 handleArrows(event.key); 4493 } 4494 4495 // ESC 4496 else if (event.key === 'Escape') { 4497 handleEsc(event, innerParams, dismissWith); 4498 } 4499 }; 4500 4501 /** 4502 * @param {KeyboardEvent} event 4503 * @param {SweetAlertOptions} innerParams 4504 */ 4505 const handleEnter = (event, innerParams) => { 4506 // https://github.com/sweetalert2/sweetalert2/issues/2386 4507 if (!callIfFunction(innerParams.allowEnterKey)) { 4508 return; 4509 } 4510 const popup = getPopup(); 4511 if (!popup || !innerParams.input) { 4512 return; 4513 } 4514 const input = getInput$1(popup, innerParams.input); 4515 if (event.target && input && event.target instanceof HTMLElement && event.target.outerHTML === input.outerHTML) { 4516 if (['textarea', 'file'].includes(innerParams.input)) { 4517 return; // do not submit 4518 } 4519 clickConfirm(); 4520 event.preventDefault(); 4521 } 4522 }; 4523 4524 /** 4525 * @param {KeyboardEvent} event 4526 */ 4527 const handleTab = event => { 4528 const targetElement = event.target; 4529 const focusableElements = getFocusableElements(); 4530 let btnIndex = -1; 4531 for (let i = 0; i < focusableElements.length; i++) { 4532 if (targetElement === focusableElements[i]) { 4533 btnIndex = i; 4534 break; 4535 } 4536 }
vendor: 22,898 bytes, lines 4536-5247
4536 4537 4538 // don't prevent default for iframes (Firefox fix) 4539 // https://github.com/sweetalert2/sweetalert2/issues/2931 4540 let shouldPreventDefault = true; 4541 4542 // Cycle to the next button 4543 if (!event.shiftKey) { 4544 shouldPreventDefault = setFocus(btnIndex, 1); 4545 } 4546 4547 // Cycle to the prev button 4548 else { 4549 shouldPreventDefault = setFocus(btnIndex, -1); 4550 } 4551 event.stopPropagation(); 4552 if (shouldPreventDefault) { 4553 event.preventDefault(); 4554 } 4555 }; 4556 4557 /** 4558 * @param {string} key 4559 */ 4560 const handleArrows = key => { 4561 const actions = getActions(); 4562 const confirmButton = getConfirmButton(); 4563 const denyButton = getDenyButton(); 4564 const cancelButton = getCancelButton(); 4565 if (!actions || !confirmButton || !denyButton || !cancelButton) { 4566 return; 4567 } 4568 /** @type HTMLElement[] */ 4569 const buttons = [confirmButton, denyButton, cancelButton]; 4570 if (document.activeElement instanceof HTMLElement && !buttons.includes(document.activeElement)) { 4571 return; 4572 } 4573 const sibling = arrowKeysNextButton.includes(key) ? 'nextElementSibling' : 'previousElementSibling'; 4574 let buttonToFocus = document.activeElement; 4575 if (!buttonToFocus) { 4576 return; 4577 } 4578 for (let i = 0; i < actions.children.length; i++) { 4579 buttonToFocus = buttonToFocus[sibling]; 4580 if (!buttonToFocus) { 4581 return; 4582 } 4583 if (buttonToFocus instanceof HTMLButtonElement && isVisible$1(buttonToFocus)) { 4584 break; 4585 } 4586 } 4587 if (buttonToFocus instanceof HTMLButtonElement) { 4588 buttonToFocus.focus(); 4589 } 4590 }; 4591 4592 /** 4593 * @param {KeyboardEvent} event 4594 * @param {SweetAlertOptions} innerParams 4595 * @param {(dismiss: DismissReason) => void} dismissWith 4596 */ 4597 const handleEsc = (event, innerParams, dismissWith) => { 4598 event.preventDefault(); 4599 if (callIfFunction(innerParams.allowEscapeKey)) { 4600 dismissWith(DismissReason.esc); 4601 } 4602 }; 4603 4604 /** 4605 * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has. 4606 * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')` 4607 * This is the approach that Babel will probably take to implement private methods/fields 4608 * https://github.com/tc39/proposal-private-methods 4609 * https://github.com/babel/babel/pull/7555 4610 * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module* 4611 * then we can use that language feature. 4612 */ 4613 4614 var privateMethods = { 4615 swalPromiseResolve: new WeakMap(), 4616 swalPromiseReject: new WeakMap() 4617 }; 4618 4619 // From https://developer.paciellogroup.com/blog/2018/06/the-current-state-of-modal-dialog-accessibility/ 4620 // Adding aria-hidden="true" to elements outside of the active modal dialog ensures that 4621 // elements not within the active modal dialog will not be surfaced if a user opens a screen 4622 // readerâs list of elements (headings, form controls, landmarks, etc.) in the document. 4623 4624 const setAriaHidden = () => { 4625 const container = getContainer(); 4626 const bodyChildren = Array.from(document.body.children); 4627 bodyChildren.forEach(el => { 4628 if (el.contains(container)) { 4629 return; 4630 } 4631 if (el.hasAttribute('aria-hidden')) { 4632 el.setAttribute('data-previous-aria-hidden', el.getAttribute('aria-hidden') || ''); 4633 } 4634 el.setAttribute('aria-hidden', 'true'); 4635 }); 4636 }; 4637 const unsetAriaHidden = () => { 4638 const bodyChildren = Array.from(document.body.children); 4639 bodyChildren.forEach(el => { 4640 if (el.hasAttribute('data-previous-aria-hidden')) { 4641 el.setAttribute('aria-hidden', el.getAttribute('data-previous-aria-hidden') || ''); 4642 el.removeAttribute('data-previous-aria-hidden'); 4643 } else { 4644 el.removeAttribute('aria-hidden'); 4645 } 4646 }); 4647 }; 4648 4649 // @ts-ignore 4650 const isSafariOrIOS = typeof window !== 'undefined' && Boolean(window.GestureEvent); // true for Safari desktop + all iOS browsers https://stackoverflow.com/a/70585394 4651 4652 // @ts-ignore 4653 const isIOS = isSafariOrIOS && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; 4654 4655 /** 4656 * Fix iOS scrolling 4657 * http://stackoverflow.com/q/39626302 4658 */ 4659 const iOSfix = () => { 4660 if (isSafariOrIOS && !hasClass(document.body, swalClasses.iosfix)) { 4661 const offset = document.body.scrollTop; 4662 document.body.style.top = `${offset * -1}px`; 4663 addClass(document.body, swalClasses.iosfix); 4664 lockBodyScroll(); 4665 } 4666 }; 4667 4668 /** 4669 * https://github.com/sweetalert2/sweetalert2/issues/1246 4670 */ 4671 const lockBodyScroll = () => { 4672 const container = getContainer(); 4673 if (!container) { 4674 return; 4675 } 4676 /** @type {boolean} */ 4677 let preventTouchMove; 4678 /** 4679 * @param {TouchEvent} event 4680 */ 4681 container.ontouchstart = event => { 4682 preventTouchMove = shouldPreventTouchMove(event); 4683 }; 4684 /** 4685 * @param {TouchEvent} event 4686 */ 4687 container.ontouchmove = event => { 4688 if (preventTouchMove) { 4689 event.preventDefault(); 4690 event.stopPropagation(); 4691 } 4692 }; 4693 }; 4694 4695 /** 4696 * @param {TouchEvent} event 4697 * @returns {boolean} 4698 */ 4699 const shouldPreventTouchMove = event => { 4700 const target = event.target; 4701 const container = getContainer(); 4702 const htmlContainer = getHtmlContainer(); 4703 if (!container || !htmlContainer) { 4704 return false; 4705 } 4706 if (isStylus(event) || isZoom(event)) { 4707 return false; 4708 } 4709 if (target === container) { 4710 return true; 4711 } 4712 if (!isScrollable(container) && target instanceof HTMLElement && !selfOrParentIsScrollable(target, htmlContainer) && 4713 // #2823 4714 target.tagName !== 'INPUT' && 4715 // #1603 4716 target.tagName !== 'TEXTAREA' && 4717 // #2266 4718 !(isScrollable(htmlContainer) && 4719 // #1944 4720 htmlContainer.contains(target))) { 4721 return true; 4722 } 4723 return false; 4724 }; 4725 4726 /** 4727 * https://github.com/sweetalert2/sweetalert2/issues/1786 4728 * 4729 * @param {TouchEvent} event 4730 * @returns {boolean} 4731 */ 4732 const isStylus = event => { 4733 return Boolean(event.touches && event.touches.length && 4734 // @ts-ignore - touchType is not a standard property 4735 event.touches[0].touchType === 'stylus'); 4736 }; 4737 4738 /** 4739 * https://github.com/sweetalert2/sweetalert2/issues/1891 4740 * 4741 * @param {TouchEvent} event 4742 * @returns {boolean} 4743 */ 4744 const isZoom = event => { 4745 return event.touches && event.touches.length > 1; 4746 }; 4747 const undoIOSfix = () => { 4748 if (hasClass(document.body, swalClasses.iosfix)) { 4749 const offset = parseInt(document.body.style.top, 10); 4750 removeClass(document.body, swalClasses.iosfix); 4751 document.body.style.top = ''; 4752 document.body.scrollTop = offset * -1; 4753 } 4754 }; 4755 4756 /** 4757 * Measure scrollbar width for padding body during modal show/hide 4758 * https://github.com/twbs/bootstrap/blob/master/js/src/modal.js 4759 * 4760 * @returns {number} 4761 */ 4762 const measureScrollbar = () => { 4763 const scrollDiv = document.createElement('div'); 4764 scrollDiv.className = swalClasses['scrollbar-measure']; 4765 document.body.appendChild(scrollDiv); 4766 const scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth; 4767 document.body.removeChild(scrollDiv); 4768 return scrollbarWidth; 4769 }; 4770 4771 /** 4772 * Remember state in cases where opening and handling a modal will fiddle with it. 4773 * @type {number | null} 4774 */ 4775 let previousBodyPadding = null; 4776 4777 /** 4778 * @param {string} initialBodyOverflow 4779 */ 4780 const replaceScrollbarWithPadding = initialBodyOverflow => { 4781 // for queues, do not do this more than once 4782 if (previousBodyPadding !== null) { 4783 return; 4784 } 4785 // if the body has overflow 4786 if (document.body.scrollHeight > window.innerHeight || initialBodyOverflow === 'scroll' // https://github.com/sweetalert2/sweetalert2/issues/2663 4787 ) { 4788 // add padding so the content doesn't shift after removal of scrollbar 4789 previousBodyPadding = parseInt(window.getComputedStyle(document.body).getPropertyValue('padding-right')); 4790 document.body.style.paddingRight = `${previousBodyPadding + measureScrollbar()}px`; 4791 } 4792 }; 4793 const undoReplaceScrollbarWithPadding = () => { 4794 if (previousBodyPadding !== null) { 4795 document.body.style.paddingRight = `${previousBodyPadding}px`; 4796 previousBodyPadding = null; 4797 } 4798 }; 4799 4800 /** 4801 * @param {SweetAlert} instance 4802 * @param {HTMLElement} container 4803 * @param {boolean} returnFocus 4804 * @param {(() => void) | undefined} didClose 4805 */ 4806 function removePopupAndResetState(instance, container, returnFocus, didClose) { 4807 if (isToast()) { 4808 triggerDidCloseAndDispose(instance, didClose); 4809 } else { 4810 restoreActiveElement(returnFocus).then(() => triggerDidCloseAndDispose(instance, didClose)); 4811 removeKeydownHandler(globalState); 4812 } 4813 4814 // workaround for https://github.com/sweetalert2/sweetalert2/issues/2088 4815 // for some reason removing the container in Safari will scroll the document to bottom 4816 if (isSafariOrIOS) { 4817 container.setAttribute('style', 'display:none !important'); 4818 container.removeAttribute('class'); 4819 container.innerHTML = ''; 4820 } else { 4821 container.remove(); 4822 } 4823 if (isModal()) { 4824 undoReplaceScrollbarWithPadding(); 4825 undoIOSfix(); 4826 unsetAriaHidden(); 4827 } 4828 removeBodyClasses(); 4829 } 4830 4831 /** 4832 * Remove SweetAlert2 classes from body 4833 */ 4834 function removeBodyClasses() { 4835 removeClass([document.documentElement, document.body], [swalClasses.shown, swalClasses['height-auto'], swalClasses['no-backdrop'], swalClasses['toast-shown']]); 4836 } 4837 4838 /** 4839 * Instance method to close sweetAlert 4840 * 4841 * @param {SweetAlertResult | undefined} resolveValue 4842 * @this {SweetAlert} 4843 */ 4844 function close(resolveValue) { 4845 resolveValue = prepareResolveValue(resolveValue); 4846 const swalPromiseResolve = privateMethods.swalPromiseResolve.get(this); 4847 const didClose = triggerClosePopup(this); 4848 if (this.isAwaitingPromise) { 4849 // A swal awaiting for a promise (after a click on Confirm or Deny) cannot be dismissed anymore #2335 4850 if (!resolveValue.isDismissed) { 4851 handleAwaitingPromise(this); 4852 swalPromiseResolve(resolveValue); 4853 } 4854 } else if (didClose) { 4855 // Resolve Swal promise 4856 swalPromiseResolve(resolveValue); 4857 } 4858 } 4859 4860 /** 4861 * @param {SweetAlert} instance 4862 * @returns {boolean} 4863 */ 4864 const triggerClosePopup = instance => { 4865 const popup = getPopup(); 4866 if (!popup) { 4867 return false; 4868 } 4869 const innerParams = privateProps.innerParams.get(instance); 4870 if (!innerParams || hasClass(popup, innerParams.hideClass.popup)) { 4871 return false; 4872 } 4873 removeClass(popup, innerParams.showClass.popup); 4874 addClass(popup, innerParams.hideClass.popup); 4875 const backdrop = getContainer(); 4876 removeClass(backdrop, innerParams.showClass.backdrop); 4877 addClass(backdrop, innerParams.hideClass.backdrop); 4878 handlePopupAnimation(instance, popup, innerParams); 4879 return true; 4880 }; 4881 4882 /** 4883 * @param {Error | string} error 4884 * @this {SweetAlert} 4885 */ 4886 function rejectPromise(error) { 4887 const rejectPromise = privateMethods.swalPromiseReject.get(this); 4888 handleAwaitingPromise(this); 4889 if (rejectPromise) { 4890 // Reject Swal promise 4891 rejectPromise(error); 4892 } 4893 } 4894 4895 /** 4896 * @param {SweetAlert} instance 4897 */ 4898 const handleAwaitingPromise = instance => { 4899 if (instance.isAwaitingPromise) { 4900 // @ts-ignore 4901 delete instance.isAwaitingPromise; 4902 // The instance might have been previously partly destroyed, we must resume the destroy process in this case #2335 4903 if (!privateProps.innerParams.get(instance)) { 4904 instance._destroy(); 4905 } 4906 } 4907 }; 4908 4909 /** 4910 * @param {SweetAlertResult | undefined} resolveValue 4911 * @returns {SweetAlertResult} 4912 */ 4913 const prepareResolveValue = resolveValue => { 4914 // When user calls Swal.close() 4915 if (typeof resolveValue === 'undefined') { 4916 return { 4917 isConfirmed: false, 4918 isDenied: false, 4919 isDismissed: true 4920 }; 4921 } 4922 return Object.assign({ 4923 isConfirmed: false, 4924 isDenied: false, 4925 isDismissed: false 4926 }, resolveValue); 4927 }; 4928 4929 /** 4930 * @param {SweetAlert} instance 4931 * @param {HTMLElement} popup 4932 * @param {SweetAlertOptions} innerParams 4933 */ 4934 const handlePopupAnimation = (instance, popup, innerParams) => { 4935 var _globalState$eventEmi; 4936 const container = getContainer(); 4937 // If animation is supported, animate 4938 const animationIsSupported = hasCssAnimation(popup); 4939 if (typeof innerParams.willClose === 'function') { 4940 innerParams.willClose(popup); 4941 } 4942 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('willClose', popup); 4943 if (animationIsSupported && container) { 4944 animatePopup(instance, popup, container, Boolean(innerParams.returnFocus), innerParams.didClose); 4945 } else if (container) { 4946 // Otherwise, remove immediately 4947 removePopupAndResetState(instance, container, Boolean(innerParams.returnFocus), innerParams.didClose); 4948 } 4949 }; 4950 4951 /** 4952 * @param {SweetAlert} instance 4953 * @param {HTMLElement} popup 4954 * @param {HTMLElement} container 4955 * @param {boolean} returnFocus 4956 * @param {(() => void) | undefined} didClose 4957 */ 4958 const animatePopup = (instance, popup, container, returnFocus, didClose) => { 4959 globalState.swalCloseEventFinishedCallback = removePopupAndResetState.bind(null, instance, container, returnFocus, didClose); 4960 /** 4961 * @param {AnimationEvent | TransitionEvent} e 4962 */ 4963 const swalCloseAnimationFinished = function (e) { 4964 if (e.target === popup) { 4965 var _globalState$swalClos; 4966 (_globalState$swalClos = globalState.swalCloseEventFinishedCallback) === null || _globalState$swalClos === void 0 || _globalState$swalClos.call(globalState); 4967 delete globalState.swalCloseEventFinishedCallback; 4968 popup.removeEventListener('animationend', swalCloseAnimationFinished); 4969 popup.removeEventListener('transitionend', swalCloseAnimationFinished); 4970 } 4971 }; 4972 popup.addEventListener('animationend', swalCloseAnimationFinished); 4973 popup.addEventListener('transitionend', swalCloseAnimationFinished); 4974 }; 4975 4976 /** 4977 * @param {SweetAlert} instance 4978 * @param {(() => void) | undefined} didClose 4979 */ 4980 const triggerDidCloseAndDispose = (instance, didClose) => { 4981 setTimeout(() => { 4982 var _globalState$eventEmi2; 4983 if (typeof didClose === 'function') { 4984 didClose.bind(instance.params)(); 4985 } 4986 (_globalState$eventEmi2 = globalState.eventEmitter) === null || _globalState$eventEmi2 === void 0 || _globalState$eventEmi2.emit('didClose'); 4987 // instance might have been destroyed already 4988 if (instance._destroy) { 4989 instance._destroy(); 4990 } 4991 }); 4992 }; 4993 4994 /** 4995 * Shows loader (spinner), this is useful with AJAX requests. 4996 * By default the loader be shown instead of the "Confirm" button. 4997 * 4998 * @param {HTMLButtonElement | null} [buttonToReplace] 4999 */ 5000 const showLoading = buttonToReplace => { 5001 let popup = getPopup(); 5002 if (!popup) { 5003 new Swal(); 5004 } 5005 popup = getPopup(); 5006 if (!popup) { 5007 return; 5008 } 5009 const loader = getLoader(); 5010 if (isToast()) { 5011 hide(getIcon()); 5012 } else { 5013 replaceButton(popup, buttonToReplace); 5014 } 5015 show(loader); 5016 popup.setAttribute('data-loading', 'true'); 5017 popup.setAttribute('aria-busy', 'true'); 5018 popup.focus(); 5019 }; 5020 5021 /** 5022 * @param {HTMLElement} popup 5023 * @param {HTMLButtonElement | null} [buttonToReplace] 5024 */ 5025 const replaceButton = (popup, buttonToReplace) => { 5026 const actions = getActions(); 5027 const loader = getLoader(); 5028 if (!actions || !loader) { 5029 return; 5030 } 5031 if (!buttonToReplace && isVisible$1(getConfirmButton())) { 5032 buttonToReplace = getConfirmButton(); 5033 } 5034 show(actions); 5035 if (buttonToReplace) { 5036 hide(buttonToReplace); 5037 loader.setAttribute('data-button-to-replace', buttonToReplace.className); 5038 actions.insertBefore(loader, buttonToReplace); 5039 } 5040 addClass([popup, actions], swalClasses.loading); 5041 }; 5042 5043 /** 5044 * @param {SweetAlert} instance 5045 * @param {SweetAlertOptions} params 5046 */ 5047 const handleInputOptionsAndValue = (instance, params) => { 5048 if (params.input === 'select' || params.input === 'radio') { 5049 handleInputOptions(instance, params); 5050 } else if (['text', 'email', 'number', 'tel', 'textarea'].some(i => i === params.input) && (hasToPromiseFn(params.inputValue) || isPromise(params.inputValue))) { 5051 showLoading(getConfirmButton()); 5052 handleInputValue(instance, params); 5053 } 5054 }; 5055 5056 /** 5057 * @param {SweetAlert} instance 5058 * @param {SweetAlertOptions} innerParams 5059 * @returns {SweetAlertInputValue} 5060 */ 5061 const getInputValue = (instance, innerParams) => { 5062 const input = instance.getInput(); 5063 if (!input) { 5064 return null; 5065 } 5066 switch (innerParams.input) { 5067 case 'checkbox': 5068 return getCheckboxValue(input); 5069 case 'radio': 5070 return getRadioValue(input); 5071 case 'file': 5072 return getFileValue(input); 5073 default: 5074 return innerParams.inputAutoTrim ? input.value.trim() : input.value; 5075 } 5076 }; 5077 5078 /** 5079 * @param {HTMLInputElement} input 5080 * @returns {number} 5081 */ 5082 const getCheckboxValue = input => input.checked ? 1 : 0; 5083 5084 /** 5085 * @param {HTMLInputElement} input 5086 * @returns {string | null} 5087 */ 5088 const getRadioValue = input => input.checked ? input.value : null; 5089 5090 /** 5091 * @param {HTMLInputElement} input 5092 * @returns {FileList | File | null} 5093 */ 5094 const getFileValue = input => input.files && input.files.length ? input.getAttribute('multiple') !== null ? input.files : input.files[0] : null; 5095 5096 /** 5097 * @param {SweetAlert} instance 5098 * @param {SweetAlertOptions} params 5099 */ 5100 const handleInputOptions = (instance, params) => { 5101 const popup = getPopup(); 5102 if (!popup) { 5103 return; 5104 } 5105 /** 5106 * @param {*} inputOptions 5107 */ 5108 const processInputOptions = inputOptions => { 5109 if (params.input === 'select') { 5110 populateSelectOptions(popup, formatInputOptions(inputOptions), params); 5111 } else if (params.input === 'radio') { 5112 populateRadioOptions(popup, formatInputOptions(inputOptions), params); 5113 } 5114 }; 5115 if (hasToPromiseFn(params.inputOptions) || isPromise(params.inputOptions)) { 5116 showLoading(getConfirmButton()); 5117 asPromise(params.inputOptions).then(inputOptions => { 5118 instance.hideLoading(); 5119 processInputOptions(inputOptions); 5120 }); 5121 } else if (typeof params.inputOptions === 'object') { 5122 processInputOptions(params.inputOptions); 5123 } else { 5124 error(`Unexpected type of inputOptions! Expected object, Map or Promise, got ${typeof params.inputOptions}`); 5125 } 5126 }; 5127 5128 /** 5129 * @param {SweetAlert} instance 5130 * @param {SweetAlertOptions} params 5131 */ 5132 const handleInputValue = (instance, params) => { 5133 const input = instance.getInput(); 5134 if (!input) { 5135 return; 5136 } 5137 hide(input); 5138 asPromise(params.inputValue).then(inputValue => { 5139 input.value = params.input === 'number' ? `${parseFloat(inputValue) || 0}` : `${inputValue}`; 5140 show(input); 5141 input.focus(); 5142 instance.hideLoading(); 5143 }).catch(err => { 5144 error(`Error in inputValue promise: ${err}`); 5145 input.value = ''; 5146 show(input); 5147 input.focus(); 5148 instance.hideLoading(); 5149 }); 5150 }; 5151 5152 /** 5153 * @param {HTMLElement} popup 5154 * @param {InputOptionFlattened[]} inputOptions 5155 * @param {SweetAlertOptions} params 5156 */ 5157 function populateSelectOptions(popup, inputOptions, params) { 5158 const select = getDirectChildByClass(popup, swalClasses.select); 5159 if (!select) { 5160 return; 5161 } 5162 /** 5163 * @param {HTMLElement} parent 5164 * @param {string} optionLabel 5165 * @param {string} optionValue 5166 */ 5167 const renderOption = (parent, optionLabel, optionValue) => { 5168 const option = document.createElement('option'); 5169 option.value = optionValue; 5170 setInnerHtml(option, optionLabel); 5171 option.selected = isSelected(optionValue, params.inputValue); 5172 parent.appendChild(option); 5173 }; 5174 inputOptions.forEach(inputOption => { 5175 const optionValue = inputOption[0]; 5176 const optionLabel = inputOption[1]; 5177 // <optgroup> spec: 5178 // https://www.w3.org/TR/html401/interact/forms.html#h-17.6 5179 // "...all OPTGROUP elements must be specified directly within a SELECT element (i.e., groups may not be nested)..." 5180 // check whether this is a <optgroup> 5181 if (Array.isArray(optionLabel)) { 5182 // if it is an array, then it is an <optgroup> 5183 const optgroup = document.createElement('optgroup'); 5184 optgroup.label = optionValue; 5185 optgroup.disabled = false; // not configurable for now 5186 select.appendChild(optgroup); 5187 optionLabel.forEach(o => renderOption(optgroup, o[1], o[0])); 5188 } else { 5189 // case of <option> 5190 renderOption(select, optionLabel, optionValue); 5191 } 5192 }); 5193 select.focus(); 5194 } 5195 5196 /** 5197 * @param {HTMLElement} popup 5198 * @param {InputOptionFlattened[]} inputOptions 5199 * @param {SweetAlertOptions} params 5200 */ 5201 function populateRadioOptions(popup, inputOptions, params) { 5202 const radio = getDirectChildByClass(popup, swalClasses.radio); 5203 if (!radio) { 5204 return; 5205 } 5206 inputOptions.forEach(inputOption => { 5207 const radioValue = inputOption[0]; 5208 const radioLabel = inputOption[1]; 5209 const radioInput = document.createElement('input'); 5210 const radioLabelElement = document.createElement('label'); 5211 radioInput.type = 'radio'; 5212 radioInput.name = swalClasses.radio; 5213 radioInput.value = radioValue; 5214 if (isSelected(radioValue, params.inputValue)) { 5215 radioInput.checked = true; 5216 } 5217 const label = document.createElement('span'); 5218 setInnerHtml(label, radioLabel); 5219 label.className = swalClasses.label; 5220 radioLabelElement.appendChild(radioInput); 5221 radioLabelElement.appendChild(label); 5222 radio.appendChild(radioLabelElement); 5223 }); 5224 const radios = radio.querySelectorAll('input'); 5225 if (radios.length) { 5226 radios[0].focus(); 5227 } 5228 } 5229 5230 /** 5231 * Converts `inputOptions` into an array of `[value, label]`s 5232 * 5233 * @param {*} inputOptions 5234 * @typedef {string[]} InputOptionFlattened 5235 * @returns {InputOptionFlattened[]} 5236 */ 5237 const formatInputOptions = inputOptions => { 5238 const entries = inputOptions instanceof Map ? Array.from(inputOptions) : Object.entries(inputOptions); 5239 return entries.map(([key, value]) => [key, typeof value === 'object' ? formatInputOptions(value) : value]); // case of <optgroup> 5240 }; 5241 5242 /** 5243 * @param {string} optionValue 5244 * @param {SweetAlertInputValue} inputValue 5245 * @returns {boolean} 5246 */ 5247 const isSelected = (optionValue, inputValue) =>
vendor: 8,097 bytes, lines 5247-5496
5247{ 5248 return Boolean(inputValue) && inputValue !== null && inputValue !== undefined && inputValue.toString() === optionValue.toString(); 5249 }; 5250 5251 /** 5252 * @param {SweetAlert} instance 5253 */ 5254 const handleConfirmButtonClick = instance => { 5255 const innerParams = privateProps.innerParams.get(instance); 5256 instance.disableButtons(); 5257 if (innerParams.input) { 5258 handleConfirmOrDenyWithInput(instance, 'confirm'); 5259 } else { 5260 confirm(instance, true); 5261 } 5262 }; 5263 5264 /** 5265 * @param {SweetAlert} instance 5266 */ 5267 const handleDenyButtonClick = instance => { 5268 const innerParams = privateProps.innerParams.get(instance); 5269 instance.disableButtons(); 5270 if (innerParams.returnInputValueOnDeny) { 5271 handleConfirmOrDenyWithInput(instance, 'deny'); 5272 } else { 5273 deny(instance, false); 5274 } 5275 }; 5276 5277 /** 5278 * @param {SweetAlert} instance 5279 * @param {(dismiss: DismissReason) => void} dismissWith 5280 */ 5281 const handleCancelButtonClick = (instance, dismissWith) => { 5282 instance.disableButtons(); 5283 dismissWith(DismissReason.cancel); 5284 }; 5285 5286 /** 5287 * @param {SweetAlert} instance 5288 * @param {'confirm' | 'deny'} type 5289 */ 5290 const handleConfirmOrDenyWithInput = (instance, type) => { 5291 const innerParams = privateProps.innerParams.get(instance); 5292 if (!innerParams.input) { 5293 error(`The "input" parameter is needed to be set when using returnInputValueOn${capitalizeFirstLetter(type)}`); 5294 return; 5295 } 5296 const input = instance.getInput(); 5297 const inputValue = getInputValue(instance, innerParams); 5298 if (innerParams.inputValidator) { 5299 handleInputValidator(instance, inputValue, type); 5300 } else if (input && !input.checkValidity()) { 5301 instance.enableButtons(); 5302 instance.showValidationMessage(innerParams.validationMessage || input.validationMessage); 5303 } else if (type === 'deny') { 5304 deny(instance, inputValue); 5305 } else { 5306 confirm(instance, inputValue); 5307 } 5308 }; 5309 5310 /** 5311 * @param {SweetAlert} instance 5312 * @param {SweetAlertInputValue} inputValue 5313 * @param {'confirm' | 'deny'} type 5314 */ 5315 const handleInputValidator = (instance, inputValue, type) => { 5316 const innerParams = privateProps.innerParams.get(instance); 5317 instance.disableInput(); 5318 const validationPromise = Promise.resolve().then(() => asPromise(innerParams.inputValidator(inputValue, innerParams.validationMessage))); 5319 validationPromise.then(validationMessage => { 5320 instance.enableButtons(); 5321 instance.enableInput(); 5322 if (validationMessage) { 5323 instance.showValidationMessage(validationMessage); 5324 } else if (type === 'deny') { 5325 deny(instance, inputValue); 5326 } else { 5327 confirm(instance, inputValue); 5328 } 5329 }); 5330 }; 5331 5332 /** 5333 * @param {SweetAlert} instance 5334 * @param {*} value 5335 */ 5336 const deny = (instance, value) => { 5337 const innerParams = privateProps.innerParams.get(instance); 5338 if (innerParams.showLoaderOnDeny) { 5339 showLoading(getDenyButton()); 5340 } 5341 if (innerParams.preDeny) { 5342 instance.isAwaitingPromise = true; // Flagging the instance as awaiting a promise so it's own promise's reject/resolve methods doesn't get destroyed until the result from this preDeny's promise is received 5343 const preDenyPromise = Promise.resolve().then(() => asPromise(innerParams.preDeny(value, innerParams.validationMessage))); 5344 preDenyPromise.then(preDenyValue => { 5345 if (preDenyValue === false) { 5346 instance.hideLoading(); 5347 handleAwaitingPromise(instance); 5348 } else { 5349 instance.close(/** @type SweetAlertResult */{ 5350 isDenied: true, 5351 value: typeof preDenyValue === 'undefined' ? value : preDenyValue 5352 }); 5353 } 5354 }).catch(error => rejectWith(instance, error)); 5355 } else { 5356 instance.close(/** @type SweetAlertResult */{ 5357 isDenied: true, 5358 value 5359 }); 5360 } 5361 }; 5362 5363 /** 5364 * @param {SweetAlert} instance 5365 * @param {*} value 5366 */ 5367 const succeedWith = (instance, value) => { 5368 instance.close(/** @type SweetAlertResult */{ 5369 isConfirmed: true, 5370 value 5371 }); 5372 }; 5373 5374 /** 5375 * 5376 * @param {SweetAlert} instance 5377 * @param {string} error 5378 */ 5379 const rejectWith = (instance, error) => { 5380 instance.rejectPromise(error); 5381 }; 5382 5383 /** 5384 * 5385 * @param {SweetAlert} instance 5386 * @param {*} value 5387 */ 5388 const confirm = (instance, value) => { 5389 const innerParams = privateProps.innerParams.get(instance); 5390 if (innerParams.showLoaderOnConfirm) { 5391 showLoading(); 5392 } 5393 if (innerParams.preConfirm) { 5394 instance.resetValidationMessage(); 5395 instance.isAwaitingPromise = true; // Flagging the instance as awaiting a promise so it's own promise's reject/resolve methods doesn't get destroyed until the result from this preConfirm's promise is received 5396 const preConfirmPromise = Promise.resolve().then(() => asPromise(innerParams.preConfirm(value, innerParams.validationMessage))); 5397 preConfirmPromise.then(preConfirmValue => { 5398 if (isVisible$1(getValidationMessage()) || preConfirmValue === false) { 5399 instance.hideLoading(); 5400 handleAwaitingPromise(instance); 5401 } else { 5402 succeedWith(instance, typeof preConfirmValue === 'undefined' ? value : preConfirmValue); 5403 } 5404 }).catch(error => rejectWith(instance, error)); 5405 } else { 5406 succeedWith(instance, value); 5407 } 5408 }; 5409 5410 /** 5411 * Hides loader and shows back the button which was hidden by .showLoading() 5412 * @this {SweetAlert} 5413 */ 5414 function hideLoading() { 5415 // do nothing if popup is closed 5416 const innerParams = privateProps.innerParams.get(this); 5417 if (!innerParams) { 5418 return; 5419 } 5420 const domCache = privateProps.domCache.get(this); 5421 hide(domCache.loader); 5422 if (isToast()) { 5423 if (innerParams.icon) { 5424 show(getIcon()); 5425 } 5426 } else { 5427 showRelatedButton(domCache); 5428 } 5429 removeClass([domCache.popup, domCache.actions], swalClasses.loading); 5430 domCache.popup.removeAttribute('aria-busy'); 5431 domCache.popup.removeAttribute('data-loading'); 5432 domCache.confirmButton.disabled = false; 5433 domCache.denyButton.disabled = false; 5434 domCache.cancelButton.disabled = false; 5435 const focusedElement = privateProps.focusedElement.get(this); 5436 if (focusedElement instanceof HTMLElement && document.activeElement === document.body) { 5437 focusedElement.focus(); 5438 } 5439 privateProps.focusedElement.delete(this); 5440 } 5441 5442 /** 5443 * @param {DomCache} domCache 5444 */ 5445 const showRelatedButton = domCache => { 5446 const dataButtonToReplace = domCache.loader.getAttribute('data-button-to-replace'); 5447 const buttonToReplace = dataButtonToReplace ? domCache.popup.getElementsByClassName(dataButtonToReplace) : []; 5448 if (buttonToReplace.length) { 5449 show(/** @type {HTMLElement} */buttonToReplace[0], 'inline-block'); 5450 } else if (allButtonsAreHidden()) { 5451 hide(domCache.actions); 5452 } 5453 }; 5454 5455 /** 5456 * Gets the input DOM node, this method works with input parameter. 5457 * 5458 * @returns {HTMLInputElement | null} 5459 * @this {SweetAlert} 5460 */ 5461 function getInput() { 5462 const innerParams = privateProps.innerParams.get(this); 5463 const domCache = privateProps.domCache.get(this); 5464 if (!domCache) { 5465 return null; 5466 } 5467 return getInput$1(domCache.popup, innerParams.input); 5468 } 5469 5470 /** 5471 * @param {SweetAlert} instance 5472 * @param {string[]} buttons 5473 * @param {boolean} disabled 5474 */ 5475 function setButtonsDisabled(instance, buttons, disabled) { 5476 const domCache = privateProps.domCache.get(instance); 5477 buttons.forEach(button => { 5478 domCache[button].disabled = disabled; 5479 }); 5480 } 5481 5482 /** 5483 * @param {HTMLInputElement | null} input 5484 * @param {boolean} disabled 5485 */ 5486 function setInputDisabled(input, disabled) { 5487 const popup = getPopup(); 5488 if (!popup || !input) { 5489 return; 5490 } 5491 if (input.type === 'radio') { 5492 /** @type {NodeListOf<HTMLInputElement>} */ 5493 const radios = popup.querySelectorAll(`[name="${swalClasses.radio}"]`); 5494 for (let i = 0; i < radios.length; i++) { 5495 radios[i].disabled = disabled; 5496 }
vendor: 53,846 bytes, lines 5496-7201
5496 5497 } else { 5498 input.disabled = disabled; 5499 } 5500 } 5501 5502 /** 5503 * Enable all the buttons 5504 * @this {SweetAlert} 5505 */ 5506 function enableButtons() { 5507 setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], false); 5508 const focusedElement = privateProps.focusedElement.get(this); 5509 if (focusedElement instanceof HTMLElement && document.activeElement === document.body) { 5510 focusedElement.focus(); 5511 } 5512 privateProps.focusedElement.delete(this); 5513 } 5514 5515 /** 5516 * Disable all the buttons 5517 * @this {SweetAlert} 5518 */ 5519 function disableButtons() { 5520 privateProps.focusedElement.set(this, document.activeElement); 5521 setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], true); 5522 } 5523 5524 /** 5525 * Enable the input field 5526 * @this {SweetAlert} 5527 */ 5528 function enableInput() { 5529 setInputDisabled(this.getInput(), false); 5530 } 5531 5532 /** 5533 * Disable the input field 5534 * @this {SweetAlert} 5535 */ 5536 function disableInput() { 5537 setInputDisabled(this.getInput(), true); 5538 } 5539 5540 /** 5541 * Show block with validation message 5542 * 5543 * @param {string} error 5544 * @this {SweetAlert} 5545 */ 5546 function showValidationMessage(error) { 5547 const domCache = privateProps.domCache.get(this); 5548 const params = privateProps.innerParams.get(this); 5549 setInnerHtml(domCache.validationMessage, error); 5550 domCache.validationMessage.className = swalClasses['validation-message']; 5551 if (params.customClass && params.customClass.validationMessage) { 5552 addClass(domCache.validationMessage, params.customClass.validationMessage); 5553 } 5554 show(domCache.validationMessage); 5555 const input = this.getInput(); 5556 if (input) { 5557 input.setAttribute('aria-invalid', 'true'); 5558 input.setAttribute('aria-describedby', swalClasses['validation-message']); 5559 focusInput(input); 5560 addClass(input, swalClasses.inputerror); 5561 } 5562 } 5563 5564 /** 5565 * Hide block with validation message 5566 * 5567 * @this {SweetAlert} 5568 */ 5569 function resetValidationMessage() { 5570 const domCache = privateProps.domCache.get(this); 5571 if (domCache.validationMessage) { 5572 hide(domCache.validationMessage); 5573 } 5574 const input = this.getInput(); 5575 if (input) { 5576 input.removeAttribute('aria-invalid'); 5577 input.removeAttribute('aria-describedby'); 5578 removeClass(input, swalClasses.inputerror); 5579 } 5580 } 5581 5582 const defaultParams = { 5583 title: '', 5584 titleText: '', 5585 text: '', 5586 html: '', 5587 footer: '', 5588 icon: undefined, 5589 iconColor: undefined, 5590 iconHtml: undefined, 5591 template: undefined, 5592 toast: false, 5593 draggable: false, 5594 animation: true, 5595 theme: 'light', 5596 showClass: { 5597 popup: 'swal2-show', 5598 backdrop: 'swal2-backdrop-show', 5599 icon: 'swal2-icon-show' 5600 }, 5601 hideClass: { 5602 popup: 'swal2-hide', 5603 backdrop: 'swal2-backdrop-hide', 5604 icon: 'swal2-icon-hide' 5605 }, 5606 customClass: {}, 5607 target: 'body', 5608 color: undefined, 5609 backdrop: true, 5610 heightAuto: true, 5611 allowOutsideClick: true, 5612 allowEscapeKey: true, 5613 allowEnterKey: true, 5614 stopKeydownPropagation: true, 5615 keydownListenerCapture: false, 5616 showConfirmButton: true, 5617 showDenyButton: false, 5618 showCancelButton: false, 5619 preConfirm: undefined, 5620 preDeny: undefined, 5621 confirmButtonText: 'OK', 5622 confirmButtonAriaLabel: '', 5623 confirmButtonColor: undefined, 5624 denyButtonText: 'No', 5625 denyButtonAriaLabel: '', 5626 denyButtonColor: undefined, 5627 cancelButtonText: 'Cancel', 5628 cancelButtonAriaLabel: '', 5629 cancelButtonColor: undefined, 5630 buttonsStyling: true, 5631 reverseButtons: false, 5632 focusConfirm: true, 5633 focusDeny: false, 5634 focusCancel: false, 5635 returnFocus: true, 5636 showCloseButton: false, 5637 closeButtonHtml: '×', 5638 closeButtonAriaLabel: 'Close this dialog', 5639 loaderHtml: '', 5640 showLoaderOnConfirm: false, 5641 showLoaderOnDeny: false, 5642 imageUrl: undefined, 5643 imageWidth: undefined, 5644 imageHeight: undefined, 5645 imageAlt: '', 5646 timer: undefined, 5647 timerProgressBar: false, 5648 width: undefined, 5649 padding: undefined, 5650 background: undefined, 5651 input: undefined, 5652 inputPlaceholder: '', 5653 inputLabel: '', 5654 inputValue: '', 5655 inputOptions: {}, 5656 inputAutoFocus: true, 5657 inputAutoTrim: true, 5658 inputAttributes: {}, 5659 inputValidator: undefined, 5660 returnInputValueOnDeny: false, 5661 validationMessage: undefined, 5662 grow: false, 5663 position: 'center', 5664 progressSteps: [], 5665 currentProgressStep: undefined, 5666 progressStepsDistance: undefined, 5667 willOpen: undefined, 5668 didOpen: undefined, 5669 didRender: undefined, 5670 willClose: undefined, 5671 didClose: undefined, 5672 didDestroy: undefined, 5673 scrollbarPadding: true, 5674 topLayer: false 5675 }; 5676 const updatableParams = ['allowEscapeKey', 'allowOutsideClick', 'background', 'buttonsStyling', 'cancelButtonAriaLabel', 'cancelButtonColor', 'cancelButtonText', 'closeButtonAriaLabel', 'closeButtonHtml', 'color', 'confirmButtonAriaLabel', 'confirmButtonColor', 'confirmButtonText', 'currentProgressStep', 'customClass', 'denyButtonAriaLabel', 'denyButtonColor', 'denyButtonText', 'didClose', 'didDestroy', 'draggable', 'footer', 'hideClass', 'html', 'icon', 'iconColor', 'iconHtml', 'imageAlt', 'imageHeight', 'imageUrl', 'imageWidth', 'preConfirm', 'preDeny', 'progressSteps', 'returnFocus', 'reverseButtons', 'showCancelButton', 'showCloseButton', 'showConfirmButton', 'showDenyButton', 'text', 'title', 'titleText', 'theme', 'willClose']; 5677 5678 /** @type {Record<string, string | undefined>} */ 5679 const deprecatedParams = { 5680 allowEnterKey: undefined 5681 }; 5682 const toastIncompatibleParams = ['allowOutsideClick', 'allowEnterKey', 'backdrop', 'draggable', 'focusConfirm', 'focusDeny', 'focusCancel', 'returnFocus', 'heightAuto', 'keydownListenerCapture']; 5683 5684 /** 5685 * Is valid parameter 5686 * 5687 * @param {string} paramName 5688 * @returns {boolean} 5689 */ 5690 const isValidParameter = paramName => { 5691 return Object.prototype.hasOwnProperty.call(defaultParams, paramName); 5692 }; 5693 5694 /** 5695 * Is valid parameter for Swal.update() method 5696 * 5697 * @param {string} paramName 5698 * @returns {boolean} 5699 */ 5700 const isUpdatableParameter = paramName => { 5701 return updatableParams.indexOf(paramName) !== -1; 5702 }; 5703 5704 /** 5705 * Is deprecated parameter 5706 * 5707 * @param {string} paramName 5708 * @returns {string | undefined} 5709 */ 5710 const isDeprecatedParameter = paramName => { 5711 return deprecatedParams[paramName]; 5712 }; 5713 5714 /** 5715 * @param {string} param 5716 */ 5717 const checkIfParamIsValid = param => { 5718 if (!isValidParameter(param)) { 5719 warn(`Unknown parameter "${param}"`); 5720 } 5721 }; 5722 5723 /** 5724 * @param {string} param 5725 */ 5726 const checkIfToastParamIsValid = param => { 5727 if (toastIncompatibleParams.includes(param)) { 5728 warn(`The parameter "${param}" is incompatible with toasts`); 5729 } 5730 }; 5731 5732 /** 5733 * @param {string} param 5734 */ 5735 const checkIfParamIsDeprecated = param => { 5736 const isDeprecated = isDeprecatedParameter(param); 5737 if (isDeprecated) { 5738 warnAboutDeprecation(param, isDeprecated); 5739 } 5740 }; 5741 5742 /** 5743 * Show relevant warnings for given params 5744 * 5745 * @param {SweetAlertOptions} params 5746 */ 5747 const showWarningsForParams = params => { 5748 if (params.backdrop === false && params.allowOutsideClick) { 5749 warn('"allowOutsideClick" parameter requires `backdrop` parameter to be set to `true`'); 5750 } 5751 if (params.theme && !['light', 'dark', 'auto', 'minimal', 'borderless', 'bootstrap-4', 'bootstrap-4-light', 'bootstrap-4-dark', 'bootstrap-5', 'bootstrap-5-light', 'bootstrap-5-dark', 'material-ui', 'material-ui-light', 'material-ui-dark', 'embed-iframe', 'bulma', 'bulma-light', 'bulma-dark'].includes(params.theme)) { 5752 warn(`Invalid theme "${params.theme}"`); 5753 } 5754 for (const param in params) { 5755 checkIfParamIsValid(param); 5756 if (params.toast) { 5757 checkIfToastParamIsValid(param); 5758 } 5759 checkIfParamIsDeprecated(param); 5760 } 5761 }; 5762 5763 /** 5764 * Updates popup parameters. 5765 * 5766 * @this {any} 5767 * @param {SweetAlertOptions} params 5768 */ 5769 function update(params) { 5770 const container = getContainer(); 5771 const popup = getPopup(); 5772 const innerParams = privateProps.innerParams.get(this); 5773 if (!popup || hasClass(popup, innerParams.hideClass.popup)) { 5774 warn(`You're trying to update the closed or closing popup, that won't work. Use the update() method in preConfirm parameter or show a new popup.`); 5775 return; 5776 } 5777 const validUpdatableParams = filterValidParams(params); 5778 const updatedParams = Object.assign({}, innerParams, validUpdatableParams); 5779 showWarningsForParams(updatedParams); 5780 if (container) { 5781 container.dataset['swal2Theme'] = updatedParams.theme; 5782 } 5783 render(this, updatedParams); 5784 privateProps.innerParams.set(this, updatedParams); 5785 Object.defineProperties(this, { 5786 params: { 5787 value: Object.assign({}, this.params, params), 5788 writable: false, 5789 enumerable: true 5790 } 5791 }); 5792 } 5793 5794 /** 5795 * @param {SweetAlertOptions} params 5796 * @returns {SweetAlertOptions} 5797 */ 5798 const filterValidParams = params => { 5799 /** @type {Record<string, any>} */ 5800 const validUpdatableParams = {}; 5801 Object.keys(params).forEach(param => { 5802 if (isUpdatableParameter(param)) { 5803 const typedParams = /** @type {Record<string, any>} */params; 5804 validUpdatableParams[param] = typedParams[param]; 5805 } else { 5806 warn(`Invalid parameter to update: ${param}`); 5807 } 5808 }); 5809 return validUpdatableParams; 5810 }; 5811 5812 /** 5813 * Dispose the current SweetAlert2 instance 5814 * @this {SweetAlert} 5815 */ 5816 function _destroy() { 5817 var _globalState$eventEmi; 5818 const domCache = privateProps.domCache.get(this); 5819 const innerParams = privateProps.innerParams.get(this); 5820 if (!innerParams) { 5821 disposeWeakMaps(this); // The WeakMaps might have been partly destroyed, we must recall it to dispose any remaining WeakMaps #2335 5822 return; // This instance has already been destroyed 5823 } 5824 5825 // Check if there is another Swal closing 5826 if (domCache.popup && globalState.swalCloseEventFinishedCallback) { 5827 globalState.swalCloseEventFinishedCallback(); 5828 delete globalState.swalCloseEventFinishedCallback; 5829 } 5830 if (typeof innerParams.didDestroy === 'function') { 5831 innerParams.didDestroy(); 5832 } 5833 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('didDestroy'); 5834 disposeSwal(this); 5835 } 5836 5837 /** 5838 * @param {SweetAlert} instance 5839 */ 5840 const disposeSwal = instance => { 5841 disposeWeakMaps(instance); 5842 // Unset this.params so GC will dispose it (#1569) 5843 // @ts-ignore 5844 delete instance.params; 5845 // Unset globalState props so GC will dispose globalState (#1569) 5846 delete globalState.keydownHandler; 5847 delete globalState.keydownTarget; 5848 // Unset currentInstance 5849 delete globalState.currentInstance; 5850 }; 5851 5852 /** 5853 * @param {SweetAlert} instance 5854 */ 5855 const disposeWeakMaps = instance => { 5856 // If the current instance is awaiting a promise result, we keep the privateMethods to call them once the promise result is retrieved #2335 5857 if (instance.isAwaitingPromise) { 5858 unsetWeakMaps(privateProps, instance); 5859 instance.isAwaitingPromise = true; 5860 } else { 5861 unsetWeakMaps(privateMethods, instance); 5862 unsetWeakMaps(privateProps, instance); 5863 5864 // @ts-ignore 5865 delete instance.isAwaitingPromise; 5866 // Unset instance methods 5867 // @ts-ignore 5868 delete instance.disableButtons; 5869 // @ts-ignore 5870 delete instance.enableButtons; 5871 // @ts-ignore 5872 delete instance.getInput; 5873 // @ts-ignore 5874 delete instance.disableInput; 5875 // @ts-ignore 5876 delete instance.enableInput; 5877 // @ts-ignore 5878 delete instance.hideLoading; 5879 // @ts-ignore 5880 delete instance.disableLoading; 5881 // @ts-ignore 5882 delete instance.showValidationMessage; 5883 // @ts-ignore 5884 delete instance.resetValidationMessage; 5885 // @ts-ignore 5886 delete instance.close; 5887 // @ts-ignore 5888 delete instance.closePopup; 5889 // @ts-ignore 5890 delete instance.closeModal; 5891 // @ts-ignore 5892 delete instance.closeToast; 5893 // @ts-ignore 5894 delete instance.rejectPromise; 5895 // @ts-ignore 5896 delete instance.update; 5897 // @ts-ignore 5898 delete instance._destroy; 5899 } 5900 }; 5901 5902 /** 5903 * @param {Record<string, WeakMap<any, any>>} obj 5904 * @param {SweetAlert} instance 5905 */ 5906 const unsetWeakMaps = (obj, instance) => { 5907 for (const i in obj) { 5908 obj[i].delete(instance); 5909 } 5910 }; 5911 5912 var instanceMethods = /*#__PURE__*/Object.freeze({ 5913 __proto__: null, 5914 _destroy: _destroy, 5915 close: close, 5916 closeModal: close, 5917 closePopup: close, 5918 closeToast: close, 5919 disableButtons: disableButtons, 5920 disableInput: disableInput, 5921 disableLoading: hideLoading, 5922 enableButtons: enableButtons, 5923 enableInput: enableInput, 5924 getInput: getInput, 5925 handleAwaitingPromise: handleAwaitingPromise, 5926 hideLoading: hideLoading, 5927 rejectPromise: rejectPromise, 5928 resetValidationMessage: resetValidationMessage, 5929 showValidationMessage: showValidationMessage, 5930 update: update 5931 }); 5932 5933 /** 5934 * @param {SweetAlertOptions} innerParams 5935 * @param {DomCache} domCache 5936 * @param {(dismiss: DismissReason) => void} dismissWith 5937 */ 5938 const handlePopupClick = (innerParams, domCache, dismissWith) => { 5939 if (innerParams.toast) { 5940 handleToastClick(innerParams, domCache, dismissWith); 5941 } else { 5942 // Ignore click events that had mousedown on the popup but mouseup on the container 5943 // This can happen when the user drags a slider 5944 handleModalMousedown(domCache); 5945 5946 // Ignore click events that had mousedown on the container but mouseup on the popup 5947 handleContainerMousedown(domCache); 5948 handleModalClick(innerParams, domCache, dismissWith); 5949 } 5950 }; 5951 5952 /** 5953 * @param {SweetAlertOptions} innerParams 5954 * @param {DomCache} domCache 5955 * @param {(dismiss: DismissReason) => void} dismissWith 5956 */ 5957 const handleToastClick = (innerParams, domCache, dismissWith) => { 5958 // Closing toast by internal click 5959 domCache.popup.onclick = () => { 5960 if (innerParams && (isAnyButtonShown(innerParams) || innerParams.timer || innerParams.input)) { 5961 return; 5962 } 5963 dismissWith(DismissReason.close); 5964 }; 5965 }; 5966 5967 /** 5968 * @param {SweetAlertOptions} innerParams 5969 * @returns {boolean} 5970 */ 5971 const isAnyButtonShown = innerParams => { 5972 return Boolean(innerParams.showConfirmButton || innerParams.showDenyButton || innerParams.showCancelButton || innerParams.showCloseButton); 5973 }; 5974 let ignoreOutsideClick = false; 5975 5976 /** 5977 * @param {DomCache} domCache 5978 */ 5979 const handleModalMousedown = domCache => { 5980 domCache.popup.onmousedown = () => { 5981 domCache.container.onmouseup = function (e) { 5982 domCache.container.onmouseup = () => {}; 5983 // We only check if the mouseup target is the container because usually it doesn't 5984 // have any other direct children aside of the popup 5985 if (e.target === domCache.container) { 5986 ignoreOutsideClick = true; 5987 } 5988 }; 5989 }; 5990 }; 5991 5992 /** 5993 * @param {DomCache} domCache 5994 */ 5995 const handleContainerMousedown = domCache => { 5996 domCache.container.onmousedown = e => { 5997 // prevent the modal text from being selected on double click on the container (allowOutsideClick: false) 5998 if (e.target === domCache.container) { 5999 e.preventDefault(); 6000 } 6001 domCache.popup.onmouseup = function (e) { 6002 domCache.popup.onmouseup = () => {}; 6003 // We also need to check if the mouseup target is a child of the popup 6004 if (e.target === domCache.popup || e.target instanceof HTMLElement && domCache.popup.contains(e.target)) { 6005 ignoreOutsideClick = true; 6006 } 6007 }; 6008 }; 6009 }; 6010 6011 /** 6012 * @param {SweetAlertOptions} innerParams 6013 * @param {DomCache} domCache 6014 * @param {(dismiss: DismissReason) => void} dismissWith 6015 */ 6016 const handleModalClick = (innerParams, domCache, dismissWith) => { 6017 domCache.container.onclick = e => { 6018 if (ignoreOutsideClick) { 6019 ignoreOutsideClick = false; 6020 return; 6021 } 6022 if (e.target === domCache.container && callIfFunction(innerParams.allowOutsideClick)) { 6023 dismissWith(DismissReason.backdrop); 6024 } 6025 }; 6026 }; 6027 6028 /** 6029 * @param {unknown} elem 6030 * @returns {boolean} 6031 */ 6032 const isJqueryElement = elem => typeof elem === 'object' && elem !== null && 'jquery' in elem; 6033 6034 /** 6035 * @param {unknown} elem 6036 * @returns {boolean} 6037 */ 6038 const isElement = elem => elem instanceof Element || isJqueryElement(elem); 6039 6040 /** 6041 * @param {ReadonlyArray<unknown>} args 6042 * @returns {SweetAlertOptions} 6043 */ 6044 const argsToParams = args => { 6045 /** @type {Record<string, unknown>} */ 6046 const params = {}; 6047 if (typeof args[0] === 'object' && !isElement(args[0])) { 6048 Object.assign(params, args[0]); 6049 } else { 6050 ['title', 'html', 'icon'].forEach((name, index) => { 6051 const arg = args[index]; 6052 if (typeof arg === 'string' || isElement(arg)) { 6053 params[name] = arg; 6054 } else if (arg !== undefined) { 6055 error(`Unexpected type of ${name}! Expected "string" or "Element", got ${typeof arg}`); 6056 } 6057 }); 6058 } 6059 return /** @type {SweetAlertOptions} */params; 6060 }; 6061 6062 /** 6063 * Main method to create a new SweetAlert2 popup 6064 * 6065 * @this {new (...args: any[]) => any} 6066 * @param {...SweetAlertOptions} args 6067 * @returns {Promise<SweetAlertResult>} 6068 */ 6069 function fire(...args) { 6070 return new this(...args); 6071 } 6072 6073 /** 6074 * Returns an extended version of `Swal` containing `params` as defaults. 6075 * Useful for reusing Swal configuration. 6076 * 6077 * For example: 6078 * 6079 * Before: 6080 * const textPromptOptions = { input: 'text', showCancelButton: true } 6081 * const {value: firstName} = await Swal.fire({ ...textPromptOptions, title: 'What is your first name?' }) 6082 * const {value: lastName} = await Swal.fire({ ...textPromptOptions, title: 'What is your last name?' }) 6083 * 6084 * After: 6085 * const TextPrompt = Swal.mixin({ input: 'text', showCancelButton: true }) 6086 * const {value: firstName} = await TextPrompt('What is your first name?') 6087 * const {value: lastName} = await TextPrompt('What is your last name?') 6088 * 6089 * @param {SweetAlertOptions} mixinParams 6090 * @returns {SweetAlert} 6091 * @this {typeof import('../SweetAlert.js').SweetAlert} 6092 */ 6093 function mixin(mixinParams) { 6094 // @ts-ignore: 'this' refers to the SweetAlert constructor 6095 class MixinSwal extends this { 6096 /** 6097 * @param {any} params 6098 * @param {any} priorityMixinParams 6099 */ 6100 _main(params, priorityMixinParams) { 6101 return super._main(params, Object.assign({}, mixinParams, priorityMixinParams)); 6102 } 6103 } 6104 // @ts-ignore 6105 return MixinSwal; 6106 } 6107 6108 /** 6109 * If `timer` parameter is set, returns number of milliseconds of timer remained. 6110 * Otherwise, returns undefined. 6111 * 6112 * @returns {number | undefined} 6113 */ 6114 const getTimerLeft = () => { 6115 return globalState.timeout && globalState.timeout.getTimerLeft(); 6116 }; 6117 6118 /** 6119 * Stop timer. Returns number of milliseconds of timer remained. 6120 * If `timer` parameter isn't set, returns undefined. 6121 * 6122 * @returns {number | undefined} 6123 */ 6124 const stopTimer = () => { 6125 if (globalState.timeout) { 6126 stopTimerProgressBar(); 6127 return globalState.timeout.stop(); 6128 } 6129 }; 6130 6131 /** 6132 * Resume timer. Returns number of milliseconds of timer remained. 6133 * If `timer` parameter isn't set, returns undefined. 6134 * 6135 * @returns {number | undefined} 6136 */ 6137 const resumeTimer = () => { 6138 if (globalState.timeout) { 6139 const remaining = globalState.timeout.start(); 6140 animateTimerProgressBar(remaining); 6141 return remaining; 6142 } 6143 }; 6144 6145 /** 6146 * Resume timer. Returns number of milliseconds of timer remained. 6147 * If `timer` parameter isn't set, returns undefined. 6148 * 6149 * @returns {number | undefined} 6150 */ 6151 const toggleTimer = () => { 6152 const timer = globalState.timeout; 6153 return timer && (timer.running ? stopTimer() : resumeTimer()); 6154 }; 6155 6156 /** 6157 * Increase timer. Returns number of milliseconds of an updated timer. 6158 * If `timer` parameter isn't set, returns undefined. 6159 * 6160 * @param {number} ms 6161 * @returns {number | undefined} 6162 */ 6163 const increaseTimer = ms => { 6164 if (globalState.timeout) { 6165 const remaining = globalState.timeout.increase(ms); 6166 animateTimerProgressBar(remaining, true); 6167 return remaining; 6168 } 6169 }; 6170 6171 /** 6172 * Check if timer is running. Returns true if timer is running 6173 * or false if timer is paused or stopped. 6174 * If `timer` parameter isn't set, returns undefined 6175 * 6176 * @returns {boolean} 6177 */ 6178 const isTimerRunning = () => { 6179 return Boolean(globalState.timeout && globalState.timeout.isRunning()); 6180 }; 6181 6182 let bodyClickListenerAdded = false; 6183 /** @type {Record<string, any>} */ 6184 const clickHandlers = {}; 6185 6186 /** 6187 * @this {any} 6188 * @param {string} attr 6189 */ 6190 function bindClickHandler(attr = 'data-swal-template') { 6191 clickHandlers[attr] = this; 6192 if (!bodyClickListenerAdded) { 6193 document.body.addEventListener('click', bodyClickListener); 6194 bodyClickListenerAdded = true; 6195 } 6196 } 6197 6198 /** 6199 * @param {MouseEvent} event 6200 */ 6201 const bodyClickListener = event => { 6202 for (let el = /** @type {any} */event.target; el && el !== document; el = el.parentNode) { 6203 for (const attr in clickHandlers) { 6204 const template = el.getAttribute && el.getAttribute(attr); 6205 if (template) { 6206 clickHandlers[attr].fire({ 6207 template 6208 }); 6209 return; 6210 } 6211 } 6212 } 6213 }; 6214 6215 // Source: https://gist.github.com/mudge/5830382?permalink_comment_id=2691957#gistcomment-2691957 6216 6217 class EventEmitter { 6218 constructor() { 6219 /** @type {Events} */ 6220 this.events = {}; 6221 } 6222 6223 /** 6224 * @param {string} eventName 6225 * @returns {EventHandlers} 6226 */ 6227 _getHandlersByEventName(eventName) { 6228 if (typeof this.events[eventName] === 'undefined') { 6229 // not Set because we need to keep the FIFO order 6230 // https://github.com/sweetalert2/sweetalert2/pull/2763#discussion_r1748990334 6231 this.events[eventName] = []; 6232 } 6233 return this.events[eventName]; 6234 } 6235 6236 /** 6237 * @param {string} eventName 6238 * @param {EventHandler} eventHandler 6239 */ 6240 on(eventName, eventHandler) { 6241 const currentHandlers = this._getHandlersByEventName(eventName); 6242 if (!currentHandlers.includes(eventHandler)) { 6243 currentHandlers.push(eventHandler); 6244 } 6245 } 6246 6247 /** 6248 * @param {string} eventName 6249 * @param {EventHandler} eventHandler 6250 */ 6251 once(eventName, eventHandler) { 6252 /** 6253 * @param {...any} args 6254 */ 6255 const onceFn = (...args) => { 6256 this.removeListener(eventName, onceFn); 6257 // @ts-ignore 6258 eventHandler.apply(this, args); 6259 }; 6260 this.on(eventName, onceFn); 6261 } 6262 6263 /** 6264 * @param {string} eventName 6265 * @param {...any} args 6266 */ 6267 emit(eventName, ...args) { 6268 this._getHandlersByEventName(eventName).forEach( 6269 /** 6270 * @param {EventHandler} eventHandler 6271 */ 6272 eventHandler => { 6273 try { 6274 // @ts-ignore 6275 eventHandler.apply(this, args); 6276 } catch (error) { 6277 console.error(error); 6278 } 6279 }); 6280 } 6281 6282 /** 6283 * @param {string} eventName 6284 * @param {EventHandler} eventHandler 6285 */ 6286 removeListener(eventName, eventHandler) { 6287 const currentHandlers = this._getHandlersByEventName(eventName); 6288 const index = currentHandlers.indexOf(eventHandler); 6289 if (index > -1) { 6290 currentHandlers.splice(index, 1); 6291 } 6292 } 6293 6294 /** 6295 * @param {string} eventName 6296 */ 6297 removeAllListeners(eventName) { 6298 if (this.events[eventName] !== undefined) { 6299 // https://github.com/sweetalert2/sweetalert2/pull/2763#discussion_r1749239222 6300 this.events[eventName].length = 0; 6301 } 6302 } 6303 reset() { 6304 this.events = {}; 6305 } 6306 } 6307 6308 globalState.eventEmitter = new EventEmitter(); 6309 6310 /** 6311 * @param {string} eventName 6312 * @param {EventHandler} eventHandler 6313 */ 6314 const on = (eventName, eventHandler) => { 6315 if (globalState.eventEmitter) { 6316 globalState.eventEmitter.on(eventName, eventHandler); 6317 } 6318 }; 6319 6320 /** 6321 * @param {string} eventName 6322 * @param {EventHandler} eventHandler 6323 */ 6324 const once = (eventName, eventHandler) => { 6325 if (globalState.eventEmitter) { 6326 globalState.eventEmitter.once(eventName, eventHandler); 6327 } 6328 }; 6329 6330 /** 6331 * @param {string} [eventName] 6332 * @param {EventHandler} [eventHandler] 6333 */ 6334 const off = (eventName, eventHandler) => { 6335 if (!globalState.eventEmitter) { 6336 return; 6337 } 6338 6339 // Remove all handlers for all events 6340 if (!eventName) { 6341 globalState.eventEmitter.reset(); 6342 return; 6343 } 6344 if (eventHandler) { 6345 // Remove a specific handler 6346 globalState.eventEmitter.removeListener(eventName, eventHandler); 6347 } else { 6348 // Remove all handlers for a specific event 6349 globalState.eventEmitter.removeAllListeners(eventName); 6350 } 6351 }; 6352 6353 var staticMethods = /*#__PURE__*/Object.freeze({ 6354 __proto__: null, 6355 argsToParams: argsToParams, 6356 bindClickHandler: bindClickHandler, 6357 clickCancel: clickCancel, 6358 clickConfirm: clickConfirm, 6359 clickDeny: clickDeny, 6360 enableLoading: showLoading, 6361 fire: fire, 6362 getActions: getActions, 6363 getCancelButton: getCancelButton, 6364 getCloseButton: getCloseButton, 6365 getConfirmButton: getConfirmButton, 6366 getContainer: getContainer, 6367 getDenyButton: getDenyButton, 6368 getFocusableElements: getFocusableElements, 6369 getFooter: getFooter, 6370 getHtmlContainer: getHtmlContainer, 6371 getIcon: getIcon, 6372 getIconContent: getIconContent, 6373 getImage: getImage, 6374 getInputLabel: getInputLabel, 6375 getLoader: getLoader, 6376 getPopup: getPopup, 6377 getProgressSteps: getProgressSteps, 6378 getTimerLeft: getTimerLeft, 6379 getTimerProgressBar: getTimerProgressBar, 6380 getTitle: getTitle, 6381 getValidationMessage: getValidationMessage, 6382 increaseTimer: increaseTimer, 6383 isDeprecatedParameter: isDeprecatedParameter, 6384 isLoading: isLoading, 6385 isTimerRunning: isTimerRunning, 6386 isUpdatableParameter: isUpdatableParameter, 6387 isValidParameter: isValidParameter, 6388 isVisible: isVisible, 6389 mixin: mixin, 6390 off: off, 6391 on: on, 6392 once: once, 6393 resumeTimer: resumeTimer, 6394 showLoading: showLoading, 6395 stopTimer: stopTimer, 6396 toggleTimer: toggleTimer 6397 }); 6398 6399 class Timer { 6400 /** 6401 * @param {() => void} callback 6402 * @param {number} delay 6403 */ 6404 constructor(callback, delay) { 6405 this.callback = callback; 6406 this.remaining = delay; 6407 this.running = false; 6408 this.start(); 6409 } 6410 6411 /** 6412 * @returns {number} 6413 */ 6414 start() { 6415 if (!this.running) { 6416 this.running = true; 6417 this.started = new Date(); 6418 this.id = setTimeout(this.callback, this.remaining); 6419 } 6420 return this.remaining; 6421 } 6422 6423 /** 6424 * @returns {number} 6425 */ 6426 stop() { 6427 if (this.started && this.running) { 6428 this.running = false; 6429 clearTimeout(this.id); 6430 this.remaining -= new Date().getTime() - this.started.getTime(); 6431 } 6432 return this.remaining; 6433 } 6434 6435 /** 6436 * @param {number} n 6437 * @returns {number} 6438 */ 6439 increase(n) { 6440 const running = this.running; 6441 if (running) { 6442 this.stop(); 6443 } 6444 this.remaining += n; 6445 if (running) { 6446 this.start(); 6447 } 6448 return this.remaining; 6449 } 6450 6451 /** 6452 * @returns {number} 6453 */ 6454 getTimerLeft() { 6455 if (this.running) { 6456 this.stop(); 6457 this.start(); 6458 } 6459 return this.remaining; 6460 } 6461 6462 /** 6463 * @returns {boolean} 6464 */ 6465 isRunning() { 6466 return this.running; 6467 } 6468 } 6469 6470 const swalStringParams = ['swal-title', 'swal-html', 'swal-footer']; 6471 6472 /** 6473 * @param {SweetAlertOptions} params 6474 * @returns {SweetAlertOptions} 6475 */ 6476 const getTemplateParams = params => { 6477 const template = typeof params.template === 'string' ? (/** @type {HTMLTemplateElement} */document.querySelector(params.template)) : params.template; 6478 if (!template) { 6479 return {}; 6480 } 6481 /** @type {DocumentFragment} */ 6482 const templateContent = template.content; 6483 showWarningsForElements(templateContent); 6484 const result = Object.assign(getSwalParams(templateContent), getSwalFunctionParams(templateContent), getSwalButtons(templateContent), getSwalImage(templateContent), getSwalIcon(templateContent), getSwalInput(templateContent), getSwalStringParams(templateContent, swalStringParams)); 6485 return result; 6486 }; 6487 6488 /** 6489 * @param {DocumentFragment} templateContent 6490 * @returns {Record<string, string | boolean | number>} 6491 */ 6492 const getSwalParams = templateContent => { 6493 /** @type {Record<string, string | boolean | number>} */ 6494 const result = {}; 6495 /** @type {HTMLElement[]} */ 6496 const swalParams = Array.from(templateContent.querySelectorAll('swal-param')); 6497 swalParams.forEach(param => { 6498 showWarningsForAttributes(param, ['name', 'value']); 6499 const paramName = /** @type {keyof SweetAlertOptions} */param.getAttribute('name'); 6500 const value = param.getAttribute('value'); 6501 if (!paramName || !value) { 6502 return; 6503 } 6504 if (paramName in defaultParams && typeof defaultParams[(/** @type {keyof typeof defaultParams} */paramName)] === 'boolean') { 6505 result[paramName] = value !== 'false'; 6506 } else if (paramName in defaultParams && typeof defaultParams[(/** @type {keyof typeof defaultParams} */paramName)] === 'object') { 6507 result[paramName] = JSON.parse(value); 6508 } else { 6509 result[paramName] = value; 6510 } 6511 }); 6512 return result; 6513 }; 6514 6515 /** 6516 * @param {DocumentFragment} templateContent 6517 * @returns {Record<string, () => void>} 6518 */ 6519 const getSwalFunctionParams = templateContent => { 6520 /** @type {Record<string, () => void>} */ 6521 const result = {}; 6522 /** @type {HTMLElement[]} */ 6523 const swalFunctions = Array.from(templateContent.querySelectorAll('swal-function-param')); 6524 swalFunctions.forEach(param => { 6525 const paramName = /** @type {keyof SweetAlertOptions} */param.getAttribute('name'); 6526 const value = param.getAttribute('value'); 6527 if (!paramName || !value) { 6528 return; 6529 } 6530 result[paramName] = new Function(`return ${value}`)(); 6531 }); 6532 return result; 6533 }; 6534 6535 /** 6536 * @param {DocumentFragment} templateContent 6537 * @returns {Record<string, string | boolean>} 6538 */ 6539 const getSwalButtons = templateContent => { 6540 /** @type {Record<string, string | boolean>} */ 6541 const result = {}; 6542 /** @type {HTMLElement[]} */ 6543 const swalButtons = Array.from(templateContent.querySelectorAll('swal-button')); 6544 swalButtons.forEach(button => { 6545 showWarningsForAttributes(button, ['type', 'color', 'aria-label']); 6546 const type = button.getAttribute('type'); 6547 if (!type || !['confirm', 'cancel', 'deny'].includes(type)) { 6548 return; 6549 } 6550 result[`${type}ButtonText`] = button.innerHTML; 6551 result[`show${capitalizeFirstLetter(type)}Button`] = true; 6552 const color = button.getAttribute('color'); 6553 if (color !== null) { 6554 result[`${type}ButtonColor`] = color; 6555 } 6556 const ariaLabel = button.getAttribute('aria-label'); 6557 if (ariaLabel !== null) { 6558 result[`${type}ButtonAriaLabel`] = ariaLabel; 6559 } 6560 }); 6561 return result; 6562 }; 6563 6564 /** 6565 * @param {DocumentFragment} templateContent 6566 * @returns {Pick<SweetAlertOptions, 'imageUrl' | 'imageWidth' | 'imageHeight' | 'imageAlt'>} 6567 */ 6568 const getSwalImage = templateContent => { 6569 const result = {}; 6570 /** @type {HTMLElement | null} */ 6571 const image = templateContent.querySelector('swal-image'); 6572 if (image) { 6573 showWarningsForAttributes(image, ['src', 'width', 'height', 'alt']); 6574 // getAttribute returns null if attribute is absent; `|| undefined` converts empty string to undefined 6575 const src = image.getAttribute('src'); 6576 if (src !== null) result.imageUrl = src || undefined; 6577 const width = image.getAttribute('width'); 6578 if (width !== null) result.imageWidth = width || undefined; 6579 const height = image.getAttribute('height'); 6580 if (height !== null) result.imageHeight = height || undefined; 6581 const alt = image.getAttribute('alt'); 6582 if (alt !== null) result.imageAlt = alt || undefined; 6583 } 6584 return result; 6585 }; 6586 6587 /** 6588 * @param {DocumentFragment} templateContent 6589 * @returns {object} 6590 */ 6591 const getSwalIcon = templateContent => { 6592 const result = {}; 6593 /** @type {HTMLElement | null} */ 6594 const icon = templateContent.querySelector('swal-icon'); 6595 if (icon) { 6596 showWarningsForAttributes(icon, ['type', 'color']); 6597 if (icon.hasAttribute('type')) { 6598 result.icon = icon.getAttribute('type'); 6599 } 6600 if (icon.hasAttribute('color')) { 6601 result.iconColor = icon.getAttribute('color'); 6602 } 6603 result.iconHtml = icon.innerHTML; 6604 } 6605 return result; 6606 }; 6607 6608 /** 6609 * @param {DocumentFragment} templateContent 6610 * @returns {object} 6611 */ 6612 const getSwalInput = templateContent => { 6613 /** @type {Record<string, any>} */ 6614 const result = {}; 6615 /** @type {HTMLElement | null} */ 6616 const input = templateContent.querySelector('swal-input'); 6617 if (input) { 6618 showWarningsForAttributes(input, ['type', 'label', 'placeholder', 'value']); 6619 result.input = input.getAttribute('type') || 'text'; 6620 if (input.hasAttribute('label')) { 6621 result.inputLabel = input.getAttribute('label'); 6622 } 6623 if (input.hasAttribute('placeholder')) { 6624 result.inputPlaceholder = input.getAttribute('placeholder'); 6625 } 6626 if (input.hasAttribute('value')) { 6627 result.inputValue = input.getAttribute('value'); 6628 } 6629 } 6630 /** @type {HTMLElement[]} */ 6631 const inputOptions = Array.from(templateContent.querySelectorAll('swal-input-option')); 6632 if (inputOptions.length) { 6633 result.inputOptions = {}; 6634 inputOptions.forEach(option => { 6635 showWarningsForAttributes(option, ['value']); 6636 const optionValue = option.getAttribute('value'); 6637 if (!optionValue) { 6638 return; 6639 } 6640 const optionName = option.innerHTML; 6641 result.inputOptions[optionValue] = optionName; 6642 }); 6643 } 6644 return result; 6645 }; 6646 6647 /** 6648 * @param {DocumentFragment} templateContent 6649 * @param {string[]} paramNames 6650 * @returns {Record<string, string>} 6651 */ 6652 const getSwalStringParams = (templateContent, paramNames) => { 6653 /** @type {Record<string, string>} */ 6654 const result = {}; 6655 for (const i in paramNames) { 6656 const paramName = paramNames[i]; 6657 /** @type {HTMLElement | null} */ 6658 const tag = templateContent.querySelector(paramName); 6659 if (tag) { 6660 showWarningsForAttributes(tag, []); 6661 result[paramName.replace(/^swal-/, '')] = tag.innerHTML.trim(); 6662 } 6663 } 6664 return result; 6665 }; 6666 6667 /** 6668 * @param {DocumentFragment} templateContent 6669 */ 6670 const showWarningsForElements = templateContent => { 6671 const allowedElements = swalStringParams.concat(['swal-param', 'swal-function-param', 'swal-button', 'swal-image', 'swal-icon', 'swal-input', 'swal-input-option']); 6672 Array.from(templateContent.children).forEach(el => { 6673 const tagName = el.tagName.toLowerCase(); 6674 if (!allowedElements.includes(tagName)) { 6675 warn(`Unrecognized element <${tagName}>`); 6676 } 6677 }); 6678 }; 6679 6680 /** 6681 * @param {HTMLElement} el 6682 * @param {string[]} allowedAttributes 6683 */ 6684 const showWarningsForAttributes = (el, allowedAttributes) => { 6685 Array.from(el.attributes).forEach(attribute => { 6686 if (allowedAttributes.indexOf(attribute.name) === -1) { 6687 warn([`Unrecognized attribute "${attribute.name}" on <${el.tagName.toLowerCase()}>.`, `${allowedAttributes.length ? `Allowed attributes are: ${allowedAttributes.join(', ')}` : 'To set the value, use HTML within the element.'}`]); 6688 } 6689 }); 6690 }; 6691 6692 const SHOW_CLASS_TIMEOUT = 10; 6693 6694 /** 6695 * Open popup, add necessary classes and styles, fix scrollbar 6696 * 6697 * @param {SweetAlertOptions} params 6698 */ 6699 const openPopup = params => { 6700 var _globalState$eventEmi, _globalState$eventEmi2; 6701 const container = getContainer(); 6702 const popup = getPopup(); 6703 if (!container || !popup) { 6704 return; 6705 } 6706 if (typeof params.willOpen === 'function') { 6707 params.willOpen(popup); 6708 } 6709 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('willOpen', popup); 6710 const bodyStyles = window.getComputedStyle(document.body); 6711 const initialBodyOverflow = bodyStyles.overflowY; 6712 addClasses(container, popup, params); 6713 6714 // scrolling is 'hidden' until animation is done, after that 'auto' 6715 setTimeout(() => { 6716 setScrollingVisibility(container, popup); 6717 }, SHOW_CLASS_TIMEOUT); 6718 if (isModal()) { 6719 fixScrollContainer(container, params.scrollbarPadding !== undefined ? params.scrollbarPadding : false, initialBodyOverflow); 6720 setAriaHidden(); 6721 } 6722 6723 // https://github.com/sweetalert2/sweetalert2/issues/2923 6724 if (isIOS && params.backdrop === false && popup.scrollHeight > container.clientHeight) { 6725 // remove pointer-events: none from container, it breaks scrolling tall popups in iOS 6726 container.style.pointerEvents = 'auto'; 6727 } 6728 if (!isToast() && !globalState.previousActiveElement) { 6729 globalState.previousActiveElement = document.activeElement; 6730 } 6731 if (typeof params.didOpen === 'function') { 6732 const didOpen = params.didOpen; 6733 setTimeout(() => didOpen(popup)); 6734 } 6735 (_globalState$eventEmi2 = globalState.eventEmitter) === null || _globalState$eventEmi2 === void 0 || _globalState$eventEmi2.emit('didOpen', popup); 6736 }; 6737 6738 /** 6739 * @param {Event} event 6740 */ 6741 const swalOpenAnimationFinished = event => { 6742 const popup = getPopup(); 6743 if (!popup || event.target !== popup) { 6744 return; 6745 } 6746 const container = getContainer(); 6747 if (!container) { 6748 return; 6749 } 6750 popup.removeEventListener('animationend', swalOpenAnimationFinished); 6751 popup.removeEventListener('transitionend', swalOpenAnimationFinished); 6752 container.style.overflowY = 'auto'; 6753 6754 // no-transition is added in init() in case one swal is opened right after another 6755 removeClass(container, swalClasses['no-transition']); 6756 }; 6757 6758 /** 6759 * @param {HTMLElement} container 6760 * @param {HTMLElement} popup 6761 */ 6762 const setScrollingVisibility = (container, popup) => { 6763 if (hasCssAnimation(popup)) { 6764 container.style.overflowY = 'hidden'; 6765 popup.addEventListener('animationend', swalOpenAnimationFinished); 6766 popup.addEventListener('transitionend', swalOpenAnimationFinished); 6767 } else { 6768 container.style.overflowY = 'auto'; 6769 } 6770 }; 6771 6772 /** 6773 * @param {HTMLElement} container 6774 * @param {boolean} scrollbarPadding 6775 * @param {string} initialBodyOverflow 6776 */ 6777 const fixScrollContainer = (container, scrollbarPadding, initialBodyOverflow) => { 6778 iOSfix(); 6779 if (scrollbarPadding && initialBodyOverflow !== 'hidden') { 6780 replaceScrollbarWithPadding(initialBodyOverflow); 6781 } 6782 6783 // sweetalert2/issues/1247 6784 setTimeout(() => { 6785 container.scrollTop = 0; 6786 }); 6787 }; 6788 6789 /** 6790 * @param {HTMLElement} container 6791 * @param {HTMLElement} popup 6792 * @param {SweetAlertOptions} params 6793 */ 6794 const addClasses = (container, popup, params) => { 6795 var _params$showClass; 6796 if ((_params$showClass = params.showClass) !== null && _params$showClass !== void 0 && _params$showClass.backdrop) { 6797 addClass(container, params.showClass.backdrop); 6798 } 6799 if (params.animation) { 6800 // this workaround with opacity is needed for https://github.com/sweetalert2/sweetalert2/issues/2059 6801 popup.style.setProperty('opacity', '0', 'important'); 6802 show(popup, 'grid'); 6803 setTimeout(() => { 6804 var _params$showClass2; 6805 // Animate popup right after showing it 6806 if ((_params$showClass2 = params.showClass) !== null && _params$showClass2 !== void 0 && _params$showClass2.popup) { 6807 addClass(popup, params.showClass.popup); 6808 } 6809 // and remove the opacity workaround 6810 popup.style.removeProperty('opacity'); 6811 }, SHOW_CLASS_TIMEOUT); // 10ms in order to fix #2062 6812 } else { 6813 show(popup, 'grid'); 6814 } 6815 addClass([document.documentElement, document.body], swalClasses.shown); 6816 if (params.heightAuto && params.backdrop && !params.toast) { 6817 addClass([document.documentElement, document.body], swalClasses['height-auto']); 6818 } 6819 }; 6820 6821 var defaultInputValidators = { 6822 /** 6823 * @param {string} string 6824 * @param {string} [validationMessage] 6825 * @returns {Promise<string | void>} 6826 */ 6827 email: (string, validationMessage) => { 6828 return /^[a-zA-Z0-9.+_'-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9-]+$/.test(string) ? Promise.resolve() : Promise.resolve(validationMessage || 'Invalid email address'); 6829 }, 6830 /** 6831 * @param {string} string 6832 * @param {string} [validationMessage] 6833 * @returns {Promise<string | void>} 6834 */ 6835 url: (string, validationMessage) => { 6836 // taken from https://stackoverflow.com/a/3809435 with a small change from #1306 and #2013 6837 return /^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-z]{2,63}\b([-a-zA-Z0-9@:%_+.~#?&/=]*)$/.test(string) ? Promise.resolve() : Promise.resolve(validationMessage || 'Invalid URL'); 6838 } 6839 }; 6840 6841 /** 6842 * @param {SweetAlertOptions} params 6843 */ 6844 function setDefaultInputValidators(params) { 6845 // Use default `inputValidator` for supported input types if not provided 6846 if (params.inputValidator) { 6847 return; 6848 } 6849 if (params.input === 'email') { 6850 params.inputValidator = defaultInputValidators['email']; 6851 } 6852 if (params.input === 'url') { 6853 params.inputValidator = defaultInputValidators['url']; 6854 } 6855 } 6856 6857 /** 6858 * @param {SweetAlertOptions} params 6859 */ 6860 function validateCustomTargetElement(params) { 6861 // Determine if the custom target element is valid 6862 if (!params.target || typeof params.target === 'string' && !document.querySelector(params.target) || typeof params.target !== 'string' && !params.target.appendChild) { 6863 warn('Target parameter is not valid, defaulting to "body"'); 6864 params.target = 'body'; 6865 } 6866 } 6867 6868 /** 6869 * Set type, text and actions on popup 6870 * 6871 * @param {SweetAlertOptions} params 6872 */ 6873 function setParameters(params) { 6874 setDefaultInputValidators(params); 6875 6876 // showLoaderOnConfirm && preConfirm 6877 if (params.showLoaderOnConfirm && !params.preConfirm) { 6878 warn('showLoaderOnConfirm is set to true, but preConfirm is not defined.\n' + 'showLoaderOnConfirm should be used together with preConfirm, see usage example:\n' + 'https://sweetalert2.github.io/#ajax-request'); 6879 } 6880 validateCustomTargetElement(params); 6881 6882 // Replace newlines with <br> in title 6883 if (typeof params.title === 'string') { 6884 params.title = params.title.split('\n').join('<br />'); 6885 } 6886 init(params); 6887 } 6888 6889 /** @type {SweetAlert} */ 6890 let currentInstance; 6891 var _promise = /*#__PURE__*/new WeakMap(); 6892 class SweetAlert { 6893 /** 6894 * @param {...(SweetAlertOptions | string)} args 6895 * @this {SweetAlert} 6896 */ 6897 constructor(...args) { 6898 /** 6899 * @type {Promise<SweetAlertResult>} 6900 */ 6901 _classPrivateFieldInitSpec(this, _promise, /** @type {Promise<SweetAlertResult>} */ 6902 Promise.resolve({ 6903 isConfirmed: false, 6904 isDenied: false, 6905 isDismissed: true 6906 })); 6907 // Prevent run in Node env 6908 if (typeof window === 'undefined') { 6909 return; 6910 } 6911 currentInstance = this; 6912 6913 // @ts-ignore 6914 const outerParams = Object.freeze(this.constructor.argsToParams(args)); 6915 6916 /** @type {Readonly<SweetAlertOptions>} */ 6917 this.params = outerParams; 6918 6919 /** @type {boolean} */ 6920 this.isAwaitingPromise = false; 6921 _classPrivateFieldSet2(_promise, this, this._main(currentInstance.params)); 6922 } 6923 6924 /** 6925 * @param {any} userParams 6926 * @param {any} mixinParams 6927 */ 6928 _main(userParams, mixinParams = {}) { 6929 showWarningsForParams(Object.assign({}, mixinParams, userParams)); 6930 if (globalState.currentInstance) { 6931 const swalPromiseResolve = privateMethods.swalPromiseResolve.get(globalState.currentInstance); 6932 const { 6933 isAwaitingPromise 6934 } = globalState.currentInstance; 6935 globalState.currentInstance._destroy(); 6936 if (!isAwaitingPromise) { 6937 swalPromiseResolve({ 6938 isDismissed: true 6939 }); 6940 } 6941 if (isModal()) { 6942 unsetAriaHidden(); 6943 } 6944 } 6945 globalState.currentInstance = currentInstance; 6946 const innerParams = prepareParams(userParams, mixinParams); 6947 setParameters(innerParams); 6948 Object.freeze(innerParams); 6949 6950 // clear the previous timer 6951 if (globalState.timeout) { 6952 globalState.timeout.stop(); 6953 delete globalState.timeout; 6954 } 6955 6956 // clear the restore focus timeout 6957 clearTimeout(globalState.restoreFocusTimeout); 6958 const domCache = populateDomCache(currentInstance); 6959 render(currentInstance, innerParams); 6960 privateProps.innerParams.set(currentInstance, innerParams); 6961 return swalPromise(currentInstance, domCache, innerParams); 6962 } 6963 6964 // `catch` cannot be the name of a module export, so we define our thenable methods here instead 6965 /** 6966 * @param {any} onFulfilled 6967 */ 6968 // oxlint-disable-next-line unicorn/no-thenable 6969 then(onFulfilled) { 6970 return _classPrivateFieldGet2(_promise, this).then(onFulfilled); 6971 } 6972 6973 /** 6974 * @param {any} onFinally 6975 */ 6976 finally(onFinally) { 6977 return _classPrivateFieldGet2(_promise, this).finally(onFinally); 6978 } 6979 } 6980 6981 /** 6982 * @param {SweetAlert} instance 6983 * @param {DomCache} domCache 6984 * @param {SweetAlertOptions} innerParams 6985 * @returns {Promise<SweetAlertResult>} 6986 */ 6987 const swalPromise = (instance, domCache, innerParams) => { 6988 return new Promise((resolve, reject) => { 6989 // functions to handle all closings/dismissals 6990 /** 6991 * @param {DismissReason} dismiss 6992 */ 6993 const dismissWith = dismiss => { 6994 instance.close({ 6995 isDismissed: true, 6996 dismiss, 6997 isConfirmed: false, 6998 isDenied: false 6999 }); 7000 }; 7001 privateMethods.swalPromiseResolve.set(instance, resolve); 7002 privateMethods.swalPromiseReject.set(instance, reject); 7003 domCache.confirmButton.onclick = () => { 7004 handleConfirmButtonClick(instance); 7005 }; 7006 domCache.denyButton.onclick = () => { 7007 handleDenyButtonClick(instance); 7008 }; 7009 domCache.cancelButton.onclick = () => { 7010 handleCancelButtonClick(instance, dismissWith); 7011 }; 7012 domCache.closeButton.onclick = () => { 7013 dismissWith(DismissReason.close); 7014 }; 7015 handlePopupClick(innerParams, domCache, dismissWith); 7016 addKeydownHandler(globalState, innerParams, dismissWith); 7017 handleInputOptionsAndValue(instance, innerParams); 7018 openPopup(innerParams); 7019 setupTimer(globalState, innerParams, dismissWith); 7020 initFocus(domCache, innerParams); 7021 7022 // Scroll container to top on open (#1247, #1946) 7023 setTimeout(() => { 7024 domCache.container.scrollTop = 0; 7025 }); 7026 }); 7027 }; 7028 7029 /** 7030 * @param {SweetAlertOptions} userParams 7031 * @param {SweetAlertOptions} mixinParams 7032 * @returns {SweetAlertOptions} 7033 */ 7034 const prepareParams = (userParams, mixinParams) => { 7035 const templateParams = getTemplateParams(userParams); 7036 const params = Object.assign({}, defaultParams, mixinParams, templateParams, userParams); // precedence is described in #2131 7037 params.showClass = Object.assign({}, defaultParams.showClass, params.showClass); 7038 params.hideClass = Object.assign({}, defaultParams.hideClass, params.hideClass); 7039 if (params.animation === false) { 7040 params.showClass = { 7041 backdrop: 'swal2-noanimation' 7042 }; 7043 params.hideClass = {}; 7044 } 7045 return params; 7046 }; 7047 7048 /** 7049 * @param {SweetAlert} instance 7050 * @returns {DomCache} 7051 */ 7052 const populateDomCache = instance => { 7053 const domCache = /** @type {DomCache} */{ 7054 popup: (/** @type {HTMLElement} */getPopup()), 7055 container: (/** @type {HTMLElement} */getContainer()), 7056 actions: (/** @type {HTMLElement} */getActions()), 7057 confirmButton: (/** @type {HTMLElement} */getConfirmButton()), 7058 denyButton: (/** @type {HTMLElement} */getDenyButton()), 7059 cancelButton: (/** @type {HTMLElement} */getCancelButton()), 7060 loader: (/** @type {HTMLElement} */getLoader()), 7061 closeButton: (/** @type {HTMLElement} */getCloseButton()), 7062 validationMessage: (/** @type {HTMLElement} */getValidationMessage()), 7063 progressSteps: (/** @type {HTMLElement} */getProgressSteps()) 7064 }; 7065 privateProps.domCache.set(instance, domCache); 7066 return domCache; 7067 }; 7068 7069 /** 7070 * @param {GlobalState} globalState 7071 * @param {SweetAlertOptions} innerParams 7072 * @param {(dismiss: DismissReason) => void} dismissWith 7073 */ 7074 const setupTimer = (globalState, innerParams, dismissWith) => { 7075 const timerProgressBar = getTimerProgressBar(); 7076 hide(timerProgressBar); 7077 if (innerParams.timer) { 7078 globalState.timeout = new Timer(() => { 7079 dismissWith('timer'); 7080 delete globalState.timeout; 7081 }, innerParams.timer); 7082 if (innerParams.timerProgressBar && timerProgressBar) { 7083 show(timerProgressBar); 7084 applyCustomClass(timerProgressBar, innerParams, 'timerProgressBar'); 7085 setTimeout(() => { 7086 if (globalState.timeout && globalState.timeout.running) { 7087 // timer can be already stopped or unset at this point 7088 animateTimerProgressBar(/** @type {number} */innerParams.timer); 7089 } 7090 }); 7091 } 7092 } 7093 }; 7094 7095 /** 7096 * Initialize focus in the popup: 7097 * 7098 * 1. If `toast` is `true`, don't steal focus from the document. 7099 * 2. Else if there is an [autofocus] element, focus it. 7100 * 3. Else if `focusConfirm` is `true` and confirm button is visible, focus it. 7101 * 4. Else if `focusDeny` is `true` and deny button is visible, focus it. 7102 * 5. Else if `focusCancel` is `true` and cancel button is visible, focus it. 7103 * 6. Else focus the first focusable element in a popup (if any). 7104 * 7105 * @param {DomCache} domCache 7106 * @param {SweetAlertOptions} innerParams 7107 */ 7108 const initFocus = (domCache, innerParams) => { 7109 if (innerParams.toast) { 7110 return; 7111 } 7112 // TODO: this is dumb, remove `allowEnterKey` param in the next major version 7113 if (!callIfFunction(innerParams.allowEnterKey)) { 7114 warnAboutDeprecation('allowEnterKey', 'preConfirm: () => false'); 7115 domCache.popup.focus(); 7116 return; 7117 } 7118 if (focusAutofocus(domCache)) { 7119 return; 7120 } 7121 if (focusButton(domCache, innerParams)) { 7122 return; 7123 } 7124 setFocus(-1, 1); 7125 }; 7126 7127 /** 7128 * @param {DomCache} domCache 7129 * @returns {boolean} 7130 */ 7131 const focusAutofocus = domCache => { 7132 const autofocusElements = Array.from(domCache.popup.querySelectorAll('[autofocus]')); 7133 for (const autofocusElement of autofocusElements) { 7134 if (autofocusElement instanceof HTMLElement && isVisible$1(autofocusElement)) { 7135 autofocusElement.focus(); 7136 return true; 7137 } 7138 } 7139 return false; 7140 }; 7141 7142 /** 7143 * @param {DomCache} domCache 7144 * @param {SweetAlertOptions} innerParams 7145 * @returns {boolean} 7146 */ 7147 const focusButton = (domCache, innerParams) => { 7148 if (innerParams.focusDeny && isVisible$1(domCache.denyButton)) { 7149 domCache.denyButton.focus(); 7150 return true; 7151 } 7152 if (innerParams.focusCancel && isVisible$1(domCache.cancelButton)) { 7153 domCache.cancelButton.focus(); 7154 return true; 7155 } 7156 if (innerParams.focusConfirm && isVisible$1(domCache.confirmButton)) { 7157 domCache.confirmButton.focus(); 7158 return true; 7159 } 7160 return false; 7161 }; 7162 7163 // Assign instance methods from src/instanceMethods/*.js to prototype 7164 SweetAlert.prototype.disableButtons = disableButtons; 7165 SweetAlert.prototype.enableButtons = enableButtons; 7166 SweetAlert.prototype.getInput = getInput; 7167 SweetAlert.prototype.disableInput = disableInput; 7168 SweetAlert.prototype.enableInput = enableInput; 7169 SweetAlert.prototype.hideLoading = hideLoading; 7170 SweetAlert.prototype.disableLoading = hideLoading; 7171 SweetAlert.prototype.showValidationMessage = showValidationMessage; 7172 SweetAlert.prototype.resetValidationMessage = resetValidationMessage; 7173 SweetAlert.prototype.close = close; 7174 SweetAlert.prototype.closePopup = close; 7175 SweetAlert.prototype.closeModal = close; 7176 SweetAlert.prototype.closeToast = close; 7177 SweetAlert.prototype.rejectPromise = rejectPromise; 7178 SweetAlert.prototype.update = update; 7179 SweetAlert.prototype._destroy = _destroy; 7180 7181 // Assign static methods from src/staticMethods/*.js to constructor 7182 Object.assign(SweetAlert, staticMethods); 7183 7184 // Proxy to instance methods to constructor, for now, for backwards compatibility 7185 Object.keys(instanceMethods).forEach(key => { 7186 /** 7187 * @param {...(SweetAlertOptions | string | undefined)} args 7188 * @returns {SweetAlertResult | Promise<SweetAlertResult> | undefined} 7189 */ 7190 // @ts-ignore: Dynamic property assignment for backwards compatibility 7191 SweetAlert[key] = function (...args) { 7192 // @ts-ignore 7193 if (currentInstance && currentInstance[key]) { 7194 // @ts-ignore 7195 return currentInstance[key](...args); 7196 } 7197 return undefined; 7198 }; 7199 }); 7200 SweetAlert.DismissReason = DismissReason; 7201 SweetAlert.version = '11.26.2
72014'; 7202 7203 const Swal = SweetAlert; 7204 // @ts-ignore 7205 Swal.default = Swal; 7206 7207 return Swal; 7208 7209})); 7210if (typeof this !== 'undefined' && this.Sweetalert2){this.swal = this.sweetAlert = this.Swal = this.SweetAlert = this.Sweetalert2} 7211"undefined"!=typeof document&&function(e,t){var n=e.createElement("style");if(e.getElementsByTagName("head")[0].appendChild(n),n.styleSheet)n.styleSheet.disabled||(n.styleSheet.cssText=t);else try{n.innerHTML=t}catch(e){n.innerText=t}}(document,":root{--swal2-outline: 0 0 0 3px rgba(100, 150, 200, 0.5);--swal2-container-padding: 0.625em;--swal2-backdrop: rgba(0, 0, 0, 0.4);--swal2-backdrop-transition: background-color 0.15s;--swal2-width: 32em;--swal2-padding: 0 0 1.25em;--swal2-border: none;--swal2-border-radius: 0.3125rem;--swal2-background: white;--swal2-color: #545454;--swal2-show-animation: swal2-show 0.3s;--swal2-hide-animation: swal2-hide 0.15s forwards;--swal2-icon-zoom: 1;--swal2-icon-animations: true
vendor: 7,369 bytes, line 7211
7211;--swal2-title-padding: 0.8em 1em 0;--swal2-html-container-padding: 1em 1.6em 0.3em;--swal2-input-border: 1px solid #d9d9d9;--swal2-input-border-radius: 0.1875em;--swal2-input-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px transparent;--swal2-input-background: transparent;--swal2-input-transition: border-color 0.2s, box-shadow 0.2s;--swal2-input-hover-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px transparent;--swal2-input-focus-border: 1px solid #b4dbed;--swal2-input-focus-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px rgba(100, 150, 200, 0.5);--swal2-progress-step-background: #add8e6;--swal2-validation-message-background: #f0f0f0;--swal2-validation-message-color: #666;--swal2-footer-border-color: #eee;--swal2-footer-background: transparent;--swal2-footer-color: inherit;--swal2-timer-progress-bar-background: rgba(0, 0, 0, 0.3);--swal2-close-button-position: initial;--swal2-close-button-inset: auto;--swal2-close-button-font-size: 2.5em;--swal2-close-button-color: #ccc;--swal2-close-button-transition: color 0.2s, box-shadow 0.2s;--swal2-close-button-outline: initial;--swal2-close-button-box-shadow: inset 0 0 0 3px transparent;--swal2-close-button-focus-box-shadow: inset var(--swal2-outline);--swal2-close-button-hover-transform: none;--swal2-actions-justify-content: center;--swal2-actions-width: auto;--swal2-actions-margin: 1.25em auto 0;--swal2-actions-padding: 0;--swal2-actions-border-radius: 0;--swal2-actions-background: transparent;--swal2-action-button-transition: background-color 0.2s, box-shadow 0.2s;--swal2-action-button-hover: black 10%;--swal2-action-button-active: black 10%;--swal2-confirm-button-box-shadow: none;--swal2-confirm-button-border-radius: 0.25em;--swal2-confirm-button-background-color: #7066e0;--swal2-confirm-button-color: #fff;--swal2-deny-button-box-shadow: none;--swal2-deny-button-border-radius: 0.25em;--swal2-deny-button-background-color: #dc3741;--swal2-deny-button-color: #fff;--swal2-cancel-button-box-shadow: none;--swal2-cancel-button-border-radius: 0.25em;--swal2-cancel-button-background-color: #6e7881;--swal2-cancel-button-color: #fff;--swal2-toast-show-animation: swal2-toast-show 0.5s;--swal2-toast-hide-animation: swal2-toast-hide 0.1s forwards;--swal2-toast-border: none;--swal2-toast-box-shadow: 0 0 1px hsl(0deg 0% 0% / 0.075), 0 1px 2px hsl(0deg 0% 0% / 0.075), 1px 2px 4px hsl(0deg 0% 0% / 0.075), 1px 3px 8px hsl(0deg 0% 0% / 0.075), 2px 4px 16px hsl(0deg 0% 0% / 0.075)}[data-swal2-theme=dark]{--swal2-dark-theme-black: #19191a;--swal2-dark-theme-white: #e1e1e1;--swal2-background: var(--swal2-dark-theme-black);--swal2-color: var(--swal2-dark-theme-white);--swal2-footer-border-color: #555;--swal2-input-background: color-mix(in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10%);--swal2-validation-message-background: color-mix( in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10% );--swal2-validation-message-color: var(--swal2-dark-theme-white);--swal2-timer-progress-bar-background: rgba(255, 255, 255, 0.7)}@media(prefers-color-scheme: dark){[data-swal2-theme=auto]{--swal2-dark-theme-black: #19191a;--swal2-dark-theme-white: #e1e1e1;--swal2-background: var(--swal2-dark-theme-black);--swal2-color: var(--swal2-dark-theme-white);--swal2-footer-border-color: #555;--swal2-input-background: color-mix(in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10%);--swal2-validation-message-background: color-mix( in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10% );--swal2-validation-message-color: var(--swal2-dark-theme-white);--swal2-timer-progress-bar-background: rgba(255, 255, 255, 0.7)}}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown){overflow:hidden}body.swal2-height-auto{height:auto !important}body.swal2-no-backdrop .swal2-container{background-color:rgba(0,0,0,0) !important;pointer-events:none}body.swal2-no-backdrop .swal2-container .swal2-popup{pointer-events:auto}body.swal2-no-backdrop .swal2-container .swal2-modal{box-shadow:0 0 10px var(--swal2-backdrop)}body.swal2-toast-shown .swal2-container{box-sizing:border-box;width:360px;max-width:100%;background-color:rgba(0,0,0,0);pointer-events:none}body.swal2-toast-shown .swal2-container.swal2-top{inset:0 auto auto 50%;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-top-end,body.swal2-toast-shown .swal2-container.swal2-top-right{inset:0 0 auto auto}body.swal2-toast-shown .swal2-container.swal2-top-start,body.swal2-toast-shown .swal2-container.swal2-top-left{inset:0 auto auto 0}body.swal2-toast-shown .swal2-container.swal2-center-start,body.swal2-toast-shown .swal2-container.swal2-center-left{inset:50% auto auto 0;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-center{inset:50% auto auto 50%;transform:translate(-50%, -50%)}body.swal2-toast-shown .swal2-container.swal2-center-end,body.swal2-toast-shown .swal2-container.swal2-center-right{inset:50% 0 auto auto;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-start,body.swal2-toast-shown .swal2-container.swal2-bottom-left{inset:auto auto 0 0}body.swal2-toast-shown .swal2-container.swal2-bottom{inset:auto auto 0 50%;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-end,body.swal2-toast-shown .swal2-container.swal2-bottom-right{inset:auto 0 0 auto}@media print{body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown){overflow-y:scroll !important}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown)>[aria-hidden=true]{display:none}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown) .swal2-container{position:static !important}}div:where(.swal2-container){display:grid;position:fixed;z-index:1060;inset:0;box-sizing:border-box;grid-template-areas:\"top-start top top-end\" \"center-start center center-end\" \"bottom-start bottom-center bottom-end\";grid-template-rows:minmax(min-content, auto) minmax(min-content, auto) minmax(min-content, auto);height:100%;padding:var(--swal2-container-padding);overflow-x:hidden;transition:var(--swal2-backdrop-transition);-webkit-overflow-scrolling:touch}div:where(.swal2-container).swal2-backdrop-show,div:where(.swal2-container).swal2-noanimation{background:var(--swal2-backdrop)}div:where(.swal2-container).swal2-backdrop-hide{background:rgba(0,0,0,0) !important}div:where(.swal2-container).swal2-top-start,div:where(.swal2-container).swal2-center-start,div:where(.swal2-container).swal2-bottom-start{grid-template-columns:minmax(0, 1fr) auto auto}div:where(.swal2-container).swal2-top,div:where(.swal2-container).swal2-center,div:where(.swal2-container).swal2-bottom{grid-template-columns:auto minmax(0, 1fr) auto}div:where(.swal2-container).swal2-top-end,div:where(.swal2-container).swal2-center-end,div:where(.swal2-container).swal2-bottom-end{grid-template-columns:auto auto minmax(0, 1fr)}div:where(.swal2-container).swal2-top-start>.swal2-popup{align-self:start}div:where(.swal2-container).swal2-top>.swal2-popup{grid-column:2;place-self:start center}div:where(.swal2-container).swal2-top-end>.swal2-popup,div:where(.swal2-container).swal2-top-right>.swal2-popup{grid-column:3;place-self:start end}div:where(.swal2-container).swal2-center-start>.swal2-popup,div:where(.swal2-container).swal2-center-left>.swal2-popup{grid-row:2;
vendor: 4,251 bytes, line 7211
7211align-self:center}div:where(.swal2-container).swal2-center>.swal2-popup{grid-column:2;grid-row:2;place-self:center center}div:where(.swal2-container).swal2-center-end>.swal2-popup,div:where(.swal2-container).swal2-center-right>.swal2-popup{grid-column:3;grid-row:2;place-self:center end}div:where(.swal2-container).swal2-bottom-start>.swal2-popup,div:where(.swal2-container).swal2-bottom-left>.swal2-popup{grid-column:1;grid-row:3;align-self:end}div:where(.swal2-container).swal2-bottom>.swal2-popup{grid-column:2;grid-row:3;place-self:end center}div:where(.swal2-container).swal2-bottom-end>.swal2-popup,div:where(.swal2-container).swal2-bottom-right>.swal2-popup{grid-column:3;grid-row:3;place-self:end end}div:where(.swal2-container).swal2-grow-row>.swal2-popup,div:where(.swal2-container).swal2-grow-fullscreen>.swal2-popup{grid-column:1/4;width:100%}div:where(.swal2-container).swal2-grow-column>.swal2-popup,div:where(.swal2-container).swal2-grow-fullscreen>.swal2-popup{grid-row:1/4;align-self:stretch}div:where(.swal2-container).swal2-no-transition{transition:none !important}div:where(.swal2-container)[popover]{width:auto;border:0}div:where(.swal2-container) div:where(.swal2-popup){display:none;position:relative;box-sizing:border-box;grid-template-columns:minmax(0, 100%);width:var(--swal2-width);max-width:100%;padding:var(--swal2-padding);border:var(--swal2-border);border-radius:var(--swal2-border-radius);background:var(--swal2-background);color:var(--swal2-color);font-family:inherit;font-size:1rem;container-name:swal2-popup}div:where(.swal2-container) div:where(.swal2-popup):focus{outline:none}div:where(.swal2-container) div:where(.swal2-popup).swal2-loading{overflow-y:hidden}div:where(.swal2-container) div:where(.swal2-popup).swal2-draggable{cursor:grab}div:where(.swal2-container) div:where(.swal2-popup).swal2-draggable div:where(.swal2-icon){cursor:grab}div:where(.swal2-container) div:where(.swal2-popup).swal2-dragging{cursor:grabbing}div:where(.swal2-container) div:where(.swal2-popup).swal2-dragging div:where(.swal2-icon){cursor:grabbing}div:where(.swal2-container) h2:where(.swal2-title){position:relative;max-width:100%;margin:0;padding:var(--swal2-title-padding);color:inherit;font-size:1.875em;font-weight:600;text-align:center;text-transform:none;overflow-wrap:break-word;cursor:initial}div:where(.swal2-container) div:where(.swal2-actions){display:flex;z-index:1;box-sizing:border-box;flex-wrap:wrap;align-items:center;justify-content:var(--swal2-actions-justify-content);width:var(--swal2-actions-width);margin:var(--swal2-actions-margin);padding:var(--swal2-actions-padding);border-radius:var(--swal2-actions-border-radius);background:var(--swal2-actions-background)}div:where(.swal2-container) div:where(.swal2-loader){display:none;align-items:center;justify-content:center;width:2.2em;height:2.2em;margin:0 1.875em;animation:swal2-rotate-loading 1.5s linear 0s infinite normal;border-width:.25em;border-style:solid;border-radius:100%;border-color:#2778c4 rgba(0,0,0,0) #2778c4 rgba(0,0,0,0)}div:where(.swal2-container) button:where(.swal2-styled){margin:.3125em;padding:.625em 1.1em;transition:var(--swal2-action-button-transition);border:none;box-shadow:0 0 0 3px rgba(0,0,0,0);font-weight:500}div:where(.swal2-container) button:where(.swal2-styled):not([disabled]){cursor:pointer}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm){border-radius:var(--swal2-confirm-button-border-radius);background:initial;background-color:var(--swal2-confirm-button-background-color);box-shadow:var(--swal2-confirm-button-box-shadow);color:var(--swal2-confirm-button-color);font-size:1em}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm):hover{background-color:color-mix(in srgb, var(--swal2-confirm-button-background-color), var(--swal2-action-button-hover))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm):active{background-color:color-mix(in srgb, var(--swal2-confirm-button-background-color), var(--swal2-action-button-active))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny){border-radius:var(--swal2-deny-button-border-radius);background:initial;background-color:var(--swal2-deny-button-background-color);
vendor: 9,361 bytes, line 7211
7211box-shadow:var(--swal2-deny-button-box-shadow);color:var(--swal2-deny-button-color);font-size:1em}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny):hover{background-color:color-mix(in srgb, var(--swal2-deny-button-background-color), var(--swal2-action-button-hover))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny):active{background-color:color-mix(in srgb, var(--swal2-deny-button-background-color), var(--swal2-action-button-active))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel){border-radius:var(--swal2-cancel-button-border-radius);background:initial;background-color:var(--swal2-cancel-button-background-color);box-shadow:var(--swal2-cancel-button-box-shadow);color:var(--swal2-cancel-button-color);font-size:1em}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel):hover{background-color:color-mix(in srgb, var(--swal2-cancel-button-background-color), var(--swal2-action-button-hover))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel):active{background-color:color-mix(in srgb, var(--swal2-cancel-button-background-color), var(--swal2-action-button-active))}div:where(.swal2-container) button:where(.swal2-styled):focus-visible{outline:none;box-shadow:var(--swal2-action-button-focus-box-shadow)}div:where(.swal2-container) button:where(.swal2-styled)[disabled]:not(.swal2-loading){opacity:.4}div:where(.swal2-container) button:where(.swal2-styled)::-moz-focus-inner{border:0}div:where(.swal2-container) div:where(.swal2-footer){margin:1em 0 0;padding:1em 1em 0;border-top:1px solid var(--swal2-footer-border-color);background:var(--swal2-footer-background);color:var(--swal2-footer-color);font-size:1em;text-align:center;cursor:initial}div:where(.swal2-container) .swal2-timer-progress-bar-container{position:absolute;right:0;bottom:0;left:0;grid-column:auto !important;overflow:hidden;border-bottom-right-radius:var(--swal2-border-radius);border-bottom-left-radius:var(--swal2-border-radius)}div:where(.swal2-container) div:where(.swal2-timer-progress-bar){width:100%;height:.25em;background:var(--swal2-timer-progress-bar-background)}div:where(.swal2-container) img:where(.swal2-image){max-width:100%;margin:2em auto 1em;cursor:initial}div:where(.swal2-container) button:where(.swal2-close){position:var(--swal2-close-button-position);inset:var(--swal2-close-button-inset);z-index:2;align-items:center;justify-content:center;width:1.2em;height:1.2em;margin-top:0;margin-right:0;margin-bottom:-1.2em;padding:0;overflow:hidden;transition:var(--swal2-close-button-transition);border:none;border-radius:var(--swal2-border-radius);outline:var(--swal2-close-button-outline);background:rgba(0,0,0,0);color:var(--swal2-close-button-color);font-family:monospace;font-size:var(--swal2-close-button-font-size);cursor:pointer;justify-self:end}div:where(.swal2-container) button:where(.swal2-close):hover{transform:var(--swal2-close-button-hover-transform);background:rgba(0,0,0,0);color:#f27474}div:where(.swal2-container) button:where(.swal2-close):focus-visible{outline:none;box-shadow:var(--swal2-close-button-focus-box-shadow)}div:where(.swal2-container) button:where(.swal2-close)::-moz-focus-inner{border:0}div:where(.swal2-container) div:where(.swal2-html-container){z-index:1;justify-content:center;margin:0;padding:var(--swal2-html-container-padding);overflow:auto;color:inherit;font-size:1.125em;font-weight:normal;line-height:normal;text-align:center;overflow-wrap:break-word;word-break:break-word;cursor:initial}div:where(.swal2-container) input:where(.swal2-input),div:where(.swal2-container) input:where(.swal2-file),div:where(.swal2-container) textarea:where(.swal2-textarea),div:where(.swal2-container) select:where(.swal2-select),div:where(.swal2-container) div:where(.swal2-radio),div:where(.swal2-container) label:where(.swal2-checkbox){margin:1em 2em 3px}div:where(.swal2-container) input:where(.swal2-input),div:where(.swal2-container) input:where(.swal2-file),div:where(.swal2-container) textarea:where(.swal2-textarea){box-sizing:border-box;width:auto;transition:var(--swal2-input-transition);border:var(--swal2-input-border);border-radius:var(--swal2-input-border-radius);background:var(--swal2-input-background);box-shadow:var(--swal2-input-box-shadow);color:inherit;font-size:1.125em}div:where(.swal2-container) input:where(.swal2-input).swal2-inputerror,div:where(.swal2-container) input:where(.swal2-file).swal2-inputerror,div:where(.swal2-container) textarea:where(.swal2-textarea).swal2-inputerror{border-color:#f27474 !important;box-shadow:0 0 2px #f27474 !important}div:where(.swal2-container) input:where(.swal2-input):hover,div:where(.swal2-container) input:where(.swal2-file):hover,div:where(.swal2-container) textarea:where(.swal2-textarea):hover{box-shadow:var(--swal2-input-hover-box-shadow)}div:where(.swal2-container) input:where(.swal2-input):focus,div:where(.swal2-container) input:where(.swal2-file):focus,div:where(.swal2-container) textarea:where(.swal2-textarea):focus{border:var(--swal2-input-focus-border);outline:none;box-shadow:var(--swal2-input-focus-box-shadow)}div:where(.swal2-container) input:where(.swal2-input)::placeholder,div:where(.swal2-container) input:where(.swal2-file)::placeholder,div:where(.swal2-container) textarea:where(.swal2-textarea)::placeholder{color:#ccc}div:where(.swal2-container) .swal2-range{margin:1em 2em 3px;background:var(--swal2-background)}div:where(.swal2-container) .swal2-range input{width:80%}div:where(.swal2-container) .swal2-range output{width:20%;color:inherit;font-weight:600;text-align:center}div:where(.swal2-container) .swal2-range input,div:where(.swal2-container) .swal2-range output{height:2.625em;padding:0;font-size:1.125em;line-height:2.625em}div:where(.swal2-container) .swal2-input{height:2.625em;padding:0 .75em}div:where(.swal2-container) .swal2-file{width:75%;margin-right:auto;margin-left:auto;background:var(--swal2-input-background);font-size:1.125em}div:where(.swal2-container) .swal2-textarea{height:6.75em;padding:.75em}div:where(.swal2-container) .swal2-select{min-width:50%;max-width:100%;padding:.375em .625em;background:var(--swal2-input-background);color:inherit;font-size:1.125em}div:where(.swal2-container) .swal2-radio,div:where(.swal2-container) .swal2-checkbox{align-items:center;justify-content:center;background:var(--swal2-background);color:inherit}div:where(.swal2-container) .swal2-radio label,div:where(.swal2-container) .swal2-checkbox label{margin:0 .6em;font-size:1.125em}div:where(.swal2-container) .swal2-radio input,div:where(.swal2-container) .swal2-checkbox input{flex-shrink:0;margin:0 .4em}div:where(.swal2-container) label:where(.swal2-input-label){display:flex;justify-content:center;margin:1em auto 0}div:where(.swal2-container) div:where(.swal2-validation-message){align-items:center;justify-content:center;margin:1em 0 0;padding:.625em;overflow:hidden;background:var(--swal2-validation-message-background);color:var(--swal2-validation-message-color);font-size:1em;font-weight:300}div:where(.swal2-container) div:where(.swal2-validation-message)::before{content:\"!\";display:inline-block;width:1.5em;min-width:1.5em;height:1.5em;margin:0 .625em;border-radius:50%;background-color:#f27474;color:#fff;font-weight:600;line-height:1.5em;text-align:center}div:where(.swal2-container) .swal2-progress-steps{flex-wrap:wrap;align-items:center;max-width:100%;margin:1.25em auto;padding:0;background:rgba(0,0,0,0);font-weight:600}div:where(.swal2-container) .swal2-progress-steps li{display:inline-block;position:relative}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step{z-index:20;flex-shrink:0;width:2em;height:2em;border-radius:2em;background:#2778c4;color:#fff;line-height:2em;text-align:center}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step{background:#2778c4}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step{background:var(--swal2-progress-step-background);color:#fff}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step-line{background:var(--swal2-progress-step-background)}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step-line{z-index:10;flex-shrink:0;width:2.5em;height:.4em;margin:0 -1px;background:#2778c4}div:where(.swal2-icon){position:relative;box-sizing:content-box;justify-content:center;width:5em;height:5em;margin:2.5em auto .6em;zoom:var(--swal2-icon-zoom);border:.25em solid rgba(0,0,0,0);border-radius:50%;border-color:#000;font-family:inherit;line-height:5em;cursor:default;user-select:none}div:where(.swal2-icon) .swal2-icon-content{display:flex;align-items:center;font-size:3.75em}div:where(.swal2-icon).swal2-error{border-color:#f27474;color:#f27474}div:where(.swal2-icon).swal2-error .swal2-x-mark{position:relative;flex-grow:1}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line]{display:block;position:absolute;top:2.3125em;width:2.9375em;height:.3125em;border-radius:.125em;background-color:#f27474}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line][class$=left]{left:1.0625em;transform:rotate(45deg)}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line][class$=right]{right:1em;transform:rotate(-45deg)}
7211@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-error.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-error.swal2-icon-show .swal2-x-mark{animation:swal2-animate-error-x-mark .5s}}div:where(.swal2-icon).swal2-warning{border-color:#f8bb86;color:#f8bb86}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-warning.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-warning.swal2-icon-show .swal2-icon-content{animation:swal2-animate-i-mark .5s}}div:where(.swal2-icon).swal2-info{border-color:#3fc3ee;color:#3fc3ee}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-info.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-info.swal2-icon-show .swal2-icon-content{animation:swal2-animate-i-mark .8s}}div:where(.swal2-icon).swal2-question{border-color:#87adbd;color:#87adbd}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-question.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-question.swal2-icon-show .swal2-icon-content{animation:swal2-animate-question-mark .8s}}div:where(.swal2-icon).swal2-success{border-color:#a5dc86;color:#a5dc86}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line]{position:absolute;width:3.75em;height:7.5em;border-radius:50%}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line][class$=left]{top:-0.4375em;left:-2.0635em;transform:rotate(-45deg);transform-origin:3.75em 3.75em;border-radius:7.5em 0 0 7.5em}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line][class$=right]{top:-0.6875em;left:1.875em;transform:rotate(-45deg);transform-origin:0 3.75em;border-radius:0 7.5em 7.5em 0}div:where(.swal2-icon).swal2-success .swal2-success-ring{position:absolute;z-index:2;top:-0.25em;left:-0.25em;box-sizing:content-box;width:100%;height:100%;border:.25em solid rgba(165,220,134,.3);border-radius:50%}div:where(.swal2-icon).swal2-success .swal2-success-fix{position:absolute;z-index:1;top:.5em;left:1.625em;width:.4375em;height:5.625em;transform:rotate(-45deg)}div:where(.swal2-icon).swal2-success [class^=swal2-success-line]{display:block;position:absolute;z-index:2;height:.3125em;border-radius:.125em;background-color:#a5dc86}div:where(.swal2-icon).swal2-success [class^=swal2-success-line][class$=tip]{top:2.875em;left:.8125em;width:1.5625em;transform:rotate(45deg)}div:where(.swal2-icon).swal2-success [class^=swal2-success-line][class$=long]{top:2.375em;right:.5em;width:2.9375em;transform:rotate(-45deg)}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-line-tip{animation:swal2-animate-success-line-tip .75s}div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-line-long{animation:swal2-animate-success-line-long .75s}div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-circular-line-right{animation:swal2-rotate-success-circular-line 4.25s ease-in}}[class^=swal2]{-webkit-tap-highlight-color:rgba(0,0,0,0)}.swal2-show{animation:var(--swal2-show-animation)}.swal2-hide{animation:var(--swal2-hide-animation)}.swal2-noanimation{transition:none}.swal2-scrollbar-measure{position:absolute;top:-9999px;width:50px;height:50px;overflow:scroll}.swal2-rtl .swal2-close{margin-right:initial;margin-left:0}.swal2-rtl .swal2-timer-progress-bar{right:0;left:auto}.swal2-toast{box-sizing:border-box;grid-column:1/4 !important;grid-row:1/4 !important;grid-template-columns:min-content auto min-content;padding:1em;overflow-y:hidden;border:var(--swal2-toast-border);background:var(--swal2-background);box-shadow:var(--swal2-toast-box-shadow);pointer-events:auto
vendor: 5,388 bytes, line 7211
7211}.swal2-toast>*{grid-column:2}.swal2-toast h2:where(.swal2-title){margin:.5em 1em;padding:0;font-size:1em;text-align:initial}.swal2-toast .swal2-loading{justify-content:center}.swal2-toast input:where(.swal2-input){height:2em;margin:.5em;font-size:1em}.swal2-toast .swal2-validation-message{font-size:1em}.swal2-toast div:where(.swal2-footer){margin:.5em 0 0;padding:.5em 0 0;font-size:.8em}.swal2-toast button:where(.swal2-close){grid-column:3/3;grid-row:1/99;align-self:center;width:.8em;height:.8em;margin:0;font-size:2em}.swal2-toast div:where(.swal2-html-container){margin:.5em 1em;padding:0;overflow:initial;font-size:1em;text-align:initial}.swal2-toast div:where(.swal2-html-container):empty{padding:0}.swal2-toast .swal2-loader{grid-column:1;grid-row:1/99;align-self:center;width:2em;height:2em;margin:.25em}.swal2-toast .swal2-icon{grid-column:1;grid-row:1/99;align-self:center;width:2em;min-width:2em;height:2em;margin:0 .5em 0 0}.swal2-toast .swal2-icon .swal2-icon-content{display:flex;align-items:center;font-size:1.8em;font-weight:bold}.swal2-toast .swal2-icon.swal2-success .swal2-success-ring{width:2em;height:2em}.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line]{top:.875em;width:1.375em}.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=left]{left:.3125em}.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=right]{right:.3125em}.swal2-toast div:where(.swal2-actions){justify-content:flex-start;height:auto;margin:0;margin-top:.5em;padding:0 .5em}.swal2-toast button:where(.swal2-styled){margin:.25em .5em;padding:.4em .6em;font-size:1em}.swal2-toast .swal2-success{border-color:#a5dc86}.swal2-toast .swal2-success [class^=swal2-success-circular-line]{position:absolute;width:1.6em;height:3em;border-radius:50%}.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=left]{top:-0.8em;left:-0.5em;transform:rotate(-45deg);transform-origin:2em 2em;border-radius:4em 0 0 4em}.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=right]{top:-0.25em;left:.9375em;transform-origin:0 1.5em;border-radius:0 4em 4em 0}.swal2-toast .swal2-success .swal2-success-ring{width:2em;height:2em}.swal2-toast .swal2-success .swal2-success-fix{top:0;left:.4375em;width:.4375em;height:2.6875em}.swal2-toast .swal2-success [class^=swal2-success-line]{height:.3125em}.swal2-toast .swal2-success [class^=swal2-success-line][class$=tip]{top:1.125em;left:.1875em;width:.75em}.swal2-toast .swal2-success [class^=swal2-success-line][class$=long]{top:.9375em;right:.1875em;width:1.375em}@container swal2-popup style(--swal2-icon-animations:true){.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-tip{animation:swal2-toast-animate-success-line-tip .75s}.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-long{animation:swal2-toast-animate-success-line-long .75s}}.swal2-toast.swal2-show{animation:var(--swal2-toast-show-animation)}.swal2-toast.swal2-hide{animation:var(--swal2-toast-hide-animation)}@keyframes swal2-show{0%{transform:translate3d(0, -50px, 0) scale(0.9);opacity:0}100%{transform:translate3d(0, 0, 0) scale(1);opacity:1}}@keyframes swal2-hide{0%{transform:translate3d(0, 0, 0) scale(1);opacity:1}100%{transform:translate3d(0, -50px, 0) scale(0.9);opacity:0}}@keyframes swal2-animate-success-line-tip{0%{top:1.1875em;left:.0625em;width:0}54%{top:1.0625em;left:.125em;width:0}70%{top:2.1875em;left:-0.375em;width:3.125em}84%{top:3em;left:1.3125em;width:1.0625em}100%{top:2.8125em;left:.8125em;width:1.5625em}}@keyframes swal2-animate-success-line-long{0%{top:3.375em;right:2.875em;width:0}65%{top:3.375em;right:2.875em;width:0}84%{top:2.1875em;right:0;width:3.4375em}100%{top:2.375em;right:.5em;width:2.9375em}}@keyframes swal2-rotate-success-circular-line{0%{transform:rotate(-45deg)}5%{transform:rotate(-45deg)}12%{transform:rotate(-405deg)}100%{transform:rotate(-405deg)}}@keyframes swal2-animate-error-x-mark{0%{margin-top:1.625em;transform:scale(0.4);opacity:0}50%{margin-top:1.625em;transform:scale(0.4);opacity:0}80%{margin-top:-0.375em;transform:scale(1.15)}100%{margin-top:0;transform:scale(1);opacity:1}}@keyframes swal2-animate-error-icon{0%{transform:rotateX(100deg);opacity:0}100%{transform:rotateX(0deg);opacity:1}}@keyframes swal2-rotate-loading{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}@keyframes swal2-animate-question-mark{0%{transform:rotateY(-360deg)}100%{transform:rotateY(0)}}@keyframes swal2-animate-i-mark{0%{transform:rotateZ(45deg);opacity:0}25%{transform:rotateZ(-25deg);opacity:.4}50%{transform:rotateZ(15deg);opacity:.8}75%{transform:rotateZ(-5deg);opacity:1}100%{transform:rotateX(0);opacity:1}}@keyframes swal2-toast-show{0%{transform:translateY(-0.625em) rotateZ(2deg)}33%{transform:translateY(0) rotateZ(-2deg)}66%{transform:translateY(0.3125em) rotateZ(2deg)}100%{transform:translateY(0) rotateZ(0deg)}}@keyframes swal2-toast-hide{100%{transform:rotateZ(1deg);opacity:0}}@keyframes swal2-toast-animate-success-line-tip{0%{top:.5625em;left:.0625em;width:0}54%{top:.125em;left:.125em;width:0}70%{top:.625em;left:-0.25em;width:1.625em}84%{top:1.0625em;left:.75em;width:.5em}100%{top:1.125em;left:.1875em;width:.75em}}@keyframes swal2-toast-animate-success-line-long{0%{top:1.625em;right:1.375em;width:0}65%{top:1.25em;right:.9375em;width:0}84%{top:.9375em;right:0;width:1.125em}100%{top:.9375em;right:.1875em;width:1.375em}}
7211"); 7212 7213/***/ }), 7214 7215/***/ 118: 7216/***/ (function(module, __webpack_exports__, __webpack_require__) { 7217 7218"use strict"; 7219/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return counterAnimations; }); 7220var counterAnimations = function () { 7221 var els = document.querySelectorAll('.animated-counter'); 7222 if (!els.length) { return; } 7223 7224 var easeOutCubic = function (t) { return 1 - Math.pow(1 - t, 3); }; 7225 7226 function parseTarget(el) { 7227 // Prefer clean numeric from data-target (recommend: unformatted number) 7228 var s = (el.getAttribute('data-target') || el.textContent || '').trim(); 7229 7230 // Normalize thousands/decimals from common formats: 7231 s = s.replace(/\u00A0/g, ' '); // NBSP â space 7232 var hasComma = s.includes(','); 7233 var hasDot = s.includes('.'); 7234 if (hasComma && !hasDot) { s = s.replace(/,/g, '.'); } // comma as decimal 7235 s = s.replace(/[\s,]/g, ''); // drop spaces & remaining commas (thousands) 7236 var n = parseFloat(s); 7237 return Number.isNaN(n) ? 0 : n; 7238 } 7239 7240 function decimalsOf(s) { 7241 var m = String(s).match(/\.(\d+)/); 7242 return m ? m[1].length : 0; 7243 } 7244 7245 function animate(el) { 7246 var target = parseTarget(el); 7247 // Determine decimals from the normalized numeric string 7248 var decs = decimalsOf(target); 7249 var fmt = new Intl.NumberFormat(undefined, { 7250 minimumFractionDigits: decs, 7251 maximumFractionDigits: decs, 7252 }); 7253 7254 var duration = Math.max(0, parseInt(el.dataset.duration || '1200', 10)); 7255 var startVal = 0; 7256 var start = performance.now(); 7257 var delta = target - startVal; 7258 7259 // Set initial 0 once we begin 7260 el.textContent = fmt.format(0); 7261 7262 function frame(now) { 7263 var t = Math.min(1, (now - start) / duration); 7264 var eased = easeOutCubic(t); 7265 var val = startVal + delta * eased; 7266 el.textContent = fmt.format(t < 1 ? val : target); 7267 if (t < 1) { requestAnimationFrame(frame); } 7268 } 7269 7270 requestAnimationFrame(frame); 7271 } 7272 7273 function onEnter(entries, obs) { 7274 entries.forEach(function (entry) { 7275 if (entry.isIntersecting) { 7276 obs.unobserve(entry.target); 7277 animate(entry.target); 7278 } 7279 }); 7280 } 7281 7282 if ('IntersectionObserver' in window) { 7283 var io = new IntersectionObserver(onEnter, {threshold: 0.25}); 7284 els.forEach(function (el) { return io.observe(el); }); 7285 } else { 7286 // Fallback if IO not available: run immediately 7287 els.forEach(animate); 7288 } 7289}; 7290 7291 7292/***/ }), 7293 7294/***/ 119: 7295/***/ (function(module, __webpack_exports__, __webpack_require__) { 7296 7297"use strict"; 7298/* harmony default export */ __webpack_exports__["a"] = ({ 7299 init: function init() { 7300 // JavaScript to be fired on the home page 7301 }, 7302 finalize: function finalize() { 7303 // JavaScript to be fired on the home page, after the init JS 7304 }, 7305}); 7306 7307 7308/***/ }), 7309 7310/***/ 120: 7311/***/ (function(module, __webpack_exports__, __webpack_require__) { 7312 7313"use strict"; 7314/* harmony default export */ __webpack_exports__["a"] = ({
vendor: 5,558 bytes, lines 7315-7607
7315 init: function init() { 7316 // JavaScript to be fired on the about us page 7317 }, 7318}); 7319 7320 7321/***/ }), 7322 7323/***/ 121: 7324/***/ (function(module, exports) { 7325 7326// removed by extract-text-webpack-plugin 7327 7328/***/ }), 7329 7330/***/ 3: 7331/***/ (function(module, exports) { 7332 7333module.exports = jQuery; 7334 7335/***/ }), 7336 7337/***/ 4: 7338/***/ (function(module, exports, __webpack_require__) { 7339 7340/** 7341 * Swiper 8.4.7 7342 * Most modern mobile touch slider and framework with hardware accelerated transitions 7343 * https://swiperjs.com 7344 * 7345 * Copyright 2014-2023 Vladimir Kharlampidi 7346 * 7347 * Released under the MIT License 7348 * 7349 * Released on: January 30, 2023 7350 */ 7351 7352(function (global, factory) { 7353 true ? module.exports = factory() : 7354 typeof define === 'function' && define.amd ? define(factory) : 7355 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Swiper = factory()); 7356})(this, (function () { 'use strict'; 7357 7358 /** 7359 * SSR Window 4.0.2 7360 * Better handling for window object in SSR environment 7361 * https://github.com/nolimits4web/ssr-window 7362 * 7363 * Copyright 2021, Vladimir Kharlampidi 7364 * 7365 * Licensed under MIT 7366 * 7367 * Released on: December 13, 2021 7368 */ 7369 7370 /* eslint-disable no-param-reassign */ 7371 function isObject$1(obj) { 7372 return obj !== null && typeof obj === 'object' && 'constructor' in obj && obj.constructor === Object; 7373 } 7374 7375 function extend$1(target, src) { 7376 if (target === void 0) { 7377 target = {}; 7378 } 7379 7380 if (src === void 0) { 7381 src = {}; 7382 } 7383 7384 Object.keys(src).forEach(key => { 7385 if (typeof target[key] === 'undefined') target[key] = src[key];else if (isObject$1(src[key]) && isObject$1(target[key]) && Object.keys(src[key]).length > 0) { 7386 extend$1(target[key], src[key]); 7387 } 7388 }); 7389 } 7390 7391 const ssrDocument = { 7392 body: {}, 7393 7394 addEventListener() {}, 7395 7396 removeEventListener() {}, 7397 7398 activeElement: { 7399 blur() {}, 7400 7401 nodeName: '' 7402 }, 7403 7404 querySelector() { 7405 return null; 7406 }, 7407 7408 querySelectorAll() { 7409 return []; 7410 }, 7411 7412 getElementById() { 7413 return null; 7414 }, 7415 7416 createEvent() { 7417 return { 7418 initEvent() {} 7419 7420 }; 7421 }, 7422 7423 createElement() { 7424 return { 7425 children: [], 7426 childNodes: [], 7427 style: {}, 7428 7429 setAttribute() {}, 7430 7431 getElementsByTagName() { 7432 return []; 7433 } 7434 7435 }; 7436 }, 7437 7438 createElementNS() { 7439 return {}; 7440 }, 7441 7442 importNode() { 7443 return null; 7444 }, 7445 7446 location: { 7447 hash: '', 7448 host: '', 7449 hostname: '', 7450 href: '', 7451 origin: '', 7452 pathname: '', 7453 protocol: '', 7454 search: '' 7455 } 7456 }; 7457 7458 function getDocument() { 7459 const doc = typeof document !== 'undefined' ? document : {}; 7460 extend$1(doc, ssrDocument); 7461 return doc; 7462 } 7463 7464 const ssrWindow = { 7465 document: ssrDocument, 7466 navigator: { 7467 userAgent: '' 7468 }, 7469 location: { 7470 hash: '', 7471 host: '', 7472 hostname: '', 7473 href: '', 7474 origin: '', 7475 pathname: '', 7476 protocol: '', 7477 search: '' 7478 }, 7479 history: { 7480 replaceState() {}, 7481 7482 pushState() {}, 7483 7484 go() {}, 7485 7486 back() {} 7487 7488 }, 7489 CustomEvent: function CustomEvent() { 7490 return this; 7491 }, 7492 7493 addEventListener() {}, 7494 7495 removeEventListener() {}, 7496 7497 getComputedStyle() { 7498 return { 7499 getPropertyValue() { 7500 return ''; 7501 } 7502 7503 }; 7504 }, 7505 7506 Image() {}, 7507 7508 Date() {}, 7509 7510 screen: {}, 7511 7512 setTimeout() {}, 7513 7514 clearTimeout() {}, 7515 7516 matchMedia() { 7517 return {}; 7518 }, 7519 7520 requestAnimationFrame(callback) { 7521 if (typeof setTimeout === 'undefined') { 7522 callback(); 7523 return null; 7524 } 7525 7526 return setTimeout(callback, 0); 7527 }, 7528 7529 cancelAnimationFrame(id) { 7530 if (typeof setTimeout === 'undefined') { 7531 return; 7532 } 7533 7534 clearTimeout(id); 7535 } 7536 7537 }; 7538 7539 function getWindow() { 7540 const win = typeof window !== 'undefined' ? window : {}; 7541 extend$1(win, ssrWindow); 7542 return win; 7543 } 7544 7545 /** 7546 * Dom7 4.0.4 7547 * Minimalistic JavaScript library for DOM manipulation, with a jQuery-compatible API 7548 * https://framework7.io/docs/dom7.html 7549 * 7550 * Copyright 2022, Vladimir Kharlampidi 7551 * 7552 * Licensed under MIT 7553 * 7554 * Released on: January 11, 2022 7555 */ 7556 /* eslint-disable no-proto */ 7557 7558 function makeReactive(obj) { 7559 const proto = obj.__proto__; 7560 Object.defineProperty(obj, '__proto__', { 7561 get() { 7562 return proto; 7563 }, 7564 7565 set(value) { 7566 proto.__proto__ = value; 7567 } 7568 7569 }); 7570 } 7571 7572 class Dom7 extends Array { 7573 constructor(items) { 7574 if (typeof items === 'number') { 7575 super(items); 7576 } else { 7577 super(...(items || [])); 7578 makeReactive(this); 7579 } 7580 } 7581 7582 } 7583 7584 function arrayFlat(arr) { 7585 if (arr === void 0) { 7586 arr = []; 7587 } 7588 7589 const res = []; 7590 arr.forEach(el => { 7591 if (Array.isArray(el)) { 7592 res.push(...arrayFlat(el)); 7593 } else { 7594 res.push(el); 7595 } 7596 }); 7597 return res; 7598 } 7599 7600 function arrayFilter(arr, callback) { 7601 return Array.prototype.filter.call(arr, callback); 7602 } 7603 7604 function arrayUnique(arr) { 7605 const uniqueArray = []; 7606 7607 for (let i = 0; i < arr.length; i += 1) {
vendor: 13,231 bytes, lines 7608-8074
7608 if (uniqueArray.indexOf(arr[i]) === -1) uniqueArray.push(arr[i]); 7609 } 7610 7611 return uniqueArray; 7612 } 7613 7614 7615 function qsa(selector, context) { 7616 if (typeof selector !== 'string') { 7617 return [selector]; 7618 } 7619 7620 const a = []; 7621 const res = context.querySelectorAll(selector); 7622 7623 for (let i = 0; i < res.length; i += 1) { 7624 a.push(res[i]); 7625 } 7626 7627 return a; 7628 } 7629 7630 function $(selector, context) { 7631 const window = getWindow(); 7632 const document = getDocument(); 7633 let arr = []; 7634 7635 if (!context && selector instanceof Dom7) { 7636 return selector; 7637 } 7638 7639 if (!selector) { 7640 return new Dom7(arr); 7641 } 7642 7643 if (typeof selector === 'string') { 7644 const html = selector.trim(); 7645 7646 if (html.indexOf('<') >= 0 && html.indexOf('>') >= 0) { 7647 let toCreate = 'div'; 7648 if (html.indexOf('<li') === 0) toCreate = 'ul'; 7649 if (html.indexOf('<tr') === 0) toCreate = 'tbody'; 7650 if (html.indexOf('<td') === 0 || html.indexOf('<th') === 0) toCreate = 'tr'; 7651 if (html.indexOf('<tbody') === 0) toCreate = 'table'; 7652 if (html.indexOf('<option') === 0) toCreate = 'select'; 7653 const tempParent = document.createElement(toCreate); 7654 tempParent.innerHTML = html; 7655 7656 for (let i = 0; i < tempParent.childNodes.length; i += 1) { 7657 arr.push(tempParent.childNodes[i]); 7658 } 7659 } else { 7660 arr = qsa(selector.trim(), context || document); 7661 } // arr = qsa(selector, document); 7662 7663 } else if (selector.nodeType || selector === window || selector === document) { 7664 arr.push(selector); 7665 } else if (Array.isArray(selector)) { 7666 if (selector instanceof Dom7) return selector; 7667 arr = selector; 7668 } 7669 7670 return new Dom7(arrayUnique(arr)); 7671 } 7672 7673 $.fn = Dom7.prototype; // eslint-disable-next-line 7674 7675 function addClass() { 7676 for (var _len = arguments.length, classes = new Array(_len), _key = 0; _key < _len; _key++) { 7677 classes[_key] = arguments[_key]; 7678 } 7679 7680 const classNames = arrayFlat(classes.map(c => c.split(' '))); 7681 this.forEach(el => { 7682 el.classList.add(...classNames); 7683 }); 7684 return this; 7685 } 7686 7687 function removeClass() { 7688 for (var _len2 = arguments.length, classes = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { 7689 classes[_key2] = arguments[_key2]; 7690 } 7691 7692 const classNames = arrayFlat(classes.map(c => c.split(' '))); 7693 this.forEach(el => { 7694 el.classList.remove(...classNames); 7695 }); 7696 return this; 7697 } 7698 7699 function toggleClass() { 7700 for (var _len3 = arguments.length, classes = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { 7701 classes[_key3] = arguments[_key3]; 7702 } 7703 7704 const classNames = arrayFlat(classes.map(c => c.split(' '))); 7705 this.forEach(el => { 7706 classNames.forEach(className => { 7707 el.classList.toggle(className); 7708 }); 7709 }); 7710 } 7711 7712 function hasClass() { 7713 for (var _len4 = arguments.length, classes = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { 7714 classes[_key4] = arguments[_key4]; 7715 } 7716 7717 const classNames = arrayFlat(classes.map(c => c.split(' '))); 7718 return arrayFilter(this, el => { 7719 return classNames.filter(className => el.classList.contains(className)).length > 0; 7720 }).length > 0; 7721 } 7722 7723 function attr(attrs, value) { 7724 if (arguments.length === 1 && typeof attrs === 'string') { 7725 // Get attr 7726 if (this[0]) return this[0].getAttribute(attrs); 7727 return undefined; 7728 } // Set attrs 7729 7730 7731 for (let i = 0; i < this.length; i += 1) { 7732 if (arguments.length === 2) { 7733 // String 7734 this[i].setAttribute(attrs, value); 7735 } else { 7736 // Object 7737 for (const attrName in attrs) { 7738 this[i][attrName] = attrs[attrName]; 7739 this[i].setAttribute(attrName, attrs[attrName]); 7740 } 7741 } 7742 } 7743 7744 return this; 7745 } 7746 7747 function removeAttr(attr) { 7748 for (let i = 0; i < this.length; i += 1) { 7749 this[i].removeAttribute(attr); 7750 } 7751 7752 return this; 7753 } 7754 7755 function transform(transform) { 7756 for (let i = 0; i < this.length; i += 1) { 7757 this[i].style.transform = transform; 7758 } 7759 7760 return this; 7761 } 7762 7763 function transition$1(duration) { 7764 for (let i = 0; i < this.length; i += 1) { 7765 this[i].style.transitionDuration = typeof duration !== 'string' ? `${duration}ms` : duration; 7766 } 7767 7768 return this; 7769 } 7770 7771 function on() { 7772 for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) { 7773 args[_key5] = arguments[_key5]; 7774 } 7775 7776 let [eventType, targetSelector, listener, capture] = args; 7777 7778 if (typeof args[1] === 'function') { 7779 [eventType, listener, capture] = args; 7780 targetSelector = undefined; 7781 } 7782 7783 if (!capture) capture = false; 7784 7785 function handleLiveEvent(e) { 7786 const target = e.target; 7787 if (!target) return; 7788 const eventData = e.target.dom7EventData || []; 7789 7790 if (eventData.indexOf(e) < 0) { 7791 eventData.unshift(e); 7792 } 7793 7794 if ($(target).is(targetSelector)) listener.apply(target, eventData);else { 7795 const parents = $(target).parents(); // eslint-disable-line 7796 7797 for (let k = 0; k < parents.length; k += 1) { 7798 if ($(parents[k]).is(targetSelector)) listener.apply(parents[k], eventData); 7799 } 7800 } 7801 } 7802 7803 function handleEvent(e) { 7804 const eventData = e && e.target ? e.target.dom7EventData || [] : []; 7805 7806 if (eventData.indexOf(e) < 0) { 7807 eventData.unshift(e); 7808 } 7809 7810 listener.apply(this, eventData); 7811 } 7812 7813 const events = eventType.split(' '); 7814 let j; 7815 7816 for (let i = 0; i < this.length; i += 1) { 7817 const el = this[i]; 7818 7819 if (!targetSelector) { 7820 for (j = 0; j < events.length; j += 1) { 7821 const event = events[j]; 7822 if (!el.dom7Listeners) el.dom7Listeners = {}; 7823 if (!el.dom7Listeners[event]) el.dom7Listeners[event] = []; 7824 el.dom7Listeners[event].push({ 7825 listener, 7826 proxyListener: handleEvent 7827 }); 7828 el.addEventListener(event, handleEvent, capture); 7829 } 7830 } else { 7831 // Live events 7832 for (j = 0; j < events.length; j += 1) { 7833 const event = events[j]; 7834 if (!el.dom7LiveListeners) el.dom7LiveListeners = {}; 7835 if (!el.dom7LiveListeners[event]) el.dom7LiveListeners[event] = []; 7836 el.dom7LiveListeners[event].push({ 7837 listener, 7838 proxyListener: handleLiveEvent 7839 }); 7840 el.addEventListener(event, handleLiveEvent, capture); 7841 } 7842 } 7843 } 7844 7845 return this; 7846 } 7847 7848 function off() { 7849 for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) { 7850 args[_key6] = arguments[_key6]; 7851 } 7852 7853 let [eventType, targetSelector, listener, capture] = args; 7854 7855 if (typeof args[1] === 'function') { 7856 [eventType, listener, capture] = args; 7857 targetSelector = undefined; 7858 } 7859 7860 if (!capture) capture = false; 7861 const events = eventType.split(' '); 7862 7863 for (let i = 0; i < events.length; i += 1) { 7864 const event = events[i]; 7865 7866 for (let j = 0; j < this.length; j += 1) { 7867 const el = this[j]; 7868 let handlers; 7869 7870 if (!targetSelector && el.dom7Listeners) { 7871 handlers = el.dom7Listeners[event]; 7872 } else if (targetSelector && el.dom7LiveListeners) { 7873 handlers = el.dom7LiveListeners[event]; 7874 } 7875 7876 if (handlers && handlers.length) { 7877 for (let k = handlers.length - 1; k >= 0; k -= 1) { 7878 const handler = handlers[k]; 7879 7880 if (listener && handler.listener === listener) { 7881 el.removeEventListener(event, handler.proxyListener, capture); 7882 handlers.splice(k, 1); 7883 } else if (listener && handler.listener && handler.listener.dom7proxy && handler.listener.dom7proxy === listener) { 7884 el.removeEventListener(event, handler.proxyListener, capture); 7885 handlers.splice(k, 1); 7886 } else if (!listener) { 7887 el.removeEventListener(event, handler.proxyListener, capture); 7888 handlers.splice(k, 1); 7889 } 7890 } 7891 } 7892 } 7893 } 7894 7895 return this; 7896 } 7897 7898 function trigger() { 7899 const window = getWindow(); 7900 7901 for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) { 7902 args[_key9] = arguments[_key9]; 7903 } 7904 7905 const events = args[0].split(' '); 7906 const eventData = args[1]; 7907 7908 for (let i = 0; i < events.length; i += 1) { 7909 const event = events[i]; 7910 7911 for (let j = 0; j < this.length; j += 1) { 7912 const el = this[j]; 7913 7914 if (window.CustomEvent) { 7915 const evt = new window.CustomEvent(event, { 7916 detail: eventData, 7917 bubbles: true, 7918 cancelable: true 7919 }); 7920 el.dom7EventData = args.filter((data, dataIndex) => dataIndex > 0); 7921 el.dispatchEvent(evt); 7922 el.dom7EventData = []; 7923 delete el.dom7EventData; 7924 } 7925 } 7926 } 7927 7928 return this; 7929 } 7930 7931 function transitionEnd$1(callback) { 7932 const dom = this; 7933 7934 function fireCallBack(e) { 7935 if (e.target !== this) return; 7936 callback.call(this, e); 7937 dom.off('transitionend', fireCallBack); 7938 } 7939 7940 if (callback) { 7941 dom.on('transitionend', fireCallBack); 7942 } 7943 7944 return this; 7945 } 7946 7947 function outerWidth(includeMargins) { 7948 if (this.length > 0) { 7949 if (includeMargins) { 7950 const styles = this.styles(); 7951 return this[0].offsetWidth + parseFloat(styles.getPropertyValue('margin-right')) + parseFloat(styles.getPropertyValue('margin-left')); 7952 } 7953 7954 return this[0].offsetWidth; 7955 } 7956 7957 return null; 7958 } 7959 7960 function outerHeight(includeMargins) { 7961 if (this.length > 0) { 7962 if (includeMargins) { 7963 const styles = this.styles(); 7964 return this[0].offsetHeight + parseFloat(styles.getPropertyValue('margin-top')) + parseFloat(styles.getPropertyValue('margin-bottom')); 7965 } 7966 7967 return this[0].offsetHeight; 7968 } 7969 7970 return null; 7971 } 7972 7973 function offset() { 7974 if (this.length > 0) { 7975 const window = getWindow(); 7976 const document = getDocument(); 7977 const el = this[0]; 7978 const box = el.getBoundingClientRect(); 7979 const body = document.body; 7980 const clientTop = el.clientTop || body.clientTop || 0; 7981 const clientLeft = el.clientLeft || body.clientLeft || 0; 7982 const scrollTop = el === window ? window.scrollY : el.scrollTop; 7983 const scrollLeft = el === window ? window.scrollX : el.scrollLeft; 7984 return { 7985 top: box.top + scrollTop - clientTop, 7986 left: box.left + scrollLeft - clientLeft 7987 }; 7988 } 7989 7990 return null; 7991 } 7992 7993 function styles() { 7994 const window = getWindow(); 7995 if (this[0]) return window.getComputedStyle(this[0], null); 7996 return {}; 7997 } 7998 7999 function css(props, value) { 8000 const window = getWindow(); 8001 let i; 8002 8003 if (arguments.length === 1) { 8004 if (typeof props === 'string') { 8005 // .css('width') 8006 if (this[0]) return window.getComputedStyle(this[0], null).getPropertyValue(props); 8007 } else { 8008 // .css({ width: '100px' }) 8009 for (i = 0; i < this.length; i += 1) { 8010 for (const prop in props) { 8011 this[i].style[prop] = props[prop]; 8012 } 8013 } 8014 8015 return this; 8016 } 8017 } 8018 8019 if (arguments.length === 2 && typeof props === 'string') { 8020 // .css('width', '100px') 8021 for (i = 0; i < this.length; i += 1) { 8022 this[i].style[props] = value; 8023 } 8024 8025 return this; 8026 } 8027 8028 return this; 8029 } 8030 8031 function each(callback) { 8032 if (!callback) return this; 8033 this.forEach((el, index) => { 8034 callback.apply(el, [el, index]); 8035 }); 8036 return this; 8037 } 8038 8039 function filter(callback) { 8040 const result = arrayFilter(this, callback); 8041 return $(result); 8042 } 8043 8044 function html(html) { 8045 if (typeof html === 'undefined') { 8046 return this[0] ? this[0].innerHTML : null; 8047 } 8048 8049 for (let i = 0; i < this.length; i += 1) { 8050 this[i].innerHTML = html; 8051 } 8052 8053 return this; 8054 } 8055 8056 function text(text) { 8057 if (typeof text === 'undefined') { 8058 return this[0] ? this[0].textContent.trim() : null; 8059 } 8060 8061 for (let i = 0; i < this.length; i += 1) { 8062 this[i].textContent = text; 8063 } 8064 8065 return this; 8066 } 8067 8068 function is(selector) { 8069 const window = getWindow(); 8070 const document = getDocument(); 8071 const el = this[0]; 8072 let compareWith; 8073 let i; 8074 if (!el || typeof selector === 'undefined') return false;
vendor: 5,799 bytes, lines 8075-8311
8075 8076 if (typeof selector === 'string') { 8077 if (el.matches) return el.matches(selector); 8078 if (el.webkitMatchesSelector) return el.webkitMatchesSelector(selector); 8079 if (el.msMatchesSelector) return el.msMatchesSelector(selector); 8080 compareWith = $(selector); 8081 8082 for (i = 0; i < compareWith.length; i += 1) { 8083 if (compareWith[i] === el) return true; 8084 } 8085 8086 return false; 8087 } 8088 8089 if (selector === document) { 8090 return el === document; 8091 } 8092 8093 if (selector === window) { 8094 return el === window; 8095 } 8096 8097 if (selector.nodeType || selector instanceof Dom7) { 8098 compareWith = selector.nodeType ? [selector] : selector; 8099 8100 for (i = 0; i < compareWith.length; i += 1) { 8101 if (compareWith[i] === el) return true; 8102 } 8103 8104 return false; 8105 } 8106 8107 return false; 8108 } 8109 8110 function index() { 8111 let child = this[0]; 8112 let i; 8113 8114 if (child) { 8115 i = 0; // eslint-disable-next-line 8116 8117 while ((child = child.previousSibling) !== null) { 8118 if (child.nodeType === 1) i += 1; 8119 } 8120 8121 return i; 8122 } 8123 8124 return undefined; 8125 } 8126 8127 function eq(index) { 8128 if (typeof index === 'undefined') return this; 8129 const length = this.length; 8130 8131 if (index > length - 1) { 8132 return $([]); 8133 } 8134 8135 if (index < 0) { 8136 const returnIndex = length + index; 8137 if (returnIndex < 0) return $([]); 8138 return $([this[returnIndex]]); 8139 } 8140 8141 return $([this[index]]); 8142 } 8143 8144 function append() { 8145 let newChild; 8146 const document = getDocument(); 8147 8148 for (let k = 0; k < arguments.length; k += 1) { 8149 newChild = k < 0 || arguments.length <= k ? undefined : arguments[k]; 8150 8151 for (let i = 0; i < this.length; i += 1) { 8152 if (typeof newChild === 'string') { 8153 const tempDiv = document.createElement('div'); 8154 tempDiv.innerHTML = newChild; 8155 8156 while (tempDiv.firstChild) { 8157 this[i].appendChild(tempDiv.firstChild); 8158 } 8159 } else if (newChild instanceof Dom7) { 8160 for (let j = 0; j < newChild.length; j += 1) { 8161 this[i].appendChild(newChild[j]); 8162 } 8163 } else { 8164 this[i].appendChild(newChild); 8165 } 8166 } 8167 } 8168 8169 return this; 8170 } 8171 8172 function prepend(newChild) { 8173 const document = getDocument(); 8174 let i; 8175 let j; 8176 8177 for (i = 0; i < this.length; i += 1) { 8178 if (typeof newChild === 'string') { 8179 const tempDiv = document.createElement('div'); 8180 tempDiv.innerHTML = newChild; 8181 8182 for (j = tempDiv.childNodes.length - 1; j >= 0; j -= 1) { 8183 this[i].insertBefore(tempDiv.childNodes[j], this[i].childNodes[0]); 8184 } 8185 } else if (newChild instanceof Dom7) { 8186 for (j = 0; j < newChild.length; j += 1) { 8187 this[i].insertBefore(newChild[j], this[i].childNodes[0]); 8188 } 8189 } else { 8190 this[i].insertBefore(newChild, this[i].childNodes[0]); 8191 } 8192 } 8193 8194 return this; 8195 } 8196 8197 function next(selector) { 8198 if (this.length > 0) { 8199 if (selector) { 8200 if (this[0].nextElementSibling && $(this[0].nextElementSibling).is(selector)) { 8201 return $([this[0].nextElementSibling]); 8202 } 8203 8204 return $([]); 8205 } 8206 8207 if (this[0].nextElementSibling) return $([this[0].nextElementSibling]); 8208 return $([]); 8209 } 8210 8211 return $([]); 8212 } 8213 8214 function nextAll(selector) { 8215 const nextEls = []; 8216 let el = this[0]; 8217 if (!el) return $([]); 8218 8219 while (el.nextElementSibling) { 8220 const next = el.nextElementSibling; // eslint-disable-line 8221 8222 if (selector) { 8223 if ($(next).is(selector)) nextEls.push(next); 8224 } else nextEls.push(next); 8225 8226 el = next; 8227 } 8228 8229 return $(nextEls); 8230 } 8231 8232 function prev(selector) { 8233 if (this.length > 0) { 8234 const el = this[0]; 8235 8236 if (selector) { 8237 if (el.previousElementSibling && $(el.previousElementSibling).is(selector)) { 8238 return $([el.previousElementSibling]); 8239 } 8240 8241 return $([]); 8242 } 8243 8244 if (el.previousElementSibling) return $([el.previousElementSibling]); 8245 return $([]); 8246 } 8247 8248 return $([]); 8249 } 8250 8251 function prevAll(selector) { 8252 const prevEls = []; 8253 let el = this[0]; 8254 if (!el) return $([]); 8255 8256 while (el.previousElementSibling) { 8257 const prev = el.previousElementSibling; // eslint-disable-line 8258 8259 if (selector) { 8260 if ($(prev).is(selector)) prevEls.push(prev); 8261 } else prevEls.push(prev); 8262 8263 el = prev; 8264 } 8265 8266 return $(prevEls); 8267 } 8268 8269 function parent(selector) { 8270 const parents = []; // eslint-disable-line 8271 8272 for (let i = 0; i < this.length; i += 1) { 8273 if (this[i].parentNode !== null) { 8274 if (selector) { 8275 if ($(this[i].parentNode).is(selector)) parents.push(this[i].parentNode); 8276 } else { 8277 parents.push(this[i].parentNode); 8278 } 8279 } 8280 } 8281 8282 return $(parents); 8283 } 8284 8285 function parents(selector) { 8286 const parents = []; // eslint-disable-line 8287 8288 for (let i = 0; i < this.length; i += 1) { 8289 let parent = this[i].parentNode; // eslint-disable-line 8290 8291 while (parent) { 8292 if (selector) { 8293 if ($(parent).is(selector)) parents.push(parent); 8294 } else { 8295 parents.push(parent); 8296 } 8297 8298 parent = parent.parentNode; 8299 } 8300 } 8301 8302 return $(parents); 8303 } 8304 8305 function closest(selector) { 8306 let closest = this; // eslint-disable-line 8307 8308 if (typeof selector === 'undefined') { 8309 return $([]); 8310 } 8311
vendor: 4,446 bytes, lines 8312-8492
8312 if (!closest.is(selector)) { 8313 closest = closest.parents(selector).eq(0); 8314 } 8315 8316 return closest; 8317 } 8318 8319 function find(selector) { 8320 const foundElements = []; 8321 8322 for (let i = 0; i < this.length; i += 1) { 8323 const found = this[i].querySelectorAll(selector); 8324 8325 for (let j = 0; j < found.length; j += 1) { 8326 foundElements.push(found[j]); 8327 } 8328 } 8329 8330 return $(foundElements); 8331 } 8332 8333 function children(selector) { 8334 const children = []; // eslint-disable-line 8335 8336 for (let i = 0; i < this.length; i += 1) { 8337 const childNodes = this[i].children; 8338 8339 for (let j = 0; j < childNodes.length; j += 1) { 8340 if (!selector || $(childNodes[j]).is(selector)) { 8341 children.push(childNodes[j]); 8342 } 8343 } 8344 } 8345 8346 return $(children); 8347 } 8348 8349 function remove() { 8350 for (let i = 0; i < this.length; i += 1) { 8351 if (this[i].parentNode) this[i].parentNode.removeChild(this[i]); 8352 } 8353 8354 return this; 8355 } 8356 8357 const Methods = { 8358 addClass, 8359 removeClass, 8360 hasClass, 8361 toggleClass, 8362 attr, 8363 removeAttr, 8364 transform, 8365 transition: transition$1, 8366 on, 8367 off, 8368 trigger, 8369 transitionEnd: transitionEnd$1, 8370 outerWidth, 8371 outerHeight, 8372 styles, 8373 offset, 8374 css, 8375 each, 8376 html, 8377 text, 8378 is, 8379 index, 8380 eq, 8381 append, 8382 prepend, 8383 next, 8384 nextAll, 8385 prev, 8386 prevAll, 8387 parent, 8388 parents, 8389 closest, 8390 find, 8391 children, 8392 filter, 8393 remove 8394 }; 8395 Object.keys(Methods).forEach(methodName => { 8396 Object.defineProperty($.fn, methodName, { 8397 value: Methods[methodName], 8398 writable: true 8399 }); 8400 }); 8401 8402 function deleteProps(obj) { 8403 const object = obj; 8404 Object.keys(object).forEach(key => { 8405 try { 8406 object[key] = null; 8407 } catch (e) {// no getter for object 8408 } 8409 8410 try { 8411 delete object[key]; 8412 } catch (e) {// something got wrong 8413 } 8414 }); 8415 } 8416 8417 function nextTick(callback, delay) { 8418 if (delay === void 0) { 8419 delay = 0; 8420 } 8421 8422 return setTimeout(callback, delay); 8423 } 8424 8425 function now() { 8426 return Date.now(); 8427 } 8428 8429 function getComputedStyle$1(el) { 8430 const window = getWindow(); 8431 let style; 8432 8433 if (window.getComputedStyle) { 8434 style = window.getComputedStyle(el, null); 8435 } 8436 8437 if (!style && el.currentStyle) { 8438 style = el.currentStyle; 8439 } 8440 8441 if (!style) { 8442 style = el.style; 8443 } 8444 8445 return style; 8446 } 8447 8448 function getTranslate(el, axis) { 8449 if (axis === void 0) { 8450 axis = 'x'; 8451 } 8452 8453 const window = getWindow(); 8454 let matrix; 8455 let curTransform; 8456 let transformMatrix; 8457 const curStyle = getComputedStyle$1(el); 8458 8459 if (window.WebKitCSSMatrix) { 8460 curTransform = curStyle.transform || curStyle.webkitTransform; 8461 8462 if (curTransform.split(',').length > 6) { 8463 curTransform = curTransform.split(', ').map(a => a.replace(',', '.')).join(', '); 8464 } // Some old versions of Webkit choke when 'none' is passed; pass 8465 // empty string instead in this case 8466 8467 8468 transformMatrix = new window.WebKitCSSMatrix(curTransform === 'none' ? '' : curTransform); 8469 } else { 8470 transformMatrix = curStyle.MozTransform || curStyle.OTransform || curStyle.MsTransform || curStyle.msTransform || curStyle.transform || curStyle.getPropertyValue('transform').replace('translate(', 'matrix(1, 0, 0, 1,'); 8471 matrix = transformMatrix.toString().split(','); 8472 } 8473 8474 if (axis === 'x') { 8475 // Latest Chrome and webkits Fix 8476 if (window.WebKitCSSMatrix) curTransform = transformMatrix.m41; // Crazy IE10 Matrix 8477 else if (matrix.length === 16) curTransform = parseFloat(matrix[12]); // Normal Browsers 8478 else curTransform = parseFloat(matrix[4]); 8479 } 8480 8481 if (axis === 'y') { 8482 // Latest Chrome and webkits Fix 8483 if (window.WebKitCSSMatrix) curTransform = transformMatrix.m42; // Crazy IE10 Matrix 8484 else if (matrix.length === 16) curTransform = parseFloat(matrix[13]); // Normal Browsers 8485 else curTransform = parseFloat(matrix[5]); 8486 } 8487 8488 return curTransform || 0; 8489 } 8490 8491 function isObject(o) { 8492 return typeof o === 'object' && o !== null && o.constructor && Ob
vendor: 4,211 bytes, lines 8492-8614
8492ject.prototype.toString.call(o).slice(8, -1) === 'Object'; 8493 } 8494 8495 function isNode(node) { 8496 // eslint-disable-next-line 8497 if (typeof window !== 'undefined' && typeof window.HTMLElement !== 'undefined') { 8498 return node instanceof HTMLElement; 8499 } 8500 8501 return node && (node.nodeType === 1 || node.nodeType === 11); 8502 } 8503 8504 function extend() { 8505 const to = Object(arguments.length <= 0 ? undefined : arguments[0]); 8506 const noExtend = ['__proto__', 'constructor', 'prototype']; 8507 8508 for (let i = 1; i < arguments.length; i += 1) { 8509 const nextSource = i < 0 || arguments.length <= i ? undefined : arguments[i]; 8510 8511 if (nextSource !== undefined && nextSource !== null && !isNode(nextSource)) { 8512 const keysArray = Object.keys(Object(nextSource)).filter(key => noExtend.indexOf(key) < 0); 8513 8514 for (let nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex += 1) { 8515 const nextKey = keysArray[nextIndex]; 8516 const desc = Object.getOwnPropertyDescriptor(nextSource, nextKey); 8517 8518 if (desc !== undefined && desc.enumerable) { 8519 if (isObject(to[nextKey]) && isObject(nextSource[nextKey])) { 8520 if (nextSource[nextKey].__swiper__) { 8521 to[nextKey] = nextSource[nextKey]; 8522 } else { 8523 extend(to[nextKey], nextSource[nextKey]); 8524 } 8525 } else if (!isObject(to[nextKey]) && isObject(nextSource[nextKey])) { 8526 to[nextKey] = {}; 8527 8528 if (nextSource[nextKey].__swiper__) { 8529 to[nextKey] = nextSource[nextKey]; 8530 } else { 8531 extend(to[nextKey], nextSource[nextKey]); 8532 } 8533 } else { 8534 to[nextKey] = nextSource[nextKey]; 8535 } 8536 } 8537 } 8538 } 8539 } 8540 8541 return to; 8542 } 8543 8544 function setCSSProperty(el, varName, varValue) { 8545 el.style.setProperty(varName, varValue); 8546 } 8547 8548 function animateCSSModeScroll(_ref) { 8549 let { 8550 swiper, 8551 targetPosition, 8552 side 8553 } = _ref; 8554 const window = getWindow(); 8555 const startPosition = -swiper.translate; 8556 let startTime = null; 8557 let time; 8558 const duration = swiper.params.speed; 8559 swiper.wrapperEl.style.scrollSnapType = 'none'; 8560 window.cancelAnimationFrame(swiper.cssModeFrameID); 8561 const dir = targetPosition > startPosition ? 'next' : 'prev'; 8562 8563 const isOutOfBound = (current, target) => { 8564 return dir === 'next' && current >= target || dir === 'prev' && current <= target; 8565 }; 8566 8567 const animate = () => { 8568 time = new Date().getTime(); 8569 8570 if (startTime === null) { 8571 startTime = time; 8572 } 8573 8574 const progress = Math.max(Math.min((time - startTime) / duration, 1), 0); 8575 const easeProgress = 0.5 - Math.cos(progress * Math.PI) / 2; 8576 let currentPosition = startPosition + easeProgress * (targetPosition - startPosition); 8577 8578 if (isOutOfBound(currentPosition, targetPosition)) { 8579 currentPosition = targetPosition; 8580 } 8581 8582 swiper.wrapperEl.scrollTo({ 8583 [side]: currentPosition 8584 }); 8585 8586 if (isOutOfBound(currentPosition, targetPosition)) { 8587 swiper.wrapperEl.style.overflow = 'hidden'; 8588 swiper.wrapperEl.style.scrollSnapType = ''; 8589 setTimeout(() => { 8590 swiper.wrapperEl.style.overflow = ''; 8591 swiper.wrapperEl.scrollTo({ 8592 [side]: currentPosition 8593 }); 8594 }); 8595 window.cancelAnimationFrame(swiper.cssModeFrameID); 8596 return; 8597 } 8598 8599 swiper.cssModeFrameID = window.requestAnimationFrame(animate); 8600 }; 8601 8602 animate(); 8603 } 8604 8605 let support; 8606 8607 function calcSupport() { 8608 const window = getWindow(); 8609 const document = getDocument(); 8610 return { 8611 smoothScroll: document.documentElement && 'scrollBehavior' in document.documentElement.style, 8612 touch: !!('ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch), 8613 passiveListener: function checkPassiveListener() { 8614 let supportsPassive = false;
vendor: 14,071 bytes, lines 8615-9082
8615 8616 try { 8617 const opts = Object.defineProperty({}, 'passive', { 8618 // eslint-disable-next-line 8619 get() { 8620 supportsPassive = true; 8621 } 8622 8623 }); 8624 window.addEventListener('testPassiveListener', null, opts); 8625 } catch (e) {// No support 8626 } 8627 8628 return supportsPassive; 8629 }(), 8630 gestures: function checkGestures() { 8631 return 'ongesturestart' in window; 8632 }() 8633 }; 8634 } 8635 8636 function getSupport() { 8637 if (!support) { 8638 support = calcSupport(); 8639 } 8640 8641 return support; 8642 } 8643 8644 let deviceCached; 8645 8646 function calcDevice(_temp) { 8647 let { 8648 userAgent 8649 } = _temp === void 0 ? {} : _temp; 8650 const support = getSupport(); 8651 const window = getWindow(); 8652 const platform = window.navigator.platform; 8653 const ua = userAgent || window.navigator.userAgent; 8654 const device = { 8655 ios: false, 8656 android: false 8657 }; 8658 const screenWidth = window.screen.width; 8659 const screenHeight = window.screen.height; 8660 const android = ua.match(/(Android);?[\s\/]+([\d.]+)?/); // eslint-disable-line 8661 8662 let ipad = ua.match(/(iPad).*OS\s([\d_]+)/); 8663 const ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/); 8664 const iphone = !ipad && ua.match(/(iPhone\sOS|iOS)\s([\d_]+)/); 8665 const windows = platform === 'Win32'; 8666 let macos = platform === 'MacIntel'; // iPadOs 13 fix 8667 8668 const iPadScreens = ['1024x1366', '1366x1024', '834x1194', '1194x834', '834x1112', '1112x834', '768x1024', '1024x768', '820x1180', '1180x820', '810x1080', '1080x810']; 8669 8670 if (!ipad && macos && support.touch && iPadScreens.indexOf(`${screenWidth}x${screenHeight}`) >= 0) { 8671 ipad = ua.match(/(Version)\/([\d.]+)/); 8672 if (!ipad) ipad = [0, 1, '13_0_0']; 8673 macos = false; 8674 } // Android 8675 8676 8677 if (android && !windows) { 8678 device.os = 'android'; 8679 device.android = true; 8680 } 8681 8682 if (ipad || iphone || ipod) { 8683 device.os = 'ios'; 8684 device.ios = true; 8685 } // Export object 8686 8687 8688 return device; 8689 } 8690 8691 function getDevice(overrides) { 8692 if (overrides === void 0) { 8693 overrides = {}; 8694 } 8695 8696 if (!deviceCached) { 8697 deviceCached = calcDevice(overrides); 8698 } 8699 8700 return deviceCached; 8701 } 8702 8703 let browser; 8704 8705 function calcBrowser() { 8706 const window = getWindow(); 8707 8708 function isSafari() { 8709 const ua = window.navigator.userAgent.toLowerCase(); 8710 return ua.indexOf('safari') >= 0 && ua.indexOf('chrome') < 0 && ua.indexOf('android') < 0; 8711 } 8712 8713 return { 8714 isSafari: isSafari(), 8715 isWebView: /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(window.navigator.userAgent) 8716 }; 8717 } 8718 8719 function getBrowser() { 8720 if (!browser) { 8721 browser = calcBrowser(); 8722 } 8723 8724 return browser; 8725 } 8726 8727 function Resize(_ref) { 8728 let { 8729 swiper, 8730 on, 8731 emit 8732 } = _ref; 8733 const window = getWindow(); 8734 let observer = null; 8735 let animationFrame = null; 8736 8737 const resizeHandler = () => { 8738 if (!swiper || swiper.destroyed || !swiper.initialized) return; 8739 emit('beforeResize'); 8740 emit('resize'); 8741 }; 8742 8743 const createObserver = () => { 8744 if (!swiper || swiper.destroyed || !swiper.initialized) return; 8745 observer = new ResizeObserver(entries => { 8746 animationFrame = window.requestAnimationFrame(() => { 8747 const { 8748 width, 8749 height 8750 } = swiper; 8751 let newWidth = width; 8752 let newHeight = height; 8753 entries.forEach(_ref2 => { 8754 let { 8755 contentBoxSize, 8756 contentRect, 8757 target 8758 } = _ref2; 8759 if (target && target !== swiper.el) return; 8760 newWidth = contentRect ? contentRect.width : (contentBoxSize[0] || contentBoxSize).inlineSize; 8761 newHeight = contentRect ? contentRect.height : (contentBoxSize[0] || contentBoxSize).blockSize; 8762 }); 8763 8764 if (newWidth !== width || newHeight !== height) { 8765 resizeHandler(); 8766 } 8767 }); 8768 }); 8769 observer.observe(swiper.el); 8770 }; 8771 8772 const removeObserver = () => { 8773 if (animationFrame) { 8774 window.cancelAnimationFrame(animationFrame); 8775 } 8776 8777 if (observer && observer.unobserve && swiper.el) { 8778 observer.unobserve(swiper.el); 8779 observer = null; 8780 } 8781 }; 8782 8783 const orientationChangeHandler = () => { 8784 if (!swiper || swiper.destroyed || !swiper.initialized) return; 8785 emit('orientationchange'); 8786 }; 8787 8788 on('init', () => { 8789 if (swiper.params.resizeObserver && typeof window.ResizeObserver !== 'undefined') { 8790 createObserver(); 8791 return; 8792 } 8793 8794 window.addEventListener('resize', resizeHandler); 8795 window.addEventListener('orientationchange', orientationChangeHandler); 8796 }); 8797 on('destroy', () => { 8798 removeObserver(); 8799 window.removeEventListener('resize', resizeHandler); 8800 window.removeEventListener('orientationchange', orientationChangeHandler); 8801 }); 8802 } 8803 8804 function Observer(_ref) { 8805 let { 8806 swiper, 8807 extendParams, 8808 on, 8809 emit 8810 } = _ref; 8811 const observers = []; 8812 const window = getWindow(); 8813 8814 const attach = function (target, options) { 8815 if (options === void 0) { 8816 options = {}; 8817 } 8818 8819 const ObserverFunc = window.MutationObserver || window.WebkitMutationObserver; 8820 const observer = new ObserverFunc(mutations => { 8821 // The observerUpdate event should only be triggered 8822 // once despite the number of mutations. Additional 8823 // triggers are redundant and are very costly 8824 if (mutations.length === 1) { 8825 emit('observerUpdate', mutations[0]); 8826 return; 8827 } 8828 8829 const observerUpdate = function observerUpdate() { 8830 emit('observerUpdate', mutations[0]); 8831 }; 8832 8833 if (window.requestAnimationFrame) { 8834 window.requestAnimationFrame(observerUpdate); 8835 } else { 8836 window.setTimeout(observerUpdate, 0); 8837 } 8838 }); 8839 observer.observe(target, { 8840 attributes: typeof options.attributes === 'undefined' ? true : options.attributes, 8841 childList: typeof options.childList === 'undefined' ? true : options.childList, 8842 characterData: typeof options.characterData === 'undefined' ? true : options.characterData 8843 }); 8844 observers.push(observer); 8845 }; 8846 8847 const init = () => { 8848 if (!swiper.params.observer) return; 8849 8850 if (swiper.params.observeParents) { 8851 const containerParents = swiper.$el.parents(); 8852 8853 for (let i = 0; i < containerParents.length; i += 1) { 8854 attach(containerParents[i]); 8855 } 8856 } // Observe container 8857 8858 8859 attach(swiper.$el[0], { 8860 childList: swiper.params.observeSlideChildren 8861 }); // Observe wrapper 8862 8863 attach(swiper.$wrapperEl[0], { 8864 attributes: false 8865 }); 8866 }; 8867 8868 const destroy = () => { 8869 observers.forEach(observer => { 8870 observer.disconnect(); 8871 }); 8872 observers.splice(0, observers.length); 8873 }; 8874 8875 extendParams({ 8876 observer: false, 8877 observeParents: false, 8878 observeSlideChildren: false 8879 }); 8880 on('init', init); 8881 on('destroy', destroy); 8882 } 8883 8884 /* eslint-disable no-underscore-dangle */ 8885 var eventsEmitter = { 8886 on(events, handler, priority) { 8887 const self = this; 8888 if (!self.eventsListeners || self.destroyed) return self; 8889 if (typeof handler !== 'function') return self; 8890 const method = priority ? 'unshift' : 'push'; 8891 events.split(' ').forEach(event => { 8892 if (!self.eventsListeners[event]) self.eventsListeners[event] = []; 8893 self.eventsListeners[event][method](handler); 8894 }); 8895 return self; 8896 }, 8897 8898 once(events, handler, priority) { 8899 const self = this; 8900 if (!self.eventsListeners || self.destroyed) return self; 8901 if (typeof handler !== 'function') return self; 8902 8903 function onceHandler() { 8904 self.off(events, onceHandler); 8905 8906 if (onceHandler.__emitterProxy) { 8907 delete onceHandler.__emitterProxy; 8908 } 8909 8910 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { 8911 args[_key] = arguments[_key]; 8912 } 8913 8914 handler.apply(self, args); 8915 } 8916 8917 onceHandler.__emitterProxy = handler; 8918 return self.on(events, onceHandler, priority); 8919 }, 8920 8921 onAny(handler, priority) { 8922 const self = this; 8923 if (!self.eventsListeners || self.destroyed) return self; 8924 if (typeof handler !== 'function') return self; 8925 const method = priority ? 'unshift' : 'push'; 8926 8927 if (self.eventsAnyListeners.indexOf(handler) < 0) { 8928 self.eventsAnyListeners[method](handler); 8929 } 8930 8931 return self; 8932 }, 8933 8934 offAny(handler) { 8935 const self = this; 8936 if (!self.eventsListeners || self.destroyed) return self; 8937 if (!self.eventsAnyListeners) return self; 8938 const index = self.eventsAnyListeners.indexOf(handler); 8939 8940 if (index >= 0) { 8941 self.eventsAnyListeners.splice(index, 1); 8942 } 8943 8944 return self; 8945 }, 8946 8947 off(events, handler) { 8948 const self = this; 8949 if (!self.eventsListeners || self.destroyed) return self; 8950 if (!self.eventsListeners) return self; 8951 events.split(' ').forEach(event => { 8952 if (typeof handler === 'undefined') { 8953 self.eventsListeners[event] = []; 8954 } else if (self.eventsListeners[event]) { 8955 self.eventsListeners[event].forEach((eventHandler, index) => { 8956 if (eventHandler === handler || eventHandler.__emitterProxy && eventHandler.__emitterProxy === handler) { 8957 self.eventsListeners[event].splice(index, 1); 8958 } 8959 }); 8960 } 8961 }); 8962 return self; 8963 }, 8964 8965 emit() { 8966 const self = this; 8967 if (!self.eventsListeners || self.destroyed) return self; 8968 if (!self.eventsListeners) return self; 8969 let events; 8970 let data; 8971 let context; 8972 8973 for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { 8974 args[_key2] = arguments[_key2]; 8975 } 8976 8977 if (typeof args[0] === 'string' || Array.isArray(args[0])) { 8978 events = args[0]; 8979 data = args.slice(1, args.length); 8980 context = self; 8981 } else { 8982 events = args[0].events; 8983 data = args[0].data; 8984 context = args[0].context || self; 8985 } 8986 8987 data.unshift(context); 8988 const eventsArray = Array.isArray(events) ? events : events.split(' '); 8989 eventsArray.forEach(event => { 8990 if (self.eventsAnyListeners && self.eventsAnyListeners.length) { 8991 self.eventsAnyListeners.forEach(eventHandler => { 8992 eventHandler.apply(context, [event, ...data]); 8993 }); 8994 } 8995 8996 if (self.eventsListeners && self.eventsListeners[event]) { 8997 self.eventsListeners[event].forEach(eventHandler => { 8998 eventHandler.apply(context, data); 8999 }); 9000 } 9001 }); 9002 return self; 9003 } 9004 9005 }; 9006 9007 function updateSize() { 9008 const swiper = this; 9009 let width; 9010 let height; 9011 const $el = swiper.$el; 9012 9013 if (typeof swiper.params.width !== 'undefined' && swiper.params.width !== null) { 9014 width = swiper.params.width; 9015 } else { 9016 width = $el[0].clientWidth; 9017 } 9018 9019 if (typeof swiper.params.height !== 'undefined' && swiper.params.height !== null) { 9020 height = swiper.params.height; 9021 } else { 9022 height = $el[0].clientHeight; 9023 } 9024 9025 if (width === 0 && swiper.isHorizontal() || height === 0 && swiper.isVertical()) { 9026 return; 9027 } // Subtract paddings 9028 9029 9030 width = width - parseInt($el.css('padding-left') || 0, 10) - parseInt($el.css('padding-right') || 0, 10); 9031 height = height - parseInt($el.css('padding-top') || 0, 10) - parseInt($el.css('padding-bottom') || 0, 10); 9032 if (Number.isNaN(width)) width = 0; 9033 if (Number.isNaN(height)) height = 0; 9034 Object.assign(swiper, { 9035 width, 9036 height, 9037 size: swiper.isHorizontal() ? width : height 9038 }); 9039 } 9040 9041 function updateSlides() { 9042 const swiper = this; 9043 9044 function getDirectionLabel(property) { 9045 if (swiper.isHorizontal()) { 9046 return property; 9047 } // prettier-ignore 9048 9049 9050 return { 9051 'width': 'height', 9052 'margin-top': 'margin-left', 9053 'margin-bottom ': 'margin-right', 9054 'margin-left': 'margin-top', 9055 'margin-right': 'margin-bottom', 9056 'padding-left': 'padding-top', 9057 'padding-right': 'padding-bottom', 9058 'marginRight': 'marginBottom' 9059 }[property]; 9060 } 9061 9062 function getDirectionPropertyValue(node, label) { 9063 return parseFloat(node.getPropertyValue(getDirectionLabel(label)) || 0); 9064 } 9065 9066 const params = swiper.params; 9067 const { 9068 $wrapperEl, 9069 size: swiperSize, 9070 rtlTranslate: rtl, 9071 wrongRTL 9072 } = swiper; 9073 const isVirtual = swiper.virtual && params.virtual.enabled; 9074 const previousSlidesLength = isVirtual ? swiper.virtual.slides.length : swiper.slides.length; 9075 const slides = $wrapperEl.children(`.${swiper.params.slideClass}`); 9076 const slidesLength = isVirtual ? swiper.virtual.slides.length : slides.length; 9077 let snapGrid = []; 9078 const slidesGrid = []; 9079 const slidesSizesGrid = []; 9080 let offsetBefore = params.slidesOffsetBefore; 9081 9082 if (typeof offsetBefore === 'function') {
vendor: 7,771 bytes, lines 9083-9299
9083 offsetBefore = params.slidesOffsetBefore.call(swiper); 9084 } 9085 9086 let offsetAfter = params.slidesOffsetAfter; 9087 9088 if (typeof offsetAfter === 'function') { 9089 offsetAfter = params.slidesOffsetAfter.call(swiper); 9090 } 9091 9092 const previousSnapGridLength = swiper.snapGrid.length; 9093 const previousSlidesGridLength = swiper.slidesGrid.length; 9094 let spaceBetween = params.spaceBetween; 9095 let slidePosition = -offsetBefore; 9096 let prevSlideSize = 0; 9097 let index = 0; 9098 9099 if (typeof swiperSize === 'undefined') { 9100 return; 9101 } 9102 9103 if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) { 9104 spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * swiperSize; 9105 } 9106 9107 swiper.virtualSize = -spaceBetween; // reset margins 9108 9109 if (rtl) slides.css({ 9110 marginLeft: '', 9111 marginBottom: '', 9112 marginTop: '' 9113 });else slides.css({ 9114 marginRight: '', 9115 marginBottom: '', 9116 marginTop: '' 9117 }); // reset cssMode offsets 9118 9119 if (params.centeredSlides && params.cssMode) { 9120 setCSSProperty(swiper.wrapperEl, '--swiper-centered-offset-before', ''); 9121 setCSSProperty(swiper.wrapperEl, '--swiper-centered-offset-after', ''); 9122 } 9123 9124 const gridEnabled = params.grid && params.grid.rows > 1 && swiper.grid; 9125 9126 if (gridEnabled) { 9127 swiper.grid.initSlides(slidesLength); 9128 } // Calc slides 9129 9130 9131 let slideSize; 9132 const shouldResetSlideSize = params.slidesPerView === 'auto' && params.breakpoints && Object.keys(params.breakpoints).filter(key => { 9133 return typeof params.breakpoints[key].slidesPerView !== 'undefined'; 9134 }).length > 0; 9135 9136 for (let i = 0; i < slidesLength; i += 1) { 9137 slideSize = 0; 9138 const slide = slides.eq(i); 9139 9140 if (gridEnabled) { 9141 swiper.grid.updateSlide(i, slide, slidesLength, getDirectionLabel); 9142 } 9143 9144 if (slide.css('display') === 'none') continue; // eslint-disable-line 9145 9146 if (params.slidesPerView === 'auto') { 9147 if (shouldResetSlideSize) { 9148 slides[i].style[getDirectionLabel('width')] = ``; 9149 } 9150 9151 const slideStyles = getComputedStyle(slide[0]); 9152 const currentTransform = slide[0].style.transform; 9153 const currentWebKitTransform = slide[0].style.webkitTransform; 9154 9155 if (currentTransform) { 9156 slide[0].style.transform = 'none'; 9157 } 9158 9159 if (currentWebKitTransform) { 9160 slide[0].style.webkitTransform = 'none'; 9161 } 9162 9163 if (params.roundLengths) { 9164 slideSize = swiper.isHorizontal() ? slide.outerWidth(true) : slide.outerHeight(true); 9165 } else { 9166 // eslint-disable-next-line 9167 const width = getDirectionPropertyValue(slideStyles, 'width'); 9168 const paddingLeft = getDirectionPropertyValue(slideStyles, 'padding-left'); 9169 const paddingRight = getDirectionPropertyValue(slideStyles, 'padding-right'); 9170 const marginLeft = getDirectionPropertyValue(slideStyles, 'margin-left'); 9171 const marginRight = getDirectionPropertyValue(slideStyles, 'margin-right'); 9172 const boxSizing = slideStyles.getPropertyValue('box-sizing'); 9173 9174 if (boxSizing && boxSizing === 'border-box') { 9175 slideSize = width + marginLeft + marginRight; 9176 } else { 9177 const { 9178 clientWidth, 9179 offsetWidth 9180 } = slide[0]; 9181 slideSize = width + paddingLeft + paddingRight + marginLeft + marginRight + (offsetWidth - clientWidth); 9182 } 9183 } 9184 9185 if (currentTransform) { 9186 slide[0].style.transform = currentTransform; 9187 } 9188 9189 if (currentWebKitTransform) { 9190 slide[0].style.webkitTransform = currentWebKitTransform; 9191 } 9192 9193 if (params.roundLengths) slideSize = Math.floor(slideSize); 9194 } else { 9195 slideSize = (swiperSize - (params.slidesPerView - 1) * spaceBetween) / params.slidesPerView; 9196 if (params.roundLengths) slideSize = Math.floor(slideSize); 9197 9198 if (slides[i]) { 9199 slides[i].style[getDirectionLabel('width')] = `${slideSize}px`; 9200 } 9201 } 9202 9203 if (slides[i]) { 9204 slides[i].swiperSlideSize = slideSize; 9205 } 9206 9207 slidesSizesGrid.push(slideSize); 9208 9209 if (params.centeredSlides) { 9210 slidePosition = slidePosition + slideSize / 2 + prevSlideSize / 2 + spaceBetween; 9211 if (prevSlideSize === 0 && i !== 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween; 9212 if (i === 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween; 9213 if (Math.abs(slidePosition) < 1 / 1000) slidePosition = 0; 9214 if (params.roundLengths) slidePosition = Math.floor(slidePosition); 9215 if (index % params.slidesPerGroup === 0) snapGrid.push(slidePosition); 9216 slidesGrid.push(slidePosition); 9217 } else { 9218 if (params.roundLengths) slidePosition = Math.floor(slidePosition); 9219 if ((index - Math.min(swiper.params.slidesPerGroupSkip, index)) % swiper.params.slidesPerGroup === 0) snapGrid.push(slidePosition); 9220 slidesGrid.push(slidePosition); 9221 slidePosition = slidePosition + slideSize + spaceBetween; 9222 } 9223 9224 swiper.virtualSize += slideSize + spaceBetween; 9225 prevSlideSize = slideSize; 9226 index += 1; 9227 } 9228 9229 swiper.virtualSize = Math.max(swiper.virtualSize, swiperSize) + offsetAfter; 9230 9231 if (rtl && wrongRTL && (params.effect === 'slide' || params.effect === 'coverflow')) { 9232 $wrapperEl.css({ 9233 width: `${swiper.virtualSize + params.spaceBetween}px` 9234 }); 9235 } 9236 9237 if (params.setWrapperSize) { 9238 $wrapperEl.css({ 9239 [getDirectionLabel('width')]: `${swiper.virtualSize + params.spaceBetween}px` 9240 }); 9241 } 9242 9243 if (gridEnabled) { 9244 swiper.grid.updateWrapperSize(slideSize, snapGrid, getDirectionLabel); 9245 } // Remove last grid elements depending on width 9246 9247 9248 if (!params.centeredSlides) { 9249 const newSlidesGrid = []; 9250 9251 for (let i = 0; i < snapGrid.length; i += 1) { 9252 let slidesGridItem = snapGrid[i]; 9253 if (params.roundLengths) slidesGridItem = Math.floor(slidesGridItem); 9254 9255 if (snapGrid[i] <= swiper.virtualSize - swiperSize) { 9256 newSlidesGrid.push(slidesGridItem); 9257 } 9258 } 9259 9260 snapGrid = newSlidesGrid; 9261 9262 if (Math.floor(swiper.virtualSize - swiperSize) - Math.floor(snapGrid[snapGrid.length - 1]) > 1) { 9263 snapGrid.push(swiper.virtualSize - swiperSize); 9264 } 9265 } 9266 9267 if (snapGrid.length === 0) snapGrid = [0]; 9268 9269 if (params.spaceBetween !== 0) { 9270 const key = swiper.isHorizontal() && rtl ? 'marginLeft' : getDirectionLabel('marginRight'); 9271 slides.filter((_, slideIndex) => { 9272 if (!params.cssMode) return true; 9273 9274 if (slideIndex === slides.length - 1) { 9275 return false; 9276 } 9277 9278 return true; 9279 }).css({ 9280 [key]: `${spaceBetween}px` 9281 }); 9282 } 9283 9284 if (params.centeredSlides && params.centeredSlidesBounds) { 9285 let allSlidesSize = 0; 9286 slidesSizesGrid.forEach(slideSizeValue => { 9287 allSlidesSize += slideSizeValue + (params.spaceBetween ? params.spaceBetween : 0); 9288 }); 9289 allSlidesSize -= params.spaceBetween; 9290 const maxSnap = allSlidesSize - swiperSize; 9291 snapGrid = snapGrid.map(snap => { 9292 if (snap < 0) return -offsetBefore; 9293 if (snap > maxSnap) return maxSnap + offsetAfter; 9294 return snap; 9295 }); 9296 } 9297 9298 if (params.centerInsufficientSlides) { 9299 let allSlidesSize = 0;
vendor: 49,255 bytes, lines 9300-10824
9300 slidesSizesGrid.forEach(slideSizeValue => { 9301 allSlidesSize += slideSizeValue + (params.spaceBetween ? params.spaceBetween : 0); 9302 }); 9303 allSlidesSize -= params.spaceBetween; 9304 9305 if (allSlidesSize < swiperSize) { 9306 const allSlidesOffset = (swiperSize - allSlidesSize) / 2; 9307 snapGrid.forEach((snap, snapIndex) => { 9308 snapGrid[snapIndex] = snap - allSlidesOffset; 9309 }); 9310 slidesGrid.forEach((snap, snapIndex) => { 9311 slidesGrid[snapIndex] = snap + allSlidesOffset; 9312 }); 9313 } 9314 } 9315 9316 Object.assign(swiper, { 9317 slides, 9318 snapGrid, 9319 slidesGrid, 9320 slidesSizesGrid 9321 }); 9322 9323 if (params.centeredSlides && params.cssMode && !params.centeredSlidesBounds) { 9324 setCSSProperty(swiper.wrapperEl, '--swiper-centered-offset-before', `${-snapGrid[0]}px`); 9325 setCSSProperty(swiper.wrapperEl, '--swiper-centered-offset-after', `${swiper.size / 2 - slidesSizesGrid[slidesSizesGrid.length - 1] / 2}px`); 9326 const addToSnapGrid = -swiper.snapGrid[0]; 9327 const addToSlidesGrid = -swiper.slidesGrid[0]; 9328 swiper.snapGrid = swiper.snapGrid.map(v => v + addToSnapGrid); 9329 swiper.slidesGrid = swiper.slidesGrid.map(v => v + addToSlidesGrid); 9330 } 9331 9332 if (slidesLength !== previousSlidesLength) { 9333 swiper.emit('slidesLengthChange'); 9334 } 9335 9336 if (snapGrid.length !== previousSnapGridLength) { 9337 if (swiper.params.watchOverflow) swiper.checkOverflow(); 9338 swiper.emit('snapGridLengthChange'); 9339 } 9340 9341 if (slidesGrid.length !== previousSlidesGridLength) { 9342 swiper.emit('slidesGridLengthChange'); 9343 } 9344 9345 if (params.watchSlidesProgress) { 9346 swiper.updateSlidesOffset(); 9347 } 9348 9349 if (!isVirtual && !params.cssMode && (params.effect === 'slide' || params.effect === 'fade')) { 9350 const backFaceHiddenClass = `${params.containerModifierClass}backface-hidden`; 9351 const hasClassBackfaceClassAdded = swiper.$el.hasClass(backFaceHiddenClass); 9352 9353 if (slidesLength <= params.maxBackfaceHiddenSlides) { 9354 if (!hasClassBackfaceClassAdded) swiper.$el.addClass(backFaceHiddenClass); 9355 } else if (hasClassBackfaceClassAdded) { 9356 swiper.$el.removeClass(backFaceHiddenClass); 9357 } 9358 } 9359 } 9360 9361 function updateAutoHeight(speed) { 9362 const swiper = this; 9363 const activeSlides = []; 9364 const isVirtual = swiper.virtual && swiper.params.virtual.enabled; 9365 let newHeight = 0; 9366 let i; 9367 9368 if (typeof speed === 'number') { 9369 swiper.setTransition(speed); 9370 } else if (speed === true) { 9371 swiper.setTransition(swiper.params.speed); 9372 } 9373 9374 const getSlideByIndex = index => { 9375 if (isVirtual) { 9376 return swiper.slides.filter(el => parseInt(el.getAttribute('data-swiper-slide-index'), 10) === index)[0]; 9377 } 9378 9379 return swiper.slides.eq(index)[0]; 9380 }; // Find slides currently in view 9381 9382 9383 if (swiper.params.slidesPerView !== 'auto' && swiper.params.slidesPerView > 1) { 9384 if (swiper.params.centeredSlides) { 9385 (swiper.visibleSlides || $([])).each(slide => { 9386 activeSlides.push(slide); 9387 }); 9388 } else { 9389 for (i = 0; i < Math.ceil(swiper.params.slidesPerView); i += 1) { 9390 const index = swiper.activeIndex + i; 9391 if (index > swiper.slides.length && !isVirtual) break; 9392 activeSlides.push(getSlideByIndex(index)); 9393 } 9394 } 9395 } else { 9396 activeSlides.push(getSlideByIndex(swiper.activeIndex)); 9397 } // Find new height from highest slide in view 9398 9399 9400 for (i = 0; i < activeSlides.length; i += 1) { 9401 if (typeof activeSlides[i] !== 'undefined') { 9402 const height = activeSlides[i].offsetHeight; 9403 newHeight = height > newHeight ? height : newHeight; 9404 } 9405 } // Update Height 9406 9407 9408 if (newHeight || newHeight === 0) swiper.$wrapperEl.css('height', `${newHeight}px`); 9409 } 9410 9411 function updateSlidesOffset() { 9412 const swiper = this; 9413 const slides = swiper.slides; 9414 9415 for (let i = 0; i < slides.length; i += 1) { 9416 slides[i].swiperSlideOffset = swiper.isHorizontal() ? slides[i].offsetLeft : slides[i].offsetTop; 9417 } 9418 } 9419 9420 function updateSlidesProgress(translate) { 9421 if (translate === void 0) { 9422 translate = this && this.translate || 0; 9423 } 9424 9425 const swiper = this; 9426 const params = swiper.params; 9427 const { 9428 slides, 9429 rtlTranslate: rtl, 9430 snapGrid 9431 } = swiper; 9432 if (slides.length === 0) return; 9433 if (typeof slides[0].swiperSlideOffset === 'undefined') swiper.updateSlidesOffset(); 9434 let offsetCenter = -translate; 9435 if (rtl) offsetCenter = translate; // Visible Slides 9436 9437 slides.removeClass(params.slideVisibleClass); 9438 swiper.visibleSlidesIndexes = []; 9439 swiper.visibleSlides = []; 9440 9441 for (let i = 0; i < slides.length; i += 1) { 9442 const slide = slides[i]; 9443 let slideOffset = slide.swiperSlideOffset; 9444 9445 if (params.cssMode && params.centeredSlides) { 9446 slideOffset -= slides[0].swiperSlideOffset; 9447 } 9448 9449 const slideProgress = (offsetCenter + (params.centeredSlides ? swiper.minTranslate() : 0) - slideOffset) / (slide.swiperSlideSize + params.spaceBetween); 9450 const originalSlideProgress = (offsetCenter - snapGrid[0] + (params.centeredSlides ? swiper.minTranslate() : 0) - slideOffset) / (slide.swiperSlideSize + params.spaceBetween); 9451 const slideBefore = -(offsetCenter - slideOffset); 9452 const slideAfter = slideBefore + swiper.slidesSizesGrid[i]; 9453 const isVisible = slideBefore >= 0 && slideBefore < swiper.size - 1 || slideAfter > 1 && slideAfter <= swiper.size || slideBefore <= 0 && slideAfter >= swiper.size; 9454 9455 if (isVisible) { 9456 swiper.visibleSlides.push(slide); 9457 swiper.visibleSlidesIndexes.push(i); 9458 slides.eq(i).addClass(params.slideVisibleClass); 9459 } 9460 9461 slide.progress = rtl ? -slideProgress : slideProgress; 9462 slide.originalProgress = rtl ? -originalSlideProgress : originalSlideProgress; 9463 } 9464 9465 swiper.visibleSlides = $(swiper.visibleSlides); 9466 } 9467 9468 function updateProgress(translate) { 9469 const swiper = this; 9470 9471 if (typeof translate === 'undefined') { 9472 const multiplier = swiper.rtlTranslate ? -1 : 1; // eslint-disable-next-line 9473 9474 translate = swiper && swiper.translate && swiper.translate * multiplier || 0; 9475 } 9476 9477 const params = swiper.params; 9478 const translatesDiff = swiper.maxTranslate() - swiper.minTranslate(); 9479 let { 9480 progress, 9481 isBeginning, 9482 isEnd 9483 } = swiper; 9484 const wasBeginning = isBeginning; 9485 const wasEnd = isEnd; 9486 9487 if (translatesDiff === 0) { 9488 progress = 0; 9489 isBeginning = true; 9490 isEnd = true; 9491 } else { 9492 progress = (translate - swiper.minTranslate()) / translatesDiff; 9493 isBeginning = progress <= 0; 9494 isEnd = progress >= 1; 9495 } 9496 9497 Object.assign(swiper, { 9498 progress, 9499 isBeginning, 9500 isEnd 9501 }); 9502 if (params.watchSlidesProgress || params.centeredSlides && params.autoHeight) swiper.updateSlidesProgress(translate); 9503 9504 if (isBeginning && !wasBeginning) { 9505 swiper.emit('reachBeginning toEdge'); 9506 } 9507 9508 if (isEnd && !wasEnd) { 9509 swiper.emit('reachEnd toEdge'); 9510 } 9511 9512 if (wasBeginning && !isBeginning || wasEnd && !isEnd) { 9513 swiper.emit('fromEdge'); 9514 } 9515 9516 swiper.emit('progress', progress); 9517 } 9518 9519 function updateSlidesClasses() { 9520 const swiper = this; 9521 const { 9522 slides, 9523 params, 9524 $wrapperEl, 9525 activeIndex, 9526 realIndex 9527 } = swiper; 9528 const isVirtual = swiper.virtual && params.virtual.enabled; 9529 slides.removeClass(`${params.slideActiveClass} ${params.slideNextClass} ${params.slidePrevClass} ${params.slideDuplicateActiveClass} ${params.slideDuplicateNextClass} ${params.slideDuplicatePrevClass}`); 9530 let activeSlide; 9531 9532 if (isVirtual) { 9533 activeSlide = swiper.$wrapperEl.find(`.${params.slideClass}[data-swiper-slide-index="${activeIndex}"]`); 9534 } else { 9535 activeSlide = slides.eq(activeIndex); 9536 } // Active classes 9537 9538 9539 activeSlide.addClass(params.slideActiveClass); 9540 9541 if (params.loop) { 9542 // Duplicate to all looped slides 9543 if (activeSlide.hasClass(params.slideDuplicateClass)) { 9544 $wrapperEl.children(`.${params.slideClass}:not(.${params.slideDuplicateClass})[data-swiper-slide-index="${realIndex}"]`).addClass(params.slideDuplicateActiveClass); 9545 } else { 9546 $wrapperEl.children(`.${params.slideClass}.${params.slideDuplicateClass}[data-swiper-slide-index="${realIndex}"]`).addClass(params.slideDuplicateActiveClass); 9547 } 9548 } // Next Slide 9549 9550 9551 let nextSlide = activeSlide.nextAll(`.${params.slideClass}`).eq(0).addClass(params.slideNextClass); 9552 9553 if (params.loop && nextSlide.length === 0) { 9554 nextSlide = slides.eq(0); 9555 nextSlide.addClass(params.slideNextClass); 9556 } // Prev Slide 9557 9558 9559 let prevSlide = activeSlide.prevAll(`.${params.slideClass}`).eq(0).addClass(params.slidePrevClass); 9560 9561 if (params.loop && prevSlide.length === 0) { 9562 prevSlide = slides.eq(-1); 9563 prevSlide.addClass(params.slidePrevClass); 9564 } 9565 9566 if (params.loop) { 9567 // Duplicate to all looped slides 9568 if (nextSlide.hasClass(params.slideDuplicateClass)) { 9569 $wrapperEl.children(`.${params.slideClass}:not(.${params.slideDuplicateClass})[data-swiper-slide-index="${nextSlide.attr('data-swiper-slide-index')}"]`).addClass(params.slideDuplicateNextClass); 9570 } else { 9571 $wrapperEl.children(`.${params.slideClass}.${params.slideDuplicateClass}[data-swiper-slide-index="${nextSlide.attr('data-swiper-slide-index')}"]`).addClass(params.slideDuplicateNextClass); 9572 } 9573 9574 if (prevSlide.hasClass(params.slideDuplicateClass)) { 9575 $wrapperEl.children(`.${params.slideClass}:not(.${params.slideDuplicateClass})[data-swiper-slide-index="${prevSlide.attr('data-swiper-slide-index')}"]`).addClass(params.slideDuplicatePrevClass); 9576 } else { 9577 $wrapperEl.children(`.${params.slideClass}.${params.slideDuplicateClass}[data-swiper-slide-index="${prevSlide.attr('data-swiper-slide-index')}"]`).addClass(params.slideDuplicatePrevClass); 9578 } 9579 } 9580 9581 swiper.emitSlidesClasses(); 9582 } 9583 9584 function updateActiveIndex(newActiveIndex) { 9585 const swiper = this; 9586 const translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate; 9587 const { 9588 slidesGrid, 9589 snapGrid, 9590 params, 9591 activeIndex: previousIndex, 9592 realIndex: previousRealIndex, 9593 snapIndex: previousSnapIndex 9594 } = swiper; 9595 let activeIndex = newActiveIndex; 9596 let snapIndex; 9597 9598 if (typeof activeIndex === 'undefined') { 9599 for (let i = 0; i < slidesGrid.length; i += 1) { 9600 if (typeof slidesGrid[i + 1] !== 'undefined') { 9601 if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1] - (slidesGrid[i + 1] - slidesGrid[i]) / 2) { 9602 activeIndex = i; 9603 } else if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1]) { 9604 activeIndex = i + 1; 9605 } 9606 } else if (translate >= slidesGrid[i]) { 9607 activeIndex = i; 9608 } 9609 } // Normalize slideIndex 9610 9611 9612 if (params.normalizeSlideIndex) { 9613 if (activeIndex < 0 || typeof activeIndex === 'undefined') activeIndex = 0; 9614 } 9615 } 9616 9617 if (snapGrid.indexOf(translate) >= 0) { 9618 snapIndex = snapGrid.indexOf(translate); 9619 } else { 9620 const skip = Math.min(params.slidesPerGroupSkip, activeIndex); 9621 snapIndex = skip + Math.floor((activeIndex - skip) / params.slidesPerGroup); 9622 } 9623 9624 if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1; 9625 9626 if (activeIndex === previousIndex) { 9627 if (snapIndex !== previousSnapIndex) { 9628 swiper.snapIndex = snapIndex; 9629 swiper.emit('snapIndexChange'); 9630 } 9631 9632 return; 9633 } // Get real index 9634 9635 9636 const realIndex = parseInt(swiper.slides.eq(activeIndex).attr('data-swiper-slide-index') || activeIndex, 10); 9637 Object.assign(swiper, { 9638 snapIndex, 9639 realIndex, 9640 previousIndex, 9641 activeIndex 9642 }); 9643 swiper.emit('activeIndexChange'); 9644 swiper.emit('snapIndexChange'); 9645 9646 if (previousRealIndex !== realIndex) { 9647 swiper.emit('realIndexChange'); 9648 } 9649 9650 if (swiper.initialized || swiper.params.runCallbacksOnInit) { 9651 swiper.emit('slideChange'); 9652 } 9653 } 9654 9655 function updateClickedSlide(e) { 9656 const swiper = this; 9657 const params = swiper.params; 9658 const slide = $(e).closest(`.${params.slideClass}`)[0]; 9659 let slideFound = false; 9660 let slideIndex; 9661 9662 if (slide) { 9663 for (let i = 0; i < swiper.slides.length; i += 1) { 9664 if (swiper.slides[i] === slide) { 9665 slideFound = true; 9666 slideIndex = i; 9667 break; 9668 } 9669 } 9670 } 9671 9672 if (slide && slideFound) { 9673 swiper.clickedSlide = slide; 9674 9675 if (swiper.virtual && swiper.params.virtual.enabled) { 9676 swiper.clickedIndex = parseInt($(slide).attr('data-swiper-slide-index'), 10); 9677 } else { 9678 swiper.clickedIndex = slideIndex; 9679 } 9680 } else { 9681 swiper.clickedSlide = undefined; 9682 swiper.clickedIndex = undefined; 9683 return; 9684 } 9685 9686 if (params.slideToClickedSlide && swiper.clickedIndex !== undefined && swiper.clickedIndex !== swiper.activeIndex) { 9687 swiper.slideToClickedSlide(); 9688 } 9689 } 9690 9691 var update = { 9692 updateSize, 9693 updateSlides, 9694 updateAutoHeight, 9695 updateSlidesOffset, 9696 updateSlidesProgress, 9697 updateProgress, 9698 updateSlidesClasses, 9699 updateActiveIndex, 9700 updateClickedSlide 9701 }; 9702 9703 function getSwiperTranslate(axis) { 9704 if (axis === void 0) { 9705 axis = this.isHorizontal() ? 'x' : 'y'; 9706 } 9707 9708 const swiper = this; 9709 const { 9710 params, 9711 rtlTranslate: rtl, 9712 translate, 9713 $wrapperEl 9714 } = swiper; 9715 9716 if (params.virtualTranslate) { 9717 return rtl ? -translate : translate; 9718 } 9719 9720 if (params.cssMode) { 9721 return translate; 9722 } 9723 9724 let currentTranslate = getTranslate($wrapperEl[0], axis); 9725 if (rtl) currentTranslate = -currentTranslate; 9726 return currentTranslate || 0; 9727 } 9728 9729 function setTranslate(translate, byController) { 9730 const swiper = this; 9731 const { 9732 rtlTranslate: rtl, 9733 params, 9734 $wrapperEl, 9735 wrapperEl, 9736 progress 9737 } = swiper; 9738 let x = 0; 9739 let y = 0; 9740 const z = 0; 9741 9742 if (swiper.isHorizontal()) { 9743 x = rtl ? -translate : translate; 9744 } else { 9745 y = translate; 9746 } 9747 9748 if (params.roundLengths) { 9749 x = Math.floor(x); 9750 y = Math.floor(y); 9751 } 9752 9753 if (params.cssMode) { 9754 wrapperEl[swiper.isHorizontal() ? 'scrollLeft' : 'scrollTop'] = swiper.isHorizontal() ? -x : -y; 9755 } else if (!params.virtualTranslate) { 9756 $wrapperEl.transform(`translate3d(${x}px, ${y}px, ${z}px)`); 9757 } 9758 9759 swiper.previousTranslate = swiper.translate; 9760 swiper.translate = swiper.isHorizontal() ? x : y; // Check if we need to update progress 9761 9762 let newProgress; 9763 const translatesDiff = swiper.maxTranslate() - swiper.minTranslate(); 9764 9765 if (translatesDiff === 0) { 9766 newProgress = 0; 9767 } else { 9768 newProgress = (translate - swiper.minTranslate()) / translatesDiff; 9769 } 9770 9771 if (newProgress !== progress) { 9772 swiper.updateProgress(translate); 9773 } 9774 9775 swiper.emit('setTranslate', swiper.translate, byController); 9776 } 9777 9778 function minTranslate() { 9779 return -this.snapGrid[0]; 9780 } 9781 9782 function maxTranslate() { 9783 return -this.snapGrid[this.snapGrid.length - 1]; 9784 } 9785 9786 function translateTo(translate, speed, runCallbacks, translateBounds, internal) { 9787 if (translate === void 0) { 9788 translate = 0; 9789 } 9790 9791 if (speed === void 0) { 9792 speed = this.params.speed; 9793 } 9794 9795 if (runCallbacks === void 0) { 9796 runCallbacks = true; 9797 } 9798 9799 if (translateBounds === void 0) { 9800 translateBounds = true; 9801 } 9802 9803 const swiper = this; 9804 const { 9805 params, 9806 wrapperEl 9807 } = swiper; 9808 9809 if (swiper.animating && params.preventInteractionOnTransition) { 9810 return false; 9811 } 9812 9813 const minTranslate = swiper.minTranslate(); 9814 const maxTranslate = swiper.maxTranslate(); 9815 let newTranslate; 9816 if (translateBounds && translate > minTranslate) newTranslate = minTranslate;else if (translateBounds && translate < maxTranslate) newTranslate = maxTranslate;else newTranslate = translate; // Update progress 9817 9818 swiper.updateProgress(newTranslate); 9819 9820 if (params.cssMode) { 9821 const isH = swiper.isHorizontal(); 9822 9823 if (speed === 0) { 9824 wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = -newTranslate; 9825 } else { 9826 if (!swiper.support.smoothScroll) { 9827 animateCSSModeScroll({ 9828 swiper, 9829 targetPosition: -newTranslate, 9830 side: isH ? 'left' : 'top' 9831 }); 9832 return true; 9833 } 9834 9835 wrapperEl.scrollTo({ 9836 [isH ? 'left' : 'top']: -newTranslate, 9837 behavior: 'smooth' 9838 }); 9839 } 9840 9841 return true; 9842 } 9843 9844 if (speed === 0) { 9845 swiper.setTransition(0); 9846 swiper.setTranslate(newTranslate); 9847 9848 if (runCallbacks) { 9849 swiper.emit('beforeTransitionStart', speed, internal); 9850 swiper.emit('transitionEnd'); 9851 } 9852 } else { 9853 swiper.setTransition(speed); 9854 swiper.setTranslate(newTranslate); 9855 9856 if (runCallbacks) { 9857 swiper.emit('beforeTransitionStart', speed, internal); 9858 swiper.emit('transitionStart'); 9859 } 9860 9861 if (!swiper.animating) { 9862 swiper.animating = true; 9863 9864 if (!swiper.onTranslateToWrapperTransitionEnd) { 9865 swiper.onTranslateToWrapperTransitionEnd = function transitionEnd(e) { 9866 if (!swiper || swiper.destroyed) return; 9867 if (e.target !== this) return; 9868 swiper.$wrapperEl[0].removeEventListener('transitionend', swiper.onTranslateToWrapperTransitionEnd); 9869 swiper.$wrapperEl[0].removeEventListener('webkitTransitionEnd', swiper.onTranslateToWrapperTransitionEnd); 9870 swiper.onTranslateToWrapperTransitionEnd = null; 9871 delete swiper.onTranslateToWrapperTransitionEnd; 9872 9873 if (runCallbacks) { 9874 swiper.emit('transitionEnd'); 9875 } 9876 }; 9877 } 9878 9879 swiper.$wrapperEl[0].addEventListener('transitionend', swiper.onTranslateToWrapperTransitionEnd); 9880 swiper.$wrapperEl[0].addEventListener('webkitTransitionEnd', swiper.onTranslateToWrapperTransitionEnd); 9881 } 9882 } 9883 9884 return true; 9885 } 9886 9887 var translate = { 9888 getTranslate: getSwiperTranslate, 9889 setTranslate, 9890 minTranslate, 9891 maxTranslate, 9892 translateTo 9893 }; 9894 9895 function setTransition(duration, byController) { 9896 const swiper = this; 9897 9898 if (!swiper.params.cssMode) { 9899 swiper.$wrapperEl.transition(duration); 9900 } 9901 9902 swiper.emit('setTransition', duration, byController); 9903 } 9904 9905 function transitionEmit(_ref) { 9906 let { 9907 swiper, 9908 runCallbacks, 9909 direction, 9910 step 9911 } = _ref; 9912 const { 9913 activeIndex, 9914 previousIndex 9915 } = swiper; 9916 let dir = direction; 9917 9918 if (!dir) { 9919 if (activeIndex > previousIndex) dir = 'next';else if (activeIndex < previousIndex) dir = 'prev';else dir = 'reset'; 9920 } 9921 9922 swiper.emit(`transition${step}`); 9923 9924 if (runCallbacks && activeIndex !== previousIndex) { 9925 if (dir === 'reset') { 9926 swiper.emit(`slideResetTransition${step}`); 9927 return; 9928 } 9929 9930 swiper.emit(`slideChangeTransition${step}`); 9931 9932 if (dir === 'next') { 9933 swiper.emit(`slideNextTransition${step}`); 9934 } else { 9935 swiper.emit(`slidePrevTransition${step}`); 9936 } 9937 } 9938 } 9939 9940 function transitionStart(runCallbacks, direction) { 9941 if (runCallbacks === void 0) { 9942 runCallbacks = true; 9943 } 9944 9945 const swiper = this; 9946 const { 9947 params 9948 } = swiper; 9949 if (params.cssMode) return; 9950 9951 if (params.autoHeight) { 9952 swiper.updateAutoHeight(); 9953 } 9954 9955 transitionEmit({ 9956 swiper, 9957 runCallbacks, 9958 direction, 9959 step: 'Start' 9960 }); 9961 } 9962 9963 function transitionEnd(runCallbacks, direction) { 9964 if (runCallbacks === void 0) { 9965 runCallbacks = true; 9966 } 9967 9968 const swiper = this; 9969 const { 9970 params 9971 } = swiper; 9972 swiper.animating = false; 9973 if (params.cssMode) return; 9974 swiper.setTransition(0); 9975 transitionEmit({ 9976 swiper, 9977 runCallbacks, 9978 direction, 9979 step: 'End' 9980 }); 9981 } 9982 9983 var transition = { 9984 setTransition, 9985 transitionStart, 9986 transitionEnd 9987 }; 9988 9989 function slideTo(index, speed, runCallbacks, internal, initial) { 9990 if (index === void 0) { 9991 index = 0; 9992 } 9993 9994 if (speed === void 0) { 9995 speed = this.params.speed; 9996 } 9997 9998 if (runCallbacks === void 0) { 9999 runCallbacks = true; 10000 } 10001 10002 if (typeof index !== 'number' && typeof index !== 'string') { 10003 throw new Error(`The 'index' argument cannot have type other than 'number' or 'string'. [${typeof index}] given.`); 10004 } 10005 10006 if (typeof index === 'string') { 10007 /** 10008 * The `index` argument converted from `string` to `number`. 10009 * @type {number} 10010 */ 10011 const indexAsNumber = parseInt(index, 10); 10012 /** 10013 * Determines whether the `index` argument is a valid `number` 10014 * after being converted from the `string` type. 10015 * @type {boolean} 10016 */ 10017 10018 const isValidNumber = isFinite(indexAsNumber); 10019 10020 if (!isValidNumber) { 10021 throw new Error(`The passed-in 'index' (string) couldn't be converted to 'number'. [${index}] given.`); 10022 } // Knowing that the converted `index` is a valid number, 10023 // we can update the original argument's value. 10024 10025 10026 index = indexAsNumber; 10027 } 10028 10029 const swiper = this; 10030 let slideIndex = index; 10031 if (slideIndex < 0) slideIndex = 0; 10032 const { 10033 params, 10034 snapGrid, 10035 slidesGrid, 10036 previousIndex, 10037 activeIndex, 10038 rtlTranslate: rtl, 10039 wrapperEl, 10040 enabled 10041 } = swiper; 10042 10043 if (swiper.animating && params.preventInteractionOnTransition || !enabled && !internal && !initial) { 10044 return false; 10045 } 10046 10047 const skip = Math.min(swiper.params.slidesPerGroupSkip, slideIndex); 10048 let snapIndex = skip + Math.floor((slideIndex - skip) / swiper.params.slidesPerGroup); 10049 if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1; 10050 const translate = -snapGrid[snapIndex]; // Normalize slideIndex 10051 10052 if (params.normalizeSlideIndex) { 10053 for (let i = 0; i < slidesGrid.length; i += 1) { 10054 const normalizedTranslate = -Math.floor(translate * 100); 10055 const normalizedGrid = Math.floor(slidesGrid[i] * 100); 10056 const normalizedGridNext = Math.floor(slidesGrid[i + 1] * 100); 10057 10058 if (typeof slidesGrid[i + 1] !== 'undefined') { 10059 if (normalizedTranslate >= normalizedGrid && normalizedTranslate < normalizedGridNext - (normalizedGridNext - normalizedGrid) / 2) { 10060 slideIndex = i; 10061 } else if (normalizedTranslate >= normalizedGrid && normalizedTranslate < normalizedGridNext) { 10062 slideIndex = i + 1; 10063 } 10064 } else if (normalizedTranslate >= normalizedGrid) { 10065 slideIndex = i; 10066 } 10067 } 10068 } // Directions locks 10069 10070 10071 if (swiper.initialized && slideIndex !== activeIndex) { 10072 if (!swiper.allowSlideNext && translate < swiper.translate && translate < swiper.minTranslate()) { 10073 return false; 10074 } 10075 10076 if (!swiper.allowSlidePrev && translate > swiper.translate && translate > swiper.maxTranslate()) { 10077 if ((activeIndex || 0) !== slideIndex) return false; 10078 } 10079 } 10080 10081 if (slideIndex !== (previousIndex || 0) && runCallbacks) { 10082 swiper.emit('beforeSlideChangeStart'); 10083 } // Update progress 10084 10085 10086 swiper.updateProgress(translate); 10087 let direction; 10088 if (slideIndex > activeIndex) direction = 'next';else if (slideIndex < activeIndex) direction = 'prev';else direction = 'reset'; // Update Index 10089 10090 if (rtl && -translate === swiper.translate || !rtl && translate === swiper.translate) { 10091 swiper.updateActiveIndex(slideIndex); // Update Height 10092 10093 if (params.autoHeight) { 10094 swiper.updateAutoHeight(); 10095 } 10096 10097 swiper.updateSlidesClasses(); 10098 10099 if (params.effect !== 'slide') { 10100 swiper.setTranslate(translate); 10101 } 10102 10103 if (direction !== 'reset') { 10104 swiper.transitionStart(runCallbacks, direction); 10105 swiper.transitionEnd(runCallbacks, direction); 10106 } 10107 10108 return false; 10109 } 10110 10111 if (params.cssMode) { 10112 const isH = swiper.isHorizontal(); 10113 const t = rtl ? translate : -translate; 10114 10115 if (speed === 0) { 10116 const isVirtual = swiper.virtual && swiper.params.virtual.enabled; 10117 10118 if (isVirtual) { 10119 swiper.wrapperEl.style.scrollSnapType = 'none'; 10120 swiper._immediateVirtual = true; 10121 } 10122 10123 wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t; 10124 10125 if (isVirtual) { 10126 requestAnimationFrame(() => { 10127 swiper.wrapperEl.style.scrollSnapType = ''; 10128 swiper._swiperImmediateVirtual = false; 10129 }); 10130 } 10131 } else { 10132 if (!swiper.support.smoothScroll) { 10133 animateCSSModeScroll({ 10134 swiper, 10135 targetPosition: t, 10136 side: isH ? 'left' : 'top' 10137 }); 10138 return true; 10139 } 10140 10141 wrapperEl.scrollTo({ 10142 [isH ? 'left' : 'top']: t, 10143 behavior: 'smooth' 10144 }); 10145 } 10146 10147 return true; 10148 } 10149 10150 swiper.setTransition(speed); 10151 swiper.setTranslate(translate); 10152 swiper.updateActiveIndex(slideIndex); 10153 swiper.updateSlidesClasses(); 10154 swiper.emit('beforeTransitionStart', speed, internal); 10155 swiper.transitionStart(runCallbacks, direction); 10156 10157 if (speed === 0) { 10158 swiper.transitionEnd(runCallbacks, direction); 10159 } else if (!swiper.animating) { 10160 swiper.animating = true; 10161 10162 if (!swiper.onSlideToWrapperTransitionEnd) { 10163 swiper.onSlideToWrapperTransitionEnd = function transitionEnd(e) { 10164 if (!swiper || swiper.destroyed) return; 10165 if (e.target !== this) return; 10166 swiper.$wrapperEl[0].removeEventListener('transitionend', swiper.onSlideToWrapperTransitionEnd); 10167 swiper.$wrapperEl[0].removeEventListener('webkitTransitionEnd', swiper.onSlideToWrapperTransitionEnd); 10168 swiper.onSlideToWrapperTransitionEnd = null; 10169 delete swiper.onSlideToWrapperTransitionEnd; 10170 swiper.transitionEnd(runCallbacks, direction); 10171 }; 10172 } 10173 10174 swiper.$wrapperEl[0].addEventListener('transitionend', swiper.onSlideToWrapperTransitionEnd); 10175 swiper.$wrapperEl[0].addEventListener('webkitTransitionEnd', swiper.onSlideToWrapperTransitionEnd); 10176 } 10177 10178 return true; 10179 } 10180 10181 function slideToLoop(index, speed, runCallbacks, internal) { 10182 if (index === void 0) { 10183 index = 0; 10184 } 10185 10186 if (speed === void 0) { 10187 speed = this.params.speed; 10188 } 10189 10190 if (runCallbacks === void 0) { 10191 runCallbacks = true; 10192 } 10193 10194 if (typeof index === 'string') { 10195 /** 10196 * The `index` argument converted from `string` to `number`. 10197 * @type {number} 10198 */ 10199 const indexAsNumber = parseInt(index, 10); 10200 /** 10201 * Determines whether the `index` argument is a valid `number` 10202 * after being converted from the `string` type. 10203 * @type {boolean} 10204 */ 10205 10206 const isValidNumber = isFinite(indexAsNumber); 10207 10208 if (!isValidNumber) { 10209 throw new Error(`The passed-in 'index' (string) couldn't be converted to 'number'. [${index}] given.`); 10210 } // Knowing that the converted `index` is a valid number, 10211 // we can update the original argument's value. 10212 10213 10214 index = indexAsNumber; 10215 } 10216 10217 const swiper = this; 10218 let newIndex = index; 10219 10220 if (swiper.params.loop) { 10221 newIndex += swiper.loopedSlides; 10222 } 10223 10224 return swiper.slideTo(newIndex, speed, runCallbacks, internal); 10225 } 10226 10227 /* eslint no-unused-vars: "off" */ 10228 function slideNext(speed, runCallbacks, internal) { 10229 if (speed === void 0) { 10230 speed = this.params.speed; 10231 } 10232 10233 if (runCallbacks === void 0) { 10234 runCallbacks = true; 10235 } 10236 10237 const swiper = this; 10238 const { 10239 animating, 10240 enabled, 10241 params 10242 } = swiper; 10243 if (!enabled) return swiper; 10244 let perGroup = params.slidesPerGroup; 10245 10246 if (params.slidesPerView === 'auto' && params.slidesPerGroup === 1 && params.slidesPerGroupAuto) { 10247 perGroup = Math.max(swiper.slidesPerViewDynamic('current', true), 1); 10248 } 10249 10250 const increment = swiper.activeIndex < params.slidesPerGroupSkip ? 1 : perGroup; 10251 10252 if (params.loop) { 10253 if (animating && params.loopPreventsSlide) return false; 10254 swiper.loopFix(); // eslint-disable-next-line 10255 10256 swiper._clientLeft = swiper.$wrapperEl[0].clientLeft; 10257 } 10258 10259 if (params.rewind && swiper.isEnd) { 10260 return swiper.slideTo(0, speed, runCallbacks, internal); 10261 } 10262 10263 return swiper.slideTo(swiper.activeIndex + increment, speed, runCallbacks, internal); 10264 } 10265 10266 /* eslint no-unused-vars: "off" */ 10267 function slidePrev(speed, runCallbacks, internal) { 10268 if (speed === void 0) { 10269 speed = this.params.speed; 10270 } 10271 10272 if (runCallbacks === void 0) { 10273 runCallbacks = true; 10274 } 10275 10276 const swiper = this; 10277 const { 10278 params, 10279 animating, 10280 snapGrid, 10281 slidesGrid, 10282 rtlTranslate, 10283 enabled 10284 } = swiper; 10285 if (!enabled) return swiper; 10286 10287 if (params.loop) { 10288 if (animating && params.loopPreventsSlide) return false; 10289 swiper.loopFix(); // eslint-disable-next-line 10290 10291 swiper._clientLeft = swiper.$wrapperEl[0].clientLeft; 10292 } 10293 10294 const translate = rtlTranslate ? swiper.translate : -swiper.translate; 10295 10296 function normalize(val) { 10297 if (val < 0) return -Math.floor(Math.abs(val)); 10298 return Math.floor(val); 10299 } 10300 10301 const normalizedTranslate = normalize(translate); 10302 const normalizedSnapGrid = snapGrid.map(val => normalize(val)); 10303 let prevSnap = snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate) - 1]; 10304 10305 if (typeof prevSnap === 'undefined' && params.cssMode) { 10306 let prevSnapIndex; 10307 snapGrid.forEach((snap, snapIndex) => { 10308 if (normalizedTranslate >= snap) { 10309 // prevSnap = snap; 10310 prevSnapIndex = snapIndex; 10311 } 10312 }); 10313 10314 if (typeof prevSnapIndex !== 'undefined') { 10315 prevSnap = snapGrid[prevSnapIndex > 0 ? prevSnapIndex - 1 : prevSnapIndex]; 10316 } 10317 } 10318 10319 let prevIndex = 0; 10320 10321 if (typeof prevSnap !== 'undefined') { 10322 prevIndex = slidesGrid.indexOf(prevSnap); 10323 if (prevIndex < 0) prevIndex = swiper.activeIndex - 1; 10324 10325 if (params.slidesPerView === 'auto' && params.slidesPerGroup === 1 && params.slidesPerGroupAuto) { 10326 prevIndex = prevIndex - swiper.slidesPerViewDynamic('previous', true) + 1; 10327 prevIndex = Math.max(prevIndex, 0); 10328 } 10329 } 10330 10331 if (params.rewind && swiper.isBeginning) { 10332 const lastIndex = swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual ? swiper.virtual.slides.length - 1 : swiper.slides.length - 1; 10333 return swiper.slideTo(lastIndex, speed, runCallbacks, internal); 10334 } 10335 10336 return swiper.slideTo(prevIndex, speed, runCallbacks, internal); 10337 } 10338 10339 /* eslint no-unused-vars: "off" */ 10340 function slideReset(speed, runCallbacks, internal) { 10341 if (speed === void 0) { 10342 speed = this.params.speed; 10343 } 10344 10345 if (runCallbacks === void 0) { 10346 runCallbacks = true; 10347 } 10348 10349 const swiper = this; 10350 return swiper.slideTo(swiper.activeIndex, speed, runCallbacks, internal); 10351 } 10352 10353 /* eslint no-unused-vars: "off" */ 10354 function slideToClosest(speed, runCallbacks, internal, threshold) { 10355 if (speed === void 0) { 10356 speed = this.params.speed; 10357 } 10358 10359 if (runCallbacks === void 0) { 10360 runCallbacks = true; 10361 } 10362 10363 if (threshold === void 0) { 10364 threshold = 0.5; 10365 } 10366 10367 const swiper = this; 10368 let index = swiper.activeIndex; 10369 const skip = Math.min(swiper.params.slidesPerGroupSkip, index); 10370 const snapIndex = skip + Math.floor((index - skip) / swiper.params.slidesPerGroup); 10371 const translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate; 10372 10373 if (translate >= swiper.snapGrid[snapIndex]) { 10374 // The current translate is on or after the current snap index, so the choice 10375 // is between the current index and the one after it. 10376 const currentSnap = swiper.snapGrid[snapIndex]; 10377 const nextSnap = swiper.snapGrid[snapIndex + 1]; 10378 10379 if (translate - currentSnap > (nextSnap - currentSnap) * threshold) { 10380 index += swiper.params.slidesPerGroup; 10381 } 10382 } else { 10383 // The current translate is before the current snap index, so the choice 10384 // is between the current index and the one before it. 10385 const prevSnap = swiper.snapGrid[snapIndex - 1]; 10386 const currentSnap = swiper.snapGrid[snapIndex]; 10387 10388 if (translate - prevSnap <= (currentSnap - prevSnap) * threshold) { 10389 index -= swiper.params.slidesPerGroup; 10390 } 10391 } 10392 10393 index = Math.max(index, 0); 10394 index = Math.min(index, swiper.slidesGrid.length - 1); 10395 return swiper.slideTo(index, speed, runCallbacks, internal); 10396 } 10397 10398 function slideToClickedSlide() { 10399 const swiper = this; 10400 const { 10401 params, 10402 $wrapperEl 10403 } = swiper; 10404 const slidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : params.slidesPerView; 10405 let slideToIndex = swiper.clickedIndex; 10406 let realIndex; 10407 10408 if (params.loop) { 10409 if (swiper.animating) return; 10410 realIndex = parseInt($(swiper.clickedSlide).attr('data-swiper-slide-index'), 10); 10411 10412 if (params.centeredSlides) { 10413 if (slideToIndex < swiper.loopedSlides - slidesPerView / 2 || slideToIndex > swiper.slides.length - swiper.loopedSlides + slidesPerView / 2) { 10414 swiper.loopFix(); 10415 slideToIndex = $wrapperEl.children(`.${params.slideClass}[data-swiper-slide-index="${realIndex}"]:not(.${params.slideDuplicateClass})`).eq(0).index(); 10416 nextTick(() => { 10417 swiper.slideTo(slideToIndex); 10418 }); 10419 } else { 10420 swiper.slideTo(slideToIndex); 10421 } 10422 } else if (slideToIndex > swiper.slides.length - slidesPerView) { 10423 swiper.loopFix(); 10424 slideToIndex = $wrapperEl.children(`.${params.slideClass}[data-swiper-slide-index="${realIndex}"]:not(.${params.slideDuplicateClass})`).eq(0).index(); 10425 nextTick(() => { 10426 swiper.slideTo(slideToIndex); 10427 }); 10428 } else { 10429 swiper.slideTo(slideToIndex); 10430 } 10431 } else { 10432 swiper.slideTo(slideToIndex); 10433 } 10434 } 10435 10436 var slide = { 10437 slideTo, 10438 slideToLoop, 10439 slideNext, 10440 slidePrev, 10441 slideReset, 10442 slideToClosest, 10443 slideToClickedSlide 10444 }; 10445 10446 function loopCreate() { 10447 const swiper = this; 10448 const document = getDocument(); 10449 const { 10450 params, 10451 $wrapperEl 10452 } = swiper; // Remove duplicated slides 10453 10454 const $selector = $wrapperEl.children().length > 0 ? $($wrapperEl.children()[0].parentNode) : $wrapperEl; 10455 $selector.children(`.${params.slideClass}.${params.slideDuplicateClass}`).remove(); 10456 let slides = $selector.children(`.${params.slideClass}`); 10457 10458 if (params.loopFillGroupWithBlank) { 10459 const blankSlidesNum = params.slidesPerGroup - slides.length % params.slidesPerGroup; 10460 10461 if (blankSlidesNum !== params.slidesPerGroup) { 10462 for (let i = 0; i < blankSlidesNum; i += 1) { 10463 const blankNode = $(document.createElement('div')).addClass(`${params.slideClass} ${params.slideBlankClass}`); 10464 $selector.append(blankNode); 10465 } 10466 10467 slides = $selector.children(`.${params.slideClass}`); 10468 } 10469 } 10470 10471 if (params.slidesPerView === 'auto' && !params.loopedSlides) params.loopedSlides = slides.length; 10472 swiper.loopedSlides = Math.ceil(parseFloat(params.loopedSlides || params.slidesPerView, 10)); 10473 swiper.loopedSlides += params.loopAdditionalSlides; 10474 10475 if (swiper.loopedSlides > slides.length && swiper.params.loopedSlidesLimit) { 10476 swiper.loopedSlides = slides.length; 10477 } 10478 10479 const prependSlides = []; 10480 const appendSlides = []; 10481 slides.each((el, index) => { 10482 const slide = $(el); 10483 slide.attr('data-swiper-slide-index', index); 10484 }); 10485 10486 for (let i = 0; i < swiper.loopedSlides; i += 1) { 10487 const index = i - Math.floor(i / slides.length) * slides.length; 10488 appendSlides.push(slides.eq(index)[0]); 10489 prependSlides.unshift(slides.eq(slides.length - index - 1)[0]); 10490 } 10491 10492 for (let i = 0; i < appendSlides.length; i += 1) { 10493 $selector.append($(appendSlides[i].cloneNode(true)).addClass(params.slideDuplicateClass)); 10494 } 10495 10496 for (let i = prependSlides.length - 1; i >= 0; i -= 1) { 10497 $selector.prepend($(prependSlides[i].cloneNode(true)).addClass(params.slideDuplicateClass)); 10498 } 10499 } 10500 10501 function loopFix() { 10502 const swiper = this; 10503 swiper.emit('beforeLoopFix'); 10504 const { 10505 activeIndex, 10506 slides, 10507 loopedSlides, 10508 allowSlidePrev, 10509 allowSlideNext, 10510 snapGrid, 10511 rtlTranslate: rtl 10512 } = swiper; 10513 let newIndex; 10514 swiper.allowSlidePrev = true; 10515 swiper.allowSlideNext = true; 10516 const snapTranslate = -snapGrid[activeIndex]; 10517 const diff = snapTranslate - swiper.getTranslate(); // Fix For Negative Oversliding 10518 10519 if (activeIndex < loopedSlides) { 10520 newIndex = slides.length - loopedSlides * 3 + activeIndex; 10521 newIndex += loopedSlides; 10522 const slideChanged = swiper.slideTo(newIndex, 0, false, true); 10523 10524 if (slideChanged && diff !== 0) { 10525 swiper.setTranslate((rtl ? -swiper.translate : swiper.translate) - diff); 10526 } 10527 } else if (activeIndex >= slides.length - loopedSlides) { 10528 // Fix For Positive Oversliding 10529 newIndex = -slides.length + activeIndex + loopedSlides; 10530 newIndex += loopedSlides; 10531 const slideChanged = swiper.slideTo(newIndex, 0, false, true); 10532 10533 if (slideChanged && diff !== 0) { 10534 swiper.setTranslate((rtl ? -swiper.translate : swiper.translate) - diff); 10535 } 10536 } 10537 10538 swiper.allowSlidePrev = allowSlidePrev; 10539 swiper.allowSlideNext = allowSlideNext; 10540 swiper.emit('loopFix'); 10541 } 10542 10543 function loopDestroy() { 10544 const swiper = this; 10545 const { 10546 $wrapperEl, 10547 params, 10548 slides 10549 } = swiper; 10550 $wrapperEl.children(`.${params.slideClass}.${params.slideDuplicateClass},.${params.slideClass}.${params.slideBlankClass}`).remove(); 10551 slides.removeAttr('data-swiper-slide-index'); 10552 } 10553 10554 var loop = { 10555 loopCreate, 10556 loopFix, 10557 loopDestroy 10558 }; 10559 10560 function setGrabCursor(moving) { 10561 const swiper = this; 10562 if (swiper.support.touch || !swiper.params.simulateTouch || swiper.params.watchOverflow && swiper.isLocked || swiper.params.cssMode) return; 10563 const el = swiper.params.touchEventsTarget === 'container' ? swiper.el : swiper.wrapperEl; 10564 el.style.cursor = 'move'; 10565 el.style.cursor = moving ? 'grabbing' : 'grab'; 10566 } 10567 10568 function unsetGrabCursor() { 10569 const swiper = this; 10570 10571 if (swiper.support.touch || swiper.params.watchOverflow && swiper.isLocked || swiper.params.cssMode) { 10572 return; 10573 } 10574 10575 swiper[swiper.params.touchEventsTarget === 'container' ? 'el' : 'wrapperEl'].style.cursor = ''; 10576 } 10577 10578 var grabCursor = { 10579 setGrabCursor, 10580 unsetGrabCursor 10581 }; 10582 10583 function closestElement(selector, base) { 10584 if (base === void 0) { 10585 base = this; 10586 } 10587 10588 function __closestFrom(el) { 10589 if (!el || el === getDocument() || el === getWindow()) return null; 10590 if (el.assignedSlot) el = el.assignedSlot; 10591 const found = el.closest(selector); 10592 10593 if (!found && !el.getRootNode) { 10594 return null; 10595 } 10596 10597 return found || __closestFrom(el.getRootNode().host); 10598 } 10599 10600 return __closestFrom(base); 10601 } 10602 10603 function onTouchStart(event) { 10604 const swiper = this; 10605 const document = getDocument(); 10606 const window = getWindow(); 10607 const data = swiper.touchEventsData; 10608 const { 10609 params, 10610 touches, 10611 enabled 10612 } = swiper; 10613 if (!enabled) return; 10614 10615 if (swiper.animating && params.preventInteractionOnTransition) { 10616 return; 10617 } 10618 10619 if (!swiper.animating && params.cssMode && params.loop) { 10620 swiper.loopFix(); 10621 } 10622 10623 let e = event; 10624 if (e.originalEvent) e = e.originalEvent; 10625 let $targetEl = $(e.target); 10626 10627 if (params.touchEventsTarget === 'wrapper') { 10628 if (!$targetEl.closest(swiper.wrapperEl).length) return; 10629 } 10630 10631 data.isTouchEvent = e.type === 'touchstart'; 10632 if (!data.isTouchEvent && 'which' in e && e.which === 3) return; 10633 if (!data.isTouchEvent && 'button' in e && e.button > 0) return; 10634 if (data.isTouched && data.isMoved) return; // change target el for shadow root component 10635 10636 const swipingClassHasValue = !!params.noSwipingClass && params.noSwipingClass !== ''; // eslint-disable-next-line 10637 10638 const eventPath = event.composedPath ? event.composedPath() : event.path; 10639 10640 if (swipingClassHasValue && e.target && e.target.shadowRoot && eventPath) { 10641 $targetEl = $(eventPath[0]); 10642 } 10643 10644 const noSwipingSelector = params.noSwipingSelector ? params.noSwipingSelector : `.${params.noSwipingClass}`; 10645 const isTargetShadow = !!(e.target && e.target.shadowRoot); // use closestElement for shadow root element to get the actual closest for nested shadow root element 10646 10647 if (params.noSwiping && (isTargetShadow ? closestElement(noSwipingSelector, $targetEl[0]) : $targetEl.closest(noSwipingSelector)[0])) { 10648 swiper.allowClick = true; 10649 return; 10650 } 10651 10652 if (params.swipeHandler) { 10653 if (!$targetEl.closest(params.swipeHandler)[0]) return; 10654 } 10655 10656 touches.currentX = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX; 10657 touches.currentY = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY; 10658 const startX = touches.currentX; 10659 const startY = touches.currentY; // Do NOT start if iOS edge swipe is detected. Otherwise iOS app cannot swipe-to-go-back anymore 10660 10661 const edgeSwipeDetection = params.edgeSwipeDetection || params.iOSEdgeSwipeDetection; 10662 const edgeSwipeThreshold = params.edgeSwipeThreshold || params.iOSEdgeSwipeThreshold; 10663 10664 if (edgeSwipeDetection && (startX <= edgeSwipeThreshold || startX >= window.innerWidth - edgeSwipeThreshold)) { 10665 if (edgeSwipeDetection === 'prevent') { 10666 event.preventDefault(); 10667 } else { 10668 return; 10669 } 10670 } 10671 10672 Object.assign(data, { 10673 isTouched: true, 10674 isMoved: false, 10675 allowTouchCallbacks: true, 10676 isScrolling: undefined, 10677 startMoving: undefined 10678 }); 10679 touches.startX = startX; 10680 touches.startY = startY; 10681 data.touchStartTime = now(); 10682 swiper.allowClick = true; 10683 swiper.updateSize(); 10684 swiper.swipeDirection = undefined; 10685 if (params.threshold > 0) data.allowThresholdMove = false; 10686 10687 if (e.type !== 'touchstart') { 10688 let preventDefault = true; 10689 10690 if ($targetEl.is(data.focusableElements)) { 10691 preventDefault = false; 10692 10693 if ($targetEl[0].nodeName === 'SELECT') { 10694 data.isTouched = false; 10695 } 10696 } 10697 10698 if (document.activeElement && $(document.activeElement).is(data.focusableElements) && document.activeElement !== $targetEl[0]) { 10699 document.activeElement.blur(); 10700 } 10701 10702 const shouldPreventDefault = preventDefault && swiper.allowTouchMove && params.touchStartPreventDefault; 10703 10704 if ((params.touchStartForcePreventDefault || shouldPreventDefault) && !$targetEl[0].isContentEditable) { 10705 e.preventDefault(); 10706 } 10707 } 10708 10709 if (swiper.params.freeMode && swiper.params.freeMode.enabled && swiper.freeMode && swiper.animating && !params.cssMode) { 10710 swiper.freeMode.onTouchStart(); 10711 } 10712 10713 swiper.emit('touchStart', e); 10714 } 10715 10716 function onTouchMove(event) { 10717 const document = getDocument(); 10718 const swiper = this; 10719 const data = swiper.touchEventsData; 10720 const { 10721 params, 10722 touches, 10723 rtlTranslate: rtl, 10724 enabled 10725 } = swiper; 10726 if (!enabled) return; 10727 let e = event; 10728 if (e.originalEvent) e = e.originalEvent; 10729 10730 if (!data.isTouched) { 10731 if (data.startMoving && data.isScrolling) { 10732 swiper.emit('touchMoveOpposite', e); 10733 } 10734 10735 return; 10736 } 10737 10738 if (data.isTouchEvent && e.type !== 'touchmove') return; 10739 const targetTouch = e.type === 'touchmove' && e.targetTouches && (e.targetTouches[0] || e.changedTouches[0]); 10740 const pageX = e.type === 'touchmove' ? targetTouch.pageX : e.pageX; 10741 const pageY = e.type === 'touchmove' ? targetTouch.pageY : e.pageY; 10742 10743 if (e.preventedByNestedSwiper) { 10744 touches.startX = pageX; 10745 touches.startY = pageY; 10746 return; 10747 } 10748 10749 if (!swiper.allowTouchMove) { 10750 if (!$(e.target).is(data.focusableElements)) { 10751 swiper.allowClick = false; 10752 } 10753 10754 if (data.isTouched) { 10755 Object.assign(touches, { 10756 startX: pageX, 10757 startY: pageY, 10758 currentX: pageX, 10759 currentY: pageY 10760 }); 10761 data.touchStartTime = now(); 10762 } 10763 10764 return; 10765 } 10766 10767 if (data.isTouchEvent && params.touchReleaseOnEdges && !params.loop) { 10768 if (swiper.isVertical()) { 10769 // Vertical 10770 if (pageY < touches.startY && swiper.translate <= swiper.maxTranslate() || pageY > touches.startY && swiper.translate >= swiper.minTranslate()) { 10771 data.isTouched = false; 10772 data.isMoved = false; 10773 return; 10774 } 10775 } else if (pageX < touches.startX && swiper.translate <= swiper.maxTranslate() || pageX > touches.startX && swiper.translate >= swiper.minTranslate()) { 10776 return; 10777 } 10778 } 10779 10780 if (data.isTouchEvent && document.activeElement) { 10781 if (e.target === document.activeElement && $(e.target).is(data.focusableElements)) { 10782 data.isMoved = true; 10783 swiper.allowClick = false; 10784 return; 10785 } 10786 } 10787 10788 if (data.allowTouchCallbacks) { 10789 swiper.emit('touchMove', e); 10790 } 10791 10792 if (e.targetTouches && e.targetTouches.length > 1) return; 10793 touches.currentX = pageX; 10794 touches.currentY = pageY; 10795 const diffX = touches.currentX - touches.startX; 10796 const diffY = touches.currentY - touches.startY; 10797 if (swiper.params.threshold && Math.sqrt(diffX ** 2 + diffY ** 2) < swiper.params.threshold) return; 10798 10799 if (typeof data.isScrolling === 'undefined') { 10800 let touchAngle; 10801 10802 if (swiper.isHorizontal() && touches.currentY === touches.startY || swiper.isVertical() && touches.currentX === touches.startX) { 10803 data.isScrolling = false; 10804 } else { 10805 // eslint-disable-next-line 10806 if (diffX * diffX + diffY * diffY >= 25) { 10807 touchAngle = Math.atan2(Math.abs(diffY), Math.abs(diffX)) * 180 / Math.PI; 10808 data.isScrolling = swiper.isHorizontal() ? touchAngle > params.touchAngle : 90 - touchAngle > params.touchAngle; 10809 } 10810 } 10811 } 10812 10813 if (data.isScrolling) { 10814 swiper.emit('touchMoveOpposite', e); 10815 } 10816 10817 if (typeof data.startMoving === 'undefined') { 10818 if (touches.currentX !== touches.startX || touches.currentY !== touches.startY) { 10819 data.startMoving = true; 10820 } 10821 } 10822 10823 if (data.isScrolling) { 10824 data.isTouched = false;
vendor: 5,589 bytes, lines 10825-11003
10825 return; 10826 } 10827 10828 if (!data.startMoving) { 10829 return; 10830 } 10831 10832 swiper.allowClick = false; 10833 10834 if (!params.cssMode && e.cancelable) { 10835 e.preventDefault(); 10836 } 10837 10838 if (params.touchMoveStopPropagation && !params.nested) { 10839 e.stopPropagation(); 10840 } 10841 10842 if (!data.isMoved) { 10843 if (params.loop && !params.cssMode) { 10844 swiper.loopFix(); 10845 } 10846 10847 data.startTranslate = swiper.getTranslate(); 10848 swiper.setTransition(0); 10849 10850 if (swiper.animating) { 10851 swiper.$wrapperEl.trigger('webkitTransitionEnd transitionend'); 10852 } 10853 10854 data.allowMomentumBounce = false; // Grab Cursor 10855 10856 if (params.grabCursor && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) { 10857 swiper.setGrabCursor(true); 10858 } 10859 10860 swiper.emit('sliderFirstMove', e); 10861 } 10862 10863 swiper.emit('sliderMove', e); 10864 data.isMoved = true; 10865 let diff = swiper.isHorizontal() ? diffX : diffY; 10866 touches.diff = diff; 10867 diff *= params.touchRatio; 10868 if (rtl) diff = -diff; 10869 swiper.swipeDirection = diff > 0 ? 'prev' : 'next'; 10870 data.currentTranslate = diff + data.startTranslate; 10871 let disableParentSwiper = true; 10872 let resistanceRatio = params.resistanceRatio; 10873 10874 if (params.touchReleaseOnEdges) { 10875 resistanceRatio = 0; 10876 } 10877 10878 if (diff > 0 && data.currentTranslate > swiper.minTranslate()) { 10879 disableParentSwiper = false; 10880 if (params.resistance) data.currentTranslate = swiper.minTranslate() - 1 + (-swiper.minTranslate() + data.startTranslate + diff) ** resistanceRatio; 10881 } else if (diff < 0 && data.currentTranslate < swiper.maxTranslate()) { 10882 disableParentSwiper = false; 10883 if (params.resistance) data.currentTranslate = swiper.maxTranslate() + 1 - (swiper.maxTranslate() - data.startTranslate - diff) ** resistanceRatio; 10884 } 10885 10886 if (disableParentSwiper) { 10887 e.preventedByNestedSwiper = true; 10888 } // Directions locks 10889 10890 10891 if (!swiper.allowSlideNext && swiper.swipeDirection === 'next' && data.currentTranslate < data.startTranslate) { 10892 data.currentTranslate = data.startTranslate; 10893 } 10894 10895 if (!swiper.allowSlidePrev && swiper.swipeDirection === 'prev' && data.currentTranslate > data.startTranslate) { 10896 data.currentTranslate = data.startTranslate; 10897 } 10898 10899 if (!swiper.allowSlidePrev && !swiper.allowSlideNext) { 10900 data.currentTranslate = data.startTranslate; 10901 } // Threshold 10902 10903 10904 if (params.threshold > 0) { 10905 if (Math.abs(diff) > params.threshold || data.allowThresholdMove) { 10906 if (!data.allowThresholdMove) { 10907 data.allowThresholdMove = true; 10908 touches.startX = touches.currentX; 10909 touches.startY = touches.currentY; 10910 data.currentTranslate = data.startTranslate; 10911 touches.diff = swiper.isHorizontal() ? touches.currentX - touches.startX : touches.currentY - touches.startY; 10912 return; 10913 } 10914 } else { 10915 data.currentTranslate = data.startTranslate; 10916 return; 10917 } 10918 } 10919 10920 if (!params.followFinger || params.cssMode) return; // Update active index in free mode 10921 10922 if (params.freeMode && params.freeMode.enabled && swiper.freeMode || params.watchSlidesProgress) { 10923 swiper.updateActiveIndex(); 10924 swiper.updateSlidesClasses(); 10925 } 10926 10927 if (swiper.params.freeMode && params.freeMode.enabled && swiper.freeMode) { 10928 swiper.freeMode.onTouchMove(); 10929 } // Update progress 10930 10931 10932 swiper.updateProgress(data.currentTranslate); // Update translate 10933 10934 swiper.setTranslate(data.currentTranslate); 10935 } 10936 10937 function onTouchEnd(event) { 10938 const swiper = this; 10939 const data = swiper.touchEventsData; 10940 const { 10941 params, 10942 touches, 10943 rtlTranslate: rtl, 10944 slidesGrid, 10945 enabled 10946 } = swiper; 10947 if (!enabled) return; 10948 let e = event; 10949 if (e.originalEvent) e = e.originalEvent; 10950 10951 if (data.allowTouchCallbacks) { 10952 swiper.emit('touchEnd', e); 10953 } 10954 10955 data.allowTouchCallbacks = false; 10956 10957 if (!data.isTouched) { 10958 if (data.isMoved && params.grabCursor) { 10959 swiper.setGrabCursor(false); 10960 } 10961 10962 data.isMoved = false; 10963 data.startMoving = false; 10964 return; 10965 } // Return Grab Cursor 10966 10967 10968 if (params.grabCursor && data.isMoved && data.isTouched && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) { 10969 swiper.setGrabCursor(false); 10970 } // Time diff 10971 10972 10973 const touchEndTime = now(); 10974 const timeDiff = touchEndTime - data.touchStartTime; // Tap, doubleTap, Click 10975 10976 if (swiper.allowClick) { 10977 const pathTree = e.path || e.composedPath && e.composedPath(); 10978 swiper.updateClickedSlide(pathTree && pathTree[0] || e.target); 10979 swiper.emit('tap click', e); 10980 10981 if (timeDiff < 300 && touchEndTime - data.lastClickTime < 300) { 10982 swiper.emit('doubleTap doubleClick', e); 10983 } 10984 } 10985 10986 data.lastClickTime = now(); 10987 nextTick(() => { 10988 if (!swiper.destroyed) swiper.allowClick = true; 10989 }); 10990 10991 if (!data.isTouched || !data.isMoved || !swiper.swipeDirection || touches.diff === 0 || data.currentTranslate === data.startTranslate) { 10992 data.isTouched = false; 10993 data.isMoved = false; 10994 data.startMoving = false; 10995 return; 10996 } 10997 10998 data.isTouched = false; 10999 data.isMoved = false; 11000 data.startMoving = false; 11001 let currentPos; 11002 11003 if (params.followFinger) {
vendor: 23,092 bytes, lines 11004-11778
11004 currentPos = rtl ? swiper.translate : -swiper.translate; 11005 } else { 11006 currentPos = -data.currentTranslate; 11007 } 11008 11009 if (params.cssMode) { 11010 return; 11011 } 11012 11013 if (swiper.params.freeMode && params.freeMode.enabled) { 11014 swiper.freeMode.onTouchEnd({ 11015 currentPos 11016 }); 11017 return; 11018 } // Find current slide 11019 11020 11021 let stopIndex = 0; 11022 let groupSize = swiper.slidesSizesGrid[0]; 11023 11024 for (let i = 0; i < slidesGrid.length; i += i < params.slidesPerGroupSkip ? 1 : params.slidesPerGroup) { 11025 const increment = i < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup; 11026 11027 if (typeof slidesGrid[i + increment] !== 'undefined') { 11028 if (currentPos >= slidesGrid[i] && currentPos < slidesGrid[i + increment]) { 11029 stopIndex = i; 11030 groupSize = slidesGrid[i + increment] - slidesGrid[i]; 11031 } 11032 } else if (currentPos >= slidesGrid[i]) { 11033 stopIndex = i; 11034 groupSize = slidesGrid[slidesGrid.length - 1] - slidesGrid[slidesGrid.length - 2]; 11035 } 11036 } 11037 11038 let rewindFirstIndex = null; 11039 let rewindLastIndex = null; 11040 11041 if (params.rewind) { 11042 if (swiper.isBeginning) { 11043 rewindLastIndex = swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual ? swiper.virtual.slides.length - 1 : swiper.slides.length - 1; 11044 } else if (swiper.isEnd) { 11045 rewindFirstIndex = 0; 11046 } 11047 } // Find current slide size 11048 11049 11050 const ratio = (currentPos - slidesGrid[stopIndex]) / groupSize; 11051 const increment = stopIndex < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup; 11052 11053 if (timeDiff > params.longSwipesMs) { 11054 // Long touches 11055 if (!params.longSwipes) { 11056 swiper.slideTo(swiper.activeIndex); 11057 return; 11058 } 11059 11060 if (swiper.swipeDirection === 'next') { 11061 if (ratio >= params.longSwipesRatio) swiper.slideTo(params.rewind && swiper.isEnd ? rewindFirstIndex : stopIndex + increment);else swiper.slideTo(stopIndex); 11062 } 11063 11064 if (swiper.swipeDirection === 'prev') { 11065 if (ratio > 1 - params.longSwipesRatio) { 11066 swiper.slideTo(stopIndex + increment); 11067 } else if (rewindLastIndex !== null && ratio < 0 && Math.abs(ratio) > params.longSwipesRatio) { 11068 swiper.slideTo(rewindLastIndex); 11069 } else { 11070 swiper.slideTo(stopIndex); 11071 } 11072 } 11073 } else { 11074 // Short swipes 11075 if (!params.shortSwipes) { 11076 swiper.slideTo(swiper.activeIndex); 11077 return; 11078 } 11079 11080 const isNavButtonTarget = swiper.navigation && (e.target === swiper.navigation.nextEl || e.target === swiper.navigation.prevEl); 11081 11082 if (!isNavButtonTarget) { 11083 if (swiper.swipeDirection === 'next') { 11084 swiper.slideTo(rewindFirstIndex !== null ? rewindFirstIndex : stopIndex + increment); 11085 } 11086 11087 if (swiper.swipeDirection === 'prev') { 11088 swiper.slideTo(rewindLastIndex !== null ? rewindLastIndex : stopIndex); 11089 } 11090 } else if (e.target === swiper.navigation.nextEl) { 11091 swiper.slideTo(stopIndex + increment); 11092 } else { 11093 swiper.slideTo(stopIndex); 11094 } 11095 } 11096 } 11097 11098 function onResize() { 11099 const swiper = this; 11100 const { 11101 params, 11102 el 11103 } = swiper; 11104 if (el && el.offsetWidth === 0) return; // Breakpoints 11105 11106 if (params.breakpoints) { 11107 swiper.setBreakpoint(); 11108 } // Save locks 11109 11110 11111 const { 11112 allowSlideNext, 11113 allowSlidePrev, 11114 snapGrid 11115 } = swiper; // Disable locks on resize 11116 11117 swiper.allowSlideNext = true; 11118 swiper.allowSlidePrev = true; 11119 swiper.updateSize(); 11120 swiper.updateSlides(); 11121 swiper.updateSlidesClasses(); 11122 11123 if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.isBeginning && !swiper.params.centeredSlides) { 11124 swiper.slideTo(swiper.slides.length - 1, 0, false, true); 11125 } else { 11126 swiper.slideTo(swiper.activeIndex, 0, false, true); 11127 } 11128 11129 if (swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused) { 11130 swiper.autoplay.run(); 11131 } // Return locks after resize 11132 11133 11134 swiper.allowSlidePrev = allowSlidePrev; 11135 swiper.allowSlideNext = allowSlideNext; 11136 11137 if (swiper.params.watchOverflow && snapGrid !== swiper.snapGrid) { 11138 swiper.checkOverflow(); 11139 } 11140 } 11141 11142 function onClick(e) { 11143 const swiper = this; 11144 if (!swiper.enabled) return; 11145 11146 if (!swiper.allowClick) { 11147 if (swiper.params.preventClicks) e.preventDefault(); 11148 11149 if (swiper.params.preventClicksPropagation && swiper.animating) { 11150 e.stopPropagation(); 11151 e.stopImmediatePropagation(); 11152 } 11153 } 11154 } 11155 11156 function onScroll() { 11157 const swiper = this; 11158 const { 11159 wrapperEl, 11160 rtlTranslate, 11161 enabled 11162 } = swiper; 11163 if (!enabled) return; 11164 swiper.previousTranslate = swiper.translate; 11165 11166 if (swiper.isHorizontal()) { 11167 swiper.translate = -wrapperEl.scrollLeft; 11168 } else { 11169 swiper.translate = -wrapperEl.scrollTop; 11170 } // eslint-disable-next-line 11171 11172 11173 if (swiper.translate === 0) swiper.translate = 0; 11174 swiper.updateActiveIndex(); 11175 swiper.updateSlidesClasses(); 11176 let newProgress; 11177 const translatesDiff = swiper.maxTranslate() - swiper.minTranslate(); 11178 11179 if (translatesDiff === 0) { 11180 newProgress = 0; 11181 } else { 11182 newProgress = (swiper.translate - swiper.minTranslate()) / translatesDiff; 11183 } 11184 11185 if (newProgress !== swiper.progress) { 11186 swiper.updateProgress(rtlTranslate ? -swiper.translate : swiper.translate); 11187 } 11188 11189 swiper.emit('setTranslate', swiper.translate, false); 11190 } 11191 11192 let dummyEventAttached = false; 11193 11194 function dummyEventListener() {} 11195 11196 const events = (swiper, method) => { 11197 const document = getDocument(); 11198 const { 11199 params, 11200 touchEvents, 11201 el, 11202 wrapperEl, 11203 device, 11204 support 11205 } = swiper; 11206 const capture = !!params.nested; 11207 const domMethod = method === 'on' ? 'addEventListener' : 'removeEventListener'; 11208 const swiperMethod = method; // Touch Events 11209 11210 if (!support.touch) { 11211 el[domMethod](touchEvents.start, swiper.onTouchStart, false); 11212 document[domMethod](touchEvents.move, swiper.onTouchMove, capture); 11213 document[domMethod](touchEvents.end, swiper.onTouchEnd, false); 11214 } else { 11215 const passiveListener = touchEvents.start === 'touchstart' && support.passiveListener && params.passiveListeners ? { 11216 passive: true, 11217 capture: false 11218 } : false; 11219 el[domMethod](touchEvents.start, swiper.onTouchStart, passiveListener); 11220 el[domMethod](touchEvents.move, swiper.onTouchMove, support.passiveListener ? { 11221 passive: false, 11222 capture 11223 } : capture); 11224 el[domMethod](touchEvents.end, swiper.onTouchEnd, passiveListener); 11225 11226 if (touchEvents.cancel) { 11227 el[domMethod](touchEvents.cancel, swiper.onTouchEnd, passiveListener); 11228 } 11229 } // Prevent Links Clicks 11230 11231 11232 if (params.preventClicks || params.preventClicksPropagation) { 11233 el[domMethod]('click', swiper.onClick, true); 11234 } 11235 11236 if (params.cssMode) { 11237 wrapperEl[domMethod]('scroll', swiper.onScroll); 11238 } // Resize handler 11239 11240 11241 if (params.updateOnWindowResize) { 11242 swiper[swiperMethod](device.ios || device.android ? 'resize orientationchange observerUpdate' : 'resize observerUpdate', onResize, true); 11243 } else { 11244 swiper[swiperMethod]('observerUpdate', onResize, true); 11245 } 11246 }; 11247 11248 function attachEvents() { 11249 const swiper = this; 11250 const document = getDocument(); 11251 const { 11252 params, 11253 support 11254 } = swiper; 11255 swiper.onTouchStart = onTouchStart.bind(swiper); 11256 swiper.onTouchMove = onTouchMove.bind(swiper); 11257 swiper.onTouchEnd = onTouchEnd.bind(swiper); 11258 11259 if (params.cssMode) { 11260 swiper.onScroll = onScroll.bind(swiper); 11261 } 11262 11263 swiper.onClick = onClick.bind(swiper); 11264 11265 if (support.touch && !dummyEventAttached) { 11266 document.addEventListener('touchstart', dummyEventListener); 11267 dummyEventAttached = true; 11268 } 11269 11270 events(swiper, 'on'); 11271 } 11272 11273 function detachEvents() { 11274 const swiper = this; 11275 events(swiper, 'off'); 11276 } 11277 11278 var events$1 = { 11279 attachEvents, 11280 detachEvents 11281 }; 11282 11283 const isGridEnabled = (swiper, params) => { 11284 return swiper.grid && params.grid && params.grid.rows > 1; 11285 }; 11286 11287 function setBreakpoint() { 11288 const swiper = this; 11289 const { 11290 activeIndex, 11291 initialized, 11292 loopedSlides = 0, 11293 params, 11294 $el 11295 } = swiper; 11296 const breakpoints = params.breakpoints; 11297 if (!breakpoints || breakpoints && Object.keys(breakpoints).length === 0) return; // Get breakpoint for window width and update parameters 11298 11299 const breakpoint = swiper.getBreakpoint(breakpoints, swiper.params.breakpointsBase, swiper.el); 11300 if (!breakpoint || swiper.currentBreakpoint === breakpoint) return; 11301 const breakpointOnlyParams = breakpoint in breakpoints ? breakpoints[breakpoint] : undefined; 11302 const breakpointParams = breakpointOnlyParams || swiper.originalParams; 11303 const wasMultiRow = isGridEnabled(swiper, params); 11304 const isMultiRow = isGridEnabled(swiper, breakpointParams); 11305 const wasEnabled = params.enabled; 11306 11307 if (wasMultiRow && !isMultiRow) { 11308 $el.removeClass(`${params.containerModifierClass}grid ${params.containerModifierClass}grid-column`); 11309 swiper.emitContainerClasses(); 11310 } else if (!wasMultiRow && isMultiRow) { 11311 $el.addClass(`${params.containerModifierClass}grid`); 11312 11313 if (breakpointParams.grid.fill && breakpointParams.grid.fill === 'column' || !breakpointParams.grid.fill && params.grid.fill === 'column') { 11314 $el.addClass(`${params.containerModifierClass}grid-column`); 11315 } 11316 11317 swiper.emitContainerClasses(); 11318 } // Toggle navigation, pagination, scrollbar 11319 11320 11321 ['navigation', 'pagination', 'scrollbar'].forEach(prop => { 11322 const wasModuleEnabled = params[prop] && params[prop].enabled; 11323 const isModuleEnabled = breakpointParams[prop] && breakpointParams[prop].enabled; 11324 11325 if (wasModuleEnabled && !isModuleEnabled) { 11326 swiper[prop].disable(); 11327 } 11328 11329 if (!wasModuleEnabled && isModuleEnabled) { 11330 swiper[prop].enable(); 11331 } 11332 }); 11333 const directionChanged = breakpointParams.direction && breakpointParams.direction !== params.direction; 11334 const needsReLoop = params.loop && (breakpointParams.slidesPerView !== params.slidesPerView || directionChanged); 11335 11336 if (directionChanged && initialized) { 11337 swiper.changeDirection(); 11338 } 11339 11340 extend(swiper.params, breakpointParams); 11341 const isEnabled = swiper.params.enabled; 11342 Object.assign(swiper, { 11343 allowTouchMove: swiper.params.allowTouchMove, 11344 allowSlideNext: swiper.params.allowSlideNext, 11345 allowSlidePrev: swiper.params.allowSlidePrev 11346 }); 11347 11348 if (wasEnabled && !isEnabled) { 11349 swiper.disable(); 11350 } else if (!wasEnabled && isEnabled) { 11351 swiper.enable(); 11352 } 11353 11354 swiper.currentBreakpoint = breakpoint; 11355 swiper.emit('_beforeBreakpoint', breakpointParams); 11356 11357 if (needsReLoop && initialized) { 11358 swiper.loopDestroy(); 11359 swiper.loopCreate(); 11360 swiper.updateSlides(); 11361 swiper.slideTo(activeIndex - loopedSlides + swiper.loopedSlides, 0, false); 11362 } 11363 11364 swiper.emit('breakpoint', breakpointParams); 11365 } 11366 11367 function getBreakpoint(breakpoints, base, containerEl) { 11368 if (base === void 0) { 11369 base = 'window'; 11370 } 11371 11372 if (!breakpoints || base === 'container' && !containerEl) return undefined; 11373 let breakpoint = false; 11374 const window = getWindow(); 11375 const currentHeight = base === 'window' ? window.innerHeight : containerEl.clientHeight; 11376 const points = Object.keys(breakpoints).map(point => { 11377 if (typeof point === 'string' && point.indexOf('@') === 0) { 11378 const minRatio = parseFloat(point.substr(1)); 11379 const value = currentHeight * minRatio; 11380 return { 11381 value, 11382 point 11383 }; 11384 } 11385 11386 return { 11387 value: point, 11388 point 11389 }; 11390 }); 11391 points.sort((a, b) => parseInt(a.value, 10) - parseInt(b.value, 10)); 11392 11393 for (let i = 0; i < points.length; i += 1) { 11394 const { 11395 point, 11396 value 11397 } = points[i]; 11398 11399 if (base === 'window') { 11400 if (window.matchMedia(`(min-width: ${value}px)`).matches) { 11401 breakpoint = point; 11402 } 11403 } else if (value <= containerEl.clientWidth) { 11404 breakpoint = point; 11405 } 11406 } 11407 11408 return breakpoint || 'max'; 11409 } 11410 11411 var breakpoints = { 11412 setBreakpoint, 11413 getBreakpoint 11414 }; 11415 11416 function prepareClasses(entries, prefix) { 11417 const resultClasses = []; 11418 entries.forEach(item => { 11419 if (typeof item === 'object') { 11420 Object.keys(item).forEach(classNames => { 11421 if (item[classNames]) { 11422 resultClasses.push(prefix + classNames); 11423 } 11424 }); 11425 } else if (typeof item === 'string') { 11426 resultClasses.push(prefix + item); 11427 } 11428 }); 11429 return resultClasses; 11430 } 11431 11432 function addClasses() { 11433 const swiper = this; 11434 const { 11435 classNames, 11436 params, 11437 rtl, 11438 $el, 11439 device, 11440 support 11441 } = swiper; // prettier-ignore 11442 11443 const suffixes = prepareClasses(['initialized', params.direction, { 11444 'pointer-events': !support.touch 11445 }, { 11446 'free-mode': swiper.params.freeMode && params.freeMode.enabled 11447 }, { 11448 'autoheight': params.autoHeight 11449 }, { 11450 'rtl': rtl 11451 }, { 11452 'grid': params.grid && params.grid.rows > 1 11453 }, { 11454 'grid-column': params.grid && params.grid.rows > 1 && params.grid.fill === 'column' 11455 }, { 11456 'android': device.android 11457 }, { 11458 'ios': device.ios 11459 }, { 11460 'css-mode': params.cssMode 11461 }, { 11462 'centered': params.cssMode && params.centeredSlides 11463 }, { 11464 'watch-progress': params.watchSlidesProgress 11465 }], params.containerModifierClass); 11466 classNames.push(...suffixes); 11467 $el.addClass([...classNames].join(' ')); 11468 swiper.emitContainerClasses(); 11469 } 11470 11471 function removeClasses() { 11472 const swiper = this; 11473 const { 11474 $el, 11475 classNames 11476 } = swiper; 11477 $el.removeClass(classNames.join(' ')); 11478 swiper.emitContainerClasses(); 11479 } 11480 11481 var classes = { 11482 addClasses, 11483 removeClasses 11484 }; 11485 11486 function loadImage(imageEl, src, srcset, sizes, checkForComplete, callback) { 11487 const window = getWindow(); 11488 let image; 11489 11490 function onReady() { 11491 if (callback) callback(); 11492 } 11493 11494 const isPicture = $(imageEl).parent('picture')[0]; 11495 11496 if (!isPicture && (!imageEl.complete || !checkForComplete)) { 11497 if (src) { 11498 image = new window.Image(); 11499 image.onload = onReady; 11500 image.onerror = onReady; 11501 11502 if (sizes) { 11503 image.sizes = sizes; 11504 } 11505 11506 if (srcset) { 11507 image.srcset = srcset; 11508 } 11509 11510 if (src) { 11511 image.src = src; 11512 } 11513 } else { 11514 onReady(); 11515 } 11516 } else { 11517 // image already loaded... 11518 onReady(); 11519 } 11520 } 11521 11522 function preloadImages() { 11523 const swiper = this; 11524 swiper.imagesToLoad = swiper.$el.find('img'); 11525 11526 function onReady() { 11527 if (typeof swiper === 'undefined' || swiper === null || !swiper || swiper.destroyed) return; 11528 if (swiper.imagesLoaded !== undefined) swiper.imagesLoaded += 1; 11529 11530 if (swiper.imagesLoaded === swiper.imagesToLoad.length) { 11531 if (swiper.params.updateOnImagesReady) swiper.update(); 11532 swiper.emit('imagesReady'); 11533 } 11534 } 11535 11536 for (let i = 0; i < swiper.imagesToLoad.length; i += 1) { 11537 const imageEl = swiper.imagesToLoad[i]; 11538 swiper.loadImage(imageEl, imageEl.currentSrc || imageEl.getAttribute('src'), imageEl.srcset || imageEl.getAttribute('srcset'), imageEl.sizes || imageEl.getAttribute('sizes'), true, onReady); 11539 } 11540 } 11541 11542 var images = { 11543 loadImage, 11544 preloadImages 11545 }; 11546 11547 function checkOverflow() { 11548 const swiper = this; 11549 const { 11550 isLocked: wasLocked, 11551 params 11552 } = swiper; 11553 const { 11554 slidesOffsetBefore 11555 } = params; 11556 11557 if (slidesOffsetBefore) { 11558 const lastSlideIndex = swiper.slides.length - 1; 11559 const lastSlideRightEdge = swiper.slidesGrid[lastSlideIndex] + swiper.slidesSizesGrid[lastSlideIndex] + slidesOffsetBefore * 2; 11560 swiper.isLocked = swiper.size > lastSlideRightEdge; 11561 } else { 11562 swiper.isLocked = swiper.snapGrid.length === 1; 11563 } 11564 11565 if (params.allowSlideNext === true) { 11566 swiper.allowSlideNext = !swiper.isLocked; 11567 } 11568 11569 if (params.allowSlidePrev === true) { 11570 swiper.allowSlidePrev = !swiper.isLocked; 11571 } 11572 11573 if (wasLocked && wasLocked !== swiper.isLocked) { 11574 swiper.isEnd = false; 11575 } 11576 11577 if (wasLocked !== swiper.isLocked) { 11578 swiper.emit(swiper.isLocked ? 'lock' : 'unlock'); 11579 } 11580 } 11581 11582 var checkOverflow$1 = { 11583 checkOverflow 11584 }; 11585 11586 var defaults = { 11587 init: true, 11588 direction: 'horizontal', 11589 touchEventsTarget: 'wrapper', 11590 initialSlide: 0, 11591 speed: 300, 11592 cssMode: false, 11593 updateOnWindowResize: true, 11594 resizeObserver: true, 11595 nested: false, 11596 createElements: false, 11597 enabled: true, 11598 focusableElements: 'input, select, option, textarea, button, video, label', 11599 // Overrides 11600 width: null, 11601 height: null, 11602 // 11603 preventInteractionOnTransition: false, 11604 // ssr 11605 userAgent: null, 11606 url: null, 11607 // To support iOS's swipe-to-go-back gesture (when being used in-app). 11608 edgeSwipeDetection: false, 11609 edgeSwipeThreshold: 20, 11610 // Autoheight 11611 autoHeight: false, 11612 // Set wrapper width 11613 setWrapperSize: false, 11614 // Virtual Translate 11615 virtualTranslate: false, 11616 // Effects 11617 effect: 'slide', 11618 // 'slide' or 'fade' or 'cube' or 'coverflow' or 'flip' 11619 // Breakpoints 11620 breakpoints: undefined, 11621 breakpointsBase: 'window', 11622 // Slides grid 11623 spaceBetween: 0, 11624 slidesPerView: 1, 11625 slidesPerGroup: 1, 11626 slidesPerGroupSkip: 0, 11627 slidesPerGroupAuto: false, 11628 centeredSlides: false, 11629 centeredSlidesBounds: false, 11630 slidesOffsetBefore: 0, 11631 // in px 11632 slidesOffsetAfter: 0, 11633 // in px 11634 normalizeSlideIndex: true, 11635 centerInsufficientSlides: false, 11636 // Disable swiper and hide navigation when container not overflow 11637 watchOverflow: true, 11638 // Round length 11639 roundLengths: false, 11640 // Touches 11641 touchRatio: 1, 11642 touchAngle: 45, 11643 simulateTouch: true, 11644 shortSwipes: true, 11645 longSwipes: true, 11646 longSwipesRatio: 0.5, 11647 longSwipesMs: 300, 11648 followFinger: true, 11649 allowTouchMove: true, 11650 threshold: 0, 11651 touchMoveStopPropagation: false, 11652 touchStartPreventDefault: true, 11653 touchStartForcePreventDefault: false, 11654 touchReleaseOnEdges: false, 11655 // Unique Navigation Elements 11656 uniqueNavElements: true, 11657 // Resistance 11658 resistance: true, 11659 resistanceRatio: 0.85, 11660 // Progress 11661 watchSlidesProgress: false, 11662 // Cursor 11663 grabCursor: false, 11664 // Clicks 11665 preventClicks: true, 11666 preventClicksPropagation: true, 11667 slideToClickedSlide: false, 11668 // Images 11669 preloadImages: true, 11670 updateOnImagesReady: true, 11671 // loop 11672 loop: false, 11673 loopAdditionalSlides: 0, 11674 loopedSlides: null, 11675 loopedSlidesLimit: true, 11676 loopFillGroupWithBlank: false, 11677 loopPreventsSlide: true, 11678 // rewind 11679 rewind: false, 11680 // Swiping/no swiping 11681 allowSlidePrev: true, 11682 allowSlideNext: true, 11683 swipeHandler: null, 11684 // '.swipe-handler', 11685 noSwiping: true, 11686 noSwipingClass: 'swiper-no-swiping', 11687 noSwipingSelector: null, 11688 // Passive Listeners 11689 passiveListeners: true, 11690 maxBackfaceHiddenSlides: 10, 11691 // NS 11692 containerModifierClass: 'swiper-', 11693 // NEW 11694 slideClass: 'swiper-slide', 11695 slideBlankClass: 'swiper-slide-invisible-blank', 11696 slideActiveClass: 'swiper-slide-active', 11697 slideDuplicateActiveClass: 'swiper-slide-duplicate-active', 11698 slideVisibleClass: 'swiper-slide-visible', 11699 slideDuplicateClass: 'swiper-slide-duplicate', 11700 slideNextClass: 'swiper-slide-next', 11701 slideDuplicateNextClass: 'swiper-slide-duplicate-next', 11702 slidePrevClass: 'swiper-slide-prev', 11703 slideDuplicatePrevClass: 'swiper-slide-duplicate-prev', 11704 wrapperClass: 'swiper-wrapper', 11705 // Callbacks 11706 runCallbacksOnInit: true, 11707 // Internals 11708 _emitClasses: false 11709 }; 11710 11711 function moduleExtendParams(params, allModulesParams) { 11712 return function extendParams(obj) { 11713 if (obj === void 0) { 11714 obj = {}; 11715 } 11716 11717 const moduleParamName = Object.keys(obj)[0]; 11718 const moduleParams = obj[moduleParamName]; 11719 11720 if (typeof moduleParams !== 'object' || moduleParams === null) { 11721 extend(allModulesParams, obj); 11722 return; 11723 } 11724 11725 if (['navigation', 'pagination', 'scrollbar'].indexOf(moduleParamName) >= 0 && params[moduleParamName] === true) { 11726 params[moduleParamName] = { 11727 auto: true 11728 }; 11729 } 11730 11731 if (!(moduleParamName in params && 'enabled' in moduleParams)) { 11732 extend(allModulesParams, obj); 11733 return; 11734 } 11735 11736 if (params[moduleParamName] === true) { 11737 params[moduleParamName] = { 11738 enabled: true 11739 }; 11740 } 11741 11742 if (typeof params[moduleParamName] === 'object' && !('enabled' in params[moduleParamName])) { 11743 params[moduleParamName].enabled = true; 11744 } 11745 11746 if (!params[moduleParamName]) params[moduleParamName] = { 11747 enabled: false 11748 }; 11749 extend(allModulesParams, obj); 11750 }; 11751 } 11752 11753 /* eslint no-param-reassign: "off" */ 11754 const prototypes = { 11755 eventsEmitter, 11756 update, 11757 translate, 11758 transition, 11759 slide, 11760 loop, 11761 grabCursor, 11762 events: events$1, 11763 breakpoints, 11764 checkOverflow: checkOverflow$1, 11765 classes, 11766 images 11767 }; 11768 const extendedDefaults = {}; 11769 11770 class Swiper { 11771 constructor() { 11772 let el; 11773 let params; 11774 11775 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { 11776 args[_key] = arguments[_key]; 11777 } 11778
vendor: 6,515 bytes, lines 11779-11989
11779 if (args.length === 1 && args[0].constructor && Object.prototype.toString.call(args[0]).slice(8, -1) === 'Object') { 11780 params = args[0]; 11781 } else { 11782 [el, params] = args; 11783 } 11784 11785 if (!params) params = {}; 11786 params = extend({}, params); 11787 if (el && !params.el) params.el = el; 11788 11789 if (params.el && $(params.el).length > 1) { 11790 const swipers = []; 11791 $(params.el).each(containerEl => { 11792 const newParams = extend({}, params, { 11793 el: containerEl 11794 }); 11795 swipers.push(new Swiper(newParams)); 11796 }); // eslint-disable-next-line no-constructor-return 11797 11798 return swipers; 11799 } // Swiper Instance 11800 11801 11802 const swiper = this; 11803 swiper.__swiper__ = true; 11804 swiper.support = getSupport(); 11805 swiper.device = getDevice({ 11806 userAgent: params.userAgent 11807 }); 11808 swiper.browser = getBrowser(); 11809 swiper.eventsListeners = {}; 11810 swiper.eventsAnyListeners = []; 11811 swiper.modules = [...swiper.__modules__]; 11812 11813 if (params.modules && Array.isArray(params.modules)) { 11814 swiper.modules.push(...params.modules); 11815 } 11816 11817 const allModulesParams = {}; 11818 swiper.modules.forEach(mod => { 11819 mod({ 11820 swiper, 11821 extendParams: moduleExtendParams(params, allModulesParams), 11822 on: swiper.on.bind(swiper), 11823 once: swiper.once.bind(swiper), 11824 off: swiper.off.bind(swiper), 11825 emit: swiper.emit.bind(swiper) 11826 }); 11827 }); // Extend defaults with modules params 11828 11829 const swiperParams = extend({}, defaults, allModulesParams); // Extend defaults with passed params 11830 11831 swiper.params = extend({}, swiperParams, extendedDefaults, params); 11832 swiper.originalParams = extend({}, swiper.params); 11833 swiper.passedParams = extend({}, params); // add event listeners 11834 11835 if (swiper.params && swiper.params.on) { 11836 Object.keys(swiper.params.on).forEach(eventName => { 11837 swiper.on(eventName, swiper.params.on[eventName]); 11838 }); 11839 } 11840 11841 if (swiper.params && swiper.params.onAny) { 11842 swiper.onAny(swiper.params.onAny); 11843 } // Save Dom lib 11844 11845 11846 swiper.$ = $; // Extend Swiper 11847 11848 Object.assign(swiper, { 11849 enabled: swiper.params.enabled, 11850 el, 11851 // Classes 11852 classNames: [], 11853 // Slides 11854 slides: $(), 11855 slidesGrid: [], 11856 snapGrid: [], 11857 slidesSizesGrid: [], 11858 11859 // isDirection 11860 isHorizontal() { 11861 return swiper.params.direction === 'horizontal'; 11862 }, 11863 11864 isVertical() { 11865 return swiper.params.direction === 'vertical'; 11866 }, 11867 11868 // Indexes 11869 activeIndex: 0, 11870 realIndex: 0, 11871 // 11872 isBeginning: true, 11873 isEnd: false, 11874 // Props 11875 translate: 0, 11876 previousTranslate: 0, 11877 progress: 0, 11878 velocity: 0, 11879 animating: false, 11880 // Locks 11881 allowSlideNext: swiper.params.allowSlideNext, 11882 allowSlidePrev: swiper.params.allowSlidePrev, 11883 // Touch Events 11884 touchEvents: function touchEvents() { 11885 const touch = ['touchstart', 'touchmove', 'touchend', 'touchcancel']; 11886 const desktop = ['pointerdown', 'pointermove', 'pointerup']; 11887 swiper.touchEventsTouch = { 11888 start: touch[0], 11889 move: touch[1], 11890 end: touch[2], 11891 cancel: touch[3] 11892 }; 11893 swiper.touchEventsDesktop = { 11894 start: desktop[0], 11895 move: desktop[1], 11896 end: desktop[2] 11897 }; 11898 return swiper.support.touch || !swiper.params.simulateTouch ? swiper.touchEventsTouch : swiper.touchEventsDesktop; 11899 }(), 11900 touchEventsData: { 11901 isTouched: undefined, 11902 isMoved: undefined, 11903 allowTouchCallbacks: undefined, 11904 touchStartTime: undefined, 11905 isScrolling: undefined, 11906 currentTranslate: undefined, 11907 startTranslate: undefined, 11908 allowThresholdMove: undefined, 11909 // Form elements to match 11910 focusableElements: swiper.params.focusableElements, 11911 // Last click time 11912 lastClickTime: now(), 11913 clickTimeout: undefined, 11914 // Velocities 11915 velocities: [], 11916 allowMomentumBounce: undefined, 11917 isTouchEvent: undefined, 11918 startMoving: undefined 11919 }, 11920 // Clicks 11921 allowClick: true, 11922 // Touches 11923 allowTouchMove: swiper.params.allowTouchMove, 11924 touches: { 11925 startX: 0, 11926 startY: 0, 11927 currentX: 0, 11928 currentY: 0, 11929 diff: 0 11930 }, 11931 // Images 11932 imagesToLoad: [], 11933 imagesLoaded: 0 11934 }); 11935 swiper.emit('_swiper'); // Init 11936 11937 if (swiper.params.init) { 11938 swiper.init(); 11939 } // Return app instance 11940 // eslint-disable-next-line no-constructor-return 11941 11942 11943 return swiper; 11944 } 11945 11946 enable() { 11947 const swiper = this; 11948 if (swiper.enabled) return; 11949 swiper.enabled = true; 11950 11951 if (swiper.params.grabCursor) { 11952 swiper.setGrabCursor(); 11953 } 11954 11955 swiper.emit('enable'); 11956 } 11957 11958 disable() { 11959 const swiper = this; 11960 if (!swiper.enabled) return; 11961 swiper.enabled = false; 11962 11963 if (swiper.params.grabCursor) { 11964 swiper.unsetGrabCursor(); 11965 } 11966 11967 swiper.emit('disable'); 11968 } 11969 11970 setProgress(progress, speed) { 11971 const swiper = this; 11972 progress = Math.min(Math.max(progress, 0), 1); 11973 const min = swiper.minTranslate(); 11974 const max = swiper.maxTranslate(); 11975 const current = (max - min) * progress + min; 11976 swiper.translateTo(current, typeof speed === 'undefined' ? 0 : speed); 11977 swiper.updateActiveIndex(); 11978 swiper.updateSlidesClasses(); 11979 } 11980 11981 emitContainerClasses() { 11982 const swiper = this; 11983 if (!swiper.params._emitClasses || !swiper.el) return; 11984 const cls = swiper.el.className.split(' ').filter(className => { 11985 return className.indexOf('swiper') === 0 || className.indexOf(swiper.params.containerModifierClass) === 0; 11986 }); 11987 swiper.emit('_containerClasses', cls.join(' ')); 11988 } 11989
vendor: 10,256 bytes, lines 11990-12335
11990 getSlideClasses(slideEl) { 11991 const swiper = this; 11992 if (swiper.destroyed) return ''; 11993 return slideEl.className.split(' ').filter(className => { 11994 return className.indexOf('swiper-slide') === 0 || className.indexOf(swiper.params.slideClass) === 0; 11995 }).join(' '); 11996 } 11997 11998 emitSlidesClasses() { 11999 const swiper = this; 12000 if (!swiper.params._emitClasses || !swiper.el) return; 12001 const updates = []; 12002 swiper.slides.each(slideEl => { 12003 const classNames = swiper.getSlideClasses(slideEl); 12004 updates.push({ 12005 slideEl, 12006 classNames 12007 }); 12008 swiper.emit('_slideClass', slideEl, classNames); 12009 }); 12010 swiper.emit('_slideClasses', updates); 12011 } 12012 12013 slidesPerViewDynamic(view, exact) { 12014 if (view === void 0) { 12015 view = 'current'; 12016 } 12017 12018 if (exact === void 0) { 12019 exact = false; 12020 } 12021 12022 const swiper = this; 12023 const { 12024 params, 12025 slides, 12026 slidesGrid, 12027 slidesSizesGrid, 12028 size: swiperSize, 12029 activeIndex 12030 } = swiper; 12031 let spv = 1; 12032 12033 if (params.centeredSlides) { 12034 let slideSize = slides[activeIndex].swiperSlideSize; 12035 let breakLoop; 12036 12037 for (let i = activeIndex + 1; i < slides.length; i += 1) { 12038 if (slides[i] && !breakLoop) { 12039 slideSize += slides[i].swiperSlideSize; 12040 spv += 1; 12041 if (slideSize > swiperSize) breakLoop = true; 12042 } 12043 } 12044 12045 for (let i = activeIndex - 1; i >= 0; i -= 1) { 12046 if (slides[i] && !breakLoop) { 12047 slideSize += slides[i].swiperSlideSize; 12048 spv += 1; 12049 if (slideSize > swiperSize) breakLoop = true; 12050 } 12051 } 12052 } else { 12053 // eslint-disable-next-line 12054 if (view === 'current') { 12055 for (let i = activeIndex + 1; i < slides.length; i += 1) { 12056 const slideInView = exact ? slidesGrid[i] + slidesSizesGrid[i] - slidesGrid[activeIndex] < swiperSize : slidesGrid[i] - slidesGrid[activeIndex] < swiperSize; 12057 12058 if (slideInView) { 12059 spv += 1; 12060 } 12061 } 12062 } else { 12063 // previous 12064 for (let i = activeIndex - 1; i >= 0; i -= 1) { 12065 const slideInView = slidesGrid[activeIndex] - slidesGrid[i] < swiperSize; 12066 12067 if (slideInView) { 12068 spv += 1; 12069 } 12070 } 12071 } 12072 } 12073 12074 return spv; 12075 } 12076 12077 update() { 12078 const swiper = this; 12079 if (!swiper || swiper.destroyed) return; 12080 const { 12081 snapGrid, 12082 params 12083 } = swiper; // Breakpoints 12084 12085 if (params.breakpoints) { 12086 swiper.setBreakpoint(); 12087 } 12088 12089 swiper.updateSize(); 12090 swiper.updateSlides(); 12091 swiper.updateProgress(); 12092 swiper.updateSlidesClasses(); 12093 12094 function setTranslate() { 12095 const translateValue = swiper.rtlTranslate ? swiper.translate * -1 : swiper.translate; 12096 const newTranslate = Math.min(Math.max(translateValue, swiper.maxTranslate()), swiper.minTranslate()); 12097 swiper.setTranslate(newTranslate); 12098 swiper.updateActiveIndex(); 12099 swiper.updateSlidesClasses(); 12100 } 12101 12102 let translated; 12103 12104 if (swiper.params.freeMode && swiper.params.freeMode.enabled) { 12105 setTranslate(); 12106 12107 if (swiper.params.autoHeight) { 12108 swiper.updateAutoHeight(); 12109 } 12110 } else { 12111 if ((swiper.params.slidesPerView === 'auto' || swiper.params.slidesPerView > 1) && swiper.isEnd && !swiper.params.centeredSlides) { 12112 translated = swiper.slideTo(swiper.slides.length - 1, 0, false, true); 12113 } else { 12114 translated = swiper.slideTo(swiper.activeIndex, 0, false, true); 12115 } 12116 12117 if (!translated) { 12118 setTranslate(); 12119 } 12120 } 12121 12122 if (params.watchOverflow && snapGrid !== swiper.snapGrid) { 12123 swiper.checkOverflow(); 12124 } 12125 12126 swiper.emit('update'); 12127 } 12128 12129 changeDirection(newDirection, needUpdate) { 12130 if (needUpdate === void 0) { 12131 needUpdate = true; 12132 } 12133 12134 const swiper = this; 12135 const currentDirection = swiper.params.direction; 12136 12137 if (!newDirection) { 12138 // eslint-disable-next-line 12139 newDirection = currentDirection === 'horizontal' ? 'vertical' : 'horizontal'; 12140 } 12141 12142 if (newDirection === currentDirection || newDirection !== 'horizontal' && newDirection !== 'vertical') { 12143 return swiper; 12144 } 12145 12146 swiper.$el.removeClass(`${swiper.params.containerModifierClass}${currentDirection}`).addClass(`${swiper.params.containerModifierClass}${newDirection}`); 12147 swiper.emitContainerClasses(); 12148 swiper.params.direction = newDirection; 12149 swiper.slides.each(slideEl => { 12150 if (newDirection === 'vertical') { 12151 slideEl.style.width = ''; 12152 } else { 12153 slideEl.style.height = ''; 12154 } 12155 }); 12156 swiper.emit('changeDirection'); 12157 if (needUpdate) swiper.update(); 12158 return swiper; 12159 } 12160 12161 changeLanguageDirection(direction) { 12162 const swiper = this; 12163 if (swiper.rtl && direction === 'rtl' || !swiper.rtl && direction === 'ltr') return; 12164 swiper.rtl = direction === 'rtl'; 12165 swiper.rtlTranslate = swiper.params.direction === 'horizontal' && swiper.rtl; 12166 12167 if (swiper.rtl) { 12168 swiper.$el.addClass(`${swiper.params.containerModifierClass}rtl`); 12169 swiper.el.dir = 'rtl'; 12170 } else { 12171 swiper.$el.removeClass(`${swiper.params.containerModifierClass}rtl`); 12172 swiper.el.dir = 'ltr'; 12173 } 12174 12175 swiper.update(); 12176 } 12177 12178 mount(el) { 12179 const swiper = this; 12180 if (swiper.mounted) return true; // Find el 12181 12182 const $el = $(el || swiper.params.el); 12183 el = $el[0]; 12184 12185 if (!el) { 12186 return false; 12187 } 12188 12189 el.swiper = swiper; 12190 12191 const getWrapperSelector = () => { 12192 return `.${(swiper.params.wrapperClass || '').trim().split(' ').join('.')}`; 12193 }; 12194 12195 const getWrapper = () => { 12196 if (el && el.shadowRoot && el.shadowRoot.querySelector) { 12197 const res = $(el.shadowRoot.querySelector(getWrapperSelector())); // Children needs to return slot items 12198 12199 res.children = options => $el.children(options); 12200 12201 return res; 12202 } 12203 12204 if (!$el.children) { 12205 return $($el).children(getWrapperSelector()); 12206 } 12207 12208 return $el.children(getWrapperSelector()); 12209 }; // Find Wrapper 12210 12211 12212 let $wrapperEl = getWrapper(); 12213 12214 if ($wrapperEl.length === 0 && swiper.params.createElements) { 12215 const document = getDocument(); 12216 const wrapper = document.createElement('div'); 12217 $wrapperEl = $(wrapper); 12218 wrapper.className = swiper.params.wrapperClass; 12219 $el.append(wrapper); 12220 $el.children(`.${swiper.params.slideClass}`).each(slideEl => { 12221 $wrapperEl.append(slideEl); 12222 }); 12223 } 12224 12225 Object.assign(swiper, { 12226 $el, 12227 el, 12228 $wrapperEl, 12229 wrapperEl: $wrapperEl[0], 12230 mounted: true, 12231 // RTL 12232 rtl: el.dir.toLowerCase() === 'rtl' || $el.css('direction') === 'rtl', 12233 rtlTranslate: swiper.params.direction === 'horizontal' && (el.dir.toLowerCase() === 'rtl' || $el.css('direction') === 'rtl'), 12234 wrongRTL: $wrapperEl.css('display') === '-webkit-box' 12235 }); 12236 return true; 12237 } 12238 12239 init(el) { 12240 const swiper = this; 12241 if (swiper.initialized) return swiper; 12242 const mounted = swiper.mount(el); 12243 if (mounted === false) return swiper; 12244 swiper.emit('beforeInit'); // Set breakpoint 12245 12246 if (swiper.params.breakpoints) { 12247 swiper.setBreakpoint(); 12248 } // Add Classes 12249 12250 12251 swiper.addClasses(); // Create loop 12252 12253 if (swiper.params.loop) { 12254 swiper.loopCreate(); 12255 } // Update size 12256 12257 12258 swiper.updateSize(); // Update slides 12259 12260 swiper.updateSlides(); 12261 12262 if (swiper.params.watchOverflow) { 12263 swiper.checkOverflow(); 12264 } // Set Grab Cursor 12265 12266 12267 if (swiper.params.grabCursor && swiper.enabled) { 12268 swiper.setGrabCursor(); 12269 } 12270 12271 if (swiper.params.preloadImages) { 12272 swiper.preloadImages(); 12273 } // Slide To Initial Slide 12274 12275 12276 if (swiper.params.loop) { 12277 swiper.slideTo(swiper.params.initialSlide + swiper.loopedSlides, 0, swiper.params.runCallbacksOnInit, false, true); 12278 } else { 12279 swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit, false, true); 12280 } // Attach events 12281 12282 12283 swiper.attachEvents(); // Init Flag 12284 12285 swiper.initialized = true; // Emit 12286 12287 swiper.emit('init'); 12288 swiper.emit('afterInit'); 12289 return swiper; 12290 } 12291 12292 destroy(deleteInstance, cleanStyles) { 12293 if (deleteInstance === void 0) { 12294 deleteInstance = true; 12295 } 12296 12297 if (cleanStyles === void 0) { 12298 cleanStyles = true; 12299 } 12300 12301 const swiper = this; 12302 const { 12303 params, 12304 $el, 12305 $wrapperEl, 12306 slides 12307 } = swiper; 12308 12309 if (typeof swiper.params === 'undefined' || swiper.destroyed) { 12310 return null; 12311 } 12312 12313 swiper.emit('beforeDestroy'); // Init Flag 12314 12315 swiper.initialized = false; // Detach events 12316 12317 swiper.detachEvents(); // Destroy loop 12318 12319 if (params.loop) { 12320 swiper.loopDestroy(); 12321 } // Cleanup styles 12322 12323 12324 if (cleanStyles) { 12325 swiper.removeClasses(); 12326 $el.removeAttr('style'); 12327 $wrapperEl.removeAttr('style'); 12328 12329 if (slides && slides.length) { 12330 slides.removeClass([params.slideVisibleClass, params.slideActiveClass, params.slideNextClass, params.slidePrevClass].join(' ')).removeAttr('style').removeAttr('data-swiper-slide-index'); 12331 } 12332 } 12333 12334 swiper.emit('destroy'); // Detach emitter events 12335
12336 Object.keys(swiper.eventsListeners).forEach(eventName => { 12337 swiper.off(eventName); 12338 }); 12339 12340 if (deleteInstance !== false) { 12341 swiper.$el[0].swiper = null; 12342 deleteProps(swiper); 12343 } 12344 12345 swiper.destroyed = true; 12346 return null; 12347 } 12348 12349 static extendDefaults(newDefaults) { 12350 extend(extendedDefaults, newDefaults); 12351 } 12352 12353 static get extendedDefaults() { 12354 return extendedDefaults; 12355 } 12356 12357 static get defaults() { 12358 return defaults; 12359 } 12360 12361 static installModule(mod) { 12362 if (!Swiper.prototype.__modules__) Swiper.prototype.__modules__ = []; 12363 const modules = Swiper.prototype.__modules__; 12364 12365 if (typeof mod === 'function' && modules.indexOf(mod) < 0) { 12366 modules.push(mod); 12367 } 12368 } 12369 12370 static use(module) { 12371 if (Array.isArray(module)) { 12372 module.forEach(m => Swiper.installModule(m)); 12373 return Swiper; 12374 } 12375 12376 Swiper.installModule(module); 12377 return Swiper; 12378 } 12379 12380 } 12381 12382 Object.keys(prototypes).forEach(prototypeGroup => { 12383 Object.keys(prototypes[prototypeGroup]).forEach(protoMethod => { 12384 Swiper.prototype[protoMethod] = prototypes[prototypeGroup][protoMethod]; 12385 }); 12386 }); 12387 Swiper.use([Resize, Observer]); 12388 12389 function Virtual(_ref) { 12390 let { 12391 swiper, 12392 extendParams, 12393 on, 12394 emit 12395 } = _ref; 12396 extendParams({ 12397 virtual: { 12398 enabled: false, 12399 slides: [], 12400 cache: true, 12401 renderSlide: null, 12402 renderExternal: null, 12403 renderExternalUpdate: true, 12404 addSlidesBefore: 0, 12405 addSlidesAfter: 0 12406 } 12407 }); 12408 let cssModeTimeout; 12409 swiper.virtual = { 12410 cache: {}, 12411 from: undefined, 12412 to: undefined, 12413 slides: [], 12414 offset: 0, 12415 slidesGrid: [] 12416 }; 12417
12418 function renderSlide(slide, index) { 12419 const params = swiper.params.virtual; 12420 12421 if (params.cache && swiper.virtual.cache[index]) { 12422 return swiper.virtual.cache[index]; 12423 } 12424 12425 const $slideEl = params.renderSlide ? $(params.renderSlide.call(swiper, slide, index)) : $(`<div class="${swiper.params.slideClass}" data-swiper-slide-index="${index}">${slide}</div>`); 12426 if (!$slideEl.attr('data-swiper-slide-index')) $slideEl.attr('data-swiper-slide-index', index); 12427 if (params.cache) swiper.virtual.cache[index] = $slideEl; 12428 return $slideEl; 12429 } 12430 12431 function update(force) { 12432 const { 12433 slidesPerView, 12434 slidesPerGroup, 12435 centeredSlides 12436 } = swiper.params; 12437 const { 12438 addSlidesBefore, 12439 addSlidesAfter 12440 } = swiper.params.virtual; 12441 const { 12442 from: previousFrom, 12443 to: previousTo, 12444 slides, 12445 slidesGrid: previousSlidesGrid, 12446 offset: previousOffset 12447 } = swiper.virtual; 12448 12449 if (!swiper.params.cssMode) { 12450 swiper.updateActiveIndex(); 12451 } 12452 12453 const activeIndex = swiper.activeIndex || 0; 12454 let offsetProp; 12455 if (swiper.rtlTranslate) offsetProp = 'right';else offsetProp = swiper.isHorizontal() ? 'left' : 'top'; 12456 let slidesAfter; 12457 let slidesBefore; 12458 12459 if (centeredSlides) { 12460 slidesAfter = Math.floor(slidesPerView / 2) + slidesPerGroup + addSlidesAfter; 12461 slidesBefore = Math.floor(slidesPerView / 2) + slidesPerGroup + addSlidesBefore; 12462 } else { 12463 slidesAfter = slidesPerView + (slidesPerGroup - 1) + addSlidesAfter; 12464 slidesBefore = slidesPerGroup + addSlidesBefore; 12465 } 12466 12467 const from = Math.max((activeIndex || 0) - slidesBefore, 0); 12468 const to = Math.min((activeIndex || 0) + slidesAfter, slides.length - 1); 12469 const offset = (swiper.slidesGrid[from] || 0) - (swiper.slidesGrid[0] || 0); 12470 Object.assign(swiper.virtual, { 12471 from, 12472 to, 12473 offset, 12474 slidesGrid: swiper.slidesGrid 12475 }); 12476 12477 function onRendered() { 12478 swiper.updateSlides(); 12479 swiper.updateProgress(); 12480 swiper.updateSlidesClasses(); 12481 12482 if (swiper.lazy && swiper.params.lazy.enabled) { 12483 swiper.lazy.load(); 12484 } 12485 12486 emit('virtualUpdate'); 12487 } 12488 12489 if (previousFrom === from && previousTo === to && !force) { 12490 if (swiper.slidesGrid !== previousSlidesGrid && offset !== previousOffset) { 12491 swiper.slides.css(offsetProp, `${offset}px`); 12492 } 12493 12494 swiper.updateProgress(); 12495 emit('virtualUpdate'); 12496 return; 12497 } 12498 12499 if (swiper.params.virtual.renderExternal) { 12500 swiper.params.virtual.renderExternal.call(swiper, { 12501 offset, 12502 from, 12503 to, 12504 slides: function getSlides() { 12505 const slidesToRender = []; 12506 12507 for (let i = from; i <= to; i += 1) { 12508 slidesToRender.push(slides[i]); 12509 } 12510 12511 return slidesToRender; 12512 }() 12513 }); 12514 12515 if (swiper.params.virtual.renderExternalUpdate) { 12516 onRendered(); 12517 } else { 12518 emit('virtualUpdate'); 12519 } 12520 12521 return; 12522 } 12523 12524 const prependIndexes = []; 12525 const appendIndexes = []; 12526 12527 if (force) { 12528 swiper.$wrapperEl.find(`.${swiper.params.slideClass}`).remove(); 12529 } else { 12530 for (let i = previousFrom; i <= previousTo; i += 1) { 12531 if (i < from || i > to) { 12532 swiper.$wrapperEl.find(`.${swiper.params.slideClass}[data-swiper-slide-index="${i}"]`).remove(); 12533 } 12534 } 12535 } 12536 12537 for (let i = 0; i < slides.length; i += 1) { 12538 if (i >= from && i <= to) { 12539 if (typeof previousTo === 'undefined' || force) { 12540 appendIndexes.push(i); 12541 } else { 12542 if (i > previousTo) appendIndexes.push(i);
vendor: 5,052 bytes, lines 12543-12714
12543 if (i < previousFrom) prependIndexes.push(i); 12544 } 12545 } 12546 } 12547 12548 appendIndexes.forEach(index => { 12549 swiper.$wrapperEl.append(renderSlide(slides[index], index)); 12550 }); 12551 prependIndexes.sort((a, b) => b - a).forEach(index => { 12552 swiper.$wrapperEl.prepend(renderSlide(slides[index], index)); 12553 }); 12554 swiper.$wrapperEl.children('.swiper-slide').css(offsetProp, `${offset}px`); 12555 onRendered(); 12556 } 12557 12558 function appendSlide(slides) { 12559 if (typeof slides === 'object' && 'length' in slides) { 12560 for (let i = 0; i < slides.length; i += 1) { 12561 if (slides[i]) swiper.virtual.slides.push(slides[i]); 12562 } 12563 } else { 12564 swiper.virtual.slides.push(slides); 12565 } 12566 12567 update(true); 12568 } 12569 12570 function prependSlide(slides) { 12571 const activeIndex = swiper.activeIndex; 12572 let newActiveIndex = activeIndex + 1; 12573 let numberOfNewSlides = 1; 12574 12575 if (Array.isArray(slides)) { 12576 for (let i = 0; i < slides.length; i += 1) { 12577 if (slides[i]) swiper.virtual.slides.unshift(slides[i]); 12578 } 12579 12580 newActiveIndex = activeIndex + slides.length; 12581 numberOfNewSlides = slides.length; 12582 } else { 12583 swiper.virtual.slides.unshift(slides); 12584 } 12585 12586 if (swiper.params.virtual.cache) { 12587 const cache = swiper.virtual.cache; 12588 const newCache = {}; 12589 Object.keys(cache).forEach(cachedIndex => { 12590 const $cachedEl = cache[cachedIndex]; 12591 const cachedElIndex = $cachedEl.attr('data-swiper-slide-index'); 12592 12593 if (cachedElIndex) { 12594 $cachedEl.attr('data-swiper-slide-index', parseInt(cachedElIndex, 10) + numberOfNewSlides); 12595 } 12596 12597 newCache[parseInt(cachedIndex, 10) + numberOfNewSlides] = $cachedEl; 12598 }); 12599 swiper.virtual.cache = newCache; 12600 } 12601 12602 update(true); 12603 swiper.slideTo(newActiveIndex, 0); 12604 } 12605 12606 function removeSlide(slidesIndexes) { 12607 if (typeof slidesIndexes === 'undefined' || slidesIndexes === null) return; 12608 let activeIndex = swiper.activeIndex; 12609 12610 if (Array.isArray(slidesIndexes)) { 12611 for (let i = slidesIndexes.length - 1; i >= 0; i -= 1) { 12612 swiper.virtual.slides.splice(slidesIndexes[i], 1); 12613 12614 if (swiper.params.virtual.cache) { 12615 delete swiper.virtual.cache[slidesIndexes[i]]; 12616 } 12617 12618 if (slidesIndexes[i] < activeIndex) activeIndex -= 1; 12619 activeIndex = Math.max(activeIndex, 0); 12620 } 12621 } else { 12622 swiper.virtual.slides.splice(slidesIndexes, 1); 12623 12624 if (swiper.params.virtual.cache) { 12625 delete swiper.virtual.cache[slidesIndexes]; 12626 } 12627 12628 if (slidesIndexes < activeIndex) activeIndex -= 1; 12629 activeIndex = Math.max(activeIndex, 0); 12630 } 12631 12632 update(true); 12633 swiper.slideTo(activeIndex, 0); 12634 } 12635 12636 function removeAllSlides() { 12637 swiper.virtual.slides = []; 12638 12639 if (swiper.params.virtual.cache) { 12640 swiper.virtual.cache = {}; 12641 } 12642 12643 update(true); 12644 swiper.slideTo(0, 0); 12645 } 12646 12647 on('beforeInit', () => { 12648 if (!swiper.params.virtual.enabled) return; 12649 swiper.virtual.slides = swiper.params.virtual.slides; 12650 swiper.classNames.push(`${swiper.params.containerModifierClass}virtual`); 12651 swiper.params.watchSlidesProgress = true; 12652 swiper.originalParams.watchSlidesProgress = true; 12653 12654 if (!swiper.params.initialSlide) { 12655 update(); 12656 } 12657 }); 12658 on('setTranslate', () => { 12659 if (!swiper.params.virtual.enabled) return; 12660 12661 if (swiper.params.cssMode && !swiper._immediateVirtual) { 12662 clearTimeout(cssModeTimeout); 12663 cssModeTimeout = setTimeout(() => { 12664 update(); 12665 }, 100); 12666 } else { 12667 update(); 12668 } 12669 }); 12670 on('init update resize', () => { 12671 if (!swiper.params.virtual.enabled) return; 12672 12673 if (swiper.params.cssMode) { 12674 setCSSProperty(swiper.wrapperEl, '--swiper-virtual-size', `${swiper.virtualSize}px`); 12675 } 12676 }); 12677 Object.assign(swiper.virtual, { 12678 appendSlide, 12679 prependSlide, 12680 removeSlide, 12681 removeAllSlides, 12682 update 12683 }); 12684 } 12685 12686 /* eslint-disable consistent-return */ 12687 function Keyboard(_ref) { 12688 let { 12689 swiper, 12690 extendParams, 12691 on, 12692 emit 12693 } = _ref; 12694 const document = getDocument(); 12695 const window = getWindow(); 12696 swiper.keyboard = { 12697 enabled: false 12698 }; 12699 extendParams({ 12700 keyboard: { 12701 enabled: false, 12702 onlyInViewport: true, 12703 pageUpDown: true 12704 } 12705 }); 12706 12707 function handle(event) { 12708 if (!swiper.enabled) return; 12709 const { 12710 rtlTranslate: rtl 12711 } = swiper; 12712 let e = event; 12713 if (e.originalEvent) e = e.originalEvent; // jquery fix 12714
vendor: 4,245 bytes, lines 12715-12830
12715 const kc = e.keyCode || e.charCode; 12716 const pageUpDown = swiper.params.keyboard.pageUpDown; 12717 const isPageUp = pageUpDown && kc === 33; 12718 const isPageDown = pageUpDown && kc === 34; 12719 const isArrowLeft = kc === 37; 12720 const isArrowRight = kc === 39; 12721 const isArrowUp = kc === 38; 12722 const isArrowDown = kc === 40; // Directions locks 12723 12724 if (!swiper.allowSlideNext && (swiper.isHorizontal() && isArrowRight || swiper.isVertical() && isArrowDown || isPageDown)) { 12725 return false; 12726 } 12727 12728 if (!swiper.allowSlidePrev && (swiper.isHorizontal() && isArrowLeft || swiper.isVertical() && isArrowUp || isPageUp)) { 12729 return false; 12730 } 12731 12732 if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey) { 12733 return undefined; 12734 } 12735 12736 if (document.activeElement && document.activeElement.nodeName && (document.activeElement.nodeName.toLowerCase() === 'input' || document.activeElement.nodeName.toLowerCase() === 'textarea')) { 12737 return undefined; 12738 } 12739 12740 if (swiper.params.keyboard.onlyInViewport && (isPageUp || isPageDown || isArrowLeft || isArrowRight || isArrowUp || isArrowDown)) { 12741 let inView = false; // Check that swiper should be inside of visible area of window 12742 12743 if (swiper.$el.parents(`.${swiper.params.slideClass}`).length > 0 && swiper.$el.parents(`.${swiper.params.slideActiveClass}`).length === 0) { 12744 return undefined; 12745 } 12746 12747 const $el = swiper.$el; 12748 const swiperWidth = $el[0].clientWidth; 12749 const swiperHeight = $el[0].clientHeight; 12750 const windowWidth = window.innerWidth; 12751 const windowHeight = window.innerHeight; 12752 const swiperOffset = swiper.$el.offset(); 12753 if (rtl) swiperOffset.left -= swiper.$el[0].scrollLeft; 12754 const swiperCoord = [[swiperOffset.left, swiperOffset.top], [swiperOffset.left + swiperWidth, swiperOffset.top], [swiperOffset.left, swiperOffset.top + swiperHeight], [swiperOffset.left + swiperWidth, swiperOffset.top + swiperHeight]]; 12755 12756 for (let i = 0; i < swiperCoord.length; i += 1) { 12757 const point = swiperCoord[i]; 12758 12759 if (point[0] >= 0 && point[0] <= windowWidth && point[1] >= 0 && point[1] <= windowHeight) { 12760 if (point[0] === 0 && point[1] === 0) continue; // eslint-disable-line 12761 12762 inView = true; 12763 } 12764 } 12765 12766 if (!inView) return undefined; 12767 } 12768 12769 if (swiper.isHorizontal()) { 12770 if (isPageUp || isPageDown || isArrowLeft || isArrowRight) { 12771 if (e.preventDefault) e.preventDefault();else e.returnValue = false; 12772 } 12773 12774 if ((isPageDown || isArrowRight) && !rtl || (isPageUp || isArrowLeft) && rtl) swiper.slideNext(); 12775 if ((isPageUp || isArrowLeft) && !rtl || (isPageDown || isArrowRight) && rtl) swiper.slidePrev(); 12776 } else { 12777 if (isPageUp || isPageDown || isArrowUp || isArrowDown) { 12778 if (e.preventDefault) e.preventDefault();else e.returnValue = false; 12779 } 12780 12781 if (isPageDown || isArrowDown) swiper.slideNext(); 12782 if (isPageUp || isArrowUp) swiper.slidePrev(); 12783 } 12784 12785 emit('keyPress', kc); 12786 return undefined; 12787 } 12788 12789 function enable() { 12790 if (swiper.keyboard.enabled) return; 12791 $(document).on('keydown', handle); 12792 swiper.keyboard.enabled = true; 12793 } 12794 12795 function disable() { 12796 if (!swiper.keyboard.enabled) return; 12797 $(document).off('keydown', handle); 12798 swiper.keyboard.enabled = false; 12799 } 12800 12801 on('init', () => { 12802 if (swiper.params.keyboard.enabled) { 12803 enable(); 12804 } 12805 }); 12806 on('destroy', () => { 12807 if (swiper.keyboard.enabled) { 12808 disable(); 12809 } 12810 }); 12811 Object.assign(swiper.keyboard, { 12812 enable, 12813 disable 12814 }); 12815 } 12816 12817 /* eslint-disable consistent-return */ 12818 function Mousewheel(_ref) { 12819 let { 12820 swiper, 12821 extendParams, 12822 on, 12823 emit 12824 } = _ref; 12825 const window = getWindow(); 12826 extendParams({ 12827 mousewheel: { 12828 enabled: false, 12829 releaseOnEdges: false, 12830 invert: false,
vendor: 14,262 bytes, lines 12831-13200
12831 forceToAxis: false, 12832 sensitivity: 1, 12833 eventsTarget: 'container', 12834 thresholdDelta: null, 12835 thresholdTime: null 12836 } 12837 }); 12838 swiper.mousewheel = { 12839 enabled: false 12840 }; 12841 let timeout; 12842 let lastScrollTime = now(); 12843 let lastEventBeforeSnap; 12844 const recentWheelEvents = []; 12845 12846 function normalize(e) { 12847 // Reasonable defaults 12848 const PIXEL_STEP = 10; 12849 const LINE_HEIGHT = 40; 12850 const PAGE_HEIGHT = 800; 12851 let sX = 0; 12852 let sY = 0; // spinX, spinY 12853 12854 let pX = 0; 12855 let pY = 0; // pixelX, pixelY 12856 // Legacy 12857 12858 if ('detail' in e) { 12859 sY = e.detail; 12860 } 12861 12862 if ('wheelDelta' in e) { 12863 sY = -e.wheelDelta / 120; 12864 } 12865 12866 if ('wheelDeltaY' in e) { 12867 sY = -e.wheelDeltaY / 120; 12868 } 12869 12870 if ('wheelDeltaX' in e) { 12871 sX = -e.wheelDeltaX / 120; 12872 } // side scrolling on FF with DOMMouseScroll 12873 12874 12875 if ('axis' in e && e.axis === e.HORIZONTAL_AXIS) { 12876 sX = sY; 12877 sY = 0; 12878 } 12879 12880 pX = sX * PIXEL_STEP; 12881 pY = sY * PIXEL_STEP; 12882 12883 if ('deltaY' in e) { 12884 pY = e.deltaY; 12885 } 12886 12887 if ('deltaX' in e) { 12888 pX = e.deltaX; 12889 } 12890 12891 if (e.shiftKey && !pX) { 12892 // if user scrolls with shift he wants horizontal scroll 12893 pX = pY; 12894 pY = 0; 12895 } 12896 12897 if ((pX || pY) && e.deltaMode) { 12898 if (e.deltaMode === 1) { 12899 // delta in LINE units 12900 pX *= LINE_HEIGHT; 12901 pY *= LINE_HEIGHT; 12902 } else { 12903 // delta in PAGE units 12904 pX *= PAGE_HEIGHT; 12905 pY *= PAGE_HEIGHT; 12906 } 12907 } // Fall-back if spin cannot be determined 12908 12909 12910 if (pX && !sX) { 12911 sX = pX < 1 ? -1 : 1; 12912 } 12913 12914 if (pY && !sY) { 12915 sY = pY < 1 ? -1 : 1; 12916 } 12917 12918 return { 12919 spinX: sX, 12920 spinY: sY, 12921 pixelX: pX, 12922 pixelY: pY 12923 }; 12924 } 12925 12926 function handleMouseEnter() { 12927 if (!swiper.enabled) return; 12928 swiper.mouseEntered = true; 12929 } 12930 12931 function handleMouseLeave() { 12932 if (!swiper.enabled) return; 12933 swiper.mouseEntered = false; 12934 } 12935 12936 function animateSlider(newEvent) { 12937 if (swiper.params.mousewheel.thresholdDelta && newEvent.delta < swiper.params.mousewheel.thresholdDelta) { 12938 // Prevent if delta of wheel scroll delta is below configured threshold 12939 return false; 12940 } 12941 12942 if (swiper.params.mousewheel.thresholdTime && now() - lastScrollTime < swiper.params.mousewheel.thresholdTime) { 12943 // Prevent if time between scrolls is below configured threshold 12944 return false; 12945 } // If the movement is NOT big enough and 12946 // if the last time the user scrolled was too close to the current one (avoid continuously triggering the slider): 12947 // Don't go any further (avoid insignificant scroll movement). 12948 12949 12950 if (newEvent.delta >= 6 && now() - lastScrollTime < 60) { 12951 // Return false as a default 12952 return true; 12953 } // If user is scrolling towards the end: 12954 // If the slider hasn't hit the latest slide or 12955 // if the slider is a loop and 12956 // if the slider isn't moving right now: 12957 // Go to next slide and 12958 // emit a scroll event. 12959 // Else (the user is scrolling towards the beginning) and 12960 // if the slider hasn't hit the first slide or 12961 // if the slider is a loop and 12962 // if the slider isn't moving right now: 12963 // Go to prev slide and 12964 // emit a scroll event. 12965 12966 12967 if (newEvent.direction < 0) { 12968 if ((!swiper.isEnd || swiper.params.loop) && !swiper.animating) { 12969 swiper.slideNext(); 12970 emit('scroll', newEvent.raw); 12971 } 12972 } else if ((!swiper.isBeginning || swiper.params.loop) && !swiper.animating) { 12973 swiper.slidePrev(); 12974 emit('scroll', newEvent.raw); 12975 } // If you got here is because an animation has been triggered so store the current time 12976 12977 12978 lastScrollTime = new window.Date().getTime(); // Return false as a default 12979 12980 return false; 12981 } 12982 12983 function releaseScroll(newEvent) { 12984 const params = swiper.params.mousewheel; 12985 12986 if (newEvent.direction < 0) { 12987 if (swiper.isEnd && !swiper.params.loop && params.releaseOnEdges) { 12988 // Return true to animate scroll on edges 12989 return true; 12990 } 12991 } else if (swiper.isBeginning && !swiper.params.loop && params.releaseOnEdges) { 12992 // Return true to animate scroll on edges 12993 return true; 12994 } 12995 12996 return false; 12997 } 12998 12999 function handle(event) { 13000 let e = event; 13001 let disableParentSwiper = true; 13002 if (!swiper.enabled) return; 13003 const params = swiper.params.mousewheel; 13004 13005 if (swiper.params.cssMode) { 13006 e.preventDefault(); 13007 } 13008 13009 let target = swiper.$el; 13010 13011 if (swiper.params.mousewheel.eventsTarget !== 'container') { 13012 target = $(swiper.params.mousewheel.eventsTarget); 13013 } 13014 13015 if (!swiper.mouseEntered && !target[0].contains(e.target) && !params.releaseOnEdges) return true; 13016 if (e.originalEvent) e = e.originalEvent; // jquery fix 13017 13018 let delta = 0; 13019 const rtlFactor = swiper.rtlTranslate ? -1 : 1; 13020 const data = normalize(e); 13021 13022 if (params.forceToAxis) { 13023 if (swiper.isHorizontal()) { 13024 if (Math.abs(data.pixelX) > Math.abs(data.pixelY)) delta = -data.pixelX * rtlFactor;else return true; 13025 } else if (Math.abs(data.pixelY) > Math.abs(data.pixelX)) delta = -data.pixelY;else return true; 13026 } else { 13027 delta = Math.abs(data.pixelX) > Math.abs(data.pixelY) ? -data.pixelX * rtlFactor : -data.pixelY; 13028 } 13029 13030 if (delta === 0) return true; 13031 if (params.invert) delta = -delta; // Get the scroll positions 13032 13033 let positions = swiper.getTranslate() + delta * params.sensitivity; 13034 if (positions >= swiper.minTranslate()) positions = swiper.minTranslate(); 13035 if (positions <= swiper.maxTranslate()) positions = swiper.maxTranslate(); // When loop is true: 13036 // the disableParentSwiper will be true. 13037 // When loop is false: 13038 // if the scroll positions is not on edge, 13039 // then the disableParentSwiper will be true. 13040 // if the scroll on edge positions, 13041 // then the disableParentSwiper will be false. 13042 13043 disableParentSwiper = swiper.params.loop ? true : !(positions === swiper.minTranslate() || positions === swiper.maxTranslate()); 13044 if (disableParentSwiper && swiper.params.nested) e.stopPropagation(); 13045 13046 if (!swiper.params.freeMode || !swiper.params.freeMode.enabled) { 13047 // Register the new event in a variable which stores the relevant data 13048 const newEvent = { 13049 time: now(), 13050 delta: Math.abs(delta), 13051 direction: Math.sign(delta), 13052 raw: event 13053 }; // Keep the most recent events 13054 13055 if (recentWheelEvents.length >= 2) { 13056 recentWheelEvents.shift(); // only store the last N events 13057 } 13058 13059 const prevEvent = recentWheelEvents.length ? recentWheelEvents[recentWheelEvents.length - 1] : undefined; 13060 recentWheelEvents.push(newEvent); // If there is at least one previous recorded event: 13061 // If direction has changed or 13062 // if the scroll is quicker than the previous one: 13063 // Animate the slider. 13064 // Else (this is the first time the wheel is moved): 13065 // Animate the slider. 13066 13067 if (prevEvent) { 13068 if (newEvent.direction !== prevEvent.direction || newEvent.delta > prevEvent.delta || newEvent.time > prevEvent.time + 150) { 13069 animateSlider(newEvent); 13070 } 13071 } else { 13072 animateSlider(newEvent); 13073 } // If it's time to release the scroll: 13074 // Return now so you don't hit the preventDefault. 13075 13076 13077 if (releaseScroll(newEvent)) { 13078 return true; 13079 } 13080 } else { 13081 // Freemode or scrollContainer: 13082 // If we recently snapped after a momentum scroll, then ignore wheel events 13083 // to give time for the deceleration to finish. Stop ignoring after 500 msecs 13084 // or if it's a new scroll (larger delta or inverse sign as last event before 13085 // an end-of-momentum snap). 13086 const newEvent = { 13087 time: now(), 13088 delta: Math.abs(delta), 13089 direction: Math.sign(delta) 13090 }; 13091 const ignoreWheelEvents = lastEventBeforeSnap && newEvent.time < lastEventBeforeSnap.time + 500 && newEvent.delta <= lastEventBeforeSnap.delta && newEvent.direction === lastEventBeforeSnap.direction; 13092 13093 if (!ignoreWheelEvents) { 13094 lastEventBeforeSnap = undefined; 13095 13096 if (swiper.params.loop) { 13097 swiper.loopFix(); 13098 } 13099 13100 let position = swiper.getTranslate() + delta * params.sensitivity; 13101 const wasBeginning = swiper.isBeginning; 13102 const wasEnd = swiper.isEnd; 13103 if (position >= swiper.minTranslate()) position = swiper.minTranslate(); 13104 if (position <= swiper.maxTranslate()) position = swiper.maxTranslate(); 13105 swiper.setTransition(0); 13106 swiper.setTranslate(position); 13107 swiper.updateProgress(); 13108 swiper.updateActiveIndex(); 13109 swiper.updateSlidesClasses(); 13110 13111 if (!wasBeginning && swiper.isBeginning || !wasEnd && swiper.isEnd) { 13112 swiper.updateSlidesClasses(); 13113 } 13114 13115 if (swiper.params.freeMode.sticky) { 13116 // When wheel scrolling starts with sticky (aka snap) enabled, then detect 13117 // the end of a momentum scroll by storing recent (N=15?) wheel events. 13118 // 1. do all N events have decreasing or same (absolute value) delta? 13119 // 2. did all N events arrive in the last M (M=500?) msecs? 13120 // 3. does the earliest event have an (absolute value) delta that's 13121 // at least P (P=1?) larger than the most recent event's delta? 13122 // 4. does the latest event have a delta that's smaller than Q (Q=6?) pixels? 13123 // If 1-4 are "yes" then we're near the end of a momentum scroll deceleration. 13124 // Snap immediately and ignore remaining wheel events in this scroll. 13125 // See comment above for "remaining wheel events in this scroll" determination. 13126 // If 1-4 aren't satisfied, then wait to snap until 500ms after the last event. 13127 clearTimeout(timeout); 13128 timeout = undefined; 13129 13130 if (recentWheelEvents.length >= 15) { 13131 recentWheelEvents.shift(); // only store the last N events 13132 } 13133 13134 const prevEvent = recentWheelEvents.length ? recentWheelEvents[recentWheelEvents.length - 1] : undefined; 13135 const firstEvent = recentWheelEvents[0]; 13136 recentWheelEvents.push(newEvent); 13137 13138 if (prevEvent && (newEvent.delta > prevEvent.delta || newEvent.direction !== prevEvent.direction)) { 13139 // Increasing or reverse-sign delta means the user started scrolling again. Clear the wheel event log. 13140 recentWheelEvents.splice(0); 13141 } else if (recentWheelEvents.length >= 15 && newEvent.time - firstEvent.time < 500 && firstEvent.delta - newEvent.delta >= 1 && newEvent.delta <= 6) { 13142 // We're at the end of the deceleration of a momentum scroll, so there's no need 13143 // to wait for more events. Snap ASAP on the next tick. 13144 // Also, because there's some remaining momentum we'll bias the snap in the 13145 // direction of the ongoing scroll because it's better UX for the scroll to snap 13146 // in the same direction as the scroll instead of reversing to snap. Therefore, 13147 // if it's already scrolled more than 20% in the current direction, keep going. 13148 const snapToThreshold = delta > 0 ? 0.8 : 0.2; 13149 lastEventBeforeSnap = newEvent; 13150 recentWheelEvents.splice(0); 13151 timeout = nextTick(() => { 13152 swiper.slideToClosest(swiper.params.speed, true, undefined, snapToThreshold); 13153 }, 0); // no delay; move on next tick 13154 } 13155 13156 if (!timeout) { 13157 // if we get here, then we haven't detected the end of a momentum scroll, so 13158 // we'll consider a scroll "complete" when there haven't been any wheel events 13159 // for 500ms. 13160 timeout = nextTick(() => { 13161 const snapToThreshold = 0.5; 13162 lastEventBeforeSnap = newEvent; 13163 recentWheelEvents.splice(0); 13164 swiper.slideToClosest(swiper.params.speed, true, undefined, snapToThreshold); 13165 }, 500); 13166 } 13167 } // Emit event 13168 13169 13170 if (!ignoreWheelEvents) emit('scroll', e); // Stop autoplay 13171 13172 if (swiper.params.autoplay && swiper.params.autoplayDisableOnInteraction) swiper.autoplay.stop(); // Return page scroll on edge positions 13173 13174 if (position === swiper.minTranslate() || position === swiper.maxTranslate()) return true; 13175 } 13176 } 13177 13178 if (e.preventDefault) e.preventDefault();else e.returnValue = false; 13179 return false; 13180 } 13181 13182 function events(method) { 13183 let target = swiper.$el; 13184 13185 if (swiper.params.mousewheel.eventsTarget !== 'container') { 13186 target = $(swiper.params.mousewheel.eventsTarget); 13187 } 13188 13189 target[method]('mouseenter', handleMouseEnter); 13190 target[method]('mouseleave', handleMouseLeave); 13191 target[method]('wheel', handle); 13192 } 13193 13194 function enable() { 13195 if (swiper.params.cssMode) { 13196 swiper.wrapperEl.removeEventListener('wheel', handle); 13197 return true; 13198 } 13199 13200 if (swiper.mousewheel.enabled) return false;
vendor: 9,549 bytes, lines 13201-13535
13201 events('on'); 13202 swiper.mousewheel.enabled = true; 13203 return true; 13204 } 13205 13206 function disable() { 13207 if (swiper.params.cssMode) { 13208 swiper.wrapperEl.addEventListener(event, handle); 13209 return true; 13210 } 13211 13212 if (!swiper.mousewheel.enabled) return false; 13213 events('off'); 13214 swiper.mousewheel.enabled = false; 13215 return true; 13216 } 13217 13218 on('init', () => { 13219 if (!swiper.params.mousewheel.enabled && swiper.params.cssMode) { 13220 disable(); 13221 } 13222 13223 if (swiper.params.mousewheel.enabled) enable(); 13224 }); 13225 on('destroy', () => { 13226 if (swiper.params.cssMode) { 13227 enable(); 13228 } 13229 13230 if (swiper.mousewheel.enabled) disable(); 13231 }); 13232 Object.assign(swiper.mousewheel, { 13233 enable, 13234 disable 13235 }); 13236 } 13237 13238 function createElementIfNotDefined(swiper, originalParams, params, checkProps) { 13239 const document = getDocument(); 13240 13241 if (swiper.params.createElements) { 13242 Object.keys(checkProps).forEach(key => { 13243 if (!params[key] && params.auto === true) { 13244 let element = swiper.$el.children(`.${checkProps[key]}`)[0]; 13245 13246 if (!element) { 13247 element = document.createElement('div'); 13248 element.className = checkProps[key]; 13249 swiper.$el.append(element); 13250 } 13251 13252 params[key] = element; 13253 originalParams[key] = element; 13254 } 13255 }); 13256 } 13257 13258 return params; 13259 } 13260 13261 function Navigation(_ref) { 13262 let { 13263 swiper, 13264 extendParams, 13265 on, 13266 emit 13267 } = _ref; 13268 extendParams({ 13269 navigation: { 13270 nextEl: null, 13271 prevEl: null, 13272 hideOnClick: false, 13273 disabledClass: 'swiper-button-disabled', 13274 hiddenClass: 'swiper-button-hidden', 13275 lockClass: 'swiper-button-lock', 13276 navigationDisabledClass: 'swiper-navigation-disabled' 13277 } 13278 }); 13279 swiper.navigation = { 13280 nextEl: null, 13281 $nextEl: null, 13282 prevEl: null, 13283 $prevEl: null 13284 }; 13285 13286 function getEl(el) { 13287 let $el; 13288 13289 if (el) { 13290 $el = $(el); 13291 13292 if (swiper.params.uniqueNavElements && typeof el === 'string' && $el.length > 1 && swiper.$el.find(el).length === 1) { 13293 $el = swiper.$el.find(el); 13294 } 13295 } 13296 13297 return $el; 13298 } 13299 13300 function toggleEl($el, disabled) { 13301 const params = swiper.params.navigation; 13302 13303 if ($el && $el.length > 0) { 13304 $el[disabled ? 'addClass' : 'removeClass'](params.disabledClass); 13305 if ($el[0] && $el[0].tagName === 'BUTTON') $el[0].disabled = disabled; 13306 13307 if (swiper.params.watchOverflow && swiper.enabled) { 13308 $el[swiper.isLocked ? 'addClass' : 'removeClass'](params.lockClass); 13309 } 13310 } 13311 } 13312 13313 function update() { 13314 // Update Navigation Buttons 13315 if (swiper.params.loop) return; 13316 const { 13317 $nextEl, 13318 $prevEl 13319 } = swiper.navigation; 13320 toggleEl($prevEl, swiper.isBeginning && !swiper.params.rewind); 13321 toggleEl($nextEl, swiper.isEnd && !swiper.params.rewind); 13322 } 13323 13324 function onPrevClick(e) { 13325 e.preventDefault(); 13326 if (swiper.isBeginning && !swiper.params.loop && !swiper.params.rewind) return; 13327 swiper.slidePrev(); 13328 emit('navigationPrev'); 13329 } 13330 13331 function onNextClick(e) { 13332 e.preventDefault(); 13333 if (swiper.isEnd && !swiper.params.loop && !swiper.params.rewind) return; 13334 swiper.slideNext(); 13335 emit('navigationNext'); 13336 } 13337 13338 function init() { 13339 const params = swiper.params.navigation; 13340 swiper.params.navigation = createElementIfNotDefined(swiper, swiper.originalParams.navigation, swiper.params.navigation, { 13341 nextEl: 'swiper-button-next', 13342 prevEl: 'swiper-button-prev' 13343 }); 13344 if (!(params.nextEl || params.prevEl)) return; 13345 const $nextEl = getEl(params.nextEl); 13346 const $prevEl = getEl(params.prevEl); 13347 13348 if ($nextEl && $nextEl.length > 0) { 13349 $nextEl.on('click', onNextClick); 13350 } 13351 13352 if ($prevEl && $prevEl.length > 0) { 13353 $prevEl.on('click', onPrevClick); 13354 } 13355 13356 Object.assign(swiper.navigation, { 13357 $nextEl, 13358 nextEl: $nextEl && $nextEl[0], 13359 $prevEl, 13360 prevEl: $prevEl && $prevEl[0] 13361 }); 13362 13363 if (!swiper.enabled) { 13364 if ($nextEl) $nextEl.addClass(params.lockClass); 13365 if ($prevEl) $prevEl.addClass(params.lockClass); 13366 } 13367 } 13368 13369 function destroy() { 13370 const { 13371 $nextEl, 13372 $prevEl 13373 } = swiper.navigation; 13374 13375 if ($nextEl && $nextEl.length) { 13376 $nextEl.off('click', onNextClick); 13377 $nextEl.removeClass(swiper.params.navigation.disabledClass); 13378 } 13379 13380 if ($prevEl && $prevEl.length) { 13381 $prevEl.off('click', onPrevClick); 13382 $prevEl.removeClass(swiper.params.navigation.disabledClass); 13383 } 13384 } 13385 13386 on('init', () => { 13387 if (swiper.params.navigation.enabled === false) { 13388 // eslint-disable-next-line 13389 disable(); 13390 } else { 13391 init(); 13392 update(); 13393 } 13394 }); 13395 on('toEdge fromEdge lock unlock', () => { 13396 update(); 13397 }); 13398 on('destroy', () => { 13399 destroy(); 13400 }); 13401 on('enable disable', () => { 13402 const { 13403 $nextEl, 13404 $prevEl 13405 } = swiper.navigation; 13406 13407 if ($nextEl) { 13408 $nextEl[swiper.enabled ? 'removeClass' : 'addClass'](swiper.params.navigation.lockClass); 13409 } 13410 13411 if ($prevEl) { 13412 $prevEl[swiper.enabled ? 'removeClass' : 'addClass'](swiper.params.navigation.lockClass); 13413 } 13414 }); 13415 on('click', (_s, e) => { 13416 const { 13417 $nextEl, 13418 $prevEl 13419 } = swiper.navigation; 13420 const targetEl = e.target; 13421 13422 if (swiper.params.navigation.hideOnClick && !$(targetEl).is($prevEl) && !$(targetEl).is($nextEl)) { 13423 if (swiper.pagination && swiper.params.pagination && swiper.params.pagination.clickable && (swiper.pagination.el === targetEl || swiper.pagination.el.contains(targetEl))) return; 13424 let isHidden; 13425 13426 if ($nextEl) { 13427 isHidden = $nextEl.hasClass(swiper.params.navigation.hiddenClass); 13428 } else if ($prevEl) { 13429 isHidden = $prevEl.hasClass(swiper.params.navigation.hiddenClass); 13430 } 13431 13432 if (isHidden === true) { 13433 emit('navigationShow'); 13434 } else { 13435 emit('navigationHide'); 13436 } 13437 13438 if ($nextEl) { 13439 $nextEl.toggleClass(swiper.params.navigation.hiddenClass); 13440 } 13441 13442 if ($prevEl) { 13443 $prevEl.toggleClass(swiper.params.navigation.hiddenClass); 13444 } 13445 } 13446 }); 13447 13448 const enable = () => { 13449 swiper.$el.removeClass(swiper.params.navigation.navigationDisabledClass); 13450 init(); 13451 update(); 13452 }; 13453 13454 const disable = () => { 13455 swiper.$el.addClass(swiper.params.navigation.navigationDisabledClass); 13456 destroy(); 13457 }; 13458 13459 Object.assign(swiper.navigation, { 13460 enable, 13461 disable, 13462 update, 13463 init, 13464 destroy 13465 }); 13466 } 13467 13468 function classesToSelector(classes) { 13469 if (classes === void 0) { 13470 classes = ''; 13471 } 13472 13473 return `.${classes.trim().replace(/([\.:!\/])/g, '\\$1') // eslint-disable-line 13474 .replace(/ /g, '.')}`; 13475 } 13476 13477 function Pagination(_ref) { 13478 let { 13479 swiper, 13480 extendParams, 13481 on, 13482 emit 13483 } = _ref; 13484 const pfx = 'swiper-pagination'; 13485 extendParams({ 13486 pagination: { 13487 el: null, 13488 bulletElement: 'span', 13489 clickable: false, 13490 hideOnClick: false, 13491 renderBullet: null, 13492 renderProgressbar: null, 13493 renderFraction: null, 13494 renderCustom: null, 13495 progressbarOpposite: false, 13496 type: 'bullets', 13497 // 'bullets' or 'progressbar' or 'fraction' or 'custom' 13498 dynamicBullets: false, 13499 dynamicMainBullets: 1, 13500 formatFractionCurrent: number => number, 13501 formatFractionTotal: number => number, 13502 bulletClass: `${pfx}-bullet`, 13503 bulletActiveClass: `${pfx}-bullet-active`, 13504 modifierClass: `${pfx}-`, 13505 currentClass: `${pfx}-current`, 13506 totalClass: `${pfx}-total`, 13507 hiddenClass: `${pfx}-hidden`, 13508 progressbarFillClass: `${pfx}-progressbar-fill`, 13509 progressbarOppositeClass: `${pfx}-progressbar-opposite`, 13510 clickableClass: `${pfx}-clickable`, 13511 lockClass: `${pfx}-lock`, 13512 horizontalClass: `${pfx}-horizontal`, 13513 verticalClass: `${pfx}-vertical`, 13514 paginationDisabledClass: `${pfx}-disabled` 13515 } 13516 }); 13517 swiper.pagination = { 13518 el: null, 13519 $el: null, 13520 bullets: [] 13521 }; 13522 let bulletSize; 13523 let dynamicBulletIndex = 0; 13524 13525 function isPaginationDisabled() { 13526 return !swiper.params.pagination.el || !swiper.pagination.el || !swiper.pagination.$el || swiper.pagination.$el.length === 0; 13527 } 13528 13529 function setSideBullets($bulletEl, position) { 13530 const { 13531 bulletActiveClass 13532 } = swiper.params.pagination; 13533 $bulletEl[position]().addClass(`${bulletActiveClass}-${position}`)[position]().addClass(`${bulletActiveClass}-${position}-${position}`); 13534 } 13535
vendor: 19,910 bytes, lines 13536-14120
13536 function update() { 13537 // Render || Update Pagination bullets/items 13538 const rtl = swiper.rtl; 13539 const params = swiper.params.pagination; 13540 if (isPaginationDisabled()) return; 13541 const slidesLength = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.slides.length : swiper.slides.length; 13542 const $el = swiper.pagination.$el; // Current/Total 13543 13544 let current; 13545 const total = swiper.params.loop ? Math.ceil((slidesLength - swiper.loopedSlides * 2) / swiper.params.slidesPerGroup) : swiper.snapGrid.length; 13546 13547 if (swiper.params.loop) { 13548 current = Math.ceil((swiper.activeIndex - swiper.loopedSlides) / swiper.params.slidesPerGroup); 13549 13550 if (current > slidesLength - 1 - swiper.loopedSlides * 2) { 13551 current -= slidesLength - swiper.loopedSlides * 2; 13552 } 13553 13554 if (current > total - 1) current -= total; 13555 if (current < 0 && swiper.params.paginationType !== 'bullets') current = total + current; 13556 } else if (typeof swiper.snapIndex !== 'undefined') { 13557 current = swiper.snapIndex; 13558 } else { 13559 current = swiper.activeIndex || 0; 13560 } // Types 13561 13562 13563 if (params.type === 'bullets' && swiper.pagination.bullets && swiper.pagination.bullets.length > 0) { 13564 const bullets = swiper.pagination.bullets; 13565 let firstIndex; 13566 let lastIndex; 13567 let midIndex; 13568 13569 if (params.dynamicBullets) { 13570 bulletSize = bullets.eq(0)[swiper.isHorizontal() ? 'outerWidth' : 'outerHeight'](true); 13571 $el.css(swiper.isHorizontal() ? 'width' : 'height', `${bulletSize * (params.dynamicMainBullets + 4)}px`); 13572 13573 if (params.dynamicMainBullets > 1 && swiper.previousIndex !== undefined) { 13574 dynamicBulletIndex += current - (swiper.previousIndex - swiper.loopedSlides || 0); 13575 13576 if (dynamicBulletIndex > params.dynamicMainBullets - 1) { 13577 dynamicBulletIndex = params.dynamicMainBullets - 1; 13578 } else if (dynamicBulletIndex < 0) { 13579 dynamicBulletIndex = 0; 13580 } 13581 } 13582 13583 firstIndex = Math.max(current - dynamicBulletIndex, 0); 13584 lastIndex = firstIndex + (Math.min(bullets.length, params.dynamicMainBullets) - 1); 13585 midIndex = (lastIndex + firstIndex) / 2; 13586 } 13587 13588 bullets.removeClass(['', '-next', '-next-next', '-prev', '-prev-prev', '-main'].map(suffix => `${params.bulletActiveClass}${suffix}`).join(' ')); 13589 13590 if ($el.length > 1) { 13591 bullets.each(bullet => { 13592 const $bullet = $(bullet); 13593 const bulletIndex = $bullet.index(); 13594 13595 if (bulletIndex === current) { 13596 $bullet.addClass(params.bulletActiveClass); 13597 } 13598 13599 if (params.dynamicBullets) { 13600 if (bulletIndex >= firstIndex && bulletIndex <= lastIndex) { 13601 $bullet.addClass(`${params.bulletActiveClass}-main`); 13602 } 13603 13604 if (bulletIndex === firstIndex) { 13605 setSideBullets($bullet, 'prev'); 13606 } 13607 13608 if (bulletIndex === lastIndex) { 13609 setSideBullets($bullet, 'next'); 13610 } 13611 } 13612 }); 13613 } else { 13614 const $bullet = bullets.eq(current); 13615 const bulletIndex = $bullet.index(); 13616 $bullet.addClass(params.bulletActiveClass); 13617 13618 if (params.dynamicBullets) { 13619 const $firstDisplayedBullet = bullets.eq(firstIndex); 13620 const $lastDisplayedBullet = bullets.eq(lastIndex); 13621 13622 for (let i = firstIndex; i <= lastIndex; i += 1) { 13623 bullets.eq(i).addClass(`${params.bulletActiveClass}-main`); 13624 } 13625 13626 if (swiper.params.loop) { 13627 if (bulletIndex >= bullets.length) { 13628 for (let i = params.dynamicMainBullets; i >= 0; i -= 1) { 13629 bullets.eq(bullets.length - i).addClass(`${params.bulletActiveClass}-main`); 13630 } 13631 13632 bullets.eq(bullets.length - params.dynamicMainBullets - 1).addClass(`${params.bulletActiveClass}-prev`); 13633 } else { 13634 setSideBullets($firstDisplayedBullet, 'prev'); 13635 setSideBullets($lastDisplayedBullet, 'next'); 13636 } 13637 } else { 13638 setSideBullets($firstDisplayedBullet, 'prev'); 13639 setSideBullets($lastDisplayedBullet, 'next'); 13640 } 13641 } 13642 } 13643 13644 if (params.dynamicBullets) { 13645 const dynamicBulletsLength = Math.min(bullets.length, params.dynamicMainBullets + 4); 13646 const bulletsOffset = (bulletSize * dynamicBulletsLength - bulletSize) / 2 - midIndex * bulletSize; 13647 const offsetProp = rtl ? 'right' : 'left'; 13648 bullets.css(swiper.isHorizontal() ? offsetProp : 'top', `${bulletsOffset}px`); 13649 } 13650 } 13651 13652 if (params.type === 'fraction') { 13653 $el.find(classesToSelector(params.currentClass)).text(params.formatFractionCurrent(current + 1)); 13654 $el.find(classesToSelector(params.totalClass)).text(params.formatFractionTotal(total)); 13655 } 13656 13657 if (params.type === 'progressbar') { 13658 let progressbarDirection; 13659 13660 if (params.progressbarOpposite) { 13661 progressbarDirection = swiper.isHorizontal() ? 'vertical' : 'horizontal'; 13662 } else { 13663 progressbarDirection = swiper.isHorizontal() ? 'horizontal' : 'vertical'; 13664 } 13665 13666 const scale = (current + 1) / total; 13667 let scaleX = 1; 13668 let scaleY = 1; 13669 13670 if (progressbarDirection === 'horizontal') { 13671 scaleX = scale; 13672 } else { 13673 scaleY = scale; 13674 } 13675 13676 $el.find(classesToSelector(params.progressbarFillClass)).transform(`translate3d(0,0,0) scaleX(${scaleX}) scaleY(${scaleY})`).transition(swiper.params.speed); 13677 } 13678 13679 if (params.type === 'custom' && params.renderCustom) { 13680 $el.html(params.renderCustom(swiper, current + 1, total)); 13681 emit('paginationRender', $el[0]); 13682 } else { 13683 emit('paginationUpdate', $el[0]); 13684 } 13685 13686 if (swiper.params.watchOverflow && swiper.enabled) { 13687 $el[swiper.isLocked ? 'addClass' : 'removeClass'](params.lockClass); 13688 } 13689 } 13690 13691 function render() { 13692 // Render Container 13693 const params = swiper.params.pagination; 13694 if (isPaginationDisabled()) return; 13695 const slidesLength = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.slides.length : swiper.slides.length; 13696 const $el = swiper.pagination.$el; 13697 let paginationHTML = ''; 13698 13699 if (params.type === 'bullets') { 13700 let numberOfBullets = swiper.params.loop ? Math.ceil((slidesLength - swiper.loopedSlides * 2) / swiper.params.slidesPerGroup) : swiper.snapGrid.length; 13701 13702 if (swiper.params.freeMode && swiper.params.freeMode.enabled && !swiper.params.loop && numberOfBullets > slidesLength) { 13703 numberOfBullets = slidesLength; 13704 } 13705 13706 for (let i = 0; i < numberOfBullets; i += 1) { 13707 if (params.renderBullet) { 13708 paginationHTML += params.renderBullet.call(swiper, i, params.bulletClass); 13709 } else { 13710 paginationHTML += `<${params.bulletElement} class="${params.bulletClass}"></${params.bulletElement}>`; 13711 } 13712 } 13713 13714 $el.html(paginationHTML); 13715 swiper.pagination.bullets = $el.find(classesToSelector(params.bulletClass)); 13716 } 13717 13718 if (params.type === 'fraction') { 13719 if (params.renderFraction) { 13720 paginationHTML = params.renderFraction.call(swiper, params.currentClass, params.totalClass); 13721 } else { 13722 paginationHTML = `<span class="${params.currentClass}"></span>` + ' / ' + `<span class="${params.totalClass}"></span>`; 13723 } 13724 13725 $el.html(paginationHTML); 13726 } 13727 13728 if (params.type === 'progressbar') { 13729 if (params.renderProgressbar) { 13730 paginationHTML = params.renderProgressbar.call(swiper, params.progressbarFillClass); 13731 } else { 13732 paginationHTML = `<span class="${params.progressbarFillClass}"></span>`; 13733 } 13734 13735 $el.html(paginationHTML); 13736 } 13737 13738 if (params.type !== 'custom') { 13739 emit('paginationRender', swiper.pagination.$el[0]); 13740 } 13741 } 13742 13743 function init() { 13744 swiper.params.pagination = createElementIfNotDefined(swiper, swiper.originalParams.pagination, swiper.params.pagination, { 13745 el: 'swiper-pagination' 13746 }); 13747 const params = swiper.params.pagination; 13748 if (!params.el) return; 13749 let $el = $(params.el); 13750 if ($el.length === 0) return; 13751 13752 if (swiper.params.uniqueNavElements && typeof params.el === 'string' && $el.length > 1) { 13753 $el = swiper.$el.find(params.el); // check if it belongs to another nested Swiper 13754 13755 if ($el.length > 1) { 13756 $el = $el.filter(el => { 13757 if ($(el).parents('.swiper')[0] !== swiper.el) return false; 13758 return true; 13759 }); 13760 } 13761 } 13762 13763 if (params.type === 'bullets' && params.clickable) { 13764 $el.addClass(params.clickableClass); 13765 } 13766 13767 $el.addClass(params.modifierClass + params.type); 13768 $el.addClass(swiper.isHorizontal() ? params.horizontalClass : params.verticalClass); 13769 13770 if (params.type === 'bullets' && params.dynamicBullets) { 13771 $el.addClass(`${params.modifierClass}${params.type}-dynamic`); 13772 dynamicBulletIndex = 0; 13773 13774 if (params.dynamicMainBullets < 1) { 13775 params.dynamicMainBullets = 1; 13776 } 13777 } 13778 13779 if (params.type === 'progressbar' && params.progressbarOpposite) { 13780 $el.addClass(params.progressbarOppositeClass); 13781 } 13782 13783 if (params.clickable) { 13784 $el.on('click', classesToSelector(params.bulletClass), function onClick(e) { 13785 e.preventDefault(); 13786 let index = $(this).index() * swiper.params.slidesPerGroup; 13787 if (swiper.params.loop) index += swiper.loopedSlides; 13788 swiper.slideTo(index); 13789 }); 13790 } 13791 13792 Object.assign(swiper.pagination, { 13793 $el, 13794 el: $el[0] 13795 }); 13796 13797 if (!swiper.enabled) { 13798 $el.addClass(params.lockClass); 13799 } 13800 } 13801 13802 function destroy() { 13803 const params = swiper.params.pagination; 13804 if (isPaginationDisabled()) return; 13805 const $el = swiper.pagination.$el; 13806 $el.removeClass(params.hiddenClass); 13807 $el.removeClass(params.modifierClass + params.type); 13808 $el.removeClass(swiper.isHorizontal() ? params.horizontalClass : params.verticalClass); 13809 if (swiper.pagination.bullets && swiper.pagination.bullets.removeClass) swiper.pagination.bullets.removeClass(params.bulletActiveClass); 13810 13811 if (params.clickable) { 13812 $el.off('click', classesToSelector(params.bulletClass)); 13813 } 13814 } 13815 13816 on('init', () => { 13817 if (swiper.params.pagination.enabled === false) { 13818 // eslint-disable-next-line 13819 disable(); 13820 } else { 13821 init(); 13822 render(); 13823 update(); 13824 } 13825 }); 13826 on('activeIndexChange', () => { 13827 if (swiper.params.loop) { 13828 update(); 13829 } else if (typeof swiper.snapIndex === 'undefined') { 13830 update(); 13831 } 13832 }); 13833 on('snapIndexChange', () => { 13834 if (!swiper.params.loop) { 13835 update(); 13836 } 13837 }); 13838 on('slidesLengthChange', () => { 13839 if (swiper.params.loop) { 13840 render(); 13841 update(); 13842 } 13843 }); 13844 on('snapGridLengthChange', () => { 13845 if (!swiper.params.loop) { 13846 render(); 13847 update(); 13848 } 13849 }); 13850 on('destroy', () => { 13851 destroy(); 13852 }); 13853 on('enable disable', () => { 13854 const { 13855 $el 13856 } = swiper.pagination; 13857 13858 if ($el) { 13859 $el[swiper.enabled ? 'removeClass' : 'addClass'](swiper.params.pagination.lockClass); 13860 } 13861 }); 13862 on('lock unlock', () => { 13863 update(); 13864 }); 13865 on('click', (_s, e) => { 13866 const targetEl = e.target; 13867 const { 13868 $el 13869 } = swiper.pagination; 13870 13871 if (swiper.params.pagination.el && swiper.params.pagination.hideOnClick && $el && $el.length > 0 && !$(targetEl).hasClass(swiper.params.pagination.bulletClass)) { 13872 if (swiper.navigation && (swiper.navigation.nextEl && targetEl === swiper.navigation.nextEl || swiper.navigation.prevEl && targetEl === swiper.navigation.prevEl)) return; 13873 const isHidden = $el.hasClass(swiper.params.pagination.hiddenClass); 13874 13875 if (isHidden === true) { 13876 emit('paginationShow'); 13877 } else { 13878 emit('paginationHide'); 13879 } 13880 13881 $el.toggleClass(swiper.params.pagination.hiddenClass); 13882 } 13883 }); 13884 13885 const enable = () => { 13886 swiper.$el.removeClass(swiper.params.pagination.paginationDisabledClass); 13887 13888 if (swiper.pagination.$el) { 13889 swiper.pagination.$el.removeClass(swiper.params.pagination.paginationDisabledClass); 13890 } 13891 13892 init(); 13893 render(); 13894 update(); 13895 }; 13896 13897 const disable = () => { 13898 swiper.$el.addClass(swiper.params.pagination.paginationDisabledClass); 13899 13900 if (swiper.pagination.$el) { 13901 swiper.pagination.$el.addClass(swiper.params.pagination.paginationDisabledClass); 13902 } 13903 13904 destroy(); 13905 }; 13906 13907 Object.assign(swiper.pagination, { 13908 enable, 13909 disable, 13910 render, 13911 update, 13912 init, 13913 destroy 13914 }); 13915 } 13916 13917 function Scrollbar(_ref) { 13918 let { 13919 swiper, 13920 extendParams, 13921 on, 13922 emit 13923 } = _ref; 13924 const document = getDocument(); 13925 let isTouched = false; 13926 let timeout = null; 13927 let dragTimeout = null; 13928 let dragStartPos; 13929 let dragSize; 13930 let trackSize; 13931 let divider; 13932 extendParams({ 13933 scrollbar: { 13934 el: null, 13935 dragSize: 'auto', 13936 hide: false, 13937 draggable: false, 13938 snapOnRelease: true, 13939 lockClass: 'swiper-scrollbar-lock', 13940 dragClass: 'swiper-scrollbar-drag', 13941 scrollbarDisabledClass: 'swiper-scrollbar-disabled', 13942 horizontalClass: `swiper-scrollbar-horizontal`, 13943 verticalClass: `swiper-scrollbar-vertical` 13944 } 13945 }); 13946 swiper.scrollbar = { 13947 el: null, 13948 dragEl: null, 13949 $el: null, 13950 $dragEl: null 13951 }; 13952 13953 function setTranslate() { 13954 if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return; 13955 const { 13956 scrollbar, 13957 rtlTranslate: rtl, 13958 progress 13959 } = swiper; 13960 const { 13961 $dragEl, 13962 $el 13963 } = scrollbar; 13964 const params = swiper.params.scrollbar; 13965 let newSize = dragSize; 13966 let newPos = (trackSize - dragSize) * progress; 13967 13968 if (rtl) { 13969 newPos = -newPos; 13970 13971 if (newPos > 0) { 13972 newSize = dragSize - newPos; 13973 newPos = 0; 13974 } else if (-newPos + dragSize > trackSize) { 13975 newSize = trackSize + newPos; 13976 } 13977 } else if (newPos < 0) { 13978 newSize = dragSize + newPos; 13979 newPos = 0; 13980 } else if (newPos + dragSize > trackSize) { 13981 newSize = trackSize - newPos; 13982 } 13983 13984 if (swiper.isHorizontal()) { 13985 $dragEl.transform(`translate3d(${newPos}px, 0, 0)`); 13986 $dragEl[0].style.width = `${newSize}px`; 13987 } else { 13988 $dragEl.transform(`translate3d(0px, ${newPos}px, 0)`); 13989 $dragEl[0].style.height = `${newSize}px`; 13990 } 13991 13992 if (params.hide) { 13993 clearTimeout(timeout); 13994 $el[0].style.opacity = 1; 13995 timeout = setTimeout(() => { 13996 $el[0].style.opacity = 0; 13997 $el.transition(400); 13998 }, 1000); 13999 } 14000 } 14001 14002 function setTransition(duration) { 14003 if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return; 14004 swiper.scrollbar.$dragEl.transition(duration); 14005 } 14006 14007 function updateSize() { 14008 if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return; 14009 const { 14010 scrollbar 14011 } = swiper; 14012 const { 14013 $dragEl, 14014 $el 14015 } = scrollbar; 14016 $dragEl[0].style.width = ''; 14017 $dragEl[0].style.height = ''; 14018 trackSize = swiper.isHorizontal() ? $el[0].offsetWidth : $el[0].offsetHeight; 14019 divider = swiper.size / (swiper.virtualSize + swiper.params.slidesOffsetBefore - (swiper.params.centeredSlides ? swiper.snapGrid[0] : 0)); 14020 14021 if (swiper.params.scrollbar.dragSize === 'auto') { 14022 dragSize = trackSize * divider; 14023 } else { 14024 dragSize = parseInt(swiper.params.scrollbar.dragSize, 10); 14025 } 14026 14027 if (swiper.isHorizontal()) { 14028 $dragEl[0].style.width = `${dragSize}px`; 14029 } else { 14030 $dragEl[0].style.height = `${dragSize}px`; 14031 } 14032 14033 if (divider >= 1) { 14034 $el[0].style.display = 'none'; 14035 } else { 14036 $el[0].style.display = ''; 14037 } 14038 14039 if (swiper.params.scrollbar.hide) { 14040 $el[0].style.opacity = 0; 14041 } 14042 14043 if (swiper.params.watchOverflow && swiper.enabled) { 14044 scrollbar.$el[swiper.isLocked ? 'addClass' : 'removeClass'](swiper.params.scrollbar.lockClass); 14045 } 14046 } 14047 14048 function getPointerPosition(e) { 14049 if (swiper.isHorizontal()) { 14050 return e.type === 'touchstart' || e.type === 'touchmove' ? e.targetTouches[0].clientX : e.clientX; 14051 } 14052 14053 return e.type === 'touchstart' || e.type === 'touchmove' ? e.targetTouches[0].clientY : e.clientY; 14054 } 14055 14056 function setDragPosition(e) { 14057 const { 14058 scrollbar, 14059 rtlTranslate: rtl 14060 } = swiper; 14061 const { 14062 $el 14063 } = scrollbar; 14064 let positionRatio; 14065 positionRatio = (getPointerPosition(e) - $el.offset()[swiper.isHorizontal() ? 'left' : 'top'] - (dragStartPos !== null ? dragStartPos : dragSize / 2)) / (trackSize - dragSize); 14066 positionRatio = Math.max(Math.min(positionRatio, 1), 0); 14067 14068 if (rtl) { 14069 positionRatio = 1 - positionRatio; 14070 } 14071 14072 const position = swiper.minTranslate() + (swiper.maxTranslate() - swiper.minTranslate()) * positionRatio; 14073 swiper.updateProgress(position); 14074 swiper.setTranslate(position); 14075 swiper.updateActiveIndex(); 14076 swiper.updateSlidesClasses(); 14077 } 14078 14079 function onDragStart(e) { 14080 const params = swiper.params.scrollbar; 14081 const { 14082 scrollbar, 14083 $wrapperEl 14084 } = swiper; 14085 const { 14086 $el, 14087 $dragEl 14088 } = scrollbar; 14089 isTouched = true; 14090 dragStartPos = e.target === $dragEl[0] || e.target === $dragEl ? getPointerPosition(e) - e.target.getBoundingClientRect()[swiper.isHorizontal() ? 'left' : 'top'] : null; 14091 e.preventDefault(); 14092 e.stopPropagation(); 14093 $wrapperEl.transition(100); 14094 $dragEl.transition(100); 14095 setDragPosition(e); 14096 clearTimeout(dragTimeout); 14097 $el.transition(0); 14098 14099 if (params.hide) { 14100 $el.css('opacity', 1); 14101 } 14102 14103 if (swiper.params.cssMode) { 14104 swiper.$wrapperEl.css('scroll-snap-type', 'none'); 14105 } 14106 14107 emit('scrollbarDragStart', e); 14108 } 14109 14110 function onDragMove(e) { 14111 const { 14112 scrollbar, 14113 $wrapperEl 14114 } = swiper; 14115 const { 14116 $el, 14117 $dragEl 14118 } = scrollbar; 14119 if (!isTouched) return; 14120 if (e.preventDefault) e.preventDefault();else e.returnValue = false;
14121 setDragPosition(e); 14122 $wrapperEl.transition(0); 14123 $el.transition(0); 14124 $dragEl.transition(0); 14125 emit('scrollbarDragMove', e); 14126 } 14127 14128 function onDragEnd(e) { 14129 const params = swiper.params.scrollbar; 14130 const { 14131 scrollbar, 14132 $wrapperEl 14133 } = swiper; 14134 const { 14135 $el 14136 } = scrollbar; 14137 if (!isTouched) return; 14138 isTouched = false; 14139 14140 if (swiper.params.cssMode) { 14141 swiper.$wrapperEl.css('scroll-snap-type', ''); 14142 $wrapperEl.transition(''); 14143 } 14144 14145 if (params.hide) { 14146 clearTimeout(dragTimeout); 14147 dragTimeout = nextTick(() => { 14148 $el.css('opacity', 0); 14149 $el.transition(400); 14150 }, 1000); 14151 } 14152 14153 emit('scrollbarDragEnd', e); 14154 14155 if (params.snapOnRelease) { 14156 swiper.slideToClosest(); 14157 } 14158 } 14159 14160 function events(method) { 14161 const { 14162 scrollbar, 14163 touchEventsTouch, 14164 touchEventsDesktop, 14165 params, 14166 support 14167 } = swiper; 14168 const $el = scrollbar.$el; 14169 if (!$el) return; 14170 const target = $el[0]; 14171 const activeListener = support.passiveListener && params.passiveListeners ? { 14172 passive: false, 14173 capture: false 14174 } : false; 14175 const passiveListener = support.passiveListener && params.passiveListeners ? { 14176 passive: true, 14177 capture: false 14178 } : false; 14179 if (!target) return; 14180 const eventMethod = method === 'on' ? 'addEventListener' : 'removeEventListener'; 14181 14182 if (!support.touch) { 14183 target[eventMethod](touchEventsDesktop.start, onDragStart, activeListener); 14184 document[eventMethod](touchEventsDesktop.move, onDragMove, activeListener); 14185 document[eventMethod](touchEventsDesktop.end, onDragEnd, passiveListener); 14186 } else { 14187 target[eventMethod](touchEventsTouch.start, onDragStart, activeListener); 14188 target[eventMethod](touchEventsTouch.move, onDragMove, activeListener); 14189 target[eventMethod](touchEventsTouch.end, onDragEnd, passiveListener); 14190 } 14191 } 14192 14193 function enableDraggable() { 14194 if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return; 14195 events('on'); 14196 } 14197 14198 function disableDraggable() { 14199 if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return; 14200 events('off'); 14201 } 14202 14203 function init() { 14204 const { 14205 scrollbar, 14206 $el: $swiperEl 14207 } = swiper; 14208 swiper.params.scrollbar = createElementIfNotDefined(swiper, swiper.originalParams.scrollbar, swiper.params.scrollbar, { 14209 el: 'swiper-scrollbar' 14210 }); 14211 const params = swiper.params.scrollbar; 14212 if (!params.el) return; 14213 let $el = $(params.el); 14214 14215 if (swiper.params.uniqueNavElements && typeof params.el === 'string' && $el.length > 1 && $swiperEl.find(params.el).length === 1) { 14216 $el = $swiperEl.find(params.el); 14217 } 14218 14219 $el.addClass(swiper.isHorizontal() ? params.horizontalClass : params.verticalClass); 14220 let $dragEl = $el.find(`.${swiper.params.scrollbar.dragClass}`); 14221 14222 if ($dragEl.length === 0) { 14223 $dragEl = $(`<div class="${swiper.params.scrollbar.dragClass}"></div>`); 14224 $el.append($dragEl); 14225 } 14226 14227 Object.assign(scrollbar, { 14228 $el, 14229 el: $el[0], 14230 $dragEl, 14231 dragEl: $dragEl[0] 14232 }); 14233 14234 if (params.draggable) { 14235 enableDraggable(); 14236 } 14237 14238 if ($el) { 14239 $el[swiper.enabled ? 'removeClass' : 'addClass'](swiper.params.scrollbar.lockClass); 14240 } 14241 } 14242 14243 function destroy() { 14244 const params = swiper.params.scrollbar; 14245 const $el = swiper.scrollbar.$el; 14246 14247 if ($el) { 14248 $el.removeClass(swiper.isHorizontal() ? params.horizontalClass : params.verticalClass); 14249 } 14250 14251 disableDraggable(); 14252 } 14253 14254 on('init', () => { 14255 if (swiper.params.scrollbar.enabled === false) { 14256 // eslint-disable-next-line 14257 disable(); 14258 } else { 14259 init(); 14260 updateSize(); 14261 setTranslate(); 14262 } 14263 }); 14264 on('update resize observerUpdate lock unlock', () => { 14265 updateSize(); 14266 }); 14267 on('setTranslate', () => { 14268 setTranslate(); 14269 }); 14270 on('setTransition', (_s, duration) => { 14271 setTransition(duration); 14272 }); 14273 on('enable disable', () => { 14274 const { 14275 $el 14276 } = swiper.scrollbar; 14277 14278 if ($el) { 14279 $el[swiper.enabled ? 'removeClass' : 'addClass'](swiper.params.scrollbar.lockClass); 14280 } 14281 }); 14282 on('destroy', () => { 14283 destroy(); 14284 }); 14285 14286 const enable = () => { 14287 swiper.$el.removeClass(swiper.params.scrollbar.scrollbarDisabledClass); 14288 14289 if (swiper.scrollbar.$el) { 14290 swiper.scrollbar.$el.removeClass(swiper.params.scrollbar.scrollbarDisabledClass); 14291 } 14292 14293 init(); 14294 updateSize(); 14295 setTranslate(); 14296 }; 14297 14298 const disable = () => { 14299 swiper.$el.addClass(swiper.params.scrollbar.scrollbarDisabledClass); 14300 14301 if (swiper.scrollbar.$el) { 14302 swiper.scrollbar.$el.addClass(swiper.params.scrollbar.scrollbarDisabledClass); 14303 } 14304 14305 destroy(); 14306 }; 14307 14308 Object.assign(swiper.scrollbar, { 14309 enable, 14310 disable, 14311 updateSize, 14312 setTranslate, 14313 init, 14314 destroy 14315 }); 14316 } 14317 14318 function Parallax(_ref) { 14319 let { 14320 swiper, 14321 extendParams, 14322 on 14323 } = _ref; 14324 extendParams({ 14325 parallax: { 14326 enabled: false 14327 } 14328 }); 14329 14330 const setTransform = (el, progress) => { 14331 const { 14332 rtl 14333 } = swiper; 14334 const $el = $(el); 14335 const rtlFactor = rtl ? -1 : 1; 14336 const p = $el.attr('data-swiper-parallax') || '0'; 14337 let x = $el.attr('data-swiper-parallax-x'); 14338 let y = $el.attr('data-swiper-parallax-y'); 14339 const scale = $el.attr('data-swiper-parallax-scale'); 14340 const opacity = $el.attr('data-swiper-parallax-opacity'); 14341 14342 if (x || y) { 14343 x = x || '0'; 14344 y = y || '0'; 14345 } else if (swiper.isHorizontal()) { 14346 x = p; 14347 y = '0'; 14348 } else { 14349 y = p; 14350 x = '0'; 14351 } 14352 14353 if (x.indexOf('%') >= 0) { 14354 x = `${parseInt(x, 10) * progress * rtlFactor}%`; 14355 } else { 14356 x = `${x * progress * rtlFactor}px`;
14357 } 14358 14359 if (y.indexOf('%') >= 0) { 14360 y = `${parseInt(y, 10) * progress}%`; 14361 } else { 14362 y = `${y * progress}px`; 14363 } 14364 14365 if (typeof opacity !== 'undefined' && opacity !== null) { 14366 const currentOpacity = opacity - (opacity - 1) * (1 - Math.abs(progress)); 14367 $el[0].style.opacity = currentOpacity; 14368 } 14369 14370 if (typeof scale === 'undefined' || scale === null) { 14371 $el.transform(`translate3d(${x}, ${y}, 0px)`); 14372 } else { 14373 const currentScale = scale - (scale - 1) * (1 - Math.abs(progress)); 14374 $el.transform(`translate3d(${x}, ${y}, 0px) scale(${currentScale})`); 14375 } 14376 }; 14377 14378 const setTranslate = () => { 14379 const { 14380 $el, 14381 slides, 14382 progress, 14383 snapGrid 14384 } = swiper; 14385 $el.children('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]').each(el => { 14386 setTransform(el, progress); 14387 }); 14388 slides.each((slideEl, slideIndex) => { 14389 let slideProgress = slideEl.progress; 14390 14391 if (swiper.params.slidesPerGroup > 1 && swiper.params.slidesPerView !== 'auto') { 14392 slideProgress += Math.ceil(slideIndex / 2) - progress * (snapGrid.length - 1); 14393 } 14394 14395 slideProgress = Math.min(Math.max(slideProgress, -1), 1); 14396 $(slideEl).find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]').each(el => { 14397 setTransform(el, slideProgress); 14398 }); 14399 }); 14400 }; 14401 14402 const setTransition = function (duration) { 14403 if (duration === void 0) { 14404 duration = swiper.params.speed; 14405 } 14406 14407 const { 14408 $el 14409 } = swiper; 14410 $el.find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]').each(parallaxEl => { 14411 const $parallaxEl = $(parallaxEl); 14412 let parallaxDuration = parseInt($parallaxEl.attr('data-swiper-parallax-duration'), 10) || duration; 14413 if (duration === 0) parallaxDuration = 0; 14414 $parallaxEl.transition(parallaxDuration); 14415 }); 14416 }; 14417 14418 on('beforeInit', () => { 14419 if (!swiper.params.parallax.enabled) return; 14420 swiper.params.watchSlidesProgress = true; 14421 swiper.originalParams.watchSlidesProgress = true; 14422 }); 14423 on('init', () => { 14424 if (!swiper.params.parallax.enabled) return; 14425 setTranslate(); 14426 }); 14427 on('setTranslate', () => { 14428 if (!swiper.params.parallax.enabled) return; 14429 setTranslate(); 14430 }); 14431 on('setTransition', (_swiper, duration) => { 14432 if (!swiper.params.parallax.enabled) return; 14433 setTransition(duration); 14434 }); 14435 } 14436 14437 function Zoom(_ref) { 14438 let { 14439 swiper, 14440 extendParams, 14441 on, 14442 emit 14443 } = _ref; 14444 const window = getWindow(); 14445 extendParams({ 14446 zoom: { 14447 enabled: false, 14448 maxRatio: 3, 14449 minRatio: 1, 14450 toggle: true, 14451 containerClass: 'swiper-zoom-container', 14452 zoomedSlideClass: 'swiper-slide-zoomed' 14453 } 14454 }); 14455 swiper.zoom = { 14456 enabled: false 14457 }; 14458 let currentScale = 1; 14459 let isScaling = false; 14460 let gesturesEnabled; 14461 let fakeGestureTouched; 14462 let fakeGestureMoved; 14463 const gesture = { 14464 $slideEl: undefined, 14465 slideWidth: undefined, 14466 slideHeight: undefined, 14467 $imageEl: undefined, 14468 $imageWrapEl: undefined, 14469 maxRatio: 3 14470 }; 14471 const image = { 14472 isTouched: undefined, 14473 isMoved: undefined, 14474 currentX: undefined, 14475 currentY: undefined, 14476 minX: undefined, 14477 minY: undefined, 14478 maxX: undefined, 14479 maxY: undefined, 14480 width: undefined, 14481 height: undefined, 14482 startX: undefined, 14483 startY: undefined, 14484 touchesStart: {}, 14485 touchesCurrent: {} 14486 }; 14487 const velocity = { 14488 x: undefined, 14489 y: undefined, 14490 prevPositionX: undefined, 14491 prevPositionY: undefined, 14492 prevTime: undefined 14493 }; 14494 let scale = 1; 14495 Object.defineProperty(swiper.zoom, 'scale', { 14496 get() { 14497 return scale; 14498 }, 14499 14500 set(value) { 14501 if (scale !== value) { 14502 const imageEl = gesture.$imageEl ? gesture.$imageEl[0] : undefined; 14503 const slideEl = gesture.$slideEl ? gesture.$slideEl[0] : undefined; 14504 emit('zoomChange', value, imageEl, slideEl); 14505 } 14506 14507 scale = value; 14508 } 14509 14510 }); 14511 14512 function getDistanceBetweenTouches(e) { 14513 if (e.targetTouches.length < 2) return 1; 14514 const x1 = e.targetTouches[0].pageX; 14515 const y1 = e.targetTouches[0].pageY; 14516 const x2 = e.targetTouches[1].pageX; 14517 const y2 = e.targetTouches[1].pageY; 14518 const distance = Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2); 14519 return distance; 14520 } // Events 14521 14522 14523 function onGestureStart(e) { 14524 const support = swiper.support; 14525 const params = swiper.params.zoom; 14526 fakeGestureTouched = false;
vendor: 13,553 bytes, lines 14527-14863
14527 fakeGestureMoved = false; 14528 14529 if (!support.gestures) { 14530 if (e.type !== 'touchstart' || e.type === 'touchstart' && e.targetTouches.length < 2) { 14531 return; 14532 } 14533 14534 fakeGestureTouched = true; 14535 gesture.scaleStart = getDistanceBetweenTouches(e); 14536 } 14537 14538 if (!gesture.$slideEl || !gesture.$slideEl.length) { 14539 gesture.$slideEl = $(e.target).closest(`.${swiper.params.slideClass}`); 14540 if (gesture.$slideEl.length === 0) gesture.$slideEl = swiper.slides.eq(swiper.activeIndex); 14541 gesture.$imageEl = gesture.$slideEl.find(`.${params.containerClass}`).eq(0).find('picture, img, svg, canvas, .swiper-zoom-target').eq(0); 14542 gesture.$imageWrapEl = gesture.$imageEl.parent(`.${params.containerClass}`); 14543 gesture.maxRatio = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio; 14544 14545 if (gesture.$imageWrapEl.length === 0) { 14546 gesture.$imageEl = undefined; 14547 return; 14548 } 14549 } 14550 14551 if (gesture.$imageEl) { 14552 gesture.$imageEl.transition(0); 14553 } 14554 14555 isScaling = true; 14556 } 14557 14558 function onGestureChange(e) { 14559 const support = swiper.support; 14560 const params = swiper.params.zoom; 14561 const zoom = swiper.zoom; 14562 14563 if (!support.gestures) { 14564 if (e.type !== 'touchmove' || e.type === 'touchmove' && e.targetTouches.length < 2) { 14565 return; 14566 } 14567 14568 fakeGestureMoved = true; 14569 gesture.scaleMove = getDistanceBetweenTouches(e); 14570 } 14571 14572 if (!gesture.$imageEl || gesture.$imageEl.length === 0) { 14573 if (e.type === 'gesturechange') onGestureStart(e); 14574 return; 14575 } 14576 14577 if (support.gestures) { 14578 zoom.scale = e.scale * currentScale; 14579 } else { 14580 zoom.scale = gesture.scaleMove / gesture.scaleStart * currentScale; 14581 } 14582 14583 if (zoom.scale > gesture.maxRatio) { 14584 zoom.scale = gesture.maxRatio - 1 + (zoom.scale - gesture.maxRatio + 1) ** 0.5; 14585 } 14586 14587 if (zoom.scale < params.minRatio) { 14588 zoom.scale = params.minRatio + 1 - (params.minRatio - zoom.scale + 1) ** 0.5; 14589 } 14590 14591 gesture.$imageEl.transform(`translate3d(0,0,0) scale(${zoom.scale})`); 14592 } 14593 14594 function onGestureEnd(e) { 14595 const device = swiper.device; 14596 const support = swiper.support; 14597 const params = swiper.params.zoom; 14598 const zoom = swiper.zoom; 14599 14600 if (!support.gestures) { 14601 if (!fakeGestureTouched || !fakeGestureMoved) { 14602 return; 14603 } 14604 14605 if (e.type !== 'touchend' || e.type === 'touchend' && e.changedTouches.length < 2 && !device.android) { 14606 return; 14607 } 14608 14609 fakeGestureTouched = false; 14610 fakeGestureMoved = false; 14611 } 14612 14613 if (!gesture.$imageEl || gesture.$imageEl.length === 0) return; 14614 zoom.scale = Math.max(Math.min(zoom.scale, gesture.maxRatio), params.minRatio); 14615 gesture.$imageEl.transition(swiper.params.speed).transform(`translate3d(0,0,0) scale(${zoom.scale})`); 14616 currentScale = zoom.scale; 14617 isScaling = false; 14618 if (zoom.scale === 1) gesture.$slideEl = undefined; 14619 } 14620 14621 function onTouchStart(e) { 14622 const device = swiper.device; 14623 if (!gesture.$imageEl || gesture.$imageEl.length === 0) return; 14624 if (image.isTouched) return; 14625 if (device.android && e.cancelable) e.preventDefault(); 14626 image.isTouched = true; 14627 image.touchesStart.x = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX; 14628 image.touchesStart.y = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY; 14629 } 14630 14631 function onTouchMove(e) { 14632 const zoom = swiper.zoom; 14633 if (!gesture.$imageEl || gesture.$imageEl.length === 0) return; 14634 swiper.allowClick = false; 14635 if (!image.isTouched || !gesture.$slideEl) return; 14636 14637 if (!image.isMoved) { 14638 image.width = gesture.$imageEl[0].offsetWidth; 14639 image.height = gesture.$imageEl[0].offsetHeight; 14640 image.startX = getTranslate(gesture.$imageWrapEl[0], 'x') || 0; 14641 image.startY = getTranslate(gesture.$imageWrapEl[0], 'y') || 0; 14642 gesture.slideWidth = gesture.$slideEl[0].offsetWidth; 14643 gesture.slideHeight = gesture.$slideEl[0].offsetHeight; 14644 gesture.$imageWrapEl.transition(0); 14645 } // Define if we need image drag 14646 14647 14648 const scaledWidth = image.width * zoom.scale; 14649 const scaledHeight = image.height * zoom.scale; 14650 if (scaledWidth < gesture.slideWidth && scaledHeight < gesture.slideHeight) return; 14651 image.minX = Math.min(gesture.slideWidth / 2 - scaledWidth / 2, 0); 14652 image.maxX = -image.minX; 14653 image.minY = Math.min(gesture.slideHeight / 2 - scaledHeight / 2, 0); 14654 image.maxY = -image.minY; 14655 image.touchesCurrent.x = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX; 14656 image.touchesCurrent.y = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY; 14657 14658 if (!image.isMoved && !isScaling) { 14659 if (swiper.isHorizontal() && (Math.floor(image.minX) === Math.floor(image.startX) && image.touchesCurrent.x < image.touchesStart.x || Math.floor(image.maxX) === Math.floor(image.startX) && image.touchesCurrent.x > image.touchesStart.x)) { 14660 image.isTouched = false; 14661 return; 14662 } 14663 14664 if (!swiper.isHorizontal() && (Math.floor(image.minY) === Math.floor(image.startY) && image.touchesCurrent.y < image.touchesStart.y || Math.floor(image.maxY) === Math.floor(image.startY) && image.touchesCurrent.y > image.touchesStart.y)) { 14665 image.isTouched = false; 14666 return; 14667 } 14668 } 14669 14670 if (e.cancelable) { 14671 e.preventDefault(); 14672 } 14673 14674 e.stopPropagation(); 14675 image.isMoved = true; 14676 image.currentX = image.touchesCurrent.x - image.touchesStart.x + image.startX; 14677 image.currentY = image.touchesCurrent.y - image.touchesStart.y + image.startY; 14678 14679 if (image.currentX < image.minX) { 14680 image.currentX = image.minX + 1 - (image.minX - image.currentX + 1) ** 0.8; 14681 } 14682 14683 if (image.currentX > image.maxX) { 14684 image.currentX = image.maxX - 1 + (image.currentX - image.maxX + 1) ** 0.8; 14685 } 14686 14687 if (image.currentY < image.minY) { 14688 image.currentY = image.minY + 1 - (image.minY - image.currentY + 1) ** 0.8; 14689 } 14690 14691 if (image.currentY > image.maxY) { 14692 image.currentY = image.maxY - 1 + (image.currentY - image.maxY + 1) ** 0.8; 14693 } // Velocity 14694 14695 14696 if (!velocity.prevPositionX) velocity.prevPositionX = image.touchesCurrent.x; 14697 if (!velocity.prevPositionY) velocity.prevPositionY = image.touchesCurrent.y; 14698 if (!velocity.prevTime) velocity.prevTime = Date.now(); 14699 velocity.x = (image.touchesCurrent.x - velocity.prevPositionX) / (Date.now() - velocity.prevTime) / 2; 14700 velocity.y = (image.touchesCurrent.y - velocity.prevPositionY) / (Date.now() - velocity.prevTime) / 2; 14701 if (Math.abs(image.touchesCurrent.x - velocity.prevPositionX) < 2) velocity.x = 0; 14702 if (Math.abs(image.touchesCurrent.y - velocity.prevPositionY) < 2) velocity.y = 0; 14703 velocity.prevPositionX = image.touchesCurrent.x; 14704 velocity.prevPositionY = image.touchesCurrent.y; 14705 velocity.prevTime = Date.now(); 14706 gesture.$imageWrapEl.transform(`translate3d(${image.currentX}px, ${image.currentY}px,0)`); 14707 } 14708 14709 function onTouchEnd() { 14710 const zoom = swiper.zoom; 14711 if (!gesture.$imageEl || gesture.$imageEl.length === 0) return; 14712 14713 if (!image.isTouched || !image.isMoved) { 14714 image.isTouched = false; 14715 image.isMoved = false; 14716 return; 14717 } 14718 14719 image.isTouched = false; 14720 image.isMoved = false; 14721 let momentumDurationX = 300; 14722 let momentumDurationY = 300; 14723 const momentumDistanceX = velocity.x * momentumDurationX; 14724 const newPositionX = image.currentX + momentumDistanceX; 14725 const momentumDistanceY = velocity.y * momentumDurationY; 14726 const newPositionY = image.currentY + momentumDistanceY; // Fix duration 14727 14728 if (velocity.x !== 0) momentumDurationX = Math.abs((newPositionX - image.currentX) / velocity.x); 14729 if (velocity.y !== 0) momentumDurationY = Math.abs((newPositionY - image.currentY) / velocity.y); 14730 const momentumDuration = Math.max(momentumDurationX, momentumDurationY); 14731 image.currentX = newPositionX; 14732 image.currentY = newPositionY; // Define if we need image drag 14733 14734 const scaledWidth = image.width * zoom.scale; 14735 const scaledHeight = image.height * zoom.scale; 14736 image.minX = Math.min(gesture.slideWidth / 2 - scaledWidth / 2, 0); 14737 image.maxX = -image.minX; 14738 image.minY = Math.min(gesture.slideHeight / 2 - scaledHeight / 2, 0); 14739 image.maxY = -image.minY; 14740 image.currentX = Math.max(Math.min(image.currentX, image.maxX), image.minX); 14741 image.currentY = Math.max(Math.min(image.currentY, image.maxY), image.minY); 14742 gesture.$imageWrapEl.transition(momentumDuration).transform(`translate3d(${image.currentX}px, ${image.currentY}px,0)`); 14743 } 14744 14745 function onTransitionEnd() { 14746 const zoom = swiper.zoom; 14747 14748 if (gesture.$slideEl && swiper.previousIndex !== swiper.activeIndex) { 14749 if (gesture.$imageEl) { 14750 gesture.$imageEl.transform('translate3d(0,0,0) scale(1)'); 14751 } 14752 14753 if (gesture.$imageWrapEl) { 14754 gesture.$imageWrapEl.transform('translate3d(0,0,0)'); 14755 } 14756 14757 zoom.scale = 1; 14758 currentScale = 1; 14759 gesture.$slideEl = undefined; 14760 gesture.$imageEl = undefined; 14761 gesture.$imageWrapEl = undefined; 14762 } 14763 } 14764 14765 function zoomIn(e) { 14766 const zoom = swiper.zoom; 14767 const params = swiper.params.zoom; 14768 14769 if (!gesture.$slideEl) { 14770 if (e && e.target) { 14771 gesture.$slideEl = $(e.target).closest(`.${swiper.params.slideClass}`); 14772 } 14773 14774 if (!gesture.$slideEl) { 14775 if (swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual) { 14776 gesture.$slideEl = swiper.$wrapperEl.children(`.${swiper.params.slideActiveClass}`); 14777 } else { 14778 gesture.$slideEl = swiper.slides.eq(swiper.activeIndex); 14779 } 14780 } 14781 14782 gesture.$imageEl = gesture.$slideEl.find(`.${params.containerClass}`).eq(0).find('picture, img, svg, canvas, .swiper-zoom-target').eq(0); 14783 gesture.$imageWrapEl = gesture.$imageEl.parent(`.${params.containerClass}`); 14784 } 14785 14786 if (!gesture.$imageEl || gesture.$imageEl.length === 0 || !gesture.$imageWrapEl || gesture.$imageWrapEl.length === 0) return; 14787 14788 if (swiper.params.cssMode) { 14789 swiper.wrapperEl.style.overflow = 'hidden'; 14790 swiper.wrapperEl.style.touchAction = 'none'; 14791 } 14792 14793 gesture.$slideEl.addClass(`${params.zoomedSlideClass}`); 14794 let touchX; 14795 let touchY; 14796 let offsetX; 14797 let offsetY; 14798 let diffX; 14799 let diffY; 14800 let translateX; 14801 let translateY; 14802 let imageWidth; 14803 let imageHeight; 14804 let scaledWidth; 14805 let scaledHeight; 14806 let translateMinX; 14807 let translateMinY; 14808 let translateMaxX; 14809 let translateMaxY; 14810 let slideWidth; 14811 let slideHeight; 14812 14813 if (typeof image.touchesStart.x === 'undefined' && e) { 14814 touchX = e.type === 'touchend' ? e.changedTouches[0].pageX : e.pageX; 14815 touchY = e.type === 'touchend' ? e.changedTouches[0].pageY : e.pageY; 14816 } else { 14817 touchX = image.touchesStart.x; 14818 touchY = image.touchesStart.y; 14819 } 14820 14821 zoom.scale = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio; 14822 currentScale = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio; 14823 14824 if (e) { 14825 slideWidth = gesture.$slideEl[0].offsetWidth; 14826 slideHeight = gesture.$slideEl[0].offsetHeight; 14827 offsetX = gesture.$slideEl.offset().left + window.scrollX; 14828 offsetY = gesture.$slideEl.offset().top + window.scrollY; 14829 diffX = offsetX + slideWidth / 2 - touchX; 14830 diffY = offsetY + slideHeight / 2 - touchY; 14831 imageWidth = gesture.$imageEl[0].offsetWidth; 14832 imageHeight = gesture.$imageEl[0].offsetHeight; 14833 scaledWidth = imageWidth * zoom.scale; 14834 scaledHeight = imageHeight * zoom.scale; 14835 translateMinX = Math.min(slideWidth / 2 - scaledWidth / 2, 0); 14836 translateMinY = Math.min(slideHeight / 2 - scaledHeight / 2, 0); 14837 translateMaxX = -translateMinX; 14838 translateMaxY = -translateMinY; 14839 translateX = diffX * zoom.scale; 14840 translateY = diffY * zoom.scale; 14841 14842 if (translateX < translateMinX) { 14843 translateX = translateMinX; 14844 } 14845 14846 if (translateX > translateMaxX) { 14847 translateX = translateMaxX; 14848 } 14849 14850 if (translateY < translateMinY) { 14851 translateY = translateMinY; 14852 } 14853 14854 if (translateY > translateMaxY) { 14855 translateY = translateMaxY; 14856 } 14857 } else { 14858 translateX = 0; 14859 translateY = 0; 14860 } 14861 14862 gesture.$imageWrapEl.transition(300).transform(`translate3d(${translateX}px, ${translateY}px,0)`); 14863 gesture.$imageEl.transition(300).transform(`translate3d(0,
148630,0) scale(${zoom.scale})`); 14864 } 14865 14866 function zoomOut() { 14867 const zoom = swiper.zoom; 14868 const params = swiper.params.zoom; 14869 14870 if (!gesture.$slideEl) { 14871 if (swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual) { 14872 gesture.$slideEl = swiper.$wrapperEl.children(`.${swiper.params.slideActiveClass}`); 14873 } else { 14874 gesture.$slideEl = swiper.slides.eq(swiper.activeIndex); 14875 } 14876 14877 gesture.$imageEl = gesture.$slideEl.find(`.${params.containerClass}`).eq(0).find('picture, img, svg, canvas, .swiper-zoom-target').eq(0); 14878 gesture.$imageWrapEl = gesture.$imageEl.parent(`.${params.containerClass}`); 14879 } 14880 14881 if (!gesture.$imageEl || gesture.$imageEl.length === 0 || !gesture.$imageWrapEl || gesture.$imageWrapEl.length === 0) return; 14882 14883 if (swiper.params.cssMode) { 14884 swiper.wrapperEl.style.overflow = ''; 14885 swiper.wrapperEl.style.touchAction = ''; 14886 } 14887 14888 zoom.scale = 1; 14889 currentScale = 1; 14890 gesture.$imageWrapEl.transition(300).transform('translate3d(0,0,0)'); 14891 gesture.$imageEl.transition(300).transform('translate3d(0,0,0) scale(1)'); 14892 gesture.$slideEl.removeClass(`${params.zoomedSlideClass}`); 14893 gesture.$slideEl = undefined; 14894 } // Toggle Zoom 14895 14896 14897 function zoomToggle(e) { 14898 const zoom = swiper.zoom; 14899 14900 if (zoom.scale && zoom.scale !== 1) { 14901 // Zoom Out 14902 zoomOut(); 14903 } else { 14904 // Zoom In 14905 zoomIn(e); 14906 } 14907 } 14908 14909 function getListeners() { 14910 const support = swiper.support; 14911 const passiveListener = swiper.touchEvents.start === 'touchstart' && support.passiveListener && swiper.params.passiveListeners ? { 14912 passive: true, 14913 capture: false 14914 } : false; 14915 const activeListenerWithCapture = support.passiveListener ? { 14916 passive: false, 14917 capture: true 14918 } : true; 14919 return { 14920 passiveListener, 14921 activeListenerWithCapture 14922 }; 14923 } 14924 14925 function getSlideSelector() { 14926 return `.${swiper.params.slideClass}`; 14927 } 14928 14929 function toggleGestures(method) { 14930 const { 14931 passiveListener 14932 } = getListeners(); 14933 const slideSelector = getSlideSelector(); 14934 swiper.$wrapperEl[method]('gesturestart', slideSelector, onGestureStart, passiveListener); 14935 swiper.$wrapperEl[method]('gesturechange', slideSelector, onGestureChange, passiveListener); 14936 swiper.$wrapperEl[method]('gestureend', slideSelector, onGestureEnd, passiveListener); 14937 } 14938 14939 function enableGestures() { 14940 if (gesturesEnabled) return; 14941 gesturesEnabled = true; 14942 toggleGestures('on'); 14943 } 14944 14945 function disableGestures() { 14946 if (!gesturesEnabled) return; 14947 gesturesEnabled = false; 14948 toggleGestures('off'); 14949 } // Attach/Detach Events 14950 14951 14952 function enable() { 14953 const zoom = swiper.zoom; 14954 if (zoom.enabled) return; 14955 zoom.enabled = true; 14956 const support = swiper.support; 14957 const { 14958 passiveListener, 14959 activeListenerWithCapture 14960 } = getListeners(); 14961 const slideSelector = getSlideSelector(); // Scale image 14962 14963 if (support.gestures) { 14964 swiper.$wrapperEl.on(swiper.touchEvents.start, enableGestures, passiveListener); 14965 swiper.$wrapperEl.on(swiper.touchEvents.end, disableGestures, passiveListener); 14966 } else if (swiper.touchEvents.start === 'touchstart') { 14967 swiper.$wrapperEl.on(swiper.touchEvents.start, slideSelector, onGestureStart, passiveListener); 14968 swiper.$wrapperEl.on(swiper.touchEvents.move, slideSelector, onGestureChange, activeListenerWithCapture); 14969 swiper.$wrapperEl.on(swiper.touchEvents.end, slideSelector, onGestureEnd, passiveListener); 14970 14971 if (swiper.touchEvents.cancel) { 14972 swiper.$wrapperEl.on(swiper.touchEvents.cancel, slideSelector, onGestureEnd, passiveListener); 14973 } 14974 } // Move image 14975 14976 14977 swiper.$wrapperEl.on(swiper.touchEvents.move, `.${swiper.params.zoom.containerClass}`, onTouchMove, activeListenerWithCapture); 14978 } 14979 14980 function disable() { 14981 const zoom = swiper.zoom; 14982 if (!zoom.enabled) return; 14983 const support = swiper.support; 14984 zoom.enabled = false;
14985 const { 14986 passiveListener, 14987 activeListenerWithCapture 14988 } = getListeners(); 14989 const slideSelector = getSlideSelector(); // Scale image 14990 14991 if (support.gestures) { 14992 swiper.$wrapperEl.off(swiper.touchEvents.start, enableGestures, passiveListener); 14993 swiper.$wrapperEl.off(swiper.touchEvents.end, disableGestures, passiveListener); 14994 } else if (swiper.touchEvents.start === 'touchstart') { 14995 swiper.$wrapperEl.off(swiper.touchEvents.start, slideSelector, onGestureStart, passiveListener); 14996 swiper.$wrapperEl.off(swiper.touchEvents.move, slideSelector, onGestureChange, activeListenerWithCapture); 14997 swiper.$wrapperEl.off(swiper.touchEvents.end, slideSelector, onGestureEnd, passiveListener); 14998 14999 if (swiper.touchEvents.cancel) { 15000 swiper.$wrapperEl.off(swiper.touchEvents.cancel, slideSelector, onGestureEnd, passiveListener); 15001 } 15002 } // Move image 15003 15004 15005 swiper.$wrapperEl.off(swiper.touchEvents.move, `.${swiper.params.zoom.containerClass}`, onTouchMove, activeListenerWithCapture); 15006 } 15007 15008 on('init', () => { 15009 if (swiper.params.zoom.enabled) { 15010 enable(); 15011 } 15012 }); 15013 on('destroy', () => { 15014 disable(); 15015 }); 15016 on('touchStart', (_s, e) => { 15017 if (!swiper.zoom.enabled) return; 15018 onTouchStart(e); 15019 }); 15020 on('touchEnd', (_s, e) => { 15021 if (!swiper.zoom.enabled) return; 15022 onTouchEnd(); 15023 }); 15024 on('doubleTap', (_s, e) => { 15025 if (!swiper.animating && swiper.params.zoom.enabled && swiper.zoom.enabled && swiper.params.zoom.toggle) { 15026 zoomToggle(e); 15027 } 15028 }); 15029 on('transitionEnd', () => { 15030 if (swiper.zoom.enabled && swiper.params.zoom.enabled) { 15031 onTransitionEnd(); 15032 } 15033 }); 15034 on('slideChange', () => { 15035 if (swiper.zoom.enabled && swiper.params.zoom.enabled && swiper.params.cssMode) { 15036 onTransitionEnd(); 15037 } 15038 }); 15039 Object.assign(swiper.zoom, { 15040 enable, 15041 disable, 15042 in: zoomIn, 15043 out: zoomOut, 15044 toggle: zoomToggle 15045 }); 15046 } 15047 15048 function Lazy(_ref) { 15049 let { 15050 swiper, 15051 extendParams, 15052 on, 15053 emit 15054 } = _ref; 15055 extendParams({ 15056 lazy: { 15057 checkInView: false, 15058 enabled: false, 15059 loadPrevNext: false, 15060 loadPrevNextAmount: 1, 15061 loadOnTransitionStart: false, 15062 scrollingElement: '', 15063 elementClass: 'swiper-lazy', 15064 loadingClass: 'swiper-lazy-loading', 15065 loadedClass: 'swiper-lazy-loaded', 15066 preloaderClass: 'swiper-lazy-preloader' 15067 } 15068 }); 15069 swiper.lazy = {}; 15070 let scrollHandlerAttached = false; 15071 let initialImageLoaded = false; 15072 15073 function loadInSlide(index, loadInDuplicate) { 15074 if (loadInDuplicate === void 0) { 15075 loadInDuplicate = true; 15076 } 15077 15078 const params = swiper.params.lazy; 15079 if (typeof index === 'undefined') return; 15080 if (swiper.slides.length === 0) return; 15081 const isVirtual = swiper.virtual && swiper.params.virtual.enabled; 15082 const $slideEl = isVirtual ? swiper.$wrapperEl.children(`.${swiper.params.slideClass}[data-swiper-slide-index="${index}"]`) : swiper.slides.eq(index); 15083 const $images = $slideEl.find(`.${params.elementClass}:not(.${params.loadedClass}):not(.${params.loadingClass})`); 15084 15085 if ($slideEl.hasClass(params.elementClass) && !$slideEl.hasClass(params.loadedClass) && !$slideEl.hasClass(params.loadingClass)) { 15086 $images.push($slideEl[0]); 15087 } 15088 15089 if ($images.length === 0) return; 15090 $images.each(imageEl => { 15091 const $imageEl = $(imageEl); 15092 $imageEl.addClass(params.loadingClass); 15093 const background = $imageEl.attr('data-background'); 15094 const src = $imageEl.attr('data-src'); 15095 const srcset = $imageEl.attr('data-srcset'); 15096 const sizes = $imageEl.attr('data-sizes'); 15097 const $pictureEl = $imageEl.parent('picture'); 15098 swiper.loadImage($imageEl[0], src || background, srcset, sizes, false, () => { 15099 if (typeof swiper === 'undefined' || swiper === null || !swiper || swiper && !swiper.params || swiper.destroyed) return; 15100 15101 if (background) { 15102 $imageEl.css('background-image', `url("${background}")`); 15103 $imageEl.removeAttr('data-background'); 15104 } else { 15105 if (srcset) { 15106 $imageEl.attr('srcset', srcset); 15107 $imageEl.removeAttr('data-srcset'); 15108 } 15109 15110 if (sizes) { 15111 $imageEl.attr('sizes', sizes); 15112 $imageEl.removeAttr('data-sizes'); 15113 } 15114 15115 if ($pictureEl.length) { 15116 $pictureEl.children('source').each(sourceEl => { 15117 const $source = $(sourceEl); 15118 15119 if ($source.attr('data-srcset')) { 15120 $source.attr('srcset', $source.attr('data-srcset')); 15121 $source.removeAttr('data-srcset'); 15122 } 15123 }); 15124 } 15125 15126 if (src) { 15127 $imageEl.attr('src', src); 15128 $imageEl.removeAttr('data-src'); 15129 } 15130 } 15131 15132 $imageEl.addClass(params.loadedClass).removeClass(params.loadingClass); 15133 $slideEl.find(`.${params.preloaderClass}`).remove(); 15134
15135 if (swiper.params.loop && loadInDuplicate) { 15136 const slideOriginalIndex = $slideEl.attr('data-swiper-slide-index'); 15137 15138 if ($slideEl.hasClass(swiper.params.slideDuplicateClass)) { 15139 const originalSlide = swiper.$wrapperEl.children(`[data-swiper-slide-index="${slideOriginalIndex}"]:not(.${swiper.params.slideDuplicateClass})`); 15140 loadInSlide(originalSlide.index(), false); 15141 } else { 15142 const duplicatedSlide = swiper.$wrapperEl.children(`.${swiper.params.slideDuplicateClass}[data-swiper-slide-index="${slideOriginalIndex}"]`); 15143 loadInSlide(duplicatedSlide.index(), false); 15144 } 15145 } 15146 15147 emit('lazyImageReady', $slideEl[0], $imageEl[0]); 15148 15149 if (swiper.params.autoHeight) { 15150 swiper.updateAutoHeight(); 15151 } 15152 }); 15153 emit('lazyImageLoad', $slideEl[0], $imageEl[0]); 15154 }); 15155 } 15156 15157 function load() { 15158 const { 15159 $wrapperEl, 15160 params: swiperParams, 15161 slides, 15162 activeIndex 15163 } = swiper; 15164 const isVirtual = swiper.virtual && swiperParams.virtual.enabled; 15165 const params = swiperParams.lazy; 15166 let slidesPerView = swiperParams.slidesPerView; 15167 15168 if (slidesPerView === 'auto') { 15169 slidesPerView = 0; 15170 } 15171 15172 function slideExist(index) { 15173 if (isVirtual) { 15174 if ($wrapperEl.children(`.${swiperParams.slideClass}[data-swiper-slide-index="${index}"]`).length) { 15175 return true; 15176 } 15177 } else if (slides[index]) return true; 15178 15179 return false; 15180 } 15181 15182 function slideIndex(slideEl) { 15183 if (isVirtual) { 15184 return $(slideEl).attr('data-swiper-slide-index'); 15185 } 15186 15187 return $(slideEl).index(); 15188 } 15189 15190 if (!initialImageLoaded) initialImageLoaded = true; 15191 15192 if (swiper.params.watchSlidesProgress) { 15193 $wrapperEl.children(`.${swiperParams.slideVisibleClass}`).each(slideEl => { 15194 const index = isVirtual ? $(slideEl).attr('data-swiper-slide-index') : $(slideEl).index(); 15195 loadInSlide(index); 15196 }); 15197 } else if (slidesPerView > 1) { 15198 for (let i = activeIndex; i < activeIndex + slidesPerView; i += 1) { 15199 if (slideExist(i)) loadInSlide(i); 15200 } 15201 } else { 15202 loadInSlide(activeIndex); 15203 } 15204 15205 if (params.loadPrevNext) { 15206 if (slidesPerView > 1 || params.loadPrevNextAmount && params.loadPrevNextAmount > 1) { 15207 const amount = params.loadPrevNextAmount; 15208 const spv = Math.ceil(slidesPerView); 15209 const maxIndex = Math.min(activeIndex + spv + Math.max(amount, spv), slides.length); 15210 const minIndex = Math.max(activeIndex - Math.max(spv, amount), 0); // Next Slides 15211 15212 for (let i = activeIndex + spv; i < maxIndex; i += 1) { 15213 if (slideExist(i)) loadInSlide(i); 15214 } // Prev Slides 15215 15216 15217 for (let i = minIndex; i < activeIndex; i += 1) { 15218 if (slideExist(i)) loadInSlide(i); 15219 } 15220 } else { 15221 const nextSlide = $wrapperEl.children(`.${swiperParams.slideNextClass}`); 15222 if (nextSlide.length > 0) loadInSlide(slideIndex(nextSlide)); 15223 const prevSlide = $wrapperEl.children(`.${swiperParams.slidePrevClass}`); 15224 if (prevSlide.length > 0) loadInSlide(slideIndex(prevSlide)); 15225 } 15226 } 15227 } 15228 15229 function checkInViewOnLoad() { 15230 const window = getWindow(); 15231 if (!swiper || swiper.destroyed) return; 15232 const $scrollElement = swiper.params.lazy.scrollingElement ? $(swiper.params.lazy.scrollingElement) : $(window); 15233 const isWindow = $scrollElement[0] === window; 15234 const scrollElementWidth = isWindow ? window.innerWidth : $scrollElement[0].offsetWidth; 15235 const scrollElementHeight = isWindow ? window.innerHeight : $scrollElement[0].offsetHeight; 15236 const swiperOffset = swiper.$el.offset(); 15237 const { 15238 rtlTranslate: rtl 15239 } = swiper; 15240 let inView = false;
15241 if (rtl) swiperOffset.left -= swiper.$el[0].scrollLeft; 15242 const swiperCoord = [[swiperOffset.left, swiperOffset.top], [swiperOffset.left + swiper.width, swiperOffset.top], [swiperOffset.left, swiperOffset.top + swiper.height], [swiperOffset.left + swiper.width, swiperOffset.top + swiper.height]]; 15243 15244 for (let i = 0; i < swiperCoord.length; i += 1) { 15245 const point = swiperCoord[i]; 15246 15247 if (point[0] >= 0 && point[0] <= scrollElementWidth && point[1] >= 0 && point[1] <= scrollElementHeight) { 15248 if (point[0] === 0 && point[1] === 0) continue; // eslint-disable-line 15249 15250 inView = true; 15251 } 15252 } 15253 15254 const passiveListener = swiper.touchEvents.start === 'touchstart' && swiper.support.passiveListener && swiper.params.passiveListeners ? { 15255 passive: true, 15256 capture: false 15257 } : false; 15258 15259 if (inView) { 15260 load(); 15261 $scrollElement.off('scroll', checkInViewOnLoad, passiveListener); 15262 } else if (!scrollHandlerAttached) { 15263 scrollHandlerAttached = true; 15264 $scrollElement.on('scroll', checkInViewOnLoad, passiveListener); 15265 } 15266 } 15267 15268 on('beforeInit', () => { 15269 if (swiper.params.lazy.enabled && swiper.params.preloadImages) { 15270 swiper.params.preloadImages = false; 15271 } 15272 }); 15273 on('init', () => { 15274 if (swiper.params.lazy.enabled) { 15275 if (swiper.params.lazy.checkInView) { 15276 checkInViewOnLoad(); 15277 } else { 15278 load(); 15279 } 15280 } 15281 }); 15282 on('scroll', () => { 15283 if (swiper.params.freeMode && swiper.params.freeMode.enabled && !swiper.params.freeMode.sticky) { 15284 load(); 15285 } 15286 }); 15287 on('scrollbarDragMove resize _freeModeNoMomentumRelease', () => { 15288 if (swiper.params.lazy.enabled) { 15289 if (swiper.params.lazy.checkInView) { 15290 checkInViewOnLoad(); 15291 } else { 15292 load(); 15293 } 15294 } 15295 }); 15296 on('transitionStart', () => { 15297 if (swiper.params.lazy.enabled) { 15298 if (swiper.params.lazy.loadOnTransitionStart || !swiper.params.lazy.loadOnTransitionStart && !initialImageLoaded) { 15299 if (swiper.params.lazy.checkInView) { 15300 checkInViewOnLoad(); 15301 } else { 15302 load(); 15303 } 15304 } 15305 } 15306 }); 15307 on('transitionEnd', () => { 15308 if (swiper.params.lazy.enabled && !swiper.params.lazy.loadOnTransitionStart) { 15309 if (swiper.params.lazy.checkInView) { 15310 checkInViewOnLoad(); 15311 } else { 15312 load(); 15313 } 15314 } 15315 }); 15316 on('slideChange', () => { 15317 const { 15318 lazy, 15319 cssMode, 15320 watchSlidesProgress, 15321 touchReleaseOnEdges, 15322 resistanceRatio 15323 } = swiper.params; 15324 15325 if (lazy.enabled && (cssMode || watchSlidesProgress && (touchReleaseOnEdges || resistanceRatio === 0))) { 15326 load(); 15327 } 15328 }); 15329 on('destroy', () => { 15330 if (!swiper.$el) return; 15331 swiper.$el.find(`.${swiper.params.lazy.loadingClass}`).removeClass(swiper.params.lazy.loadingClass); 15332 }); 15333 Object.assign(swiper.lazy, { 15334 load, 15335 loadInSlide 15336 }); 15337 } 15338 15339 /* eslint no-bitwise: ["error", { "allow": [">>"] }] */ 15340 function Controller(_ref) { 15341 let { 15342 swiper, 15343 extendParams, 15344 on 15345 } = _ref; 15346 extendParams({ 15347 controller: { 15348 control: undefined, 15349 inverse: false, 15350 by: 'slide' // or 'container' 15351 15352 } 15353 }); 15354 swiper.controller = { 15355 control: undefined 15356 }; 15357 15358 function LinearSpline(x, y) { 15359 const binarySearch = function search() { 15360 let maxIndex; 15361 let minIndex; 15362 let guess; 15363 return (array, val) => { 15364 minIndex = -1; 15365 maxIndex = array.length; 15366 15367 while (maxIndex - minIndex > 1) { 15368 guess = maxIndex + minIndex >> 1; 15369 15370 if (array[guess] <= val) { 15371 minIndex = guess; 15372 } else { 15373 maxIndex = guess; 15374 } 15375 } 15376
vendor: 6,111 bytes, lines 15377-15554
15377 return maxIndex; 15378 }; 15379 }(); 15380 15381 this.x = x; 15382 this.y = y; 15383 this.lastIndex = x.length - 1; // Given an x value (x2), return the expected y2 value: 15384 // (x1,y1) is the known point before given value, 15385 // (x3,y3) is the known point after given value. 15386 15387 let i1; 15388 let i3; 15389 15390 this.interpolate = function interpolate(x2) { 15391 if (!x2) return 0; // Get the indexes of x1 and x3 (the array indexes before and after given x2): 15392 15393 i3 = binarySearch(this.x, x2); 15394 i1 = i3 - 1; // We have our indexes i1 & i3, so we can calculate already: 15395 // y2 := ((x2âx1) à (y3ây1)) ÷ (x3âx1) + y1 15396 15397 return (x2 - this.x[i1]) * (this.y[i3] - this.y[i1]) / (this.x[i3] - this.x[i1]) + this.y[i1]; 15398 }; 15399 15400 return this; 15401 } // xxx: for now i will just save one spline function to to 15402 15403 15404 function getInterpolateFunction(c) { 15405 if (!swiper.controller.spline) { 15406 swiper.controller.spline = swiper.params.loop ? new LinearSpline(swiper.slidesGrid, c.slidesGrid) : new LinearSpline(swiper.snapGrid, c.snapGrid); 15407 } 15408 } 15409 15410 function setTranslate(_t, byController) { 15411 const controlled = swiper.controller.control; 15412 let multiplier; 15413 let controlledTranslate; 15414 const Swiper = swiper.constructor; 15415 15416 function setControlledTranslate(c) { 15417 // this will create an Interpolate function based on the snapGrids 15418 // x is the Grid of the scrolled scroller and y will be the controlled scroller 15419 // it makes sense to create this only once and recall it for the interpolation 15420 // the function does a lot of value caching for performance 15421 const translate = swiper.rtlTranslate ? -swiper.translate : swiper.translate; 15422 15423 if (swiper.params.controller.by === 'slide') { 15424 getInterpolateFunction(c); // i am not sure why the values have to be multiplicated this way, tried to invert the snapGrid 15425 // but it did not work out 15426 15427 controlledTranslate = -swiper.controller.spline.interpolate(-translate); 15428 } 15429 15430 if (!controlledTranslate || swiper.params.controller.by === 'container') { 15431 multiplier = (c.maxTranslate() - c.minTranslate()) / (swiper.maxTranslate() - swiper.minTranslate()); 15432 controlledTranslate = (translate - swiper.minTranslate()) * multiplier + c.minTranslate(); 15433 } 15434 15435 if (swiper.params.controller.inverse) { 15436 controlledTranslate = c.maxTranslate() - controlledTranslate; 15437 } 15438 15439 c.updateProgress(controlledTranslate); 15440 c.setTranslate(controlledTranslate, swiper); 15441 c.updateActiveIndex(); 15442 c.updateSlidesClasses(); 15443 } 15444 15445 if (Array.isArray(controlled)) { 15446 for (let i = 0; i < controlled.length; i += 1) { 15447 if (controlled[i] !== byController && controlled[i] instanceof Swiper) { 15448 setControlledTranslate(controlled[i]); 15449 } 15450 } 15451 } else if (controlled instanceof Swiper && byController !== controlled) { 15452 setControlledTranslate(controlled); 15453 } 15454 } 15455 15456 function setTransition(duration, byController) { 15457 const Swiper = swiper.constructor; 15458 const controlled = swiper.controller.control; 15459 let i; 15460 15461 function setControlledTransition(c) { 15462 c.setTransition(duration, swiper); 15463 15464 if (duration !== 0) { 15465 c.transitionStart(); 15466 15467 if (c.params.autoHeight) { 15468 nextTick(() => { 15469 c.updateAutoHeight(); 15470 }); 15471 } 15472 15473 c.$wrapperEl.transitionEnd(() => { 15474 if (!controlled) return; 15475 15476 if (c.params.loop && swiper.params.controller.by === 'slide') { 15477 c.loopFix(); 15478 } 15479 15480 c.transitionEnd(); 15481 }); 15482 } 15483 } 15484 15485 if (Array.isArray(controlled)) { 15486 for (i = 0; i < controlled.length; i += 1) { 15487 if (controlled[i] !== byController && controlled[i] instanceof Swiper) { 15488 setControlledTransition(controlled[i]); 15489 } 15490 } 15491 } else if (controlled instanceof Swiper && byController !== controlled) { 15492 setControlledTransition(controlled); 15493 } 15494 } 15495 15496 function removeSpline() { 15497 if (!swiper.controller.control) return; 15498 15499 if (swiper.controller.spline) { 15500 swiper.controller.spline = undefined; 15501 delete swiper.controller.spline; 15502 } 15503 } 15504 15505 on('beforeInit', () => { 15506 swiper.controller.control = swiper.params.controller.control; 15507 }); 15508 on('update', () => { 15509 removeSpline(); 15510 }); 15511 on('resize', () => { 15512 removeSpline(); 15513 }); 15514 on('observerUpdate', () => { 15515 removeSpline(); 15516 }); 15517 on('setTranslate', (_s, translate, byController) => { 15518 if (!swiper.controller.control) return; 15519 swiper.controller.setTranslate(translate, byController); 15520 }); 15521 on('setTransition', (_s, duration, byController) => { 15522 if (!swiper.controller.control) return; 15523 swiper.controller.setTransition(duration, byController); 15524 }); 15525 Object.assign(swiper.controller, { 15526 setTranslate, 15527 setTransition 15528 }); 15529 } 15530 15531 function A11y(_ref) { 15532 let { 15533 swiper, 15534 extendParams, 15535 on 15536 } = _ref; 15537 extendParams({ 15538 a11y: { 15539 enabled: true, 15540 notificationClass: 'swiper-notification', 15541 prevSlideMessage: 'Previous slide', 15542 nextSlideMessage: 'Next slide', 15543 firstSlideMessage: 'This is the first slide', 15544 lastSlideMessage: 'This is the last slide', 15545 paginationBulletMessage: 'Go to slide {{index}}', 15546 slideLabelMessage: '{{index}} / {{slidesLength}}', 15547 containerMessage: null, 15548 containerRoleDescriptionMessage: null, 15549 itemRoleDescriptionMessage: null, 15550 slideRole: 'group', 15551 id: null 15552 } 15553 }); 15554 swiper.a11y = {
15555 clicked: false 15556 }; 15557 let liveRegion = null; 15558 15559 function notify(message) { 15560 const notification = liveRegion; 15561 if (notification.length === 0) return; 15562 notification.html(''); 15563 notification.html(message); 15564 } 15565 15566 function getRandomNumber(size) { 15567 if (size === void 0) { 15568 size = 16; 15569 } 15570 15571 const randomChar = () => Math.round(16 * Math.random()).toString(16); 15572 15573 return 'x'.repeat(size).replace(/x/g, randomChar); 15574 } 15575 15576 function makeElFocusable($el) { 15577 $el.attr('tabIndex', '0'); 15578 } 15579 15580 function makeElNotFocusable($el) { 15581 $el.attr('tabIndex', '-1'); 15582 } 15583 15584 function addElRole($el, role) { 15585 $el.attr('role', role); 15586 } 15587 15588 function addElRoleDescription($el, description) { 15589 $el.attr('aria-roledescription', description); 15590 } 15591 15592 function addElControls($el, controls) { 15593 $el.attr('aria-controls', controls); 15594 } 15595 15596 function addElLabel($el, label) { 15597 $el.attr('aria-label', label); 15598 } 15599 15600 function addElId($el, id) { 15601 $el.attr('id', id); 15602 } 15603 15604 function addElLive($el, live) { 15605 $el.attr('aria-live', live); 15606 } 15607 15608 function disableEl($el) { 15609 $el.attr('aria-disabled', true); 15610 } 15611 15612 function enableEl($el) { 15613 $el.attr('aria-disabled', false); 15614 } 15615 15616 function onEnterOrSpaceKey(e) { 15617 if (e.keyCode !== 13 && e.keyCode !== 32) return; 15618 const params = swiper.params.a11y; 15619 const $targetEl = $(e.target); 15620 15621 if (swiper.navigation && swiper.navigation.$nextEl && $targetEl.is(swiper.navigation.$nextEl)) { 15622 if (!(swiper.isEnd && !swiper.params.loop)) { 15623 swiper.slideNext(); 15624 } 15625 15626 if (swiper.isEnd) { 15627 notify(params.lastSlideMessage); 15628 } else { 15629 notify(params.nextSlideMessage); 15630 } 15631 } 15632 15633 if (swiper.navigation && swiper.navigation.$prevEl && $targetEl.is(swiper.navigation.$prevEl)) { 15634 if (!(swiper.isBeginning && !swiper.params.loop)) { 15635 swiper.slidePrev(); 15636 } 15637 15638 if (swiper.isBeginning) { 15639 notify(params.firstSlideMessage); 15640 } else { 15641 notify(params.prevSlideMessage); 15642 } 15643 } 15644 15645 if (swiper.pagination && $targetEl.is(classesToSelector(swiper.params.pagination.bulletClass))) { 15646 $targetEl[0].click(); 15647 } 15648 } 15649 15650 function updateNavigation() { 15651 if (swiper.params.loop || swiper.params.rewind || !swiper.navigation) return; 15652 const { 15653 $nextEl, 15654 $prevEl 15655 } = swiper.navigation; 15656 15657 if ($prevEl && $prevEl.length > 0) { 15658 if (swiper.isBeginning) { 15659 disableEl($prevEl); 15660 makeElNotFocusable($prevEl); 15661 } else { 15662 enableEl($prevEl); 15663 makeElFocusable($prevEl); 15664 } 15665 } 15666 15667 if ($nextEl && $nextEl.length > 0) { 15668 if (swiper.isEnd) { 15669 disableEl($nextEl); 15670 makeElNotFocusable($nextEl); 15671 } else { 15672 enableEl($nextEl); 15673 makeElFocusable($nextEl); 15674 } 15675 } 15676 } 15677 15678 function hasPagination() { 15679 return swiper.pagination && swiper.pagination.bullets && swiper.pagination.bullets.length; 15680 } 15681 15682 function hasClickablePagination() { 15683 return hasPagination() && swiper.params.pagination.clickable; 15684 } 15685 15686 function updatePagination() { 15687 const params = swiper.params.a11y; 15688 if (!hasPagination()) return; 15689 swiper.pagination.bullets.each(bulletEl => { 15690 const $bulletEl = $(bulletEl); 15691 15692 if (swiper.params.pagination.clickable) { 15693 makeElFocusable($bulletEl); 15694 15695 if (!swiper.params.pagination.renderBullet) { 15696 addElRole($bulletEl, 'button'); 15697 addElLabel($bulletEl, params.paginationBulletMessage.replace(/\{\{index\}\}/, $bulletEl.index() + 1)); 15698 } 15699 } 15700 15701 if ($bulletEl.is(`.${swiper.params.pagination.bulletActiveClass}`)) { 15702 $bulletEl.attr('aria-current', 'true'); 15703 } else { 15704 $bulletEl.removeAttr('aria-current'); 15705 } 15706 }); 15707 } 15708 15709 const initNavEl = ($el, wrapperId, message) => { 15710 makeElFocusable($el); 15711 15712 if ($el[0].tagName !== 'BUTTON') { 15713 addElRole($el, 'button'); 15714 $el.on('keydown', onEnterOrSpaceKey); 15715 } 15716 15717 addElLabel($el, message); 15718 addElControls($el, wrapperId); 15719 }; 15720 15721 const handlePointerDown = () => { 15722 swiper.a11y.clicked = true; 15723 }; 15724 15725 const handlePointerUp = () => { 15726 requestAnimationFrame(() => { 15727 requestAnimationFrame(() => { 15728 if (!swiper.destroyed) { 15729 swiper.a11y.clicked = false;
15730 } 15731 }); 15732 }); 15733 }; 15734 15735 const handleFocus = e => { 15736 if (swiper.a11y.clicked) return; 15737 const slideEl = e.target.closest(`.${swiper.params.slideClass}`); 15738 if (!slideEl || !swiper.slides.includes(slideEl)) return; 15739 const isActive = swiper.slides.indexOf(slideEl) === swiper.activeIndex; 15740 const isVisible = swiper.params.watchSlidesProgress && swiper.visibleSlides && swiper.visibleSlides.includes(slideEl); 15741 if (isActive || isVisible) return; 15742 if (e.sourceCapabilities && e.sourceCapabilities.firesTouchEvents) return; 15743 15744 if (swiper.isHorizontal()) { 15745 swiper.el.scrollLeft = 0; 15746 } else { 15747 swiper.el.scrollTop = 0; 15748 } 15749 15750 swiper.slideTo(swiper.slides.indexOf(slideEl), 0); 15751 }; 15752 15753 const initSlides = () => { 15754 const params = swiper.params.a11y; 15755 15756 if (params.itemRoleDescriptionMessage) { 15757 addElRoleDescription($(swiper.slides), params.itemRoleDescriptionMessage); 15758 } 15759 15760 if (params.slideRole) { 15761 addElRole($(swiper.slides), params.slideRole); 15762 } 15763 15764 const slidesLength = swiper.params.loop ? swiper.slides.filter(el => !el.classList.contains(swiper.params.slideDuplicateClass)).length : swiper.slides.length; 15765 15766 if (params.slideLabelMessage) { 15767 swiper.slides.each((slideEl, index) => { 15768 const $slideEl = $(slideEl); 15769 const slideIndex = swiper.params.loop ? parseInt($slideEl.attr('data-swiper-slide-index'), 10) : index; 15770 const ariaLabelMessage = params.slideLabelMessage.replace(/\{\{index\}\}/, slideIndex + 1).replace(/\{\{slidesLength\}\}/, slidesLength); 15771 addElLabel($slideEl, ariaLabelMessage); 15772 }); 15773 } 15774 }; 15775 15776 const init = () => { 15777 const params = swiper.params.a11y; 15778 swiper.$el.append(liveRegion); // Container 15779 15780 const $containerEl = swiper.$el; 15781 15782 if (params.containerRoleDescriptionMessage) { 15783 addElRoleDescription($containerEl, params.containerRoleDescriptionMessage); 15784 } 15785 15786 if (params.containerMessage) { 15787 addElLabel($containerEl, params.containerMessage); 15788 } // Wrapper 15789 15790 15791 const $wrapperEl = swiper.$wrapperEl; 15792 const wrapperId = params.id || $wrapperEl.attr('id') || `swiper-wrapper-${getRandomNumber(16)}`; 15793 const live = swiper.params.autoplay && swiper.params.autoplay.enabled ? 'off' : 'polite'; 15794 addElId($wrapperEl, wrapperId); 15795 addElLive($wrapperEl, live); // Slide 15796 15797 initSlides(); // Navigation 15798 15799 let $nextEl; 15800 let $prevEl; 15801 15802 if (swiper.navigation && swiper.navigation.$nextEl) { 15803 $nextEl = swiper.navigation.$nextEl; 15804 } 15805 15806 if (swiper.navigation && swiper.navigation.$prevEl) { 15807 $prevEl = swiper.navigation.$prevEl; 15808 } 15809 15810 if ($nextEl && $nextEl.length) { 15811 initNavEl($nextEl, wrapperId, params.nextSlideMessage); 15812 } 15813 15814 if ($prevEl && $prevEl.length) { 15815 initNavEl($prevEl, wrapperId, params.prevSlideMessage); 15816 } // Pagination 15817 15818 15819 if (hasClickablePagination()) { 15820 swiper.pagination.$el.on('keydown', classesToSelector(swiper.params.pagination.bulletClass), onEnterOrSpaceKey); 15821 } // Tab focus 15822 15823 15824 swiper.$el.on('focus', handleFocus, true); 15825 swiper.$el.on('pointerdown', handlePointerDown, true); 15826 swiper.$el.on('pointerup', handlePointerUp, true); 15827 }; 15828 15829 function destroy() { 15830 if (liveRegion && liveRegion.length > 0) liveRegion.remove(); 15831 let $nextEl; 15832 let $prevEl; 15833 15834 if (swiper.navigation && swiper.navigation.$nextEl) { 15835 $nextEl = swiper.navigation.$nextEl; 15836 } 15837 15838 if (swiper.navigation && swiper.navigation.$prevEl) { 15839 $prevEl = swiper.navigation.$prevEl; 15840 } 15841 15842 if ($nextEl) { 15843 $nextEl.off('keydown', onEnterOrSpaceKey); 15844 } 15845 15846 if ($prevEl) { 15847 $prevEl.off('keydown', onEnterOrSpaceKey); 15848 } // Pagination 15849 15850 15851 if (hasClickablePagination()) { 15852 swiper.pagination.$el.off('keydown', classesToSelector(swiper.params.pagination.bulletClass), onEnterOrSpaceKey); 15853 } // Tab focus 15854 15855 15856 swiper.$el.off('focus', handleFocus, true); 15857 swiper.$el.off('pointerdown', handlePointerDown, true); 15858 swiper.$el.off('pointerup', handlePointerUp, true); 15859 } 15860 15861 on('beforeInit', () => { 15862 liveRegion = $(`<span class="${swiper.params.a11y.notificationClass}
vendor: 5,355 bytes, lines 15862-16049
15862" aria-live="assertive" aria-atomic="true"></span>`); 15863 }); 15864 on('afterInit', () => { 15865 if (!swiper.params.a11y.enabled) return; 15866 init(); 15867 }); 15868 on('slidesLengthChange snapGridLengthChange slidesGridLengthChange', () => { 15869 if (!swiper.params.a11y.enabled) return; 15870 initSlides(); 15871 }); 15872 on('fromEdge toEdge afterInit lock unlock', () => { 15873 if (!swiper.params.a11y.enabled) return; 15874 updateNavigation(); 15875 }); 15876 on('paginationUpdate', () => { 15877 if (!swiper.params.a11y.enabled) return; 15878 updatePagination(); 15879 }); 15880 on('destroy', () => { 15881 if (!swiper.params.a11y.enabled) return; 15882 destroy(); 15883 }); 15884 } 15885 15886 function History(_ref) { 15887 let { 15888 swiper, 15889 extendParams, 15890 on 15891 } = _ref; 15892 extendParams({ 15893 history: { 15894 enabled: false, 15895 root: '', 15896 replaceState: false, 15897 key: 'slides', 15898 keepQuery: false 15899 } 15900 }); 15901 let initialized = false; 15902 let paths = {}; 15903 15904 const slugify = text => { 15905 return text.toString().replace(/\s+/g, '-').replace(/[^\w-]+/g, '').replace(/--+/g, '-').replace(/^-+/, '').replace(/-+$/, ''); 15906 }; 15907 15908 const getPathValues = urlOverride => { 15909 const window = getWindow(); 15910 let location; 15911 15912 if (urlOverride) { 15913 location = new URL(urlOverride); 15914 } else { 15915 location = window.location; 15916 } 15917 15918 const pathArray = location.pathname.slice(1).split('/').filter(part => part !== ''); 15919 const total = pathArray.length; 15920 const key = pathArray[total - 2]; 15921 const value = pathArray[total - 1]; 15922 return { 15923 key, 15924 value 15925 }; 15926 }; 15927 15928 const setHistory = (key, index) => { 15929 const window = getWindow(); 15930 if (!initialized || !swiper.params.history.enabled) return; 15931 let location; 15932 15933 if (swiper.params.url) { 15934 location = new URL(swiper.params.url); 15935 } else { 15936 location = window.location; 15937 } 15938 15939 const slide = swiper.slides.eq(index); 15940 let value = slugify(slide.attr('data-history')); 15941 15942 if (swiper.params.history.root.length > 0) { 15943 let root = swiper.params.history.root; 15944 if (root[root.length - 1] === '/') root = root.slice(0, root.length - 1); 15945 value = `${root}/${key}/${value}`; 15946 } else if (!location.pathname.includes(key)) { 15947 value = `${key}/${value}`; 15948 } 15949 15950 if (swiper.params.history.keepQuery) { 15951 value += location.search; 15952 } 15953 15954 const currentState = window.history.state; 15955 15956 if (currentState && currentState.value === value) { 15957 return; 15958 } 15959 15960 if (swiper.params.history.replaceState) { 15961 window.history.replaceState({ 15962 value 15963 }, null, value); 15964 } else { 15965 window.history.pushState({ 15966 value 15967 }, null, value); 15968 } 15969 }; 15970 15971 const scrollToSlide = (speed, value, runCallbacks) => { 15972 if (value) { 15973 for (let i = 0, length = swiper.slides.length; i < length; i += 1) { 15974 const slide = swiper.slides.eq(i); 15975 const slideHistory = slugify(slide.attr('data-history')); 15976 15977 if (slideHistory === value && !slide.hasClass(swiper.params.slideDuplicateClass)) { 15978 const index = slide.index(); 15979 swiper.slideTo(index, speed, runCallbacks); 15980 } 15981 } 15982 } else { 15983 swiper.slideTo(0, speed, runCallbacks); 15984 } 15985 }; 15986 15987 const setHistoryPopState = () => { 15988 paths = getPathValues(swiper.params.url); 15989 scrollToSlide(swiper.params.speed, paths.value, false); 15990 }; 15991 15992 const init = () => { 15993 const window = getWindow(); 15994 if (!swiper.params.history) return; 15995 15996 if (!window.history || !window.history.pushState) { 15997 swiper.params.history.enabled = false; 15998 swiper.params.hashNavigation.enabled = true; 15999 return; 16000 } 16001 16002 initialized = true; 16003 paths = getPathValues(swiper.params.url); 16004 if (!paths.key && !paths.value) return; 16005 scrollToSlide(0, paths.value, swiper.params.runCallbacksOnInit); 16006 16007 if (!swiper.params.history.replaceState) { 16008 window.addEventListener('popstate', setHistoryPopState); 16009 } 16010 }; 16011 16012 const destroy = () => { 16013 const window = getWindow(); 16014 16015 if (!swiper.params.history.replaceState) { 16016 window.removeEventListener('popstate', setHistoryPopState); 16017 } 16018 }; 16019 16020 on('init', () => { 16021 if (swiper.params.history.enabled) { 16022 init(); 16023 } 16024 }); 16025 on('destroy', () => { 16026 if (swiper.params.history.enabled) { 16027 destroy(); 16028 } 16029 }); 16030 on('transitionEnd _freeModeNoMomentumRelease', () => { 16031 if (initialized) { 16032 setHistory(swiper.params.history.key, swiper.activeIndex); 16033 } 16034 }); 16035 on('slideChange', () => { 16036 if (initialized && swiper.params.cssMode) { 16037 setHistory(swiper.params.history.key, swiper.activeIndex); 16038 } 16039 }); 16040 } 16041 16042 function HashNavigation(_ref) { 16043 let { 16044 swiper, 16045 extendParams, 16046 emit, 16047 on 16048 } = _ref; 16049 let initialized = false;
16050 const document = getDocument(); 16051 const window = getWindow(); 16052 extendParams({ 16053 hashNavigation: { 16054 enabled: false, 16055 replaceState: false, 16056 watchState: false 16057 } 16058 }); 16059 16060 const onHashChange = () => { 16061 emit('hashChange'); 16062 const newHash = document.location.hash.replace('#', ''); 16063 const activeSlideHash = swiper.slides.eq(swiper.activeIndex).attr('data-hash'); 16064 16065 if (newHash !== activeSlideHash) { 16066 const newIndex = swiper.$wrapperEl.children(`.${swiper.params.slideClass}[data-hash="${newHash}"]`).index(); 16067 if (typeof newIndex === 'undefined') return; 16068 swiper.slideTo(newIndex); 16069 } 16070 }; 16071 16072 const setHash = () => { 16073 if (!initialized || !swiper.params.hashNavigation.enabled) return; 16074 16075 if (swiper.params.hashNavigation.replaceState && window.history && window.history.replaceState) { 16076 window.history.replaceState(null, null, `#${swiper.slides.eq(swiper.activeIndex).attr('data-hash')}` || ''); 16077 emit('hashSet'); 16078 } else { 16079 const slide = swiper.slides.eq(swiper.activeIndex); 16080 const hash = slide.attr('data-hash') || slide.attr('data-history'); 16081 document.location.hash = hash || ''; 16082 emit('hashSet'); 16083 } 16084 }; 16085 16086 const init = () => { 16087 if (!swiper.params.hashNavigation.enabled || swiper.params.history && swiper.params.history.enabled) return; 16088 initialized = true; 16089 const hash = document.location.hash.replace('#', ''); 16090 16091 if (hash) { 16092 const speed = 0; 16093 16094 for (let i = 0, length = swiper.slides.length; i < length; i += 1) { 16095 const slide = swiper.slides.eq(i); 16096 const slideHash = slide.attr('data-hash') || slide.attr('data-history'); 16097 16098 if (slideHash === hash && !slide.hasClass(swiper.params.slideDuplicateClass)) { 16099 const index = slide.index(); 16100 swiper.slideTo(index, speed, swiper.params.runCallbacksOnInit, true); 16101 } 16102 } 16103 } 16104 16105 if (swiper.params.hashNavigation.watchState) { 16106 $(window).on('hashchange', onHashChange); 16107 } 16108 }; 16109 16110 const destroy = () => { 16111 if (swiper.params.hashNavigation.watchState) { 16112 $(window).off('hashchange', onHashChange); 16113 } 16114 }; 16115 16116 on('init', () => { 16117 if (swiper.params.hashNavigation.enabled) { 16118 init(); 16119 } 16120 }); 16121 on('destroy', () => { 16122 if (swiper.params.hashNavigation.enabled) { 16123 destroy(); 16124 } 16125 }); 16126 on('transitionEnd _freeModeNoMomentumRelease', () => { 16127 if (initialized) { 16128 setHash(); 16129 } 16130 }); 16131 on('slideChange', () => { 16132 if (initialized && swiper.params.cssMode) { 16133 setHash(); 16134 } 16135 }); 16136 } 16137 16138 /* eslint no-underscore-dangle: "off" */ 16139 function Autoplay(_ref) { 16140 let { 16141 swiper, 16142 extendParams, 16143 on, 16144 emit 16145 } = _ref; 16146 let timeout; 16147 swiper.autoplay = { 16148 running: false, 16149 paused: false 16150 }; 16151 extendParams({ 16152 autoplay: { 16153 enabled: false, 16154 delay: 3000, 16155 waitForTransition: true, 16156 disableOnInteraction: true, 16157 stopOnLastSlide: false, 16158 reverseDirection: false, 16159 pauseOnMouseEnter: false 16160 } 16161 }); 16162 16163 function run() { 16164 if (!swiper.size) { 16165 swiper.autoplay.running = false; 16166 swiper.autoplay.paused = false; 16167 return; 16168 } 16169 16170 const $activeSlideEl = swiper.slides.eq(swiper.activeIndex); 16171 let delay = swiper.params.autoplay.delay; 16172 16173 if ($activeSlideEl.attr('data-swiper-autoplay')) { 16174 delay = $activeSlideEl.attr('data-swiper-autoplay') || swiper.params.autoplay.delay; 16175 } 16176 16177 clearTimeout(timeout); 16178 timeout = nextTick(() => { 16179 let autoplayResult; 16180 16181 if (swiper.params.autoplay.reverseDirection) { 16182 if (swiper.params.loop) { 16183 swiper.loopFix(); 16184 autoplayResult = swiper.slidePrev(swiper.params.speed, true, true); 16185 emit('autoplay'); 16186 } else if (!swiper.isBeginning) { 16187 autoplayResult = swiper.slidePrev(swiper.params.speed, true, true); 16188 emit('autoplay'); 16189 } else if (!swiper.params.autoplay.stopOnLastSlide) { 16190 autoplayResult = swiper.slideTo(swiper.slides.length - 1, swiper.params.speed, true, true); 16191 emit('autoplay'); 16192 } else { 16193 stop(); 16194 } 16195 } else if (swiper.params.loop) { 16196 swiper.loopFix(); 16197 autoplayResult = swiper.slideNext(swiper.params.speed, true, true); 16198 emit('autoplay'); 16199 } else if (!swiper.isEnd) { 16200 autoplayResult = swiper.slideNext(swiper.params.speed, true, true); 16201 emit('autoplay'); 16202 } else if (!swiper.params.autoplay.stopOnLastSlide) { 16203 autoplayResult = swiper.slideTo(0, swiper.params.speed, true, true); 16204 emit('autoplay'); 16205 } else { 16206 stop(); 16207 } 16208 16209 if (swiper.params.cssMode && swiper.autoplay.running) run();else if (autoplayResult === false) { 16210 run(); 16211 } 16212 }, delay); 16213 } 16214 16215 function start() { 16216 if (typeof timeout !== 'undefined') return false;
vendor: 4,501 bytes, lines 16217-16381
16217 if (swiper.autoplay.running) return false; 16218 swiper.autoplay.running = true; 16219 emit('autoplayStart'); 16220 run(); 16221 return true; 16222 } 16223 16224 function stop() { 16225 if (!swiper.autoplay.running) return false; 16226 if (typeof timeout === 'undefined') return false; 16227 16228 if (timeout) { 16229 clearTimeout(timeout); 16230 timeout = undefined; 16231 } 16232 16233 swiper.autoplay.running = false; 16234 emit('autoplayStop'); 16235 return true; 16236 } 16237 16238 function pause(speed) { 16239 if (!swiper.autoplay.running) return; 16240 if (swiper.autoplay.paused) return; 16241 if (timeout) clearTimeout(timeout); 16242 swiper.autoplay.paused = true; 16243 16244 if (speed === 0 || !swiper.params.autoplay.waitForTransition) { 16245 swiper.autoplay.paused = false; 16246 run(); 16247 } else { 16248 ['transitionend', 'webkitTransitionEnd'].forEach(event => { 16249 swiper.$wrapperEl[0].addEventListener(event, onTransitionEnd); 16250 }); 16251 } 16252 } 16253 16254 function onVisibilityChange() { 16255 const document = getDocument(); 16256 16257 if (document.visibilityState === 'hidden' && swiper.autoplay.running) { 16258 pause(); 16259 } 16260 16261 if (document.visibilityState === 'visible' && swiper.autoplay.paused) { 16262 run(); 16263 swiper.autoplay.paused = false; 16264 } 16265 } 16266 16267 function onTransitionEnd(e) { 16268 if (!swiper || swiper.destroyed || !swiper.$wrapperEl) return; 16269 if (e.target !== swiper.$wrapperEl[0]) return; 16270 ['transitionend', 'webkitTransitionEnd'].forEach(event => { 16271 swiper.$wrapperEl[0].removeEventListener(event, onTransitionEnd); 16272 }); 16273 swiper.autoplay.paused = false; 16274 16275 if (!swiper.autoplay.running) { 16276 stop(); 16277 } else { 16278 run(); 16279 } 16280 } 16281 16282 function onMouseEnter() { 16283 if (swiper.params.autoplay.disableOnInteraction) { 16284 stop(); 16285 } else { 16286 emit('autoplayPause'); 16287 pause(); 16288 } 16289 16290 ['transitionend', 'webkitTransitionEnd'].forEach(event => { 16291 swiper.$wrapperEl[0].removeEventListener(event, onTransitionEnd); 16292 }); 16293 } 16294 16295 function onMouseLeave() { 16296 if (swiper.params.autoplay.disableOnInteraction) { 16297 return; 16298 } 16299 16300 swiper.autoplay.paused = false; 16301 emit('autoplayResume'); 16302 run(); 16303 } 16304 16305 function attachMouseEvents() { 16306 if (swiper.params.autoplay.pauseOnMouseEnter) { 16307 swiper.$el.on('mouseenter', onMouseEnter); 16308 swiper.$el.on('mouseleave', onMouseLeave); 16309 } 16310 } 16311 16312 function detachMouseEvents() { 16313 swiper.$el.off('mouseenter', onMouseEnter); 16314 swiper.$el.off('mouseleave', onMouseLeave); 16315 } 16316 16317 on('init', () => { 16318 if (swiper.params.autoplay.enabled) { 16319 start(); 16320 const document = getDocument(); 16321 document.addEventListener('visibilitychange', onVisibilityChange); 16322 attachMouseEvents(); 16323 } 16324 }); 16325 on('beforeTransitionStart', (_s, speed, internal) => { 16326 if (swiper.autoplay.running) { 16327 if (internal || !swiper.params.autoplay.disableOnInteraction) { 16328 swiper.autoplay.pause(speed); 16329 } else { 16330 stop(); 16331 } 16332 } 16333 }); 16334 on('sliderFirstMove', () => { 16335 if (swiper.autoplay.running) { 16336 if (swiper.params.autoplay.disableOnInteraction) { 16337 stop(); 16338 } else { 16339 pause(); 16340 } 16341 } 16342 }); 16343 on('touchEnd', () => { 16344 if (swiper.params.cssMode && swiper.autoplay.paused && !swiper.params.autoplay.disableOnInteraction) { 16345 run(); 16346 } 16347 }); 16348 on('destroy', () => { 16349 detachMouseEvents(); 16350 16351 if (swiper.autoplay.running) { 16352 stop(); 16353 } 16354 16355 const document = getDocument(); 16356 document.removeEventListener('visibilitychange', onVisibilityChange); 16357 }); 16358 Object.assign(swiper.autoplay, { 16359 pause, 16360 run, 16361 start, 16362 stop 16363 }); 16364 } 16365 16366 function Thumb(_ref) { 16367 let { 16368 swiper, 16369 extendParams, 16370 on 16371 } = _ref; 16372 extendParams({ 16373 thumbs: { 16374 swiper: null, 16375 multipleActiveThumbs: true, 16376 autoScrollOffset: 0, 16377 slideThumbActiveClass: 'swiper-slide-thumb-active', 16378 thumbsContainerClass: 'swiper-thumbs' 16379 } 16380 }); 16381 let initialized = false;
16382 let swiperCreated = false; 16383 swiper.thumbs = { 16384 swiper: null 16385 }; 16386 16387 function onThumbClick() { 16388 const thumbsSwiper = swiper.thumbs.swiper; 16389 if (!thumbsSwiper || thumbsSwiper.destroyed) return; 16390 const clickedIndex = thumbsSwiper.clickedIndex; 16391 const clickedSlide = thumbsSwiper.clickedSlide; 16392 if (clickedSlide && $(clickedSlide).hasClass(swiper.params.thumbs.slideThumbActiveClass)) return; 16393 if (typeof clickedIndex === 'undefined' || clickedIndex === null) return; 16394 let slideToIndex; 16395 16396 if (thumbsSwiper.params.loop) { 16397 slideToIndex = parseInt($(thumbsSwiper.clickedSlide).attr('data-swiper-slide-index'), 10); 16398 } else { 16399 slideToIndex = clickedIndex; 16400 } 16401 16402 if (swiper.params.loop) { 16403 let currentIndex = swiper.activeIndex; 16404 16405 if (swiper.slides.eq(currentIndex).hasClass(swiper.params.slideDuplicateClass)) { 16406 swiper.loopFix(); // eslint-disable-next-line 16407 16408 swiper._clientLeft = swiper.$wrapperEl[0].clientLeft; 16409 currentIndex = swiper.activeIndex; 16410 } 16411 16412 const prevIndex = swiper.slides.eq(currentIndex).prevAll(`[data-swiper-slide-index="${slideToIndex}"]`).eq(0).index(); 16413 const nextIndex = swiper.slides.eq(currentIndex).nextAll(`[data-swiper-slide-index="${slideToIndex}"]`).eq(0).index(); 16414 if (typeof prevIndex === 'undefined') slideToIndex = nextIndex;else if (typeof nextIndex === 'undefined') slideToIndex = prevIndex;else if (nextIndex - currentIndex < currentIndex - prevIndex) slideToIndex = nextIndex;else slideToIndex = prevIndex; 16415 } 16416 16417 swiper.slideTo(slideToIndex); 16418 } 16419 16420 function init() { 16421 const { 16422 thumbs: thumbsParams 16423 } = swiper.params; 16424 if (initialized) return false; 16425 initialized = true; 16426 const SwiperClass = swiper.constructor; 16427 16428 if (thumbsParams.swiper instanceof SwiperClass) { 16429 swiper.thumbs.swiper = thumbsParams.swiper; 16430 Object.assign(swiper.thumbs.swiper.originalParams, { 16431 watchSlidesProgress: true, 16432 slideToClickedSlide: false 16433 }); 16434 Object.assign(swiper.thumbs.swiper.params, { 16435 watchSlidesProgress: true, 16436 slideToClickedSlide: false 16437 }); 16438 } else if (isObject(thumbsParams.swiper)) { 16439 const thumbsSwiperParams = Object.assign({}, thumbsParams.swiper); 16440 Object.assign(thumbsSwiperParams, { 16441 watchSlidesProgress: true, 16442 slideToClickedSlide: false 16443 }); 16444 swiper.thumbs.swiper = new SwiperClass(thumbsSwiperParams); 16445 swiperCreated = true; 16446 } 16447 16448 swiper.thumbs.swiper.$el.addClass(swiper.params.thumbs.thumbsContainerClass); 16449 swiper.thumbs.swiper.on('tap', onThumbClick); 16450 return true; 16451 } 16452 16453 function update(initial) { 16454 const thumbsSwiper = swiper.thumbs.swiper; 16455 if (!thumbsSwiper || thumbsSwiper.destroyed) return; 16456 const slidesPerView = thumbsSwiper.params.slidesPerView === 'auto' ? thumbsSwiper.slidesPerViewDynamic() : thumbsSwiper.params.slidesPerView; // Activate thumbs 16457 16458 let thumbsToActivate = 1; 16459 const thumbActiveClass = swiper.params.thumbs.slideThumbActiveClass; 16460 16461 if (swiper.params.slidesPerView > 1 && !swiper.params.centeredSlides) { 16462 thumbsToActivate = swiper.params.slidesPerView; 16463 } 16464 16465 if (!swiper.params.thumbs.multipleActiveThumbs) { 16466 thumbsToActivate = 1; 16467 } 16468 16469 thumbsToActivate = Math.floor(thumbsToActivate); 16470 thumbsSwiper.slides.removeClass(thumbActiveClass); 16471 16472 if (thumbsSwiper.params.loop || thumbsSwiper.params.virtual && thumbsSwiper.params.virtual.enabled) { 16473 for (let i = 0; i < thumbsToActivate; i += 1) { 16474 thumbsSwiper.$wrapperEl.children(`[data-swiper-slide-index="${swiper.realIndex + i}"]`).addClass(thumbActiveClass); 16475 } 16476 } else { 16477 for (let i = 0; i < thumbsToActivate; i += 1) {
16478 thumbsSwiper.slides.eq(swiper.realIndex + i).addClass(thumbActiveClass); 16479 } 16480 } 16481 16482 const autoScrollOffset = swiper.params.thumbs.autoScrollOffset; 16483 const useOffset = autoScrollOffset && !thumbsSwiper.params.loop; 16484 16485 if (swiper.realIndex !== thumbsSwiper.realIndex || useOffset) { 16486 let currentThumbsIndex = thumbsSwiper.activeIndex; 16487 let newThumbsIndex; 16488 let direction; 16489 16490 if (thumbsSwiper.params.loop) { 16491 if (thumbsSwiper.slides.eq(currentThumbsIndex).hasClass(thumbsSwiper.params.slideDuplicateClass)) { 16492 thumbsSwiper.loopFix(); // eslint-disable-next-line 16493 16494 thumbsSwiper._clientLeft = thumbsSwiper.$wrapperEl[0].clientLeft; 16495 currentThumbsIndex = thumbsSwiper.activeIndex; 16496 } // Find actual thumbs index to slide to 16497 16498 16499 const prevThumbsIndex = thumbsSwiper.slides.eq(currentThumbsIndex).prevAll(`[data-swiper-slide-index="${swiper.realIndex}"]`).eq(0).index(); 16500 const nextThumbsIndex = thumbsSwiper.slides.eq(currentThumbsIndex).nextAll(`[data-swiper-slide-index="${swiper.realIndex}"]`).eq(0).index(); 16501 16502 if (typeof prevThumbsIndex === 'undefined') { 16503 newThumbsIndex = nextThumbsIndex; 16504 } else if (typeof nextThumbsIndex === 'undefined') { 16505 newThumbsIndex = prevThumbsIndex; 16506 } else if (nextThumbsIndex - currentThumbsIndex === currentThumbsIndex - prevThumbsIndex) { 16507 newThumbsIndex = thumbsSwiper.params.slidesPerGroup > 1 ? nextThumbsIndex : currentThumbsIndex; 16508 } else if (nextThumbsIndex - currentThumbsIndex < currentThumbsIndex - prevThumbsIndex) { 16509 newThumbsIndex = nextThumbsIndex; 16510 } else { 16511 newThumbsIndex = prevThumbsIndex; 16512 } 16513 16514 direction = swiper.activeIndex > swiper.previousIndex ? 'next' : 'prev'; 16515 } else { 16516 newThumbsIndex = swiper.realIndex; 16517 direction = newThumbsIndex > swiper.previousIndex ? 'next' : 'prev'; 16518 } 16519 16520 if (useOffset) { 16521 newThumbsIndex += direction === 'next' ? autoScrollOffset : -1 * autoScrollOffset; 16522 } 16523 16524 if (thumbsSwiper.visibleSlidesIndexes && thumbsSwiper.visibleSlidesIndexes.indexOf(newThumbsIndex) < 0) { 16525 if (thumbsSwiper.params.centeredSlides) { 16526 if (newThumbsIndex > currentThumbsIndex) { 16527 newThumbsIndex = newThumbsIndex - Math.floor(slidesPerView / 2) + 1; 16528 } else { 16529 newThumbsIndex = newThumbsIndex + Math.floor(slidesPerView / 2) - 1; 16530 } 16531 } else if (newThumbsIndex > currentThumbsIndex && thumbsSwiper.params.slidesPerGroup === 1) ; 16532 16533 thumbsSwiper.slideTo(newThumbsIndex, initial ? 0 : undefined); 16534 } 16535 } 16536 } 16537 16538 on('beforeInit', () => { 16539 const { 16540 thumbs 16541 } = swiper.params; 16542 if (!thumbs || !thumbs.swiper) return; 16543 init(); 16544 update(true); 16545 }); 16546 on('slideChange update resize observerUpdate', () => { 16547 update(); 16548 }); 16549 on('setTransition', (_s, duration) => { 16550 const thumbsSwiper = swiper.thumbs.swiper; 16551 if (!thumbsSwiper || thumbsSwiper.destroyed) return; 16552 thumbsSwiper.setTransition(duration); 16553 }); 16554 on('beforeDestroy', () => { 16555 const thumbsSwiper = swiper.thumbs.swiper; 16556 if (!thumbsSwiper || thumbsSwiper.destroyed) return; 16557 16558 if (swiperCreated) { 16559 thumbsSwiper.destroy(); 16560 } 16561 }); 16562 Object.assign(swiper.thumbs, { 16563 init, 16564 update 16565 }); 16566 } 16567 16568 function freeMode(_ref) { 16569 let { 16570 swiper, 16571 extendParams, 16572 emit, 16573 once 16574 } = _ref; 16575 extendParams({ 16576 freeMode: { 16577 enabled: false, 16578 momentum: true, 16579 momentumRatio: 1, 16580 momentumBounce: true, 16581 momentumBounceRatio: 1, 16582 momentumVelocityRatio: 1, 16583 sticky: false, 16584 minimumVelocity: 0.02 16585 } 16586 }); 16587 16588 function onTouchStart() { 16589 const translate = swiper.getTranslate(); 16590 swiper.setTranslate(translate); 16591 swiper.setTransition(0); 16592 swiper.touchEventsData.velocities.length = 0; 16593 swiper.freeMode.onTouchEnd({
vendor: 8,546 bytes, lines 16594-16836
16594 currentPos: swiper.rtl ? swiper.translate : -swiper.translate 16595 }); 16596 } 16597 16598 function onTouchMove() { 16599 const { 16600 touchEventsData: data, 16601 touches 16602 } = swiper; // Velocity 16603 16604 if (data.velocities.length === 0) { 16605 data.velocities.push({ 16606 position: touches[swiper.isHorizontal() ? 'startX' : 'startY'], 16607 time: data.touchStartTime 16608 }); 16609 } 16610 16611 data.velocities.push({ 16612 position: touches[swiper.isHorizontal() ? 'currentX' : 'currentY'], 16613 time: now() 16614 }); 16615 } 16616 16617 function onTouchEnd(_ref2) { 16618 let { 16619 currentPos 16620 } = _ref2; 16621 const { 16622 params, 16623 $wrapperEl, 16624 rtlTranslate: rtl, 16625 snapGrid, 16626 touchEventsData: data 16627 } = swiper; // Time diff 16628 16629 const touchEndTime = now(); 16630 const timeDiff = touchEndTime - data.touchStartTime; 16631 16632 if (currentPos < -swiper.minTranslate()) { 16633 swiper.slideTo(swiper.activeIndex); 16634 return; 16635 } 16636 16637 if (currentPos > -swiper.maxTranslate()) { 16638 if (swiper.slides.length < snapGrid.length) { 16639 swiper.slideTo(snapGrid.length - 1); 16640 } else { 16641 swiper.slideTo(swiper.slides.length - 1); 16642 } 16643 16644 return; 16645 } 16646 16647 if (params.freeMode.momentum) { 16648 if (data.velocities.length > 1) { 16649 const lastMoveEvent = data.velocities.pop(); 16650 const velocityEvent = data.velocities.pop(); 16651 const distance = lastMoveEvent.position - velocityEvent.position; 16652 const time = lastMoveEvent.time - velocityEvent.time; 16653 swiper.velocity = distance / time; 16654 swiper.velocity /= 2; 16655 16656 if (Math.abs(swiper.velocity) < params.freeMode.minimumVelocity) { 16657 swiper.velocity = 0; 16658 } // this implies that the user stopped moving a finger then released. 16659 // There would be no events with distance zero, so the last event is stale. 16660 16661 16662 if (time > 150 || now() - lastMoveEvent.time > 300) { 16663 swiper.velocity = 0; 16664 } 16665 } else { 16666 swiper.velocity = 0; 16667 } 16668 16669 swiper.velocity *= params.freeMode.momentumVelocityRatio; 16670 data.velocities.length = 0; 16671 let momentumDuration = 1000 * params.freeMode.momentumRatio; 16672 const momentumDistance = swiper.velocity * momentumDuration; 16673 let newPosition = swiper.translate + momentumDistance; 16674 if (rtl) newPosition = -newPosition; 16675 let doBounce = false; 16676 let afterBouncePosition; 16677 const bounceAmount = Math.abs(swiper.velocity) * 20 * params.freeMode.momentumBounceRatio; 16678 let needsLoopFix; 16679 16680 if (newPosition < swiper.maxTranslate()) { 16681 if (params.freeMode.momentumBounce) { 16682 if (newPosition + swiper.maxTranslate() < -bounceAmount) { 16683 newPosition = swiper.maxTranslate() - bounceAmount; 16684 } 16685 16686 afterBouncePosition = swiper.maxTranslate(); 16687 doBounce = true; 16688 data.allowMomentumBounce = true; 16689 } else { 16690 newPosition = swiper.maxTranslate(); 16691 } 16692 16693 if (params.loop && params.centeredSlides) needsLoopFix = true; 16694 } else if (newPosition > swiper.minTranslate()) { 16695 if (params.freeMode.momentumBounce) { 16696 if (newPosition - swiper.minTranslate() > bounceAmount) { 16697 newPosition = swiper.minTranslate() + bounceAmount; 16698 } 16699 16700 afterBouncePosition = swiper.minTranslate(); 16701 doBounce = true; 16702 data.allowMomentumBounce = true; 16703 } else { 16704 newPosition = swiper.minTranslate(); 16705 } 16706 16707 if (params.loop && params.centeredSlides) needsLoopFix = true; 16708 } else if (params.freeMode.sticky) { 16709 let nextSlide; 16710 16711 for (let j = 0; j < snapGrid.length; j += 1) { 16712 if (snapGrid[j] > -newPosition) { 16713 nextSlide = j; 16714 break; 16715 } 16716 } 16717 16718 if (Math.abs(snapGrid[nextSlide] - newPosition) < Math.abs(snapGrid[nextSlide - 1] - newPosition) || swiper.swipeDirection === 'next') { 16719 newPosition = snapGrid[nextSlide]; 16720 } else { 16721 newPosition = snapGrid[nextSlide - 1]; 16722 } 16723 16724 newPosition = -newPosition; 16725 } 16726 16727 if (needsLoopFix) { 16728 once('transitionEnd', () => { 16729 swiper.loopFix(); 16730 }); 16731 } // Fix duration 16732 16733 16734 if (swiper.velocity !== 0) { 16735 if (rtl) { 16736 momentumDuration = Math.abs((-newPosition - swiper.translate) / swiper.velocity); 16737 } else { 16738 momentumDuration = Math.abs((newPosition - swiper.translate) / swiper.velocity); 16739 } 16740 16741 if (params.freeMode.sticky) { 16742 // If freeMode.sticky is active and the user ends a swipe with a slow-velocity 16743 // event, then durations can be 20+ seconds to slide one (or zero!) slides. 16744 // It's easy to see this when simulating touch with mouse events. To fix this, 16745 // limit single-slide swipes to the default slide duration. This also has the 16746 // nice side effect of matching slide speed if the user stopped moving before 16747 // lifting finger or mouse vs. moving slowly before lifting the finger/mouse. 16748 // For faster swipes, also apply limits (albeit higher ones). 16749 const moveDistance = Math.abs((rtl ? -newPosition : newPosition) - swiper.translate); 16750 const currentSlideSize = swiper.slidesSizesGrid[swiper.activeIndex]; 16751 16752 if (moveDistance < currentSlideSize) { 16753 momentumDuration = params.speed; 16754 } else if (moveDistance < 2 * currentSlideSize) { 16755 momentumDuration = params.speed * 1.5; 16756 } else { 16757 momentumDuration = params.speed * 2.5; 16758 } 16759 } 16760 } else if (params.freeMode.sticky) { 16761 swiper.slideToClosest(); 16762 return; 16763 } 16764 16765 if (params.freeMode.momentumBounce && doBounce) { 16766 swiper.updateProgress(afterBouncePosition); 16767 swiper.setTransition(momentumDuration); 16768 swiper.setTranslate(newPosition); 16769 swiper.transitionStart(true, swiper.swipeDirection); 16770 swiper.animating = true; 16771 $wrapperEl.transitionEnd(() => { 16772 if (!swiper || swiper.destroyed || !data.allowMomentumBounce) return; 16773 emit('momentumBounce'); 16774 swiper.setTransition(params.speed); 16775 setTimeout(() => { 16776 swiper.setTranslate(afterBouncePosition); 16777 $wrapperEl.transitionEnd(() => { 16778 if (!swiper || swiper.destroyed) return; 16779 swiper.transitionEnd(); 16780 }); 16781 }, 0); 16782 }); 16783 } else if (swiper.velocity) { 16784 emit('_freeModeNoMomentumRelease'); 16785 swiper.updateProgress(newPosition); 16786 swiper.setTransition(momentumDuration); 16787 swiper.setTranslate(newPosition); 16788 swiper.transitionStart(true, swiper.swipeDirection); 16789 16790 if (!swiper.animating) { 16791 swiper.animating = true; 16792 $wrapperEl.transitionEnd(() => { 16793 if (!swiper || swiper.destroyed) return; 16794 swiper.transitionEnd(); 16795 }); 16796 } 16797 } else { 16798 swiper.updateProgress(newPosition); 16799 } 16800 16801 swiper.updateActiveIndex(); 16802 swiper.updateSlidesClasses(); 16803 } else if (params.freeMode.sticky) { 16804 swiper.slideToClosest(); 16805 return; 16806 } else if (params.freeMode) { 16807 emit('_freeModeNoMomentumRelease'); 16808 } 16809 16810 if (!params.freeMode.momentum || timeDiff >= params.longSwipesMs) { 16811 swiper.updateProgress(); 16812 swiper.updateActiveIndex(); 16813 swiper.updateSlidesClasses(); 16814 } 16815 } 16816 16817 Object.assign(swiper, { 16818 freeMode: { 16819 onTouchStart, 16820 onTouchMove, 16821 onTouchEnd 16822 } 16823 }); 16824 } 16825 16826 function Grid(_ref) { 16827 let { 16828 swiper, 16829 extendParams 16830 } = _ref; 16831 extendParams({ 16832 grid: { 16833 rows: 1, 16834 fill: 'column' 16835 } 16836 });
16837 let slidesNumberEvenToRows; 16838 let slidesPerRow; 16839 let numFullColumns; 16840 16841 const initSlides = slidesLength => { 16842 const { 16843 slidesPerView 16844 } = swiper.params; 16845 const { 16846 rows, 16847 fill 16848 } = swiper.params.grid; 16849 slidesPerRow = slidesNumberEvenToRows / rows; 16850 numFullColumns = Math.floor(slidesLength / rows); 16851 16852 if (Math.floor(slidesLength / rows) === slidesLength / rows) { 16853 slidesNumberEvenToRows = slidesLength; 16854 } else { 16855 slidesNumberEvenToRows = Math.ceil(slidesLength / rows) * rows; 16856 } 16857 16858 if (slidesPerView !== 'auto' && fill === 'row') { 16859 slidesNumberEvenToRows = Math.max(slidesNumberEvenToRows, slidesPerView * rows); 16860 } 16861 }; 16862 16863 const updateSlide = (i, slide, slidesLength, getDirectionLabel) => { 16864 const { 16865 slidesPerGroup, 16866 spaceBetween 16867 } = swiper.params; 16868 const { 16869 rows, 16870 fill 16871 } = swiper.params.grid; // Set slides order 16872 16873 let newSlideOrderIndex; 16874 let column; 16875 let row; 16876 16877 if (fill === 'row' && slidesPerGroup > 1) { 16878 const groupIndex = Math.floor(i / (slidesPerGroup * rows)); 16879 const slideIndexInGroup = i - rows * slidesPerGroup * groupIndex; 16880 const columnsInGroup = groupIndex === 0 ? slidesPerGroup : Math.min(Math.ceil((slidesLength - groupIndex * rows * slidesPerGroup) / rows), slidesPerGroup); 16881 row = Math.floor(slideIndexInGroup / columnsInGroup); 16882 column = slideIndexInGroup - row * columnsInGroup + groupIndex * slidesPerGroup; 16883 newSlideOrderIndex = column + row * slidesNumberEvenToRows / rows; 16884 slide.css({ 16885 '-webkit-order': newSlideOrderIndex, 16886 order: newSlideOrderIndex 16887 }); 16888 } else if (fill === 'column') { 16889 column = Math.floor(i / rows); 16890 row = i - column * rows; 16891 16892 if (column > numFullColumns || column === numFullColumns && row === rows - 1) { 16893 row += 1; 16894 16895 if (row >= rows) { 16896 row = 0; 16897 column += 1; 16898 } 16899 } 16900 } else { 16901 row = Math.floor(i / slidesPerRow); 16902 column = i - row * slidesPerRow; 16903 } 16904 16905 slide.css(getDirectionLabel('margin-top'), row !== 0 ? spaceBetween && `${spaceBetween}px` : ''); 16906 }; 16907 16908 const updateWrapperSize = (slideSize, snapGrid, getDirectionLabel) => { 16909 const { 16910 spaceBetween, 16911 centeredSlides, 16912 roundLengths 16913 } = swiper.params; 16914 const { 16915 rows 16916 } = swiper.params.grid; 16917 swiper.virtualSize = (slideSize + spaceBetween) * slidesNumberEvenToRows; 16918 swiper.virtualSize = Math.ceil(swiper.virtualSize / rows) - spaceBetween; 16919 swiper.$wrapperEl.css({ 16920 [getDirectionLabel('width')]: `${swiper.virtualSize + spaceBetween}px` 16921 }); 16922 16923 if (centeredSlides) { 16924 snapGrid.splice(0, snapGrid.length); 16925 const newSlidesGrid = []; 16926 16927 for (let i = 0; i < snapGrid.length; i += 1) { 16928 let slidesGridItem = snapGrid[i]; 16929 if (roundLengths) slidesGridItem = Math.floor(slidesGridItem); 16930 if (snapGrid[i] < swiper.virtualSize + snapGrid[0]) newSlidesGrid.push(slidesGridItem); 16931 } 16932 16933 snapGrid.push(...newSlidesGrid); 16934 } 16935 }; 16936 16937 swiper.grid = { 16938 initSlides, 16939 updateSlide, 16940 updateWrapperSize 16941 }; 16942 } 16943 16944 function appendSlide(slides) { 16945 const swiper = this; 16946 const { 16947 $wrapperEl, 16948 params 16949 } = swiper; 16950 16951 if (params.loop) { 16952 swiper.loopDestroy(); 16953 } 16954 16955 if (typeof slides === 'object' && 'length' in slides) { 16956 for (let i = 0; i < slides.length; i += 1) { 16957 if (slides[i]) $wrapperEl.append(slides[i]); 16958 } 16959 } else { 16960 $wrapperEl.append(slides); 16961 } 16962 16963 if (params.loop) { 16964 swiper.loopCreate(); 16965 } 16966 16967 if (!params.observer) { 16968 swiper.update(); 16969 } 16970 } 16971 16972 function prependSlide(slides) { 16973 const swiper = this; 16974 const { 16975 params, 16976 $wrapperEl, 16977 activeIndex 16978 } = swiper; 16979 16980 if (params.loop) { 16981 swiper.loopDestroy(); 16982 } 16983 16984 let newActiveIndex = activeIndex + 1; 16985 16986 if (typeof slides === 'object' && 'length' in slides) { 16987 for (let i = 0; i < slides.length; i += 1) {
vendor: 6,052 bytes, lines 16988-17201
16988 if (slides[i]) $wrapperEl.prepend(slides[i]); 16989 } 16990 16991 newActiveIndex = activeIndex + slides.length; 16992 } else { 16993 $wrapperEl.prepend(slides); 16994 } 16995 16996 if (params.loop) { 16997 swiper.loopCreate(); 16998 } 16999 17000 if (!params.observer) { 17001 swiper.update(); 17002 } 17003 17004 swiper.slideTo(newActiveIndex, 0, false); 17005 } 17006 17007 function addSlide(index, slides) { 17008 const swiper = this; 17009 const { 17010 $wrapperEl, 17011 params, 17012 activeIndex 17013 } = swiper; 17014 let activeIndexBuffer = activeIndex; 17015 17016 if (params.loop) { 17017 activeIndexBuffer -= swiper.loopedSlides; 17018 swiper.loopDestroy(); 17019 swiper.slides = $wrapperEl.children(`.${params.slideClass}`); 17020 } 17021 17022 const baseLength = swiper.slides.length; 17023 17024 if (index <= 0) { 17025 swiper.prependSlide(slides); 17026 return; 17027 } 17028 17029 if (index >= baseLength) { 17030 swiper.appendSlide(slides); 17031 return; 17032 } 17033 17034 let newActiveIndex = activeIndexBuffer > index ? activeIndexBuffer + 1 : activeIndexBuffer; 17035 const slidesBuffer = []; 17036 17037 for (let i = baseLength - 1; i >= index; i -= 1) { 17038 const currentSlide = swiper.slides.eq(i); 17039 currentSlide.remove(); 17040 slidesBuffer.unshift(currentSlide); 17041 } 17042 17043 if (typeof slides === 'object' && 'length' in slides) { 17044 for (let i = 0; i < slides.length; i += 1) { 17045 if (slides[i]) $wrapperEl.append(slides[i]); 17046 } 17047 17048 newActiveIndex = activeIndexBuffer > index ? activeIndexBuffer + slides.length : activeIndexBuffer; 17049 } else { 17050 $wrapperEl.append(slides); 17051 } 17052 17053 for (let i = 0; i < slidesBuffer.length; i += 1) { 17054 $wrapperEl.append(slidesBuffer[i]); 17055 } 17056 17057 if (params.loop) { 17058 swiper.loopCreate(); 17059 } 17060 17061 if (!params.observer) { 17062 swiper.update(); 17063 } 17064 17065 if (params.loop) { 17066 swiper.slideTo(newActiveIndex + swiper.loopedSlides, 0, false); 17067 } else { 17068 swiper.slideTo(newActiveIndex, 0, false); 17069 } 17070 } 17071 17072 function removeSlide(slidesIndexes) { 17073 const swiper = this; 17074 const { 17075 params, 17076 $wrapperEl, 17077 activeIndex 17078 } = swiper; 17079 let activeIndexBuffer = activeIndex; 17080 17081 if (params.loop) { 17082 activeIndexBuffer -= swiper.loopedSlides; 17083 swiper.loopDestroy(); 17084 swiper.slides = $wrapperEl.children(`.${params.slideClass}`); 17085 } 17086 17087 let newActiveIndex = activeIndexBuffer; 17088 let indexToRemove; 17089 17090 if (typeof slidesIndexes === 'object' && 'length' in slidesIndexes) { 17091 for (let i = 0; i < slidesIndexes.length; i += 1) { 17092 indexToRemove = slidesIndexes[i]; 17093 if (swiper.slides[indexToRemove]) swiper.slides.eq(indexToRemove).remove(); 17094 if (indexToRemove < newActiveIndex) newActiveIndex -= 1; 17095 } 17096 17097 newActiveIndex = Math.max(newActiveIndex, 0); 17098 } else { 17099 indexToRemove = slidesIndexes; 17100 if (swiper.slides[indexToRemove]) swiper.slides.eq(indexToRemove).remove(); 17101 if (indexToRemove < newActiveIndex) newActiveIndex -= 1; 17102 newActiveIndex = Math.max(newActiveIndex, 0); 17103 } 17104 17105 if (params.loop) { 17106 swiper.loopCreate(); 17107 } 17108 17109 if (!params.observer) { 17110 swiper.update(); 17111 } 17112 17113 if (params.loop) { 17114 swiper.slideTo(newActiveIndex + swiper.loopedSlides, 0, false); 17115 } else { 17116 swiper.slideTo(newActiveIndex, 0, false); 17117 } 17118 } 17119 17120 function removeAllSlides() { 17121 const swiper = this; 17122 const slidesIndexes = []; 17123 17124 for (let i = 0; i < swiper.slides.length; i += 1) { 17125 slidesIndexes.push(i); 17126 } 17127 17128 swiper.removeSlide(slidesIndexes); 17129 } 17130 17131 function Manipulation(_ref) { 17132 let { 17133 swiper 17134 } = _ref; 17135 Object.assign(swiper, { 17136 appendSlide: appendSlide.bind(swiper), 17137 prependSlide: prependSlide.bind(swiper), 17138 addSlide: addSlide.bind(swiper), 17139 removeSlide: removeSlide.bind(swiper), 17140 removeAllSlides: removeAllSlides.bind(swiper) 17141 }); 17142 } 17143 17144 function effectInit(params) { 17145 const { 17146 effect, 17147 swiper, 17148 on, 17149 setTranslate, 17150 setTransition, 17151 overwriteParams, 17152 perspective, 17153 recreateShadows, 17154 getEffectParams 17155 } = params; 17156 on('beforeInit', () => { 17157 if (swiper.params.effect !== effect) return; 17158 swiper.classNames.push(`${swiper.params.containerModifierClass}${effect}`); 17159 17160 if (perspective && perspective()) { 17161 swiper.classNames.push(`${swiper.params.containerModifierClass}3d`); 17162 } 17163 17164 const overwriteParamsResult = overwriteParams ? overwriteParams() : {}; 17165 Object.assign(swiper.params, overwriteParamsResult); 17166 Object.assign(swiper.originalParams, overwriteParamsResult); 17167 }); 17168 on('setTranslate', () => { 17169 if (swiper.params.effect !== effect) return; 17170 setTranslate(); 17171 }); 17172 on('setTransition', (_s, duration) => { 17173 if (swiper.params.effect !== effect) return; 17174 setTransition(duration); 17175 }); 17176 on('transitionEnd', () => { 17177 if (swiper.params.effect !== effect) return; 17178 17179 if (recreateShadows) { 17180 if (!getEffectParams || !getEffectParams().slideShadows) return; // remove shadows 17181 17182 swiper.slides.each(slideEl => { 17183 const $slideEl = swiper.$(slideEl); 17184 $slideEl.find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').remove(); 17185 }); // create new one 17186 17187 recreateShadows(); 17188 } 17189 }); 17190 let requireUpdateOnVirtual; 17191 on('virtualUpdate', () => { 17192 if (swiper.params.effect !== effect) return; 17193 17194 if (!swiper.slides.length) { 17195 requireUpdateOnVirtual = true; 17196 } 17197 17198 requestAnimationFrame(() => { 17199 if (requireUpdateOnVirtual && swiper.slides && swiper.slides.length) { 17200 setTranslate(); 17201 requireUpdateOnVirtual = false;
17202 } 17203 }); 17204 }); 17205 } 17206 17207 function effectTarget(effectParams, $slideEl) { 17208 if (effectParams.transformEl) { 17209 return $slideEl.find(effectParams.transformEl).css({ 17210 'backface-visibility': 'hidden', 17211 '-webkit-backface-visibility': 'hidden' 17212 }); 17213 } 17214 17215 return $slideEl; 17216 } 17217 17218 function effectVirtualTransitionEnd(_ref) { 17219 let { 17220 swiper, 17221 duration, 17222 transformEl, 17223 allSlides 17224 } = _ref; 17225 const { 17226 slides, 17227 activeIndex, 17228 $wrapperEl 17229 } = swiper; 17230 17231 if (swiper.params.virtualTranslate && duration !== 0) { 17232 let eventTriggered = false; 17233 let $transitionEndTarget; 17234 17235 if (allSlides) { 17236 $transitionEndTarget = transformEl ? slides.find(transformEl) : slides; 17237 } else { 17238 $transitionEndTarget = transformEl ? slides.eq(activeIndex).find(transformEl) : slides.eq(activeIndex); 17239 } 17240 17241 $transitionEndTarget.transitionEnd(() => { 17242 if (eventTriggered) return; 17243 if (!swiper || swiper.destroyed) return; 17244 eventTriggered = true; 17245 swiper.animating = false; 17246 const triggerEvents = ['webkitTransitionEnd', 'transitionend']; 17247 17248 for (let i = 0; i < triggerEvents.length; i += 1) { 17249 $wrapperEl.trigger(triggerEvents[i]); 17250 } 17251 }); 17252 } 17253 } 17254 17255 function EffectFade(_ref) { 17256 let { 17257 swiper, 17258 extendParams, 17259 on 17260 } = _ref; 17261 extendParams({ 17262 fadeEffect: { 17263 crossFade: false, 17264 transformEl: null 17265 } 17266 }); 17267 17268 const setTranslate = () => { 17269 const { 17270 slides 17271 } = swiper; 17272 const params = swiper.params.fadeEffect; 17273 17274 for (let i = 0; i < slides.length; i += 1) { 17275 const $slideEl = swiper.slides.eq(i); 17276 const offset = $slideEl[0].swiperSlideOffset; 17277 let tx = -offset; 17278 if (!swiper.params.virtualTranslate) tx -= swiper.translate; 17279 let ty = 0; 17280 17281 if (!swiper.isHorizontal()) { 17282 ty = tx; 17283 tx = 0; 17284 } 17285 17286 const slideOpacity = swiper.params.fadeEffect.crossFade ? Math.max(1 - Math.abs($slideEl[0].progress), 0) : 1 + Math.min(Math.max($slideEl[0].progress, -1), 0); 17287 const $targetEl = effectTarget(params, $slideEl); 17288 $targetEl.css({ 17289 opacity: slideOpacity 17290 }).transform(`translate3d(${tx}px, ${ty}px, 0px)`); 17291 } 17292 }; 17293 17294 const setTransition = duration => { 17295 const { 17296 transformEl 17297 } = swiper.params.fadeEffect; 17298 const $transitionElements = transformEl ? swiper.slides.find(transformEl) : swiper.slides; 17299 $transitionElements.transition(duration); 17300 effectVirtualTransitionEnd({ 17301 swiper, 17302 duration, 17303 transformEl, 17304 allSlides: true 17305 }); 17306 }; 17307 17308 effectInit({ 17309 effect: 'fade', 17310 swiper, 17311 on, 17312 setTranslate, 17313 setTransition, 17314 overwriteParams: () => ({ 17315 slidesPerView: 1, 17316 slidesPerGroup: 1, 17317 watchSlidesProgress: true, 17318 spaceBetween: 0, 17319 virtualTranslate: !swiper.params.cssMode 17320 }) 17321 }); 17322 } 17323 17324 function EffectCube(_ref) { 17325 let { 17326 swiper, 17327 extendParams, 17328 on 17329 } = _ref; 17330 extendParams({ 17331 cubeEffect: { 17332 slideShadows: true, 17333 shadow: true, 17334 shadowOffset: 20, 17335 shadowScale: 0.94 17336 } 17337 }); 17338 17339 const createSlideShadows = ($slideEl, progress, isHorizontal) => { 17340 let shadowBefore = isHorizontal ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top'); 17341 let shadowAfter = isHorizontal ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom'); 17342 17343 if (shadowBefore.length === 0) { 17344 shadowBefore = $(`<div class="swiper-slide-shadow-${isHorizontal ? 'left' : 'top'}"></div>`); 17345 $slideEl.append(shadowBefore); 17346 } 17347 17348 if (shadowAfter.length === 0) { 17349 shadowAfter = $(`<div class="swiper-slide-shadow-${isHorizontal ? 'right' : 'bottom'}"></div>`); 17350 $slideEl.append(shadowAfter); 17351 } 17352 17353 if (shadowBefore.length) shadowBefore[0].style.opacity = Math.max(-progress, 0); 17354 if (shadowAfter.length) shadowAfter[0].style.opacity = Math.max(progress, 0); 17355 }; 17356 17357 const recreateShadows = () => { 17358 // create new ones 17359 const isHorizontal = swiper.isHorizontal(); 17360 swiper.slides.each(slideEl => { 17361 const progress = Math.max(Math.min(slideEl.progress, 1), -1); 17362 createSlideShadows($(slideEl), progress, isHorizontal); 17363 }); 17364 }; 17365 17366 const setTranslate = () => { 17367 const { 17368 $el, 17369 $wrapperEl, 17370 slides, 17371 width: swiperWidth, 17372 height: swiperHeight, 17373 rtlTranslate: rtl, 17374 size: swiperSize, 17375 browser 17376 } = swiper; 17377 const params = swiper.params.cubeEffect; 17378 const isHorizontal = swiper.isHorizontal(); 17379 const isVirtual = swiper.virtual && swiper.params.virtual.enabled; 17380 let wrapperRotate = 0; 17381 let $cubeShadowEl; 17382 17383 if (params.shadow) { 17384 if (isHorizontal) { 17385 $cubeShadowEl = $wrapperEl.find('.swiper-cube-shadow'); 17386 17387 if ($cubeShadowEl.length === 0) {
vendor: 20,967 bytes, lines 17388-17969
17388 $cubeShadowEl = $('<div class="swiper-cube-shadow"></div>'); 17389 $wrapperEl.append($cubeShadowEl); 17390 } 17391 17392 $cubeShadowEl.css({ 17393 height: `${swiperWidth}px` 17394 }); 17395 } else { 17396 $cubeShadowEl = $el.find('.swiper-cube-shadow'); 17397 17398 if ($cubeShadowEl.length === 0) { 17399 $cubeShadowEl = $('<div class="swiper-cube-shadow"></div>'); 17400 $el.append($cubeShadowEl); 17401 } 17402 } 17403 } 17404 17405 for (let i = 0; i < slides.length; i += 1) { 17406 const $slideEl = slides.eq(i); 17407 let slideIndex = i; 17408 17409 if (isVirtual) { 17410 slideIndex = parseInt($slideEl.attr('data-swiper-slide-index'), 10); 17411 } 17412 17413 let slideAngle = slideIndex * 90; 17414 let round = Math.floor(slideAngle / 360); 17415 17416 if (rtl) { 17417 slideAngle = -slideAngle; 17418 round = Math.floor(-slideAngle / 360); 17419 } 17420 17421 const progress = Math.max(Math.min($slideEl[0].progress, 1), -1); 17422 let tx = 0; 17423 let ty = 0; 17424 let tz = 0; 17425 17426 if (slideIndex % 4 === 0) { 17427 tx = -round * 4 * swiperSize; 17428 tz = 0; 17429 } else if ((slideIndex - 1) % 4 === 0) { 17430 tx = 0; 17431 tz = -round * 4 * swiperSize; 17432 } else if ((slideIndex - 2) % 4 === 0) { 17433 tx = swiperSize + round * 4 * swiperSize; 17434 tz = swiperSize; 17435 } else if ((slideIndex - 3) % 4 === 0) { 17436 tx = -swiperSize; 17437 tz = 3 * swiperSize + swiperSize * 4 * round; 17438 } 17439 17440 if (rtl) { 17441 tx = -tx; 17442 } 17443 17444 if (!isHorizontal) { 17445 ty = tx; 17446 tx = 0; 17447 } 17448 17449 const transform = `rotateX(${isHorizontal ? 0 : -slideAngle}deg) rotateY(${isHorizontal ? slideAngle : 0}deg) translate3d(${tx}px, ${ty}px, ${tz}px)`; 17450 17451 if (progress <= 1 && progress > -1) { 17452 wrapperRotate = slideIndex * 90 + progress * 90; 17453 if (rtl) wrapperRotate = -slideIndex * 90 - progress * 90; 17454 } 17455 17456 $slideEl.transform(transform); 17457 17458 if (params.slideShadows) { 17459 createSlideShadows($slideEl, progress, isHorizontal); 17460 } 17461 } 17462 17463 $wrapperEl.css({ 17464 '-webkit-transform-origin': `50% 50% -${swiperSize / 2}px`, 17465 'transform-origin': `50% 50% -${swiperSize / 2}px` 17466 }); 17467 17468 if (params.shadow) { 17469 if (isHorizontal) { 17470 $cubeShadowEl.transform(`translate3d(0px, ${swiperWidth / 2 + params.shadowOffset}px, ${-swiperWidth / 2}px) rotateX(90deg) rotateZ(0deg) scale(${params.shadowScale})`); 17471 } else { 17472 const shadowAngle = Math.abs(wrapperRotate) - Math.floor(Math.abs(wrapperRotate) / 90) * 90; 17473 const multiplier = 1.5 - (Math.sin(shadowAngle * 2 * Math.PI / 360) / 2 + Math.cos(shadowAngle * 2 * Math.PI / 360) / 2); 17474 const scale1 = params.shadowScale; 17475 const scale2 = params.shadowScale / multiplier; 17476 const offset = params.shadowOffset; 17477 $cubeShadowEl.transform(`scale3d(${scale1}, 1, ${scale2}) translate3d(0px, ${swiperHeight / 2 + offset}px, ${-swiperHeight / 2 / scale2}px) rotateX(-90deg)`); 17478 } 17479 } 17480 17481 const zFactor = browser.isSafari || browser.isWebView ? -swiperSize / 2 : 0; 17482 $wrapperEl.transform(`translate3d(0px,0,${zFactor}px) rotateX(${swiper.isHorizontal() ? 0 : wrapperRotate}deg) rotateY(${swiper.isHorizontal() ? -wrapperRotate : 0}deg)`); 17483 $wrapperEl[0].style.setProperty('--swiper-cube-translate-z', `${zFactor}px`); 17484 }; 17485 17486 const setTransition = duration => { 17487 const { 17488 $el, 17489 slides 17490 } = swiper; 17491 slides.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration); 17492 17493 if (swiper.params.cubeEffect.shadow && !swiper.isHorizontal()) { 17494 $el.find('.swiper-cube-shadow').transition(duration); 17495 } 17496 }; 17497 17498 effectInit({ 17499 effect: 'cube', 17500 swiper, 17501 on, 17502 setTranslate, 17503 setTransition, 17504 recreateShadows, 17505 getEffectParams: () => swiper.params.cubeEffect, 17506 perspective: () => true, 17507 overwriteParams: () => ({ 17508 slidesPerView: 1, 17509 slidesPerGroup: 1, 17510 watchSlidesProgress: true, 17511 resistanceRatio: 0, 17512 spaceBetween: 0, 17513 centeredSlides: false, 17514 virtualTranslate: true 17515 }) 17516 }); 17517 } 17518 17519 function createShadow(params, $slideEl, side) { 17520 const shadowClass = `swiper-slide-shadow${side ? `-${side}` : ''}`; 17521 const $shadowContainer = params.transformEl ? $slideEl.find(params.transformEl) : $slideEl; 17522 let $shadowEl = $shadowContainer.children(`.${shadowClass}`); 17523 17524 if (!$shadowEl.length) { 17525 $shadowEl = $(`<div class="swiper-slide-shadow${side ? `-${side}` : ''}"></div>`); 17526 $shadowContainer.append($shadowEl); 17527 } 17528 17529 return $shadowEl; 17530 } 17531 17532 function EffectFlip(_ref) { 17533 let { 17534 swiper, 17535 extendParams, 17536 on 17537 } = _ref; 17538 extendParams({ 17539 flipEffect: { 17540 slideShadows: true, 17541 limitRotation: true, 17542 transformEl: null 17543 } 17544 }); 17545 17546 const createSlideShadows = ($slideEl, progress, params) => { 17547 let shadowBefore = swiper.isHorizontal() ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top'); 17548 let shadowAfter = swiper.isHorizontal() ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom'); 17549 17550 if (shadowBefore.length === 0) { 17551 shadowBefore = createShadow(params, $slideEl, swiper.isHorizontal() ? 'left' : 'top'); 17552 } 17553 17554 if (shadowAfter.length === 0) { 17555 shadowAfter = createShadow(params, $slideEl, swiper.isHorizontal() ? 'right' : 'bottom'); 17556 } 17557 17558 if (shadowBefore.length) shadowBefore[0].style.opacity = Math.max(-progress, 0); 17559 if (shadowAfter.length) shadowAfter[0].style.opacity = Math.max(progress, 0); 17560 }; 17561 17562 const recreateShadows = () => { 17563 // Set shadows 17564 const params = swiper.params.flipEffect; 17565 swiper.slides.each(slideEl => { 17566 const $slideEl = $(slideEl); 17567 let progress = $slideEl[0].progress; 17568 17569 if (swiper.params.flipEffect.limitRotation) { 17570 progress = Math.max(Math.min(slideEl.progress, 1), -1); 17571 } 17572 17573 createSlideShadows($slideEl, progress, params); 17574 }); 17575 }; 17576 17577 const setTranslate = () => { 17578 const { 17579 slides, 17580 rtlTranslate: rtl 17581 } = swiper; 17582 const params = swiper.params.flipEffect; 17583 17584 for (let i = 0; i < slides.length; i += 1) { 17585 const $slideEl = slides.eq(i); 17586 let progress = $slideEl[0].progress; 17587 17588 if (swiper.params.flipEffect.limitRotation) { 17589 progress = Math.max(Math.min($slideEl[0].progress, 1), -1); 17590 } 17591 17592 const offset = $slideEl[0].swiperSlideOffset; 17593 const rotate = -180 * progress; 17594 let rotateY = rotate; 17595 let rotateX = 0; 17596 let tx = swiper.params.cssMode ? -offset - swiper.translate : -offset; 17597 let ty = 0; 17598 17599 if (!swiper.isHorizontal()) { 17600 ty = tx; 17601 tx = 0; 17602 rotateX = -rotateY; 17603 rotateY = 0; 17604 } else if (rtl) { 17605 rotateY = -rotateY; 17606 } 17607 17608 $slideEl[0].style.zIndex = -Math.abs(Math.round(progress)) + slides.length; 17609 17610 if (params.slideShadows) { 17611 createSlideShadows($slideEl, progress, params); 17612 } 17613 17614 const transform = `translate3d(${tx}px, ${ty}px, 0px) rotateX(${rotateX}deg) rotateY(${rotateY}deg)`; 17615 const $targetEl = effectTarget(params, $slideEl); 17616 $targetEl.transform(transform); 17617 } 17618 }; 17619 17620 const setTransition = duration => { 17621 const { 17622 transformEl 17623 } = swiper.params.flipEffect; 17624 const $transitionElements = transformEl ? swiper.slides.find(transformEl) : swiper.slides; 17625 $transitionElements.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration); 17626 effectVirtualTransitionEnd({ 17627 swiper, 17628 duration, 17629 transformEl 17630 }); 17631 }; 17632 17633 effectInit({ 17634 effect: 'flip', 17635 swiper, 17636 on, 17637 setTranslate, 17638 setTransition, 17639 recreateShadows, 17640 getEffectParams: () => swiper.params.flipEffect, 17641 perspective: () => true, 17642 overwriteParams: () => ({ 17643 slidesPerView: 1, 17644 slidesPerGroup: 1, 17645 watchSlidesProgress: true, 17646 spaceBetween: 0, 17647 virtualTranslate: !swiper.params.cssMode 17648 }) 17649 }); 17650 } 17651 17652 function EffectCoverflow(_ref) { 17653 let { 17654 swiper, 17655 extendParams, 17656 on 17657 } = _ref; 17658 extendParams({ 17659 coverflowEffect: { 17660 rotate: 50, 17661 stretch: 0, 17662 depth: 100, 17663 scale: 1, 17664 modifier: 1, 17665 slideShadows: true, 17666 transformEl: null 17667 } 17668 }); 17669 17670 const setTranslate = () => { 17671 const { 17672 width: swiperWidth, 17673 height: swiperHeight, 17674 slides, 17675 slidesSizesGrid 17676 } = swiper; 17677 const params = swiper.params.coverflowEffect; 17678 const isHorizontal = swiper.isHorizontal(); 17679 const transform = swiper.translate; 17680 const center = isHorizontal ? -transform + swiperWidth / 2 : -transform + swiperHeight / 2; 17681 const rotate = isHorizontal ? params.rotate : -params.rotate; 17682 const translate = params.depth; // Each slide offset from center 17683 17684 for (let i = 0, length = slides.length; i < length; i += 1) { 17685 const $slideEl = slides.eq(i); 17686 const slideSize = slidesSizesGrid[i]; 17687 const slideOffset = $slideEl[0].swiperSlideOffset; 17688 const centerOffset = (center - slideOffset - slideSize / 2) / slideSize; 17689 const offsetMultiplier = typeof params.modifier === 'function' ? params.modifier(centerOffset) : centerOffset * params.modifier; 17690 let rotateY = isHorizontal ? rotate * offsetMultiplier : 0; 17691 let rotateX = isHorizontal ? 0 : rotate * offsetMultiplier; // var rotateZ = 0 17692 17693 let translateZ = -translate * Math.abs(offsetMultiplier); 17694 let stretch = params.stretch; // Allow percentage to make a relative stretch for responsive sliders 17695 17696 if (typeof stretch === 'string' && stretch.indexOf('%') !== -1) { 17697 stretch = parseFloat(params.stretch) / 100 * slideSize; 17698 } 17699 17700 let translateY = isHorizontal ? 0 : stretch * offsetMultiplier; 17701 let translateX = isHorizontal ? stretch * offsetMultiplier : 0; 17702 let scale = 1 - (1 - params.scale) * Math.abs(offsetMultiplier); // Fix for ultra small values 17703 17704 if (Math.abs(translateX) < 0.001) translateX = 0; 17705 if (Math.abs(translateY) < 0.001) translateY = 0; 17706 if (Math.abs(translateZ) < 0.001) translateZ = 0; 17707 if (Math.abs(rotateY) < 0.001) rotateY = 0; 17708 if (Math.abs(rotateX) < 0.001) rotateX = 0; 17709 if (Math.abs(scale) < 0.001) scale = 0; 17710 const slideTransform = `translate3d(${translateX}px,${translateY}px,${translateZ}px) rotateX(${rotateX}deg) rotateY(${rotateY}deg) scale(${scale})`; 17711 const $targetEl = effectTarget(params, $slideEl); 17712 $targetEl.transform(slideTransform); 17713 $slideEl[0].style.zIndex = -Math.abs(Math.round(offsetMultiplier)) + 1; 17714 17715 if (params.slideShadows) { 17716 // Set shadows 17717 let $shadowBeforeEl = isHorizontal ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top'); 17718 let $shadowAfterEl = isHorizontal ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom'); 17719 17720 if ($shadowBeforeEl.length === 0) { 17721 $shadowBeforeEl = createShadow(params, $slideEl, isHorizontal ? 'left' : 'top'); 17722 } 17723 17724 if ($shadowAfterEl.length === 0) { 17725 $shadowAfterEl = createShadow(params, $slideEl, isHorizontal ? 'right' : 'bottom'); 17726 } 17727 17728 if ($shadowBeforeEl.length) $shadowBeforeEl[0].style.opacity = offsetMultiplier > 0 ? offsetMultiplier : 0; 17729 if ($shadowAfterEl.length) $shadowAfterEl[0].style.opacity = -offsetMultiplier > 0 ? -offsetMultiplier : 0; 17730 } 17731 } 17732 }; 17733 17734 const setTransition = duration => { 17735 const { 17736 transformEl 17737 } = swiper.params.coverflowEffect; 17738 const $transitionElements = transformEl ? swiper.slides.find(transformEl) : swiper.slides; 17739 $transitionElements.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration); 17740 }; 17741 17742 effectInit({ 17743 effect: 'coverflow', 17744 swiper, 17745 on, 17746 setTranslate, 17747 setTransition, 17748 perspective: () => true, 17749 overwriteParams: () => ({ 17750 watchSlidesProgress: true 17751 }) 17752 }); 17753 } 17754 17755 function EffectCreative(_ref) { 17756 let { 17757 swiper, 17758 extendParams, 17759 on 17760 } = _ref; 17761 extendParams({ 17762 creativeEffect: { 17763 transformEl: null, 17764 limitProgress: 1, 17765 shadowPerProgress: false, 17766 progressMultiplier: 1, 17767 perspective: true, 17768 prev: { 17769 translate: [0, 0, 0], 17770 rotate: [0, 0, 0], 17771 opacity: 1, 17772 scale: 1 17773 }, 17774 next: { 17775 translate: [0, 0, 0], 17776 rotate: [0, 0, 0], 17777 opacity: 1, 17778 scale: 1 17779 } 17780 } 17781 }); 17782 17783 const getTranslateValue = value => { 17784 if (typeof value === 'string') return value; 17785 return `${value}px`; 17786 }; 17787 17788 const setTranslate = () => { 17789 const { 17790 slides, 17791 $wrapperEl, 17792 slidesSizesGrid 17793 } = swiper; 17794 const params = swiper.params.creativeEffect; 17795 const { 17796 progressMultiplier: multiplier 17797 } = params; 17798 const isCenteredSlides = swiper.params.centeredSlides; 17799 17800 if (isCenteredSlides) { 17801 const margin = slidesSizesGrid[0] / 2 - swiper.params.slidesOffsetBefore || 0; 17802 $wrapperEl.transform(`translateX(calc(50% - ${margin}px))`); 17803 } 17804 17805 for (let i = 0; i < slides.length; i += 1) { 17806 const $slideEl = slides.eq(i); 17807 const slideProgress = $slideEl[0].progress; 17808 const progress = Math.min(Math.max($slideEl[0].progress, -params.limitProgress), params.limitProgress); 17809 let originalProgress = progress; 17810 17811 if (!isCenteredSlides) { 17812 originalProgress = Math.min(Math.max($slideEl[0].originalProgress, -params.limitProgress), params.limitProgress); 17813 } 17814 17815 const offset = $slideEl[0].swiperSlideOffset; 17816 const t = [swiper.params.cssMode ? -offset - swiper.translate : -offset, 0, 0]; 17817 const r = [0, 0, 0]; 17818 let custom = false; 17819 17820 if (!swiper.isHorizontal()) { 17821 t[1] = t[0]; 17822 t[0] = 0; 17823 } 17824 17825 let data = { 17826 translate: [0, 0, 0], 17827 rotate: [0, 0, 0], 17828 scale: 1, 17829 opacity: 1 17830 }; 17831 17832 if (progress < 0) { 17833 data = params.next; 17834 custom = true; 17835 } else if (progress > 0) { 17836 data = params.prev; 17837 custom = true; 17838 } // set translate 17839 17840 17841 t.forEach((value, index) => { 17842 t[index] = `calc(${value}px + (${getTranslateValue(data.translate[index])} * ${Math.abs(progress * multiplier)}))`; 17843 }); // set rotates 17844 17845 r.forEach((value, index) => { 17846 r[index] = data.rotate[index] * Math.abs(progress * multiplier); 17847 }); 17848 $slideEl[0].style.zIndex = -Math.abs(Math.round(slideProgress)) + slides.length; 17849 const translateString = t.join(', '); 17850 const rotateString = `rotateX(${r[0]}deg) rotateY(${r[1]}deg) rotateZ(${r[2]}deg)`; 17851 const scaleString = originalProgress < 0 ? `scale(${1 + (1 - data.scale) * originalProgress * multiplier})` : `scale(${1 - (1 - data.scale) * originalProgress * multiplier})`; 17852 const opacityString = originalProgress < 0 ? 1 + (1 - data.opacity) * originalProgress * multiplier : 1 - (1 - data.opacity) * originalProgress * multiplier; 17853 const transform = `translate3d(${translateString}) ${rotateString} ${scaleString}`; // Set shadows 17854 17855 if (custom && data.shadow || !custom) { 17856 let $shadowEl = $slideEl.children('.swiper-slide-shadow'); 17857 17858 if ($shadowEl.length === 0 && data.shadow) { 17859 $shadowEl = createShadow(params, $slideEl); 17860 } 17861 17862 if ($shadowEl.length) { 17863 const shadowOpacity = params.shadowPerProgress ? progress * (1 / params.limitProgress) : progress; 17864 $shadowEl[0].style.opacity = Math.min(Math.max(Math.abs(shadowOpacity), 0), 1); 17865 } 17866 } 17867 17868 const $targetEl = effectTarget(params, $slideEl); 17869 $targetEl.transform(transform).css({ 17870 opacity: opacityString 17871 }); 17872 17873 if (data.origin) { 17874 $targetEl.css('transform-origin', data.origin); 17875 } 17876 } 17877 }; 17878 17879 const setTransition = duration => { 17880 const { 17881 transformEl 17882 } = swiper.params.creativeEffect; 17883 const $transitionElements = transformEl ? swiper.slides.find(transformEl) : swiper.slides; 17884 $transitionElements.transition(duration).find('.swiper-slide-shadow').transition(duration); 17885 effectVirtualTransitionEnd({ 17886 swiper, 17887 duration, 17888 transformEl, 17889 allSlides: true 17890 }); 17891 }; 17892 17893 effectInit({ 17894 effect: 'creative', 17895 swiper, 17896 on, 17897 setTranslate, 17898 setTransition, 17899 perspective: () => swiper.params.creativeEffect.perspective, 17900 overwriteParams: () => ({ 17901 watchSlidesProgress: true, 17902 virtualTranslate: !swiper.params.cssMode 17903 }) 17904 }); 17905 } 17906 17907 function EffectCards(_ref) { 17908 let { 17909 swiper, 17910 extendParams, 17911 on 17912 } = _ref; 17913 extendParams({ 17914 cardsEffect: { 17915 slideShadows: true, 17916 transformEl: null, 17917 rotate: true, 17918 perSlideRotate: 2, 17919 perSlideOffset: 8 17920 } 17921 }); 17922 17923 const setTranslate = () => { 17924 const { 17925 slides, 17926 activeIndex 17927 } = swiper; 17928 const params = swiper.params.cardsEffect; 17929 const { 17930 startTranslate, 17931 isTouched 17932 } = swiper.touchEventsData; 17933 const currentTranslate = swiper.translate; 17934 17935 for (let i = 0; i < slides.length; i += 1) { 17936 const $slideEl = slides.eq(i); 17937 const slideProgress = $slideEl[0].progress; 17938 const progress = Math.min(Math.max(slideProgress, -4), 4); 17939 let offset = $slideEl[0].swiperSlideOffset; 17940 17941 if (swiper.params.centeredSlides && !swiper.params.cssMode) { 17942 swiper.$wrapperEl.transform(`translateX(${swiper.minTranslate()}px)`); 17943 } 17944 17945 if (swiper.params.centeredSlides && swiper.params.cssMode) { 17946 offset -= slides[0].swiperSlideOffset; 17947 } 17948 17949 let tX = swiper.params.cssMode ? -offset - swiper.translate : -offset; 17950 let tY = 0; 17951 const tZ = -100 * Math.abs(progress); 17952 let scale = 1; 17953 let rotate = -params.perSlideRotate * progress; 17954 let tXAdd = params.perSlideOffset - Math.abs(progress) * 0.75; 17955 const slideIndex = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.from + i : i; 17956 const isSwipeToNext = (slideIndex === activeIndex || slideIndex === activeIndex - 1) && progress > 0 && progress < 1 && (isTouched || swiper.params.cssMode) && currentTranslate < startTranslate; 17957 const isSwipeToPrev = (slideIndex === activeIndex || slideIndex === activeIndex + 1) && progress < 0 && progress > -1 && (isTouched || swiper.params.cssMode) && currentTranslate > startTranslate; 17958 17959 if (isSwipeToNext || isSwipeToPrev) { 17960 const subProgress = (1 - Math.abs((Math.abs(progress) - 0.5) / 0.5)) ** 0.5; 17961 rotate += -28 * progress * subProgress; 17962 scale += -0.5 * subProgress; 17963 tXAdd += 96 * subProgress; 17964 tY = `${-25 * subProgress * Math.abs(progress)}%`; 17965 } 17966 17967 if (progress < 0) { 17968 // next 17969 tX = `calc(${tX}px + (${tXAdd * Math.abs(progress)}%))`;
17970 } else if (progress > 0) { 17971 // prev 17972 tX = `calc(${tX}px + (-${tXAdd * Math.abs(progress)}%))`; 17973 } else { 17974 tX = `${tX}px`; 17975 } 17976 17977 if (!swiper.isHorizontal()) { 17978 const prevY = tY; 17979 tY = tX; 17980 tX = prevY; 17981 } 17982 17983 const scaleString = progress < 0 ? `${1 + (1 - scale) * progress}` : `${1 - (1 - scale) * progress}`; 17984 const transform = ` 17985 translate3d(${tX}, ${tY}, ${tZ}px) 17986 rotateZ(${params.rotate ? rotate : 0}deg) 17987 scale(${scaleString}) 17988 `; 17989 17990 if (params.slideShadows) { 17991 // Set shadows 17992 let $shadowEl = $slideEl.find('.swiper-slide-shadow'); 17993 17994 if ($shadowEl.length === 0) { 17995 $shadowEl = createShadow(params, $slideEl); 17996 } 17997 17998 if ($shadowEl.length) $shadowEl[0].style.opacity = Math.min(Math.max((Math.abs(progress) - 0.5) / 0.5, 0), 1); 17999 } 18000 18001 $slideEl[0].style.zIndex = -Math.abs(Math.round(slideProgress)) + slides.length; 18002 const $targetEl = effectTarget(params, $slideEl); 18003 $targetEl.transform(transform); 18004 } 18005 }; 18006 18007 const setTransition = duration => { 18008 const { 18009 transformEl 18010 } = swiper.params.cardsEffect; 18011 const $transitionElements = transformEl ? swiper.slides.find(transformEl) : swiper.slides; 18012 $transitionElements.transition(duration).find('.swiper-slide-shadow').transition(duration); 18013 effectVirtualTransitionEnd({ 18014 swiper, 18015 duration, 18016 transformEl 18017 }); 18018 }; 18019 18020 effectInit({ 18021 effect: 'cards', 18022 swiper, 18023 on, 18024 setTranslate, 18025 setTransition, 18026 perspective: () => true, 18027 overwriteParams: () => ({ 18028 watchSlidesProgress: true, 18029 virtualTranslate: !swiper.params.cssMode 18030 }) 18031 }); 18032 } 18033 18034 // Swiper Class 18035 const modules = [Virtual, Keyboard, Mousewheel, Navigation, Pagination, Scrollbar, Parallax, Zoom, Lazy, Controller, A11y, History, HashNavigation, Autoplay, Thumb, freeMode, Grid, Manipulation, EffectFade, EffectCube, EffectFlip, EffectCoverflow, EffectCreative, EffectCards]; 18036 Swiper.use(modules); 18037 18038 return Swiper; 18039 18040})); 18041//# sourceMappingURL=swiper-bundle.js.map 18042 18043 18044/***/ }) 18045 18046/******/ }); 18047//# sourceMappingURL=main.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.