From e9ab5fc2d92ee175e4709636389460f8aef75488 Mon Sep 17 00:00:00 2001 From: Connor Anderson Date: Thu, 20 May 2021 13:29:57 -0400 Subject: [PATCH 01/13] fix race condition --- script/core.hbs | 10 ++ script/partials/page-specific-scripts.hbs | 3 + script/partials/sdk-js-script-tags.hbs | 4 +- static/entry.js | 5 +- static/js/page-specific-scripts-loaded.js | 13 +++ .../VerticalFullPageMapOrchestrator.js | 2 +- .../vertical-full-page-map/page-setup.js | 29 +---- .../vertical-full-page-map/page.html.hbs | 106 +++++++++--------- ..._full_page_map_with_filters.html.hbs.patch | 60 +++++----- 9 files changed, 119 insertions(+), 113 deletions(-) create mode 100644 script/partials/page-specific-scripts.hbs create mode 100644 static/js/page-specific-scripts-loaded.js diff --git a/script/core.hbs b/script/core.hbs index f8b28dbd6..d3b6eb2a1 100644 --- a/script/core.hbs +++ b/script/core.hbs @@ -7,6 +7,14 @@ +{{/ifeq}} \ No newline at end of file diff --git a/script/partials/sdk-js-script-tags.hbs b/script/partials/sdk-js-script-tags.hbs index 4f93801be..935465dd6 100644 --- a/script/partials/sdk-js-script-tags.hbs +++ b/script/partials/sdk-js-script-tags.hbs @@ -6,11 +6,11 @@ \ No newline at end of file diff --git a/static/entry.js b/static/entry.js index f571d728e..f420b475d 100644 --- a/static/entry.js +++ b/static/entry.js @@ -32,4 +32,7 @@ import StorageKeys from './js/constants/storage-keys'; export { StorageKeys }; import transformFacets from './js/transform-facets'; -export { transformFacets } \ No newline at end of file +export { transformFacets } + +import pageSpecificScriptsLoaded from './js/page-specific-scripts-loaded.js' +export { pageSpecificScriptsLoaded }; \ No newline at end of file diff --git a/static/js/page-specific-scripts-loaded.js b/static/js/page-specific-scripts-loaded.js new file mode 100644 index 000000000..180f51779 --- /dev/null +++ b/static/js/page-specific-scripts-loaded.js @@ -0,0 +1,13 @@ +/** + * A promise executor function which calls resolve once all page-specific scripts are loaded + * + * @param {Function} resolve + */ +export default function (resolve) { + const locatorBundleScript = document.querySelector('script#js-answersLocatorBundleScript'); + if (locatorBundleScript) { + locatorBundleScript.onload = resolve; + } else { + resolve(); + } +}; \ No newline at end of file diff --git a/static/js/theme-map/VerticalFullPageMapOrchestrator.js b/static/js/theme-map/VerticalFullPageMapOrchestrator.js index b5099e95a..e75bc1926 100644 --- a/static/js/theme-map/VerticalFullPageMapOrchestrator.js +++ b/static/js/theme-map/VerticalFullPageMapOrchestrator.js @@ -67,7 +67,7 @@ class VerticalFullPageMapOrchestrator extends ANSWERS.Component { * The default zoom level for the map * @type {number} */ - this.defaultZoom = this.providerOptions.zoom || 14; + this.defaultZoom = this.providerOptions.zoom || 4; /** * The current zoom level of the map diff --git a/templates/vertical-full-page-map/page-setup.js b/templates/vertical-full-page-map/page-setup.js index 9e01130d2..14ef945d4 100644 --- a/templates/vertical-full-page-map/page-setup.js +++ b/templates/vertical-full-page-map/page-setup.js @@ -1,31 +1,8 @@ -function addFullPageMap() { - {{> theme-components/theme-map/script}} - {{> theme-components/vertical-full-page-map/script}} -} - -if (window.locatorBundleLoaded) { - addFullPageMap(); -} else { - const locatorBundleScript = document.querySelector('script#js-answersLocatorBundleScript'); - locatorBundleScript.onload = () => { - window.locatorBundleLoaded = true; - locatorBundleScript.dispatchEvent(new Event('vertical-full-page-map-bundle-loaded')); - addFullPageMap(); - } -} - /** - * Registers listeners on the card once the locator bundle is loaded + * Registers listeners on the card * * @param {ANSWERS.Component} card A location card */ -function registerVerticalFullPageMapCardListeners(card) { - if (window.locatorBundleLoaded) { - new VerticalFullPageMap.CardListenerAssigner({card: card}).addListenersToCard(); - return; - } - const verticalFullPageMapScript = document.querySelector('script#js-verticalFullPageMapScript'); - verticalFullPageMapScript.addEventListener('vertical-full-page-map-bundle-loaded', () => { - new VerticalFullPageMap.CardListenerAssigner({card: card}).addListenersToCard(); - }); + function registerVerticalFullPageMapCardListeners(card) { + new VerticalFullPageMap.CardListenerAssigner({card: card}).addListenersToCard(); } \ No newline at end of file diff --git a/templates/vertical-full-page-map/page.html.hbs b/templates/vertical-full-page-map/page.html.hbs index 7302b1077..f51d21da7 100644 --- a/templates/vertical-full-page-map/page.html.hbs +++ b/templates/vertical-full-page-map/page.html.hbs @@ -1,6 +1,8 @@ {{#> layouts/html pageWrapperCss="YxtPage-wrapper--mobileListView" }} - {{#> script/core }} + {{#> script/core pageTemplate="vertical-full-page-map"}} {{> cards/all }} + {{> theme-components/theme-map/script}} + {{> theme-components/vertical-full-page-map/script}} {{!-- {{> templates/vertical-full-page-map/collapsible-filters/page-setup }} --}} {{> templates/vertical-full-page-map/page-setup }} {{> templates/vertical-full-page-map/script/searchbar }} @@ -17,66 +19,64 @@ {{> templates/vertical-full-page-map/script/locationbias modifier="main" }} {{> templates/vertical-full-page-map/script/locationbias modifier="mobileMap" }} {{/script/core }} - -
-
-
-
-
-
- {{> templates/vertical-full-page-map/markup/searchbar }} - {{> templates/vertical-full-page-map/markup/navigation }} -
-
- {{> templates/vertical-full-page-map/markup/spellcheck }} -
- {{> templates/vertical-full-page-map/markup/verticalresultscount }} - {{> templates/vertical-full-page-map/markup/appliedfilters }} - {{!-- {{> templates/vertical-full-page-map/collapsible-filters/markup/filterlink }} --}} - {{!-- {{> templates/vertical-full-page-map/collapsible-filters/markup/viewresultsbutton }} --}} -
-
- {{> templates/vertical-full-page-map/markup/alternativeresults }} +
+
+
+
+
+
+ {{> templates/vertical-full-page-map/markup/searchbar }} + {{> templates/vertical-full-page-map/markup/navigation }}
- - {{!--
--}} - {{!-- {{> templates/vertical-full-page-map/markup/sortoptions }} --}} - {{!-- {{> templates/vertical-full-page-map/markup/facets }} --}} - {{!-- {{> templates/vertical-full-page-map/markup/filterbox }} --}} - {{!--
--}} -
-
-
-
- {{> templates/vertical-full-page-map/markup/verticalresults }} - {{> templates/vertical-full-page-map/markup/pagination }} - {{!-- {{> templates/vertical-full-page-map/markup/qasubmission }} --}} -
-
-
-
-
- {{> templates/vertical-full-page-map/markup/searchthisareabutton }} + {{> templates/vertical-full-page-map/markup/spellcheck }} +
+ {{> templates/vertical-full-page-map/markup/verticalresultscount }} + {{> templates/vertical-full-page-map/markup/appliedfilters }} + {{!-- {{> templates/vertical-full-page-map/collapsible-filters/markup/filterlink }} --}} + {{!-- {{> templates/vertical-full-page-map/collapsible-filters/markup/viewresultsbutton }} --}}
-
- {{> templates/vertical-full-page-map/markup/searchthisareatoggle modifier="desktop"}} - {{> templates/vertical-full-page-map/markup/locationbias modifier="main"}} +
+ {{> templates/vertical-full-page-map/markup/alternativeresults }}
-
- {{> templates/vertical-full-page-map/markup/map }} -
- {{> templates/vertical-full-page-map/markup/searchthisareatoggle modifier="mobileMap"}} - {{> templates/vertical-full-page-map/markup/locationbias modifier="mobileMap"}} + + {{!--
--}} + {{!-- {{> templates/vertical-full-page-map/markup/sortoptions }} --}} + {{!-- {{> templates/vertical-full-page-map/markup/facets }} --}} + {{!-- {{> templates/vertical-full-page-map/markup/filterbox }} --}} + {{!--
--}} +
+
+
+
+ {{> templates/vertical-full-page-map/markup/verticalresults }} + {{> templates/vertical-full-page-map/markup/pagination }} + {{!-- {{> templates/vertical-full-page-map/markup/qasubmission }} --}} +
+
- {{> templates/vertical-full-page-map/markup/mobilelisttoggles }} +
+ {{> templates/vertical-full-page-map/markup/searchthisareabutton }} +
+
+ {{> templates/vertical-full-page-map/markup/searchthisareatoggle modifier="desktop"}} + {{> templates/vertical-full-page-map/markup/locationbias modifier="main"}} +
+
+ {{> templates/vertical-full-page-map/markup/map }} +
+ {{> templates/vertical-full-page-map/markup/searchthisareatoggle modifier="mobileMap"}} + {{> templates/vertical-full-page-map/markup/locationbias modifier="mobileMap"}} +
+
+ {{> templates/vertical-full-page-map/markup/mobilelisttoggles }}
- +
+ {{/layouts/html }} diff --git a/test-site/pages-patches/locations_full_page_map_with_filters.html.hbs.patch b/test-site/pages-patches/locations_full_page_map_with_filters.html.hbs.patch index f4cc27221..466233289 100644 --- a/test-site/pages-patches/locations_full_page_map_with_filters.html.hbs.patch +++ b/test-site/pages-patches/locations_full_page_map_with_filters.html.hbs.patch @@ -1,15 +1,15 @@ ---- locations_full_page_map_with_filters.html.hbs -+++ locations_full_page_map_with_filters.html.hbs -@@ -1,7 +1,7 @@ - {{#> layouts/html pageWrapperCss="YxtPage-wrapper--mobileListView" }} - {{#> script/core }} +--- templates/vertical-full-page-map/page.html.hbs 2021-05-19 22:15:49.000000000 -0400 ++++ test-site/pages/locations_full_page_map_with_filters.html.hbs 2021-05-20 11:19:09.000000000 -0400 +@@ -3,7 +3,7 @@ {{> cards/all }} + {{> theme-components/theme-map/script}} + {{> theme-components/vertical-full-page-map/script}} - {{!-- {{> templates/vertical-full-page-map/collapsible-filters/page-setup }} --}} + {{> templates/vertical-full-page-map/collapsible-filters/page-setup }} {{> templates/vertical-full-page-map/page-setup }} {{> templates/vertical-full-page-map/script/searchbar }} {{> templates/vertical-full-page-map/script/spellcheck }} -@@ -9,7 +9,7 @@ +@@ -11,7 +11,7 @@ {{> templates/vertical-full-page-map/script/verticalresultscount }} {{> templates/vertical-full-page-map/script/appliedfilters }} {{!-- {{> templates/vertical-full-page-map/script/sortoptions }} --}} @@ -18,28 +18,28 @@ {{!-- {{> templates/vertical-full-page-map/script/filterbox }} --}} {{> templates/vertical-full-page-map/script/verticalresults }} {{> templates/vertical-full-page-map/script/pagination }} -@@ -32,19 +32,19 @@ -
- {{> templates/vertical-full-page-map/markup/verticalresultscount }} - {{> templates/vertical-full-page-map/markup/appliedfilters }} -- {{!-- {{> templates/vertical-full-page-map/collapsible-filters/markup/filterlink }} --}} -- {{!-- {{> templates/vertical-full-page-map/collapsible-filters/markup/viewresultsbutton }} --}} -+ {{> templates/vertical-full-page-map/collapsible-filters/markup/filterlink }} -+ {{> templates/vertical-full-page-map/collapsible-filters/markup/viewresultsbutton }} -
-
- {{> templates/vertical-full-page-map/markup/alternativeresults }} -
+@@ -33,19 +33,19 @@ +
+ {{> templates/vertical-full-page-map/markup/verticalresultscount }} + {{> templates/vertical-full-page-map/markup/appliedfilters }} +- {{!-- {{> templates/vertical-full-page-map/collapsible-filters/markup/filterlink }} --}} +- {{!-- {{> templates/vertical-full-page-map/collapsible-filters/markup/viewresultsbutton }} --}} ++ {{> templates/vertical-full-page-map/collapsible-filters/markup/filterlink }} ++ {{> templates/vertical-full-page-map/collapsible-filters/markup/viewresultsbutton }}
- -- {{!--
--}} -+
- {{!-- {{> templates/vertical-full-page-map/markup/sortoptions }} --}} -- {{!-- {{> templates/vertical-full-page-map/markup/facets }} --}} -+ {{> templates/vertical-full-page-map/markup/facets }} - {{!-- {{> templates/vertical-full-page-map/markup/filterbox }} --}} -- {{!--
--}} -+
-
-
-
+
+ {{> templates/vertical-full-page-map/markup/alternativeresults }} +
+
+ +- {{!--
--}} ++
+ {{!-- {{> templates/vertical-full-page-map/markup/sortoptions }} --}} +- {{!-- {{> templates/vertical-full-page-map/markup/facets }} --}} ++ {{> templates/vertical-full-page-map/markup/facets }} + {{!-- {{> templates/vertical-full-page-map/markup/filterbox }} --}} +- {{!--
--}} ++
+
+
+
From 6d554334872de56704d3dcfc782dc823e967e125 Mon Sep 17 00:00:00 2001 From: Connor Anderson Date: Thu, 20 May 2021 15:29:50 -0400 Subject: [PATCH 02/13] fix unit tests --- tests/script/partials/sdk-js-script-tags.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/script/partials/sdk-js-script-tags.js b/tests/script/partials/sdk-js-script-tags.js index f12e37ef0..83ad65cbf 100644 --- a/tests/script/partials/sdk-js-script-tags.js +++ b/tests/script/partials/sdk-js-script-tags.js @@ -3,24 +3,24 @@ const hbs = require('../../test-utils/hbs'); const defaultOutput = ` `; const jaOutput = ` `; From 35c841066cfd69fc638966a69cc6a49e1ec9f9ca Mon Sep 17 00:00:00 2001 From: Connor Anderson Date: Thu, 20 May 2021 16:13:53 -0400 Subject: [PATCH 03/13] add a tab --- .../vertical-full-page-map/page.html.hbs | 100 +++++++++--------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/templates/vertical-full-page-map/page.html.hbs b/templates/vertical-full-page-map/page.html.hbs index f51d21da7..beb68498e 100644 --- a/templates/vertical-full-page-map/page.html.hbs +++ b/templates/vertical-full-page-map/page.html.hbs @@ -19,64 +19,64 @@ {{> templates/vertical-full-page-map/script/locationbias modifier="main" }} {{> templates/vertical-full-page-map/script/locationbias modifier="mobileMap" }} {{/script/core }} -
-
-
-
-
-
- {{> templates/vertical-full-page-map/markup/searchbar }} - {{> templates/vertical-full-page-map/markup/navigation }} +
+
+
+
+
+
+ {{> templates/vertical-full-page-map/markup/searchbar }} + {{> templates/vertical-full-page-map/markup/navigation }} +
+
+ {{> templates/vertical-full-page-map/markup/spellcheck }} +
+ {{> templates/vertical-full-page-map/markup/verticalresultscount }} + {{> templates/vertical-full-page-map/markup/appliedfilters }} + {{!-- {{> templates/vertical-full-page-map/collapsible-filters/markup/filterlink }} --}} + {{!-- {{> templates/vertical-full-page-map/collapsible-filters/markup/viewresultsbutton }} --}} +
+
+ {{> templates/vertical-full-page-map/markup/alternativeresults }}
- {{> templates/vertical-full-page-map/markup/spellcheck }} -
- {{> templates/vertical-full-page-map/markup/verticalresultscount }} - {{> templates/vertical-full-page-map/markup/appliedfilters }} - {{!-- {{> templates/vertical-full-page-map/collapsible-filters/markup/filterlink }} --}} - {{!-- {{> templates/vertical-full-page-map/collapsible-filters/markup/viewresultsbutton }} --}} -
-
- {{> templates/vertical-full-page-map/markup/alternativeresults }} -
-
- - {{!--
--}} - {{!-- {{> templates/vertical-full-page-map/markup/sortoptions }} --}} - {{!-- {{> templates/vertical-full-page-map/markup/facets }} --}} - {{!-- {{> templates/vertical-full-page-map/markup/filterbox }} --}} - {{!--
--}} -
-
-
-
- {{> templates/vertical-full-page-map/markup/verticalresults }} - {{> templates/vertical-full-page-map/markup/pagination }} - {{!-- {{> templates/vertical-full-page-map/markup/qasubmission }} --}} + + {{!--
--}} + {{!-- {{> templates/vertical-full-page-map/markup/sortoptions }} --}} + {{!-- {{> templates/vertical-full-page-map/markup/facets }} --}} + {{!-- {{> templates/vertical-full-page-map/markup/filterbox }} --}} + {{!--
--}} +
+
+
+
+ {{> templates/vertical-full-page-map/markup/verticalresults }} + {{> templates/vertical-full-page-map/markup/pagination }} + {{!-- {{> templates/vertical-full-page-map/markup/qasubmission }} --}} +
+
+ {{> templates/vertical-full-page-map/markup/searchthisareabutton }} +
+
+ {{> templates/vertical-full-page-map/markup/searchthisareatoggle modifier="desktop"}} + {{> templates/vertical-full-page-map/markup/locationbias modifier="main"}} +
-
- {{> templates/vertical-full-page-map/markup/searchthisareabutton }} -
-
- {{> templates/vertical-full-page-map/markup/searchthisareatoggle modifier="desktop"}} - {{> templates/vertical-full-page-map/markup/locationbias modifier="main"}} -
-
-
- {{> templates/vertical-full-page-map/markup/map }} -
- {{> templates/vertical-full-page-map/markup/searchthisareatoggle modifier="mobileMap"}} - {{> templates/vertical-full-page-map/markup/locationbias modifier="mobileMap"}} +
+ {{> templates/vertical-full-page-map/markup/map }} +
+ {{> templates/vertical-full-page-map/markup/searchthisareatoggle modifier="mobileMap"}} + {{> templates/vertical-full-page-map/markup/locationbias modifier="mobileMap"}} +
+ {{> templates/vertical-full-page-map/markup/mobilelisttoggles }}
- {{> templates/vertical-full-page-map/markup/mobilelisttoggles }}
-
- + {{/layouts/html }} From a5d8ef6290a18aeeba847a53e013bc5291dbaab7 Mon Sep 17 00:00:00 2001 From: Connor Anderson Date: Thu, 20 May 2021 16:21:04 -0400 Subject: [PATCH 04/13] revert tab --- .../vertical-full-page-map/page.html.hbs | 100 +++++++++--------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/templates/vertical-full-page-map/page.html.hbs b/templates/vertical-full-page-map/page.html.hbs index beb68498e..f51d21da7 100644 --- a/templates/vertical-full-page-map/page.html.hbs +++ b/templates/vertical-full-page-map/page.html.hbs @@ -19,64 +19,64 @@ {{> templates/vertical-full-page-map/script/locationbias modifier="main" }} {{> templates/vertical-full-page-map/script/locationbias modifier="mobileMap" }} {{/script/core }} -
-
-
-
-
-
- {{> templates/vertical-full-page-map/markup/searchbar }} - {{> templates/vertical-full-page-map/markup/navigation }} -
-
- {{> templates/vertical-full-page-map/markup/spellcheck }} -
- {{> templates/vertical-full-page-map/markup/verticalresultscount }} - {{> templates/vertical-full-page-map/markup/appliedfilters }} - {{!-- {{> templates/vertical-full-page-map/collapsible-filters/markup/filterlink }} --}} - {{!-- {{> templates/vertical-full-page-map/collapsible-filters/markup/viewresultsbutton }} --}} -
-
- {{> templates/vertical-full-page-map/markup/alternativeresults }} +
+
+
+
+
+
+ {{> templates/vertical-full-page-map/markup/searchbar }} + {{> templates/vertical-full-page-map/markup/navigation }}
- - {{!--
--}} - {{!-- {{> templates/vertical-full-page-map/markup/sortoptions }} --}} - {{!-- {{> templates/vertical-full-page-map/markup/facets }} --}} - {{!-- {{> templates/vertical-full-page-map/markup/filterbox }} --}} - {{!--
--}} -
-
-
-
- {{> templates/vertical-full-page-map/markup/verticalresults }} - {{> templates/vertical-full-page-map/markup/pagination }} - {{!-- {{> templates/vertical-full-page-map/markup/qasubmission }} --}} -
-
-
-
-
- {{> templates/vertical-full-page-map/markup/searchthisareabutton }} + {{> templates/vertical-full-page-map/markup/spellcheck }} +
+ {{> templates/vertical-full-page-map/markup/verticalresultscount }} + {{> templates/vertical-full-page-map/markup/appliedfilters }} + {{!-- {{> templates/vertical-full-page-map/collapsible-filters/markup/filterlink }} --}} + {{!-- {{> templates/vertical-full-page-map/collapsible-filters/markup/viewresultsbutton }} --}}
-
- {{> templates/vertical-full-page-map/markup/searchthisareatoggle modifier="desktop"}} - {{> templates/vertical-full-page-map/markup/locationbias modifier="main"}} +
+ {{> templates/vertical-full-page-map/markup/alternativeresults }}
-
- {{> templates/vertical-full-page-map/markup/map }} -
- {{> templates/vertical-full-page-map/markup/searchthisareatoggle modifier="mobileMap"}} - {{> templates/vertical-full-page-map/markup/locationbias modifier="mobileMap"}} + + {{!--
--}} + {{!-- {{> templates/vertical-full-page-map/markup/sortoptions }} --}} + {{!-- {{> templates/vertical-full-page-map/markup/facets }} --}} + {{!-- {{> templates/vertical-full-page-map/markup/filterbox }} --}} + {{!--
--}} +
+
+
+
+ {{> templates/vertical-full-page-map/markup/verticalresults }} + {{> templates/vertical-full-page-map/markup/pagination }} + {{!-- {{> templates/vertical-full-page-map/markup/qasubmission }} --}} +
+
- {{> templates/vertical-full-page-map/markup/mobilelisttoggles }} +
+ {{> templates/vertical-full-page-map/markup/searchthisareabutton }} +
+
+ {{> templates/vertical-full-page-map/markup/searchthisareatoggle modifier="desktop"}} + {{> templates/vertical-full-page-map/markup/locationbias modifier="main"}} +
+
+ {{> templates/vertical-full-page-map/markup/map }} +
+ {{> templates/vertical-full-page-map/markup/searchthisareatoggle modifier="mobileMap"}} + {{> templates/vertical-full-page-map/markup/locationbias modifier="mobileMap"}} +
+
+ {{> templates/vertical-full-page-map/markup/mobilelisttoggles }}
- +
+ {{/layouts/html }} From 520888a7a64bfd5e935d1a8a51b9bbd3cfb2124d Mon Sep 17 00:00:00 2001 From: Connor Anderson Date: Fri, 21 May 2021 12:01:12 -0400 Subject: [PATCH 05/13] tweak on error behavior --- script/core.hbs | 4 +++- static/js/page-specific-scripts-loaded.js | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/script/core.hbs b/script/core.hbs index d3b6eb2a1..b506f5aa8 100644 --- a/script/core.hbs +++ b/script/core.hbs @@ -11,7 +11,9 @@ const waitBeforeInitPromises = [ new Promise(HitchhikerJS.pageSpecificScriptsLoaded) ]; - Promise.all(waitBeforeInitPromises).then(() => { + Promise.all(waitBeforeInitPromises).catch(error => { + console.error(error); + }).finally(() => { initAnswers(); }) } diff --git a/static/js/page-specific-scripts-loaded.js b/static/js/page-specific-scripts-loaded.js index 180f51779..5f5748cf2 100644 --- a/static/js/page-specific-scripts-loaded.js +++ b/static/js/page-specific-scripts-loaded.js @@ -1,12 +1,16 @@ /** * A promise executor function which calls resolve once all page-specific scripts are loaded * - * @param {Function} resolve + * @param {Function} resolve + * @param {Function} reject */ -export default function (resolve) { +export default function (resolve, reject) { const locatorBundleScript = document.querySelector('script#js-answersLocatorBundleScript'); if (locatorBundleScript) { locatorBundleScript.onload = resolve; + locatorBundleScript.onerror = () => { + reject('Failed to load locator-bundle.js'); + }; } else { resolve(); } From 4752433723cc57a21b82fa40debca3c10356ddac Mon Sep 17 00:00:00 2001 From: Connor Anderson Date: Fri, 21 May 2021 15:23:08 -0400 Subject: [PATCH 06/13] oshi feedback use domcontentloaded --- layouts/html.hbs | 1 + script/core.hbs | 14 +++----------- script/partials/page-specific-scripts.hbs | 3 --- script/partials/sdk-js-script-tags.hbs | 2 -- static/entry.js | 5 +---- static/js/page-specific-scripts-loaded.js | 17 ----------------- tests/script/partials/sdk-js-script-tags.js | 9 +-------- 7 files changed, 6 insertions(+), 45 deletions(-) delete mode 100644 script/partials/page-specific-scripts.hbs delete mode 100644 static/js/page-specific-scripts-loaded.js diff --git a/layouts/html.hbs b/layouts/html.hbs index d41854428..2563ebd2c 100644 --- a/layouts/html.hbs +++ b/layouts/html.hbs @@ -80,6 +80,7 @@ diff --git a/script/core.hbs b/script/core.hbs index b506f5aa8..8cf20a891 100644 --- a/script/core.hbs +++ b/script/core.hbs @@ -7,16 +7,6 @@ +{{/ifeq}} \ No newline at end of file diff --git a/script/partials/page-specific-scripts.hbs b/script/partials/page-specific-scripts.hbs deleted file mode 100644 index cb56fb866..000000000 --- a/script/partials/page-specific-scripts.hbs +++ /dev/null @@ -1,3 +0,0 @@ -{{#ifeq pageTemplate 'vertical-full-page-map'}} - -{{/ifeq}} \ No newline at end of file diff --git a/script/partials/sdk-js-script-tags.hbs b/script/partials/sdk-js-script-tags.hbs index 935465dd6..3f916e6cd 100644 --- a/script/partials/sdk-js-script-tags.hbs +++ b/script/partials/sdk-js-script-tags.hbs @@ -6,11 +6,9 @@ \ No newline at end of file diff --git a/static/entry.js b/static/entry.js index f420b475d..f571d728e 100644 --- a/static/entry.js +++ b/static/entry.js @@ -32,7 +32,4 @@ import StorageKeys from './js/constants/storage-keys'; export { StorageKeys }; import transformFacets from './js/transform-facets'; -export { transformFacets } - -import pageSpecificScriptsLoaded from './js/page-specific-scripts-loaded.js' -export { pageSpecificScriptsLoaded }; \ No newline at end of file +export { transformFacets } \ No newline at end of file diff --git a/static/js/page-specific-scripts-loaded.js b/static/js/page-specific-scripts-loaded.js deleted file mode 100644 index 5f5748cf2..000000000 --- a/static/js/page-specific-scripts-loaded.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - * A promise executor function which calls resolve once all page-specific scripts are loaded - * - * @param {Function} resolve - * @param {Function} reject - */ -export default function (resolve, reject) { - const locatorBundleScript = document.querySelector('script#js-answersLocatorBundleScript'); - if (locatorBundleScript) { - locatorBundleScript.onload = resolve; - locatorBundleScript.onerror = () => { - reject('Failed to load locator-bundle.js'); - }; - } else { - resolve(); - } -}; \ No newline at end of file diff --git a/tests/script/partials/sdk-js-script-tags.js b/tests/script/partials/sdk-js-script-tags.js index 83ad65cbf..b9c003fba 100644 --- a/tests/script/partials/sdk-js-script-tags.js +++ b/tests/script/partials/sdk-js-script-tags.js @@ -1,26 +1,21 @@ const hbs = require('../../test-utils/hbs'); - const defaultOutput = ` `; const jaOutput = ` `; @@ -28,7 +23,6 @@ it('creates correct tags when no locale specified', () => { const partialUsage = '{{> script/partials/sdk-js-script-tags sdkVersion=1.8}}' expect(hbs.compile(partialUsage)()).toEqual(defaultOutput); }); - it('creates correct tags for en', () => { const partialUsage = `{{> script/partials/sdk-js-script-tags sdkVersion=1.8 @@ -36,11 +30,10 @@ it('creates correct tags for en', () => { }}` expect(hbs.compile(partialUsage)()).toEqual(defaultOutput); }); - it('creates correct tags for ja', () => { const partialUsage = `{{> script/partials/sdk-js-script-tags sdkVersion=1.8 locale="ja" }}` expect(hbs.compile(partialUsage)()).toEqual(jaOutput); -}); +}); \ No newline at end of file From 3f9e9803e9b6ea31e54bada86719ec6501a8a6a7 Mon Sep 17 00:00:00 2001 From: Connor Anderson Date: Fri, 21 May 2021 15:29:37 -0400 Subject: [PATCH 07/13] add spaces --- tests/script/partials/sdk-js-script-tags.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/script/partials/sdk-js-script-tags.js b/tests/script/partials/sdk-js-script-tags.js index b9c003fba..dc3edba47 100644 --- a/tests/script/partials/sdk-js-script-tags.js +++ b/tests/script/partials/sdk-js-script-tags.js @@ -23,6 +23,7 @@ it('creates correct tags when no locale specified', () => { const partialUsage = '{{> script/partials/sdk-js-script-tags sdkVersion=1.8}}' expect(hbs.compile(partialUsage)()).toEqual(defaultOutput); }); + it('creates correct tags for en', () => { const partialUsage = `{{> script/partials/sdk-js-script-tags sdkVersion=1.8 @@ -30,10 +31,11 @@ it('creates correct tags for en', () => { }}` expect(hbs.compile(partialUsage)()).toEqual(defaultOutput); }); + it('creates correct tags for ja', () => { const partialUsage = `{{> script/partials/sdk-js-script-tags sdkVersion=1.8 locale="ja" }}` expect(hbs.compile(partialUsage)()).toEqual(jaOutput); -}); \ No newline at end of file +}); From 06996f4ad0b35d928297011bc280be9038832f39 Mon Sep 17 00:00:00 2001 From: Connor Anderson Date: Fri, 21 May 2021 15:30:04 -0400 Subject: [PATCH 08/13] another space --- tests/script/partials/sdk-js-script-tags.js | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/script/partials/sdk-js-script-tags.js b/tests/script/partials/sdk-js-script-tags.js index dc3edba47..3492097fa 100644 --- a/tests/script/partials/sdk-js-script-tags.js +++ b/tests/script/partials/sdk-js-script-tags.js @@ -1,4 +1,5 @@ const hbs = require('../../test-utils/hbs'); + const defaultOutput = ` -{{/ifeq}} \ No newline at end of file +}} \ No newline at end of file diff --git a/templates/vertical-full-page-map/page.html.hbs b/templates/vertical-full-page-map/page.html.hbs index f51d21da7..dedf2fb83 100644 --- a/templates/vertical-full-page-map/page.html.hbs +++ b/templates/vertical-full-page-map/page.html.hbs @@ -19,64 +19,65 @@ {{> templates/vertical-full-page-map/script/locationbias modifier="main" }} {{> templates/vertical-full-page-map/script/locationbias modifier="mobileMap" }} {{/script/core }} -
-
-
-
-
-
- {{> templates/vertical-full-page-map/markup/searchbar }} - {{> templates/vertical-full-page-map/markup/navigation }} + +
+
+
+
+
+
+ {{> templates/vertical-full-page-map/markup/searchbar }} + {{> templates/vertical-full-page-map/markup/navigation }} +
+
+ {{> templates/vertical-full-page-map/markup/spellcheck }} +
+ {{> templates/vertical-full-page-map/markup/verticalresultscount }} + {{> templates/vertical-full-page-map/markup/appliedfilters }} + {{!-- {{> templates/vertical-full-page-map/collapsible-filters/markup/filterlink }} --}} + {{!-- {{> templates/vertical-full-page-map/collapsible-filters/markup/viewresultsbutton }} --}} +
+
+ {{> templates/vertical-full-page-map/markup/alternativeresults }}
- {{> templates/vertical-full-page-map/markup/spellcheck }} -
- {{> templates/vertical-full-page-map/markup/verticalresultscount }} - {{> templates/vertical-full-page-map/markup/appliedfilters }} - {{!-- {{> templates/vertical-full-page-map/collapsible-filters/markup/filterlink }} --}} - {{!-- {{> templates/vertical-full-page-map/collapsible-filters/markup/viewresultsbutton }} --}} -
-
- {{> templates/vertical-full-page-map/markup/alternativeresults }} -
-
- - {{!--
--}} - {{!-- {{> templates/vertical-full-page-map/markup/sortoptions }} --}} - {{!-- {{> templates/vertical-full-page-map/markup/facets }} --}} - {{!-- {{> templates/vertical-full-page-map/markup/filterbox }} --}} - {{!--
--}} -
-
-
-
- {{> templates/vertical-full-page-map/markup/verticalresults }} - {{> templates/vertical-full-page-map/markup/pagination }} - {{!-- {{> templates/vertical-full-page-map/markup/qasubmission }} --}} + + {{!--
--}} + {{!-- {{> templates/vertical-full-page-map/markup/sortoptions }} --}} + {{!-- {{> templates/vertical-full-page-map/markup/facets }} --}} + {{!-- {{> templates/vertical-full-page-map/markup/filterbox }} --}} + {{!--
--}} +
+
+
+
+ {{> templates/vertical-full-page-map/markup/verticalresults }} + {{> templates/vertical-full-page-map/markup/pagination }} + {{!-- {{> templates/vertical-full-page-map/markup/qasubmission }} --}} +
+
+ {{> templates/vertical-full-page-map/markup/searchthisareabutton }} +
+
+ {{> templates/vertical-full-page-map/markup/searchthisareatoggle modifier="desktop"}} + {{> templates/vertical-full-page-map/markup/locationbias modifier="main"}} +
-
- {{> templates/vertical-full-page-map/markup/searchthisareabutton }} -
-
- {{> templates/vertical-full-page-map/markup/searchthisareatoggle modifier="desktop"}} - {{> templates/vertical-full-page-map/markup/locationbias modifier="main"}} -
-
-
- {{> templates/vertical-full-page-map/markup/map }} -
- {{> templates/vertical-full-page-map/markup/searchthisareatoggle modifier="mobileMap"}} - {{> templates/vertical-full-page-map/markup/locationbias modifier="mobileMap"}} +
+ {{> templates/vertical-full-page-map/markup/map }} +
+ {{> templates/vertical-full-page-map/markup/searchthisareatoggle modifier="mobileMap"}} + {{> templates/vertical-full-page-map/markup/locationbias modifier="mobileMap"}} +
+ {{> templates/vertical-full-page-map/markup/mobilelisttoggles }}
- {{> templates/vertical-full-page-map/markup/mobilelisttoggles }}
-
- + {{/layouts/html }} diff --git a/test-site/pages-patches/locations_full_page_map_with_filters.html.hbs.patch b/test-site/pages-patches/locations_full_page_map_with_filters.html.hbs.patch index 466233289..bf9e6d1bd 100644 --- a/test-site/pages-patches/locations_full_page_map_with_filters.html.hbs.patch +++ b/test-site/pages-patches/locations_full_page_map_with_filters.html.hbs.patch @@ -1,5 +1,5 @@ ---- templates/vertical-full-page-map/page.html.hbs 2021-05-19 22:15:49.000000000 -0400 -+++ test-site/pages/locations_full_page_map_with_filters.html.hbs 2021-05-20 11:19:09.000000000 -0400 +--- templates/vertical-full-page-map/page.html.hbs 2021-05-24 11:38:14.000000000 -0400 ++++ test-site/pages/locations_full_page_map_with_filters.html.hbs 2021-05-24 11:41:13.000000000 -0400 @@ -3,7 +3,7 @@ {{> cards/all }} {{> theme-components/theme-map/script}} @@ -18,28 +18,28 @@ {{!-- {{> templates/vertical-full-page-map/script/filterbox }} --}} {{> templates/vertical-full-page-map/script/verticalresults }} {{> templates/vertical-full-page-map/script/pagination }} -@@ -33,19 +33,19 @@ -
- {{> templates/vertical-full-page-map/markup/verticalresultscount }} - {{> templates/vertical-full-page-map/markup/appliedfilters }} -- {{!-- {{> templates/vertical-full-page-map/collapsible-filters/markup/filterlink }} --}} -- {{!-- {{> templates/vertical-full-page-map/collapsible-filters/markup/viewresultsbutton }} --}} -+ {{> templates/vertical-full-page-map/collapsible-filters/markup/filterlink }} -+ {{> templates/vertical-full-page-map/collapsible-filters/markup/viewresultsbutton }} +@@ -34,19 +34,19 @@ +
+ {{> templates/vertical-full-page-map/markup/verticalresultscount }} + {{> templates/vertical-full-page-map/markup/appliedfilters }} +- {{!-- {{> templates/vertical-full-page-map/collapsible-filters/markup/filterlink }} --}} +- {{!-- {{> templates/vertical-full-page-map/collapsible-filters/markup/viewresultsbutton }} --}} ++ {{> templates/vertical-full-page-map/collapsible-filters/markup/filterlink }} ++ {{> templates/vertical-full-page-map/collapsible-filters/markup/viewresultsbutton }} +
+
+ {{> templates/vertical-full-page-map/markup/alternativeresults }} +
-
- {{> templates/vertical-full-page-map/markup/alternativeresults }} -
-
- -- {{!--
--}} -+
- {{!-- {{> templates/vertical-full-page-map/markup/sortoptions }} --}} -- {{!-- {{> templates/vertical-full-page-map/markup/facets }} --}} -+ {{> templates/vertical-full-page-map/markup/facets }} - {{!-- {{> templates/vertical-full-page-map/markup/filterbox }} --}} -- {{!--
--}} -+
-
-
-
+ +- {{!--
--}} ++
+ {{!-- {{> templates/vertical-full-page-map/markup/sortoptions }} --}} +- {{!-- {{> templates/vertical-full-page-map/markup/facets }} --}} ++ {{> templates/vertical-full-page-map/markup/facets }} + {{!-- {{> templates/vertical-full-page-map/markup/filterbox }} --}} +- {{!--
--}} ++
+
+
+
diff --git a/test-site/public/overlay.html b/test-site/public/overlay.html index d7dc1a930..064489ddd 100644 --- a/test-site/public/overlay.html +++ b/test-site/public/overlay.html @@ -22,4 +22,4 @@ { text: "Do you have gift cards?", }, { text: "I want a snack now", }, ] -}; \ No newline at end of file +}; \ No newline at end of file From 2496fa2df9c927b03d9cc7088e5313fd63bcda92 Mon Sep 17 00:00:00 2001 From: Connor Anderson Date: Mon, 24 May 2021 12:50:34 -0400 Subject: [PATCH 10/13] add space below --- script/core.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/core.hbs b/script/core.hbs index 0e13892bd..f8b28dbd6 100644 --- a/script/core.hbs +++ b/script/core.hbs @@ -85,4 +85,4 @@ {{> script/partials/sdk-js-script-tags locale=(findFirst params.sdkLocaleOverride global_config.locale 'en') sdkVersion=global_config.sdkVersion -}} \ No newline at end of file +}} From 430fe5a3b27833a43e9282300bfb9609ba617032 Mon Sep 17 00:00:00 2001 From: Connor Anderson Date: Mon, 24 May 2021 12:51:31 -0400 Subject: [PATCH 11/13] remove pageTemplate param --- templates/vertical-full-page-map/page.html.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/vertical-full-page-map/page.html.hbs b/templates/vertical-full-page-map/page.html.hbs index dedf2fb83..79b0b4e5c 100644 --- a/templates/vertical-full-page-map/page.html.hbs +++ b/templates/vertical-full-page-map/page.html.hbs @@ -1,5 +1,5 @@ {{#> layouts/html pageWrapperCss="YxtPage-wrapper--mobileListView" }} - {{#> script/core pageTemplate="vertical-full-page-map"}} + {{#> script/core }} {{> cards/all }} {{> theme-components/theme-map/script}} {{> theme-components/vertical-full-page-map/script}} From 6cf073c8a3504f35aca30670ebb710e19c255463 Mon Sep 17 00:00:00 2001 From: Connor Anderson Date: Mon, 24 May 2021 12:52:29 -0400 Subject: [PATCH 12/13] undo overlay async change --- test-site/public/overlay.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-site/public/overlay.html b/test-site/public/overlay.html index 064489ddd..d7dc1a930 100644 --- a/test-site/public/overlay.html +++ b/test-site/public/overlay.html @@ -22,4 +22,4 @@ { text: "Do you have gift cards?", }, { text: "I want a snack now", }, ] -}; \ No newline at end of file +}; \ No newline at end of file From 9698a802f9b00c912b4bbbe162ca9dc0c43a3680 Mon Sep 17 00:00:00 2001 From: Connor Anderson Date: Mon, 24 May 2021 15:01:07 -0400 Subject: [PATCH 13/13] move partials back to page-setup --- templates/vertical-full-page-map/page-setup.js | 3 +++ templates/vertical-full-page-map/page.html.hbs | 2 -- ...tions_full_page_map_with_filters.html.hbs.patch | 14 +++++++------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/templates/vertical-full-page-map/page-setup.js b/templates/vertical-full-page-map/page-setup.js index 14ef945d4..48540c3b8 100644 --- a/templates/vertical-full-page-map/page-setup.js +++ b/templates/vertical-full-page-map/page-setup.js @@ -1,3 +1,6 @@ +{{> theme-components/theme-map/script}} +{{> theme-components/vertical-full-page-map/script}} + /** * Registers listeners on the card * diff --git a/templates/vertical-full-page-map/page.html.hbs b/templates/vertical-full-page-map/page.html.hbs index 79b0b4e5c..ea861d123 100644 --- a/templates/vertical-full-page-map/page.html.hbs +++ b/templates/vertical-full-page-map/page.html.hbs @@ -1,8 +1,6 @@ {{#> layouts/html pageWrapperCss="YxtPage-wrapper--mobileListView" }} {{#> script/core }} {{> cards/all }} - {{> theme-components/theme-map/script}} - {{> theme-components/vertical-full-page-map/script}} {{!-- {{> templates/vertical-full-page-map/collapsible-filters/page-setup }} --}} {{> templates/vertical-full-page-map/page-setup }} {{> templates/vertical-full-page-map/script/searchbar }} diff --git a/test-site/pages-patches/locations_full_page_map_with_filters.html.hbs.patch b/test-site/pages-patches/locations_full_page_map_with_filters.html.hbs.patch index bf9e6d1bd..fca029815 100644 --- a/test-site/pages-patches/locations_full_page_map_with_filters.html.hbs.patch +++ b/test-site/pages-patches/locations_full_page_map_with_filters.html.hbs.patch @@ -1,15 +1,15 @@ ---- templates/vertical-full-page-map/page.html.hbs 2021-05-24 11:38:14.000000000 -0400 -+++ test-site/pages/locations_full_page_map_with_filters.html.hbs 2021-05-24 11:41:13.000000000 -0400 -@@ -3,7 +3,7 @@ +--- templates/vertical-full-page-map/page.html.hbs 2021-05-24 14:53:55.000000000 -0400 ++++ test-site/pages/locations_full_page_map_with_filters.html.hbs 2021-05-24 14:58:17.000000000 -0400 +@@ -1,7 +1,7 @@ + {{#> layouts/html pageWrapperCss="YxtPage-wrapper--mobileListView" }} + {{#> script/core }} {{> cards/all }} - {{> theme-components/theme-map/script}} - {{> theme-components/vertical-full-page-map/script}} - {{!-- {{> templates/vertical-full-page-map/collapsible-filters/page-setup }} --}} + {{> templates/vertical-full-page-map/collapsible-filters/page-setup }} {{> templates/vertical-full-page-map/page-setup }} {{> templates/vertical-full-page-map/script/searchbar }} {{> templates/vertical-full-page-map/script/spellcheck }} -@@ -11,7 +11,7 @@ +@@ -9,7 +9,7 @@ {{> templates/vertical-full-page-map/script/verticalresultscount }} {{> templates/vertical-full-page-map/script/appliedfilters }} {{!-- {{> templates/vertical-full-page-map/script/sortoptions }} --}} @@ -18,7 +18,7 @@ {{!-- {{> templates/vertical-full-page-map/script/filterbox }} --}} {{> templates/vertical-full-page-map/script/verticalresults }} {{> templates/vertical-full-page-map/script/pagination }} -@@ -34,19 +34,19 @@ +@@ -32,19 +32,19 @@
{{> templates/vertical-full-page-map/markup/verticalresultscount }} {{> templates/vertical-full-page-map/markup/appliedfilters }}