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