diff --git a/ui.apps/src/main/content/jcr_root/apps/core/cif/clientlibs/common/js/CommerceGraphqlApi.js b/ui.apps/src/main/content/jcr_root/apps/core/cif/clientlibs/common/js/CommerceGraphqlApi.js index 86e21d7dda..bc34dbcfc7 100644 --- a/ui.apps/src/main/content/jcr_root/apps/core/cif/clientlibs/common/js/CommerceGraphqlApi.js +++ b/ui.apps/src/main/content/jcr_root/apps/core/cif/clientlibs/common/js/CommerceGraphqlApi.js @@ -13,6 +13,7 @@ ******************************************************************************/ 'use strict'; +window.CIF = window.CIF || {}; class CommerceGraphqlApi { constructor(props) { if (!props || !props.endpoint || !props.storeView) { diff --git a/ui.apps/src/main/content/jcr_root/apps/core/cif/clientlibs/common/js/PageContext.js b/ui.apps/src/main/content/jcr_root/apps/core/cif/clientlibs/common/js/PageContext.js deleted file mode 100644 index 33d8ff3982..0000000000 --- a/ui.apps/src/main/content/jcr_root/apps/core/cif/clientlibs/common/js/PageContext.js +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * - * Copyright 2019 Adobe. All rights reserved. - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - * - ******************************************************************************/ - -/** - * A context object which controls the page behaviour and holds the state of the various components on the page - * @type {*|{}} - */ - -let PageContext = (function(document) { - 'use strict'; - - const checkCookie = cookieName => { - return document.cookie.split(';').filter(item => item.trim().startsWith(`${cookieName}=`)).length > 0; - }; - - const cookieValue = cookieName => { - let b = document.cookie.match(`(^|[^;]+)\\s*${cookieName}\\s*=\\s*([^;]+)`); - return b ? b.pop() : ''; - }; - - function PageContext() { - let cartInfo = {}; - // process the cif.cart cookie, containing the cartId and cartQuote - const cookieName = 'cif.cart'; - if (checkCookie(cookieName)) { - const cifCartCookie = cookieValue(cookieName); - - if (cifCartCookie.length > 0) { - let [cartId, cartQuote] = cifCartCookie.split('#'); - cartInfo = { cartId, cartQuote }; - } - } - - return { - cartInfo: cartInfo, - setCartInfoCookie: function({ cartId, cartQuote }) { - document.cookie = `${cookieName}=${cartId}#${cartQuote};path=/`; - } - }; - } - - return PageContext; -})(window.document); - -export default PageContext; diff --git a/ui.apps/src/main/content/jcr_root/apps/core/cif/clientlibs/common/js/pageContextLoader.js b/ui.apps/src/main/content/jcr_root/apps/core/cif/clientlibs/common/js/pageContextLoader.js deleted file mode 100644 index 0f7e7c0c52..0000000000 --- a/ui.apps/src/main/content/jcr_root/apps/core/cif/clientlibs/common/js/pageContextLoader.js +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * - * Copyright ${year} Adobe. All rights reserved. - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - * - ******************************************************************************/ - -import PageContext from './PageContext.js'; - -window.CIF = window.CIF || {}; - -(function() { - function onDocumentReady() { - window.CIF.PageContext = new PageContext(); - } - - if (document.readyState !== 'loading') { - onDocumentReady(); - } else { - document.addEventListener('DOMContentLoaded', onDocumentReady); - } -})(); diff --git a/ui.apps/test/components/commerce/navigation/navigationTest.js b/ui.apps/test/components/commerce/navigation/navigationTest.js index 59991937ae..a2c2c20195 100644 --- a/ui.apps/test/components/commerce/navigation/navigationTest.js +++ b/ui.apps/test/components/commerce/navigation/navigationTest.js @@ -21,12 +21,6 @@ describe('Navigation', () => { var navigationRoot; before(() => { - window.CIF = { - PageContext: { - maskPage: function() {}, - unmaskPage: function() {} - } - }; body = window.document.querySelector('body'); navigationRoot = document.createElement('div'); body.insertAdjacentElement('afterbegin', navigationRoot);