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2E,KAAK,SAAU,IAAI5E,EAAgBC,IACzCG,EAAEH,GAAI2E,KAAK,UAAUvB,MACvB,GAAE,G","sources":["webpack://disp0001/./src/widgets/park-summary-tabs/park-summary-tabs.js"],"sourcesContent":["Promise.all([\r\n  import(/* webpackMode: \"eager\" */ './park-summary-tabs.scss'),\r\n  import('../tab-park-info/tab-park-info'),\r\n  import('../tab-see-and-do/tab-see-and-do'),\r\n  import('../reviews/reviews'),\r\n  import('../groups-functions/groups-functions'),\r\n  import('../tab-current-deals/tab-current-deals'),\r\n]).then(() => {\r\n  $('.widget.park-summary-tabs').each(function (i, el) {\r\n    $(el).data('widget', new ParkSummaryTabs(el))\r\n    $(el).data('widget').init()\r\n  })\r\n})\r\n\r\nfunction ParkSummaryTabs(el) {\r\n  const self = this\r\n  self.el = $(el)\r\n\r\n  self.tabsToLoad = 3\r\n  self.tabsLoaded = 0\r\n\r\n  self.lastActiveTabName = ''\r\n\r\n  self.updateUrlWithTab = function (name, title) {\r\n    // Update the page title\r\n    document.title = title\r\n\r\n    // Append the tab name to the URL path\r\n    //\r\n    // '0/     1      /   2   /   3    /   4  /  5  '\r\n    // '/caravan-parks/{state}/{region}/{slug}/{tab}'\r\n    let segments = window.location.pathname.split('/')\r\n    segments[5] = name // Adds tab name in 5th position of path segments\r\n\r\n    const pathname = segments.join('/')\r\n\r\n    let params = new URLSearchParams(window.location.search)\r\n    params.delete('tab')\r\n\r\n    const url = window.location.origin + pathname + '?' + params.toString()\r\n\r\n    history.pushState(null, title, url)\r\n  }\r\n\r\n  self.setAllTabsNotActive = function () {\r\n    self.el.find('.tab-container .tab').removeClass('active')\r\n    self.el.find('.accordion-heading').removeClass('active')\r\n    self.el.find('.tab-content').removeClass('active')\r\n  }\r\n\r\n  self.setTabActive = function (name) {\r\n    self.setAllTabsNotActive()\r\n    // If name empty or 'features' (which should only show on mobile), then show the first tab as active\r\n    if (name === '' || name === 'features') {\r\n      const firstTab = self.el.find(`.tab-container .tab[data-tab]`).first()\r\n      name = firstTab.attr('data-tab')\r\n    }\r\n\r\n    ////Sets the active tab if a tab name is included in the base url.\r\n    //let tabs = self.el.find(`.tab-container .tab[data-tab]`)\r\n    //$(tabs).each(function (tab) {\r\n    //  let current_tab = $(tabs[tab])\r\n\r\n    //  var path = window.location.pathname;\r\n    //  let current_tab_name = current_tab.attr('data-tab');\r\n    //  if (path.match('/' + current_tab_name)) {\r\n    //    name = current_tab_name;\r\n    //  }\r\n    //})\r\n\r\n    self.el.find(`.tab-container .tab[data-tab=\"${name}\"]`).addClass('active')\r\n    self.el.find(`.accordion-heading[data-tab=\"${name}\"]`).addClass('active')\r\n    self.el.find(`.tab-content[data-tab='${name}']`).addClass('active')\r\n  }\r\n\r\n  self.removeTab = function (name)\r\n  {\r\n    self.el.find(`.tab-container .tab[data-tab=\"${name}\"]`).css('display', 'none');\r\n    self.el.find(`.accordion-heading[data-tab=\"${name}\"]`)\r\n      .removeClass('active')\r\n      .addClass('inactive')\r\n      .css('display','none');\r\n\r\n    self.el.find(`.tab-content[data-tab='${name}']`)\r\n      .removeClass('active')\r\n      .addClass('inactive');\r\n  }\r\n\r\n  self.reloadTab = function (name) {\r\n    self.el.find(`.tab-container .tab[data-tab=\"${name}\"]`).css('display', 'block');\r\n      // self.el.find(`.accordion-heading[data-tab=\"${name}\"]`)\r\n      // .addClass('active');\r\n\r\n    self.el.find(`.tab-content[data-tab='${name}']`)\r\n      .addClass('active');\r\n\r\n  }\r\n\r\n\r\n  const displayAsTabs = function () {\r\n    self.setTabActive(self.lastActiveTabName)\r\n  }\r\n\r\n  self.initTabs = function () {\r\n    self.setAllTabsNotActive()\r\n    let shouldLoadFirstTab = false\r\n    let tabs = self.el.find(`.tab-container .tab[data-tab]`)\r\n\r\n    //check if there is a selected tab base from url segments\r\n    let lastUrlSegment = window.location.pathname.split(\"/\").pop()\r\n    if ($(\".tab-container .tab[data-tab='\" + lastUrlSegment + \"']\").length)\r\n    {\r\n      self.setTabActive(lastUrlSegment) // Ensures tab or accordion is expanded on page load\r\n      shouldLoadFirstTab = false\r\n      return false // exit loop\r\n    }\r\n\r\n\r\n    $(tabs).each(function (tab) {\r\n      let $tab = $(tabs[tab])            \r\n      if ($tab.hasClass('active')) {\r\n        self.lastActiveTabName = $tab.attr('data-tab')\r\n\r\n        self.setTabActive(self.lastActiveTabName) // Ensures tab or accordion is expanded on page load\r\n        shouldLoadFirstTab = false\r\n        return false // exit loop\r\n      }\r\n\r\n      shouldLoadFirstTab = true\r\n    })\r\n\r\n    const shouldDisplayAsTabs = window.matchMedia('(min-width: 1600px)')\r\n\r\n    if (shouldLoadFirstTab && shouldDisplayAsTabs.matches) {\r\n      const $firstTab = $(tabs[0])\r\n      const firstTabName = $firstTab.attr('data-tab')\r\n      self.setTabActive(firstTabName)\r\n    }\r\n    \r\n    shouldDisplayAsTabs.addEventListener('change', function (media) {\r\n      if (media.matches) {\r\n        displayAsTabs()\r\n      }\r\n    })\r\n  }\r\n\r\n  self.init = function () {\r\n    if (process.env.NODE_ENV === 'development') {\r\n      console.log('ParkSummaryTabs init', self)\r\n    }\r\n\r\n    // When tab is clicked\r\n    self.el.find('.tab-container .tab').click(function (event) {\r\n      event.preventDefault()\r\n\r\n      const $tab = $(this)\r\n      const name = $tab.attr('data-tab')\r\n      const pageTitle = $tab.attr('data-title')\r\n\r\n      self.setTabActive(name)\r\n\r\n      self.lastActiveTabName = name\r\n\r\n      self.updateUrlWithTab(name, pageTitle)\r\n    })\r\n\r\n    // When accordion heading is clicked\r\n    self.el.find('.accordion-heading').click(function (event) {\r\n      event.preventDefault()\r\n\r\n      const $accordionHeading = $(this)\r\n      const name = $accordionHeading.attr('data-tab')\r\n      const pageTitle = $accordionHeading.attr('data-title')\r\n\r\n      // toggle open/closed the accordion\r\n      $accordionHeading.toggleClass('active')\r\n      $accordionHeading.parents('.park-summary-tabs').find(`.tab-content[data-tab='${name}']`).toggleClass('active')\r\n\r\n      if ($accordionHeading.hasClass('active')) {\r\n        self.lastActiveTabName = name\r\n      } else {\r\n        self.lastActiveTabName = ''\r\n      }\r\n\r\n      self.updateUrlWithTab(name, pageTitle)\r\n\r\n      if (self.el.find('.tab-content .features').length) {\r\n        let widest = 0\r\n\r\n        self.el.find('.feature').each(function (i, el) {\r\n          const thisWidth = $(this).outerWidth()\r\n          if (thisWidth > widest) {\r\n            widest = thisWidth\r\n          }\r\n\r\n          if ($(window).width() > 1024) {\r\n            $(el).find('.icon').popup({\r\n              on: 'hover',\r\n              position: 'top left',\r\n            })\r\n          }\r\n        })\r\n        if (widest !== 0) self.el.find('.feature').css('width', widest)\r\n      }\r\n    })\r\n    \r\n    window.dbs.globalEvents.subscribe('remove_tab', function (name) {\r\n      self.removeTab(name)\r\n    })\r\n\r\n    window.dbs.globalEvents.subscribe('reload_tab', function (name) {\r\n      self.reloadTab(name);\r\n    })\r\n\r\n\r\n    // Keep track of how many tabs we need loaded before we show this widget on the page.\r\n    // This allows us to avoid displaying tabs with empty content, because the content is being\r\n    // requested by an endpoint or other dynamic source.\r\n    window.dbs.globalEvents.subscribe('tab_loaded', function () {\r\n      self.tabsLoaded++\r\n      if (self.tabsLoaded >= self.tabsToLoad) {\r\n        self.initTabs()\r\n      }\r\n      self.el.css('opacity', 1)\r\n    })\r\n\r\n    // emit 'was_tab_loaded' is used to double-check if any tabs were loaded before this script was init.\r\n    // In which case, would mean we did not count that loaded tab as loaded, and this would then fail to\r\n    // init the tabs via the subscribe 'tab_loaded' event, causing this widget to now show on the page.\r\n    window.dbs.globalEvents.emit('was_tab_loaded', null, true)\r\n  }\r\n}\r\n"],"names":["ParkSummaryTabs","el","self","this","$","tabsToLoad","tabsLoaded","lastActiveTabName","updateUrlWithTab","name","title","document","segments","window","location","pathname","split","join","params","URLSearchParams","search","delete","url","origin","toString","history","pushState","setAllTabsNotActive","find","removeClass","setTabActive","first","attr","addClass","removeTab","css","reloadTab","initTabs","shouldLoadFirstTab","tabs","lastUrlSegment","pop","length","each","tab","$tab","hasClass","shouldDisplayAsTabs","matchMedia","matches","firstTabName","addEventListener","media","init","click","event","preventDefault","pageTitle","$accordionHeading","toggleClass","parents","widest","i","thisWidth","outerWidth","width","popup","on","position","dbs","globalEvents","subscribe","emit","Promise","all","then","data"],"sourceRoot":""}