vendor: 4,869 bytes, lines 1-459
1/** 2 3 * Owl Carousel v2.2.1 4 5 * Copyright 2013-2017 David Deutsch 6 7 * Licensed under () 8 9 */ 10 11/** 12 13 * Owl carousel 14 15 * @version 2.1.6 16 17 * @author Bartosz Wojciechowski 18 19 * @author David Deutsch 20 21 * @license The MIT License (MIT) 22 23 * @todo Lazy Load Icon 24 25 * @todo prevent animationend bubling 26 27 * @todo itemsScaleUp 28 29 * @todo Test Zepto 30 31 * @todo stagePadding calculate wrong active classes 32 33 */ 34 35;(function($, window, document, undefined) { 36 37 38 39 /** 40 41 * Creates a carousel. 42 43 * @class The Owl Carousel. 44 45 * @public 46 47 * @param {HTMLElement|jQuery} element - The element to create the carousel for. 48 49 * @param {Object} [options] - The options 50 51 */ 52 53 function Owl(element, options) { 54 55 56 57 /** 58 59 * Current settings for the carousel. 60 61 * @public 62 63 */ 64 65 this.settings = null; 66 67 68 69 /** 70 71 * Current options set by the caller including defaults. 72 73 * @public 74 75 */ 76 77 this.options = $.extend({}, Owl.Defaults, options); 78 79 80 81 /** 82 83 * Plugin element. 84 85 * @public 86 87 */ 88 89 this.$element = $(element); 90 91 92 93 /** 94 95 * Proxied event handlers. 96 97 * @protected 98 99 */ 100 101 this._handlers = {}; 102 103 104 105 /** 106 107 * References to the running plugins of this carousel. 108 109 * @protected 110 111 */ 112 113 this._plugins = {}; 114 115 116 117 /** 118 119 * Currently suppressed events to prevent them from beeing retriggered. 120 121 * @protected 122 123 */ 124 125 this._supress = {}; 126 127 128 129 /** 130 131 * Absolute current position. 132 133 * @protected 134 135 */ 136 137 this._current = null; 138 139 140 141 /** 142 143 * Animation speed in milliseconds. 144 145 * @protected 146 147 */ 148 149 this._speed = null; 150 151 152 153 /** 154 155 * Coordinates of all items in pixel. 156 157 * @todo The name of this member is missleading. 158 159 * @protected 160 161 */ 162 163 this._coordinates = []; 164 165 166 167 /** 168 169 * Current breakpoint. 170 171 * @todo Real media queries would be nice. 172 173 * @protected 174 175 */ 176 177 this._breakpoint = null; 178 179 180 181 /** 182 183 * Current width of the plugin element. 184 185 */ 186 187 this._width = null; 188 189 190 191 /** 192 193 * All real items. 194 195 * @protected 196 197 */ 198 199 this._items = []; 200 201 202 203 /** 204 205 * All cloned items. 206 207 * @protected 208 209 */ 210 211 this._clones = []; 212 213 214 215 /** 216 217 * Merge values of all items. 218 219 * @todo Maybe this could be part of a plugin. 220 221 * @protected 222 223 */ 224 225 this._mergers = []; 226 227 228 229 /** 230 231 * Widths of all items. 232 233 */ 234 235 this._widths = []; 236 237 238 239 /** 240 241 * Invalidated parts within the update process. 242 243 * @protected 244 245 */ 246 247 this._invalidated = {}; 248 249 250 251 /** 252 253 * Ordered list of workers for the update process. 254 255 * @protected 256 257 */ 258 259 this._pipe = []; 260 261 262 263 /** 264 265 * Current state information for the drag operation. 266 267 * @todo #261 268 269 * @protected 270 271 */ 272 273 this._drag = { 274 275 time: null, 276 277 target: null, 278 279 pointer: null, 280 281 stage: { 282 283 start: null, 284 285 current: null 286 287 }, 288 289 direction: null 290 291 }; 292 293 294 295 /** 296 297 * Current state information and their tags. 298 299 * @type {Object} 300 301 * @protected 302 303 */ 304 305 this._states = { 306 307 current: {}, 308 309 tags: { 310 311 'initializing': [ 'busy' ], 312 313 'animating': [ 'busy' ], 314 315 'dragging': [ 'interacting' ] 316 317 } 318 319 }; 320 321 322 323 $.each([ 'onResize', 'onThrottledResize' ], $.proxy(function(i, handler) { 324 325 this._handlers[handler] = $.proxy(this[handler], this); 326 327 }, this)); 328 329 330 331 $.each(Owl.Plugins, $.proxy(function(key, plugin) { 332 333 this._plugins[key.charAt(0).toLowerCase() + key.slice(1)] 334 335 = new plugin(this); 336 337 }, this)); 338 339 340 341 $.each(Owl.Workers, $.proxy(function(priority, worker) { 342 343 this._pipe.push({ 344 345 'filter': worker.filter, 346 347 'run': $.proxy(worker.run, this) 348 349 }); 350 351 }, this)); 352 353 354 355 this.setup(); 356 357 this.initialize(); 358 359 } 360 361 362 363 /** 364 365 * Default options for the carousel. 366 367 * @public 368 369 */ 370 371 Owl.Defaults = { 372 373 items: 3, 374 375 loop: false, 376 377 center: false, 378 379 rewind: false, 380 381 382 383 mouseDrag: true, 384 385 touchDrag: true, 386 387 pullDrag: true, 388 389 freeDrag: false, 390 391 392 393 margin: 0, 394 395 stagePadding: 0, 396 397 398 399 merge: false, 400 401 mergeFit: true, 402 403 autoWidth: false, 404 405 406 407 startPosition: 0, 408 409 rtl: false, 410 411 412 413 smartSpeed: 250, 414 415 fluidSpeed: false, 416 417 dragEndSpeed: false, 418 419 420 421 responsive: {}, 422 423 responsiveRefreshRate: 200, 424 425 responsiveBaseElement: window, 426 427 428 429 fallbackEasing: 'swing', 430 431 432 433 info: false, 434 435 436 437 nestedItemSelector: false, 438 439 itemElement: 'div', 440 441 stageElement: 'div', 442 443 444 445 refreshClass: 'owl-refresh', 446 447 loadedClass: 'owl-loaded', 448 449 loadingClass: 'owl-loading', 450 451 rtlClass: 'owl-rtl', 452 453 responsiveClass: 'owl-responsive', 454 455 dragClass: 'owl-drag', 456 457 itemClass: 'owl-item', 458 459 stageClass: 'owl-stage',
vendor: 4,363 bytes, lines 460-773
460 461 stageOuterClass: 'owl-stage-outer', 462 463 grabClass: 'owl-grab' 464 465 }; 466 467 468 469 /** 470 471 * Enumeration for width. 472 473 * @public 474 475 * @readonly 476 477 * @enum {String} 478 479 */ 480 481 Owl.Width = { 482 483 Default: 'default', 484 485 Inner: 'inner', 486 487 Outer: 'outer' 488 489 }; 490 491 492 493 /** 494 495 * Enumeration for types. 496 497 * @public 498 499 * @readonly 500 501 * @enum {String} 502 503 */ 504 505 Owl.Type = { 506 507 Event: 'event', 508 509 State: 'state' 510 511 }; 512 513 514 515 /** 516 517 * Contains all registered plugins. 518 519 * @public 520 521 */ 522 523 Owl.Plugins = {}; 524 525 526 527 /** 528 529 * List of workers involved in the update process. 530 531 */ 532 533 Owl.Workers = [ { 534 535 filter: [ 'width', 'settings' ], 536 537 run: function() { 538 539 this._width = this.$element.width(); 540 541 } 542 543 }, { 544 545 filter: [ 'width', 'items', 'settings' ], 546 547 run: function(cache) { 548 549 cache.current = this._items && this._items[this.relative(this._current)]; 550 551 } 552 553 }, { 554 555 filter: [ 'items', 'settings' ], 556 557 run: function() { 558 559 this.$stage.children('.cloned').remove(); 560 561 } 562 563 }, { 564 565 filter: [ 'width', 'items', 'settings' ], 566 567 run: function(cache) { 568 569 var margin = this.settings.margin || '', 570 571 grid = !this.settings.autoWidth, 572 573 rtl = this.settings.rtl, 574 575 css = { 576 577 'width': 'auto', 578 579 'margin-left': rtl ? margin : '', 580 581 'margin-right': rtl ? '' : margin 582 583 }; 584 585 586 587 !grid && this.$stage.children().css(css); 588 589 590 591 cache.css = css; 592 593 } 594 595 }, { 596 597 filter: [ 'width', 'items', 'settings' ], 598 599 run: function(cache) { 600 601 var width = (this.width() / this.settings.items).toFixed(3) - this.settings.margin, 602 603 merge = null, 604 605 iterator = this._items.length, 606 607 grid = !this.settings.autoWidth, 608 609 widths = []; 610 611 612 613 cache.items = { 614 615 merge: false, 616 617 width: width 618 619 }; 620 621 622 623 while (iterator--) { 624 625 merge = this._mergers[iterator]; 626 627 merge = this.settings.mergeFit && Math.min(merge, this.settings.items) || merge; 628 629 630 631 cache.items.merge = merge > 1 || cache.items.merge; 632 633 634 635 widths[iterator] = !grid ? this._items[iterator].width() : width * merge; 636 637 } 638 639 640 641 this._widths = widths; 642 643 } 644 645 }, { 646 647 filter: [ 'items', 'settings' ], 648 649 run: function() { 650 651 var clones = [], 652 653 items = this._items, 654 655 settings = this.settings, 656 657 // TODO: Should be computed from number of min width items in stage 658 659 view = Math.max(settings.items * 2, 4), 660 661 size = Math.ceil(items.length / 2) * 2, 662 663 repeat = settings.loop && items.length ? settings.rewind ? view : Math.max(view, size) : 0, 664 665 append = '', 666 667 prepend = ''; 668 669 670 671 repeat /= 2; 672 673 674 675 while (repeat--) { 676 677 // Switch to only using appended clones 678 679 clones.push(this.normalize(clones.length / 2, true)); 680 681 append = append + items[clones[clones.length - 1]][0].outerHTML; 682 683 clones.push(this.normalize(items.length - 1 - (clones.length - 1) / 2, true)); 684 685 prepend = items[clones[clones.length - 1]][0].outerHTML + prepend; 686 687 } 688 689 690 691 this._clones = clones; 692 693 694 695 $(append).addClass('cloned').appendTo(this.$stage); 696 697 $(prepend).addClass('cloned').prependTo(this.$stage); 698 699 } 700 701 }, { 702 703 filter: [ 'width', 'items', 'settings' ], 704 705 run: function() { 706 707 var rtl = this.settings.rtl ? 1 : -1, 708 709 size = this._clones.length + this._items.length, 710 711 iterator = -1, 712 713 previous = 0, 714 715 current = 0, 716 717 coordinates = []; 718 719 720 721 while (++iterator < size) { 722 723 previous = coordinates[iterator - 1] || 0; 724 725 current = this._widths[this.relative(iterator)] + this.settings.margin; 726 727 coordinates.push(previous + current * rtl); 728 729 } 730 731 732 733 this._coordinates = coordinates; 734 735 } 736 737 }, { 738 739 filter: [ 'width', 'items', 'settings' ], 740 741 run: function() { 742 743 var padding = this.settings.stagePadding, 744 745 coordinates = this._coordinates, 746 747 css = { 748 749 'width': Math.ceil(Math.abs(coordinates[coordinates.length - 1])) + padding * 2, 750 751 'padding-left': padding || '', 752 753 'padding-right': padding || '' 754 755 }; 756 757 758 759 this.$stage.css(css); 760 761 } 762 763 }, { 764 765 filter: [ 'width', 'items', 'settings' ], 766 767 run: function(cache) { 768 769 var iterator = this._coordinates.length, 770 771 grid = !this.settings.autoWidth, 772 773 items = this.$stage.children();
vendor: 8,223 bytes, lines 774-1356
774 775 776 777 if (grid && cache.items.merge) { 778 779 while (iterator--) { 780 781 cache.css.width = this._widths[this.relative(iterator)]; 782 783 items.eq(iterator).css(cache.css); 784 785 } 786 787 } else if (grid) { 788 789 cache.css.width = cache.items.width; 790 791 items.css(cache.css); 792 793 } 794 795 } 796 797 }, { 798 799 filter: [ 'items' ], 800 801 run: function() { 802 803 this._coordinates.length < 1 && this.$stage.removeAttr('style'); 804 805 } 806 807 }, { 808 809 filter: [ 'width', 'items', 'settings' ], 810 811 run: function(cache) { 812 813 cache.current = cache.current ? this.$stage.children().index(cache.current) : 0; 814 815 cache.current = Math.max(this.minimum(), Math.min(this.maximum(), cache.current)); 816 817 this.reset(cache.current); 818 819 } 820 821 }, { 822 823 filter: [ 'position' ], 824 825 run: function() { 826 827 this.animate(this.coordinates(this._current)); 828 829 } 830 831 }, { 832 833 filter: [ 'width', 'position', 'items', 'settings' ], 834 835 run: function() { 836 837 var rtl = this.settings.rtl ? 1 : -1, 838 839 padding = this.settings.stagePadding * 2, 840 841 begin = this.coordinates(this.current()) + padding, 842 843 end = begin + this.width() * rtl, 844 845 inner, outer, matches = [], i, n; 846 847 848 849 for (i = 0, n = this._coordinates.length; i < n; i++) { 850 851 inner = this._coordinates[i - 1] || 0; 852 853 outer = Math.abs(this._coordinates[i]) + padding * rtl; 854 855 856 857 if ((this.op(inner, '<=', begin) && (this.op(inner, '>', end))) 858 859 || (this.op(outer, '<', begin) && this.op(outer, '>', end))) { 860 861 matches.push(i); 862 863 } 864 865 } 866 867 868 869 this.$stage.children('.active').removeClass('active'); 870 871 this.$stage.children(':eq(' + matches.join('), :eq(') + ')').addClass('active'); 872 873 874 875 if (this.settings.center) { 876 877 this.$stage.children('.center').removeClass('center'); 878 879 this.$stage.children().eq(this.current()).addClass('center'); 880 881 } 882 883 } 884 885 } ]; 886 887 888 889 /** 890 891 * Initializes the carousel. 892 893 * @protected 894 895 */ 896 897 Owl.prototype.initialize = function() { 898 899 this.enter('initializing'); 900 901 this.trigger('initialize'); 902 903 904 905 this.$element.toggleClass(this.settings.rtlClass, this.settings.rtl); 906 907 908 909 if (this.settings.autoWidth && !this.is('pre-loading')) { 910 911 var imgs, nestedSelector, width; 912 913 imgs = this.$element.find('img'); 914 915 nestedSelector = this.settings.nestedItemSelector ? '.' + this.settings.nestedItemSelector : undefined; 916 917 width = this.$element.children(nestedSelector).width(); 918 919 920 921 if (imgs.length && width <= 0) { 922 923 this.preloadAutoWidthImages(imgs); 924 925 } 926 927 } 928 929 930 931 this.$element.addClass(this.options.loadingClass); 932 933 934 935 // create stage 936 937 this.$stage = $('<' + this.settings.stageElement + ' class="' + this.settings.stageClass + '"/>') 938 939 .wrap('<div class="' + this.settings.stageOuterClass + '"/>'); 940 941 942 943 // append stage 944 945 this.$element.append(this.$stage.parent()); 946 947 948 949 // append content 950 951 this.replace(this.$element.children().not(this.$stage.parent())); 952 953 954 955 // check visibility 956 957 if (this.$element.is(':visible')) { 958 959 // update view 960 961 this.refresh(); 962 963 } else { 964 965 // invalidate width 966 967 this.invalidate('width'); 968 969 } 970 971 972 973 this.$element 974 975 .removeClass(this.options.loadingClass) 976 977 .addClass(this.options.loadedClass); 978 979 980 981 // register event handlers 982 983 this.registerEventHandlers(); 984 985 986 987 this.leave('initializing'); 988 989 this.trigger('initialized'); 990 991 }; 992 993 994 995 /** 996 997 * Setups the current settings. 998 999 * @todo Remove responsive classes. Why should adaptive designs be brought into IE8? 1000 1001 * @todo Support for media queries by using `matchMedia` would be nice. 1002 1003 * @public 1004 1005 */ 1006 1007 Owl.prototype.setup = function() { 1008 1009 var viewport = this.viewport(), 1010 1011 overwrites = this.options.responsive, 1012 1013 match = -1, 1014 1015 settings = null; 1016 1017 1018 1019 if (!overwrites) { 1020 1021 settings = $.extend({}, this.options); 1022 1023 } else { 1024 1025 $.each(overwrites, function(breakpoint) { 1026 1027 if (breakpoint <= viewport && breakpoint > match) { 1028 1029 match = Number(breakpoint); 1030 1031 } 1032 1033 }); 1034 1035 1036 1037 settings = $.extend({}, this.options, overwrites[match]); 1038 1039 if (typeof settings.stagePadding === 'function') { 1040 1041 settings.stagePadding = settings.stagePadding(); 1042 1043 } 1044 1045 delete settings.responsive; 1046 1047 1048 1049 // responsive class 1050 1051 if (settings.responsiveClass) { 1052 1053 this.$element.attr('class', 1054 1055 this.$element.attr('class').replace(new RegExp('(' + this.options.responsiveClass + '-)\\S+\\s', 'g'), '$1' + match) 1056 1057 ); 1058 1059 } 1060 1061 } 1062 1063 1064 1065 this.trigger('change', { property: { name: 'settings', value: settings } }); 1066 1067 this._breakpoint = match; 1068 1069 this.settings = settings; 1070 1071 this.invalidate('settings'); 1072 1073 this.trigger('changed', { property: { name: 'settings', value: this.settings } }); 1074 1075 }; 1076 1077 1078 1079 /** 1080 1081 * Updates option logic if necessery. 1082 1083 * @protected 1084 1085 */ 1086 1087 Owl.prototype.optionsLogic = function() { 1088 1089 if (this.settings.autoWidth) { 1090 1091 this.settings.stagePadding = false; 1092 1093 this.settings.merge = false; 1094 1095 } 1096 1097 }; 1098 1099 1100 1101 /** 1102 1103 * Prepares an item before add. 1104 1105 * @todo Rename event parameter `content` to `item`. 1106 1107 * @protected 1108 1109 * @returns {jQuery|HTMLElement} - The item container. 1110 1111 */ 1112 1113 Owl.prototype.prepare = function(item) { 1114 1115 var event = this.trigger('prepare', { content: item }); 1116 1117 1118 1119 if (!event.data) { 1120 1121 event.data = $('<' + this.settings.itemElement + '/>') 1122 1123 .addClass(this.options.itemClass).append(item) 1124 1125 } 1126 1127 1128 1129 this.trigger('prepared', { content: event.data }); 1130 1131 1132 1133 return event.data; 1134 1135 }; 1136 1137 1138 1139 /** 1140 1141 * Updates the view. 1142 1143 * @public 1144 1145 */ 1146 1147 Owl.prototype.update = function() { 1148 1149 var i = 0, 1150 1151 n = this._pipe.length, 1152 1153 filter = $.proxy(function(p) { return this[p] }, this._invalidated), 1154 1155 cache = {}; 1156 1157 1158 1159 while (i < n) { 1160 1161 if (this._invalidated.all || $.grep(this._pipe[i].filter, filter).length > 0) { 1162 1163 this._pipe[i].run(cache); 1164 1165 } 1166 1167 i++; 1168 1169 } 1170 1171 1172 1173 this._invalidated = {}; 1174 1175 1176 1177 !this.is('valid') && this.enter('valid'); 1178 1179 }; 1180 1181 1182 1183 /** 1184 1185 * Gets the width of the view. 1186 1187 * @public 1188 1189 * @param {Owl.Width} [dimension=Owl.Width.Default] - The dimension to return. 1190 1191 * @returns {Number} - The width of the view in pixel. 1192 1193 */ 1194 1195 Owl.prototype.width = function(dimension) { 1196 1197 dimension = dimension || Owl.Width.Default; 1198 1199 switch (dimension) { 1200 1201 case Owl.Width.Inner: 1202 1203 case Owl.Width.Outer: 1204 1205 return this._width; 1206 1207 default: 1208 1209 return this._width - this.settings.stagePadding * 2 + this.settings.margin; 1210 1211 } 1212 1213 }; 1214 1215 1216 1217 /** 1218 1219 * Refreshes the carousel primarily for adaptive purposes. 1220 1221 * @public 1222 1223 */ 1224 1225 Owl.prototype.refresh = function() { 1226 1227 this.enter('refreshing'); 1228 1229 this.trigger('refresh'); 1230 1231 1232 1233 this.setup(); 1234 1235 1236 1237 this.optionsLogic(); 1238 1239 1240 1241 this.$element.addClass(this.options.refreshClass); 1242 1243 1244 1245 this.update(); 1246 1247 1248 1249 this.$element.removeClass(this.options.refreshClass); 1250 1251 1252 1253 this.leave('refreshing'); 1254 1255 this.trigger('refreshed'); 1256 1257 }; 1258 1259 1260 1261 /** 1262 1263 * Checks window `resize` event. 1264 1265 * @protected 1266 1267 */ 1268 1269 Owl.prototype.onThrottledResize = function() { 1270 1271 window.clearTimeout(this.resizeTimer); 1272 1273 this.resizeTimer = window.setTimeout(this._handlers.onResize, this.settings.responsiveRefreshRate); 1274 1275 }; 1276 1277 1278 1279 /** 1280 1281 * Checks window `resize` event. 1282 1283 * @protected 1284 1285 */ 1286 1287 Owl.prototype.onResize = function() { 1288 1289 if (!this._items.length) { 1290 1291 return false; 1292 1293 } 1294 1295 1296 1297 if (this._width === this.$element.width()) { 1298 1299 return false; 1300 1301 } 1302 1303 1304 1305 if (!this.$element.is(':visible')) { 1306 1307 return false; 1308 1309 } 1310 1311 1312 1313 this.enter('resizing'); 1314 1315 1316 1317 if (this.trigger('resize').isDefaultPrevented()) { 1318 1319 this.leave('resizing'); 1320 1321 return false; 1322 1323 } 1324 1325 1326 1327 this.invalidate('width'); 1328 1329 1330 1331 this.refresh(); 1332 1333 1334 1335 this.leave('resizing'); 1336 1337 this.trigger('resized'); 1338 1339 }; 1340 1341 1342 1343 /** 1344 1345 * Registers event handlers. 1346 1347 * @todo Check `msPointerEnabled` 1348 1349 * @todo #261 1350 1351 * @protected 1352 1353 */ 1354 1355 Owl.prototype.registerEventHandlers = function() { 1356
vendor: 5,548 bytes, lines 1357-1691
1357 if ($.support.transition) { 1358 1359 this.$stage.on($.support.transition.end + '.owl.core', $.proxy(this.onTransitionEnd, this)); 1360 1361 } 1362 1363 1364 1365 if (this.settings.responsive !== false) { 1366 1367 this.on(window, 'resize', this._handlers.onThrottledResize); 1368 1369 } 1370 1371 1372 1373 if (this.settings.mouseDrag) { 1374 1375 this.$element.addClass(this.options.dragClass); 1376 1377 this.$stage.on('mousedown.owl.core', $.proxy(this.onDragStart, this)); 1378 1379 this.$stage.on('dragstart.owl.core selectstart.owl.core', function() { return false }); 1380 1381 } 1382 1383 1384 1385 if (this.settings.touchDrag){ 1386 1387 this.$stage.on('touchstart.owl.core', $.proxy(this.onDragStart, this)); 1388 1389 this.$stage.on('touchcancel.owl.core', $.proxy(this.onDragEnd, this)); 1390 1391 } 1392 1393 }; 1394 1395 1396 1397 /** 1398 1399 * Handles `touchstart` and `mousedown` events. 1400 1401 * @todo Horizontal swipe threshold as option 1402 1403 * @todo #261 1404 1405 * @protected 1406 1407 * @param {Event} event - The event arguments. 1408 1409 */ 1410 1411 Owl.prototype.onDragStart = function(event) { 1412 1413 var stage = null; 1414 1415 1416 1417 if (event.which === 3) { 1418 1419 return; 1420 1421 } 1422 1423 1424 1425 if ($.support.transform) { 1426 1427 stage = this.$stage.css('transform').replace(/.*\(|\)| /g, '').split(','); 1428 1429 stage = { 1430 1431 x: stage[stage.length === 16 ? 12 : 4], 1432 1433 y: stage[stage.length === 16 ? 13 : 5] 1434 1435 }; 1436 1437 } else { 1438 1439 stage = this.$stage.position(); 1440 1441 stage = { 1442 1443 x: this.settings.rtl ? 1444 1445 stage.left + this.$stage.width() - this.width() + this.settings.margin : 1446 1447 stage.left, 1448 1449 y: stage.top 1450 1451 }; 1452 1453 } 1454 1455 1456 1457 if (this.is('animating')) { 1458 1459 $.support.transform ? this.animate(stage.x) : this.$stage.stop() 1460 1461 this.invalidate('position'); 1462 1463 } 1464 1465 1466 1467 this.$element.toggleClass(this.options.grabClass, event.type === 'mousedown'); 1468 1469 1470 1471 this.speed(0); 1472 1473 1474 1475 this._drag.time = new Date().getTime(); 1476 1477 this._drag.target = $(event.target); 1478 1479 this._drag.stage.start = stage; 1480 1481 this._drag.stage.current = stage; 1482 1483 this._drag.pointer = this.pointer(event); 1484 1485 1486 1487 $(document).on('mouseup.owl.core touchend.owl.core', $.proxy(this.onDragEnd, this)); 1488 1489 1490 1491 $(document).one('mousemove.owl.core touchmove.owl.core', $.proxy(function(event) { 1492 1493 var delta = this.difference(this._drag.pointer, this.pointer(event)); 1494 1495 1496 1497 $(document).on('mousemove.owl.core touchmove.owl.core', $.proxy(this.onDragMove, this)); 1498 1499 1500 1501 if (Math.abs(delta.x) < Math.abs(delta.y) && this.is('valid')) { 1502 1503 return; 1504 1505 } 1506 1507 1508 1509 event.preventDefault(); 1510 1511 1512 1513 this.enter('dragging'); 1514 1515 this.trigger('drag'); 1516 1517 }, this)); 1518 1519 }; 1520 1521 1522 1523 /** 1524 1525 * Handles the `touchmove` and `mousemove` events. 1526 1527 * @todo #261 1528 1529 * @protected 1530 1531 * @param {Event} event - The event arguments. 1532 1533 */ 1534 1535 Owl.prototype.onDragMove = function(event) { 1536 1537 var minimum = null, 1538 1539 maximum = null, 1540 1541 pull = null, 1542 1543 delta = this.difference(this._drag.pointer, this.pointer(event)), 1544 1545 stage = this.difference(this._drag.stage.start, delta); 1546 1547 1548 1549 if (!this.is('dragging')) { 1550 1551 return; 1552 1553 } 1554 1555 1556 1557 event.preventDefault(); 1558 1559 1560 1561 if (this.settings.loop) { 1562 1563 minimum = this.coordinates(this.minimum()); 1564 1565 maximum = this.coordinates(this.maximum() + 1) - minimum; 1566 1567 stage.x = (((stage.x - minimum) % maximum + maximum) % maximum) + minimum; 1568 1569 } else { 1570 1571 minimum = this.settings.rtl ? this.coordinates(this.maximum()) : this.coordinates(this.minimum()); 1572 1573 maximum = this.settings.rtl ? this.coordinates(this.minimum()) : this.coordinates(this.maximum()); 1574 1575 pull = this.settings.pullDrag ? -1 * delta.x / 5 : 0; 1576 1577 stage.x = Math.max(Math.min(stage.x, minimum + pull), maximum + pull); 1578 1579 } 1580 1581 1582 1583 this._drag.stage.current = stage; 1584 1585 1586 1587 this.animate(stage.x); 1588 1589 }; 1590 1591 1592 1593 /** 1594 1595 * Handles the `touchend` and `mouseup` events. 1596 1597 * @todo #261 1598 1599 * @todo Threshold for click event 1600 1601 * @protected 1602 1603 * @param {Event} event - The event arguments. 1604 1605 */ 1606 1607 Owl.prototype.onDragEnd = function(event) { 1608 1609 var delta = this.difference(this._drag.pointer, this.pointer(event)), 1610 1611 stage = this._drag.stage.current, 1612 1613 direction = delta.x > 0 ^ this.settings.rtl ? 'left' : 'right'; 1614 1615 1616 1617 $(document).off('.owl.core'); 1618 1619 1620 1621 this.$element.removeClass(this.options.grabClass); 1622 1623 1624 1625 if (delta.x !== 0 && this.is('dragging') || !this.is('valid')) { 1626 1627 this.speed(this.settings.dragEndSpeed || this.settings.smartSpeed); 1628 1629 this.current(this.closest(stage.x, delta.x !== 0 ? direction : this._drag.direction)); 1630 1631 this.invalidate('position'); 1632 1633 this.update(); 1634 1635 1636 1637 this._drag.direction = direction; 1638 1639 1640 1641 if (Math.abs(delta.x) > 3 || new Date().getTime() - this._drag.time > 300) { 1642 1643 this._drag.target.one('click.owl.core', function() { return false; }); 1644 1645 } 1646 1647 } 1648 1649 1650 1651 if (!this.is('dragging')) { 1652 1653 return; 1654 1655 } 1656 1657 1658 1659 this.leave('dragging'); 1660 1661 this.trigger('dragged'); 1662 1663 }; 1664 1665 1666 1667 /** 1668 1669 * Gets absolute position of the closest item for a coordinate. 1670 1671 * @todo Setting `freeDrag` makes `closest` not reusable. See #165. 1672 1673 * @protected 1674 1675 * @param {Number} coordinate - The coordinate in pixel. 1676 1677 * @param {String} direction - The direction to check for the closest item. Ether `left` or `right`. 1678 1679 * @return {Number} - The absolute position of the closest item. 1680 1681 */ 1682 1683 Owl.prototype.closest = function(coordinate, direction) { 1684 1685 var position = -1, 1686 1687 pull = 30, 1688 1689 width = this.width(), 1690 1691 coordinates = this.coordinates();
vendor: 16,570 bytes, lines 1692-2724
1692 1693 1694 1695 if (!this.settings.freeDrag) { 1696 1697 // check closest item 1698 1699 $.each(coordinates, $.proxy(function(index, value) { 1700 1701 // on a left pull, check on current index 1702 1703 if (direction === 'left' && coordinate > value - pull && coordinate < value + pull) { 1704 1705 position = index; 1706 1707 // on a right pull, check on previous index 1708 1709 // to do so, subtract width from value and set position = index + 1 1710 1711 } else if (direction === 'right' && coordinate > value - width - pull && coordinate < value - width + pull) { 1712 1713 position = index + 1; 1714 1715 } else if (this.op(coordinate, '<', value) 1716 1717 && this.op(coordinate, '>', coordinates[index + 1] || value - width)) { 1718 1719 position = direction === 'left' ? index + 1 : index; 1720 1721 } 1722 1723 return position === -1; 1724 1725 }, this)); 1726 1727 } 1728 1729 1730 1731 if (!this.settings.loop) { 1732 1733 // non loop boundries 1734 1735 if (this.op(coordinate, '>', coordinates[this.minimum()])) { 1736 1737 position = coordinate = this.minimum(); 1738 1739 } else if (this.op(coordinate, '<', coordinates[this.maximum()])) { 1740 1741 position = coordinate = this.maximum(); 1742 1743 } 1744 1745 } 1746 1747 1748 1749 return position; 1750 1751 }; 1752 1753 1754 1755 /** 1756 1757 * Animates the stage. 1758 1759 * @todo #270 1760 1761 * @public 1762 1763 * @param {Number} coordinate - The coordinate in pixels. 1764 1765 */ 1766 1767 Owl.prototype.animate = function(coordinate) { 1768 1769 var animate = this.speed() > 0; 1770 1771 1772 1773 this.is('animating') && this.onTransitionEnd(); 1774 1775 1776 1777 if (animate) { 1778 1779 this.enter('animating'); 1780 1781 this.trigger('translate'); 1782 1783 } 1784 1785 1786 1787 if ($.support.transform3d && $.support.transition) { 1788 1789 this.$stage.css({ 1790 1791 transform: 'translate3d(' + coordinate + 'px,0px,0px)', 1792 1793 transition: (this.speed() / 1000) + 's' 1794 1795 }); 1796 1797 } else if (animate) { 1798 1799 this.$stage.animate({ 1800 1801 left: coordinate + 'px' 1802 1803 }, this.speed(), this.settings.fallbackEasing, $.proxy(this.onTransitionEnd, this)); 1804 1805 } else { 1806 1807 this.$stage.css({ 1808 1809 left: coordinate + 'px' 1810 1811 }); 1812 1813 } 1814 1815 }; 1816 1817 1818 1819 /** 1820 1821 * Checks whether the carousel is in a specific state or not. 1822 1823 * @param {String} state - The state to check. 1824 1825 * @returns {Boolean} - The flag which indicates if the carousel is busy. 1826 1827 */ 1828 1829 Owl.prototype.is = function(state) { 1830 1831 return this._states.current[state] && this._states.current[state] > 0; 1832 1833 }; 1834 1835 1836 1837 /** 1838 1839 * Sets the absolute position of the current item. 1840 1841 * @public 1842 1843 * @param {Number} [position] - The new absolute position or nothing to leave it unchanged. 1844 1845 * @returns {Number} - The absolute position of the current item. 1846 1847 */ 1848 1849 Owl.prototype.current = function(position) { 1850 1851 if (position === undefined) { 1852 1853 return this._current; 1854 1855 } 1856 1857 1858 1859 if (this._items.length === 0) { 1860 1861 return undefined; 1862 1863 } 1864 1865 1866 1867 position = this.normalize(position); 1868 1869 1870 1871 if (this._current !== position) { 1872 1873 var event = this.trigger('change', { property: { name: 'position', value: position } }); 1874 1875 1876 1877 if (event.data !== undefined) { 1878 1879 position = this.normalize(event.data); 1880 1881 } 1882 1883 1884 1885 this._current = position; 1886 1887 1888 1889 this.invalidate('position'); 1890 1891 1892 1893 this.trigger('changed', { property: { name: 'position', value: this._current } }); 1894 1895 } 1896 1897 1898 1899 return this._current; 1900 1901 }; 1902 1903 1904 1905 /** 1906 1907 * Invalidates the given part of the update routine. 1908 1909 * @param {String} [part] - The part to invalidate. 1910 1911 * @returns {Array.<String>} - The invalidated parts. 1912 1913 */ 1914 1915 Owl.prototype.invalidate = function(part) { 1916 1917 if ($.type(part) === 'string') { 1918 1919 this._invalidated[part] = true; 1920 1921 this.is('valid') && this.leave('valid'); 1922 1923 } 1924 1925 return $.map(this._invalidated, function(v, i) { return i }); 1926 1927 }; 1928 1929 1930 1931 /** 1932 1933 * Resets the absolute position of the current item. 1934 1935 * @public 1936 1937 * @param {Number} position - The absolute position of the new item. 1938 1939 */ 1940 1941 Owl.prototype.reset = function(position) { 1942 1943 position = this.normalize(position); 1944 1945 1946 1947 if (position === undefined) { 1948 1949 return; 1950 1951 } 1952 1953 1954 1955 this._speed = 0; 1956 1957 this._current = position; 1958 1959 1960 1961 this.suppress([ 'translate', 'translated' ]); 1962 1963 1964 1965 this.animate(this.coordinates(position)); 1966 1967 1968 1969 this.release([ 'translate', 'translated' ]); 1970 1971 }; 1972 1973 1974 1975 /** 1976 1977 * Normalizes an absolute or a relative position of an item. 1978 1979 * @public 1980 1981 * @param {Number} position - The absolute or relative position to normalize. 1982 1983 * @param {Boolean} [relative=false] - Whether the given position is relative or not. 1984 1985 * @returns {Number} - The normalized position. 1986 1987 */ 1988 1989 Owl.prototype.normalize = function(position, relative) { 1990 1991 var n = this._items.length, 1992 1993 m = relative ? 0 : this._clones.length; 1994 1995 1996 1997 if (!this.isNumeric(position) || n < 1) { 1998 1999 position = undefined; 2000 2001 } else if (position < 0 || position >= n + m) { 2002 2003 position = ((position - m / 2) % n + n) % n + m / 2; 2004 2005 } 2006 2007 2008 2009 return position; 2010 2011 }; 2012 2013 2014 2015 /** 2016 2017 * Converts an absolute position of an item into a relative one. 2018 2019 * @public 2020 2021 * @param {Number} position - The absolute position to convert. 2022 2023 * @returns {Number} - The converted position. 2024 2025 */ 2026 2027 Owl.prototype.relative = function(position) { 2028 2029 position -= this._clones.length / 2; 2030 2031 return this.normalize(position, true); 2032 2033 }; 2034 2035 2036 2037 /** 2038 2039 * Gets the maximum position for the current item. 2040 2041 * @public 2042 2043 * @param {Boolean} [relative=false] - Whether to return an absolute position or a relative position. 2044 2045 * @returns {Number} 2046 2047 */ 2048 2049 Owl.prototype.maximum = function(relative) { 2050 2051 var settings = this.settings, 2052 2053 maximum = this._coordinates.length, 2054 2055 iterator, 2056 2057 reciprocalItemsWidth, 2058 2059 elementWidth; 2060 2061 2062 2063 if (settings.loop) { 2064 2065 maximum = this._clones.length / 2 + this._items.length - 1; 2066 2067 } else if (settings.autoWidth || settings.merge) { 2068 2069 iterator = this._items.length; 2070 2071 reciprocalItemsWidth = this._items[--iterator].width(); 2072 2073 elementWidth = this.$element.width(); 2074 2075 while (iterator--) { 2076 2077 reciprocalItemsWidth += this._items[iterator].width() + this.settings.margin; 2078 2079 if (reciprocalItemsWidth > elementWidth) { 2080 2081 break; 2082 2083 } 2084 2085 } 2086 2087 maximum = iterator + 1; 2088 2089 } else if (settings.center) { 2090 2091 maximum = this._items.length - 1; 2092 2093 } else { 2094 2095 maximum = this._items.length - settings.items; 2096 2097 } 2098 2099 2100 2101 if (relative) { 2102 2103 maximum -= this._clones.length / 2; 2104 2105 } 2106 2107 2108 2109 return Math.max(maximum, 0); 2110 2111 }; 2112 2113 2114 2115 /** 2116 2117 * Gets the minimum position for the current item. 2118 2119 * @public 2120 2121 * @param {Boolean} [relative=false] - Whether to return an absolute position or a relative position. 2122 2123 * @returns {Number} 2124 2125 */ 2126 2127 Owl.prototype.minimum = function(relative) { 2128 2129 return relative ? 0 : this._clones.length / 2; 2130 2131 }; 2132 2133 2134 2135 /** 2136 2137 * Gets an item at the specified relative position. 2138 2139 * @public 2140 2141 * @param {Number} [position] - The relative position of the item. 2142 2143 * @return {jQuery|Array.<jQuery>} - The item at the given position or all items if no position was given. 2144 2145 */ 2146 2147 Owl.prototype.items = function(position) { 2148 2149 if (position === undefined) { 2150 2151 return this._items.slice(); 2152 2153 } 2154 2155 2156 2157 position = this.normalize(position, true); 2158 2159 return this._items[position]; 2160 2161 }; 2162 2163 2164 2165 /** 2166 2167 * Gets an item at the specified relative position. 2168 2169 * @public 2170 2171 * @param {Number} [position] - The relative position of the item. 2172 2173 * @return {jQuery|Array.<jQuery>} - The item at the given position or all items if no position was given. 2174 2175 */ 2176 2177 Owl.prototype.mergers = function(position) { 2178 2179 if (position === undefined) { 2180 2181 return this._mergers.slice(); 2182 2183 } 2184 2185 2186 2187 position = this.normalize(position, true); 2188 2189 return this._mergers[position]; 2190 2191 }; 2192 2193 2194 2195 /** 2196 2197 * Gets the absolute positions of clones for an item. 2198 2199 * @public 2200 2201 * @param {Number} [position] - The relative position of the item. 2202 2203 * @returns {Array.<Number>} - The absolute positions of clones for the item or all if no position was given. 2204 2205 */ 2206 2207 Owl.prototype.clones = function(position) { 2208 2209 var odd = this._clones.length / 2, 2210 2211 even = odd + this._items.length, 2212 2213 map = function(index) { return index % 2 === 0 ? even + index / 2 : odd - (index + 1) / 2 }; 2214 2215 2216 2217 if (position === undefined) { 2218 2219 return $.map(this._clones, function(v, i) { return map(i) }); 2220 2221 } 2222 2223 2224 2225 return $.map(this._clones, function(v, i) { return v === position ? map(i) : null }); 2226 2227 }; 2228 2229 2230 2231 /** 2232 2233 * Sets the current animation speed. 2234 2235 * @public 2236 2237 * @param {Number} [speed] - The animation speed in milliseconds or nothing to leave it unchanged. 2238 2239 * @returns {Number} - The current animation speed in milliseconds. 2240 2241 */ 2242 2243 Owl.prototype.speed = function(speed) { 2244 2245 if (speed !== undefined) { 2246 2247 this._speed = speed; 2248 2249 } 2250 2251 2252 2253 return this._speed; 2254 2255 }; 2256 2257 2258 2259 /** 2260 2261 * Gets the coordinate of an item. 2262 2263 * @todo The name of this method is missleanding. 2264 2265 * @public 2266 2267 * @param {Number} position - The absolute position of the item within `minimum()` and `maximum()`. 2268 2269 * @returns {Number|Array.<Number>} - The coordinate of the item in pixel or all coordinates. 2270 2271 */ 2272 2273 Owl.prototype.coordinates = function(position) { 2274 2275 var multiplier = 1, 2276 2277 newPosition = position - 1, 2278 2279 coordinate; 2280 2281 2282 2283 if (position === undefined) { 2284 2285 return $.map(this._coordinates, $.proxy(function(coordinate, index) { 2286 2287 return this.coordinates(index); 2288 2289 }, this)); 2290 2291 } 2292 2293 2294 2295 if (this.settings.center) { 2296 2297 if (this.settings.rtl) { 2298 2299 multiplier = -1; 2300 2301 newPosition = position + 1; 2302 2303 } 2304 2305 2306 2307 coordinate = this._coordinates[position]; 2308 2309 coordinate += (this.width() - coordinate + (this._coordinates[newPosition] || 0)) / 2 * multiplier; 2310 2311 } else { 2312 2313 coordinate = this._coordinates[newPosition] || 0; 2314 2315 } 2316 2317 2318 2319 coordinate = Math.ceil(coordinate); 2320 2321 2322 2323 return coordinate; 2324 2325 }; 2326 2327 2328 2329 /** 2330 2331 * Calculates the speed for a translation. 2332 2333 * @protected 2334 2335 * @param {Number} from - The absolute position of the start item. 2336 2337 * @param {Number} to - The absolute position of the target item. 2338 2339 * @param {Number} [factor=undefined] - The time factor in milliseconds. 2340 2341 * @returns {Number} - The time in milliseconds for the translation. 2342 2343 */ 2344 2345 Owl.prototype.duration = function(from, to, factor) { 2346 2347 if (factor === 0) { 2348 2349 return 0; 2350 2351 } 2352 2353 2354 2355 return Math.min(Math.max(Math.abs(to - from), 1), 6) * Math.abs((factor || this.settings.smartSpeed)); 2356 2357 }; 2358 2359 2360 2361 /** 2362 2363 * Slides to the specified item. 2364 2365 * @public 2366 2367 * @param {Number} position - The position of the item. 2368 2369 * @param {Number} [speed] - The time in milliseconds for the transition. 2370 2371 */ 2372 2373 Owl.prototype.to = function(position, speed) { 2374 2375 var current = this.current(), 2376 2377 revert = null, 2378 2379 distance = position - this.relative(current), 2380 2381 direction = (distance > 0) - (distance < 0), 2382 2383 items = this._items.length, 2384 2385 minimum = this.minimum(), 2386 2387 maximum = this.maximum(); 2388 2389 2390 2391 if (this.settings.loop) { 2392 2393 if (!this.settings.rewind && Math.abs(distance) > items / 2) { 2394 2395 distance += direction * -1 * items; 2396 2397 } 2398 2399 2400 2401 position = current + distance; 2402 2403 revert = ((position - minimum) % items + items) % items + minimum; 2404 2405 2406 2407 if (revert !== position && revert - distance <= maximum && revert - distance > 0) { 2408 2409 current = revert - distance; 2410 2411 position = revert; 2412 2413 this.reset(current); 2414 2415 } 2416 2417 } else if (this.settings.rewind) { 2418 2419 maximum += 1; 2420 2421 position = (position % maximum + maximum) % maximum; 2422 2423 } else { 2424 2425 position = Math.max(minimum, Math.min(maximum, position)); 2426 2427 } 2428 2429 2430 2431 this.speed(this.duration(current, position, speed)); 2432 2433 this.current(position); 2434 2435 2436 2437 if (this.$element.is(':visible')) { 2438 2439 this.update(); 2440 2441 } 2442 2443 }; 2444 2445 2446 2447 /** 2448 2449 * Slides to the next item. 2450 2451 * @public 2452 2453 * @param {Number} [speed] - The time in milliseconds for the transition. 2454 2455 */ 2456 2457 Owl.prototype.next = function(speed) { 2458 2459 speed = speed || false; 2460 2461 this.to(this.relative(this.current()) + 1, speed); 2462 2463 }; 2464 2465 2466 2467 /** 2468 2469 * Slides to the previous item. 2470 2471 * @public 2472 2473 * @param {Number} [speed] - The time in milliseconds for the transition. 2474 2475 */ 2476 2477 Owl.prototype.prev = function(speed) { 2478 2479 speed = speed || false; 2480 2481 this.to(this.relative(this.current()) - 1, speed); 2482 2483 }; 2484 2485 2486 2487 /** 2488 2489 * Handles the end of an animation. 2490 2491 * @protected 2492 2493 * @param {Event} event - The event arguments. 2494 2495 */ 2496 2497 Owl.prototype.onTransitionEnd = function(event) { 2498 2499 2500 2501 // if css2 animation then event object is undefined 2502 2503 if (event !== undefined) { 2504 2505 event.stopPropagation(); 2506 2507 2508 2509 // Catch only owl-stage transitionEnd event 2510 2511 if ((event.target || event.srcElement || event.originalTarget) !== this.$stage.get(0)) { 2512 2513 return false; 2514 2515 } 2516 2517 } 2518 2519 2520 2521 this.leave('animating'); 2522 2523 this.trigger('translated'); 2524 2525 }; 2526 2527 2528 2529 /** 2530 2531 * Gets viewport width. 2532 2533 * @protected 2534 2535 * @return {Number} - The width in pixel. 2536 2537 */ 2538 2539 Owl.prototype.viewport = function() { 2540 2541 var width; 2542 2543 if (this.options.responsiveBaseElement !== window) { 2544 2545 width = $(this.options.responsiveBaseElement).width(); 2546 2547 } else if (window.innerWidth) { 2548 2549 width = window.innerWidth; 2550 2551 } else if (document.documentElement && document.documentElement.clientWidth) { 2552 2553 width = document.documentElement.clientWidth; 2554 2555 } else { 2556 2557 console.warn('Can not detect viewport width.'); 2558 2559 } 2560 2561 return width; 2562 2563 }; 2564 2565 2566 2567 /** 2568 2569 * Replaces the current content. 2570 2571 * @public 2572 2573 * @param {HTMLElement|jQuery|String} content - The new content. 2574 2575 */ 2576 2577 Owl.prototype.replace = function(content) { 2578 2579 this.$stage.empty(); 2580 2581 this._items = []; 2582 2583 2584 2585 if (content) { 2586 2587 content = (content instanceof jQuery) ? content : $(content); 2588 2589 } 2590 2591 2592 2593 if (this.settings.nestedItemSelector) { 2594 2595 content = content.find('.' + this.settings.nestedItemSelector); 2596 2597 } 2598 2599 2600 2601 content.filter(function() { 2602 2603 return this.nodeType === 1; 2604 2605 }).each($.proxy(function(index, item) { 2606 2607 item = this.prepare(item); 2608 2609 this.$stage.append(item); 2610 2611 this._items.push(item); 2612 2613 this._mergers.push(item.find('[data-merge]').addBack('[data-merge]').attr('data-merge') * 1 || 1); 2614 2615 }, this)); 2616 2617 2618 2619 this.reset(this.isNumeric(this.settings.startPosition) ? this.settings.startPosition : 0); 2620 2621 2622 2623 this.invalidate('items'); 2624 2625 }; 2626 2627 2628 2629 /** 2630 2631 * Adds an item. 2632 2633 * @todo Use `item` instead of `content` for the event arguments. 2634 2635 * @public 2636 2637 * @param {HTMLElement|jQuery|String} content - The item content to add. 2638 2639 * @param {Number} [position] - The relative position at which to insert the item otherwise the item will be added to the end. 2640 2641 */ 2642 2643 Owl.prototype.add = function(content, position) { 2644 2645 var current = this.relative(this._current); 2646 2647 2648 2649 position = position === undefined ? this._items.length : this.normalize(position, true); 2650 2651 content = content instanceof jQuery ? content : $(content); 2652 2653 2654 2655 this.trigger('add', { content: content, position: position }); 2656 2657 2658 2659 content = this.prepare(content); 2660 2661 2662 2663 if (this._items.length === 0 || position === this._items.length) { 2664 2665 this._items.length === 0 && this.$stage.append(content); 2666 2667 this._items.length !== 0 && this._items[position - 1].after(content); 2668 2669 this._items.push(content); 2670 2671 this._mergers.push(content.find('[data-merge]').addBack('[data-merge]').attr('data-merge') * 1 || 1); 2672 2673 } else { 2674 2675 this._items[position].before(content); 2676 2677 this._items.splice(position, 0, content); 2678 2679 this._mergers.splice(position, 0, content.find('[data-merge]').addBack('[data-merge]').attr('data-merge') * 1 || 1); 2680 2681 } 2682 2683 2684 2685 this._items[current] && this.reset(this._items[current].index()); 2686 2687 2688 2689 this.invalidate('items'); 2690 2691 2692 2693 this.trigger('added', { content: content, position: position }); 2694 2695 }; 2696 2697 2698 2699 /** 2700 2701 * Removes an item by its position. 2702 2703 * @todo Use `item` instead of `content` for the event arguments. 2704 2705 * @public 2706 2707 * @param {Number} position - The relative position of the item to remove. 2708 2709 */ 2710 2711 Owl.prototype.remove = function(position) { 2712 2713 position = this.normalize(position, true); 2714 2715 2716 2717 if (position === undefined) { 2718 2719 return; 2720 2721 } 2722 2723 2724
vendor: 4,331 bytes, lines 2725-2981
2725 this.trigger('remove', { content: this._items[position], position: position }); 2726 2727 2728 2729 this._items[position].remove(); 2730 2731 this._items.splice(position, 1); 2732 2733 this._mergers.splice(position, 1); 2734 2735 2736 2737 this.invalidate('items'); 2738 2739 2740 2741 this.trigger('removed', { content: null, position: position }); 2742 2743 }; 2744 2745 2746 2747 /** 2748 2749 * Preloads images with auto width. 2750 2751 * @todo Replace by a more generic approach 2752 2753 * @protected 2754 2755 */ 2756 2757 Owl.prototype.preloadAutoWidthImages = function(images) { 2758 2759 images.each($.proxy(function(i, element) { 2760 2761 this.enter('pre-loading'); 2762 2763 element = $(element); 2764 2765 $(new Image()).one('load', $.proxy(function(e) { 2766 2767 element.attr('src', e.target.src); 2768 2769 element.css('opacity', 1); 2770 2771 this.leave('pre-loading'); 2772 2773 !this.is('pre-loading') && !this.is('initializing') && this.refresh(); 2774 2775 }, this)).attr('src', element.attr('src') || element.attr('data-src') || element.attr('data-src-retina')); 2776 2777 }, this)); 2778 2779 }; 2780 2781 2782 2783 /** 2784 2785 * Destroys the carousel. 2786 2787 * @public 2788 2789 */ 2790 2791 Owl.prototype.destroy = function() { 2792 2793 2794 2795 this.$element.off('.owl.core'); 2796 2797 this.$stage.off('.owl.core'); 2798 2799 $(document).off('.owl.core'); 2800 2801 2802 2803 if (this.settings.responsive !== false) { 2804 2805 window.clearTimeout(this.resizeTimer); 2806 2807 this.off(window, 'resize', this._handlers.onThrottledResize); 2808 2809 } 2810 2811 2812 2813 for (var i in this._plugins) { 2814 2815 this._plugins[i].destroy(); 2816 2817 } 2818 2819 2820 2821 this.$stage.children('.cloned').remove(); 2822 2823 2824 2825 this.$stage.unwrap(); 2826 2827 this.$stage.children().contents().unwrap(); 2828 2829 this.$stage.children().unwrap(); 2830 2831 2832 2833 this.$element 2834 2835 .removeClass(this.options.refreshClass) 2836 2837 .removeClass(this.options.loadingClass) 2838 2839 .removeClass(this.options.loadedClass) 2840 2841 .removeClass(this.options.rtlClass) 2842 2843 .removeClass(this.options.dragClass) 2844 2845 .removeClass(this.options.grabClass) 2846 2847 .attr('class', this.$element.attr('class').replace(new RegExp(this.options.responsiveClass + '-\\S+\\s', 'g'), '')) 2848 2849 .removeData('owl.carousel'); 2850 2851 }; 2852 2853 2854 2855 /** 2856 2857 * Operators to calculate right-to-left and left-to-right. 2858 2859 * @protected 2860 2861 * @param {Number} [a] - The left side operand. 2862 2863 * @param {String} [o] - The operator. 2864 2865 * @param {Number} [b] - The right side operand. 2866 2867 */ 2868 2869 Owl.prototype.op = function(a, o, b) { 2870 2871 var rtl = this.settings.rtl; 2872 2873 switch (o) { 2874 2875 case '<': 2876 2877 return rtl ? a > b : a < b; 2878 2879 case '>': 2880 2881 return rtl ? a < b : a > b; 2882 2883 case '>=': 2884 2885 return rtl ? a <= b : a >= b; 2886 2887 case '<=': 2888 2889 return rtl ? a >= b : a <= b; 2890 2891 default: 2892 2893 break; 2894 2895 } 2896 2897 }; 2898 2899 2900 2901 /** 2902 2903 * Attaches to an internal event. 2904 2905 * @protected 2906 2907 * @param {HTMLElement} element - The event source. 2908 2909 * @param {String} event - The event name. 2910 2911 * @param {Function} listener - The event handler to attach. 2912 2913 * @param {Boolean} capture - Wether the event should be handled at the capturing phase or not. 2914 2915 */ 2916 2917 Owl.prototype.on = function(element, event, listener, capture) { 2918 2919 if (element.addEventListener) { 2920 2921 element.addEventListener(event, listener, capture); 2922 2923 } else if (element.attachEvent) { 2924 2925 element.attachEvent('on' + event, listener); 2926 2927 } 2928 2929 }; 2930 2931 2932 2933 /** 2934 2935 * Detaches from an internal event. 2936 2937 * @protected 2938 2939 * @param {HTMLElement} element - The event source. 2940 2941 * @param {String} event - The event name. 2942 2943 * @param {Function} listener - The attached event handler to detach. 2944 2945 * @param {Boolean} capture - Wether the attached event handler was registered as a capturing listener or not. 2946 2947 */ 2948 2949 Owl.prototype.off = function(element, event, listener, capture) { 2950 2951 if (element.removeEventListener) { 2952 2953 element.removeEventListener(event, listener, capture); 2954 2955 } else if (element.detachEvent) { 2956 2957 element.detachEvent('on' + event, listener); 2958 2959 } 2960 2961 }; 2962 2963 2964 2965 /** 2966 2967 * Triggers a public event. 2968 2969 * @todo Remove `status`, `relatedTarget` should be used instead. 2970 2971 * @protected 2972 2973 * @param {String} name - The event name. 2974 2975 * @param {*} [data=null] - The event data. 2976 2977 * @param {String} [namespace=carousel] - The event namespace. 2978 2979 * @param {String} [state] - The state which is associated with the event. 2980 2981 * @param {Boolean}
vendor: 43,147 bytes, lines 2981-5978
2981 [enter=false] - Indicates if the call enters the specified state or not. 2982 2983 * @returns {Event} - The event arguments. 2984 2985 */ 2986 2987 Owl.prototype.trigger = function(name, data, namespace, state, enter) { 2988 2989 var status = { 2990 2991 item: { count: this._items.length, index: this.current() } 2992 2993 }, handler = $.camelCase( 2994 2995 $.grep([ 'on', name, namespace ], function(v) { return v }) 2996 2997 .join('-').toLowerCase() 2998 2999 ), event = $.Event( 3000 3001 [ name, 'owl', namespace || 'carousel' ].join('.').toLowerCase(), 3002 3003 $.extend({ relatedTarget: this }, status, data) 3004 3005 ); 3006 3007 3008 3009 if (!this._supress[name]) { 3010 3011 $.each(this._plugins, function(name, plugin) { 3012 3013 if (plugin.onTrigger) { 3014 3015 plugin.onTrigger(event); 3016 3017 } 3018 3019 }); 3020 3021 3022 3023 this.register({ type: Owl.Type.Event, name: name }); 3024 3025 this.$element.trigger(event); 3026 3027 3028 3029 if (this.settings && typeof this.settings[handler] === 'function') { 3030 3031 this.settings[handler].call(this, event); 3032 3033 } 3034 3035 } 3036 3037 3038 3039 return event; 3040 3041 }; 3042 3043 3044 3045 /** 3046 3047 * Enters a state. 3048 3049 * @param name - The state name. 3050 3051 */ 3052 3053 Owl.prototype.enter = function(name) { 3054 3055 $.each([ name ].concat(this._states.tags[name] || []), $.proxy(function(i, name) { 3056 3057 if (this._states.current[name] === undefined) { 3058 3059 this._states.current[name] = 0; 3060 3061 } 3062 3063 3064 3065 this._states.current[name]++; 3066 3067 }, this)); 3068 3069 }; 3070 3071 3072 3073 /** 3074 3075 * Leaves a state. 3076 3077 * @param name - The state name. 3078 3079 */ 3080 3081 Owl.prototype.leave = function(name) { 3082 3083 $.each([ name ].concat(this._states.tags[name] || []), $.proxy(function(i, name) { 3084 3085 this._states.current[name]--; 3086 3087 }, this)); 3088 3089 }; 3090 3091 3092 3093 /** 3094 3095 * Registers an event or state. 3096 3097 * @public 3098 3099 * @param {Object} object - The event or state to register. 3100 3101 */ 3102 3103 Owl.prototype.register = function(object) { 3104 3105 if (object.type === Owl.Type.Event) { 3106 3107 if (!$.event.special[object.name]) { 3108 3109 $.event.special[object.name] = {}; 3110 3111 } 3112 3113 3114 3115 if (!$.event.special[object.name].owl) { 3116 3117 var _default = $.event.special[object.name]._default; 3118 3119 $.event.special[object.name]._default = function(e) { 3120 3121 if (_default && _default.apply && (!e.namespace || e.namespace.indexOf('owl') === -1)) { 3122 3123 return _default.apply(this, arguments); 3124 3125 } 3126 3127 return e.namespace && e.namespace.indexOf('owl') > -1; 3128 3129 }; 3130 3131 $.event.special[object.name].owl = true; 3132 3133 } 3134 3135 } else if (object.type === Owl.Type.State) { 3136 3137 if (!this._states.tags[object.name]) { 3138 3139 this._states.tags[object.name] = object.tags; 3140 3141 } else { 3142 3143 this._states.tags[object.name] = this._states.tags[object.name].concat(object.tags); 3144 3145 } 3146 3147 3148 3149 this._states.tags[object.name] = $.grep(this._states.tags[object.name], $.proxy(function(tag, i) { 3150 3151 return $.inArray(tag, this._states.tags[object.name]) === i; 3152 3153 }, this)); 3154 3155 } 3156 3157 }; 3158 3159 3160 3161 /** 3162 3163 * Suppresses events. 3164 3165 * @protected 3166 3167 * @param {Array.<String>} events - The events to suppress. 3168 3169 */ 3170 3171 Owl.prototype.suppress = function(events) { 3172 3173 $.each(events, $.proxy(function(index, event) { 3174 3175 this._supress[event] = true; 3176 3177 }, this)); 3178 3179 }; 3180 3181 3182 3183 /** 3184 3185 * Releases suppressed events. 3186 3187 * @protected 3188 3189 * @param {Array.<String>} events - The events to release. 3190 3191 */ 3192 3193 Owl.prototype.release = function(events) { 3194 3195 $.each(events, $.proxy(function(index, event) { 3196 3197 delete this._supress[event]; 3198 3199 }, this)); 3200 3201 }; 3202 3203 3204 3205 /** 3206 3207 * Gets unified pointer coordinates from event. 3208 3209 * @todo #261 3210 3211 * @protected 3212 3213 * @param {Event} - The `mousedown` or `touchstart` event. 3214 3215 * @returns {Object} - Contains `x` and `y` coordinates of current pointer position. 3216 3217 */ 3218 3219 Owl.prototype.pointer = function(event) { 3220 3221 var result = { x: null, y: null }; 3222 3223 3224 3225 event = event.originalEvent || event || window.event; 3226 3227 3228 3229 event = event.touches && event.touches.length ? 3230 3231 event.touches[0] : event.changedTouches && event.changedTouches.length ? 3232 3233 event.changedTouches[0] : event; 3234 3235 3236 3237 if (event.pageX) { 3238 3239 result.x = event.pageX; 3240 3241 result.y = event.pageY; 3242 3243 } else { 3244 3245 result.x = event.clientX; 3246 3247 result.y = event.clientY; 3248 3249 } 3250 3251 3252 3253 return result; 3254 3255 }; 3256 3257 3258 3259 /** 3260 3261 * Determines if the input is a Number or something that can be coerced to a Number 3262 3263 * @protected 3264 3265 * @param {Number|String|Object|Array|Boolean|RegExp|Function|Symbol} - The input to be tested 3266 3267 * @returns {Boolean} - An indication if the input is a Number or can be coerced to a Number 3268 3269 */ 3270 3271 Owl.prototype.isNumeric = function(number) { 3272 3273 return !isNaN(parseFloat(number)); 3274 3275 }; 3276 3277 3278 3279 /** 3280 3281 * Gets the difference of two vectors. 3282 3283 * @todo #261 3284 3285 * @protected 3286 3287 * @param {Object} - The first vector. 3288 3289 * @param {Object} - The second vector. 3290 3291 * @returns {Object} - The difference. 3292 3293 */ 3294 3295 Owl.prototype.difference = function(first, second) { 3296 3297 return { 3298 3299 x: first.x - second.x, 3300 3301 y: first.y - second.y 3302 3303 }; 3304 3305 }; 3306 3307 3308 3309 /** 3310 3311 * The jQuery Plugin for the Owl Carousel 3312 3313 * @todo Navigation plugin `next` and `prev` 3314 3315 * @public 3316 3317 */ 3318 3319 $.fn.owlCarousel = function(option) { 3320 3321 var args = Array.prototype.slice.call(arguments, 1); 3322 3323 3324 3325 return this.each(function() { 3326 3327 var $this = $(this), 3328 3329 data = $this.data('owl.carousel'); 3330 3331 3332 3333 if (!data) { 3334 3335 data = new Owl(this, typeof option == 'object' && option); 3336 3337 $this.data('owl.carousel', data); 3338 3339 3340 3341 $.each([ 3342 3343 'next', 'prev', 'to', 'destroy', 'refresh', 'replace', 'add', 'remove' 3344 3345 ], function(i, event) { 3346 3347 data.register({ type: Owl.Type.Event, name: event }); 3348 3349 data.$element.on(event + '.owl.carousel.core', $.proxy(function(e) { 3350 3351 if (e.namespace && e.relatedTarget !== this) { 3352 3353 this.suppress([ event ]); 3354 3355 data[event].apply(this, [].slice.call(arguments, 1)); 3356 3357 this.release([ event ]); 3358 3359 } 3360 3361 }, data)); 3362 3363 }); 3364 3365 } 3366 3367 3368 3369 if (typeof option == 'string' && option.charAt(0) !== '_') { 3370 3371 data[option].apply(data, args); 3372 3373 } 3374 3375 }); 3376 3377 }; 3378 3379 3380 3381 /** 3382 3383 * The constructor for the jQuery Plugin 3384 3385 * @public 3386 3387 */ 3388 3389 $.fn.owlCarousel.Constructor = Owl; 3390 3391 3392 3393})(window.Zepto || window.jQuery, window, document); 3394 3395 3396 3397/** 3398 3399 * AutoRefresh Plugin 3400 3401 * @version 2.1.0 3402 3403 * @author Artus Kolanowski 3404 3405 * @author David Deutsch 3406 3407 * @license The MIT License (MIT) 3408 3409 */ 3410 3411;(function($, window, document, undefined) { 3412 3413 3414 3415 /** 3416 3417 * Creates the auto refresh plugin. 3418 3419 * @class The Auto Refresh Plugin 3420 3421 * @param {Owl} carousel - The Owl Carousel 3422 3423 */ 3424 3425 var AutoRefresh = function(carousel) { 3426 3427 /** 3428 3429 * Reference to the core. 3430 3431 * @protected 3432 3433 * @type {Owl} 3434 3435 */ 3436 3437 this._core = carousel; 3438 3439 3440 3441 /** 3442 3443 * Refresh interval. 3444 3445 * @protected 3446 3447 * @type {number} 3448 3449 */ 3450 3451 this._interval = null; 3452 3453 3454 3455 /** 3456 3457 * Whether the element is currently visible or not. 3458 3459 * @protected 3460 3461 * @type {Boolean} 3462 3463 */ 3464 3465 this._visible = null; 3466 3467 3468 3469 /** 3470 3471 * All event handlers. 3472 3473 * @protected 3474 3475 * @type {Object} 3476 3477 */ 3478 3479 this._handlers = { 3480 3481 'initialized.owl.carousel': $.proxy(function(e) { 3482 3483 if (e.namespace && this._core.settings.autoRefresh) { 3484 3485 this.watch(); 3486 3487 } 3488 3489 }, this) 3490 3491 }; 3492 3493 3494 3495 // set default options 3496 3497 this._core.options = $.extend({}, AutoRefresh.Defaults, this._core.options); 3498 3499 3500 3501 // register event handlers 3502 3503 this._core.$element.on(this._handlers); 3504 3505 }; 3506 3507 3508 3509 /** 3510 3511 * Default options. 3512 3513 * @public 3514 3515 */ 3516 3517 AutoRefresh.Defaults = { 3518 3519 autoRefresh: true, 3520 3521 autoRefreshInterval: 500 3522 3523 }; 3524 3525 3526 3527 /** 3528 3529 * Watches the element. 3530 3531 */ 3532 3533 AutoRefresh.prototype.watch = function() { 3534 3535 if (this._interval) { 3536 3537 return; 3538 3539 } 3540 3541 3542 3543 this._visible = this._core.$element.is(':visible'); 3544 3545 this._interval = window.setInterval($.proxy(this.refresh, this), this._core.settings.autoRefreshInterval); 3546 3547 }; 3548 3549 3550 3551 /** 3552 3553 * Refreshes the element. 3554 3555 */ 3556 3557 AutoRefresh.prototype.refresh = function() { 3558 3559 if (this._core.$element.is(':visible') === this._visible) { 3560 3561 return; 3562 3563 } 3564 3565 3566 3567 this._visible = !this._visible; 3568 3569 3570 3571 this._core.$element.toggleClass('owl-hidden', !this._visible); 3572 3573 3574 3575 this._visible && (this._core.invalidate('width') && this._core.refresh()); 3576 3577 }; 3578 3579 3580 3581 /** 3582 3583 * Destroys the plugin. 3584 3585 */ 3586 3587 AutoRefresh.prototype.destroy = function() { 3588 3589 var handler, property; 3590 3591 3592 3593 window.clearInterval(this._interval); 3594 3595 3596 3597 for (handler in this._handlers) { 3598 3599 this._core.$element.off(handler, this._handlers[handler]); 3600 3601 } 3602 3603 for (property in Object.getOwnPropertyNames(this)) { 3604 3605 typeof this[property] != 'function' && (this[property] = null); 3606 3607 } 3608 3609 }; 3610 3611 3612 3613 $.fn.owlCarousel.Constructor.Plugins.AutoRefresh = AutoRefresh; 3614 3615 3616 3617})(window.Zepto || window.jQuery, window, document); 3618 3619 3620 3621/** 3622 3623 * Lazy Plugin 3624 3625 * @version 2.1.0 3626 3627 * @author Bartosz Wojciechowski 3628 3629 * @author David Deutsch 3630 3631 * @license The MIT License (MIT) 3632 3633 */ 3634 3635;(function($, window, document, undefined) { 3636 3637 3638 3639 /** 3640 3641 * Creates the lazy plugin. 3642 3643 * @class The Lazy Plugin 3644 3645 * @param {Owl} carousel - The Owl Carousel 3646 3647 */ 3648 3649 var Lazy = function(carousel) { 3650 3651 3652 3653 /** 3654 3655 * Reference to the core. 3656 3657 * @protected 3658 3659 * @type {Owl} 3660 3661 */ 3662 3663 this._core = carousel; 3664 3665 3666 3667 /** 3668 3669 * Already loaded items. 3670 3671 * @protected 3672 3673 * @type {Array.<jQuery>} 3674 3675 */ 3676 3677 this._loaded = []; 3678 3679 3680 3681 /** 3682 3683 * Event handlers. 3684 3685 * @protected 3686 3687 * @type {Object} 3688 3689 */ 3690 3691 this._handlers = { 3692 3693 'initialized.owl.carousel change.owl.carousel resized.owl.carousel': $.proxy(function(e) { 3694 3695 if (!e.namespace) { 3696 3697 return; 3698 3699 } 3700 3701 3702 3703 if (!this._core.settings || !this._core.settings.lazyLoad) { 3704 3705 return; 3706 3707 } 3708 3709 3710 3711 if ((e.property && e.property.name == 'position') || e.type == 'initialized') { 3712 3713 var settings = this._core.settings, 3714 3715 n = (settings.center && Math.ceil(settings.items / 2) || settings.items), 3716 3717 i = ((settings.center && n * -1) || 0), 3718 3719 position = (e.property && e.property.value !== undefined ? e.property.value : this._core.current()) + i, 3720 3721 clones = this._core.clones().length, 3722 3723 load = $.proxy(function(i, v) { this.load(v) }, this); 3724 3725 3726 3727 while (i++ < n) { 3728 3729 this.load(clones / 2 + this._core.relative(position)); 3730 3731 clones && $.each(this._core.clones(this._core.relative(position)), load); 3732 3733 position++; 3734 3735 } 3736 3737 } 3738 3739 }, this) 3740 3741 }; 3742 3743 3744 3745 // set the default options 3746 3747 this._core.options = $.extend({}, Lazy.Defaults, this._core.options); 3748 3749 3750 3751 // register event handler 3752 3753 this._core.$element.on(this._handlers); 3754 3755 }; 3756 3757 3758 3759 /** 3760 3761 * Default options. 3762 3763 * @public 3764 3765 */ 3766 3767 Lazy.Defaults = { 3768 3769 lazyLoad: false 3770 3771 }; 3772 3773 3774 3775 /** 3776 3777 * Loads all resources of an item at the specified position. 3778 3779 * @param {Number} position - The absolute position of the item. 3780 3781 * @protected 3782 3783 */ 3784 3785 Lazy.prototype.load = function(position) { 3786 3787 var $item = this._core.$stage.children().eq(position), 3788 3789 $elements = $item && $item.find('.owl-lazy'); 3790 3791 3792 3793 if (!$elements || $.inArray($item.get(0), this._loaded) > -1) { 3794 3795 return; 3796 3797 } 3798 3799 3800 3801 $elements.each($.proxy(function(index, element) { 3802 3803 var $element = $(element), image, 3804 3805 url = (window.devicePixelRatio > 1 && $element.attr('data-src-retina')) || $element.attr('data-src'); 3806 3807 3808 3809 this._core.trigger('load', { element: $element, url: url }, 'lazy'); 3810 3811 3812 3813 if ($element.is('img')) { 3814 3815 $element.one('load.owl.lazy', $.proxy(function() { 3816 3817 $element.css('opacity', 1); 3818 3819 this._core.trigger('loaded', { element: $element, url: url }, 'lazy'); 3820 3821 }, this)).attr('src', url); 3822 3823 } else { 3824 3825 image = new Image(); 3826 3827 image.onload = $.proxy(function() { 3828 3829 $element.css({ 3830 3831 'background-image': 'url("' + url + '")', 3832 3833 'opacity': '1' 3834 3835 }); 3836 3837 this._core.trigger('loaded', { element: $element, url: url }, 'lazy'); 3838 3839 }, this); 3840 3841 image.src = url; 3842 3843 } 3844 3845 }, this)); 3846 3847 3848 3849 this._loaded.push($item.get(0)); 3850 3851 }; 3852 3853 3854 3855 /** 3856 3857 * Destroys the plugin. 3858 3859 * @public 3860 3861 */ 3862 3863 Lazy.prototype.destroy = function() { 3864 3865 var handler, property; 3866 3867 3868 3869 for (handler in this.handlers) { 3870 3871 this._core.$element.off(handler, this.handlers[handler]); 3872 3873 } 3874 3875 for (property in Object.getOwnPropertyNames(this)) { 3876 3877 typeof this[property] != 'function' && (this[property] = null); 3878 3879 } 3880 3881 }; 3882 3883 3884 3885 $.fn.owlCarousel.Constructor.Plugins.Lazy = Lazy; 3886 3887 3888 3889})(window.Zepto || window.jQuery, window, document); 3890 3891 3892 3893/** 3894 3895 * AutoHeight Plugin 3896 3897 * @version 2.1.0 3898 3899 * @author Bartosz Wojciechowski 3900 3901 * @author David Deutsch 3902 3903 * @license The MIT License (MIT) 3904 3905 */ 3906 3907;(function($, window, document, undefined) { 3908 3909 3910 3911 /** 3912 3913 * Creates the auto height plugin. 3914 3915 * @class The Auto Height Plugin 3916 3917 * @param {Owl} carousel - The Owl Carousel 3918 3919 */ 3920 3921 var AutoHeight = function(carousel) { 3922 3923 /** 3924 3925 * Reference to the core. 3926 3927 * @protected 3928 3929 * @type {Owl} 3930 3931 */ 3932 3933 this._core = carousel; 3934 3935 3936 3937 /** 3938 3939 * All event handlers. 3940 3941 * @protected 3942 3943 * @type {Object} 3944 3945 */ 3946 3947 this._handlers = { 3948 3949 'initialized.owl.carousel refreshed.owl.carousel': $.proxy(function(e) { 3950 3951 if (e.namespace && this._core.settings.autoHeight) { 3952 3953 this.update(); 3954 3955 } 3956 3957 }, this), 3958 3959 'changed.owl.carousel': $.proxy(function(e) { 3960 3961 if (e.namespace && this._core.settings.autoHeight && e.property.name == 'position'){ 3962 3963 this.update(); 3964 3965 } 3966 3967 }, this), 3968 3969 'loaded.owl.lazy': $.proxy(function(e) { 3970 3971 if (e.namespace && this._core.settings.autoHeight 3972 3973 && e.element.closest('.' + this._core.settings.itemClass).index() === this._core.current()) { 3974 3975 this.update(); 3976 3977 } 3978 3979 }, this) 3980 3981 }; 3982 3983 3984 3985 // set default options 3986 3987 this._core.options = $.extend({}, AutoHeight.Defaults, this._core.options); 3988 3989 3990 3991 // register event handlers 3992 3993 this._core.$element.on(this._handlers); 3994 3995 }; 3996 3997 3998 3999 /** 4000 4001 * Default options. 4002 4003 * @public 4004 4005 */ 4006 4007 AutoHeight.Defaults = { 4008 4009 autoHeight: false, 4010 4011 autoHeightClass: 'owl-height' 4012 4013 }; 4014 4015 4016 4017 /** 4018 4019 * Updates the view. 4020 4021 */ 4022 4023 AutoHeight.prototype.update = function() { 4024 4025 var start = this._core._current, 4026 4027 end = start + this._core.settings.items, 4028 4029 visible = this._core.$stage.children().toArray().slice(start, end), 4030 4031 heights = [], 4032 4033 maxheight = 0; 4034 4035 4036 4037 $.each(visible, function(index, item) { 4038 4039 heights.push($(item).height()); 4040 4041 }); 4042 4043 4044 4045 maxheight = Math.max.apply(null, heights); 4046 4047 4048 4049 this._core.$stage.parent() 4050 4051 .height(maxheight) 4052 4053 .addClass(this._core.settings.autoHeightClass); 4054 4055 }; 4056 4057 4058 4059 AutoHeight.prototype.destroy = function() { 4060 4061 var handler, property; 4062 4063 4064 4065 for (handler in this._handlers) { 4066 4067 this._core.$element.off(handler, this._handlers[handler]); 4068 4069 } 4070 4071 for (property in Object.getOwnPropertyNames(this)) { 4072 4073 typeof this[property] != 'function' && (this[property] = null); 4074 4075 } 4076 4077 }; 4078 4079 4080 4081 $.fn.owlCarousel.Constructor.Plugins.AutoHeight = AutoHeight; 4082 4083 4084 4085})(window.Zepto || window.jQuery, window, document); 4086 4087 4088 4089/** 4090 4091 * Video Plugin 4092 4093 * @version 2.1.0 4094 4095 * @author Bartosz Wojciechowski 4096 4097 * @author David Deutsch 4098 4099 * @license The MIT License (MIT) 4100 4101 */ 4102 4103;(function($, window, document, undefined) { 4104 4105 4106 4107 /** 4108 4109 * Creates the video plugin. 4110 4111 * @class The Video Plugin 4112 4113 * @param {Owl} carousel - The Owl Carousel 4114 4115 */ 4116 4117 var Video = function(carousel) { 4118 4119 /** 4120 4121 * Reference to the core. 4122 4123 * @protected 4124 4125 * @type {Owl} 4126 4127 */ 4128 4129 this._core = carousel; 4130 4131 4132 4133 /** 4134 4135 * Cache all video URLs. 4136 4137 * @protected 4138 4139 * @type {Object} 4140 4141 */ 4142 4143 this._videos = {}; 4144 4145 4146 4147 /** 4148 4149 * Current playing item. 4150 4151 * @protected 4152 4153 * @type {jQuery} 4154 4155 */ 4156 4157 this._playing = null; 4158 4159 4160 4161 /** 4162 4163 * All event handlers. 4164 4165 * @todo The cloned content removale is too late 4166 4167 * @protected 4168 4169 * @type {Object} 4170 4171 */ 4172 4173 this._handlers = { 4174 4175 'initialized.owl.carousel': $.proxy(function(e) { 4176 4177 if (e.namespace) { 4178 4179 this._core.register({ type: 'state', name: 'playing', tags: [ 'interacting' ] }); 4180 4181 } 4182 4183 }, this), 4184 4185 'resize.owl.carousel': $.proxy(function(e) { 4186 4187 if (e.namespace && this._core.settings.video && this.isInFullScreen()) { 4188 4189 e.preventDefault(); 4190 4191 } 4192 4193 }, this), 4194 4195 'refreshed.owl.carousel': $.proxy(function(e) { 4196 4197 if (e.namespace && this._core.is('resizing')) { 4198 4199 this._core.$stage.find('.cloned .owl-video-frame').remove(); 4200 4201 } 4202 4203 }, this), 4204 4205 'changed.owl.carousel': $.proxy(function(e) { 4206 4207 if (e.namespace && e.property.name === 'position' && this._playing) { 4208 4209 this.stop(); 4210 4211 } 4212 4213 }, this), 4214 4215 'prepared.owl.carousel': $.proxy(function(e) { 4216 4217 if (!e.namespace) { 4218 4219 return; 4220 4221 } 4222 4223 4224 4225 var $element = $(e.content).find('.owl-video'); 4226 4227 4228 4229 if ($element.length) { 4230 4231 $element.css('display', 'none'); 4232 4233 this.fetch($element, $(e.content)); 4234 4235 } 4236 4237 }, this) 4238 4239 }; 4240 4241 4242 4243 // set default options 4244 4245 this._core.options = $.extend({}, Video.Defaults, this._core.options); 4246 4247 4248 4249 // register event handlers 4250 4251 this._core.$element.on(this._handlers); 4252 4253 4254 4255 this._core.$element.on('click.owl.video', '.owl-video-play-icon', $.proxy(function(e) { 4256 4257 this.play(e); 4258 4259 }, this)); 4260 4261 }; 4262 4263 4264 4265 /** 4266 4267 * Default options. 4268 4269 * @public 4270 4271 */ 4272 4273 Video.Defaults = { 4274 4275 video: false, 4276 4277 videoHeight: false, 4278 4279 videoWidth: false 4280 4281 }; 4282 4283 4284 4285 /** 4286 4287 * Gets the video ID and the type (YouTube/Vimeo/vzaar only). 4288 4289 * @protected 4290 4291 * @param {jQuery} target - The target containing the video data. 4292 4293 * @param {jQuery} item - The item containing the video. 4294 4295 */ 4296 4297 Video.prototype.fetch = function(target, item) { 4298 4299 var type = (function() { 4300 4301 if (target.attr('data-vimeo-id')) { 4302 4303 return 'vimeo'; 4304 4305 } else if (target.attr('data-vzaar-id')) { 4306 4307 return 'vzaar' 4308 4309 } else { 4310 4311 return 'youtube'; 4312 4313 } 4314 4315 })(), 4316 4317 id = target.attr('data-vimeo-id') || target.attr('data-youtube-id') || target.attr('data-vzaar-id'), 4318 4319 width = target.attr('data-width') || this._core.settings.videoWidth, 4320 4321 height = target.attr('data-height') || this._core.settings.videoHeight, 4322 4323 url = target.attr('href'); 4324 4325 4326 4327 if (url) { 4328 4329 4330 4331 /* 4332 4333 Parses the id's out of the following urls (and probably more): 4334 4335 https://www.youtube.com/watch?v=:id 4336 4337 https://youtu.be/:id 4338 4339 https://vimeo.com/:id 4340 4341 https://vimeo.com/channels/:channel/:id 4342 4343 https://vimeo.com/groups/:group/videos/:id 4344 4345 https://app.vzaar.com/videos/:id 4346 4347 4348 4349 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 4350 4351 */ 4352 4353 4354 4355 id = url.match(/(http:|https:|)\/\/(player.|www.|app.)?(vimeo\.com|youtu(be\.com|\.be|be\.googleapis\.com)|vzaar\.com)\/(video\/|videos\/|embed\/|channels\/.+\/|groups\/.+\/|watch\?v=|v\/)?([A-Za-z0-9._%-]*)(\&\S+)?/); 4356 4357 4358 4359 if (id[3].indexOf('youtu') > -1) { 4360 4361 type = 'youtube'; 4362 4363 } else if (id[3].indexOf('vimeo') > -1) { 4364 4365 type = 'vimeo'; 4366 4367 } else if (id[3].indexOf('vzaar') > -1) { 4368 4369 type = 'vzaar'; 4370 4371 } else { 4372 4373 throw new Error('Video URL not supported.'); 4374 4375 } 4376 4377 id = id[6]; 4378 4379 } else { 4380 4381 throw new Error('Missing video URL.'); 4382 4383 } 4384 4385 4386 4387 this._videos[url] = { 4388 4389 type: type, 4390 4391 id: id, 4392 4393 width: width, 4394 4395 height: height 4396 4397 }; 4398 4399 4400 4401 item.attr('data-video', url); 4402 4403 4404 4405 this.thumbnail(target, this._videos[url]); 4406 4407 }; 4408 4409 4410 4411 /** 4412 4413 * Creates video thumbnail. 4414 4415 * @protected 4416 4417 * @param {jQuery} target - The target containing the video data. 4418 4419 * @param {Object} info - The video info object. 4420 4421 * @see `fetch` 4422 4423 */ 4424 4425 Video.prototype.thumbnail = function(target, video) { 4426 4427 var tnLink, 4428 4429 icon, 4430 4431 path, 4432 4433 dimensions = video.width && video.height ? 'style="width:' + video.width + 'px;height:' + video.height + 'px;"' : '', 4434 4435 customTn = target.find('img'), 4436 4437 srcType = 'src', 4438 4439 lazyClass = '', 4440 4441 settings = this._core.settings, 4442 4443 create = function(path) { 4444 4445 icon = '<div class="owl-video-play-icon"></div>'; 4446 4447 4448 4449 if (settings.lazyLoad) { 4450 4451 tnLink = '<div class="owl-video-tn ' + lazyClass + '" ' + srcType + '="' + path + '"></div>'; 4452 4453 } else { 4454 4455 tnLink = '<div class="owl-video-tn" style="opacity:1;background-image:url(' + path + ')"></div>'; 4456 4457 } 4458 4459 target.after(tnLink); 4460 4461 target.after(icon); 4462 4463 }; 4464 4465 4466 4467 // wrap video content into owl-video-wrapper div 4468 4469 target.wrap('<div class="owl-video-wrapper"' + dimensions + '></div>'); 4470 4471 4472 4473 if (this._core.settings.lazyLoad) { 4474 4475 srcType = 'data-src'; 4476 4477 lazyClass = 'owl-lazy'; 4478 4479 } 4480 4481 4482 4483 // custom thumbnail 4484 4485 if (customTn.length) { 4486 4487 create(customTn.attr(srcType)); 4488 4489 customTn.remove(); 4490 4491 return false; 4492 4493 } 4494 4495 4496 4497 if (video.type === 'youtube') { 4498 4499 path = "//img.youtube.com/vi/" + video.id + "/hqdefault.jpg"; 4500 4501 create(path); 4502 4503 } else if (video.type === 'vimeo') { 4504 4505 $.ajax({ 4506 4507 type: 'GET', 4508 4509 url: '//vimeo.com/api/v2/video/' + video.id + '.json', 4510 4511 jsonp: 'callback', 4512 4513 dataType: 'jsonp', 4514 4515 success: function(data) { 4516 4517 path = data[0].thumbnail_large; 4518 4519 create(path); 4520 4521 } 4522 4523 }); 4524 4525 } else if (video.type === 'vzaar') { 4526 4527 $.ajax({ 4528 4529 type: 'GET', 4530 4531 url: '//vzaar.com/api/videos/' + video.id + '.json', 4532 4533 jsonp: 'callback', 4534 4535 dataType: 'jsonp', 4536 4537 success: function(data) { 4538 4539 path = data.framegrab_url; 4540 4541 create(path); 4542 4543 } 4544 4545 }); 4546 4547 } 4548 4549 }; 4550 4551 4552 4553 /** 4554 4555 * Stops the current video. 4556 4557 * @public 4558 4559 */ 4560 4561 Video.prototype.stop = function() { 4562 4563 this._core.trigger('stop', null, 'video'); 4564 4565 this._playing.find('.owl-video-frame').remove(); 4566 4567 this._playing.removeClass('owl-video-playing'); 4568 4569 this._playing = null; 4570 4571 this._core.leave('playing'); 4572 4573 this._core.trigger('stopped', null, 'video'); 4574 4575 }; 4576 4577 4578 4579 /** 4580 4581 * Starts the current video. 4582 4583 * @public 4584 4585 * @param {Event} event - The event arguments. 4586 4587 */ 4588 4589 Video.prototype.play = function(event) { 4590 4591 var target = $(event.target), 4592 4593 item = target.closest('.' + this._core.settings.itemClass), 4594 4595 video = this._videos[item.attr('data-video')], 4596 4597 width = video.width || '100%', 4598 4599 height = video.height || this._core.$stage.height(), 4600 4601 html; 4602 4603 4604 4605 if (this._playing) { 4606 4607 return; 4608 4609 } 4610 4611 4612 4613 this._core.enter('playing'); 4614 4615 this._core.trigger('play', null, 'video'); 4616 4617 4618 4619 item = this._core.items(this._core.relative(item.index())); 4620 4621 4622 4623 this._core.reset(item.index()); 4624 4625 4626 4627 if (video.type === 'youtube') { 4628 4629 html = '<iframe width="' + width + '" height="' + height + '" src="//www.youtube.com/embed/' + 4630 4631 video.id + '?autoplay=1&rel=0&v=' + video.id + '" frameborder="0" allowfullscreen></iframe>'; 4632 4633 } else if (video.type === 'vimeo') { 4634 4635 html = '<iframe src="//player.vimeo.com/video/' + video.id + 4636 4637 '?autoplay=1" width="' + width + '" height="' + height + 4638 4639 '" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>'; 4640 4641 } else if (video.type === 'vzaar') { 4642 4643 html = '<iframe frameborder="0"' + 'height="' + height + '"' + 'width="' + width + 4644 4645 '" allowfullscreen mozallowfullscreen webkitAllowFullScreen ' + 4646 4647 'src="//view.vzaar.com/' + video.id + '/player?autoplay=true"></iframe>'; 4648 4649 } 4650 4651 4652 4653 $('<div class="owl-video-frame">' + html + '</div>').insertAfter(item.find('.owl-video')); 4654 4655 4656 4657 this._playing = item.addClass('owl-video-playing'); 4658 4659 }; 4660 4661 4662 4663 /** 4664 4665 * Checks whether an video is currently in full screen mode or not. 4666 4667 * @todo Bad style because looks like a readonly method but changes members. 4668 4669 * @protected 4670 4671 * @returns {Boolean} 4672 4673 */ 4674 4675 Video.prototype.isInFullScreen = function() { 4676 4677 var element = document.fullscreenElement || document.mozFullScreenElement || 4678 4679 document.webkitFullscreenElement; 4680 4681 4682 4683 return element && $(element).parent().hasClass('owl-video-frame'); 4684 4685 }; 4686 4687 4688 4689 /** 4690 4691 * Destroys the plugin. 4692 4693 */ 4694 4695 Video.prototype.destroy = function() { 4696 4697 var handler, property; 4698 4699 4700 4701 this._core.$element.off('click.owl.video'); 4702 4703 4704 4705 for (handler in this._handlers) { 4706 4707 this._core.$element.off(handler, this._handlers[handler]); 4708 4709 } 4710 4711 for (property in Object.getOwnPropertyNames(this)) { 4712 4713 typeof this[property] != 'function' && (this[property] = null); 4714 4715 } 4716 4717 }; 4718 4719 4720 4721 $.fn.owlCarousel.Constructor.Plugins.Video = Video; 4722 4723 4724 4725})(window.Zepto || window.jQuery, window, document); 4726 4727 4728 4729/** 4730 4731 * Animate Plugin 4732 4733 * @version 2.1.0 4734 4735 * @author Bartosz Wojciechowski 4736 4737 * @author David Deutsch 4738 4739 * @license The MIT License (MIT) 4740 4741 */ 4742 4743;(function($, window, document, undefined) { 4744 4745 4746 4747 /** 4748 4749 * Creates the animate plugin. 4750 4751 * @class The Navigation Plugin 4752 4753 * @param {Owl} scope - The Owl Carousel 4754 4755 */ 4756 4757 var Animate = function(scope) { 4758 4759 this.core = scope; 4760 4761 this.core.options = $.extend({}, Animate.Defaults, this.core.options); 4762 4763 this.swapping = true; 4764 4765 this.previous = undefined; 4766 4767 this.next = undefined; 4768 4769 4770 4771 this.handlers = { 4772 4773 'change.owl.carousel': $.proxy(function(e) { 4774 4775 if (e.namespace && e.property.name == 'position') { 4776 4777 this.previous = this.core.current(); 4778 4779 this.next = e.property.value; 4780 4781 } 4782 4783 }, this), 4784 4785 'drag.owl.carousel dragged.owl.carousel translated.owl.carousel': $.proxy(function(e) { 4786 4787 if (e.namespace) { 4788 4789 this.swapping = e.type == 'translated'; 4790 4791 } 4792 4793 }, this), 4794 4795 'translate.owl.carousel': $.proxy(function(e) { 4796 4797 if (e.namespace && this.swapping && (this.core.options.animateOut || this.core.options.animateIn)) { 4798 4799 this.swap(); 4800 4801 } 4802 4803 }, this) 4804 4805 }; 4806 4807 4808 4809 this.core.$element.on(this.handlers); 4810 4811 }; 4812 4813 4814 4815 /** 4816 4817 * Default options. 4818 4819 * @public 4820 4821 */ 4822 4823 Animate.Defaults = { 4824 4825 animateOut: false, 4826 4827 animateIn: false 4828 4829 }; 4830 4831 4832 4833 /** 4834 4835 * Toggles the animation classes whenever an translations starts. 4836 4837 * @protected 4838 4839 * @returns {Boolean|undefined} 4840 4841 */ 4842 4843 Animate.prototype.swap = function() { 4844 4845 4846 4847 if (this.core.settings.items !== 1) { 4848 4849 return; 4850 4851 } 4852 4853 4854 4855 if (!$.support.animation || !$.support.transition) { 4856 4857 return; 4858 4859 } 4860 4861 4862 4863 this.core.speed(0); 4864 4865 4866 4867 var left, 4868 4869 clear = $.proxy(this.clear, this), 4870 4871 previous = this.core.$stage.children().eq(this.previous), 4872 4873 next = this.core.$stage.children().eq(this.next), 4874 4875 incoming = this.core.settings.animateIn, 4876 4877 outgoing = this.core.settings.animateOut; 4878 4879 4880 4881 if (this.core.current() === this.previous) { 4882 4883 return; 4884 4885 } 4886 4887 4888 4889 if (outgoing) { 4890 4891 left = this.core.coordinates(this.previous) - this.core.coordinates(this.next); 4892 4893 previous.one($.support.animation.end, clear) 4894 4895 .css( { 'left': left + 'px' } ) 4896 4897 .addClass('animated owl-animated-out') 4898 4899 .addClass(outgoing); 4900 4901 } 4902 4903 4904 4905 if (incoming) { 4906 4907 next.one($.support.animation.end, clear) 4908 4909 .addClass('animated owl-animated-in') 4910 4911 .addClass(incoming); 4912 4913 } 4914 4915 }; 4916 4917 4918 4919 Animate.prototype.clear = function(e) { 4920 4921 $(e.target).css( { 'left': '' } ) 4922 4923 .removeClass('animated owl-animated-out owl-animated-in') 4924 4925 .removeClass(this.core.settings.animateIn) 4926 4927 .removeClass(this.core.settings.animateOut); 4928 4929 this.core.onTransitionEnd(); 4930 4931 }; 4932 4933 4934 4935 /** 4936 4937 * Destroys the plugin. 4938 4939 * @public 4940 4941 */ 4942 4943 Animate.prototype.destroy = function() { 4944 4945 var handler, property; 4946 4947 4948 4949 for (handler in this.handlers) { 4950 4951 this.core.$element.off(handler, this.handlers[handler]); 4952 4953 } 4954 4955 for (property in Object.getOwnPropertyNames(this)) { 4956 4957 typeof this[property] != 'function' && (this[property] = null); 4958 4959 } 4960 4961 }; 4962 4963 4964 4965 $.fn.owlCarousel.Constructor.Plugins.Animate = Animate; 4966 4967 4968 4969})(window.Zepto || window.jQuery, window, document); 4970 4971 4972 4973/** 4974 4975 * Autoplay Plugin 4976 4977 * @version 2.1.0 4978 4979 * @author Bartosz Wojciechowski 4980 4981 * @author Artus Kolanowski 4982 4983 * @author David Deutsch 4984 4985 * @license The MIT License (MIT) 4986 4987 */ 4988 4989;(function($, window, document, undefined) { 4990 4991 4992 4993 /** 4994 4995 * Creates the autoplay plugin. 4996 4997 * @class The Autoplay Plugin 4998 4999 * @param {Owl} scope - The Owl Carousel 5000 5001 */ 5002 5003 var Autoplay = function(carousel) { 5004 5005 /** 5006 5007 * Reference to the core. 5008 5009 * @protected 5010 5011 * @type {Owl} 5012 5013 */ 5014 5015 this._core = carousel; 5016 5017 5018 5019 /** 5020 5021 * The autoplay timeout. 5022 5023 * @type {Timeout} 5024 5025 */ 5026 5027 this._timeout = null; 5028 5029 5030 5031 /** 5032 5033 * Indicates whenever the autoplay is paused. 5034 5035 * @type {Boolean} 5036 5037 */ 5038 5039 this._paused = false; 5040 5041 5042 5043 /** 5044 5045 * All event handlers. 5046 5047 * @protected 5048 5049 * @type {Object} 5050 5051 */ 5052 5053 this._handlers = { 5054 5055 'changed.owl.carousel': $.proxy(function(e) { 5056 5057 if (e.namespace && e.property.name === 'settings') { 5058 5059 if (this._core.settings.autoplay) { 5060 5061 this.play(); 5062 5063 } else { 5064 5065 this.stop(); 5066 5067 } 5068 5069 } else if (e.namespace && e.property.name === 'position') { 5070 5071 //console.log('play?', e); 5072 5073 if (this._core.settings.autoplay) { 5074 5075 this._setAutoPlayInterval(); 5076 5077 } 5078 5079 } 5080 5081 }, this), 5082 5083 'initialized.owl.carousel': $.proxy(function(e) { 5084 5085 if (e.namespace && this._core.settings.autoplay) { 5086 5087 this.play(); 5088 5089 } 5090 5091 }, this), 5092 5093 'play.owl.autoplay': $.proxy(function(e, t, s) { 5094 5095 if (e.namespace) { 5096 5097 this.play(t, s); 5098 5099 } 5100 5101 }, this), 5102 5103 'stop.owl.autoplay': $.proxy(function(e) { 5104 5105 if (e.namespace) { 5106 5107 this.stop(); 5108 5109 } 5110 5111 }, this), 5112 5113 'mouseover.owl.autoplay': $.proxy(function() { 5114 5115 if (this._core.settings.autoplayHoverPause && this._core.is('rotating')) { 5116 5117 this.pause(); 5118 5119 } 5120 5121 }, this), 5122 5123 'mouseleave.owl.autoplay': $.proxy(function() { 5124 5125 if (this._core.settings.autoplayHoverPause && this._core.is('rotating')) { 5126 5127 this.play(); 5128 5129 } 5130 5131 }, this), 5132 5133 'touchstart.owl.core': $.proxy(function() { 5134 5135 if (this._core.settings.autoplayHoverPause && this._core.is('rotating')) { 5136 5137 this.pause(); 5138 5139 } 5140 5141 }, this), 5142 5143 'touchend.owl.core': $.proxy(function() { 5144 5145 if (this._core.settings.autoplayHoverPause) { 5146 5147 this.play(); 5148 5149 } 5150 5151 }, this) 5152 5153 }; 5154 5155 5156 5157 // register event handlers 5158 5159 this._core.$element.on(this._handlers); 5160 5161 5162 5163 // set default options 5164 5165 this._core.options = $.extend({}, Autoplay.Defaults, this._core.options); 5166 5167 }; 5168 5169 5170 5171 /** 5172 5173 * Default options. 5174 5175 * @public 5176 5177 */ 5178 5179 Autoplay.Defaults = { 5180 5181 autoplay: false, 5182 5183 autoplayTimeout: 5000, 5184 5185 autoplayHoverPause: false, 5186 5187 autoplaySpeed: false 5188 5189 }; 5190 5191 5192 5193 /** 5194 5195 * Starts the autoplay. 5196 5197 * @public 5198 5199 * @param {Number} [timeout] - The interval before the next animation starts. 5200 5201 * @param {Number} [speed] - The animation speed for the animations. 5202 5203 */ 5204 5205 Autoplay.prototype.play = function(timeout, speed) { 5206 5207 this._paused = false; 5208 5209 5210 5211 if (this._core.is('rotating')) { 5212 5213 return; 5214 5215 } 5216 5217 5218 5219 this._core.enter('rotating'); 5220 5221 5222 5223 this._setAutoPlayInterval(); 5224 5225 }; 5226 5227 5228 5229 /** 5230 5231 * Gets a new timeout 5232 5233 * @private 5234 5235 * @param {Number} [timeout] - The interval before the next animation starts. 5236 5237 * @param {Number} [speed] - The animation speed for the animations. 5238 5239 * @return {Timeout} 5240 5241 */ 5242 5243 Autoplay.prototype._getNextTimeout = function(timeout, speed) { 5244 5245 if ( this._timeout ) { 5246 5247 window.clearTimeout(this._timeout); 5248 5249 } 5250 5251 return window.setTimeout($.proxy(function() { 5252 5253 if (this._paused || this._core.is('busy') || this._core.is('interacting') || document.hidden) { 5254 5255 return; 5256 5257 } 5258 5259 this._core.next(speed || this._core.settings.autoplaySpeed); 5260 5261 }, this), timeout || this._core.settings.autoplayTimeout); 5262 5263 }; 5264 5265 5266 5267 /** 5268 5269 * Sets autoplay in motion. 5270 5271 * @private 5272 5273 */ 5274 5275 Autoplay.prototype._setAutoPlayInterval = function() { 5276 5277 this._timeout = this._getNextTimeout(); 5278 5279 }; 5280 5281 5282 5283 /** 5284 5285 * Stops the autoplay. 5286 5287 * @public 5288 5289 */ 5290 5291 Autoplay.prototype.stop = function() { 5292 5293 if (!this._core.is('rotating')) { 5294 5295 return; 5296 5297 } 5298 5299 5300 5301 window.clearTimeout(this._timeout); 5302 5303 this._core.leave('rotating'); 5304 5305 }; 5306 5307 5308 5309 /** 5310 5311 * Stops the autoplay. 5312 5313 * @public 5314 5315 */ 5316 5317 Autoplay.prototype.pause = function() { 5318 5319 if (!this._core.is('rotating')) { 5320 5321 return; 5322 5323 } 5324 5325 5326 5327 this._paused = true; 5328 5329 }; 5330 5331 5332 5333 /** 5334 5335 * Destroys the plugin. 5336 5337 */ 5338 5339 Autoplay.prototype.destroy = function() { 5340 5341 var handler, property; 5342 5343 5344 5345 this.stop(); 5346 5347 5348 5349 for (handler in this._handlers) { 5350 5351 this._core.$element.off(handler, this._handlers[handler]); 5352 5353 } 5354 5355 for (property in Object.getOwnPropertyNames(this)) { 5356 5357 typeof this[property] != 'function' && (this[property] = null); 5358 5359 } 5360 5361 }; 5362 5363 5364 5365 $.fn.owlCarousel.Constructor.Plugins.autoplay = Autoplay; 5366 5367 5368 5369})(window.Zepto || window.jQuery, window, document); 5370 5371 5372 5373/** 5374 5375 * Navigation Plugin 5376 5377 * @version 2.1.0 5378 5379 * @author Artus Kolanowski 5380 5381 * @author David Deutsch 5382 5383 * @license The MIT License (MIT) 5384 5385 */ 5386 5387;(function($, window, document, undefined) { 5388 5389 'use strict'; 5390 5391 5392 5393 /** 5394 5395 * Creates the navigation plugin. 5396 5397 * @class The Navigation Plugin 5398 5399 * @param {Owl} carousel - The Owl Carousel. 5400 5401 */ 5402 5403 var Navigation = function(carousel) { 5404 5405 /** 5406 5407 * Reference to the core. 5408 5409 * @protected 5410 5411 * @type {Owl} 5412 5413 */ 5414 5415 this._core = carousel; 5416 5417 5418 5419 /** 5420 5421 * Indicates whether the plugin is initialized or not. 5422 5423 * @protected 5424 5425 * @type {Boolean} 5426 5427 */ 5428 5429 this._initialized = false; 5430 5431 5432 5433 /** 5434 5435 * The current paging indexes. 5436 5437 * @protected 5438 5439 * @type {Array} 5440 5441 */ 5442 5443 this._pages = []; 5444 5445 5446 5447 /** 5448 5449 * All DOM elements of the user interface. 5450 5451 * @protected 5452 5453 * @type {Object} 5454 5455 */ 5456 5457 this._controls = {}; 5458 5459 5460 5461 /** 5462 5463 * Markup for an indicator. 5464 5465 * @protected 5466 5467 * @type {Array.<String>} 5468 5469 */ 5470 5471 this._templates = []; 5472 5473 5474 5475 /** 5476 5477 * The carousel element. 5478 5479 * @type {jQuery} 5480 5481 */ 5482 5483 this.$element = this._core.$element; 5484 5485 5486 5487 /** 5488 5489 * Overridden methods of the carousel. 5490 5491 * @protected 5492 5493 * @type {Object} 5494 5495 */ 5496 5497 this._overrides = { 5498 5499 next: this._core.next, 5500 5501 prev: this._core.prev, 5502 5503 to: this._core.to 5504 5505 }; 5506 5507 5508 5509 /** 5510 5511 * All event handlers. 5512 5513 * @protected 5514 5515 * @type {Object} 5516 5517 */ 5518 5519 this._handlers = { 5520 5521 'prepared.owl.carousel': $.proxy(function(e) { 5522 5523 if (e.namespace && this._core.settings.dotsData) { 5524 5525 this._templates.push('<div class="' + this._core.settings.dotClass + '">' + 5526 5527 $(e.content).find('[data-dot]').addBack('[data-dot]').attr('data-dot') + '</div>'); 5528 5529 } 5530 5531 }, this), 5532 5533 'added.owl.carousel': $.proxy(function(e) { 5534 5535 if (e.namespace && this._core.settings.dotsData) { 5536 5537 this._templates.splice(e.position, 0, this._templates.pop()); 5538 5539 } 5540 5541 }, this), 5542 5543 'remove.owl.carousel': $.proxy(function(e) { 5544 5545 if (e.namespace && this._core.settings.dotsData) { 5546 5547 this._templates.splice(e.position, 1); 5548 5549 } 5550 5551 }, this), 5552 5553 'changed.owl.carousel': $.proxy(function(e) { 5554 5555 if (e.namespace && e.property.name == 'position') { 5556 5557 this.draw(); 5558 5559 } 5560 5561 }, this), 5562 5563 'initialized.owl.carousel': $.proxy(function(e) { 5564 5565 if (e.namespace && !this._initialized) { 5566 5567 this._core.trigger('initialize', null, 'navigation'); 5568 5569 this.initialize(); 5570 5571 this.update(); 5572 5573 this.draw(); 5574 5575 this._initialized = true; 5576 5577 this._core.trigger('initialized', null, 'navigation'); 5578 5579 } 5580 5581 }, this), 5582 5583 'refreshed.owl.carousel': $.proxy(function(e) { 5584 5585 if (e.namespace && this._initialized) { 5586 5587 this._core.trigger('refresh', null, 'navigation'); 5588 5589 this.update(); 5590 5591 this.draw(); 5592 5593 this._core.trigger('refreshed', null, 'navigation'); 5594 5595 } 5596 5597 }, this) 5598 5599 }; 5600 5601 5602 5603 // set default options 5604 5605 this._core.options = $.extend({}, Navigation.Defaults, this._core.options); 5606 5607 5608 5609 // register event handlers 5610 5611 this.$element.on(this._handlers); 5612 5613 }; 5614 5615 5616 5617 /** 5618 5619 * Default options. 5620 5621 * @public 5622 5623 * @todo Rename `slideBy` to `navBy` 5624 5625 */ 5626 5627 Navigation.Defaults = { 5628 5629 nav: false, 5630 5631 navText: [ 'prev', 'next' ], 5632 5633 navSpeed: false, 5634 5635 navElement: 'div', 5636 5637 navContainer: false, 5638 5639 navContainerClass: 'owl-nav', 5640 5641 navClass: [ 'owl-prev', 'owl-next' ], 5642 5643 slideBy: 1, 5644 5645 dotClass: 'owl-dot', 5646 5647 dotsClass: 'owl-dots', 5648 5649 dots: true, 5650 5651 dotsEach: false, 5652 5653 dotsData: false, 5654 5655 dotsSpeed: false, 5656 5657 dotsContainer: false 5658 5659 }; 5660 5661 5662 5663 /** 5664 5665 * Initializes the layout of the plugin and extends the carousel. 5666 5667 * @protected 5668 5669 */ 5670 5671 Navigation.prototype.initialize = function() { 5672 5673 var override, 5674 5675 settings = this._core.settings; 5676 5677 5678 5679 // create DOM structure for relative navigation 5680 5681 this._controls.$relative = (settings.navContainer ? $(settings.navContainer) 5682 5683 : $('<div>').addClass(settings.navContainerClass).appendTo(this.$element)).addClass('disabled'); 5684 5685 5686 5687 this._controls.$previous = $('<' + settings.navElement + '>') 5688 5689 .addClass(settings.navClass[0]) 5690 5691 .html(settings.navText[0]) 5692 5693 .prependTo(this._controls.$relative) 5694 5695 .on('click', $.proxy(function(e) { 5696 5697 this.prev(settings.navSpeed); 5698 5699 }, this)); 5700 5701 this._controls.$next = $('<' + settings.navElement + '>') 5702 5703 .addClass(settings.navClass[1]) 5704 5705 .html(settings.navText[1]) 5706 5707 .appendTo(this._controls.$relative) 5708 5709 .on('click', $.proxy(function(e) { 5710 5711 this.next(settings.navSpeed); 5712 5713 }, this)); 5714 5715 5716 5717 // create DOM structure for absolute navigation 5718 5719 if (!settings.dotsData) { 5720 5721 this._templates = [ $('<div>') 5722 5723 .addClass(settings.dotClass) 5724 5725 .append($('<span>')) 5726 5727 .prop('outerHTML') ]; 5728 5729 } 5730 5731 5732 5733 this._controls.$absolute = (settings.dotsContainer ? $(settings.dotsContainer) 5734 5735 : $('<div>').addClass(settings.dotsClass).appendTo(this.$element)).addClass('disabled'); 5736 5737 5738 5739 this._controls.$absolute.on('click', 'div', $.proxy(function(e) { 5740 5741 var index = $(e.target).parent().is(this._controls.$absolute) 5742 5743 ? $(e.target).index() : $(e.target).parent().index(); 5744 5745 5746 5747 e.preventDefault(); 5748 5749 5750 5751 this.to(index, settings.dotsSpeed); 5752 5753 }, this)); 5754 5755 5756 5757 // override public methods of the carousel 5758 5759 for (override in this._overrides) { 5760 5761 this._core[override] = $.proxy(this[override], this); 5762 5763 } 5764 5765 }; 5766 5767 5768 5769 /** 5770 5771 * Destroys the plugin. 5772 5773 * @protected 5774 5775 */ 5776 5777 Navigation.prototype.destroy = function() { 5778 5779 var handler, control, property, override; 5780 5781 5782 5783 for (handler in this._handlers) { 5784 5785 this.$element.off(handler, this._handlers[handler]); 5786 5787 } 5788 5789 for (control in this._controls) { 5790 5791 this._controls[control].remove(); 5792 5793 } 5794 5795 for (override in this.overides) { 5796 5797 this._core[override] = this._overrides[override]; 5798 5799 } 5800 5801 for (property in Object.getOwnPropertyNames(this)) { 5802 5803 typeof this[property] != 'function' && (this[property] = null); 5804 5805 } 5806 5807 }; 5808 5809 5810 5811 /** 5812 5813 * Updates the internal state. 5814 5815 * @protected 5816 5817 */ 5818 5819 Navigation.prototype.update = function() { 5820 5821 var i, j, k, 5822 5823 lower = this._core.clones().length / 2, 5824 5825 upper = lower + this._core.items().length, 5826 5827 maximum = this._core.maximum(true), 5828 5829 settings = this._core.settings, 5830 5831 size = settings.center || settings.autoWidth || settings.dotsData 5832 5833 ? 1 : settings.dotsEach || settings.items; 5834 5835 5836 5837 if (settings.slideBy !== 'page') { 5838 5839 settings.slideBy = Math.min(settings.slideBy, settings.items); 5840 5841 } 5842 5843 5844 5845 if (settings.dots || settings.slideBy == 'page') { 5846 5847 this._pages = []; 5848 5849 5850 5851 for (i = lower, j = 0, k = 0; i < upper; i++) { 5852 5853 if (j >= size || j === 0) { 5854 5855 this._pages.push({ 5856 5857 start: Math.min(maximum, i - lower), 5858 5859 end: i - lower + size - 1 5860 5861 }); 5862 5863 if (Math.min(maximum, i - lower) === maximum) { 5864 5865 break; 5866 5867 } 5868 5869 j = 0, ++k; 5870 5871 } 5872 5873 j += this._core.mergers(this._core.relative(i)); 5874 5875 } 5876 5877 } 5878 5879 }; 5880 5881 5882 5883 /** 5884 5885 * Draws the user interface. 5886 5887 * @todo The option `dotsData` wont work. 5888 5889 * @protected 5890 5891 */ 5892 5893 Navigation.prototype.draw = function() { 5894 5895 var difference, 5896 5897 settings = this._core.settings, 5898 5899 disabled = this._core.items().length <= settings.items, 5900 5901 index = this._core.relative(this._core.current()), 5902 5903 loop = settings.loop || settings.rewind; 5904 5905 5906 5907 this._controls.$relative.toggleClass('disabled', !settings.nav || disabled); 5908 5909 5910 5911 if (settings.nav) { 5912 5913 this._controls.$previous.toggleClass('disabled', !loop && index <= this._core.minimum(true)); 5914 5915 this._controls.$next.toggleClass('disabled', !loop && index >= this._core.maximum(true)); 5916 5917 } 5918 5919 5920 5921 this._controls.$absolute.toggleClass('disabled', !settings.dots || disabled); 5922 5923 5924 5925 if (settings.dots) { 5926 5927 difference = this._pages.length - this._controls.$absolute.children().length; 5928 5929 5930 5931 if (settings.dotsData && difference !== 0) { 5932 5933 this._controls.$absolute.html(this._templates.join('')); 5934 5935 } else if (difference > 0) { 5936 5937 this._controls.$absolute.append(new Array(difference + 1).join(this._templates[0])); 5938 5939 } else if (difference < 0) { 5940 5941 this._controls.$absolute.children().slice(difference).remove(); 5942 5943 } 5944 5945 5946 5947 this._controls.$absolute.find('.active').removeClass('active'); 5948 5949 this._controls.$absolute.children().eq($.inArray(this.current(), this._pages)).addClass('active'); 5950 5951 } 5952 5953 }; 5954 5955 5956 5957 /** 5958 5959 * Extends event data. 5960 5961 * @protected 5962 5963 * @param {Event} event - The event object which gets thrown. 5964 5965 */ 5966 5967 Navigation.prototype.onTrigger = function(event) { 5968 5969 var settings = this._core.settings; 5970 5971 5972 5973 event.page = { 5974 5975 index: $.inArray(this.current(), this._pages), 5976 5977 count: this._pages.length, 5978
vendor: 8,138 bytes, lines 5979-6549
5979 size: settings && (settings.center || settings.autoWidth || settings.dotsData 5980 5981 ? 1 : settings.dotsEach || settings.items) 5982 5983 }; 5984 5985 }; 5986 5987 5988 5989 /** 5990 5991 * Gets the current page position of the carousel. 5992 5993 * @protected 5994 5995 * @returns {Number} 5996 5997 */ 5998 5999 Navigation.prototype.current = function() { 6000 6001 var current = this._core.relative(this._core.current()); 6002 6003 return $.grep(this._pages, $.proxy(function(page, index) { 6004 6005 return page.start <= current && page.end >= current; 6006 6007 }, this)).pop(); 6008 6009 }; 6010 6011 6012 6013 /** 6014 6015 * Gets the current succesor/predecessor position. 6016 6017 * @protected 6018 6019 * @returns {Number} 6020 6021 */ 6022 6023 Navigation.prototype.getPosition = function(successor) { 6024 6025 var position, length, 6026 6027 settings = this._core.settings; 6028 6029 6030 6031 if (settings.slideBy == 'page') { 6032 6033 position = $.inArray(this.current(), this._pages); 6034 6035 length = this._pages.length; 6036 6037 successor ? ++position : --position; 6038 6039 position = this._pages[((position % length) + length) % length].start; 6040 6041 } else { 6042 6043 position = this._core.relative(this._core.current()); 6044 6045 length = this._core.items().length; 6046 6047 successor ? position += settings.slideBy : position -= settings.slideBy; 6048 6049 } 6050 6051 6052 6053 return position; 6054 6055 }; 6056 6057 6058 6059 /** 6060 6061 * Slides to the next item or page. 6062 6063 * @public 6064 6065 * @param {Number} [speed=false] - The time in milliseconds for the transition. 6066 6067 */ 6068 6069 Navigation.prototype.next = function(speed) { 6070 6071 $.proxy(this._overrides.to, this._core)(this.getPosition(true), speed); 6072 6073 }; 6074 6075 6076 6077 /** 6078 6079 * Slides to the previous item or page. 6080 6081 * @public 6082 6083 * @param {Number} [speed=false] - The time in milliseconds for the transition. 6084 6085 */ 6086 6087 Navigation.prototype.prev = function(speed) { 6088 6089 $.proxy(this._overrides.to, this._core)(this.getPosition(false), speed); 6090 6091 }; 6092 6093 6094 6095 /** 6096 6097 * Slides to the specified item or page. 6098 6099 * @public 6100 6101 * @param {Number} position - The position of the item or page. 6102 6103 * @param {Number} [speed] - The time in milliseconds for the transition. 6104 6105 * @param {Boolean} [standard=false] - Whether to use the standard behaviour or not. 6106 6107 */ 6108 6109 Navigation.prototype.to = function(position, speed, standard) { 6110 6111 var length; 6112 6113 6114 6115 if (!standard && this._pages.length) { 6116 6117 length = this._pages.length; 6118 6119 $.proxy(this._overrides.to, this._core)(this._pages[((position % length) + length) % length].start, speed); 6120 6121 } else { 6122 6123 $.proxy(this._overrides.to, this._core)(position, speed); 6124 6125 } 6126 6127 }; 6128 6129 6130 6131 $.fn.owlCarousel.Constructor.Plugins.Navigation = Navigation; 6132 6133 6134 6135})(window.Zepto || window.jQuery, window, document); 6136 6137 6138 6139/** 6140 6141 * Hash Plugin 6142 6143 * @version 2.1.0 6144 6145 * @author Artus Kolanowski 6146 6147 * @author David Deutsch 6148 6149 * @license The MIT License (MIT) 6150 6151 */ 6152 6153;(function($, window, document, undefined) { 6154 6155 'use strict'; 6156 6157 6158 6159 /** 6160 6161 * Creates the hash plugin. 6162 6163 * @class The Hash Plugin 6164 6165 * @param {Owl} carousel - The Owl Carousel 6166 6167 */ 6168 6169 var Hash = function(carousel) { 6170 6171 /** 6172 6173 * Reference to the core. 6174 6175 * @protected 6176 6177 * @type {Owl} 6178 6179 */ 6180 6181 this._core = carousel; 6182 6183 6184 6185 /** 6186 6187 * Hash index for the items. 6188 6189 * @protected 6190 6191 * @type {Object} 6192 6193 */ 6194 6195 this._hashes = {}; 6196 6197 6198 6199 /** 6200 6201 * The carousel element. 6202 6203 * @type {jQuery} 6204 6205 */ 6206 6207 this.$element = this._core.$element; 6208 6209 6210 6211 /** 6212 6213 * All event handlers. 6214 6215 * @protected 6216 6217 * @type {Object} 6218 6219 */ 6220 6221 this._handlers = { 6222 6223 'initialized.owl.carousel': $.proxy(function(e) { 6224 6225 if (e.namespace && this._core.settings.startPosition === 'URLHash') { 6226 6227 $(window).trigger('hashchange.owl.navigation'); 6228 6229 } 6230 6231 }, this), 6232 6233 'prepared.owl.carousel': $.proxy(function(e) { 6234 6235 if (e.namespace) { 6236 6237 var hash = $(e.content).find('[data-hash]').addBack('[data-hash]').attr('data-hash'); 6238 6239 6240 6241 if (!hash) { 6242 6243 return; 6244 6245 } 6246 6247 6248 6249 this._hashes[hash] = e.content; 6250 6251 } 6252 6253 }, this), 6254 6255 'changed.owl.carousel': $.proxy(function(e) { 6256 6257 if (e.namespace && e.property.name === 'position') { 6258 6259 var current = this._core.items(this._core.relative(this._core.current())), 6260 6261 hash = $.map(this._hashes, function(item, hash) { 6262 6263 return item === current ? hash : null; 6264 6265 }).join(); 6266 6267 6268 6269 if (!hash || window.location.hash.slice(1) === hash) { 6270 6271 return; 6272 6273 } 6274 6275 6276 6277 window.location.hash = hash; 6278 6279 } 6280 6281 }, this) 6282 6283 }; 6284 6285 6286 6287 // set default options 6288 6289 this._core.options = $.extend({}, Hash.Defaults, this._core.options); 6290 6291 6292 6293 // register the event handlers 6294 6295 this.$element.on(this._handlers); 6296 6297 6298 6299 // register event listener for hash navigation 6300 6301 $(window).on('hashchange.owl.navigation', $.proxy(function(e) { 6302 6303 var hash = window.location.hash.substring(1), 6304 6305 items = this._core.$stage.children(), 6306 6307 position = this._hashes[hash] && items.index(this._hashes[hash]); 6308 6309 6310 6311 if (position === undefined || position === this._core.current()) { 6312 6313 return; 6314 6315 } 6316 6317 6318 6319 this._core.to(this._core.relative(position), false, true); 6320 6321 }, this)); 6322 6323 }; 6324 6325 6326 6327 /** 6328 6329 * Default options. 6330 6331 * @public 6332 6333 */ 6334 6335 Hash.Defaults = { 6336 6337 URLhashListener: false 6338 6339 }; 6340 6341 6342 6343 /** 6344 6345 * Destroys the plugin. 6346 6347 * @public 6348 6349 */ 6350 6351 Hash.prototype.destroy = function() { 6352 6353 var handler, property; 6354 6355 6356 6357 $(window).off('hashchange.owl.navigation'); 6358 6359 6360 6361 for (handler in this._handlers) { 6362 6363 this._core.$element.off(handler, this._handlers[handler]); 6364 6365 } 6366 6367 for (property in Object.getOwnPropertyNames(this)) { 6368 6369 typeof this[property] != 'function' && (this[property] = null); 6370 6371 } 6372 6373 }; 6374 6375 6376 6377 $.fn.owlCarousel.Constructor.Plugins.Hash = Hash; 6378 6379 6380 6381})(window.Zepto || window.jQuery, window, document); 6382 6383 6384 6385/** 6386 6387 * Support Plugin 6388 6389 * 6390 6391 * @version 2.1.0 6392 6393 * @author Vivid Planet Software GmbH 6394 6395 * @author Artus Kolanowski 6396 6397 * @author David Deutsch 6398 6399 * @license The MIT License (MIT) 6400 6401 */ 6402 6403;(function($, window, document, undefined) { 6404 6405 6406 6407 var style = $('<support>').get(0).style, 6408 6409 prefixes = 'Webkit Moz O ms'.split(' '), 6410 6411 events = { 6412 6413 transition: { 6414 6415 end: { 6416 6417 WebkitTransition: 'webkitTransitionEnd', 6418 6419 MozTransition: 'transitionend', 6420 6421 OTransition: 'oTransitionEnd', 6422 6423 transition: 'transitionend' 6424 6425 } 6426 6427 }, 6428 6429 animation: { 6430 6431 end: { 6432 6433 WebkitAnimation: 'webkitAnimationEnd', 6434 6435 MozAnimation: 'animationend', 6436 6437 OAnimation: 'oAnimationEnd', 6438 6439 animation: 'animationend' 6440 6441 } 6442 6443 } 6444 6445 }, 6446 6447 tests = { 6448 6449 csstransforms: function() { 6450 6451 return !!test('transform'); 6452 6453 }, 6454 6455 csstransforms3d: function() { 6456 6457 return !!test('perspective'); 6458 6459 }, 6460 6461 csstransitions: function() { 6462 6463 return !!test('transition'); 6464 6465 }, 6466 6467 cssanimations: function() { 6468 6469 return !!test('animation'); 6470 6471 } 6472 6473 }; 6474 6475 6476 6477 function test(property, prefixed) { 6478 6479 var result = false, 6480 6481 upper = property.charAt(0).toUpperCase() + property.slice(1); 6482 6483 6484 6485 $.each((property + ' ' + prefixes.join(upper + ' ') + upper).split(' '), function(i, property) { 6486 6487 if (style[property] !== undefined) { 6488 6489 result = prefixed ? property : true; 6490 6491 return false; 6492 6493 } 6494 6495 }); 6496 6497 6498 6499 return result; 6500 6501 } 6502 6503 6504 6505 function prefixed(property) { 6506 6507 return test(property, true); 6508 6509 } 6510 6511 6512 6513 if (tests.csstransitions()) { 6514 6515 /* jshint -W053 */ 6516 6517 $.support.transition = new String(prefixed('transition')) 6518 6519 $.support.transition.end = events.transition.end[ $.support.transition ]; 6520 6521 } 6522 6523 6524 6525 if (tests.cssanimations()) { 6526 6527 /* jshint -W053 */ 6528 6529 $.support.animation = new String(prefixed('animation')) 6530 6531 $.support.animation.end = events.animation.end[ $.support.animation ]; 6532 6533 } 6534 6535 6536 6537 if (tests.csstransforms()) { 6538 6539 /* jshint -W053 */ 6540 6541 $.support.transform = new String(prefixed('transform')); 6542 6543 $.support.transform3d = tests.csstransforms3d(); 6544 6545 } 6546 6547 6548 6549})(window.Zepto || window.jQuery, window, document);
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.