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