1/******************************************************************************* 2 * Copyright 2019 Adobe 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 ******************************************************************************/ 16 17/** 18 * Element.matches() 19 * https://developer.mozilla.org/enUS/docs/Web/API/Element/matches#Polyfill 20 */ 21if (!Element.prototype.matches) { 22 Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector; 23} 24 25// eslint-disable-next-line valid-jsdoc 26/** 27 * Element.closest() 28 * https://developer.mozilla.org/enUS/docs/Web/API/Element/closest#Polyfill 29 */ 30if (!Element.prototype.closest) { 31 Element.prototype.closest = function(s) { 32 "use strict"; 33 var el = this; 34 if (!document.documentElement.contains(el)) { 35 return null; 36 } 37 do { 38 if (el.matches(s)) { 39 return el; 40 } 41 el = el.parentElement || el.parentNode; 42 } while (el !== null && el.nodeType === 1); 43 return null; 44 }; 45} 46 47/******************************************************************************* 48 * Copyright 2019 Adobe 49 * 50 * Licensed under the Apache License, Version 2.0 (the "License"); 51 * you may not use this file except in compliance with the License. 52 * You may obtain a copy of the License at 53 * 54 * http://www.apache.org/licenses/LICENSE-2.0 55 * 56 * Unless required by applicable law or agreed to in writing, software 57 * distributed under the License is distributed on an "AS IS" BASIS, 58 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 59 * See the License for the specific language governing permissions and 60 * limitations under the License. 61 ******************************************************************************/ 62(function() { 63 "use strict"; 64 65 var dataLayerEnabled; 66 var dataLayer; 67 68 var NS = "cmp"; 69 var IS = "accordion"; 70 71 var keyCodes = { 72 ENTER: 13, 73 SPACE: 32, 74 END: 35, 75 HOME: 36, 76 ARROW_LEFT: 37, 77 ARROW_UP: 38, 78 ARROW_RIGHT: 39, 79 ARROW_DOWN: 40 80 }; 81 82 var selectors = { 83 self: "[data-" + NS + '-is="' + IS + '"]' 84 }; 85
86 var cssClasses = { 87 button: { 88 disabled: "cmp-accordion__button--disabled", 89 expanded: "cmp-accordion__button--expanded" 90 }, 91 panel: { 92 hidden: "cmp-accordion__panel--hidden", 93 expanded: "cmp-accordion__panel--expanded" 94 } 95 }; 96 97 var dataAttributes = { 98 item: { 99 expanded: "data-cmp-expanded" 100 } 101 }; 102 103 var properties = { 104 /** 105 * Determines whether a single accordion item is forced to be expanded at a time. 106 * Expanding one item will collapse all others. 107 * 108 * @memberof Accordion 109 * @type {Boolean} 110 * @default false 111 */ 112 "singleExpansion": { 113 "default": false, 114 "transform": function(value) { 115 return !(value === null || typeof value === "undefined"); 116 } 117 } 118 }; 119 120 /** 121 * Accordion Configuration. 122 * 123 * @typedef {Object} AccordionConfig Represents an Accordion configuration 124 * @property {HTMLElement} element The HTMLElement representing the Accordion 125 * @property {Object} options The Accordion options 126 */ 127 128 /** 129 * Accordion. 130 * 131 * @class Accordion 132 * @classdesc An interactive Accordion component for toggling panels of related content 133 * @param {AccordionConfig} config The Accordion configuration 134 */ 135 function Accordion(config) { 136 var that = this; 137 138 if (config && config.element) { 139 init(config); 140 } 141 142 /** 143 * Initializes the Accordion. 144 * 145 * @private 146 * @param {AccordionConfig} config The Accordion configuration 147 */ 148 function init(config) { 149 that._config = config; 150 151 // prevents multiple initialization 152 config.element.removeAttribute("data-" + NS + "-is"); 153 154 setupProperties(config.options); 155 cacheElements(config.element); 156 157 if (that._elements["item"]) { 158 // ensures multiple element types are arrays. 159 that._elements["item"] = Array.isArray(that._elements["item"]) ? that._elements["item"] : [that._elements["item"]]; 160 that._elements["button"] = Array.isArray(that._elements["button"]) ? that._elements["button"] : [that._elements["button"]]; 161 that._elements["panel"] = Array.isArray(that._elements["panel"]) ? that._elements["panel"] : [that._elements["panel"]]; 162 163 // Expand the item based on deep-link-id if it matches with any existing accordion item id 164 var deepLinkItem = CQ.CoreComponents.container.utils.getDeepLinkItem(that, "item"); 165 if (deepLinkItem && !deepLinkItem.hasAttribute(dataAttributes.item.expanded)) { 166 setItemExpanded(deepLinkItem, true); 167 } 168 169 if (that._properties.singleExpansion) { 170 // No deep linking 171 if (!deepLinkItem) { 172 var expandedItems = getExpandedItems(); 173 // no expanded item annotated, force the first item to display. 174 if (expandedItems.length === 0) { 175 toggle(0); 176 } 177 // multiple expanded items annotated, display the last item open. 178 if (expandedItems.length > 1) { 179 toggle(expandedItems.length - 1); 180 } 181 } else { 182 // Deep link case 183 // Collapse the items other than which is deep linked 184 for (var j = 0; j < that._elements["item"].length; j++) { 185 if (that._elements["item"][j].id !== deepLinkItem.id && 186 that._elements["item"][j].hasAttribute(dataAttributes.item.expanded)) { 187 setItemExpanded(that._elements["item"][j], false); 188 } 189 } 190 } 191 } 192 193 refreshItems(); 194 bindEvents(); 195 196 if (window.Granite && window.Granite.author && window.Granite.author.MessageChannel) { 197 /* 198 * Editor message handling: 199 * - subscribe to "cmp.panelcontainer" message requests sent by the editor frame
200 * - check that the message data panel container type is correct and that the id (path) matches this specific Accordion component 201 * - if so, route the "navigate" operation to enact a navigation of the Accordion based on index data 202 */ 203 CQ.CoreComponents.MESSAGE_CHANNEL = CQ.CoreComponents.MESSAGE_CHANNEL || new window.Granite.author.MessageChannel("cqauthor", window); 204 CQ.CoreComponents.MESSAGE_CHANNEL.subscribeRequestMessage("cmp.panelcontainer", function(message) { 205 if (message.data && message.data.type === "cmp-accordion" && message.data.id === that._elements.self.dataset["cmpPanelcontainerId"]) { 206 if (message.data.operation === "navigate") { 207 // switch to single expansion mode when navigating in edit mode. 208 var singleExpansion = that._properties.singleExpansion; 209 that._properties.singleExpansion = true; 210 toggle(message.data.index); 211 212 // revert to the configured state. 213 that._properties.singleExpansion = singleExpansion; 214 } 215 } 216 }); 217 } 218 } 219 } 220 221 /** 222 * Caches the Accordion elements as defined via the {@code data-accordion-hook="ELEMENT_NAME"} markup API. 223 * 224 * @private 225 * @param {HTMLElement} wrapper The Accordion wrapper element 226 */ 227 function cacheElements(wrapper) { 228 that._elements = {}; 229 that._elements.self = wrapper; 230 var hooks = that._elements.self.querySelectorAll("[data-" + NS + "-hook-" + IS + "]"); 231 232 for (var i = 0; i < hooks.length; i++) { 233 var hook = hooks[i]; 234 if (hook.closest("." + NS + "-" + IS) === that._elements.self) { // only process own accordion elements 235 var capitalized = IS; 236 capitalized = capitalized.charAt(0).toUpperCase() + capitalized.slice(1); 237 var key = hook.dataset[NS + "Hook" + capitalized]; 238 if (that._elements[key]) { 239 if (!Array.isArray(that._elements[key])) { 240 var tmp = that._elements[key]; 241 that._elements[key] = [tmp]; 242 } 243 that._elements[key].push(hook); 244 } else { 245 that._elements[key] = hook; 246 } 247 } 248 } 249 } 250 251 /** 252 * Sets up properties for the Accordion based on the passed options. 253 * 254 * @private 255 * @param {Object} options The Accordion options 256 */ 257 function setupProperties(options) { 258 that._properties = {}; 259 260 for (var key in properties) { 261 if (properties.hasOwnProperty(key)) { 262 var property = properties[key]; 263 var value = null; 264 265 if (options && options[key] != null) { 266 value = options[key]; 267 268 // transform the provided option 269 if (property && typeof property.transform === "function") { 270 value = property.transform(value); 271 } 272 } 273 274 if (value === null) { 275 // value still null, take the property default 276 value = properties[key]["default"]; 277 } 278 279 that._properties[key] = value; 280 } 281 } 282 } 283 284 /** 285 * Binds Accordion event handling. 286 * 287 * @private 288 */ 289 function bindEvents() { 290 var buttons = that._elements["button"]; 291 if (buttons) { 292 for (var i = 0; i < buttons.length; i++) { 293 (function(index) { 294 buttons[i].addEventListener("click", function(event) { 295 toggle(index); 296 focusButton(index); 297 }); 298 buttons[i].addEventListener("keydown", function(event) { 299 onButtonKeyDown(event, index); 300 }); 301 })(i); 302 } 303 } 304 } 305 306 /** 307 * Handles button keydown events. 308 * 309 * @private 310 * @param {Object} event The keydown event 311 * @param {Number} index The index of the button triggering the event 312 */ 313 function onButtonKeyDown(event, index) { 314 var lastIndex = that._elements["button"].length - 1; 315 316 switch (event.keyCode) { 317 case keyCodes.ARROW_LEFT: 318 case keyCodes.ARROW_UP: 319 event.preventDefault(); 320 if (index > 0) { 321 focusButton(index - 1); 322 } 323 break; 324 case keyCodes.ARROW_RIGHT: 325 case keyCodes.ARROW_DOWN: 326 event.preventDefault(); 327 if (index < lastIndex) { 328 focusButton(index + 1); 329 } 330 break; 331 case keyCodes.HOME: 332 event.preventDefault(); 333 focusButton(0); 334 break; 335 case keyCodes.END: 336 event.preventDefault(); 337 focusButton(lastIndex); 338 break;
339 case keyCodes.ENTER: 340 case keyCodes.SPACE: 341 event.preventDefault(); 342 toggle(index); 343 focusButton(index); 344 break; 345 default: 346 return; 347 } 348 } 349 350 /** 351 * General handler for toggle of an item. 352 * 353 * @private 354 * @param {Number} index The index of the item to toggle 355 */ 356 function toggle(index) { 357 var item = that._elements["item"][index]; 358 if (item) { 359 if (that._properties.singleExpansion) { 360 // ensure only a single item is expanded if single expansion is enabled. 361 for (var i = 0; i < that._elements["item"].length; i++) { 362 if (that._elements["item"][i] !== item) { 363 var expanded = getItemExpanded(that._elements["item"][i]); 364 if (expanded) { 365 setItemExpanded(that._elements["item"][i], false); 366 } 367 } 368 } 369 setItemExpanded(item, true); 370 } else { 371 setItemExpanded(item, !getItemExpanded(item)); 372 } 373 374 if (dataLayerEnabled) { 375 var accordionId = that._elements.self.id; 376 var expandedItems = getExpandedItems() 377 .map(function(item) { 378 return Object.keys(JSON.parse(item.dataset.cmpDataLayer))[0]; 379 }); 380 381 var uploadPayload = {component: {}}; 382 uploadPayload.component[accordionId] = { shownItems: expandedItems }; 383 384 var removePayload = {component: {}}; 385 removePayload.component[accordionId] = { shownItems: undefined }; 386 387 dataLayer.push(removePayload); 388 dataLayer.push(uploadPayload); 389 } 390 } 391 } 392 393 /** 394 * Sets an item's expanded state based on the provided flag and refreshes its internals. 395 * 396 * @private 397 * @param {HTMLElement} item The item to mark as expanded, or not expanded 398 * @param {Boolean} expanded true to mark the item expanded, false otherwise 399 */ 400 function setItemExpanded(item, expanded) { 401 if (expanded) { 402 item.setAttribute(dataAttributes.item.expanded, ""); 403 if (dataLayerEnabled) { 404 dataLayer.push({ 405 event: "cmp:show", 406 eventInfo: { 407 path: "component." + getDataLayerId(item.dataset.cmpDataLayer) 408 } 409 }); 410 } 411 412 } else { 413 item.removeAttribute(dataAttributes.item.expanded); 414 if (dataLayerEnabled) { 415 dataLayer.push({ 416 event: "cmp:hide", 417 eventInfo: { 418 path: "component." + getDataLayerId(item.dataset.cmpDataLayer) 419 } 420 }); 421 } 422 } 423 refreshItem(item); 424 } 425 426 /** 427 * Gets an item's expanded state. 428 * 429 * @private 430 * @param {HTMLElement} item The item for checking its expanded state 431 * @returns {Boolean} true if the item is expanded, false otherwise 432 */ 433 function getItemExpanded(item) { 434 return item && item.dataset && item.dataset["cmpExpanded"] !== undefined; 435 } 436 437 /** 438 * Refreshes an item based on its expanded state. 439 * 440 * @private 441 * @param {HTMLElement} item The item to refresh 442 */ 443 function refreshItem(item) { 444 var expanded = getItemExpanded(item); 445 if (expanded) { 446 expandItem(item); 447 } else { 448 collapseItem(item); 449 } 450 } 451 452 /** 453 * Refreshes all items based on their expanded state. 454 * 455 * @private 456 */ 457 function refreshItems() { 458 for (var i = 0; i < that._elements["item"].length; i++) { 459 refreshItem(that._elements["item"][i]); 460 } 461 } 462 463 /** 464 * Returns all expanded items. 465 * 466 * @private 467 * @returns {HTMLElement[]} The expanded items 468 */ 469 function getExpandedItems() { 470 var expandedItems = []; 471 472 for (var i = 0; i < that._elements["item"].length; i++) { 473 var item = that._elements["item"][i]; 474 var expanded = getItemExpanded(item); 475 if (expanded) { 476 expandedItems.push(item); 477 } 478 } 479 480 return expandedItems; 481 } 482 483 /** 484 * Annotates the item and its internals with 485 * the necessary style and accessibility attributes to indicate it is expanded. 486 * 487 * @private 488 * @param {HTMLElement} item The item to annotate as expanded 489 */ 490 function expandItem(item) { 491 var index = that._elements["item"].indexOf(item); 492 if (index > -1) { 493 var button = that._elements["button"][index]; 494 var panel = that._elements["panel"][index];
495 button.classList.add(cssClasses.button.expanded); 496 button.setAttribute("aria-expanded", true); 497 panel.classList.add(cssClasses.panel.expanded); 498 panel.classList.remove(cssClasses.panel.hidden); 499 panel.setAttribute("aria-hidden", false); 500 501 if (that._properties.singleExpansion) { 502 button.classList.add(cssClasses.button.disabled); 503 button.setAttribute("aria-disabled", true); 504 } 505 } 506 } 507 508 /** 509 * Annotates the item and its internals with 510 * the necessary style and accessibility attributes to indicate it is not expanded. 511 * 512 * @private 513 * @param {HTMLElement} item The item to annotate as not expanded 514 */ 515 function collapseItem(item) { 516 var index = that._elements["item"].indexOf(item); 517 if (index > -1) { 518 var button = that._elements["button"][index]; 519 var panel = that._elements["panel"][index]; 520 button.classList.remove(cssClasses.button.disabled); 521 button.classList.remove(cssClasses.button.expanded); 522 button.removeAttribute("aria-disabled"); 523 button.setAttribute("aria-expanded", false); 524 panel.classList.add(cssClasses.panel.hidden); 525 panel.classList.remove(cssClasses.panel.expanded); 526 panel.setAttribute("aria-hidden", true); 527 } 528 } 529 530 /** 531 * Focuses the button at the provided index. 532 * 533 * @private 534 * @param {Number} index The index of the button to focus 535 */ 536 function focusButton(index) { 537 var button = that._elements["button"][index]; 538 button.focus(); 539 } 540 } 541 542 /** 543 * Reads options data from the Accordion wrapper element, defined via {@code data-cmp-*} data attributes. 544 * 545 * @private 546 * @param {HTMLElement} element The Accordion element to read options data from 547 * @returns {Object} The options read from the component data attributes 548 */ 549 function readData(element) { 550 var data = element.dataset; 551 var options = []; 552 var capitalized = IS; 553 capitalized = capitalized.charAt(0).toUpperCase() + capitalized.slice(1); 554 var reserved = ["is", "hook" + capitalized]; 555 556 for (var key in data) { 557 if (data.hasOwnProperty(key)) { 558 var value = data[key]; 559 560 if (key.indexOf(NS) === 0) { 561 key = key.slice(NS.length); 562 key = key.charAt(0).toLowerCase() + key.substring(1); 563 564 if (reserved.indexOf(key) === -1) { 565 options[key] = value; 566 } 567 } 568 } 569 } 570 571 return options; 572 } 573 574 /** 575 * Parses the dataLayer string and returns the ID 576 * 577 * @private 578 * @param {String} componentDataLayer the dataLayer string 579 * @returns {String} dataLayerId or undefined 580 */ 581 function getDataLayerId(componentDataLayer) { 582 return Object.keys(JSON.parse(componentDataLayer))[0]; 583 } 584 585 /** 586 * Document ready handler and DOM mutation observers. Initializes Accordion components as necessary. 587 * 588 * @private 589 */ 590 function onDocumentReady() { 591 dataLayerEnabled = document.body.hasAttribute("data-cmp-data-layer-enabled"); 592 dataLayer = (dataLayerEnabled)? window.adobeDataLayer = window.adobeDataLayer || [] : undefined; 593 594 var elements = document.querySelectorAll(selectors.self); 595 for (var i = 0; i < elements.length; i++) { 596 new Accordion({ element: elements[i], options: readData(elements[i]) }); 597 } 598 599 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; 600 var body = document.querySelector("body"); 601 var observer = new MutationObserver(function(mutations) { 602 mutations.forEach(function(mutation) { 603 // needed for IE 604 var nodesArray = [].slice.call(mutation.addedNodes); 605 if (nodesArray.length > 0) { 606 nodesArray.forEach(function(addedNode) { 607 if (addedNode.querySelectorAll) { 608 var elementsArray = [].slice.call(addedNode.querySelectorAll(selectors.self)); 609 elementsArray.forEach(function(element) { 610 new Accordion({ element: element, options: readData(element) }); 611 }); 612 } 613 }); 614 } 615 }); 616 }); 617 618 observer.observe(body, { 619 subtree: true, 620 childList: true, 621 characterData: true 622 }); 623 } 624 625 if (document.readyState !== "loading") { 626 onDocumentReady(); 627 } else { 628 document.addEventListener("DOMContentLoaded", onDocumentReady); 629 } 630}()); 631 632/******************************************************************************* 633 * Copyright 2018 Adobe 634 * 635 * Licensed under the Apache License, Version 2.0 (the "License");
636 * you may not use this file except in compliance with the License. 637 * You may obtain a copy of the License at 638 * 639 * http://www.apache.org/licenses/LICENSE2.0 640 * 641 * Unless required by applicable law or agreed to in writing, software 642 * distributed under the License is distributed on an "AS IS" BASIS, 643 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 644 * See the License for the specific language governing permissions and 645 * limitations under the License. 646 ******************************************************************************/ 647 648/** 649 * Element.matches() 650 * https://developer.mozilla.org/enUS/docs/Web/API/Element/matches#Polyfill 651 */ 652if (!Element.prototype.matches) { 653 Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector; 654} 655 656// eslint-disable-next-line valid-jsdoc 657/** 658 * Element.closest() 659 * https://developer.mozilla.org/enUS/docs/Web/API/Element/closest#Polyfill 660 */ 661if (!Element.prototype.closest) { 662 Element.prototype.closest = function(s) { 663 "use strict"; 664 var el = this; 665 if (!document.documentElement.contains(el)) { 666 return null; 667 } 668 do { 669 if (el.matches(s)) { 670 return el; 671 } 672 el = el.parentElement || el.parentNode; 673 } while (el !== null && el.nodeType === 1); 674 return null; 675 }; 676} 677 678/******************************************************************************* 679 * Copyright 2018 Adobe 680 * 681 * Licensed under the Apache License, Version 2.0 (the "License"); 682 * you may not use this file except in compliance with the License. 683 * You may obtain a copy of the License at 684 * 685 * http://www.apache.org/licenses/LICENSE-2.0 686 * 687 * Unless required by applicable law or agreed to in writing, software 688 * distributed under the License is distributed on an "AS IS" BASIS, 689 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 690 * See the License for the specific language governing permissions and 691 * limitations under the License. 692 ******************************************************************************/ 693(function() { 694 "use strict"; 695 696 var dataLayerEnabled; 697 var dataLayer; 698 699 var NS = "cmp"; 700 var IS = "tabs"; 701 702 var keyCodes = { 703 END: 35, 704 HOME: 36, 705 ARROW_LEFT: 37, 706 ARROW_UP: 38, 707 ARROW_RIGHT: 39, 708 ARROW_DOWN: 40 709 }; 710 711 var selectors = { 712 self: "[data-" + NS + '-is="' + IS + '"]', 713 active: { 714 tab: "cmp-tabs__tab--active", 715 tabpanel: "cmp-tabs__tabpanel--active" 716 } 717 }; 718 719 /** 720 * Tabs Configuration 721 * 722 * @typedef {Object} TabsConfig Represents a Tabs configuration 723 * @property {HTMLElement} element The HTMLElement representing the Tabs 724 * @property {Object} options The Tabs options 725 */ 726 727 /** 728 * Tabs 729 * 730 * @class Tabs 731 * @classdesc An interactive Tabs component for navigating a list of tabs 732 * @param {TabsConfig} config The Tabs configuration 733 */ 734 function Tabs(config) { 735 var that = this; 736 737 if (config && config.element) { 738 init(config); 739 } 740 741 /** 742 * Initializes the Tabs 743 * 744 * @private 745 * @param {TabsConfig} config The Tabs configuration 746 */ 747 function init(config) { 748 that._config = config; 749 750 // prevents multiple initialization 751 config.element.removeAttribute("data-" + NS + "-is"); 752 753 cacheElements(config.element); 754 that._active = getActiveIndex(that._elements["tab"]); 755 756 if (that._elements.tabpanel) { 757 refreshActive(); 758 bindEvents(); 759 } 760 761 // Show the tab based on deep-link-id if it matches with any existing tab item id 762 var deepLinkItemIdx = CQ.CoreComponents.container.utils.getDeepLinkItemIdx(that, "tabpanel"); 763 if (deepLinkItemIdx) { 764 var deepLinkItem = that._elements["tab"][deepLinkItemIdx]; 765 if (deepLinkItem && that._elements["tab"][that._active].id !== deepLinkItem.id) { 766 navigateAndFocusTab(deepLinkItemIdx); 767 } 768 } 769 770 if (window.Granite && window.Granite.author && window.Granite.author.MessageChannel) { 771 /* 772 * Editor message handling: 773 * - subscribe to "cmp.panelcontainer" message requests sent by the editor frame
774 * - check that the message data panel container type is correct and that the id (path) matches this specific Tabs component 775 * - if so, route the "navigate" operation to enact a navigation of the Tabs based on index data 776 */ 777 CQ.CoreComponents.MESSAGE_CHANNEL = CQ.CoreComponents.MESSAGE_CHANNEL || new window.Granite.author.MessageChannel("cqauthor", window); 778 CQ.CoreComponents.MESSAGE_CHANNEL.subscribeRequestMessage("cmp.panelcontainer", function(message) { 779 if (message.data && message.data.type === "cmp-tabs" && message.data.id === that._elements.self.dataset["cmpPanelcontainerId"]) { 780 if (message.data.operation === "navigate") { 781 navigate(message.data.index); 782 } 783 } 784 }); 785 } 786 } 787 788 /** 789 * Returns the index of the active tab, if no tab is active returns 0 790 * 791 * @param {Array} tabs Tab elements 792 * @returns {Number} Index of the active tab, 0 if none is active 793 */ 794 function getActiveIndex(tabs) { 795 if (tabs) { 796 for (var i = 0; i < tabs.length; i++) { 797 if (tabs[i].classList.contains(selectors.active.tab)) { 798 return i; 799 } 800 } 801 } 802 return 0; 803 } 804 805 /** 806 * Caches the Tabs elements as defined via the {@code data-tabs-hook="ELEMENT_NAME"} markup API 807 * 808 * @private 809 * @param {HTMLElement} wrapper The Tabs wrapper element 810 */ 811 function cacheElements(wrapper) { 812 that._elements = {}; 813 that._elements.self = wrapper; 814 var hooks = that._elements.self.querySelectorAll("[data-" + NS + "-hook-" + IS + "]"); 815 816 for (var i = 0; i < hooks.length; i++) { 817 var hook = hooks[i]; 818 if (hook.closest("." + NS + "-" + IS) === that._elements.self) { // only process own tab elements 819 var capitalized = IS; 820 capitalized = capitalized.charAt(0).toUpperCase() + capitalized.slice(1); 821 var key = hook.dataset[NS + "Hook" + capitalized]; 822 if (that._elements[key]) { 823 if (!Array.isArray(that._elements[key])) { 824 var tmp = that._elements[key]; 825 that._elements[key] = [tmp]; 826 } 827 that._elements[key].push(hook); 828 } else { 829 that._elements[key] = hook; 830 } 831 } 832 } 833 } 834 835 /** 836 * Binds Tabs event handling 837 * 838 * @private 839 */ 840 function bindEvents() { 841 var tabs = that._elements["tab"]; 842 if (tabs) { 843 for (var i = 0; i < tabs.length; i++) { 844 (function(index) { 845 tabs[i].addEventListener("click", function(event) { 846 navigateAndFocusTab(index); 847 }); 848 tabs[i].addEventListener("keydown", function(event) { 849 onKeyDown(event); 850 }); 851 })(i); 852 } 853 } 854 } 855 856 /** 857 * Handles tab keydown events 858 * 859 * @private 860 * @param {Object} event The keydown event 861 */ 862 function onKeyDown(event) { 863 var index = that._active; 864 var lastIndex = that._elements["tab"].length - 1; 865 866 switch (event.keyCode) { 867 case keyCodes.ARROW_LEFT: 868 case keyCodes.ARROW_UP: 869 event.preventDefault(); 870 if (index > 0) { 871 navigateAndFocusTab(index - 1); 872 } 873 break; 874 case keyCodes.ARROW_RIGHT: 875 case keyCodes.ARROW_DOWN: 876 event.preventDefault(); 877 if (index < lastIndex) { 878 navigateAndFocusTab(index + 1); 879 } 880 break; 881 case keyCodes.HOME: 882 event.preventDefault(); 883 navigateAndFocusTab(0); 884 break; 885 case keyCodes.END: 886 event.preventDefault(); 887 navigateAndFocusTab(lastIndex); 888 break; 889 default: 890 return; 891 } 892 } 893 894 /** 895 * Refreshes the tab markup based on the current {@code Tabs#_active} index 896 * 897 * @private 898 */ 899 function refreshActive() { 900 var tabpanels = that._elements["tabpanel"]; 901 var tabs = that._elements["tab"]; 902 903 if (tabpanels) { 904 if (Array.isArray(tabpanels)) { 905 for (var i = 0; i < tabpanels.length; i++) { 906 if (i === parseInt(that._active)) { 907 tabpanels[i].classList.add(selectors.active.tabpanel); 908 tabpanels[i].removeAttribute("aria-hidden"); 909 tabs[i].classList.add(selectors.active.tab); 910 tabs[i].setAttribute("aria-selected", true); 911 tabs[i].setAttribute("tabindex", "0"); 912 } else { 913 tabpanels[i].classList.remove(selectors.active.tabpanel); 914 tabpanels[i].setAttribute("aria-hidden", true); 915 tabs[i].classList.remove(selectors.active.tab); 916 tabs[i].setAttribute("aria-selected", false); 917 tabs[i].setAttribute("tabindex", "-1"); 918 } 919 } 920 } else { 921 // only one tab 922 tabpanels.classList.add(selectors.active.tabpanel); 923 tabs.classList.add(selectors.active.tab); 924 } 925 } 926 } 927 928 /** 929 * Focuses the element and prevents scrolling the element into view 930 * 931 * @param {HTMLElement} element Element to focus 932 */ 933 function focusWithoutScroll(element) { 934 var x = window.scrollX || window.pageXOffset; 935 var y = window.scrollY || window.pageYOffset; 936 element.focus(); 937 window.scrollTo(x, y); 938 } 939 940 /** 941 * Navigates to the tab at the provided index 942 * 943 * @private 944 * @param {Number} index The index of the tab to navigate to 945 */ 946 function navigate(index) { 947 that._active = index; 948 refreshActive(); 949 } 950 951 /** 952 * Navigates to the item at the provided index and ensures the active tab gains focus 953 * 954 * @private 955 * @param {Number} index The index of the item to navigate to 956 */ 957 function navigateAndFocusTab(index) { 958 var exActive = that._active; 959 navigate(index); 960 focusWithoutScroll(that._elements["tab"][index]); 961 962 if (dataLayerEnabled) { 963 964 var activeItem = getDataLayerId(that._elements.tabpanel[index].dataset.cmpDataLayer); 965 var exActiveItem = getDataLayerId(that._elements.tabpanel[exActive].dataset.cmpDataLayer); 966 967 dataLayer.push({ 968 event: "cmp:show", 969 eventInfo: { 970 path: "component." + activeItem 971 } 972 }); 973 974 dataLayer.push({ 975 event: "cmp:hide", 976 eventInfo: { 977 path: "component." + exActiveItem 978 } 979 }); 980 981 var tabsId = that._elements.self.id; 982 var uploadPayload = { component: {} }; 983 uploadPayload.component[tabsId] = { shownItems: [activeItem] }; 984 985 var removePayload = { component: {} }; 986 removePayload.component[tabsId] = { shownItems: undefined }; 987 988 dataLayer.push(removePayload); 989 dataLayer.push(uploadPayload); 990 } 991 } 992 } 993 994 /**
995 * Reads options data from the Tabs wrapper element, defined via {@code data-cmp-*} data attributes 996 * 997 * @private 998 * @param {HTMLElement} element The Tabs element to read options data from 999 * @returns {Object} The options read from the component data attributes 1000 */ 1001 function readData(element) { 1002 var data = element.dataset; 1003 var options = []; 1004 var capitalized = IS; 1005 capitalized = capitalized.charAt(0).toUpperCase() + capitalized.slice(1); 1006 var reserved = ["is", "hook" + capitalized]; 1007 1008 for (var key in data) { 1009 if (data.hasOwnProperty(key)) { 1010 var value = data[key]; 1011 1012 if (key.indexOf(NS) === 0) { 1013 key = key.slice(NS.length); 1014 key = key.charAt(0).toLowerCase() + key.substring(1); 1015 1016 if (reserved.indexOf(key) === -1) { 1017 options[key] = value; 1018 } 1019 } 1020 } 1021 } 1022 1023 return options; 1024 } 1025 1026 /** 1027 * Parses the dataLayer string and returns the ID 1028 * 1029 * @private 1030 * @param {String} componentDataLayer the dataLayer string 1031 * @returns {String} dataLayerId or undefined 1032 */ 1033 function getDataLayerId(componentDataLayer) { 1034 return Object.keys(JSON.parse(componentDataLayer))[0]; 1035 } 1036 1037 /** 1038 * Document ready handler and DOM mutation observers. Initializes Tabs components as necessary. 1039 * 1040 * @private 1041 */ 1042 function onDocumentReady() { 1043 dataLayerEnabled = document.body.hasAttribute("data-cmp-data-layer-enabled"); 1044 dataLayer = (dataLayerEnabled)? window.adobeDataLayer = window.adobeDataLayer || [] : undefined; 1045 1046 var elements = document.querySelectorAll(selectors.self); 1047 for (var i = 0; i < elements.length; i++) { 1048 new Tabs({ element: elements[i], options: readData(elements[i]) }); 1049 } 1050 1051 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; 1052 var body = document.querySelector("body"); 1053 var observer = new MutationObserver(function(mutations) { 1054 mutations.forEach(function(mutation) { 1055 // needed for IE 1056 var nodesArray = [].slice.call(mutation.addedNodes); 1057 if (nodesArray.length > 0) { 1058 nodesArray.forEach(function(addedNode) { 1059 if (addedNode.querySelectorAll) { 1060 var elementsArray = [].slice.call(addedNode.querySelectorAll(selectors.self)); 1061 elementsArray.forEach(function(element) { 1062 new Tabs({ element: element, options: readData(element) }); 1063 }); 1064 } 1065 }); 1066 } 1067 }); 1068 }); 1069 1070 observer.observe(body, { 1071 subtree: true, 1072 childList: true, 1073 characterData: true 1074 }); 1075 } 1076 1077 if (document.readyState !== "loading") { 1078 onDocumentReady(); 1079 } else { 1080 document.addEventListener("DOMContentLoaded", onDocumentReady); 1081 } 1082 1083}()); 1084 1085/******************************************************************************* 1086 * Copyright 2018 Adobe 1087 * 1088 * Licensed under the Apache License, Version 2.0 (the "License"); 1089 * you may not use this file except in compliance with the License. 1090 * You may obtain a copy of the License at 1091 * 1092 * http://www.apache.org/licenses/LICENSE-2.0 1093 * 1094 * Unless required by applicable law or agreed to in writing, software 1095 * distributed under the License is distributed on an "AS IS" BASIS, 1096 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1097 * See the License for the specific language governing permissions and 1098 * limitations under the License. 1099 ******************************************************************************/ 1100(function() { 1101 "use strict"; 1102 1103 var dataLayerEnabled; 1104 var dataLayer; 1105 1106 var NS = "cmp"; 1107 var IS = "carousel"; 1108 1109 var keyCodes = { 1110 SPACE: 32, 1111 END: 35, 1112 HOME: 36, 1113 ARROW_LEFT: 37, 1114 ARROW_UP: 38, 1115 ARROW_RIGHT: 39, 1116 ARROW_DOWN: 40 1117 }; 1118 1119 var selectors = { 1120 self: "[data-" + NS + '-is="' + IS + '"]' 1121 }; 1122 1123 var properties = { 1124 /** 1125 * Determines whether the Carousel will automatically transition between slides 1126 * 1127 * @memberof Carousel
1128 * @type {Boolean} 1129 * @default false 1130 */ 1131 "autoplay": { 1132 "default": false, 1133 "transform": function(value) { 1134 return !(value === null || typeof value === "undefined"); 1135 } 1136 }, 1137 /** 1138 * Duration (in milliseconds) before automatically transitioning to the next slide 1139 * 1140 * @memberof Carousel 1141 * @type {Number} 1142 * @default 5000 1143 */ 1144 "delay": { 1145 "default": 5000, 1146 "transform": function(value) { 1147 value = parseFloat(value); 1148 return !isNaN(value) ? value : null; 1149 } 1150 }, 1151 /** 1152 * Determines whether automatic pause on hovering the carousel is disabled 1153 * 1154 * @memberof Carousel 1155 * @type {Boolean} 1156 * @default false 1157 */ 1158 "autopauseDisabled": { 1159 "default": false, 1160 "transform": function(value) { 1161 return !(value === null || typeof value === "undefined"); 1162 } 1163 } 1164 }; 1165 1166 /** 1167 * Carousel Configuration 1168 * 1169 * @typedef {Object} CarouselConfig Represents a Carousel configuration 1170 * @property {HTMLElement} element The HTMLElement representing the Carousel 1171 * @property {Object} options The Carousel options 1172 */ 1173 1174 /** 1175 * Carousel 1176 * 1177 * @class Carousel 1178 * @classdesc An interactive Carousel component for navigating a list of generic items 1179 * @param {CarouselConfig} config The Carousel configuration 1180 */ 1181 function Carousel(config) { 1182 var that = this; 1183 1184 if (config && config.element) { 1185 init(config); 1186 } 1187 1188 /** 1189 * Initializes the Carousel 1190 * 1191 * @private 1192 * @param {CarouselConfig} config The Carousel configuration 1193 */ 1194 function init(config) { 1195 // prevents multiple initialization 1196 config.element.removeAttribute("data-" + NS + "-is"); 1197 1198 setupProperties(config.options); 1199 cacheElements(config.element); 1200 1201 that._active = 0; 1202 that._paused = false; 1203 1204 if (that._elements.item) { 1205 refreshActive(); 1206 bindEvents(); 1207 resetAutoplayInterval(); 1208 refreshPlayPauseActions(); 1209 } 1210 1211 // TODO: This section is only relevant in edit mode and should move to the editor clientLib 1212 if (window.Granite && window.Granite.author && window.Granite.author.MessageChannel) { 1213 /* 1214 * Editor message handling: 1215 * - subscribe to "cmp.panelcontainer" message requests sent by the editor frame 1216 * - check that the message data panel container type is correct and that the id (path) matches this specific Carousel component 1217 * - if so, route the "navigate" operation to enact a navigation of the Carousel based on index data 1218 */ 1219 window.CQ = window.CQ || {}; 1220 window.CQ.CoreComponents = window.CQ.CoreComponents || {}; 1221 CQ.CoreComponents.MESSAGE_CHANNEL = CQ.CoreComponents.MESSAGE_CHANNEL || new window.Granite.author.MessageChannel("cqauthor", window); 1222 CQ.CoreComponents.MESSAGE_CHANNEL.subscribeRequestMessage("cmp.panelcontainer", function(message) { 1223 if (message.data && message.data.type === "cmp-carousel" && message.data.id === that._elements.self.dataset["cmpPanelcontainerId"]) { 1224 if (message.data.operation === "navigate") { 1225 navigate(message.data.index); 1226 } 1227 } 1228 }); 1229 } 1230 } 1231 1232 /** 1233 * Caches the Carousel elements as defined via the {@code data-carousel-hook="ELEMENT_NAME"} markup API 1234 * 1235 * @private 1236 * @param {HTMLElement} wrapper The Carousel wrapper element 1237 */ 1238 function cacheElements(wrapper) { 1239 that._elements = {}; 1240 that._elements.self = wrapper; 1241 var hooks = that._elements.self.querySelectorAll("[data-" + NS + "-hook-" + IS + "]"); 1242 1243 for (var i = 0; i < hooks.length; i++) { 1244 var hook = hooks[i]; 1245 var capitalized = IS; 1246 capitalized = capitalized.charAt(0).toUpperCase() + capitalized.slice(1); 1247 var key = hook.dataset[NS + "Hook" + capitalized]; 1248 if (that._elements[key]) { 1249 if (!Array.isArray(that._elements[key])) { 1250 var tmp = that._elements[key]; 1251 that._elements[key] = [tmp]; 1252 } 1253 that._elements[key].push(hook); 1254 } else { 1255 that._elements[key] = hook; 1256 } 1257 } 1258 } 1259 1260 /** 1261 * Sets up properties for the Carousel based on the passed options. 1262 * 1263 * @private 1264 * @param {Object} options The Carousel options 1265 */ 1266 function setupProperties(options) { 1267 that._properties = {}; 1268 1269 for (var key in properties) { 1270 if (properties.hasOwnProperty(key)) { 1271 var property = properties[key]; 1272 var value = null; 1273 1274 if (options && options[key] != null) { 1275 value = options[key]; 1276 1277 // transform the provided option 1278 if (property && typeof property.transform === "function") { 1279 value = property.transform(value); 1280 } 1281 } 1282 1283 if (value === null) { 1284 // value still null, take the property default 1285 value = properties[key]["default"]; 1286 } 1287 1288 that._properties[key] = value; 1289 } 1290 } 1291 } 1292 1293 /** 1294 * Binds Carousel event handling 1295 * 1296 * @private 1297 */ 1298 function bindEvents() { 1299 if (that._elements["previous"]) { 1300 that._elements["previous"].addEventListener("click", function() { 1301 var index = getPreviousIndex(); 1302 navigate(index); 1303 if (dataLayerEnabled) { 1304 dataLayer.push({ 1305 event: "cmp:show", 1306 eventInfo: { 1307 path: "component." + getDataLayerId(that._elements.item[index].dataset.cmpDataLayer) 1308 } 1309 }); 1310 } 1311 }); 1312 } 1313 1314 if (that._elements["next"]) { 1315 that._elements["next"].addEventListener("click", function() { 1316 var index = getNextIndex(); 1317 navigate(index); 1318 if (dataLayerEnabled) { 1319 dataLayer.push({ 1320 event: "cmp:show", 1321 eventInfo: { 1322 path: "component." + getDataLayerId(that._elements.item[index].dataset.cmpDataLayer) 1323 } 1324 }); 1325 } 1326 }); 1327 } 1328 1329 var indicators = that._elements["indicator"]; 1330 if (indicators) { 1331 for (var i = 0; i < indicators.length; i++) { 1332 (function(index) { 1333 indicators[i].addEventListener("click", function(event) { 1334 navigateAndFocusIndicator(index); 1335 }); 1336 })(i); 1337 } 1338 } 1339 1340 if (that._elements["pause"]) { 1341 if (that._properties.autoplay) { 1342 that._elements["pause"].addEventListener("click", onPauseClick); 1343 } 1344 } 1345 1346 if (that._elements["play"]) { 1347 if (that._properties.autoplay) { 1348 that._elements["play"].addEventListener("click", onPlayClick); 1349 } 1350 } 1351 1352 that._elements.self.addEventListener("keydown", onKeyDown); 1353 1354 if (!that._properties.autopauseDisabled) { 1355 that._elements.self.addEventListener("mouseenter", onMouseEnter); 1356 that._elements.self.addEventListener("mouseleave", onMouseLeave); 1357 } 1358 } 1359 1360 /**
1361 * Handles carousel keydown events 1362 * 1363 * @private 1364 * @param {Object} event The keydown event 1365 */ 1366 function onKeyDown(event) { 1367 var index = that._active; 1368 var lastIndex = that._elements["indicator"].length - 1; 1369 1370 switch (event.keyCode) { 1371 case keyCodes.ARROW_LEFT: 1372 case keyCodes.ARROW_UP: 1373 event.preventDefault(); 1374 if (index > 0) { 1375 navigateAndFocusIndicator(index - 1); 1376 } 1377 break; 1378 case keyCodes.ARROW_RIGHT: 1379 case keyCodes.ARROW_DOWN: 1380 event.preventDefault(); 1381 if (index < lastIndex) { 1382 navigateAndFocusIndicator(index + 1); 1383 } 1384 break; 1385 case keyCodes.HOME: 1386 event.preventDefault(); 1387 navigateAndFocusIndicator(0); 1388 break; 1389 case keyCodes.END: 1390 event.preventDefault(); 1391 navigateAndFocusIndicator(lastIndex); 1392 break; 1393 case keyCodes.SPACE: 1394 if (that._properties.autoplay && (event.target !== that._elements["previous"] && event.target !== that._elements["next"])) { 1395 event.preventDefault(); 1396 if (!that._paused) { 1397 pause(); 1398 } else { 1399 play(); 1400 } 1401 } 1402 if (event.target === that._elements["pause"]) { 1403 that._elements["play"].focus(); 1404 } 1405 if (event.target === that._elements["play"]) { 1406 that._elements["pause"].focus(); 1407 } 1408 break; 1409 default: 1410 return; 1411 } 1412 } 1413 1414 /** 1415 * Handles carousel mouseenter events 1416 * 1417 * @private 1418 * @param {Object} event The mouseenter event 1419 */ 1420 function onMouseEnter(event) { 1421 clearAutoplayInterval(); 1422 } 1423 1424 /** 1425 * Handles carousel mouseleave events 1426 * 1427 * @private 1428 * @param {Object} event The mouseleave event 1429 */ 1430 function onMouseLeave(event) { 1431 resetAutoplayInterval(); 1432 } 1433 1434 /** 1435 * Handles pause element click events 1436 * 1437 * @private 1438 * @param {Object} event The click event 1439 */ 1440 function onPauseClick(event) { 1441 pause(); 1442 that._elements["play"].focus(); 1443 } 1444 1445 /** 1446 * Handles play element click events 1447 * 1448 * @private 1449 * @param {Object} event The click event 1450 */ 1451 function onPlayClick() { 1452 play(); 1453 that._elements["pause"].focus(); 1454 } 1455 1456 /** 1457 * Pauses the playing of the Carousel. Sets {@code Carousel#_paused} marker. 1458 * Only relevant when autoplay is enabled 1459 * 1460 * @private 1461 */ 1462 function pause() { 1463 that._paused = true; 1464 clearAutoplayInterval(); 1465 refreshPlayPauseActions(); 1466 } 1467 1468 /** 1469 * Enables the playing of the Carousel. Sets {@code Carousel#_paused} marker. 1470 * Only relevant when autoplay is enabled 1471 * 1472 * @private 1473 */ 1474 function play() { 1475 that._paused = false; 1476 1477 // If the Carousel is hovered, don't begin auto transitioning until the next mouse leave event 1478 var hovered = false; 1479 if (that._elements.self.parentElement) { 1480 hovered = that._elements.self.parentElement.querySelector(":hover") === that._elements.self; 1481 } 1482 if (that._properties.autopauseDisabled || !hovered) { 1483 resetAutoplayInterval(); 1484 } 1485 1486 refreshPlayPauseActions(); 1487 } 1488 1489 /** 1490 * Refreshes the play/pause action markup based on the {@code Carousel#_paused} state 1491 * 1492 * @private 1493 */ 1494 function refreshPlayPauseActions() {
1495 setActionDisabled(that._elements["pause"], that._paused); 1496 setActionDisabled(that._elements["play"], !that._paused); 1497 } 1498 1499 /** 1500 * Refreshes the item markup based on the current {@code Carousel#_active} index 1501 * 1502 * @private 1503 */ 1504 function refreshActive() { 1505 var items = that._elements["item"]; 1506 var indicators = that._elements["indicator"]; 1507 1508 if (items) { 1509 if (Array.isArray(items)) { 1510 for (var i = 0; i < items.length; i++) { 1511 if (i === parseInt(that._active)) { 1512 items[i].classList.add("cmp-carousel__item--active"); 1513 items[i].removeAttribute("aria-hidden"); 1514 indicators[i].classList.add("cmp-carousel__indicator--active"); 1515 indicators[i].setAttribute("aria-selected", true); 1516 indicators[i].setAttribute("tabindex", "0"); 1517 } else { 1518 items[i].classList.remove("cmp-carousel__item--active"); 1519 items[i].setAttribute("aria-hidden", true); 1520 indicators[i].classList.remove("cmp-carousel__indicator--active"); 1521 indicators[i].setAttribute("aria-selected", false); 1522 indicators[i].setAttribute("tabindex", "-1"); 1523 } 1524 } 1525 } else { 1526 // only one item 1527 items.classList.add("cmp-carousel__item--active"); 1528 indicators.classList.add("cmp-carousel__indicator--active"); 1529 } 1530 } 1531 } 1532 1533 /** 1534 * Focuses the element and prevents scrolling the element into view 1535 * 1536 * @param {HTMLElement} element Element to focus 1537 */ 1538 function focusWithoutScroll(element) { 1539 var x = window.scrollX || window.pageXOffset; 1540 var y = window.scrollY || window.pageYOffset; 1541 element.focus(); 1542 window.scrollTo(x, y); 1543 } 1544 1545 /** 1546 * Retrieves the next active index, with looping 1547 * 1548 * @private 1549 * @returns {Number} Index of the next carousel item 1550 */ 1551 function getNextIndex() { 1552 return that._active === (that._elements["item"].length - 1) ? 0 : that._active + 1; 1553 } 1554 1555 /** 1556 * Retrieves the previous active index, with looping 1557 * 1558 * @private 1559 * @returns {Number} Index of the previous carousel item 1560 */ 1561 function getPreviousIndex() { 1562 return that._active === 0 ? (that._elements["item"].length - 1) : that._active - 1; 1563 } 1564 1565 /** 1566 * Navigates to the item at the provided index 1567 * 1568 * @private 1569 * @param {Number} index The index of the item to navigate to 1570 */ 1571 function navigate(index) { 1572 if (index < 0 || index > (that._elements["item"].length - 1)) { 1573 return; 1574 } 1575 1576 that._active = index; 1577 refreshActive(); 1578 1579 if (dataLayerEnabled) { 1580 var carouselId = that._elements.self.id; 1581 var activeItem = getDataLayerId(that._elements.item[index].dataset.cmpDataLayer); 1582 var updatePayload = { component: {} }; 1583 updatePayload.component[carouselId] = { shownItems: [activeItem] }; 1584 1585 var removePayload = { component: {} }; 1586 removePayload.component[carouselId] = { shownItems: undefined }; 1587 1588 dataLayer.push(removePayload); 1589 dataLayer.push(updatePayload); 1590 } 1591 1592 // reset the autoplay transition interval following navigation, if not already hovering the carousel 1593 if (that._elements.self.parentElement) { 1594 if (that._elements.self.parentElement.querySelector(":hover") !== that._elements.self) { 1595 resetAutoplayInterval(); 1596 } 1597 } 1598 } 1599 1600 /** 1601 * Navigates to the item at the provided index and ensures the active indicator gains focus 1602 * 1603 * @private 1604 * @param {Number} index The index of the item to navigate to 1605 */ 1606 function navigateAndFocusIndicator(index) { 1607 navigate(index); 1608 focusWithoutScroll(that._elements["indicator"][index]); 1609 1610 if (dataLayerEnabled) { 1611 dataLayer.push({ 1612 event: "cmp:show", 1613 eventInfo: { 1614 path: "component." + getDataLayerId(that._elements.item[index].dataset.cmpDataLayer) 1615 } 1616 }); 1617 } 1618 } 1619 1620 /** 1621 * Starts/resets automatic slide transition interval 1622 * 1623 * @private 1624 */ 1625 function resetAutoplayInterval() { 1626 if (that._paused || !that._properties.autoplay) { 1627 return; 1628 } 1629 clearAutoplayInterval(); 1630 that._autoplayIntervalId = window.setInterval(function() { 1631 if (document.visibilityState && document.hidden) { 1632 return; 1633 } 1634 var indicators = that._elements["indicators"]; 1635 if (indicators !== document.activeElement && indicators.contains(document.activeElement)) { 1636 // if an indicator has focus, ensure we switch focus following navigation 1637 navigateAndFocusIndicator(getNextIndex()); 1638 } else { 1639 navigate(getNextIndex()); 1640 } 1641 }, that._properties.delay); 1642 } 1643 1644 /** 1645 * Clears/pauses automatic slide transition interval 1646 * 1647 * @private 1648 */ 1649 function clearAutoplayInterval() { 1650 window.clearInterval(that._autoplayIntervalId); 1651 that._autoplayIntervalId = null; 1652 } 1653 1654 /** 1655 * Sets the disabled state for an action and toggles the appropriate CSS classes 1656 * 1657 * @private 1658 * @param {HTMLElement} action Action to disable 1659 * @param {Boolean} [disable] {@code true} to disable, {@code false} to enable 1660 */ 1661 function setActionDisabled(action, disable) { 1662 if (!action) { 1663 return; 1664 } 1665 if (disable !== false) { 1666 action.disabled = true; 1667 action.classList.add("cmp-carousel__action--disabled"); 1668 } else { 1669 action.disabled = false;
1670 action.classList.remove("cmp-carousel__action--disabled"); 1671 } 1672 } 1673 } 1674 1675 /** 1676 * Reads options data from the Carousel wrapper element, defined via {@code data-cmp-*} data attributes 1677 * 1678 * @private 1679 * @param {HTMLElement} element The Carousel element to read options data from 1680 * @returns {Object} The options read from the component data attributes 1681 */ 1682 function readData(element) { 1683 var data = element.dataset; 1684 var options = []; 1685 var capitalized = IS; 1686 capitalized = capitalized.charAt(0).toUpperCase() + capitalized.slice(1); 1687 var reserved = ["is", "hook" + capitalized]; 1688 1689 for (var key in data) { 1690 if (data.hasOwnProperty(key)) { 1691 var value = data[key]; 1692 1693 if (key.indexOf(NS) === 0) { 1694 key = key.slice(NS.length); 1695 key = key.charAt(0).toLowerCase() + key.substring(1); 1696 1697 if (reserved.indexOf(key) === -1) { 1698 options[key] = value; 1699 } 1700 } 1701 } 1702 } 1703 1704 return options; 1705 } 1706 1707 /** 1708 * Parses the dataLayer string and returns the ID 1709 * 1710 * @private 1711 * @param {String} componentDataLayer the dataLayer string 1712 * @returns {String} dataLayerId or undefined 1713 */ 1714 function getDataLayerId(componentDataLayer) { 1715 return Object.keys(JSON.parse(componentDataLayer))[0]; 1716 } 1717 1718 /** 1719 * Document ready handler and DOM mutation observers. Initializes Carousel components as necessary. 1720 * 1721 * @private 1722 */ 1723 function onDocumentReady() { 1724 dataLayerEnabled = document.body.hasAttribute("data-cmp-data-layer-enabled"); 1725 dataLayer = (dataLayerEnabled)? window.adobeDataLayer = window.adobeDataLayer || [] : undefined; 1726 1727 var elements = document.querySelectorAll(selectors.self); 1728 for (var i = 0; i < elements.length; i++) { 1729 new Carousel({ element: elements[i], options: readData(elements[i]) }); 1730 } 1731 1732 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; 1733 var body = document.querySelector("body"); 1734 var observer = new MutationObserver(function(mutations) { 1735 mutations.forEach(function(mutation) { 1736 // needed for IE 1737 var nodesArray = [].slice.call(mutation.addedNodes); 1738 if (nodesArray.length > 0) { 1739 nodesArray.forEach(function(addedNode) { 1740 if (addedNode.querySelectorAll) { 1741 var elementsArray = [].slice.call(addedNode.querySelectorAll(selectors.self)); 1742 elementsArray.forEach(function(element) { 1743 new Carousel({ element: element, options: readData(element) }); 1744 }); 1745 } 1746 }); 1747 } 1748 }); 1749 }); 1750 1751 observer.observe(body, { 1752 subtree: true, 1753 childList: true, 1754 characterData: true 1755 }); 1756 } 1757 1758 if (document.readyState !== "loading") { 1759 onDocumentReady(); 1760 } else { 1761 document.addEventListener("DOMContentLoaded", onDocumentReady); 1762 } 1763 1764}()); 1765 1766/******************************************************************************* 1767 * Copyright 2017 Adobe 1768 * 1769 * Licensed under the Apache License, Version 2.0 (the "License"); 1770 * you may not use this file except in compliance with the License. 1771 * You may obtain a copy of the License at 1772 * 1773 * http://www.apache.org/licenses/LICENSE-2.0 1774 * 1775 * Unless required by applicable law or agreed to in writing, software 1776 * distributed under the License is distributed on an "AS IS" BASIS, 1777 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1778 * See the License for the specific language governing permissions and 1779 * limitations under the License. 1780 ******************************************************************************/ 1781if (window.Element && !Element.prototype.closest) { 1782 // eslint valid-jsdoc: "off" 1783 Element.prototype.closest = 1784 function(s) { 1785 "use strict"; 1786 var matches = (this.document || this.ownerDocument).querySelectorAll(s); 1787 var el = this; 1788 var i; 1789 do { 1790 i = matches.length; 1791 while (--i >= 0 && matches.item(i) !== el) { 1792 // continue 1793 } 1794 } while ((i < 0) && (el = el.parentElement)); 1795 return el; 1796 }; 1797} 1798 1799if (window.Element && !Element.prototype.matches) { 1800 Element.prototype.matches = 1801 Element.prototype.matchesSelector || 1802 Element.prototype.mozMatchesSelector || 1803 Element.prototype.msMatchesSelector || 1804 Element.prototype.oMatchesSelector || 1805 Element.prototype.webkitMatchesSelector || 1806 function(s) { 1807 "use strict"; 1808 var matches = (this.document || this.ownerDocument).querySelectorAll(s); 1809 var i = matches.length; 1810 while (--i >= 0 && matches.item(i) !== this) { 1811 // continue 1812 } 1813 return i > -1; 1814 }; 1815} 1816 1817if (!Object.assign) { 1818 Object.assign = function(target, varArgs) { // .length of function is 2 1819 "use strict"; 1820 if (target === null) { 1821 throw new TypeError("Cannot convert undefined or null to object"); 1822 } 1823 1824 var to = Object(target); 1825 1826 for (var index = 1; index < arguments.length; index++) { 1827 var nextSource = arguments[index]; 1828 1829 if (nextSource !== null) { 1830 for (var nextKey in nextSource) { 1831 if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) { 1832 to[nextKey] = nextSource[nextKey]; 1833 } 1834 } 1835 } 1836 } 1837 return to; 1838 }; 1839} 1840 1841(function(arr) { 1842 "use strict"; 1843 arr.forEach(function(item) { 1844 if (item.hasOwnProperty("remove")) { 1845 return; 1846 } 1847 Object.defineProperty(item, "remove", { 1848 configurable: true, 1849 enumerable: true, 1850 writable: true, 1851 value: function remove() { 1852 this.parentNode.removeChild(this); 1853 } 1854 }); 1855 }); 1856})([Element.prototype, CharacterData.prototype, DocumentType.prototype]); 1857 1858/******************************************************************************* 1859 * Copyright 2016 Adobe 1860 * 1861 * Licensed under the Apache License, Version 2.0 (the "License");
1862 * you may not use this file except in compliance with the License. 1863 * You may obtain a copy of the License at 1864 * 1865 * http://www.apache.org/licenses/LICENSE-2.0 1866 * 1867 * Unless required by applicable law or agreed to in writing, software 1868 * distributed under the License is distributed on an "AS IS" BASIS, 1869 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1870 * See the License for the specific language governing permissions and 1871 * limitations under the License. 1872 ******************************************************************************/ 1873(function() { 1874 "use strict"; 1875 1876 var NS = "cmp"; 1877 var IS = "image"; 1878 1879 var EMPTY_PIXEL = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"; 1880 var LAZY_THRESHOLD_DEFAULT = 0; 1881 var SRC_URI_TEMPLATE_WIDTH_VAR = "{.width}"; 1882 1883 var selectors = { 1884 self: "[data-" + NS + '-is="' + IS + '"]', 1885 image: '[data-cmp-hook-image="image"]', 1886 map: '[data-cmp-hook-image="map"]', 1887 area: '[data-cmp-hook-image="area"]' 1888 }; 1889 1890 var lazyLoader = { 1891 "cssClass": "cmp-image__image--is-loading", 1892 "style": { 1893 "height": 0, 1894 "padding-bottom": "" // will be replaced with % ratio 1895 } 1896 }; 1897 1898 var properties = { 1899 /** 1900 * An array of alternative image widths (in pixels). 1901 * Used to replace a {.width} variable in the src property with an optimal width if a URI template is provided. 1902 * 1903 * @memberof Image 1904 * @type {Number[]} 1905 * @default [] 1906 */ 1907 "widths": { 1908 "default": [], 1909 "transform": function(value) { 1910 var widths = []; 1911 value.split(",").forEach(function(item) { 1912 item = parseFloat(item); 1913 if (!isNaN(item)) { 1914 widths.push(item); 1915 } 1916 }); 1917 return widths; 1918 } 1919 }, 1920 /** 1921 * Indicates whether the image should be rendered lazily. 1922 * 1923 * @memberof Image 1924 * @type {Boolean} 1925 * @default false 1926 */ 1927 "lazy": { 1928 "default": false, 1929 "transform": function(value) { 1930 return !(value === null || typeof value === "undefined"); 1931 } 1932 }, 1933 /** 1934 * Indicates image is DynamicMedia image. 1935 * 1936 * @memberof Image 1937 * @type {Boolean} 1938 * @default false 1939 */ 1940 "dmimage": { 1941 "default": false, 1942 "transform": function(value) { 1943 return !(value === null || typeof value === "undefined"); 1944 } 1945 }, 1946 /** 1947 * The lazy threshold. 1948 * This is the number of pixels, in advance of becoming visible, when an lazy-loading image should begin 1949 * to load. 1950 * 1951 * @memberof Image 1952 * @type {Number} 1953 * @default 0 1954 */ 1955 "lazythreshold": { 1956 "default": 0, 1957 "transform": function(value) { 1958 var val = parseInt(value); 1959 if (isNaN(val)) { 1960 return LAZY_THRESHOLD_DEFAULT; 1961 } 1962 return val; 1963 } 1964 }, 1965 /** 1966 * The image source. 1967 * 1968 * Can be a simple image source, or a URI template representation that 1969 * can be variable expanded - useful for building an image configuration with an alternative width. 1970 * e.g. '/path/image.coreimg{.width}.jpeg/1506620954214.jpeg' 1971 * 1972 * @memberof Image 1973 * @type {String} 1974 */ 1975 "src": { 1976 "transform": function(value) { 1977 return decodeURIComponent(value); 1978 } 1979 } 1980 }; 1981 1982 var devicePixelRatio = window.devicePixelRatio || 1; 1983 1984 function readData(element) { 1985 var data = element.dataset; 1986 var options = []; 1987 var capitalized = IS; 1988 capitalized = capitalized.charAt(0).toUpperCase() + capitalized.slice(1); 1989 var reserved = ["is", "hook" + capitalized]; 1990 1991 for (var key in data) { 1992 if (data.hasOwnProperty(key)) { 1993 var value = data[key]; 1994 1995 if (key.indexOf(NS) === 0) { 1996 key = key.slice(NS.length); 1997 key = key.charAt(0).toLowerCase() + key.substring(1); 1998 1999 if (reserved.indexOf(key) === -1) { 2000 options[key] = value; 2001 } 2002 } 2003 } 2004 } 2005 2006 return options; 2007 } 2008 2009 function Image(config) { 2010 var that = this; 2011 2012 var smartCrops = {}; 2013 2014 function init(config) { 2015 // prevents multiple initialization 2016 config.element.removeAttribute("data-" + NS + "-is"); 2017 2018 setupProperties(config.options); 2019 cacheElements(config.element); 2020 // check image is DM asset; if true try to make req=set 2021 if (config.options.src && config.options.hasOwnProperty("dmimage") && (config.options["smartcroprendition"] === "SmartCrop:Auto")) { 2022 var request = new XMLHttpRequest(); 2023 var url = decodeURIComponent(config.options.src).split(SRC_URI_TEMPLATE_WIDTH_VAR)[0] + "?req=set,json"; 2024 2025 2026 request.open("GET", url, false); 2027 request.onload = function() { 2028 if (request.status >= 200 && request.status < 400) { 2029 // success status 2030 var responseText = request.responseText; 2031 var rePayload = new RegExp(/^(?:\/\*jsonp\*\/)?\s*([^()]+)\(([\s\S]+),\s*"[0-9]*"\);?$/gmi); 2032 var rePayloadJSON = new RegExp(/^{[\s\S]*}$/gmi); 2033 var resPayload = rePayload.exec(responseText); 2034 var payload; 2035 if (resPayload) { 2036 var payloadStr = resPayload[2]; 2037 if (rePayloadJSON.test(payloadStr)) { 2038 payload = JSON.parse(payloadStr); 2039 } 2040 2041 } 2042 // check "relation" - only in case of smartcrop preset 2043 if (payload && payload.set.relation && payload.set.relation.length > 0) { 2044 for (var i = 0; i < payload.set.relation.length; i++) { 2045 smartCrops[parseInt(payload.set.relation[i].userdata.SmartCropWidth)] = 2046 ":" + payload.set.relation[i].userdata.SmartCropDef; 2047 } 2048 } 2049 } else { 2050 // error status 2051 } 2052 }; 2053 request.send(); 2054 } 2055 2056 if (!that._elements.noscript) { 2057 return; 2058 } 2059 2060 that._elements.container = that._elements.link ? that._elements.link : that._elements.self; 2061 2062 unwrapNoScript(); 2063 2064 if (that._properties.lazy) { 2065 addLazyLoader(); 2066 } 2067 2068 if (that._elements.map) { 2069 that._elements.image.addEventListener("load", onLoad); 2070 } 2071 2072 window.addEventListener("resize", onWindowResize); 2073 ["focus", "click", "load", "transitionend", "animationend", "scroll"].forEach(function(name) { 2074 document.addEventListener(name, that.update); 2075 }); 2076 2077 that._elements.image.addEventListener("cmp-image-redraw", that.update);
2078 that.update(); 2079 } 2080 2081 function loadImage() { 2082 var hasWidths = (that._properties.widths && that._properties.widths.length > 0) || Object.keys(smartCrops).length > 0; 2083 var replacement; 2084 if (Object.keys(smartCrops).length > 0) { 2085 var optimalWidth = getOptimalWidth(Object.keys(smartCrops)); 2086 replacement = smartCrops[optimalWidth]; 2087 } else { 2088 replacement = hasWidths ? (that._properties.dmimage ? "" : ".") + getOptimalWidth(that._properties.widths) : ""; 2089 } 2090 var url = that._properties.src.replace(SRC_URI_TEMPLATE_WIDTH_VAR, replacement); 2091 2092 var imgSrcAttribute = that._elements.image.getAttribute("src"); 2093 if (imgSrcAttribute === null || imgSrcAttribute === EMPTY_PIXEL) { 2094 that._elements.image.setAttribute("src", url); 2095 if (!hasWidths) { 2096 window.removeEventListener("scroll", that.update); 2097 } 2098 } 2099 2100 if (that._lazyLoaderShowing) { 2101 that._elements.image.addEventListener("load", removeLazyLoader); 2102 } 2103 } 2104 2105 function getOptimalWidth(widths) { 2106 var container = that._elements.self; 2107 var containerWidth = container.clientWidth; 2108 while (containerWidth === 0 && container.parentNode) { 2109 container = container.parentNode; 2110 containerWidth = container.clientWidth; 2111 } 2112 var optimalWidth = containerWidth * devicePixelRatio; 2113 var len = widths.length; 2114 var key = 0; 2115 2116 while ((key < len - 1) && (widths[key] < optimalWidth)) { 2117 key++; 2118 } 2119 2120 return widths[key].toString(); 2121 } 2122 2123 function addLazyLoader() { 2124 var width = that._elements.image.getAttribute("width"); 2125 var height = that._elements.image.getAttribute("height"); 2126 2127 if (width && height) { 2128 var ratio = (height / width) * 100; 2129 var styles = lazyLoader.style; 2130 2131 styles["padding-bottom"] = ratio + "%"; 2132 2133 for (var s in styles) { 2134 if (styles.hasOwnProperty(s)) { 2135 that._elements.image.style[s] = styles[s]; 2136 } 2137 } 2138 } 2139 that._elements.image.setAttribute("src", EMPTY_PIXEL); 2140 that._elements.image.classList.add(lazyLoader.cssClass); 2141 that._lazyLoaderShowing = true; 2142 } 2143 2144 function unwrapNoScript() { 2145 var markup = decodeNoscript(that._elements.noscript.textContent.trim()); 2146 var parser = new DOMParser(); 2147 2148 // temporary document avoids requesting the image before removing its src 2149 var temporaryDocument = parser.parseFromString(markup, "text/html"); 2150 var imageElement = temporaryDocument.querySelector(selectors.image); 2151 imageElement.removeAttribute("src"); 2152 that._elements.container.insertBefore(imageElement, that._elements.noscript); 2153 2154 var mapElement = temporaryDocument.querySelector(selectors.map); 2155 if (mapElement) { 2156 that._elements.container.insertBefore(mapElement, that._elements.noscript); 2157 } 2158 2159 that._elements.noscript.parentNode.removeChild(that._elements.noscript); 2160 if (that._elements.container.matches(selectors.image)) { 2161 that._elements.image = that._elements.container; 2162 } else { 2163 that._elements.image = that._elements.container.querySelector(selectors.image); 2164 } 2165 2166 that._elements.map = that._elements.container.querySelector(selectors.map); 2167 that._elements.areas = that._elements.container.querySelectorAll(selectors.area); 2168 } 2169 2170 function removeLazyLoader() { 2171 that._elements.image.classList.remove(lazyLoader.cssClass); 2172 for (var property in lazyLoader.style) { 2173 if (lazyLoader.style.hasOwnProperty(property)) { 2174 that._elements.image.style[property] = ""; 2175 } 2176 } 2177 that._elements.image.removeEventListener("load", removeLazyLoader); 2178 that._lazyLoaderShowing = false;
2179 } 2180 2181 function isLazyVisible() { 2182 if (that._elements.container.offsetParent === null) { 2183 return false; 2184 } 2185 2186 var wt = window.pageYOffset; 2187 var wb = wt + document.documentElement.clientHeight; 2188 var et = that._elements.container.getBoundingClientRect().top + wt; 2189 var eb = et + that._elements.container.clientHeight; 2190 2191 return eb >= wt - that._properties.lazythreshold && et <= wb + that._properties.lazythreshold; 2192 } 2193 2194 function resizeAreas() { 2195 if (that._elements.areas && that._elements.areas.length > 0) { 2196 for (var i = 0; i < that._elements.areas.length; i++) { 2197 var width = that._elements.image.width; 2198 var height = that._elements.image.height; 2199 2200 if (width && height) { 2201 var relcoords = that._elements.areas[i].dataset.cmpRelcoords; 2202 if (relcoords) { 2203 var relativeCoordinates = relcoords.split(","); 2204 var coordinates = new Array(relativeCoordinates.length); 2205 2206 for (var j = 0; j < coordinates.length; j++) { 2207 if (j % 2 === 0) { 2208 coordinates[j] = parseInt(relativeCoordinates[j] * width); 2209 } else { 2210 coordinates[j] = parseInt(relativeCoordinates[j] * height); 2211 } 2212 } 2213 2214 that._elements.areas[i].coords = coordinates; 2215 } 2216 } 2217 } 2218 } 2219 } 2220 2221 function cacheElements(wrapper) { 2222 that._elements = {}; 2223 that._elements.self = wrapper; 2224 var hooks = that._elements.self.querySelectorAll("[data-" + NS + "-hook-" + IS + "]"); 2225 2226 for (var i = 0; i < hooks.length; i++) { 2227 var hook = hooks[i]; 2228 var capitalized = IS; 2229 capitalized = capitalized.charAt(0).toUpperCase() + capitalized.slice(1); 2230 var key = hook.dataset[NS + "Hook" + capitalized]; 2231 that._elements[key] = hook; 2232 } 2233 } 2234 2235 function setupProperties(options) { 2236 that._properties = {}; 2237 2238 for (var key in properties) { 2239 if (properties.hasOwnProperty(key)) { 2240 var property = properties[key]; 2241 if (options && options[key] != null) { 2242 if (property && typeof property.transform === "function") { 2243 that._properties[key] = property.transform(options[key]); 2244 } else { 2245 that._properties[key] = options[key]; 2246 } 2247 } else { 2248 that._properties[key] = properties[key]["default"]; 2249 } 2250 } 2251 } 2252 } 2253 2254 function onWindowResize() { 2255 that.update(); 2256 resizeAreas(); 2257 } 2258 2259 function onLoad() { 2260 resizeAreas(); 2261 } 2262 2263 that.update = function() { 2264 if (that._properties.lazy) { 2265 if (isLazyVisible()) { 2266 loadImage(); 2267 } 2268 } else { 2269 loadImage(); 2270 } 2271 }; 2272 2273 if (config && config.element) { 2274 init(config); 2275 } 2276 } 2277 2278 function onDocumentReady() { 2279 var elements = document.querySelectorAll(selectors.self); 2280 for (var i = 0; i < elements.length; i++) { 2281 new Image({ element: elements[i], options: readData(elements[i]) }); 2282 } 2283 2284 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; 2285 var body = document.querySelector("body"); 2286 var observer = new MutationObserver(function(mutations) { 2287 mutations.forEach(function(mutation) { 2288 // needed for IE 2289 var nodesArray = [].slice.call(mutation.addedNodes); 2290 if (nodesArray.length > 0) { 2291 nodesArray.forEach(function(addedNode) { 2292 if (addedNode.querySelectorAll) { 2293 var elementsArray = [].slice.call(addedNode.querySelectorAll(selectors.self)); 2294 elementsArray.forEach(function(element) { 2295 new Image({ element: element, options: readData(element) }); 2296 }); 2297 } 2298 }); 2299 } 2300 }); 2301 }); 2302 2303 observer.observe(body, { 2304 subtree: true, 2305 childList: true, 2306 characterData: true 2307 }); 2308 } 2309 2310 if (document.readyState !== "loading") { 2311 onDocumentReady(); 2312 } else { 2313 document.addEventListener("DOMContentLoaded", onDocumentReady); 2314 } 2315 2316 /* 2317 on drag & drop of the component into a parsys, noscript's content will be escaped multiple times by the editor which creates 2318 the DOM for editing; the HTML parser cannot be used here due to the multiple escaping 2319 */ 2320 function decodeNoscript(text) { 2321 text = text.replace(/&(amp;)*lt;/g, "<"); 2322 text = text.replace(/&(amp;)*gt;/g, ">"); 2323 return text; 2324 } 2325 2326})(); 2327 2328 2329/******************************************************************************* 2330 * Copyright 2017 Adobe 2331 * 2332 * Licensed under the Apache License, Version 2.0 (the "License");
2333 * you may not use this file except in compliance with the License. 2334 * You may obtain a copy of the License at 2335 * 2336 * http://www.apache.org/licenses/LICENSE-2.0 2337 * 2338 * Unless required by applicable law or agreed to in writing, software 2339 * distributed under the License is distributed on an "AS IS" BASIS, 2340 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2341 * See the License for the specific language governing permissions and 2342 * limitations under the License. 2343 ******************************************************************************/ 2344if (window.Element && !Element.prototype.closest) { 2345 // eslint valid-jsdoc: "off" 2346 Element.prototype.closest = 2347 function(s) { 2348 "use strict"; 2349 var matches = (this.document || this.ownerDocument).querySelectorAll(s); 2350 var el = this; 2351 var i; 2352 do { 2353 i = matches.length; 2354 while (--i >= 0 && matches.item(i) !== el) { 2355 // continue 2356 } 2357 } while ((i < 0) && (el = el.parentElement)); 2358 return el; 2359 }; 2360} 2361 2362if (window.Element && !Element.prototype.matches) { 2363 Element.prototype.matches = 2364 Element.prototype.matchesSelector || 2365 Element.prototype.mozMatchesSelector || 2366 Element.prototype.msMatchesSelector || 2367 Element.prototype.oMatchesSelector || 2368 Element.prototype.webkitMatchesSelector || 2369 function(s) { 2370 "use strict"; 2371 var matches = (this.document || this.ownerDocument).querySelectorAll(s); 2372 var i = matches.length; 2373 while (--i >= 0 && matches.item(i) !== this) { 2374 // continue 2375 } 2376 return i > -1; 2377 }; 2378} 2379 2380if (!Object.assign) { 2381 Object.assign = function(target, varArgs) { // .length of function is 2 2382 "use strict"; 2383 if (target === null) { 2384 throw new TypeError("Cannot convert undefined or null to object"); 2385 } 2386 2387 var to = Object(target); 2388 2389 for (var index = 1; index < arguments.length; index++) { 2390 var nextSource = arguments[index]; 2391 2392 if (nextSource !== null) { 2393 for (var nextKey in nextSource) { 2394 if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) { 2395 to[nextKey] = nextSource[nextKey]; 2396 } 2397 } 2398 } 2399 } 2400 return to; 2401 }; 2402} 2403 2404(function(arr) { 2405 "use strict"; 2406 arr.forEach(function(item) { 2407 if (item.hasOwnProperty("remove")) { 2408 return; 2409 } 2410 Object.defineProperty(item, "remove", { 2411 configurable: true, 2412 enumerable: true, 2413 writable: true, 2414 value: function remove() { 2415 this.parentNode.removeChild(this); 2416 } 2417 }); 2418 }); 2419})([Element.prototype, CharacterData.prototype, DocumentType.prototype]); 2420 2421/******************************************************************************* 2422 * Copyright 2016 Adobe 2423 * 2424 * Licensed under the Apache License, Version 2.0 (the "License"); 2425 * you may not use this file except in compliance with the License. 2426 * You may obtain a copy of the License at 2427 * 2428 * http://www.apache.org/licenses/LICENSE-2.0 2429 * 2430 * Unless required by applicable law or agreed to in writing, software 2431 * distributed under the License is distributed on an "AS IS" BASIS, 2432 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2433 * See the License for the specific language governing permissions and 2434 * limitations under the License. 2435 ******************************************************************************/ 2436(function() { 2437 "use strict"; 2438 2439 var NS = "cmp"; 2440 var IS = "image"; 2441 2442 var EMPTY_PIXEL = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"; 2443 var LAZY_THRESHOLD_DEFAULT = 0; 2444 var SRC_URI_TEMPLATE_WIDTH_VAR = "{.width}"; 2445 2446 var selectors = { 2447 self: "[data-" + NS + '-is="' + IS + '"]', 2448 image: '[data-cmp-hook-image="image"]', 2449 map: '[data-cmp-hook-image="map"]', 2450 area: '[data-cmp-hook-image="area"]' 2451 }; 2452 2453 var lazyLoader = { 2454 "cssClass": "cmp-image__image--is-loading", 2455 "style": { 2456 "height": 0, 2457 "padding-bottom": "" // will be replaced with % ratio 2458 } 2459 }; 2460 2461 var properties = { 2462 /** 2463 * An array of alternative image widths (in pixels). 2464 * Used to replace a {.width} variable in the src property with an optimal width if a URI template is provided. 2465 * 2466 * @memberof Image 2467 * @type {Number[]} 2468 * @default [] 2469 */ 2470 "widths": { 2471 "default": [], 2472 "transform": function(value) { 2473 var widths = []; 2474 value.split(",").forEach(function(item) { 2475 item = parseFloat(item); 2476 if (!isNaN(item)) { 2477 widths.push(item); 2478 } 2479 }); 2480 return widths; 2481 } 2482 }, 2483 /** 2484 * Indicates whether the image should be rendered lazily. 2485 * 2486 * @memberof Image 2487 * @type {Boolean} 2488 * @default false 2489 */ 2490 "lazy": { 2491 "default": false, 2492 "transform": function(value) { 2493 return !(value === null || typeof value === "undefined"); 2494 } 2495 }, 2496 /** 2497 * Indicates image is DynamicMedia image. 2498 * 2499 * @memberof Image 2500 * @type {Boolean} 2501 * @default false 2502 */ 2503 "dmimage": { 2504 "default": false, 2505 "transform": function(value) { 2506 return !(value === null || typeof value === "undefined"); 2507 } 2508 }, 2509 /** 2510 * The lazy threshold. 2511 * This is the number of pixels, in advance of becoming visible, when an lazy-loading image should begin 2512 * to load. 2513 * 2514 * @memberof Image 2515 * @type {Number} 2516 * @default 0 2517 */ 2518 "lazythreshold": { 2519 "default": 0, 2520 "transform": function(value) { 2521 const val = parseInt(value); 2522 if (isNaN(val)) { 2523 return LAZY_THRESHOLD_DEFAULT; 2524 } 2525 return val; 2526 } 2527 }, 2528 /** 2529 * The image source. 2530 * 2531 * Can be a simple image source, or a URI template representation that 2532 * can be variable expanded - useful for building an image configuration with an alternative width. 2533 * e.g. '/path/image.coreimg{.width}.jpeg/1506620954214.jpeg' 2534 * 2535 * @memberof Image 2536 * @type {String} 2537 */ 2538 "src": { 2539 "transform": function(value) { 2540 return decodeURIComponent(value); 2541 } 2542 } 2543 }; 2544 2545 var devicePixelRatio = window.devicePixelRatio || 1; 2546 2547 function readData(element) { 2548 var data = element.dataset; 2549 var options = []; 2550 var capitalized = IS; 2551 capitalized = capitalized.charAt(0).toUpperCase() + capitalized.slice(1); 2552 var reserved = ["is", "hook" + capitalized]; 2553 2554 for (var key in data) { 2555 if (data.hasOwnProperty(key)) { 2556 var value = data[key]; 2557 2558 if (key.indexOf(NS) === 0) { 2559 key = key.slice(NS.length); 2560 key = key.charAt(0).toLowerCase() + key.substring(1); 2561 2562 if (reserved.indexOf(key) === -1) { 2563 options[key] = value; 2564 } 2565 } 2566 } 2567 } 2568 2569 return options; 2570 } 2571 2572 function Image(config) { 2573 var that = this; 2574 2575 var smartCrops = {}; 2576 2577 function init(config) { 2578 // prevents multiple initialization 2579 config.element.removeAttribute("data-" + NS + "-is"); 2580 2581 setupProperties(config.options); 2582 cacheElements(config.element); 2583 //check image is DM asset; if true try to make req=set 2584 if (config.options.src && config.options.hasOwnProperty("dmimage") && (config.options["smartcroprendition"] === "SmartCrop:Auto")) { 2585 var request = new XMLHttpRequest(); 2586 var url = decodeURIComponent(config.options.src).split(SRC_URI_TEMPLATE_WIDTH_VAR)[0] + "?req=set,json"; 2587 2588 2589 request.open("GET", url, false); 2590 request.onload = function() { 2591 if (request.status >= 200 && request.status < 400) { 2592 // success status 2593 var responseText = request.responseText; 2594 var rePayload = new RegExp(/^(?:\/\*jsonp\*\/)?\s*([^()]+)\(([\s\S]+),\s*"[0-9]*"\);?$/gmi); 2595 var rePayloadJSON = new RegExp(/^{[\s\S]*}$/gmi); 2596 var resPayload = rePayload.exec(responseText); 2597 var smartcropList = ""; 2598 var payload; 2599 if (resPayload) { 2600 var payloadStr = resPayload[2]; 2601 if (rePayloadJSON.test(payloadStr)) { 2602 payload = JSON.parse(payloadStr); 2603 } 2604 2605 } 2606 //check "relation" - only in case of smartcrop preset 2607 if (payload && payload.set.relation && payload.set.relation.length > 0) { 2608 for(var i = 0; i < payload.set.relation.length ; i++) { 2609 smartcropList += payload.set.relation[i].n +"\n"; 2610 smartCrops[parseInt(payload.set.relation[i].userdata.SmartCropWidth)] = ":" + payload.set.relation[i].userdata.SmartCropDef; 2611 } 2612 } 2613 } else { 2614 // error status 2615 } 2616 }; 2617 request.send(); 2618 } 2619 2620 if (!that._elements.noscript) { 2621 return; 2622 } 2623 2624 that._elements.container = that._elements.link ? that._elements.link : that._elements.self; 2625 2626 unwrapNoScript(); 2627 2628 if (that._properties.lazy) { 2629 addLazyLoader(); 2630 } 2631 2632 if (that._elements.map) { 2633 that._elements.image.addEventListener("load", onLoad); 2634 } 2635 2636 window.addEventListener("resize", onWindowResize); 2637 ["focus", "click", "load", "transitionend", "animationend", "scroll"].forEach(function(name) { 2638 document.addEventListener(name, that.update); 2639 }); 2640 2641 that._elements.image.addEventListener("cmp-image-redraw", that.update);
2642 that.update(); 2643 } 2644 2645 function loadImage() { 2646 var hasWidths = (that._properties.widths && that._properties.widths.length > 0) || Object.keys(smartCrops).length > 0; 2647 var replacement; 2648 if (Object.keys(smartCrops).length > 0) { 2649 var optimalWidth = getOptimalWidth(Object.keys(smartCrops)); 2650 replacement = smartCrops[optimalWidth]; 2651 } else { 2652 replacement = hasWidths ? (that._properties.dmimage ? "" : ".") + getOptimalWidth(that._properties.widths) : ""; 2653 } 2654 var url = that._properties.src.replace(SRC_URI_TEMPLATE_WIDTH_VAR, replacement); 2655 2656 if (that._elements.image.getAttribute("src") !== url) { 2657 that._elements.image.setAttribute("src", url); 2658 if (!hasWidths) { 2659 window.removeEventListener("scroll", that.update); 2660 } 2661 } 2662 2663 if (that._lazyLoaderShowing) { 2664 that._elements.image.addEventListener("load", removeLazyLoader); 2665 } 2666 } 2667 2668 function getOptimalWidth(widths) { 2669 var container = that._elements.self; 2670 var containerWidth = container.clientWidth; 2671 while (containerWidth === 0 && container.parentNode) { 2672 container = container.parentNode; 2673 containerWidth = container.clientWidth; 2674 } 2675 var optimalWidth = containerWidth * devicePixelRatio; 2676 var len = widths.length; 2677 var key = 0; 2678 2679 while ((key < len - 1) && (widths[key] < optimalWidth)) { 2680 key++; 2681 } 2682 2683 return widths[key].toString(); 2684 } 2685 2686 function addLazyLoader() { 2687 var width = that._elements.image.getAttribute("width"); 2688 var height = that._elements.image.getAttribute("height"); 2689 2690 if (width && height) { 2691 var ratio = (height / width) * 100; 2692 var styles = lazyLoader.style; 2693 2694 styles["padding-bottom"] = ratio + "%"; 2695 2696 for (var s in styles) { 2697 if (styles.hasOwnProperty(s)) { 2698 that._elements.image.style[s] = styles[s]; 2699 } 2700 } 2701 } 2702 that._elements.image.setAttribute("src", EMPTY_PIXEL); 2703 that._elements.image.classList.add(lazyLoader.cssClass); 2704 that._lazyLoaderShowing = true; 2705 } 2706 2707 function unwrapNoScript() { 2708 var markup = decodeNoscript(that._elements.noscript.textContent.trim()); 2709 var parser = new DOMParser(); 2710 2711 // temporary document avoids requesting the image before removing its src 2712 var temporaryDocument = parser.parseFromString(markup, "text/html"); 2713 var imageElement = temporaryDocument.querySelector(selectors.image); 2714 imageElement.removeAttribute("src"); 2715 that._elements.container.insertBefore(imageElement, that._elements.noscript); 2716 2717 var mapElement = temporaryDocument.querySelector(selectors.map); 2718 if (mapElement) { 2719 that._elements.container.insertBefore(mapElement, that._elements.noscript); 2720 } 2721 2722 that._elements.noscript.parentNode.removeChild(that._elements.noscript); 2723 if (that._elements.container.matches(selectors.image)) { 2724 that._elements.image = that._elements.container; 2725 } else { 2726 that._elements.image = that._elements.container.querySelector(selectors.image); 2727 } 2728 2729 that._elements.map = that._elements.container.querySelector(selectors.map); 2730 that._elements.areas = that._elements.container.querySelectorAll(selectors.area); 2731 } 2732 2733 function removeLazyLoader() { 2734 that._elements.image.classList.remove(lazyLoader.cssClass); 2735 for (var property in lazyLoader.style) { 2736 if (lazyLoader.style.hasOwnProperty(property)) { 2737 that._elements.image.style[property] = ""; 2738 } 2739 } 2740 that._elements.image.removeEventListener("load", removeLazyLoader); 2741 that._lazyLoaderShowing = false;
2742 } 2743 2744 function isLazyVisible() { 2745 if (that._elements.container.offsetParent === null) { 2746 return false; 2747 } 2748 2749 var wt = window.pageYOffset; 2750 var wb = wt + document.documentElement.clientHeight; 2751 var et = that._elements.container.getBoundingClientRect().top + wt; 2752 var eb = et + that._elements.container.clientHeight; 2753 2754 return eb >= wt - that._properties.lazythreshold && et <= wb + that._properties.lazythreshold; 2755 } 2756 2757 function resizeAreas() { 2758 if (that._elements.areas && that._elements.areas.length > 0) { 2759 for (var i = 0; i < that._elements.areas.length; i++) { 2760 var width = that._elements.image.width; 2761 var height = that._elements.image.height; 2762 2763 if (width && height) { 2764 var relcoords = that._elements.areas[i].dataset.cmpRelcoords; 2765 if (relcoords) { 2766 var relativeCoordinates = relcoords.split(","); 2767 var coordinates = new Array(relativeCoordinates.length); 2768 2769 for (var j = 0; j < coordinates.length; j++) { 2770 if (j % 2 === 0) { 2771 coordinates[j] = parseInt(relativeCoordinates[j] * width); 2772 } else { 2773 coordinates[j] = parseInt(relativeCoordinates[j] * height); 2774 } 2775 } 2776 2777 that._elements.areas[i].coords = coordinates; 2778 } 2779 } 2780 } 2781 } 2782 } 2783 2784 function cacheElements(wrapper) { 2785 that._elements = {}; 2786 that._elements.self = wrapper; 2787 var hooks = that._elements.self.querySelectorAll("[data-" + NS + "-hook-" + IS + "]"); 2788 2789 for (var i = 0; i < hooks.length; i++) { 2790 var hook = hooks[i]; 2791 var capitalized = IS; 2792 capitalized = capitalized.charAt(0).toUpperCase() + capitalized.slice(1); 2793 var key = hook.dataset[NS + "Hook" + capitalized]; 2794 that._elements[key] = hook; 2795 } 2796 } 2797 2798 function setupProperties(options) { 2799 that._properties = {}; 2800 2801 for (var key in properties) { 2802 if (properties.hasOwnProperty(key)) { 2803 var property = properties[key]; 2804 if (options && options[key] != null) { 2805 if (property && typeof property.transform === "function") { 2806 that._properties[key] = property.transform(options[key]); 2807 } else { 2808 that._properties[key] = options[key]; 2809 } 2810 } else { 2811 that._properties[key] = properties[key]["default"]; 2812 } 2813 } 2814 } 2815 } 2816 2817 function onWindowResize() { 2818 that.update(); 2819 resizeAreas(); 2820 } 2821 2822 function onLoad() { 2823 resizeAreas(); 2824 } 2825 2826 that.update = function() { 2827 if (that._properties.lazy) { 2828 if (isLazyVisible()) { 2829 loadImage(); 2830 } 2831 } else { 2832 loadImage(); 2833 } 2834 }; 2835 2836 if (config && config.element) { 2837 init(config); 2838 } 2839 } 2840 2841 function onDocumentReady() { 2842 var elements = document.querySelectorAll(selectors.self); 2843 for (var i = 0; i < elements.length; i++) { 2844 new Image({ element: elements[i], options: readData(elements[i]) }); 2845 } 2846 2847 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; 2848 var body = document.querySelector("body"); 2849 var observer = new MutationObserver(function(mutations) { 2850 mutations.forEach(function(mutation) { 2851 // needed for IE 2852 var nodesArray = [].slice.call(mutation.addedNodes); 2853 if (nodesArray.length > 0) { 2854 nodesArray.forEach(function(addedNode) { 2855 if (addedNode.querySelectorAll) { 2856 var elementsArray = [].slice.call(addedNode.querySelectorAll(selectors.self)); 2857 elementsArray.forEach(function(element) { 2858 new Image({ element: element, options: readData(element) }); 2859 }); 2860 } 2861 }); 2862 } 2863 }); 2864 }); 2865 2866 observer.observe(body, { 2867 subtree: true, 2868 childList: true, 2869 characterData: true 2870 }); 2871 } 2872 2873 if (document.readyState !== "loading") { 2874 onDocumentReady(); 2875 } else { 2876 document.addEventListener("DOMContentLoaded", onDocumentReady); 2877 } 2878 2879 /* 2880 on drag & drop of the component into a parsys, noscript's content will be escaped multiple times by the editor which creates 2881 the DOM for editing; the HTML parser cannot be used here due to the multiple escaping 2882 */ 2883 function decodeNoscript(text) { 2884 text = text.replace(/&(amp;)*lt;/g, "<"); 2885 text = text.replace(/&(amp;)*gt;/g, ">"); 2886 return text; 2887 } 2888 2889})(); 2890 2891/******************************************************************************* 2892 * Copyright 2017 Adobe 2893 * 2894 * Licensed under the Apache License, Version 2.0 (the "License");
2895 * you may not use this file except in compliance with the License. 2896 * You may obtain a copy of the License at 2897 * 2898 * http://www.apache.org/licenses/LICENSE-2.0 2899 * 2900 * Unless required by applicable law or agreed to in writing, software 2901 * distributed under the License is distributed on an "AS IS" BASIS, 2902 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2903 * See the License for the specific language governing permissions and 2904 * limitations under the License. 2905 ******************************************************************************/ 2906(function() { 2907 "use strict"; 2908 2909 var NS = "cmp"; 2910 var IS = "search"; 2911 2912 var DELAY = 300; // time before fetching new results when the user is typing a search string 2913 var LOADING_DISPLAY_DELAY = 300; // minimum time during which the loading indicator is displayed 2914 var PARAM_RESULTS_OFFSET = "resultsOffset"; 2915 2916 var keyCodes = { 2917 TAB: 9, 2918 ENTER: 13, 2919 ESCAPE: 27, 2920 ARROW_UP: 38, 2921 ARROW_DOWN: 40 2922 }; 2923 2924 var selectors = { 2925 self: "[data-" + NS + '-is="' + IS + '"]', 2926 item: { 2927 self: "[data-" + NS + "-hook-" + IS + '="item"]', 2928 title: "[data-" + NS + "-hook-" + IS + '="itemTitle"]', 2929 focused: "." + NS + "-search__item--is-focused" 2930 } 2931 }; 2932 2933 var properties = { 2934 /** 2935 * The minimum required length of the search term before results are fetched. 2936 * 2937 * @memberof Search 2938 * @type {Number} 2939 * @default 3 2940 */ 2941 minLength: { 2942 "default": 3, 2943 transform: function(value) { 2944 value = parseFloat(value); 2945 return isNaN(value) ? null : value; 2946 } 2947 }, 2948 /** 2949 * The maximal number of results fetched by a search request. 2950 * 2951 * @memberof Search 2952 * @type {Number} 2953 * @default 10 2954 */ 2955 resultsSize: { 2956 "default": 10, 2957 transform: function(value) { 2958 value = parseFloat(value); 2959 return isNaN(value) ? null : value; 2960 } 2961 } 2962 }; 2963 2964 var idCount = 0; 2965 2966 function readData(element) { 2967 var data = element.dataset; 2968 var options = []; 2969 var capitalized = IS; 2970 capitalized = capitalized.charAt(0).toUpperCase() + capitalized.slice(1); 2971 var reserved = ["is", "hook" + capitalized]; 2972 2973 for (var key in data) { 2974 if (data.hasOwnProperty(key)) { 2975 var value = data[key]; 2976 2977 if (key.indexOf(NS) === 0) { 2978 key = key.slice(NS.length); 2979 key = key.charAt(0).toLowerCase() + key.substring(1); 2980 2981 if (reserved.indexOf(key) === -1) { 2982 options[key] = value; 2983 } 2984 } 2985 } 2986 } 2987 2988 return options; 2989 } 2990 2991 function toggleShow(element, show) { 2992 if (element) { 2993 if (show !== false) { 2994 element.style.display = "block"; 2995 element.setAttribute("aria-hidden", false); 2996 } else { 2997 element.style.display = "none"; 2998 element.setAttribute("aria-hidden", true); 2999 } 3000 } 3001 } 3002 3003 function serialize(form) { 3004 var query = []; 3005 if (form && form.elements) { 3006 for (var i = 0; i < form.elements.length; i++) { 3007 var node = form.elements[i]; 3008 if (!node.disabled && node.name) { 3009 var param = [node.name, encodeURIComponent(node.value)]; 3010 query.push(param.join("=")); 3011 } 3012 } 3013 } 3014 return query.join("&"); 3015 } 3016 3017 function mark(node, regex) { 3018 if (!node || !regex) { 3019 return; 3020 } 3021 3022 // text nodes 3023 if (node.nodeType === 3) { 3024 var nodeValue = node.nodeValue; 3025 var match = regex.exec(nodeValue); 3026 3027 if (nodeValue && match) { 3028 var element = document.createElement("mark"); 3029 element.className = NS + "-search__item-mark"; 3030 element.appendChild(document.createTextNode(match[0])); 3031 3032 var after = node.splitText(match.index); 3033 after.nodeValue = after.nodeValue.substring(match[0].length); 3034 node.parentNode.insertBefore(element, after); 3035 } 3036 } else if (node.hasChildNodes()) { 3037 for (var i = 0; i < node.childNodes.length; i++) { 3038 // recurse 3039 mark(node.childNodes[i], regex); 3040 } 3041 } 3042 } 3043 3044 function Search(config) { 3045 if (config.element) { 3046 // prevents multiple initialization 3047 config.element.removeAttribute("data-" + NS + "-is"); 3048 } 3049 3050 this._cacheElements(config.element); 3051 this._setupProperties(config.options); 3052 3053 this._action = this._elements.form.getAttribute("action"); 3054 this._resultsOffset = 0; 3055 this._hasMoreResults = true; 3056 3057 this._elements.input.addEventListener("input", this._onInput.bind(this)); 3058 this._elements.input.addEventListener("focus", this._onInput.bind(this)); 3059 this._elements.input.addEventListener("keydown", this._onKeydown.bind(this)); 3060 this._elements.clear.addEventListener("click", this._onClearClick.bind(this)); 3061 document.addEventListener("click", this._onDocumentClick.bind(this)); 3062 this._elements.results.addEventListener("scroll", this._onScroll.bind(this)); 3063 3064 this._makeAccessible(); 3065 } 3066 3067 Search.prototype._displayResults = function() { 3068 if (this._elements.input.value.length === 0) { 3069 toggleShow(this._elements.clear, false); 3070 this._cancelResults(); 3071 } else if (this._elements.input.value.length < this._properties.minLength) { 3072 toggleShow(this._elements.clear, true); 3073 } else { 3074 this._updateResults(); 3075 toggleShow(this._elements.clear, true); 3076 } 3077 }; 3078 3079 Search.prototype._onScroll = function(event) { 3080 // fetch new results when the results to be scrolled down are less than the visible results 3081 if (this._elements.results.scrollTop + 2 * this._elements.results.clientHeight >= this._elements.results.scrollHeight) { 3082 this._resultsOffset += this._properties.resultsSize; 3083 this._displayResults(); 3084 } 3085 }; 3086 3087 Search.prototype._onInput = function(event) { 3088 var self = this; 3089 self._cancelResults(); 3090 // start searching when the search term reaches the minimum length 3091 this._timeout = setTimeout(function() { 3092 self._displayResults(); 3093 }, DELAY); 3094 }; 3095 3096 Search.prototype._onKeydown = function(event) { 3097 var self = this; 3098 3099 switch (event.keyCode) { 3100 case keyCodes.TAB: 3101 if (self._resultsOpen()) { 3102 event.preventDefault(); 3103 } 3104 break;
3105 case keyCodes.ENTER: 3106 event.preventDefault(); 3107 if (self._resultsOpen()) { 3108 var focused = self._elements.results.querySelector(selectors.item.focused); 3109 if (focused) { 3110 focused.click(); 3111 } 3112 } 3113 break; 3114 case keyCodes.ESCAPE: 3115 self._cancelResults(); 3116 break; 3117 case keyCodes.ARROW_UP: 3118 if (self._resultsOpen()) { 3119 event.preventDefault(); 3120 self._stepResultFocus(true); 3121 } 3122 break; 3123 case keyCodes.ARROW_DOWN: 3124 if (self._resultsOpen()) { 3125 event.preventDefault(); 3126 self._stepResultFocus(); 3127 } else { 3128 // test the input and if necessary fetch and display the results 3129 self._onInput(); 3130 } 3131 break; 3132 default: 3133 return; 3134 } 3135 }; 3136 3137 Search.prototype._onClearClick = function(event) { 3138 event.preventDefault(); 3139 this._elements.input.value = ""; 3140 toggleShow(this._elements.clear, false); 3141 toggleShow(this._elements.results, false); 3142 }; 3143 3144 Search.prototype._onDocumentClick = function(event) { 3145 var inputContainsTarget = this._elements.input.contains(event.target); 3146 var resultsContainTarget = this._elements.results.contains(event.target); 3147 3148 if (!(inputContainsTarget || resultsContainTarget)) { 3149 toggleShow(this._elements.results, false); 3150 } 3151 }; 3152 3153 Search.prototype._resultsOpen = function() { 3154 return this._elements.results.style.display !== "none"; 3155 }; 3156 3157 Search.prototype._makeAccessible = function() { 3158 var id = NS + "-search-results-" + idCount; 3159 this._elements.input.setAttribute("aria-owns", id); 3160 this._elements.results.id = id; 3161 idCount++; 3162 }; 3163 3164 Search.prototype._generateItems = function(data, results) { 3165 var self = this; 3166 3167 data.forEach(function(item) { 3168 var el = document.createElement("span"); 3169 el.innerHTML = self._elements.itemTemplate.innerHTML; 3170 el.querySelectorAll(selectors.item.title)[0].appendChild(document.createTextNode(item.title)); 3171 el.querySelectorAll(selectors.item.self)[0].setAttribute("href", item.url); 3172 results.innerHTML += el.innerHTML; 3173 }); 3174 }; 3175 3176 Search.prototype._markResults = function() { 3177 var nodeList = this._elements.results.querySelectorAll(selectors.item.self); 3178 var escapedTerm = this._elements.input.value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); 3179 var regex = new RegExp("(" + escapedTerm + ")", "gi"); 3180 3181 for (var i = this._resultsOffset - 1; i < nodeList.length; ++i) { 3182 var result = nodeList[i]; 3183 mark(result, regex); 3184 } 3185 }; 3186 3187 Search.prototype._stepResultFocus = function(reverse) { 3188 var results = this._elements.results.querySelectorAll(selectors.item.self); 3189 var focused = this._elements.results.querySelector(selectors.item.focused); 3190 var newFocused; 3191 var index = Array.prototype.indexOf.call(results, focused); 3192 var focusedCssClass = NS + "-search__item--is-focused"; 3193 3194 if (results.length > 0) { 3195 3196 if (!reverse) { 3197 // highlight the next result 3198 if (index < 0) { 3199 results[0].classList.add(focusedCssClass); 3200 } else if (index + 1 < results.length) { 3201 results[index].classList.remove(focusedCssClass); 3202 results[index + 1].classList.add(focusedCssClass); 3203 } 3204 3205 // if the last visible result is partially hidden, scroll up until it's completely visible 3206 newFocused = this._elements.results.querySelector(selectors.item.focused); 3207 if (newFocused) { 3208 var bottomHiddenHeight = newFocused.offsetTop + newFocused.offsetHeight - this._elements.results.scrollTop - this._elements.results.clientHeight; 3209 if (bottomHiddenHeight > 0) { 3210 this._elements.results.scrollTop += bottomHiddenHeight; 3211 } else { 3212 this._onScroll(); 3213 } 3214 } 3215 3216 } else { 3217 // highlight the previous result 3218 if (index >= 1) { 3219 results[index].classList.remove(focusedCssClass); 3220 results[index - 1].classList.add(focusedCssClass); 3221 } 3222 3223 // if the first visible result is partially hidden, scroll down until it's completely visible 3224 newFocused = this._elements.results.querySelector(selectors.item.focused); 3225 if (newFocused) { 3226 var topHiddenHeight = this._elements.results.scrollTop - newFocused.offsetTop; 3227 if (topHiddenHeight > 0) { 3228 this._elements.results.scrollTop -= topHiddenHeight; 3229 } 3230 } 3231 } 3232 } 3233 }; 3234 3235 Search.prototype._updateResults = function() { 3236 var self = this; 3237 if (self._hasMoreResults) { 3238 var request = new XMLHttpRequest(); 3239 var url = self._action + "?" + serialize(self._elements.form) + "&" + PARAM_RESULTS_OFFSET + "=" + self._resultsOffset; 3240 3241 request.open("GET", url, true); 3242 request.onload = function() { 3243 // when the results are loaded: hide the loading indicator and display the search icon after a minimum period 3244 setTimeout(function() { 3245 toggleShow(self._elements.loadingIndicator, false); 3246 toggleShow(self._elements.icon, true); 3247 }, LOADING_DISPLAY_DELAY); 3248 if (request.status >= 200 && request.status < 400) { 3249 // success status 3250 var data = JSON.parse(request.responseText); 3251 if (data.length > 0) { 3252 self._generateItems(data, self._elements.results); 3253 self._markResults(); 3254 toggleShow(self._elements.results, true); 3255 } else { 3256 self._hasMoreResults = false;
3257 } 3258 // the total number of results is not a multiple of the fetched results: 3259 // -> we reached the end of the query 3260 if (self._elements.results.querySelectorAll(selectors.item.self).length % self._properties.resultsSize > 0) { 3261 self._hasMoreResults = false; 3262 } 3263 } else { 3264 // error status 3265 } 3266 }; 3267 // when the results are loading: display the loading indicator and hide the search icon 3268 toggleShow(self._elements.loadingIndicator, true); 3269 toggleShow(self._elements.icon, false); 3270 request.send(); 3271 } 3272 }; 3273 3274 Search.prototype._cancelResults = function() { 3275 clearTimeout(this._timeout); 3276 this._elements.results.scrollTop = 0; 3277 this._resultsOffset = 0; 3278 this._hasMoreResults = true; 3279 this._elements.results.innerHTML = ""; 3280 }; 3281 3282 Search.prototype._cacheElements = function(wrapper) { 3283 this._elements = {}; 3284 this._elements.self = wrapper; 3285 var hooks = this._elements.self.querySelectorAll("[data-" + NS + "-hook-" + IS + "]"); 3286 3287 for (var i = 0; i < hooks.length; i++) { 3288 var hook = hooks[i]; 3289 var capitalized = IS; 3290 capitalized = capitalized.charAt(0).toUpperCase() + capitalized.slice(1); 3291 var key = hook.dataset[NS + "Hook" + capitalized]; 3292 this._elements[key] = hook; 3293 } 3294 }; 3295 3296 Search.prototype._setupProperties = function(options) { 3297 this._properties = {}; 3298 3299 for (var key in properties) { 3300 if (properties.hasOwnProperty(key)) { 3301 var property = properties[key]; 3302 if (options && options[key] != null) { 3303 if (property && typeof property.transform === "function") { 3304 this._properties[key] = property.transform(options[key]); 3305 } else { 3306 this._properties[key] = options[key]; 3307 } 3308 } else { 3309 this._properties[key] = properties[key]["default"]; 3310 } 3311 } 3312 } 3313 }; 3314 3315 function onDocumentReady() { 3316 var elements = document.querySelectorAll(selectors.self); 3317 for (var i = 0; i < elements.length; i++) { 3318 new Search({ element: elements[i], options: readData(elements[i]) }); 3319 } 3320 3321 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; 3322 var body = document.querySelector("body"); 3323 var observer = new MutationObserver(function(mutations) { 3324 mutations.forEach(function(mutation) { 3325 // needed for IE 3326 var nodesArray = [].slice.call(mutation.addedNodes); 3327 if (nodesArray.length > 0) { 3328 nodesArray.forEach(function(addedNode) { 3329 if (addedNode.querySelectorAll) { 3330 var elementsArray = [].slice.call(addedNode.querySelectorAll(selectors.self)); 3331 elementsArray.forEach(function(element) { 3332 new Search({ element: element, options: readData(element) }); 3333 }); 3334 } 3335 }); 3336 } 3337 }); 3338 }); 3339 3340 observer.observe(body, { 3341 subtree: true, 3342 childList: true, 3343 characterData: true 3344 }); 3345 } 3346 3347 if (document.readyState !== "loading") { 3348 onDocumentReady(); 3349 } else { 3350 document.addEventListener("DOMContentLoaded", onDocumentReady); 3351 } 3352 3353})(); 3354 3355/******************************************************************************* 3356 * Copyright 2016 Adobe 3357 * 3358 * Licensed under the Apache License, Version 2.0 (the "License"); 3359 * you may not use this file except in compliance with the License. 3360 * You may obtain a copy of the License at 3361 * 3362 * http://www.apache.org/licenses/LICENSE-2.0 3363 * 3364 * Unless required by applicable law or agreed to in writing, softw
3364are 3365 * distributed under the License is distributed on an "AS IS" BASIS, 3366 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3367 * See the License for the specific language governing permissions and 3368 * limitations under the License. 3369 ******************************************************************************/ 3370(function() { 3371 "use strict"; 3372 3373 var NS = "cmp"; 3374 var IS = "formText"; 3375 var IS_DASH = "form-text"; 3376 3377 var selectors = { 3378 self: "[data-" + NS + '-is="' + IS + '"]' 3379 }; 3380 3381 var properties = { 3382 /** 3383 * A validation message to display if there is a type mismatch between the user input and expected input. 3384 * 3385 * @type {String} 3386 */ 3387 constraintMessage: { 3388 }, 3389 /** 3390 * A validation message to display if no input is supplied, but input is expected for the field. 3391 * 3392 * @type {String} 3393 */ 3394 requiredMessage: { 3395 } 3396 }; 3397 3398 function readData(element) { 3399 var data = element.dataset; 3400 var options = []; 3401 var capitalized = IS; 3402 capitalized = capitalized.charAt(0).toUpperCase() + capitalized.slice(1); 3403 var reserved = ["is", "hook" + capitalized]; 3404 3405 for (var key in data) { 3406 if (data.hasOwnProperty(key)) { 3407 var value = data[key]; 3408 3409 if (key.indexOf(NS) === 0) { 3410 key = key.slice(NS.length); 3411 key = key.charAt(0).toLowerCase() + key.substring(1); 3412 3413 if (reserved.indexOf(key) === -1) { 3414 options[key] = value; 3415 } 3416 } 3417 } 3418 } 3419 3420 return options; 3421 } 3422 3423 function FormText(config) { 3424 if (config.element) { 3425 // prevents multiple initialization 3426 config.element.removeAttribute("data-" + NS + "-is"); 3427 } 3428 3429 this._cacheElements(config.element); 3430 this._setupProperties(config.options); 3431 3432 this._elements.input.addEventListener("invalid", this._onInvalid.bind(this)); 3433 this._elements.input.addEventListener("input", this._onInput.bind(this)); 3434 } 3435 3436 FormText.prototype._onInvalid = function(event) { 3437 event.target.setCustomValidity(""); 3438 if (event.target.validity.typeMismatch) { 3439 if (this._properties.constraintMessage) { 3440 event.target.setCustomValidity(this._properties.constraintMessage); 3441 } 3442 } else if (event.target.validity.valueMissing) { 3443 if (this._properties.requiredMessage) { 3444 event.target.setCustomValidity(this._properties.requiredMessage); 3445 } 3446 } 3447 }; 3448 3449 FormText.prototype._onInput = function(event) { 3450 event.target.setCustomValidity(""); 3451 }; 3452 3453 FormText.prototype._cacheElements = function(wrapper) { 3454 this._elements = {}; 3455 this._elements.self = wrapper; 3456 var hooks = this._elements.self.querySelectorAll("[data-" + NS + "-hook-" + IS_DASH + "]"); 3457 for (var i = 0; i < hooks.length; i++) { 3458 var hook = hooks[i]; 3459 var capitalized = IS; 3460 capitalized = capitalized.charAt(0).toUpperCase() + capitalized.slice(1); 3461 var key = hook.dataset[NS + "Hook" + capitalized]; 3462 this._elements[key] = hook; 3463 } 3464 }; 3465 3466 FormText.prototype._setupProperties = function(options) { 3467 this._properties = {}; 3468 3469 for (var key in properties) { 3470 if (properties.hasOwnProperty(key)) { 3471 var property = properties[key]; 3472 if (options && options[key] != null) { 3473 if (property && typeof property.transform === "function") { 3474 this._properties[key] = property.transform(options[key]); 3475 } else { 3476 this._properties[key] = options[key]; 3477 } 3478 } else { 3479 this._properties[key] = properties[key]["default"]; 3480 } 3481 } 3482 } 3483 }; 3484 3485 function onDocumentReady() { 3486 var elements = document.querySelectorAll(selectors.self); 3487 for (var i = 0; i < elements.length; i++) { 3488 new FormText({ element: elements[i], options: readData(elements[i]) }); 3489 } 3490 3491 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; 3492 var body = document.querySelector("body"); 3493 var observer = new MutationObserver(function(mutations) { 3494 mutations.forEach(function(mutation) { 3495 // needed for IE 3496 var nodesArray = [].slice.call(mutation.addedNodes); 3497 if (nodesArray.length > 0) { 3498 nodesArray.forEach(function(addedNode) { 3499 if (addedNode.querySelectorAll) { 3500 var elementsArray = [].slice.call(addedNode.querySelectorAll(selectors.self)); 3501 elementsArray.forEach(function(element) { 3502 new FormText({ element: element, options: readData(element) }); 3503 }); 3504 } 3505 }); 3506 } 3507 }); 3508 }); 3509 3510 observer.observe(body, { 3511 subtree: true, 3512 childList: true, 3513 characterData: true 3514 }); 3515 } 3516 3517 if (document.readyState !== "loading") { 3518 onDocumentReady(); 3519 } else { 3520 document.addEventListener("DOMContentLoaded", onDocumentReady); 3521 } 3522 3523})(); 3524 3525/******************************************************************************* 3526 * Copyright 2020 Adobe 3527 * 3528 * Licensed under the Apache License, Version 2.0 (the "License");
3529 * you may not use this file except in compliance with the License. 3530 * You may obtain a copy of the License at 3531 * 3532 * http://www.apache.org/licenses/LICENSE-2.0 3533 * 3534 * Unless required by applicable law or agreed to in writing, software 3535 * distributed under the License is distributed on an "AS IS" BASIS, 3536 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3537 * See the License for the specific language governing permissions and 3538 * limitations under the License. 3539 ******************************************************************************/ 3540(function() { 3541 "use strict"; 3542 3543 var NS = "cmp"; 3544 var IS = "pdfviewer"; 3545 var SDK_URL = "https://documentcloud.adobe.com/view-sdk/main.js"; 3546 var SDK_READY_EVENT = "adobe_dc_view_sdk.ready"; 3547 3548 var selectors = { 3549 self: "[data-" + NS + '-is="' + IS + '"]', 3550 sdkScript: 'script[src="' + SDK_URL + '"]' 3551 }; 3552 3553 function initSDK() { 3554 var sdkIncluded = document.querySelectorAll(selectors.sdkScript).length > 0; 3555 if (!window.adobe_dc_view_sdk && !sdkIncluded) { 3556 var dcv = document.createElement("script"); 3557 dcv.type = "text/javascript"; 3558 dcv.src = SDK_URL; 3559 document.body.appendChild(dcv); 3560 } 3561 } 3562 3563 function previewPdf(component) { 3564 // prevents multiple initialization 3565 component.removeAttribute("data-" + NS + "-is"); 3566 3567 // add the view sdk to the page 3568 initSDK(); 3569 3570 // manage the preview 3571 if (component.dataset && component.id) { 3572 if (window.AdobeDC && window.AdobeDC.View) { 3573 dcView(component); 3574 } else { 3575 document.addEventListener(SDK_READY_EVENT, function () { 3576 dcView(component); 3577 }); 3578 } 3579 } 3580 } 3581 3582 function dcView(component) { 3583 var adobeDCView = new AdobeDC.View({ 3584 clientId: component.dataset.cmpClientId, 3585 divId: component.id + '-content', 3586 reportSuiteId: component.dataset.cmpReportSuiteId 3587 }); 3588 adobeDCView.previewFile({ 3589 content:{location: {url: component.dataset.cmpDocumentPath}}, 3590 metaData:{fileName: component.dataset.cmpDocumentFileName} 3591 }, JSON.parse(component.dataset.cmpViewerConfigJson)); 3592 } 3593 3594 /** 3595 * Document ready handler and DOM mutation observers. Initializes Accordion components as necessary. 3596 * 3597 * @private 3598 */ 3599 function onDocumentReady() { 3600 var elements = document.querySelectorAll(selectors.self); 3601 for (var i = 0; i < elements.length; i++) { 3602 previewPdf(elements[i]); 3603 } 3604 3605 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; 3606 var body = document.querySelector("body"); 3607 var observer = new MutationObserver(function(mutations) { 3608 mutations.forEach(function(mutation) { 3609 // needed for IE 3610 var nodesArray = [].slice.call(mutation.addedNodes); 3611 if (nodesArray.length > 0) { 3612 nodesArray.forEach(function(addedNode) { 3613 if (addedNode.querySelectorAll) { 3614 var elementsArray = [].slice.call(addedNode.querySelectorAll(selectors.self)); 3615 elementsArray.forEach(function(element) { 3616 previewPdf(element); 3617 }); 3618 } 3619 }); 3620 } 3621 }); 3622 }); 3623 3624 observer.observe(body, { 3625 subtree: true, 3626 childList: true, 3627 characterData: true 3628 }); 3629 3630 } 3631 3632 if (document.readyState !== "loading") { 3633 onDocumentReady(); 3634 } else { 3635 document.addEventListener("DOMContentLoaded", onDocumentReady); 3636 } 3637}()); 3638 3639/******************************************************************************* 3640 * Copyright 2020 Adobe 3641 * 3642 * Licensed under the Apache License, Version 2.0 (the "License"); 3643 * you may not use this file except in compliance with the License. 3644 * You may obtain a copy of the License at 3645 * 3646 * http://www.apache.org/licenses/LICENSE2.0 3647 * 3648 * Unless required by applicable law or agreed to in writing, softw
3648are 3649 * distributed under the License is distributed on an "AS IS" BASIS, 3650 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3651 * See the License for the specific language governing permissions and 3652 * limitations under the License. 3653 ******************************************************************************/ 3654 3655/** 3656 * Element.matches() 3657 * https://developer.mozilla.org/enUS/docs/Web/API/Element/matches#Polyfill 3658 */ 3659if (!Element.prototype.matches) { 3660 Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector; 3661} 3662 3663// eslint-disable-next-line valid-jsdoc 3664/** 3665 * Element.closest() 3666 * https://developer.mozilla.org/enUS/docs/Web/API/Element/closest#Polyfill 3667 */ 3668if (!Element.prototype.closest) { 3669 Element.prototype.closest = function(s) { 3670 "use strict"; 3671 var el = this; 3672 if (!document.documentElement.contains(el)) { 3673 return null; 3674 } 3675 do { 3676 if (el.matches(s)) { 3677 return el; 3678 } 3679 el = el.parentElement || el.parentNode; 3680 } while (el !== null && el.nodeType === 1); 3681 return null; 3682 }; 3683} 3684 3685// https://tc39.github.io/ecma262/#sec-array.prototype.find 3686if (!Array.prototype.find) { 3687 Object.defineProperty(Array.prototype, "find", { 3688 value: function(predicate) { 3689 "use strict"; 3690 // 1. Let O be ? ToObject(this value). 3691 if (this == null) { 3692 throw TypeError('"this" is null or not defined'); 3693 } 3694 3695 var o = Object(this); 3696 3697 // 2. Let len be ? ToLength(? Get(O, "length")). 3698 var len = o.length >>> 0; 3699 3700 // 3. If IsCallable(predicate) is false, throw a TypeError exception. 3701 if (typeof predicate !== "function") { 3702 throw TypeError("predicate must be a function"); 3703 } 3704 3705 // 4. If thisArg was supplied, let T be thisArg; else let T be undefined. 3706 var thisArg = arguments[1]; 3707 3708 // 5. Let k be 0. 3709 var k = 0; 3710 3711 // 6. Repeat, while k < len 3712 while (k < len) { 3713 // a. Let Pk be ! ToString(k). 3714 // b. Let kValue be ? Get(O, Pk). 3715 // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). 3716 // d. If testResult is true, return kValue. 3717 var kValue = o[k]; 3718 if (predicate.call(thisArg, kValue, k, o)) { 3719 return kValue; 3720 } 3721 // e. Increase k by 1. 3722 k++; 3723 } 3724 3725 // 7. Return undefined. 3726 return undefined; 3727 }, 3728 configurable: true, 3729 writable: true 3730 }); 3731} 3732 3733"use strict";function _slicedToArray(t,e){return _arrayWithHoles(t)||_iterableToArrayLimit(t,e)||_unsupportedIterableToArray(t,e)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(t,e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t)){var n=[],r=!0,o=!1,a=void 0;try{for(var i,u=t[Symbol.iterator]();!(r=(i=u.next()).done)&&(n.push(i.value),!e||n.length!==e);r=!0);}catch(t){o=!0,a=t}finally{try{r||null==u.return||u.return()}finally{if(o)throw a}}return n}}function _arrayWithHoles(t){if(Array.isArray(t))return t}function _createForOfIteratorHelper(t){if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(t=_unsupportedIterableToArray(t))){var e=0,n=function(){};return{s:n,n:function(){return e>=t.length?{done:!0}:{done:!1,value:t[e++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,o,a=!0,i=!1;return{s:function(){r=t[Symbol.iterator]()},n:function(){var t=r.next();return a=t.done,t},e:function(t){i=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(i)throw o}}}}function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(t,e):void 0}}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}!function a(i,u,c){function f(e,t){if(!u[e]){if(!i[e]){var n="function"==typeof require&&require;if(!t&&n)return n(e,!0);if(s)return s(e,!0);var r=new Error("Cannot find module '"+e+"'");throw r.code="MODULE_NOT_FOUND",r}var o=u[e]={exports:{}};i[e][0].call(o.exports,function(t){return f(i[e][1][t]||t)},o,o.exports,a,i,u,c)}return u[e].exports}for(var s="function"==typeof require&&require,t=0;t<c.length;t++)f(c[t]);return f}({1:[function(t,wn,En){(function(On){(function(){function n(t,e){for(var n=-1,r=null==t?0:t.length,o=0,a=[];++n<r;){var i=t[n];e(i,n,t)&&(a[o++]=i)}return a}function a(t,e){for(var n=-1,r=null==t?0:t.length,o=Array(r);++n<r;)o[n]=e(t[n],n,t);return o}function f(t,e){for(var n=-1,r=e.length,o=t.length;++n<r;)t[o+n]=e[n];return t}function b(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(e(t[n],n,t))return!0;return!1}function o(t,e,n){var r=t.length;for(n+=-1;++n<r;)if(e(t[n],n,t))return n;return-1}function i(t){return t!=t}function t(e){return function(t){return e(t)}}function h(t){var n=-1,r=Array(t.size);return t.forEach(function(t,e){r[++n]=[e,t]}),r}function e(e){var n=Object;return function(t){return e(n(t))}}function v(t){var e=-1,n=Array(t.size);return t.forEach(function(t){n[++e]=t}),n}function r(){}function u(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function c(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function s(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function d(t){var e=-1,n=null==t?0:t.length;for(this.__data__=new s;++e<n;)this.add(t[e])}function g(t){this.size=(this.__data__=new c(t)).size}function l(t,e){var n=hn(t),r=!n&&bn(t),o=!n&&!r&&vn(t),a=!n&&!r&&!o&&_n(t);if(n=n||r||o||a){r=t.length;for(var i=String,u=-1,c=Array(r);++u<r;)c[u]=i(u);r=c}else r=[];var f;i=r.length;for(f in t)!e&&!be.call(t,f)||n&&("length"==f||o&&("offset"==f||"parent"==f)||a&&("buffer"==f||"byteLength"==f||"byteOffset"==f)||X(f,i))||r.push(f);return r}function _(t,e,n){(n===Mt||ft(t[e],n))&&(n!==Mt||e in t)||j(t,e,n)}function y(t,e,n){var r=t[e];be.call(t,e)&&ft(r,n)&&(n!==Mt||e in t)||j(t,e,n)}function p(t,e){for(var n=t.length;n--;)if(ft(t[n][0],e))return n;return-1}function j(t,e,n){"__proto__"==e&&xe?xe(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}function m(n,r,o,t,e,a){var i,u=1&r,c=2&r,f=4&r;
3733if(o&&(i=e?o(n,t,e,a):o(n)),i!==Mt)return i;if(!bt(n))return n;if(t=hn(n)){if(i=function(t){var e=t.length,n=new t.constructor(e);return e&&"string"==typeof t[0]&&be.call(t,"index")&&(n.index=t.index,n.input=t.input),n}(n),!u)return P(n,i)}else{var s=nn(n),l="[object Function]"==s||"[object GeneratorFunction]"==s;if(vn(n))return M(n,u);if("[object Object]"==s||"[object Arguments]"==s||l&&!e){if(i=c||l?{}:K(n),!u)return c?function(t,e){return U(t,en(t),e)}(n,function(t,e){return t&&U(e,Lt(e),t)}(i,n)):function(t,e){return U(t,tn(t),e)}(n,function(t,e){return t&&U(e,St(e),t)}(i,n))}else{if(!Qt[s])return e?n:{};i=function(t,e,n){var r=t.constructor;switch(e){case"[object ArrayBuffer]":return z(t);case"[object Boolean]":case"[object Date]":return new r(+t);case"[object DataView]":return e=n?z(t.buffer):t.buffer,new t.constructor(e,t.byteOffset,t.byteLength);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return C(t,n);case"[object Map]":return new r;case"[object Number]":case"[object String]":return new r(t);case"[object RegExp]":return(e=new t.constructor(t.source,Ht.exec(t))).lastIndex=t.lastIndex,e;case"[object Set]":return new r;case"[object Symbol]":return qe?Object(qe.call(t)):{}}}(n,s,u)}}if(e=(a=a||new g).get(n))return e;if(a.set(n,i),gn(n))return n.forEach(function(t){i.add(m(t,r,o,t,n,a))}),i;if(dn(n))return n.forEach(function(t,e){i.set(e,m(t,r,o,e,n,a))}),i;c=f?c?B:H:c?Lt:St;var p=t?Mt:c(n);return function(t,e){for(var n=-1,r=null==t?0:t.length;++n<r&&!1!==e(t[n],n,t););}(p||n,function(t,e){p&&(t=n[e=t]),y(i,e,m(t,r,o,e,n,a))}),i}function A(t,e){for(var n=0,r=(e=D(e,t)).length;null!=t&&n<r;)t=t[nt(e[n++])];return n&&n==r?t:Mt}function O(t,e,n){return e=e(t),hn(t)?e:f(e,n(t))}function w(t){if(null==t)t=t===Mt?"[object Undefined]":"[object Null]";else if(Te&&Te in Object(t)){var e=be.call(t,Te),n=t[Te];try{t[Te]=Mt;var r=!0}catch(t){}var o=ve.call(t);r&&(e?t[Te]=n:delete t[Te]),t=o}else t=ve.call(t);return t}function E(t,e){return null!=t&&be.call(t,e)}function S(t,e){return null!=t&&e in Object(t)}function L(t){return ht(t)&&"[object Arguments]"==w(t)}function T(t,e,n,r,o){if(t===e)e=!0;else if(null==t||null==e||!ht(t)&&!ht(e))e=t!=t&&e!=e;else t:{var a,i,u=hn(t),c=hn(e),f="[object Object]"==(a="[object Arguments]"==(a=u?"[object Array]":nn(t))?"[object Object]":a);c="[object Object]"==(i="[object Arguments]"==(i=c?"[object Array]":nn(e))?"[object Object]":i);if((i=a==i)&&vn(t)){if(!vn(e)){e=!1;break t}f=!(u=!0)}if(i&&!f)o=o||new g,e=u||_n(t)?V(t,e,n,r,T,o):function(t,e,n,r,o,a,i){switch(n){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)break;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":if(t.byteLength!=e.byteLength||!a(new me(t),new me(e)))break;return!0;case"[object Boolean]":case"[object Date]":case"[object Number]":return ft(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var u=h;case"[object Set]":if(u=u||v,t.size!=e.size&&!(1&r))break;return(n=i.get(t))?n==e:(r|=2,i.set(t,e),e=V(u(t),u(e),r,o,a,i),i.delete(t),e);case"[object Symbol]":if(qe)return qe.call(t)==qe.call(e)}return!1}(t,e,a,n,r,T,o);else{if(!(1&n)&&(u=f&&be.call(t,"__wrapped__"),a=c&&be.call(e,"__wrapped__"),u||a)){e=T(t=u?t.value():t,e=a?e.value():e,n,r,o=o||new g);break t}if(i)e:if(o=o||new g,u=1&n,a=H(t),c=a.length,i=H(e).length,c==i||u){for(f=c;f--;){var s=a[f];if(!(u?s in e:be.call(e,s))){e=!1;break e}}if((i=o.get(t))&&o.get(e))e=i==e;else{i=!0,o.set(t,e),o.set(e,t);for(var l=u;++f<c;){var p=t[s=a[f]],y=e[s];if(r)var b=u?r(y,p,s,e,t,o):r(p,y,s,t,e,o);if(b===Mt?p!==y&&!T(p,y,n,r,o):!b){i=!1;break}l=l||"constructor"==s}i&&!l&&((n=t.constructor)!=(r=e.constructor)&&"constructor"in t&&"constructor"in e&&!("function"==typeof n&&n instanceof n&&"function"==typeof r&&r instanceof r)&&(i=!1)),o.delete(t),o.delete(e),e=i}}else e=!1;else e=!1}}return e}function x(t){return"function"==typeof t?t:null==t?It:"object"==_typeof(t)?hn(t)?function(n,r){return Y(n)&&r==r&&!bt(r)?tt(nt(n),r):function(t){var e=wt(t,n);return e===Mt&&e===r?Et(t,n):T(r,e,3)}}(t[0],t[1]):function(e){var n=function(t){for(var e=St(t),n=e.length;n--;){var r=e[n],o=t[r];e[n]=[r,o,o==o&&!bt(o)]}return e}(e);return 1==n.length&&n[0][2]?tt(n[0][0],n[0][1]):function(t){return t===e||function(t,e){var n=e.length,r=n;if(null==t)return!r;for(t=Object(t);n--;){if((o=e[n])[2]?o[1]!==t[o[0]]:!(o[0]in t))return!1}for(;++n<r;
3733){var o,a=(o=e[n])[0],i=t[a],u=o[1];if(o[2]){if(i===Mt&&!(a in t))return!1}else if(o=new g,void 0!==Mt||!T(u,i,3,void 0,o))return!1}return!0}(t,n)}}(t):Nt(t)}function I(t){if(!Z(t))return Ne(t);var e,n=[];for(e in Object(t))be.call(t,e)&&"constructor"!=e&&n.push(e);return n}function k(s,l,p,y,b){s!==l&&Ye(l,function(t,e){if(bt(t)){var n=b=b||new g,r="__proto__"==e?Mt:s[e],o="__proto__"==e?Mt:l[e];if(f=n.get(o))_(s,e,f);else{var a=(f=y?y(r,o,e+"",s,l,n):Mt)===Mt;if(a){var i=hn(o),u=!i&&vn(o),c=!i&&!u&&_n(o),f=o;i||u||c?f=hn(r)?r:lt(r)?P(r):u?M(o,!(a=!1)):c?C(o,!(a=!1)):[]:vt(o)||bn(o)?bn(f=r)?f=At(r):(!bt(r)||p&&pt(r))&&(f=K(o)):a=!1}a&&(n.set(o,f),k(f,o,p,y,n),n.delete(o)),_(s,e,f)}}else(n=y?y("__proto__"==e?Mt:s[e],t,e+"",s,l,b):Mt)===Mt&&(n=t),_(s,e,n)},Lt)}function N(t){if("string"==typeof t)return t;if(hn(t))return a(t,N)+"";if(gt(t))return Je?Je.call(t):"";var e=t+"";return"0"==e&&1/t==-zt?"-0":e}function F(t,e){var n;if((e=D(e,t)).length<2)n=t;else{var r=0,o=-1,a=-1,i=(n=e).length;for(r<0&&(r=i<-r?0:i+r),(o=i<o?i:o)<0&&(o+=i),i=o<r?0:o-r>>>0,r>>>=0,o=Array(i);++a<i;)o[a]=n[a+r];n=A(t,o)}null==(t=n)||delete t[nt(it(e))]}function D(t,e){return hn(t)?t:Y(t,e)?[t]:ln(Ot(t))}function M(t,e){if(e)return t.slice();var n=t.length;n=Ae?Ae(n):new t.constructor(n);return t.copy(n),n}function z(t){var e=new t.constructor(t.byteLength);return new me(e).set(new me(t)),e}function C(t,e){return new t.constructor(e?z(t.buffer):t.buffer,t.byteOffset,t.length)}function P(t,e){var n=-1,r=t.length;for(e=e||Array(r);++n<r;)e[n]=t[n];return e}function U(t,e,n){var r=!n;n=n||{};for(var o=-1,a=e.length;++o<a;){var i=e[o],u=Mt;u===Mt&&(u=t[i]),r?j(n,i,u):y(n,i,u)}return n}function R(f){return function(t){return sn(et(t,void 0,It),t+"")}(function(t,e){var n,r=-1,o=e.length,a=1<o?e[o-1]:Mt,i=2<o?e[2]:Mt;a=3<f.length&&"function"==typeof a?(o--,a):Mt;if(n=i){n=e[0];var u=e[1];if(bt(i)){var c=_typeof(u);n=!!("number"==c?st(i)&&X(u,i.length):"string"==c&&u in i)&&ft(i[u],n)}else n=!1}for(n&&(a=o<3?Mt:a,o=1),t=Object(t);++r<o;)(i=e[r])&&f(t,i,r,a);return t})}function $(t){return vt(t)?Mt:t}function V(t,e,n,r,o,a){var i=1&n,u=t.length;if(u!=(c=e.length)&&!(i&&u<c))return!1;if((c=a.get(t))&&a.get(e))return c==e;var c=-1,f=!0,s=2&n?new d:Mt;for(a.set(t,e),a.set(e,t);++c<u;){var l=t[c],p=e[c];if(r)var y=i?r(p,l,c,e,t,a):r(l,p,c,t,e,a);if(y!==Mt){if(y)continue;f=!1;break}if(s){if(!b(e,function(t,e){if(!s.has(e)&&(l===t||o(l,t,n,r,a)))return s.push(e)})){f=!1;break}}else if(l!==p&&!o(l,p,n,r,a)){f=!1;break}}return a.delete(t),a.delete(e),f}function H(t){return O(t,St,tn)}function B(t){return O(t,Lt,en)}function W(t,e){var n=(n=r.iteratee||kt)===kt?x:n;return arguments.length?n(t,e):n}function G(t,e){var n=t.__data__,r=_typeof(e);return("string"==r||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==e:null===e)?n["string"==typeof e?"string":"hash"]:n.map}function q(t,e){var n=null==t?Mt:t[e];return!bt(n)||he&&he in n||!(pt(n)?ge:Gt).test(rt(n))?Mt:n}function J(t,e,n){for(var r=-1,o=(e=D(e,t)).length,a=!1;++r<o;){var i=nt(e[r]);if(!(a=null!=t&&n(t,i)))break;t=t[i]}return a||++r!=o?a:!!(o=null==t?0:t.length)&&yt(o)&&X(i,o)&&(hn(t)||bn(t))}function K(t){return"function"!=typeof t.constructor||Z(t)?{}:Ke(Oe(t))}function Q(t){return hn(t)||bn(t)||!!(Le&&t&&t[Le])}function X(t,e){var n=_typeof(t);return!!(e=null==e?9007199254740991:e)&&("number"==n||"symbol"!=n&&Jt.test(t))&&-1<t&&0==t%1&&t<e}function Y(t,e){if(hn(t))return!1;var n=_typeof(t);return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=t&&!gt(t))||Ut.test(t)||!Pt.test(t)||null!=e&&t in Object(e)}function Z(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||le)}function tt(e,n){return function(t){return null!=t&&t[e]===n&&(n!==Mt||e in Object(t))}}function et(o,a,i){return a=Fe(a===Mt?o.length-1:a,0),function(){for(var t=arguments,e=-1,n=Fe(t.length-a,0),r=Array(n);++e<n;)r[e]=t[a+e];for(e=-1,n=Array(a+1);++e<a;)n[e]=t[e];return n[a]=i(r),function(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}(o,this,n)}}function nt(t){if("string"==typeof t||gt(t))return t;var e=t+"";return"0"==e&&1/t==-zt?"-0":e}function rt(t){if(null==t)return"";try{return ye.call(t)}catch(t){}return t+""}function ot(t,e,n){var r=null==t?0:t.length;return r?((n=null==n?0:jt(n))<0&&(n=Fe(r+n,0)),o(t,W(e,3),n)):-1}function at(t){return null!=t&&t.length?function t(e,n,r,o,a){var i=-1,u=e.length;for(r=r||Q,a=a||[];++i<u;){var c=e[i];0<n&&r(c)?1<n?t(c,n-1,r,o,a):f(a,c):o||(a[a.length]=c)}return a}(t,1):[]}function it(t){var e=null==t?0:t.length;return e?t[e-1]:Mt}function ut(r,o){function a(){var t=arguments,e=o?o.apply(this,t):t[0],n=a.cache;return n.has(e)?n.get(e):(t=r.apply(this,t),a.cache=n.set(e,t)||n,t)}if("function"!=typeof r||null!=o&&"function"!=typeof o)throw new TypeError("Expected a function");return a.cache=new(ut.Cache||s),a}function ct(e){if("function"!=typeof e)throw new TypeError("Expected a function");return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}function ft(t,e){return t===e||t!=t&&e!=e}function st(t){return null!=t&&yt(t.length)&&!pt(t)}function lt(t){return ht(t)&&st(t)}function pt(t){return!!bt(t)&&("[object Function]"==(t=w(t))||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t)}function yt(t){return"number"==typeof t&&-1<t&&0==t%1&&t<=9007199254740991}function bt(t){var e=_typeof(t);return null!=t&&("object"==e||"function"==e)}function ht(t){return null!=t&&"object"==_typeof(t)}function vt(t){return!(!ht(t)||"[object Object]"!=w(t))&&(null===(t=Oe(t))||"function"==typeof(t=be.call(t,"constructor")&&t.constructor)&&t instanceof t&&ye.call(t)==de)}function dt(t){return"string"==typeof t||!hn(t)&&ht(t)&&"[object String]"==w(t)}function gt(t){return"symbol"==_typeof(t)||ht(t)&&"[object Symbol]"==w(t)}function _t(t){return t?(t=mt(t))===zt||t===-zt?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function jt(t){var e=(t=_t(t))%1;return t==t?e?t-e:t:0}function mt(t){if("number"==typeof t)return t;if(gt(t))return Ct;if(bt(t)&&(t=bt(t="function"==typeof t.valueOf?t.valueOf():t)?t+"":t),"string"!=typeof t)return 0===t?t:+t;t=t.replace($t,"");var e=Wt.test(t);return e||qt.test(t)?Yt(t.slice(2),e?2:8):Bt.test(t)?Ct:+t}function At(t){return U(t,Lt(t))}function Ot(t){return null==t?"":N(t)}function wt(t,e,n){return(t=null==t?Mt:A(t,e))===Mt?n:t}function Et(t,e){return null!=t&&J(t,e,S)}function St(t){return st(t)?l(t):I(t)}function Lt(t){if(st(t))t=l(t,!0);else if(bt(t)){var e,n=Z(t),r=[];for(e in t)("constructor"!=e||!n&&be.call(t,e))&&r.push(e);t=r}else{if(e=[],null!=t)for(n in Object(t))e.push(n);t=e}return t}function Tt(t){return null==t?[]:function(e,t){return a(t,function(t){return e[t]})}(t,St(t))}function xt(t){return function(){return t}}function It(t){return t}function kt(t){return x("function"==typeof t?t:m(t,1))}function Nt(t){return Y(t)?function(e){return function(t){return null==t?Mt:t[e]}}(nt(t)):function(e){return function(t){return A(t,e)}}(t)}function Ft(){return[]}function Dt(){return!1}var Mt,zt=1/0,Ct=NaN,Pt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ut=/^\w*$/,Rt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,$t=/^\s+|\s+$/g,Vt=/\\(\\)?/g,Ht=/\w*$/,Bt=/^[-+]0x[0-9a-f]+$/i,Wt=/^0b[01]+$/i,Gt=/^\[object .+?Constructor\]$/,qt=/^0o[0-7]+$/i,Jt=/^(?:0|[1-9]\d*)$/,Kt={};
3733Kt["[object Float32Array]"]=Kt["[object Float64Array]"]=Kt["[object Int8Array]"]=Kt["[object Int16Array]"]=Kt["[object Int32Array]"]=Kt["[object Uint8Array]"]=Kt["[object Uint8ClampedArray]"]=Kt["[object Uint16Array]"]=Kt["[object Uint32Array]"]=!0,Kt["[object Arguments]"]=Kt["[object Array]"]=Kt["[object ArrayBuffer]"]=Kt["[object Boolean]"]=Kt["[object DataView]"]=Kt["[object Date]"]=Kt["[object Error]"]=Kt["[object Function]"]=Kt["[object Map]"]=Kt["[object Number]"]=Kt["[object Object]"]=Kt["[object RegExp]"]=Kt["[object Set]"]=Kt["[object String]"]=Kt["[object WeakMap]"]=!1;var Qt={};Qt["[object Arguments]"]=Qt["[object Array]"]=Qt["[object ArrayBuffer]"]=Qt["[object DataView]"]=Qt["[object Boolean]"]=Qt["[object Date]"]=Qt["[object Float32Array]"]=Qt["[object Float64Array]"]=Qt["[object Int8Array]"]=Qt["[object Int16Array]"]=Qt["[object Int32Array]"]=Qt["[object Map]"]=Qt["[object Number]"]=Qt["[object Object]"]=Qt["[object RegExp]"]=Qt["[object Set]"]=Qt["[object String]"]=Qt["[object Symbol]"]=Qt["[object Uint8Array]"]=Qt["[object Uint8ClampedArray]"]=Qt["[object Uint16Array]"]=Qt["[object Uint32Array]"]=!0,Qt["[object Error]"]=Qt["[object Function]"]=Qt["[object WeakMap]"]=!1;var Xt,Yt=parseInt,Zt="object"==_typeof(On)&&On&&On.Object===Object&&On,te="object"==("undefined"==typeof self?"undefined":_typeof(self))&&self&&self.Object===Object&&self,ee=Zt||te||Function("return this")(),ne="object"==_typeof(En)&&En&&!En.nodeType&&En,re=ne&&"object"==_typeof(wn)&&wn&&!wn.nodeType&&wn,oe=re&&re.exports===ne,ae=oe&&Zt.process;t:{try{Xt=ae&&ae.binding&&ae.binding("util");break t}catch(t){}Xt=void 0}var ie,ue=Xt&&Xt.isMap,ce=Xt&&Xt.isSet,fe=Xt&&Xt.isTypedArray,se=Array.prototype,le=Object.prototype,pe=ee["__core-js_shared__"],ye=Function.prototype.toString,be=le.hasOwnProperty,he=(ie=/[^.]+$/.exec(pe&&pe.keys&&pe.keys.IE_PROTO||""))?"Symbol(src)_1."+ie:"",ve=le.toString,de=ye.call(Object),ge=RegExp("^"+ye.call(be).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),_e=oe?ee.Buffer:Mt,je=ee.Symbol,me=ee.Uint8Array,Ae=_e?_e.a:Mt,Oe=e(Object.getPrototypeOf),we=Object.create,Ee=le.propertyIsEnumerable,Se=se.splice,Le=je?je.isConcatSpreadable:Mt,Te=je?je.toStringTag:Mt,xe=function(){try{var t=q(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),Ie=Object.getOwnPropertySymbols,ke=_e?_e.isBuffer:Mt,Ne=e(Object.keys),Fe=Math.max,De=Date.now,Me=q(ee,"DataView"),ze=q(ee,"Map"),Ce=q(ee,"Promise"),Pe=q(ee,"Set"),Ue=q(ee,"WeakMap"),Re=q(Object,"create"),$e=rt(Me),Ve=rt(ze),He=rt(Ce),Be=rt(Pe),We=rt(Ue),Ge=je?je.prototype:Mt,qe=Ge?Ge.valueOf:Mt,Je=Ge?Ge.toString:Mt,Ke=function(t){return bt(t)?we?we(t):(Qe.prototype=t,t=new Qe,Qe.prototype=Mt,t):{}};function Qe(){}u.prototype.clear=function(){this.__data__=Re?Re(null):{},this.size=0},u.prototype.delete=function(t){return t=this.has(t)&&delete this.__data__[t],this.size-=t?1:0,t},u.prototype.get=function(t){var e=this.__data__;return Re?"__lodash_hash_undefined__"===(t=e[t])?Mt:t:be.call(e,t)?e[t]:Mt},u.prototype.has=function(t){var e=this.__data__;return Re?e[t]!==Mt:be.call(e,t)},u.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=Re&&e===Mt?"__lodash_hash_undefined__":e,this},c.prototype.clear=function(){this.__data__=[],this.size=0},c.prototype.delete=function(t){var e=this.__data__;return!((t=p(e,t))<0||(t==e.length-1?e.pop():Se.call(e,t,1),--this.size,0))},c.prototype.get=function(t){var e=this.__data__;return(t=p(e,t))<0?Mt:e[t][1]},c.prototype.has=function(t){return-1<p(this.__data__,t)},c.prototype.set=function(t,e){var n=this.__data__,r=p(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this},s.prototype.clear=function(){this.size=0,this.__data__={hash:new u,map:new(ze||c),string:new u}},s.prototype.delete=function(t){return t=G(this,t).delete(t),this.size-=t?1:0,t},s.prototype.get=function(t){return G(this,t).get(t)},s.prototype.has=function(t){return G(this,t).has(t)},s.prototype.set=function(t,e){var n=G(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this},d.prototype.add=d.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},d.prototype.has=function(t){return this.__data__.has(t)},g.prototype.clear=function(){this.__data__=new c,this.size=0},g.prototype.delete=function(t){var e=this.__data__;return t=e.delete(t),this.size=e.size,t},g.prototype.get=function(t){return this.__data__.get(t)},g.prototype.has=function(t){return this.__data__.has(t)},g.prototype.set=function(t,e){var n=this.__data__;if(n instanceof c){var r=n.__data__;if(!ze||r.length<199)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new s(r)}return n.set(t,e),this.size=n.size,this};var Xe=function(t,e){if(null==t)return t;if(!st(t))return function(t,e){return t&&Ye(t,e,St)}(t,e);for(var n=t.length,r=-1,o=Object(t);++r<n&&!1!==e(o[r],r,o););return t},Ye=function(t,e,n){for(var r=-1,o=Object(t),a=(n=n(t)).length;a--;){var i=n[++r];if(!1===e(o[i],i,o))break}return t},Ze=xe?function(t,e){return xe(t,"toString",{configurable:!0,enumerable:!1,value:xt(e),writable:!0})}:It,tn=Ie?function(e){return null==e?[]:(e=Object(e),n(Ie(e),function(t){return Ee.call(e,t)}))}:Ft,en=Ie?function(t){for(var e=[];t;)f(e,tn(t)),t=Oe(t);return e}:Ft,nn=w;(Me&&"[object DataView]"!=nn(new Me(new ArrayBuffer(1)))||ze&&"[object Map]"!=nn(new ze)||Ce&&"[object Promise]"!=nn(Ce.resolve())||Pe&&"[object Set]"!=nn(new Pe)||Ue&&"[object WeakMap]"!=nn(new Ue))&&(nn=function(t){var e=w(t);if(t=(t="[object Object]"==e?t.constructor:Mt)?rt(t):"")switch(t){case $e:return"[object DataView]";case Ve:return"[object Map]";case He:return"[object Promise]";case Be:return"[object Set]";case We:return"[object WeakMap]"}return e});var rn,on,an,un,cn,fn,sn=(un=Ze,fn=cn=0,function(){var t=De(),e=16-(t-fn);if(fn=t,0<e){if(800<=++cn)return arguments[0]}else cn=0;return un.apply(Mt,arguments)}),ln=(an=(on=ut(on=function(t){var o=[];return 46===t.charCodeAt(0)&&o.push(""),t.replace(Rt,function(t,e,n,r){o.push(n?r.replace(Vt,"$1"):e||t)}),o},function(t){return 500===an.size&&an.clear(),t})).cache,on),pn=(rn=ot,function(t,e,n){var r=Object(t);if(!st(t)){var o=W(e,3);t=St(t),e=function(t){return o(r[t],t,r)}}return-1<(e=rn(t,e,n))?r[o?t[e]:e]:Mt});ut.Cache=s;var yn,bn=L(function(){return arguments}())?L:function(t){return ht(t)&&be.call(t,"callee")&&!Ee.call(t,"callee")},hn=Array.isArray,vn=ke||Dt,dn=ue?t(ue):function(t){return ht(t)&&"[object Map]"==nn(t)},gn=ce?t(ce):function(t){return ht(t)&&"[object Set]"==nn(t)}
3733,_n=fe?t(fe):function(t){return ht(t)&&yt(t.length)&&!!Kt[w(t)]},jn=R(function(t,e,n){k(t,e,n)}),mn=R(function(t,e,n,r){k(t,e,n,r)}),An=sn(et(yn=function(e,t){var n={};if(null==e)return n;var r=!1;t=a(t,function(t){return t=D(t,e),r=r||1<t.length,t}),U(e,B(e),n),r&&(n=m(n,7,$));for(var o=t.length;o--;)F(n,t[o]);return n},Mt,at),yn+"");r.constant=xt,r.flatten=at,r.iteratee=kt,r.keys=St,r.keysIn=Lt,r.memoize=ut,r.merge=jn,r.mergeWith=mn,r.negate=ct,r.omit=An,r.property=Nt,r.reject=function(t,e){return(hn(t)?n:function(t,r){var o=[];return Xe(t,function(t,e,n){r(t,e,n)&&o.push(t)}),o})(t,ct(W(e,3)))},r.toPlainObject=At,r.values=Tt,r.cloneDeep=function(t){return m(t,5)},r.cloneDeepWith=function(t,e){return m(t,5,e="function"==typeof e?e:Mt)},r.eq=ft,r.find=pn,r.findIndex=ot,r.get=wt,r.has=function(t,e){return null!=t&&J(t,e,E)},r.hasIn=Et,r.identity=It,r.includes=function(t,e,n,r){if(t=st(t)?t:Tt(t),n=n&&!r?jt(n):0,r=t.length,n<0&&(n=Fe(r+n,0)),dt(t))t=n<=r&&-1<t.indexOf(e,n);else{if(r=!!r){if(e==e)t:{for(n-=1,r=t.length;++n<r;)if(t[n]===e){t=n;break t}t=-1}else t=o(t,i,n);r=-1<t}t=r}return t},r.isArguments=bn,r.isArray=hn,r.isArrayLike=st,r.isArrayLikeObject=lt,r.isBuffer=vn,r.isEmpty=function(t){if(null==t)return!0;if(st(t)&&(hn(t)||"string"==typeof t||"function"==typeof t.splice||vn(t)||_n(t)||bn(t)))return!t.length;var e=nn(t);if("[object Map]"==e||"[object Set]"==e)return!t.size;if(Z(t))return!I(t).length;for(var n in t)if(be.call(t,n))return!1;return!0},r.isEqual=function(t,e){return T(t,e)},r.isFunction=pt,r.isLength=yt,r.isMap=dn,r.isNull=function(t){return null===t},r.isObject=bt,r.isObjectLike=ht,r.isPlainObject=vt,r.isSet=gn,r.isString=dt,r.isSymbol=gt,r.isTypedArray=_n,r.last=it,r.stubArray=Ft,r.stubFalse=Dt,r.toFinite=_t,r.toInteger=jt,r.toNumber=mt,r.toString=Ot,r.VERSION="4.17.5","function"==typeof define&&"object"==_typeof(define.amd)&&define.amd?(ee._=r,define(function(){return r})):re?((re.exports=r)._=r,ne._=r):ee._=r}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(t,e,n){e.exports={itemType:{DATA:"data",FCTN:"fctn",EVENT:"event",LISTENER_ON:"listenerOn",LISTENER_OFF:"listenerOff"},dataLayerEvent:{CHANGE:"adobeDataLayer:change",EVENT:"adobeDataLayer:event"},listenerScope:{PAST:"past",FUTURE:"future",ALL:"all"}}},{}],3:[function(t,e,n){var r=t("../custom-lodash"),l=t("../version.json").version,p=r.cloneDeep,y=r.get,b=t("./item"),h=t("./listener"),v=t("./listenerManager"),d=t("./constants"),g=t("./utils/customMerge");e.exports=function(t){var f,e=t||{},n=[],r=[],o={},a={},i={getState:function(){return o},getDataLayer:function(){return n},getPreviousState:function(){return a}};function u(t){a=p(o),o=g(o,t.data)}function c(t){t.valid?{data:function(t){u(t),f.triggerListeners(t)},fctn:function(t){t.config.call(n,n)},event:function(t){t.data&&u(t),f.triggerListeners(t)},listenerOn:function(t){var e=h(t);switch(e.scope){case d.listenerScope.PAST:var n,r=_createForOfIteratorHelper(c(t));try{for(r.s();!(n=r.n()).done;){var o=n.value;f.triggerListener(e,o)}}catch(t){r.e(t)}finally{r.f()}break;case d.listenerScope.FUTURE:f.register(e);break;case d.listenerScope.ALL:if(f.register(e)){var a,i=_createForOfIteratorHelper(c(t));try{for(i.s();!(a=i.n()).done;){var u=a.value;f.triggerListener(e,u)}}catch(t){i.e(t)}finally{i.f()}}}},listenerOff:function(t){f.unregister(h(t))}}[t.type](t):s(t);function c(t){return 0===n.length||t.index>n.length-1?[]:n.slice(0,t.index).map(function(t){return b(t)})}}function s(t){var e="The following item cannot be handled by the data layer because it does not have a valid format: "+JSON.stringify(t.config);console.error(e)}return function(){Array.isArray(e.dataLayer)||(e.dataLayer=[]);r=e.dataLayer.splice(0,e.dataLayer.length),(n=e.dataLayer).version=l,o={},a={},f=v(i)}(),n.push=function(t){var n=arguments,r=arguments;if(Object.keys(n).forEach(function(t){var e=b(n[t]);switch(e.valid||(s(e),delete r[t]),e.type){case d.itemType.DATA:case d.itemType.EVENT:c(e);break;case d.itemType.FCTN:delete r[t],c(e);break;case d.itemType.LISTENER_ON:case d.itemType.LISTENER_OFF:delete r[t]}}),r[0])return Array.prototype.push.apply(this,r)},n.getState=function(t){return t?y(p(o),t):p(o)},n.addEventListener=function(t,e,n){c(b({on:t,handler:e,scope:n&&n.scope,path:n&&n.path}))},n.removeEventListener=function(t,e){c(b({off:t,handler:e}))},function(){for(var t=0;t<r.length;t++)n.push(r[t])}(),i}},{"../custom-lodash":1,"../version.json":14,"./constants":2,"./item":5,"./listener":7,"./listenerManager":8,"./utils/customMerge":10}],4:[function(t,e,n){var r={Manager:t("./dataLayerManager")};window.adobeDataLayer=window.adobeDataLayer||[],r.Manager({dataLayer:window.adobeDataLayer}),e.exports=r},{"./dataLayerManager":3}],5:[function(t,e,n){var r=t("../custom-lodash"),i=r.isPlainObject,u=r.isEmpty,c=r.omit,f=r.find,s=t("./utils/dataMatchesContraints"),l=t("./itemConstraints"),p=t("./constants");e.exports=function(t,e){var n=t,r=e,o=f(Object.keys(l),function(t){return s(n,l[t])})||"function"==typeof n&&p.itemType.FCTN||i(n)&&p.itemType.DATA,a=function(){var t=c(n,Object.keys(l.event));if(!u(t))return t}();return{config:n,type:o,data:a,valid:!!o,index:r}}},{"../custom-lodash":1,"./constants":2,"./itemConstraints":6,"./utils/dataMatchesContraints":11}],6:[function(t,e,n){e.exports={event:{event:{type:"string"},eventInfo:{optional:!0}},listenerOn:{on:{type:"string"},handler:{type:"function"},scope:{type:"string",values:["past","future","all"],optional:!0},path:{type:"string",optional:!0}},listenerOff:{off:{type:"string"},handler:{type:"function",optional:!0},scope:{type:"string",values:["past","future","all"],optional:!0},path:{type:"string",optional:!0}}}},{}],7:[function(t,e,n){var r=t("./constants");e.exports=function(t){return{event:t.config.on||t.config.off,handler:t.config.handler||null,scope:t.config.scope||t.config.on&&r.listenerScope.ALL||null,path:t.config.path||null}}},{"./constants":2}],8:[function(t,e,n){var r=t("../custom-lodash"),f=r.cloneDeep,s=r.get,i=t("./constants"),l=t("./utils/listenerMatch"),u=t("./utils/indexOfListener");e.exports=function(t){var o={},c=t,r=u.bind(null,o);function a(t,e,n){if(l(t,e)){var r=[f(e.config)];if(e.data)if(t.path){var o=s(c.getPreviousState(),t.path),a=s(f(e.data),t.path);r.push(o,a)}
3733else if(!n){var i=c.getPreviousState(),u=f(c.getState());r.push(i,u)}t.handler.apply(c.getDataLayer(),r)}}return{register:function(t){var e=t.event;return Object.prototype.hasOwnProperty.call(o,e)?-1===r(t)&&(o[t.event].push(t),!0):(o[t.event]=[t],!0)},unregister:function(t){var e=t.event;if(Object.prototype.hasOwnProperty.call(o,e))if(t.handler||t.scope||t.path){var n=r(t);-1<n&&o[e].splice(n,1)}else o[e]=[]},triggerListeners:function(r){(function(t){var e=[];switch(t.type){case i.itemType.DATA:e.push(i.dataLayerEvent.CHANGE);break;case i.itemType.EVENT:e.push(i.dataLayerEvent.EVENT),t.data&&e.push(i.dataLayerEvent.CHANGE),t.config.event!==i.dataLayerEvent.CHANGE&&e.push(t.config.event)}return e})(r).forEach(function(t){if(Object.prototype.hasOwnProperty.call(o,t)){var e,n=_createForOfIteratorHelper(o[t]);try{for(n.s();!(e=n.n()).done;){a(e.value,r,!1)}}catch(t){n.e(t)}finally{n.f()}}})},triggerListener:function(t,e){a(t,e,!0)}}}},{"../custom-lodash":1,"./constants":2,"./utils/indexOfListener":12,"./utils/listenerMatch":13}],9:[function(t,e,n){var r=t("../../custom-lodash"),o=r.has,a=r.get;e.exports=function(t,e){for(var n=e.substring(0,e.lastIndexOf("."));n;){if(o(t,n)){var r=a(t,n);if(null==r)return!0}n=n.substring(0,n.lastIndexOf("."))}return!1}},{"../../custom-lodash":1}],10:[function(t,e,n){var r=t("../../custom-lodash"),s=r.cloneDeepWith,l=r.isObject,p=r.isArray,y=r.reject,o=r.mergeWith,a=r.isNull;e.exports=function(t,e){return o(t,e,function(t,e,n,r){if(null==e)return null}),t=function(t,e){return s(t,function(f){return function e(t,n,r,o){if(l(t)){if(p(t))return y(t,f).map(function(t){return s(t,e)});for(var a={},i=0,u=Object.keys(t);i<u.length;i++){var c=u[i];f(t[c])||(a[c]=s(t[c],e))}return a}}}(1<arguments.length&&void 0!==e?e:function(t){return!t}))}(t,a)}},{"../../custom-lodash":1}],11:[function(t,e,n){var r=t("../../custom-lodash"),o=r.find,s=r.includes;e.exports=function(c,f){return void 0===o(Object.keys(f),function(t){var e=f[t].type,n=t&&f[t].values,r=!f[t].optional,o=c[t],a=_typeof(o),i=e&&a!==e,u=n&&!s(n,o);return r?!o||i||u:o&&(i||u)})}},{"../../custom-lodash":1}],12:[function(t,e,n){var c=t("../../custom-lodash").isEqual;e.exports=function(t,e){var n=e.event;if(Object.prototype.hasOwnProperty.call(t,n)){var r,o=_createForOfIteratorHelper(t[n].entries());try{for(o.s();!(r=o.n()).done;){var a=_slicedToArray(r.value,2),i=a[0],u=a[1];if(c(u.handler,e.handler))return i}}catch(t){o.e(t)}finally{o.f()}}return-1}},{"../../custom-lodash":1}],13:[function(t,e,n){var r=t("../../custom-lodash").has,a=t("../constants"),o=t("./ancestorRemoved");function i(t,e){return!e.data||!t.path||(r(e.data,t.path)||o(e.data,t.path))}e.exports=function(t,e){var n=t.event,r=e.config,o=!1;return e.type===a.itemType.DATA?n===a.dataLayerEvent.CHANGE&&(o=i(t,e)):e.type===a.itemType.EVENT&&(n!==a.dataLayerEvent.EVENT&&n!==r.event||(o=i(t,e)),e.data&&n===a.dataLayerEvent.CHANGE&&(o=i(t,e))),o}},{"../../custom-lodash":1,"../constants":2,"./ancestorRemoved":9}],14:[function(t,e,n){e.exports={version:"1.1.3"}},{}]},{},[4]); 3734//# sourceMappingURL=adobe-client-data-layer.min.js.map 3735 3736/******************************************************************************* 3737 * Copyright 2020 Adobe 3738 * 3739 * Licensed under the Apache License, Version 2.0 (the "License"); 3740 * you may not use this file except in compliance with the License. 3741 * You may obtain a copy of the License at 3742 * 3743 * http://www.apache.org/licenses/LICENSE-2.0 3744 * 3745 * Unless required by applicable law or agreed to in writing, software 3746 * distributed under the License is distributed on an "AS IS" BASIS, 3747 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3748 * See the License for the specific language governing permissions and 3749 * limitations under the License. 3750 ******************************************************************************/ 3751(function() { 3752 "use strict"; 3753 3754 var dataLayerEnabled; 3755 var dataLayer; 3756 3757 function addComponentToDataLayer(component) { 3758 dataLayer.push({ 3759 component: getComponentObject(component) 3760 }); 3761 } 3762 3763 function attachClickEventListener(element) { 3764 element.addEventListener("click", addClickToDataLayer); 3765 } 3766 3767 function getComponentObject(element) { 3768 var component = getComponentData(element); 3769 var componentID = Object.keys(component)[0]; 3770 // if the component does not have a parent ID property, use the ID of the parent element 3771 if (component && component[componentID] && !component[componentID].parentId) { 3772 var parentElement = element.parentNode.closest("[data-cmp-data-layer], body"); 3773 if (parentElement) { 3774 component[componentID].parentId = parentElement.id; 3775 } 3776 } 3777 3778 return component; 3779 } 3780 3781 function addClickToDataLayer(event) { 3782 var element = event.currentTarget; 3783 var componentId = getClickId(element); 3784 3785 dataLayer.push({ 3786 event: "cmp:click", 3787 eventInfo: { 3788 path: "component." + componentId 3789 } 3790 }); 3791 } 3792 3793 function getComponentData(element) { 3794 var dataLayerJson = element.dataset.cmpDataLayer; 3795 return JSON.parse(dataLayerJson); 3796 } 3797 3798 function getClickId(element) { 3799 if (element.dataset.cmpDataLayer) { 3800 return Object.keys(JSON.parse(element.dataset.cmpDataLayer))[0]; 3801 } 3802 3803 var componentElement = element.closest("[data-cmp-data-layer]"); 3804 3805 return Object.keys(JSON.parse(componentElement.dataset.cmpDataLayer))[0]; 3806 } 3807 3808 function onDocumentReady() { 3809 dataLayerEnabled = document.body.hasAttribute("data-cmp-data-layer-enabled"); 3810 dataLayer = (dataLayerEnabled)? window.adobeDataLayer = window.adobeDataLayer || [] : undefined; 3811 3812 if (dataLayerEnabled) { 3813 3814 var components = document.querySelectorAll("[data-cmp-data-layer]"); 3815 var clickableElements = document.querySelectorAll("[data-cmp-clickable]"); 3816
3817 components.forEach(function (component) { 3818 addComponentToDataLayer(component); 3819 }); 3820 3821 clickableElements.forEach(function (element) { 3822 attachClickEventListener(element); 3823 }); 3824 3825 dataLayer.push({ 3826 event: "cmp:loaded" 3827 }); 3828 } 3829 } 3830 3831 if (document.readyState !== "loading") { 3832 onDocumentReady(); 3833 } else { 3834 document.addEventListener("DOMContentLoaded", onDocumentReady); 3835 } 3836 3837}()); 3838 3839/******************************************************************************* 3840 * Copyright 2018 Adobe Systems Incorporated 3841 * 3842 * Licensed under the Apache License, Version 2.0 (the "License"); 3843 * you may not use this file except in compliance with the License. 3844 * You may obtain a copy of the License at 3845 * 3846 * http://www.apache.org/licenses/LICENSE-2.0 3847 * 3848 * Unless required by applicable law or agreed to in writing, software 3849 * distributed under the License is distributed on an "AS IS" BASIS, 3850 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3851 * See the License for the specific language governing permissions and 3852 * limitations under the License. 3853 ******************************************************************************/ 3854(function($, window) { 3855 "use strict"; 3856 3857 $.fn.extend({ 3858 hasClasses: function(selector) { 3859 if (typeof selector == 'string') { 3860 selector = (selector.match(/^\./)) ? selector.replace(/^\./, '').split('.') : $.trim(selector).split(' '); 3861 } 3862 for (var i = 0, len = selector.length; i < len; i++) { 3863 if (this.hasClass(selector[i])) { 3864 return true; 3865 } 3866 } 3867 return false; 3868 } 3869 }); 3870 3871 $(window).on("load", function() { 3872 var modalOpenElements = document.getElementsByClassName("cmp-modal__open"); 3873 for(var i=0; i< modalOpenElements.length; i++) { 3874 $(modalOpenElements[i]).find("a").addClass("cmp-modal__js-open"); 3875 $(modalOpenElements[i]).find("a").attr("data-target", "modal-target" + (i + 1)); 3876 $(modalOpenElements[i]).find(".cmp-modal__js-target").attr("id", "modal-target" + (i + 1)); 3877 } 3878 }); 3879 3880 $(".cmp-modal__open").each(function(){ 3881 var firstAElement = $(this).find("a").eq(0); 3882 var modalOpenElement = $(this); 3883 3884 $(firstAElement).on("click",function(){
3885 /* Images that disappear after animation do not display modal. */ 3886 if ($(modalOpenElement).hasClasses("bounceOut fadeOut")) { 3887 return false; 3888 } 3889 3890 var target = $(firstAElement).data("target"); 3891 var modal = document.getElementById(target); 3892 var speed = $(modal).data("animate-speed"); 3893 if (speed && !isNaN(parseInt(speed, 10))) { 3894 $(modal).fadeIn(parseInt(speed, 10)); 3895 } else { 3896 $(modal).fadeIn(1000); 3897 } 3898 3899 $(modal).parent(".cmp-modal").parent(".modal").appendTo("body"); 3900 3901 return false; 3902 }); 3903 }); 3904 3905 $(".cmp-modal__js-close").on("click",function(){ 3906 var action = "pauseVideo"; 3907 var $playerWindow = $('iframe.cmp-youtube__trigger'); 3908 3909 $.each($playerWindow,function(){ 3910 this.contentWindow.postMessage('{"event":"command","func":"'+action+'","args":""}', '*'); 3911 }); 3912 3913 $(".cmp-modal__js-target").fadeOut(); 3914 3915 return false; 3916 }); 3917 3918 /* Processing at the end of animation of the display source image component. */ 3919 $(".cmp-image.animated.cmp-modal__open").on("webkitAnimationEnd", function(){ 3920 $(this).addClass("cmp-modal__animation-end"); 3921 }); 3922}(jQuery, this)); 3923 3924/******************************************************************************* 3925 * Copyright 2018 Adobe Systems Incorporated 3926 * 3927 * Licensed under the Apache License, Version 2.0 (the "License"); 3928 * you may not use this file except in compliance with the License. 3929 * You may obtain a copy of the License at 3930 * 3931 * http://www.apache.org/licenses/LICENSE-2.0 3932 * 3933 * Unless required by applicable law or agreed to in writing, software 3934 * distributed under the License is distributed on an "AS IS" BASIS, 3935 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3936 * See the License for the specific language governing permissions and 3937 * limitations under the License. 3938 ******************************************************************************/ 3939(function($, window) { 3940 "use strict"; 3941 3942 var windowWidth = parseInt(window.innerWidth); 3943 var breakpoint = 780; 3944 var flgMenu = ""; 3945 var isNavOpen = false; 3946 3947 function spMenu() { 3948 windowWidth = parseInt(window.innerWidth); 3949 if (windowWidth < breakpoint && flgMenu !== "sp") { 3950 let navigationButton = $(".cmp-header__content-top-nav-button"); 3951 let navigationItems = $(".cmp-header__navigation")[0]; 3952 $(navigationItems).css({ 3953 display: 'block' 3954 }); 3955 $(navigationItems).hide(); 3956 $(".cmp-header__content-top-menu").hide(); 3957 $(".cmp-header__content-top-search").hide(); 3958 $("[class*='cmp-header__content-top-nav-button'][class*='navClose']").css({ 3959 display: "none" 3960 }); 3961 $("[class*='cmp-header__content-top-nav-button'][class*='navOpen']").css({ 3962 display: "block" 3963 }); 3964 var liFrame = null; 3965 if ($(navigationItems).length > 0) { 3966 let clone = $($(navigationItems).children().eq(0)).clone()[0]; 3967 $(clone).empty(); 3968 liFrame = clone; 3969 } 3970 if (liFrame !== null) { 3971 let children = $(".cmp-header__content-top-menu").children("li"); 3972 for (var i = 0; i < children.length; i++) { 3973 let clone = $(children[i]).clone(); 3974 let addChild = $(liFrame).clone()[0]; 3975 $($(clone).children().eq(0)).appendTo($(addChild)); 3976 $(addChild).addClass("sp"); 3977 $(addChild).appendTo(navigationItems); 3978 } 3979 let addChild = $(liFrame).clone()[0]; 3980 let cloneSearch = $($(".cmp-header__content-top-search")[0]).clone(); 3981 $(cloneSearch).css({ 3982 display: "block" 3983 }) 3984 $(cloneSearch).appendTo($(addChild)); 3985 $(addChild).addClass("sp"); 3986 $(addChild).appendTo(navigationItems); 3987 } 3988 flgMenu = "sp"; 3989 3990 navigationButton.on("click", function () { 3991 if (isNavOpen) { 3992 $("[class*='cmp-header__content-top-nav-button'][class*='navClose']").css({ 3993 display: "none" 3994 }); 3995 $(navigationItems).fadeOut(); 3996 $("[class*='cmp-header__content-top-nav-button'][class*='navOpen']").css({ 3997 display: "block" 3998 }); 3999 4000 } else { 4001 $("[class*='cmp-header__content-top-nav-button'][class*='navOpen']").css({ 4002 display: "none" 4003 }); 4004 $(navigationItems).fadeIn(); 4005 $("[class*='cmp-header__content-top-nav-button'][class*='navClose']").css({ 4006 display: "block" 4007 }); 4008 } 4009 isNavOpen = !isNavOpen; 4010 }); 4011 4012 } else if (windowWidth >= breakpoint && flgMenu !== "pc") { 4013 let navigationItems = $(".cmp-header__navigation")[0]; 4014 $(navigationItems).hide(); 4015 4016 let navigationButton = $(".cmp-header__content-top-nav-button"); 4017 $(navigationButton).off('click'); 4018 $("[class*='cmp-header__content-top-nav-button'][class*='navClose']").css({ 4019 display: "none" 4020 }); 4021 $("[class*='cmp-header__content-top-nav-button'][class*='navOpen']").css({ 4022 display: "block" 4023 }); 4024 $(navigationButton).hide(); 4025 isNavOpen = false;
4026 4027 $(".cmp-header__content-top-menu").show(); 4028 $(".cmp-header__content-top-search").show(); 4029 4030 $(navigationItems).find('.sp').remove(); 4031 $(navigationItems).css({ 4032 display: 'flex' 4033 }); 4034 flgMenu = "pc"; 4035 } 4036 } 4037 4038 $(function () { 4039 $(window).on("load resize", function () { 4040 spMenu(); 4041 }); 4042 }); 4043}(jQuery, this)); 4044 4045(function($, window) { 4046 "use strict"; 4047 4048 $(".cmp-footer__content-scroll-to-top-button").click(function () { 4049 $("body,html").animate({ 4050 scrollTop: 0 4051 }, 500); 4052 return false; 4053 }); 4054}(jQuery, this)); 4055 4056(function($) { 4057 "use strict"; 4058 4059 $(".scroll-to-top a").click(function () { 4060 $("body,html").animate({ 4061 scrollTop: 0 4062 }, 500); 4063 return false; 4064 }); 4065}(jQuery, this)); 4066
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.