1// Menu Functions 2function nonprofit_organization_openNav() { 3 jQuery(".sidenav").addClass('show'); 4} 5 6function nonprofit_organization_closeNav() { 7 jQuery(".sidenav").removeClass('show'); 8} 9 10/////////////////////// Focus handling /////////////////////// 11(function(window, document) { 12 function nonprofit_organization_handleMobileMenuNavigation() { 13 document.addEventListener('keydown', function(e) { 14 if (window.innerWidth > 991) return; 15 const nav = document.querySelector('.sidenav.show'); 16 if (!nav) return; 17 const focusableElements = Array.from(nav.querySelectorAll( 18 'a, button, [tabindex="0"], input, [tabindex]:not([tabindex="-1"])' 19 )).filter(el => el.offsetParent !== null); 20 21 if (focusableElements.length === 0) return; 22 23 const firstElement = focusableElements[0]; 24 const lastElement = focusableElements[focusableElements.length - 1]; 25 const activeElement = document.activeElement; 26 27 if (e.key === 'Tab') { 28 if (!e.shiftKey && activeElement === lastElement) { 29 e.preventDefault(); 30 firstElement.focus(); 31 } 32 else if (e.shiftKey && activeElement === firstElement) { 33 e.preventDefault(); 34 lastElement.focus(); 35 } 36 else if (!nav.contains(activeElement)) { 37 e.preventDefault(); 38 firstElement.focus(); 39 } 40 return; 41 } 42 43 if (e.key === 'Tab' && e.shiftKey) { 44 const activeElement = document.activeElement; 45 46 if (activeElement.closest('.dropdown-menu')) { 47 e.preventDefault(); 48 49 //current submenu 50 const currentSubmenu = activeElement.closest('.dropdown-menu'); 51 const submenuItems = Array.from(currentSubmenu.querySelectorAll('a, button, [tabindex="0"]')) 52 .filter(el => el.offsetParent !== null); 53 const currentIndex = submenuItems.indexOf(activeElement); 54 if (currentIndex > 0) { 55 submenuItems[currentIndex - 1].focus(); 56 } else { 57 const parentDropdown = currentSubmenu.closest('.dropdown, .page_item_has_children'); 58 if (parentDropdown) { 59 // Find all focusable elements in parent 60 const allFocusable = Array.from(parentDropdown.querySelectorAll('a, button, [tabindex="0"]')) 61 .filter(el => el.offsetParent !== null); 62 63 // Filter to only direct children of parentDropdown 64 const parentItems = allFocusable.filter(el => el.parentElement === parentDropdown); 65 66 if (parentItems.length > 0) { 67 parentItems[0].focus(); 68 } 69 } 70 } 71 } 72 } 73 }); 74 } 75 76 document.addEventListener('DOMContentLoaded', function() { 77 nonprofit_organization_handleMobileMenuNavigation(); 78 79 document.addEventListener('focusin', function(e) { 80 if (window.innerWidth > 991) return; 81 82 const focusedItem = e.target; 83 const submenu = focusedItem.closest('.dropdown-menu'); 84 if (submenu) { 85 submenu.style.display = 'block'; 86 submenu.classList.add('show'); 87 } 88 }); 89 }); 90})(window, document); 91 92jQuery(document).ready(function ($) { 93 /*--- adding dropdown class to menu -----*/ 94$("#site-navigation ul.sub-menu,#site-navigation ul.children").parent().addClass("dropdown"); 95 $("#site-navigation ul.sub-menu,#site-navigation ul.children").addClass("dropdown-menu"); 96 $("#site-navigation ul#menuid li.dropdown a,#site-navigation ul.children li.dropdown a").addClass("dropdown-toggle"); 97 $("#site-navigation ul.sub-menu li a,#site-navigation ul.children li a").removeClass("dropdown-toggle"); 98 $('#site-navigation nav li.dropdown > a,#site-navigation .page_item_has_children a').append('<span class="caret"></span>'); 99 $('#site-navigation a.dropdown-toggle').attr('data-toggle', 'dropdown'); 100 101 /-- Mobile menu --/ 102 if ($('#site-navigation').length) { 103 $('#site-navigation .menu li.dropdown, #site-navigation li.page_item_has_children').append(function () { 104 // Changed Bootstrap icon to Dashicon (arrow down) 105 return '<span class="dashicons dashicons-arrow-down-alt2" aria-hidden="true"></span>'; 106 });
107 108 $('#site-navigation .menu li.dropdown .dashicons, #site-navigation li.page_item_has_children .dashicons').on('click', function () { 109 $(this).parent('li').children('ul').slideToggle().toggleClass('show'); 110 }); 111 } 112 113 $(window).on('scroll', function () { 114 if ($(this).scrollTop() > 200) 115 $('.btntoTop').addClass('active'); 116 else 117 $('.btntoTop').removeClass('active'); 118 }); 119 120 /*-- Reload page when width is between 320 and 768px and only from desktop */ 121 var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ? true : false; 122 $(window).on('resize', function () { 123 var win = $(this); //this = window 124 if (win.width() > 320 && win.width() < 991 && isMobile == false && !$("body").hasClass("elementor-editor-active")) { 125 location.reload(); 126 } 127 }); 128}); 129 130 131/////////////////////// end ///////////////////////;
vendor: 23,216 bytes, lines 132-1078
132/** 133 * Owl Carousel v2.3.4 134 * Copyright 2013-2018 David Deutsch 135 * Licensed under: SEE LICENSE IN https://github.com/OwlCarousel2/OwlCarousel2/blob/master/LICENSE 136 */ 137/** 138 * Owl carousel 139 * @version 2.3.4 140 * @author Bartosz Wojciechowski 141 * @author David Deutsch 142 * @license The MIT License (MIT) 143 * @todo Lazy Load Icon 144 * @todo prevent animationend bubling 145 * @todo itemsScaleUp 146 * @todo Test Zepto 147 * @todo stagePadding calculate wrong active classes 148 */ 149;(function($, window, document, undefined) { 150 151 /** 152 * Creates a carousel. 153 * @class The Owl Carousel. 154 * @public 155 * @param {HTMLElement|jQuery} element - The element to create the carousel for. 156 * @param {Object} [options] - The options 157 */ 158 function Owl(element, options) { 159 160 /** 161 * Current settings for the carousel. 162 * @public 163 */ 164 this.settings = null; 165 166 /** 167 * Current options set by the caller including defaults. 168 * @public 169 */ 170 this.options = $.extend({}, Owl.Defaults, options); 171 172 /** 173 * Plugin element. 174 * @public 175 */ 176 this.$element = $(element); 177 178 /** 179 * Proxied event handlers. 180 * @protected 181 */ 182 this._handlers = {}; 183 184 /** 185 * References to the running plugins of this carousel. 186 * @protected 187 */ 188 this._plugins = {}; 189 190 /** 191 * Currently suppressed events to prevent them from being retriggered. 192 * @protected 193 */ 194 this._supress = {}; 195 196 /** 197 * Absolute current position. 198 * @protected 199 */ 200 this._current = null; 201 202 /** 203 * Animation speed in milliseconds. 204 * @protected 205 */ 206 this._speed = null; 207 208 /** 209 * Coordinates of all items in pixel. 210 * @todo The name of this member is missleading. 211 * @protected 212 */ 213 this._coordinates = []; 214 215 /** 216 * Current breakpoint. 217 * @todo Real media queries would be nice. 218 * @protected 219 */ 220 this._breakpoint = null; 221 222 /** 223 * Current width of the plugin element. 224 */ 225 this._width = null; 226 227 /** 228 * All real items. 229 * @protected 230 */ 231 this._items = []; 232 233 /** 234 * All cloned items. 235 * @protected 236 */ 237 this._clones = []; 238 239 /** 240 * Merge values of all items. 241 * @todo Maybe this could be part of a plugin. 242 * @protected 243 */ 244 this._mergers = []; 245 246 /** 247 * Widths of all items. 248 */ 249 this._widths = []; 250 251 /** 252 * Invalidated parts within the update process. 253 * @protected 254 */ 255 this._invalidated = {}; 256 257 /** 258 * Ordered list of workers for the update process. 259 * @protected 260 */ 261 this._pipe = []; 262 263 /** 264 * Current state information for the drag operation. 265 * @todo #261 266 * @protected 267 */ 268 this._drag = { 269 time: null, 270 target: null, 271 pointer: null, 272 stage: { 273 start: null, 274 current: null 275 }, 276 direction: null 277 }; 278 279 /** 280 * Current state information and their tags. 281 * @type {Object} 282 * @protected 283 */ 284 this._states = { 285 current: {}, 286 tags: { 287 'initializing': [ 'busy' ], 288 'animating': [ 'busy' ], 289 'dragging': [ 'interacting' ] 290 } 291 }; 292 293 $.each([ 'onResize', 'onThrottledResize' ], $.proxy(function(i, handler) { 294 this._handlers[handler] = $.proxy(this[handler], this); 295 }, this)); 296 297 $.each(Owl.Plugins, $.proxy(function(key, plugin) { 298 this._plugins[key.charAt(0).toLowerCase() + key.slice(1)] 299 = new plugin(this); 300 }, this)); 301 302 $.each(Owl.Workers, $.proxy(function(priority, worker) { 303 this._pipe.push({ 304 'filter': worker.filter, 305 'run': $.proxy(worker.run, this) 306 }); 307 }, this)); 308 309 this.setup(); 310 this.initialize(); 311 } 312 313 /** 314 * Default options for the carousel. 315 * @public 316 */ 317 Owl.Defaults = { 318 items: 3, 319 loop: false, 320 center: false, 321 rewind: false, 322 checkVisibility: true, 323 324 mouseDrag: true, 325 touchDrag: true, 326 pullDrag: true, 327 freeDrag: false, 328 329 margin: 0, 330 stagePadding: 0, 331 332 merge: false, 333 mergeFit: true, 334 autoWidth: false, 335 336 startPosition: 0, 337 rtl: false, 338 339 smartSpeed: 250, 340 fluidSpeed: false, 341 dragEndSpeed: false, 342 343 responsive: {}, 344 responsiveRefreshRate: 200, 345 responsiveBaseElement: window, 346 347 fallbackEasing: 'swing', 348 slideTransition: '', 349 350 info: false, 351 352 nestedItemSelector: false, 353 itemElement: 'div', 354 stageElement: 'div', 355 356 refreshClass: 'owl-refresh', 357 loadedClass: 'owl-loaded', 358 loadingClass: 'owl-loading', 359 rtlClass: 'owl-rtl', 360 responsiveClass: 'owl-responsive', 361 dragClass: 'owl-drag', 362 itemClass: 'owl-item', 363 stageClass: 'owl-stage', 364 stageOuterClass: 'owl-stage-outer', 365 grabClass: 'owl-grab' 366 }; 367 368 /** 369 * Enumeration for width. 370 * @public 371 * @readonly 372 * @enum {String} 373 */ 374 Owl.Width = { 375 Default: 'default', 376 Inner: 'inner', 377 Outer: 'outer' 378 }; 379 380 /** 381 * Enumeration for types. 382 * @public 383 * @readonly 384 * @enum {String} 385 */ 386 Owl.Type = { 387 Event: 'event', 388 State: 'state' 389 }; 390 391 /** 392 * Contains all registered plugins. 393 * @public 394 */ 395 Owl.Plugins = {}; 396 397 /** 398 * List of workers involved in the update process. 399 */ 400 Owl.Workers = [ { 401 filter: [ 'width', 'settings' ], 402 run: function() { 403 this._width = this.$element.width(); 404 } 405 }, { 406 filter: [ 'width', 'items', 'settings' ], 407 run: function(cache) { 408 cache.current = this._items && this._items[this.relative(this._current)]; 409 } 410 }, { 411 filter: [ 'items', 'settings' ], 412 run: function() { 413 this.$stage.children('.cloned').remove(); 414 } 415 }, { 416 filter: [ 'width', 'items', 'settings' ], 417 run: function(cache) { 418 var margin = this.settings.margin || '', 419 grid = !this.settings.autoWidth, 420 rtl = this.settings.rtl, 421 css = { 422 'width': 'auto', 423 'margin-left': rtl ? margin : '', 424 'margin-right': rtl ? '' : margin 425 }; 426 427 !grid && this.$stage.children().css(css); 428 429 cache.css = css; 430 } 431 }, { 432 filter: [ 'width', 'items', 'settings' ], 433 run: function(cache) { 434 var width = (this.width() / this.settings.items).toFixed(3) - this.settings.margin, 435 merge = null, 436 iterator = this._items.length, 437 grid = !this.settings.autoWidth, 438 widths = []; 439 440 cache.items = { 441 merge: false, 442 width: width 443 }; 444 445 while (iterator--) { 446 merge = this._mergers[iterator]; 447 merge = this.settings.mergeFit && Math.min(merge, this.settings.items) || merge; 448 449 cache.items.merge = merge > 1 || cache.items.merge; 450 451 widths[iterator] = !grid ? this._items[iterator].width() : width * merge; 452 } 453 454 this._widths = widths; 455 } 456 }, { 457 filter: [ 'items', 'settings' ], 458 run: function() { 459 var clones = [], 460 items = this._items, 461 settings = this.settings, 462 // TODO: Should be computed from number of min width items in stage 463 view = Math.max(settings.items * 2, 4), 464 size = Math.ceil(items.length / 2) * 2, 465 repeat = settings.loop && items.length ? settings.rewind ? view : Math.max(view, size) : 0, 466 append = '', 467 prepend = ''; 468 469 repeat /= 2; 470 471 while (repeat > 0) { 472 // Switch to only using appended clones 473 clones.push(this.normalize(clones.length / 2, true)); 474 append = append + items[clones[clones.length - 1]][0].outerHTML; 475 clones.push(this.normalize(items.length - 1 - (clones.length - 1) / 2, true)); 476 prepend = items[clones[clones.length - 1]][0].outerHTML + prepend; 477 repeat -= 1; 478 } 479 480 this._clones = clones; 481 482 $(append).addClass('cloned').appendTo(this.$stage); 483 $(prepend).addClass('cloned').prependTo(this.$stage); 484 } 485 }, { 486 filter: [ 'width', 'items', 'settings' ], 487 run: function() { 488 var rtl = this.settings.rtl ? 1 : -1, 489 size = this._clones.length + this._items.length, 490 iterator = -1, 491 previous = 0, 492 current = 0, 493 coordinates = []; 494 495 while (++iterator < size) { 496 previous = coordinates[iterator - 1] || 0; 497 current = this._widths[this.relative(iterator)] + this.settings.margin; 498 coordinates.push(previous + current * rtl); 499 } 500 501 this._coordinates = coordinates; 502 } 503 }, { 504 filter: [ 'width', 'items', 'settings' ], 505 run: function() { 506 var padding = this.settings.stagePadding, 507 coordinates = this._coordinates, 508 css = { 509 'width': Math.ceil(Math.abs(coordinates[coordinates.length - 1])) + padding * 2, 510 'padding-left': padding || '', 511 'padding-right': padding || '' 512 }; 513 514 this.$stage.css(css); 515 } 516 }, { 517 filter: [ 'width', 'items', 'settings' ], 518 run: function(cache) { 519 var iterator = this._coordinates.length, 520 grid = !this.settings.autoWidth, 521 items = this.$stage.children(); 522 523 if (grid && cache.items.merge) { 524 while (iterator--) { 525 cache.css.width = this._widths[this.relative(iterator)]; 526 items.eq(iterator).css(cache.css); 527 } 528 } else if (grid) { 529 cache.css.width = cache.items.width; 530 items.css(cache.css); 531 } 532 } 533 }, { 534 filter: [ 'items' ], 535 run: function() { 536 this._coordinates.length < 1 && this.$stage.removeAttr('style'); 537 } 538 }, { 539 filter: [ 'width', 'items', 'settings' ], 540 run: function(cache) { 541 cache.current = cache.current ? this.$stage.children().index(cache.current) : 0; 542 cache.current = Math.max(this.minimum(), Math.min(this.maximum(), cache.current)); 543 this.reset(cache.current); 544 } 545 }, { 546 filter: [ 'position' ], 547 run: function() { 548 this.animate(this.coordinates(this._current)); 549 } 550 }, { 551 filter: [ 'width', 'position', 'items', 'settings' ], 552 run: function() { 553 var rtl = this.settings.rtl ? 1 : -1, 554 padding = this.settings.stagePadding * 2, 555 begin = this.coordinates(this.current()) + padding, 556 end = begin + this.width() * rtl, 557 inner, outer, matches = [], i, n; 558 559 for (i = 0, n = this._coordinates.length; i < n; i++) { 560 inner = this._coordinates[i - 1] || 0; 561 outer = Math.abs(this._coordinates[i]) + padding * rtl; 562 563 if ((this.op(inner, '<=', begin) && (this.op(inner, '>', end))) 564 || (this.op(outer, '<', begin) && this.op(outer, '>', end))) { 565 matches.push(i); 566 } 567 } 568 569 this.$stage.children('.active').removeClass('active'); 570 this.$stage.children(':eq(' + matches.join('), :eq(') + ')').addClass('active'); 571 572 this.$stage.children('.center').removeClass('center'); 573 if (this.settings.center) { 574 this.$stage.children().eq(this.current()).addClass('center'); 575 } 576 } 577 } ]; 578 579 /** 580 * Create the stage DOM element 581 */ 582 Owl.prototype.initializeStage = function() { 583 this.$stage = this.$element.find('.' + this.settings.stageClass); 584 585 // if the stage is already in the DOM, grab it and skip stage initialization 586 if (this.$stage.length) { 587 return; 588 } 589 590 this.$element.addClass(this.options.loadingClass); 591 592 // create stage 593 this.$stage = $('<' + this.settings.stageElement + '>', { 594 "class": this.settings.stageClass 595 }).wrap( $( '<div/>', { 596 "class": this.settings.stageOuterClass 597 })); 598 599 // append stage 600 this.$element.append(this.$stage.parent()); 601 }; 602 603 /** 604 * Create item DOM elements 605 */ 606 Owl.prototype.initializeItems = function() { 607 var $items = this.$element.find('.owl-item'); 608 609 // if the items are already in the DOM, grab them and skip item initialization 610 if ($items.length) { 611 this._items = $items.get().map(function(item) { 612 return $(item); 613 }); 614 615 this._mergers = this._items.map(function() { 616 return 1; 617 }); 618 619 this.refresh(); 620 621 return; 622 } 623 624 // append content 625 this.replace(this.$element.children().not(this.$stage.parent())); 626 627 // check visibility 628 if (this.isVisible()) { 629 // update view 630 this.refresh(); 631 } else { 632 // invalidate width 633 this.invalidate('width'); 634 } 635 636 this.$element 637 .removeClass(this.options.loadingClass) 638 .addClass(this.options.loadedClass); 639 }; 640 641 /** 642 * Initializes the carousel. 643 * @protected 644 */ 645 Owl.prototype.initialize = function() { 646 this.enter('initializing'); 647 this.trigger('initialize'); 648 649 this.$element.toggleClass(this.settings.rtlClass, this.settings.rtl); 650 651 if (this.settings.autoWidth && !this.is('pre-loading')) { 652 var imgs, nestedSelector, width; 653 imgs = this.$element.find('img'); 654 nestedSelector = this.settings.nestedItemSelector ? '.' + this.settings.nestedItemSelector : undefined; 655 width = this.$element.children(nestedSelector).width(); 656 657 if (imgs.length && width <= 0) { 658 this.preloadAutoWidthImages(imgs); 659 } 660 } 661 662 this.initializeStage(); 663 this.initializeItems(); 664 665 // register event handlers 666 this.registerEventHandlers(); 667 668 this.leave('initializing'); 669 this.trigger('initialized'); 670 }; 671 672 /** 673 * @returns {Boolean} visibility of $element 674 * if you know the carousel will always be visible you can set `checkVisibility` to `false` to 675 * prevent the expensive browser layout forced reflow the $element.is(':visible') does 676 */ 677 Owl.prototype.isVisible = function() { 678 return this.settings.checkVisibility 679 ? this.$element.is(':visible') 680 : true; 681 }; 682 683 /** 684 * Setups the current settings. 685 * @todo Remove responsive classes. Why should adaptive designs be brought into IE8? 686 * @todo Support for media queries by using `matchMedia` would be nice. 687 * @public 688 */ 689 Owl.prototype.setup = function() { 690 var viewport = this.viewport(), 691 overwrites = this.options.responsive, 692 match = -1, 693 settings = null; 694 695 if (!overwrites) { 696 settings = $.extend({}, this.options); 697 } else { 698 $.each(overwrites, function(breakpoint) { 699 if (breakpoint <= viewport && breakpoint > match) { 700 match = Number(breakpoint); 701 } 702 }); 703 704 settings = $.extend({}, this.options, overwrites[match]); 705 if (typeof settings.stagePadding === 'function') { 706 settings.stagePadding = settings.stagePadding(); 707 } 708 delete settings.responsive; 709 710 // responsive class 711 if (settings.responsiveClass) { 712 this.$element.attr('class', 713 this.$element.attr('class').replace(new RegExp('(' + this.options.responsiveClass + '-)\\S+\\s', 'g'), '$1' + match) 714 ); 715 } 716 } 717 718 this.trigger('change', { property: { name: 'settings', value: settings } }); 719 this._breakpoint = match; 720 this.settings = settings; 721 this.invalidate('settings'); 722 this.trigger('changed', { property: { name: 'settings', value: this.settings } }); 723 }; 724 725 /** 726 * Updates option logic if necessery. 727 * @protected 728 */ 729 Owl.prototype.optionsLogic = function() { 730 if (this.settings.autoWidth) { 731 this.settings.stagePadding = false; 732 this.settings.merge = false; 733 } 734 }; 735 736 /** 737 * Prepares an item before add. 738 * @todo Rename event parameter `content` to `item`. 739 * @protected 740 * @returns {jQuery|HTMLElement} - The item container. 741 */ 742 Owl.prototype.prepare = function(item) { 743 var event = this.trigger('prepare', { content: item }); 744 745 if (!event.data) { 746 event.data = $('<' + this.settings.itemElement + '/>') 747 .addClass(this.options.itemClass).append(item) 748 } 749 750 this.trigger('prepared', { content: event.data }); 751 752 return event.data; 753 }; 754 755 /** 756 * Updates the view. 757 * @public 758 */ 759 Owl.prototype.update = function() { 760 var i = 0, 761 n = this._pipe.length, 762 filter = $.proxy(function(p) { return this[p] }, this._invalidated), 763 cache = {}; 764 765 while (i < n) { 766 if (this._invalidated.all || $.grep(this._pipe[i].filter, filter).length > 0) { 767 this._pipe[i].run(cache); 768 } 769 i++; 770 } 771 772 this._invalidated = {}; 773 774 !this.is('valid') && this.enter('valid'); 775 }; 776 777 /** 778 * Gets the width of the view. 779 * @public 780 * @param {Owl.Width} [dimension=Owl.Width.Default] - The dimension to return. 781 * @returns {Number} - The width of the view in pixel. 782 */ 783 Owl.prototype.width = function(dimension) { 784 dimension = dimension || Owl.Width.Default; 785 switch (dimension) { 786 case Owl.Width.Inner: 787 case Owl.Width.Outer: 788 return this._width; 789 default: 790 return this._width - this.settings.stagePadding * 2 + this.settings.margin; 791 } 792 }; 793 794 /** 795 * Refreshes the carousel primarily for adaptive purposes. 796 * @public 797 */ 798 Owl.prototype.refresh = function() { 799 this.enter('refreshing'); 800 this.trigger('refresh'); 801 802 this.setup(); 803 804 this.optionsLogic(); 805 806 this.$element.addClass(this.options.refreshClass); 807 808 this.update(); 809 810 this.$element.removeClass(this.options.refreshClass); 811 812 this.leave('refreshing'); 813 this.trigger('refreshed'); 814 }; 815 816 /** 817 * Checks window `resize` event. 818 * @protected 819 */ 820 Owl.prototype.onThrottledResize = function() { 821 window.clearTimeout(this.resizeTimer); 822 this.resizeTimer = window.setTimeout(this._handlers.onResize, this.settings.responsiveRefreshRate); 823 }; 824 825 /** 826 * Checks window `resize` event. 827 * @protected 828 */ 829 Owl.prototype.onResize = function() { 830 if (!this._items.length) { 831 return false; 832 } 833 834 if (this._width === this.$element.width()) { 835 return false; 836 } 837 838 if (!this.isVisible()) { 839 return false; 840 } 841 842 this.enter('resizing'); 843 844 if (this.trigger('resize').isDefaultPrevented()) { 845 this.leave('resizing'); 846 return false; 847 } 848 849 this.invalidate('width'); 850 851 this.refresh(); 852 853 this.leave('resizing'); 854 this.trigger('resized'); 855 }; 856 857 /** 858 * Registers event handlers. 859 * @todo Check `msPointerEnabled` 860 * @todo #261 861 * @protected 862 */ 863 Owl.prototype.registerEventHandlers = function() { 864 if ($.support.transition) { 865 this.$stage.on($.support.transition.end + '.owl.core', $.proxy(this.onTransitionEnd, this)); 866 } 867 868 if (this.settings.responsive !== false) { 869 this.on(window, 'resize', this._handlers.onThrottledResize); 870 } 871 872 if (this.settings.mouseDrag) { 873 this.$element.addClass(this.options.dragClass); 874 this.$stage.on('mousedown.owl.core', $.proxy(this.onDragStart, this)); 875 this.$stage.on('dragstart.owl.core selectstart.owl.core', function() { return false }); 876 } 877 878 if (this.settings.touchDrag){ 879 this.$stage.on('touchstart.owl.core', $.proxy(this.onDragStart, this)); 880 this.$stage.on('touchcancel.owl.core', $.proxy(this.onDragEnd, this)); 881 } 882 }; 883 884 /** 885 * Handles `touchstart` and `mousedown` events. 886 * @todo Horizontal swipe threshold as option 887 * @todo #261 888 * @protected 889 * @param {Event} event - The event arguments. 890 */ 891 Owl.prototype.onDragStart = function(event) { 892 var stage = null; 893 894 if (event.which === 3) { 895 return; 896 } 897 898 if ($.support.transform) { 899 stage = this.$stage.css('transform').replace(/.*\(|\)| /g, '').split(','); 900 stage = { 901 x: stage[stage.length === 16 ? 12 : 4], 902 y: stage[stage.length === 16 ? 13 : 5] 903 }; 904 } else { 905 stage = this.$stage.position(); 906 stage = { 907 x: this.settings.rtl ? 908 stage.left + this.$stage.width() - this.width() + this.settings.margin : 909 stage.left, 910 y: stage.top 911 }; 912 } 913 914 if (this.is('animating')) { 915 $.support.transform ? this.animate(stage.x) : this.$stage.stop() 916 this.invalidate('position'); 917 } 918 919 this.$element.toggleClass(this.options.grabClass, event.type === 'mousedown'); 920 921 this.speed(0); 922 923 this._drag.time = new Date().getTime(); 924 this._drag.target = $(event.target); 925 this._drag.stage.start = stage; 926 this._drag.stage.current = stage; 927 this._drag.pointer = this.pointer(event); 928 929 $(document).on('mouseup.owl.core touchend.owl.core', $.proxy(this.onDragEnd, this)); 930 931 $(document).one('mousemove.owl.core touchmove.owl.core', $.proxy(function(event) { 932 var delta = this.difference(this._drag.pointer, this.pointer(event)); 933 934 $(document).on('mousemove.owl.core touchmove.owl.core', $.proxy(this.onDragMove, this)); 935 936 if (Math.abs(delta.x) < Math.abs(delta.y) && this.is('valid')) { 937 return; 938 } 939 940 event.preventDefault(); 941 942 this.enter('dragging'); 943 this.trigger('drag'); 944 }, this)); 945 }; 946 947 /** 948 * Handles the `touchmove` and `mousemove` events. 949 * @todo #261 950 * @protected 951 * @param {Event} event - The event arguments. 952 */ 953 Owl.prototype.onDragMove = function(event) { 954 var minimum = null, 955 maximum = null, 956 pull = null, 957 delta = this.difference(this._drag.pointer, this.pointer(event)), 958 stage = this.difference(this._drag.stage.start, delta); 959 960 if (!this.is('dragging')) { 961 return; 962 } 963 964 event.preventDefault(); 965 966 if (this.settings.loop) { 967 minimum = this.coordinates(this.minimum()); 968 maximum = this.coordinates(this.maximum() + 1) - minimum; 969 stage.x = (((stage.x - minimum) % maximum + maximum) % maximum) + minimum; 970 } else { 971 minimum = this.settings.rtl ? this.coordinates(this.maximum()) : this.coordinates(this.minimum()); 972 maximum = this.settings.rtl ? this.coordinates(this.minimum()) : this.coordinates(this.maximum()); 973 pull = this.settings.pullDrag ? -1 * delta.x / 5 : 0; 974 stage.x = Math.max(Math.min(stage.x, minimum + pull), maximum + pull); 975 } 976 977 this._drag.stage.current = stage; 978 979 this.animate(stage.x); 980 }; 981 982 /** 983 * Handles the `touchend` and `mouseup` events. 984 * @todo #261 985 * @todo Threshold for click event 986 * @protected 987 * @param {Event} event - The event arguments. 988 */ 989 Owl.prototype.onDragEnd = function(event) { 990 var delta = this.difference(this._drag.pointer, this.pointer(event)), 991 stage = this._drag.stage.current, 992 direction = delta.x > 0 ^ this.settings.rtl ? 'left' : 'right'; 993 994 $(document).off('.owl.core'); 995 996 this.$element.removeClass(this.options.grabClass); 997 998 if (delta.x !== 0 && this.is('dragging') || !this.is('valid')) { 999 this.speed(this.settings.dragEndSpeed || this.settings.smartSpeed); 1000 this.current(this.closest(stage.x, delta.x !== 0 ? direction : this._drag.direction)); 1001 this.invalidate('position'); 1002 this.update(); 1003 1004 this._drag.direction = direction; 1005 1006 if (Math.abs(delta.x) > 3 || new Date().getTime() - this._drag.time > 300) { 1007 this._drag.target.one('click.owl.core', function() { return false; }); 1008 } 1009 } 1010 1011 if (!this.is('dragging')) { 1012 return; 1013 } 1014 1015 this.leave('dragging'); 1016 this.trigger('dragged'); 1017 }; 1018 1019 /** 1020 * Gets absolute position of the closest item for a coordinate. 1021 * @todo Setting `freeDrag` makes `closest` not reusable. See #165. 1022 * @protected 1023 * @param {Number} coordinate - The coordinate in pixel. 1024 * @param {String} direction - The direction to check for the closest item. Ether `left` or `right`. 1025 * @return {Number} - The absolute position of the closest item. 1026 */ 1027 Owl.prototype.closest = function(coordinate, direction) { 1028 var position = -1, 1029 pull = 30, 1030 width = this.width(), 1031 coordinates = this.coordinates(); 1032 1033 if (!this.settings.freeDrag) { 1034 // check closest item 1035 $.each(coordinates, $.proxy(function(index, value) { 1036 // on a left pull, check on current index 1037 if (direction === 'left' && coordinate > value - pull && coordinate < value + pull) { 1038 position = index; 1039 // on a right pull, check on previous index 1040 // to do so, subtract width from value and set position = index + 1 1041 } else if (direction === 'right' && coordinate > value - width - pull && coordinate < value - width + pull) { 1042 position = index + 1; 1043 } else if (this.op(coordinate, '<', value) 1044 && this.op(coordinate, '>', coordinates[index + 1] !== undefined ? coordinates[index + 1] : value - width)) { 1045 position = direction === 'left' ? index + 1 : index; 1046 } 1047 return position === -1; 1048 }, this)); 1049 } 1050 1051 if (!this.settings.loop) { 1052 // non loop boundries 1053 if (this.op(coordinate, '>', coordinates[this.minimum()])) { 1054 position = coordinate = this.minimum(); 1055 } else if (this.op(coordinate, '<', coordinates[this.maximum()])) { 1056 position = coordinate = this.maximum(); 1057 } 1058 } 1059 1060 return position; 1061 }; 1062 1063 /** 1064 * Animates the stage. 1065 * @todo #270 1066 * @public 1067 * @param {Number} coordinate - The coordinate in pixels. 1068 */ 1069 Owl.prototype.animate = function(coordinate) { 1070 var animate = this.speed() > 0; 1071 1072 this.is('animating') && this.onTransitionEnd(); 1073 1074 if (animate) { 1075 this.enter('animating'); 1076 this.trigger('translate'); 1077 } 1078
vendor: 10,524 bytes, lines 1079-1446
1079 if ($.support.transform3d && $.support.transition) { 1080 this.$stage.css({ 1081 transform: 'translate3d(' + coordinate + 'px,0px,0px)', 1082 transition: (this.speed() / 1000) + 's' + ( 1083 this.settings.slideTransition ? ' ' + this.settings.slideTransition : '' 1084 ) 1085 }); 1086 } else if (animate) { 1087 this.$stage.animate({ 1088 left: coordinate + 'px' 1089 }, this.speed(), this.settings.fallbackEasing, $.proxy(this.onTransitionEnd, this)); 1090 } else { 1091 this.$stage.css({ 1092 left: coordinate + 'px' 1093 }); 1094 } 1095 }; 1096 1097 /** 1098 * Checks whether the carousel is in a specific state or not. 1099 * @param {String} state - The state to check. 1100 * @returns {Boolean} - The flag which indicates if the carousel is busy. 1101 */ 1102 Owl.prototype.is = function(state) { 1103 return this._states.current[state] && this._states.current[state] > 0; 1104 }; 1105 1106 /** 1107 * Sets the absolute position of the current item. 1108 * @public 1109 * @param {Number} [position] - The new absolute position or nothing to leave it unchanged. 1110 * @returns {Number} - The absolute position of the current item. 1111 */ 1112 Owl.prototype.current = function(position) { 1113 if (position === undefined) { 1114 return this._current; 1115 } 1116 1117 if (this._items.length === 0) { 1118 return undefined; 1119 } 1120 1121 position = this.normalize(position); 1122 1123 if (this._current !== position) { 1124 var event = this.trigger('change', { property: { name: 'position', value: position } }); 1125 1126 if (event.data !== undefined) { 1127 position = this.normalize(event.data); 1128 } 1129 1130 this._current = position; 1131 1132 this.invalidate('position'); 1133 1134 this.trigger('changed', { property: { name: 'position', value: this._current } }); 1135 } 1136 1137 return this._current; 1138 }; 1139 1140 /** 1141 * Invalidates the given part of the update routine. 1142 * @param {String} [part] - The part to invalidate. 1143 * @returns {Array.<String>} - The invalidated parts. 1144 */ 1145 Owl.prototype.invalidate = function(part) { 1146 if ($.type(part) === 'string') { 1147 this._invalidated[part] = true; 1148 this.is('valid') && this.leave('valid'); 1149 } 1150 return $.map(this._invalidated, function(v, i) { return i }); 1151 }; 1152 1153 /** 1154 * Resets the absolute position of the current item. 1155 * @public 1156 * @param {Number} position - The absolute position of the new item. 1157 */ 1158 Owl.prototype.reset = function(position) { 1159 position = this.normalize(position); 1160 1161 if (position === undefined) { 1162 return; 1163 } 1164 1165 this._speed = 0; 1166 this._current = position; 1167 1168 this.suppress([ 'translate', 'translated' ]); 1169 1170 this.animate(this.coordinates(position)); 1171 1172 this.release([ 'translate', 'translated' ]); 1173 }; 1174 1175 /** 1176 * Normalizes an absolute or a relative position of an item. 1177 * @public 1178 * @param {Number} position - The absolute or relative position to normalize. 1179 * @param {Boolean} [relative=false] - Whether the given position is relative or not. 1180 * @returns {Number} - The normalized position. 1181 */ 1182 Owl.prototype.normalize = function(position, relative) { 1183 var n = this._items.length, 1184 m = relative ? 0 : this._clones.length; 1185 1186 if (!this.isNumeric(position) || n < 1) { 1187 position = undefined; 1188 } else if (position < 0 || position >= n + m) { 1189 position = ((position - m / 2) % n + n) % n + m / 2; 1190 } 1191 1192 return position; 1193 }; 1194 1195 /** 1196 * Converts an absolute position of an item into a relative one. 1197 * @public 1198 * @param {Number} position - The absolute position to convert. 1199 * @returns {Number} - The converted position. 1200 */ 1201 Owl.prototype.relative = function(position) { 1202 position -= this._clones.length / 2; 1203 return this.normalize(position, true); 1204 }; 1205 1206 /** 1207 * Gets the maximum position for the current item. 1208 * @public 1209 * @param {Boolean} [relative=false] - Whether to return an absolute position or a relative position. 1210 * @returns {Number} 1211 */ 1212 Owl.prototype.maximum = function(relative) { 1213 var settings = this.settings, 1214 maximum = this._coordinates.length, 1215 iterator, 1216 reciprocalItemsWidth, 1217 elementWidth; 1218 1219 if (settings.loop) { 1220 maximum = this._clones.length / 2 + this._items.length - 1; 1221 } else if (settings.autoWidth || settings.merge) { 1222 iterator = this._items.length; 1223 if (iterator) { 1224 reciprocalItemsWidth = this._items[--iterator].width(); 1225 elementWidth = this.$element.width(); 1226 while (iterator--) { 1227 reciprocalItemsWidth += this._items[iterator].width() + this.settings.margin; 1228 if (reciprocalItemsWidth > elementWidth) { 1229 break; 1230 } 1231 } 1232 } 1233 maximum = iterator + 1; 1234 } else if (settings.center) { 1235 maximum = this._items.length - 1; 1236 } else { 1237 maximum = this._items.length - settings.items; 1238 } 1239 1240 if (relative) { 1241 maximum -= this._clones.length / 2; 1242 } 1243 1244 return Math.max(maximum, 0); 1245 }; 1246 1247 /** 1248 * Gets the minimum position for the current item. 1249 * @public 1250 * @param {Boolean} [relative=false] - Whether to return an absolute position or a relative position. 1251 * @returns {Number} 1252 */ 1253 Owl.prototype.minimum = function(relative) { 1254 return relative ? 0 : this._clones.length / 2; 1255 }; 1256 1257 /** 1258 * Gets an item at the specified relative position. 1259 * @public 1260 * @param {Number} [position] - The relative position of the item. 1261 * @return {jQuery|Array.<jQuery>} - The item at the given position or all items if no position was given. 1262 */ 1263 Owl.prototype.items = function(position) { 1264 if (position === undefined) { 1265 return this._items.slice(); 1266 } 1267 1268 position = this.normalize(position, true); 1269 return this._items[position]; 1270 }; 1271 1272 /** 1273 * Gets an item at the specified relative position. 1274 * @public 1275 * @param {Number} [position] - The relative position of the item. 1276 * @return {jQuery|Array.<jQuery>} - The item at the given position or all items if no position was given. 1277 */ 1278 Owl.prototype.mergers = function(position) { 1279 if (position === undefined) { 1280 return this._mergers.slice(); 1281 } 1282 1283 position = this.normalize(position, true); 1284 return this._mergers[position]; 1285 }; 1286 1287 /** 1288 * Gets the absolute positions of clones for an item. 1289 * @public 1290 * @param {Number} [position] - The relative position of the item. 1291 * @returns {Array.<Number>} - The absolute positions of clones for the item or all if no position was given. 1292 */ 1293 Owl.prototype.clones = function(position) { 1294 var odd = this._clones.length / 2, 1295 even = odd + this._items.length, 1296 map = function(index) { return index % 2 === 0 ? even + index / 2 : odd - (index + 1) / 2 }; 1297 1298 if (position === undefined) { 1299 return $.map(this._clones, function(v, i) { return map(i) }); 1300 } 1301 1302 return $.map(this._clones, function(v, i) { return v === position ? map(i) : null }); 1303 }; 1304 1305 /** 1306 * Sets the current animation speed. 1307 * @public 1308 * @param {Number} [speed] - The animation speed in milliseconds or nothing to leave it unchanged. 1309 * @returns {Number} - The current animation speed in milliseconds. 1310 */ 1311 Owl.prototype.speed = function(speed) { 1312 if (speed !== undefined) { 1313 this._speed = speed; 1314 } 1315 1316 return this._speed; 1317 }; 1318 1319 /** 1320 * Gets the coordinate of an item. 1321 * @todo The name of this method is missleanding. 1322 * @public 1323 * @param {Number} position - The absolute position of the item within `minimum()` and `maximum()`. 1324 * @returns {Number|Array.<Number>} - The coordinate of the item in pixel or all coordinates. 1325 */ 1326 Owl.prototype.coordinates = function(position) { 1327 var multiplier = 1, 1328 newPosition = position - 1, 1329 coordinate; 1330 1331 if (position === undefined) { 1332 return $.map(this._coordinates, $.proxy(function(coordinate, index) { 1333 return this.coordinates(index); 1334 }, this)); 1335 } 1336 1337 if (this.settings.center) { 1338 if (this.settings.rtl) { 1339 multiplier = -1; 1340 newPosition = position + 1; 1341 } 1342 1343 coordinate = this._coordinates[position]; 1344 coordinate += (this.width() - coordinate + (this._coordinates[newPosition] || 0)) / 2 * multiplier; 1345 } else { 1346 coordinate = this._coordinates[newPosition] || 0; 1347 } 1348 1349 coordinate = Math.ceil(coordinate); 1350 1351 return coordinate; 1352 }; 1353 1354 /** 1355 * Calculates the speed for a translation. 1356 * @protected 1357 * @param {Number} from - The absolute position of the start item. 1358 * @param {Number} to - The absolute position of the target item. 1359 * @param {Number} [factor=undefined] - The time factor in milliseconds. 1360 * @returns {Number} - The time in milliseconds for the translation. 1361 */ 1362 Owl.prototype.duration = function(from, to, factor) { 1363 if (factor === 0) { 1364 return 0; 1365 } 1366 1367 return Math.min(Math.max(Math.abs(to - from), 1), 6) * Math.abs((factor || this.settings.smartSpeed)); 1368 }; 1369 1370 /** 1371 * Slides to the specified item. 1372 * @public 1373 * @param {Number} position - The position of the item. 1374 * @param {Number} [speed] - The time in milliseconds for the transition. 1375 */ 1376 Owl.prototype.to = function(position, speed) { 1377 var current = this.current(), 1378 revert = null, 1379 distance = position - this.relative(current), 1380 direction = (distance > 0) - (distance < 0), 1381 items = this._items.length, 1382 minimum = this.minimum(), 1383 maximum = this.maximum(); 1384 1385 if (this.settings.loop) { 1386 if (!this.settings.rewind && Math.abs(distance) > items / 2) { 1387 distance += direction * -1 * items; 1388 } 1389 1390 position = current + distance; 1391 revert = ((position - minimum) % items + items) % items + minimum; 1392 1393 if (revert !== position && revert - distance <= maximum && revert - distance > 0) { 1394 current = revert - distance; 1395 position = revert; 1396 this.reset(current); 1397 } 1398 } else if (this.settings.rewind) { 1399 maximum += 1; 1400 position = (position % maximum + maximum) % maximum; 1401 } else { 1402 position = Math.max(minimum, Math.min(maximum, position)); 1403 } 1404 1405 this.speed(this.duration(current, position, speed)); 1406 this.current(position); 1407 1408 if (this.isVisible()) { 1409 this.update(); 1410 } 1411 }; 1412 1413 /** 1414 * Slides to the next item. 1415 * @public 1416 * @param {Number} [speed] - The time in milliseconds for the transition. 1417 */ 1418 Owl.prototype.next = function(speed) { 1419 speed = speed || false; 1420 this.to(this.relative(this.current()) + 1, speed); 1421 }; 1422 1423 /** 1424 * Slides to the previous item. 1425 * @public 1426 * @param {Number} [speed] - The time in milliseconds for the transition. 1427 */ 1428 Owl.prototype.prev = function(speed) { 1429 speed = speed || false; 1430 this.to(this.relative(this.current()) - 1, speed); 1431 }; 1432 1433 /** 1434 * Handles the end of an animation. 1435 * @protected 1436 * @param {Event} event - The event arguments. 1437 */ 1438 Owl.prototype.onTransitionEnd = function(event) { 1439 1440 // if css2 animation then event object is undefined 1441 if (event !== undefined) { 1442 event.stopPropagation(); 1443 1444 // Catch only owl-stage transitionEnd event 1445 if ((event.target || event.srcElement || event.originalTarget) !== this.$stage.get(0)) { 1446 return false;
vendor: 22,957 bytes, lines 1447-2295
1447 } 1448 } 1449 1450 this.leave('animating'); 1451 this.trigger('translated'); 1452 }; 1453 1454 /** 1455 * Gets viewport width. 1456 * @protected 1457 * @return {Number} - The width in pixel. 1458 */ 1459 Owl.prototype.viewport = function() { 1460 var width; 1461 if (this.options.responsiveBaseElement !== window) { 1462 width = $(this.options.responsiveBaseElement).width(); 1463 } else if (window.innerWidth) { 1464 width = window.innerWidth; 1465 } else if (document.documentElement && document.documentElement.clientWidth) { 1466 width = document.documentElement.clientWidth; 1467 } else { 1468 console.warn('Can not detect viewport width.'); 1469 } 1470 return width; 1471 }; 1472 1473 /** 1474 * Replaces the current content. 1475 * @public 1476 * @param {HTMLElement|jQuery|String} content - The new content. 1477 */ 1478 Owl.prototype.replace = function(content) { 1479 this.$stage.empty(); 1480 this._items = []; 1481 1482 if (content) { 1483 content = (content instanceof jQuery) ? content : $(content); 1484 } 1485 1486 if (this.settings.nestedItemSelector) { 1487 content = content.find('.' + this.settings.nestedItemSelector); 1488 } 1489 1490 content.filter(function() { 1491 return this.nodeType === 1; 1492 }).each($.proxy(function(index, item) { 1493 item = this.prepare(item); 1494 this.$stage.append(item); 1495 this._items.push(item); 1496 this._mergers.push(item.find('[data-merge]').addBack('[data-merge]').attr('data-merge') * 1 || 1); 1497 }, this)); 1498 1499 this.reset(this.isNumeric(this.settings.startPosition) ? this.settings.startPosition : 0); 1500 1501 this.invalidate('items'); 1502 }; 1503 1504 /** 1505 * Adds an item. 1506 * @todo Use `item` instead of `content` for the event arguments. 1507 * @public 1508 * @param {HTMLElement|jQuery|String} content - The item content to add. 1509 * @param {Number} [position] - The relative position at which to insert the item otherwise the item will be added to the end. 1510 */ 1511 Owl.prototype.add = function(content, position) { 1512 var current = this.relative(this._current); 1513 1514 position = position === undefined ? this._items.length : this.normalize(position, true); 1515 content = content instanceof jQuery ? content : $(content); 1516 1517 this.trigger('add', { content: content, position: position }); 1518 1519 content = this.prepare(content); 1520 1521 if (this._items.length === 0 || position === this._items.length) { 1522 this._items.length === 0 && this.$stage.append(content); 1523 this._items.length !== 0 && this._items[position - 1].after(content); 1524 this._items.push(content); 1525 this._mergers.push(content.find('[data-merge]').addBack('[data-merge]').attr('data-merge') * 1 || 1); 1526 } else { 1527 this._items[position].before(content); 1528 this._items.splice(position, 0, content); 1529 this._mergers.splice(position, 0, content.find('[data-merge]').addBack('[data-merge]').attr('data-merge') * 1 || 1); 1530 } 1531 1532 this._items[current] && this.reset(this._items[current].index()); 1533 1534 this.invalidate('items'); 1535 1536 this.trigger('added', { content: content, position: position }); 1537 }; 1538 1539 /** 1540 * Removes an item by its position. 1541 * @todo Use `item` instead of `content` for the event arguments. 1542 * @public 1543 * @param {Number} position - The relative position of the item to remove. 1544 */ 1545 Owl.prototype.remove = function(position) { 1546 position = this.normalize(position, true); 1547 1548 if (position === undefined) { 1549 return; 1550 } 1551 1552 this.trigger('remove', { content: this._items[position], position: position }); 1553 1554 this._items[position].remove(); 1555 this._items.splice(position, 1); 1556 this._mergers.splice(position, 1); 1557 1558 this.invalidate('items'); 1559 1560 this.trigger('removed', { content: null, position: position }); 1561 }; 1562 1563 /** 1564 * Preloads images with auto width. 1565 * @todo Replace by a more generic approach 1566 * @protected 1567 */ 1568 Owl.prototype.preloadAutoWidthImages = function(images) { 1569 images.each($.proxy(function(i, element) { 1570 this.enter('pre-loading'); 1571 element = $(element); 1572 $(new Image()).one('load', $.proxy(function(e) { 1573 element.attr('src', e.target.src); 1574 element.css('opacity', 1); 1575 this.leave('pre-loading'); 1576 !this.is('pre-loading') && !this.is('initializing') && this.refresh(); 1577 }, this)).attr('src', element.attr('src') || element.attr('data-src') || element.attr('data-src-retina')); 1578 }, this)); 1579 }; 1580 1581 /** 1582 * Destroys the carousel. 1583 * @public 1584 */ 1585 Owl.prototype.destroy = function() { 1586 1587 this.$element.off('.owl.core'); 1588 this.$stage.off('.owl.core'); 1589 $(document).off('.owl.core'); 1590 1591 if (this.settings.responsive !== false) { 1592 window.clearTimeout(this.resizeTimer); 1593 this.off(window, 'resize', this._handlers.onThrottledResize); 1594 } 1595 1596 for (var i in this._plugins) { 1597 this._plugins[i].destroy(); 1598 } 1599 1600 this.$stage.children('.cloned').remove(); 1601 1602 this.$stage.unwrap(); 1603 this.$stage.children().contents().unwrap(); 1604 this.$stage.children().unwrap(); 1605 this.$stage.remove(); 1606 this.$element 1607 .removeClass(this.options.refreshClass) 1608 .removeClass(this.options.loadingClass) 1609 .removeClass(this.options.loadedClass) 1610 .removeClass(this.options.rtlClass) 1611 .removeClass(this.options.dragClass) 1612 .removeClass(this.options.grabClass) 1613 .attr('class', this.$element.attr('class').replace(new RegExp(this.options.responsiveClass + '-\\S+\\s', 'g'), '')) 1614 .removeData('owl.carousel'); 1615 }; 1616 1617 /** 1618 * Operators to calculate right-to-left and left-to-right. 1619 * @protected 1620 * @param {Number} [a] - The left side operand. 1621 * @param {String} [o] - The operator. 1622 * @param {Number} [b] - The right side operand. 1623 */ 1624 Owl.prototype.op = function(a, o, b) { 1625 var rtl = this.settings.rtl; 1626 switch (o) { 1627 case '<': 1628 return rtl ? a > b : a < b; 1629 case '>': 1630 return rtl ? a < b : a > b; 1631 case '>=': 1632 return rtl ? a <= b : a >= b; 1633 case '<=': 1634 return rtl ? a >= b : a <= b; 1635 default: 1636 break; 1637 } 1638 }; 1639 1640 /** 1641 * Attaches to an internal event. 1642 * @protected 1643 * @param {HTMLElement} element - The event source. 1644 * @param {String} event - The event name. 1645 * @param {Function} listener - The event handler to attach. 1646 * @param {Boolean} capture - Wether the event should be handled at the capturing phase or not. 1647 */ 1648 Owl.prototype.on = function(element, event, listener, capture) { 1649 if (element.addEventListener) { 1650 element.addEventListener(event, listener, capture); 1651 } else if (element.attachEvent) { 1652 element.attachEvent('on' + event, listener); 1653 } 1654 }; 1655 1656 /** 1657 * Detaches from an internal event. 1658 * @protected 1659 * @param {HTMLElement} element - The event source. 1660 * @param {String} event - The event name. 1661 * @param {Function} listener - The attached event handler to detach. 1662 * @param {Boolean} capture - Wether the attached event handler was registered as a capturing listener or not. 1663 */ 1664 Owl.prototype.off = function(element, event, listener, capture) { 1665 if (element.removeEventListener) { 1666 element.removeEventListener(event, listener, capture); 1667 } else if (element.detachEvent) { 1668 element.detachEvent('on' + event, listener); 1669 } 1670 }; 1671 1672 /** 1673 * Triggers a public event. 1674 * @todo Remove `status`, `relatedTarget` should be used instead. 1675 * @protected 1676 * @param {String} name - The event name. 1677 * @param {*} [data=null] - The event data. 1678 * @param {String} [namespace=carousel] - The event namespace. 1679 * @param {String} [state] - The state which is associated with the event. 1680 * @param {Boolean} [enter=false] - Indicates if the call enters the specified state or not. 1681 * @returns {Event} - The event arguments. 1682 */ 1683 Owl.prototype.trigger = function(name, data, namespace, state, enter) { 1684 var status = { 1685 item: { count: this._items.length, index: this.current() } 1686 }, handler = $.camelCase( 1687 $.grep([ 'on', name, namespace ], function(v) { return v }) 1688 .join('-').toLowerCase() 1689 ), event = $.Event( 1690 [ name, 'owl', namespace || 'carousel' ].join('.').toLowerCase(), 1691 $.extend({ relatedTarget: this }, status, data) 1692 ); 1693 1694 if (!this._supress[name]) { 1695 $.each(this._plugins, function(name, plugin) { 1696 if (plugin.onTrigger) { 1697 plugin.onTrigger(event); 1698 } 1699 }); 1700 1701 this.register({ type: Owl.Type.Event, name: name }); 1702 this.$element.trigger(event); 1703 1704 if (this.settings && typeof this.settings[handler] === 'function') { 1705 this.settings[handler].call(this, event); 1706 } 1707 } 1708 1709 return event; 1710 }; 1711 1712 /** 1713 * Enters a state. 1714 * @param name - The state name. 1715 */ 1716 Owl.prototype.enter = function(name) { 1717 $.each([ name ].concat(this._states.tags[name] || []), $.proxy(function(i, name) { 1718 if (this._states.current[name] === undefined) { 1719 this._states.current[name] = 0; 1720 } 1721 1722 this._states.current[name]++; 1723 }, this)); 1724 }; 1725 1726 /** 1727 * Leaves a state. 1728 * @param name - The state name. 1729 */ 1730 Owl.prototype.leave = function(name) { 1731 $.each([ name ].concat(this._states.tags[name] || []), $.proxy(function(i, name) { 1732 this._states.current[name]--; 1733 }, this)); 1734 }; 1735 1736 /** 1737 * Registers an event or state. 1738 * @public 1739 * @param {Object} object - The event or state to register. 1740 */ 1741 Owl.prototype.register = function(object) { 1742 if (object.type === Owl.Type.Event) { 1743 if (!$.event.special[object.name]) { 1744 $.event.special[object.name] = {}; 1745 } 1746 1747 if (!$.event.special[object.name].owl) { 1748 var _default = $.event.special[object.name]._default; 1749 $.event.special[object.name]._default = function(e) { 1750 if (_default && _default.apply && (!e.namespace || e.namespace.indexOf('owl') === -1)) { 1751 return _default.apply(this, arguments); 1752 } 1753 return e.namespace && e.namespace.indexOf('owl') > -1; 1754 }; 1755 $.event.special[object.name].owl = true; 1756 } 1757 } else if (object.type === Owl.Type.State) { 1758 if (!this._states.tags[object.name]) { 1759 this._states.tags[object.name] = object.tags; 1760 } else { 1761 this._states.tags[object.name] = this._states.tags[object.name].concat(object.tags); 1762 } 1763 1764 this._states.tags[object.name] = $.grep(this._states.tags[object.name], $.proxy(function(tag, i) { 1765 return $.inArray(tag, this._states.tags[object.name]) === i; 1766 }, this)); 1767 } 1768 }; 1769 1770 /** 1771 * Suppresses events. 1772 * @protected 1773 * @param {Array.<String>} events - The events to suppress. 1774 */ 1775 Owl.prototype.suppress = function(events) { 1776 $.each(events, $.proxy(function(index, event) { 1777 this._supress[event] = true; 1778 }, this)); 1779 }; 1780 1781 /** 1782 * Releases suppressed events. 1783 * @protected 1784 * @param {Array.<String>} events - The events to release. 1785 */ 1786 Owl.prototype.release = function(events) { 1787 $.each(events, $.proxy(function(index, event) { 1788 delete this._supress[event]; 1789 }, this)); 1790 }; 1791 1792 /** 1793 * Gets unified pointer coordinates from event. 1794 * @todo #261 1795 * @protected 1796 * @param {Event} - The `mousedown` or `touchstart` event. 1797 * @returns {Object} - Contains `x` and `y` coordinates of current pointer position. 1798 */ 1799 Owl.prototype.pointer = function(event) { 1800 var result = { x: null, y: null }; 1801 1802 event = event.originalEvent || event || window.event; 1803 1804 event = event.touches && event.touches.length ? 1805 event.touches[0] : event.changedTouches && event.changedTouches.length ? 1806 event.changedTouches[0] : event; 1807 1808 if (event.pageX) { 1809 result.x = event.pageX; 1810 result.y = event.pageY; 1811 } else { 1812 result.x = event.clientX; 1813 result.y = event.clientY; 1814 } 1815 1816 return result; 1817 }; 1818 1819 /** 1820 * Determines if the input is a Number or something that can be coerced to a Number 1821 * @protected 1822 * @param {Number|String|Object|Array|Boolean|RegExp|Function|Symbol} - The input to be tested 1823 * @returns {Boolean} - An indication if the input is a Number or can be coerced to a Number 1824 */ 1825 Owl.prototype.isNumeric = function(number) { 1826 return !isNaN(parseFloat(number)); 1827 }; 1828 1829 /** 1830 * Gets the difference of two vectors. 1831 * @todo #261 1832 * @protected 1833 * @param {Object} - The first vector. 1834 * @param {Object} - The second vector. 1835 * @returns {Object} - The difference. 1836 */ 1837 Owl.prototype.difference = function(first, second) { 1838 return { 1839 x: first.x - second.x, 1840 y: first.y - second.y 1841 }; 1842 }; 1843 1844 /** 1845 * The jQuery Plugin for the Owl Carousel 1846 * @todo Navigation plugin `next` and `prev` 1847 * @public 1848 */ 1849 $.fn.owlCarousel = function(option) { 1850 var args = Array.prototype.slice.call(arguments, 1); 1851 1852 return this.each(function() { 1853 var $this = $(this), 1854 data = $this.data('owl.carousel'); 1855 1856 if (!data) { 1857 data = new Owl(this, typeof option == 'object' && option); 1858 $this.data('owl.carousel', data); 1859 1860 $.each([ 1861 'next', 'prev', 'to', 'destroy', 'refresh', 'replace', 'add', 'remove' 1862 ], function(i, event) { 1863 data.register({ type: Owl.Type.Event, name: event }); 1864 data.$element.on(event + '.owl.carousel.core', $.proxy(function(e) { 1865 if (e.namespace && e.relatedTarget !== this) { 1866 this.suppress([ event ]); 1867 data[event].apply(this, [].slice.call(arguments, 1)); 1868 this.release([ event ]); 1869 } 1870 }, data)); 1871 }); 1872 } 1873 1874 if (typeof option == 'string' && option.charAt(0) !== '_') { 1875 data[option].apply(data, args); 1876 } 1877 }); 1878 }; 1879 1880 /** 1881 * The constructor for the jQuery Plugin 1882 * @public 1883 */ 1884 $.fn.owlCarousel.Constructor = Owl; 1885 1886})(window.Zepto || window.jQuery, window, document); 1887 1888/** 1889 * AutoRefresh Plugin 1890 * @version 2.3.4 1891 * @author Artus Kolanowski 1892 * @author David Deutsch 1893 * @license The MIT License (MIT) 1894 */ 1895;(function($, window, document, undefined) { 1896 1897 /** 1898 * Creates the auto refresh plugin. 1899 * @class The Auto Refresh Plugin 1900 * @param {Owl} carousel - The Owl Carousel 1901 */ 1902 var AutoRefresh = function(carousel) { 1903 /** 1904 * Reference to the core. 1905 * @protected 1906 * @type {Owl} 1907 */ 1908 this._core = carousel; 1909 1910 /** 1911 * Refresh interval. 1912 * @protected 1913 * @type {number} 1914 */ 1915 this._interval = null; 1916 1917 /** 1918 * Whether the element is currently visible or not. 1919 * @protected 1920 * @type {Boolean} 1921 */ 1922 this._visible = null; 1923 1924 /** 1925 * All event handlers. 1926 * @protected 1927 * @type {Object} 1928 */ 1929 this._handlers = { 1930 'initialized.owl.carousel': $.proxy(function(e) { 1931 if (e.namespace && this._core.settings.autoRefresh) { 1932 this.watch(); 1933 } 1934 }, this) 1935 }; 1936 1937 // set default options 1938 this._core.options = $.extend({}, AutoRefresh.Defaults, this._core.options); 1939 1940 // register event handlers 1941 this._core.$element.on(this._handlers); 1942 }; 1943 1944 /** 1945 * Default options. 1946 * @public 1947 */ 1948 AutoRefresh.Defaults = { 1949 autoRefresh: true, 1950 autoRefreshInterval: 500 1951 }; 1952 1953 /** 1954 * Watches the element. 1955 */ 1956 AutoRefresh.prototype.watch = function() { 1957 if (this._interval) { 1958 return; 1959 } 1960 1961 this._visible = this._core.isVisible(); 1962 this._interval = window.setInterval($.proxy(this.refresh, this), this._core.settings.autoRefreshInterval); 1963 }; 1964 1965 /** 1966 * Refreshes the element. 1967 */ 1968 AutoRefresh.prototype.refresh = function() { 1969 if (this._core.isVisible() === this._visible) { 1970 return; 1971 } 1972 1973 this._visible = !this._visible; 1974 1975 this._core.$element.toggleClass('owl-hidden', !this._visible); 1976 1977 this._visible && (this._core.invalidate('width') && this._core.refresh()); 1978 }; 1979 1980 /** 1981 * Destroys the plugin. 1982 */ 1983 AutoRefresh.prototype.destroy = function() { 1984 var handler, property; 1985 1986 window.clearInterval(this._interval); 1987 1988 for (handler in this._handlers) { 1989 this._core.$element.off(handler, this._handlers[handler]); 1990 } 1991 for (property in Object.getOwnPropertyNames(this)) { 1992 typeof this[property] != 'function' && (this[property] = null); 1993 } 1994 }; 1995 1996 $.fn.owlCarousel.Constructor.Plugins.AutoRefresh = AutoRefresh; 1997 1998})(window.Zepto || window.jQuery, window, document); 1999 2000/** 2001 * Lazy Plugin 2002 * @version 2.3.4 2003 * @author Bartosz Wojciechowski 2004 * @author David Deutsch 2005 * @license The MIT License (MIT) 2006 */ 2007;(function($, window, document, undefined) { 2008 2009 /** 2010 * Creates the lazy plugin. 2011 * @class The Lazy Plugin 2012 * @param {Owl} carousel - The Owl Carousel 2013 */ 2014 var Lazy = function(carousel) { 2015 2016 /** 2017 * Reference to the core. 2018 * @protected 2019 * @type {Owl} 2020 */ 2021 this._core = carousel; 2022 2023 /** 2024 * Already loaded items. 2025 * @protected 2026 * @type {Array.<jQuery>} 2027 */ 2028 this._loaded = []; 2029 2030 /** 2031 * Event handlers. 2032 * @protected 2033 * @type {Object} 2034 */ 2035 this._handlers = { 2036 'initialized.owl.carousel change.owl.carousel resized.owl.carousel': $.proxy(function(e) { 2037 if (!e.namespace) { 2038 return; 2039 } 2040 2041 if (!this._core.settings || !this._core.settings.lazyLoad) { 2042 return; 2043 } 2044 2045 if ((e.property && e.property.name == 'position') || e.type == 'initialized') { 2046 var settings = this._core.settings, 2047 n = (settings.center && Math.ceil(settings.items / 2) || settings.items), 2048 i = ((settings.center && n * -1) || 0), 2049 position = (e.property && e.property.value !== undefined ? e.property.value : this._core.current()) + i, 2050 clones = this._core.clones().length, 2051 load = $.proxy(function(i, v) { this.load(v) }, this); 2052 //TODO: Need documentation for this new option 2053 if (settings.lazyLoadEager > 0) { 2054 n += settings.lazyLoadEager; 2055 // If the carousel is looping also preload images that are to the "left" 2056 if (settings.loop) { 2057 position -= settings.lazyLoadEager; 2058 n++; 2059 } 2060 } 2061 2062 while (i++ < n) { 2063 this.load(clones / 2 + this._core.relative(position)); 2064 clones && $.each(this._core.clones(this._core.relative(position)), load); 2065 position++; 2066 } 2067 } 2068 }, this) 2069 }; 2070 2071 // set the default options 2072 this._core.options = $.extend({}, Lazy.Defaults, this._core.options); 2073 2074 // register event handler 2075 this._core.$element.on(this._handlers); 2076 }; 2077 2078 /** 2079 * Default options. 2080 * @public 2081 */ 2082 Lazy.Defaults = { 2083 lazyLoad: false, 2084 lazyLoadEager: 0 2085 }; 2086 2087 /** 2088 * Loads all resources of an item at the specified position. 2089 * @param {Number} position - The absolute position of the item. 2090 * @protected 2091 */ 2092 Lazy.prototype.load = function(position) { 2093 var $item = this._core.$stage.children().eq(position), 2094 $elements = $item && $item.find('.owl-lazy'); 2095 2096 if (!$elements || $.inArray($item.get(0), this._loaded) > -1) { 2097 return; 2098 } 2099 2100 $elements.each($.proxy(function(index, element) { 2101 var $element = $(element), image, 2102 url = (window.devicePixelRatio > 1 && $element.attr('data-src-retina')) || $element.attr('data-src') || $element.attr('data-srcset'); 2103 2104 this._core.trigger('load', { element: $element, url: url }, 'lazy'); 2105 2106 if ($element.is('img')) { 2107 $element.one('load.owl.lazy', $.proxy(function() { 2108 $element.css('opacity', 1); 2109 this._core.trigger('loaded', { element: $element, url: url }, 'lazy'); 2110 }, this)).attr('src', url); 2111 } else if ($element.is('source')) { 2112 $element.one('load.owl.lazy', $.proxy(function() { 2113 this._core.trigger('loaded', { element: $element, url: url }, 'lazy'); 2114 }, this)).attr('srcset', url); 2115 } else { 2116 image = new Image(); 2117 image.onload = $.proxy(function() { 2118 $element.css({ 2119 'background-image': 'url("' + url + '")', 2120 'opacity': '1' 2121 }); 2122 this._core.trigger('loaded', { element: $element, url: url }, 'lazy'); 2123 }, this); 2124 image.src = url; 2125 } 2126 }, this)); 2127 2128 this._loaded.push($item.get(0)); 2129 }; 2130 2131 /** 2132 * Destroys the plugin. 2133 * @public 2134 */ 2135 Lazy.prototype.destroy = function() { 2136 var handler, property; 2137 2138 for (handler in this.handlers) { 2139 this._core.$element.off(handler, this.handlers[handler]); 2140 } 2141 for (property in Object.getOwnPropertyNames(this)) { 2142 typeof this[property] != 'function' && (this[property] = null); 2143 } 2144 }; 2145 2146 $.fn.owlCarousel.Constructor.Plugins.Lazy = Lazy; 2147 2148})(window.Zepto || window.jQuery, window, document); 2149 2150/** 2151 * AutoHeight Plugin 2152 * @version 2.3.4 2153 * @author Bartosz Wojciechowski 2154 * @author David Deutsch 2155 * @license The MIT License (MIT) 2156 */ 2157;(function($, window, document, undefined) { 2158 2159 /** 2160 * Creates the auto height plugin. 2161 * @class The Auto Height Plugin 2162 * @param {Owl} carousel - The Owl Carousel 2163 */ 2164 var AutoHeight = function(carousel) { 2165 /** 2166 * Reference to the core. 2167 * @protected 2168 * @type {Owl} 2169 */ 2170 this._core = carousel; 2171 2172 this._previousHeight = null; 2173 2174 /** 2175 * All event handlers. 2176 * @protected 2177 * @type {Object} 2178 */ 2179 this._handlers = { 2180 'initialized.owl.carousel refreshed.owl.carousel': $.proxy(function(e) { 2181 if (e.namespace && this._core.settings.autoHeight) { 2182 this.update(); 2183 } 2184 }, this), 2185 'changed.owl.carousel': $.proxy(function(e) { 2186 if (e.namespace && this._core.settings.autoHeight && e.property.name === 'position'){ 2187 this.update(); 2188 } 2189 }, this), 2190 'loaded.owl.lazy': $.proxy(function(e) { 2191 if (e.namespace && this._core.settings.autoHeight 2192 && e.element.closest('.' + this._core.settings.itemClass).index() === this._core.current()) { 2193 this.update(); 2194 } 2195 }, this) 2196 }; 2197 2198 // set default options 2199 this._core.options = $.extend({}, AutoHeight.Defaults, this._core.options); 2200 2201 // register event handlers 2202 this._core.$element.on(this._handlers); 2203 this._intervalId = null; 2204 var refThis = this; 2205 2206 // These changes have been taken from a PR by gavrochelegnou proposed in #1575 2207 // and have been made compatible with the latest jQuery version 2208 $(window).on('load', function() { 2209 if (refThis._core.settings.autoHeight) { 2210 refThis.update(); 2211 } 2212 }); 2213 2214 // Autoresize the height of the carousel when window is resized 2215 // When carousel has images, the height is dependent on the width 2216 // and should also change on resize 2217 $(window).resize(function() { 2218 if (refThis._core.settings.autoHeight) { 2219 if (refThis._intervalId != null) { 2220 clearTimeout(refThis._intervalId); 2221 } 2222 2223 refThis._intervalId = setTimeout(function() { 2224 refThis.update(); 2225 }, 250); 2226 } 2227 }); 2228 2229 }; 2230 2231 /** 2232 * Default options. 2233 * @public 2234 */ 2235 AutoHeight.Defaults = { 2236 autoHeight: false, 2237 autoHeightClass: 'owl-height' 2238 }; 2239 2240 /** 2241 * Updates the view. 2242 */ 2243 AutoHeight.prototype.update = function() { 2244 var start = this._core._current, 2245 end = start + this._core.settings.items, 2246 lazyLoadEnabled = this._core.settings.lazyLoad, 2247 visible = this._core.$stage.children().toArray().slice(start, end), 2248 heights = [], 2249 maxheight = 0; 2250 2251 $.each(visible, function(index, item) { 2252 heights.push($(item).height()); 2253 }); 2254 2255 maxheight = Math.max.apply(null, heights); 2256 2257 if (maxheight <= 1 && lazyLoadEnabled && this._previousHeight) { 2258 maxheight = this._previousHeight; 2259 } 2260 2261 this._previousHeight = maxheight; 2262 2263 this._core.$stage.parent() 2264 .height(maxheight) 2265 .addClass(this._core.settings.autoHeightClass); 2266 }; 2267 2268 AutoHeight.prototype.destroy = function() { 2269 var handler, property; 2270 2271 for (handler in this._handlers) { 2272 this._core.$element.off(handler, this._handlers[handler]); 2273 } 2274 for (property in Object.getOwnPropertyNames(this)) { 2275 typeof this[property] !== 'function' && (this[property] = null); 2276 } 2277 }; 2278 2279 $.fn.owlCarousel.Constructor.Plugins.AutoHeight = AutoHeight; 2280 2281})(window.Zepto || window.jQuery, window, document); 2282 2283/** 2284 * Video Plugin 2285 * @version 2.3.4 2286 * @author Bartosz Wojciechowski 2287 * @author David Deutsch 2288 * @license The MIT License (MIT) 2289 */ 2290;(function($, window, document, undefined) { 2291 2292 /** 2293 * Creates the video plugin. 2294 * @class The Video Plugin 2295 * @param {Owl} carousel - The Owl Carousel
vendor: 5,347 bytes, lines 2296-2493
2296 */ 2297 var Video = function(carousel) { 2298 /** 2299 * Reference to the core. 2300 * @protected 2301 * @type {Owl} 2302 */ 2303 this._core = carousel; 2304 2305 /** 2306 * Cache all video URLs. 2307 * @protected 2308 * @type {Object} 2309 */ 2310 this._videos = {}; 2311 2312 /** 2313 * Current playing item. 2314 * @protected 2315 * @type {jQuery} 2316 */ 2317 this._playing = null; 2318 2319 /** 2320 * All event handlers. 2321 * @todo The cloned content removale is too late 2322 * @protected 2323 * @type {Object} 2324 */ 2325 this._handlers = { 2326 'initialized.owl.carousel': $.proxy(function(e) { 2327 if (e.namespace) { 2328 this._core.register({ type: 'state', name: 'playing', tags: [ 'interacting' ] }); 2329 } 2330 }, this), 2331 'resize.owl.carousel': $.proxy(function(e) { 2332 if (e.namespace && this._core.settings.video && this.isInFullScreen()) { 2333 e.preventDefault(); 2334 } 2335 }, this), 2336 'refreshed.owl.carousel': $.proxy(function(e) { 2337 if (e.namespace && this._core.is('resizing')) { 2338 this._core.$stage.find('.cloned .owl-video-frame').remove(); 2339 } 2340 }, this), 2341 'changed.owl.carousel': $.proxy(function(e) { 2342 if (e.namespace && e.property.name === 'position' && this._playing) { 2343 this.stop(); 2344 } 2345 }, this), 2346 'prepared.owl.carousel': $.proxy(function(e) { 2347 if (!e.namespace) { 2348 return; 2349 } 2350 2351 var $element = $(e.content).find('.owl-video'); 2352 2353 if ($element.length) { 2354 $element.css('display', 'none'); 2355 this.fetch($element, $(e.content)); 2356 } 2357 }, this) 2358 }; 2359 2360 // set default options 2361 this._core.options = $.extend({}, Video.Defaults, this._core.options); 2362 2363 // register event handlers 2364 this._core.$element.on(this._handlers); 2365 2366 this._core.$element.on('click.owl.video', '.owl-video-play-icon', $.proxy(function(e) { 2367 this.play(e); 2368 }, this)); 2369 }; 2370 2371 /** 2372 * Default options. 2373 * @public 2374 */ 2375 Video.Defaults = { 2376 video: false, 2377 videoHeight: false, 2378 videoWidth: false 2379 }; 2380 2381 /** 2382 * Gets the video ID and the type (YouTube/Vimeo/vzaar only). 2383 * @protected 2384 * @param {jQuery} target - The target containing the video data. 2385 * @param {jQuery} item - The item containing the video. 2386 */ 2387 Video.prototype.fetch = function(target, item) { 2388 var type = (function() { 2389 if (target.attr('data-vimeo-id')) { 2390 return 'vimeo'; 2391 } else if (target.attr('data-vzaar-id')) { 2392 return 'vzaar' 2393 } else { 2394 return 'youtube'; 2395 } 2396 })(), 2397 id = target.attr('data-vimeo-id') || target.attr('data-youtube-id') || target.attr('data-vzaar-id'), 2398 width = target.attr('data-width') || this._core.settings.videoWidth, 2399 height = target.attr('data-height') || this._core.settings.videoHeight, 2400 url = target.attr('href'); 2401 2402 if (url) { 2403 2404 /* 2405 Parses the id's out of the following urls (and probably more): 2406 https://www.youtube.com/watch?v=:id 2407 https://youtu.be/:id 2408 https://vimeo.com/:id 2409 https://vimeo.com/channels/:channel/:id 2410 https://vimeo.com/groups/:group/videos/:id 2411 https://app.vzaar.com/videos/:id 2412 2413 Visual example: https://regexper.com/#(http%3A%7Chttps%3A%7C)%5C%2F%5C%2F(player.%7Cwww.%7Capp.)%3F(vimeo%5C.com%7Cyoutu(be%5C.com%7C%5C.be%7Cbe%5C.googleapis%5C.com)%7Cvzaar%5C.com)%5C%2F(video%5C%2F%7Cvideos%5C%2F%7Cembed%5C%2F%7Cchannels%5C%2F.%2B%5C%2F%7Cgroups%5C%2F.%2B%5C%2F%7Cwatch%5C%3Fv%3D%7Cv%5C%2F)%3F(%5BA-Za-z0-9._%25-%5D*)(%5C%26%5CS%2B)%3F 2414 */ 2415 2416 id = url.match(/(http:|https:|)\/\/(player.|www.|app.)?(vimeo\.com|youtu(be\.com|\.be|be\.googleapis\.com|be\-nocookie\.com)|vzaar\.com)\/(video\/|videos\/|embed\/|channels\/.+\/|groups\/.+\/|watch\?v=|v\/)?([A-Za-z0-9._%-]*)(\&\S+)?/); 2417 2418 if (id[3].indexOf('youtu') > -1) { 2419 type = 'youtube'; 2420 } else if (id[3].indexOf('vimeo') > -1) { 2421 type = 'vimeo'; 2422 } else if (id[3].indexOf('vzaar') > -1) { 2423 type = 'vzaar'; 2424 } else { 2425 throw new Error('Video URL not supported.'); 2426 } 2427 id = id[6]; 2428 } else { 2429 throw new Error('Missing video URL.'); 2430 } 2431 2432 this._videos[url] = { 2433 type: type, 2434 id: id, 2435 width: width, 2436 height: height 2437 }; 2438 2439 item.attr('data-video', url); 2440 2441 this.thumbnail(target, this._videos[url]); 2442 }; 2443 2444 /** 2445 * Creates video thumbnail. 2446 * @protected 2447 * @param {jQuery} target - The target containing the video data. 2448 * @param {Object} info - The video info object. 2449 * @see `fetch` 2450 */ 2451 Video.prototype.thumbnail = function(target, video) { 2452 var tnLink, 2453 icon, 2454 path, 2455 dimensions = video.width && video.height ? 'width:' + video.width + 'px;height:' + video.height + 'px;' : '', 2456 customTn = target.find('img'), 2457 srcType = 'src', 2458 lazyClass = '', 2459 settings = this._core.settings, 2460 create = function(path) { 2461 icon = '<div class="owl-video-play-icon"></div>'; 2462 2463 if (settings.lazyLoad) { 2464 tnLink = $('<div/>',{ 2465 "class": 'owl-video-tn ' + lazyClass, 2466 "srcType": path 2467 }); 2468 } else { 2469 tnLink = $( '<div/>', { 2470 "class": "owl-video-tn", 2471 "style": 'opacity:1;background-image:url(' + path + ')' 2472 }); 2473 } 2474 target.after(tnLink); 2475 target.after(icon); 2476 }; 2477 2478 // wrap video content into owl-video-wrapper div 2479 target.wrap( $( '<div/>', { 2480 "class": "owl-video-wrapper", 2481 "style": dimensions 2482 })); 2483 2484 if (this._core.settings.lazyLoad) { 2485 srcType = 'data-src'; 2486 lazyClass = 'owl-lazy'; 2487 } 2488 2489 // custom thumbnail 2490 if (customTn.length) { 2491 create(customTn.attr(srcType)); 2492 customTn.remove(); 2493 return false;
vendor: 15,908 bytes, lines 2494-3131
2494 } 2495 2496 if (video.type === 'youtube') { 2497 path = "//img.youtube.com/vi/" + video.id + "/hqdefault.jpg"; 2498 create(path); 2499 } else if (video.type === 'vimeo') { 2500 $.ajax({ 2501 type: 'GET', 2502 url: '//vimeo.com/api/v2/video/' + video.id + '.json', 2503 jsonp: 'callback', 2504 dataType: 'jsonp', 2505 success: function(data) { 2506 path = data[0].thumbnail_large; 2507 create(path); 2508 } 2509 }); 2510 } else if (video.type === 'vzaar') { 2511 $.ajax({ 2512 type: 'GET', 2513 url: '//vzaar.com/api/videos/' + video.id + '.json', 2514 jsonp: 'callback', 2515 dataType: 'jsonp', 2516 success: function(data) { 2517 path = data.framegrab_url; 2518 create(path); 2519 } 2520 }); 2521 } 2522 }; 2523 2524 /** 2525 * Stops the current video. 2526 * @public 2527 */ 2528 Video.prototype.stop = function() { 2529 this._core.trigger('stop', null, 'video'); 2530 this._playing.find('.owl-video-frame').remove(); 2531 this._playing.removeClass('owl-video-playing'); 2532 this._playing = null; 2533 this._core.leave('playing'); 2534 this._core.trigger('stopped', null, 'video'); 2535 }; 2536 2537 /** 2538 * Starts the current video. 2539 * @public 2540 * @param {Event} event - The event arguments. 2541 */ 2542 Video.prototype.play = function(event) { 2543 var target = $(event.target), 2544 item = target.closest('.' + this._core.settings.itemClass), 2545 video = this._videos[item.attr('data-video')], 2546 width = video.width || '100%', 2547 height = video.height || this._core.$stage.height(), 2548 html, 2549 iframe; 2550 2551 if (this._playing) { 2552 return; 2553 } 2554 2555 this._core.enter('playing'); 2556 this._core.trigger('play', null, 'video'); 2557 2558 item = this._core.items(this._core.relative(item.index())); 2559 2560 this._core.reset(item.index()); 2561 2562 html = $( '<iframe frameborder="0" allowfullscreen mozallowfullscreen webkitAllowFullScreen ></iframe>' ); 2563 html.attr( 'height', height ); 2564 html.attr( 'width', width ); 2565 if (video.type === 'youtube') { 2566 html.attr( 'src', '//www.youtube.com/embed/' + video.id + '?autoplay=1&rel=0&v=' + video.id ); 2567 } else if (video.type === 'vimeo') { 2568 html.attr( 'src', '//player.vimeo.com/video/' + video.id + '?autoplay=1' ); 2569 } else if (video.type === 'vzaar') { 2570 html.attr( 'src', '//view.vzaar.com/' + video.id + '/player?autoplay=true' ); 2571 } 2572 2573 iframe = $(html).wrap( '<div class="owl-video-frame" />' ).insertAfter(item.find('.owl-video')); 2574 2575 this._playing = item.addClass('owl-video-playing'); 2576 }; 2577 2578 /** 2579 * Checks whether an video is currently in full screen mode or not. 2580 * @todo Bad style because looks like a readonly method but changes members. 2581 * @protected 2582 * @returns {Boolean} 2583 */ 2584 Video.prototype.isInFullScreen = function() { 2585 var element = document.fullscreenElement || document.mozFullScreenElement || 2586 document.webkitFullscreenElement; 2587 2588 return element && $(element).parent().hasClass('owl-video-frame'); 2589 }; 2590 2591 /** 2592 * Destroys the plugin. 2593 */ 2594 Video.prototype.destroy = function() { 2595 var handler, property; 2596 2597 this._core.$element.off('click.owl.video'); 2598 2599 for (handler in this._handlers) { 2600 this._core.$element.off(handler, this._handlers[handler]); 2601 } 2602 for (property in Object.getOwnPropertyNames(this)) { 2603 typeof this[property] != 'function' && (this[property] = null); 2604 } 2605 }; 2606 2607 $.fn.owlCarousel.Constructor.Plugins.Video = Video; 2608 2609})(window.Zepto || window.jQuery, window, document); 2610 2611/** 2612 * Animate Plugin 2613 * @version 2.3.4 2614 * @author Bartosz Wojciechowski 2615 * @author David Deutsch 2616 * @license The MIT License (MIT) 2617 */ 2618;(function($, window, document, undefined) { 2619 2620 /** 2621 * Creates the animate plugin. 2622 * @class The Navigation Plugin 2623 * @param {Owl} scope - The Owl Carousel 2624 */ 2625 var Animate = function(scope) { 2626 this.core = scope; 2627 this.core.options = $.extend({}, Animate.Defaults, this.core.options); 2628 this.swapping = true; 2629 this.previous = undefined; 2630 this.next = undefined; 2631 2632 this.handlers = { 2633 'change.owl.carousel': $.proxy(function(e) { 2634 if (e.namespace && e.property.name == 'position') { 2635 this.previous = this.core.current(); 2636 this.next = e.property.value; 2637 } 2638 }, this), 2639 'drag.owl.carousel dragged.owl.carousel translated.owl.carousel': $.proxy(function(e) { 2640 if (e.namespace) { 2641 this.swapping = e.type == 'translated'; 2642 } 2643 }, this), 2644 'translate.owl.carousel': $.proxy(function(e) { 2645 if (e.namespace && this.swapping && (this.core.options.animateOut || this.core.options.animateIn)) { 2646 this.swap(); 2647 } 2648 }, this) 2649 }; 2650 2651 this.core.$element.on(this.handlers); 2652 }; 2653 2654 /** 2655 * Default options. 2656 * @public 2657 */ 2658 Animate.Defaults = { 2659 animateOut: false, 2660 animateIn: false 2661 }; 2662 2663 /** 2664 * Toggles the animation classes whenever an translations starts. 2665 * @protected 2666 * @returns {Boolean|undefined} 2667 */ 2668 Animate.prototype.swap = function() { 2669 2670 if (this.core.settings.items !== 1) { 2671 return; 2672 } 2673 2674 if (!$.support.animation || !$.support.transition) { 2675 return; 2676 } 2677 2678 this.core.speed(0); 2679 2680 var left, 2681 clear = $.proxy(this.clear, this), 2682 previous = this.core.$stage.children().eq(this.previous), 2683 next = this.core.$stage.children().eq(this.next), 2684 incoming = this.core.settings.animateIn, 2685 outgoing = this.core.settings.animateOut; 2686 2687 if (this.core.current() === this.previous) { 2688 return; 2689 } 2690 2691 if (outgoing) { 2692 left = this.core.coordinates(this.previous) - this.core.coordinates(this.next); 2693 previous.one($.support.animation.end, clear) 2694 .css( { 'left': left + 'px' } ) 2695 .addClass('animated owl-animated-out') 2696 .addClass(outgoing); 2697 } 2698 2699 if (incoming) { 2700 next.one($.support.animation.end, clear) 2701 .addClass('animated owl-animated-in') 2702 .addClass(incoming); 2703 } 2704 }; 2705 2706 Animate.prototype.clear = function(e) { 2707 $(e.target).css( { 'left': '' } ) 2708 .removeClass('animated owl-animated-out owl-animated-in') 2709 .removeClass(this.core.settings.animateIn) 2710 .removeClass(this.core.settings.animateOut); 2711 this.core.onTransitionEnd(); 2712 }; 2713 2714 /** 2715 * Destroys the plugin. 2716 * @public 2717 */ 2718 Animate.prototype.destroy = function() { 2719 var handler, property; 2720 2721 for (handler in this.handlers) { 2722 this.core.$element.off(handler, this.handlers[handler]); 2723 } 2724 for (property in Object.getOwnPropertyNames(this)) { 2725 typeof this[property] != 'function' && (this[property] = null); 2726 } 2727 }; 2728 2729 $.fn.owlCarousel.Constructor.Plugins.Animate = Animate; 2730 2731})(window.Zepto || window.jQuery, window, document); 2732 2733/** 2734 * Autoplay Plugin 2735 * @version 2.3.4 2736 * @author Bartosz Wojciechowski 2737 * @author Artus Kolanowski 2738 * @author David Deutsch 2739 * @author Tom De Caluwé 2740 * @license The MIT License (MIT) 2741 */ 2742;(function($, window, document, undefined) { 2743 2744 /** 2745 * Creates the autoplay plugin. 2746 * @class The Autoplay Plugin 2747 * @param {Owl} scope - The Owl Carousel 2748 */ 2749 var Autoplay = function(carousel) { 2750 /** 2751 * Reference to the core. 2752 * @protected 2753 * @type {Owl} 2754 */ 2755 this._core = carousel; 2756 2757 /** 2758 * The autoplay timeout id. 2759 * @type {Number} 2760 */ 2761 this._call = null; 2762 2763 /** 2764 * Depending on the state of the plugin, this variable contains either 2765 * the start time of the timer or the current timer value if it's 2766 * paused. Since we start in a paused state we initialize the timer 2767 * value. 2768 * @type {Number} 2769 */ 2770 this._time = 0; 2771 2772 /** 2773 * Stores the timeout currently used. 2774 * @type {Number} 2775 */ 2776 this._timeout = 0; 2777 2778 /** 2779 * Indicates whenever the autoplay is paused. 2780 * @type {Boolean} 2781 */ 2782 this._paused = true; 2783 2784 /** 2785 * All event handlers. 2786 * @protected 2787 * @type {Object} 2788 */ 2789 this._handlers = { 2790 'changed.owl.carousel': $.proxy(function(e) { 2791 if (e.namespace && e.property.name === 'settings') { 2792 if (this._core.settings.autoplay) { 2793 this.play(); 2794 } else { 2795 this.stop(); 2796 } 2797 } else if (e.namespace && e.property.name === 'position' && this._paused) { 2798 // Reset the timer. This code is triggered when the position 2799 // of the carousel was changed through user interaction. 2800 this._time = 0; 2801 } 2802 }, this), 2803 'initialized.owl.carousel': $.proxy(function(e) { 2804 if (e.namespace && this._core.settings.autoplay) { 2805 this.play(); 2806 } 2807 }, this), 2808 'play.owl.autoplay': $.proxy(function(e, t, s) { 2809 if (e.namespace) { 2810 this.play(t, s); 2811 } 2812 }, this), 2813 'stop.owl.autoplay': $.proxy(function(e) { 2814 if (e.namespace) { 2815 this.stop(); 2816 } 2817 }, this), 2818 'mouseover.owl.autoplay': $.proxy(function() { 2819 if (this._core.settings.autoplayHoverPause && this._core.is('rotating')) { 2820 this.pause(); 2821 } 2822 }, this), 2823 'mouseleave.owl.autoplay': $.proxy(function() { 2824 if (this._core.settings.autoplayHoverPause && this._core.is('rotating')) { 2825 this.play(); 2826 } 2827 }, this), 2828 'touchstart.owl.core': $.proxy(function() { 2829 if (this._core.settings.autoplayHoverPause && this._core.is('rotating')) { 2830 this.pause(); 2831 } 2832 }, this), 2833 'touchend.owl.core': $.proxy(function() { 2834 if (this._core.settings.autoplayHoverPause) { 2835 this.play(); 2836 } 2837 }, this) 2838 }; 2839 2840 // register event handlers 2841 this._core.$element.on(this._handlers); 2842 2843 // set default options 2844 this._core.options = $.extend({}, Autoplay.Defaults, this._core.options); 2845 }; 2846 2847 /** 2848 * Default options. 2849 * @public 2850 */ 2851 Autoplay.Defaults = { 2852 autoplay: false, 2853 autoplayTimeout: 5000, 2854 autoplayHoverPause: false, 2855 autoplaySpeed: false 2856 }; 2857 2858 /** 2859 * Transition to the next slide and set a timeout for the next transition. 2860 * @private 2861 * @param {Number} [speed] - The animation speed for the animations. 2862 */ 2863 Autoplay.prototype._next = function(speed) { 2864 this._call = window.setTimeout( 2865 $.proxy(this._next, this, speed), 2866 this._timeout * (Math.round(this.read() / this._timeout) + 1) - this.read() 2867 ); 2868 2869 if (this._core.is('interacting') || document.hidden) { 2870 return; 2871 } 2872 this._core.next(speed || this._core.settings.autoplaySpeed); 2873 } 2874 2875 /** 2876 * Reads the current timer value when the timer is playing. 2877 * @public 2878 */ 2879 Autoplay.prototype.read = function() { 2880 return new Date().getTime() - this._time; 2881 }; 2882 2883 /** 2884 * Starts the autoplay. 2885 * @public 2886 * @param {Number} [timeout] - The interval before the next animation starts. 2887 * @param {Number} [speed] - The animation speed for the animations. 2888 */ 2889 Autoplay.prototype.play = function(timeout, speed) { 2890 var elapsed; 2891 2892 if (!this._core.is('rotating')) { 2893 this._core.enter('rotating'); 2894 } 2895 2896 timeout = timeout || this._core.settings.autoplayTimeout; 2897 2898 // Calculate the elapsed time since the last transition. If the carousel 2899 // wasn't playing this calculation will yield zero. 2900 elapsed = Math.min(this._time % (this._timeout || timeout), timeout); 2901 2902 if (this._paused) { 2903 // Start the clock. 2904 this._time = this.read(); 2905 this._paused = false; 2906 } else { 2907 // Clear the active timeout to allow replacement. 2908 window.clearTimeout(this._call); 2909 } 2910 2911 // Adjust the origin of the timer to match the new timeout value. 2912 this._time += this.read() % timeout - elapsed; 2913 2914 this._timeout = timeout; 2915 this._call = window.setTimeout($.proxy(this._next, this, speed), timeout - elapsed); 2916 }; 2917 2918 /** 2919 * Stops the autoplay. 2920 * @public 2921 */ 2922 Autoplay.prototype.stop = function() { 2923 if (this._core.is('rotating')) { 2924 // Reset the clock. 2925 this._time = 0; 2926 this._paused = true; 2927 2928 window.clearTimeout(this._call); 2929 this._core.leave('rotating'); 2930 } 2931 }; 2932 2933 /** 2934 * Pauses the autoplay. 2935 * @public 2936 */ 2937 Autoplay.prototype.pause = function() { 2938 if (this._core.is('rotating') && !this._paused) { 2939 // Pause the clock. 2940 this._time = this.read(); 2941 this._paused = true; 2942 2943 window.clearTimeout(this._call); 2944 } 2945 }; 2946 2947 /** 2948 * Destroys the plugin. 2949 */ 2950 Autoplay.prototype.destroy = function() { 2951 var handler, property; 2952 2953 this.stop(); 2954 2955 for (handler in this._handlers) { 2956 this._core.$element.off(handler, this._handlers[handler]); 2957 } 2958 for (property in Object.getOwnPropertyNames(this)) { 2959 typeof this[property] != 'function' && (this[property] = null); 2960 } 2961 }; 2962 2963 $.fn.owlCarousel.Constructor.Plugins.autoplay = Autoplay; 2964 2965})(window.Zepto || window.jQuery, window, document); 2966 2967/** 2968 * Navigation Plugin 2969 * @version 2.3.4 2970 * @author Artus Kolanowski 2971 * @author David Deutsch 2972 * @license The MIT License (MIT) 2973 */ 2974;(function($, window, document, undefined) { 2975 'use strict'; 2976 2977 /** 2978 * Creates the navigation plugin. 2979 * @class The Navigation Plugin 2980 * @param {Owl} carousel - The Owl Carousel. 2981 */ 2982 var Navigation = function(carousel) { 2983 /** 2984 * Reference to the core. 2985 * @protected 2986 * @type {Owl} 2987 */ 2988 this._core = carousel; 2989 2990 /** 2991 * Indicates whether the plugin is initialized or not. 2992 * @protected 2993 * @type {Boolean} 2994 */ 2995 this._initialized = false; 2996 2997 /** 2998 * The current paging indexes. 2999 * @protected 3000 * @type {Array} 3001 */ 3002 this._pages = []; 3003 3004 /** 3005 * All DOM elements of the user interface. 3006 * @protected 3007 * @type {Object} 3008 */ 3009 this._controls = {}; 3010 3011 /** 3012 * Markup for an indicator. 3013 * @protected 3014 * @type {Array.<String>} 3015 */ 3016 this._templates = []; 3017 3018 /** 3019 * The carousel element. 3020 * @type {jQuery} 3021 */ 3022 this.$element = this._core.$element; 3023 3024 /** 3025 * Overridden methods of the carousel. 3026 * @protected 3027 * @type {Object} 3028 */ 3029 this._overrides = { 3030 next: this._core.next, 3031 prev: this._core.prev, 3032 to: this._core.to 3033 }; 3034 3035 /** 3036 * All event handlers. 3037 * @protected 3038 * @type {Object} 3039 */ 3040 this._handlers = { 3041 'prepared.owl.carousel': $.proxy(function(e) { 3042 if (e.namespace && this._core.settings.dotsData) { 3043 this._templates.push('<div class="' + this._core.settings.dotClass + '">' + 3044 $(e.content).find('[data-dot]').addBack('[data-dot]').attr('data-dot') + '</div>'); 3045 } 3046 }, this), 3047 'added.owl.carousel': $.proxy(function(e) { 3048 if (e.namespace && this._core.settings.dotsData) { 3049 this._templates.splice(e.position, 0, this._templates.pop()); 3050 } 3051 }, this), 3052 'remove.owl.carousel': $.proxy(function(e) { 3053 if (e.namespace && this._core.settings.dotsData) { 3054 this._templates.splice(e.position, 1); 3055 } 3056 }, this), 3057 'changed.owl.carousel': $.proxy(function(e) { 3058 if (e.namespace && e.property.name == 'position') { 3059 this.draw(); 3060 } 3061 }, this), 3062 'initialized.owl.carousel': $.proxy(function(e) { 3063 if (e.namespace && !this._initialized) { 3064 this._core.trigger('initialize', null, 'navigation'); 3065 this.initialize(); 3066 this.update(); 3067 this.draw(); 3068 this._initialized = true; 3069 this._core.trigger('initialized', null, 'navigation'); 3070 } 3071 }, this), 3072 'refreshed.owl.carousel': $.proxy(function(e) { 3073 if (e.namespace && this._initialized) { 3074 this._core.trigger('refresh', null, 'navigation'); 3075 this.update(); 3076 this.draw(); 3077 this._core.trigger('refreshed', null, 'navigation'); 3078 } 3079 }, this) 3080 }; 3081 3082 // set default options 3083 this._core.options = $.extend({}, Navigation.Defaults, this._core.options); 3084 3085 // register event handlers 3086 this.$element.on(this._handlers); 3087 }; 3088 3089 /** 3090 * Default options. 3091 * @public 3092 * @todo Rename `slideBy` to `navBy` 3093 */ 3094 Navigation.Defaults = { 3095 nav: false, 3096 navText: [ 3097 '<span aria-label="' + 'Previous' + '">‹</span>', 3098 '<span aria-label="' + 'Next' + '">›</span>' 3099 ], 3100 navSpeed: false, 3101 navElement: 'button type="button" role="presentation"', 3102 navContainer: false, 3103 navContainerClass: 'owl-nav', 3104 navClass: [ 3105 'owl-prev', 3106 'owl-next' 3107 ], 3108 slideBy: 1, 3109 dotClass: 'owl-dot', 3110 dotsClass: 'owl-dots', 3111 dots: true, 3112 dotsEach: false, 3113 dotsData: false, 3114 dotsSpeed: false, 3115 dotsContainer: false 3116 }; 3117 3118 /** 3119 * Initializes the layout of the plugin and extends the carousel. 3120 * @protected 3121 */ 3122 Navigation.prototype.initialize = function() { 3123 var override, 3124 settings = this._core.settings; 3125 3126 // create DOM structure for relative navigation 3127 this._controls.$relative = (settings.navContainer ? $(settings.navContainer) 3128 : $('<div>').addClass(settings.navContainerClass).appendTo(this.$element)).addClass('disabled'); 3129 3130 this._controls.$previous = $('<' + settings.navElement + '>') 3131 .addClass(settings.navClass[0])
vendor: 4,756 bytes, lines 3132-3293
3132 .html(settings.navText[0]) 3133 .prependTo(this._controls.$relative) 3134 .on('click', $.proxy(function(e) { 3135 this.prev(settings.navSpeed); 3136 }, this)); 3137 this._controls.$next = $('<' + settings.navElement + '>') 3138 .addClass(settings.navClass[1]) 3139 .html(settings.navText[1]) 3140 .appendTo(this._controls.$relative) 3141 .on('click', $.proxy(function(e) { 3142 this.next(settings.navSpeed); 3143 }, this)); 3144 3145 // create DOM structure for absolute navigation 3146 if (!settings.dotsData) { 3147 this._templates = [ $('<button role="button">') 3148 .addClass(settings.dotClass) 3149 .append($('<span>')) 3150 .prop('outerHTML') ]; 3151 } 3152 3153 this._controls.$absolute = (settings.dotsContainer ? $(settings.dotsContainer) 3154 : $('<div>').addClass(settings.dotsClass).appendTo(this.$element)).addClass('disabled'); 3155 3156 this._controls.$absolute.on('click', 'button', $.proxy(function(e) { 3157 var index = $(e.target).parent().is(this._controls.$absolute) 3158 ? $(e.target).index() : $(e.target).parent().index(); 3159 3160 e.preventDefault(); 3161 3162 this.to(index, settings.dotsSpeed); 3163 }, this)); 3164 3165 /*$el.on('focusin', function() { 3166 $(document).off(".carousel"); 3167 3168 $(document).on('keydown.carousel', function(e) { 3169 if(e.keyCode == 37) { 3170 $el.trigger('prev.owl') 3171 } 3172 if(e.keyCode == 39) { 3173 $el.trigger('next.owl') 3174 } 3175 }); 3176 });*/ 3177 3178 // override public methods of the carousel 3179 for (override in this._overrides) { 3180 this._core[override] = $.proxy(this[override], this); 3181 } 3182 }; 3183 3184 /** 3185 * Destroys the plugin. 3186 * @protected 3187 */ 3188 Navigation.prototype.destroy = function() { 3189 var handler, control, property, override, settings; 3190 settings = this._core.settings; 3191 3192 for (handler in this._handlers) { 3193 this.$element.off(handler, this._handlers[handler]); 3194 } 3195 for (control in this._controls) { 3196 if (control === '$relative' && settings.navContainer) { 3197 this._controls[control].html(''); 3198 } else { 3199 this._controls[control].remove(); 3200 } 3201 } 3202 for (override in this.overides) { 3203 this._core[override] = this._overrides[override]; 3204 } 3205 for (property in Object.getOwnPropertyNames(this)) { 3206 typeof this[property] != 'function' && (this[property] = null); 3207 } 3208 }; 3209 3210 /** 3211 * Updates the internal state. 3212 * @protected 3213 */ 3214 Navigation.prototype.update = function() { 3215 var i, j, k, 3216 lower = this._core.clones().length / 2, 3217 upper = lower + this._core.items().length, 3218 maximum = this._core.maximum(true), 3219 settings = this._core.settings, 3220 size = settings.center || settings.autoWidth || settings.dotsData 3221 ? 1 : settings.dotsEach || settings.items; 3222 3223 if (settings.slideBy !== 'page') { 3224 settings.slideBy = Math.min(settings.slideBy, settings.items); 3225 } 3226 3227 if (settings.dots || settings.slideBy == 'page') { 3228 this._pages = []; 3229 3230 for (i = lower, j = 0, k = 0; i < upper; i++) { 3231 if (j >= size || j === 0) { 3232 this._pages.push({ 3233 start: Math.min(maximum, i - lower), 3234 end: i - lower + size - 1 3235 }); 3236 if (Math.min(maximum, i - lower) === maximum) { 3237 break; 3238 } 3239 j = 0, ++k; 3240 } 3241 j += this._core.mergers(this._core.relative(i)); 3242 } 3243 } 3244 }; 3245 3246 /** 3247 * Draws the user interface. 3248 * @todo The option `dotsData` wont work. 3249 * @protected 3250 */ 3251 Navigation.prototype.draw = function() { 3252 var difference, 3253 settings = this._core.settings, 3254 disabled = this._core.items().length <= settings.items, 3255 index = this._core.relative(this._core.current()), 3256 loop = settings.loop || settings.rewind; 3257 3258 this._controls.$relative.toggleClass('disabled', !settings.nav || disabled); 3259 3260 if (settings.nav) { 3261 this._controls.$previous.toggleClass('disabled', !loop && index <= this._core.minimum(true)); 3262 this._controls.$next.toggleClass('disabled', !loop && index >= this._core.maximum(true)); 3263 } 3264 3265 this._controls.$absolute.toggleClass('disabled', !settings.dots || disabled); 3266 3267 if (settings.dots) { 3268 difference = this._pages.length - this._controls.$absolute.children().length; 3269 3270 if (settings.dotsData && difference !== 0) { 3271 this._controls.$absolute.html(this._templates.join('')); 3272 } else if (difference > 0) { 3273 this._controls.$absolute.append(new Array(difference + 1).join(this._templates[0])); 3274 } else if (difference < 0) { 3275 this._controls.$absolute.children().slice(difference).remove(); 3276 } 3277 3278 this._controls.$absolute.find('.active').removeClass('active'); 3279 this._controls.$absolute.children().eq($.inArray(this.current(), this._pages)).addClass('active'); 3280 } 3281 }; 3282 3283 /** 3284 * Extends event data. 3285 * @protected 3286 * @param {Event} event - The event object which gets thrown. 3287 */ 3288 Navigation.prototype.onTrigger = function(event) { 3289 var settings = this._core.settings; 3290 3291 event.page = { 3292 index: $.inArray(this.current(), this._pages), 3293 count: this._pages.length,
vendor: 7,284 bytes, lines 3294-3579
3294 size: settings && (settings.center || settings.autoWidth || settings.dotsData 3295 ? 1 : settings.dotsEach || settings.items) 3296 }; 3297 }; 3298 3299 /** 3300 * Gets the current page position of the carousel. 3301 * @protected 3302 * @returns {Number} 3303 */ 3304 Navigation.prototype.current = function() { 3305 var current = this._core.relative(this._core.current()); 3306 return $.grep(this._pages, $.proxy(function(page, index) { 3307 return page.start <= current && page.end >= current; 3308 }, this)).pop(); 3309 }; 3310 3311 /** 3312 * Gets the current succesor/predecessor position. 3313 * @protected 3314 * @returns {Number} 3315 */ 3316 Navigation.prototype.getPosition = function(successor) { 3317 var position, length, 3318 settings = this._core.settings; 3319 3320 if (settings.slideBy == 'page') { 3321 position = $.inArray(this.current(), this._pages); 3322 length = this._pages.length; 3323 successor ? ++position : --position; 3324 position = this._pages[((position % length) + length) % length].start; 3325 } else { 3326 position = this._core.relative(this._core.current()); 3327 length = this._core.items().length; 3328 successor ? position += settings.slideBy : position -= settings.slideBy; 3329 } 3330 3331 return position; 3332 }; 3333 3334 /** 3335 * Slides to the next item or page. 3336 * @public 3337 * @param {Number} [speed=false] - The time in milliseconds for the transition. 3338 */ 3339 Navigation.prototype.next = function(speed) { 3340 $.proxy(this._overrides.to, this._core)(this.getPosition(true), speed); 3341 }; 3342 3343 /** 3344 * Slides to the previous item or page. 3345 * @public 3346 * @param {Number} [speed=false] - The time in milliseconds for the transition. 3347 */ 3348 Navigation.prototype.prev = function(speed) { 3349 $.proxy(this._overrides.to, this._core)(this.getPosition(false), speed); 3350 }; 3351 3352 /** 3353 * Slides to the specified item or page. 3354 * @public 3355 * @param {Number} position - The position of the item or page. 3356 * @param {Number} [speed] - The time in milliseconds for the transition. 3357 * @param {Boolean} [standard=false] - Whether to use the standard behaviour or not. 3358 */ 3359 Navigation.prototype.to = function(position, speed, standard) { 3360 var length; 3361 3362 if (!standard && this._pages.length) { 3363 length = this._pages.length; 3364 $.proxy(this._overrides.to, this._core)(this._pages[((position % length) + length) % length].start, speed); 3365 } else { 3366 $.proxy(this._overrides.to, this._core)(position, speed); 3367 } 3368 }; 3369 3370 $.fn.owlCarousel.Constructor.Plugins.Navigation = Navigation; 3371 3372})(window.Zepto || window.jQuery, window, document); 3373 3374/** 3375 * Hash Plugin 3376 * @version 2.3.4 3377 * @author Artus Kolanowski 3378 * @author David Deutsch 3379 * @license The MIT License (MIT) 3380 */ 3381;(function($, window, document, undefined) { 3382 'use strict'; 3383 3384 /** 3385 * Creates the hash plugin. 3386 * @class The Hash Plugin 3387 * @param {Owl} carousel - The Owl Carousel 3388 */ 3389 var Hash = function(carousel) { 3390 /** 3391 * Reference to the core. 3392 * @protected 3393 * @type {Owl} 3394 */ 3395 this._core = carousel; 3396 3397 /** 3398 * Hash index for the items. 3399 * @protected 3400 * @type {Object} 3401 */ 3402 this._hashes = {}; 3403 3404 /** 3405 * The carousel element. 3406 * @type {jQuery} 3407 */ 3408 this.$element = this._core.$element; 3409 3410 /** 3411 * All event handlers. 3412 * @protected 3413 * @type {Object} 3414 */ 3415 this._handlers = { 3416 'initialized.owl.carousel': $.proxy(function(e) { 3417 if (e.namespace && this._core.settings.startPosition === 'URLHash') { 3418 $(window).trigger('hashchange.owl.navigation'); 3419 } 3420 }, this), 3421 'prepared.owl.carousel': $.proxy(function(e) { 3422 if (e.namespace) { 3423 var hash = $(e.content).find('[data-hash]').addBack('[data-hash]').attr('data-hash'); 3424 3425 if (!hash) { 3426 return; 3427 } 3428 3429 this._hashes[hash] = e.content; 3430 } 3431 }, this), 3432 'changed.owl.carousel': $.proxy(function(e) { 3433 if (e.namespace && e.property.name === 'position') { 3434 var current = this._core.items(this._core.relative(this._core.current())), 3435 hash = $.map(this._hashes, function(item, hash) { 3436 return item === current ? hash : null; 3437 }).join(); 3438 3439 if (!hash || window.location.hash.slice(1) === hash) { 3440 return; 3441 } 3442 3443 window.location.hash = hash; 3444 } 3445 }, this) 3446 }; 3447 3448 // set default options 3449 this._core.options = $.extend({}, Hash.Defaults, this._core.options); 3450 3451 // register the event handlers 3452 this.$element.on(this._handlers); 3453 3454 // register event listener for hash navigation 3455 $(window).on('hashchange.owl.navigation', $.proxy(function(e) { 3456 var hash = window.location.hash.substring(1), 3457 items = this._core.$stage.children(), 3458 position = this._hashes[hash] && items.index(this._hashes[hash]); 3459 3460 if (position === undefined || position === this._core.current()) { 3461 return; 3462 } 3463 3464 this._core.to(this._core.relative(position), false, true); 3465 }, this)); 3466 }; 3467 3468 /** 3469 * Default options. 3470 * @public 3471 */ 3472 Hash.Defaults = { 3473 URLhashListener: false 3474 }; 3475 3476 /** 3477 * Destroys the plugin. 3478 * @public 3479 */ 3480 Hash.prototype.destroy = function() { 3481 var handler, property; 3482 3483 $(window).off('hashchange.owl.navigation'); 3484 3485 for (handler in this._handlers) { 3486 this._core.$element.off(handler, this._handlers[handler]); 3487 } 3488 for (property in Object.getOwnPropertyNames(this)) { 3489 typeof this[property] != 'function' && (this[property] = null); 3490 } 3491 }; 3492 3493 $.fn.owlCarousel.Constructor.Plugins.Hash = Hash; 3494 3495})(window.Zepto || window.jQuery, window, document); 3496 3497/** 3498 * Support Plugin 3499 * 3500 * @version 2.3.4 3501 * @author Vivid Planet Software GmbH 3502 * @author Artus Kolanowski 3503 * @author David Deutsch 3504 * @license The MIT License (MIT) 3505 */ 3506;(function($, window, document, undefined) { 3507 3508 var style = $('<support>').get(0).style, 3509 prefixes = 'Webkit Moz O ms'.split(' '), 3510 events = { 3511 transition: { 3512 end: { 3513 WebkitTransition: 'webkitTransitionEnd', 3514 MozTransition: 'transitionend', 3515 OTransition: 'oTransitionEnd', 3516 transition: 'transitionend' 3517 } 3518 }, 3519 animation: { 3520 end: { 3521 WebkitAnimation: 'webkitAnimationEnd', 3522 MozAnimation: 'animationend', 3523 OAnimation: 'oAnimationEnd', 3524 animation: 'animationend' 3525 } 3526 } 3527 }, 3528 tests = { 3529 csstransforms: function() { 3530 return !!test('transform'); 3531 }, 3532 csstransforms3d: function() { 3533 return !!test('perspective'); 3534 }, 3535 csstransitions: function() { 3536 return !!test('transition'); 3537 }, 3538 cssanimations: function() { 3539 return !!test('animation'); 3540 } 3541 }; 3542 3543 function test(property, prefixed) { 3544 var result = false, 3545 upper = property.charAt(0).toUpperCase() + property.slice(1); 3546 3547 $.each((property + ' ' + prefixes.join(upper + ' ') + upper).split(' '), function(i, property) { 3548 if (style[property] !== undefined) { 3549 result = prefixed ? property : true; 3550 return false; 3551 } 3552 }); 3553 3554 return result; 3555 } 3556 3557 function prefixed(property) { 3558 return test(property, true); 3559 } 3560 3561 if (tests.csstransitions()) { 3562 /* jshint -W053 */ 3563 $.support.transition = new String(prefixed('transition')) 3564 $.support.transition.end = events.transition.end[ $.support.transition ]; 3565 } 3566 3567 if (tests.cssanimations()) { 3568 /* jshint -W053 */ 3569 $.support.animation = new String(prefixed('animation')) 3570 $.support.animation.end = events.animation.end[ $.support.animation ]; 3571 } 3572 3573 if (tests.csstransforms()) { 3574 /* jshint -W053 */ 3575 $.support.transform = new String(prefixed('transform')); 3576 $.support.transform3d = tests.csstransforms3d(); 3577 } 3578 3579})(window.Zepto || window.jQuery, window, document);
3580; 3581/* =============================================== 3582 OWL CAROUSEL SLIDER 3583=============================================== */ 3584 3585jQuery('document').ready(function(){ 3586 var owl = jQuery('.slider .owl-carousel'); 3587 owl.owlCarousel({ 3588 margin:20, 3589 nav: true, 3590 autoplay : true, 3591 lazyLoad: true, 3592 autoplayTimeout: 3000, 3593 loop: false, 3594 dots:false, 3595 navText : ['<i class="fas fa-arrow-left"></i>','<i class="fas fa-arrow-right"></i> '], 3596 responsive: { 3597 0: { 3598 items: 1 3599 }, 3600 600: { 3601 items: 1 3602 }, 3603 1000: { 3604 items: 1 3605 } 3606 }, 3607 autoplayHoverPause : true, 3608 mouseDrag: true 3609 }); 3610}); 3611 3612/* =============================================== 3613 OPEN CLOSE MENU 3614============================================= */ 3615 3616function nonprofit_organization_open_menu() { 3617 jQuery('button.menu-toggle').addClass('close-panal'); 3618 setTimeout(function(){ 3619 jQuery('nav#main-menu').show(); 3620 }, 100); 3621 3622 return false; 3623} 3624 3625jQuery( "button.menu-toggle").on("click", nonprofit_organization_open_menu); 3626 3627function nonprofit_organization_close_menu() { 3628 jQuery('button.close-menu').removeClass('close-panal'); 3629 jQuery('nav#main-menu').hide(); 3630} 3631 3632jQuery( "button.close-menu").on("click", nonprofit_organization_close_menu); 3633 3634/* =============================================== 3635 TRAP TAB FOCUS ON MODAL MENU 3636============================================= */ 3637 3638jQuery('button.close-menu').on('keydown', function (e) { 3639 if (jQuery("this:focus") && (e.which === 9)) { 3640 e.preventDefault(); 3641 jQuery(this).blur(); 3642 jQuery('button.menu-toggle').focus(); 3643 } 3644}); 3645 3646/* =============================================== 3647 SCROLL TOP 3648============================================= */ 3649 3650jQuery(window).scroll(function () { 3651 if (jQuery(this).scrollTop() > 100) { 3652 jQuery('.scroll-up').fadeIn(); 3653 } else { 3654 jQuery('.scroll-up').fadeOut(); 3655 } 3656}); 3657 3658jQuery('a[href="#tobottom"]').click(function () { 3659 jQuery('html, body').animate({scrollTop: 0}, 'slow'); 3660 return false; 3661}); 3662 3663/* =============================================== 3664 STICKY-HEADER 3665============================================= */ 3666 3667jQuery(window).scroll(function () { 3668 var sticky = jQuery('.sticky-header'), 3669 scroll = jQuery(window).scrollTop(); 3670 3671 if (scroll >= 100) sticky.addClass('fixed-header'); 3672 else sticky.removeClass('fixed-header'); 3673}); 3674 3675/*=============================================== 3676 PRELOADER 3677=============================================== */ 3678 3679jQuery('document').ready(function($){ 3680 setTimeout(function () { 3681 jQuery(".cssloader").fadeOut("fast"); 3682},2000); 3683}); 3684;
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.