vendor: 161,986 bytes, lines 1-5463
1/*! 2 * Materialize v1.0.0 (http://materializecss.com) 3 * Copyright 2014-2017 Materialize 4 * MIT License (https://raw.githubusercontent.com/Dogfalo/materialize/master/LICENSE) 5 */ 6var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; 7 8var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 9 10function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 11 12function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 13 14function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 15 16/*! cash-dom 1.3.5, https://github.com/kenwheeler/cash @license MIT */ 17(function (factory) { 18 window.cash = factory(); 19})(function () { 20 var doc = document, 21 win = window, 22 ArrayProto = Array.prototype, 23 slice = ArrayProto.slice, 24 filter = ArrayProto.filter, 25 push = ArrayProto.push; 26 27 var noop = function () {}, 28 isFunction = function (item) { 29 // @see https://crbug.com/568448 30 return typeof item === typeof noop && item.call; 31 }, 32 isString = function (item) { 33 return typeof item === typeof ""; 34 }; 35 36 var idMatch = /^#[\w-]*$/, 37 classMatch = /^\.[\w-]*$/, 38 htmlMatch = /<.+>/, 39 singlet = /^\w+$/; 40 41 function find(selector, context) { 42 context = context || doc; 43 var elems = classMatch.test(selector) ? context.getElementsByClassName(selector.slice(1)) : singlet.test(selector) ? context.getElementsByTagName(selector) : context.querySelectorAll(selector); 44 return elems; 45 } 46 47 var frag; 48 function parseHTML(str) { 49 if (!frag) { 50 frag = doc.implementation.createHTMLDocument(null); 51 var base = frag.createElement("base"); 52 base.href = doc.location.href; 53 frag.head.appendChild(base); 54 } 55 56 frag.body.innerHTML = str; 57 58 return frag.body.childNodes; 59 } 60 61 function onReady(fn) { 62 if (doc.readyState !== "loading") { 63 fn(); 64 } else { 65 doc.addEventListener("DOMContentLoaded", fn); 66 } 67 } 68 69 function Init(selector, context) { 70 if (!selector) { 71 return this; 72 } 73 74 // If already a cash collection, don't do any further processing 75 if (selector.cash && selector !== win) { 76 return selector; 77 } 78 79 var elems = selector, 80 i = 0, 81 length; 82 83 if (isString(selector)) { 84 elems = idMatch.test(selector) ? 85 // If an ID use the faster getElementById check 86 doc.getElementById(selector.slice(1)) : htmlMatch.test(selector) ? 87 // If HTML, parse it into real elements 88 parseHTML(selector) : 89 // else use `find` 90 find(selector, context); 91 92 // If function, use as shortcut for DOM ready 93 } else if (isFunction(selector)) { 94 onReady(selector);return this; 95 } 96 97 if (!elems) { 98 return this; 99 } 100 101 // If a single DOM element is passed in or received via ID, return the single element 102 if (elems.nodeType || elems === win) { 103 this[0] = elems; 104 this.length = 1; 105 } else { 106 // Treat like an array and loop through each item. 107 length = this.length = elems.length; 108 for (; i < length; i++) { 109 this[i] = elems[i]; 110 } 111 } 112 113 return this; 114 } 115 116 function cash(selector, context) { 117 return new Init(selector, context); 118 } 119 120 var fn = cash.fn = cash.prototype = Init.prototype = { // jshint ignore:line 121 cash: true, 122 length: 0, 123 push: push, 124 splice: ArrayProto.splice, 125 map: ArrayProto.map, 126 init: Init 127 }; 128 129 Object.defineProperty(fn, "constructor", { value: cash }); 130 131 cash.parseHTML = parseHTML; 132 cash.noop = noop; 133 cash.isFunction = isFunction; 134 cash.isString = isString; 135 136 cash.extend = fn.extend = function (target) { 137 target = target || {}; 138 139 var args = slice.call(arguments), 140 length = args.length, 141 i = 1; 142 143 if (args.length === 1) { 144 target = this; 145 i = 0; 146 } 147 148 for (; i < length; i++) { 149 if (!args[i]) { 150 continue; 151 } 152 for (var key in args[i]) { 153 if (args[i].hasOwnProperty(key)) { 154 target[key] = args[i][key]; 155 } 156 } 157 } 158 159 return target; 160 }; 161 162 function each(collection, callback) { 163 var l = collection.length, 164 i = 0; 165 166 for (; i < l; i++) { 167 if (callback.call(collection[i], collection[i], i, collection) === false) { 168 break; 169 } 170 } 171 } 172 173 function matches(el, selector) { 174 var m = el && (el.matches || el.webkitMatchesSelector || el.mozMatchesSelector || el.msMatchesSelector || el.oMatchesSelector); 175 return !!m && m.call(el, selector); 176 } 177 178 function getCompareFunction(selector) { 179 return ( 180 /* Use browser's `matches` function if string */ 181 isString(selector) ? matches : 182 /* Match a cash element */ 183 selector.cash ? function (el) { 184 return selector.is(el); 185 } : 186 /* Direct comparison */ 187 function (el, selector) { 188 return el === selector; 189 } 190 ); 191 } 192 193 function unique(collection) { 194 return cash(slice.call(collection).filter(function (item, index, self) { 195 return self.indexOf(item) === index; 196 })); 197 } 198 199 cash.extend({ 200 merge: function (first, second) { 201 var len = +second.length, 202 i = first.length, 203 j = 0; 204 205 for (; j < len; i++, j++) { 206 first[i] = second[j]; 207 } 208 209 first.length = i; 210 return first; 211 }, 212 213 each: each, 214 matches: matches, 215 unique: unique, 216 isArray: Array.isArray, 217 isNumeric: function (n) { 218 return !isNaN(parseFloat(n)) && isFinite(n); 219 } 220 221 }); 222 223 var uid = cash.uid = "_cash" + Date.now(); 224 225 function getDataCache(node) { 226 return node[uid] = node[uid] || {}; 227 } 228 229 function setData(node, key, value) { 230 return getDataCache(node)[key] = value; 231 } 232 233 function getData(node, key) { 234 var c = getDataCache(node); 235 if (c[key] === undefined) { 236 c[key] = node.dataset ? node.dataset[key] : cash(node).attr("data-" + key); 237 } 238 return c[key]; 239 } 240 241 function removeData(node, key) { 242 var c = getDataCache(node); 243 if (c) { 244 delete c[key]; 245 } else if (node.dataset) { 246 delete node.dataset[key]; 247 } else { 248 cash(node).removeAttr("data-" + name); 249 } 250 } 251 252 fn.extend({ 253 data: function (name, value) { 254 if (isString(name)) { 255 return value === undefined ? getData(this[0], name) : this.each(function (v) { 256 return setData(v, name, value); 257 }); 258 } 259 260 for (var key in name) { 261 this.data(key, name[key]); 262 } 263 264 return this; 265 }, 266 267 removeData: function (key) { 268 return this.each(function (v) { 269 return removeData(v, key); 270 }); 271 } 272 273 }); 274 275 var notWhiteMatch = /\S+/g; 276 277 function getClasses(c) { 278 return isString(c) && c.match(notWhiteMatch); 279 } 280 281 function hasClass(v, c) { 282 return v.classList ? v.classList.contains(c) : new RegExp("(^| )" + c + "( |$)", "gi").test(v.className); 283 } 284 285 function addClass(v, c, spacedName) { 286 if (v.classList) { 287 v.classList.add(c); 288 } else if (spacedName.indexOf(" " + c + " ")) { 289 v.className += " " + c; 290 } 291 } 292 293 function removeClass(v, c) { 294 if (v.classList) { 295 v.classList.remove(c); 296 } else { 297 v.className = v.className.replace(c, ""); 298 } 299 } 300 301 fn.extend({ 302 addClass: function (c) { 303 var classes = getClasses(c); 304 305 return classes ? this.each(function (v) { 306 var spacedName = " " + v.className + " "; 307 each(classes, function (c) { 308 addClass(v, c, spacedName); 309 }); 310 }) : this; 311 }, 312 313 attr: function (name, value) { 314 if (!name) { 315 return undefined; 316 } 317 318 if (isString(name)) { 319 if (value === undefined) { 320 return this[0] ? this[0].getAttribute ? this[0].getAttribute(name) : this[0][name] : undefined; 321 } 322 323 return this.each(function (v) { 324 if (v.setAttribute) { 325 v.setAttribute(name, value); 326 } else { 327 v[name] = value; 328 } 329 }); 330 } 331 332 for (var key in name) { 333 this.attr(key, name[key]); 334 } 335 336 return this; 337 }, 338 339 hasClass: function (c) { 340 var check = false, 341 classes = getClasses(c); 342 if (classes && classes.length) { 343 this.each(function (v) { 344 check = hasClass(v, classes[0]); 345 return !check; 346 }); 347 } 348 return check; 349 }, 350 351 prop: function (name, value) { 352 if (isString(name)) { 353 return value === undefined ? this[0][name] : this.each(function (v) { 354 v[name] = value; 355 }); 356 } 357 358 for (var key in name) { 359 this.prop(key, name[key]); 360 } 361 362 return this; 363 }, 364 365 removeAttr: function (name) { 366 return this.each(function (v) { 367 if (v.removeAttribute) { 368 v.removeAttribute(name); 369 } else { 370 delete v[name]; 371 } 372 }); 373 }, 374 375 removeClass: function (c) { 376 if (!arguments.length) { 377 return this.attr("class", ""); 378 } 379 var classes = getClasses(c); 380 return classes ? this.each(function (v) { 381 each(classes, function (c) { 382 removeClass(v, c); 383 }); 384 }) : this; 385 }, 386 387 removeProp: function (name) { 388 return this.each(function (v) { 389 delete v[name]; 390 }); 391 }, 392 393 toggleClass: function (c, state) { 394 if (state !== undefined) { 395 return this[state ? "addClass" : "removeClass"](c); 396 } 397 var classes = getClasses(c); 398 return classes ? this.each(function (v) { 399 var spacedName = " " + v.className + " "; 400 each(classes, function (c) { 401 if (hasClass(v, c)) { 402 removeClass(v, c); 403 } else { 404 addClass(v, c, spacedName); 405 } 406 }); 407 }) : this; 408 } }); 409 410 fn.extend({ 411 add: function (selector, context) { 412 return unique(cash.merge(this, cash(selector, context))); 413 }, 414 415 each: function (callback) { 416 each(this, callback); 417 return this; 418 }, 419 420 eq: function (index) { 421 return cash(this.get(index)); 422 }, 423 424 filter: function (selector) { 425 if (!selector) { 426 return this; 427 } 428 429 var comparator = isFunction(selector) ? selector : getCompareFunction(selector); 430 431 return cash(filter.call(this, function (e) { 432 return comparator(e, selector); 433 })); 434 }, 435 436 first: function () { 437 return this.eq(0); 438 }, 439 440 get: function (index) { 441 if (index === undefined) { 442 return slice.call(this); 443 } 444 return index < 0 ? this[index + this.length] : this[index]; 445 }, 446 447 index: function (elem) { 448 var child = elem ? cash(elem)[0] : this[0], 449 collection = elem ? this : cash(child).parent().children(); 450 return slice.call(collection).indexOf(child); 451 }, 452 453 last: function () { 454 return this.eq(-1); 455 } 456 457 }); 458 459 var camelCase = function () { 460 var camelRegex = /(?:^\w|[A-Z]|\b\w)/g, 461 whiteSpace = /[\s-_]+/g; 462 return function (str) { 463 return str.replace(camelRegex, function (letter, index) { 464 return letter[index === 0 ? "toLowerCase" : "toUpperCase"](); 465 }).replace(whiteSpace, ""); 466 }; 467 }(); 468 469 var getPrefixedProp = function () { 470 var cache = {}, 471 doc = document, 472 div = doc.createElement("div"), 473 style = div.style; 474 475 return function (prop) { 476 prop = camelCase(prop); 477 if (cache[prop]) { 478 return cache[prop]; 479 } 480 481 var ucProp = prop.charAt(0).toUpperCase() + prop.slice(1), 482 prefixes = ["webkit", "moz", "ms", "o"], 483 props = (prop + " " + prefixes.join(ucProp + " ") + ucProp).split(" "); 484 485 each(props, function (p) { 486 if (p in style) { 487 cache[p] = prop = cache[prop] = p; 488 return false; 489 } 490 }); 491 492 return cache[prop]; 493 }; 494 }(); 495 496 cash.prefixedProp = getPrefixedProp; 497 cash.camelCase = camelCase; 498 499 fn.extend({ 500 css: function (prop, value) { 501 if (isString(prop)) { 502 prop = getPrefixedProp(prop); 503 return arguments.length > 1 ? this.each(function (v) { 504 return v.style[prop] = value; 505 }) : win.getComputedStyle(this[0])[prop]; 506 } 507 508 for (var key in prop) { 509 this.css(key, prop[key]); 510 } 511 512 return this; 513 } 514 515 }); 516 517 function compute(el, prop) { 518 return parseInt(win.getComputedStyle(el[0], null)[prop], 10) || 0; 519 } 520 521 each(["Width", "Height"], function (v) { 522 var lower = v.toLowerCase(); 523 524 fn[lower] = function () { 525 return this[0].getBoundingClientRect()[lower]; 526 }; 527 528 fn["inner" + v] = function () { 529 return this[0]["client" + v]; 530 }; 531 532 fn["outer" + v] = function (margins) { 533 return this[0]["offset" + v] + (margins ? compute(this, "margin" + (v === "Width" ? "Left" : "Top")) + compute(this, "margin" + (v === "Width" ? "Right" : "Bottom")) : 0); 534 }; 535 }); 536 537 function registerEvent(node, eventName, callback) { 538 var eventCache = getData(node, "_cashEvents") || setData(node, "_cashEvents", {}); 539 eventCache[eventName] = eventCache[eventName] || []; 540 eventCache[eventName].push(callback); 541 node.addEventListener(eventName, callback); 542 } 543 544 function removeEvent(node, eventName, callback) { 545 var events = getData(node, "_cashEvents"), 546 eventCache = events && events[eventName], 547 index; 548 549 if (!eventCache) { 550 return; 551 } 552 553 if (callback) { 554 node.removeEventListener(eventName, callback); 555 index = eventCache.indexOf(callback); 556 if (index >= 0) { 557 eventCache.splice(index, 1); 558 } 559 } else { 560 each(eventCache, function (event) { 561 node.removeEventListener(eventName, event); 562 }); 563 eventCache = []; 564 } 565 } 566 567 fn.extend({ 568 off: function (eventName, callback) { 569 return this.each(function (v) { 570 return removeEvent(v, eventName, callback); 571 }); 572 }, 573 574 on: function (eventName, delegate, callback, runOnce) { 575 // jshint ignore:line 576 var originalCallback; 577 if (!isString(eventName)) { 578 for (var key in eventName) { 579 this.on(key, delegate, eventName[key]); 580 } 581 return this; 582 } 583 584 if (isFunction(delegate)) { 585 callback = delegate; 586 delegate = null; 587 } 588 589 if (eventName === "ready") { 590 onReady(callback); 591 return this; 592 } 593 594 if (delegate) { 595 originalCallback = callback; 596 callback = function (e) { 597 var t = e.target; 598 while (!matches(t, delegate)) { 599 if (t === this || t === null) { 600 return t = false; 601 } 602 603 t = t.parentNode; 604 } 605 606 if (t) { 607 originalCallback.call(t, e); 608 } 609 }; 610 } 611 612 return this.each(function (v) { 613 var finalCallback = callback; 614 if (runOnce) { 615 finalCallback = function () { 616 callback.apply(this, arguments); 617 removeEvent(v, eventName, finalCallback); 618 }; 619 } 620 registerEvent(v, eventName, finalCallback); 621 }); 622 }, 623 624 one: function (eventName, delegate, callback) { 625 return this.on(eventName, delegate, callback, true); 626 }, 627 628 ready: onReady, 629 630 /** 631 * Modified 632 * Triggers browser event 633 * @param String eventName 634 * @param Object data - Add properties to event object 635 */ 636 trigger: function (eventName, data) { 637 if (document.createEvent) { 638 var evt = document.createEvent('HTMLEvents'); 639 evt.initEvent(eventName, true, false); 640 evt = this.extend(evt, data); 641 return this.each(function (v) { 642 return v.dispatchEvent(evt); 643 }); 644 } 645 } 646 647 }); 648 649 function encode(name, value) { 650 return "&" + encodeURIComponent(name) + "=" + encodeURIComponent(value).replace(/%20/g, "+"); 651 } 652 653 function getSelectMultiple_(el) { 654 var values = []; 655 each(el.options, function (o) { 656 if (o.selected) { 657 values.push(o.value); 658 } 659 }); 660 return values.length ? values : null; 661 } 662 663 function getSelectSingle_(el) { 664 var selectedIndex = el.selectedIndex; 665 return selectedIndex >= 0 ? el.options[selectedIndex].value : null; 666 } 667 668 function getValue(el) { 669 var type = el.type; 670 if (!type) { 671 return null; 672 } 673 switch (type.toLowerCase()) { 674 case "select-one": 675 return getSelectSingle_(el); 676 case "select-multiple": 677 return getSelectMultiple_(el); 678 case "radio": 679 return el.checked ? el.value : null; 680 case "checkbox": 681 return el.checked ? el.value : null; 682 default: 683 return el.value ? el.value : null; 684 } 685 } 686 687 fn.extend({ 688 serialize: function () { 689 var query = ""; 690 691 each(this[0].elements || this, function (el) { 692 if (el.disabled || el.tagName === "FIELDSET") { 693 return; 694 } 695 var name = el.name; 696 switch (el.type.toLowerCase()) { 697 case "file": 698 case "reset": 699 case "submit": 700 case "button": 701 break; 702 case "select-multiple": 703 var values = getValue(el); 704 if (values !== null) { 705 each(values, function (value) { 706 query += encode(name, value); 707 }); 708 } 709 break; 710 default: 711 var value = getValue(el); 712 if (value !== null) { 713 query += encode(name, value); 714 } 715 } 716 }); 717 718 return query.substr(1); 719 }, 720 721 val: function (value) { 722 if (value === undefined) { 723 return getValue(this[0]); 724 } 725 726 return this.each(function (v) { 727 return v.value = value; 728 }); 729 } 730 731 }); 732 733 function insertElement(el, child, prepend) { 734 if (prepend) { 735 var first = el.childNodes[0]; 736 el.insertBefore(child, first); 737 } else { 738 el.appendChild(child); 739 } 740 } 741 742 function insertContent(parent, child, prepend) { 743 var str = isString(child); 744 745 if (!str && child.length) { 746 each(child, function (v) { 747 return insertContent(parent, v, prepend); 748 }); 749 return; 750 } 751 752 each(parent, str ? function (v) { 753 return v.insertAdjacentHTML(prepend ? "afterbegin" : "beforeend", child); 754 } : function (v, i) { 755 return insertElement(v, i === 0 ? child : child.cloneNode(true), prepend); 756 }); 757 } 758 759 fn.extend({ 760 after: function (selector) { 761 cash(selector).insertAfter(this); 762 return this; 763 }, 764 765 append: function (content) { 766 insertContent(this, content); 767 return this; 768 }, 769 770 appendTo: function (parent) { 771 insertContent(cash(parent), this); 772 return this; 773 }, 774 775 before: function (selector) { 776 cash(selector).insertBefore(this); 777 return this; 778 }, 779 780 clone: function () { 781 return cash(this.map(function (v) { 782 return v.cloneNode(true); 783 })); 784 }, 785 786 empty: function () { 787 this.html(""); 788 return this; 789 }, 790 791 html: function (content) { 792 if (content === undefined) { 793 return this[0].innerHTML; 794 } 795 var source = content.nodeType ? content[0].outerHTML : content; 796 return this.each(function (v) { 797 return v.innerHTML = source; 798 }); 799 }, 800 801 insertAfter: function (selector) { 802 var _this = this; 803 804 cash(selector).each(function (el, i) { 805 var parent = el.parentNode, 806 sibling = el.nextSibling; 807 _this.each(function (v) { 808 parent.insertBefore(i === 0 ? v : v.cloneNode(true), sibling); 809 }); 810 }); 811 812 return this; 813 }, 814 815 insertBefore: function (selector) { 816 var _this2 = this; 817 cash(selector).each(function (el, i) { 818 var parent = el.parentNode; 819 _this2.each(function (v) { 820 parent.insertBefore(i === 0 ? v : v.cloneNode(true), el); 821 }); 822 }); 823 return this; 824 }, 825 826 prepend: function (content) { 827 insertContent(this, content, true); 828 return this; 829 }, 830 831 prependTo: function (parent) { 832 insertContent(cash(parent), this, true); 833 return this; 834 }, 835 836 remove: function () { 837 return this.each(function (v) { 838 if (!!v.parentNode) { 839 return v.parentNode.removeChild(v); 840 } 841 }); 842 }, 843 844 text: function (content) { 845 if (content === undefined) { 846 return this[0].textContent; 847 } 848 return this.each(function (v) { 849 return v.textContent = content; 850 }); 851 } 852 853 }); 854 855 var docEl = doc.documentElement; 856 857 fn.extend({ 858 position: function () { 859 var el = this[0]; 860 return { 861 left: el.offsetLeft, 862 top: el.offsetTop 863 }; 864 }, 865 866 offset: function () { 867 var rect = this[0].getBoundingClientRect(); 868 return { 869 top: rect.top + win.pageYOffset - docEl.clientTop, 870 left: rect.left + win.pageXOffset - docEl.clientLeft 871 }; 872 }, 873 874 offsetParent: function () { 875 return cash(this[0].offsetParent); 876 } 877 878 }); 879 880 fn.extend({ 881 children: function (selector) { 882 var elems = []; 883 this.each(function (el) { 884 push.apply(elems, el.children); 885 }); 886 elems = unique(elems); 887 888 return !selector ? elems : elems.filter(function (v) { 889 return matches(v, selector); 890 }); 891 }, 892 893 closest: function (selector) { 894 if (!selector || this.length < 1) { 895 return cash(); 896 } 897 if (this.is(selector)) { 898 return this.filter(selector); 899 } 900 return this.parent().closest(selector); 901 }, 902 903 is: function (selector) { 904 if (!selector) { 905 return false; 906 } 907 908 var match = false, 909 comparator = getCompareFunction(selector); 910 911 this.each(function (el) { 912 match = comparator(el, selector); 913 return !match; 914 }); 915 916 return match; 917 }, 918 919 find: function (selector) { 920 if (!selector || selector.nodeType) { 921 return cash(selector && this.has(selector).length ? selector : null); 922 } 923 924 var elems = []; 925 this.each(function (el) { 926 push.apply(elems, find(selector, el)); 927 }); 928 929 return unique(elems); 930 }, 931 932 has: function (selector) { 933 var comparator = isString(selector) ? function (el) { 934 return find(selector, el).length !== 0; 935 } : function (el) { 936 return el.contains(selector); 937 }; 938 939 return this.filter(comparator); 940 }, 941 942 next: function () { 943 return cash(this[0].nextElementSibling); 944 }, 945 946 not: function (selector) { 947 if (!selector) { 948 return this; 949 } 950 951 var comparator = getCompareFunction(selector); 952 953 return this.filter(function (el) { 954 return !comparator(el, selector); 955 }); 956 }, 957 958 parent: function () { 959 var result = []; 960 961 this.each(function (item) { 962 if (item && item.parentNode) { 963 result.push(item.parentNode); 964 } 965 }); 966 967 return unique(result); 968 }, 969 970 parents: function (selector) { 971 var last, 972 result = []; 973 974 this.each(function (item) { 975 last = item; 976 977 while (last && last.parentNode && last !== doc.body.parentNode) { 978 last = last.parentNode; 979 980 if (!selector || selector && matches(last, selector)) { 981 result.push(last); 982 } 983 } 984 }); 985 986 return unique(result); 987 }, 988 989 prev: function () { 990 return cash(this[0].previousElementSibling); 991 }, 992 993 siblings: function (selector) { 994 var collection = this.parent().children(selector), 995 el = this[0]; 996 997 return collection.filter(function (i) { 998 return i !== el; 999 }); 1000 } 1001 1002 }); 1003 1004 return cash; 1005}); 1006; 1007var Component = function () { 1008 /** 1009 * Generic constructor for all components 1010 * @constructor 1011 * @param {Element} el 1012 * @param {Object} options 1013 */ 1014 function Component(classDef, el, options) { 1015 _classCallCheck(this, Component); 1016 1017 // Display error if el is valid HTML Element 1018 if (!(el instanceof Element)) { 1019 console.error(Error(el + ' is not an HTML Element')); 1020 } 1021 1022 // If exists, destroy and reinitialize in child 1023 var ins = classDef.getInstance(el); 1024 if (!!ins) { 1025 ins.destroy(); 1026 } 1027 1028 this.el = el; 1029 this.$el = cash(el); 1030 } 1031 1032 /** 1033 * Initializes components 1034 * @param {class} classDef 1035 * @param {Element | NodeList | jQuery} els 1036 * @param {Object} options 1037 */ 1038 1039 1040 _createClass(Component, null, [{ 1041 key: "init", 1042 value: function init(classDef, els, options) { 1043 var instances = null; 1044 if (els instanceof Element) { 1045 instances = new classDef(els, options); 1046 } else if (!!els && (els.jquery || els.cash || els instanceof NodeList)) { 1047 var instancesArr = []; 1048 for (var i = 0; i < els.length; i++) { 1049 instancesArr.push(new classDef(els[i], options)); 1050 } 1051 instances = instancesArr; 1052 } 1053 1054 return instances; 1055 } 1056 }]); 1057 1058 return Component; 1059}(); 1060 1061; // Required for Meteor package, the use of window prevents export by Meteor 1062(function (window) { 1063 if (window.Package) { 1064 M = {}; 1065 } else { 1066 window.M = {}; 1067 } 1068 1069 // Check for jQuery 1070 M.jQueryLoaded = !!window.jQuery; 1071})(window); 1072 1073// AMD 1074if (typeof define === 'function' && define.amd) { 1075 define('M', [], function () { 1076 return M; 1077 }); 1078 1079 // Common JS 1080} else if (typeof exports !== 'undefined' && !exports.nodeType) { 1081 if (typeof module !== 'undefined' && !module.nodeType && module.exports) { 1082 exports = module.exports = M; 1083 } 1084 exports.default = M; 1085} 1086 1087M.version = '1.0.0'; 1088 1089M.keys = { 1090 TAB: 9, 1091 ENTER: 13, 1092 ESC: 27, 1093 ARROW_UP: 38, 1094 ARROW_DOWN: 40 1095}; 1096 1097/** 1098 * TabPress Keydown handler 1099 */ 1100M.tabPressed = false; 1101M.keyDown = false; 1102var docHandleKeydown = function (e) { 1103 M.keyDown = true; 1104 if (e.which === M.keys.TAB || e.which === M.keys.ARROW_DOWN || e.which === M.keys.ARROW_UP) { 1105 M.tabPressed = true; 1106 } 1107}; 1108var docHandleKeyup = function (e) { 1109 M.keyDown = false; 1110 if (e.which === M.keys.TAB || e.which === M.keys.ARROW_DOWN || e.which === M.keys.ARROW_UP) { 1111 M.tabPressed = false; 1112 } 1113}; 1114var docHandleFocus = function (e) { 1115 if (M.keyDown) { 1116 document.body.classList.add('keyboard-focused'); 1117 } 1118}; 1119var docHandleBlur = function (e) { 1120 document.body.classList.remove('keyboard-focused'); 1121}; 1122document.addEventListener('keydown', docHandleKeydown, true); 1123document.addEventListener('keyup', docHandleKeyup, true); 1124document.addEventListener('focus', docHandleFocus, true); 1125document.addEventListener('blur', docHandleBlur, true); 1126 1127/** 1128 * Initialize jQuery wrapper for plugin 1129 * @param {Class} plugin javascript class 1130 * @param {string} pluginName jQuery plugin name 1131 * @param {string} classRef Class reference name 1132 */ 1133M.initializeJqueryWrapper = function (plugin, pluginName, classRef) { 1134 jQuery.fn[pluginName] = function (methodOrOptions) { 1135 // Call plugin method if valid method name is passed in 1136 if (plugin.prototype[methodOrOptions]) { 1137 var params = Array.prototype.slice.call(arguments, 1); 1138 1139 // Getter methods 1140 if (methodOrOptions.slice(0, 3) === 'get') { 1141 var instance = this.first()[0][classRef]; 1142 return instance[methodOrOptions].apply(instance, params); 1143 } 1144 1145 // Void methods 1146 return this.each(function () { 1147 var instance = this[classRef]; 1148 instance[methodOrOptions].apply(instance, params); 1149 }); 1150 1151 // Initialize plugin if options or no argument is passed in 1152 } else if (typeof methodOrOptions === 'object' || !methodOrOptions) { 1153 plugin.init(this, arguments[0]); 1154 return this; 1155 } 1156 1157 // Return error if an unrecognized method name is passed in 1158 jQuery.error("Method " + methodOrOptions + " does not exist on jQuery." + pluginName); 1159 }; 1160}; 1161 1162/** 1163 * Automatically initialize components 1164 * @param {Element} context DOM Element to search within for components 1165 */ 1166M.AutoInit = function (context) { 1167 // Use document.body if no context is given 1168 var root = !!context ? context : document.body; 1169 1170 var registry = { 1171 Autocomplete: root.querySelectorAll('.autocomplete:not(.no-autoinit)'), 1172 Carousel: root.querySelectorAll('.carousel:not(.no-autoinit)'), 1173 Chips: root.querySelectorAll('.chips:not(.no-autoinit)'), 1174 Collapsible: root.querySelectorAll('.collapsible:not(.no-autoinit)'), 1175 Datepicker: root.querySelectorAll('.datepicker:not(.no-autoinit)'), 1176 Dropdown: root.querySelectorAll('.dropdown-trigger:not(.no-autoinit)'), 1177 Materialbox: root.querySelectorAll('.materialboxed:not(.no-autoinit)'), 1178 Modal: root.querySelectorAll('.modal:not(.no-autoinit)'), 1179 Parallax: root.querySelectorAll('.parallax:not(.no-autoinit)'), 1180 Pushpin: root.querySelectorAll('.pushpin:not(.no-autoinit)'), 1181 ScrollSpy: root.querySelectorAll('.scrollspy:not(.no-autoinit)'), 1182 FormSelect: root.querySelectorAll('select:not(.no-autoinit)'), 1183 Sidenav: root.querySelectorAll('.sidenav:not(.no-autoinit)'), 1184 Tabs: root.querySelectorAll('.tabs:not(.no-autoinit)'), 1185 TapTarget: root.querySelectorAll('.tap-target:not(.no-autoinit)'), 1186 Timepicker: root.querySelectorAll('.timepicker:not(.no-autoinit)'), 1187 Tooltip: root.querySelectorAll('.tooltipped:not(.no-autoinit)'), 1188 FloatingActionButton: root.querySelectorAll('.fixed-action-btn:not(.no-autoinit)') 1189 }; 1190 1191 for (var pluginName in registry) { 1192 var plugin = M[pluginName]; 1193 plugin.init(registry[pluginName]); 1194 } 1195}; 1196 1197/** 1198 * Generate approximated selector string for a jQuery object 1199 * @param {jQuery} obj jQuery object to be parsed 1200 * @returns {string} 1201 */ 1202M.objectSelectorString = function (obj) { 1203 var tagStr = obj.prop('tagName') || ''; 1204 var idStr = obj.attr('id') || ''; 1205 var classStr = obj.attr('class') || ''; 1206 return (tagStr + idStr + classStr).replace(/\s/g, ''); 1207}; 1208 1209// Unique Random ID 1210M.guid = function () { 1211 function s4() { 1212 return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1); 1213 } 1214 return function () { 1215 return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4(); 1216 }; 1217}(); 1218 1219/** 1220 * Escapes hash from special characters 1221 * @param {string} hash String returned from this.hash 1222 * @returns {string} 1223 */ 1224M.escapeHash = function (hash) { 1225 return hash.replace(/(:|\.|\[|\]|,|=|\/)/g, '\\$1'); 1226}; 1227 1228M.elementOrParentIsFixed = function (element) { 1229 var $element = $(element); 1230 var $checkElements = $element.add($element.parents()); 1231 var isFixed = false; 1232 $checkElements.each(function () { 1233 if ($(this).css('position') === 'fixed') { 1234 isFixed = true; 1235 return false; 1236 } 1237 }); 1238 return isFixed; 1239}; 1240 1241/** 1242 * @typedef {Object} Edges 1243 * @property {Boolean} top If the top edge was exceeded 1244 * @property {Boolean} right If the right edge was exceeded 1245 * @property {Boolean} bottom If the bottom edge was exceeded 1246 * @property {Boolean} left If the left edge was exceeded 1247 */ 1248 1249/** 1250 * @typedef {Object} Bounding 1251 * @property {Number} left left offset coordinate 1252 * @property {Number} top top offset coordinate 1253 * @property {Number} width 1254 * @property {Number} height 1255 */ 1256 1257/** 1258 * Escapes hash from special characters 1259 * @param {Element} container Container element that acts as the boundary 1260 * @param {Bounding} bounding element bounding that is being checked 1261 * @param {Number} offset offset from edge that counts as exceeding 1262 * @returns {Edges} 1263 */ 1264M.checkWithinContainer = function (container, bounding, offset) { 1265 var edges = { 1266 top: false, 1267 right: false, 1268 bottom: false, 1269 left: false 1270 }; 1271 1272 var containerRect = container.getBoundingClientRect(); 1273 // If body element is smaller than viewport, use viewport height instead. 1274 var containerBottom = container === document.body ? Math.max(containerRect.bottom, window.innerHeight) : containerRect.bottom; 1275 1276 var scrollLeft = container.scrollLeft; 1277 var scrollTop = container.scrollTop; 1278 1279 var scrolledX = bounding.left - scrollLeft; 1280 var scrolledY = bounding.top - scrollTop; 1281 1282 // Check for container and viewport for each edge 1283 if (scrolledX < containerRect.left + offset || scrolledX < offset) { 1284 edges.left = true; 1285 } 1286 1287 if (scrolledX + bounding.width > containerRect.right - offset || scrolledX + bounding.width > window.innerWidth - offset) { 1288 edges.right = true; 1289 } 1290 1291 if (scrolledY < containerRect.top + offset || scrolledY < offset) { 1292 edges.top = true; 1293 } 1294 1295 if (scrolledY + bounding.height > containerBottom - offset || scrolledY + bounding.height > window.innerHeight - offset) { 1296 edges.bottom = true; 1297 } 1298 1299 return edges; 1300}; 1301 1302M.checkPossibleAlignments = function (el, container, bounding, offset) { 1303 var canAlign = { 1304 top: true, 1305 right: true, 1306 bottom: true, 1307 left: true, 1308 spaceOnTop: null, 1309 spaceOnRight: null, 1310 spaceOnBottom: null, 1311 spaceOnLeft: null 1312 }; 1313 1314 var containerAllowsOverflow = getComputedStyle(container).overflow === 'visible'; 1315 var containerRect = container.getBoundingClientRect(); 1316 var containerHeight = Math.min(containerRect.height, window.innerHeight); 1317 var containerWidth = Math.min(containerRect.width, window.innerWidth); 1318 var elOffsetRect = el.getBoundingClientRect(); 1319 1320 var scrollLeft = container.scrollLeft; 1321 var scrollTop = container.scrollTop; 1322 1323 var scrolledX = bounding.left - scrollLeft; 1324 var scrolledYTopEdge = bounding.top - scrollTop; 1325 var scrolledYBottomEdge = bounding.top + elOffsetRect.height - scrollTop; 1326 1327 // Check for container and viewport for left 1328 canAlign.spaceOnRight = !containerAllowsOverflow ? containerWidth - (scrolledX + bounding.width) : window.innerWidth - (elOffsetRect.left + bounding.width); 1329 if (canAlign.spaceOnRight < 0) { 1330 canAlign.left = false; 1331 } 1332 1333 // Check for container and viewport for Right 1334 canAlign.spaceOnLeft = !containerAllowsOverflow ? scrolledX - bounding.width + elOffsetRect.width : elOffsetRect.right - bounding.width; 1335 if (canAlign.spaceOnLeft < 0) { 1336 canAlign.right = false; 1337 } 1338 1339 // Check for container and viewport for Top 1340 canAlign.spaceOnBottom = !containerAllowsOverflow ? containerHeight - (scrolledYTopEdge + bounding.height + offset) : window.innerHeight - (elOffsetRect.top + bounding.height + offset); 1341 if (canAlign.spaceOnBottom < 0) { 1342 canAlign.top = false; 1343 } 1344 1345 // Check for container and viewport for Bottom 1346 canAlign.spaceOnTop = !containerAllowsOverflow ? scrolledYBottomEdge - (bounding.height - offset) : elOffsetRect.bottom - (bounding.height + offset); 1347 if (canAlign.spaceOnTop < 0) { 1348 canAlign.bottom = false; 1349 } 1350 1351 return canAlign; 1352}; 1353 1354M.getOverflowParent = function (element) { 1355 if (element == null) { 1356 return null; 1357 } 1358 1359 if (element === document.body || getComputedStyle(element).overflow !== 'visible') { 1360 return element; 1361 } 1362 1363 return M.getOverflowParent(element.parentElement); 1364}; 1365 1366/** 1367 * Gets id of component from a trigger 1368 * @param {Element} trigger trigger 1369 * @returns {string} 1370 */ 1371M.getIdFromTrigger = function (trigger) { 1372 var id = trigger.getAttribute('data-target'); 1373 if (!id) { 1374 id = trigger.getAttribute('href'); 1375 if (id) { 1376 id = id.slice(1); 1377 } else { 1378 id = ''; 1379 } 1380 } 1381 return id; 1382}; 1383 1384/** 1385 * Multi browser support for document scroll top 1386 * @returns {Number} 1387 */ 1388M.getDocumentScrollTop = function () { 1389 return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0; 1390}; 1391 1392/** 1393 * Multi browser support for document scroll left 1394 * @returns {Number} 1395 */ 1396M.getDocumentScrollLeft = function () { 1397 return window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0; 1398}; 1399 1400/** 1401 * @typedef {Object} Edges 1402 * @property {Boolean} top If the top edge was exceeded 1403 * @property {Boolean} right If the right edge was exceeded 1404 * @property {Boolean} bottom If the bottom edge was exceeded 1405 * @property {Boolean} left If the left edge was exceeded 1406 */ 1407 1408/** 1409 * @typedef {Object} Bounding 1410 * @property {Number} left left offset coordinate 1411 * @property {Number} top top offset coordinate 1412 * @property {Number} width 1413 * @property {Number} height 1414 */ 1415 1416/** 1417 * Get time in ms 1418 * @license https://raw.github.com/jashkenas/underscore/master/LICENSE 1419 * @type {function} 1420 * @return {number} 1421 */ 1422var getTime = Date.now || function () { 1423 return new Date().getTime(); 1424}; 1425 1426/** 1427 * Returns a function, that, when invoked, will only be triggered at most once 1428 * during a given window of time. Normally, the throttled function will run 1429 * as much as it can, without ever going more than once per `wait` duration; 1430 * but if you'd like to disable the execution on the leading edge, pass 1431 * `{leading: false}`. To disable execution on the trailing edge, ditto. 1432 * @license https://raw.github.com/jashkenas/underscore/master/LICENSE 1433 * @param {function} func 1434 * @param {number} wait 1435 * @param {Object=} options 1436 * @returns {Function} 1437 */ 1438M.throttle = function (func, wait, options) { 1439 var context = void 0, 1440 args = void 0, 1441 result = void 0; 1442 var timeout = null; 1443 var previous = 0; 1444 options || (options = {}); 1445 var later = function () { 1446 previous = options.leading === false ? 0 : getTime(); 1447 timeout = null; 1448 result = func.apply(context, args); 1449 context = args = null; 1450 }; 1451 return function () { 1452 var now = getTime(); 1453 if (!previous && options.leading === false) previous = now; 1454 var remaining = wait - (now - previous); 1455 context = this; 1456 args = arguments; 1457 if (remaining <= 0) { 1458 clearTimeout(timeout); 1459 timeout = null; 1460 previous = now; 1461 result = func.apply(context, args); 1462 context = args = null; 1463 } else if (!timeout && options.trailing !== false) { 1464 timeout = setTimeout(later, remaining); 1465 } 1466 return result; 1467 }; 1468}; 1469; /* 1470 v2.2.0 1471 2017 Julian Garnier 1472 Released under the MIT license 1473 */ 1474var $jscomp = { scope: {} };$jscomp.defineProperty = "function" == typeof Object.defineProperties ? Object.defineProperty : function (e, r, p) { 1475 if (p.get || p.set) throw new TypeError("ES3 does not support getters and setters.");e != Array.prototype && e != Object.prototype && (e[r] = p.value); 1476};$jscomp.getGlobal = function (e) { 1477 return "undefined" != typeof window && window === e ? e : "undefined" != typeof global && null != global ? global : e; 1478};$jscomp.global = $jscomp.getGlobal(this);$jscomp.SYMBOL_PREFIX = "jscomp_symbol_"; 1479$jscomp.initSymbol = function () { 1480 $jscomp.initSymbol = function () {};$jscomp.global.Symbol || ($jscomp.global.Symbol = $jscomp.Symbol); 1481};$jscomp.symbolCounter_ = 0;$jscomp.Symbol = function (e) { 1482 return $jscomp.SYMBOL_PREFIX + (e || "") + $jscomp.symbolCounter_++; 1483}; 1484$jscomp.initSymbolIterator = function () { 1485 $jscomp.initSymbol();var e = $jscomp.global.Symbol.iterator;e || (e = $jscomp.global.Symbol.iterator = $jscomp.global.Symbol("iterator"));"function" != typeof Array.prototype[e] && $jscomp.defineProperty(Array.prototype, e, { configurable: !0, writable: !0, value: function () { 1486 return $jscomp.arrayIterator(this); 1487 } });$jscomp.initSymbolIterator = function () {}; 1488};$jscomp.arrayIterator = function (e) { 1489 var r = 0;return $jscomp.iteratorPrototype(function () { 1490 return r < e.length ? { done: !1, value: e[r++] } : { done: !0 }; 1491 }); 1492}; 1493$jscomp.iteratorPrototype = function (e) { 1494 $jscomp.initSymbolIterator();e = { next: e };e[$jscomp.global.Symbol.iterator] = function () { 1495 return this; 1496 };return e; 1497};$jscomp.array = $jscomp.array || {};$jscomp.iteratorFromArray = function (e, r) { 1498 $jscomp.initSymbolIterator();e instanceof String && (e += "");var p = 0, 1499 m = { next: function () { 1500 if (p < e.length) { 1501 var u = p++;return { value: r(u, e[u]), done: !1 }; 1502 }m.next = function () { 1503 return { done: !0, value: void 0 }; 1504 };return m.next(); 1505 } };m[Symbol.iterator] = function () { 1506 return m; 1507 };return m; 1508}; 1509$jscomp.polyfill = function (e, r, p, m) { 1510 if (r) { 1511 p = $jscomp.global;e = e.split(".");for (m = 0; m < e.length - 1; m++) { 1512 var u = e[m];u in p || (p[u] = {});p = p[u]; 1513 }e = e[e.length - 1];m = p[e];r = r(m);r != m && null != r && $jscomp.defineProperty(p, e, { configurable: !0, writable: !0, value: r }); 1514 } 1515};$jscomp.polyfill("Array.prototype.keys", function (e) { 1516 return e ? e : function () { 1517 return $jscomp.iteratorFromArray(this, function (e) { 1518 return e; 1519 }); 1520 }; 1521}, "es6-impl", "es3");var $jscomp$this = this; 1522(function (r) { 1523 M.anime = r(); 1524})(function () { 1525 function e(a) { 1526 if (!h.col(a)) try { 1527 return document.querySelectorAll(a); 1528 } catch (c) {} 1529 }function r(a, c) { 1530 for (var d = a.length, b = 2 <= arguments.length ? arguments[1] : void 0, f = [], n = 0; n < d; n++) { 1531 if (n in a) { 1532 var k = a[n];c.call(b, k, n, a) && f.push(k); 1533 } 1534 }return f; 1535 }function p(a) { 1536 return a.reduce(function (a, d) { 1537 return a.concat(h.arr(d) ? p(d) : d); 1538 }, []); 1539 }function m(a) { 1540 if (h.arr(a)) return a; 1541 h.str(a) && (a = e(a) || a);return a instanceof NodeList || a instanceof HTMLCollection ? [].slice.call(a) : [a]; 1542 }function u(a, c) { 1543 return a.some(function (a) { 1544 return a === c; 1545 }); 1546 }function C(a) { 1547 var c = {}, 1548 d;for (d in a) { 1549 c[d] = a[d]; 1550 }return c; 1551 }function D(a, c) { 1552 var d = C(a), 1553 b;for (b in a) { 1554 d[b] = c.hasOwnProperty(b) ? c[b] : a[b]; 1555 }return d; 1556 }function z(a, c) { 1557 var d = C(a), 1558 b;for (b in c) { 1559 d[b] = h.und(a[b]) ? c[b] : a[b]; 1560 }return d; 1561 }function T(a) { 1562 a = a.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, function (a, c, d, k) { 1563 return c + c + d + d + k + k; 1564 });var c = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a); 1565 a = parseInt(c[1], 16);var d = parseInt(c[2], 16), 1566 c = parseInt(c[3], 16);return "rgba(" + a + "," + d + "," + c + ",1)"; 1567 }function U(a) { 1568 function c(a, c, b) { 1569 0 > b && (b += 1);1 < b && --b;return b < 1 / 6 ? a + 6 * (c - a) * b : .5 > b ? c : b < 2 / 3 ? a + (c - a) * (2 / 3 - b) * 6 : a; 1570 }var d = /hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(a) || /hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(a);a = parseInt(d[1]) / 360;var b = parseInt(d[2]) / 100, 1571 f = parseInt(d[3]) / 100, 1572 d = d[4] || 1;if (0 == b) f = b = a = f;else { 1573 var n = .5 > f ? f * (1 + b) : f + b - f * b, 1574 k = 2 * f - n, 1575 f = c(k, n, a + 1 / 3), 1576 b = c(k, n, a);a = c(k, n, a - 1 / 3); 1577 }return "rgba(" + 255 * f + "," + 255 * b + "," + 255 * a + "," + d + ")"; 1578 }function y(a) { 1579 if (a = /([\+\-]?[0-9#\.]+)(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(a)) return a[2]; 1580 }function V(a) { 1581 if (-1 < a.indexOf("translate") || "perspective" === a) return "px";if (-1 < a.indexOf("rotate") || -1 < a.indexOf("skew")) return "deg"; 1582 }function I(a, c) { 1583 return h.fnc(a) ? a(c.target, c.id, c.total) : a; 1584 }function E(a, c) { 1585 if (c in a.style) return getComputedStyle(a).getPropertyValue(c.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase()) || "0"; 1586 }function J(a, c) { 1587 if (h.dom(a) && u(W, c)) return "transform";if (h.dom(a) && (a.getAttribute(c) || h.svg(a) && a[c])) return "attribute";if (h.dom(a) && "transform" !== c && E(a, c)) return "css";if (null != a[c]) return "object"; 1588 }function X(a, c) { 1589 var d = V(c), 1590 d = -1 < c.indexOf("scale") ? 1 : 0 + d;a = a.style.transform;if (!a) return d;for (var b = [], f = [], n = [], k = /(\w+)\((.+?)\)/g; b = k.exec(a);) { 1591 f.push(b[1]), n.push(b[2]); 1592 }a = r(n, function (a, b) { 1593 return f[b] === c; 1594 });return a.length ? a[0] : d; 1595 }function K(a, c) { 1596 switch (J(a, c)) {case "transform": 1597 return X(a, c);case "css": 1598 return E(a, c);case "attribute": 1599 return a.getAttribute(c);}return a[c] || 0; 1600 }function L(a, c) { 1601 var d = /^(\*=|\+=|-=)/.exec(a);if (!d) return a;var b = y(a) || 0;c = parseFloat(c);a = parseFloat(a.replace(d[0], ""));switch (d[0][0]) {case "+": 1602 return c + a + b;case "-": 1603 return c - a + b;case "*": 1604 return c * a + b;} 1605 }function F(a, c) { 1606 return Math.sqrt(Math.pow(c.x - a.x, 2) + Math.pow(c.y - a.y, 2)); 1607 }function M(a) { 1608 a = a.points;for (var c = 0, d, b = 0; b < a.numberOfItems; b++) { 1609 var f = a.getItem(b);0 < b && (c += F(d, f));d = f; 1610 }return c; 1611 }function N(a) { 1612 if (a.getTotalLength) return a.getTotalLength();switch (a.tagName.toLowerCase()) {case "circle": 1613 return 2 * Math.PI * a.getAttribute("r");case "rect": 1614 return 2 * a.getAttribute("width") + 2 * a.getAttribute("height");case "line": 1615 return F({ x: a.getAttribute("x1"), y: a.getAttribute("y1") }, { x: a.getAttribute("x2"), y: a.getAttribute("y2") });case "polyline": 1616 return M(a);case "polygon": 1617 var c = a.points;return M(a) + F(c.getItem(c.numberOfItems - 1), c.getItem(0));} 1618 }function Y(a, c) { 1619 function d(b) { 1620 b = void 0 === b ? 0 : b;return a.el.getPointAtLength(1 <= c + b ? c + b : 0); 1621 }var b = d(), 1622 f = d(-1), 1623 n = d(1);switch (a.property) {case "x": 1624 return b.x;case "y": 1625 return b.y; 1626 case "angle": 1627 return 180 * Math.atan2(n.y - f.y, n.x - f.x) / Math.PI;} 1628 }function O(a, c) { 1629 var d = /-?\d*\.?\d+/g, 1630 b;b = h.pth(a) ? a.totalLength : a;if (h.col(b)) { 1631 if (h.rgb(b)) { 1632 var f = /rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(b);b = f ? "rgba(" + f[1] + ",1)" : b; 1633 } else b = h.hex(b) ? T(b) : h.hsl(b) ? U(b) : void 0; 1634 } else f = (f = y(b)) ? b.substr(0, b.length - f.length) : b, b = c && !/\s/g.test(b) ? f + c : f;b += "";return { original: b, numbers: b.match(d) ? b.match(d).map(Number) : [0], strings: h.str(a) || c ? b.split(d) : [] }; 1635 }function P(a) { 1636 a = a ? p(h.arr(a) ? a.map(m) : m(a)) : [];return r(a, function (a, d, b) { 1637 return b.indexOf(a) === d; 1638 }); 1639 }function Z(a) { 1640 var c = P(a);return c.map(function (a, b) { 1641 return { target: a, id: b, total: c.length }; 1642 }); 1643 }function aa(a, c) { 1644 var d = C(c);if (h.arr(a)) { 1645 var b = a.length;2 !== b || h.obj(a[0]) ? h.fnc(c.duration) || (d.duration = c.duration / b) : a = { value: a }; 1646 }return m(a).map(function (a, b) { 1647 b = b ? 0 : c.delay;a = h.obj(a) && !h.pth(a) ? a : { value: a };h.und(a.delay) && (a.delay = b);return a; 1648 }).map(function (a) { 1649 return z(a, d); 1650 }); 1651 }function ba(a, c) { 1652 var d = {}, 1653 b;for (b in a) { 1654 var f = I(a[b], c);h.arr(f) && (f = f.map(function (a) { 1655 return I(a, c); 1656 }), 1 === f.length && (f = f[0]));d[b] = f; 1657 }d.duration = parseFloat(d.duration);d.delay = parseFloat(d.delay);return d; 1658 }function ca(a) { 1659 return h.arr(a) ? A.apply(this, a) : Q[a]; 1660 }function da(a, c) { 1661 var d;return a.tweens.map(function (b) { 1662 b = ba(b, c);var f = b.value, 1663 e = K(c.target, a.name), 1664 k = d ? d.to.original : e, 1665 k = h.arr(f) ? f[0] : k, 1666 w = L(h.arr(f) ? f[1] : f, k), 1667 e = y(w) || y(k) || y(e);b.from = O(k, e);b.to = O(w, e);b.start = d ? d.end : a.offset;b.end = b.start + b.delay + b.duration;b.easing = ca(b.easing);b.elasticity = (1E3 - Math.min(Math.max(b.elasticity, 1), 999)) / 1E3;b.isPath = h.pth(f);b.isColor = h.col(b.from.original);b.isColor && (b.round = 1);return d = b; 1668 }); 1669 }function ea(a, c) { 1670 return r(p(a.map(function (a) { 1671 return c.map(function (b) { 1672 var c = J(a.target, b.name);if (c) { 1673 var d = da(b, a);b = { type: c, property: b.name, animatable: a, tweens: d, duration: d[d.length - 1].end, delay: d[0].delay }; 1674 } else b = void 0;return b; 1675 }); 1676 })), function (a) { 1677 return !h.und(a); 1678 }); 1679 }function R(a, c, d, b) { 1680 var f = "delay" === a;return c.length ? (f ? Math.min : Math.max).apply(Math, c.map(function (b) { 1681 return b[a]; 1682 })) : f ? b.delay : d.offset + b.delay + b.duration; 1683 }function fa(a) { 1684 var c = D(ga, a), 1685 d = D(S, a), 1686 b = Z(a.targets), 1687 f = [], 1688 e = z(c, d), 1689 k;for (k in a) { 1690 e.hasOwnProperty(k) || "targets" === k || f.push({ name: k, offset: e.offset, tweens: aa(a[k], d) }); 1691 }a = ea(b, f);return z(c, { children: [], animatables: b, animations: a, duration: R("duration", a, c, d), delay: R("delay", a, c, d) }); 1692 }function q(a) { 1693 function c() { 1694 return window.Promise && new Promise(function (a) { 1695 return p = a; 1696 }); 1697 }function d(a) { 1698 return g.reversed ? g.duration - a : a; 1699 }function b(a) { 1700 for (var b = 0, c = {}, d = g.animations, f = d.length; b < f;) { 1701 var e = d[b], 1702 k = e.animatable, 1703 h = e.tweens, 1704 n = h.length - 1, 1705 l = h[n];n && (l = r(h, function (b) { 1706 return a < b.end; 1707 })[0] || l);for (var h = Math.min(Math.max(a - l.start - l.delay, 0), l.duration) / l.duration, w = isNaN(h) ? 1 : l.easing(h, l.elasticity), h = l.to.strings, p = l.round, n = [], m = void 0, m = l.to.numbers.length, t = 0; t < m; t++) { 1708 var x = void 0, 1709 x = l.to.numbers[t], 1710 q = l.from.numbers[t], 1711 x = l.isPath ? Y(l.value, w * x) : q + w * (x - q);p && (l.isColor && 2 < t || (x = Math.round(x * p) / p));n.push(x); 1712 }if (l = h.length) for (m = h[0], w = 0; w < l; w++) { 1713 p = h[w + 1], t = n[w], isNaN(t) || (m = p ? m + (t + p) : m + (t + " ")); 1714 } else m = n[0];ha[e.type](k.target, e.property, m, c, k.id);e.currentValue = m;b++; 1715 }if (b = Object.keys(c).length) for (d = 0; d < b; d++) { 1716 H || (H = E(document.body, "transform") ? "transform" : "-webkit-transform"), g.animatables[d].target.style[H] = c[d].join(" "); 1717 }g.currentTime = a;g.progress = a / g.duration * 100; 1718 }function f(a) { 1719 if (g[a]) g[a](g); 1720 }function e() { 1721 g.remaining && !0 !== g.remaining && g.remaining--; 1722 }function k(a) { 1723 var k = g.duration, 1724 n = g.offset, 1725 w = n + g.delay, 1726 r = g.currentTime, 1727 x = g.reversed, 1728 q = d(a);if (g.children.length) { 1729 var u = g.children, 1730 v = u.length; 1731 if (q >= g.currentTime) for (var G = 0; G < v; G++) { 1732 u[G].seek(q); 1733 } else for (; v--;) { 1734 u[v].seek(q); 1735 } 1736 }if (q >= w || !k) g.began || (g.began = !0, f("begin")), f("run");if (q > n && q < k) b(q);else if (q <= n && 0 !== r && (b(0), x && e()), q >= k && r !== k || !k) b(k), x || e();f("update");a >= k && (g.remaining ? (t = h, "alternate" === g.direction && (g.reversed = !g.reversed)) : (g.pause(), g.completed || (g.completed = !0, f("complete"), "Promise" in window && (p(), m = c()))), l = 0); 1737 }a = void 0 === a ? {} : a;var h, 1738 t, 1739 l = 0, 1740 p = null, 1741 m = c(), 1742 g = fa(a);g.reset = function () { 1743 var a = g.direction, 1744 c = g.loop;g.currentTime = 0;g.progress = 0;g.paused = !0;g.began = !1;g.completed = !1;g.reversed = "reverse" === a;g.remaining = "alternate" === a && 1 === c ? 2 : c;b(0);for (a = g.children.length; a--;) { 1745 g.children[a].reset(); 1746 } 1747 };g.tick = function (a) { 1748 h = a;t || (t = h);k((l + h - t) * q.speed); 1749 };g.seek = function (a) { 1750 k(d(a)); 1751 };g.pause = function () { 1752 var a = v.indexOf(g);-1 < a && v.splice(a, 1);g.paused = !0; 1753 };g.play = function () { 1754 g.paused && (g.paused = !1, t = 0, l = d(g.currentTime), v.push(g), B || ia()); 1755 };g.reverse = function () { 1756 g.reversed = !g.reversed;t = 0;l = d(g.currentTime); 1757 };g.restart = function () { 1758 g.pause(); 1759 g.reset();g.play(); 1760 };g.finished = m;g.reset();g.autoplay && g.play();return g; 1761 }var ga = { update: void 0, begin: void 0, run: void 0, complete: void 0, loop: 1, direction: "normal", autoplay: !0, offset: 0 }, 1762 S = { duration: 1E3, delay: 0, easing: "easeOutElastic", elasticity: 500, round: 0 }, 1763 W = "translateX translateY translateZ rotate rotateX rotateY rotateZ scale scaleX scaleY scaleZ skewX skewY perspective".split(" "), 1764 H, 1765 h = { arr: function (a) { 1766 return Array.isArray(a); 1767 }, obj: function (a) { 1768 return -1 < Object.prototype.toString.call(a).indexOf("Object"); 1769 }, 1770 pth: function (a) { 1771 return h.obj(a) && a.hasOwnProperty("totalLength"); 1772 }, svg: function (a) { 1773 return a instanceof SVGElement; 1774 }, dom: function (a) { 1775 return a.nodeType || h.svg(a); 1776 }, str: function (a) { 1777 return "string" === typeof a; 1778 }, fnc: function (a) { 1779 return "function" === typeof a; 1780 }, und: function (a) { 1781 return "undefined" === typeof a; 1782 }, hex: function (a) { 1783 return (/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(a) 1784 ); 1785 }, rgb: function (a) { 1786 return (/^rgb/.test(a) 1787 ); 1788 }, hsl: function (a) { 1789 return (/^hsl/.test(a) 1790 ); 1791 }, col: function (a) { 1792 return h.hex(a) || h.rgb(a) || h.hsl(a); 1793 } }, 1794 A = function () { 1795 function a(a, d, b) { 1796 return (((1 - 3 * b + 3 * d) * a + (3 * b - 6 * d)) * a + 3 * d) * a; 1797 }return function (c, d, b, f) { 1798 if (0 <= c && 1 >= c && 0 <= b && 1 >= b) { 1799 var e = new Float32Array(11);if (c !== d || b !== f) for (var k = 0; 11 > k; ++k) { 1800 e[k] = a(.1 * k, c, b); 1801 }return function (k) { 1802 if (c === d && b === f) return k;if (0 === k) return 0;if (1 === k) return 1;for (var h = 0, l = 1; 10 !== l && e[l] <= k; ++l) { 1803 h += .1; 1804 }--l;var l = h + (k - e[l]) / (e[l + 1] - e[l]) * .1, 1805 n = 3 * (1 - 3 * b + 3 * c) * l * l + 2 * (3 * b - 6 * c) * l + 3 * c;if (.001 <= n) { 1806 for (h = 0; 4 > h; ++h) { 1807 n = 3 * (1 - 3 * b + 3 * c) * l * l + 2 * (3 * b - 6 * c) * l + 3 * c;if (0 === n) break;var m = a(l, c, b) - k, 1808 l = l - m / n; 1809 }k = l; 1810 } else if (0 === n) k = l;else { 1811 var l = h, 1812 h = h + .1, 1813 g = 0;do { 1814 m = l + (h - l) / 2, n = a(m, c, b) - k, 0 < n ? h = m : l = m; 1815 } while (1e-7 < Math.abs(n) && 10 > ++g);k = m; 1816 }return a(k, d, f); 1817 }; 1818 } 1819 }; 1820 }(), 1821 Q = function () { 1822 function a(a, b) { 1823 return 0 === a || 1 === a ? a : -Math.pow(2, 10 * (a - 1)) * Math.sin(2 * (a - 1 - b / (2 * Math.PI) * Math.asin(1)) * Math.PI / b); 1824 }var c = "Quad Cubic Quart Quint Sine Expo Circ Back Elastic".split(" "), 1825 d = { In: [[.55, .085, .68, .53], [.55, .055, .675, .19], [.895, .03, .685, .22], [.755, .05, .855, .06], [.47, 0, .745, .715], [.95, .05, .795, .035], [.6, .04, .98, .335], [.6, -.28, .735, .045], a], Out: [[.25, .46, .45, .94], [.215, .61, .355, 1], [.165, .84, .44, 1], [.23, 1, .32, 1], [.39, .575, .565, 1], [.19, 1, .22, 1], [.075, .82, .165, 1], [.175, .885, .32, 1.275], function (b, c) { 1826 return 1 - a(1 - b, c); 1827 }], InOut: [[.455, .03, .515, .955], [.645, .045, .355, 1], [.77, 0, .175, 1], [.86, 0, .07, 1], [.445, .05, .55, .95], [1, 0, 0, 1], [.785, .135, .15, .86], [.68, -.55, .265, 1.55], function (b, c) { 1828 return .5 > b ? a(2 * b, c) / 2 : 1 - a(-2 * b + 2, c) / 2; 1829 }] }, 1830 b = { linear: A(.25, .25, .75, .75) }, 1831 f = {}, 1832 e;for (e in d) { 1833 f.type = e, d[f.type].forEach(function (a) { 1834 return function (d, f) { 1835 b["ease" + a.type + c[f]] = h.fnc(d) ? d : A.apply($jscomp$this, d); 1836 }; 1837 }(f)), f = { type: f.type }; 1838 }return b; 1839 }(), 1840 ha = { css: function (a, c, d) { 1841 return a.style[c] = d; 1842 }, attribute: function (a, c, d) { 1843 return a.setAttribute(c, d); 1844 }, object: function (a, c, d) { 1845 return a[c] = d; 1846 }, transform: function (a, c, d, b, f) { 1847 b[f] || (b[f] = []);b[f].push(c + "(" + d + ")"); 1848 } }, 1849 v = [], 1850 B = 0, 1851 ia = function () { 1852 function a() { 1853 B = requestAnimationFrame(c); 1854 }function c(c) { 1855 var b = v.length;if (b) { 1856 for (var d = 0; d < b;) { 1857 v[d] && v[d].tick(c), d++; 1858 }a(); 1859 } else cancelAnimationFrame(B), B = 0; 1860 }return a; 1861 }();q.version = "2.2.0";q.speed = 1;q.running = v;q.remove = function (a) { 1862 a = P(a);for (var c = v.length; c--;) { 1863 for (var d = v[c], b = d.animations, f = b.length; f--;) { 1864 u(a, b[f].animatable.target) && (b.splice(f, 1), b.length || d.pause()); 1865 } 1866 } 1867 };q.getValue = K;q.path = function (a, c) { 1868 var d = h.str(a) ? e(a)[0] : a, 1869 b = c || 100;return function (a) { 1870 return { el: d, property: a, totalLength: N(d) * (b / 100) }; 1871 }; 1872 };q.setDashoffset = function (a) { 1873 var c = N(a);a.setAttribute("stroke-dasharray", c);return c; 1874 };q.bezier = A;q.easings = Q;q.timeline = function (a) { 1875 var c = q(a);c.pause();c.duration = 0;c.add = function (d) { 1876 c.children.forEach(function (a) { 1877 a.began = !0;a.completed = !0; 1878 });m(d).forEach(function (b) { 1879 var d = z(b, D(S, a || {}));d.targets = d.targets || a.targets;b = c.duration;var e = d.offset;d.autoplay = !1;d.direction = c.direction;d.offset = h.und(e) ? b : L(e, b);c.began = !0;c.completed = !0;c.seek(d.offset);d = q(d);d.began = !0;d.completed = !0;d.duration > b && (c.duration = d.duration);c.children.push(d); 1880 });c.seek(0);c.reset();c.autoplay && c.restart();return c; 1881 };return c; 1882 };q.random = function (a, c) { 1883 return Math.floor(Math.random() * (c - a + 1)) + a; 1884 };return q; 1885}); 1886;(function ($, anim) { 1887 'use strict'; 1888 1889 var _defaults = { 1890 accordion: true, 1891 onOpenStart: undefined, 1892 onOpenEnd: undefined, 1893 onCloseStart: undefined, 1894 onCloseEnd: undefined, 1895 inDuration: 300, 1896 outDuration: 300 1897 }; 1898 1899 /** 1900 * @class 1901 * 1902 */ 1903 1904 var Collapsible = function (_Component) { 1905 _inherits(Collapsible, _Component); 1906 1907 /** 1908 * Construct Collapsible instance 1909 * @constructor 1910 * @param {Element} el 1911 * @param {Object} options 1912 */ 1913 function Collapsible(el, options) { 1914 _classCallCheck(this, Collapsible); 1915 1916 var _this3 = _possibleConstructorReturn(this, (Collapsible.__proto__ || Object.getPrototypeOf(Collapsible)).call(this, Collapsible, el, options)); 1917 1918 _this3.el.M_Collapsible = _this3; 1919 1920 /** 1921 * Options for the collapsible 1922 * @member Collapsible#options 1923 * @prop {Boolean} [accordion=false] - Type of the collapsible 1924 * @prop {Function} onOpenStart - Callback function called before collapsible is opened 1925 * @prop {Function} onOpenEnd - Callback function called after collapsible is opened 1926 * @prop {Function} onCloseStart - Callback function called before collapsible is closed 1927 * @prop {Function} onCloseEnd - Callback function called after collapsible is closed 1928 * @prop {Number} inDuration - Transition in duration in milliseconds. 1929 * @prop {Number} outDuration - Transition duration in milliseconds. 1930 */ 1931 _this3.options = $.extend({}, Collapsible.defaults, options); 1932 1933 // Setup tab indices 1934 _this3.$headers = _this3.$el.children('li').children('.collapsible-header'); 1935 _this3.$headers.attr('tabindex', 0); 1936 1937 _this3._setupEventHandlers(); 1938 1939 // Open first active 1940 var $activeBodies = _this3.$el.children('li.active').children('.collapsible-body'); 1941 if (_this3.options.accordion) { 1942 // Handle Accordion 1943 $activeBodies.first().css('display', 'block'); 1944 } else { 1945 // Handle Expandables 1946 $activeBodies.css('display', 'block'); 1947 } 1948 return _this3; 1949 } 1950 1951 _createClass(Collapsible, [{ 1952 key: "destroy", 1953 1954 1955 /** 1956 * Teardown component 1957 */ 1958 value: function destroy() { 1959 this._removeEventHandlers(); 1960 this.el.M_Collapsible = undefined; 1961 } 1962 1963 /** 1964 * Setup Event Handlers 1965 */ 1966 1967 }, { 1968 key: "_setupEventHandlers", 1969 value: function _setupEventHandlers() { 1970 var _this4 = this; 1971 1972 this._handleCollapsibleClickBound = this._handleCollapsibleClick.bind(this); 1973 this._handleCollapsibleKeydownBound = this._handleCollapsibleKeydown.bind(this); 1974 this.el.addEventListener('click', this._handleCollapsibleClickBound); 1975 this.$headers.each(function (header) { 1976 header.addEventListener('keydown', _this4._handleCollapsibleKeydownBound); 1977 }); 1978 } 1979 1980 /** 1981 * Remove Event Handlers 1982 */ 1983 1984 }, { 1985 key: "_removeEventHandlers", 1986 value: function _removeEventHandlers() { 1987 var _this5 = this; 1988 1989 this.el.removeEventListener('click', this._handleCollapsibleClickBound); 1990 this.$headers.each(function (header) { 1991 header.removeEventListener('keydown', _this5._handleCollapsibleKeydownBound); 1992 }); 1993 } 1994 1995 /** 1996 * Handle Collapsible Click 1997 * @param {Event} e 1998 */ 1999 2000 }, { 2001 key: "_handleCollapsibleClick", 2002 value: function _handleCollapsibleClick(e) { 2003 var $header = $(e.target).closest('.collapsible-header'); 2004 if (e.target && $header.length) { 2005 var $collapsible = $header.closest('.collapsible'); 2006 if ($collapsible[0] === this.el) { 2007 var $collapsibleLi = $header.closest('li'); 2008 var $collapsibleLis = $collapsible.children('li'); 2009 var isActive = $collapsibleLi[0].classList.contains('active'); 2010 var index = $collapsibleLis.index($collapsibleLi); 2011 2012 if (isActive) { 2013 this.close(index); 2014 } else { 2015 this.open(index); 2016 } 2017 } 2018 } 2019 } 2020 2021 /** 2022 * Handle Collapsible Keydown 2023 * @param {Event} e 2024 */ 2025 2026 }, { 2027 key: "_handleCollapsibleKeydown", 2028 value: function _handleCollapsibleKeydown(e) { 2029 if (e.keyCode === 13) { 2030 this._handleCollapsibleClickBound(e); 2031 } 2032 } 2033 2034 /** 2035 * Animate in collapsible slide 2036 * @param {Number} index - 0th index of slide 2037 */ 2038 2039 }, { 2040 key: "_animateIn", 2041 value: function _animateIn(index) { 2042 var _this6 = this; 2043 2044 var $collapsibleLi = this.$el.children('li').eq(index); 2045 if ($collapsibleLi.length) { 2046 var $body = $collapsibleLi.children('.collapsible-body'); 2047 2048 anim.remove($body[0]); 2049 $body.css({ 2050 display: 'block', 2051 overflow: 'hidden', 2052 height: 0, 2053 paddingTop: '', 2054 paddingBottom: '' 2055 }); 2056 2057 var pTop = $body.css('padding-top'); 2058 var pBottom = $body.css('padding-bottom'); 2059 var finalHeight = $body[0].scrollHeight; 2060 $body.css({ 2061 paddingTop: 0, 2062 paddingBottom: 0 2063 }); 2064 2065 anim({ 2066 targets: $body[0], 2067 height: finalHeight, 2068 paddingTop: pTop, 2069 paddingBottom: pBottom, 2070 duration: this.options.inDuration, 2071 easing: 'easeInOutCubic', 2072 complete: function (anim) { 2073 $body.css({ 2074 overflow: '', 2075 paddingTop: '', 2076 paddingBottom: '', 2077 height: '' 2078 }); 2079 2080 // onOpenEnd callback 2081 if (typeof _this6.options.onOpenEnd === 'function') { 2082 _this6.options.onOpenEnd.call(_this6, $collapsibleLi[0]); 2083 } 2084 } 2085 }); 2086 } 2087 } 2088 2089 /** 2090 * Animate out collapsible slide 2091 * @param {Number} index - 0th index of slide to open 2092 */ 2093 2094 }, { 2095 key: "_animateOut", 2096 value: function _animateOut(index) { 2097 var _this7 = this; 2098 2099 var $collapsibleLi = this.$el.children('li').eq(index); 2100 if ($collapsibleLi.length) { 2101 var $body = $collapsibleLi.children('.collapsible-body'); 2102 anim.remove($body[0]); 2103 $body.css('overflow', 'hidden'); 2104 anim({ 2105 targets: $body[0], 2106 height: 0, 2107 paddingTop: 0, 2108 paddingBottom: 0, 2109 duration: this.options.outDuration, 2110 easing: 'easeInOutCubic', 2111 complete: function () { 2112 $body.css({ 2113 height: '', 2114 overflow: '', 2115 padding: '', 2116 display: '' 2117 }); 2118 2119 // onCloseEnd callback 2120 if (typeof _this7.options.onCloseEnd === 'function') { 2121 _this7.options.onCloseEnd.call(_this7, $collapsibleLi[0]); 2122 } 2123 } 2124 }); 2125 } 2126 } 2127 2128 /** 2129 * Open Collapsible 2130 * @param {Number} index - 0th index of slide 2131 */ 2132 2133 }, { 2134 key: "open", 2135 value: function open(index) { 2136 var _this8 = this; 2137 2138 var $collapsibleLi = this.$el.children('li').eq(index); 2139 if ($collapsibleLi.length && !$collapsibleLi[0].classList.contains('active')) { 2140 // onOpenStart callback 2141 if (typeof this.options.onOpenStart === 'function') { 2142 this.options.onOpenStart.call(this, $collapsibleLi[0]); 2143 } 2144 2145 // Handle accordion behavior 2146 if (this.options.accordion) { 2147 var $collapsibleLis = this.$el.children('li'); 2148 var $activeLis = this.$el.children('li.active'); 2149 $activeLis.each(function (el) { 2150 var index = $collapsibleLis.index($(el)); 2151 _this8.close(index); 2152 }); 2153 } 2154 2155 // Animate in 2156 $collapsibleLi[0].classList.add('active'); 2157 this._animateIn(index); 2158 } 2159 } 2160 2161 /** 2162 * Close Collapsible 2163 * @param {Number} index - 0th index of slide 2164 */ 2165 2166 }, { 2167 key: "close", 2168 value: function close(index) { 2169 var $collapsibleLi = this.$el.children('li').eq(index); 2170 if ($collapsibleLi.length && $collapsibleLi[0].classList.contains('active')) { 2171 // onCloseStart callback 2172 if (typeof this.options.onCloseStart === 'function') { 2173 this.options.onCloseStart.call(this, $collapsibleLi[0]); 2174 } 2175 2176 // Animate out 2177 $collapsibleLi[0].classList.remove('active'); 2178 this._animateOut(index); 2179 } 2180 } 2181 }], [{ 2182 key: "init", 2183 value: function init(els, options) { 2184 return _get(Collapsible.__proto__ || Object.getPrototypeOf(Collapsible), "init", this).call(this, this, els, options); 2185 } 2186 2187 /** 2188 * Get Instance 2189 */ 2190 2191 }, { 2192 key: "getInstance", 2193 value: function getInstance(el) { 2194 var domElem = !!el.jquery ? el[0] : el; 2195 return domElem.M_Collapsible; 2196 } 2197 }, { 2198 key: "defaults", 2199 get: function () { 2200 return _defaults; 2201 } 2202 }]); 2203 2204 return Collapsible; 2205 }(Component); 2206 2207 M.Collapsible = Collapsible; 2208 2209 if (M.jQueryLoaded) { 2210 M.initializeJqueryWrapper(Collapsible, 'collapsible', 'M_Collapsible'); 2211 } 2212})(cash, M.anime); 2213;(function ($, anim) { 2214 'use strict'; 2215 2216 var _defaults = { 2217 alignment: 'left', 2218 autoFocus: true, 2219 constrainWidth: true, 2220 container: null, 2221 coverTrigger: true, 2222 closeOnClick: true, 2223 hover: false, 2224 inDuration: 150, 2225 outDuration: 250, 2226 onOpenStart: null, 2227 onOpenEnd: null, 2228 onCloseStart: null, 2229 onCloseEnd: null, 2230 onItemClick: null 2231 }; 2232 2233 /** 2234 * @class 2235 */ 2236 2237 var Dropdown = function (_Component2) { 2238 _inherits(Dropdown, _Component2); 2239 2240 function Dropdown(el, options) { 2241 _classCallCheck(this, Dropdown); 2242 2243 var _this9 = _possibleConstructorReturn(this, (Dropdown.__proto__ || Object.getPrototypeOf(Dropdown)).call(this, Dropdown, el, options)); 2244 2245 _this9.el.M_Dropdown = _this9; 2246 Dropdown._dropdowns.push(_this9); 2247 2248 _this9.id = M.getIdFromTrigger(el); 2249 _this9.dropdownEl = document.getElementById(_this9.id); 2250 _this9.$dropdownEl = $(_this9.dropdownEl); 2251 2252 /** 2253 * Options for the dropdown 2254 * @member Dropdown#options 2255 * @prop {String} [alignment='left'] - Edge which the dropdown is aligned to 2256 * @prop {Boolean} [autoFocus=true] - Automatically focus dropdown el for keyboard 2257 * @prop {Boolean} [constrainWidth=true] - Constrain width to width of the button 2258 * @prop {Element} container - Container element to attach dropdown to (optional) 2259 * @prop {Boolean} [coverTrigger=true] - Place dropdown over trigger 2260 * @prop {Boolean} [closeOnClick=true] - Close on click of dropdown item 2261 * @prop {Boolean} [hover=false] - Open dropdown on hover 2262 * @prop {Number} [inDuration=150] - Duration of open animation in ms 2263 * @prop {Number} [outDuration=250] - Duration of close animation in ms 2264 * @prop {Function} onOpenStart - Function called when dropdown starts opening 2265 * @prop {Function} onOpenEnd - Function called when dropdown finishes opening 2266 * @prop {Function} onCloseStart - Function called when dropdown starts closing 2267 * @prop {Function} onCloseEnd - Function called when dropdown finishes closing 2268 */ 2269 _this9.options = $.extend({}, Dropdown.defaults, options); 2270 2271 /** 2272 * Describes open/close state of dropdown 2273 * @type {Boolean} 2274 */ 2275 _this9.isOpen = false; 2276 2277 /** 2278 * Describes if dropdown content is scrollable 2279 * @type {Boolean} 2280 */ 2281 _this9.isScrollable = false; 2282 2283 /** 2284 * Describes if touch moving on dropdown content 2285 * @type {Boolean} 2286 */ 2287 _this9.isTouchMoving = false; 2288 2289 _this9.focusedIndex = -1; 2290 _this9.filterQuery = []; 2291 2292 // Move dropdown-content after dropdown-trigger 2293 if (!!_this9.options.container) { 2294 $(_this9.options.container).append(_this9.dropdownEl); 2295 } else { 2296 _this9.$el.after(_this9.dropdownEl); 2297 } 2298 2299 _this9._makeDropdownFocusable(); 2300 _this9._resetFilterQueryBound = _this9._resetFilterQuery.bind(_this9); 2301 _this9._handleDocumentClickBound = _this9._handleDocumentClick.bind(_this9); 2302 _this9._handleDocumentTouchmoveBound = _this9._handleDocumentTouchmove.bind(_this9); 2303 _this9._handleDropdownClickBound = _this9._handleDropdownClick.bind(_this9); 2304 _this9._handleDropdownKeydownBound = _this9._handleDropdownKeydown.bind(_this9); 2305 _this9._handleTriggerKeydownBound = _this9._handleTriggerKeydown.bind(_this9); 2306 _this9._setupEventHandlers(); 2307 return _this9; 2308 } 2309 2310 _createClass(Dropdown, [{ 2311 key: "destroy", 2312 2313 2314 /** 2315 * Teardown component 2316 */ 2317 value: function destroy() { 2318 this._resetDropdownStyles(); 2319 this._removeEventHandlers(); 2320 Dropdown._dropdowns.splice(Dropdown._dropdowns.indexOf(this), 1); 2321 this.el.M_Dropdown = undefined; 2322 } 2323 2324 /** 2325 * Setup Event Handlers 2326 */ 2327 2328 }, { 2329 key: "_setupEventHandlers", 2330 value: function _setupEventHandlers() { 2331 // Trigger keydown handler 2332 this.el.addEventListener('keydown', this._handleTriggerKeydownBound); 2333 2334 // Item click handler 2335 this.dropdownEl.addEventListener('click', this._handleDropdownClickBound); 2336 2337 // Hover event handlers 2338 if (this.options.hover) { 2339 this._handleMouseEnterBound = this._handleMouseEnter.bind(this); 2340 this.el.addEventListener('mouseenter', this._handleMouseEnterBound); 2341 this._handleMouseLeaveBound = this._handleMouseLeave.bind(this); 2342 this.el.addEventListener('mouseleave', this._handleMouseLeaveBound); 2343 this.dropdownEl.addEventListener('mouseleave', this._handleMouseLeaveBound); 2344 2345 // Click event handlers 2346 } else { 2347 this._handleClickBound = this._handleClick.bind(this); 2348 this.el.addEventListener('click', this._handleClickBound); 2349 } 2350 } 2351 2352 /** 2353 * Remove Event Handlers 2354 */ 2355 2356 }, { 2357 key: "_removeEventHandlers", 2358 value: function _removeEventHandlers() { 2359 this.el.removeEventListener('keydown', this._handleTriggerKeydownBound); 2360 this.dropdownEl.removeEventListener('click', this._handleDropdownClickBound); 2361 2362 if (this.options.hover) { 2363 this.el.removeEventListener('mouseenter', this._handleMouseEnterBound); 2364 this.el.removeEventListener('mouseleave', this._handleMouseLeaveBound); 2365 this.dropdownEl.removeEventListener('mouseleave', this._handleMouseLeaveBound); 2366 } else { 2367 this.el.removeEventListener('click', this._handleClickBound); 2368 } 2369 } 2370 }, { 2371 key: "_setupTemporaryEventHandlers", 2372 value: function _setupTemporaryEventHandlers() { 2373 // Use capture phase event handler to prevent click 2374 document.body.addEventListener('click', this._handleDocumentClickBound, true); 2375 document.body.addEventListener('touchend', this._handleDocumentClickBound); 2376 document.body.addEventListener('touchmove', this._handleDocumentTouchmoveBound); 2377 this.dropdownEl.addEventListener('keydown', this._handleDropdownKeydownBound); 2378 } 2379 }, { 2380 key: "_removeTemporaryEventHandlers", 2381 value: function _removeTemporaryEventHandlers() { 2382 // Use capture phase event handler to prevent click 2383 document.body.removeEventListener('click', this._handleDocumentClickBound, true); 2384 document.body.removeEventListener('touchend', this._handleDocumentClickBound); 2385 document.body.removeEventListener('touchmove', this._handleDocumentTouchmoveBound); 2386 this.dropdownEl.removeEventListener('keydown', this._handleDropdownKeydownBound); 2387 } 2388 }, { 2389 key: "_handleClick", 2390 value: function _handleClick(e) { 2391 e.preventDefault(); 2392 this.open(); 2393 } 2394 }, { 2395 key: "_handleMouseEnter", 2396 value: function _handleMouseEnter() { 2397 this.open(); 2398 } 2399 }, { 2400 key: "_handleMouseLeave", 2401 value: function _handleMouseLeave(e) { 2402 var toEl = e.toElement || e.relatedTarget; 2403 var leaveToDropdownContent = !!$(toEl).closest('.dropdown-content').length; 2404 var leaveToActiveDropdownTrigger = false; 2405 2406 var $closestTrigger = $(toEl).closest('.dropdown-trigger'); 2407 if ($closestTrigger.length && !!$closestTrigger[0].M_Dropdown && $closestTrigger[0].M_Dropdown.isOpen) { 2408 leaveToActiveDropdownTrigger = true; 2409 } 2410 2411 // Close hover dropdown if mouse did not leave to either active dropdown-trigger or dropdown-content 2412 if (!leaveToActiveDropdownTrigger && !leaveToDropdownContent) { 2413 this.close(); 2414 } 2415 } 2416 }, { 2417 key: "_handleDocumentClick", 2418 value: function _handleDocumentClick(e) { 2419 var _this10 = this; 2420 2421 var $target = $(e.target); 2422 if (this.options.closeOnClick && $target.closest('.dropdown-content').length && !this.isTouchMoving) { 2423 // isTouchMoving to check if scrolling on mobile. 2424 setTimeout(function () { 2425 _this10.close(); 2426 }, 0); 2427 } else if ($target.closest('.dropdown-trigger').length || !$target.closest('.dropdown-content').length) { 2428 setTimeout(function () { 2429 _this10.close(); 2430 }, 0); 2431 } 2432 this.isTouchMoving = false; 2433 } 2434 }, { 2435 key: "_handleTriggerKeydown", 2436 value: function _handleTriggerKeydown(e) { 2437 // ARROW DOWN OR ENTER WHEN SELECT IS CLOSED - open Dropdown 2438 if ((e.which === M.keys.ARROW_DOWN || e.which === M.keys.ENTER) && !this.isOpen) { 2439 e.preventDefault(); 2440 this.open(); 2441 } 2442 } 2443 2444 /** 2445 * Handle Document Touchmove 2446 * @param {Event} e 2447 */ 2448 2449 }, { 2450 key: "_handleDocumentTouchmove", 2451 value: function _handleDocumentTouchmove(e) { 2452 var $target = $(e.target); 2453 if ($target.closest('.dropdown-content').length) { 2454 this.isTouchMoving = true; 2455 } 2456 } 2457 2458 /** 2459 * Handle Dropdown Click 2460 * @param {Event} e 2461 */ 2462 2463 }, { 2464 key: "_handleDropdownClick", 2465 value: function _handleDropdownClick(e) { 2466 // onItemClick callback 2467 if (typeof this.options.onItemClick === 'function') { 2468 var itemEl = $(e.target).closest('li')[0]; 2469 this.options.onItemClick.call(this, itemEl); 2470 } 2471 } 2472 2473 /** 2474 * Handle Dropdown Keydown 2475 * @param {Event} e 2476 */ 2477 2478 }, { 2479 key: "_handleDropdownKeydown", 2480 value: function _handleDropdownKeydown(e) { 2481 if (e.which === M.keys.TAB) { 2482 e.preventDefault(); 2483 this.close(); 2484 2485 // Navigate down dropdown list 2486 } else if ((e.which === M.keys.ARROW_DOWN || e.which === M.keys.ARROW_UP) && this.isOpen) { 2487 e.preventDefault(); 2488 var direction = e.which === M.keys.ARROW_DOWN ? 1 : -1; 2489 var newFocusedIndex = this.focusedIndex; 2490 var foundNewIndex = false; 2491 do { 2492 newFocusedIndex = newFocusedIndex + direction; 2493 2494 if (!!this.dropdownEl.children[newFocusedIndex] && this.dropdownEl.children[newFocusedIndex].tabIndex !== -1) { 2495 foundNewIndex = true; 2496 break; 2497 } 2498 } while (newFocusedIndex < this.dropdownEl.children.length && newFocusedIndex >= 0); 2499 2500 if (foundNewIndex) { 2501 this.focusedIndex = newFocusedIndex; 2502 this._focusFocusedItem(); 2503 } 2504 2505 // ENTER selects choice on focused item 2506 } else if (e.which === M.keys.ENTER && this.isOpen) { 2507 // Search for <a> and <button> 2508 var focusedElement = this.dropdownEl.children[this.focusedIndex]; 2509 var $activatableElement = $(focusedElement).find('a, button').first(); 2510 2511 // Click a or button tag if exists, otherwise click li tag 2512 if (!!$activatableElement.length) { 2513 $activatableElement[0].click(); 2514 } else if (!!focusedElement) { 2515 focusedElement.click(); 2516 } 2517 2518 // Close dropdown on ESC 2519 } else if (e.which === M.keys.ESC && this.isOpen) { 2520 e.preventDefault(); 2521 this.close(); 2522 } 2523 2524 // CASE WHEN USER TYPE LETTERS 2525 var letter = String.fromCharCode(e.which).toLowerCase(), 2526 nonLetters = [9, 13, 27, 38, 40]; 2527 if (letter && nonLetters.indexOf(e.which) === -1) { 2528 this.filterQuery.push(letter); 2529 2530 var string = this.filterQuery.join(''), 2531 newOptionEl = $(this.dropdownEl).find('li').filter(function (el) { 2532 return $(el).text().toLowerCase().indexOf(string) === 0; 2533 })[0]; 2534 2535 if (newOptionEl) { 2536 this.focusedIndex = $(newOptionEl).index(); 2537 this._focusFocusedItem(); 2538 } 2539 } 2540 2541 this.filterTimeout = setTimeout(this._resetFilterQueryBound, 1000); 2542 } 2543 2544 /** 2545 * Setup dropdown 2546 */ 2547 2548 }, { 2549 key: "_resetFilterQuery", 2550 value: function _resetFilterQuery() { 2551 this.filterQuery = []; 2552 } 2553 }, { 2554 key: "_resetDropdownStyles", 2555 value: function _resetDropdownStyles() { 2556 this.$dropdownEl.css({ 2557 display: '', 2558 width: '', 2559 height: '', 2560 left: '', 2561 top: '', 2562 'transform-origin': '', 2563 transform: '', 2564 opacity: '' 2565 }); 2566 } 2567 }, { 2568 key: "_makeDropdownFocusable", 2569 value: function _makeDropdownFocusable() { 2570 // Needed for arrow key navigation 2571 this.dropdownEl.tabIndex = 0; 2572 2573 // Only set tabindex if it hasn't been set by user 2574 $(this.dropdownEl).children().each(function (el) { 2575 if (!el.getAttribute('tabindex')) { 2576 el.setAttribute('tabindex', 0); 2577 } 2578 }); 2579 } 2580 }, { 2581 key: "_focusFocusedItem", 2582 value: function _focusFocusedItem() { 2583 if (this.focusedIndex >= 0 && this.focusedIndex < this.dropdownEl.children.length && this.options.autoFocus) { 2584 this.dropdownEl.children[this.focusedIndex].focus(); 2585 } 2586 } 2587 }, { 2588 key: "_getDropdownPosition", 2589 value: function _getDropdownPosition() { 2590 var offsetParentBRect = this.el.offsetParent.getBoundingClientRect(); 2591 var triggerBRect = this.el.getBoundingClientRect(); 2592 var dropdownBRect = this.dropdownEl.getBoundingClientRect(); 2593 2594 var idealHeight = dropdownBRect.height; 2595 var idealWidth = dropdownBRect.width; 2596 var idealXPos = triggerBRect.left - dropdownBRect.left; 2597 var idealYPos = triggerBRect.top - dropdownBRect.top; 2598 2599 var dropdownBounds = { 2600 left: idealXPos, 2601 top: idealYPos, 2602 height: idealHeight, 2603 width: idealWidth 2604 }; 2605 2606 // Countainer here will be closest ancestor with overflow: hidden 2607 var closestOverflowParent = !!this.dropdownEl.offsetParent ? this.dropdownEl.offsetParent : this.dropdownEl.parentNode; 2608 2609 var alignments = M.checkPossibleAlignments(this.el, closestOverflowParent, dropdownBounds, this.options.coverTrigger ? 0 : triggerBRect.height); 2610 2611 var verticalAlignment = 'top'; 2612 var horizontalAlignment = this.options.alignment; 2613 idealYPos += this.options.coverTrigger ? 0 : triggerBRect.height; 2614 2615 // Reset isScrollable 2616 this.isScrollable = false; 2617 2618 if (!alignments.top) { 2619 if (alignments.bottom) { 2620 verticalAlignment = 'bottom'; 2621 } else { 2622 this.isScrollable = true; 2623 2624 // Determine which side has most space and cutoff at correct height 2625 if (alignments.spaceOnTop > alignments.spaceOnBottom) { 2626 verticalAlignment = 'bottom'; 2627 idealHeight += alignments.spaceOnTop; 2628 idealYPos -= alignments.spaceOnTop; 2629 } else { 2630 idealHeight += alignments.spaceOnBottom; 2631 } 2632 } 2633 } 2634 2635 // If preferred horizontal alignment is possible 2636 if (!alignments[horizontalAlignment]) { 2637 var oppositeAlignment = horizontalAlignment === 'left' ? 'right' : 'left'; 2638 if (alignments[oppositeAlignment]) { 2639 horizontalAlignment = oppositeAlignment; 2640 } else { 2641 // Determine which side has most space and cutoff at correct height 2642 if (alignments.spaceOnLeft > alignments.spaceOnRight) { 2643 horizontalAlignment = 'right'; 2644 idealWidth += alignments.spaceOnLeft; 2645 idealXPos -= alignments.spaceOnLeft; 2646 } else { 2647 horizontalAlignment = 'left'; 2648 idealWidth += alignments.spaceOnRight; 2649 } 2650 } 2651 } 2652 2653 if (verticalAlignment === 'bottom') { 2654 idealYPos = idealYPos - dropdownBRect.height + (this.options.coverTrigger ? triggerBRect.height : 0); 2655 } 2656 if (horizontalAlignment === 'right') { 2657 idealXPos = idealXPos - dropdownBRect.width + triggerBRect.width; 2658 } 2659 return { 2660 x: idealXPos, 2661 y: idealYPos, 2662 verticalAlignment: verticalAlignment, 2663 horizontalAlignment: horizontalAlignment, 2664 height: idealHeight, 2665 width: idealWidth 2666 }; 2667 } 2668 2669 /** 2670 * Animate in dropdown 2671 */ 2672 2673 }, { 2674 key: "_animateIn", 2675 value: function _animateIn() { 2676 var _this11 = this; 2677 2678 anim.remove(this.dropdownEl); 2679 anim({ 2680 targets: this.dropdownEl, 2681 opacity: { 2682 value: [0, 1], 2683 easing: 'easeOutQuad' 2684 }, 2685 scaleX: [0.3, 1], 2686 scaleY: [0.3, 1], 2687 duration: this.options.inDuration, 2688 easing: 'easeOutQuint', 2689 complete: function (anim) { 2690 if (_this11.options.autoFocus) { 2691 _this11.dropdownEl.focus(); 2692 } 2693 2694 // onOpenEnd callback 2695 if (typeof _this11.options.onOpenEnd === 'function') { 2696 _this11.options.onOpenEnd.call(_this11, _this11.el); 2697 } 2698 } 2699 }); 2700 } 2701 2702 /** 2703 * Animate out dropdown 2704 */ 2705 2706 }, { 2707 key: "_animateOut", 2708 value: function _animateOut() { 2709 var _this12 = this; 2710 2711 anim.remove(this.dropdownEl); 2712 anim({ 2713 targets: this.dropdownEl, 2714 opacity: { 2715 value: 0, 2716 easing: 'easeOutQuint' 2717 }, 2718 scaleX: 0.3, 2719 scaleY: 0.3, 2720 duration: this.options.outDuration, 2721 easing: 'easeOutQuint', 2722 complete: function (anim) { 2723 _this12._resetDropdownStyles(); 2724 2725 // onCloseEnd callback 2726 if (typeof _this12.options.onCloseEnd === 'function') { 2727 _this12.options.onCloseEnd.call(_this12, _this12.el); 2728 } 2729 } 2730 }); 2731 } 2732 2733 /** 2734 * Place dropdown 2735 */ 2736 2737 }, { 2738 key: "_placeDropdown", 2739 value: function _placeDropdown() { 2740 // Set width before calculating positionInfo 2741 var idealWidth = this.options.constrainWidth ? this.el.getBoundingClientRect().width : this.dropdownEl.getBoundingClientRect().width; 2742 this.dropdownEl.style.width = idealWidth + 'px'; 2743 2744 var positionInfo = this._getDropdownPosition(); 2745 this.dropdownEl.style.left = positionInfo.x + 'px'; 2746 this.dropdownEl.style.top = positionInfo.y + 'px'; 2747 this.dropdownEl.style.height = positionInfo.height + 'px'; 2748 this.dropdownEl.style.width = positionInfo.width + 'px'; 2749 this.dropdownEl.style.transformOrigin = (positionInfo.horizontalAlignment === 'left' ? '0' : '100%') + " " + (positionInfo.verticalAlignment === 'top' ? '0' : '100%'); 2750 } 2751 2752 /** 2753 * Open Dropdown 2754 */ 2755 2756 }, { 2757 key: "open", 2758 value: function open() { 2759 if (this.isOpen) { 2760 return; 2761 } 2762 this.isOpen = true; 2763 2764 // onOpenStart callback 2765 if (typeof this.options.onOpenStart === 'function') { 2766 this.options.onOpenStart.call(this, this.el); 2767 } 2768 2769 // Reset styles 2770 this._resetDropdownStyles(); 2771 this.dropdownEl.style.display = 'block'; 2772 2773 this._placeDropdown(); 2774 this._animateIn(); 2775 this._setupTemporaryEventHandlers(); 2776 } 2777 2778 /** 2779 * Close Dropdown 2780 */ 2781 2782 }, { 2783 key: "close", 2784 value: function close() { 2785 if (!this.isOpen) { 2786 return; 2787 } 2788 this.isOpen = false; 2789 this.focusedIndex = -1; 2790 2791 // onCloseStart callback 2792 if (typeof this.options.onCloseStart === 'function') { 2793 this.options.onCloseStart.call(this, this.el); 2794 } 2795 2796 this._animateOut(); 2797 this._removeTemporaryEventHandlers(); 2798 2799 if (this.options.autoFocus) { 2800 this.el.focus(); 2801 } 2802 } 2803 2804 /** 2805 * Recalculate dimensions 2806 */ 2807 2808 }, { 2809 key: "recalculateDimensions", 2810 value: function recalculateDimensions() { 2811 if (this.isOpen) { 2812 this.$dropdownEl.css({ 2813 width: '', 2814 height: '', 2815 left: '', 2816 top: '', 2817 'transform-origin': '' 2818 }); 2819 this._placeDropdown(); 2820 } 2821 } 2822 }], [{ 2823 key: "init", 2824 value: function init(els, options) { 2825 return _get(Dropdown.__proto__ || Object.getPrototypeOf(Dropdown), "init", this).call(this, this, els, options); 2826 } 2827 2828 /** 2829 * Get Instance 2830 */ 2831 2832 }, { 2833 key: "getInstance", 2834 value: function getInstance(el) { 2835 var domElem = !!el.jquery ? el[0] : el; 2836 return domElem.M_Dropdown; 2837 } 2838 }, { 2839 key: "defaults", 2840 get: function () { 2841 return _defaults; 2842 } 2843 }]); 2844 2845 return Dropdown; 2846 }(Component); 2847 2848 /** 2849 * @static 2850 * @memberof Dropdown 2851 */ 2852 2853 2854 Dropdown._dropdowns = []; 2855 2856 M.Dropdown = Dropdown; 2857 2858 if (M.jQueryLoaded) { 2859 M.initializeJqueryWrapper(Dropdown, 'dropdown', 'M_Dropdown'); 2860 } 2861})(cash, M.anime); 2862;(function ($, anim) { 2863 'use strict'; 2864 2865 var _defaults = { 2866 opacity: 0.5, 2867 inDuration: 250, 2868 outDuration: 250, 2869 onOpenStart: null, 2870 onOpenEnd: null, 2871 onCloseStart: null, 2872 onCloseEnd: null, 2873 preventScrolling: true, 2874 dismissible: true, 2875 startingTop: '4%', 2876 endingTop: '10%' 2877 }; 2878 2879 /** 2880 * @class 2881 * 2882 */ 2883 2884 var Modal = function (_Component3) { 2885 _inherits(Modal, _Component3); 2886 2887 /** 2888 * Construct Modal instance and set up overlay 2889 * @constructor 2890 * @param {Element} el 2891 * @param {Object} options 2892 */ 2893 function Modal(el, options) { 2894 _classCallCheck(this, Modal); 2895 2896 var _this13 = _possibleConstructorReturn(this, (Modal.__proto__ || Object.getPrototypeOf(Modal)).call(this, Modal, el, options)); 2897 2898 _this13.el.M_Modal = _this13; 2899 2900 /** 2901 * Options for the modal 2902 * @member Modal#options 2903 * @prop {Number} [opacity=0.5] - Opacity of the modal overlay 2904 * @prop {Number} [inDuration=250] - Length in ms of enter transition 2905 * @prop {Number} [outDuration=250] - Length in ms of exit transition 2906 * @prop {Function} onOpenStart - Callback function called before modal is opened 2907 * @prop {Function} onOpenEnd - Callback function called after modal is opened 2908 * @prop {Function} onCloseStart - Callback function called before modal is closed 2909 * @prop {Function} onCloseEnd - Callback function called after modal is closed 2910 * @prop {Boolean} [dismissible=true] - Allow modal to be dismissed by keyboard or overlay click 2911 * @prop {String} [startingTop='4%'] - startingTop 2912 * @prop {String} [endingTop='10%'] - endingTop 2913 */ 2914 _this13.options = $.extend({}, Modal.defaults, options); 2915 2916 /** 2917 * Describes open/close state of modal 2918 * @type {Boolean} 2919 */ 2920 _this13.isOpen = false; 2921 2922 _this13.id = _this13.$el.attr('id'); 2923 _this13._openingTrigger = undefined; 2924 _this13.$overlay = $('<div class="modal-overlay"></div>'); 2925 _this13.el.tabIndex = 0; 2926 _this13._nthModalOpened = 0; 2927 2928 Modal._count++; 2929 _this13._setupEventHandlers(); 2930 return _this13; 2931 } 2932 2933 _createClass(Modal, [{ 2934 key: "destroy", 2935 2936 2937 /** 2938 * Teardown component 2939 */ 2940 value: function destroy() { 2941 Modal._count--; 2942 this._removeEventHandlers(); 2943 this.el.removeAttribute('style'); 2944 this.$overlay.remove(); 2945 this.el.M_Modal = undefined; 2946 } 2947 2948 /** 2949 * Setup Event Handlers 2950 */ 2951 2952 }, { 2953 key: "_setupEventHandlers", 2954 value: function _setupEventHandlers() { 2955 this._handleOverlayClickBound = this._handleOverlayClick.bind(this); 2956 this._handleModalCloseClickBound = this._handleModalCloseClick.bind(this); 2957 2958 if (Modal._count === 1) { 2959 document.body.addEventListener('click', this._handleTriggerClick); 2960 } 2961 this.$overlay[0].addEventListener('click', this._handleOverlayClickBound); 2962 this.el.addEventListener('click', this._handleModalCloseClickBound); 2963 } 2964 2965 /** 2966 * Remove Event Handlers 2967 */ 2968 2969 }, { 2970 key: "_removeEventHandlers", 2971 value: function _removeEventHandlers() { 2972 if (Modal._count === 0) { 2973 document.body.removeEventListener('click', this._handleTriggerClick); 2974 } 2975 this.$overlay[0].removeEventListener('click', this._handleOverlayClickBound); 2976 this.el.removeEventListener('click', this._handleModalCloseClickBound); 2977 } 2978 2979 /** 2980 * Handle Trigger Click 2981 * @param {Event} e 2982 */ 2983 2984 }, { 2985 key: "_handleTriggerClick", 2986 value: function _handleTriggerClick(e) { 2987 var $trigger = $(e.target).closest('.modal-trigger'); 2988 if ($trigger.length) { 2989 var modalId = M.getIdFromTrigger($trigger[0]); 2990 var modalInstance = document.getElementById(modalId).M_Modal; 2991 if (modalInstance) { 2992 modalInstance.open($trigger); 2993 } 2994 e.preventDefault(); 2995 } 2996 } 2997 2998 /** 2999 * Handle Overlay Click 3000 */ 3001 3002 }, { 3003 key: "_handleOverlayClick", 3004 value: function _handleOverlayClick() { 3005 if (this.options.dismissible) { 3006 this.close(); 3007 } 3008 } 3009 3010 /** 3011 * Handle Modal Close Click 3012 * @param {Event} e 3013 */ 3014 3015 }, { 3016 key: "_handleModalCloseClick", 3017 value: function _handleModalCloseClick(e) { 3018 var $closeTrigger = $(e.target).closest('.modal-close'); 3019 if ($closeTrigger.length) { 3020 this.close(); 3021 } 3022 } 3023 3024 /** 3025 * Handle Keydown 3026 * @param {Event} e 3027 */ 3028 3029 }, { 3030 key: "_handleKeydown", 3031 value: function _handleKeydown(e) { 3032 // ESC key 3033 if (e.keyCode === 27 && this.options.dismissible) { 3034 this.close(); 3035 } 3036 } 3037 3038 /** 3039 * Handle Focus 3040 * @param {Event} e 3041 */ 3042 3043 }, { 3044 key: "_handleFocus", 3045 value: function _handleFocus(e) { 3046 // Only trap focus if this modal is the last model opened (prevents loops in nested modals). 3047 if (!this.el.contains(e.target) && this._nthModalOpened === Modal._modalsOpen) { 3048 this.el.focus(); 3049 } 3050 } 3051 3052 /** 3053 * Animate in modal 3054 */ 3055 3056 }, { 3057 key: "_animateIn", 3058 value: function _animateIn() { 3059 var _this14 = this; 3060 3061 // Set initial styles 3062 $.extend(this.el.style, { 3063 display: 'block', 3064 opacity: 0 3065 }); 3066 $.extend(this.$overlay[0].style, { 3067 display: 'block', 3068 opacity: 0 3069 }); 3070 3071 // Animate overlay 3072 anim({ 3073 targets: this.$overlay[0], 3074 opacity: this.options.opacity, 3075 duration: this.options.inDuration, 3076 easing: 'easeOutQuad' 3077 }); 3078 3079 // Define modal animation options 3080 var enterAnimOptions = { 3081 targets: this.el, 3082 duration: this.options.inDuration, 3083 easing: 'easeOutCubic', 3084 // Handle modal onOpenEnd callback 3085 complete: function () { 3086 if (typeof _this14.options.onOpenEnd === 'function') { 3087 _this14.options.onOpenEnd.call(_this14, _this14.el, _this14._openingTrigger); 3088 } 3089 } 3090 }; 3091 3092 // Bottom sheet animation 3093 if (this.el.classList.contains('bottom-sheet')) { 3094 $.extend(enterAnimOptions, { 3095 bottom: 0, 3096 opacity: 1 3097 }); 3098 anim(enterAnimOptions); 3099 3100 // Normal modal animation 3101 } else { 3102 $.extend(enterAnimOptions, { 3103 top: [this.options.startingTop, this.options.endingTop], 3104 opacity: 1, 3105 scaleX: [0.8, 1], 3106 scaleY: [0.8, 1] 3107 }); 3108 anim(enterAnimOptions); 3109 } 3110 } 3111 3112 /** 3113 * Animate out modal 3114 */ 3115 3116 }, { 3117 key: "_animateOut", 3118 value: function _animateOut() { 3119 var _this15 = this; 3120 3121 // Animate overlay 3122 anim({ 3123 targets: this.$overlay[0], 3124 opacity: 0, 3125 duration: this.options.outDuration, 3126 easing: 'easeOutQuart' 3127 }); 3128 3129 // Define modal animation options 3130 var exitAnimOptions = { 3131 targets: this.el, 3132 duration: this.options.outDuration, 3133 easing: 'easeOutCubic', 3134 // Handle modal ready callback 3135 complete: function () { 3136 _this15.el.style.display = 'none'; 3137 _this15.$overlay.remove(); 3138 3139 // Call onCloseEnd callback 3140 if (typeof _this15.options.onCloseEnd === 'function') { 3141 _this15.options.onCloseEnd.call(_this15, _this15.el); 3142 } 3143 } 3144 }; 3145 3146 // Bottom sheet animation 3147 if (this.el.classList.contains('bottom-sheet')) { 3148 $.extend(exitAnimOptions, { 3149 bottom: '-100%', 3150 opacity: 0 3151 }); 3152 anim(exitAnimOptions); 3153 3154 // Normal modal animation 3155 } else { 3156 $.extend(exitAnimOptions, { 3157 top: [this.options.endingTop, this.options.startingTop], 3158 opacity: 0, 3159 scaleX: 0.8, 3160 scaleY: 0.8 3161 }); 3162 anim(exitAnimOptions); 3163 } 3164 } 3165 3166 /** 3167 * Open Modal 3168 * @param {cash} [$trigger] 3169 */ 3170 3171 }, { 3172 key: "open", 3173 value: function open($trigger) { 3174 if (this.isOpen) { 3175 return; 3176 } 3177 3178 this.isOpen = true; 3179 Modal._modalsOpen++; 3180 this._nthModalOpened = Modal._modalsOpen; 3181 3182 // Set Z-Index based on number of currently open modals 3183 this.$overlay[0].style.zIndex = 1000 + Modal._modalsOpen * 2; 3184 this.el.style.zIndex = 1000 + Modal._modalsOpen * 2 + 1; 3185 3186 // Set opening trigger, undefined indicates modal was opened by javascript 3187 this._openingTrigger = !!$trigger ? $trigger[0] : undefined; 3188 3189 // onOpenStart callback 3190 if (typeof this.options.onOpenStart === 'function') { 3191 this.options.onOpenStart.call(this, this.el, this._openingTrigger); 3192 } 3193 3194 if (this.options.preventScrolling) { 3195 document.body.style.overflow = 'hidden'; 3196 } 3197 3198 this.el.classList.add('open'); 3199 this.el.insertAdjacentElement('afterend', this.$overlay[0]); 3200 3201 if (this.options.dismissible) { 3202 this._handleKeydownBound = this._handleKeydown.bind(this); 3203 this._handleFocusBound = this._handleFocus.bind(this); 3204 document.addEventListener('keydown', this._handleKeydownBound); 3205 document.addEventListener('focus', this._handleFocusBound, true); 3206 } 3207 3208 anim.remove(this.el); 3209 anim.remove(this.$overlay[0]); 3210 this._animateIn(); 3211 3212 // Focus modal 3213 this.el.focus(); 3214 3215 return this; 3216 } 3217 3218 /** 3219 * Close Modal 3220 */ 3221 3222 }, { 3223 key: "close", 3224 value: function close() { 3225 if (!this.isOpen) { 3226 return; 3227 } 3228 3229 this.isOpen = false; 3230 Modal._modalsOpen--; 3231 this._nthModalOpened = 0; 3232 3233 // Call onCloseStart callback 3234 if (typeof this.options.onCloseStart === 'function') { 3235 this.options.onCloseStart.call(this, this.el); 3236 } 3237 3238 this.el.classList.remove('open'); 3239 3240 // Enable body scrolling only if there are no more modals open. 3241 if (Modal._modalsOpen === 0) { 3242 document.body.style.overflow = ''; 3243 } 3244 3245 if (this.options.dismissible) { 3246 document.removeEventListener('keydown', this._handleKeydownBound); 3247 document.removeEventListener('focus', this._handleFocusBound, true); 3248 } 3249 3250 anim.remove(this.el); 3251 anim.remove(this.$overlay[0]); 3252 this._animateOut(); 3253 return this; 3254 } 3255 }], [{ 3256 key: "init", 3257 value: function init(els, options) { 3258 return _get(Modal.__proto__ || Object.getPrototypeOf(Modal), "init", this).call(this, this, els, options); 3259 } 3260 3261 /** 3262 * Get Instance 3263 */ 3264 3265 }, { 3266 key: "getInstance", 3267 value: function getInstance(el) { 3268 var domElem = !!el.jquery ? el[0] : el; 3269 return domElem.M_Modal; 3270 } 3271 }, { 3272 key: "defaults", 3273 get: function () { 3274 return _defaults; 3275 } 3276 }]); 3277 3278 return Modal; 3279 }(Component); 3280 3281 /** 3282 * @static 3283 * @memberof Modal 3284 */ 3285 3286 3287 Modal._modalsOpen = 0; 3288 3289 /** 3290 * @static 3291 * @memberof Modal 3292 */ 3293 Modal._count = 0; 3294 3295 M.Modal = Modal; 3296 3297 if (M.jQueryLoaded) { 3298 M.initializeJqueryWrapper(Modal, 'modal', 'M_Modal'); 3299 } 3300})(cash, M.anime); 3301;(function ($, anim) { 3302 'use strict'; 3303 3304 var _defaults = { 3305 inDuration: 275, 3306 outDuration: 200, 3307 onOpenStart: null, 3308 onOpenEnd: null, 3309 onCloseStart: null, 3310 onCloseEnd: null 3311 }; 3312 3313 /** 3314 * @class 3315 * 3316 */ 3317 3318 var Materialbox = function (_Component4) { 3319 _inherits(Materialbox, _Component4); 3320 3321 /** 3322 * Construct Materialbox instance 3323 * @constructor 3324 * @param {Element} el 3325 * @param {Object} options 3326 */ 3327 function Materialbox(el, options) { 3328 _classCallCheck(this, Materialbox); 3329 3330 var _this16 = _possibleConstructorReturn(this, (Materialbox.__proto__ || Object.getPrototypeOf(Materialbox)).call(this, Materialbox, el, options)); 3331 3332 _this16.el.M_Materialbox = _this16; 3333 3334 /** 3335 * Options for the modal 3336 * @member Materialbox#options 3337 * @prop {Number} [inDuration=275] - Length in ms of enter transition 3338 * @prop {Number} [outDuration=200] - Length in ms of exit transition 3339 * @prop {Function} onOpenStart - Callback function called before materialbox is opened 3340 * @prop {Function} onOpenEnd - Callback function called after materialbox is opened 3341 * @prop {Function} onCloseStart - Callback function called before materialbox is closed 3342 * @prop {Function} onCloseEnd - Callback function called after materialbox is closed 3343 */ 3344 _this16.options = $.extend({}, Materialbox.defaults, options); 3345 3346 _this16.overlayActive = false; 3347 _this16.doneAnimating = true; 3348 _this16.placeholder = $('<div></div>').addClass('material-placeholder'); 3349 _this16.originalWidth = 0; 3350 _this16.originalHeight = 0; 3351 _this16.originInlineStyles = _this16.$el.attr('style'); 3352 _this16.caption = _this16.el.getAttribute('data-caption') || ''; 3353 3354 // Wrap 3355 _this16.$el.before(_this16.placeholder); 3356 _this16.placeholder.append(_this16.$el); 3357 3358 _this16._setupEventHandlers(); 3359 return _this16; 3360 } 3361 3362 _createClass(Materialbox, [{ 3363 key: "destroy", 3364 3365 3366 /** 3367 * Teardown component 3368 */ 3369 value: function destroy() { 3370 this._removeEventHandlers(); 3371 this.el.M_Materialbox = undefined; 3372 3373 // Unwrap image 3374 $(this.placeholder).after(this.el).remove(); 3375 3376 this.$el.removeAttr('style'); 3377 } 3378 3379 /** 3380 * Setup Event Handlers 3381 */ 3382 3383 }, { 3384 key: "_setupEventHandlers", 3385 value: function _setupEventHandlers() { 3386 this._handleMaterialboxClickBound = this._handleMaterialboxClick.bind(this); 3387 this.el.addEventListener('click', this._handleMaterialboxClickBound); 3388 } 3389 3390 /** 3391 * Remove Event Handlers 3392 */ 3393 3394 }, { 3395 key: "_removeEventHandlers", 3396 value: function _removeEventHandlers() { 3397 this.el.removeEventListener('click', this._handleMaterialboxClickBound); 3398 } 3399 3400 /** 3401 * Handle Materialbox Click 3402 * @param {Event} e 3403 */ 3404 3405 }, { 3406 key: "_handleMaterialboxClick", 3407 value: function _handleMaterialboxClick(e) { 3408 // If already modal, return to original 3409 if (this.doneAnimating === false || this.overlayActive && this.doneAnimating) { 3410 this.close(); 3411 } else { 3412 this.open(); 3413 } 3414 } 3415 3416 /** 3417 * Handle Window Scroll 3418 */ 3419 3420 }, { 3421 key: "_handleWindowScroll", 3422 value: function _handleWindowScroll() { 3423 if (this.overlayActive) { 3424 this.close(); 3425 } 3426 } 3427 3428 /** 3429 * Handle Window Resize 3430 */ 3431 3432 }, { 3433 key: "_handleWindowResize", 3434 value: function _handleWindowResize() { 3435 if (this.overlayActive) { 3436 this.close(); 3437 } 3438 } 3439 3440 /** 3441 * Handle Window Resize 3442 * @param {Event} e 3443 */ 3444 3445 }, { 3446 key: "_handleWindowEscape", 3447 value: function _handleWindowEscape(e) { 3448 // ESC key 3449 if (e.keyCode === 27 && this.doneAnimating && this.overlayActive) { 3450 this.close(); 3451 } 3452 } 3453 3454 /** 3455 * Find ancestors with overflow: hidden; and make visible 3456 */ 3457 3458 }, { 3459 key: "_makeAncestorsOverflowVisible", 3460 value: function _makeAncestorsOverflowVisible() { 3461 this.ancestorsChanged = $(); 3462 var ancestor = this.placeholder[0].parentNode; 3463 while (ancestor !== null && !$(ancestor).is(document)) { 3464 var curr = $(ancestor); 3465 if (curr.css('overflow') !== 'visible') { 3466 curr.css('overflow', 'visible'); 3467 if (this.ancestorsChanged === undefined) { 3468 this.ancestorsChanged = curr; 3469 } else { 3470 this.ancestorsChanged = this.ancestorsChanged.add(curr); 3471 } 3472 } 3473 ancestor = ancestor.parentNode; 3474 } 3475 } 3476 3477 /** 3478 * Animate image in 3479 */ 3480 3481 }, { 3482 key: "_animateImageIn", 3483 value: function _animateImageIn() { 3484 var _this17 = this; 3485 3486 var animOptions = { 3487 targets: this.el, 3488 height: [this.originalHeight, this.newHeight], 3489 width: [this.originalWidth, this.newWidth], 3490 left: M.getDocumentScrollLeft() + this.windowWidth / 2 - this.placeholder.offset().left - this.newWidth / 2, 3491 top: M.getDocumentScrollTop() + this.windowHeight / 2 - this.placeholder.offset().top - this.newHeight / 2, 3492 duration: this.options.inDuration, 3493 easing: 'easeOutQuad', 3494 complete: function () { 3495 _this17.doneAnimating = true; 3496 3497 // onOpenEnd callback 3498 if (typeof _this17.options.onOpenEnd === 'function') { 3499 _this17.options.onOpenEnd.call(_this17, _this17.el); 3500 } 3501 } 3502 }; 3503 3504 // Override max-width or max-height if needed 3505 this.maxWidth = this.$el.css('max-width'); 3506 this.maxHeight = this.$el.css('max-height'); 3507 if (this.maxWidth !== 'none') { 3508 animOptions.maxWidth = this.newWidth; 3509 } 3510 if (this.maxHeight !== 'none') { 3511 animOptions.maxHeight = this.newHeight; 3512 } 3513 3514 anim(animOptions); 3515 } 3516 3517 /** 3518 * Animate image out 3519 */ 3520 3521 }, { 3522 key: "_animateImageOut", 3523 value: function _animateImageOut() { 3524 var _this18 = this; 3525 3526 var animOptions = { 3527 targets: this.el, 3528 width: this.originalWidth, 3529 height: this.originalHeight, 3530 left: 0, 3531 top: 0, 3532 duration: this.options.outDuration, 3533 easing: 'easeOutQuad', 3534 complete: function () { 3535 _this18.placeholder.css({ 3536 height: '', 3537 width: '', 3538 position: '', 3539 top: '', 3540 left: '' 3541 }); 3542 3543 // Revert to width or height attribute 3544 if (_this18.attrWidth) { 3545 _this18.$el.attr('width', _this18.attrWidth); 3546 } 3547 if (_this18.attrHeight) { 3548 _this18.$el.attr('height', _this18.attrHeight); 3549 } 3550 3551 _this18.$el.removeAttr('style'); 3552 _this18.originInlineStyles && _this18.$el.attr('style', _this18.originInlineStyles); 3553 3554 // Remove class 3555 _this18.$el.removeClass('active'); 3556 _this18.doneAnimating = true; 3557 3558 // Remove overflow overrides on ancestors 3559 if (_this18.ancestorsChanged.length) { 3560 _this18.ancestorsChanged.css('overflow', ''); 3561 } 3562 3563 // onCloseEnd callback 3564 if (typeof _this18.options.onCloseEnd === 'function') { 3565 _this18.options.onCloseEnd.call(_this18, _this18.el); 3566 } 3567 } 3568 }; 3569 3570 anim(animOptions); 3571 } 3572 3573 /** 3574 * Update open and close vars 3575 */ 3576 3577 }, { 3578 key: "_updateVars", 3579 value: function _updateVars() { 3580 this.windowWidth = window.innerWidth; 3581 this.windowHeight = window.innerHeight; 3582 this.caption = this.el.getAttribute('data-caption') || ''; 3583 } 3584 3585 /** 3586 * Open Materialbox 3587 */ 3588 3589 }, { 3590 key: "open", 3591 value: function open() { 3592 var _this19 = this; 3593 3594 this._updateVars(); 3595 this.originalWidth = this.el.getBoundingClientRect().width; 3596 this.originalHeight = this.el.getBoundingClientRect().height; 3597 3598 // Set states 3599 this.doneAnimating = false; 3600 this.$el.addClass('active'); 3601 this.overlayActive = true; 3602 3603 // onOpenStart callback 3604 if (typeof this.options.onOpenStart === 'function') { 3605 this.options.onOpenStart.call(this, this.el); 3606 } 3607 3608 // Set positioning for placeholder 3609 this.placeholder.css({ 3610 width: this.placeholder[0].getBoundingClientRect().width + 'px', 3611 height: this.placeholder[0].getBoundingClientRect().height + 'px', 3612 position: 'relative', 3613 top: 0, 3614 left: 0 3615 }); 3616 3617 this._makeAncestorsOverflowVisible(); 3618 3619 // Set css on origin 3620 this.$el.css({ 3621 position: 'absolute', 3622 'z-index': 1000, 3623 'will-change': 'left, top, width, height' 3624 }); 3625 3626 // Change from width or height attribute to css 3627 this.attrWidth = this.$el.attr('width'); 3628 this.attrHeight = this.$el.attr('height'); 3629 if (this.attrWidth) { 3630 this.$el.css('width', this.attrWidth + 'px'); 3631 this.$el.removeAttr('width'); 3632 } 3633 if (this.attrHeight) { 3634 this.$el.css('width', this.attrHeight + 'px'); 3635 this.$el.removeAttr('height'); 3636 } 3637 3638 // Add overlay 3639 this.$overlay = $('<div id="materialbox-overlay"></div>').css({ 3640 opacity: 0 3641 }).one('click', function () { 3642 if (_this19.doneAnimating) { 3643 _this19.close(); 3644 } 3645 }); 3646 3647 // Put before in origin image to preserve z-index layering. 3648 this.$el.before(this.$overlay); 3649 3650 // Set dimensions if needed 3651 var overlayOffset = this.$overlay[0].getBoundingClientRect(); 3652 this.$overlay.css({ 3653 width: this.windowWidth + 'px', 3654 height: this.windowHeight + 'px', 3655 left: -1 * overlayOffset.left + 'px', 3656 top: -1 * overlayOffset.top + 'px' 3657 }); 3658 3659 anim.remove(this.el); 3660 anim.remove(this.$overlay[0]); 3661 3662 // Animate Overlay 3663 anim({ 3664 targets: this.$overlay[0], 3665 opacity: 1, 3666 duration: this.options.inDuration, 3667 easing: 'easeOutQuad' 3668 }); 3669 3670 // Add and animate caption if it exists 3671 if (this.caption !== '') { 3672 if (this.$photocaption) { 3673 anim.remove(this.$photoCaption[0]); 3674 } 3675 this.$photoCaption = $('<div class="materialbox-caption"></div>'); 3676 this.$photoCaption.text(this.caption); 3677 $('body').append(this.$photoCaption); 3678 this.$photoCaption.css({ display: 'inline' }); 3679 3680 anim({ 3681 targets: this.$photoCaption[0], 3682 opacity: 1, 3683 duration: this.options.inDuration, 3684 easing: 'easeOutQuad' 3685 }); 3686 } 3687 3688 // Resize Image 3689 var ratio = 0; 3690 var widthPercent = this.originalWidth / this.windowWidth; 3691 var heightPercent = this.originalHeight / this.windowHeight; 3692 this.newWidth = 0; 3693 this.newHeight = 0; 3694 3695 if (widthPercent > heightPercent) { 3696 ratio = this.originalHeight / this.originalWidth; 3697 this.newWidth = this.windowWidth * 0.9; 3698 this.newHeight = this.windowWidth * 0.9 * ratio; 3699 } else { 3700 ratio = this.originalWidth / this.originalHeight; 3701 this.newWidth = this.windowHeight * 0.9 * ratio; 3702 this.newHeight = this.windowHeight * 0.9; 3703 } 3704 3705 this._animateImageIn(); 3706 3707 // Handle Exit triggers 3708 this._handleWindowScrollBound = this._handleWindowScroll.bind(this); 3709 this._handleWindowResizeBound = this._handleWindowResize.bind(this); 3710 this._handleWindowEscapeBound = this._handleWindowEscape.bind(this); 3711 3712 window.addEventListener('scroll', this._handleWindowScrollBound); 3713 window.addEventListener('resize', this._handleWindowResizeBound); 3714 window.addEventListener('keyup', this._handleWindowEscapeBound); 3715 } 3716 3717 /** 3718 * Close Materialbox 3719 */ 3720 3721 }, { 3722 key: "close", 3723 value: function close() { 3724 var _this20 = this; 3725 3726 this._updateVars(); 3727 this.doneAnimating = false; 3728 3729 // onCloseStart callback 3730 if (typeof this.options.onCloseStart === 'function') { 3731 this.options.onCloseStart.call(this, this.el); 3732 } 3733 3734 anim.remove(this.el); 3735 anim.remove(this.$overlay[0]); 3736 3737 if (this.caption !== '') { 3738 anim.remove(this.$photoCaption[0]); 3739 } 3740 3741 // disable exit handlers 3742 window.removeEventListener('scroll', this._handleWindowScrollBound); 3743 window.removeEventListener('resize', this._handleWindowResizeBound); 3744 window.removeEventListener('keyup', this._handleWindowEscapeBound); 3745 3746 anim({ 3747 targets: this.$overlay[0], 3748 opacity: 0, 3749 duration: this.options.outDuration, 3750 easing: 'easeOutQuad', 3751 complete: function () { 3752 _this20.overlayActive = false; 3753 _this20.$overlay.remove(); 3754 } 3755 }); 3756 3757 this._animateImageOut(); 3758 3759 // Remove Caption + reset css settings on image 3760 if (this.caption !== '') { 3761 anim({ 3762 targets: this.$photoCaption[0], 3763 opacity: 0, 3764 duration: this.options.outDuration, 3765 easing: 'easeOutQuad', 3766 complete: function () { 3767 _this20.$photoCaption.remove(); 3768 } 3769 }); 3770 } 3771 } 3772 }], [{ 3773 key: "init", 3774 value: function init(els, options) { 3775 return _get(Materialbox.__proto__ || Object.getPrototypeOf(Materialbox), "init", this).call(this, this, els, options); 3776 } 3777 3778 /** 3779 * Get Instance 3780 */ 3781 3782 }, { 3783 key: "getInstance", 3784 value: function getInstance(el) { 3785 var domElem = !!el.jquery ? el[0] : el; 3786 return domElem.M_Materialbox; 3787 } 3788 }, { 3789 key: "defaults", 3790 get: function () { 3791 return _defaults; 3792 } 3793 }]); 3794 3795 return Materialbox; 3796 }(Component); 3797 3798 M.Materialbox = Materialbox; 3799 3800 if (M.jQueryLoaded) { 3801 M.initializeJqueryWrapper(Materialbox, 'materialbox', 'M_Materialbox'); 3802 } 3803})(cash, M.anime); 3804;(function ($) { 3805 'use strict'; 3806 3807 var _defaults = { 3808 responsiveThreshold: 0 // breakpoint for swipeable 3809 }; 3810 3811 var Parallax = function (_Component5) { 3812 _inherits(Parallax, _Component5); 3813 3814 function Parallax(el, options) { 3815 _classCallCheck(this, Parallax); 3816 3817 var _this21 = _possibleConstructorReturn(this, (Parallax.__proto__ || Object.getPrototypeOf(Parallax)).call(this, Parallax, el, options)); 3818 3819 _this21.el.M_Parallax = _this21; 3820 3821 /** 3822 * Options for the Parallax 3823 * @member Parallax#options 3824 * @prop {Number} responsiveThreshold 3825 */ 3826 _this21.options = $.extend({}, Parallax.defaults, options); 3827 _this21._enabled = window.innerWidth > _this21.options.responsiveThreshold; 3828 3829 _this21.$img = _this21.$el.find('img').first(); 3830 _this21.$img.each(function () { 3831 var el = this; 3832 if (el.complete) $(el).trigger('load'); 3833 }); 3834 3835 _this21._updateParallax(); 3836 _this21._setupEventHandlers(); 3837 _this21._setupStyles(); 3838 3839 Parallax._parallaxes.push(_this21); 3840 return _this21; 3841 } 3842 3843 _createClass(Parallax, [{ 3844 key: "destroy", 3845 3846 3847 /** 3848 * Teardown component 3849 */ 3850 value: function destroy() { 3851 Parallax._parallaxes.splice(Parallax._parallaxes.indexOf(this), 1); 3852 this.$img[0].style.transform = ''; 3853 this._removeEventHandlers(); 3854 3855 this.$el[0].M_Parallax = undefined; 3856 } 3857 }, { 3858 key: "_setupEventHandlers", 3859 value: function _setupEventHandlers() { 3860 this._handleImageLoadBound = this._handleImageLoad.bind(this); 3861 this.$img[0].addEventListener('load', this._handleImageLoadBound); 3862 3863 if (Parallax._parallaxes.length === 0) { 3864 Parallax._handleScrollThrottled = M.throttle(Parallax._handleScroll, 5); 3865 window.addEventListener('scroll', Parallax._handleScrollThrottled); 3866 3867 Parallax._handleWindowResizeThrottled = M.throttle(Parallax._handleWindowResize, 5); 3868 window.addEventListener('resize', Parallax._handleWindowResizeThrottled); 3869 } 3870 } 3871 }, { 3872 key: "_removeEventHandlers", 3873 value: function _removeEventHandlers() { 3874 this.$img[0].removeEventListener('load', this._handleImageLoadBound); 3875 3876 if (Parallax._parallaxes.length === 0) { 3877 window.removeEventListener('scroll', Parallax._handleScrollThrottled); 3878 window.removeEventListener('resize', Parallax._handleWindowResizeThrottled); 3879 } 3880 } 3881 }, { 3882 key: "_setupStyles", 3883 value: function _setupStyles() { 3884 this.$img[0].style.opacity = 1; 3885 } 3886 }, { 3887 key: "_handleImageLoad", 3888 value: function _handleImageLoad() { 3889 this._updateParallax(); 3890 } 3891 }, { 3892 key: "_updateParallax", 3893 value: function _updateParallax() { 3894 var containerHeight = this.$el.height() > 0 ? this.el.parentNode.offsetHeight : 500; 3895 var imgHeight = this.$img[0].offsetHeight; 3896 var parallaxDist = imgHeight - containerHeight; 3897 var bottom = this.$el.offset().top + containerHeight; 3898 var top = this.$el.offset().top; 3899 var scrollTop = M.getDocumentScrollTop(); 3900 var windowHeight = window.innerHeight; 3901 var windowBottom = scrollTop + windowHeight; 3902 var percentScrolled = (windowBottom - top) / (containerHeight + windowHeight); 3903 var parallax = parallaxDist * percentScrolled; 3904 3905 if (!this._enabled) { 3906 this.$img[0].style.transform = ''; 3907 } else if (bottom > scrollTop && top < scrollTop + windowHeight) { 3908 this.$img[0].style.transform = "translate3D(-50%, " + parallax + "px, 0)"; 3909 } 3910 } 3911 }], [{ 3912 key: "init", 3913 value: function init(els, options) { 3914 return _get(Parallax.__proto__ || Object.getPrototypeOf(Parallax), "init", this).call(this, this, els, options); 3915 } 3916 3917 /** 3918 * Get Instance 3919 */ 3920 3921 }, { 3922 key: "getInstance", 3923 value: function getInstance(el) { 3924 var domElem = !!el.jquery ? el[0] : el; 3925 return domElem.M_Parallax; 3926 } 3927 }, { 3928 key: "_handleScroll", 3929 value: function _handleScroll() { 3930 for (var i = 0; i < Parallax._parallaxes.length; i++) { 3931 var parallaxInstance = Parallax._parallaxes[i]; 3932 parallaxInstance._updateParallax.call(parallaxInstance); 3933 } 3934 } 3935 }, { 3936 key: "_handleWindowResize", 3937 value: function _handleWindowResize() { 3938 for (var i = 0; i < Parallax._parallaxes.length; i++) { 3939 var parallaxInstance = Parallax._parallaxes[i]; 3940 parallaxInstance._enabled = window.innerWidth > parallaxInstance.options.responsiveThreshold; 3941 } 3942 } 3943 }, { 3944 key: "defaults", 3945 get: function () { 3946 return _defaults; 3947 } 3948 }]); 3949 3950 return Parallax; 3951 }(Component); 3952 3953 /** 3954 * @static 3955 * @memberof Parallax 3956 */ 3957 3958 3959 Parallax._parallaxes = []; 3960 3961 M.Parallax = Parallax; 3962 3963 if (M.jQueryLoaded) { 3964 M.initializeJqueryWrapper(Parallax, 'parallax', 'M_Parallax'); 3965 } 3966})(cash); 3967;(function ($, anim) { 3968 'use strict'; 3969 3970 var _defaults = { 3971 duration: 300, 3972 onShow: null, 3973 swipeable: false, 3974 responsiveThreshold: Infinity // breakpoint for swipeable 3975 }; 3976 3977 /** 3978 * @class 3979 * 3980 */ 3981 3982 var Tabs = function (_Component6) { 3983 _inherits(Tabs, _Component6); 3984 3985 /** 3986 * Construct Tabs instance 3987 * @constructor 3988 * @param {Element} el 3989 * @param {Object} options 3990 */ 3991 function Tabs(el, options) { 3992 _classCallCheck(this, Tabs); 3993 3994 var _this22 = _possibleConstructorReturn(this, (Tabs.__proto__ || Object.getPrototypeOf(Tabs)).call(this, Tabs, el, options)); 3995 3996 _this22.el.M_Tabs = _this22; 3997 3998 /** 3999 * Options for the Tabs 4000 * @member Tabs#options 4001 * @prop {Number} duration 4002 * @prop {Function} onShow 4003 * @prop {Boolean} swipeable 4004 * @prop {Number} responsiveThreshold 4005 */ 4006 _this22.options = $.extend({}, Tabs.defaults, options); 4007 4008 // Setup 4009 _this22.$tabLinks = _this22.$el.children('li.tab').children('a'); 4010 _this22.index = 0; 4011 _this22._setupActiveTabLink(); 4012 4013 // Setup tabs content 4014 if (_this22.options.swipeable) { 4015 _this22._setupSwipeableTabs(); 4016 } else { 4017 _this22._setupNormalTabs(); 4018 } 4019 4020 // Setup tabs indicator after content to ensure accurate widths 4021 _this22._setTabsAndTabWidth(); 4022 _this22._createIndicator(); 4023 4024 _this22._setupEventHandlers(); 4025 return _this22; 4026 } 4027 4028 _createClass(Tabs, [{ 4029 key: "destroy", 4030 4031 4032 /** 4033 * Teardown component 4034 */ 4035 value: function destroy() { 4036 this._removeEventHandlers(); 4037 this._indicator.parentNode.removeChild(this._indicator); 4038 4039 if (this.options.swipeable) { 4040 this._teardownSwipeableTabs(); 4041 } else { 4042 this._teardownNormalTabs(); 4043 } 4044 4045 this.$el[0].M_Tabs = undefined; 4046 } 4047 4048 /** 4049 * Setup Event Handlers 4050 */ 4051 4052 }, { 4053 key: "_setupEventHandlers", 4054 value: function _setupEventHandlers() { 4055 this._handleWindowResizeBound = this._handleWindowResize.bind(this); 4056 window.addEventListener('resize', this._handleWindowResizeBound); 4057 4058 this._handleTabClickBound = this._handleTabClick.bind(this); 4059 this.el.addEventListener('click', this._handleTabClickBound); 4060 } 4061 4062 /** 4063 * Remove Event Handlers 4064 */ 4065 4066 }, { 4067 key: "_removeEventHandlers", 4068 value: function _removeEventHandlers() { 4069 window.removeEventListener('resize', this._handleWindowResizeBound); 4070 this.el.removeEventListener('click', this._handleTabClickBound); 4071 } 4072 4073 /** 4074 * Handle window Resize 4075 */ 4076 4077 }, { 4078 key: "_handleWindowResize", 4079 value: function _handleWindowResize() { 4080 this._setTabsAndTabWidth(); 4081 4082 if (this.tabWidth !== 0 && this.tabsWidth !== 0) { 4083 this._indicator.style.left = this._calcLeftPos(this.$activeTabLink) + 'px'; 4084 this._indicator.style.right = this._calcRightPos(this.$activeTabLink) + 'px'; 4085 } 4086 } 4087 4088 /** 4089 * Handle tab click 4090 * @param {Event} e 4091 */ 4092 4093 }, { 4094 key: "_handleTabClick", 4095 value: function _handleTabClick(e) { 4096 var _this23 = this; 4097 4098 var tab = $(e.target).closest('li.tab'); 4099 var tabLink = $(e.target).closest('a'); 4100 4101 // Handle click on tab link only 4102 if (!tabLink.length || !tabLink.parent().hasClass('tab')) { 4103 return; 4104 } 4105 4106 if (tab.hasClass('disabled')) { 4107 e.preventDefault(); 4108 return; 4109 } 4110 4111 // Act as regular link if target attribute is specified. 4112 if (!!tabLink.attr('target')) { 4113 return; 4114 } 4115 4116 // Make the old tab inactive. 4117 this.$activeTabLink.removeClass('active'); 4118 var $oldContent = this.$content; 4119 4120 // Update the variables with the new link and content 4121 this.$activeTabLink = tabLink; 4122 this.$content = $(M.escapeHash(tabLink[0].hash)); 4123 this.$tabLinks = this.$el.children('li.tab').children('a'); 4124 4125 // Make the tab active. 4126 this.$activeTabLink.addClass('active'); 4127 var prevIndex = this.index; 4128 this.index = Math.max(this.$tabLinks.index(tabLink), 0); 4129 4130 // Swap content 4131 if (this.options.swipeable) { 4132 if (this._tabsCarousel) { 4133 this._tabsCarousel.set(this.index, function () { 4134 if (typeof _this23.options.onShow === 'function') { 4135 _this23.options.onShow.call(_this23, _this23.$content[0]); 4136 } 4137 }); 4138 } 4139 } else { 4140 if (this.$content.length) { 4141 this.$content[0].style.display = 'block'; 4142 this.$content.addClass('active'); 4143 if (typeof this.options.onShow === 'function') { 4144 this.options.onShow.call(this, this.$content[0]); 4145 } 4146 4147 if ($oldContent.length && !$oldContent.is(this.$content)) { 4148 $oldContent[0].style.display = 'none'; 4149 $oldContent.removeClass('active'); 4150 } 4151 } 4152 } 4153 4154 // Update widths after content is swapped (scrollbar bugfix) 4155 this._setTabsAndTabWidth(); 4156 4157 // Update indicator 4158 this._animateIndicator(prevIndex); 4159 4160 // Prevent the anchor's default click action 4161 e.preventDefault(); 4162 } 4163 4164 /** 4165 * Generate elements for tab indicator. 4166 */ 4167 4168 }, { 4169 key: "_createIndicator", 4170 value: function _createIndicator() { 4171 var _this24 = this; 4172 4173 var indicator = document.createElement('li'); 4174 indicator.classList.add('indicator'); 4175 4176 this.el.appendChild(indicator); 4177 this._indicator = indicator; 4178 4179 setTimeout(function () { 4180 _this24._indicator.style.left = _this24._calcLeftPos(_this24.$activeTabLink) + 'px'; 4181 _this24._indicator.style.right = _this24._calcRightPos(_this24.$activeTabLink) + 'px'; 4182 }, 0); 4183 } 4184 4185 /** 4186 * Setup first active tab link. 4187 */ 4188 4189 }, { 4190 key: "_setupActiveTabLink", 4191 value: function _setupActiveTabLink() { 4192 // If the location.hash matches one of the links, use that as the active tab. 4193 this.$activeTabLink = $(this.$tabLinks.filter('[href="' + location.hash + '"]')); 4194 4195 // If no match is found, use the first link or any with class 'active' as the initial active tab. 4196 if (this.$activeTabLink.length === 0) { 4197 this.$activeTabLink = this.$el.children('li.tab').children('a.active').first(); 4198 } 4199 if (this.$activeTabLink.length === 0) { 4200 this.$activeTabLink = this.$el.children('li.tab').children('a').first(); 4201 } 4202 4203 this.$tabLinks.removeClass('active'); 4204 this.$activeTabLink[0].classList.add('active'); 4205 4206 this.index = Math.max(this.$tabLinks.index(this.$activeTabLink), 0); 4207 4208 if (this.$activeTabLink.length) { 4209 this.$content = $(M.escapeHash(this.$activeTabLink[0].hash)); 4210 this.$content.addClass('active'); 4211 } 4212 } 4213 4214 /** 4215 * Setup swipeable tabs 4216 */ 4217 4218 }, { 4219 key: "_setupSwipeableTabs", 4220 value: function _setupSwipeableTabs() { 4221 var _this25 = this; 4222 4223 // Change swipeable according to responsive threshold 4224 if (window.innerWidth > this.options.responsiveThreshold) { 4225 this.options.swipeable = false; 4226 } 4227 4228 var $tabsContent = $(); 4229 this.$tabLinks.each(function (link) { 4230 var $currContent = $(M.escapeHash(link.hash)); 4231 $currContent.addClass('carousel-item'); 4232 $tabsContent = $tabsContent.add($currContent); 4233 }); 4234 4235 var $tabsWrapper = $('<div class="tabs-content carousel carousel-slider"></div>'); 4236 $tabsContent.first().before($tabsWrapper); 4237 $tabsWrapper.append($tabsContent); 4238 $tabsContent[0].style.display = ''; 4239 4240 // Keep active tab index to set initial carousel slide 4241 var activeTabIndex = this.$activeTabLink.closest('.tab').index(); 4242 4243 this._tabsCarousel = M.Carousel.init($tabsWrapper[0], { 4244 fullWidth: true, 4245 noWrap: true, 4246 onCycleTo: function (item) { 4247 var prevIndex = _this25.index; 4248 _this25.index = $(item).index(); 4249 _this25.$activeTabLink.removeClass('active'); 4250 _this25.$activeTabLink = _this25.$tabLinks.eq(_this25.index); 4251 _this25.$activeTabLink.addClass('active'); 4252 _this25._animateIndicator(prevIndex); 4253 if (typeof _this25.options.onShow === 'function') { 4254 _this25.options.onShow.call(_this25, _this25.$content[0]); 4255 } 4256 } 4257 }); 4258 4259 // Set initial carousel slide to active tab 4260 this._tabsCarousel.set(activeTabIndex); 4261 } 4262 4263 /** 4264 * Teardown normal tabs. 4265 */ 4266 4267 }, { 4268 key: "_teardownSwipeableTabs", 4269 value: function _teardownSwipeableTabs() { 4270 var $tabsWrapper = this._tabsCarousel.$el; 4271 this._tabsCarousel.destroy(); 4272 4273 // Unwrap 4274 $tabsWrapper.after($tabsWrapper.children()); 4275 $tabsWrapper.remove(); 4276 } 4277 4278 /** 4279 * Setup normal tabs. 4280 */ 4281 4282 }, { 4283 key: "_setupNormalTabs", 4284 value: function _setupNormalTabs() { 4285 // Hide Tabs Content 4286 this.$tabLinks.not(this.$activeTabLink).each(function (link) { 4287 if (!!link.hash) { 4288 var $currContent = $(M.escapeHash(link.hash)); 4289 if ($currContent.length) { 4290 $currContent[0].style.display = 'none'; 4291 } 4292 } 4293 }); 4294 } 4295 4296 /** 4297 * Teardown normal tabs. 4298 */ 4299 4300 }, { 4301 key: "_teardownNormalTabs", 4302 value: function _teardownNormalTabs() { 4303 // show Tabs Content 4304 this.$tabLinks.each(function (link) { 4305 if (!!link.hash) { 4306 var $currContent = $(M.escapeHash(link.hash)); 4307 if ($currContent.length) { 4308 $currContent[0].style.display = ''; 4309 } 4310 } 4311 }); 4312 } 4313 4314 /** 4315 * set tabs and tab width 4316 */ 4317 4318 }, { 4319 key: "_setTabsAndTabWidth", 4320 value: function _setTabsAndTabWidth() { 4321 this.tabsWidth = this.$el.width(); 4322 this.tabWidth = Math.max(this.tabsWidth, this.el.scrollWidth) / this.$tabLinks.length; 4323 } 4324 4325 /** 4326 * Finds right attribute for indicator based on active tab. 4327 * @param {cash} el 4328 */ 4329 4330 }, { 4331 key: "_calcRightPos", 4332 value: function _calcRightPos(el) { 4333 return Math.ceil(this.tabsWidth - el.position().left - el[0].getBoundingClientRect().width); 4334 } 4335 4336 /** 4337 * Finds left attribute for indicator based on active tab. 4338 * @param {cash} el 4339 */ 4340 4341 }, { 4342 key: "_calcLeftPos", 4343 value: function _calcLeftPos(el) { 4344 return Math.floor(el.position().left); 4345 } 4346 }, { 4347 key: "updateTabIndicator", 4348 value: function updateTabIndicator() { 4349 this._setTabsAndTabWidth(); 4350 this._animateIndicator(this.index); 4351 } 4352 4353 /** 4354 * Animates Indicator to active tab. 4355 * @param {Number} prevIndex 4356 */ 4357 4358 }, { 4359 key: "_animateIndicator", 4360 value: function _animateIndicator(prevIndex) { 4361 var leftDelay = 0, 4362 rightDelay = 0; 4363 4364 if (this.index - prevIndex >= 0) { 4365 leftDelay = 90; 4366 } else { 4367 rightDelay = 90; 4368 } 4369 4370 // Animate 4371 var animOptions = { 4372 targets: this._indicator, 4373 left: { 4374 value: this._calcLeftPos(this.$activeTabLink), 4375 delay: leftDelay 4376 }, 4377 right: { 4378 value: this._calcRightPos(this.$activeTabLink), 4379 delay: rightDelay 4380 }, 4381 duration: this.options.duration, 4382 easing: 'easeOutQuad' 4383 }; 4384 anim.remove(this._indicator); 4385 anim(animOptions); 4386 } 4387 4388 /** 4389 * Select tab. 4390 * @param {String} tabId 4391 */ 4392 4393 }, { 4394 key: "select", 4395 value: function select(tabId) { 4396 var tab = this.$tabLinks.filter('[href="#' + tabId + '"]'); 4397 if (tab.length) { 4398 tab.trigger('click'); 4399 } 4400 } 4401 }], [{ 4402 key: "init", 4403 value: function init(els, options) { 4404 return _get(Tabs.__proto__ || Object.getPrototypeOf(Tabs), "init", this).call(this, this, els, options); 4405 } 4406 4407 /** 4408 * Get Instance 4409 */ 4410 4411 }, { 4412 key: "getInstance", 4413 value: function getInstance(el) { 4414 var domElem = !!el.jquery ? el[0] : el; 4415 return domElem.M_Tabs; 4416 } 4417 }, { 4418 key: "defaults", 4419 get: function () { 4420 return _defaults; 4421 } 4422 }]); 4423 4424 return Tabs; 4425 }(Component); 4426 4427 M.Tabs = Tabs; 4428 4429 if (M.jQueryLoaded) { 4430 M.initializeJqueryWrapper(Tabs, 'tabs', 'M_Tabs'); 4431 } 4432})(cash, M.anime); 4433;(function ($, anim) { 4434 'use strict'; 4435 4436 var _defaults = { 4437 exitDelay: 200, 4438 enterDelay: 0, 4439 html: null, 4440 margin: 5, 4441 inDuration: 250, 4442 outDuration: 200, 4443 position: 'bottom', 4444 transitionMovement: 10 4445 }; 4446 4447 /** 4448 * @class 4449 * 4450 */ 4451 4452 var Tooltip = function (_Component7) { 4453 _inherits(Tooltip, _Component7); 4454 4455 /** 4456 * Construct Tooltip instance 4457 * @constructor 4458 * @param {Element} el 4459 * @param {Object} options 4460 */ 4461 function Tooltip(el, options) { 4462 _classCallCheck(this, Tooltip); 4463 4464 var _this26 = _possibleConstructorReturn(this, (Tooltip.__proto__ || Object.getPrototypeOf(Tooltip)).call(this, Tooltip, el, options)); 4465 4466 _this26.el.M_Tooltip = _this26; 4467 _this26.options = $.extend({}, Tooltip.defaults, options); 4468 4469 _this26.isOpen = false; 4470 _this26.isHovered = false; 4471 _this26.isFocused = false; 4472 _this26._appendTooltipEl(); 4473 _this26._setupEventHandlers(); 4474 return _this26; 4475 } 4476 4477 _createClass(Tooltip, [{ 4478 key: "destroy", 4479 4480 4481 /** 4482 * Teardown component 4483 */ 4484 value: function destroy() { 4485 $(this.tooltipEl).remove(); 4486 this._removeEventHandlers(); 4487 this.el.M_Tooltip = undefined; 4488 } 4489 }, { 4490 key: "_appendTooltipEl", 4491 value: function _appendTooltipEl() { 4492 var tooltipEl = document.createElement('div'); 4493 tooltipEl.classList.add('material-tooltip'); 4494 this.tooltipEl = tooltipEl; 4495 4496 var tooltipContentEl = document.createElement('div'); 4497 tooltipContentEl.classList.add('tooltip-content'); 4498 tooltipContentEl.innerHTML = this.options.html; 4499 tooltipEl.appendChild(tooltipContentEl); 4500 document.body.appendChild(tooltipEl); 4501 } 4502 }, { 4503 key: "_updateTooltipContent", 4504 value: function _updateTooltipContent() { 4505 this.tooltipEl.querySelector('.tooltip-content').innerHTML = this.options.html; 4506 } 4507 }, { 4508 key: "_setupEventHandlers", 4509 value: function _setupEventHandlers() { 4510 this._handleMouseEnterBound = this._handleMouseEnter.bind(this); 4511 this._handleMouseLeaveBound = this._handleMouseLeave.bind(this); 4512 this._handleFocusBound = this._handleFocus.bind(this); 4513 this._handleBlurBound = this._handleBlur.bind(this); 4514 this.el.addEventListener('mouseenter', this._handleMouseEnterBound); 4515 this.el.addEventListener('mouseleave', this._handleMouseLeaveBound); 4516 this.el.addEventListener('focus', this._handleFocusBound, true); 4517 this.el.addEventListener('blur', this._handleBlurBound, true); 4518 } 4519 }, { 4520 key: "_removeEventHandlers", 4521 value: function _removeEventHandlers() { 4522 this.el.removeEventListener('mouseenter', this._handleMouseEnterBound); 4523 this.el.removeEventListener('mouseleave', this._handleMouseLeaveBound); 4524 this.el.removeEventListener('focus', this._handleFocusBound, true); 4525 this.el.removeEventListener('blur', this._handleBlurBound, true); 4526 } 4527 }, { 4528 key: "open", 4529 value: function open(isManual) { 4530 if (this.isOpen) { 4531 return; 4532 } 4533 isManual = isManual === undefined ? true : undefined; // Default value true 4534 this.isOpen = true; 4535 // Update tooltip content with HTML attribute options 4536 this.options = $.extend({}, this.options, this._getAttributeOptions()); 4537 this._updateTooltipContent(); 4538 this._setEnterDelayTimeout(isManual); 4539 } 4540 }, { 4541 key: "close", 4542 value: function close() { 4543 if (!this.isOpen) { 4544 return; 4545 } 4546 4547 this.isHovered = false; 4548 this.isFocused = false; 4549 this.isOpen = false; 4550 this._setExitDelayTimeout(); 4551 } 4552 4553 /** 4554 * Create timeout which delays when the tooltip closes 4555 */ 4556 4557 }, { 4558 key: "_setExitDelayTimeout", 4559 value: function _setExitDelayTimeout() { 4560 var _this27 = this; 4561 4562 clearTimeout(this._exitDelayTimeout); 4563 4564 this._exitDelayTimeout = setTimeout(function () { 4565 if (_this27.isHovered || _this27.isFocused) { 4566 return; 4567 } 4568 4569 _this27._animateOut(); 4570 }, this.options.exitDelay); 4571 } 4572 4573 /** 4574 * Create timeout which delays when the toast closes 4575 */ 4576 4577 }, { 4578 key: "_setEnterDelayTimeout", 4579 value: function _setEnterDelayTimeout(isManual) { 4580 var _this28 = this; 4581 4582 clearTimeout(this._enterDelayTimeout); 4583 4584 this._enterDelayTimeout = setTimeout(function () { 4585 if (!_this28.isHovered && !_this28.isFocused && !isManual) { 4586 return; 4587 } 4588 4589 _this28._animateIn(); 4590 }, this.options.enterDelay); 4591 } 4592 }, { 4593 key: "_positionTooltip", 4594 value: function _positionTooltip() { 4595 var origin = this.el, 4596 tooltip = this.tooltipEl, 4597 originHeight = origin.offsetHeight, 4598 originWidth = origin.offsetWidth, 4599 tooltipHeight = tooltip.offsetHeight, 4600 tooltipWidth = tooltip.offsetWidth, 4601 newCoordinates = void 0, 4602 margin = this.options.margin, 4603 targetTop = void 0, 4604 targetLeft = void 0; 4605 4606 this.xMovement = 0, this.yMovement = 0; 4607 4608 targetTop = origin.getBoundingClientRect().top + M.getDocumentScrollTop(); 4609 targetLeft = origin.getBoundingClientRect().left + M.getDocumentScrollLeft(); 4610 4611 if (this.options.position === 'top') { 4612 targetTop += -tooltipHeight - margin; 4613 targetLeft += originWidth / 2 - tooltipWidth / 2; 4614 this.yMovement = -this.options.transitionMovement; 4615 } else if (this.options.position === 'right') { 4616 targetTop += originHeight / 2 - tooltipHeight / 2; 4617 targetLeft += originWidth + margin; 4618 this.xMovement = this.options.transitionMovement; 4619 } else if (this.options.position === 'left') { 4620 targetTop += originHeight / 2 - tooltipHeight / 2; 4621 targetLeft += -tooltipWidth - margin; 4622 this.xMovement = -this.options.transitionMovement; 4623 } else { 4624 targetTop += originHeight + margin; 4625 targetLeft += originWidth / 2 - tooltipWidth / 2; 4626 this.yMovement = this.options.transitionMovement; 4627 } 4628 4629 newCoordinates = this._repositionWithinScreen(targetLeft, targetTop, tooltipWidth, tooltipHeight); 4630 $(tooltip).css({ 4631 top: newCoordinates.y + 'px', 4632 left: newCoordinates.x + 'px' 4633 }); 4634 } 4635 }, { 4636 key: "_repositionWithinScreen", 4637 value: function _repositionWithinScreen(x, y, width, height) { 4638 var scrollLeft = M.getDocumentScrollLeft(); 4639 var scrollTop = M.getDocumentScrollTop(); 4640 var newX = x - scrollLeft; 4641 var newY = y - scrollTop; 4642 4643 var bounding = { 4644 left: newX, 4645 top: newY, 4646 width: width, 4647 height: height 4648 }; 4649 4650 var offset = this.options.margin + this.options.transitionMovement; 4651 var edges = M.checkWithinContainer(document.body, bounding, offset); 4652 4653 if (edges.left) { 4654 newX = offset; 4655 } else if (edges.right) { 4656 newX -= newX + width - window.innerWidth; 4657 } 4658 4659 if (edges.top) { 4660 newY = offset; 4661 } else if (edges.bottom) { 4662 newY -= newY + height - window.innerHeight; 4663 } 4664 4665 return { 4666 x: newX + scrollLeft, 4667 y: newY + scrollTop 4668 }; 4669 } 4670 }, { 4671 key: "_animateIn", 4672 value: function _animateIn() { 4673 this._positionTooltip(); 4674 this.tooltipEl.style.visibility = 'visible'; 4675 anim.remove(this.tooltipEl); 4676 anim({ 4677 targets: this.tooltipEl, 4678 opacity: 1, 4679 translateX: this.xMovement, 4680 translateY: this.yMovement, 4681 duration: this.options.inDuration, 4682 easing: 'easeOutCubic' 4683 }); 4684 } 4685 }, { 4686 key: "_animateOut", 4687 value: function _animateOut() { 4688 anim.remove(this.tooltipEl); 4689 anim({ 4690 targets: this.tooltipEl, 4691 opacity: 0, 4692 translateX: 0, 4693 translateY: 0, 4694 duration: this.options.outDuration, 4695 easing: 'easeOutCubic' 4696 }); 4697 } 4698 }, { 4699 key: "_handleMouseEnter", 4700 value: function _handleMouseEnter() { 4701 this.isHovered = true; 4702 this.isFocused = false; // Allows close of tooltip when opened by focus. 4703 this.open(false); 4704 } 4705 }, { 4706 key: "_handleMouseLeave", 4707 value: function _handleMouseLeave() { 4708 this.isHovered = false; 4709 this.isFocused = false; // Allows close of tooltip when opened by focus. 4710 this.close(); 4711 } 4712 }, { 4713 key: "_handleFocus", 4714 value: function _handleFocus() { 4715 if (M.tabPressed) { 4716 this.isFocused = true; 4717 this.open(false); 4718 } 4719 } 4720 }, { 4721 key: "_handleBlur", 4722 value: function _handleBlur() { 4723 this.isFocused = false; 4724 this.close(); 4725 } 4726 }, { 4727 key: "_getAttributeOptions", 4728 value: function _getAttributeOptions() { 4729 var attributeOptions = {}; 4730 var tooltipTextOption = this.el.getAttribute('data-tooltip'); 4731 var positionOption = this.el.getAttribute('data-position'); 4732 4733 if (tooltipTextOption) { 4734 attributeOptions.html = tooltipTextOption; 4735 } 4736 4737 if (positionOption) { 4738 attributeOptions.position = positionOption; 4739 } 4740 return attributeOptions; 4741 } 4742 }], [{ 4743 key: "init", 4744 value: function init(els, options) { 4745 return _get(Tooltip.__proto__ || Object.getPrototypeOf(Tooltip), "init", this).call(this, this, els, options); 4746 } 4747 4748 /** 4749 * Get Instance 4750 */ 4751 4752 }, { 4753 key: "getInstance", 4754 value: function getInstance(el) { 4755 var domElem = !!el.jquery ? el[0] : el; 4756 return domElem.M_Tooltip; 4757 } 4758 }, { 4759 key: "defaults", 4760 get: function () { 4761 return _defaults; 4762 } 4763 }]); 4764 4765 return Tooltip; 4766 }(Component); 4767 4768 M.Tooltip = Tooltip; 4769 4770 if (M.jQueryLoaded) { 4771 M.initializeJqueryWrapper(Tooltip, 'tooltip', 'M_Tooltip'); 4772 } 4773})(cash, M.anime); 4774; /*! 4775 * Waves v0.6.4 4776 * http://fian.my.id/Waves 4777 * 4778 * Copyright 2014 Alfiana E. Sibuea and other contributors 4779 * Released under the MIT license 4780 * https://github.com/fians/Waves/blob/master/LICENSE 4781 */ 4782 4783;(function (window) { 4784 'use strict'; 4785 4786 var Waves = Waves || {}; 4787 var $$ = document.querySelectorAll.bind(document); 4788 4789 // Find exact position of element 4790 function isWindow(obj) { 4791 return obj !== null && obj === obj.window; 4792 } 4793 4794 function getWindow(elem) { 4795 return isWindow(elem) ? elem : elem.nodeType === 9 && elem.defaultView; 4796 } 4797 4798 function offset(elem) { 4799 var docElem, 4800 win, 4801 box = { top: 0, left: 0 }, 4802 doc = elem && elem.ownerDocument; 4803 4804 docElem = doc.documentElement; 4805 4806 if (typeof elem.getBoundingClientRect !== typeof undefined) { 4807 box = elem.getBoundingClientRect(); 4808 } 4809 win = getWindow(doc); 4810 return { 4811 top: box.top + win.pageYOffset - docElem.clientTop, 4812 left: box.left + win.pageXOffset - docElem.clientLeft 4813 }; 4814 } 4815 4816 function convertStyle(obj) { 4817 var style = ''; 4818 4819 for (var a in obj) { 4820 if (obj.hasOwnProperty(a)) { 4821 style += a + ':' + obj[a] + ';'; 4822 } 4823 } 4824 4825 return style; 4826 } 4827 4828 var Effect = { 4829 4830 // Effect delay 4831 duration: 750, 4832 4833 show: function (e, element) { 4834 4835 // Disable right click 4836 if (e.button === 2) { 4837 return false; 4838 } 4839 4840 var el = element || this; 4841 4842 // Create ripple 4843 var ripple = document.createElement('div'); 4844 ripple.className = 'waves-ripple'; 4845 el.appendChild(ripple); 4846 4847 // Get click coordinate and element witdh 4848 var pos = offset(el); 4849 var relativeY = e.pageY - pos.top; 4850 var relativeX = e.pageX - pos.left; 4851 var scale = 'scale(' + el.clientWidth / 100 * 10 + ')'; 4852 4853 // Support for touch devices 4854 if ('touches' in e) { 4855 relativeY = e.touches[0].pageY - pos.top; 4856 relativeX = e.touches[0].pageX - pos.left; 4857 } 4858 4859 // Attach data to element 4860 ripple.setAttribute('data-hold', Date.now()); 4861 ripple.setAttribute('data-scale', scale); 4862 ripple.setAttribute('data-x', relativeX); 4863 ripple.setAttribute('data-y', relativeY); 4864 4865 // Set ripple position 4866 var rippleStyle = { 4867 'top': relativeY + 'px', 4868 'left': relativeX + 'px' 4869 }; 4870 4871 ripple.className = ripple.className + ' waves-notransition'; 4872 ripple.setAttribute('style', convertStyle(rippleStyle)); 4873 ripple.className = ripple.className.replace('waves-notransition', ''); 4874 4875 // Scale the ripple 4876 rippleStyle['-webkit-transform'] = scale; 4877 rippleStyle['-moz-transform'] = scale; 4878 rippleStyle['-ms-transform'] = scale; 4879 rippleStyle['-o-transform'] = scale; 4880 rippleStyle.transform = scale; 4881 rippleStyle.opacity = '1'; 4882 4883 rippleStyle['-webkit-transition-duration'] = Effect.duration + 'ms'; 4884 rippleStyle['-moz-transition-duration'] = Effect.duration + 'ms'; 4885 rippleStyle['-o-transition-duration'] = Effect.duration + 'ms'; 4886 rippleStyle['transition-duration'] = Effect.duration + 'ms'; 4887 4888 rippleStyle['-webkit-transition-timing-function'] = 'cubic-bezier(0.250, 0.460, 0.450, 0.940)'; 4889 rippleStyle['-moz-transition-timing-function'] = 'cubic-bezier(0.250, 0.460, 0.450, 0.940)'; 4890 rippleStyle['-o-transition-timing-function'] = 'cubic-bezier(0.250, 0.460, 0.450, 0.940)'; 4891 rippleStyle['transition-timing-function'] = 'cubic-bezier(0.250, 0.460, 0.450, 0.940)'; 4892 4893 ripple.setAttribute('style', convertStyle(rippleStyle)); 4894 }, 4895 4896 hide: function (e) { 4897 TouchHandler.touchup(e); 4898 4899 var el = this; 4900 var width = el.clientWidth * 1.4; 4901 4902 // Get first ripple 4903 var ripple = null; 4904 var ripples = el.getElementsByClassName('waves-ripple'); 4905 if (ripples.length > 0) { 4906 ripple = ripples[ripples.length - 1]; 4907 } else { 4908 return false; 4909 } 4910 4911 var relativeX = ripple.getAttribute('data-x'); 4912 var relativeY = ripple.getAttribute('data-y'); 4913 var scale = ripple.getAttribute('data-scale'); 4914 4915 // Get delay beetween mousedown and mouse leave 4916 var diff = Date.now() - Number(ripple.getAttribute('data-hold')); 4917 var delay = 350 - diff; 4918 4919 if (delay < 0) { 4920 delay = 0; 4921 } 4922 4923 // Fade out ripple after delay 4924 setTimeout(function () { 4925 var style = { 4926 'top': relativeY + 'px', 4927 'left': relativeX + 'px', 4928 'opacity': '0', 4929 4930 // Duration 4931 '-webkit-transition-duration': Effect.duration + 'ms', 4932 '-moz-transition-duration': Effect.duration + 'ms', 4933 '-o-transition-duration': Effect.duration + 'ms', 4934 'transition-duration': Effect.duration + 'ms', 4935 '-webkit-transform': scale, 4936 '-moz-transform': scale, 4937 '-ms-transform': scale, 4938 '-o-transform': scale, 4939 'transform': scale 4940 }; 4941 4942 ripple.setAttribute('style', convertStyle(style)); 4943 4944 setTimeout(function () { 4945 try { 4946 el.removeChild(ripple); 4947 } catch (e) { 4948 return false; 4949 } 4950 }, Effect.duration); 4951 }, delay); 4952 }, 4953 4954 // Little hack to make <input> can perform waves effect 4955 wrapInput: function (elements) { 4956 for (var a = 0; a < elements.length; a++) { 4957 var el = elements[a]; 4958 4959 if (el.tagName.toLowerCase() === 'input') { 4960 var parent = el.parentNode; 4961 4962 // If input already have parent just pass through 4963 if (parent.tagName.toLowerCase() === 'i' && parent.className.indexOf('waves-effect') !== -1) { 4964 continue; 4965 } 4966 4967 // Put element class and style to the specified parent 4968 var wrapper = document.createElement('i'); 4969 wrapper.className = el.className + ' waves-input-wrapper'; 4970 4971 var elementStyle = el.getAttribute('style'); 4972 4973 if (!elementStyle) { 4974 elementStyle = ''; 4975 } 4976 4977 wrapper.setAttribute('style', elementStyle); 4978 4979 el.className = 'waves-button-input'; 4980 el.removeAttribute('style'); 4981 4982 // Put element as child 4983 parent.replaceChild(wrapper, el); 4984 wrapper.appendChild(el); 4985 } 4986 } 4987 } 4988 }; 4989 4990 /** 4991 * Disable mousedown event for 500ms during and after touch 4992 */ 4993 var TouchHandler = { 4994 /* uses an integer rather than bool so there's no issues with 4995 * needing to clear timeouts if another touch event occurred 4996 * within the 500ms. Cannot mouseup between touchstart and 4997 * touchend, nor in the 500ms after touchend. */ 4998 touches: 0, 4999 allowEvent: function (e) { 5000 var allow = true; 5001 5002 if (e.type === 'touchstart') { 5003 TouchHandler.touches += 1; //push 5004 } else if (e.type === 'touchend' || e.type === 'touchcancel') { 5005 setTimeout(function () { 5006 if (TouchHandler.touches > 0) { 5007 TouchHandler.touches -= 1; //pop after 500ms 5008 } 5009 }, 500); 5010 } else if (e.type === 'mousedown' && TouchHandler.touches > 0) { 5011 allow = false; 5012 } 5013 5014 return allow; 5015 }, 5016 touchup: function (e) { 5017 TouchHandler.allowEvent(e); 5018 } 5019 }; 5020 5021 /** 5022 * Delegated click handler for .waves-effect element. 5023 * returns null when .waves-effect element not in "click tree" 5024 */ 5025 function getWavesEffectElement(e) { 5026 if (TouchHandler.allowEvent(e) === false) { 5027 return null; 5028 } 5029 5030 var element = null; 5031 var target = e.target || e.srcElement; 5032 5033 while (target.parentNode !== null) { 5034 if (!(target instanceof SVGElement) && target.className.indexOf('waves-effect') !== -1) { 5035 element = target; 5036 break; 5037 } 5038 target = target.parentNode; 5039 } 5040 return element; 5041 } 5042 5043 /** 5044 * Bubble the click and show effect if .waves-effect elem was found 5045 */ 5046 function showEffect(e) { 5047 var element = getWavesEffectElement(e); 5048 5049 if (element !== null) { 5050 Effect.show(e, element); 5051 5052 if ('ontouchstart' in window) { 5053 element.addEventListener('touchend', Effect.hide, false); 5054 element.addEventListener('touchcancel', Effect.hide, false); 5055 } 5056 5057 element.addEventListener('mouseup', Effect.hide, false); 5058 element.addEventListener('mouseleave', Effect.hide, false); 5059 element.addEventListener('dragend', Effect.hide, false); 5060 } 5061 } 5062 5063 Waves.displayEffect = function (options) { 5064 options = options || {}; 5065 5066 if ('duration' in options) { 5067 Effect.duration = options.duration; 5068 } 5069 5070 //Wrap input inside <i> tag 5071 Effect.wrapInput($$('.waves-effect')); 5072 5073 if ('ontouchstart' in window) { 5074 document.body.addEventListener('touchstart', showEffect, false); 5075 } 5076 5077 document.body.addEventListener('mousedown', showEffect, false); 5078 }; 5079 5080 /** 5081 * Attach Waves to an input element (or any element which doesn't 5082 * bubble mouseup/mousedown events). 5083 * Intended to be used with dynamically loaded forms/inputs, or 5084 * where the user doesn't want a delegated click handler. 5085 */ 5086 Waves.attach = function (element) { 5087 //FUTURE: automatically add waves classes and allow users 5088 // to specify them with an options param? Eg. light/classic/button 5089 if (element.tagName.toLowerCase() === 'input') { 5090 Effect.wrapInput([element]); 5091 element = element.parentNode; 5092 } 5093 5094 if ('ontouchstart' in window) { 5095 element.addEventListener('touchstart', showEffect, false); 5096 } 5097 5098 element.addEventListener('mousedown', showEffect, false); 5099 }; 5100 5101 window.Waves = Waves; 5102 5103 document.addEventListener('DOMContentLoaded', function () { 5104 Waves.displayEffect(); 5105 }, false); 5106})(window); 5107;(function ($, anim) { 5108 'use strict'; 5109 5110 var _defaults = { 5111 html: '', 5112 displayLength: 4000, 5113 inDuration: 300, 5114 outDuration: 375, 5115 classes: '', 5116 completeCallback: null, 5117 activationPercent: 0.8 5118 }; 5119 5120 var Toast = function () { 5121 function Toast(options) { 5122 _classCallCheck(this, Toast); 5123 5124 /** 5125 * Options for the toast 5126 * @member Toast#options 5127 */ 5128 this.options = $.extend({}, Toast.defaults, options); 5129 this.message = this.options.html; 5130 5131 /** 5132 * Describes current pan state toast 5133 * @type {Boolean} 5134 */ 5135 this.panning = false; 5136 5137 /** 5138 * Time remaining until toast is removed 5139 */ 5140 this.timeRemaining = this.options.displayLength; 5141 5142 if (Toast._toasts.length === 0) { 5143 Toast._createContainer(); 5144 } 5145 5146 // Create new toast 5147 Toast._toasts.push(this); 5148 var toastElement = this._createToast(); 5149 toastElement.M_Toast = this; 5150 this.el = toastElement; 5151 this.$el = $(toastElement); 5152 this._animateIn(); 5153 this._setTimer(); 5154 } 5155 5156 _createClass(Toast, [{ 5157 key: "_createToast", 5158 5159 5160 /** 5161 * Create toast and append it to toast container 5162 */ 5163 value: function _createToast() { 5164 var toast = document.createElement('div'); 5165 toast.classList.add('toast'); 5166 5167 // Add custom classes onto toast 5168 if (!!this.options.classes.length) { 5169 $(toast).addClass(this.options.classes); 5170 } 5171 5172 // Set content 5173 if (typeof HTMLElement === 'object' ? this.message instanceof HTMLElement : this.message && typeof this.message === 'object' && this.message !== null && this.message.nodeType === 1 && typeof this.message.nodeName === 'string') { 5174 toast.appendChild(this.message); 5175 5176 // Check if it is jQuery object 5177 } else if (!!this.message.jquery) { 5178 $(toast).append(this.message[0]); 5179 5180 // Insert as html; 5181 } else { 5182 toast.innerHTML = this.message; 5183 } 5184 5185 // Append toasft 5186 Toast._container.appendChild(toast); 5187 return toast; 5188 } 5189 5190 /** 5191 * Animate in toast 5192 */ 5193 5194 }, { 5195 key: "_animateIn", 5196 value: function _animateIn() { 5197 // Animate toast in 5198 anim({ 5199 targets: this.el, 5200 top: 0, 5201 opacity: 1, 5202 duration: this.options.inDuration, 5203 easing: 'easeOutCubic' 5204 }); 5205 } 5206 5207 /** 5208 * Create setInterval which automatically removes toast when timeRemaining >= 0 5209 * has been reached 5210 */ 5211 5212 }, { 5213 key: "_setTimer", 5214 value: function _setTimer() { 5215 var _this29 = this; 5216 5217 if (this.timeRemaining !== Infinity) { 5218 this.counterInterval = setInterval(function () { 5219 // If toast is not being dragged, decrease its time remaining 5220 if (!_this29.panning) { 5221 _this29.timeRemaining -= 20; 5222 } 5223 5224 // Animate toast out 5225 if (_this29.timeRemaining <= 0) { 5226 _this29.dismiss(); 5227 } 5228 }, 20); 5229 } 5230 } 5231 5232 /** 5233 * Dismiss toast with animation 5234 */ 5235 5236 }, { 5237 key: "dismiss", 5238 value: function dismiss() { 5239 var _this30 = this; 5240 5241 window.clearInterval(this.counterInterval); 5242 var activationDistance = this.el.offsetWidth * this.options.activationPercent; 5243 5244 if (this.wasSwiped) { 5245 this.el.style.transition = 'transform .05s, opacity .05s'; 5246 this.el.style.transform = "translateX(" + activationDistance + "px)"; 5247 this.el.style.opacity = 0; 5248 } 5249 5250 anim({ 5251 targets: this.el, 5252 opacity: 0, 5253 marginTop: -40, 5254 duration: this.options.outDuration, 5255 easing: 'easeOutExpo', 5256 complete: function () { 5257 // Call the optional callback 5258 if (typeof _this30.options.completeCallback === 'function') { 5259 _this30.options.completeCallback(); 5260 } 5261 // Remove toast from DOM 5262 _this30.$el.remove(); 5263 Toast._toasts.splice(Toast._toasts.indexOf(_this30), 1); 5264 if (Toast._toasts.length === 0) { 5265 Toast._removeContainer(); 5266 } 5267 } 5268 }); 5269 } 5270 }], [{ 5271 key: "getInstance", 5272 5273 5274 /** 5275 * Get Instance 5276 */ 5277 value: function getInstance(el) { 5278 var domElem = !!el.jquery ? el[0] : el; 5279 return domElem.M_Toast; 5280 } 5281 5282 /** 5283 * Append toast container and add event handlers 5284 */ 5285 5286 }, { 5287 key: "_createContainer", 5288 value: function _createContainer() { 5289 var container = document.createElement('div'); 5290 container.setAttribute('id', 'toast-container'); 5291 5292 // Add event handler 5293 container.addEventListener('touchstart', Toast._onDragStart); 5294 container.addEventListener('touchmove', Toast._onDragMove); 5295 container.addEventListener('touchend', Toast._onDragEnd); 5296 5297 container.addEventListener('mousedown', Toast._onDragStart); 5298 document.addEventListener('mousemove', Toast._onDragMove); 5299 document.addEventListener('mouseup', Toast._onDragEnd); 5300 5301 document.body.appendChild(container); 5302 Toast._container = container; 5303 } 5304 5305 /** 5306 * Remove toast container and event handlers 5307 */ 5308 5309 }, { 5310 key: "_removeContainer", 5311 value: function _removeContainer() { 5312 // Add event handler 5313 document.removeEventListener('mousemove', Toast._onDragMove); 5314 document.removeEventListener('mouseup', Toast._onDragEnd); 5315 5316 $(Toast._container).remove(); 5317 Toast._container = null; 5318 } 5319 5320 /** 5321 * Begin drag handler 5322 * @param {Event} e 5323 */ 5324 5325 }, { 5326 key: "_onDragStart", 5327 value: function _onDragStart(e) { 5328 if (e.target && $(e.target).closest('.toast').length) { 5329 var $toast = $(e.target).closest('.toast'); 5330 var toast = $toast[0].M_Toast; 5331 toast.panning = true; 5332 Toast._draggedToast = toast; 5333 toast.el.classList.add('panning'); 5334 toast.el.style.transition = ''; 5335 toast.startingXPos = Toast._xPos(e); 5336 toast.time = Date.now(); 5337 toast.xPos = Toast._xPos(e); 5338 } 5339 } 5340 5341 /** 5342 * Drag move handler 5343 * @param {Event} e 5344 */ 5345 5346 }, { 5347 key: "_onDragMove", 5348 value: function _onDragMove(e) { 5349 if (!!Toast._draggedToast) { 5350 e.preventDefault(); 5351 var toast = Toast._draggedToast; 5352 toast.deltaX = Math.abs(toast.xPos - Toast._xPos(e)); 5353 toast.xPos = Toast._xPos(e); 5354 toast.velocityX = toast.deltaX / (Date.now() - toast.time); 5355 toast.time = Date.now(); 5356 5357 var totalDeltaX = toast.xPos - toast.startingXPos; 5358 var activationDistance = toast.el.offsetWidth * toast.options.activationPercent; 5359 toast.el.style.transform = "translateX(" + totalDeltaX + "px)"; 5360 toast.el.style.opacity = 1 - Math.abs(totalDeltaX / activationDistance); 5361 } 5362 } 5363 5364 /** 5365 * End drag handler 5366 */ 5367 5368 }, { 5369 key: "_onDragEnd", 5370 value: function _onDragEnd() { 5371 if (!!Toast._draggedToast) { 5372 var toast = Toast._draggedToast; 5373 toast.panning = false; 5374 toast.el.classList.remove('panning'); 5375 5376 var totalDeltaX = toast.xPos - toast.startingXPos; 5377 var activationDistance = toast.el.offsetWidth * toast.options.activationPercent; 5378 var shouldBeDismissed = Math.abs(totalDeltaX) > activationDistance || toast.velocityX > 1; 5379 5380 // Remove toast 5381 if (shouldBeDismissed) { 5382 toast.wasSwiped = true; 5383 toast.dismiss(); 5384 5385 // Animate toast back to original position 5386 } else { 5387 toast.el.style.transition = 'transform .2s, opacity .2s'; 5388 toast.el.style.transform = ''; 5389 toast.el.style.opacity = ''; 5390 } 5391 Toast._draggedToast = null; 5392 } 5393 } 5394 5395 /** 5396 * Get x position of mouse or touch event 5397 * @param {Event} e 5398 */ 5399 5400 }, { 5401 key: "_xPos", 5402 value: function _xPos(e) { 5403 if (e.targetTouches && e.targetTouches.length >= 1) { 5404 return e.targetTouches[0].clientX; 5405 } 5406 // mouse event 5407 return e.clientX; 5408 } 5409 5410 /** 5411 * Remove all toasts 5412 */ 5413 5414 }, { 5415 key: "dismissAll", 5416 value: function dismissAll() { 5417 for (var toastIndex in Toast._toasts) { 5418 Toast._toasts[toastIndex].dismiss(); 5419 } 5420 } 5421 }, { 5422 key: "defaults", 5423 get: function () { 5424 return _defaults; 5425 } 5426 }]); 5427 5428 return Toast; 5429 }(); 5430 5431 /** 5432 * @static 5433 * @memberof Toast 5434 * @type {Array.<Toast>} 5435 */ 5436 5437 5438 Toast._toasts = []; 5439 5440 /** 5441 * @static 5442 * @memberof Toast 5443 */ 5444 Toast._container = null; 5445 5446 /** 5447 * @static 5448 * @memberof Toast 5449 * @type {Toast} 5450 */ 5451 Toast._draggedToast = null; 5452 5453 M.Toast = Toast; 5454 M.toast = function (options) { 5455 return new Toast(options); 5456 }; 5457})(cash, M.anime); 5458;(function ($, anim) { 5459 'use strict'; 5460 5461 var _defaults = { 5462 edge: 'left', 5463 draggable:
5463fals
vendor: 51,168 bytes, lines 5463-7164
5463e, 5464 inDuration: 250, 5465 outDuration: 200, 5466 onOpenStart: null, 5467 onOpenEnd: null, 5468 onCloseStart: null, 5469 onCloseEnd: null, 5470 preventScrolling: true 5471 }; 5472 5473 /** 5474 * @class 5475 */ 5476 5477 var Sidenav = function (_Component8) { 5478 _inherits(Sidenav, _Component8); 5479 5480 /** 5481 * Construct Sidenav instance and set up overlay 5482 * @constructor 5483 * @param {Element} el 5484 * @param {Object} options 5485 */ 5486 function Sidenav(el, options) { 5487 _classCallCheck(this, Sidenav); 5488 5489 var _this31 = _possibleConstructorReturn(this, (Sidenav.__proto__ || Object.getPrototypeOf(Sidenav)).call(this, Sidenav, el, options)); 5490 5491 _this31.el.M_Sidenav = _this31; 5492 _this31.id = _this31.$el.attr('id'); 5493 5494 /** 5495 * Options for the Sidenav 5496 * @member Sidenav#options 5497 * @prop {String} [edge='left'] - Side of screen on which Sidenav appears 5498 * @prop {Boolean} [draggable=true] - Allow swipe gestures to open/close Sidenav 5499 * @prop {Number} [inDuration=250] - Length in ms of enter transition 5500 * @prop {Number} [outDuration=200] - Length in ms of exit transition 5501 * @prop {Function} onOpenStart - Function called when sidenav starts entering 5502 * @prop {Function} onOpenEnd - Function called when sidenav finishes entering 5503 * @prop {Function} onCloseStart - Function called when sidenav starts exiting 5504 * @prop {Function} onCloseEnd - Function called when sidenav finishes exiting 5505 */ 5506 _this31.options = $.extend({}, Sidenav.defaults, options); 5507 5508 /** 5509 * Describes open/close state of Sidenav 5510 * @type {Boolean} 5511 */ 5512 _this31.isOpen = false; 5513 5514 /** 5515 * Describes if Sidenav is fixed 5516 * @type {Boolean} 5517 */ 5518 _this31.isFixed = _this31.el.classList.contains('sidenav-fixed'); 5519 5520 /** 5521 * Describes if Sidenav is being draggeed 5522 * @type {Boolean} 5523 */ 5524 _this31.isDragged = false; 5525 5526 // Window size variables for window resize checks 5527 _this31.lastWindowWidth = window.innerWidth; 5528 _this31.lastWindowHeight = window.innerHeight; 5529 5530 _this31._createOverlay(); 5531 _this31._createDragTarget(); 5532 _this31._setupEventHandlers(); 5533 _this31._setupClasses(); 5534 _this31._setupFixed(); 5535 5536 Sidenav._sidenavs.push(_this31); 5537 return _this31; 5538 } 5539 5540 _createClass(Sidenav, [{ 5541 key: "destroy", 5542 5543 5544 /** 5545 * Teardown component 5546 */ 5547 value: function destroy() { 5548 this._removeEventHandlers(); 5549 this._enableBodyScrolling(); 5550 this._overlay.parentNode.removeChild(this._overlay); 5551 this.dragTarget.parentNode.removeChild(this.dragTarget); 5552 this.el.M_Sidenav = undefined; 5553 this.el.style.transform = ''; 5554 5555 var index = Sidenav._sidenavs.indexOf(this); 5556 if (index >= 0) { 5557 Sidenav._sidenavs.splice(index, 1); 5558 } 5559 } 5560 }, { 5561 key: "_createOverlay", 5562 value: function _createOverlay() { 5563 var overlay = document.createElement('div'); 5564 this._closeBound = this.close.bind(this); 5565 overlay.classList.add('sidenav-overlay'); 5566 5567 overlay.addEventListener('click', this._closeBound); 5568 5569 document.body.appendChild(overlay); 5570 this._overlay = overlay; 5571 } 5572 }, { 5573 key: "_setupEventHandlers", 5574 value: function _setupEventHandlers() { 5575 if (Sidenav._sidenavs.length === 0) { 5576 document.body.addEventListener('click', this._handleTriggerClick); 5577 } 5578 5579 this._handleDragTargetDragBound = this._handleDragTargetDrag.bind(this); 5580 this._handleDragTargetReleaseBound = this._handleDragTargetRelease.bind(this); 5581 this._handleCloseDragBound = this._handleCloseDrag.bind(this); 5582 this._handleCloseReleaseBound = this._handleCloseRelease.bind(this); 5583 this._handleCloseTriggerClickBound = this._handleCloseTriggerClick.bind(this); 5584 5585 this.dragTarget.addEventListener('touchmove', this._handleDragTargetDragBound); 5586 this.dragTarget.addEventListener('touchend', this._handleDragTargetReleaseBound); 5587 this._overlay.addEventListener('touchmove', this._handleCloseDragBound); 5588 this._overlay.addEventListener('touchend', this._handleCloseReleaseBound); 5589 this.el.addEventListener('touchmove', this._handleCloseDragBound); 5590 this.el.addEventListener('touchend', this._handleCloseReleaseBound); 5591 this.el.addEventListener('click', this._handleCloseTriggerClickBound); 5592 5593 // Add resize for side nav fixed 5594 if (this.isFixed) { 5595 this._handleWindowResizeBound = this._handleWindowResize.bind(this); 5596 window.addEventListener('resize', this._handleWindowResizeBound); 5597 } 5598 } 5599 }, { 5600 key: "_removeEventHandlers", 5601 value: function _removeEventHandlers() { 5602 if (Sidenav._sidenavs.length === 1) { 5603 document.body.removeEventListener('click', this._handleTriggerClick); 5604 } 5605 5606 this.dragTarget.removeEventListener('touchmove', this._handleDragTargetDragBound); 5607 this.dragTarget.removeEventListener('touchend', this._handleDragTargetReleaseBound); 5608 this._overlay.removeEventListener('touchmove', this._handleCloseDragBound); 5609 this._overlay.removeEventListener('touchend', this._handleCloseReleaseBound); 5610 this.el.removeEventListener('touchmove', this._handleCloseDragBound); 5611 this.el.removeEventListener('touchend', this._handleCloseReleaseBound); 5612 this.el.removeEventListener('click', this._handleCloseTriggerClickBound); 5613 5614 // Remove resize for side nav fixed 5615 if (this.isFixed) { 5616 window.removeEventListener('resize', this._handleWindowResizeBound); 5617 } 5618 } 5619 5620 /** 5621 * Handle Trigger Click 5622 * @param {Event} e 5623 */ 5624 5625 }, { 5626 key: "_handleTriggerClick", 5627 value: function _handleTriggerClick(e) { 5628 var $trigger = $(e.target).closest('.sidenav-trigger'); 5629 if (e.target && $trigger.length) { 5630 var sidenavId = M.getIdFromTrigger($trigger[0]); 5631 5632 var sidenavInstance = document.getElementById(sidenavId).M_Sidenav; 5633 if (sidenavInstance) { 5634 sidenavInstance.open($trigger); 5635 } 5636 e.preventDefault(); 5637 } 5638 } 5639 5640 /** 5641 * Set variables needed at the beggining of drag 5642 * and stop any current transition. 5643 * @param {Event} e 5644 */ 5645 5646 }, { 5647 key: "_startDrag", 5648 value: function _startDrag(e) { 5649 var clientX = e.targetTouches[0].clientX; 5650 this.isDragged = true; 5651 this._startingXpos = clientX; 5652 this._xPos = this._startingXpos; 5653 this._time = Date.now(); 5654 this._width = this.el.getBoundingClientRect().width; 5655 this._overlay.style.display = 'block'; 5656 this._initialScrollTop = this.isOpen ? this.el.scrollTop : M.getDocumentScrollTop(); 5657 this._verticallyScrolling = false; 5658 anim.remove(this.el); 5659 anim.remove(this._overlay); 5660 } 5661 5662 /** 5663 * Set variables needed at each drag move update tick 5664 * @param {Event} e 5665 */ 5666 5667 }, { 5668 key: "_dragMoveUpdate", 5669 value: function _dragMoveUpdate(e) { 5670 var clientX = e.targetTouches[0].clientX; 5671 var currentScrollTop = this.isOpen ? this.el.scrollTop : M.getDocumentScrollTop(); 5672 this.deltaX = Math.abs(this._xPos - clientX); 5673 this._xPos = clientX; 5674 this.velocityX = this.deltaX / (Date.now() - this._time); 5675 this._time = Date.now(); 5676 if (this._initialScrollTop !== currentScrollTop) { 5677 this._verticallyScrolling = true; 5678 } 5679 } 5680 5681 /** 5682 * Handles Dragging of Sidenav 5683 * @param {Event} e 5684 */ 5685 5686 }, { 5687 key: "_handleDragTargetDrag", 5688 value: function _handleDragTargetDrag(e) { 5689 // Check if draggable 5690 if (!this.options.draggable || this._isCurrentlyFixed() || this._verticallyScrolling) { 5691 return; 5692 } 5693 5694 // If not being dragged, set initial drag start variables 5695 if (!this.isDragged) { 5696 this._startDrag(e); 5697 } 5698 5699 // Run touchmove updates 5700 this._dragMoveUpdate(e); 5701 5702 // Calculate raw deltaX 5703 var totalDeltaX = this._xPos - this._startingXpos; 5704 5705 // dragDirection is the attempted user drag direction 5706 var dragDirection = totalDeltaX > 0 ? 'right' : 'left'; 5707 5708 // Don't allow totalDeltaX to exceed Sidenav width or be dragged in the opposite direction 5709 totalDeltaX = Math.min(this._width, Math.abs(totalDeltaX)); 5710 if (this.options.edge === dragDirection) { 5711 totalDeltaX = 0; 5712 } 5713 5714 /** 5715 * transformX is the drag displacement 5716 * transformPrefix is the initial transform placement 5717 * Invert values if Sidenav is right edge 5718 */ 5719 var transformX = totalDeltaX; 5720 var transformPrefix = 'translateX(-100%)'; 5721 if (this.options.edge === 'right') { 5722 transformPrefix = 'translateX(100%)'; 5723 transformX = -transformX; 5724 } 5725 5726 // Calculate open/close percentage of sidenav, with open = 1 and close = 0 5727 this.percentOpen = Math.min(1, totalDeltaX / this._width); 5728 5729 // Set transform and opacity styles 5730 this.el.style.transform = transformPrefix + " translateX(" + transformX + "px)"; 5731 this._overlay.style.opacity = this.percentOpen; 5732 } 5733 5734 /** 5735 * Handle Drag Target Release 5736 */ 5737 5738 }, { 5739 key: "_handleDragTargetRelease", 5740 value: function _handleDragTargetRelease() { 5741 if (this.isDragged) { 5742 if (this.percentOpen > 0.2) { 5743 this.open(); 5744 } else { 5745 this._animateOut(); 5746 } 5747 5748 this.isDragged = false; 5749 this._verticallyScrolling = false; 5750 } 5751 } 5752 5753 /** 5754 * Handle Close Drag 5755 * @param {Event} e 5756 */ 5757 5758 }, { 5759 key: "_handleCloseDrag", 5760 value: function _handleCloseDrag(e) { 5761 if (this.isOpen) { 5762 // Check if draggable 5763 if (!this.options.draggable || this._isCurrentlyFixed() || this._verticallyScrolling) { 5764 return; 5765 } 5766 5767 // If not being dragged, set initial drag start variables 5768 if (!this.isDragged) { 5769 this._startDrag(e); 5770 } 5771 5772 // Run touchmove updates 5773 this._dragMoveUpdate(e); 5774 5775 // Calculate raw deltaX 5776 var totalDeltaX = this._xPos - this._startingXpos; 5777 5778 // dragDirection is the attempted user drag direction 5779 var dragDirection = totalDeltaX > 0 ? 'right' : 'left'; 5780 5781 // Don't allow totalDeltaX to exceed Sidenav width or be dragged in the opposite direction 5782 totalDeltaX = Math.min(this._width, Math.abs(totalDeltaX)); 5783 if (this.options.edge !== dragDirection) { 5784 totalDeltaX = 0; 5785 } 5786 5787 var transformX = -totalDeltaX; 5788 if (this.options.edge === 'right') { 5789 transformX = -transformX; 5790 } 5791 5792 // Calculate open/close percentage of sidenav, with open = 1 and close = 0 5793 this.percentOpen = Math.min(1, 1 - totalDeltaX / this._width); 5794 5795 // Set transform and opacity styles 5796 this.el.style.transform = "translateX(" + transformX + "px)"; 5797 this._overlay.style.opacity = this.percentOpen; 5798 } 5799 } 5800 5801 /** 5802 * Handle Close Release 5803 */ 5804 5805 }, { 5806 key: "_handleCloseRelease", 5807 value: function _handleCloseRelease() { 5808 if (this.isOpen && this.isDragged) { 5809 if (this.percentOpen > 0.8) { 5810 this._animateIn(); 5811 } else { 5812 this.close(); 5813 } 5814 5815 this.isDragged = false; 5816 this._verticallyScrolling = false; 5817 } 5818 } 5819 5820 /** 5821 * Handles closing of Sidenav when element with class .sidenav-close 5822 */ 5823 5824 }, { 5825 key: "_handleCloseTriggerClick", 5826 value: function _handleCloseTriggerClick(e) { 5827 var $closeTrigger = $(e.target).closest('.sidenav-close'); 5828 if ($closeTrigger.length && !this._isCurrentlyFixed()) { 5829 this.close(); 5830 } 5831 } 5832 5833 /** 5834 * Handle Window Resize 5835 */ 5836 5837 }, { 5838 key: "_handleWindowResize", 5839 value: function _handleWindowResize() { 5840 // Only handle horizontal resizes 5841 if (this.lastWindowWidth !== window.innerWidth) { 5842 if (window.innerWidth > 992) { 5843 this.open(); 5844 } else { 5845 this.close(); 5846 } 5847 } 5848 5849 this.lastWindowWidth = window.innerWidth; 5850 this.lastWindowHeight = window.innerHeight; 5851 } 5852 }, { 5853 key: "_setupClasses", 5854 value: function _setupClasses() { 5855 if (this.options.edge === 'right') { 5856 this.el.classList.add('right-aligned'); 5857 this.dragTarget.classList.add('right-aligned'); 5858 } 5859 } 5860 }, { 5861 key: "_removeClasses", 5862 value: function _removeClasses() { 5863 this.el.classList.remove('right-aligned'); 5864 this.dragTarget.classList.remove('right-aligned'); 5865 } 5866 }, { 5867 key: "_setupFixed", 5868 value: function _setupFixed() { 5869 if (this._isCurrentlyFixed()) { 5870 this.open(); 5871 } 5872 } 5873 }, { 5874 key: "_isCurrentlyFixed", 5875 value: function _isCurrentlyFixed() { 5876 return this.isFixed && window.innerWidth > 992; 5877 } 5878 }, { 5879 key: "_createDragTarget", 5880 value: function _createDragTarget() { 5881 var dragTarget = document.createElement('div'); 5882 dragTarget.classList.add('drag-target'); 5883 document.body.appendChild(dragTarget); 5884 this.dragTarget = dragTarget; 5885 } 5886 }, { 5887 key: "_preventBodyScrolling", 5888 value: function _preventBodyScrolling() { 5889 var body = document.body; 5890 body.style.overflow = 'hidden'; 5891 } 5892 }, { 5893 key: "_enableBodyScrolling", 5894 value: function _enableBodyScrolling() { 5895 var body = document.body; 5896 body.style.overflow = ''; 5897 } 5898 }, { 5899 key: "open", 5900 value: function open() { 5901 if (this.isOpen === true) { 5902 return; 5903 } 5904 5905 this.isOpen = true; 5906 5907 // Run onOpenStart callback 5908 if (typeof this.options.onOpenStart === 'function') { 5909 this.options.onOpenStart.call(this, this.el); 5910 } 5911 5912 // Handle fixed Sidenav 5913 if (this._isCurrentlyFixed()) { 5914 anim.remove(this.el); 5915 anim({ 5916 targets: this.el, 5917 translateX: 0, 5918 duration: 0, 5919 easing: 'easeOutQuad' 5920 }); 5921 this._enableBodyScrolling(); 5922 this._overlay.style.display = 'none'; 5923 5924 // Handle non-fixed Sidenav 5925 } else { 5926 if (this.options.preventScrolling) { 5927 this._preventBodyScrolling(); 5928 } 5929 5930 if (!this.isDragged || this.percentOpen != 1) { 5931 this._animateIn(); 5932 } 5933 } 5934 } 5935 }, { 5936 key: "close", 5937 value: function close() { 5938 if (this.isOpen === false) { 5939 return; 5940 } 5941 5942 this.isOpen = false; 5943 5944 // Run onCloseStart callback 5945 if (typeof this.options.onCloseStart === 'function') { 5946 this.options.onCloseStart.call(this, this.el); 5947 } 5948 5949 // Handle fixed Sidenav 5950 if (this._isCurrentlyFixed()) { 5951 var transformX = this.options.edge === 'left' ? '-105%' : '105%'; 5952 this.el.style.transform = "translateX(" + transformX + ")"; 5953 5954 // Handle non-fixed Sidenav 5955 } else { 5956 this._enableBodyScrolling(); 5957 5958 if (!this.isDragged || this.percentOpen != 0) { 5959 this._animateOut(); 5960 } else { 5961 this._overlay.style.display = 'none'; 5962 } 5963 } 5964 } 5965 }, { 5966 key: "_animateIn", 5967 value: function _animateIn() { 5968 this._animateSidenavIn(); 5969 this._animateOverlayIn(); 5970 } 5971 }, { 5972 key: "_animateSidenavIn", 5973 value: function _animateSidenavIn() { 5974 var _this32 = this; 5975 5976 var slideOutPercent = this.options.edge === 'left' ? -1 : 1; 5977 if (this.isDragged) { 5978 slideOutPercent = this.options.edge === 'left' ? slideOutPercent + this.percentOpen : slideOutPercent - this.percentOpen; 5979 } 5980 5981 anim.remove(this.el); 5982 anim({ 5983 targets: this.el, 5984 translateX: [slideOutPercent * 100 + "%", 0], 5985 duration: this.options.inDuration, 5986 easing: 'easeOutQuad', 5987 complete: function () { 5988 // Run onOpenEnd callback 5989 if (typeof _this32.options.onOpenEnd === 'function') { 5990 _this32.options.onOpenEnd.call(_this32, _this32.el); 5991 } 5992 } 5993 }); 5994 } 5995 }, { 5996 key: "_animateOverlayIn", 5997 value: function _animateOverlayIn() { 5998 var start = 0; 5999 if (this.isDragged) { 6000 start = this.percentOpen; 6001 } else { 6002 $(this._overlay).css({ 6003 display: 'block' 6004 }); 6005 } 6006 6007 anim.remove(this._overlay); 6008 anim({ 6009 targets: this._overlay, 6010 opacity: [start, 1], 6011 duration: this.options.inDuration, 6012 easing: 'easeOutQuad' 6013 }); 6014 } 6015 }, { 6016 key: "_animateOut", 6017 value: function _animateOut() { 6018 this._animateSidenavOut(); 6019 this._animateOverlayOut(); 6020 } 6021 }, { 6022 key: "_animateSidenavOut", 6023 value: function _animateSidenavOut() { 6024 var _this33 = this; 6025 6026 var endPercent = this.options.edge === 'left' ? -1 : 1; 6027 var slideOutPercent = 0; 6028 if (this.isDragged) { 6029 slideOutPercent = this.options.edge === 'left' ? endPercent + this.percentOpen : endPercent - this.percentOpen; 6030 } 6031 6032 anim.remove(this.el); 6033 anim({ 6034 targets: this.el, 6035 translateX: [slideOutPercent * 100 + "%", endPercent * 105 + "%"], 6036 duration: this.options.outDuration, 6037 easing: 'easeOutQuad', 6038 complete: function () { 6039 // Run onOpenEnd callback 6040 if (typeof _this33.options.onCloseEnd === 'function') { 6041 _this33.options.onCloseEnd.call(_this33, _this33.el); 6042 } 6043 } 6044 }); 6045 } 6046 }, { 6047 key: "_animateOverlayOut", 6048 value: function _animateOverlayOut() { 6049 var _this34 = this; 6050 6051 anim.remove(this._overlay); 6052 anim({ 6053 targets: this._overlay, 6054 opacity: 0, 6055 duration: this.options.outDuration, 6056 easing: 'easeOutQuad', 6057 complete: function () { 6058 $(_this34._overlay).css('display', 'none'); 6059 } 6060 }); 6061 } 6062 }], [{ 6063 key: "init", 6064 value: function init(els, options) { 6065 return _get(Sidenav.__proto__ || Object.getPrototypeOf(Sidenav), "init", this).call(this, this, els, options); 6066 } 6067 6068 /** 6069 * Get Instance 6070 */ 6071 6072 }, { 6073 key: "getInstance", 6074 value: function getInstance(el) { 6075 var domElem = !!el.jquery ? el[0] : el; 6076 return domElem.M_Sidenav; 6077 } 6078 }, { 6079 key: "defaults", 6080 get: function () { 6081 return _defaults; 6082 } 6083 }]); 6084 6085 return Sidenav; 6086 }(Component); 6087 6088 /** 6089 * @static 6090 * @memberof Sidenav 6091 * @type {Array.<Sidenav>} 6092 */ 6093 6094 6095 Sidenav._sidenavs = []; 6096 6097 M.Sidenav = Sidenav; 6098 6099 if (M.jQueryLoaded) { 6100 M.initializeJqueryWrapper(Sidenav, 'sidenav', 'M_Sidenav'); 6101 } 6102})(cash, M.anime); 6103;(function ($, anim) { 6104 'use strict'; 6105 6106 var _defaults = { 6107 throttle: 100, 6108 scrollOffset: 200, // offset - 200 allows elements near bottom of page to scroll 6109 activeClass: 'active', 6110 getActiveElement: function (id) { 6111 return 'a[href="#' + id + '"]'; 6112 } 6113 }; 6114 6115 /** 6116 * @class 6117 * 6118 */ 6119 6120 var ScrollSpy = function (_Component9) { 6121 _inherits(ScrollSpy, _Component9); 6122 6123 /** 6124 * Construct ScrollSpy instance 6125 * @constructor 6126 * @param {Element} el 6127 * @param {Object} options 6128 */ 6129 function ScrollSpy(el, options) { 6130 _classCallCheck(this, ScrollSpy); 6131 6132 var _this35 = _possibleConstructorReturn(this, (ScrollSpy.__proto__ || Object.getPrototypeOf(ScrollSpy)).call(this, ScrollSpy, el, options)); 6133 6134 _this35.el.M_ScrollSpy = _this35; 6135 6136 /** 6137 * Options for the modal 6138 * @member Modal#options 6139 * @prop {Number} [throttle=100] - Throttle of scroll handler 6140 * @prop {Number} [scrollOffset=200] - Offset for centering element when scrolled to 6141 * @prop {String} [activeClass='active'] - Class applied to active elements 6142 * @prop {Function} [getActiveElement] - Used to find active element 6143 */ 6144 _this35.options = $.extend({}, ScrollSpy.defaults, options); 6145 6146 // setup 6147 ScrollSpy._elements.push(_this35); 6148 ScrollSpy._count++; 6149 ScrollSpy._increment++; 6150 _this35.tickId = -1; 6151 _this35.id = ScrollSpy._increment; 6152 _this35._setupEventHandlers(); 6153 _this35._handleWindowScroll(); 6154 return _this35; 6155 } 6156 6157 _createClass(ScrollSpy, [{ 6158 key: "destroy", 6159 6160 6161 /** 6162 * Teardown component 6163 */ 6164 value: function destroy() { 6165 ScrollSpy._elements.splice(ScrollSpy._elements.indexOf(this), 1); 6166 ScrollSpy._elementsInView.splice(ScrollSpy._elementsInView.indexOf(this), 1); 6167 ScrollSpy._visibleElements.splice(ScrollSpy._visibleElements.indexOf(this.$el), 1); 6168 ScrollSpy._count--; 6169 this._removeEventHandlers(); 6170 $(this.options.getActiveElement(this.$el.attr('id'))).removeClass(this.options.activeClass); 6171 this.el.M_ScrollSpy = undefined; 6172 } 6173 6174 /** 6175 * Setup Event Handlers 6176 */ 6177 6178 }, { 6179 key: "_setupEventHandlers", 6180 value: function _setupEventHandlers() { 6181 var throttledResize = M.throttle(this._handleWindowScroll, 200); 6182 this._handleThrottledResizeBound = throttledResize.bind(this); 6183 this._handleWindowScrollBound = this._handleWindowScroll.bind(this); 6184 if (ScrollSpy._count === 1) { 6185 window.addEventListener('scroll', this._handleWindowScrollBound); 6186 window.addEventListener('resize', this._handleThrottledResizeBound); 6187 document.body.addEventListener('click', this._handleTriggerClick); 6188 } 6189 } 6190 6191 /** 6192 * Remove Event Handlers 6193 */ 6194 6195 }, { 6196 key: "_removeEventHandlers", 6197 value: function _removeEventHandlers() { 6198 if (ScrollSpy._count === 0) { 6199 window.removeEventListener('scroll', this._handleWindowScrollBound); 6200 window.removeEventListener('resize', this._handleThrottledResizeBound); 6201 document.body.removeEventListener('click', this._handleTriggerClick); 6202 } 6203 } 6204 6205 /** 6206 * Handle Trigger Click 6207 * @param {Event} e 6208 */ 6209 6210 }, { 6211 key: "_handleTriggerClick", 6212 value: function _handleTriggerClick(e) { 6213 var $trigger = $(e.target); 6214 for (var i = ScrollSpy._elements.length - 1; i >= 0; i--) { 6215 var scrollspy = ScrollSpy._elements[i]; 6216 if ($trigger.is('a[href="#' + scrollspy.$el.attr('id') + '"]')) { 6217 e.preventDefault(); 6218 var offset = scrollspy.$el.offset().top + 1; 6219 6220 anim({ 6221 targets: [document.documentElement, document.body], 6222 scrollTop: offset - scrollspy.options.scrollOffset, 6223 duration: 400, 6224 easing: 'easeOutCubic' 6225 }); 6226 break; 6227 } 6228 } 6229 } 6230 6231 /** 6232 * Handle Window Scroll 6233 */ 6234 6235 }, { 6236 key: "_handleWindowScroll", 6237 value: function _handleWindowScroll() { 6238 // unique tick id 6239 ScrollSpy._ticks++; 6240 6241 // viewport rectangle 6242 var top = M.getDocumentScrollTop(), 6243 left = M.getDocumentScrollLeft(), 6244 right = left + window.innerWidth, 6245 bottom = top + window.innerHeight; 6246 6247 // determine which elements are in view 6248 var intersections = ScrollSpy._findElements(top, right, bottom, left); 6249 for (var i = 0; i < intersections.length; i++) { 6250 var scrollspy = intersections[i]; 6251 var lastTick = scrollspy.tickId; 6252 if (lastTick < 0) { 6253 // entered into view 6254 scrollspy._enter(); 6255 } 6256 6257 // update tick id 6258 scrollspy.tickId = ScrollSpy._ticks; 6259 } 6260 6261 for (var _i = 0; _i < ScrollSpy._elementsInView.length; _i++) { 6262 var _scrollspy = ScrollSpy._elementsInView[_i]; 6263 var _lastTick = _scrollspy.tickId; 6264 if (_lastTick >= 0 && _lastTick !== ScrollSpy._ticks) { 6265 // exited from view 6266 _scrollspy._exit(); 6267 _scrollspy.tickId = -1; 6268 } 6269 } 6270 6271 // remember elements in view for next tick 6272 ScrollSpy._elementsInView = intersections; 6273 } 6274 6275 /** 6276 * Find elements that are within the boundary 6277 * @param {number} top 6278 * @param {number} right 6279 * @param {number} bottom 6280 * @param {number} left 6281 * @return {Array.<ScrollSpy>} A collection of elements 6282 */ 6283 6284 }, { 6285 key: "_enter", 6286 value: function _enter() { 6287 ScrollSpy._visibleElements = ScrollSpy._visibleElements.filter(function (value) { 6288 return value.height() != 0; 6289 }); 6290 6291 if (ScrollSpy._visibleElements[0]) { 6292 $(this.options.getActiveElement(ScrollSpy._visibleElements[0].attr('id'))).removeClass(this.options.activeClass); 6293 if (ScrollSpy._visibleElements[0][0].M_ScrollSpy && this.id < ScrollSpy._visibleElements[0][0].M_ScrollSpy.id) { 6294 ScrollSpy._visibleElements.unshift(this.$el); 6295 } else { 6296 ScrollSpy._visibleElements.push(this.$el); 6297 } 6298 } else { 6299 ScrollSpy._visibleElements.push(this.$el); 6300 } 6301 6302 $(this.options.getActiveElement(ScrollSpy._visibleElements[0].attr('id'))).addClass(this.options.activeClass); 6303 } 6304 }, { 6305 key: "_exit", 6306 value: function _exit() { 6307 var _this36 = this; 6308 6309 ScrollSpy._visibleElements = ScrollSpy._visibleElements.filter(function (value) { 6310 return value.height() != 0; 6311 }); 6312 6313 if (ScrollSpy._visibleElements[0]) { 6314 $(this.options.getActiveElement(ScrollSpy._visibleElements[0].attr('id'))).removeClass(this.options.activeClass); 6315 6316 ScrollSpy._visibleElements = ScrollSpy._visibleElements.filter(function (el) { 6317 return el.attr('id') != _this36.$el.attr('id'); 6318 }); 6319 if (ScrollSpy._visibleElements[0]) { 6320 // Check if empty 6321 $(this.options.getActiveElement(ScrollSpy._visibleElements[0].attr('id'))).addClass(this.options.activeClass); 6322 } 6323 } 6324 } 6325 }], [{ 6326 key: "init", 6327 value: function init(els, options) { 6328 return _get(ScrollSpy.__proto__ || Object.getPrototypeOf(ScrollSpy), "init", this).call(this, this, els, options); 6329 } 6330 6331 /** 6332 * Get Instance 6333 */ 6334 6335 }, { 6336 key: "getInstance", 6337 value: function getInstance(el) { 6338 var domElem = !!el.jquery ? el[0] : el; 6339 return domElem.M_ScrollSpy; 6340 } 6341 }, { 6342 key: "_findElements", 6343 value: function _findElements(top, right, bottom, left) { 6344 var hits = []; 6345 for (var i = 0; i < ScrollSpy._elements.length; i++) { 6346 var scrollspy = ScrollSpy._elements[i]; 6347 var currTop = top + scrollspy.options.scrollOffset || 200; 6348 6349 if (scrollspy.$el.height() > 0) { 6350 var elTop = scrollspy.$el.offset().top, 6351 elLeft = scrollspy.$el.offset().left, 6352 elRight = elLeft + scrollspy.$el.width(), 6353 elBottom = elTop + scrollspy.$el.height(); 6354 6355 var isIntersect = !(elLeft > right || elRight < left || elTop > bottom || elBottom < currTop); 6356 6357 if (isIntersect) { 6358 hits.push(scrollspy); 6359 } 6360 } 6361 } 6362 return hits; 6363 } 6364 }, { 6365 key: "defaults", 6366 get: function () { 6367 return _defaults; 6368 } 6369 }]); 6370 6371 return ScrollSpy; 6372 }(Component); 6373 6374 /** 6375 * @static 6376 * @memberof ScrollSpy 6377 * @type {Array.<ScrollSpy>} 6378 */ 6379 6380 6381 ScrollSpy._elements = []; 6382 6383 /** 6384 * @static 6385 * @memberof ScrollSpy 6386 * @type {Array.<ScrollSpy>} 6387 */ 6388 ScrollSpy._elementsInView = []; 6389 6390 /** 6391 * @static 6392 * @memberof ScrollSpy 6393 * @type {Array.<cash>} 6394 */ 6395 ScrollSpy._visibleElements = []; 6396 6397 /** 6398 * @static 6399 * @memberof ScrollSpy 6400 */ 6401 ScrollSpy._count = 0; 6402 6403 /** 6404 * @static 6405 * @memberof ScrollSpy 6406 */ 6407 ScrollSpy._increment = 0; 6408 6409 /** 6410 * @static 6411 * @memberof ScrollSpy 6412 */ 6413 ScrollSpy._ticks = 0; 6414 6415 M.ScrollSpy = ScrollSpy; 6416 6417 if (M.jQueryLoaded) { 6418 M.initializeJqueryWrapper(ScrollSpy, 'scrollSpy', 'M_ScrollSpy'); 6419 } 6420})(cash, M.anime); 6421;(function ($) { 6422 'use strict'; 6423 6424 var _defaults = { 6425 data: {}, // Autocomplete data set 6426 limit: Infinity, // Limit of results the autocomplete shows 6427 onAutocomplete: null, // Callback for when autocompleted 6428 minLength: 1, // Min characters before autocomplete starts 6429 sortFunction: function (a, b, inputString) { 6430 // Sort function for sorting autocomplete results 6431 return a.indexOf(inputString) - b.indexOf(inputString); 6432 } 6433 }; 6434 6435 /** 6436 * @class 6437 * 6438 */ 6439 6440 var Autocomplete = function (_Component10) { 6441 _inherits(Autocomplete, _Component10); 6442 6443 /** 6444 * Construct Autocomplete instance 6445 * @constructor 6446 * @param {Element} el 6447 * @param {Object} options 6448 */ 6449 function Autocomplete(el, options) { 6450 _classCallCheck(this, Autocomplete); 6451 6452 var _this37 = _possibleConstructorReturn(this, (Autocomplete.__proto__ || Object.getPrototypeOf(Autocomplete)).call(this, Autocomplete, el, options)); 6453 6454 _this37.el.M_Autocomplete = _this37; 6455 6456 /** 6457 * Options for the autocomplete 6458 * @member Autocomplete#options 6459 * @prop {Number} duration 6460 * @prop {Number} dist 6461 * @prop {number} shift 6462 * @prop {number} padding 6463 * @prop {Boolean} fullWidth 6464 * @prop {Boolean} indicators 6465 * @prop {Boolean} noWrap 6466 * @prop {Function} onCycleTo 6467 */ 6468 _this37.options = $.extend({}, Autocomplete.defaults, options); 6469 6470 // Setup 6471 _this37.isOpen = false; 6472 _this37.count = 0; 6473 _this37.activeIndex = -1; 6474 _this37.oldVal; 6475 _this37.$inputField = _this37.$el.closest('.input-field'); 6476 _this37.$active = $(); 6477 _this37._mousedown = false; 6478 _this37._setupDropdown(); 6479 6480 _this37._setupEventHandlers(); 6481 return _this37; 6482 } 6483 6484 _createClass(Autocomplete, [{ 6485 key: "destroy", 6486 6487 6488 /** 6489 * Teardown component 6490 */ 6491 value: function destroy() { 6492 this._removeEventHandlers(); 6493 this._removeDropdown(); 6494 this.el.M_Autocomplete = undefined; 6495 } 6496 6497 /** 6498 * Setup Event Handlers 6499 */ 6500 6501 }, { 6502 key: "_setupEventHandlers", 6503 value: function _setupEventHandlers() { 6504 this._handleInputBlurBound = this._handleInputBlur.bind(this); 6505 this._handleInputKeyupAndFocusBound = this._handleInputKeyupAndFocus.bind(this); 6506 this._handleInputKeydownBound = this._handleInputKeydown.bind(this); 6507 this._handleInputClickBound = this._handleInputClick.bind(this); 6508 this._handleContainerMousedownAndTouchstartBound = this._handleContainerMousedownAndTouchstart.bind(this); 6509 this._handleContainerMouseupAndTouchendBound = this._handleContainerMouseupAndTouchend.bind(this); 6510 6511 this.el.addEventListener('blur', this._handleInputBlurBound); 6512 this.el.addEventListener('keyup', this._handleInputKeyupAndFocusBound); 6513 this.el.addEventListener('focus', this._handleInputKeyupAndFocusBound); 6514 this.el.addEventListener('keydown', this._handleInputKeydownBound); 6515 this.el.addEventListener('click', this._handleInputClickBound); 6516 this.container.addEventListener('mousedown', this._handleContainerMousedownAndTouchstartBound); 6517 this.container.addEventListener('mouseup', this._handleContainerMouseupAndTouchendBound); 6518 6519 if (typeof window.ontouchstart !== 'undefined') { 6520 this.container.addEventListener('touchstart', this._handleContainerMousedownAndTouchstartBound); 6521 this.container.addEventListener('touchend', this._handleContainerMouseupAndTouchendBound); 6522 } 6523 } 6524 6525 /** 6526 * Remove Event Handlers 6527 */ 6528 6529 }, { 6530 key: "_removeEventHandlers", 6531 value: function _removeEventHandlers() { 6532 this.el.removeEventListener('blur', this._handleInputBlurBound); 6533 this.el.removeEventListener('keyup', this._handleInputKeyupAndFocusBound); 6534 this.el.removeEventListener('focus', this._handleInputKeyupAndFocusBound); 6535 this.el.removeEventListener('keydown', this._handleInputKeydownBound); 6536 this.el.removeEventListener('click', this._handleInputClickBound); 6537 this.container.removeEventListener('mousedown', this._handleContainerMousedownAndTouchstartBound); 6538 this.container.removeEventListener('mouseup', this._handleContainerMouseupAndTouchendBound); 6539 6540 if (typeof window.ontouchstart !== 'undefined') { 6541 this.container.removeEventListener('touchstart', this._handleContainerMousedownAndTouchstartBound); 6542 this.container.removeEventListener('touchend', this._handleContainerMouseupAndTouchendBound); 6543 } 6544 } 6545 6546 /** 6547 * Setup dropdown 6548 */ 6549 6550 }, { 6551 key: "_setupDropdown", 6552 value: function _setupDropdown() { 6553 var _this38 = this; 6554 6555 this.container = document.createElement('ul'); 6556 this.container.id = "autocomplete-options-" + M.guid(); 6557 $(this.container).addClass('autocomplete-content dropdown-content'); 6558 this.$inputField.append(this.container); 6559 this.el.setAttribute('data-target', this.container.id); 6560 6561 this.dropdown = M.Dropdown.init(this.el, { 6562 autoFocus: false, 6563 closeOnClick: false, 6564 coverTrigger: false, 6565 onItemClick: function (itemEl) { 6566 _this38.selectOption($(itemEl)); 6567 } 6568 }); 6569 6570 // Sketchy removal of dropdown click handler 6571 this.el.removeEventListener('click', this.dropdown._handleClickBound); 6572 } 6573 6574 /** 6575 * Remove dropdown 6576 */ 6577 6578 }, { 6579 key: "_removeDropdown", 6580 value: function _removeDropdown() { 6581 this.container.parentNode.removeChild(this.container); 6582 } 6583 6584 /** 6585 * Handle Input Blur 6586 */ 6587 6588 }, { 6589 key: "_handleInputBlur", 6590 value: function _handleInputBlur() { 6591 if (!this._mousedown) { 6592 this.close(); 6593 this._resetAutocomplete(); 6594 } 6595 } 6596 6597 /** 6598 * Handle Input Keyup and Focus 6599 * @param {Event} e 6600 */ 6601 6602 }, { 6603 key: "_handleInputKeyupAndFocus", 6604 value: function _handleInputKeyupAndFocus(e) { 6605 if (e.type === 'keyup') { 6606 Autocomplete._keydown = false; 6607 } 6608 6609 this.count = 0; 6610 var val = this.el.value.toLowerCase(); 6611 6612 // Don't capture enter or arrow key usage. 6613 if (e.keyCode === 13 || e.keyCode === 38 || e.keyCode === 40) { 6614 return; 6615 } 6616 6617 // Check if the input isn't empty 6618 // Check if focus triggered by tab 6619 if (this.oldVal !== val && (M.tabPressed || e.type !== 'focus')) { 6620 this.open(); 6621 } 6622 6623 // Update oldVal 6624 this.oldVal = val; 6625 } 6626 6627 /** 6628 * Handle Input Keydown 6629 * @param {Event} e 6630 */ 6631 6632 }, { 6633 key: "_handleInputKeydown", 6634 value: function _handleInputKeydown(e) { 6635 Autocomplete._keydown = true; 6636 6637 // Arrow keys and enter key usage 6638 var keyCode = e.keyCode, 6639 liElement = void 0, 6640 numItems = $(this.container).children('li').length; 6641 6642 // select element on Enter 6643 if (keyCode === M.keys.ENTER && this.activeIndex >= 0) { 6644 liElement = $(this.container).children('li').eq(this.activeIndex); 6645 if (liElement.length) { 6646 this.selectOption(liElement); 6647 e.preventDefault(); 6648 } 6649 return; 6650 } 6651 6652 // Capture up and down key 6653 if (keyCode === M.keys.ARROW_UP || keyCode === M.keys.ARROW_DOWN) { 6654 e.preventDefault(); 6655 6656 if (keyCode === M.keys.ARROW_UP && this.activeIndex > 0) { 6657 this.activeIndex--; 6658 } 6659 6660 if (keyCode === M.keys.ARROW_DOWN && this.activeIndex < numItems - 1) { 6661 this.activeIndex++; 6662 } 6663 6664 this.$active.removeClass('active'); 6665 if (this.activeIndex >= 0) { 6666 this.$active = $(this.container).children('li').eq(this.activeIndex); 6667 this.$active.addClass('active'); 6668 } 6669 } 6670 } 6671 6672 /** 6673 * Handle Input Click 6674 * @param {Event} e 6675 */ 6676 6677 }, { 6678 key: "_handleInputClick", 6679 value: function _handleInputClick(e) { 6680 this.open(); 6681 } 6682 6683 /** 6684 * Handle Container Mousedown and Touchstart 6685 * @param {Event} e 6686 */ 6687 6688 }, { 6689 key: "_handleContainerMousedownAndTouchstart", 6690 value: function _handleContainerMousedownAndTouchstart(e) { 6691 this._mousedown = true; 6692 } 6693 6694 /** 6695 * Handle Container Mouseup and Touchend 6696 * @param {Event} e 6697 */ 6698 6699 }, { 6700 key: "_handleContainerMouseupAndTouchend", 6701 value: function _handleContainerMouseupAndTouchend(e) { 6702 this._mousedown = false; 6703 } 6704 6705 /** 6706 * Highlight partial match 6707 */ 6708 6709 }, { 6710 key: "_highlight", 6711 value: function _highlight(string, $el) { 6712 var img = $el.find('img'); 6713 var matchStart = $el.text().toLowerCase().indexOf('' + string.toLowerCase() + ''), 6714 matchEnd = matchStart + string.length - 1, 6715 beforeMatch = $el.text().slice(0, matchStart), 6716 matchText = $el.text().slice(matchStart, matchEnd + 1), 6717 afterMatch = $el.text().slice(matchEnd + 1); 6718 $el.html("<span>" + beforeMatch + "<span class='highlight'>" + matchText + "</span>" + afterMatch + "</span>"); 6719 if (img.length) { 6720 $el.prepend(img); 6721 } 6722 } 6723 6724 /** 6725 * Reset current element position 6726 */ 6727 6728 }, { 6729 key: "_resetCurrentElement", 6730 value: function _resetCurrentElement() { 6731 this.activeIndex = -1; 6732 this.$active.removeClass('active'); 6733 } 6734 6735 /** 6736 * Reset autocomplete elements 6737 */ 6738 6739 }, { 6740 key: "_resetAutocomplete", 6741 value: function _resetAutocomplete() { 6742 $(this.container).empty(); 6743 this._resetCurrentElement(); 6744 this.oldVal = null; 6745 this.isOpen = false; 6746 this._mousedown = false; 6747 } 6748 6749 /** 6750 * Select autocomplete option 6751 * @param {Element} el Autocomplete option list item element 6752 */ 6753 6754 }, { 6755 key: "selectOption", 6756 value: function selectOption(el) { 6757 var text = el.text().trim(); 6758 this.el.value = text; 6759 this.$el.trigger('change'); 6760 this._resetAutocomplete(); 6761 this.close(); 6762 6763 // Handle onAutocomplete callback. 6764 if (typeof this.options.onAutocomplete === 'function') { 6765 this.options.onAutocomplete.call(this, text); 6766 } 6767 } 6768 6769 /** 6770 * Render dropdown content 6771 * @param {Object} data data set 6772 * @param {String} val current input value 6773 */ 6774 6775 }, { 6776 key: "_renderDropdown", 6777 value: function _renderDropdown(data, val) { 6778 var _this39 = this; 6779 6780 this._resetAutocomplete(); 6781 6782 var matchingData = []; 6783 6784 // Gather all matching data 6785 for (var key in data) { 6786 if (data.hasOwnProperty(key) && key.toLowerCase().indexOf(val) !== -1) { 6787 // Break if past limit 6788 if (this.count >= this.options.limit) { 6789 break; 6790 } 6791 6792 var entry = { 6793 data: data[key], 6794 key: key 6795 }; 6796 matchingData.push(entry); 6797 6798 this.count++; 6799 } 6800 } 6801 6802 // Sort 6803 if (this.options.sortFunction) { 6804 var sortFunctionBound = function (a, b) { 6805 return _this39.options.sortFunction(a.key.toLowerCase(), b.key.toLowerCase(), val.toLowerCase()); 6806 }; 6807 matchingData.sort(sortFunctionBound); 6808 } 6809 6810 // Render 6811 for (var i = 0; i < matchingData.length; i++) { 6812 var _entry = matchingData[i]; 6813 var $autocompleteOption = $('<li></li>'); 6814 if (!!_entry.data) { 6815 $autocompleteOption.append("<img src=\"" + _entry.data + "\" class=\"right circle\"><span>" + _entry.key + "</span>"); 6816 } else { 6817 $autocompleteOption.append('<span>' + _entry.key + '</span>'); 6818 } 6819 6820 $(this.container).append($autocompleteOption); 6821 this._highlight(val, $autocompleteOption); 6822 } 6823 } 6824 6825 /** 6826 * Open Autocomplete Dropdown 6827 */ 6828 6829 }, { 6830 key: "open", 6831 value: function open() { 6832 var val = this.el.value.toLowerCase(); 6833 6834 this._resetAutocomplete(); 6835 6836 if (val.length >= this.options.minLength) { 6837 this.isOpen = true; 6838 this._renderDropdown(this.options.data, val); 6839 } 6840 6841 // Open dropdown 6842 if (!this.dropdown.isOpen) { 6843 this.dropdown.open(); 6844 } else { 6845 // Recalculate dropdown when its already open 6846 this.dropdown.recalculateDimensions(); 6847 } 6848 } 6849 6850 /** 6851 * Close Autocomplete Dropdown 6852 */ 6853 6854 }, { 6855 key: "close", 6856 value: function close() { 6857 this.dropdown.close(); 6858 } 6859 6860 /** 6861 * Update Data 6862 * @param {Object} data 6863 */ 6864 6865 }, { 6866 key: "updateData", 6867 value: function updateData(data) { 6868 var val = this.el.value.toLowerCase(); 6869 this.options.data = data; 6870 6871 if (this.isOpen) { 6872 this._renderDropdown(data, val); 6873 } 6874 } 6875 }], [{ 6876 key: "init", 6877 value: function init(els, options) { 6878 return _get(Autocomplete.__proto__ || Object.getPrototypeOf(Autocomplete), "init", this).call(this, this, els, options); 6879 } 6880 6881 /** 6882 * Get Instance 6883 */ 6884 6885 }, { 6886 key: "getInstance", 6887 value: function getInstance(el) { 6888 var domElem = !!el.jquery ? el[0] : el; 6889 return domElem.M_Autocomplete; 6890 } 6891 }, { 6892 key: "defaults", 6893 get: function () { 6894 return _defaults; 6895 } 6896 }]); 6897 6898 return Autocomplete; 6899 }(Component); 6900 6901 /** 6902 * @static 6903 * @memberof Autocomplete 6904 */ 6905 6906 6907 Autocomplete._keydown = false; 6908 6909 M.Autocomplete = Autocomplete; 6910 6911 if (M.jQueryLoaded) { 6912 M.initializeJqueryWrapper(Autocomplete, 'autocomplete', 'M_Autocomplete'); 6913 } 6914})(cash); 6915;(function ($) { 6916 // Function to update labels of text fields 6917 M.updateTextFields = function () { 6918 var input_selector = 'input[type=text], input[type=password], input[type=email], input[type=url], input[type=tel], input[type=number], input[type=search], input[type=date], input[type=time], textarea'; 6919 $(input_selector).each(function (element, index) { 6920 var $this = $(this); 6921 if (element.value.length > 0 || $(element).is(':focus') || element.autofocus || $this.attr('placeholder') !== null) { 6922 $this.siblings('label').addClass('active'); 6923 } else if (element.validity) { 6924 $this.siblings('label').toggleClass('active', element.validity.badInput === true); 6925 } else { 6926 $this.siblings('label').removeClass('active'); 6927 } 6928 }); 6929 }; 6930 6931 M.validate_field = function (object) { 6932 var hasLength = object.attr('data-length') !== null; 6933 var lenAttr = parseInt(object.attr('data-length')); 6934 var len = object[0].value.length; 6935 6936 if (len === 0 && object[0].validity.badInput === false && !object.is(':required')) { 6937 if (object.hasClass('validate')) { 6938 object.removeClass('valid'); 6939 object.removeClass('invalid'); 6940 } 6941 } else { 6942 if (object.hasClass('validate')) { 6943 // Check for character counter attributes 6944 if (object.is(':valid') && hasLength && len <= lenAttr || object.is(':valid') && !hasLength) { 6945 object.removeClass('invalid'); 6946 object.addClass('valid'); 6947 } else { 6948 object.removeClass('valid'); 6949 object.addClass('invalid'); 6950 } 6951 } 6952 } 6953 }; 6954 6955 M.textareaAutoResize = function ($textarea) { 6956 // Wrap if native element 6957 if ($textarea instanceof Element) { 6958 $textarea = $($textarea); 6959 } 6960 6961 if (!$textarea.length) { 6962 console.error('No textarea element found'); 6963 return; 6964 } 6965 6966 // Textarea Auto Resize 6967 var hiddenDiv = $('.hiddendiv').first(); 6968 if (!hiddenDiv.length) { 6969 hiddenDiv = $('<div class="hiddendiv common"></div>'); 6970 $('body').append(hiddenDiv); 6971 } 6972 6973 // Set font properties of hiddenDiv 6974 var fontFamily = $textarea.css('font-family'); 6975 var fontSize = $textarea.css('font-size'); 6976 var lineHeight = $textarea.css('line-height'); 6977 6978 // Firefox can't handle padding shorthand. 6979 var paddingTop = $textarea.css('padding-top'); 6980 var paddingRight = $textarea.css('padding-right'); 6981 var paddingBottom = $textarea.css('padding-bottom'); 6982 var paddingLeft = $textarea.css('padding-left'); 6983 6984 if (fontSize) { 6985 hiddenDiv.css('font-size', fontSize); 6986 } 6987 if (fontFamily) { 6988 hiddenDiv.css('font-family', fontFamily); 6989 } 6990 if (lineHeight) { 6991 hiddenDiv.css('line-height', lineHeight); 6992 } 6993 if (paddingTop) { 6994 hiddenDiv.css('padding-top', paddingTop); 6995 } 6996 if (paddingRight) { 6997 hiddenDiv.css('padding-right', paddingRight); 6998 } 6999 if (paddingBottom) { 7000 hiddenDiv.css('padding-bottom', paddingBottom); 7001 } 7002 if (paddingLeft) { 7003 hiddenDiv.css('padding-left', paddingLeft); 7004 } 7005 7006 // Set original-height, if none 7007 if (!$textarea.data('original-height')) { 7008 $textarea.data('original-height', $textarea.height()); 7009 } 7010 7011 if ($textarea.attr('wrap') === 'off') { 7012 hiddenDiv.css('overflow-wrap', 'normal').css('white-space', 'pre'); 7013 } 7014 7015 hiddenDiv.text($textarea[0].value + '\n'); 7016 var content = hiddenDiv.html().replace(/\n/g, '<br>'); 7017 hiddenDiv.html(content); 7018 7019 // When textarea is hidden, width goes crazy. 7020 // Approximate with half of window size 7021 7022 if ($textarea[0].offsetWidth > 0 && $textarea[0].offsetHeight > 0) { 7023 hiddenDiv.css('width', $textarea.width() + 'px'); 7024 } else { 7025 hiddenDiv.css('width', window.innerWidth / 2 + 'px'); 7026 } 7027 7028 /** 7029 * Resize if the new height is greater than the 7030 * original height of the textarea 7031 */ 7032 if ($textarea.data('original-height') <= hiddenDiv.innerHeight()) { 7033 $textarea.css('height', hiddenDiv.innerHeight() + 'px'); 7034 } else if ($textarea[0].value.length < $textarea.data('previous-length')) { 7035 /** 7036 * In case the new height is less than original height, it 7037 * means the textarea has less text than before 7038 * So we set the height to the original one 7039 */ 7040 $textarea.css('height', $textarea.data('original-height') + 'px'); 7041 } 7042 $textarea.data('previous-length', $textarea[0].value.length); 7043 }; 7044 7045 $(document).ready(function () { 7046 // Text based inputs 7047 var input_selector = 'input[type=text], input[type=password], input[type=email], input[type=url], input[type=tel], input[type=number], input[type=search], input[type=date], input[type=time], textarea'; 7048 7049 // Add active if form auto complete 7050 $(document).on('change', input_selector, function () { 7051 if (this.value.length !== 0 || $(this).attr('placeholder') !== null) { 7052 $(this).siblings('label').addClass('active'); 7053 } 7054 M.validate_field($(this)); 7055 }); 7056 7057 // Add active if input element has been pre-populated on document ready 7058 $(document).ready(function () { 7059 M.updateTextFields(); 7060 }); 7061 7062 // HTML DOM FORM RESET handling 7063 $(document).on('reset', function (e) { 7064 var formReset = $(e.target); 7065 if (formReset.is('form')) { 7066 formReset.find(input_selector).removeClass('valid').removeClass('invalid'); 7067 formReset.find(input_selector).each(function (e) { 7068 if (this.value.length) { 7069 $(this).siblings('label').removeClass('active'); 7070 } 7071 }); 7072 7073 // Reset select (after native reset) 7074 setTimeout(function () { 7075 formReset.find('select').each(function () { 7076 // check if initialized 7077 if (this.M_FormSelect) { 7078 $(this).trigger('change'); 7079 } 7080 }); 7081 }, 0); 7082 } 7083 }); 7084 7085 /** 7086 * Add active when element has focus 7087 * @param {Event} e 7088 */ 7089 document.addEventListener('focus', function (e) { 7090 if ($(e.target).is(input_selector)) { 7091 $(e.target).siblings('label, .prefix').addClass('active'); 7092 } 7093 }, true); 7094 7095 /** 7096 * Remove active when element is blurred 7097 * @param {Event} e 7098 */ 7099 document.addEventListener('blur', function (e) { 7100 var $inputElement = $(e.target); 7101 if ($inputElement.is(input_selector)) { 7102 var selector = '.prefix'; 7103 7104 if ($inputElement[0].value.length === 0 && $inputElement[0].validity.badInput !== true && $inputElement.attr('placeholder') === null) { 7105 selector += ', label'; 7106 } 7107 $inputElement.siblings(selector).removeClass('active'); 7108 M.validate_field($inputElement); 7109 } 7110 }, true); 7111 7112 // Radio and Checkbox focus class 7113 var radio_checkbox = 'input[type=radio], input[type=checkbox]'; 7114 $(document).on('keyup', radio_checkbox, function (e) { 7115 // TAB, check if tabbing to radio or checkbox. 7116 if (e.which === M.keys.TAB) { 7117 $(this).addClass('tabbed'); 7118 var $this = $(this); 7119 $this.one('blur', function (e) { 7120 $(this).removeClass('tabbed'); 7121 }); 7122 return; 7123 } 7124 }); 7125 7126 var text_area_selector = '.materialize-textarea'; 7127 $(text_area_selector).each(function () { 7128 var $textarea = $(this); 7129 /** 7130 * Resize textarea on document load after storing 7131 * the original height and the original length 7132 */ 7133 $textarea.data('original-height', $textarea.height()); 7134 $textarea.data('previous-length', this.value.length); 7135 M.textareaAutoResize($textarea); 7136 }); 7137 7138 $(document).on('keyup', text_area_selector, function () { 7139 M.textareaAutoResize($(this)); 7140 }); 7141 $(document).on('keydown', text_area_selector, function () { 7142 M.textareaAutoResize($(this)); 7143 }); 7144 7145 // File Input Path 7146 $(document).on('change', '.file-field input[type="file"]', function () { 7147 var file_field = $(this).closest('.file-field'); 7148 var path_input = file_field.find('input.file-path'); 7149 var files = $(this)[0].files; 7150 var file_names = []; 7151 for (var i = 0; i < files.length; i++) { 7152 file_names.push(files[i].name); 7153 } 7154 path_input[0].value = file_names.join(', '); 7155 path_input.trigger('change'); 7156 }); 7157 }); // End of $(document).ready 7158})(cash); 7159;(function ($, anim) { 7160 'use strict'; 7161 7162 var _defaults = { 7163 indicators: true, 7164
vendor: 5,908 bytes, lines 7164-7381
7164duration: 500, 7165 interval: 6000 7166 }; 7167 7168 /** 7169 * @class 7170 * 7171 */ 7172 7173 var Slider = function (_Component11) { 7174 _inherits(Slider, _Component11); 7175 7176 /** 7177 * Construct Slider instance and set up overlay 7178 * @constructor 7179 * @param {Element} el 7180 * @param {Object} options 7181 */ 7182 function Slider(el, options) { 7183 _classCallCheck(this, Slider); 7184 7185 var _this40 = _possibleConstructorReturn(this, (Slider.__proto__ || Object.getPrototypeOf(Slider)).call(this, Slider, el, options)); 7186 7187 _this40.el.M_Slider = _this40; 7188 7189 /** 7190 * Options for the modal 7191 * @member Slider#options 7192 * @prop {Boolean} [indicators=true] - Show indicators 7193 * @prop {Number} [height=400] - height of slider 7194 * @prop {Number} [duration=500] - Length in ms of slide transition 7195 * @prop {Number} [interval=6000] - Length in ms of slide interval 7196 */ 7197 _this40.options = $.extend({}, Slider.defaults, options); 7198 7199 // setup 7200 _this40.$slider = _this40.$el.find('.slides'); 7201 _this40.$slides = _this40.$slider.children('li'); 7202 _this40.activeIndex = _this40.$slides.filter(function (item) { 7203 return $(item).hasClass('active'); 7204 }).first().index(); 7205 if (_this40.activeIndex != -1) { 7206 _this40.$active = _this40.$slides.eq(_this40.activeIndex); 7207 } 7208 7209 _this40._setSliderHeight(); 7210 7211 // Set initial positions of captions 7212 _this40.$slides.find('.caption').each(function (el) { 7213 _this40._animateCaptionIn(el, 0); 7214 }); 7215 7216 // Move img src into background-image 7217 _this40.$slides.find('img').each(function (el) { 7218 var placeholderBase64 = 'data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=='; 7219 if ($(el).attr('src') !== placeholderBase64) { 7220 $(el).css('background-image', 'url("' + $(el).attr('src') + '")'); 7221 $(el).attr('src', placeholderBase64); 7222 } 7223 }); 7224 7225 _this40._setupIndicators(); 7226 7227 // Show active slide 7228 if (_this40.$active) { 7229 _this40.$active.css('display', 'block'); 7230 } else { 7231 _this40.$slides.first().addClass('active'); 7232 anim({ 7233 targets: _this40.$slides.first()[0], 7234 opacity: 1, 7235 duration: _this40.options.duration, 7236 easing: 'easeOutQuad' 7237 }); 7238 7239 _this40.activeIndex = 0; 7240 _this40.$active = _this40.$slides.eq(_this40.activeIndex); 7241 7242 // Update indicators 7243 if (_this40.options.indicators) { 7244 _this40.$indicators.eq(_this40.activeIndex).addClass('active'); 7245 } 7246 } 7247 7248 // Adjust height to current slide 7249 _this40.$active.find('img').each(function (el) { 7250 anim({ 7251 targets: _this40.$active.find('.caption')[0], 7252 opacity: 1, 7253 translateX: 0, 7254 translateY: 0, 7255 duration: _this40.options.duration, 7256 easing: 'easeOutQuad' 7257 }); 7258 }); 7259 7260 _this40._setupEventHandlers(); 7261 7262 // auto scroll 7263 _this40.start(); 7264 return _this40; 7265 } 7266 7267 _createClass(Slider, [{ 7268 key: "destroy", 7269 7270 7271 /** 7272 * Teardown component 7273 */ 7274 value: function destroy() { 7275 this.pause(); 7276 this._removeIndicators(); 7277 this._removeEventHandlers(); 7278 this.el.M_Slider = undefined; 7279 } 7280 7281 /** 7282 * Setup Event Handlers 7283 */ 7284 7285 }, { 7286 key: "_setupEventHandlers", 7287 value: function _setupEventHandlers() { 7288 var _this41 = this; 7289 7290 this._handleIntervalBound = this._handleInterval.bind(this); 7291 this._handleIndicatorClickBound = this._handleIndicatorClick.bind(this); 7292 7293 if (this.options.indicators) { 7294 this.$indicators.each(function (el) { 7295 el.addEventListener('click', _this41._handleIndicatorClickBound); 7296 }); 7297 } 7298 } 7299 7300 /** 7301 * Remove Event Handlers 7302 */ 7303 7304 }, { 7305 key: "_removeEventHandlers", 7306 value: function _removeEventHandlers() { 7307 var _this42 = this; 7308 7309 if (this.options.indicators) { 7310 this.$indicators.each(function (el) { 7311 el.removeEventListener('click', _this42._handleIndicatorClickBound); 7312 }); 7313 } 7314 } 7315 7316 /** 7317 * Handle indicator click 7318 * @param {Event} e 7319 */ 7320 7321 }, { 7322 key: "_handleIndicatorClick", 7323 value: function _handleIndicatorClick(e) { 7324 var currIndex = $(e.target).index(); 7325 this.set(currIndex); 7326 } 7327 7328 /** 7329 * Handle Interval 7330 */ 7331 7332 }, { 7333 key: "_handleInterval", 7334 value: function _handleInterval() { 7335 var newActiveIndex = this.$slider.find('.active').index(); 7336 if (this.$slides.length === newActiveIndex + 1) newActiveIndex = 0; 7337 // loop to start 7338 else newActiveIndex += 1; 7339 7340 this.set(newActiveIndex); 7341 } 7342 7343 /** 7344 * Animate in caption 7345 * @param {Element} caption 7346 * @param {Number} duration 7347 */ 7348 7349 }, { 7350 key: "_animateCaptionIn", 7351 value: function _animateCaptionIn(caption, duration) { 7352 var animOptions = { 7353 targets: caption, 7354 opacity: 0, 7355 duration: duration, 7356 easing: 'easeOutQuad' 7357 }; 7358 7359 if ($(caption).hasClass('center-align')) { 7360 animOptions.translateY = -100; 7361 } else if ($(caption).hasClass('right-align')) { 7362 animOptions.translateX = 100; 7363 } else if ($(caption).hasClass('left-align')) { 7364 animOptions.translateX = -100; 7365 } 7366 7367 anim(animOptions); 7368 } 7369 7370 /** 7371 * Set height of slider 7372 */ 7373 7374 }, { 7375 key: "_setSliderHeight", 7376 value: function _setSliderHeight() { 7377 // If fullscreen, do nothing 7378 if (!this.$el.hasClass('fullscreen')) { 7379 if (this.options.indicators) { 7380 // Add height if indicators are present 7381 this.$el.css('height', this.options.height +
vendor: 151,916 bytes, lines 7381-12373
73810 + 'px'); 7382 } else { 7383 this.$el.css('height', this.options.height + 'px'); 7384 } 7385 this.$slider.css('height', this.options.height + 'px'); 7386 } 7387 } 7388 7389 /** 7390 * Setup indicators 7391 */ 7392 7393 }, { 7394 key: "_setupIndicators", 7395 value: function _setupIndicators() { 7396 var _this43 = this; 7397 7398 if (this.options.indicators) { 7399 this.$indicators = $('<ul class="indicators"></ul>'); 7400 this.$slides.each(function (el, index) { 7401 var $indicator = $('<li class="indicator-item"></li>'); 7402 _this43.$indicators.append($indicator[0]); 7403 }); 7404 this.$el.append(this.$indicators[0]); 7405 this.$indicators = this.$indicators.children('li.indicator-item'); 7406 } 7407 } 7408 7409 /** 7410 * Remove indicators 7411 */ 7412 7413 }, { 7414 key: "_removeIndicators", 7415 value: function _removeIndicators() { 7416 this.$el.find('ul.indicators').remove(); 7417 } 7418 7419 /** 7420 * Cycle to nth item 7421 * @param {Number} index 7422 */ 7423 7424 }, { 7425 key: "set", 7426 value: function set(index) { 7427 var _this44 = this; 7428 7429 // Wrap around indices. 7430 if (index >= this.$slides.length) index = 0;else if (index < 0) index = this.$slides.length - 1; 7431 7432 // Only do if index changes 7433 if (this.activeIndex != index) { 7434 this.$active = this.$slides.eq(this.activeIndex); 7435 var $caption = this.$active.find('.caption'); 7436 this.$active.removeClass('active'); 7437 7438 anim({ 7439 targets: this.$active[0], 7440 opacity: 0, 7441 duration: this.options.duration, 7442 easing: 'easeOutQuad', 7443 complete: function () { 7444 _this44.$slides.not('.active').each(function (el) { 7445 anim({ 7446 targets: el, 7447 opacity: 0, 7448 translateX: 0, 7449 translateY: 0, 7450 duration: 0, 7451 easing: 'easeOutQuad' 7452 }); 7453 }); 7454 } 7455 }); 7456 7457 this._animateCaptionIn($caption[0], this.options.duration); 7458 7459 // Update indicators 7460 if (this.options.indicators) { 7461 this.$indicators.eq(this.activeIndex).removeClass('active'); 7462 this.$indicators.eq(index).addClass('active'); 7463 } 7464 7465 anim({ 7466 targets: this.$slides.eq(index)[0], 7467 opacity: 1, 7468 duration: this.options.duration, 7469 easing: 'easeOutQuad' 7470 }); 7471 7472 anim({ 7473 targets: this.$slides.eq(index).find('.caption')[0], 7474 opacity: 1, 7475 translateX: 0, 7476 translateY: 0, 7477 duration: this.options.duration, 7478 delay: this.options.duration, 7479 easing: 'easeOutQuad' 7480 }); 7481 7482 this.$slides.eq(index).addClass('active'); 7483 this.activeIndex = index; 7484 7485 // Reset interval 7486 this.start(); 7487 } 7488 } 7489 7490 /** 7491 * Pause slider interval 7492 */ 7493 7494 }, { 7495 key: "pause", 7496 value: function pause() { 7497 clearInterval(this.interval); 7498 } 7499 7500 /** 7501 * Start slider interval 7502 */ 7503 7504 }, { 7505 key: "start", 7506 value: function start() { 7507 clearInterval(this.interval); 7508 this.interval = setInterval(this._handleIntervalBound, this.options.duration + this.options.interval); 7509 } 7510 7511 /** 7512 * Move to next slide 7513 */ 7514 7515 }, { 7516 key: "next", 7517 value: function next() { 7518 var newIndex = this.activeIndex + 1; 7519 7520 // Wrap around indices. 7521 if (newIndex >= this.$slides.length) newIndex = 0;else if (newIndex < 0) newIndex = this.$slides.length - 1; 7522 7523 this.set(newIndex); 7524 } 7525 7526 /** 7527 * Move to previous slide 7528 */ 7529 7530 }, { 7531 key: "prev", 7532 value: function prev() { 7533 var newIndex = this.activeIndex - 1; 7534 7535 // Wrap around indices. 7536 if (newIndex >= this.$slides.length) newIndex = 0;else if (newIndex < 0) newIndex = this.$slides.length - 1; 7537 7538 this.set(newIndex); 7539 } 7540 }], [{ 7541 key: "init", 7542 value: function init(els, options) { 7543 return _get(Slider.__proto__ || Object.getPrototypeOf(Slider), "init", this).call(this, this, els, options); 7544 } 7545 7546 /** 7547 * Get Instance 7548 */ 7549 7550 }, { 7551 key: "getInstance", 7552 value: function getInstance(el) { 7553 var domElem = !!el.jquery ? el[0] : el; 7554 return domElem.M_Slider; 7555 } 7556 }, { 7557 key: "defaults", 7558 get: function () { 7559 return _defaults; 7560 } 7561 }]); 7562 7563 return Slider; 7564 }(Component); 7565 7566 M.Slider = Slider; 7567 7568 if (M.jQueryLoaded) { 7569 M.initializeJqueryWrapper(Slider, 'slider', 'M_Slider'); 7570 } 7571})(cash, M.anime); 7572;(function ($, anim) { 7573 $(document).on('click', '.card', function (e) { 7574 if ($(this).children('.card-reveal').length) { 7575 var $card = $(e.target).closest('.card'); 7576 if ($card.data('initialOverflow') === undefined) { 7577 $card.data('initialOverflow', $card.css('overflow') === undefined ? '' : $card.css('overflow')); 7578 } 7579 var $cardReveal = $(this).find('.card-reveal'); 7580 if ($(e.target).is($('.card-reveal .card-title')) || $(e.target).is($('.card-reveal .card-title i'))) { 7581 // Make Reveal animate down and display none 7582 anim({ 7583 targets: $cardReveal[0], 7584 translateY: 0, 7585 duration: 225, 7586 easing: 'easeInOutQuad', 7587 complete: function (anim) { 7588 var el = anim.animatables[0].target; 7589 $(el).css({ display: 'none' }); 7590 $card.css('overflow', $card.data('initialOverflow')); 7591 } 7592 }); 7593 } else if ($(e.target).is($('.card .activator')) || $(e.target).is($('.card .activator i'))) { 7594 $card.css('overflow', 'hidden'); 7595 $cardReveal.css({ display: 'block' }); 7596 anim({ 7597 targets: $cardReveal[0], 7598 translateY: '-100%', 7599 duration: 300, 7600 easing: 'easeInOutQuad' 7601 }); 7602 } 7603 } 7604 }); 7605})(cash, M.anime); 7606;(function ($) { 7607 'use strict'; 7608 7609 var _defaults = { 7610 data: [], 7611 placeholder: '', 7612 secondaryPlaceholder: '', 7613 autocompleteOptions: {}, 7614 limit: Infinity, 7615 onChipAdd: null, 7616 onChipSelect: null, 7617 onChipDelete: null 7618 }; 7619 7620 /** 7621 * @typedef {Object} chip 7622 * @property {String} tag chip tag string 7623 * @property {String} [image] chip avatar image string 7624 */ 7625 7626 /** 7627 * @class 7628 * 7629 */ 7630 7631 var Chips = function (_Component12) { 7632 _inherits(Chips, _Component12); 7633 7634 /** 7635 * Construct Chips instance and set up overlay 7636 * @constructor 7637 * @param {Element} el 7638 * @param {Object} options 7639 */ 7640 function Chips(el, options) { 7641 _classCallCheck(this, Chips); 7642 7643 var _this45 = _possibleConstructorReturn(this, (Chips.__proto__ || Object.getPrototypeOf(Chips)).call(this, Chips, el, options)); 7644 7645 _this45.el.M_Chips = _this45; 7646 7647 /** 7648 * Options for the modal 7649 * @member Chips#options 7650 * @prop {Array} data 7651 * @prop {String} placeholder 7652 * @prop {String} secondaryPlaceholder 7653 * @prop {Object} autocompleteOptions 7654 */ 7655 _this45.options = $.extend({}, Chips.defaults, options); 7656 7657 _this45.$el.addClass('chips input-field'); 7658 _this45.chipsData = []; 7659 _this45.$chips = $(); 7660 _this45._setupInput(); 7661 _this45.hasAutocomplete = Object.keys(_this45.options.autocompleteOptions).length > 0; 7662 7663 // Set input id 7664 if (!_this45.$input.attr('id')) { 7665 _this45.$input.attr('id', M.guid()); 7666 } 7667 7668 // Render initial chips 7669 if (_this45.options.data.length) { 7670 _this45.chipsData = _this45.options.data; 7671 _this45._renderChips(_this45.chipsData); 7672 } 7673 7674 // Setup autocomplete if needed 7675 if (_this45.hasAutocomplete) { 7676 _this45._setupAutocomplete(); 7677 } 7678 7679 _this45._setPlaceholder(); 7680 _this45._setupLabel(); 7681 _this45._setupEventHandlers(); 7682 return _this45; 7683 } 7684 7685 _createClass(Chips, [{ 7686 key: "getData", 7687 7688 7689 /** 7690 * Get Chips Data 7691 */ 7692 value: function getData() { 7693 return this.chipsData; 7694 } 7695 7696 /** 7697 * Teardown component 7698 */ 7699 7700 }, { 7701 key: "destroy", 7702 value: function destroy() { 7703 this._removeEventHandlers(); 7704 this.$chips.remove(); 7705 this.el.M_Chips = undefined; 7706 } 7707 7708 /** 7709 * Setup Event Handlers 7710 */ 7711 7712 }, { 7713 key: "_setupEventHandlers", 7714 value: function _setupEventHandlers() { 7715 this._handleChipClickBound = this._handleChipClick.bind(this); 7716 this._handleInputKeydownBound = this._handleInputKeydown.bind(this); 7717 this._handleInputFocusBound = this._handleInputFocus.bind(this); 7718 this._handleInputBlurBound = this._handleInputBlur.bind(this); 7719 7720 this.el.addEventListener('click', this._handleChipClickBound); 7721 document.addEventListener('keydown', Chips._handleChipsKeydown); 7722 document.addEventListener('keyup', Chips._handleChipsKeyup); 7723 this.el.addEventListener('blur', Chips._handleChipsBlur, true); 7724 this.$input[0].addEventListener('focus', this._handleInputFocusBound); 7725 this.$input[0].addEventListener('blur', this._handleInputBlurBound); 7726 this.$input[0].addEventListener('keydown', this._handleInputKeydownBound); 7727 } 7728 7729 /** 7730 * Remove Event Handlers 7731 */ 7732 7733 }, { 7734 key: "_removeEventHandlers", 7735 value: function _removeEventHandlers() { 7736 this.el.removeEventListener('click', this._handleChipClickBound); 7737 document.removeEventListener('keydown', Chips._handleChipsKeydown); 7738 document.removeEventListener('keyup', Chips._handleChipsKeyup); 7739 this.el.removeEventListener('blur', Chips._handleChipsBlur, true); 7740 this.$input[0].removeEventListener('focus', this._handleInputFocusBound); 7741 this.$input[0].removeEventListener('blur', this._handleInputBlurBound); 7742 this.$input[0].removeEventListener('keydown', this._handleInputKeydownBound); 7743 } 7744 7745 /** 7746 * Handle Chip Click 7747 * @param {Event} e 7748 */ 7749 7750 }, { 7751 key: "_handleChipClick", 7752 value: function _handleChipClick(e) { 7753 var $chip = $(e.target).closest('.chip'); 7754 var clickedClose = $(e.target).is('.close'); 7755 if ($chip.length) { 7756 var index = $chip.index(); 7757 if (clickedClose) { 7758 // delete chip 7759 this.deleteChip(index); 7760 this.$input[0].focus(); 7761 } else { 7762 // select chip 7763 this.selectChip(index); 7764 } 7765 7766 // Default handle click to focus on input 7767 } else { 7768 this.$input[0].focus(); 7769 } 7770 } 7771 7772 /** 7773 * Handle Chips Keydown 7774 * @param {Event} e 7775 */ 7776 7777 }, { 7778 key: "_handleInputFocus", 7779 7780 7781 /** 7782 * Handle Input Focus 7783 */ 7784 value: function _handleInputFocus() { 7785 this.$el.addClass('focus'); 7786 } 7787 7788 /** 7789 * Handle Input Blur 7790 */ 7791 7792 }, { 7793 key: "_handleInputBlur", 7794 value: function _handleInputBlur() { 7795 this.$el.removeClass('focus'); 7796 } 7797 7798 /** 7799 * Handle Input Keydown 7800 * @param {Event} e 7801 */ 7802 7803 }, { 7804 key: "_handleInputKeydown", 7805 value: function _handleInputKeydown(e) { 7806 Chips._keydown = true; 7807 7808 // enter 7809 if (e.keyCode === 13) { 7810 // Override enter if autocompleting. 7811 if (this.hasAutocomplete && this.autocomplete && this.autocomplete.isOpen) { 7812 return; 7813 } 7814 7815 e.preventDefault(); 7816 this.addChip({ 7817 tag: this.$input[0].value 7818 }); 7819 this.$input[0].value = ''; 7820 7821 // delete or left 7822 } else if ((e.keyCode === 8 || e.keyCode === 37) && this.$input[0].value === '' && this.chipsData.length) { 7823 e.preventDefault(); 7824 this.selectChip(this.chipsData.length - 1); 7825 } 7826 } 7827 7828 /** 7829 * Render Chip 7830 * @param {chip} chip 7831 * @return {Element} 7832 */ 7833 7834 }, { 7835 key: "_renderChip", 7836 value: function _renderChip(chip) { 7837 if (!chip.tag) { 7838 return; 7839 } 7840 7841 var renderedChip = document.createElement('div'); 7842 var closeIcon = document.createElement('i'); 7843 renderedChip.classList.add('chip'); 7844 renderedChip.textContent = chip.tag; 7845 renderedChip.setAttribute('tabindex', 0); 7846 $(closeIcon).addClass('material-icons close'); 7847 closeIcon.textContent = 'close'; 7848 7849 // attach image if needed 7850 if (chip.image) { 7851 var img = document.createElement('img'); 7852 img.setAttribute('src', chip.image); 7853 renderedChip.insertBefore(img, renderedChip.firstChild); 7854 } 7855 7856 renderedChip.appendChild(closeIcon); 7857 return renderedChip; 7858 } 7859 7860 /** 7861 * Render Chips 7862 */ 7863 7864 }, { 7865 key: "_renderChips", 7866 value: function _renderChips() { 7867 this.$chips.remove(); 7868 for (var i = 0; i < this.chipsData.length; i++) { 7869 var chipEl = this._renderChip(this.chipsData[i]); 7870 this.$el.append(chipEl); 7871 this.$chips.add(chipEl); 7872 } 7873 7874 // move input to end 7875 this.$el.append(this.$input[0]); 7876 } 7877 7878 /** 7879 * Setup Autocomplete 7880 */ 7881 7882 }, { 7883 key: "_setupAutocomplete", 7884 value: function _setupAutocomplete() { 7885 var _this46 = this; 7886 7887 this.options.autocompleteOptions.onAutocomplete = function (val) { 7888 _this46.addChip({ 7889 tag: val 7890 }); 7891 _this46.$input[0].value = ''; 7892 _this46.$input[0].focus(); 7893 }; 7894 7895 this.autocomplete = M.Autocomplete.init(this.$input[0], this.options.autocompleteOptions); 7896 } 7897 7898 /** 7899 * Setup Input 7900 */ 7901 7902 }, { 7903 key: "_setupInput", 7904 value: function _setupInput() { 7905 this.$input = this.$el.find('input'); 7906 if (!this.$input.length) { 7907 this.$input = $('<input></input>'); 7908 this.$el.append(this.$input); 7909 } 7910 7911 this.$input.addClass('input'); 7912 } 7913 7914 /** 7915 * Setup Label 7916 */ 7917 7918 }, { 7919 key: "_setupLabel", 7920 value: function _setupLabel() { 7921 this.$label = this.$el.find('label'); 7922 if (this.$label.length) { 7923 this.$label.setAttribute('for', this.$input.attr('id')); 7924 } 7925 } 7926 7927 /** 7928 * Set placeholder 7929 */ 7930 7931 }, { 7932 key: "_setPlaceholder", 7933 value: function _setPlaceholder() { 7934 if (this.chipsData !== undefined && !this.chipsData.length && this.options.placeholder) { 7935 $(this.$input).prop('placeholder', this.options.placeholder); 7936 } else if ((this.chipsData === undefined || !!this.chipsData.length) && this.options.secondaryPlaceholder) { 7937 $(this.$input).prop('placeholder', this.options.secondaryPlaceholder); 7938 } 7939 } 7940 7941 /** 7942 * Check if chip is valid 7943 * @param {chip} chip 7944 */ 7945 7946 }, { 7947 key: "_isValid", 7948 value: function _isValid(chip) { 7949 if (chip.hasOwnProperty('tag') && chip.tag !== '') { 7950 var exists = false; 7951 for (var i = 0; i < this.chipsData.length; i++) { 7952 if (this.chipsData[i].tag === chip.tag) { 7953 exists = true; 7954 break; 7955 } 7956 } 7957 return !exists; 7958 } 7959 7960 return false; 7961 } 7962 7963 /** 7964 * Add chip 7965 * @param {chip} chip 7966 */ 7967 7968 }, { 7969 key: "addChip", 7970 value: function addChip(chip) { 7971 if (!this._isValid(chip) || this.chipsData.length >= this.options.limit) { 7972 return; 7973 } 7974 7975 var renderedChip = this._renderChip(chip); 7976 this.$chips.add(renderedChip); 7977 this.chipsData.push(chip); 7978 $(this.$input).before(renderedChip); 7979 this._setPlaceholder(); 7980 7981 // fire chipAdd callback 7982 if (typeof this.options.onChipAdd === 'function') { 7983 this.options.onChipAdd.call(this, this.$el, renderedChip); 7984 } 7985 } 7986 7987 /** 7988 * Delete chip 7989 * @param {Number} chip 7990 */ 7991 7992 }, { 7993 key: "deleteChip", 7994 value: function deleteChip(chipIndex) { 7995 var $chip = this.$chips.eq(chipIndex); 7996 this.$chips.eq(chipIndex).remove(); 7997 this.$chips = this.$chips.filter(function (el) { 7998 return $(el).index() >= 0; 7999 }); 8000 this.chipsData.splice(chipIndex, 1); 8001 this._setPlaceholder(); 8002 8003 // fire chipDelete callback 8004 if (typeof this.options.onChipDelete === 'function') { 8005 this.options.onChipDelete.call(this, this.$el, $chip[0]); 8006 } 8007 } 8008 8009 /** 8010 * Select chip 8011 * @param {Number} chip 8012 */ 8013 8014 }, { 8015 key: "selectChip", 8016 value: function selectChip(chipIndex) { 8017 var $chip = this.$chips.eq(chipIndex); 8018 this._selectedChip = $chip; 8019 $chip[0].focus(); 8020 8021 // fire chipSelect callback 8022 if (typeof this.options.onChipSelect === 'function') { 8023 this.options.onChipSelect.call(this, this.$el, $chip[0]); 8024 } 8025 } 8026 }], [{ 8027 key: "init", 8028 value: function init(els, options) { 8029 return _get(Chips.__proto__ || Object.getPrototypeOf(Chips), "init", this).call(this, this, els, options); 8030 } 8031 8032 /** 8033 * Get Instance 8034 */ 8035 8036 }, { 8037 key: "getInstance", 8038 value: function getInstance(el) { 8039 var domElem = !!el.jquery ? el[0] : el; 8040 return domElem.M_Chips; 8041 } 8042 }, { 8043 key: "_handleChipsKeydown", 8044 value: function _handleChipsKeydown(e) { 8045 Chips._keydown = true; 8046 8047 var $chips = $(e.target).closest('.chips'); 8048 var chipsKeydown = e.target && $chips.length; 8049 8050 // Don't handle keydown inputs on input and textarea 8051 if ($(e.target).is('input, textarea') || !chipsKeydown) { 8052 return; 8053 } 8054 8055 var currChips = $chips[0].M_Chips; 8056 8057 // backspace and delete 8058 if (e.keyCode === 8 || e.keyCode === 46) { 8059 e.preventDefault(); 8060 8061 var selectIndex = currChips.chipsData.length; 8062 if (currChips._selectedChip) { 8063 var index = currChips._selectedChip.index(); 8064 currChips.deleteChip(index); 8065 currChips._selectedChip = null; 8066 8067 // Make sure selectIndex doesn't go negative 8068 selectIndex = Math.max(index - 1, 0); 8069 } 8070 8071 if (currChips.chipsData.length) { 8072 currChips.selectChip(selectIndex); 8073 } 8074 8075 // left arrow key 8076 } else if (e.keyCode === 37) { 8077 if (currChips._selectedChip) { 8078 var _selectIndex = currChips._selectedChip.index() - 1; 8079 if (_selectIndex < 0) { 8080 return; 8081 } 8082 currChips.selectChip(_selectIndex); 8083 } 8084 8085 // right arrow key 8086 } else if (e.keyCode === 39) { 8087 if (currChips._selectedChip) { 8088 var _selectIndex2 = currChips._selectedChip.index() + 1; 8089 8090 if (_selectIndex2 >= currChips.chipsData.length) { 8091 currChips.$input[0].focus(); 8092 } else { 8093 currChips.selectChip(_selectIndex2); 8094 } 8095 } 8096 } 8097 } 8098 8099 /** 8100 * Handle Chips Keyup 8101 * @param {Event} e 8102 */ 8103 8104 }, { 8105 key: "_handleChipsKeyup", 8106 value: function _handleChipsKeyup(e) { 8107 Chips._keydown = false; 8108 } 8109 8110 /** 8111 * Handle Chips Blur 8112 * @param {Event} e 8113 */ 8114 8115 }, { 8116 key: "_handleChipsBlur", 8117 value: function _handleChipsBlur(e) { 8118 if (!Chips._keydown) { 8119 var $chips = $(e.target).closest('.chips'); 8120 var currChips = $chips[0].M_Chips; 8121 8122 currChips._selectedChip = null; 8123 } 8124 } 8125 }, { 8126 key: "defaults", 8127 get: function () { 8128 return _defaults; 8129 } 8130 }]); 8131 8132 return Chips; 8133 }(Component); 8134 8135 /** 8136 * @static 8137 * @memberof Chips 8138 */ 8139 8140 8141 Chips._keydown = false; 8142 8143 M.Chips = Chips; 8144 8145 if (M.jQueryLoaded) { 8146 M.initializeJqueryWrapper(Chips, 'chips', 'M_Chips'); 8147 } 8148 8149 $(document).ready(function () { 8150 // Handle removal of static chips. 8151 $(document.body).on('click', '.chip .close', function () { 8152 var $chips = $(this).closest('.chips'); 8153 if ($chips.length && $chips[0].M_Chips) { 8154 return; 8155 } 8156 $(this).closest('.chip').remove(); 8157 }); 8158 }); 8159})(cash); 8160;(function ($) { 8161 'use strict'; 8162 8163 var _defaults = { 8164 top: 0, 8165 bottom: Infinity, 8166 offset: 0, 8167 onPositionChange: null 8168 }; 8169 8170 /** 8171 * @class 8172 * 8173 */ 8174 8175 var Pushpin = function (_Component13) { 8176 _inherits(Pushpin, _Component13); 8177 8178 /** 8179 * Construct Pushpin instance 8180 * @constructor 8181 * @param {Element} el 8182 * @param {Object} options 8183 */ 8184 function Pushpin(el, options) { 8185 _classCallCheck(this, Pushpin); 8186 8187 var _this47 = _possibleConstructorReturn(this, (Pushpin.__proto__ || Object.getPrototypeOf(Pushpin)).call(this, Pushpin, el, options)); 8188 8189 _this47.el.M_Pushpin = _this47; 8190 8191 /** 8192 * Options for the modal 8193 * @member Pushpin#options 8194 */ 8195 _this47.options = $.extend({}, Pushpin.defaults, options); 8196 8197 _this47.originalOffset = _this47.el.offsetTop; 8198 Pushpin._pushpins.push(_this47); 8199 _this47._setupEventHandlers(); 8200 _this47._updatePosition(); 8201 return _this47; 8202 } 8203 8204 _createClass(Pushpin, [{ 8205 key: "destroy", 8206 8207 8208 /** 8209 * Teardown component 8210 */ 8211 value: function destroy() { 8212 this.el.style.top = null; 8213 this._removePinClasses(); 8214 this._removeEventHandlers(); 8215 8216 // Remove pushpin Inst 8217 var index = Pushpin._pushpins.indexOf(this); 8218 Pushpin._pushpins.splice(index, 1); 8219 } 8220 }, { 8221 key: "_setupEventHandlers", 8222 value: function _setupEventHandlers() { 8223 document.addEventListener('scroll', Pushpin._updateElements); 8224 } 8225 }, { 8226 key: "_removeEventHandlers", 8227 value: function _removeEventHandlers() { 8228 document.removeEventListener('scroll', Pushpin._updateElements); 8229 } 8230 }, { 8231 key: "_updatePosition", 8232 value: function _updatePosition() { 8233 var scrolled = M.getDocumentScrollTop() + this.options.offset; 8234 8235 if (this.options.top <= scrolled && this.options.bottom >= scrolled && !this.el.classList.contains('pinned')) { 8236 this._removePinClasses(); 8237 this.el.style.top = this.options.offset + "px"; 8238 this.el.classList.add('pinned'); 8239 8240 // onPositionChange callback 8241 if (typeof this.options.onPositionChange === 'function') { 8242 this.options.onPositionChange.call(this, 'pinned'); 8243 } 8244 } 8245 8246 // Add pin-top (when scrolled position is above top) 8247 if (scrolled < this.options.top && !this.el.classList.contains('pin-top')) { 8248 this._removePinClasses(); 8249 this.el.style.top = 0; 8250 this.el.classList.add('pin-top'); 8251 8252 // onPositionChange callback 8253 if (typeof this.options.onPositionChange === 'function') { 8254 this.options.onPositionChange.call(this, 'pin-top'); 8255 } 8256 } 8257 8258 // Add pin-bottom (when scrolled position is below bottom) 8259 if (scrolled > this.options.bottom && !this.el.classList.contains('pin-bottom')) { 8260 this._removePinClasses(); 8261 this.el.classList.add('pin-bottom'); 8262 this.el.style.top = this.options.bottom - this.originalOffset + "px"; 8263 8264 // onPositionChange callback 8265 if (typeof this.options.onPositionChange === 'function') { 8266 this.options.onPositionChange.call(this, 'pin-bottom'); 8267 } 8268 } 8269 } 8270 }, { 8271 key: "_removePinClasses", 8272 value: function _removePinClasses() { 8273 // IE 11 bug (can't remove multiple classes in one line) 8274 this.el.classList.remove('pin-top'); 8275 this.el.classList.remove('pinned'); 8276 this.el.classList.remove('pin-bottom'); 8277 } 8278 }], [{ 8279 key: "init", 8280 value: function init(els, options) { 8281 return _get(Pushpin.__proto__ || Object.getPrototypeOf(Pushpin), "init", this).call(this, this, els, options); 8282 } 8283 8284 /** 8285 * Get Instance 8286 */ 8287 8288 }, { 8289 key: "getInstance", 8290 value: function getInstance(el) { 8291 var domElem = !!el.jquery ? el[0] : el; 8292 return domElem.M_Pushpin; 8293 } 8294 }, { 8295 key: "_updateElements", 8296 value: function _updateElements() { 8297 for (var elIndex in Pushpin._pushpins) { 8298 var pInstance = Pushpin._pushpins[elIndex]; 8299 pInstance._updatePosition(); 8300 } 8301 } 8302 }, { 8303 key: "defaults", 8304 get: function () { 8305 return _defaults; 8306 } 8307 }]); 8308 8309 return Pushpin; 8310 }(Component); 8311 8312 /** 8313 * @static 8314 * @memberof Pushpin 8315 */ 8316 8317 8318 Pushpin._pushpins = []; 8319 8320 M.Pushpin = Pushpin; 8321 8322 if (M.jQueryLoaded) { 8323 M.initializeJqueryWrapper(Pushpin, 'pushpin', 'M_Pushpin'); 8324 } 8325})(cash); 8326;(function ($, anim) { 8327 'use strict'; 8328 8329 var _defaults = { 8330 direction: 'top', 8331 hoverEnabled: true, 8332 toolbarEnabled: false 8333 }; 8334 8335 $.fn.reverse = [].reverse; 8336 8337 /** 8338 * @class 8339 * 8340 */ 8341 8342 var FloatingActionButton = function (_Component14) { 8343 _inherits(FloatingActionButton, _Component14); 8344 8345 /** 8346 * Construct FloatingActionButton instance 8347 * @constructor 8348 * @param {Element} el 8349 * @param {Object} options 8350 */ 8351 function FloatingActionButton(el, options) { 8352 _classCallCheck(this, FloatingActionButton); 8353 8354 var _this48 = _possibleConstructorReturn(this, (FloatingActionButton.__proto__ || Object.getPrototypeOf(FloatingActionButton)).call(this, FloatingActionButton, el, options)); 8355 8356 _this48.el.M_FloatingActionButton = _this48; 8357 8358 /** 8359 * Options for the fab 8360 * @member FloatingActionButton#options 8361 * @prop {Boolean} [direction] - Direction fab menu opens 8362 * @prop {Boolean} [hoverEnabled=true] - Enable hover vs click 8363 * @prop {Boolean} [toolbarEnabled=false] - Enable toolbar transition 8364 */ 8365 _this48.options = $.extend({}, FloatingActionButton.defaults, options); 8366 8367 _this48.isOpen = false; 8368 _this48.$anchor = _this48.$el.children('a').first(); 8369 _this48.$menu = _this48.$el.children('ul').first(); 8370 _this48.$floatingBtns = _this48.$el.find('ul .btn-floating'); 8371 _this48.$floatingBtnsReverse = _this48.$el.find('ul .btn-floating').reverse(); 8372 _this48.offsetY = 0; 8373 _this48.offsetX = 0; 8374 8375 _this48.$el.addClass("direction-" + _this48.options.direction); 8376 if (_this48.options.direction === 'top') { 8377 _this48.offsetY = 40; 8378 } else if (_this48.options.direction === 'right') { 8379 _this48.offsetX = -40; 8380 } else if (_this48.options.direction === 'bottom') { 8381 _this48.offsetY = -40; 8382 } else { 8383 _this48.offsetX = 40; 8384 } 8385 _this48._setupEventHandlers(); 8386 return _this48; 8387 } 8388 8389 _createClass(FloatingActionButton, [{ 8390 key: "destroy", 8391 8392 8393 /** 8394 * Teardown component 8395 */ 8396 value: function destroy() { 8397 this._removeEventHandlers(); 8398 this.el.M_FloatingActionButton = undefined; 8399 } 8400 8401 /** 8402 * Setup Event Handlers 8403 */ 8404 8405 }, { 8406 key: "_setupEventHandlers", 8407 value: function _setupEventHandlers() { 8408 this._handleFABClickBound = this._handleFABClick.bind(this); 8409 this._handleOpenBound = this.open.bind(this); 8410 this._handleCloseBound = this.close.bind(this); 8411 8412 if (this.options.hoverEnabled && !this.options.toolbarEnabled) { 8413 this.el.addEventListener('mouseenter', this._handleOpenBound); 8414 this.el.addEventListener('mouseleave', this._handleCloseBound); 8415 } else { 8416 this.el.addEventListener('click', this._handleFABClickBound); 8417 } 8418 } 8419 8420 /** 8421 * Remove Event Handlers 8422 */ 8423 8424 }, { 8425 key: "_removeEventHandlers", 8426 value: function _removeEventHandlers() { 8427 if (this.options.hoverEnabled && !this.options.toolbarEnabled) { 8428 this.el.removeEventListener('mouseenter', this._handleOpenBound); 8429 this.el.removeEventListener('mouseleave', this._handleCloseBound); 8430 } else { 8431 this.el.removeEventListener('click', this._handleFABClickBound); 8432 } 8433 } 8434 8435 /** 8436 * Handle FAB Click 8437 */ 8438 8439 }, { 8440 key: "_handleFABClick", 8441 value: function _handleFABClick() { 8442 if (this.isOpen) { 8443 this.close(); 8444 } else { 8445 this.open(); 8446 } 8447 } 8448 8449 /** 8450 * Handle Document Click 8451 * @param {Event} e 8452 */ 8453 8454 }, { 8455 key: "_handleDocumentClick", 8456 value: function _handleDocumentClick(e) { 8457 if (!$(e.target).closest(this.$menu).length) { 8458 this.close(); 8459 } 8460 } 8461 8462 /** 8463 * Open FAB 8464 */ 8465 8466 }, { 8467 key: "open", 8468 value: function open() { 8469 if (this.isOpen) { 8470 return; 8471 } 8472 8473 if (this.options.toolbarEnabled) { 8474 this._animateInToolbar(); 8475 } else { 8476 this._animateInFAB(); 8477 } 8478 this.isOpen = true; 8479 } 8480 8481 /** 8482 * Close FAB 8483 */ 8484 8485 }, { 8486 key: "close", 8487 value: function close() { 8488 if (!this.isOpen) { 8489 return; 8490 } 8491 8492 if (this.options.toolbarEnabled) { 8493 window.removeEventListener('scroll', this._handleCloseBound, true); 8494 document.body.removeEventListener('click', this._handleDocumentClickBound, true); 8495 this._animateOutToolbar(); 8496 } else { 8497 this._animateOutFAB(); 8498 } 8499 this.isOpen = false; 8500 } 8501 8502 /** 8503 * Classic FAB Menu open 8504 */ 8505 8506 }, { 8507 key: "_animateInFAB", 8508 value: function _animateInFAB() { 8509 var _this49 = this; 8510 8511 this.$el.addClass('active'); 8512 8513 var time = 0; 8514 this.$floatingBtnsReverse.each(function (el) { 8515 anim({ 8516 targets: el, 8517 opacity: 1, 8518 scale: [0.4, 1], 8519 translateY: [_this49.offsetY, 0], 8520 translateX: [_this49.offsetX, 0], 8521 duration: 275, 8522 delay: time, 8523 easing: 'easeInOutQuad' 8524 }); 8525 time += 40; 8526 }); 8527 } 8528 8529 /** 8530 * Classic FAB Menu close 8531 */ 8532 8533 }, { 8534 key: "_animateOutFAB", 8535 value: function _animateOutFAB() { 8536 var _this50 = this; 8537 8538 this.$floatingBtnsReverse.each(function (el) { 8539 anim.remove(el); 8540 anim({ 8541 targets: el, 8542 opacity: 0, 8543 scale: 0.4, 8544 translateY: _this50.offsetY, 8545 translateX: _this50.offsetX, 8546 duration: 175, 8547 easing: 'easeOutQuad', 8548 complete: function () { 8549 _this50.$el.removeClass('active'); 8550 } 8551 }); 8552 }); 8553 } 8554 8555 /** 8556 * Toolbar transition Menu open 8557 */ 8558 8559 }, { 8560 key: "_animateInToolbar", 8561 value: function _animateInToolbar() { 8562 var _this51 = this; 8563 8564 var scaleFactor = void 0; 8565 var windowWidth = window.innerWidth; 8566 var windowHeight = window.innerHeight; 8567 var btnRect = this.el.getBoundingClientRect(); 8568 var backdrop = $('<div class="fab-backdrop"></div>'); 8569 var fabColor = this.$anchor.css('background-color'); 8570 this.$anchor.append(backdrop); 8571 8572 this.offsetX = btnRect.left - windowWidth / 2 + btnRect.width / 2; 8573 this.offsetY = windowHeight - btnRect.bottom; 8574 scaleFactor = windowWidth / backdrop[0].clientWidth; 8575 this.btnBottom = btnRect.bottom; 8576 this.btnLeft = btnRect.left; 8577 this.btnWidth = btnRect.width; 8578 8579 // Set initial state 8580 this.$el.addClass('active'); 8581 this.$el.css({ 8582 'text-align': 'center', 8583 width: '100%', 8584 bottom: 0, 8585 left: 0, 8586 transform: 'translateX(' + this.offsetX + 'px)', 8587 transition: 'none' 8588 }); 8589 this.$anchor.css({ 8590 transform: 'translateY(' + -this.offsetY + 'px)', 8591 transition: 'none' 8592 }); 8593 backdrop.css({ 8594 'background-color': fabColor 8595 }); 8596 8597 setTimeout(function () { 8598 _this51.$el.css({ 8599 transform: '', 8600 transition: 'transform .2s cubic-bezier(0.550, 0.085, 0.680, 0.530), background-color 0s linear .2s' 8601 }); 8602 _this51.$anchor.css({ 8603 overflow: 'visible', 8604 transform: '', 8605 transition: 'transform .2s' 8606 }); 8607 8608 setTimeout(function () { 8609 _this51.$el.css({ 8610 overflow: 'hidden', 8611 'background-color': fabColor 8612 }); 8613 backdrop.css({ 8614 transform: 'scale(' + scaleFactor + ')', 8615 transition: 'transform .2s cubic-bezier(0.550, 0.055, 0.675, 0.190)' 8616 }); 8617 _this51.$menu.children('li').children('a').css({ 8618 opacity: 1 8619 }); 8620 8621 // Scroll to close. 8622 _this51._handleDocumentClickBound = _this51._handleDocumentClick.bind(_this51); 8623 window.addEventListener('scroll', _this51._handleCloseBound, true); 8624 document.body.addEventListener('click', _this51._handleDocumentClickBound, true); 8625 }, 100); 8626 }, 0); 8627 } 8628 8629 /** 8630 * Toolbar transition Menu close 8631 */ 8632 8633 }, { 8634 key: "_animateOutToolbar", 8635 value: function _animateOutToolbar() { 8636 var _this52 = this; 8637 8638 var windowWidth = window.innerWidth; 8639 var windowHeight = window.innerHeight; 8640 var backdrop = this.$el.find('.fab-backdrop'); 8641 var fabColor = this.$anchor.css('background-color'); 8642 8643 this.offsetX = this.btnLeft - windowWidth / 2 + this.btnWidth / 2; 8644 this.offsetY = windowHeight - this.btnBottom; 8645 8646 // Hide backdrop 8647 this.$el.removeClass('active'); 8648 this.$el.css({ 8649 'background-color': 'transparent', 8650 transition: 'none' 8651 }); 8652 this.$anchor.css({ 8653 transition: 'none' 8654 }); 8655 backdrop.css({ 8656 transform: 'scale(0)', 8657 'background-color': fabColor 8658 }); 8659 this.$menu.children('li').children('a').css({ 8660 opacity: '' 8661 }); 8662 8663 setTimeout(function () { 8664 backdrop.remove(); 8665 8666 // Set initial state. 8667 _this52.$el.css({ 8668 'text-align': '', 8669 width: '', 8670 bottom: '', 8671 left: '', 8672 overflow: '', 8673 'background-color': '', 8674 transform: 'translate3d(' + -_this52.offsetX + 'px,0,0)' 8675 }); 8676 _this52.$anchor.css({ 8677 overflow: '', 8678 transform: 'translate3d(0,' + _this52.offsetY + 'px,0)' 8679 }); 8680 8681 setTimeout(function () { 8682 _this52.$el.css({ 8683 transform: 'translate3d(0,0,0)', 8684 transition: 'transform .2s' 8685 }); 8686 _this52.$anchor.css({ 8687 transform: 'translate3d(0,0,0)', 8688 transition: 'transform .2s cubic-bezier(0.550, 0.055, 0.675, 0.190)' 8689 }); 8690 }, 20); 8691 }, 200); 8692 } 8693 }], [{ 8694 key: "init", 8695 value: function init(els, options) { 8696 return _get(FloatingActionButton.__proto__ || Object.getPrototypeOf(FloatingActionButton), "init", this).call(this, this, els, options); 8697 } 8698 8699 /** 8700 * Get Instance 8701 */ 8702 8703 }, { 8704 key: "getInstance", 8705 value: function getInstance(el) { 8706 var domElem = !!el.jquery ? el[0] : el; 8707 return domElem.M_FloatingActionButton; 8708 } 8709 }, { 8710 key: "defaults", 8711 get: function () { 8712 return _defaults; 8713 } 8714 }]); 8715 8716 return FloatingActionButton; 8717 }(Component); 8718 8719 M.FloatingActionButton = FloatingActionButton; 8720 8721 if (M.jQueryLoaded) { 8722 M.initializeJqueryWrapper(FloatingActionButton, 'floatingActionButton', 'M_FloatingActionButton'); 8723 } 8724})(cash, M.anime); 8725;(function ($) { 8726 'use strict'; 8727 8728 var _defaults = { 8729 // Close when date is selected 8730 autoClose: false, 8731 8732 // the default output format for the input field value 8733 format: 'mmm dd, yyyy', 8734 8735 // Used to create date object from current input string 8736 parse: null, 8737 8738 // The initial date to view when first opened 8739 defaultDate: null, 8740 8741 // Make the `defaultDate` the initial selected value 8742 setDefaultDate: false, 8743 8744 disableWeekends: false, 8745 8746 disableDayFn: null, 8747 8748 // First day of week (0: Sunday, 1: Monday etc) 8749 firstDay: 0, 8750 8751 // The earliest date that can be selected 8752 minDate: null, 8753 // Thelatest date that can be selected 8754 maxDate: null, 8755 8756 // Number of years either side, or array of upper/lower range 8757 yearRange: 10, 8758 8759 // used internally (don't config outside) 8760 minYear: 0, 8761 maxYear: 9999, 8762 minMonth: undefined, 8763 maxMonth: undefined, 8764 8765 startRange: null, 8766 endRange: null, 8767 8768 isRTL: false, 8769 8770 // Render the month after year in the calendar title 8771 showMonthAfterYear: false, 8772 8773 // Render days of the calendar grid that fall in the next or previous month 8774 showDaysInNextAndPreviousMonths: false, 8775 8776 // Specify a DOM element to render the calendar in 8777 container: null, 8778 8779 // Show clear button 8780 showClearBtn: false, 8781 8782 // internationalization 8783 i18n: { 8784 cancel: 'Cancel', 8785 clear: 'Clear', 8786 done: 'Ok', 8787 previousMonth: '‹', 8788 nextMonth: '›', 8789 months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], 8790 monthsShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], 8791 weekdays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], 8792 weekdaysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], 8793 weekdaysAbbrev: ['S', 'M', 'T', 'W', 'T', 'F', 'S'] 8794 }, 8795 8796 // events array 8797 events: [], 8798 8799 // callback function 8800 onSelect: null, 8801 onOpen: null, 8802 onClose: null, 8803 onDraw: null 8804 }; 8805 8806 /** 8807 * @class 8808 * 8809 */ 8810 8811 var Datepicker = function (_Component15) { 8812 _inherits(Datepicker, _Component15); 8813 8814 /** 8815 * Construct Datepicker instance and set up overlay 8816 * @constructor 8817 * @param {Element} el 8818 * @param {Object} options 8819 */ 8820 function Datepicker(el, options) { 8821 _classCallCheck(this, Datepicker); 8822 8823 var _this53 = _possibleConstructorReturn(this, (Datepicker.__proto__ || Object.getPrototypeOf(Datepicker)).call(this, Datepicker, el, options)); 8824 8825 _this53.el.M_Datepicker = _this53; 8826 8827 _this53.options = $.extend({}, Datepicker.defaults, options); 8828 8829 // make sure i18n defaults are not lost when only few i18n option properties are passed 8830 if (!!options && options.hasOwnProperty('i18n') && typeof options.i18n === 'object') { 8831 _this53.options.i18n = $.extend({}, Datepicker.defaults.i18n, options.i18n); 8832 } 8833 8834 // Remove time component from minDate and maxDate options 8835 if (_this53.options.minDate) _this53.options.minDate.setHours(0, 0, 0, 0); 8836 if (_this53.options.maxDate) _this53.options.maxDate.setHours(0, 0, 0, 0); 8837 8838 _this53.id = M.guid(); 8839 8840 _this53._setupVariables(); 8841 _this53._insertHTMLIntoDOM(); 8842 _this53._setupModal(); 8843 8844 _this53._setupEventHandlers(); 8845 8846 if (!_this53.options.defaultDate) { 8847 _this53.options.defaultDate = new Date(Date.parse(_this53.el.value)); 8848 } 8849 8850 var defDate = _this53.options.defaultDate; 8851 if (Datepicker._isDate(defDate)) { 8852 if (_this53.options.setDefaultDate) { 8853 _this53.setDate(defDate, true); 8854 _this53.setInputValue(); 8855 } else { 8856 _this53.gotoDate(defDate); 8857 } 8858 } else { 8859 _this53.gotoDate(new Date()); 8860 } 8861 8862 /** 8863 * Describes open/close state of datepicker 8864 * @type {Boolean} 8865 */ 8866 _this53.isOpen = false; 8867 return _this53; 8868 } 8869 8870 _createClass(Datepicker, [{ 8871 key: "destroy", 8872 8873 8874 /** 8875 * Teardown component 8876 */ 8877 value: function destroy() { 8878 this._removeEventHandlers(); 8879 this.modal.destroy(); 8880 $(this.modalEl).remove(); 8881 this.destroySelects(); 8882 this.el.M_Datepicker = undefined; 8883 } 8884 }, { 8885 key: "destroySelects", 8886 value: function destroySelects() { 8887 var oldYearSelect = this.calendarEl.querySelector('.orig-select-year'); 8888 if (oldYearSelect) { 8889 M.FormSelect.getInstance(oldYearSelect).destroy(); 8890 } 8891 var oldMonthSelect = this.calendarEl.querySelector('.orig-select-month'); 8892 if (oldMonthSelect) { 8893 M.FormSelect.getInstance(oldMonthSelect).destroy(); 8894 } 8895 } 8896 }, { 8897 key: "_insertHTMLIntoDOM", 8898 value: function _insertHTMLIntoDOM() { 8899 if (this.options.showClearBtn) { 8900 $(this.clearBtn).css({ visibility: '' }); 8901 this.clearBtn.innerHTML = this.options.i18n.clear; 8902 } 8903 8904 this.doneBtn.innerHTML = this.options.i18n.done; 8905 this.cancelBtn.innerHTML = this.options.i18n.cancel; 8906 8907 if (this.options.container) { 8908 this.$modalEl.appendTo(this.options.container); 8909 } else { 8910 this.$modalEl.insertBefore(this.el); 8911 } 8912 } 8913 }, { 8914 key: "_setupModal", 8915 value: function _setupModal() { 8916 var _this54 = this; 8917 8918 this.modalEl.id = 'modal-' + this.id; 8919 this.modal = M.Modal.init(this.modalEl, { 8920 onCloseEnd: function () { 8921 _this54.isOpen = false; 8922 } 8923 }); 8924 } 8925 }, { 8926 key: "toString", 8927 value: function toString(format) { 8928 var _this55 = this; 8929 8930 format = format || this.options.format; 8931 if (!Datepicker._isDate(this.date)) { 8932 return ''; 8933 } 8934 8935 var formatArray = format.split(/(d{1,4}|m{1,4}|y{4}|yy|!.)/g); 8936 var formattedDate = formatArray.map(function (label) { 8937 if (_this55.formats[label]) { 8938 return _this55.formats[label](); 8939 } 8940 8941 return label; 8942 }).join(''); 8943 return formattedDate; 8944 } 8945 }, { 8946 key: "setDate", 8947 value: function setDate(date, preventOnSelect) { 8948 if (!date) { 8949 this.date = null; 8950 this._renderDateDisplay(); 8951 return this.draw(); 8952 } 8953 if (typeof date === 'string') { 8954 date = new Date(Date.parse(date)); 8955 } 8956 if (!Datepicker._isDate(date)) { 8957 return; 8958 } 8959 8960 var min = this.options.minDate, 8961 max = this.options.maxDate; 8962 8963 if (Datepicker._isDate(min) && date < min) { 8964 date = min; 8965 } else if (Datepicker._isDate(max) && date > max) { 8966 date = max; 8967 } 8968 8969 this.date = new Date(date.getTime()); 8970 8971 this._renderDateDisplay(); 8972 8973 Datepicker._setToStartOfDay(this.date); 8974 this.gotoDate(this.date); 8975 8976 if (!preventOnSelect && typeof this.options.onSelect === 'function') { 8977 this.options.onSelect.call(this, this.date); 8978 } 8979 } 8980 }, { 8981 key: "setInputValue", 8982 value: function setInputValue() { 8983 this.el.value = this.toString(); 8984 this.$el.trigger('change', { firedBy: this }); 8985 } 8986 }, { 8987 key: "_renderDateDisplay", 8988 value: function _renderDateDisplay() { 8989 var displayDate = Datepicker._isDate(this.date) ? this.date : new Date(); 8990 var i18n = this.options.i18n; 8991 var day = i18n.weekdaysShort[displayDate.getDay()]; 8992 var month = i18n.monthsShort[displayDate.getMonth()]; 8993 var date = displayDate.getDate(); 8994 this.yearTextEl.innerHTML = displayDate.getFullYear(); 8995 this.dateTextEl.innerHTML = day + ", " + month + " " + date; 8996 } 8997 8998 /** 8999 * change view to a specific date 9000 */ 9001 9002 }, { 9003 key: "gotoDate", 9004 value: function gotoDate(date) { 9005 var newCalendar = true; 9006 9007 if (!Datepicker._isDate(date)) { 9008 return; 9009 } 9010 9011 if (this.calendars) { 9012 var firstVisibleDate = new Date(this.calendars[0].year, this.calendars[0].month, 1), 9013 lastVisibleDate = new Date(this.calendars[this.calendars.length - 1].year, this.calendars[this.calendars.length - 1].month, 1), 9014 visibleDate = date.getTime(); 9015 // get the end of the month 9016 lastVisibleDate.setMonth(lastVisibleDate.getMonth() + 1); 9017 lastVisibleDate.setDate(lastVisibleDate.getDate() - 1); 9018 newCalendar = visibleDate < firstVisibleDate.getTime() || lastVisibleDate.getTime() < visibleDate; 9019 } 9020 9021 if (newCalendar) { 9022 this.calendars = [{ 9023 month: date.getMonth(), 9024 year: date.getFullYear() 9025 }]; 9026 } 9027 9028 this.adjustCalendars(); 9029 } 9030 }, { 9031 key: "adjustCalendars", 9032 value: function adjustCalendars() { 9033 this.calendars[0] = this.adjustCalendar(this.calendars[0]); 9034 this.draw(); 9035 } 9036 }, { 9037 key: "adjustCalendar", 9038 value: function adjustCalendar(calendar) { 9039 if (calendar.month < 0) { 9040 calendar.year -= Math.ceil(Math.abs(calendar.month) / 12); 9041 calendar.month += 12; 9042 } 9043 if (calendar.month > 11) { 9044 calendar.year += Math.floor(Math.abs(calendar.month) / 12); 9045 calendar.month -= 12; 9046 } 9047 return calendar; 9048 } 9049 }, { 9050 key: "nextMonth", 9051 value: function nextMonth() { 9052 this.calendars[0].month++; 9053 this.adjustCalendars(); 9054 } 9055 }, { 9056 key: "prevMonth", 9057 value: function prevMonth() { 9058 this.calendars[0].month--; 9059 this.adjustCalendars(); 9060 } 9061 }, { 9062 key: "render", 9063 value: function render(year, month, randId) { 9064 var opts = this.options, 9065 now = new Date(), 9066 days = Datepicker._getDaysInMonth(year, month), 9067 before = new Date(year, month, 1).getDay(), 9068 data = [], 9069 row = []; 9070 Datepicker._setToStartOfDay(now); 9071 if (opts.firstDay > 0) { 9072 before -= opts.firstDay; 9073 if (before < 0) { 9074 before += 7; 9075 } 9076 } 9077 var previousMonth = month === 0 ? 11 : month - 1, 9078 nextMonth = month === 11 ? 0 : month + 1, 9079 yearOfPreviousMonth = month === 0 ? year - 1 : year, 9080 yearOfNextMonth = month === 11 ? year + 1 : year, 9081 daysInPreviousMonth = Datepicker._getDaysInMonth(yearOfPreviousMonth, previousMonth); 9082 var cells = days + before, 9083 after = cells; 9084 while (after > 7) { 9085 after -= 7; 9086 } 9087 cells += 7 - after; 9088 var isWeekSelected = false; 9089 for (var i = 0, r = 0; i < cells; i++) { 9090 var day = new Date(year, month, 1 + (i - before)), 9091 isSelected = Datepicker._isDate(this.date) ? Datepicker._compareDates(day, this.date) : false, 9092 isToday = Datepicker._compareDates(day, now), 9093 hasEvent = opts.events.indexOf(day.toDateString()) !== -1 ? true : false, 9094 isEmpty = i < before || i >= days + before, 9095 dayNumber = 1 + (i - before), 9096 monthNumber = month, 9097 yearNumber = year, 9098 isStartRange = opts.startRange && Datepicker._compareDates(opts.startRange, day), 9099 isEndRange = opts.endRange && Datepicker._compareDates(opts.endRange, day), 9100 isInRange = opts.startRange && opts.endRange && opts.startRange < day && day < opts.endRange, 9101 isDisabled = opts.minDate && day < opts.minDate || opts.maxDate && day > opts.maxDate || opts.disableWeekends && Datepicker._isWeekend(day) || opts.disableDayFn && opts.disableDayFn(day); 9102 9103 if (isEmpty) { 9104 if (i < before) { 9105 dayNumber = daysInPreviousMonth + dayNumber; 9106 monthNumber = previousMonth; 9107 yearNumber = yearOfPreviousMonth; 9108 } else { 9109 dayNumber = dayNumber - days; 9110 monthNumber = nextMonth; 9111 yearNumber = yearOfNextMonth; 9112 } 9113 } 9114 9115 var dayConfig = { 9116 day: dayNumber, 9117 month: monthNumber, 9118 year: yearNumber, 9119 hasEvent: hasEvent, 9120 isSelected: isSelected, 9121 isToday: isToday, 9122 isDisabled: isDisabled, 9123 isEmpty: isEmpty, 9124 isStartRange: isStartRange, 9125 isEndRange: isEndRange, 9126 isInRange: isInRange, 9127 showDaysInNextAndPreviousMonths: opts.showDaysInNextAndPreviousMonths 9128 }; 9129 9130 row.push(this.renderDay(dayConfig)); 9131 9132 if (++r === 7) { 9133 data.push(this.renderRow(row, opts.isRTL, isWeekSelected)); 9134 row = []; 9135 r = 0; 9136 isWeekSelected = false; 9137 } 9138 } 9139 return this.renderTable(opts, data, randId); 9140 } 9141 }, { 9142 key: "renderDay", 9143 value: function renderDay(opts) { 9144 var arr = []; 9145 var ariaSelected = 'false'; 9146 if (opts.isEmpty) { 9147 if (opts.showDaysInNextAndPreviousMonths) { 9148 arr.push('is-outside-current-month'); 9149 arr.push('is-selection-disabled'); 9150 } else { 9151 return '<td class="is-empty"></td>'; 9152 } 9153 } 9154 if (opts.isDisabled) { 9155 arr.push('is-disabled'); 9156 } 9157 9158 if (opts.isToday) { 9159 arr.push('is-today'); 9160 } 9161 if (opts.isSelected) { 9162 arr.push('is-selected'); 9163 ariaSelected = 'true'; 9164 } 9165 if (opts.hasEvent) { 9166 arr.push('has-event'); 9167 } 9168 if (opts.isInRange) { 9169 arr.push('is-inrange'); 9170 } 9171 if (opts.isStartRange) { 9172 arr.push('is-startrange'); 9173 } 9174 if (opts.isEndRange) { 9175 arr.push('is-endrange'); 9176 } 9177 return "<td data-day=\"" + opts.day + "\" class=\"" + arr.join(' ') + "\" aria-selected=\"" + ariaSelected + "\">" + ("<button class=\"datepicker-day-button\" type=\"button\" data-year=\"" + opts.year + "\" data-month=\"" + opts.month + "\" data-day=\"" + opts.day + "\">" + opts.day + "</button>") + '</td>'; 9178 } 9179 }, { 9180 key: "renderRow", 9181 value: function renderRow(days, isRTL, isRowSelected) { 9182 return '<tr class="datepicker-row' + (isRowSelected ? ' is-selected' : '') + '">' + (isRTL ? days.reverse() : days).join('') + '</tr>'; 9183 } 9184 }, { 9185 key: "renderTable", 9186 value: function renderTable(opts, data, randId) { 9187 return '<div class="datepicker-table-wrapper"><table cellpadding="0" cellspacing="0" class="datepicker-table" role="grid" aria-labelledby="' + randId + '">' + this.renderHead(opts) + this.renderBody(data) + '</table></div>'; 9188 } 9189 }, { 9190 key: "renderHead", 9191 value: function renderHead(opts) { 9192 var i = void 0, 9193 arr = []; 9194 for (i = 0; i < 7; i++) { 9195 arr.push("<th scope=\"col\"><abbr title=\"" + this.renderDayName(opts, i) + "\">" + this.renderDayName(opts, i, true) + "</abbr></th>"); 9196 } 9197 return '<thead><tr>' + (opts.isRTL ? arr.reverse() : arr).join('') + '</tr></thead>'; 9198 } 9199 }, { 9200 key: "renderBody", 9201 value: function renderBody(rows) { 9202 return '<tbody>' + rows.join('') + '</tbody>'; 9203 } 9204 }, { 9205 key: "renderTitle", 9206 value: function renderTitle(instance, c, year, month, refYear, randId) { 9207 var i = void 0, 9208 j = void 0, 9209 arr = void 0, 9210 opts = this.options, 9211 isMinYear = year === opts.minYear, 9212 isMaxYear = year === opts.maxYear, 9213 html = '<div id="' + randId + '" class="datepicker-controls" role="heading" aria-live="assertive">', 9214 monthHtml = void 0, 9215 yearHtml = void 0, 9216 prev = true, 9217 next = true; 9218 9219 for (arr = [], i = 0; i < 12; i++) { 9220 arr.push('<option value="' + (year === refYear ? i - c : 12 + i - c) + '"' + (i === month ? ' selected="selected"' : '') + (isMinYear && i < opts.minMonth || isMaxYear && i > opts.maxMonth ? 'disabled="disabled"' : '') + '>' + opts.i18n.months[i] + '</option>'); 9221 } 9222 9223 monthHtml = '<select class="datepicker-select orig-select-month" tabindex="-1">' + arr.join('') + '</select>'; 9224 9225 if ($.isArray(opts.yearRange)) { 9226 i = opts.yearRange[0]; 9227 j = opts.yearRange[1] + 1; 9228 } else { 9229 i = year - opts.yearRange; 9230 j = 1 + year + opts.yearRange; 9231 } 9232 9233 for (arr = []; i < j && i <= opts.maxYear; i++) { 9234 if (i >= opts.minYear) { 9235 arr.push("<option value=\"" + i + "\" " + (i === year ? 'selected="selected"' : '') + ">" + i + "</option>"); 9236 } 9237 } 9238 9239 yearHtml = "<select class=\"datepicker-select orig-select-year\" tabindex=\"-1\">" + arr.join('') + "</select>"; 9240 9241 var leftArrow = '<svg fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M15.41 16.09l-4.58-4.59 4.58-4.59L14 5.5l-6 6 6 6z"/><path d="M0-.5h24v24H0z" fill="none"/></svg>'; 9242 html += "<button class=\"month-prev" + (prev ? '' : ' is-disabled') + "\" type=\"button\">" + leftArrow + "</button>"; 9243 9244 html += '<div class="selects-container">'; 9245 if (opts.showMonthAfterYear) { 9246 html += yearHtml + monthHtml; 9247 } else { 9248 html += monthHtml + yearHtml; 9249 } 9250 html += '</div>'; 9251 9252 if (isMinYear && (month === 0 || opts.minMonth >= month)) { 9253 prev = false; 9254 } 9255 9256 if (isMaxYear && (month === 11 || opts.maxMonth <= month)) { 9257 next = false; 9258 } 9259 9260 var rightArrow = '<svg fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M8.59 16.34l4.58-4.59-4.58-4.59L10 5.75l6 6-6 6z"/><path d="M0-.25h24v24H0z" fill="none"/></svg>'; 9261 html += "<button class=\"month-next" + (next ? '' : ' is-disabled') + "\" type=\"button\">" + rightArrow + "</button>"; 9262 9263 return html += '</div>'; 9264 } 9265 9266 /** 9267 * refresh the HTML 9268 */ 9269 9270 }, { 9271 key: "draw", 9272 value: function draw(force) { 9273 if (!this.isOpen && !force) { 9274 return; 9275 } 9276 var opts = this.options, 9277 minYear = opts.minYear, 9278 maxYear = opts.maxYear, 9279 minMonth = opts.minMonth, 9280 maxMonth = opts.maxMonth, 9281 html = '', 9282 randId = void 0; 9283 9284 if (this._y <= minYear) { 9285 this._y = minYear; 9286 if (!isNaN(minMonth) && this._m < minMonth) { 9287 this._m = minMonth; 9288 } 9289 } 9290 if (this._y >= maxYear) { 9291 this._y = maxYear; 9292 if (!isNaN(maxMonth) && this._m > maxMonth) { 9293 this._m = maxMonth; 9294 } 9295 } 9296 9297 randId = 'datepicker-title-' + Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 2); 9298 9299 for (var c = 0; c < 1; c++) { 9300 this._renderDateDisplay(); 9301 html += this.renderTitle(this, c, this.calendars[c].year, this.calendars[c].month, this.calendars[0].year, randId) + this.render(this.calendars[c].year, this.calendars[c].month, randId); 9302 } 9303 9304 this.destroySelects(); 9305 9306 this.calendarEl.innerHTML = html; 9307 9308 // Init Materialize Select 9309 var yearSelect = this.calendarEl.querySelector('.orig-select-year'); 9310 var monthSelect = this.calendarEl.querySelector('.orig-select-month'); 9311 M.FormSelect.init(yearSelect, { 9312 classes: 'select-year', 9313 dropdownOptions: { container: document.body, constrainWidth: false } 9314 }); 9315 M.FormSelect.init(monthSelect, { 9316 classes: 'select-month', 9317 dropdownOptions: { container: document.body, constrainWidth: false } 9318 }); 9319 9320 // Add change handlers for select 9321 yearSelect.addEventListener('change', this._handleYearChange.bind(this)); 9322 monthSelect.addEventListener('change', this._handleMonthChange.bind(this)); 9323 9324 if (typeof this.options.onDraw === 'function') { 9325 this.options.onDraw(this); 9326 } 9327 } 9328 9329 /** 9330 * Setup Event Handlers 9331 */ 9332 9333 }, { 9334 key: "_setupEventHandlers", 9335 value: function _setupEventHandlers() { 9336 this._handleInputKeydownBound = this._handleInputKeydown.bind(this); 9337 this._handleInputClickBound = this._handleInputClick.bind(this); 9338 this._handleInputChangeBound = this._handleInputChange.bind(this); 9339 this._handleCalendarClickBound = this._handleCalendarClick.bind(this); 9340 this._finishSelectionBound = this._finishSelection.bind(this); 9341 this._handleMonthChange = this._handleMonthChange.bind(this); 9342 this._closeBound = this.close.bind(this); 9343 9344 this.el.addEventListener('click', this._handleInputClickBound); 9345 this.el.addEventListener('keydown', this._handleInputKeydownBound); 9346 this.el.addEventListener('change', this._handleInputChangeBound); 9347 this.calendarEl.addEventListener('click', this._handleCalendarClickBound); 9348 this.doneBtn.addEventListener('click', this._finishSelectionBound); 9349 this.cancelBtn.addEventListener('click', this._closeBound); 9350 9351 if (this.options.showClearBtn) { 9352 this._handleClearClickBound = this._handleClearClick.bind(this); 9353 this.clearBtn.addEventListener('click', this._handleClearClickBound); 9354 } 9355 } 9356 }, { 9357 key: "_setupVariables", 9358 value: function _setupVariables() { 9359 var _this56 = this; 9360 9361 this.$modalEl = $(Datepicker._template); 9362 this.modalEl = this.$modalEl[0]; 9363 9364 this.calendarEl = this.modalEl.querySelector('.datepicker-calendar'); 9365 9366 this.yearTextEl = this.modalEl.querySelector('.year-text'); 9367 this.dateTextEl = this.modalEl.querySelector('.date-text'); 9368 if (this.options.showClearBtn) { 9369 this.clearBtn = this.modalEl.querySelector('.datepicker-clear'); 9370 } 9371 this.doneBtn = this.modalEl.querySelector('.datepicker-done'); 9372 this.cancelBtn = this.modalEl.querySelector('.datepicker-cancel'); 9373 9374 this.formats = { 9375 d: function () { 9376 return _this56.date.getDate(); 9377 }, 9378 dd: function () { 9379 var d = _this56.date.getDate(); 9380 return (d < 10 ? '0' : '') + d; 9381 }, 9382 ddd: function () { 9383 return _this56.options.i18n.weekdaysShort[_this56.date.getDay()]; 9384 }, 9385 dddd: function () { 9386 return _this56.options.i18n.weekdays[_this56.date.getDay()]; 9387 }, 9388 m: function () { 9389 return _this56.date.getMonth() + 1; 9390 }, 9391 mm: function () { 9392 var m = _this56.date.getMonth() + 1; 9393 return (m < 10 ? '0' : '') + m; 9394 }, 9395 mmm: function () { 9396 return _this56.options.i18n.monthsShort[_this56.date.getMonth()]; 9397 }, 9398 mmmm: function () { 9399 return _this56.options.i18n.months[_this56.date.getMonth()]; 9400 }, 9401 yy: function () { 9402 return ('' + _this56.date.getFullYear()).slice(2); 9403 }, 9404 yyyy: function () { 9405 return _this56.date.getFullYear(); 9406 } 9407 }; 9408 } 9409 9410 /** 9411 * Remove Event Handlers 9412 */ 9413 9414 }, { 9415 key: "_removeEventHandlers", 9416 value: function _removeEventHandlers() { 9417 this.el.removeEventListener('click', this._handleInputClickBound); 9418 this.el.removeEventListener('keydown', this._handleInputKeydownBound); 9419 this.el.removeEventListener('change', this._handleInputChangeBound); 9420 this.calendarEl.removeEventListener('click', this._handleCalendarClickBound); 9421 } 9422 }, { 9423 key: "_handleInputClick", 9424 value: function _handleInputClick() { 9425 this.open(); 9426 } 9427 }, { 9428 key: "_handleInputKeydown", 9429 value: function _handleInputKeydown(e) { 9430 if (e.which === M.keys.ENTER) { 9431 e.preventDefault(); 9432 this.open(); 9433 } 9434 } 9435 }, { 9436 key: "_handleCalendarClick", 9437 value: function _handleCalendarClick(e) { 9438 if (!this.isOpen) { 9439 return; 9440 } 9441 9442 var $target = $(e.target); 9443 if (!$target.hasClass('is-disabled')) { 9444 if ($target.hasClass('datepicker-day-button') && !$target.hasClass('is-empty') && !$target.parent().hasClass('is-disabled')) { 9445 this.setDate(new Date(e.target.getAttribute('data-year'), e.target.getAttribute('data-month'), e.target.getAttribute('data-day'))); 9446 if (this.options.autoClose) { 9447 this._finishSelection(); 9448 } 9449 } else if ($target.closest('.month-prev').length) { 9450 this.prevMonth(); 9451 } else if ($target.closest('.month-next').length) { 9452 this.nextMonth(); 9453 } 9454 } 9455 } 9456 }, { 9457 key: "_handleClearClick", 9458 value: function _handleClearClick() { 9459 this.date = null; 9460 this.setInputValue(); 9461 this.close(); 9462 } 9463 }, { 9464 key: "_handleMonthChange", 9465 value: function _handleMonthChange(e) { 9466 this.gotoMonth(e.target.value); 9467 } 9468 }, { 9469 key: "_handleYearChange", 9470 value: function _handleYearChange(e) { 9471 this.gotoYear(e.target.value); 9472 } 9473 9474 /** 9475 * change view to a specific month (zero-index, e.g. 0: January) 9476 */ 9477 9478 }, { 9479 key: "gotoMonth", 9480 value: function gotoMonth(month) { 9481 if (!isNaN(month)) { 9482 this.calendars[0].month = parseInt(month, 10); 9483 this.adjustCalendars(); 9484 } 9485 } 9486 9487 /** 9488 * change view to a specific full year (e.g. "2012") 9489 */ 9490 9491 }, { 9492 key: "gotoYear", 9493 value: function gotoYear(year) { 9494 if (!isNaN(year)) { 9495 this.calendars[0].year = parseInt(year, 10); 9496 this.adjustCalendars(); 9497 } 9498 } 9499 }, { 9500 key: "_handleInputChange", 9501 value: function _handleInputChange(e) { 9502 var date = void 0; 9503 9504 // Prevent change event from being fired when triggered by the plugin 9505 if (e.firedBy === this) { 9506 return; 9507 } 9508 if (this.options.parse) { 9509 date = this.options.parse(this.el.value, this.options.format); 9510 } else { 9511 date = new Date(Date.parse(this.el.value)); 9512 } 9513 9514 if (Datepicker._isDate(date)) { 9515 this.setDate(date); 9516 } 9517 } 9518 }, { 9519 key: "renderDayName", 9520 value: function renderDayName(opts, day, abbr) { 9521 day += opts.firstDay; 9522 while (day >= 7) { 9523 day -= 7; 9524 } 9525 return abbr ? opts.i18n.weekdaysAbbrev[day] : opts.i18n.weekdays[day]; 9526 } 9527 9528 /** 9529 * Set input value to the selected date and close Datepicker 9530 */ 9531 9532 }, { 9533 key: "_finishSelection", 9534 value: function _finishSelection() { 9535 this.setInputValue(); 9536 this.close(); 9537 } 9538 9539 /** 9540 * Open Datepicker 9541 */ 9542 9543 }, { 9544 key: "open", 9545 value: function open() { 9546 if (this.isOpen) { 9547 return; 9548 } 9549 9550 this.isOpen = true; 9551 if (typeof this.options.onOpen === 'function') { 9552 this.options.onOpen.call(this); 9553 } 9554 this.draw(); 9555 this.modal.open(); 9556 return this; 9557 } 9558 9559 /** 9560 * Close Datepicker 9561 */ 9562 9563 }, { 9564 key: "close", 9565 value: function close() { 9566 if (!this.isOpen) { 9567 return; 9568 } 9569 9570 this.isOpen = false; 9571 if (typeof this.options.onClose === 'function') { 9572 this.options.onClose.call(this); 9573 } 9574 this.modal.close(); 9575 return this; 9576 } 9577 }], [{ 9578 key: "init", 9579 value: function init(els, options) { 9580 return _get(Datepicker.__proto__ || Object.getPrototypeOf(Datepicker), "init", this).call(this, this, els, options); 9581 } 9582 }, { 9583 key: "_isDate", 9584 value: function _isDate(obj) { 9585 return (/Date/.test(Object.prototype.toString.call(obj)) && !isNaN(obj.getTime()) 9586 ); 9587 } 9588 }, { 9589 key: "_isWeekend", 9590 value: function _isWeekend(date) { 9591 var day = date.getDay(); 9592 return day === 0 || day === 6; 9593 } 9594 }, { 9595 key: "_setToStartOfDay", 9596 value: function _setToStartOfDay(date) { 9597 if (Datepicker._isDate(date)) date.setHours(0, 0, 0, 0); 9598 } 9599 }, { 9600 key: "_getDaysInMonth", 9601 value: function _getDaysInMonth(year, month) { 9602 return [31, Datepicker._isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; 9603 } 9604 }, { 9605 key: "_isLeapYear", 9606 value: function _isLeapYear(year) { 9607 // solution by Matti Virkkunen: http://stackoverflow.com/a/4881951 9608 return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0; 9609 } 9610 }, { 9611 key: "_compareDates", 9612 value: function _compareDates(a, b) { 9613 // weak date comparison (use setToStartOfDay(date) to ensure correct result) 9614 return a.getTime() === b.getTime(); 9615 } 9616 }, { 9617 key: "_setToStartOfDay", 9618 value: function _setToStartOfDay(date) { 9619 if (Datepicker._isDate(date)) date.setHours(0, 0, 0, 0); 9620 } 9621 9622 /** 9623 * Get Instance 9624 */ 9625 9626 }, { 9627 key: "getInstance", 9628 value: function getInstance(el) { 9629 var domElem = !!el.jquery ? el[0] : el; 9630 return domElem.M_Datepicker; 9631 } 9632 }, { 9633 key: "defaults", 9634 get: function () { 9635 return _defaults; 9636 } 9637 }]); 9638 9639 return Datepicker; 9640 }(Component); 9641 9642 Datepicker._template = ['<div class= "modal datepicker-modal">', '<div class="modal-content datepicker-container">', '<div class="datepicker-date-display">', '<span class="year-text"></span>', '<span class="date-text"></span>', '</div>', '<div class="datepicker-calendar-container">', '<div class="datepicker-calendar"></div>', '<div class="datepicker-footer">', '<button class="btn-flat datepicker-clear waves-effect" style="visibility: hidden;" type="button"></button>', '<div class="confirmation-btns">', '<button class="btn-flat datepicker-cancel waves-effect" type="button"></button>', '<button class="btn-flat datepicker-done waves-effect" type="button"></button>', '</div>', '</div>', '</div>', '</div>', '</div>'].join(''); 9643 9644 M.Datepicker = Datepicker; 9645 9646 if (M.jQueryLoaded) { 9647 M.initializeJqueryWrapper(Datepicker, 'datepicker', 'M_Datepicker'); 9648 } 9649})(cash); 9650;(function ($) { 9651 'use strict'; 9652 9653 var _defaults = { 9654 dialRadius: 135, 9655 outerRadius: 105, 9656 innerRadius: 70, 9657 tickRadius: 20, 9658 duration: 350, 9659 container: null, 9660 defaultTime: 'now', // default time, 'now' or '13:14' e.g. 9661 fromNow: 0, // Millisecond offset from the defaultTime 9662 showClearBtn: false, 9663 9664 // internationalization 9665 i18n: { 9666 cancel: 'Cancel', 9667 clear: 'Clear', 9668 done: 'Ok' 9669 }, 9670 9671 autoClose: false, // auto close when minute is selected 9672 twelveHour: true, // change to 12 hour AM/PM clock from 24 hour 9673 vibrate: true, // vibrate the device when dragging clock hand 9674 9675 // Callbacks 9676 onOpenStart: null, 9677 onOpenEnd: null, 9678 onCloseStart: null, 9679 onCloseEnd: null, 9680 onSelect: null 9681 }; 9682 9683 /** 9684 * @class 9685 * 9686 */ 9687 9688 var Timepicker = function (_Component16) { 9689 _inherits(Timepicker, _Component16); 9690 9691 function Timepicker(el, options) { 9692 _classCallCheck(this, Timepicker); 9693 9694 var _this57 = _possibleConstructorReturn(this, (Timepicker.__proto__ || Object.getPrototypeOf(Timepicker)).call(this, Timepicker, el, options)); 9695 9696 _this57.el.M_Timepicker = _this57; 9697 9698 _this57.options = $.extend({}, Timepicker.defaults, options); 9699 9700 _this57.id = M.guid(); 9701 _this57._insertHTMLIntoDOM(); 9702 _this57._setupModal(); 9703 _this57._setupVariables(); 9704 _this57._setupEventHandlers(); 9705 9706 _this57._clockSetup(); 9707 _this57._pickerSetup(); 9708 return _this57; 9709 } 9710 9711 _createClass(Timepicker, [{ 9712 key: "destroy", 9713 9714 9715 /** 9716 * Teardown component 9717 */ 9718 value: function destroy() { 9719 this._removeEventHandlers(); 9720 this.modal.destroy(); 9721 $(this.modalEl).remove(); 9722 this.el.M_Timepicker = undefined; 9723 } 9724 9725 /** 9726 * Setup Event Handlers 9727 */ 9728 9729 }, { 9730 key: "_setupEventHandlers", 9731 value: function _setupEventHandlers() { 9732 this._handleInputKeydownBound = this._handleInputKeydown.bind(this); 9733 this._handleInputClickBound = this._handleInputClick.bind(this); 9734 this._handleClockClickStartBound = this._handleClockClickStart.bind(this); 9735 this._handleDocumentClickMoveBound = this._handleDocumentClickMove.bind(this); 9736 this._handleDocumentClickEndBound = this._handleDocumentClickEnd.bind(this); 9737 9738 this.el.addEventListener('click', this._handleInputClickBound); 9739 this.el.addEventListener('keydown', this._handleInputKeydownBound); 9740 this.plate.addEventListener('mousedown', this._handleClockClickStartBound); 9741 this.plate.addEventListener('touchstart', this._handleClockClickStartBound); 9742 9743 $(this.spanHours).on('click', this.showView.bind(this, 'hours')); 9744 $(this.spanMinutes).on('click', this.showView.bind(this, 'minutes')); 9745 } 9746 }, { 9747 key: "_removeEventHandlers", 9748 value: function _removeEventHandlers() { 9749 this.el.removeEventListener('click', this._handleInputClickBound); 9750 this.el.removeEventListener('keydown', this._handleInputKeydownBound); 9751 } 9752 }, { 9753 key: "_handleInputClick", 9754 value: function _handleInputClick() { 9755 this.open(); 9756 } 9757 }, { 9758 key: "_handleInputKeydown", 9759 value: function _handleInputKeydown(e) { 9760 if (e.which === M.keys.ENTER) { 9761 e.preventDefault(); 9762 this.open(); 9763 } 9764 } 9765 }, { 9766 key: "_handleClockClickStart", 9767 value: function _handleClockClickStart(e) { 9768 e.preventDefault(); 9769 var clockPlateBR = this.plate.getBoundingClientRect(); 9770 var offset = { x: clockPlateBR.left, y: clockPlateBR.top }; 9771 9772 this.x0 = offset.x + this.options.dialRadius; 9773 this.y0 = offset.y + this.options.dialRadius; 9774 this.moved = false; 9775 var clickPos = Timepicker._Pos(e); 9776 this.dx = clickPos.x - this.x0; 9777 this.dy = clickPos.y - this.y0; 9778 9779 // Set clock hands 9780 this.setHand(this.dx, this.dy, false); 9781 9782 // Mousemove on document 9783 document.addEventListener('mousemove', this._handleDocumentClickMoveBound); 9784 document.addEventListener('touchmove', this._handleDocumentClickMoveBound); 9785 9786 // Mouseup on document 9787 document.addEventListener('mouseup', this._handleDocumentClickEndBound); 9788 document.addEventListener('touchend', this._handleDocumentClickEndBound); 9789 } 9790 }, { 9791 key: "_handleDocumentClickMove", 9792 value: function _handleDocumentClickMove(e) { 9793 e.preventDefault(); 9794 var clickPos = Timepicker._Pos(e); 9795 var x = clickPos.x - this.x0; 9796 var y = clickPos.y - this.y0; 9797 this.moved = true; 9798 this.setHand(x, y, false, true); 9799 } 9800 }, { 9801 key: "_handleDocumentClickEnd", 9802 value: function _handleDocumentClickEnd(e) { 9803 var _this58 = this; 9804 9805 e.preventDefault(); 9806 document.removeEventListener('mouseup', this._handleDocumentClickEndBound); 9807 document.removeEventListener('touchend', this._handleDocumentClickEndBound); 9808 var clickPos = Timepicker._Pos(e); 9809 var x = clickPos.x - this.x0; 9810 var y = clickPos.y - this.y0; 9811 if (this.moved && x === this.dx && y === this.dy) { 9812 this.setHand(x, y); 9813 } 9814 9815 if (this.currentView === 'hours') { 9816 this.showView('minutes', this.options.duration / 2); 9817 } else if (this.options.autoClose) { 9818 $(this.minutesView).addClass('timepicker-dial-out'); 9819 setTimeout(function () { 9820 _this58.done(); 9821 }, this.options.duration / 2); 9822 } 9823 9824 if (typeof this.options.onSelect === 'function') { 9825 this.options.onSelect.call(this, this.hours, this.minutes); 9826 } 9827 9828 // Unbind mousemove event 9829 document.removeEventListener('mousemove', this._handleDocumentClickMoveBound); 9830 document.removeEventListener('touchmove', this._handleDocumentClickMoveBound); 9831 } 9832 }, { 9833 key: "_insertHTMLIntoDOM", 9834 value: function _insertHTMLIntoDOM() { 9835 this.$modalEl = $(Timepicker._template); 9836 this.modalEl = this.$modalEl[0]; 9837 this.modalEl.id = 'modal-' + this.id; 9838 9839 // Append popover to input by default 9840 var containerEl = document.querySelector(this.options.container); 9841 if (this.options.container && !!containerEl) { 9842 this.$modalEl.appendTo(containerEl); 9843 } else { 9844 this.$modalEl.insertBefore(this.el); 9845 } 9846 } 9847 }, { 9848 key: "_setupModal", 9849 value: function _setupModal() { 9850 var _this59 = this; 9851 9852 this.modal = M.Modal.init(this.modalEl, { 9853 onOpenStart: this.options.onOpenStart, 9854 onOpenEnd: this.options.onOpenEnd, 9855 onCloseStart: this.options.onCloseStart, 9856 onCloseEnd: function () { 9857 if (typeof _this59.options.onCloseEnd === 'function') { 9858 _this59.options.onCloseEnd.call(_this59); 9859 } 9860 _this59.isOpen = false; 9861 } 9862 }); 9863 } 9864 }, { 9865 key: "_setupVariables", 9866 value: function _setupVariables() { 9867 this.currentView = 'hours'; 9868 this.vibrate = navigator.vibrate ? 'vibrate' : navigator.webkitVibrate ? 'webkitVibrate' : null; 9869 9870 this._canvas = this.modalEl.querySelector('.timepicker-canvas'); 9871 this.plate = this.modalEl.querySelector('.timepicker-plate'); 9872 9873 this.hoursView = this.modalEl.querySelector('.timepicker-hours'); 9874 this.minutesView = this.modalEl.querySelector('.timepicker-minutes'); 9875 this.spanHours = this.modalEl.querySelector('.timepicker-span-hours'); 9876 this.spanMinutes = this.modalEl.querySelector('.timepicker-span-minutes'); 9877 this.spanAmPm = this.modalEl.querySelector('.timepicker-span-am-pm'); 9878 this.footer = this.modalEl.querySelector('.timepicker-footer'); 9879 this.amOrPm = 'PM'; 9880 } 9881 }, { 9882 key: "_pickerSetup", 9883 value: function _pickerSetup() { 9884 var $clearBtn = $("<button class=\"btn-flat timepicker-clear waves-effect\" style=\"visibility: hidden;\" type=\"button\" tabindex=\"" + (this.options.twelveHour ? '3' : '1') + "\">" + this.options.i18n.clear + "</button>").appendTo(this.footer).on('click', this.clear.bind(this)); 9885 if (this.options.showClearBtn) { 9886 $clearBtn.css({ visibility: '' }); 9887 } 9888 9889 var confirmationBtnsContainer = $('<div class="confirmation-btns"></div>'); 9890 $('<button class="btn-flat timepicker-close waves-effect" type="button" tabindex="' + (this.options.twelveHour ? '3' : '1') + '">' + this.options.i18n.cancel + '</button>').appendTo(confirmationBtnsContainer).on('click', this.close.bind(this)); 9891 $('<button class="btn-flat timepicker-close waves-effect" type="button" tabindex="' + (this.options.twelveHour ? '3' : '1') + '">' + this.options.i18n.done + '</button>').appendTo(confirmationBtnsContainer).on('click', this.done.bind(this)); 9892 confirmationBtnsContainer.appendTo(this.footer); 9893 } 9894 }, { 9895 key: "_clockSetup", 9896 value: function _clockSetup() { 9897 if (this.options.twelveHour) { 9898 this.$amBtn = $('<div class="am-btn">AM</div>'); 9899 this.$pmBtn = $('<div class="pm-btn">PM</div>'); 9900 this.$amBtn.on('click', this._handleAmPmClick.bind(this)).appendTo(this.spanAmPm); 9901 this.$pmBtn.on('click', this._handleAmPmClick.bind(this)).appendTo(this.spanAmPm); 9902 } 9903 9904 this._buildHoursView(); 9905 this._buildMinutesView(); 9906 this._buildSVGClock(); 9907 } 9908 }, { 9909 key: "_buildSVGClock", 9910 value: function _buildSVGClock() { 9911 // Draw clock hands and others 9912 var dialRadius = this.options.dialRadius; 9913 var tickRadius = this.options.tickRadius; 9914 var diameter = dialRadius * 2; 9915 9916 var svg = Timepicker._createSVGEl('svg'); 9917 svg.setAttribute('class', 'timepicker-svg'); 9918 svg.setAttribute('width', diameter); 9919 svg.setAttribute('height', diameter); 9920 var g = Timepicker._createSVGEl('g'); 9921 g.setAttribute('transform', 'translate(' + dialRadius + ',' + dialRadius + ')'); 9922 var bearing = Timepicker._createSVGEl('circle'); 9923 bearing.setAttribute('class', 'timepicker-canvas-bearing'); 9924 bearing.setAttribute('cx', 0); 9925 bearing.setAttribute('cy', 0); 9926 bearing.setAttribute('r', 4); 9927 var hand = Timepicker._createSVGEl('line'); 9928 hand.setAttribute('x1', 0); 9929 hand.setAttribute('y1', 0); 9930 var bg = Timepicker._createSVGEl('circle'); 9931 bg.setAttribute('class', 'timepicker-canvas-bg'); 9932 bg.setAttribute('r', tickRadius); 9933 g.appendChild(hand); 9934 g.appendChild(bg); 9935 g.appendChild(bearing); 9936 svg.appendChild(g); 9937 this._canvas.appendChild(svg); 9938 9939 this.hand = hand; 9940 this.bg = bg; 9941 this.bearing = bearing; 9942 this.g = g; 9943 } 9944 }, { 9945 key: "_buildHoursView", 9946 value: function _buildHoursView() { 9947 var $tick = $('<div class="timepicker-tick"></div>'); 9948 // Hours view 9949 if (this.options.twelveHour) { 9950 for (var i = 1; i < 13; i += 1) { 9951 var tick = $tick.clone(); 9952 var radian = i / 6 * Math.PI; 9953 var radius = this.options.outerRadius; 9954 tick.css({ 9955 left: this.options.dialRadius + Math.sin(radian) * radius - this.options.tickRadius + 'px', 9956 top: this.options.dialRadius - Math.cos(radian) * radius - this.options.tickRadius + 'px' 9957 }); 9958 tick.html(i === 0 ? '00' : i); 9959 this.hoursView.appendChild(tick[0]); 9960 // tick.on(mousedownEvent, mousedown); 9961 } 9962 } else { 9963 for (var _i2 = 0; _i2 < 24; _i2 += 1) { 9964 var _tick = $tick.clone(); 9965 var _radian = _i2 / 6 * Math.PI; 9966 var inner = _i2 > 0 && _i2 < 13; 9967 var _radius = inner ? this.options.innerRadius : this.options.outerRadius; 9968 _tick.css({ 9969 left: this.options.dialRadius + Math.sin(_radian) * _radius - this.options.tickRadius + 'px', 9970 top: this.options.dialRadius - Math.cos(_radian) * _radius - this.options.tickRadius + 'px' 9971 }); 9972 _tick.html(_i2 === 0 ? '00' : _i2); 9973 this.hoursView.appendChild(_tick[0]); 9974 // tick.on(mousedownEvent, mousedown); 9975 } 9976 } 9977 } 9978 }, { 9979 key: "_buildMinutesView", 9980 value: function _buildMinutesView() { 9981 var $tick = $('<div class="timepicker-tick"></div>'); 9982 // Minutes view 9983 for (var i = 0; i < 60; i += 5) { 9984 var tick = $tick.clone(); 9985 var radian = i / 30 * Math.PI; 9986 tick.css({ 9987 left: this.options.dialRadius + Math.sin(radian) * this.options.outerRadius - this.options.tickRadius + 'px', 9988 top: this.options.dialRadius - Math.cos(radian) * this.options.outerRadius - this.options.tickRadius + 'px' 9989 }); 9990 tick.html(Timepicker._addLeadingZero(i)); 9991 this.minutesView.appendChild(tick[0]); 9992 } 9993 } 9994 }, { 9995 key: "_handleAmPmClick", 9996 value: function _handleAmPmClick(e) { 9997 var $btnClicked = $(e.target); 9998 this.amOrPm = $btnClicked.hasClass('am-btn') ? 'AM' : 'PM'; 9999 this._updateAmPmView(); 10000 } 10001 }, { 10002 key: "_updateAmPmView", 10003 value: function _updateAmPmView() { 10004 if (this.options.twelveHour) { 10005 this.$amBtn.toggleClass('text-primary', this.amOrPm === 'AM'); 10006 this.$pmBtn.toggleClass('text-primary', this.amOrPm === 'PM'); 10007 } 10008 } 10009 }, { 10010 key: "_updateTimeFromInput", 10011 value: function _updateTimeFromInput() { 10012 // Get the time 10013 var value = ((this.el.value || this.options.defaultTime || '') + '').split(':'); 10014 if (this.options.twelveHour && !(typeof value[1] === 'undefined')) { 10015 if (value[1].toUpperCase().indexOf('AM') > 0) { 10016 this.amOrPm = 'AM'; 10017 } else { 10018 this.amOrPm = 'PM'; 10019 } 10020 value[1] = value[1].replace('AM', '').replace('PM', ''); 10021 } 10022 if (value[0] === 'now') { 10023 var now = new Date(+new Date() + this.options.fromNow); 10024 value = [now.getHours(), now.getMinutes()]; 10025 if (this.options.twelveHour) { 10026 this.amOrPm = value[0] >= 12 && value[0] < 24 ? 'PM' : 'AM'; 10027 } 10028 } 10029 this.hours = +value[0] || 0; 10030 this.minutes = +value[1] || 0; 10031 this.spanHours.innerHTML = this.hours; 10032 this.spanMinutes.innerHTML = Timepicker._addLeadingZero(this.minutes); 10033 10034 this._updateAmPmView(); 10035 } 10036 }, { 10037 key: "showView", 10038 value: function showView(view, delay) { 10039 if (view === 'minutes' && $(this.hoursView).css('visibility') === 'visible') { 10040 // raiseCallback(this.options.beforeHourSelect); 10041 } 10042 var isHours = view === 'hours', 10043 nextView = isHours ? this.hoursView : this.minutesView, 10044 hideView = isHours ? this.minutesView : this.hoursView; 10045 this.currentView = view; 10046 10047 $(this.spanHours).toggleClass('text-primary', isHours); 10048 $(this.spanMinutes).toggleClass('text-primary', !isHours); 10049 10050 // Transition view 10051 hideView.classList.add('timepicker-dial-out'); 10052 $(nextView).css('visibility', 'visible').removeClass('timepicker-dial-out'); 10053 10054 // Reset clock hand 10055 this.resetClock(delay); 10056 10057 // After transitions ended 10058 clearTimeout(this.toggleViewTimer); 10059 this.toggleViewTimer = setTimeout(function () { 10060 $(hideView).css('visibility', 'hidden'); 10061 }, this.options.duration); 10062 } 10063 }, { 10064 key: "resetClock", 10065 value: function resetClock(delay) { 10066 var view = this.currentView, 10067 value = this[view], 10068 isHours = view === 'hours', 10069 unit = Math.PI / (isHours ? 6 : 30), 10070 radian = value * unit, 10071 radius = isHours && value > 0 && value < 13 ? this.options.innerRadius : this.options.outerRadius, 10072 x = Math.sin(radian) * radius, 10073 y = -Math.cos(radian) * radius, 10074 self = this; 10075 10076 if (delay) { 10077 $(this.canvas).addClass('timepicker-canvas-out'); 10078 setTimeout(function () { 10079 $(self.canvas).removeClass('timepicker-canvas-out'); 10080 self.setHand(x, y); 10081 }, delay); 10082 } else { 10083 this.setHand(x, y); 10084 } 10085 } 10086 }, { 10087 key: "setHand", 10088 value: function setHand(x, y, roundBy5) { 10089 var _this60 = this; 10090 10091 var radian = Math.atan2(x, -y), 10092 isHours = this.currentView === 'hours', 10093 unit = Math.PI / (isHours || roundBy5 ? 6 : 30), 10094 z = Math.sqrt(x * x + y * y), 10095 inner = isHours && z < (this.options.outerRadius + this.options.innerRadius) / 2, 10096 radius = inner ? this.options.innerRadius : this.options.outerRadius; 10097 10098 if (this.options.twelveHour) { 10099 radius = this.options.outerRadius; 10100 } 10101 10102 // Radian should in range [0, 2PI] 10103 if (radian < 0) { 10104 radian = Math.PI * 2 + radian; 10105 } 10106 10107 // Get the round value 10108 var value = Math.round(radian / unit); 10109 10110 // Get the round radian 10111 radian = value * unit; 10112 10113 // Correct the hours or minutes 10114 if (this.options.twelveHour) { 10115 if (isHours) { 10116 if (value === 0) value = 12; 10117 } else { 10118 if (roundBy5) value *= 5; 10119 if (value === 60) value = 0; 10120 } 10121 } else { 10122 if (isHours) { 10123 if (value === 12) { 10124 value = 0; 10125 } 10126 value = inner ? value === 0 ? 12 : value : value === 0 ? 0 : value + 12; 10127 } else { 10128 if (roundBy5) { 10129 value *= 5; 10130 } 10131 if (value === 60) { 10132 value = 0; 10133 } 10134 } 10135 } 10136 10137 // Once hours or minutes changed, vibrate the device 10138 if (this[this.currentView] !== value) { 10139 if (this.vibrate && this.options.vibrate) { 10140 // Do not vibrate too frequently 10141 if (!this.vibrateTimer) { 10142 navigator[this.vibrate](10); 10143 this.vibrateTimer = setTimeout(function () { 10144 _this60.vibrateTimer = null; 10145 }, 100); 10146 } 10147 } 10148 } 10149 10150 this[this.currentView] = value; 10151 if (isHours) { 10152 this['spanHours'].innerHTML = value; 10153 } else { 10154 this['spanMinutes'].innerHTML = Timepicker._addLeadingZero(value); 10155 } 10156 10157 // Set clock hand and others' position 10158 var cx1 = Math.sin(radian) * (radius - this.options.tickRadius), 10159 cy1 = -Math.cos(radian) * (radius - this.options.tickRadius), 10160 cx2 = Math.sin(radian) * radius, 10161 cy2 = -Math.cos(radian) * radius; 10162 this.hand.setAttribute('x2', cx1); 10163 this.hand.setAttribute('y2', cy1); 10164 this.bg.setAttribute('cx', cx2); 10165 this.bg.setAttribute('cy', cy2); 10166 } 10167 }, { 10168 key: "open", 10169 value: function open() { 10170 if (this.isOpen) { 10171 return; 10172 } 10173 10174 this.isOpen = true; 10175 this._updateTimeFromInput(); 10176 this.showView('hours'); 10177 10178 this.modal.open(); 10179 } 10180 }, { 10181 key: "close", 10182 value: function close() { 10183 if (!this.isOpen) { 10184 return; 10185 } 10186 10187 this.isOpen = false; 10188 this.modal.close(); 10189 } 10190 10191 /** 10192 * Finish timepicker selection. 10193 */ 10194 10195 }, { 10196 key: "done", 10197 value: function done(e, clearValue) { 10198 // Set input value 10199 var last = this.el.value; 10200 var value = clearValue ? '' : Timepicker._addLeadingZero(this.hours) + ':' + Timepicker._addLeadingZero(this.minutes); 10201 this.time = value; 10202 if (!clearValue && this.options.twelveHour) { 10203 value = value + " " + this.amOrPm; 10204 } 10205 this.el.value = value; 10206 10207 // Trigger change event 10208 if (value !== last) { 10209 this.$el.trigger('change'); 10210 } 10211 10212 this.close(); 10213 this.el.focus(); 10214 } 10215 }, { 10216 key: "clear", 10217 value: function clear() { 10218 this.done(null, true); 10219 } 10220 }], [{ 10221 key: "init", 10222 value: function init(els, options) { 10223 return _get(Timepicker.__proto__ || Object.getPrototypeOf(Timepicker), "init", this).call(this, this, els, options); 10224 } 10225 }, { 10226 key: "_addLeadingZero", 10227 value: function _addLeadingZero(num) { 10228 return (num < 10 ? '0' : '') + num; 10229 } 10230 }, { 10231 key: "_createSVGEl", 10232 value: function _createSVGEl(name) { 10233 var svgNS = 'http://www.w3.org/2000/svg'; 10234 return document.createElementNS(svgNS, name); 10235 } 10236 10237 /** 10238 * @typedef {Object} Point 10239 * @property {number} x The X Coordinate 10240 * @property {number} y The Y Coordinate 10241 */ 10242 10243 /** 10244 * Get x position of mouse or touch event 10245 * @param {Event} e 10246 * @return {Point} x and y location 10247 */ 10248 10249 }, { 10250 key: "_Pos", 10251 value: function _Pos(e) { 10252 if (e.targetTouches && e.targetTouches.length >= 1) { 10253 return { x: e.targetTouches[0].clientX, y: e.targetTouches[0].clientY }; 10254 } 10255 // mouse event 10256 return { x: e.clientX, y: e.clientY }; 10257 } 10258 10259 /** 10260 * Get Instance 10261 */ 10262 10263 }, { 10264 key: "getInstance", 10265 value: function getInstance(el) { 10266 var domElem = !!el.jquery ? el[0] : el; 10267 return domElem.M_Timepicker; 10268 } 10269 }, { 10270 key: "defaults", 10271 get: function () { 10272 return _defaults; 10273 } 10274 }]); 10275 10276 return Timepicker; 10277 }(Component); 10278 10279 Timepicker._template = ['<div class= "modal timepicker-modal">', '<div class="modal-content timepicker-container">', '<div class="timepicker-digital-display">', '<div class="timepicker-text-container">', '<div class="timepicker-display-column">', '<span class="timepicker-span-hours text-primary"></span>', ':', '<span class="timepicker-span-minutes"></span>', '</div>', '<div class="timepicker-display-column timepicker-display-am-pm">', '<div class="timepicker-span-am-pm"></div>', '</div>', '</div>', '</div>', '<div class="timepicker-analog-display">', '<div class="timepicker-plate">', '<div class="timepicker-canvas"></div>', '<div class="timepicker-dial timepicker-hours"></div>', '<div class="timepicker-dial timepicker-minutes timepicker-dial-out"></div>', '</div>', '<div class="timepicker-footer"></div>', '</div>', '</div>', '</div>'].join(''); 10280 10281 M.Timepicker = Timepicker; 10282 10283 if (M.jQueryLoaded) { 10284 M.initializeJqueryWrapper(Timepicker, 'timepicker', 'M_Timepicker'); 10285 } 10286})(cash); 10287;(function ($) { 10288 'use strict'; 10289 10290 var _defaults = {}; 10291 10292 /** 10293 * @class 10294 * 10295 */ 10296 10297 var CharacterCounter = function (_Component17) { 10298 _inherits(CharacterCounter, _Component17); 10299 10300 /** 10301 * Construct CharacterCounter instance 10302 * @constructor 10303 * @param {Element} el 10304 * @param {Object} options 10305 */ 10306 function CharacterCounter(el, options) { 10307 _classCallCheck(this, CharacterCounter); 10308 10309 var _this61 = _possibleConstructorReturn(this, (CharacterCounter.__proto__ || Object.getPrototypeOf(CharacterCounter)).call(this, CharacterCounter, el, options)); 10310 10311 _this61.el.M_CharacterCounter = _this61; 10312 10313 /** 10314 * Options for the character counter 10315 */ 10316 _this61.options = $.extend({}, CharacterCounter.defaults, options); 10317 10318 _this61.isInvalid = false; 10319 _this61.isValidLength = false; 10320 _this61._setupCounter(); 10321 _this61._setupEventHandlers(); 10322 return _this61; 10323 } 10324 10325 _createClass(CharacterCounter, [{ 10326 key: "destroy", 10327 10328 10329 /** 10330 * Teardown component 10331 */ 10332 value: function destroy() { 10333 this._removeEventHandlers(); 10334 this.el.CharacterCounter = undefined; 10335 this._removeCounter(); 10336 } 10337 10338 /** 10339 * Setup Event Handlers 10340 */ 10341 10342 }, { 10343 key: "_setupEventHandlers", 10344 value: function _setupEventHandlers() { 10345 this._handleUpdateCounterBound = this.updateCounter.bind(this); 10346 10347 this.el.addEventListener('focus', this._handleUpdateCounterBound, true); 10348 this.el.addEventListener('input', this._handleUpdateCounterBound, true); 10349 } 10350 10351 /** 10352 * Remove Event Handlers 10353 */ 10354 10355 }, { 10356 key: "_removeEventHandlers", 10357 value: function _removeEventHandlers() { 10358 this.el.removeEventListener('focus', this._handleUpdateCounterBound, true); 10359 this.el.removeEventListener('input', this._handleUpdateCounterBound, true); 10360 } 10361 10362 /** 10363 * Setup counter element 10364 */ 10365 10366 }, { 10367 key: "_setupCounter", 10368 value: function _setupCounter() { 10369 this.counterEl = document.createElement('span'); 10370 $(this.counterEl).addClass('character-counter').css({ 10371 float: 'right', 10372 'font-size': '12px', 10373 height: 1 10374 }); 10375 10376 this.$el.parent().append(this.counterEl); 10377 } 10378 10379 /** 10380 * Remove counter element 10381 */ 10382 10383 }, { 10384 key: "_removeCounter", 10385 value: function _removeCounter() { 10386 $(this.counterEl).remove(); 10387 } 10388 10389 /** 10390 * Update counter 10391 */ 10392 10393 }, { 10394 key: "updateCounter", 10395 value: function updateCounter() { 10396 var maxLength = +this.$el.attr('data-length'), 10397 actualLength = this.el.value.length; 10398 this.isValidLength = actualLength <= maxLength; 10399 var counterString = actualLength; 10400 10401 if (maxLength) { 10402 counterString += '/' + maxLength; 10403 this._validateInput(); 10404 } 10405 10406 $(this.counterEl).html(counterString); 10407 } 10408 10409 /** 10410 * Add validation classes 10411 */ 10412 10413 }, { 10414 key: "_validateInput", 10415 value: function _validateInput() { 10416 if (this.isValidLength && this.isInvalid) { 10417 this.isInvalid = false; 10418 this.$el.removeClass('invalid'); 10419 } else if (!this.isValidLength && !this.isInvalid) { 10420 this.isInvalid = true; 10421 this.$el.removeClass('valid'); 10422 this.$el.addClass('invalid'); 10423 } 10424 } 10425 }], [{ 10426 key: "init", 10427 value: function init(els, options) { 10428 return _get(CharacterCounter.__proto__ || Object.getPrototypeOf(CharacterCounter), "init", this).call(this, this, els, options); 10429 } 10430 10431 /** 10432 * Get Instance 10433 */ 10434 10435 }, { 10436 key: "getInstance", 10437 value: function getInstance(el) { 10438 var domElem = !!el.jquery ? el[0] : el; 10439 return domElem.M_CharacterCounter; 10440 } 10441 }, { 10442 key: "defaults", 10443 get: function () { 10444 return _defaults; 10445 } 10446 }]); 10447 10448 return CharacterCounter; 10449 }(Component); 10450 10451 M.CharacterCounter = CharacterCounter; 10452 10453 if (M.jQueryLoaded) { 10454 M.initializeJqueryWrapper(CharacterCounter, 'characterCounter', 'M_CharacterCounter'); 10455 } 10456})(cash); 10457;(function ($) { 10458 'use strict'; 10459 10460 var _defaults = { 10461 duration: 200, // ms 10462 dist: -100, // zoom scale TODO: make this more intuitive as an option 10463 shift: 0, // spacing for center image 10464 padding: 0, // Padding between non center items 10465 numVisible: 5, // Number of visible items in carousel 10466 fullWidth: false, // Change to full width styles 10467 indicators: false, // Toggle indicators 10468 noWrap: false, // Don't wrap around and cycle through items. 10469 onCycleTo: null // Callback for when a new slide is cycled to. 10470 }; 10471 10472 /** 10473 * @class 10474 * 10475 */ 10476 10477 var Carousel = function (_Component18) { 10478 _inherits(Carousel, _Component18); 10479 10480 /** 10481 * Construct Carousel instance 10482 * @constructor 10483 * @param {Element} el 10484 * @param {Object} options 10485 */ 10486 function Carousel(el, options) { 10487 _classCallCheck(this, Carousel); 10488 10489 var _this62 = _possibleConstructorReturn(this, (Carousel.__proto__ || Object.getPrototypeOf(Carousel)).call(this, Carousel, el, options)); 10490 10491 _this62.el.M_Carousel = _this62; 10492 10493 /** 10494 * Options for the carousel 10495 * @member Carousel#options 10496 * @prop {Number} duration 10497 * @prop {Number} dist 10498 * @prop {Number} shift 10499 * @prop {Number} padding 10500 * @prop {Number} numVisible 10501 * @prop {Boolean} fullWidth 10502 * @prop {Boolean} indicators 10503 * @prop {Boolean} noWrap 10504 * @prop {Function} onCycleTo 10505 */ 10506 _this62.options = $.extend({}, Carousel.defaults, options); 10507 10508 // Setup 10509 _this62.hasMultipleSlides = _this62.$el.find('.carousel-item').length > 1; 10510 _this62.showIndicators = _this62.options.indicators && _this62.hasMultipleSlides; 10511 _this62.noWrap = _this62.options.noWrap || !_this62.hasMultipleSlides; 10512 _this62.pressed = false; 10513 _this62.dragged = false; 10514 _this62.offset = _this62.target = 0; 10515 _this62.images = []; 10516 _this62.itemWidth = _this62.$el.find('.carousel-item').first().innerWidth(); 10517 _this62.itemHeight = _this62.$el.find('.carousel-item').first().innerHeight(); 10518 _this62.dim = _this62.itemWidth * 2 + _this62.options.padding || 1; // Make sure dim is non zero for divisions. 10519 _this62._autoScrollBound = _this62._autoScroll.bind(_this62); 10520 _this62._trackBound = _this62._track.bind(_this62); 10521 10522 // Full Width carousel setup 10523 if (_this62.options.fullWidth) { 10524 _this62.options.dist = 0; 10525 _this62._setCarouselHeight(); 10526 10527 // Offset fixed items when indicators. 10528 if (_this62.showIndicators) { 10529 _this62.$el.find('.carousel-fixed-item').addClass('with-indicators'); 10530 } 10531 } 10532 10533 // Iterate through slides 10534 _this62.$indicators = $('<ul class="indicators"></ul>'); 10535 _this62.$el.find('.carousel-item').each(function (el, i) { 10536 _this62.images.push(el); 10537 if (_this62.showIndicators) { 10538 var $indicator = $('<li class="indicator-item"></li>'); 10539 10540 // Add active to first by default. 10541 if (i === 0) { 10542 $indicator[0].classList.add('active'); 10543 } 10544 10545 _this62.$indicators.append($indicator); 10546 } 10547 }); 10548 if (_this62.showIndicators) { 10549 _this62.$el.append(_this62.$indicators); 10550 } 10551 _this62.count = _this62.images.length; 10552 10553 // Cap numVisible at count 10554 _this62.options.numVisible = Math.min(_this62.count, _this62.options.numVisible); 10555 10556 // Setup cross browser string 10557 _this62.xform = 'transform'; 10558 ['webkit', 'Moz', 'O', 'ms'].every(function (prefix) { 10559 var e = prefix + 'Transform'; 10560 if (typeof document.body.style[e] !== 'undefined') { 10561 _this62.xform = e; 10562 return false; 10563 } 10564 return true; 10565 }); 10566 10567 _this62._setupEventHandlers(); 10568 _this62._scroll(_this62.offset); 10569 return _this62; 10570 } 10571 10572 _createClass(Carousel, [{ 10573 key: "destroy", 10574 10575 10576 /** 10577 * Teardown component 10578 */ 10579 value: function destroy() { 10580 this._removeEventHandlers(); 10581 this.el.M_Carousel = undefined; 10582 } 10583 10584 /** 10585 * Setup Event Handlers 10586 */ 10587 10588 }, { 10589 key: "_setupEventHandlers", 10590 value: function _setupEventHandlers() { 10591 var _this63 = this; 10592 10593 this._handleCarouselTapBound = this._handleCarouselTap.bind(this); 10594 this._handleCarouselDragBound = this._handleCarouselDrag.bind(this); 10595 this._handleCarouselReleaseBound = this._handleCarouselRelease.bind(this); 10596 this._handleCarouselClickBound = this._handleCarouselClick.bind(this); 10597 10598 if (typeof window.ontouchstart !== 'undefined') { 10599 this.el.addEventListener('touchstart', this._handleCarouselTapBound); 10600 this.el.addEventListener('touchmove', this._handleCarouselDragBound); 10601 this.el.addEventListener('touchend', this._handleCarouselReleaseBound); 10602 } 10603 10604 this.el.addEventListener('mousedown', this._handleCarouselTapBound); 10605 this.el.addEventListener('mousemove', this._handleCarouselDragBound); 10606 this.el.addEventListener('mouseup', this._handleCarouselReleaseBound); 10607 this.el.addEventListener('mouseleave', this._handleCarouselReleaseBound); 10608 this.el.addEventListener('click', this._handleCarouselClickBound); 10609 10610 if (this.showIndicators && this.$indicators) { 10611 this._handleIndicatorClickBound = this._handleIndicatorClick.bind(this); 10612 this.$indicators.find('.indicator-item').each(function (el, i) { 10613 el.addEventListener('click', _this63._handleIndicatorClickBound); 10614 }); 10615 } 10616 10617 // Resize 10618 var throttledResize = M.throttle(this._handleResize, 200); 10619 this._handleThrottledResizeBound = throttledResize.bind(this); 10620 10621 window.addEventListener('resize', this._handleThrottledResizeBound); 10622 } 10623 10624 /** 10625 * Remove Event Handlers 10626 */ 10627 10628 }, { 10629 key: "_removeEventHandlers", 10630 value: function _removeEventHandlers() { 10631 var _this64 = this; 10632 10633 if (typeof window.ontouchstart !== 'undefined') { 10634 this.el.removeEventListener('touchstart', this._handleCarouselTapBound); 10635 this.el.removeEventListener('touchmove', this._handleCarouselDragBound); 10636 this.el.removeEventListener('touchend', this._handleCarouselReleaseBound); 10637 } 10638 this.el.removeEventListener('mousedown', this._handleCarouselTapBound); 10639 this.el.removeEventListener('mousemove', this._handleCarouselDragBound); 10640 this.el.removeEventListener('mouseup', this._handleCarouselReleaseBound); 10641 this.el.removeEventListener('mouseleave', this._handleCarouselReleaseBound); 10642 this.el.removeEventListener('click', this._handleCarouselClickBound); 10643 10644 if (this.showIndicators && this.$indicators) { 10645 this.$indicators.find('.indicator-item').each(function (el, i) { 10646 el.removeEventListener('click', _this64._handleIndicatorClickBound); 10647 }); 10648 } 10649 10650 window.removeEventListener('resize', this._handleThrottledResizeBound); 10651 } 10652 10653 /** 10654 * Handle Carousel Tap 10655 * @param {Event} e 10656 */ 10657 10658 }, { 10659 key: "_handleCarouselTap", 10660 value: function _handleCarouselTap(e) { 10661 // Fixes firefox draggable image bug 10662 if (e.type === 'mousedown' && $(e.target).is('img')) { 10663 e.preventDefault(); 10664 } 10665 this.pressed = true; 10666 this.dragged = false; 10667 this.verticalDragged = false; 10668 this.reference = this._xpos(e); 10669 this.referenceY = this._ypos(e); 10670 10671 this.velocity = this.amplitude = 0; 10672 this.frame = this.offset; 10673 this.timestamp = Date.now(); 10674 clearInterval(this.ticker); 10675 this.ticker = setInterval(this._trackBound, 100); 10676 } 10677 10678 /** 10679 * Handle Carousel Drag 10680 * @param {Event} e 10681 */ 10682 10683 }, { 10684 key: "_handleCarouselDrag", 10685 value: function _handleCarouselDrag(e) { 10686 var x = void 0, 10687 y = void 0, 10688 delta = void 0, 10689 deltaY = void 0; 10690 if (this.pressed) { 10691 x = this._xpos(e); 10692 y = this._ypos(e); 10693 delta = this.reference - x; 10694 deltaY = Math.abs(this.referenceY - y); 10695 if (deltaY < 30 && !this.verticalDragged) { 10696 // If vertical scrolling don't allow dragging. 10697 if (delta > 2 || delta < -2) { 10698 this.dragged = true; 10699 this.reference = x; 10700 this._scroll(this.offset + delta); 10701 } 10702 } else if (this.dragged) { 10703 // If dragging don't allow vertical scroll. 10704 e.preventDefault(); 10705 e.stopPropagation(); 10706 return false; 10707 } else { 10708 // Vertical scrolling. 10709 this.verticalDragged = true; 10710 } 10711 } 10712 10713 if (this.dragged) { 10714 // If dragging don't allow vertical scroll. 10715 e.preventDefault(); 10716 e.stopPropagation(); 10717 return false; 10718 } 10719 } 10720 10721 /** 10722 * Handle Carousel Release 10723 * @param {Event} e 10724 */ 10725 10726 }, { 10727 key: "_handleCarouselRelease", 10728 value: function _handleCarouselRelease(e) { 10729 if (this.pressed) { 10730 this.pressed = false; 10731 } else { 10732 return; 10733 } 10734 10735 clearInterval(this.ticker); 10736 this.target = this.offset; 10737 if (this.velocity > 10 || this.velocity < -10) { 10738 this.amplitude = 0.9 * this.velocity; 10739 this.target = this.offset + this.amplitude; 10740 } 10741 this.target = Math.round(this.target / this.dim) * this.dim; 10742 10743 // No wrap of items. 10744 if (this.noWrap) { 10745 if (this.target >= this.dim * (this.count - 1)) { 10746 this.target = this.dim * (this.count - 1); 10747 } else if (this.target < 0) { 10748 this.target = 0; 10749 } 10750 } 10751 this.amplitude = this.target - this.offset; 10752 this.timestamp = Date.now(); 10753 requestAnimationFrame(this._autoScrollBound); 10754 10755 if (this.dragged) { 10756 e.preventDefault(); 10757 e.stopPropagation(); 10758 } 10759 return false; 10760 } 10761 10762 /** 10763 * Handle Carousel CLick 10764 * @param {Event} e 10765 */ 10766 10767 }, { 10768 key: "_handleCarouselClick", 10769 value: function _handleCarouselClick(e) { 10770 // Disable clicks if carousel was dragged. 10771 if (this.dragged) { 10772 e.preventDefault(); 10773 e.stopPropagation(); 10774 return false; 10775 } else if (!this.options.fullWidth) { 10776 var clickedIndex = $(e.target).closest('.carousel-item').index(); 10777 var diff = this._wrap(this.center) - clickedIndex; 10778 10779 // Disable clicks if carousel was shifted by click 10780 if (diff !== 0) { 10781 e.preventDefault(); 10782 e.stopPropagation(); 10783 } 10784 this._cycleTo(clickedIndex); 10785 } 10786 } 10787 10788 /** 10789 * Handle Indicator CLick 10790 * @param {Event} e 10791 */ 10792 10793 }, { 10794 key: "_handleIndicatorClick", 10795 value: function _handleIndicatorClick(e) { 10796 e.stopPropagation(); 10797 10798 var indicator = $(e.target).closest('.indicator-item'); 10799 if (indicator.length) { 10800 this._cycleTo(indicator.index()); 10801 } 10802 } 10803 10804 /** 10805 * Handle Throttle Resize 10806 * @param {Event} e 10807 */ 10808 10809 }, { 10810 key: "_handleResize", 10811 value: function _handleResize(e) { 10812 if (this.options.fullWidth) { 10813 this.itemWidth = this.$el.find('.carousel-item').first().innerWidth(); 10814 this.imageHeight = this.$el.find('.carousel-item.active').height(); 10815 this.dim = this.itemWidth * 2 + this.options.padding; 10816 this.offset = this.center * 2 * this.itemWidth; 10817 this.target = this.offset; 10818 this._setCarouselHeight(true); 10819 } else { 10820 this._scroll(); 10821 } 10822 } 10823 10824 /** 10825 * Set carousel height based on first slide 10826 * @param {Booleam} imageOnly - true for image slides 10827 */ 10828 10829 }, { 10830 key: "_setCarouselHeight", 10831 value: function _setCarouselHeight(imageOnly) { 10832 var _this65 = this; 10833 10834 var firstSlide = this.$el.find('.carousel-item.active').length ? this.$el.find('.carousel-item.active').first() : this.$el.find('.carousel-item').first(); 10835 var firstImage = firstSlide.find('img').first(); 10836 if (firstImage.length) { 10837 if (firstImage[0].complete) { 10838 // If image won't trigger the load event 10839 var imageHeight = firstImage.height(); 10840 if (imageHeight > 0) { 10841 this.$el.css('height', imageHeight + 'px'); 10842 } else { 10843 // If image still has no height, use the natural dimensions to calculate 10844 var naturalWidth = firstImage[0].naturalWidth; 10845 var naturalHeight = firstImage[0].naturalHeight; 10846 var adjustedHeight = this.$el.width() / naturalWidth * naturalHeight; 10847 this.$el.css('height', adjustedHeight + 'px'); 10848 } 10849 } else { 10850 // Get height when image is loaded normally 10851 firstImage.one('load', function (el, i) { 10852 _this65.$el.css('height', el.offsetHeight + 'px'); 10853 }); 10854 } 10855 } else if (!imageOnly) { 10856 var slideHeight = firstSlide.height(); 10857 this.$el.css('height', slideHeight + 'px'); 10858 } 10859 } 10860 10861 /** 10862 * Get x position from event 10863 * @param {Event} e 10864 */ 10865 10866 }, { 10867 key: "_xpos", 10868 value: function _xpos(e) { 10869 // touch event 10870 if (e.targetTouches && e.targetTouches.length >= 1) { 10871 return e.targetTouches[0].clientX; 10872 } 10873 10874 // mouse event 10875 return e.clientX; 10876 } 10877 10878 /** 10879 * Get y position from event 10880 * @param {Event} e 10881 */ 10882 10883 }, { 10884 key: "_ypos", 10885 value: function _ypos(e) { 10886 // touch event 10887 if (e.targetTouches && e.targetTouches.length >= 1) { 10888 return e.targetTouches[0].clientY; 10889 } 10890 10891 // mouse event 10892 return e.clientY; 10893 } 10894 10895 /** 10896 * Wrap index 10897 * @param {Number} x 10898 */ 10899 10900 }, { 10901 key: "_wrap", 10902 value: function _wrap(x) { 10903 return x >= this.count ? x % this.count : x < 0 ? this._wrap(this.count + x % this.count) : x; 10904 } 10905 10906 /** 10907 * Tracks scrolling information 10908 */ 10909 10910 }, { 10911 key: "_track", 10912 value: function _track() { 10913 var now = void 0, 10914 elapsed = void 0, 10915 delta = void 0, 10916 v = void 0; 10917 10918 now = Date.now(); 10919 elapsed = now - this.timestamp; 10920 this.timestamp = now; 10921 delta = this.offset - this.frame; 10922 this.frame = this.offset; 10923 10924 v = 1000 * delta / (1 + elapsed); 10925 this.velocity = 0.8 * v + 0.2 * this.velocity; 10926 } 10927 10928 /** 10929 * Auto scrolls to nearest carousel item. 10930 */ 10931 10932 }, { 10933 key: "_autoScroll", 10934 value: function _autoScroll() { 10935 var elapsed = void 0, 10936 delta = void 0; 10937 10938 if (this.amplitude) { 10939 elapsed = Date.now() - this.timestamp; 10940 delta = this.amplitude * Math.exp(-elapsed / this.options.duration); 10941 if (delta > 2 || delta < -2) { 10942 this._scroll(this.target - delta); 10943 requestAnimationFrame(this._autoScrollBound); 10944 } else { 10945 this._scroll(this.target); 10946 } 10947 } 10948 } 10949 10950 /** 10951 * Scroll to target 10952 * @param {Number} x 10953 */ 10954 10955 }, { 10956 key: "_scroll", 10957 value: function _scroll(x) { 10958 var _this66 = this; 10959 10960 // Track scrolling state 10961 if (!this.$el.hasClass('scrolling')) { 10962 this.el.classList.add('scrolling'); 10963 } 10964 if (this.scrollingTimeout != null) { 10965 window.clearTimeout(this.scrollingTimeout); 10966 } 10967 this.scrollingTimeout = window.setTimeout(function () { 10968 _this66.$el.removeClass('scrolling'); 10969 }, this.options.duration); 10970 10971 // Start actual scroll 10972 var i = void 0, 10973 half = void 0, 10974 delta = void 0, 10975 dir = void 0, 10976 tween = void 0, 10977 el = void 0, 10978 alignment = void 0, 10979 zTranslation = void 0, 10980 tweenedOpacity = void 0, 10981 centerTweenedOpacity = void 0; 10982 var lastCenter = this.center; 10983 var numVisibleOffset = 1 / this.options.numVisible; 10984 10985 this.offset = typeof x === 'number' ? x : this.offset; 10986 this.center = Math.floor((this.offset + this.dim / 2) / this.dim); 10987 delta = this.offset - this.center * this.dim; 10988 dir = delta < 0 ? 1 : -1; 10989 tween = -dir * delta * 2 / this.dim; 10990 half = this.count >> 1; 10991 10992 if (this.options.fullWidth) { 10993 alignment = 'translateX(0)'; 10994 centerTweenedOpacity = 1; 10995 } else { 10996 alignment = 'translateX(' + (this.el.clientWidth - this.itemWidth) / 2 + 'px) '; 10997 alignment += 'translateY(' + (this.el.clientHeight - this.itemHeight) / 2 + 'px)'; 10998 centerTweenedOpacity = 1 - numVisibleOffset * tween; 10999 } 11000 11001 // Set indicator active 11002 if (this.showIndicators) { 11003 var diff = this.center % this.count; 11004 var activeIndicator = this.$indicators.find('.indicator-item.active'); 11005 if (activeIndicator.index() !== diff) { 11006 activeIndicator.removeClass('active'); 11007 this.$indicators.find('.indicator-item').eq(diff)[0].classList.add('active'); 11008 } 11009 } 11010 11011 // center 11012 // Don't show wrapped items. 11013 if (!this.noWrap || this.center >= 0 && this.center < this.count) { 11014 el = this.images[this._wrap(this.center)]; 11015 11016 // Add active class to center item. 11017 if (!$(el).hasClass('active')) { 11018 this.$el.find('.carousel-item').removeClass('active'); 11019 el.classList.add('active'); 11020 } 11021 var transformString = alignment + " translateX(" + -delta / 2 + "px) translateX(" + dir * this.options.shift * tween * i + "px) translateZ(" + this.options.dist * tween + "px)"; 11022 this._updateItemStyle(el, centerTweenedOpacity, 0, transformString); 11023 } 11024 11025 for (i = 1; i <= half; ++i) { 11026 // right side 11027 if (this.options.fullWidth) { 11028 zTranslation = this.options.dist; 11029 tweenedOpacity = i === half && delta < 0 ? 1 - tween : 1; 11030 } else { 11031 zTranslation = this.options.dist * (i * 2 + tween * dir); 11032 tweenedOpacity = 1 - numVisibleOffset * (i * 2 + tween * dir); 11033 } 11034 // Don't show wrapped items. 11035 if (!this.noWrap || this.center + i < this.count) { 11036 el = this.images[this._wrap(this.center + i)]; 11037 var _transformString = alignment + " translateX(" + (this.options.shift + (this.dim * i - delta) / 2) + "px) translateZ(" + zTranslation + "px)"; 11038 this._updateItemStyle(el, tweenedOpacity, -i, _transformString); 11039 } 11040 11041 // left side 11042 if (this.options.fullWidth) { 11043 zTranslation = this.options.dist; 11044 tweenedOpacity = i === half && delta > 0 ? 1 - tween : 1; 11045 } else { 11046 zTranslation = this.options.dist * (i * 2 - tween * dir); 11047 tweenedOpacity = 1 - numVisibleOffset * (i * 2 - tween * dir); 11048 } 11049 // Don't show wrapped items. 11050 if (!this.noWrap || this.center - i >= 0) { 11051 el = this.images[this._wrap(this.center - i)]; 11052 var _transformString2 = alignment + " translateX(" + (-this.options.shift + (-this.dim * i - delta) / 2) + "px) translateZ(" + zTranslation + "px)"; 11053 this._updateItemStyle(el, tweenedOpacity, -i, _transformString2); 11054 } 11055 } 11056 11057 // center 11058 // Don't show wrapped items. 11059 if (!this.noWrap || this.center >= 0 && this.center < this.count) { 11060 el = this.images[this._wrap(this.center)]; 11061 var _transformString3 = alignment + " translateX(" + -delta / 2 + "px) translateX(" + dir * this.options.shift * tween + "px) translateZ(" + this.options.dist * tween + "px)"; 11062 this._updateItemStyle(el, centerTweenedOpacity, 0, _transformString3); 11063 } 11064 11065 // onCycleTo callback 11066 var $currItem = this.$el.find('.carousel-item').eq(this._wrap(this.center)); 11067 if (lastCenter !== this.center && typeof this.options.onCycleTo === 'function') { 11068 this.options.onCycleTo.call(this, $currItem[0], this.dragged); 11069 } 11070 11071 // One time callback 11072 if (typeof this.oneTimeCallback === 'function') { 11073 this.oneTimeCallback.call(this, $currItem[0], this.dragged); 11074 this.oneTimeCallback = null; 11075 } 11076 } 11077 11078 /** 11079 * Cycle to target 11080 * @param {Element} el 11081 * @param {Number} opacity 11082 * @param {Number} zIndex 11083 * @param {String} transform 11084 */ 11085 11086 }, { 11087 key: "_updateItemStyle", 11088 value: function _updateItemStyle(el, opacity, zIndex, transform) { 11089 el.style[this.xform] = transform; 11090 el.style.zIndex = zIndex; 11091 el.style.opacity = opacity; 11092 el.style.visibility = 'visible'; 11093 } 11094 11095 /** 11096 * Cycle to target 11097 * @param {Number} n 11098 * @param {Function} callback 11099 */ 11100 11101 }, { 11102 key: "_cycleTo", 11103 value: function _cycleTo(n, callback) { 11104 var diff = this.center % this.count - n; 11105 11106 // Account for wraparound. 11107 if (!this.noWrap) { 11108 if (diff < 0) { 11109 if (Math.abs(diff + this.count) < Math.abs(diff)) { 11110 diff += this.count; 11111 } 11112 } else if (diff > 0) { 11113 if (Math.abs(diff - this.count) < diff) { 11114 diff -= this.count; 11115 } 11116 } 11117 } 11118 11119 this.target = this.dim * Math.round(this.offset / this.dim); 11120 // Next 11121 if (diff < 0) { 11122 this.target += this.dim * Math.abs(diff); 11123 11124 // Prev 11125 } else if (diff > 0) { 11126 this.target -= this.dim * diff; 11127 } 11128 11129 // Set one time callback 11130 if (typeof callback === 'function') { 11131 this.oneTimeCallback = callback; 11132 } 11133 11134 // Scroll 11135 if (this.offset !== this.target) { 11136 this.amplitude = this.target - this.offset; 11137 this.timestamp = Date.now(); 11138 requestAnimationFrame(this._autoScrollBound); 11139 } 11140 } 11141 11142 /** 11143 * Cycle to next item 11144 * @param {Number} [n] 11145 */ 11146 11147 }, { 11148 key: "next", 11149 value: function next(n) { 11150 if (n === undefined || isNaN(n)) { 11151 n = 1; 11152 } 11153 11154 var index = this.center + n; 11155 if (index >= this.count || index < 0) { 11156 if (this.noWrap) { 11157 return; 11158 } 11159 11160 index = this._wrap(index); 11161 } 11162 this._cycleTo(index); 11163 } 11164 11165 /** 11166 * Cycle to previous item 11167 * @param {Number} [n] 11168 */ 11169 11170 }, { 11171 key: "prev", 11172 value: function prev(n) { 11173 if (n === undefined || isNaN(n)) { 11174 n = 1; 11175 } 11176 11177 var index = this.center - n; 11178 if (index >= this.count || index < 0) { 11179 if (this.noWrap) { 11180 return; 11181 } 11182 11183 index = this._wrap(index); 11184 } 11185 11186 this._cycleTo(index); 11187 } 11188 11189 /** 11190 * Cycle to nth item 11191 * @param {Number} [n] 11192 * @param {Function} callback 11193 */ 11194 11195 }, { 11196 key: "set", 11197 value: function set(n, callback) { 11198 if (n === undefined || isNaN(n)) { 11199 n = 0; 11200 } 11201 11202 if (n > this.count || n < 0) { 11203 if (this.noWrap) { 11204 return; 11205 } 11206 11207 n = this._wrap(n); 11208 } 11209 11210 this._cycleTo(n, callback); 11211 } 11212 }], [{ 11213 key: "init", 11214 value: function init(els, options) { 11215 return _get(Carousel.__proto__ || Object.getPrototypeOf(Carousel), "init", this).call(this, this, els, options); 11216 } 11217 11218 /** 11219 * Get Instance 11220 */ 11221 11222 }, { 11223 key: "getInstance", 11224 value: function getInstance(el) { 11225 var domElem = !!el.jquery ? el[0] : el; 11226 return domElem.M_Carousel; 11227 } 11228 }, { 11229 key: "defaults", 11230 get: function () { 11231 return _defaults; 11232 } 11233 }]); 11234 11235 return Carousel; 11236 }(Component); 11237 11238 M.Carousel = Carousel; 11239 11240 if (M.jQueryLoaded) { 11241 M.initializeJqueryWrapper(Carousel, 'carousel', 'M_Carousel'); 11242 } 11243})(cash); 11244;(function ($) { 11245 'use strict'; 11246 11247 var _defaults = { 11248 onOpen: undefined, 11249 onClose: undefined 11250 }; 11251 11252 /** 11253 * @class 11254 * 11255 */ 11256 11257 var TapTarget = function (_Component19) { 11258 _inherits(TapTarget, _Component19); 11259 11260 /** 11261 * Construct TapTarget instance 11262 * @constructor 11263 * @param {Element} el 11264 * @param {Object} options 11265 */ 11266 function TapTarget(el, options) { 11267 _classCallCheck(this, TapTarget); 11268 11269 var _this67 = _possibleConstructorReturn(this, (TapTarget.__proto__ || Object.getPrototypeOf(TapTarget)).call(this, TapTarget, el, options)); 11270 11271 _this67.el.M_TapTarget = _this67; 11272 11273 /** 11274 * Options for the select 11275 * @member TapTarget#options 11276 * @prop {Function} onOpen - Callback function called when feature discovery is opened 11277 * @prop {Function} onClose - Callback function called when feature discovery is closed 11278 */ 11279 _this67.options = $.extend({}, TapTarget.defaults, options); 11280 11281 _this67.isOpen = false; 11282 11283 // setup 11284 _this67.$origin = $('#' + _this67.$el.attr('data-target')); 11285 _this67._setup(); 11286 11287 _this67._calculatePositioning(); 11288 _this67._setupEventHandlers(); 11289 return _this67; 11290 } 11291 11292 _createClass(TapTarget, [{ 11293 key: "destroy", 11294 11295 11296 /** 11297 * Teardown component 11298 */ 11299 value: function destroy() { 11300 this._removeEventHandlers(); 11301 this.el.TapTarget = undefined; 11302 } 11303 11304 /** 11305 * Setup Event Handlers 11306 */ 11307 11308 }, { 11309 key: "_setupEventHandlers", 11310 value: function _setupEventHandlers() { 11311 this._handleDocumentClickBound = this._handleDocumentClick.bind(this); 11312 this._handleTargetClickBound = this._handleTargetClick.bind(this); 11313 this._handleOriginClickBound = this._handleOriginClick.bind(this); 11314 11315 this.el.addEventListener('click', this._handleTargetClickBound); 11316 this.originEl.addEventListener('click', this._handleOriginClickBound); 11317 11318 // Resize 11319 var throttledResize = M.throttle(this._handleResize, 200); 11320 this._handleThrottledResizeBound = throttledResize.bind(this); 11321 11322 window.addEventListener('resize', this._handleThrottledResizeBound); 11323 } 11324 11325 /** 11326 * Remove Event Handlers 11327 */ 11328 11329 }, { 11330 key: "_removeEventHandlers", 11331 value: function _removeEventHandlers() { 11332 this.el.removeEventListener('click', this._handleTargetClickBound); 11333 this.originEl.removeEventListener('click', this._handleOriginClickBound); 11334 window.removeEventListener('resize', this._handleThrottledResizeBound); 11335 } 11336 11337 /** 11338 * Handle Target Click 11339 * @param {Event} e 11340 */ 11341 11342 }, { 11343 key: "_handleTargetClick", 11344 value: function _handleTargetClick(e) { 11345 this.open(); 11346 } 11347 11348 /** 11349 * Handle Origin Click 11350 * @param {Event} e 11351 */ 11352 11353 }, { 11354 key: "_handleOriginClick", 11355 value: function _handleOriginClick(e) { 11356 this.close(); 11357 } 11358 11359 /** 11360 * Handle Resize 11361 * @param {Event} e 11362 */ 11363 11364 }, { 11365 key: "_handleResize", 11366 value: function _handleResize(e) { 11367 this._calculatePositioning(); 11368 } 11369 11370 /** 11371 * Handle Resize 11372 * @param {Event} e 11373 */ 11374 11375 }, { 11376 key: "_handleDocumentClick", 11377 value: function _handleDocumentClick(e) { 11378 if (!$(e.target).closest('.tap-target-wrapper').length) { 11379 this.close(); 11380 e.preventDefault(); 11381 e.stopPropagation(); 11382 } 11383 } 11384 11385 /** 11386 * Setup Tap Target 11387 */ 11388 11389 }, { 11390 key: "_setup", 11391 value: function _setup() { 11392 // Creating tap target 11393 this.wrapper = this.$el.parent()[0]; 11394 this.waveEl = $(this.wrapper).find('.tap-target-wave')[0]; 11395 this.originEl = $(this.wrapper).find('.tap-target-origin')[0]; 11396 this.contentEl = this.$el.find('.tap-target-content')[0]; 11397 11398 // Creating wrapper 11399 if (!$(this.wrapper).hasClass('.tap-target-wrapper')) { 11400 this.wrapper = document.createElement('div'); 11401 this.wrapper.classList.add('tap-target-wrapper'); 11402 this.$el.before($(this.wrapper)); 11403 this.wrapper.append(this.el); 11404 } 11405 11406 // Creating content 11407 if (!this.contentEl) { 11408 this.contentEl = document.createElement('div'); 11409 this.contentEl.classList.add('tap-target-content'); 11410 this.$el.append(this.contentEl); 11411 } 11412 11413 // Creating foreground wave 11414 if (!this.waveEl) { 11415 this.waveEl = document.createElement('div'); 11416 this.waveEl.classList.add('tap-target-wave'); 11417 11418 // Creating origin 11419 if (!this.originEl) { 11420 this.originEl = this.$origin.clone(true, true); 11421 this.originEl.addClass('tap-target-origin'); 11422 this.originEl.removeAttr('id'); 11423 this.originEl.removeAttr('style'); 11424 this.originEl = this.originEl[0]; 11425 this.waveEl.append(this.originEl); 11426 } 11427 11428 this.wrapper.append(this.waveEl); 11429 } 11430 } 11431 11432 /** 11433 * Calculate positioning 11434 */ 11435 11436 }, { 11437 key: "_calculatePositioning", 11438 value: function _calculatePositioning() { 11439 // Element or parent is fixed position? 11440 var isFixed = this.$origin.css('position') === 'fixed'; 11441 if (!isFixed) { 11442 var parents = this.$origin.parents(); 11443 for (var i = 0; i < parents.length; i++) { 11444 isFixed = $(parents[i]).css('position') == 'fixed'; 11445 if (isFixed) { 11446 break; 11447 } 11448 } 11449 } 11450 11451 // Calculating origin 11452 var originWidth = this.$origin.outerWidth(); 11453 var originHeight = this.$origin.outerHeight(); 11454 var originTop = isFixed ? this.$origin.offset().top - M.getDocumentScrollTop() : this.$origin.offset().top; 11455 var originLeft = isFixed ? this.$origin.offset().left - M.getDocumentScrollLeft() : this.$origin.offset().left; 11456 11457 // Calculating screen 11458 var windowWidth = window.innerWidth; 11459 var windowHeight = window.innerHeight; 11460 var centerX = windowWidth / 2; 11461 var centerY = windowHeight / 2; 11462 var isLeft = originLeft <= centerX; 11463 var isRight = originLeft > centerX; 11464 var isTop = originTop <= centerY; 11465 var isBottom = originTop > centerY; 11466 var isCenterX = originLeft >= windowWidth * 0.25 && originLeft <= windowWidth * 0.75; 11467 11468 // Calculating tap target 11469 var tapTargetWidth = this.$el.outerWidth(); 11470 var tapTargetHeight = this.$el.outerHeight(); 11471 var tapTargetTop = originTop + originHeight / 2 - tapTargetHeight / 2; 11472 var tapTargetLeft = originLeft + originWidth / 2 - tapTargetWidth / 2; 11473 var tapTargetPosition = isFixed ? 'fixed' : 'absolute'; 11474 11475 // Calculating content 11476 var tapTargetTextWidth = isCenterX ? tapTargetWidth : tapTargetWidth / 2 + originWidth; 11477 var tapTargetTextHeight = tapTargetHeight / 2; 11478 var tapTargetTextTop = isTop ? tapTargetHeight / 2 : 0; 11479 var tapTargetTextBottom = 0; 11480 var tapTargetTextLeft = isLeft && !isCenterX ? tapTargetWidth / 2 - originWidth : 0; 11481 var tapTargetTextRight = 0; 11482 var tapTargetTextPadding = originWidth; 11483 var tapTargetTextAlign = isBottom ? 'bottom' : 'top'; 11484 11485 // Calculating wave 11486 var tapTargetWaveWidth = originWidth > originHeight ? originWidth * 2 : originWidth * 2; 11487 var tapTargetWaveHeight = tapTargetWaveWidth; 11488 var tapTargetWaveTop = tapTargetHeight / 2 - tapTargetWaveHeight / 2; 11489 var tapTargetWaveLeft = tapTargetWidth / 2 - tapTargetWaveWidth / 2; 11490 11491 // Setting tap target 11492 var tapTargetWrapperCssObj = {}; 11493 tapTargetWrapperCssObj.top = isTop ? tapTargetTop + 'px' : ''; 11494 tapTargetWrapperCssObj.right = isRight ? windowWidth - tapTargetLeft - tapTargetWidth + 'px' : ''; 11495 tapTargetWrapperCssObj.bottom = isBottom ? windowHeight - tapTargetTop - tapTargetHeight + 'px' : ''; 11496 tapTargetWrapperCssObj.left = isLeft ? tapTargetLeft + 'px' : ''; 11497 tapTargetWrapperCssObj.position = tapTargetPosition; 11498 $(this.wrapper).css(tapTargetWrapperCssObj); 11499 11500 // Setting content 11501 $(this.contentEl).css({ 11502 width: tapTargetTextWidth + 'px', 11503 height: tapTargetTextHeight + 'px', 11504 top: tapTargetTextTop + 'px', 11505 right: tapTargetTextRight + 'px', 11506 bottom: tapTargetTextBottom + 'px', 11507 left: tapTargetTextLeft + 'px', 11508 padding: tapTargetTextPadding + 'px', 11509 verticalAlign: tapTargetTextAlign 11510 }); 11511 11512 // Setting wave 11513 $(this.waveEl).css({ 11514 top: tapTargetWaveTop + 'px', 11515 left: tapTargetWaveLeft + 'px', 11516 width: tapTargetWaveWidth + 'px', 11517 height: tapTargetWaveHeight + 'px' 11518 }); 11519 } 11520 11521 /** 11522 * Open TapTarget 11523 */ 11524 11525 }, { 11526 key: "open", 11527 value: function open() { 11528 if (this.isOpen) { 11529 return; 11530 } 11531 11532 // onOpen callback 11533 if (typeof this.options.onOpen === 'function') { 11534 this.options.onOpen.call(this, this.$origin[0]); 11535 } 11536 11537 this.isOpen = true; 11538 this.wrapper.classList.add('open'); 11539 11540 document.body.addEventListener('click', this._handleDocumentClickBound, true); 11541 document.body.addEventListener('touchend', this._handleDocumentClickBound); 11542 } 11543 11544 /** 11545 * Close Tap Target 11546 */ 11547 11548 }, { 11549 key: "close", 11550 value: function close() { 11551 if (!this.isOpen) { 11552 return; 11553 } 11554 11555 // onClose callback 11556 if (typeof this.options.onClose === 'function') { 11557 this.options.onClose.call(this, this.$origin[0]); 11558 } 11559 11560 this.isOpen = false; 11561 this.wrapper.classList.remove('open'); 11562 11563 document.body.removeEventListener('click', this._handleDocumentClickBound, true); 11564 document.body.removeEventListener('touchend', this._handleDocumentClickBound); 11565 } 11566 }], [{ 11567 key: "init", 11568 value: function init(els, options) { 11569 return _get(TapTarget.__proto__ || Object.getPrototypeOf(TapTarget), "init", this).call(this, this, els, options); 11570 } 11571 11572 /** 11573 * Get Instance 11574 */ 11575 11576 }, { 11577 key: "getInstance", 11578 value: function getInstance(el) { 11579 var domElem = !!el.jquery ? el[0] : el; 11580 return domElem.M_TapTarget; 11581 } 11582 }, { 11583 key: "defaults", 11584 get: function () { 11585 return _defaults; 11586 } 11587 }]); 11588 11589 return TapTarget; 11590 }(Component); 11591 11592 M.TapTarget = TapTarget; 11593 11594 if (M.jQueryLoaded) { 11595 M.initializeJqueryWrapper(TapTarget, 'tapTarget', 'M_TapTarget'); 11596 } 11597})(cash); 11598;(function ($) { 11599 'use strict'; 11600 11601 var _defaults = { 11602 classes: '', 11603 dropdownOptions: {} 11604 }; 11605 11606 /** 11607 * @class 11608 * 11609 */ 11610 11611 var FormSelect = function (_Component20) { 11612 _inherits(FormSelect, _Component20); 11613 11614 /** 11615 * Construct FormSelect instance 11616 * @constructor 11617 * @param {Element} el 11618 * @param {Object} options 11619 */ 11620 function FormSelect(el, options) { 11621 _classCallCheck(this, FormSelect); 11622 11623 // Don't init if browser default version 11624 var _this68 = _possibleConstructorReturn(this, (FormSelect.__proto__ || Object.getPrototypeOf(FormSelect)).call(this, FormSelect, el, options)); 11625 11626 if (_this68.$el.hasClass('browser-default')) { 11627 return _possibleConstructorReturn(_this68); 11628 } 11629 11630 _this68.el.M_FormSelect = _this68; 11631 11632 /** 11633 * Options for the select 11634 * @member FormSelect#options 11635 */ 11636 _this68.options = $.extend({}, FormSelect.defaults, options); 11637 11638 _this68.isMultiple = _this68.$el.prop('multiple'); 11639 11640 // Setup 11641 _this68.el.tabIndex = -1; 11642 _this68._keysSelected = {}; 11643 _this68._valueDict = {}; // Maps key to original and generated option element. 11644 _this68._setupDropdown(); 11645 11646 _this68._setupEventHandlers(); 11647 return _this68; 11648 } 11649 11650 _createClass(FormSelect, [{ 11651 key: "destroy", 11652 11653 11654 /** 11655 * Teardown component 11656 */ 11657 value: function destroy() { 11658 this._removeEventHandlers(); 11659 this._removeDropdown(); 11660 this.el.M_FormSelect = undefined; 11661 } 11662 11663 /** 11664 * Setup Event Handlers 11665 */ 11666 11667 }, { 11668 key: "_setupEventHandlers", 11669 value: function _setupEventHandlers() { 11670 var _this69 = this; 11671 11672 this._handleSelectChangeBound = this._handleSelectChange.bind(this); 11673 this._handleOptionClickBound = this._handleOptionClick.bind(this); 11674 this._handleInputClickBound = this._handleInputClick.bind(this); 11675 11676 $(this.dropdownOptions).find('li:not(.optgroup)').each(function (el) { 11677 el.addEventListener('click', _this69._handleOptionClickBound); 11678 }); 11679 this.el.addEventListener('change', this._handleSelectChangeBound); 11680 this.input.addEventListener('click', this._handleInputClickBound); 11681 } 11682 11683 /** 11684 * Remove Event Handlers 11685 */ 11686 11687 }, { 11688 key: "_removeEventHandlers", 11689 value: function _removeEventHandlers() { 11690 var _this70 = this; 11691 11692 $(this.dropdownOptions).find('li:not(.optgroup)').each(function (el) { 11693 el.removeEventListener('click', _this70._handleOptionClickBound); 11694 }); 11695 this.el.removeEventListener('change', this._handleSelectChangeBound); 11696 this.input.removeEventListener('click', this._handleInputClickBound); 11697 } 11698 11699 /** 11700 * Handle Select Change 11701 * @param {Event} e 11702 */ 11703 11704 }, { 11705 key: "_handleSelectChange", 11706 value: function _handleSelectChange(e) { 11707 this._setValueToInput(); 11708 } 11709 11710 /** 11711 * Handle Option Click 11712 * @param {Event} e 11713 */ 11714 11715 }, { 11716 key: "_handleOptionClick", 11717 value: function _handleOptionClick(e) { 11718 e.preventDefault(); 11719 var option = $(e.target).closest('li')[0]; 11720 var key = option.id; 11721 if (!$(option).hasClass('disabled') && !$(option).hasClass('optgroup') && key.length) { 11722 var selected = true; 11723 11724 if (this.isMultiple) { 11725 // Deselect placeholder option if still selected. 11726 var placeholderOption = $(this.dropdownOptions).find('li.disabled.selected'); 11727 if (placeholderOption.length) { 11728 placeholderOption.removeClass('selected'); 11729 placeholderOption.find('input[type="checkbox"]').prop('checked', false); 11730 this._toggleEntryFromArray(placeholderOption[0].id); 11731 } 11732 selected = this._toggleEntryFromArray(key); 11733 } else { 11734 $(this.dropdownOptions).find('li').removeClass('selected'); 11735 $(option).toggleClass('selected', selected); 11736 } 11737 11738 // Set selected on original select option 11739 // Only trigger if selected state changed 11740 var prevSelected = $(this._valueDict[key].el).prop('selected'); 11741 if (prevSelected !== selected) { 11742 $(this._valueDict[key].el).prop('selected', selected); 11743 this.$el.trigger('change'); 11744 } 11745 } 11746 11747 e.stopPropagation(); 11748 } 11749 11750 /** 11751 * Handle Input Click 11752 */ 11753 11754 }, { 11755 key: "_handleInputClick", 11756 value: function _handleInputClick() { 11757 if (this.dropdown && this.dropdown.isOpen) { 11758 this._setValueToInput(); 11759 this._setSelectedStates(); 11760 } 11761 } 11762 11763 /** 11764 * Setup dropdown 11765 */ 11766 11767 }, { 11768 key: "_setupDropdown", 11769 value: function _setupDropdown() { 11770 var _this71 = this; 11771 11772 this.wrapper = document.createElement('div'); 11773 $(this.wrapper).addClass('select-wrapper ' + this.options.classes); 11774 this.$el.before($(this.wrapper)); 11775 this.wrapper.appendChild(this.el); 11776 11777 if (this.el.disabled) { 11778 this.wrapper.classList.add('disabled'); 11779 } 11780 11781 // Create dropdown 11782 this.$selectOptions = this.$el.children('option, optgroup'); 11783 this.dropdownOptions = document.createElement('ul'); 11784 this.dropdownOptions.id = "select-options-" + M.guid(); 11785 $(this.dropdownOptions).addClass('dropdown-content select-dropdown ' + (this.isMultiple ? 'multiple-select-dropdown' : '')); 11786 11787 // Create dropdown structure. 11788 if (this.$selectOptions.length) { 11789 this.$selectOptions.each(function (el) { 11790 if ($(el).is('option')) { 11791 // Direct descendant option. 11792 var optionEl = void 0; 11793 if (_this71.isMultiple) { 11794 optionEl = _this71._appendOptionWithIcon(_this71.$el, el, 'multiple'); 11795 } else { 11796 optionEl = _this71._appendOptionWithIcon(_this71.$el, el); 11797 } 11798 11799 _this71._addOptionToValueDict(el, optionEl); 11800 } else if ($(el).is('optgroup')) { 11801 // Optgroup. 11802 var selectOptions = $(el).children('option'); 11803 $(_this71.dropdownOptions).append($('<li class="optgroup"><span>' + el.getAttribute('label') + '</span></li>')[0]); 11804 11805 selectOptions.each(function (el) { 11806 var optionEl = _this71._appendOptionWithIcon(_this71.$el, el, 'optgroup-option'); 11807 _this71._addOptionToValueDict(el, optionEl); 11808 }); 11809 } 11810 }); 11811 } 11812 11813 this.$el.after(this.dropdownOptions); 11814 11815 // Add input dropdown 11816 this.input = document.createElement('input'); 11817 $(this.input).addClass('select-dropdown dropdown-trigger'); 11818 this.input.setAttribute('type', 'text'); 11819 this.input.setAttribute('readonly', 'true'); 11820 this.input.setAttribute('data-target', this.dropdownOptions.id); 11821 if (this.el.disabled) { 11822 $(this.input).prop('disabled', 'true'); 11823 } 11824 11825 this.$el.before(this.input); 11826 this._setValueToInput(); 11827 11828 // Add caret 11829 var dropdownIcon = $('<svg class="caret" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/><path d="M0 0h24v24H0z" fill="none"/></svg>'); 11830 this.$el.before(dropdownIcon[0]); 11831 11832 // Initialize dropdown 11833 if (!this.el.disabled) { 11834 var dropdownOptions = $.extend({}, this.options.dropdownOptions); 11835 11836 // Add callback for centering selected option when dropdown content is scrollable 11837 dropdownOptions.onOpenEnd = function (el) { 11838 var selectedOption = $(_this71.dropdownOptions).find('.selected').first(); 11839 11840 if (selectedOption.length) { 11841 // Focus selected option in dropdown 11842 M.keyDown = true; 11843 _this71.dropdown.focusedIndex = selectedOption.index(); 11844 _this71.dropdown._focusFocusedItem(); 11845 M.keyDown = false; 11846 11847 // Handle scrolling to selected option 11848 if (_this71.dropdown.isScrollable) { 11849 var scrollOffset = selectedOption[0].getBoundingClientRect().top - _this71.dropdownOptions.getBoundingClientRect().top; // scroll to selected option 11850 scrollOffset -= _this71.dropdownOptions.clientHeight / 2; // center in dropdown 11851 _this71.dropdownOptions.scrollTop = scrollOffset; 11852 } 11853 } 11854 }; 11855 11856 if (this.isMultiple) { 11857 dropdownOptions.closeOnClick = false; 11858 } 11859 this.dropdown = M.Dropdown.init(this.input, dropdownOptions); 11860 } 11861 11862 // Add initial selections 11863 this._setSelectedStates(); 11864 } 11865 11866 /** 11867 * Add option to value dict 11868 * @param {Element} el original option element 11869 * @param {Element} optionEl generated option element 11870 */ 11871 11872 }, { 11873 key: "_addOptionToValueDict", 11874 value: function _addOptionToValueDict(el, optionEl) { 11875 var index = Object.keys(this._valueDict).length; 11876 var key = this.dropdownOptions.id + index; 11877 var obj = {}; 11878 optionEl.id = key; 11879 11880 obj.el = el; 11881 obj.optionEl = optionEl; 11882 this._valueDict[key] = obj; 11883 } 11884 11885 /** 11886 * Remove dropdown 11887 */ 11888 11889 }, { 11890 key: "_removeDropdown", 11891 value: function _removeDropdown() { 11892 $(this.wrapper).find('.caret').remove(); 11893 $(this.input).remove(); 11894 $(this.dropdownOptions).remove(); 11895 $(this.wrapper).before(this.$el); 11896 $(this.wrapper).remove(); 11897 } 11898 11899 /** 11900 * Setup dropdown 11901 * @param {Element} select select element 11902 * @param {Element} option option element from select 11903 * @param {String} type 11904 * @return {Element} option element added 11905 */ 11906 11907 }, { 11908 key: "_appendOptionWithIcon", 11909 value: function _appendOptionWithIcon(select, option, type) { 11910 // Add disabled attr if disabled 11911 var disabledClass = option.disabled ? 'disabled ' : ''; 11912 var optgroupClass = type === 'optgroup-option' ? 'optgroup-option ' : ''; 11913 var multipleCheckbox = this.isMultiple ? "<label><input type=\"checkbox\"" + disabledClass + "\"/><span>" + option.innerHTML + "</span></label>" : option.innerHTML; 11914 var liEl = $('<li></li>'); 11915 var spanEl = $('<span></span>'); 11916 spanEl.html(multipleCheckbox); 11917 liEl.addClass(disabledClass + " " + optgroupClass); 11918 liEl.append(spanEl); 11919 11920 // add icons 11921 var iconUrl = option.getAttribute('data-icon'); 11922 if (!!iconUrl) { 11923 var imgEl = $("<img alt=\"\" src=\"" + iconUrl + "\">"); 11924 liEl.prepend(imgEl); 11925 } 11926 11927 // Check for multiple type. 11928 $(this.dropdownOptions).append(liEl[0]); 11929 return liEl[0]; 11930 } 11931 11932 /** 11933 * Toggle entry from option 11934 * @param {String} key Option key 11935 * @return {Boolean} if entry was added or removed 11936 */ 11937 11938 }, { 11939 key: "_toggleEntryFromArray", 11940 value: function _toggleEntryFromArray(key) { 11941 var notAdded = !this._keysSelected.hasOwnProperty(key); 11942 var $optionLi = $(this._valueDict[key].optionEl); 11943 11944 if (notAdded) { 11945 this._keysSelected[key] = true; 11946 } else { 11947 delete this._keysSelected[key]; 11948 } 11949 11950 $optionLi.toggleClass('selected', notAdded); 11951 11952 // Set checkbox checked value 11953 $optionLi.find('input[type="checkbox"]').prop('checked', notAdded); 11954 11955 // use notAdded instead of true (to detect if the option is selected or not) 11956 $optionLi.prop('selected', notAdded); 11957 11958 return notAdded; 11959 } 11960 11961 /** 11962 * Set text value to input 11963 */ 11964 11965 }, { 11966 key: "_setValueToInput", 11967 value: function _setValueToInput() { 11968 var values = []; 11969 var options = this.$el.find('option'); 11970 11971 options.each(function (el) { 11972 if ($(el).prop('selected')) { 11973 var text = $(el).text(); 11974 values.push(text); 11975 } 11976 }); 11977 11978 if (!values.length) { 11979 var firstDisabled = this.$el.find('option:disabled').eq(0); 11980 if (firstDisabled.length && firstDisabled[0].value === '') { 11981 values.push(firstDisabled.text()); 11982 } 11983 } 11984 11985 this.input.value = values.join(', '); 11986 } 11987 11988 /** 11989 * Set selected state of dropdown to match actual select element 11990 */ 11991 11992 }, { 11993 key: "_setSelectedStates", 11994 value: function _setSelectedStates() { 11995 this._keysSelected = {}; 11996 11997 for (var key in this._valueDict) { 11998 var option = this._valueDict[key]; 11999 var optionIsSelected = $(option.el).prop('selected'); 12000 $(option.optionEl).find('input[type="checkbox"]').prop('checked', optionIsSelected); 12001 if (optionIsSelected) { 12002 this._activateOption($(this.dropdownOptions), $(option.optionEl)); 12003 this._keysSelected[key] = true; 12004 } else { 12005 $(option.optionEl).removeClass('selected'); 12006 } 12007 } 12008 } 12009 12010 /** 12011 * Make option as selected and scroll to selected position 12012 * @param {jQuery} collection Select options jQuery element 12013 * @param {Element} newOption element of the new option 12014 */ 12015 12016 }, { 12017 key: "_activateOption", 12018 value: function _activateOption(collection, newOption) { 12019 if (newOption) { 12020 if (!this.isMultiple) { 12021 collection.find('li.selected').removeClass('selected'); 12022 } 12023 var option = $(newOption); 12024 option.addClass('selected'); 12025 } 12026 } 12027 12028 /** 12029 * Get Selected Values 12030 * @return {Array} Array of selected values 12031 */ 12032 12033 }, { 12034 key: "getSelectedValues", 12035 value: function getSelectedValues() { 12036 var selectedValues = []; 12037 for (var key in this._keysSelected) { 12038 selectedValues.push(this._valueDict[key].el.value); 12039 } 12040 return selectedValues; 12041 } 12042 }], [{ 12043 key: "init", 12044 value: function init(els, options) { 12045 return _get(FormSelect.__proto__ || Object.getPrototypeOf(FormSelect), "init", this).call(this, this, els, options); 12046 } 12047 12048 /** 12049 * Get Instance 12050 */ 12051 12052 }, { 12053 key: "getInstance", 12054 value: function getInstance(el) { 12055 var domElem = !!el.jquery ? el[0] : el; 12056 return domElem.M_FormSelect; 12057 } 12058 }, { 12059 key: "defaults", 12060 get: function () { 12061 return _defaults; 12062 } 12063 }]); 12064 12065 return FormSelect; 12066 }(Component); 12067 12068 M.FormSelect = FormSelect; 12069 12070 if (M.jQueryLoaded) { 12071 M.initializeJqueryWrapper(FormSelect, 'formSelect', 'M_FormSelect'); 12072 } 12073})(cash); 12074;(function ($, anim) { 12075 'use strict'; 12076 12077 var _defaults = {}; 12078 12079 /** 12080 * @class 12081 * 12082 */ 12083 12084 var Range = function (_Component21) { 12085 _inherits(Range, _Component21); 12086 12087 /** 12088 * Construct Range instance 12089 * @constructor 12090 * @param {Element} el 12091 * @param {Object} options 12092 */ 12093 function Range(el, options) { 12094 _classCallCheck(this, Range); 12095 12096 var _this72 = _possibleConstructorReturn(this, (Range.__proto__ || Object.getPrototypeOf(Range)).call(this, Range, el, options)); 12097 12098 _this72.el.M_Range = _this72; 12099 12100 /** 12101 * Options for the range 12102 * @member Range#options 12103 */ 12104 _this72.options = $.extend({}, Range.defaults, options); 12105 12106 _this72._mousedown = false; 12107 12108 // Setup 12109 _this72._setupThumb(); 12110 12111 _this72._setupEventHandlers(); 12112 return _this72; 12113 } 12114 12115 _createClass(Range, [{ 12116 key: "destroy", 12117 12118 12119 /** 12120 * Teardown component 12121 */ 12122 value: function destroy() { 12123 this._removeEventHandlers(); 12124 this._removeThumb(); 12125 this.el.M_Range = undefined; 12126 } 12127 12128 /** 12129 * Setup Event Handlers 12130 */ 12131 12132 }, { 12133 key: "_setupEventHandlers", 12134 value: function _setupEventHandlers() { 12135 this._handleRangeChangeBound = this._handleRangeChange.bind(this); 12136 this._handleRangeMousedownTouchstartBound = this._handleRangeMousedownTouchstart.bind(this); 12137 this._handleRangeInputMousemoveTouchmoveBound = this._handleRangeInputMousemoveTouchmove.bind(this); 12138 this._handleRangeMouseupTouchendBound = this._handleRangeMouseupTouchend.bind(this); 12139 this._handleRangeBlurMouseoutTouchleaveBound = this._handleRangeBlurMouseoutTouchleave.bind(this); 12140 12141 this.el.addEventListener('change', this._handleRangeChangeBound); 12142 12143 this.el.addEventListener('mousedown', this._handleRangeMousedownTouchstartBound); 12144 this.el.addEventListener('touchstart', this._handleRangeMousedownTouchstartBound); 12145 12146 this.el.addEventListener('input', this._handleRangeInputMousemoveTouchmoveBound); 12147 this.el.addEventListener('mousemove', this._handleRangeInputMousemoveTouchmoveBound); 12148 this.el.addEventListener('touchmove', this._handleRangeInputMousemoveTouchmoveBound); 12149 12150 this.el.addEventListener('mouseup', this._handleRangeMouseupTouchendBound); 12151 this.el.addEventListener('touchend', this._handleRangeMouseupTouchendBound); 12152 12153 this.el.addEventListener('blur', this._handleRangeBlurMouseoutTouchleaveBound); 12154 this.el.addEventListener('mouseout', this._handleRangeBlurMouseoutTouchleaveBound); 12155 this.el.addEventListener('touchleave', this._handleRangeBlurMouseoutTouchleaveBound); 12156 } 12157 12158 /** 12159 * Remove Event Handlers 12160 */ 12161 12162 }, { 12163 key: "_removeEventHandlers", 12164 value: function _removeEventHandlers() { 12165 this.el.removeEventListener('change', this._handleRangeChangeBound); 12166 12167 this.el.removeEventListener('mousedown', this._handleRangeMousedownTouchstartBound); 12168 this.el.removeEventListener('touchstart', this._handleRangeMousedownTouchstartBound); 12169 12170 this.el.removeEventListener('input', this._handleRangeInputMousemoveTouchmoveBound); 12171 this.el.removeEventListener('mousemove', this._handleRangeInputMousemoveTouchmoveBound); 12172 this.el.removeEventListener('touchmove', this._handleRangeInputMousemoveTouchmoveBound); 12173 12174 this.el.removeEventListener('mouseup', this._handleRangeMouseupTouchendBound); 12175 this.el.removeEventListener('touchend', this._handleRangeMouseupTouchendBound); 12176 12177 this.el.removeEventListener('blur', this._handleRangeBlurMouseoutTouchleaveBound); 12178 this.el.removeEventListener('mouseout', this._handleRangeBlurMouseoutTouchleaveBound); 12179 this.el.removeEventListener('touchleave', this._handleRangeBlurMouseoutTouchleaveBound); 12180 } 12181 12182 /** 12183 * Handle Range Change 12184 * @param {Event} e 12185 */ 12186 12187 }, { 12188 key: "_handleRangeChange", 12189 value: function _handleRangeChange() { 12190 $(this.value).html(this.$el.val()); 12191 12192 if (!$(this.thumb).hasClass('active')) { 12193 this._showRangeBubble(); 12194 } 12195 12196 var offsetLeft = this._calcRangeOffset(); 12197 $(this.thumb).addClass('active').css('left', offsetLeft + 'px'); 12198 } 12199 12200 /** 12201 * Handle Range Mousedown and Touchstart 12202 * @param {Event} e 12203 */ 12204 12205 }, { 12206 key: "_handleRangeMousedownTouchstart", 12207 value: function _handleRangeMousedownTouchstart(e) { 12208 // Set indicator value 12209 $(this.value).html(this.$el.val()); 12210 12211 this._mousedown = true; 12212 this.$el.addClass('active'); 12213 12214 if (!$(this.thumb).hasClass('active')) { 12215 this._showRangeBubble(); 12216 } 12217 12218 if (e.type !== 'input') { 12219 var offsetLeft = this._calcRangeOffset(); 12220 $(this.thumb).addClass('active').css('left', offsetLeft + 'px'); 12221 } 12222 } 12223 12224 /** 12225 * Handle Range Input, Mousemove and Touchmove 12226 */ 12227 12228 }, { 12229 key: "_handleRangeInputMousemoveTouchmove", 12230 value: function _handleRangeInputMousemoveTouchmove() { 12231 if (this._mousedown) { 12232 if (!$(this.thumb).hasClass('active')) { 12233 this._showRangeBubble(); 12234 } 12235 12236 var offsetLeft = this._calcRangeOffset(); 12237 $(this.thumb).addClass('active').css('left', offsetLeft + 'px'); 12238 $(this.value).html(this.$el.val()); 12239 } 12240 } 12241 12242 /** 12243 * Handle Range Mouseup and Touchend 12244 */ 12245 12246 }, { 12247 key: "_handleRangeMouseupTouchend", 12248 value: function _handleRangeMouseupTouchend() { 12249 this._mousedown = false; 12250 this.$el.removeClass('active'); 12251 } 12252 12253 /** 12254 * Handle Range Blur, Mouseout and Touchleave 12255 */ 12256 12257 }, { 12258 key: "_handleRangeBlurMouseoutTouchleave", 12259 value: function _handleRangeBlurMouseoutTouchleave() { 12260 if (!this._mousedown) { 12261 var paddingLeft = parseInt(this.$el.css('padding-left')); 12262 var marginLeft = 7 + paddingLeft + 'px'; 12263 12264 if ($(this.thumb).hasClass('active')) { 12265 anim.remove(this.thumb); 12266 anim({ 12267 targets: this.thumb, 12268 height: 0, 12269 width: 0, 12270 top: 10, 12271 easing: 'easeOutQuad', 12272 marginLeft: marginLeft, 12273 duration: 100 12274 }); 12275 } 12276 $(this.thumb).removeClass('active'); 12277 } 12278 } 12279 12280 /** 12281 * Setup dropdown 12282 */ 12283 12284 }, { 12285 key: "_setupThumb", 12286 value: function _setupThumb() { 12287 this.thumb = document.createElement('span'); 12288 this.value = document.createElement('span'); 12289 $(this.thumb).addClass('thumb'); 12290 $(this.value).addClass('value'); 12291 $(this.thumb).append(this.value); 12292 this.$el.after(this.thumb); 12293 } 12294 12295 /** 12296 * Remove dropdown 12297 */ 12298 12299 }, { 12300 key: "_removeThumb", 12301 value: function _removeThumb() { 12302 $(this.thumb).remove(); 12303 } 12304 12305 /** 12306 * morph thumb into bubble 12307 */ 12308 12309 }, { 12310 key: "_showRangeBubble", 12311 value: function _showRangeBubble() { 12312 var paddingLeft = parseInt($(this.thumb).parent().css('padding-left')); 12313 var marginLeft = -7 + paddingLeft + 'px'; // TODO: fix magic number? 12314 anim.remove(this.thumb); 12315 anim({ 12316 targets: this.thumb, 12317 height: 30, 12318 width: 30, 12319 top: -30, 12320 marginLeft: marginLeft, 12321 duration: 300, 12322 easing: 'easeOutQuint' 12323 }); 12324 } 12325 12326 /** 12327 * Calculate the offset of the thumb 12328 * @return {Number} offset in pixels 12329 */ 12330 12331 }, { 12332 key: "_calcRangeOffset", 12333 value: function _calcRangeOffset() { 12334 var width = this.$el.width() - 15; 12335 var max = parseFloat(this.$el.attr('max')) || 100; // Range default max 12336 var min = parseFloat(this.$el.attr('min')) || 0; // Range default min 12337 var percent = (parseFloat(this.$el.val()) - min) / (max - min); 12338 return percent * width; 12339 } 12340 }], [{ 12341 key: "init", 12342 value: function init(els, options) { 12343 return _get(Range.__proto__ || Object.getPrototypeOf(Range), "init", this).call(this, this, els, options); 12344 } 12345 12346 /** 12347 * Get Instance 12348 */ 12349 12350 }, { 12351 key: "getInstance", 12352 value: function getInstance(el) { 12353 var domElem = !!el.jquery ? el[0] : el; 12354 return domElem.M_Range; 12355 } 12356 }, { 12357 key: "defaults", 12358 get: function () { 12359 return _defaults; 12360 } 12361 }]); 12362 12363 return Range; 12364 }(Component); 12365 12366 M.Range = Range; 12367 12368 if (M.jQueryLoaded) { 12369 M.initializeJqueryWrapper(Range, 'range', 'M_Range'); 12370 } 12371 12372 Range.init($('input[type=range]')); 12373})(cash, M.anime);
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.