{ "version": 3, "sources": [ "../../../../../../Coria/src/Foundation/JavascriptCommon/code/scripts/common/urlUtils.js", "QTCLocationSearch/main.js" ], "names": [], "mappings": "AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,AC1KA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA", "file": "QTCLocationSearch.js", "sourcesContent": [ "define('common/urlUtils',[\r\n],\r\n function () {\r\n\r\n // Takes the url and parses the query string parameters out of it.\r\n // Returns the parameters and their string values as object { paramName1: value1, paramName2: value2, ...},\r\n // or an empty object in case there are no parameters in url.\r\n function parseQueryParamsFromUrl(url) {\r\n url = url ? url : window.location.search; // default url parameter if not set\r\n // take just the query search part of url (lose the leading question mark)\r\n var query = decomposeUrl(url).search;\r\n if (query.indexOf(\"?\") >= 0) query = query.substring(query.indexOf(\"?\") + 1);\r\n var urlParams = {},\r\n match,\r\n search = /([^&=]+)=?([^&]*)/g,\r\n decode = function (s) { return decodeURI(decodeURIComponent(s)); };\r\n\r\n while (match = search.exec(query))\r\n urlParams[decode(match[1])] = decode(match[2]);\r\n\r\n return urlParams;\r\n }\r\n\r\n // Takes the url, decomposes it into three components: path, search, hash,\r\n // and returns those three components in an object.\r\n // When searching for hash string which is directly after path (without search parameters) we're ignoring '#/'.\r\n // That is not a hash, that is Angular routing and it's actually part of the path.\r\n function decomposeUrl(url) {\r\n var path = '';\r\n var search = '';\r\n var hash = '';\r\n if (url.indexOf('?') >= 0) {\r\n // there is search string already in the url\r\n path = url.substring(0, url.indexOf('?'));\r\n search = url.substring(url.indexOf('?'));\r\n if (search.indexOf('#') >= 0) {\r\n // there is also a hash string in the url\r\n hash = search.substring(search.indexOf('#'));\r\n search = search.substring(0, search.indexOf('#'));\r\n }\r\n } else if (url.indexOf('#') >= 0 && url.indexOf('#') != url.indexOf('#/')) {\r\n // no search string, but there is hash string\r\n path = url.substring(0, url.indexOf('#'));\r\n hash = url.substring(url.indexOf('#'));\r\n } else {\r\n // no search string, no hash string\r\n path = url ? url : '';\r\n }\r\n return {\r\n path: path, // path also includes the protocol and hostname (if they existed in the given url)\r\n search: search,\r\n hash: hash\r\n }\r\n }\r\n\r\n // Adds a new query string parameter into the given url.\r\n // Returns the newly constructed url.\r\n function putParamIntoUrl(paramName, paramValue, url) {\r\n // first we'll split the url into 3 components\r\n var urlComp = decomposeUrl(url);\r\n // add the new query string parameter into search string\r\n urlComp.search = (urlComp.search ? urlComp.search + '&' : '?') + paramName + '=' + encodeURIComponent(paramValue);\r\n // return the new url\r\n return urlComp.path + urlComp.search + urlComp.hash;\r\n }\r\n\r\n // Reads the specified query string parameter from a given url.\r\n // Returns the value of that parameter (a string value). \r\n function getParamFromUrl(paramName, url) {\r\n return parseQueryParamsFromUrl(url)[paramName];\r\n }\r\n\r\n // Modifies the given DOM element's href property, or the current page's URL (if\r\n // no domElement has been given) by adding new query string parameter with the\r\n // given value. \r\n function pushParamIntoLink(paramName, paramValue, domElement) {\r\n var url;\r\n if (domElement) url = $(domElement).attr('href'); // url from DOM element\r\n else url = window.location.href; // current page url\r\n\r\n var params = parseQueryParamsFromUrl(url);\r\n\r\n // making sure that we find the parameter no matter how it's written (case insensitive)\r\n for (var p in params) {\r\n if (p.toLowerCase() === paramName.toLowerCase()) {\r\n paramName = p;\r\n break;\r\n }\r\n }\r\n\r\n params[paramName] = paramValue; // update (or add) the parameter\r\n var newSearchString = $.param(params); // and construct a new search string.\r\n\r\n var urlComp = decomposeUrl(url);\r\n if (domElement) {\r\n // set new href property on DOM element\r\n var newHref = urlComp.path + (newSearchString ? ('?' + newSearchString) : '') + urlComp.hash;\r\n $(domElement).attr('href', newHref);\r\n } else {\r\n if (history && history.pushState) { // because some older browsers (IE 9 or older) don't support this\r\n // for other pages put new URL to browser's address bar using window.history\r\n history.replaceState(\r\n null,\r\n null,\r\n urlComp.path +\r\n (newSearchString ? ('?' + newSearchString) : '') +\r\n urlComp.hash\r\n );\r\n }\r\n }\r\n }\r\n\r\n // Reads the query string parameter from the domElement's href property, or from\r\n // the current page's URL (if no domElement has been given). Removes the parameter\r\n // from the URL and puts new URL into the domElement's href property, or into the\r\n // browser's address bar.\r\n // Returns the value of that parameter (a string value).\r\n function popParamFromLink(paramName, domElement) {\r\n var url;\r\n if (domElement) url = $(domElement).attr('href'); // url from DOM element\r\n else url = window.location.href; // current page url\r\n\r\n var params = parseQueryParamsFromUrl(url);\r\n var retVal;\r\n\r\n // making sure that we find the parameter no matter how it's written (case insensitive)\r\n for (var p in params) {\r\n if (p.toLowerCase() === paramName.toLowerCase()) {\r\n paramName = p;\r\n break;\r\n }\r\n }\r\n\r\n if (params[paramName]) {\r\n // the requested parameter exists in the url\r\n retVal = params[paramName]; // Its value will be returned from the function.\r\n delete params[paramName]; // Remove the parameter from the array,\r\n var newSearchString = $.param(params); // and construct a new search string.\r\n var urlComp = decomposeUrl(url);\r\n if (domElement) {\r\n // set new href property on DOM element\r\n var newHref = urlComp.path + (newSearchString ? ('?' + newSearchString) : '') + urlComp.hash;\r\n $(domElement).attr('href', newHref);\r\n } else {\r\n if (history && history.pushState) { // because some older browsers (IE 9 or older) don't support this\r\n // for other pages put new URL to browser's address bar using window.history\r\n history.replaceState(\r\n null,\r\n null,\r\n urlComp.path +\r\n (newSearchString ? ('?' + newSearchString) : '') +\r\n urlComp.hash\r\n );\r\n }\r\n }\r\n }\r\n return retVal;\r\n }\r\n\r\n\r\n return {\r\n parseQueryParamsFromUrl: parseQueryParamsFromUrl,\r\n decomposeUrl: decomposeUrl,\r\n putParamIntoUrl: putParamIntoUrl,\r\n getParamFromUrl: getParamFromUrl,\r\n pushParamIntoLink: pushParamIntoLink,\r\n popParamFromLink: popParamFromLink\r\n }\r\n });\r\n\n", "require([\"common/urlUtils\"],\r\n function (urlUtils) {\r\n const selectedTagSelector = \"#hdnTag\";\r\n const selectedStatusSelector = \"#hdnStatus\";\r\n const mapSelector = \"map\";\r\n const searchResultsSelector = \".search-results-wrapper\";\r\n const loadMoreItemsNumberAttr = \"loadMoreItemsNumber\";\r\n const hdnCoordinateSelector = \"#hdnCoordinate\";\r\n const radiusDropdownSelector = \"#radiusDropdown\";\r\n const radiusDivSelector = \"#radiusDiv\";\r\n const tagsDropdownSelector = \"#ddlTags\";\r\n const statusDropdownSelector = \"#ddlStatus\";\r\n const tagFilterSelector = \"#tagFilter\";\r\n const statusFilterSelector = \"#statusFilter\";\r\n const locationSearchResultsDivSelector = \"#locationSearchResults\";\r\n const viewAllButtonSelector = \"#btnViewAllResults\";\r\n const shareResultsSelector = \"#btnShareResults\";\r\n const locationDropdownSelector = \".mapboxgl-ctrl-geocoder--input\";\r\n const inputValidationErrorClass = \"input-validation-error\";\r\n const animationDuration = 1500;\r\n var address;\r\n var searchKeyword;\r\n var city;\r\n var postalCode;\r\n var state;\r\n var placeType;\r\n //const minMarkersNumberInView = 6;\r\n const disabledLinkClassName = \"disabled\";\r\n var visitWebsiteLinkInPopup;\r\n var initialZoom = true;\r\n var initZoom = 3.5;\r\n var lastSearch = null;\r\n var clickedSearch = false;\r\n var selectedTags = [];\r\n var mapLoaded = false;\r\n var mobileWidth = 767;\r\n var beforeInit = false;\r\n var hasSelectedLocation = false;\r\n var filteredResults = [];\r\n\r\n $(document).ready(function () {\r\n $(\".map-buttons-wrapper\").addClass(\"empty\");\r\n showCustomSelect();\r\n if (useValidationMessage.toLowerCase() == \"false\")\r\n $(\"#btnLocationSearch\").prop('disabled', true);\r\n $('#geocoder').find('input').on('keyup', function () {\r\n if ($(this).val() != null && $(this).val() != '') {\r\n $(\"#btnLocationSearch\").prop('disabled', false);\r\n } else {\r\n if (useValidationMessage.toLowerCase() == \"false\")\r\n $(\"#btnLocationSearch\").prop('disabled', true);\r\n }\r\n });\r\n\r\n $(\"#btnLocationSearch\").off('click').on('click', function () {\r\n clickedSearch = true;\r\n displayResults();\r\n $(\".map-buttons-wrapper\").removeClass(\"empty\");\r\n });\r\n\r\n $(\"[id^=ddlTags]\").on('change', function () {\r\n var hdnElement = $(this).closest(\"div\").find(\"[id^=hdnTag]\"); \r\n debugger;\r\n $(hdnElement).val(this.value);\r\n });\r\n\r\n $('#ddlStatus').on('change', function () {\r\n $(selectedStatusSelector).val(this.value);\r\n });\r\n\r\n $(\"#btnShareResults\").off('click').on('click', function () {\r\n shareResults();\r\n });\r\n\r\n $(\"#btnViewAllResults\").off('click').on('click', function () {\r\n viewAllResults();\r\n });\r\n\r\n $(\"#geocoder\").find(\"input\").attr(\"placeholder\", $(\"#\" + mapSelector).data(\"addressSearchText\"));\r\n\r\n if (hasLoadMoreInit.toLowerCase() == \"true\")\r\n displayedResultsCount = parseInt($(\"#\" + mapSelector).data(loadMoreItemsNumberAttr));\r\n else\r\n displayedResultsCount = locations.length;\r\n\r\n setUIFromQueryParams();\r\n lastSearch = getSearchParameters();\r\n //Hide map for mobile by default and show for desktop\r\n if (showHideButton.toLowerCase() == \"true\") {\r\n if ($(window).width() <= mobileWidth) {\r\n $('#hideMapCheckbox').prop('checked', true);\r\n onHideMap();\r\n }\r\n }\r\n else {\r\n if ($(window).width() <= mobileWidth) onShowMap();\r\n }\r\n\r\n $('#hideMapCheckbox').change(function () {\r\n if (this.checked) {\r\n onHideMap();\r\n } else {\r\n onShowMap();\r\n }\r\n });\r\n\r\n var jumpTo = window.location.hash;\r\n if (jumpTo) {\r\n var topOfElement = document.querySelector(jumpTo).offsetTop;\r\n window.scroll({ top: topOfElement, behavior: \"smooth\" });\r\n }\r\n });\r\n\r\n function onHideMap() {\r\n $('#map').removeClass('shown');\r\n $('#map').addClass('hidden');\r\n $('.show-on-map').hide();\r\n $('.result-td').removeClass('flex-50');\r\n }\r\n\r\n function onShowMap() {\r\n $('#map').removeClass('hidden');\r\n $('#map').addClass('shown');\r\n map.resize();\r\n $('.show-on-map').show();\r\n $('.result-td').addClass('flex-50');\r\n }\r\n\r\n printSearchResults = function () {\r\n var allElements = $('body *').not('.search-results-wrapper');\r\n allElements.addClass(\"d-print-none\");\r\n $('.search-results-wrapper').addClass(\"d-print-grid\");\r\n $('.search-results-wrapper').find(\"*\").removeClass(\"d-print-none\").addClass(\"d-print-grid\");\r\n $('.search-results-wrapper').parents().removeClass(\"d-print-none\").addClass(\"d-print-grid\");\r\n window.print();\r\n }\r\n\r\n function viewAllResults() {\r\n var url = window.location.pathname;\r\n var queryParams = urlUtils.parseQueryParamsFromUrl();\r\n history.replaceState(\"\", document.title, url);\r\n if (queryParams && queryParams.tags)\r\n urlUtils.pushParamIntoLink(\"tags\", queryParams.tags);\r\n if (queryParams && queryParams.status)\r\n urlUtils.pushParamIntoLink(\"status\", queryParams.status);\r\n if (queryParams && queryParams.pediatric)\r\n urlUtils.pushParamIntoLink(\"pediatric\", \"1\");\r\n url = window.location.pathname + window.location.search;\r\n history.replaceState(\"\", document.title, url);\r\n refreshMarkers(locations.length);\r\n $(\"[id^=search_result_]\").css(\"display\", \"\");\r\n $(viewAllButtonSelector).hide();\r\n $(locationDropdownSelector).val(\"\");\r\n setStatusOnItemsBasedOnStatusFilter();\r\n addMapClusters(locations);\r\n var bounds = getBoundsFromResults(locations, locations.length);\r\n map.flyTo({ center: [-74.5, 40], zoom: initialZoom });\r\n map.fitBounds(bounds, { padding: 50 });\r\n }\r\n\r\n function shareResults() {\r\n var mapId = \"#\" + mapSelector;\r\n var subject = $(mapId).data(\"shareResultsEmailSubject\");\r\n var body = $(mapId).data(\"shareResultsEmailBody\");\r\n body = body.replace(\"{resultsUrl}\", window.location.href);\r\n body = encodeURIComponent(body);\r\n window.location = \"mailto:?subject=\" + subject + \"&body=\" + body;\r\n }\r\n\r\n function setUIFromQueryParams() {\r\n var queryParams = urlUtils.parseQueryParamsFromUrl();\r\n var minimumMarkersToShow = locations.length;\r\n if (queryParams) {\r\n var hasCoordinateParameter = false;\r\n if (!$.isEmptyObject(queryParams)) {\r\n if (queryParams.coordinate) {\r\n minimumMarkersToShow = 6;\r\n hasCoordinateParameter = true;\r\n coordinateString = \"[\" + decodeURIComponent(queryParams.coordinate) + \"]\";\r\n var coordinate = JSON.parse(coordinateString);\r\n $(hdnCoordinateSelector).val(coordinateString);\r\n $.ajax({\r\n url: \"https://api.mapbox.com/geocoding/v5/mapbox.places/\" + coordinate[1].toString() + \"%2C%20\" + coordinate[0].toString() + \".json?access_token=\" + mapboxAccessToken,\r\n type: 'GET',\r\n success: function (data) {\r\n if (data && data.type == \"FeatureCollection\") {\r\n if (data.features && data.features.length > 0) {\r\n\r\n var queryStringPlaceType = queryParams.place_type;\r\n var placeName = \"\";\r\n if (queryStringPlaceType) {\r\n for (var i = 0; i < data.features.length; i++) {\r\n var feature = data.features[i];\r\n var featurePlaceType = feature.place_type[0];\r\n if (featurePlaceType == queryStringPlaceType) {\r\n placeName = feature.place_name;\r\n break;\r\n }\r\n }\r\n }\r\n else\r\n placeName = data.features[0].place_name;\r\n\r\n $(\"#geocoder\").find(\"input\").val(placeName);\r\n hasSelectedLocation = true;\r\n }\r\n }\r\n },\r\n error: function (err) {\r\n console.log(err);\r\n }\r\n });\r\n }\r\n\r\n setRadiusFromQueryParams(queryParams, hasCoordinateParameter);\r\n setTagsFromQueryParams(queryParams, hasCoordinateParameter);\r\n setStatusFromQueryParams(queryParams, hasCoordinateParameter);\r\n if (queryParams.comingsoonsites && queryParams.comingsoonsites == \"1\")\r\n $(\"#includeApproved\").prop('checked', true);\r\n if (!queryParams.pediatric)\r\n $(\"#pediatricFilter\").prop('checked', false);\r\n }\r\n }\r\n refreshMarkers(minimumMarkersToShow);\r\n var bounds = getBoundsFromResults(locations, minimumMarkersToShow);\r\n var tags = [];\r\n if (queryParams.tags) {\r\n tags = queryParams.tags.split(\"|\");\r\n selectedTags = tags;\r\n }\r\n displayOnlyWebsitesFilteredByTagsInResults(tags);\r\n if ($(window).width() <= mobileWidth)\r\n map.fitBounds(bounds, { padding: 80 });\r\n else\r\n map.fitBounds(bounds, { padding: 50 });\r\n initCenter = map.getCenter();\r\n beforeInit = true;\r\n }\r\n\r\n function setRadiusFromQueryParams(queryParams, hasCoordinateParameter) {\r\n if (queryParams.radius) {\r\n $(radiusDropdownSelector).val(queryParams.radius);\r\n var validValue = false;\r\n $(radiusDropdownSelector).find(\"option\").each(function () {\r\n var optionValue = $(this).val();\r\n if (optionValue == queryParams.radius) {\r\n validValue = true;\r\n return false;\r\n }\r\n });\r\n\r\n if (validValue) {\r\n var styledSelect = $(radiusDivSelector).find('div.select-styled');\r\n styledSelect.text(queryParams.radius);\r\n }\r\n }\r\n else {\r\n if (hasCoordinateParameter) {\r\n var styledSelect = $(radiusDivSelector).find('div.select-styled');\r\n styledSelect.text($(radiusDropdownSelector).find(\"option\").eq(0).text());\r\n }\r\n }\r\n }\r\n\r\n function setTagsFromQueryParams(queryParams, hasCoordinateParameter) {\r\n if (queryParams.tags) {\r\n var tag = \"\";\r\n var tagArray = queryParams.tags.split(\"|\");\r\n for (var i = 0; i < tagArray.length; i++) {\r\n var tagId = tagArray[i];\r\n $('[id^=ddlTags_]').each(function () {\r\n var option = $(this).find('option[value=' + tagId + ']');\r\n if (option && option.length > 0) {\r\n tag = $(option).text();\r\n var name = $(this).attr(\"id\").replace(\"ddlTags_\", \"\");\r\n $(selectedTagSelector + name).val(tagId);\r\n var styledSelect = $('div[name=\"tagFilter_' + name + '\"]').find('div.select-styled');\r\n styledSelect.text(tag);\r\n }\r\n });\r\n }\r\n //$(selectedTagSelector).val(queryParams.tags);\r\n //$(tagsDropdownSelector).val(queryParams.tags);\r\n //var validValue = false;\r\n //var tag = \"\";\r\n //$(tagsDropdownSelector).find(\"option\").each(function () {\r\n // var optionValue = $(this).val();\r\n // if (optionValue != \"\") {\r\n // if (queryParams.tags.indexOf(optionValue) > -1) {\r\n // tag = $(this).text();\r\n // validValue = true;\r\n // return false;\r\n // }\r\n // }\r\n //});\r\n\r\n //if (validValue) {\r\n // var styledSelect = $(tagFilterSelector).find('div.select-styled');\r\n // styledSelect.text(tag);\r\n //}\r\n }\r\n else {\r\n if (hasCoordinateParameter) {\r\n var styledSelect = $(tagFilterSelector).find('div.select-styled');\r\n styledSelect.text($(tagsDropdownSelector).find(\"option\").eq(0).text());\r\n }\r\n }\r\n }\r\n\r\n function setStatusFromQueryParams(queryParams, hasCoordinateParameter) {\r\n if (queryParams.status) {\r\n $(selectedStatusSelector).val(queryParams.status);\r\n $(statusDropdownSelector).val(queryParams.status);\r\n var validValue = false;\r\n var status = \"\";\r\n $(statusDropdownSelector).find(\"option\").each(function () {\r\n var optionValue = $(this).val();\r\n if (optionValue != \"\") {\r\n if (queryParams.status.indexOf(optionValue) > -1) {\r\n status = $(this).text();\r\n validValue = true;\r\n return false;\r\n }\r\n }\r\n });\r\n\r\n if (validValue) {\r\n var styledSelect = $(statusFilterSelector).find('div.select-styled');\r\n styledSelect.text(status);\r\n }\r\n }\r\n else {\r\n if (hasCoordinateParameter) {\r\n var styledSelect = $(statusFilterSelector).find('div.select-styled');\r\n styledSelect.text($(statusDropdownSelector).find(\"option\").eq(0).text());\r\n }\r\n }\r\n }\r\n\r\n onShowOnMapClick = function (el) {\r\n var coordinateArr = $(el).data(\"resultItemCoordinate\");\r\n if (coordinateArr && coordinateArr.length == 2) {\r\n var isMapHidden = $('#hideMapCheckbox').is(':checked');\r\n if (isMapHidden) {\r\n onShowMap();\r\n $('#hideMapCheckbox').prop('checked', false);\r\n }\r\n $(window).scrollTop($(\"#map\").offset().top);\r\n removePopups();\r\n var selectedPopups = [];\r\n for (var i = 0; i < locations.length; i++) {\r\n var location = locations[i];\r\n if (coordinateArr[0].toPrecision(9) == location.Coordinate.Latitude.toPrecision(9) && coordinateArr[1].toPrecision(9) == location.Coordinate.Longitude.toPrecision(9))\r\n selectedPopups.push(location);\r\n }\r\n\r\n if (selectedPopups.length > 0) {\r\n setPopup(selectedPopups);\r\n }\r\n var longLat = [coordinateArr[1], coordinateArr[0] + 0.003];\r\n map.flyTo({ center: longLat, minZoom: 5, zoom: 5, duration: 0 });\r\n delay(1000).then(() => map.flyTo({ center: longLat, zoom: 15, duration: animationDuration }));\r\n }\r\n }\r\n\r\n var popups = [];\r\n displayedResultsCount = 0;\r\n // TO MAKE THE MAP APPEAR YOU MUST\r\n // ADD YOUR ACCESS TOKEN FROM\r\n // https://account.mapbox.com\r\n mapboxgl.accessToken = mapboxAccessToken;\r\n var zoomLevel = 3.5;\r\n const map = new mapboxgl.Map({\r\n container: mapSelector, // container ID\r\n style: mapboxStyle, // style URL\r\n center: [-74.5, 40], // starting position [lng, lat]\r\n zoom: zoomLevel, // starting zoom\r\n //maxBounds: bounds,\r\n scrollZoom: false\r\n });\r\n\r\n const nav = new mapboxgl.NavigationControl({ showCompass: false })\r\n map.addControl(nav, 'bottom-right');\r\n\r\n map.on('idle', () => {\r\n if (beforeInit) {\r\n if (!mapLoaded) {\r\n var searchParams = getSearchParameters();\r\n if (searchParams.Coordinate) {\r\n var mapboxBounds = [\r\n [-126.3, 21],\r\n [-67.9326, 57]\r\n ];\r\n //if height of mapbox map is larger than width, we need different mapbox bounds\r\n if ($(window).width() <= mobileWidth) {\r\n var mapWidth = $(\"#\" + mapSelector).width();\r\n var mapHeight = $(\"#\" + mapSelector).height();\r\n if (mapHeight > mapWidth) {\r\n mapboxBounds = [\r\n [-140, 0],\r\n [-40.9326, 70]\r\n ];\r\n }\r\n }\r\n\r\n map.setMaxBounds(mapboxBounds);\r\n }\r\n else {\r\n var mapboxInitBounds = map.getBounds();\r\n //setting max bounds by inital map view with all locations\r\n map.setMaxBounds(mapboxInitBounds);\r\n }\r\n zoomLevel = map.getZoom();\r\n setStatusOnItemsBasedOnStatusFilter();\r\n addMapClusters(filteredResults);\r\n mapLoaded = true;\r\n }\r\n beforeInit = false;\r\n }\r\n\r\n attachClickEventToExtLinks();\r\n if (visitWebsiteLinkInPopup != null) {\r\n enableVisitWebsiteLink(visitWebsiteLinkInPopup, true);\r\n visitWebsiteLinkInPopup = null;\r\n }\r\n });\r\n\r\n /* layers */\r\n function getGeoJSONPoint(locationResult) {\r\n var featureItem = {\r\n type: \"Feature\",\r\n geometry: {\r\n type: \"Point\",\r\n coordinates: [locationResult.Coordinate.Longitude, locationResult.Coordinate.Latitude]\r\n },\r\n properties: locationResult\r\n };\r\n\r\n featureItem.properties.activated = locationResult.Activated;\r\n if (locationResult.Activated == \"0\") {\r\n featureItem.properties.activatedVal = 0;\r\n featureItem.properties.unactivated = 1;\r\n }\r\n else {\r\n featureItem.properties.activatedVal = 1;\r\n featureItem.properties.unactivated = 0;\r\n }\r\n return featureItem;\r\n }\r\n\r\n function getGeoJsonData(results) {\r\n const data = { \"type\": \"FeatureCollection\" };\r\n var locationsData = [];\r\n for (var i = 0; i < results.length; i++) {\r\n var location = results[i];\r\n locationsData.push(getGeoJSONPoint(location));\r\n }\r\n data.features = locationsData;\r\n return data;\r\n }\r\n\r\n function addMapClusters(results) {\r\n var data = getGeoJsonData(results);\r\n\r\n if (map.getSource('QTClocations')) {\r\n map.removeLayer(\"clusters\");\r\n map.removeLayer(\"cluster-count\");\r\n map.removeLayer(\"unclustered-point\");\r\n map.removeSource(\"QTClocations\");\r\n }\r\n const act = ['>', ['get', 'activatedVal'], 0];\r\n const magUnact = ['>', ['get', 'unactivated'], 0];\r\n\r\n map.addSource('QTClocations', {\r\n 'type': 'geojson',\r\n 'data': data,\r\n 'cluster': useClusters == \"True\" ? true : false, \r\n 'clusterRadius': 20,\r\n 'clusterMaxZoom': 14,\r\n 'clusterProperties': {\r\n \"sumActive\": [\"+\", ['case', act, 1, 0]],\r\n \"sumUnactive\": [\"+\", ['case', magUnact, 1, 0]]\r\n }\r\n });\r\n\r\n const activeOnly = ['all', ['>', ['get', 'sumActive'], 0], ['==', ['get', 'sumUnactive'], 0]];\r\n const both = ['all', ['>', ['get', 'sumActive'], 0], ['>', ['get', 'sumUnactive'], 0]];\r\n const activationInProgressOnly = ['all', ['==', ['get', 'sumActive'], 0], ['>', ['get', 'sumUnactive'], 0]];\r\n\r\n map.addLayer({\r\n id: 'clusters',\r\n type: 'circle',\r\n source: 'QTClocations',\r\n filter: ['has', 'point_count'],\r\n paint: {\r\n 'circle-color': [\r\n 'case',\r\n both,\r\n activationInProgressTagColor,\r\n activeOnly,\r\n activatedTagColor,\r\n activationInProgressOnly,\r\n activationInProgressTagColor,\r\n activationInProgressTagColor\r\n ],\r\n 'circle-radius': [\r\n 'case',\r\n both,\r\n 13,\r\n 16\r\n ],\r\n 'circle-stroke-width': [\r\n 'case',\r\n both,\r\n 6,\r\n 3\r\n ],\r\n 'circle-stroke-color': [\r\n 'case',\r\n both,\r\n activatedTagColor,\r\n '#fff'\r\n ]\r\n }\r\n });\r\n\r\n map.addLayer({\r\n id: 'cluster-count',\r\n type: 'symbol',\r\n source: 'QTClocations',\r\n filter: ['has', 'point_count'],\r\n layout: {\r\n 'text-field': ['get', 'point_count_abbreviated'],\r\n 'text-font': ['DIN Offc Pro Medium', 'Arial Unicode MS Bold'],\r\n 'text-size': 15\r\n },\r\n paint: {\r\n 'text-color': 'white'\r\n }\r\n });\r\n\r\n if (useMarkerImages == \"False\") {\r\n map.addLayer({\r\n id: 'unclustered-point',\r\n type: 'circle',\r\n source: 'QTClocations',\r\n filter: ['!', ['has', 'point_count']],\r\n paint: {\r\n 'circle-color': [\r\n \"match\", [\"get\", \"activated\"],\r\n '0', activationInProgressTagColor,\r\n '1', activatedTagColor,\r\n activationInProgressTagColor\r\n ],\r\n 'circle-radius': 10,\r\n 'circle-stroke-width': 2,\r\n 'circle-stroke-color': '#fff'\r\n }\r\n });\r\n }\r\n else {\r\n map.addLayer({\r\n id: 'unclustered-point',\r\n type: 'symbol',\r\n source: 'QTClocations',\r\n filter: ['!', ['has', 'point_count']], \r\n layout: {\r\n 'icon-image': [\r\n \"match\", [\"get\", \"activated\"],\r\n '0', 'activation-in-progress-qtc',\r\n '1', 'active-qtc',\r\n 'activation-in-progress-qtc'\r\n ],\r\n 'icon-size': 1,\r\n 'icon-allow-overlap': true\r\n }\r\n });\r\n }\r\n }\r\n\r\n map.on('load', () => {\r\n if (useMarkerImages == \"True\") {\r\n map.loadImage(\r\n activatedQTCImage,\r\n (error, image) => {\r\n if (error) throw error;\r\n // Add the image to the map style.\r\n map.addImage('active-qtc', image);\r\n }\r\n );\r\n map.loadImage(\r\n activationInProgressQTCImage,\r\n (error, image) => {\r\n if (error) throw error;\r\n // Add the image to the map style.\r\n map.addImage('activation-in-progress-qtc', image);\r\n }\r\n );\r\n }\r\n map.on('click', 'clusters', (e) => {\r\n const features = map.queryRenderedFeatures(e.point, {\r\n layers: ['clusters']\r\n });\r\n const clusterId = features[0].properties.cluster_id;\r\n map.getSource('QTClocations').getClusterExpansionZoom(\r\n clusterId,\r\n (err, zoom) => {\r\n if (err) return;\r\n map.easeTo({\r\n center: features[0].geometry.coordinates,\r\n zoom: zoom\r\n });\r\n }\r\n );\r\n });\r\n\r\n map.on('click', 'unclustered-point', (e) => {\r\n var locationResults = getlocationResultsFromCoordinates(e);\r\n if (locationResults == null) return;\r\n removePopups();\r\n setPopup(locationResults);\r\n });\r\n });\r\n\r\n function getlocationResultsFromCoordinates(e) {\r\n if (e.features && e.features.length > 0) {\r\n var locationItems = [];\r\n var locationItem = e.features[0].properties;\r\n var coordinates = JSON.parse(locationItem.Coordinate);\r\n for (var i = 0; i < locations.length; i++) {\r\n var location = locations[i];\r\n if (coordinates.Latitude.toPrecision(9) == location.Coordinate.Latitude.toPrecision(9) && coordinates.Longitude.toPrecision(9) == location.Coordinate.Longitude.toPrecision(9)) {\r\n locationItems.push(location);\r\n }\r\n }\r\n return locationItems;\r\n }\r\n return null;\r\n }\r\n\r\n function removePopups() {\r\n for (var i = 0; i < popups.length; i++) {\r\n var popup = popups[i];\r\n popup.off(\"close\", onClose);\r\n popup.remove();\r\n }\r\n\r\n popups = [];\r\n }\r\n\r\n function setPopup(locationResults) {\r\n var popupContent = \"\";\r\n var offset = -23;\r\n var locationResult;\r\n for (var i = 0; i < locationResults.length; i++) {\r\n locationResult = locationResults[i];\r\n var distance = \"\";\r\n //if (locationResult.Distance != 0) {\r\n // distance = '
\" + locationResult.Address + \"
\" +\r\n htmlTags + \"