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