!(function() { var loadScript = function(url, callback) { var script = document.createElement("script"); script.type = "text/javascript"; // If the browser is Internet Explorer. if (script.readyState) { script.onreadystatechange = function() { if (script.readyState == "loaded" || script.readyState == "complete") { script.onreadystatechange = null; callback(); } }; // For any other browser. } else { script.onload = function() { callback(); }; } script.src = url; document.getElementsByTagName("head")[0].appendChild(script); }; var storeifyappsJavaScript = function(jQuery) { var B64={alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",lookup:null,ie:/MSIE /.test(navigator.userAgent),ieo:/MSIE [67]/.test(navigator.userAgent),encode:function(a){var e,f,g,b=B64.toUtf8(a),c=-1,d=b.length,h=[,,];if(B64.ie){for(var i=[];++c>2,h[1]=(3&e)<<4|f>>4,isNaN(f)?h[2]=h[3]=64:(g=b[++c],h[2]=(15&f)<<2|g>>6,h[3]=isNaN(g)?64:63&g),i.push(B64.alphabet.charAt(h[0]),B64.alphabet.charAt(h[1]),B64.alphabet.charAt(h[2]),B64.alphabet.charAt(h[3]));return i.join("")}for(var i="";++c>2,h[1]=(3&e)<<4|f>>4,isNaN(f)?h[2]=h[3]=64:(g=b[++c],h[2]=(15&f)<<2|g>>6,h[3]=isNaN(g)?64:63&g),i+=B64.alphabet[h[0]]+B64.alphabet[h[1]]+B64.alphabet[h[2]]+B64.alphabet[h[3]];return i},decode:function(a){if(a.length%4)throw new Error("InvalidCharacterError: 'B64.decode' failed: The string to be decoded is not correctly encoded.");var b=B64.fromUtf8(a),c=0,d=b.length;if(B64.ieo){for(var e=[];d>c;)b[c]<128?e.push(String.fromCharCode(b[c++])):b[c]>191&&b[c]<224?e.push(String.fromCharCode((31&b[c++])<<6|63&b[c++])):e.push(String.fromCharCode((15&b[c++])<<12|(63&b[c++])<<6|63&b[c++]));return e.join("")}for(var e="";d>c;)e+=b[c]<128?String.fromCharCode(b[c++]):b[c]>191&&b[c]<224?String.fromCharCode((31&b[c++])<<6|63&b[c++]):String.fromCharCode((15&b[c++])<<12|(63&b[c++])<<6|63&b[c++]);return e},toUtf8:function(a){var d,b=-1,c=a.length,e=[];if(/^[\x00-\x7f]*$/.test(a))for(;++bd?e.push(d):2048>d?e.push(192|d>>6,128|63&d):e.push(224|d>>12,128|63&d>>6,128|63&d);return e},fromUtf8:function(a){var c,b=-1,d=[],e=[,,];if(!B64.lookup){for(c=B64.alphabet.length,B64.lookup={};++b>4),e[2]=B64.lookup[a.charAt(++b)],64!=e[2])&&(d.push((15&e[1])<<4|e[2]>>2),e[3]=B64.lookup[a.charAt(++b)],64!=e[3]);)d.push((3&e[2])<<6|e[3]);return d}}; var replacer = function(finder, element, blackList, type = 1) { if (!finder) { return } var regex = (typeof finder == 'string') ? new RegExp(finder, 'g') : finder; var regex2 = (typeof finder == 'string') ? new RegExp(finder, 'g') : finder; var childNodes = element.childNodes; var len = childNodes.length; var list = typeof blackList == 'undefined' ? 'html,head,style,title,link,meta,script,object,iframe,pre,a,' : blackList; while (len--) { var node = childNodes[len]; if (node.nodeType === 1 && true || (list.indexOf(node.nodeName.toLowerCase()) === -1)) { replacer(finder, node, list, type); } if (node.nodeType !== 3 || !regex.test(node.data)) { continue; } var frag = (function() { var wrap = document.createElement('span'); var frag = document.createDocumentFragment(); var sliderId = regex2.exec(node.data)[1]; if (type == 1) wrap.innerHTML = '
'; else wrap.innerHTML = '
'; while (wrap.firstChild) { frag.appendChild(wrap.firstChild); } return frag; })(); //console.log(frag); var parent = node.parentNode; parent.insertBefore(frag, node); parent.removeChild(node); } }; if (typeof storeify_app_proxy_url !== 'undefined') { storeify_app_proxy_url = storeify_app_proxy_url; }else{ storeify_app_proxy_url = url_app; } if (typeof storeify_app_url !== 'undefined') { storeify_app_url = storeify_app_url; }else{ storeify_app_url = app_url_config; } var html_reponse_short = B64.decode(html_render_short); var storelocator_products_response = JSON.parse(B64.decode(products_render)); var storelocator_tags_response = JSON.parse(B64.decode(tags_render)); var storelocator_country = JSON.parse(B64.decode(array_country)); var html_reponse = B64.decode(html_render); var html_list = JSON.parse(B64.decode(html_list_render)); var gmarkers = []; var gmarker_show = []; var markers = []; var marker_search = null; var map; var infowindow; var bounds; var randomID = 'main-slider-storelocator'; var dataApps = window.storeifyStorelocator || {}; var root_url = '/'; var storelocator_lang = []; var ifyFieldsVisibility = {'list':[1,1,1,1,1,1],'map':[1,1,1,1,1,1,1]}; var phone_icon = ''; var web_icon = ''; var email_icon = ''; var road_icon = ''; var ifyArr_country_region_city = {}; if(typeof ifyArr_country_region != 'undefined') ifyArr_country_region_city = JSON.parse(B64.decode(ifyArr_country_region)); var ify_filter_region_city = window.ify_filter_region_city || 0; var ify_mode_filtercountry = window.ify_mode_filtercountry || 1; console.log('ifyArr_country_region_city',ifyArr_country_region_city,ify_filter_region_city) let storeify_open_new_tab_index = 0; if(typeof storeify_open_new_tab != 'undefined') storeify_open_new_tab_index = storeify_open_new_tab; if (typeof ify_fieldsVisibility !== 'undefined') ifyFieldsVisibility = JSON.parse(B64.decode(ify_fieldsVisibility)); if (typeof ifylangs !== 'undefined') storelocator_lang = JSON.parse(B64.decode(ifylangs)); if (typeof dataApps.lang !== 'undefined') { storelocator_lang = dataApps.lang; } if (dataApps.root_url && dataApps.root_url != '/') root_url = dataApps.root_url; var ify_layout = dataApps.ify_layout || 1; // var limit_store = 5000; // var list_mode = 0; // var search_mode = 0; //code here // document.addEventListener('DOMContentLoaded', () => { //}); function initMap() { var script = document.createElement('script'); script.src = window.geoson_url; document.getElementsByTagName('head')[0].appendChild(script); if(document.getElementById("map") && !document.getElementById("storeify-detail-store")){ locationDiv = document.getElementById("storeify_location"); if(!locationDiv) locationDiv = document.getElementById("location"); input = document.getElementById('address'); var styledMapType = new google.maps.StyledMapType(JSON.parse(B64.decode(map_style_render))); map = new google.maps.Map(document.getElementById("map"), { center: new google.maps.LatLng(center_lat, center_lng), zoom: initial_zoom, mapTypeId: google.maps.MapTypeId.ROADMAP, mapTypeControl: false, streetViewControl: false, mapTypeControlOptions: { style: google.maps.MapTypeControlStyle.DROPDOWN_MENU } }); map.mapTypes.set('styled_map', styledMapType); map.setMapTypeId('styled_map'); infowindow = new google.maps.InfoWindow(); bounds = new google.maps.LatLngBounds(); var searchBox = new google.maps.places.SearchBox(input); var tags_input = []; if (priority_search != 'global') { const options = { componentRestrictions: { country: priority_search }, }; const autocomplete = new google.maps.places.Autocomplete(input, options); google.maps.event.addListener(autocomplete, 'place_changed', function() { searchLocation(priority_search); }); } else{ const autocomplete = new google.maps.places.Autocomplete(input); google.maps.event.addListener(autocomplete, 'place_changed', function() { searchLocation(null); }); } jQuery.each(jQuery('input.storeifyapp_stores_tags_filter:checked'), function() { tags_input.push(jQuery(this).val()); }); var filter_country = 'all',filter_region = 'ify_all',filter_city = 'ify_all'; if (jQuery('input.storeifyapp_stores_country_filter').length) { filter_country = jQuery('input.storeifyapp_stores_country_filter:checked').val(); } if (jQuery('input.storeifyapp_stores_region_filter').length) { filter_region = jQuery('input.storeifyapp_stores_region_filter:checked').val(); } if (jQuery('input.storeifyapp_stores_city_filter').length) { filter_city = jQuery('input.storeifyapp_stores_city_filter:checked').val(); } if(jQuery('.storeifyapp_stores_countrys_filter_list').data('tag') == 'select'){ filter_country = jQuery('select.storeifyapp_stores_country_filter').val(); } if(jQuery('.storeifyapp_stores_region_filter_list').data('tag') == 'select'){ filter_region = jQuery('select.storeifyapp_stores_region_filter').val(); } if(jQuery('.storeifyapp_stores_city_filter_list').data('tag') == 'select'){ filter_city = jQuery('select.storeifyapp_stores_city_filter').val(); } if(filter_region == 'unnamed_region') filter_region = ''; if(filter_city == 'unnamed_city') filter_city = ''; if (locationDiv) locationDiv.innerHTML = '
'; var tilesloaded = google.maps.event.addListener(map, "tilesloaded", function() { html_list = html_list.replaceAll("{{ directions }}",storelocator_lang.directions); html_list = html_list.replaceAll("{{ link_detail }}",storelocator_lang.link_detail); html_list = html_list.replaceAll("{{ load_map_text }}",storelocator_lang.load_map_text); let open_new_tabText = 'This link opens in a new tab.'; if(typeof storelocator_lang.open_new_tab != 'undefined') open_new_tabText = storelocator_lang.open_new_tab; html_list = html_list.replaceAll("{{ open_new_tab }}",open_new_tabText); jQuery('#' + randomID).html(html_list); jQuery("#results-slt").show(); google.maps.event.removeListener(tilesloaded); }); } } window.eqfeed_callback = function(results) { var thum = ''; var count_marker = 0; var html_list = ''; var params = []; for (var i = 0; i < results.features.length; i++) { var coords = results.features[i].geometry.coordinates; var latLng = new google.maps.LatLng(coords[1], coords[0]); var properties = results.features[i].properties; if (typeof properties.thumbnail !== 'undefined') { thum = properties.thumbnail; } params.push({ country: properties.country, region: properties.region, city: properties.city, tags: properties.tags, web: properties.web, email: properties.email, phone: properties.phone, thum: thum, id: properties.id, name: properties.name, url: properties.url, address: properties.address, social: properties.social, tags: properties.tags, schedule: properties.schedule }); if(map){ if (list_mode != 1 || (list_mode == 1 && i < limit_store)) { var data_maker = { position: new google.maps.LatLng(coords[1], coords[0]), social: properties.social, country: properties.country, region: properties.region, city: properties.city, tags: properties.tags, web: properties.web, email: properties.email, phone: properties.phone, thum: thum, id: properties.id, name: properties.name, url: properties.url, address: properties.address, schedule: properties.schedule, map: map, icon_marker: properties.icon_marker, num: i, visible: true, }; bounds.extend(latLng); count_marker++; } else { var data_maker = { position: new google.maps.LatLng(coords[1], coords[0]), social: properties.social, country: properties.country, region: properties.region, city: properties.city, tags: properties.tags, web: properties.web, email: properties.email, phone: properties.phone, thum: thum, id: properties.id, name: properties.name, url: properties.url, address: properties.address, schedule: properties.schedule, map: map, icon_marker: properties.icon_marker, num: i, visible: false, }; } var marker = createMarker(data_maker, map, infowindow); gmarkers.push(marker); } // if(i > 10) marker.setVisible(true); } if(map){ if (count_marker > 1) { jQuery("#storeify-text-result").text(jQuery("#storeify-text-result").data('results')); } else { jQuery("#storeify-text-result").text(jQuery("#storeify-text-result").data('result')); } if(ify_layout != 8) document.getElementById("num-rs").innerHTML = count_marker; if (list_mode == 2 || limit_store == 0) { jQuery("#results-slt h3.title").hide(); jQuery("#main-slider-storelocator").addClass('storeify-first-alert'); } if (list_mode == 2 || limit_store == 0) { jQuery("#results-slt h3.title").hide(); jQuery("#main-slider-storelocator").removeClass('storeify-first-alert'); } if (center_lat == 0 && center_lng == 0) { map.fitBounds(bounds); } else { map.setZoom(initial_zoom); map.setCenter(new google.maps.LatLng(center_lat, center_lng)); } document.getElementById("loading_mask_loader").style.display = 'none'; if(find_location == 1) setTimeout(function loadLocationInit() { loadGeolocationInit(); },1000); } if(shortcode_use == 1){ var listCountry = new Shortcode(document.querySelector('body'), { storeifyStorelocator: function() { var country = this.options.country; var city = this.options.city; var class_text = 'storeify-list-country'; if(city){ class_text = 'storeify-list-city'; } var htmlCountry = '
'; jQuery.each(params, function( index, value ) { if(country && value.country == country){ htmlCountry += '
'; htmlCountry += ''; if (value.address != null) { htmlCountry += '

' + value.address + '

'; } if (value.email != null && typeof value.email != 'undefined' && value.email != '') { htmlCountry += '
'+email_icon+''; htmlCountry += '' + value.email + '
'; } if (value.phone != null && typeof value.phone != 'undefined' && value.phone != '') { htmlCountry += '
'+phone_icon+''; htmlCountry += '' + value.phone + '
'; } if (value.web != null && typeof value.web != 'undefined' && value.web != '') { htmlCountry += ''; } if (value.tags.length > 0) { var tag_arr = value.tags; var tag_html = ''; jQuery.each(tag_arr, function(i, val) { tag_html += ' ' + val + ''; }); htmlCountry += '
' + tag_html +'
'; } if (value.social != null && typeof value.social != 'undefined' && value.social != '') { htmlCountry += '
' + value.social + '
'; } htmlCountry += '
'; } if(city && value.city == city){ htmlCountry += '
'; htmlCountry += ''; if (value.address != null) { htmlCountry += '

' + value.address + '

'; } if (value.email != null && typeof value.email != 'undefined' && value.email != '') { htmlCountry += '
'+email_icon+''; htmlCountry += '' + value.email + '
'; } if (value.phone != null && typeof value.phone != 'undefined' && value.phone != '') { htmlCountry += '
'+phone_icon+''; htmlCountry += '' + value.phone + '
'; } if (value.web != null && typeof value.web != 'undefined' && value.web != '') { htmlCountry += ''; } if (value.tags.length > 0) { var tag_arr = value.tags; var tag_html = ''; jQuery.each(tag_arr, function(i, val) { tag_html += ' ' + val + ''; }); htmlCountry += '
' + tag_html +'
'; } if (value.social != null && typeof value.social != 'undefined' && value.social != '') { htmlCountry += '
' + value.social + '
'; } htmlCountry += '
'; } }); htmlCountry +='
'; //return this.options.text; return htmlCountry; } }); } } function createMarker(data_maker, map, infowindow) { var html = ''; html += '
'; html += '
'; html += '
'; html += '

' + data_maker.name + '

'; if (data_maker.thum) { html += '
'; html += '
'; } else html += '
'; //html += '' + trans['address'] + ':

' + address + '

'; if(ifyFieldsVisibility['map'][0] == 1) html += '

' + data_maker.address + '

'; if (data_maker.email != null && typeof data_maker.email != 'undefined' && data_maker.email != '' && ifyFieldsVisibility['map'][1] == 1) { html += '

'+email_icon+' ' + data_maker.email + '

'; } if (data_maker.phone != null && typeof data_maker.phone != 'undefined' && data_maker.phone != '' && ifyFieldsVisibility['map'][2] == 1) { html += '

'+phone_icon+' ' + data_maker.phone + '

'; } if (data_maker.web != null && typeof data_maker.web != 'undefined' && data_maker.web != '' && ifyFieldsVisibility['map'][3] == 1) { html += ''; } if (data_maker.tags.length > 0 && ifyFieldsVisibility['map'][4] == 1) { //html += ''; var tag_arr = data_maker.tags; var tag_html = ''; jQuery.each(tag_arr, function(key, value) { tag_html += ' ' + value + ''; }); html += '

' + tag_html + '

'; } if (data_maker.social != null && typeof data_maker.social != 'undefined' && data_maker.social != '' && ifyFieldsVisibility['map'][5] == 1) { html += '
' + data_maker.social + '
'; } html +='
'; html +='
'; let open_new_tab = ''; if(storeify_open_new_tab_index == 1) open_new_tab = 'target="_blank" aria-label="'+storelocator_lang.open_new_tab+'"'; if (data_maker.schedule != null && typeof data_maker.schedule != 'undefined' && data_maker.schedule != '' && store_schedule == 1 && ifyFieldsVisibility['map'][6] == 1) { $arrLangschedule = { 'mon' : storelocator_lang.mon, 'tue' : storelocator_lang.tue, 'wed' : storelocator_lang.wed, 'thu' : storelocator_lang.thu, 'fri' : storelocator_lang.fri, 'sat' : storelocator_lang.sat, 'sun' : storelocator_lang.sun, 'store_operation' : storelocator_lang.store_operation, 'am' : storelocator_lang.am, 'pm' : storelocator_lang.pm, 'closed' : storelocator_lang.closed, 'the_next_day' : storelocator_lang.the_next_day, }; let htmlSchedule = data_maker.schedule; jQuery.each($arrLangschedule, function( key, val ) { htmlSchedule = htmlSchedule.replaceAll("{{ "+key+" }}", val); }); html += '
'+htmlSchedule+'
'; } if (data_maker.url != null) { html += '' + storelocator_lang.link_detail + ''; } html += '' + storelocator_lang.directions + '
'; html += '
'; html += '
'; var marker = new google.maps.Marker(data_maker); var icon_marker_url = window.default_marker; if(window.icon_marker != '') icon_marker_url = window.icon_marker; if (data_maker.icon_marker != null && data_maker.icon_marker != "") icon_marker_url = data_maker.icon_marker; var icon = { url: icon_marker_url, // url scaledSize: new google.maps.Size(40, 40), // scaled size // origin: new google.maps.Point(0,0), // origin // anchor: new google.maps.Point(0, 0) // anchor }; marker.setIcon(icon); google.maps.event.addListener(marker, 'click', function(evt) { // the click event function is called with the "event" as an argument if(jQuery('.chose-search-slt').val() == 'location'){ address = jQuery('#address').val(); html = html.replace("saddr=", "saddr="+address); } showInfoWindow(evt, this, map, infowindow, html); }); return marker; } function string_to_slug (str) { str = str.replace(/^\s+|\s+$/g, ''); // trim str = str.toLowerCase(); // remove accents, swap ñ for n, etc var from = "à áäâèéëêìíïîòóöôùúüûñç·/_,:;"; var to = "aaaaeeeeiiiioooouuuunc------"; for (var i=0, l=from.length ; i 5 && arguments[5] !== undefined ? arguments[5] : 0.001; var check = -1; if (getDistanceBetweenPoints(lat1, lng1, lat2, lng2) * dv <= radius) check = getDistanceBetweenPoints(lat1, lng1, lat2, lng2) * dv; return check; } /**/ function checkTag(tag, tags) { var check = 0; if (tag.length == 0 || superbag(tags, tag) == true) check = 1; return check; } function addAnalytic(resultGeo,count){ var url = storeify_app_url + '/add-analytic'; var data = { 'lat':resultGeo.geometry.location.lat(), 'lng':resultGeo.geometry.location.lng(), 'result':resultGeo.address_components, 'address':resultGeo.formatted_address, 'count':count, 'domain':Shopify.shop, }; jQuery.ajax({ url: url, type: "post", data: data, cache: false, dataType: "json", }).done(function(data) { }).fail(function() { }); } function searchLocationsNear(resultGeo, map, bounds, gmarkers,search) { var radius = document.getElementById('radius_search').value; var center = resultGeo.geometry.location; bounds = new google.maps.LatLngBounds(); //var searchUrl = baseurl + 'all/ajax?lat=' + center.lat() + '&lng=' + center.lng() + '&radius=' + radius + '&shop=' + Shopify.shop; var searchUrl = storeify_app_proxy_url + '/all/ajax'; //?lat=' + center.lat() + '&lng=' + center.lng() + '&radius=' + radius + '&radius=' + Shopify.shop; var tags_check = []; jQuery.each(jQuery('input.storeifyapp_stores_tags_filter:checked'), function() { tags_check.push(jQuery(this).val()); }); var filter_country = 'all',filter_region = 'ify_all',filter_city = 'ify_all'; if (jQuery('input.storeifyapp_stores_country_filter').length) { filter_country = jQuery('input.storeifyapp_stores_country_filter:checked').val(); } if (jQuery('input.storeifyapp_stores_region_filter').length) { filter_region = jQuery('input.storeifyapp_stores_region_filter:checked').val(); } if (jQuery('input.storeifyapp_stores_city_filter').length) { filter_city = jQuery('input.storeifyapp_stores_city_filter:checked').val(); } if(jQuery('.storeifyapp_stores_countrys_filter_list').data('tag') == 'select'){ filter_country = jQuery('select.storeifyapp_stores_country_filter').val(); } if(jQuery('.storeifyapp_stores_region_filter_list').data('tag') == 'select'){ filter_region = jQuery('select.storeifyapp_stores_region_filter').val(); } if(jQuery('.storeifyapp_stores_city_filter_list').data('tag') == 'select'){ filter_city = jQuery('select.storeifyapp_stores_city_filter').val(); } if(filter_region == 'unnamed_region') filter_region = ''; if(filter_city == 'unnamed_city') filter_city = ''; var check_country = 0; var data = { lat: center.lat(), lng: center.lng(), radius: radius, shop: Shopify.shop, tags: tags_check.join(',') }; var marker_count = 0; var marker_first; var dv = 1; if (radius_unit == 1) { dv = 0.001; } else { dv = 0.00062137; } var array_poin = []; for (var i = 0; i < gmarkers.length; i++) { // console.log( markerNodes[i]['tags'] ); marker = gmarkers[i]; var distance = checkDistanceBetweenPoints(center.lat(), center.lng(), marker.position.lat(), marker.position.lng(), radius, dv); check_country = 0; if ( (filter_country == 'all' || filter_country == marker.country) && (filter_region == 'ify_all' || filter_region == marker.region) && (filter_city == 'ify_all' || filter_city == marker.city) ) { check_country = 1; } if (distance > -1 && checkTag(tags_check, marker.tags) && check_country == 1) { thum = null; if (typeof marker.thum !== 'undefined') { thum = marker.thum; } var id = marker.id; var name = marker.name; var url = marker.url; var address = marker.address; var phone = marker.phone; var email = marker.email; var web = marker.web; var tags = marker.tags; var social = marker.social; var num = marker.num; array_poin[i] = { social: social, thum: thum, id: id, name: name, url: url, address: address, phone: phone, email: email, web: web, distance: distance, tags: tags, marker_count: marker_count, num: num }; marker.setVisible(true); marker_first = marker; marker_count++; bounds.extend(marker.getPosition()); } else { marker.setVisible(false); } } map.fitBounds(bounds); if(ify_layout != 8) document.getElementById("num-rs").innerHTML = marker_count; //jQuery("#results-slt h3.title").show(); jQuery("#main-slider-storelocator").removeClass('storeify-first-alert'); if (marker_count > 0) { array_poin = array_poin.sort(function(a, b) { return a.distance - b.distance; }); var html_list = ''; if(ify_layout != 8) for (var i = 0; i < marker_count; i++) { html_list += listItem(array_poin[i].social, array_poin[i].thum, array_poin[i].id, array_poin[i].name, array_poin[i].url, array_poin[i].address, array_poin[i].phone, array_poin[i].email, array_poin[i].web, array_poin[i].distance, array_poin[i].tags, array_poin[i].num,search); } if(marker_count == 1){ map.setCenter(marker_first.getPosition()); map.setZoom(search_result_zoom); }else{ var zoom = map.getZoom(); zoom = Math.min(zoom, 12); map.setZoom(zoom); } jQuery("#storeify-text-result").text(jQuery("#storeify-text-result").data('results')); jQuery('#' + randomID).html(html_list); } if (marker_count == 0) { map.setZoom(search_result_zoom); map.setCenter(new google.maps.LatLng(center.lat(), center.lng())); document.getElementById("loading_mask_loader").style.display = 'none'; jQuery("#results-slt").hide(); var address = document.getElementById("address").value; //alert(trans['store_near'] + address); //"store_near" jQuery("#storeify-text-result").text(jQuery("#storeify-text-result").data('result')); jQuery('#results-empty').html('
' + storelocator_lang.store_near + ' "' + address + '"
'); addAnalytic(resultGeo,marker_count); return; } jQuery('#results-empty').html('
'); jQuery("#results-slt").show(); var thum = ''; // map.fitBounds(bounds); // var zoom = map.getZoom(); // zoom = Math.min(zoom, 12); // jQuery(".map-tab-mobile-bnt-item").attr("data-zoom",zoom); // map.setZoom(zoom); document.getElementById("loading_mask_loader").style.display = 'none'; addAnalytic(resultGeo,marker_count); } function searchLocationsNearShort(resultGeo) { if (marker_search != null) marker_search.setMap(null); var center = resultGeo.geometry.location; if(infowindow) infowindow.close(); var radius = document.getElementById('radius_search').value; //var searchUrl = baseurl + 'all/ajax?lat=' + center.lat() + '&lng=' + center.lng() + '&radius=' + radius + '&shop=' + Shopify.shop; var searchUrl = storeify_app_proxy_url + '/all/ajax';//?lat=' + center.lat() + '&lng=' + center.lng() + '&radius=' + radius + '&radius=' + Shopify.shop; var tags_check = []; var filter_country = 'all',filter_region = 'ify_all',filter_city = 'ify_all'; var check_country = 0; var data = {lat:center.lat(),lng:center.lng(),radius:radius,shop: Shopify.shop,tags:tags_check.join(',')}; var marker_count = 0; var dv = 1; if(radius_unit == 1 ){ dv = 0.001; }else{ dv= 0.00062137; } var array_poin = []; for (var i = 0; i < gmarkers.length; i++) { marker = gmarkers[i]; var distance = checkDistanceBetweenPoints(center.lat(), center.lng(), marker.position.lat(), marker.position.lng(), radius, dv); check_country = 0; if ( (filter_country == 'all' || filter_country == marker.country) && (filter_region == 'ify_all' || filter_region == marker.region) && (filter_city == 'ify_all' || filter_city == marker.city) ) { check_country = 1; } if (distance > -1 && checkTag(tags_check, marker.tags) && check_country == 1) { thum = null; if (typeof marker.thum !== 'undefined') { thum = marker.thum; } var id = marker.id; var name = marker.name; var url = marker.url; var address = marker.address; var phone = marker.phone; var email = marker.email; var web = marker.web; var tags = marker.tags; var social = marker.social; var num = marker.num; array_poin[i] = { social: social, thum: thum, id: id, name: name, url: url, address: address, phone: phone, email: email, web: web, distance: distance, tags: tags, marker_count: marker_count, num: num }; marker.setVisible(true); marker_count++; } else { marker.setVisible(false); } } // markerCluster.setIgnoreHidden(true); // markerCluster.repaint(); // markerCluster.fitMapToMarkers(); document.getElementById("storeify-storeloctor-contactFrm").style.display = 'block'; document.getElementById("loading_mask_loader").style.display = 'none'; if(marker_count > 0 ){ array_poin = array_poin.sort(function (a, b) { return a.distance - b.distance ; }); var html_list=''; if(ify_layout != 8) for (var i = 0; i < marker_count; i++) { html_list += listItem(array_poin[i].social, array_poin[i].thum, array_poin[i].id, array_poin[i].name, array_poin[i].url, array_poin[i].address, array_poin[i].phone, array_poin[i].email, array_poin[i].web, array_poin[i].distance, array_poin[i].tags, array_poin[i].num); } if(ify_layout != 8) document.getElementById("num-rs").innerHTML = marker_count; jQuery('#results-slt .list-custo-storeify').html(html_list); }else{ if(ify_layout != 8) document.getElementById("num-rs").innerHTML = marker_count; jQuery("#storeify-text-result").text(jQuery("#storeify-text-result").data('result')); jQuery('#results-slt .list-custo-storeify').html(''); jQuery('#results-empty').html('
'+ storelocator_lang.store_near +'"'+ address+'"
'); } } function searchStoresByName() { if (marker_search != null) marker_search.setMap(null); if(infowindow) infowindow.close(); bounds = new google.maps.LatLngBounds(); document.getElementById("loading_mask_loader").style.display = ''; jQuery('.content-results-slt').removeClass('content-results-first'); var search_text = jQuery.trim(document.getElementById("store_search").value); var tags = []; jQuery.each(jQuery('input.storeifyapp_stores_tags_filter:checked'), function() { tags.push(jQuery(this).val()); }); var filter_country = 'all',filter_region = 'ify_all',filter_city = 'ify_all'; if (jQuery('input.storeifyapp_stores_country_filter').length) { filter_country = jQuery('input.storeifyapp_stores_country_filter:checked').val(); } if (jQuery('input.storeifyapp_stores_region_filter').length) { filter_region = jQuery('input.storeifyapp_stores_region_filter:checked').val(); } if (jQuery('input.storeifyapp_stores_city_filter').length) { filter_city = jQuery('input.storeifyapp_stores_city_filter:checked').val(); } if(jQuery('.storeifyapp_stores_countrys_filter_list').data('tag') == 'select'){ filter_country = jQuery('select.storeifyapp_stores_country_filter').val(); } if(jQuery('.storeifyapp_stores_region_filter_list').data('tag') == 'select'){ filter_region = jQuery('select.storeifyapp_stores_region_filter').val(); } if(jQuery('.storeifyapp_stores_city_filter_list').data('tag') == 'select'){ filter_city = jQuery('select.storeifyapp_stores_city_filter').val(); } if(filter_region == 'unnamed_region') filter_region = ''; if(filter_city == 'unnamed_city') filter_city = ''; var data = { name: search_text, shop: Shopify.shop, tags: tags.join(','), country: filter_country, region: filter_region, city: filter_city, v: 2 }; var searchUrl = storeify_app_proxy_url + '/searchbyname'; //?name=' + search_text + '&shop=' + Shopify.shop; jQuery.ajaxSetup({ headers: { 'X-CSRF-TOKEN': jQuery('input[name="_token"]').val() } }); jQuery.ajax({ url: searchUrl, type: "GET", data: data, cache: false, dataType: "json", }).done(function(data) { var markerNodes = data.data; if (markerNodes.length == 0) { document.getElementById("loading_mask_loader").style.display = 'none'; jQuery("#results-slt").hide(); var query_search = jQuery.trim(document.getElementById("store_search").value); jQuery('#results-empty').html('
' + storelocator_lang.no_store_name + ' "' + query_search + '"
'); setMapOnAll(null) return; } jQuery("#results-slt").show(); var thum = ''; if (markerNodes.length > 1) { jQuery("#storeify-text-result").text(jQuery("#storeify-text-result").data('results')); } else { jQuery("#storeify-text-result").text(jQuery("#storeify-text-result").data('result')); } if(ify_layout != 8) document.getElementById("num-rs").innerHTML = markerNodes.length; //jQuery("#results-slt h3.title").show(); jQuery("#main-slider-storelocator").removeClass('storeify-first-alert'); var html_list = ''; var marker_count = 0; var marker_first; for (var i = 0; i < gmarkers.length; i++) { // console.log( markerNodes[i]['tags'] ); marker = gmarkers[i]; var id = marker.id; if (markerNodes.includes(id)) { thum = null; if (typeof marker.thum !== 'undefined') { thum = marker.thum; } var name = marker.name; var url = marker.url; var address = marker.address; var phone = marker.phone; var email = marker.email; var web = marker.web; var tags = marker.tags; var social = marker.social; var num = marker.num; marker.setVisible(true); marker_first = marker; bounds.extend(marker.getPosition()); marker_count++; if(ify_layout != 8) html_list += listItem(social, thum, id, name, url, address, phone, email, web, null, tags, num); } else { marker.setVisible(false); } } map.fitBounds(bounds); var zoom = map.getZoom(); zoom = Math.min(zoom, 12); if(marker_count == 1){ map.setCenter(marker_first.getPosition()); map.setZoom(search_result_zoom); }else{ map.setZoom(zoom); } jQuery(".map-tab-mobile-bnt-item").attr("data-zoom", zoom); jQuery('#' + randomID).html(html_list); document.getElementById("loading_mask_loader").style.display = 'none'; }).fail(function() { // window.location.href = '/'; document.getElementById("loading_mask_loader").style.display = 'none'; jQuery("#results-slt").hide(); jQuery('#results-empty').html('
An error occurred. Please try again.
'); setMapOnAll(null); console.log('fail ajax') }); // } return true; } function searchStoresByProducts() { if (marker_search != null) marker_search.setMap(null); if(infowindow) infowindow.close(); bounds = new google.maps.LatLngBounds(); document.getElementById("loading_mask_loader").style.display = ''; jQuery('.content-results-slt').removeClass('content-results-first'); var search_text = document.getElementById("product_search").value; var tags = []; jQuery.each(jQuery('input.storeifyapp_stores_tags_filter:checked'), function() { tags.push(jQuery(this).val()); }); var filter_country = 'all',filter_region = 'ify_all',filter_city = 'ify_all'; if (jQuery('input.storeifyapp_stores_country_filter').length) { filter_country = jQuery('input.storeifyapp_stores_country_filter:checked').val(); } if (jQuery('input.storeifyapp_stores_region_filter').length) { filter_region = jQuery('input.storeifyapp_stores_region_filter:checked').val(); } if (jQuery('input.storeifyapp_stores_city_filter').length) { filter_city = jQuery('input.storeifyapp_stores_city_filter:checked').val(); } if(jQuery('.storeifyapp_stores_countrys_filter_list').data('tag') == 'select'){ filter_country = jQuery('select.storeifyapp_stores_country_filter').val(); } if(jQuery('.storeifyapp_stores_region_filter_list').data('tag') == 'select'){ filter_region = jQuery('select.storeifyapp_stores_region_filter').val(); } if(jQuery('.storeifyapp_stores_city_filter_list').data('tag') == 'select'){ filter_city = jQuery('select.storeifyapp_stores_city_filter').val(); } if(filter_region == 'unnamed_region') filter_region = ''; if(filter_city == 'unnamed_city') filter_city = ''; var data = { name: search_text, shop: Shopify.shop, tags: tags.join(','), country: filter_country, region: filter_region, city: filter_city, v: 2 }; var searchUrl = storeify_app_proxy_url + '/searchproduct'; //?name=' + search_text + '&shop=' + Shopify.shop; jQuery.ajaxSetup({ headers: { 'X-CSRF-TOKEN': jQuery('input[name="_token"]').val() } }); jQuery.ajax({ url: searchUrl, type: "GET", data: data, cache: false, dataType: "json", }).done(function(data) { var markerNodes = data.data; if (markerNodes.length == 0) { document.getElementById("loading_mask_loader").style.display = 'none'; jQuery("#results-slt").hide(); var query_search = document.getElementById("product_search").value; jQuery('#results-empty').html('
' + storelocator_lang.no_store_product + ' "' + query_search + '"
'); setMapOnAll(null) return; } jQuery("#results-slt").show(); var thum = ''; if (markerNodes.length > 1) { jQuery("#storeify-text-result").text(jQuery("#storeify-text-result").data('results')); } else { jQuery("#storeify-text-result").text(jQuery("#storeify-text-result").data('result')); } if(ify_layout != 8) document.getElementById("num-rs").innerHTML = markerNodes.length; //jQuery("#results-slt h3.title").show(); jQuery("#main-slider-storelocator").removeClass('storeify-first-alert'); var html_list = ''; var marker_first; var marker_count = 0; for (var i = 0; i < gmarkers.length; i++) { // console.log( markerNodes[i]['tags'] ); marker = gmarkers[i]; var id = marker.id; if (markerNodes.includes(id)) { thum = null; if (typeof marker.thum !== 'undefined') { thum = marker.thum; } var name = marker.name; var url = marker.url; var address = marker.address; var phone = marker.phone; var email = marker.email; var web = marker.web; var tags = marker.tags; var social = marker.social; var num = marker.num; marker.setVisible(true); marker_first = marker; marker_count++; bounds.extend(marker.getPosition()); if(ify_layout != 8) html_list += listItem(social, thum, id, name, url, address, phone, email, web, null, tags, num); } else { marker.setVisible(false); } } map.fitBounds(bounds); var zoom = map.getZoom(); zoom = Math.min(zoom, 12); if(marker_count == 1){ map.setCenter(marker_first.getPosition()); map.setZoom(search_result_zoom); }else{ map.setZoom(zoom); } jQuery(".map-tab-mobile-bnt-item").attr("data-zoom", zoom); jQuery('#' + randomID).html(html_list); document.getElementById("loading_mask_loader").style.display = 'none'; }).fail(function() { // window.location.href = '/'; document.getElementById("loading_mask_loader").style.display = 'none'; jQuery("#results-slt").hide(); jQuery('#results-empty').html('
An error occurred. Please try again.
'); setMapOnAll(null); console.log('fail ajax') }); // } return true; } function onMouseover(markerNum) { var currentIcon = gmarkers[markerNum]; currentIcon.setAnimation(null); if (currentIcon.getAnimation() != null) { currentIcon.setAnimation(null); } else { currentIcon.setAnimation(google.maps.Animation.BOUNCE); setTimeout(function() { currentIcon.setAnimation(null); }, 500); } } function onMouseout(markerNum) { gmarkers[markerNum].setAnimation(null); } function listItem(social, thum, id, name, url, address, phone, email, web, distance, tags, num, search) { var att = ''; if (typeof distance !== 'undefined') { att = 'datamarker="' + num + '"'; } let open_new_tab = ''; if(storeify_open_new_tab_index == 1) open_new_tab = 'target="_blank" aria-label="'+storelocator_lang.open_new_tab+'"'; var html = '
'; if (thum) { html += '
'; } html += '
'; if(ifyFieldsVisibility['list'][0] == 1){ // element.innerHTML += '
'; let linkAddress = 'https://maps.google.com/?daddr=' + address + '&saddr='+search; linkAddress = 'href="'+linkAddress+'" '+open_new_tab; if(typeof ify_link_address !=='undefined' && ify_link_address === 0){ linkAddress = 'href="javascript:void(0)"'; } html += ''; } if (distance) { //html += ''; var radius_unit_text = ' Km'; if (radius_unit != 1) radius_unit_text = ' mi'; html += '
'+road_icon+''; html += distance.toFixed(2) + radius_unit_text + '
'; } if (email != null && typeof email != 'undefined' && email != '' && ifyFieldsVisibility['list'][1] == 1) { //html += ''; html += '
'+email_icon+''; html += '' + email + '
'; } if (phone != null && typeof phone != 'undefined' && phone != '' && ifyFieldsVisibility['list'][2] == 1) { //html += ''; html += '
'+phone_icon+''; html += '' + phone + '
'; } if (web != null && typeof web != 'undefined' && web != '' && ifyFieldsVisibility['list'][3] == 1) { //html += ''; html += ''; } if (tags.length > 0 && ifyFieldsVisibility['list'][4] == 1) { var tag_arr = tags; var tag_html = ''; jQuery.each(tag_arr, function(key, value) { tag_html += ' ' + value + ''; }); html += '
' + tag_html + '
'; } if (social != null && typeof social != 'undefined' && social != '' && ifyFieldsVisibility['list'][5] == 1) { html += '
' + social + '
'; } //"link_detail" if (url != null) { html += '' + storelocator_lang.link_detail + ''; } html += '' + storelocator_lang.directions + '
'; html += '
'; return html; } function loadGeolocation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position) { var geocoder = new google.maps.Geocoder(); var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); geocoder.geocode({ 'latLng': latlng }, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { if (results[1]) { document.getElementById('address').value = results[1].formatted_address; } else { //alert(trans['no_result']); //"no_result" jQuery('#results-empty').html('
' + storelocator_lang.no_result + '
'); } } else { //alert(trans['geocoder_failed'] + status); //"geocoder_failed" jQuery('#results-empty').html('
' + storelocator_lang.geocoder_failed + '
'); } }.bind(this)); // document.getElementById("latitude").value = position.coords.latitude; // document.getElementById("longitude").value = position.coords.longitude; }.bind(this), function(error) {}.bind(this)); } } function loadGeolocationInit() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position) { var geocoder = new google.maps.Geocoder(); var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); geocoder.geocode({ 'latLng': latlng }, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { if (results[1]) { document.getElementById('address').value = results[1].formatted_address; jQuery('#submit-search').trigger( "click" ); } else { //alert(trans['no_result']); //"no_result" jQuery('#results-empty').html('
' + storelocator_lang.no_result + '
'); } } else { //alert(trans['geocoder_failed'] + status); //"geocoder_failed" jQuery('#results-empty').html('
' + storelocator_lang.geocoder_failed + '
'); } }.bind(this)); // document.getElementById("latitude").value = position.coords.latitude; // document.getElementById("longitude").value = position.coords.longitude; }.bind(this), function(error) {}.bind(this)); } } function loadGeolocationCountry() { navigator.geolocation.getCurrentPosition(function(position) { var geocoder = new google.maps.Geocoder(); var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); geocoder.geocode({ 'latLng': latlng }, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { if (results[0]) { var loc = getCountry(results); searchLocation(loc); } } }); }); searchLocation(null); } function getCountry(results) { for (var i = 0; i < results[0].address_components.length; i++) { var shortname = results[0].address_components[i].short_name; var longname = results[0].address_components[i].long_name; var type = results[0].address_components[i].types; if (type.indexOf("country") != -1) { if (!isNullOrWhitespace(shortname)) { return shortname; } else { return longname; } } } return null; } function isNullOrWhitespace(text) { if (text == null) { return true; } return text.replace(/\s/gi, '').length < 1; } function searchLocation(currentCountry = null) { if (marker_search != null) marker_search.setMap(null); if(infowindow) infowindow.close(); document.getElementById("loading_mask_loader").style.display = ''; jQuery('.content-results-slt').removeClass('content-results-first'); var address = document.getElementById("address").value; var radius_search = document.getElementById("radius_search").value; var checkboxes = document.getElementsByName('stores_tags_filter[]'); var vals = ""; for (var i = 0, n = checkboxes.length; i < n; i++) { if (checkboxes[i].checked) { vals += "," + checkboxes[i].value; } } if ((address == '' || address == null) && vals == "") { //alert(trans['please_enter']); jQuery('#address').focus(); document.getElementById("loading_mask_loader").style.display = 'none'; return false; } if ((radius_search == '' || radius_search == null) && vals == "") { //alert('Please enter a radius.'); document.getElementById("loading_mask_loader").style.display = 'none'; return false; } var focus_country = { address: address }; if (currentCountry != null) { focus_country = { address: address, componentRestrictions: { country: currentCountry, } }; } if (priority_search != 'global') { focus_country = { address: address, componentRestrictions: { country: priority_search, } }; } var geocoder = new google.maps.Geocoder(); geocoder.geocode(focus_country, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { var latlng = new google.maps.LatLng(results[0].geometry.location.lat(), results[0].geometry.location.lng()); marker_search = new google.maps.Marker({ map: map, position: latlng, icon: { url: 'https://maps.google.com/mapfiles/ms/icons/green-dot.png', scaledSize: new google.maps.Size(20, 20) }, }); google.maps.event.addListener(marker_search, 'click', function(evt) { // the click event function is called with the "event" as an argument //showInfoWindow(evt, this, map, infowindow, address); }); // markers.push(marker); searchLocationsNear(results[0], map, bounds, gmarkers,address) // searchLocationsNear(results[0].geometry.location); } else { if (currentCountry == null) { document.getElementById("loading_mask_loader").style.display = 'none'; jQuery('#results-empty').html('
' + address + '' + storelocator_lang.address_null + '
'); } else { searchLocation(null); } } }); } function findbyTags() { if (marker_search != null) marker_search.setMap(null); if(infowindow) infowindow.close(); bounds = new google.maps.LatLngBounds(); var tags_check = []; jQuery.each(jQuery('input.storeifyapp_stores_tags_filter:checked'), function() { tags_check.push(jQuery(this).val()); }); var filter_country = 'all',filter_region = 'ify_all',filter_city = 'ify_all'; if (jQuery('input.storeifyapp_stores_country_filter').length) { filter_country = jQuery('input.storeifyapp_stores_country_filter:checked').val(); } if (jQuery('input.storeifyapp_stores_region_filter').length) { filter_region = jQuery('input.storeifyapp_stores_region_filter:checked').val(); } if (jQuery('input.storeifyapp_stores_city_filter').length) { filter_city = jQuery('input.storeifyapp_stores_city_filter:checked').val(); } if(jQuery('.storeifyapp_stores_countrys_filter_list').data('tag') == 'select'){ filter_country = jQuery('select.storeifyapp_stores_country_filter').val(); } if(jQuery('.storeifyapp_stores_region_filter_list').data('tag') == 'select'){ filter_region = jQuery('select.storeifyapp_stores_region_filter').val(); } if(jQuery('.storeifyapp_stores_city_filter_list').data('tag') == 'select'){ filter_city = jQuery('select.storeifyapp_stores_city_filter').val(); } if(filter_region == 'unnamed_region') filter_region = ''; if(filter_city == 'unnamed_city') filter_city = ''; var check_country = 0; var marker_first; var marker_count = 0; var array_poin = []; var html_list = ''; for (var i = 0; i < gmarkers.length; i++) { // console.log( markerNodes[i]['tags'] ); marker = gmarkers[i]; check_country = 0; if ( (filter_country == 'all' || filter_country == marker.country) && (filter_region == 'ify_all' || filter_region == marker.region) && (filter_city == 'ify_all' || filter_city == marker.city) ) { check_country = 1; } if (checkTag(tags_check, marker.tags) && check_country == 1) { thum = null; if (typeof marker.thum !== 'undefined') { thum = marker.thum; } var id = marker.id; var name = marker.name; var url = marker.url; var address = marker.address; var phone = marker.phone; var email = marker.email; var web = marker.web; var tags = marker.tags; var social = marker.social; var num = marker.num; bounds.extend(marker.getPosition()); marker.setVisible(true); marker_first = marker; marker_count++; if(ify_layout != 8) html_list += listItem(social, thum, id, name, url, address, phone, email, web, null, tags, num); } else { marker.setVisible(false); } } map.fitBounds(bounds); document.getElementById("loading_mask_loader").style.display = 'none'; if(ify_layout != 8) document.getElementById("num-rs").innerHTML = marker_count; //jQuery("#results-slt h3.title").show(); jQuery("#main-slider-storelocator").removeClass('storeify-first-alert'); if (marker_count > 0) { if(marker_count == 1){ map.setCenter(marker_first.getPosition()); map.setZoom(search_result_zoom); }else{ var zoom = map.getZoom(); zoom = Math.min(zoom, 12); map.setZoom(zoom); } jQuery("#storeify-text-result").text(jQuery("#storeify-text-result").data('results')); jQuery('#' + randomID).html(html_list); } if (marker_count == 0) { jQuery("#results-slt").hide(); var address = document.getElementById("address").value; jQuery("#storeify-text-result").text(jQuery("#storeify-text-result").data('result')); jQuery('#results-empty').html('
' + storelocator_lang.store_near + '"' + address + '"
'); return; } jQuery('#results-empty').html('
'); jQuery("#results-slt").show(); } //---------//end code here var blackList; jQuery('body').each(function() { replacer('\\[storeify-storelocator\\]', jQuery(this).get(0), blackList, 1); replacer('\\[storeify-storelocator-short\\]', jQuery(this).get(0), blackList, 2); }); var arrLangmap = { 'location' : storelocator_lang.location, 'product_name' : storelocator_lang.product_name, 'store_name' : storelocator_lang.store_name, 'type_to_search' : storelocator_lang.type_to_search, 'use_my_location' : storelocator_lang.use_my_location, 'search_product' : storelocator_lang.search_product, 'search_store' : storelocator_lang.search_store, 'radius_2' : storelocator_lang.radius_2, 'kilometers' : storelocator_lang.kilometers, 'miles' : storelocator_lang.miles, 'radius_1' : storelocator_lang.radius_1, 'filter' : storelocator_lang.filter, 'search' : storelocator_lang.search, 'reset' : storelocator_lang.reset, 'list' : storelocator_lang.list, 'map' : storelocator_lang.map, 'store_list' : storelocator_lang.store_list, 'result' : storelocator_lang.result, 'results' : storelocator_lang.results, }; jQuery.each(arrLangmap, function( key, val ) { html_reponse = html_reponse.replaceAll("{{ "+key+" }}", val); }); jQuery('.storeifyapps-storelocator-shortcode').html(html_reponse); if (jQuery('.storeifyapps-storelocator-short').length) { jQuery('.storeifyapps-storelocator-short').html(html_reponse_short); } storelocator_tags_response = storelocator_tags_response.replaceAll("{{ filter_tags }}",storelocator_lang.filter_tags); storelocator_country = storelocator_country.replaceAll("{{ all }}",storelocator_lang.all); storelocator_country = storelocator_country.replaceAll("{{ filter_country }}",storelocator_lang.filter_country); storelocator_country = storelocator_country.replaceAll("{{ select_country }}",storelocator_lang.select_country); jQuery('#tags').html(storelocator_tags_response); jQuery('#country_html').html(storelocator_country); if(ify_filter_region_city == 1){ renderDefaultRegion(); } if(storelocator_tags_response == '' && jQuery('#stores-country-filter').length <= 0 ){ jQuery('#btn-filter').hide(); } if (jQuery('.storeifyapps-storelocator-equal').length) { jQuery('#frm-storelocator-search #map').css("height", (jQuery('.storeify-sear-box').outerHeight() + 540) + "px"); } if (list_mode == 2 || limit_store == 0) { jQuery("#results-slt h3.title").hide(); jQuery("#main-slider-storelocator").addClass('storeify-first-alert'); } // tao Region khi chi co 1 country function renderDefaultRegion(){ let currentCountry = jQuery('.storeifyapp_stores_country_filter').val(); if(jQuery('select.storeifyapp_stores_country_filter').length) currentCountry = jQuery('select.storeifyapp_stores_country_filter').val(); else currentCountry = jQuery('input.storeifyapp_stores_country_filter:checked').val(); if(currentCountry == 'all') return true; let arrValueRegion = []; if(currentCountry !== 'all'){ jQuery('#stores-city-filter').html('').hide(); if(typeof ifyArr_country_region_city[currentCountry] !=='undefined'){ arrValueRegion = Object.keys(ifyArr_country_region_city[currentCountry]); if(arrValueRegion.length == 1){ let currentRegion = arrValueRegion[0]; let arrValueCity = []; if(typeof ifyArr_country_region_city[currentCountry][currentRegion] !=='undefined'){ arrValueCity = ifyArr_country_region_city[currentCountry][currentRegion]; } renderFilter(arrValueCity,'city',Number(ify_mode_filtercountry)); } } renderFilter(arrValueRegion,'region',Number(ify_mode_filtercountry)); }else{ jQuery('#stores-region-filter').html('').hide(); jQuery('#stores-city-filter').html('').hide(); } } function setMapOnAll(map) { for (let i = 0; i < gmarkers.length; i++) { gmarkers[i].setVisible(false); } } // window.onload = initMap; function checkMapLoaded() { //console.log(dataApps.permanent_domain); if (typeof google === "undefined") { setTimeout(checkMapLoaded, 500); } else { // do some work here initMap(); } } var loadTime = 3; var loadTime2 = 1; if(dataApps.permanent_domain == 'audittesting.myshopify.com' || dataApps.permanent_domain == 'al-test-my.myshopify.com'){ loadTime = 3000; loadTime2 = 1000; } setTimeout(() => { const sl_idex = document.getElementById('storeifyapps-storelocator-index'); if (sl_idex) { sl_idex.style.opacity = '1'; sl_idex.style.transform = 'translateY(0)'; } else { console.warn('Not found: #storeifyapps-storelocator-index'); } //jQuery('#sl-tab-list').trigger('click'); }, loadTime2); jQuery( document ).ready(function() { //window.addEventListener('load', () => { let mapLoaded = false; const mapElement = document.getElementById("map"); if(mapElement){ function loadGoogleMapScript() { if (mapLoaded) return; const script = document.createElement("script"); script.src = window.api_key; script.defer = true; document.head.appendChild(script); mapLoaded = true; } const isMobile = window.innerWidth <= 992; if (isMobile){ const onMobileScroll = () => { console.log('Scroll lần đầu trên mobile!'); // Ví dụ: chỉ load Google Map sau lần scroll đầu tiên loadGoogleMapScript(); console.log( "Storeify SL loaded" ); if(!map && typeof dataApps.detail == 'undefined') checkMapLoaded(); // Xoá listener để tránh chạy lại window.removeEventListener('scroll', onMobileScroll); }; window.addEventListener('scroll', onMobileScroll); }else{ setTimeout(() => { if (!window.mapLoaded) { loadGoogleMapScript(); window.mapLoaded = true; console.log("Storeify SL loaded"); if (!map && typeof dataApps.detail == 'undefined') checkMapLoaded(); } }, loadTime); } jQuery(document).on("click", "#storeify-sl-btn-trigger-popup", function(e) { //if (!window.mapLoaded) { loadGoogleMapScript(); //window.mapLoaded = true; console.log("Storeify SL loaded"); if (!map && typeof dataApps.detail == 'undefined') checkMapLoaded(); //} }); } }); jQuery('#radius_search').on("change mousemove", function() { jQuery('#radius-value .num-range').html(jQuery(this).val()); }); jQuery(document).on("click", ".storelocator-submit-search", function(e) { e.preventDefault(); jQuery('#results-empty').html('
'); if (jQuery('.chose-search-slt').val() == 'location') { if (search_mode == 1) loadGeolocationCountry(); else searchLocation(null); } if (jQuery('.chose-search-slt').val() == 'product') { searchStoresByProducts(); } if (jQuery('.chose-search-slt').val() == 'store') { searchStoresByName(); } return 0; }); jQuery(document).on('click', '#reset-search', function(e) { e.preventDefault(); // console.log('111'); if (marker_search != null) marker_search.setMap(null); if(infowindow) infowindow.close(); jQuery('#results-empty').html('
'); jQuery('#address,#product_search').val(''); jQuery('#radius_search').val(radius_default); jQuery('.num-range').html(radius_default); jQuery(".storeifyapp_stores_tags_filter").prop("checked", false); if(jQuery("input[name=stores_country_filter]").length){ jQuery("input[name=stores_country_filter]:first").prop("checked", true).trigger("change"); } if(jQuery("select[name=stores_country_filter]").length){ jQuery("select[name=stores_country_filter]").val($("select[name=stores_country_filter] option:first").val()).trigger("change"); } // if(ify_filter_region_city == 1) // jQuery("#stores-region-filter,#stores-city-filter").html('').hide(); var count_marker = 0; for (var i = 0; i < gmarkers.length; i++) { marker = gmarkers[i]; if (list_mode != 1 || (list_mode == 1 && i < limit_store)) { gmarkers[i].setVisible(true); bounds.extend(marker.getPosition()); count_marker++; } else { gmarkers[i].setVisible(false); } } if (count_marker > 1) { jQuery("#storeify-text-result").text(jQuery("#storeify-text-result").data('results')); } else { jQuery("#storeify-text-result").text(jQuery("#storeify-text-result").data('result')); } if(ify_layout != 8) document.getElementById("num-rs").innerHTML = count_marker; //jQuery("#results-slt h3.title").show(); jQuery("#main-slider-storelocator").removeClass('storeify-first-alert'); if (center_lat == 0 && center_lng == 0) { map.fitBounds(bounds); } else { map.setZoom(initial_zoom); map.setCenter(new google.maps.LatLng(center_lat, center_lng)); } if (list_mode == 2 && limit_store == 0) { jQuery("#results-slt h3.title").hide(); jQuery("#main-slider-storelocator").addClass('storeify-first-alert'); } jQuery("#results-slt").show(); jQuery('#' + randomID).html(html_list); document.getElementById("loading_mask_loader").style.display = 'none'; }); jQuery(document).on('mouseover', '.inner-item', function() { onMouseover(jQuery(this).parent().attr("datamarker")); }); jQuery(document).on('mouseout', '.inner-item', function() { onMouseover(jQuery(this).parent().attr("datamarker")); }); jQuery(document).on('click', '.inner-item', function() { jQuery('#main-slider-storelocator .inner-item').removeClass('inner-item-active'); jQuery(this).addClass('inner-item-active'); num = jQuery(this).parent().attr("datamarker"); google.maps.event.trigger(gmarkers[num], 'click'); }); jQuery('.storeify-modal-elon .storeify-close').on("click", function() { jQuery(this).parent().parent().parent().hide(); }); jQuery('.chose-search-slt').on("change", function() { if (jQuery(this).val() == 'location') { jQuery('.input-radius-slt').parent().show(); jQuery('.gr-search-slt').show(); //jQuery('.input-attribute-slt').hide(); jQuery('#product_search').hide(); jQuery('#store_search').hide(); } if (jQuery(this).val() == 'product') { jQuery('.input-radius-slt').parent().hide(); //jQuery('.input-attribute-slt').show(); jQuery('#store_search').hide(); jQuery('.gr-search-slt').hide();; jQuery('#product_search').show(); } if (jQuery(this).val() == 'store') { jQuery('.input-radius-slt').parent().hide(); //jQuery('.input-attribute-slt').show(); jQuery('.gr-search-slt').hide(); jQuery('#product_search').hide(); jQuery('#store_search').show(); } }); function renderFilter(arrValue = [],option='region',mode = 1) { if(mode == 2){ if(arrValue.length > 0){ let html = ''; console.log('change render 7 >', html) jQuery('#stores-'+option+'-filter').html(html).show(); }else{ jQuery('#stores-'+option+'filter').html('').hide(); } }else{ if(arrValue.length > 0){ let html = '
    '; if(arrValue.length > 1){ html += '
  • '; jQuery.each(arrValue, function( index, value ) { html += '
  • '; }); }else{ html += '
  • '; } html += '
'; jQuery('#stores-'+option+'-filter').html(html).show(); }else{ jQuery('#stores-'+option+'filter').html('
').hide(); } } } jQuery(document).on('change', '.storeifyapp_stores_country_filter,.storeifyapp_stores_region_filter,.storeifyapp_stores_city_filter,.storeifyapp_stores_tags_filter', function(e) { e.preventDefault(); jQuery('#loading_mask_loader').show(); jQuery("#storeify-liststore-result").html(''); if(ify_filter_region_city == 1){ if(jQuery(this).hasClass('storeifyapp_stores_country_filter')){ console.log('change render 3') let currentCountry = jQuery(this).val(); let arrValueRegion = []; if(currentCountry !== 'all'){ jQuery('#stores-city-filter').html('').hide(); if(typeof ifyArr_country_region_city[currentCountry] !=='undefined'){ arrValueRegion = Object.keys(ifyArr_country_region_city[currentCountry]); if(arrValueRegion.length == 1){ let currentRegion = arrValueRegion[0]; let arrValueCity = []; if(typeof ifyArr_country_region_city[currentCountry][currentRegion] !=='undefined'){ arrValueCity = ifyArr_country_region_city[currentCountry][currentRegion]; } renderFilter(arrValueCity,'city',Number(ify_mode_filtercountry)); } } renderFilter(arrValueRegion,'region',Number(ify_mode_filtercountry)); }else{ jQuery('#stores-region-filter').html('').hide(); jQuery('#stores-city-filter').html('').hide(); } } if(jQuery(this).hasClass('storeifyapp_stores_region_filter')){ let currentCountry = 'all'; if(Number(ify_mode_filtercountry) == 2) currentCountry = jQuery('select.storeifyapp_stores_country_filter').val(); else currentCountry = jQuery('input.storeifyapp_stores_country_filter:checked').val(); let currentRegion = jQuery(this).val(); let arrValueCity = []; if(currentRegion !== 'ify_all'){ if(typeof ifyArr_country_region_city[currentCountry][currentRegion] !=='undefined'){ arrValueCity = ifyArr_country_region_city[currentCountry][currentRegion]; } renderFilter(arrValueCity,'city',Number(ify_mode_filtercountry)); }else{ jQuery('#stores-city-filter').html('').hide(); } } } setTimeout(function() { if (jQuery('.chose-search-slt').val() == 'location') { if (jQuery('#frm-storelocator-search #address').val() != '') { if (search_mode == 1) loadGeolocationCountry(); else searchLocation(null); } else { findbyTags(); } } if (jQuery('.chose-search-slt').val() == 'product') { if (jQuery('#frm-storelocator-search #product_search').val() != '') { searchStoresByProducts(); } else { findbyTags(); } } if (jQuery('.chose-search-slt').val() == 'store') { if (jQuery('#frm-storelocator-search #store_search').val() != '') { searchStoresByName(); } else { findbyTags(); } } }, 100); }); jQuery(document).on('click', '#getbylocal', function() { loadGeolocation(); }); jQuery(document).on('click', '.map-tab-mobile-bnt-item', function(e) { if (jQuery(this).hasClass('active') && jQuery(this).data('val') == 'map-tab-ggmap' && jQuery(this).data('zoom')) { console.log(jQuery(this).data('zoom')); map.setZoom(jQuery(this).data('zoom')); } }); jQuery(document).on("submit","#frm-storelocator-short-search",function(e) { e.preventDefault(); document.getElementById("loading_mask_loader").style.display = ''; var address = document.getElementById("address").value; var radius_search = document.getElementById("radius_search").value; if ((address == '' || address == null) && vals == "") { //alert(trans['please_enter']); jQuery('#address').focus(); document.getElementById("loading_mask_loader").style.display = 'none'; return false; } if ((radius_search == '' || radius_search == null) && vals == "") { //alert('Please enter a radius.'); document.getElementById("loading_mask_loader").style.display = 'none'; return false; } var focus_country = {address: address}; if(priority_search != 'global'){ focus_country = {address: address,componentRestrictions:{country: priority_search,}}; } var geocoder = new google.maps.Geocoder(); geocoder.geocode(focus_country, function (results, status) { jQuery('#results-empty').html(''); if (status == google.maps.GeocoderStatus.OK) { searchLocationsNearShort(results[0]); } else { document.getElementById("loading_mask_loader").style.display = 'none'; document.getElementById("storeify-storeloctor-contactFrm").style.display = 'block'; if(ify_layout != 8) document.getElementById("num-rs").innerHTML = 0; jQuery("#storeify-text-result").text(jQuery("#storeify-text-result").data('result')); jQuery('#results-slt .list-custo-storeify').html(''); jQuery('#results-empty').html('
'+storelocator_lang.store_near +'"'+ address+'"
'); } }); }); jQuery(document).on("keydown","#frm-storelocator-search input",function(e) { if (e.which == 13) { e.preventDefault(); jQuery(".storelocator-submit-search").trigger("click"); } }); jQuery(document).on('click', '.linkdetailstore', function(e) { e.preventDefault(); let href = jQuery(this).attr("href"); href = href.replace('//'+dataApps.shopify_domain, ''); if(root_url != '/') href = root_url + href; window.location.href = href; }); // jQuery(document).ready(function() { jQuery(document).on("click","#storeify-sl-btn-trigger-popup",function(e) { e.preventDefault(); jQuery("#storeify-sl-light-modal-wrapper").addClass('show'); if(jQuery("#storeify-sl-light-modal-wrapper").find('.storeify-sear-box').length){ h = jQuery("#storeify-sl-light-modal-wrapper").find('.storeify-sear-box').height()+540; jQuery('#map').height(h); } jQuery("#reset-search").trigger("click"); }); jQuery(document).on("click",".storeify-sl-light-modal-close-icon",function(e) { e.preventDefault(); jQuery("#storeify-sl-light-modal-wrapper").removeClass('show'); }); jQuery(document).on("click","#btn-filter",function(e) { e.preventDefault(); if(!jQuery(this).hasClass('open')){ jQuery(this).addClass('open'); jQuery(this).next().addClass('open'); h = jQuery('#filter-group').height(); h2 = jQuery('#main-slider-storelocator').height(); w = jQuery( window ).width(); if(w > 720){ jQuery('#main-slider-storelocator').height(h2-h); } }else{ h = jQuery('#filter-group').height(); h2 = jQuery('#main-slider-storelocator').height(); if(w > 720 && h2 < 450){ jQuery('#main-slider-storelocator').height(h2+h); } jQuery(this).removeClass('open'); jQuery('#filter-group').removeClass('open'); } }); jQuery(document).on('click', '.table-store-marker .ify-col-schedule .title-store-info', function(e) { e.preventDefault(); if(jQuery('.table-store-marker .ify-col-schedule').hasClass( "active" )){ jQuery('.table-store-marker .ify-col-schedule').removeClass( "active" ) }else{ jQuery('.table-store-marker .ify-col-schedule').addClass( "active" ) } }); }); if(document.getElementById('storeify-detail-store')) { function checkMapLoadDetail(){ if (typeof google == "undefined") { setTimeout(checkMapLoadDetail); } else { initialize(); } } var storeify_detail = dataApps.storeify_detail; var detail_zoom = dataApps.detail_zoom; var layout = dataApps.layout; var icon_marker = dataApps.icon_marker; var directionsDisplay; var directionsService; var map_detail; var street_view; var panorama; var markers = {}; var infoWindow_detail; var red_icon = 'http://maps.google.com/mapfiles/ms/icons/red-dot.png'; var purple_icon = 'http://maps.google.com/mapfiles/ms/icons/purple-dot.png'; checkMapLoadDetail(); function initialize() { var lat = storeify_detail.lat; var lng = storeify_detail.lng; var address = storeify_detail.address, directionsDisplay = new google.maps.DirectionsRenderer(); directionsService = new google.maps.DirectionsService(); var storeLatlng = new google.maps.LatLng(lat, lng); var ViewControl = true; var styledMapType = new google.maps.StyledMapType(JSON.parse(B64.decode(map_style_render))); if (layout == 2) ViewControl = false; map_detail = new google.maps.Map(document.getElementById("map"), { center: storeLatlng, zoom: detail_zoom, mapTypeId: 'roadmap', mapTypeControl: false, mapTypeControlOptions: { style: google.maps.MapTypeControlStyle.DROPDOWN_MENU }, streetViewControl: ViewControl }); map_detail.mapTypes.set('styled_map', styledMapType); map_detail.setMapTypeId('styled_map'); directionsDisplay.setMap(map_detail); directionsDisplay.setPanel(document.getElementById('directions-panel')); var control = document.getElementById('store-info-popup'); //control.style.display = 'block'; map_detail.controls[google.maps.ControlPosition.TOP_RIGHT].push(control); if (address.length != 0) { if (icon_marker != '') { var icon = { url: icon_marker, // url scaledSize: new google.maps.Size(40, 40), // scaled size // origin: new google.maps.Point(0,0), // origin // anchor: new google.maps.Point(0, 0) // anchor }; marker = new google.maps.Marker( { position: storeLatlng, map: map_detail, title: address, icon: icon }); } else { marker = new google.maps.Marker( { position: storeLatlng, map: map_detail, title: address }); } } infoWindow_detail = new google.maps.InfoWindow(); locationDiv = document.getElementById("storeify_location"); if(!locationDiv) locationDiv = document.getElementById("location"); var searchBox = new google.maps.places.SearchBox(document.getElementById('start')); var panoramaOptions = { position: storeLatlng, pov: { heading: 34, pitch: 10 } }; if (layout == 1) { street_view = new google.maps.StreetViewPanorama(document.getElementById('street_view'), panoramaOptions); map_detail.setStreetView(street_view); document.getElementById('street_view').style.display = 'block'; } else { //layout 2 panorama = map_detail.getStreetView(); panorama.setPosition(storeLatlng); panorama.setPov( /** @type {google.maps.StreetViewPov} */ ( { heading: 265, pitch: 0 })); } /*var addMarker = google.maps.event.addListener(map_detail, 'click', function (e) { closeAllInfoWindow(); var lat = e.latLng.lat(); // lat of clicked point var lng = e.latLng.lng(); // lng of clicked point var markerId = getMarkerUniqueId(lat, lng); // an that will be used to cache this marker in markers object. var geocoder = new google.maps.Geocoder; var marker; var html = ''; if (icon_marker != '') { var icon = { url: window.icon_marker, // url scaledSize: new google.maps.Size(40, 40), // scaled size // origin: new google.maps.Point(0,0), // origin // anchor: new google.maps.Point(0, 0) // anchor }; var marker = new google.maps.Marker( { position: getLatLng(lat, lng), map: map_detail, animation: google.maps.Animation.DROP, id: 'marker_' + markerId, icon: icon }); } else { var marker = new google.maps.Marker( { position: getLatLng(lat, lng), map: map_detail, animation: google.maps.Animation.DROP, id: 'marker_' + markerId, }); } geocoder.geocode( { 'location': getLatLng(lat, lng) }, function (results, status) { // console.log(results); if (status === 'OK') { if (results[0]) { // console.log(results); html += '
'; html += '' + results[0].formatted_address + ''; html += '
'; marker.html = html; markers[markerId] = marker; // cache marker in markers object infoWindow_detail = new google.maps.InfoWindow(); infoWindow_detail.setContent(html); infoWindow_detail.open(map_detail, marker); } else { window.alert("{{ addslashes(__('no_result')) }}"); } } else { window.alert("{{ addslashes(__('geocoder_failed')) }}" + status); } }); bindMarkerinfo(marker); bindMarkerEvents(marker); // bind right click event to marker });*/ }; var getMarkerUniqueId = function (lat, lng) { return lat + '_' + lng; }; var getLatLng = function (lat, lng) { return new google.maps.LatLng(lat, lng); }; function closeAllInfoWindow() { if (typeof info_window != 'undefined') { info_window.close(); } if (typeof infoWindow_detail != 'undefined') { infoWindow_detail.close(); } } /** * Binds click event to given marker and invokes a callback function that will remove the marker from map. * @param {!google.maps.Marker} marker A google.maps.Marker instance that the handler will binded. */ /*var bindMarkerinfo = function (marker) { google.maps.event.addListener(marker, "click", function (point) { closeAllInfoWindow(); var markerId = getMarkerUniqueId(point.latLng.lat(), point.latLng.lng()); // get marker id by using clicked point's coordinate var marker = markers[markerId]; // find marker infoWindow_detail = new google.maps.InfoWindow(); infoWindow_detail.setContent(marker.html); infoWindow_detail.open(map_detail, marker); // removeMarker(marker, markerId); // remove it }); };*/ /** * Binds right click event to given marker and invokes a callback function that will remove the marker from map. * @param {!google.maps.Marker} marker A google.maps.Marker instance that the handler will binded. */ /*var bindMarkerEvents = function (marker) { google.maps.event.addListener(marker, "rightclick", function (point) { var markerId = getMarkerUniqueId(point.latLng.lat(), point.latLng.lng()); // get marker id by using clicked point's coordinate var marker = markers[markerId]; // find marker removeMarker(marker, markerId); // remove it }); }; var removeMarker = function (marker, markerId) { marker.setMap(null); // set markers setMap to null to remove it from map delete markers[markerId]; // delete marker instance from markers object }; jQuery(document).on('click', '#bntDirection', function () { var start = document.getElementById('start').value; var selectedMode = document.getElementById('mode').value; var request = { origin:start, destination:storeify_detail.address, travelMode: google.maps.TravelMode[selectedMode], unitSystem: google.maps.UnitSystem.METRIC }; directionsService.route(request, function(response, status) { if (status == google.maps.DirectionsStatus.OK) { directionsDisplay.setDirections(response); } }); });*/ jQuery(document).on('click', '#toggleStreetView', function () { var toggle = panorama.getVisible(); if (toggle == false) { panorama.setVisible(true); } else { panorama.setVisible(false); } }); jQuery(document).on("click","#bntContactsubmit",function(e){ e.preventDefault(); jQuery("#storeify-contactForm .field__input ").prop('readonly', true); jQuery.ajaxSetup({ headers: { 'X-CSRF-TOKEN': jQuery('input[name="_token"]').val() } }); var data = jQuery('#storeify-contactForm').serialize(); jQuery.ajax({ url: storeify_app_proxy_url + '/send-ajax', type: "GET", data: data, cache: false, dataType: "json", }).done(function(results) { //storeify-alert jQuery("#storeify-contactForm .field__input ").prop('readonly', false); if(results.error == true){ jQuery('#storeify-contactForm .storeify-success').hide(); if(typeof results.mess == 'object') jQuery('#storeify-contactForm .storeify-alert').html('* Required Fields'); else jQuery('#storeify-contactForm .storeify-alert').html(results.mess); jQuery('#storeify-contactForm .storeify-alert').show(); }else{ jQuery('#storeify-contactForm .storeify-alert').hide(); jQuery('#storeify-contactForm .storeify-success').html(results.mess).show(); jQuery('.storeify-storelocator-hidden').css("visibility","hidden"); jQuery('#storeify-contactForm .storeify-alert,#storeify-contactForm .storeify-modal-footer').hide(); } }).fail(function() { }); }); jQuery(document).on("click",".storelocator-paged .page-item",function(e){ e.preventDefault(); jQuery('.storeify-list-product').addClass('load-ajax'); var id = jQuery('.storelocator-paged').data('id'); var count = jQuery('.storelocator-paged').data('count'); var page = 1; var btnClick = jQuery(this).data('page'); var current = jQuery('.storelocator-paged .page-item-btn.active').data('page'); if(btnClick != 'next' && btnClick != 'pre'){ page = btnClick; } if(btnClick == 'next'){ page = current + 1; } if(btnClick == 'prev'){ page = current - 1; } jQuery('.storelocator-paged .page-item').removeClass('active'); jQuery('.storelocator-paged .page-item-'+page).addClass('active'); if(page > 1 && page < count){ jQuery('.storelocator-paged .page-control').addClass('active'); } if(page == 1){ jQuery('.storelocator-paged .page-next').addClass('active'); } if(page == count){ jQuery('.storelocator-paged .page-pre').addClass('active'); } jQuery.ajax({ url: storeify_app_proxy_url + '/load-page', type: "GET", data: {id:id,page:page}, cache: false, dataType: "html", }).done(function(results) { //storeify-alert jQuery( "div.content-store-products" ).scrollTop( 0 ); jQuery([document.documentElement, document.body]).animate({ scrollTop: jQuery("div.storeify-list-product").offset().top }, 500); jQuery('.storeify-list-product').removeClass('load-ajax'); jQuery('.content-store-products .storeify-flex').html(results) }).fail(function() { jQuery('.storeify-list-product').removeClass('load-ajax'); }); }); jQuery(document).on('click', '.storeify-sl-details .back-stores a', function(e) { e.preventDefault(); let href = jQuery(this).attr("href"); href = href.replace('https://'+dataApps.shopify_domain, ''); href = href.replace('https://'+dataApps.permanent_domain, ''); if(root_url != '/') href = root_url + href; window.location.href = href; }); } //end detail }; //end storeifyappsJavaScript if (typeof jQuery == 'undefined' || typeof jQuery.fn.on == 'undefined'){ loadScript('//code.jquery.com/jquery-3.4.1.min.js', function() { storeifyAPPS = jQuery.noConflict(true); storeifyAPPS(document).ready(function() { storeifyappsJavaScript(storeifyAPPS); }); }); } else { storeifyappsJavaScript(jQuery); } })();