From 2e6db44bd2adee20f4af521a8b2ad2a34e089b78 Mon Sep 17 00:00:00 2001 From: "pawel.gaca" Date: Fri, 12 Jan 2024 14:58:22 +0100 Subject: [PATCH] =?UTF-8?q?Ostateczne=20poprawki=20kodu,=20zalogowanego=20?= =?UTF-8?q?u=C5=BCytkownika,=20sk=C5=82adania=20zam=C3=B3wienia,=20zatwier?= =?UTF-8?q?dzania=20niekt=C3=B3rych=20input=C3=B3w=20enterem?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 50 +- customMarkerMap.js | 31 - ikony/facebook_icon.png | Bin 0 -> 817 bytes ikony/google_icon.png | Bin 0 -> 913 bytes ikony/linkedin_icon.png | Bin 0 -> 486 bytes ikony/paypal_icon.png | Bin 0 -> 771 bytes index.xslt | 874 +++++++--------- mapy/oneMap.css | 16 + mapy/oneMap.js | 2183 +++++++++++++++++++++++++++++++++++++++ normalMarkerMap.js | 1 - style.css | 110 +- wydzielonyScript.js | 1053 ++++++++++--------- 12 files changed, 3210 insertions(+), 1108 deletions(-) delete mode 100644 customMarkerMap.js create mode 100644 ikony/facebook_icon.png create mode 100644 ikony/google_icon.png create mode 100644 ikony/linkedin_icon.png create mode 100644 ikony/paypal_icon.png create mode 100644 mapy/oneMap.css create mode 100644 mapy/oneMap.js delete mode 100644 normalMarkerMap.js diff --git a/README.md b/README.md index bf65e6e..5beddf3 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,49 @@ # OSCOP # -Pliki związane z OSCOP. Żeby działał trzeba stworzyć kopie jednego komponenta z place-order i resztę usunąć. Następnie wkleić kod w odpowiednie miejsca w skopiowanym komponencie. +Pliki związane z OSCOP. Żeby działał trzeba stworzyć kopie jednego komponenta z place-order(testowane na komponencie układ) i resztę usunąć. Następnie wkleić kod w odpowiednie miejsca w skopiowanym komponencie: +index.xslt w XML/XSLT\ +wydzielonyScript.js w Wydzielony Javascript\ +script.js w Javascript\ +style.css w Less/CSS\ +Dodatkowo Trzeba będzie zrobić przekierowanie (można nawet dodatkiem) po kliknięciu na "Przejdź dalej" do strony "place-order.php" -## Mapa ## -Plik normalMarkerMap zawiera wersje mapy gdzie wszystkie markery są podstawowe(niebieskie). -Jest też plik customMarkerMap, który pozwala na wstawienie customowych markerów na mapie dostaw. Jest w tej chwili dodany w pliku wydzielonyScript. +## Ikony markera na mapie ## +Aby dodać zdjęcie ikony: moderacja -> cms -> Zarządzanie plikami dla CMS. Żeby dodać nową ikonę trzeba dodać nowy obiekt w mapMarkerUrls. Można do tam wybrać link url do ikony, rozmiar, klasę. Dodatkowe opcje znajdują się w dokumentacji Leaflet w opcjach markera: https://leafletjs.com/reference.html#marker -### Ikony markera na mapie ### -Aby dodać nową ikonę trzeba dodać nowy obiekt w mapMarkerUrls. Można do tam wybrać link url do ikony, rozmiar, klasę. Dodatkowe opcje znajdują się w dokumentacji Leaflet w opcjach markera: https://leafletjs.com/reference.html#marker +## Wszystkie punkty odbioru na jednej mapie ## +Plik oneMap.js zawiera kod, który wyszykuje na jednej mapie wszystkie punkty odbioru. Póki co nie ma tam jeszcze jednej metody dostawy(np.: wyszukaj na mapie) tylko klikając np na inpost pokażą się też punkty odbioru innych dostawców. Plik oneMap.css zawiera jenynie stylizacje dwóch klas które należy dołączyć do kodu z pliku style.css ## Ikony facebook, google, linkedin, paypal ## Aby je zmienić trzeba wejść w panel -> moderacja -> działanie sklepu -> Panel klienta i Proces Składania Zamówienia (COP) -> sposoby logowania -Następnie wejść w edycje wybranego sposobu logowania i wrzucić nową ikonę. \ No newline at end of file +Następnie wejść w edycje wybranego sposobu logowania i wrzucić nową ikonę w miejsce "Grafika mała na stronie". UWAGA! Plików svg nie da się wprowadzić. + +## Brakujące Tłumaczenia (literały) ## +Trzeba je później podmienić w kodzie w Wydzielonym Java script na np.:\ + + +### Wydzielony Javascript ### +Pokaż Listę\ +Pokaż Mapę\ +Błąd podczas zmiany kraju. Przeładuj stronę jeszcze raz.\ +Błąd podczas logowania, proszę spróbować ponownie\ +banków\ +kart płatniczych\ +Lista\ +Wybierz z\ + +## Zalety ## +Zablokowana edycja danych osobowych w trakcie zamówienia(klient dalej może wysłać zamówienie na inny adres).\ +Zmiana sposobów dostaw zależnie od państwa(Czasami się buguje, może to być zależne od plików cookies)\ +Sprawdzenie czy wpisano dobry bon towarowy przed złożeniem zamówienia\ +lepiej zabezpieczony numer telefonu?(na standardzie to +2+++++++++1 przejdzie)\ +autouzupełnianie metod płatności i dostawy w edycji\ +autouzupełnianie metod płatności i dostawy na podstawie poprzednio wykonanego zakupu\ + +## Minusy ## +nie ma faktury na inne dane(żeby nie używać tego samego zapytania co OSCOP Idosella, na wszelki wypadek żeby nie pobierało opłat) + +## Dodatkowe pomysły do zrealizowania ## +sprawdzanie logina w trakcie pisania(może być słabe dla ochrony danych klienta)\ +Limit znaków | Wydłużanie się okienka od uwag do sklepu|kuriera + +## Uwagi ## +W przypadku edycji zamówienia z zapłatą za pobraniem nie można pobrać danych takiego zamówienia przed dokonaniem zapłaty. Idosell sprawdza ten problem w komunikacie na zooart6. \ No newline at end of file diff --git a/customMarkerMap.js b/customMarkerMap.js deleted file mode 100644 index 0227cfe..0000000 --- a/customMarkerMap.js +++ /dev/null @@ -1,31 +0,0 @@ -var stocks_list_more_txt=;var stocks_list_choose=;var pickupl_nopoints=;var mapTooltipLink_class="btn-small";var autocompleteData=[];var ajaxGetPickupNoMap=function(){$(".mapContainer_pickup, .pickupl_submit").show();var options={courierId:pickup_sites.courierId,isCod:pickup_sites.isCod};$.ajax({type:"GET",url:"/ajax/getPickups.php",data:options,dataType:"json",success:function(json){if(!json.pickupPoints.length){Alertek.show_alert(pickupl_nopoints);$(".loadingMap").hide();return false}setPickupPointsNoMap(json)},error:function(){orderdetails_payments.ajaxLoadSite(0);$(".no_google_api_key div.asideContainer_pickup").show();Alertek.show_alert(pickupl_error)}})};var setPickupPointsNoMap=function(json){var pickup_clone_tmp=$("#pickup_copy").clone();var pickups="";for(i in json.pickupPoints){var pickup=json.pickupPoints[i];var pickup_street=pickup.address.buildingAndHouseNumber!=""?pickup.address.street+" "+pickup.address.buildingAndHouseNumber:pickup.address.street;pickup_clone=pickup_clone_tmp.clone();pickup_clone.find("input[name=pickup_point], input[name=stock]").attr("id","pickup_point_"+pickup.id).val(pickup.id);pickup_clone.find("label").attr({id:"pp_"+pickup.id,"data-latitude":pickup.coordinates.latitude,"data-longitude":pickup.coordinates.longitude,"data-id":pickup.id,"data-requires_client_number":pickup.requiresClientNumber,for:"pickup_point_"+pickup.id});if(pickup.coordinates.longitude){pickup_clone.find("label .map_dir").attr("href","https://www.google.com/maps/dir/?api=1&destination="+pickup.coordinates.latitude+","+pickup.coordinates.longitude)}else{pickup_clone.find("label .map_dir").attr("href","https://maps.google.com?saddr=Current+Location&daddr="+pickup.address.street+"+"+pickup.address.postcode+"+"+pickup.address.city)}pickup_clone.find("b.headerText").text(pickup.name);pickup_clone.find("span.streetText").text(pickup_street);pickup_clone.find("span.zipcodePickup").html(pickup.address.postcode+' '+pickup.address.city+"");pickup_clone.find("div.moreText").text(pickup.location);pickup_clone.find("a.moreLink").attr("href",pickup.link);if(!pickup.requiresClientNumber){pickup_clone.find("input[name=client_courier_number]").remove()}pickups+=pickup_clone.html();autocompleteData.push({label:pickup.address.city+", "+pickup.address.street+" "+pickup.address.buildingAndHouseNumber+" "+pickup.address.postcode+" "+pickup.id,value:pickup.address.city+", "+pickup.address.street+" "+pickup.address.buildingAndHouseNumber+", "+pickup.id,description:pickup.location,id:pickup.id})}$("#pickup_site .asideContainer_pickup").html(pickups);var accentMap={"ł":"l","ó":"o","ź":"z","ś":"s",",":""," ":" "};var normalize=function(term){var ret="";var term=term.toLowerCase();for(var i=0;i'+pickupl_select_adress+"");$(".loadingMap").hide();return false}else{$(".mapContainer_pickup, .asideContainer_pickup, .pickupl_submit, #pickup_map").show()}pickup_sites.search_lat=place.geometry.location.lat();pickup_sites.search_lng=place.geometry.location.lng();for(var i=0;i'+pickupl_select_adress+"");$(".loadingMap").hide();return false}else{$(".mapContainer_pickup, .asideContainer_pickup, .pickupl_submit, #pickup_map").show()}$("label.pickup_point").hide();$("div.loadingMap").fadeIn("normal",function(){});$("span.loadingMarkers").hide();var options={courierId:pickup_sites.courierId,"location[latitude]":pickup_sites.search_lat,"location[longitude]":pickup_sites.search_lng,isCod:pickup_sites.isCod};if(radius){function getRadius(){var curr_zoom=pickup_sites.mapa.getZoom();if(curr_zoom>=15){return 1}else if(curr_zoom==14){return 2}else if(curr_zoom==13){return 4}else if(curr_zoom==12){return 7}else if(curr_zoom==11){return 10}else if(curr_zoom==10){return 15}else{return 20}}var options={courierId:pickup_sites.courierId,"location[latitude]":pickup_sites.search_lat,"location[longitude]":pickup_sites.search_lng,radius:getRadius(),isCod:pickup_sites.isCod}}$.ajax({type:"GET",url:"/ajax/getPickups.php",data:options,dataType:"json",success:function(json){if(!jQuery.isEmptyObject(selected_pickup_point)){for(i in json.pickupPoints){if(json.pickupPoints[i].id==selected_pickup_point.id){delete json.pickupPoints[i]}}json.pickupPoints.unshift(selected_pickup_point)}if(!json.pickupPoints.length){if(radius){$("div.asideContainer_pickup").prepend('")}else{$("div.asideContainer_pickup").prepend('")}$(".loadingMap").hide();return false}if(!pickup_sites.adress.route){for(i in json.pickupPoints){if($.trim(json.pickupPoints[i].address.city).toLowerCase()==$.trim(pickup_sites.adress.locality).toLowerCase()){options.radius=30;$.ajax({type:"GET",url:"/ajax/getPickups.php",data:options,dataType:"json",success:function(json){setPickupPoints(json,true)},error:function(){}});return false}}}setPickupPoints(json,false)},error:function(){$("div.asideContainer_pickup").prepend('")}})},showSel:function(){pickup_sites.pickupCount=$(".asideContainer_pickup .pickup_point").length;pickup_sites.pickupIteration=0;$("div.loadingMap").fadeIn("normal",function(){});$("span.loadingMap").hide();$("span.loadingMarkers").css("display","block");$("span.loadingMarkersCount").text(pickup_sites.pickupCount);$("span.loadingMarkersComplete").text(pickup_sites.pickupIteration);pickup_sites.markersArray=[];var adresData=[];$(".asideContainer_pickup .pickup_point").each(function(index){$this=$(this);adresData[index]={};adresData[index].idek=$this.data("id");adresData[index].headerText=$.trim($this.find(".headerText").text());adresData[index].streetText=$this.find(".streetText").text();adresData[index].cityText=$.trim($this.find(".cityText").text());adresData[index].moreText=$.trim($this.find(".moreLink").text());adresData[index].moreLink=$.trim($this.find(".moreLink").attr("href"));adresData[index].infoText=$.trim($this.find(".infoText").text());adresData[index].timeText=$.trim($this.find(".timeText").text());adresData[index].latitude=$.trim($this.data("latitude"));adresData[index].longitude=$.trim($this.data("longitude"));adresData[index].icon=$.trim($this.data("icon"))});var adresRow="";while(adresRow=adresData.pop()){if(adresRow.latitude&&adresRow.longitude){pickup_sites.findAdres(adresRow.headerText,adresRow.streetText,adresRow.cityText,adresRow.moreText,adresRow.moreLink,adresRow.infoText,adresRow.timeText,"none","another",false,adresRow.idek,adresRow.latitude,adresRow.longitude,adresRow.icon)}else{(function(adresRow){setTimeout(function(){pickup_sites.findAdres(adresRow.headerText,adresRow.streetText,adresRow.cityText,adresRow.moreText,adresRow.moreLink,adresRow.infoText,adresRow.timeText,"none","another",false,adresRow.idek,adresRow.latitude,adresRow.longitude,adresRow.icon)},pickup_sites.timeout)})(adresRow)}}},printDates:function(stockId){if(!$("#selectPickupDay").size())return false;var postData={stock_id:stockId};$.ajax({type:"GET",url:"/ajax/basket-delivery.php",data:postData,dataType:"json",success:function(json){if(!json){$("#selectPickupDayWrapper").hide();return false}$("#selectPickupDay").html("");$.each(json,function(index,data){$("#selectPickupDay").append('")});$("#selectPickupDayWrapper").show();$(".pickupl_hour_wrapper").show();$('#selectPickupDay [name="calendar_select_date"]').eq(1).prop("checked",true)},error:function(){Alertek.show_alert(pickupl_error)}})},setZoom:function(){var bounds=new google.maps.LatLngBounds;for(var i in pickup_sites.markersArray){bounds.extend(pickup_sites.markersArray[i].getPosition())}pickup_sites.mapa.setCenter(bounds.getCenter());pickup_sites.mapa.fitBounds(bounds);pickup_sites.mapa.setZoom(pickup_sites.mapa.getZoom());if(pickup_sites.mapa.getZoom()>15){pickup_sites.mapa.setZoom(15)}},mapInit:function(){if($("#mymap").length){return false}if($("#autocomplete_location").size()&&!$("#mymap").size()){pickup_sites.autocomplete=new google.maps.places.Autocomplete(document.getElementById("autocomplete_location"));$("label.pickup_point").hide()}pickup_sites.zoom=pickupsZoom;pickup_sites.geokoder=new google.maps.Geocoder;var wspolrzedne=new google.maps.LatLng(parseInt(bCordPickups),parseInt(lCordPickups));if(markersAnimationPickups!="")pickup_sites.markerAnimation=true;else pickup_sites.markerAnimation=false;if(markerPickupsCustomIcon!="")markerPickupsCustomIcon=true;else markerPickupsCustomIcon=false;if(mapTypePickups=="ROADMAP")var mapStyle=google.maps.MapTypeId.ROADMAP;else if(mapTypePickups=="SATELLITE")var mapStyle=google.maps.MapTypeId.SATELLITE;else if(mapTypePickups=="HYBRID")var mapStyle=google.maps.MapTypeId.HYBRID;else if(mapTypePickups=="TERRAIN")var mapStyle=google.maps.MapTypeId.TERRAIN;else var mapStyle=google.maps.MapTypeId.ROADMAP;if(navControlPickups!="")navControlPickups=true;else navControlPickups=false;if(mapTypeControlPickups!="")mapTypeControlPickups=true;else mapTypeControlPickups=false;if(scControlPickups!="")scControlPickups=true;else scControlPickups=false;if(controlTypePickups=="ZOOM_PAN")var controlStyle=google.maps.NavigationControlStyle.ZOOM_PAN;else if(controlTypePickups=="SMALL")var controlStyle=google.maps.NavigationControlStyle.SMALL;else if(controlTypePickups=="ANDROID")var controlStyle=google.maps.NavigationControlStyle.ANDROID;else var controlStyle=google.maps.NavigationControlStyle.ZOOM_PAN;if(mapTypeControlStylePickups=="DROPDOWN_MENU")var TypeControlStyle=google.maps.MapTypeControlStyle.DROPDOWN_MENU;else if(mapTypeControlStylePickups=="HORIZONTAL_BAR")var TypeControltyle=google.maps.MapTypeControlStyle.HORIZONTAL_BAR;else var TypeControlStyle=google.maps.MapTypeControlStyle.DROPDOWN_MENU;if($("img.marker_face").attr("src")!=""&&markerPickupsCustomIcon){var markerIconSize=new google.maps.Size($("img.marker_face").width(),$("img.marker_face").height());var punkt_startowy=new google.maps.Point(0,0);var punkt_zaczepienia=new google.maps.Point(parseInt($("img.marker_face").width()/2),parseInt($("img.marker_face").height()/2));pickup_sites.markerIcon=new google.maps.MarkerImage($("img.marker_face").attr("src"),markerIconSize,punkt_startowy,punkt_zaczepienia)}if(window["google_map_style_array"]){var mapOptions={gestureHandling:"cooperative",zoom:pickup_sites.zoom,center:wspolrzedne,mapTypeId:mapStyle,navigationControl:navControlPickups,mapTypeControl:mapTypeControlPickups,scaleControl:scControlPickups,styles:google_map_style_array,navigationControlOptions:{style:controlStyle},mapTypeControlOptions:{style:TypeControlStyle}}}else{var mapOptions={gestureHandling:"cooperative",zoom:pickup_sites.zoom,center:wspolrzedne,mapTypeId:mapStyle,navigationControl:navControlPickups,mapTypeControl:mapTypeControlPickups,scaleControl:scControlPickups,navigationControlOptions:{style:controlStyle},mapTypeControlOptions:{style:TypeControlStyle}}}if(pickup_sites.google_api_key===""){$(".pickupl_sel").removeAttr("disabled");$("div#ps_other").css("opacity","1.0");$("div#ps_other").css("cursor","pointer")}pickup_sites.mapa=new google.maps.Map(document.getElementById("pickup_map"),mapOptions);pickup_sites.markerInfo=new google.maps.InfoWindow;google.maps.event.addListener(pickup_sites.mapa,"idle",function(){$("span.loadingMap").text($("span.loadingNav").text())});if(pickup_sites.autocomplete){pickup_sites.autocomplete.addListener("place_changed",function(){var place=pickup_sites.autocomplete.getPlace();pickup_sites.fillInAddress(place,false);pickup_sites.getLocation()});pickup_sites.getLocation()}else{pickup_sites.showSel()}},markerClickFunction:function(latlng,content){return function(e){e.cancelBubble=true;e.returnValue=false;if(e.stopPropagation){e.stopPropagation();e.preventDefault()}pickup_sites.infoWindow.setContent(content);pickup_sites.infoWindow.setPosition(latlng);pickup_sites.infoWindow.open(pickup_sites.mapa)}},geokoderPrepare:function(point,status,headerText,streetText,cityText,moreText,moreLink,infoText,timeText,className,other,open,idek,latitude,longitude,icon){if(status==google.maps.GeocoderStatus.OK){pickup_sites.timeout=100;pickup_sites.pickupIteration++;pickup_sites.pickupFind++;var content='
'+headerText+"";content+='
'+streetText+"  "+cityText+"
";if(infoText){content+='
'+infoText+"
"}content+='
'+timeText+"
";if(moreLink){if(mapTooltipLink_class==="")content+='";else content+='"}content+="
";var opcjeMarkera={title:headerText,pickupPointID:idek};opcjeMarkera.position=point;opcjeMarkera.map=pickup_sites.mapa;if(pickup_sites.markerAnimation)opcjeMarkera.animation=google.maps.Animation.DROP;if(icon&&icon!=""){opcjeMarkera.icon=icon}else{if($("img.marker_face").attr("src")!=""&&markerPickupsCustomIcon){opcjeMarkera.icon=pickup_sites.markerIcon}}var marker=new google.maps.Marker(opcjeMarkera);pickup_sites.markersArray.push(marker);google.maps.event.addListener(marker,"click",function(marker,i){return function(e){e.cancelBubble=true;e.returnValue=false;if(e.stopPropagation){e.stopPropagation();e.preventDefault()}pickup_sites.markerInfo.setContent(content);pickup_sites.markerInfo.open(pickup_sites.mapa,marker);$('.asideContainer_pickup [value="'+marker.pickupPointID+'"]').prop("checked",true);$(".asideContainer_pickup").scrollTop(0);$(".asideContainer_pickup").scrollTop($('#pickup_site [name="pickup_point"]:checked + label').position().top)}}(marker,i));var pickupItem=$('.asideContainer_pickup [value="'+marker.pickupPointID+'"]').get(0);$('label[for="pickup_point_'+marker.pickupPointID+'"]').show().fadeTo("slow",1);google.maps.event.addDomListener(pickupItem,"click",function(marker,i){return function(e){$('.asideContainer_pickup [value="'+marker.pickupPointID+'"]').prop("checked",true);pickup_sites.markerInfo.setContent(content);pickup_sites.mapa.setCenter(opcjeMarkera.position);if(pickup_sites.mapa.getZoom()=pickup_sites.pickupCount){setTimeout(function(){$("div.loadingMap").fadeOut("normal",function(){});var _src=$('.markerCluster[src*="m1.png"]').attr("src");var _imagePath=_src.substring(0,_src.indexOf("1.png"));pickup_sites.setZoom();var create_map_selected_point=true;if(pickup_sites.mapa.zoom=pickup_sites.pickupCount){setTimeout(function(){$("div.loadingMap").fadeOut("normal",function(){});var _src=$('.markerCluster[src*="m1.png"]').attr("src");var _imagePath=_src.substring(0,_src.indexOf("1.png")-1);pickup_sites.setZoom();var create_map_selected_point=true;if(pickup_sites.mapa.zoom')}if(pickup.coordinates.longitude){pickup_clone.find("label .map_dir").attr("href","https://www.google.com/maps/dir/?api=1&destination="+pickup.coordinates.latitude+","+pickup.coordinates.longitude)}else{pickup_clone.find("label .map_dir").attr("href","https://maps.google.com?saddr=Current+Location&daddr="+pickup.address.street+"+"+pickup.address.postcode+"+"+pickup.address.city)}pickup_clone.find("b.headerText").text(pickup.name);var pickup_street=pickup.address.buildingAndHouseNumber!=""&&pickup.address.buildingAndHouseNumber!=null?pickup.address.street+" "+pickup.address.buildingAndHouseNumber:pickup.address.street;pickup_clone.find("span.streetText").text(pickup_street);pickup_clone.find("span.zipcodePickup").html(pickup.address.postcode+' '+pickup.address.city+"");pickup_clone.find("div.moreText").text(pickup.location);pickup_clone.find("a.moreLink").attr("href",pickup.link);if(pickup.requiresClientNumber){}else{pickup_clone.find("input[name=client_courier_number]").remove()}$("#pickup_site .asideContainer_pickup").append(pickup_clone.find(" > *"))}pickup_sites.showSel()};function geolocate(){pickup_sites.search_lat="";pickup_sites.search_lng="";if(navigator.geolocation){navigator.geolocation.getCurrentPosition(function(position){var geolocation={lat:position.coords.latitude,lng:position.coords.longitude};var circle=new google.maps.Circle({center:geolocation,radius:position.coords.accuracy});pickup_sites.autocomplete.setBounds(circle.getBounds())})}}$(document).on("click","#locationField .btn",function(){if(!$("#mymap").length){pickup_sites.getLocation()}else{leafletGetTextLocation();$(".leafleat-suggestions").remove()}return false});$(document).on("click","div.morePickup",function(){var activePoints=$("label.pickup_point.moreInfoShow");$(this).parents("label.pickup_point").addClass("moreInfoShow");activePoints.removeClass("moreInfoShow")});$(document).on("click",'#pickup_site [name="pickup_point"], #pickup_site [name="stock"]',function(){$('#pickup_site [name="client_courier_number"]').prop("disabled",true);$(this).find('+ label [name="client_courier_number"]').prop("disabled",false).focus();pickup_sites.printDates($(this).val())});app_shop.run(function(){pickup_sites.country_code=app_shop.vars.country_code;pickup_sites.language=app_shop.vars.language;pickup_sites.isCod=app_shop.vars.isCod;pickup_sites.courierId=app_shop.vars.courierId;init_pickupl_site();var mapLink="https://maps.googleapis.com/maps/api/js?key="+app_shop.vars.apiKey+"&libraries=places&callback=pickup_sites.mapInit";var pickup_src=document.createElement("script");pickup_src.setAttribute("src",mapLink);document.body.appendChild(pickup_src)},"all","#pickup_site");function MarkerClusterer(map,opt_markers,opt_options){this.extend(MarkerClusterer,google.maps.OverlayView);this.map_=map;this.markers_=[];this.clusters_=[];this.sizes=[53,56,66,78,90];this.styles_=[];this.ready_=false;var options=opt_options||{};this.gridSize_=options["gridSize"]||60;this.minClusterSize_=options["minimumClusterSize"]||2;this.maxZoom_=options["maxZoom"]||null;this.styles_=options["styles"]||[];this.imagePath_=options["imagePath"]||this.MARKER_CLUSTER_IMAGE_PATH_;this.imageExtension_=options["imageExtension"]||this.MARKER_CLUSTER_IMAGE_EXTENSION_;this.zoomOnClick_=true;if(options["zoomOnClick"]!=undefined){this.zoomOnClick_=options["zoomOnClick"]}this.averageCenter_=false;if(options["averageCenter"]!=undefined){this.averageCenter_=options["averageCenter"]}this.setupStyles_();this.setMap(map);this.prevZoom_=this.map_.getZoom();var that=this;google.maps.event.addListener(this.map_,"zoom_changed",function(){var zoom=that.map_.getZoom();var minZoom=that.map_.minZoom||0;var maxZoom=Math.min(that.map_.maxZoom||100,that.map_.mapTypes[that.map_.getMapTypeId()].maxZoom);zoom=Math.min(Math.max(zoom,minZoom),maxZoom);if(that.prevZoom_!=zoom){that.prevZoom_=zoom;that.resetViewport()}});google.maps.event.addListener(this.map_,"idle",function(){that.redraw()});if(opt_markers&&(opt_markers.length||Object.keys(opt_markers).length)){this.addMarkers(opt_markers,false)}}MarkerClusterer.prototype.MARKER_CLUSTER_IMAGE_PATH_="../images/m";MarkerClusterer.prototype.MARKER_CLUSTER_IMAGE_EXTENSION_="png";MarkerClusterer.prototype.extend=function(obj1,obj2){return function(object){for(var property in object.prototype){this.prototype[property]=object.prototype[property]}return this}.apply(obj1,[obj2])};MarkerClusterer.prototype.onAdd=function(){this.setReady_(true)};MarkerClusterer.prototype.draw=function(){};MarkerClusterer.prototype.setupStyles_=function(){if(this.styles_.length){return}for(var i=0,size;size=this.sizes[i];i++){this.styles_.push({url:this.imagePath_+(i+1)+"."+this.imageExtension_,height:size,width:size})}};MarkerClusterer.prototype.fitMapToMarkers=function(){var markers=this.getMarkers();var bounds=new google.maps.LatLngBounds;for(var i=0,marker;marker=markers[i];i++){bounds.extend(marker.getPosition())}this.map_.fitBounds(bounds)};MarkerClusterer.prototype.setStyles=function(styles){this.styles_=styles};MarkerClusterer.prototype.getStyles=function(){return this.styles_};MarkerClusterer.prototype.isZoomOnClick=function(){return this.zoomOnClick_};MarkerClusterer.prototype.isAverageCenter=function(){return this.averageCenter_};MarkerClusterer.prototype.getMarkers=function(){return this.markers_};MarkerClusterer.prototype.getTotalMarkers=function(){return this.markers_.length};MarkerClusterer.prototype.setMaxZoom=function(maxZoom){this.maxZoom_=maxZoom};MarkerClusterer.prototype.getMaxZoom=function(){return this.maxZoom_};MarkerClusterer.prototype.calculator_=function(markers,numStyles){var index=0;var count=markers.length;var dv=count;while(dv!==0){dv=parseInt(dv/10,10);index++}index=Math.min(index,numStyles);return{text:count,index:index}};MarkerClusterer.prototype.setCalculator=function(calculator){this.calculator_=calculator};MarkerClusterer.prototype.getCalculator=function(){return this.calculator_};MarkerClusterer.prototype.addMarkers=function(markers,opt_nodraw){if(markers.length){for(var i=0,marker;marker=markers[i];i++){this.pushMarkerTo_(marker)}}else if(Object.keys(markers).length){for(var marker in markers){this.pushMarkerTo_(markers[marker])}}if(!opt_nodraw){this.redraw()}};MarkerClusterer.prototype.pushMarkerTo_=function(marker){marker.isAdded=false;if(marker["draggable"]){var that=this;google.maps.event.addListener(marker,"dragend",function(){marker.isAdded=false;that.repaint()})}this.markers_.push(marker)};MarkerClusterer.prototype.addMarker=function(marker,opt_nodraw){this.pushMarkerTo_(marker);if(!opt_nodraw){this.redraw()}};MarkerClusterer.prototype.removeMarker_=function(marker){var index=-1;if(this.markers_.indexOf){index=this.markers_.indexOf(marker)}else{for(var i=0,m;m=this.markers_[i];i++){if(m==marker){index=i;break}}}if(index==-1){return false}marker.setMap(null);this.markers_.splice(index,1);return true};MarkerClusterer.prototype.removeMarker=function(marker,opt_nodraw){var removed=this.removeMarker_(marker);if(!opt_nodraw&&removed){this.resetViewport();this.redraw();return true}else{return false}};MarkerClusterer.prototype.removeMarkers=function(markers,opt_nodraw){var removed=false;for(var i=0,marker;marker=markers[i];i++){var r=this.removeMarker_(marker);removed=removed||r}if(!opt_nodraw&&removed){this.resetViewport();this.redraw();return true}};MarkerClusterer.prototype.setReady_=function(ready){if(!this.ready_){this.ready_=ready;this.createClusters_()}};MarkerClusterer.prototype.getTotalClusters=function(){return this.clusters_.length};MarkerClusterer.prototype.getMap=function(){return this.map_};MarkerClusterer.prototype.setMap=function(map){this.map_=map};MarkerClusterer.prototype.getGridSize=function(){return this.gridSize_};MarkerClusterer.prototype.setGridSize=function(size){this.gridSize_=size};MarkerClusterer.prototype.getMinClusterSize=function(){return this.minClusterSize_};MarkerClusterer.prototype.setMinClusterSize=function(size){this.minClusterSize_=size};MarkerClusterer.prototype.getExtendedBounds=function(bounds){var projection=this.getProjection();var tr=new google.maps.LatLng(bounds.getNorthEast().lat(),bounds.getNorthEast().lng());var bl=new google.maps.LatLng(bounds.getSouthWest().lat(),bounds.getSouthWest().lng());var trPix=projection.fromLatLngToDivPixel(tr);trPix.x+=this.gridSize_;trPix.y-=this.gridSize_;var blPix=projection.fromLatLngToDivPixel(bl);blPix.x-=this.gridSize_;blPix.y+=this.gridSize_;var ne=projection.fromDivPixelToLatLng(trPix);var sw=projection.fromDivPixelToLatLng(blPix);bounds.extend(ne);bounds.extend(sw);return bounds};MarkerClusterer.prototype.isMarkerInBounds_=function(marker,bounds){return bounds.contains(marker.getPosition())};MarkerClusterer.prototype.clearMarkers=function(){this.resetViewport(true);this.markers_=[]};MarkerClusterer.prototype.resetViewport=function(opt_hide){for(var i=0,cluster;cluster=this.clusters_[i];i++){cluster.remove()}for(var i=0,marker;marker=this.markers_[i];i++){marker.isAdded=false;if(opt_hide){marker.setMap(null)}}this.clusters_=[]};MarkerClusterer.prototype.repaint=function(){var oldClusters=this.clusters_.slice();this.clusters_.length=0;this.resetViewport();this.redraw();window.setTimeout(function(){for(var i=0,cluster;cluster=oldClusters[i];i++){cluster.remove()}},0)};MarkerClusterer.prototype.redraw=function(){this.createClusters_()};MarkerClusterer.prototype.distanceBetweenPoints_=function(p1,p2){if(!p1||!p2){return 0}var R=6371;var dLat=(p2.lat()-p1.lat())*Math.PI/180;var dLon=(p2.lng()-p1.lng())*Math.PI/180;var a=Math.sin(dLat/2)*Math.sin(dLat/2)+Math.cos(p1.lat()*Math.PI/180)*Math.cos(p2.lat()*Math.PI/180)*Math.sin(dLon/2)*Math.sin(dLon/2);var c=2*Math.atan2(Math.sqrt(a),Math.sqrt(1-a));var d=R*c;return d};MarkerClusterer.prototype.addToClosestCluster_=function(marker){var distance=4e4;var clusterToAddTo=null;var pos=marker.getPosition();for(var i=0,cluster;cluster=this.clusters_[i];i++){var center=cluster.getCenter();if(center){var d=this.distanceBetweenPoints_(center,marker.getPosition());if(d=this.minClusterSize_){marker.setMap(null)}this.updateIcon();return true};Cluster.prototype.getMarkerClusterer=function(){return this.markerClusterer_};Cluster.prototype.getBounds=function(){var bounds=new google.maps.LatLngBounds(this.center_,this.center_);var markers=this.getMarkers();for(var i=0,marker;marker=markers[i];i++){bounds.extend(marker.getPosition())}return bounds};Cluster.prototype.remove=function(){this.clusterIcon_.remove();this.markers_.length=0;delete this.markers_};Cluster.prototype.getSize=function(){return this.markers_.length};Cluster.prototype.getMarkers=function(){return this.markers_};Cluster.prototype.getCenter=function(){return this.center_};Cluster.prototype.calculateBounds_=function(){var bounds=new google.maps.LatLngBounds(this.center_,this.center_);this.bounds_=this.markerClusterer_.getExtendedBounds(bounds)};Cluster.prototype.isMarkerInClusterBounds=function(marker){return this.bounds_.contains(marker.getPosition())};Cluster.prototype.getMap=function(){return this.map_};Cluster.prototype.updateIcon=function(){var zoom=this.map_.getZoom();var mz=this.markerClusterer_.getMaxZoom();if(mz&&zoom>mz){for(var i=0,marker;marker=this.markers_[i];i++){marker.setMap(this.map_)}return}if(this.markers_.length0&&this.anchor_[0]0&&this.anchor_[1] .pickup_search_here",function(){pickup_sites.search_lat=pickup_sites.mapa.center.lat();pickup_sites.search_lng=pickup_sites.mapa.center.lng();pickup_sites.ajaxGetPickup(true)});var mymap;var isLoaded=false;var isWaitingEnd=false;var leafletGetPickups=function(lat,long,current_zoom){if(current_zoom>=15){radius=1}else if(current_zoom==14){radius=2}else if(current_zoom==13){radius=4}else if(current_zoom==12){radius=7}else if(current_zoom==11){radius=10}else if(current_zoom==10){radius=15}else{radius=20}if(current_zoom){var options={courierId:pickup_sites.courierId,"location[latitude]":lat,"location[longitude]":long,radius:radius,isCod:pickup_sites.isCod}}else{var options={courierId:pickup_sites.courierId,"location[latitude]":lat,"location[longitude]":long,isCod:pickup_sites.isCod}}$.ajax({type:"GET",url:"/ajax/getPickups.php",data:options,dataType:"json",success:function(json){if(!jQuery.isEmptyObject(selected_pickup_point)){for(i in json.pickupPoints){if(json.pickupPoints[i].id==selected_pickup_point.id){delete json.pickupPoints[i]}}json.pickupPoints.unshift(selected_pickup_point);console.log("pickupPoints unshift")}if(!json.pickupPoints.length){if($("div.asideContainer_pickup .menu_messages_message").length)$("div.asideContainer_pickup .menu_messages_message").remove();if(radius){if($("div.asideContainer_pickup .menu_messages_message").length)$("div.asideContainer_pickup .menu_messages_message").remove();$("div.asideContainer_pickup").prepend('")}else{$("div.asideContainer_pickup").prepend('")}$(".loadingMap").hide();return false}leafletItems=[];for(i in json.pickupPoints){var pickupLat=json.pickupPoints[i].coordinates.latitude;var pickupLon=json.pickupPoints[i].coordinates.longitude;if(pickupLat==""||pickupLon==""){$.ajaxSetup({async:false});$.get(location.protocol+"//nominatim.openstreetmap.org/search?format=json&q="+json.pickupPoints[i].address.street+", "+json.pickupPoints[i].address.city+" "+json.pickupPoints[i].address.city+" "+json.pickupPoints[i].address.country,function(data){if(!jQuery.isEmptyObject(data)){pickupLat=data[0].lat;pickupLon=data[0].lon}else{console.log("nie mogę znaleźć korodynatów adresu!")}})}leafletItems.push({id:json.pickupPoints[i].id,name:json.pickupPoints[i].name,link:json.pickupPoints[i].link,address:json.pickupPoints[i].address,lat:pickupLat,lon:pickupLon})}setPickupPointsNoMap(json,false,true);if(!jQuery.isEmptyObject(leafletItems)){leafletStartMap(leafletItems[0].lat,leafletItems[0].lon,true)}},error:function(){if($("div.asideContainer_pickup .menu_messages_message").length)$("div.asideContainer_pickup .menu_messages_message").remove();$("div.asideContainer_pickup").prepend('");$(".asideContainer_pickup label.pickup_point").each(function(){var aId=$(this).data("id");var aName=$(this).find(".headerText").text();var aLink=$(this).find(".map_dir").attr("href");var aAddress=$(this).find(".streetText").text()+"
"+$(this).find(".zipcodePickup").text();var aLat=$(this).data("latitude");var aLon=$(this).data("longitude");leafletItems.push({id:aId,name:aName,link:aLink,address:aAddress,lat:aLat,lon:aLon})});if(leafletItems[0].lat&&leafletItems[0].lon)leafletStartMap(leafletItems[0].lat,leafletItems[0].lon,true)}})};var leafletMarker=new Array;var leafletItems=[];function leafletDelMarkers(){for(i=0;iOpenStreetMap contributors'}).addTo(mymap);isLoaded=true;isWaitingEnd=true}$(".loadingPoints").remove();for(i=0;i`+stocks_list_more_txt+``+stocks_list_choose+``;let addressTxt="";if(leafletItems[i].address.street!=undefined){addressTxt=`
`+leafletItems[i].address.street+` `+leafletItems[i].address.buildingAndHouseNumber+` `+leafletItems[i].address.city+`
`}else{addressTxt=`
`+leafletItems[i].address+`
`}let button_text=``+leafletItems[i].name+`
`+addressTxt+`
`+href;markersList.push(leafletItems[i].id);markers[leafletItems[i].id]=L.marker([leafletItems[i].lat,leafletItems[i].lon],{icon:newMarkerIcon}).addTo(mymap).on("click",leafletOnClick).bindPopup(button_text)}mymap.setView(new L.LatLng(lat,long));let pointId=$(".asideContainer_pickup label.pickup_point").eq(0).attr("data-id");$('.asideContainer_pickup input[value="'+pointId+'"]').click();$("img.leaflet-marker-icon").each(function(){var href=$(this).attr("src");var href_prev=href.includes("preview/");if(href_prev)href=href.replace("preview/","");var href_2x=href.includes("marker-icon");if(href_2x)href=href.replace("-2x","");$(this).attr("src",href)})};var timeoutLeafLet=null;$(document).on("input","#autocomplete_location.autocomplete_nomap",function(){var that=$(this);clearTimeout(timeoutLeafLet);timeoutLeafLet=setTimeout(function(){if(that.val().length>3){leafletGetLocation(that.val())}},500)});$(document).off("click.suggestions").on("click.suggestions",".leafleat-suggestions div",function(){$("#autocomplete_location").val($(this).text());$(".leafleat-suggestions").remove();const lat=$(this).attr("data-lat");const lon=$(this).attr("data-lon");leafletDelMarkers();selected_pickup_point={};leafletGetPickups(lat,lon)});$(document).on("click",".map_button_search > .pickup_search_here_leaflet",function(){var cords=mymap.getCenter();var zoom=mymap.getZoom();leafletDelMarkers();selected_pickup_point={};leafletGetPickups(cords.lat,cords.lng,zoom)});$(document).on("click",'#pickup_site [name="pickup_point"], #pickup_site [name="stock"]',function(){const id=$(this).val();if(markers[id]){let thatMarkerCoords=markers[id].getLatLng();mymap.setView(new L.LatLng(thatMarkerCoords.lat,thatMarkerCoords.lng));markers[id].openPopup()}});var leafletGetCoords=function(address){let mymapLat="",mymapLong="";if(address){$.get(location.protocol+"//nominatim.openstreetmap.org/search?format=json&q="+address,function(data){if(!jQuery.isEmptyObject(data)){mymapLat=data[0].lat;mymapLong=data[0].lon;leafletGetPickups(mymapLat,mymapLong)}else{if($(".asideContainer_pickup label.pickup_point").length){$(".asideContainer_pickup label.pickup_point").each(function(){var aId=$(this).data("id");var aName=$(this).find(".headerText").text();var aLink=$(this).find(".map_dir").attr("href");var aAddress=$(this).find(".streetText").text()+"
"+$(this).find(".zipcodePickup").text();var aLat=$(this).data("latitude");var aLon=$(this).data("longitude");leafletItems.push({id:aId,name:aName,link:aLink,address:aAddress,lat:aLat,lon:aLon})});leafletStartMap(leafletItems[0].lat,leafletItems[0].lon,true)}if($("div.asideContainer_pickup .menu_messages_message").length)$("div.asideContainer_pickup .menu_messages_message").remove();$("div.asideContainer_pickup").prepend('")}})}else{if($(".asideContainer_pickup label.pickup_point").length){$(".asideContainer_pickup label.pickup_point").each(function(){var aId=$(this).data("id");var aName=$(this).find(".headerText").text();var aLink=$(this).find(".map_dir").attr("href");var aAddress=$(this).find(".streetText").text()+"
"+$(this).find(".zipcodePickup").text();var aLat=$(this).data("latitude");var aLon=$(this).data("longitude");leafletItems.push({id:aId,name:aName,link:aLink,address:aAddress,lat:aLat,lon:aLon})});leafletStartMap(leafletItems[0].lat,leafletItems[0].lon,true)}}};var leafletGetLocation=function(address){$.get(location.protocol+"//nominatim.openstreetmap.org/search?format=json&q="+address,function(data){if(!jQuery.isEmptyObject(data)){$("#locationField").append('
');for(i in data){$(".leafleat-suggestions").append('
'+data[i].display_name+"
")}}else{leafletStartMap(53.428,14.552,true);if($("div.asideContainer_pickup .menu_messages_message").length)$("div.asideContainer_pickup .menu_messages_message").remove();$("div.asideContainer_pickup").prepend('")}})};var leafletGetTextLocation=function(){$("#mymap").prepend(`
${}...
`);var text=$("#autocomplete_location").val();selected_pickup_point={};$.get(location.protocol+"//nominatim.openstreetmap.org/search?format=json&q="+text,function(data){if(!jQuery.isEmptyObject(data)){leafletDelMarkers();leafletGetPickups(data[0].lat,data[0].lon);$("#autocomplete_location").val(data[0].display_name)}else{if(text.search(",")){var srp=text.split(",");var new_address=srp[srp.length-1].trim();leafletGetCoords(new_address)}if($("div.asideContainer_pickup .menu_messages_message").length)$("div.asideContainer_pickup .menu_messages_message").remove();$("div.asideContainer_pickup").prepend('")}})};app_shop.run(function(){if($("#autocomplete_location").length&&$("#autocomplete_location").val()!=""){let leafletAddress=$("#autocomplete_location").val();leafletGetCoords(leafletAddress)}else{leafletGetCoords(false)}},"all","#mymap");app_shop.run(function(){$("#mymap").before($(".map_button_search"))},1,"#mymap");app_shop.run(function(){$("#mymap").prepend($(".map_button_search"))},[2,3,4],"#mymap");!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i(t.L={})}(this,function(t){"use strict";var i=Object.freeze;function h(t){var i,e,n,o;for(e=1,n=arguments.length;e=this.min.x&&e.x<=this.max.x&&i.y>=this.min.y&&e.y<=this.max.y},intersects:function(t){t=R(t);var i=this.min,e=this.max,n=t.min,o=t.max,s=o.x>=i.x&&n.x<=e.x,r=o.y>=i.y&&n.y<=e.y;return s&&r},overlaps:function(t){t=R(t);var i=this.min,e=this.max,n=t.min,o=t.max,s=o.x>i.x&&n.xi.y&&n.y=n.lat&&e.lat<=o.lat&&i.lng>=n.lng&&e.lng<=o.lng},intersects:function(t){t=D(t);var i=this._southWest,e=this._northEast,n=t.getSouthWest(),o=t.getNorthEast(),s=o.lat>=i.lat&&n.lat<=e.lat,r=o.lng>=i.lng&&n.lng<=e.lng;return s&&r},overlaps:function(t){t=D(t);var i=this._southWest,e=this._northEast,n=t.getSouthWest(),o=t.getNorthEast(),s=o.lat>i.lat&&n.lati.lng&&n.lng';var i=t.firstChild;return i.style.behavior="url(#default#VML)",i&&"object"==typeof i.adj}catch(t){return!1}}();function Bt(t){return 0<=navigator.userAgent.toLowerCase().indexOf(t)}var At=(Object.freeze||Object)({ie:it,ielt9:et,edge:nt,webkit:ot,android:st,android23:rt,androidStock:ht,opera:ut,chrome:lt,gecko:ct,safari:_t,phantom:dt,opera12:pt,win:mt,ie3d:ft,webkit3d:gt,gecko3d:vt,any3d:yt,mobile:xt,mobileWebkit:wt,mobileWebkit3d:Pt,msPointer:Lt,pointer:bt,touch:Tt,mobileOpera:zt,mobileGecko:Mt,retina:Ct,passiveEvents:Et,canvas:St,svg:Zt,vml:kt}),It=Lt?"MSPointerDown":"pointerdown",Ot=Lt?"MSPointerMove":"pointermove",Rt=Lt?"MSPointerUp":"pointerup",Nt=Lt?"MSPointerCancel":"pointercancel",Dt=["INPUT","SELECT","OPTION"],jt={},Wt=!1,Ht=0;function Ft(t,i,e,n){return"touchstart"===i?function(t,i,e){var n=a(function(t){if("mouse"!==t.pointerType&&t.MSPOINTER_TYPE_MOUSE&&t.pointerType!==t.MSPOINTER_TYPE_MOUSE){if(!(Dt.indexOf(t.target.tagName)<0))return;ji(t)}Gt(t,i)});t["_leaflet_touchstart"+e]=n,t.addEventListener(It,n,!1),Wt||(document.documentElement.addEventListener(It,Ut,!0),document.documentElement.addEventListener(Ot,Vt,!0),document.documentElement.addEventListener(Rt,qt,!0),document.documentElement.addEventListener(Nt,qt,!0),Wt=!0)}(t,e,n):"touchmove"===i?function(t,i,e){function n(t){(t.pointerType!==t.MSPOINTER_TYPE_MOUSE&&"mouse"!==t.pointerType||0!==t.buttons)&&Gt(t,i)}t["_leaflet_touchmove"+e]=n,t.addEventListener(Ot,n,!1)}(t,e,n):"touchend"===i&&function(t,i,e){function n(t){Gt(t,i)}t["_leaflet_touchend"+e]=n,t.addEventListener(Rt,n,!1),t.addEventListener(Nt,n,!1)}(t,e,n),this}function Ut(t){jt[t.pointerId]=t,Ht++}function Vt(t){jt[t.pointerId]&&(jt[t.pointerId]=t)}function qt(t){delete jt[t.pointerId],Ht--}function Gt(t,i){for(var e in t.touches=[],jt)t.touches.push(jt[e]);t.changedTouches=[t],i(t)}var Kt=Lt?"MSPointerDown":bt?"pointerdown":"touchstart",Yt=Lt?"MSPointerUp":bt?"pointerup":"touchend",Xt="_leaflet_";function Jt(t,o,i){var s,r,a=!1;function e(t){var i;if(bt){if(!nt||"mouse"===t.pointerType)return;i=Ht}else i=t.touches.length;if(!(1this.options.maxZoom)?this.setZoom(t):this},panInsideBounds:function(t,i){this._enforcingBounds=!0;var e=this.getCenter(),n=this._limitCenter(e,this._zoom,D(t));return e.equals(n)||this.panTo(n,i),this._enforcingBounds=!1,this},panInside:function(t,i){var e=I((i=i||{}).paddingTopLeft||i.padding||[0,0]),n=I(i.paddingBottomRight||i.padding||[0,0]),o=this.getCenter(),s=this.project(o),r=this.project(t),a=this.getPixelBounds(),h=a.getSize().divideBy(2),u=R([a.min.add(e),a.max.subtract(n)]);if(!u.contains(r)){this._enforcingBounds=!0;var l=s.subtract(r),c=I(r.x+l.x,r.y+l.y);(r.xu.max.x)&&(c.x=s.x-l.x,0u.max.y)&&(c.y=s.y-l.y,0=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(t,i){for(var e,n=[],o="mouseout"===i||"mouseover"===i,s=t.target||t.srcElement,r=!1;s;){if((e=this._targets[u(s)])&&("click"===i||"preclick"===i)&&!t._simulated&&this._draggableMoved(e)){r=!0;break}if(e&&e.listens(i,!0)){if(o&&!Yi(s,t))break;if(n.push(e),o)break}if(s===this._container)break;s=s.parentNode}return n.length||r||o||!Yi(s,t)||(n=[this]),n},_handleDOMEvent:function(t){if(this._loaded&&!Ki(t)){var i=t.type;"mousedown"!==i&&"keypress"!==i&&"keyup"!==i&&"keydown"!==i||Mi(t.target||t.srcElement),this._fireDOMEvent(t,i)}},_mouseEvents:["click","dblclick","mouseover","mouseout","contextmenu"],_fireDOMEvent:function(t,i,e){if("click"===t.type){var n=h({},t);n.type="preclick",this._fireDOMEvent(n,n.type,e)}if(!t._stopped&&(e=(e||[]).concat(this._findEventTargets(t,i))).length){var o=e[0];"contextmenu"===i&&o.listens(i,!0)&&ji(t);var s={originalEvent:t};if("keypress"!==t.type&&"keydown"!==t.type&&"keyup"!==t.type){var r=o.getLatLng&&(!o._radius||o._radius<=10);s.containerPoint=r?this.latLngToContainerPoint(o.getLatLng()):this.mouseEventToContainerPoint(t),s.layerPoint=this.containerPointToLayerPoint(s.containerPoint),s.latlng=r?o.getLatLng():this.layerPointToLatLng(s.layerPoint)}for(var a=0;athis.options.zoomAnimationThreshold)return!1;var n=this.getZoomScale(i),o=this._getCenterOffset(t)._divideBy(1-1/n);return!(!0!==e.animate&&!this.getSize().contains(o))&&(M(function(){this._moveStart(!0,!1)._animateZoom(t,i,!0)},this),!0)},_animateZoom:function(t,i,e,n){this._mapPane&&(e&&(this._animatingZoom=!0,this._animateToCenter=t,this._animateToZoom=i,mi(this._mapPane,"leaflet-zoom-anim")),this.fire("zoomanim",{center:t,zoom:i,noUpdate:n}),setTimeout(a(this._onZoomTransitionEnd,this),250))},_onZoomTransitionEnd:function(){this._animatingZoom&&(this._mapPane&&fi(this._mapPane,"leaflet-zoom-anim"),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom),M(function(){this._moveEnd(!0)},this))}});function Qi(t){return new te(t)}var te=S.extend({options:{position:"topright"},initialize:function(t){p(this,t)},getPosition:function(){return this.options.position},setPosition:function(t){var i=this._map;return i&&i.removeControl(this),this.options.position=t,i&&i.addControl(this),this},getContainer:function(){return this._container},addTo:function(t){this.remove(),this._map=t;var i=this._container=this.onAdd(t),e=this.getPosition(),n=t._controlCorners[e];return mi(i,"leaflet-control"),-1!==e.indexOf("bottom")?n.insertBefore(i,n.firstChild):n.appendChild(i),this._map.on("unload",this.remove,this),this},remove:function(){return this._map&&(li(this._container),this.onRemove&&this.onRemove(this._map),this._map.off("unload",this.remove,this),this._map=null),this},_refocusOnMap:function(t){this._map&&t&&0",n=document.createElement("div");return n.innerHTML=e,n.firstChild},_addItem:function(t){var i,e=document.createElement("label"),n=this._map.hasLayer(t.layer);t.overlay?((i=document.createElement("input")).type="checkbox",i.className="leaflet-control-layers-selector",i.defaultChecked=n):i=this._createRadioElement("leaflet-base-layers_"+u(this),n),this._layerControlInputs.push(i),i.layerId=u(t.layer),ki(i,"click",this._onInputClick,this);var o=document.createElement("span");o.innerHTML=" "+t.name;var s=document.createElement("div");return e.appendChild(s),s.appendChild(i),s.appendChild(o),(t.overlay?this._overlaysList:this._baseLayersList).appendChild(e),this._checkDisabledLayers(),e},_onInputClick:function(){var t,i,e=this._layerControlInputs,n=[],o=[];this._handlingClick=!0;for(var s=e.length-1;0<=s;s--)t=e[s],i=this._getLayer(t.layerId).layer,t.checked?n.push(i):t.checked||o.push(i);for(s=0;si.options.maxZoom},_expandIfNotCollapsed:function(){return this._map&&!this.options.collapsed&&this.expand(),this},_expand:function(){return this.expand()},_collapse:function(){return this.collapse()}}),ee=te.extend({options:{position:"topleft",zoomInText:"+",zoomInTitle:"Zoom in",zoomOutText:"−",zoomOutTitle:"Zoom out"},onAdd:function(t){var i="leaflet-control-zoom",e=ui("div",i+" leaflet-bar"),n=this.options;return this._zoomInButton=this._createButton(n.zoomInText,n.zoomInTitle,i+"-in",e,this._zoomIn),this._zoomOutButton=this._createButton(n.zoomOutText,n.zoomOutTitle,i+"-out",e,this._zoomOut),this._updateDisabled(),t.on("zoomend zoomlevelschange",this._updateDisabled,this),e},onRemove:function(t){t.off("zoomend zoomlevelschange",this._updateDisabled,this)},disable:function(){return this._disabled=!0,this._updateDisabled(),this},enable:function(){return this._disabled=!1,this._updateDisabled(),this},_zoomIn:function(t){!this._disabled&&this._map._zoomthis._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(t.shiftKey?3:1))},_createButton:function(t,i,e,n,o){var s=ui("a",e,n);return s.innerHTML=t,s.href="#",s.title=i,s.setAttribute("role","button"),s.setAttribute("aria-label",i),Di(s),ki(s,"click",Wi),ki(s,"click",o,this),ki(s,"click",this._refocusOnMap,this),s},_updateDisabled:function(){var t=this._map,i="leaflet-disabled";fi(this._zoomInButton,i),fi(this._zoomOutButton,i),!this._disabled&&t._zoom!==t.getMinZoom()||mi(this._zoomOutButton,i),!this._disabled&&t._zoom!==t.getMaxZoom()||mi(this._zoomInButton,i)}});$i.mergeOptions({zoomControl:!0}),$i.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new ee,this.addControl(this.zoomControl))});var ne=te.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0},onAdd:function(t){var i="leaflet-control-scale",e=ui("div",i),n=this.options;return this._addScales(n,i+"-line",e),t.on(n.updateWhenIdle?"moveend":"move",this._update,this),t.whenReady(this._update,this),e},onRemove:function(t){t.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(t,i,e){t.metric&&(this._mScale=ui("div",i,e)),t.imperial&&(this._iScale=ui("div",i,e))},_update:function(){var t=this._map,i=t.getSize().y/2,e=t.distance(t.containerPointToLatLng([0,i]),t.containerPointToLatLng([this.options.maxWidth,i]));this._updateScales(e)},_updateScales:function(t){this.options.metric&&t&&this._updateMetric(t),this.options.imperial&&t&&this._updateImperial(t)},_updateMetric:function(t){var i=this._getRoundNum(t),e=i<1e3?i+" m":i/1e3+" km";this._updateScale(this._mScale,e,i/t)},_updateImperial:function(t){var i,e,n,o=3.2808399*t;5280Leaflet'},initialize:function(t){p(this,t),this._attributions={}},onAdd:function(t){for(var i in(t.attributionControl=this)._container=ui("div","leaflet-control-attribution"),Di(this._container),t._layers)t._layers[i].getAttribution&&this.addAttribution(t._layers[i].getAttribution());return this._update(),this._container},setPrefix:function(t){return this.options.prefix=t,this._update(),this},addAttribution:function(t){return t&&(this._attributions[t]||(this._attributions[t]=0),this._attributions[t]++,this._update()),this},removeAttribution:function(t){return t&&this._attributions[t]&&(this._attributions[t]--,this._update()),this},_update:function(){if(this._map){var t=[];for(var i in this._attributions)this._attributions[i]&&t.push(i);var e=[];this.options.prefix&&e.push(this.options.prefix),t.length&&e.push(t.join(", ")),this._container.innerHTML=e.join(" | ")}}});$i.mergeOptions({attributionControl:!0}),$i.addInitHook(function(){this.options.attributionControl&&(new oe).addTo(this)});te.Layers=ie,te.Zoom=ee,te.Scale=ne,te.Attribution=oe,Qi.layers=function(t,i,e){return new ie(t,i,e)},Qi.zoom=function(t){return new ee(t)},Qi.scale=function(t){return new ne(t)},Qi.attribution=function(t){return new oe(t)};var se=S.extend({initialize:function(t){this._map=t},enable:function(){return this._enabled||(this._enabled=!0,this.addHooks()),this},disable:function(){return this._enabled&&(this._enabled=!1,this.removeHooks()),this},enabled:function(){return!!this._enabled}});se.addTo=function(t,i){return t.addHandler(i,this),this};var re,ae={Events:Z},he=Tt?"touchstart mousedown":"mousedown",ue={mousedown:"mouseup",touchstart:"touchend",pointerdown:"touchend",MSPointerDown:"touchend"},le={mousedown:"mousemove",touchstart:"touchmove",pointerdown:"touchmove",MSPointerDown:"touchmove"},ce=k.extend({options:{clickTolerance:3},initialize:function(t,i,e,n){p(this,n),this._element=t,this._dragStartTarget=i||t,this._preventOutline=e},enable:function(){this._enabled||(ki(this._dragStartTarget,he,this._onDown,this),this._enabled=!0)},disable:function(){this._enabled&&(ce._dragging===this&&this.finishDrag(),Ai(this._dragStartTarget,he,this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(t){if(!t._simulated&&this._enabled&&(this._moved=!1,!pi(this._element,"leaflet-zoom-anim")&&!(ce._dragging||t.shiftKey||1!==t.which&&1!==t.button&&!t.touches||((ce._dragging=this)._preventOutline&&Mi(this._element),Ti(),Qt(),this._moving)))){this.fire("down");var i=t.touches?t.touches[0]:t,e=Ei(this._element);this._startPoint=new B(i.clientX,i.clientY),this._parentScale=Si(e),ki(document,le[t.type],this._onMove,this),ki(document,ue[t.type],this._onUp,this)}},_onMove:function(t){if(!t._simulated&&this._enabled)if(t.touches&&1i.max.x&&(e|=2),t.yi.max.y&&(e|=8),e}function ge(t,i,e,n){var o,s=i.x,r=i.y,a=e.x-s,h=e.y-r,u=a*a+h*h;return 0this._layersMaxZoom&&this.setZoom(this._layersMaxZoom),void 0===this.options.minZoom&&this._layersMinZoom&&this.getZoom()t.y!=n.y>t.y&&t.x<(n.x-e.x)*(t.y-e.y)/(n.y-e.y)+e.x&&(u=!u);return u||je.prototype._containsPoint.call(this,t,!0)}});var He=ke.extend({initialize:function(t,i){p(this,i),this._layers={},t&&this.addData(t)},addData:function(t){var i,e,n,o=v(t)?t:t.features;if(o){for(i=0,e=o.length;iu.x&&(l=s.x+n-u.x+h.x),s.x-l-a.x<0&&(l=s.x-a.x),s.y+e+h.y>u.y&&(c=s.y+e-u.y+h.y),s.y-c-a.y<0&&(c=s.y-a.y),(l||c)&&t.fire("autopanstart").panBy([l,c])}},_onCloseButtonClick:function(t){this._close(),Wi(t)},_getAnchor:function(){return I(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}});$i.mergeOptions({closePopupOnClick:!0}),$i.include({openPopup:function(t,i,e){return t instanceof sn||(t=new sn(e).setContent(t)),i&&t.setLatLng(i),this.hasLayer(t)?this:(this._popup&&this._popup.options.autoClose&&this.closePopup(),this._popup=t,this.addLayer(t))},closePopup:function(t){return t&&t!==this._popup||(t=this._popup,this._popup=null),t&&this.removeLayer(t),this}}),Se.include({bindPopup:function(t,i){return t instanceof sn?(p(t,i),(this._popup=t)._source=this):(this._popup&&!i||(this._popup=new sn(i,this)),this._popup.setContent(t)),this._popupHandlersAdded||(this.on({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!0),this},unbindPopup:function(){return this._popup&&(this.off({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,this._popup=null),this},openPopup:function(t,i){return this._popup&&this._map&&(i=this._popup._prepareOpen(this,t,i),this._map.openPopup(this._popup,i)),this},closePopup:function(){return this._popup&&this._popup._close(),this},togglePopup:function(t){return this._popup&&(this._popup._map?this.closePopup():this.openPopup(t)),this},isPopupOpen:function(){return!!this._popup&&this._popup.isOpen()},setPopupContent:function(t){return this._popup&&this._popup.setContent(t),this},getPopup:function(){return this._popup},_openPopup:function(t){var i=t.layer||t.target;this._popup&&this._map&&(Wi(t),i instanceof Re?this.openPopup(t.layer||t.target,t.latlng):this._map.hasLayer(this._popup)&&this._popup._source===i?this.closePopup():this.openPopup(i,t.latlng))},_movePopup:function(t){this._popup.setLatLng(t.latlng)},_onKeyPress:function(t){13===t.originalEvent.keyCode&&this._openPopup(t)}});var rn=on.extend({options:{pane:"tooltipPane",offset:[0,0],direction:"auto",permanent:!1,sticky:!1,interactive:!1,opacity:.9},onAdd:function(t){on.prototype.onAdd.call(this,t),this.setOpacity(this.options.opacity),t.fire("tooltipopen",{tooltip:this}),this._source&&this._source.fire("tooltipopen",{tooltip:this},!0)},onRemove:function(t){on.prototype.onRemove.call(this,t),t.fire("tooltipclose",{tooltip:this}),this._source&&this._source.fire("tooltipclose",{tooltip:this},!0)},getEvents:function(){var t=on.prototype.getEvents.call(this);return Tt&&!this.options.permanent&&(t.preclick=this._close),t},_close:function(){this._map&&this._map.closeTooltip(this)},_initLayout:function(){var t="leaflet-tooltip "+(this.options.className||"")+" leaflet-zoom-"+(this._zoomAnimated?"animated":"hide");this._contentNode=this._container=ui("div",t)},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(t){var i=this._map,e=this._container,n=i.latLngToContainerPoint(i.getCenter()),o=i.layerPointToContainerPoint(t),s=this.options.direction,r=e.offsetWidth,a=e.offsetHeight,h=I(this.options.offset),u=this._getAnchor();t="top"===s?t.add(I(-r/2+h.x,-a+h.y+u.y,!0)):"bottom"===s?t.subtract(I(r/2-h.x,-h.y,!0)):"center"===s?t.subtract(I(r/2+h.x,a/2-u.y+h.y,!0)):"right"===s||"auto"===s&&o.xthis.options.maxZoom||ethis.options.maxZoom||void 0!==this.options.minZoom&&oe.max.x)||!i.wrapLat&&(t.ye.max.y))return!1}if(!this.options.bounds)return!0;var n=this._tileCoordsToBounds(t);return D(this.options.bounds).overlaps(n)},_keyToBounds:function(t){return this._tileCoordsToBounds(this._keyToTileCoords(t))},_tileCoordsToNwSe:function(t){var i=this._map,e=this.getTileSize(),n=t.scaleBy(e),o=n.add(e);return[i.unproject(n,t.z),i.unproject(o,t.z)]},_tileCoordsToBounds:function(t){var i=this._tileCoordsToNwSe(t),e=new N(i[0],i[1]);return this.options.noWrap||(e=this._map.wrapLatLngBounds(e)),e},_tileCoordsToKey:function(t){return t.x+":"+t.y+":"+t.z},_keyToTileCoords:function(t){var i=t.split(":"),e=new B(+i[0],+i[1]);return e.z=+i[2],e},_removeTile:function(t){var i=this._tiles[t];i&&(li(i.el),delete this._tiles[t],this.fire("tileunload",{tile:i.el,coords:this._keyToTileCoords(t)}))},_initTile:function(t){mi(t,"leaflet-tile");var i=this.getTileSize();t.style.width=i.x+"px",t.style.height=i.y+"px",t.onselectstart=l,t.onmousemove=l,et&&this.options.opacity<1&&yi(t,this.options.opacity),st&&!rt&&(t.style.WebkitBackfaceVisibility="hidden")},_addTile:function(t,i){var e=this._getTilePos(t),n=this._tileCoordsToKey(t),o=this.createTile(this._wrapCoords(t),a(this._tileReady,this,t));this._initTile(o),this.createTile.length<2&&M(a(this._tileReady,this,t,null,o)),Pi(o,e),this._tiles[n]={el:o,coords:t,current:!0},i.appendChild(o),this.fire("tileloadstart",{tile:o,coords:t})},_tileReady:function(t,i,e){i&&this.fire("tileerror",{error:i,tile:e,coords:t});var n=this._tileCoordsToKey(t);(e=this._tiles[n])&&(e.loaded=+new Date,this._map._fadeAnimated?(yi(e.el,0),C(this._fadeFrame),this._fadeFrame=M(this._updateOpacity,this)):(e.active=!0,this._pruneTiles()),i||(mi(e.el,"leaflet-tile-loaded"),this.fire("tileload",{tile:e.el,coords:t})),this._noTilesToLoad()&&(this._loading=!1,this.fire("load"),et||!this._map._fadeAnimated?M(this._pruneTiles,this):setTimeout(a(this._pruneTiles,this),250)))},_getTilePos:function(t){return t.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(t){var i=new B(this._wrapX?r(t.x,this._wrapX):t.x,this._wrapY?r(t.y,this._wrapY):t.y);return i.z=t.z,i},_pxBoundsToTileRange:function(t){var i=this.getTileSize();return new O(t.min.unscaleBy(i).floor(),t.max.unscaleBy(i).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var t in this._tiles)if(!this._tiles[t].loaded)return!1;return!0}});var un=hn.extend({options:{minZoom:0,maxZoom:18,subdomains:"abc",errorTileUrl:"",zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1},initialize:function(t,i){this._url=t,(i=p(this,i)).detectRetina&&Ct&&0')}}catch(t){return function(t){return document.createElement("<"+t+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}}(),fn={_initContainer:function(){this._container=ui("div","leaflet-vml-container")},_update:function(){this._map._animatingZoom||(_n.prototype._update.call(this),this.fire("update"))},_initPath:function(t){var i=t._container=mn("shape");mi(i,"leaflet-vml-shape "+(this.options.className||"")),i.coordsize="1 1",t._path=mn("path"),i.appendChild(t._path),this._updateStyle(t),this._layers[u(t)]=t},_addPath:function(t){var i=t._container;this._container.appendChild(i),t.options.interactive&&t.addInteractiveTarget(i)},_removePath:function(t){var i=t._container;li(i),t.removeInteractiveTarget(i),delete this._layers[u(t)]},_updateStyle:function(t){var i=t._stroke,e=t._fill,n=t.options,o=t._container;o.stroked=!!n.stroke,o.filled=!!n.fill,n.stroke?(i||(i=t._stroke=mn("stroke")),o.appendChild(i),i.weight=n.weight+"px",i.color=n.color,i.opacity=n.opacity,n.dashArray?i.dashStyle=v(n.dashArray)?n.dashArray.join(" "):n.dashArray.replace(/( *, *)/g," "):i.dashStyle="",i.endcap=n.lineCap.replace("butt","flat"),i.joinstyle=n.lineJoin):i&&(o.removeChild(i),t._stroke=null),n.fill?(e||(e=t._fill=mn("fill")),o.appendChild(e),e.color=n.fillColor||n.color,e.opacity=n.fillOpacity):e&&(o.removeChild(e),t._fill=null)},_updateCircle:function(t){var i=t._point.round(),e=Math.round(t._radius),n=Math.round(t._radiusY||e);this._setPath(t,t._empty()?"M0 0":"AL "+i.x+","+i.y+" "+e+","+n+" 0,23592600")},_setPath:function(t,i){t._path.v=i},_bringToFront:function(t){_i(t._container)},_bringToBack:function(t){di(t._container)}},gn=kt?mn:$,vn=_n.extend({getEvents:function(){var t=_n.prototype.getEvents.call(this);return t.zoomstart=this._onZoomStart,t},_initContainer:function(){this._container=gn("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=gn("g"),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){li(this._container),Ai(this._container),delete this._container,delete this._rootGroup,delete this._svgSize},_onZoomStart:function(){this._update()},_update:function(){if(!this._map._animatingZoom||!this._bounds){_n.prototype._update.call(this);var t=this._bounds,i=t.getSize(),e=this._container;this._svgSize&&this._svgSize.equals(i)||(this._svgSize=i,e.setAttribute("width",i.x),e.setAttribute("height",i.y)),Pi(e,t.min),e.setAttribute("viewBox",[t.min.x,t.min.y,i.x,i.y].join(" ")),this.fire("update")}},_initPath:function(t){var i=t._path=gn("path");t.options.className&&mi(i,t.options.className),t.options.interactive&&mi(i,"leaflet-interactive"),this._updateStyle(t),this._layers[u(t)]=t},_addPath:function(t){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(t._path),t.addInteractiveTarget(t._path)},_removePath:function(t){li(t._path),t.removeInteractiveTarget(t._path),delete this._layers[u(t)]},_updatePath:function(t){t._project(),t._update()},_updateStyle:function(t){var i=t._path,e=t.options;i&&(e.stroke?(i.setAttribute("stroke",e.color),i.setAttribute("stroke-opacity",e.opacity),i.setAttribute("stroke-width",e.weight),i.setAttribute("stroke-linecap",e.lineCap),i.setAttribute("stroke-linejoin",e.lineJoin),e.dashArray?i.setAttribute("stroke-dasharray",e.dashArray):i.removeAttribute("stroke-dasharray"),e.dashOffset?i.setAttribute("stroke-dashoffset",e.dashOffset):i.removeAttribute("stroke-dashoffset")):i.setAttribute("stroke","none"),e.fill?(i.setAttribute("fill",e.fillColor||e.color),i.setAttribute("fill-opacity",e.fillOpacity),i.setAttribute("fill-rule",e.fillRule||"evenodd")):i.setAttribute("fill","none"))},_updatePoly:function(t,i){this._setPath(t,Q(t._parts,i))},_updateCircle:function(t){var i=t._point,e=Math.max(Math.round(t._radius),1),n="a"+e+","+(Math.max(Math.round(t._radiusY),1)||e)+" 0 1,0 ",o=t._empty()?"M0 0":"M"+(i.x-e)+","+i.y+n+2*e+",0 "+n+2*-e+",0 ";this._setPath(t,o)},_setPath:function(t,i){t._path.setAttribute("d",i)},_bringToFront:function(t){_i(t._path)},_bringToBack:function(t){di(t._path)}});function yn(t){return Zt||kt?new vn(t):null}kt&&vn.include(fn),$i.include({getRenderer:function(t){var i=t.options.renderer||this._getPaneRenderer(t.options.pane)||this.options.renderer||this._renderer;return i||(i=this._renderer=this._createRenderer()),this.hasLayer(i)||this.addLayer(i),i},_getPaneRenderer:function(t){if("overlayPane"===t||void 0===t)return!1;var i=this._paneRenderers[t];return void 0===i&&(i=this._createRenderer({pane:t}),this._paneRenderers[t]=i),i},_createRenderer:function(t){return this.options.preferCanvas&&pn(t)||yn(t)}});var xn=We.extend({initialize:function(t,i){We.prototype.initialize.call(this,this._boundsToLatLngs(t),i)},setBounds:function(t){return this.setLatLngs(this._boundsToLatLngs(t))},_boundsToLatLngs:function(t){return[(t=D(t)).getSouthWest(),t.getNorthWest(),t.getNorthEast(),t.getSouthEast()]}});vn.create=gn,vn.pointsToPath=Q,He.geometryToLayer=Fe,He.coordsToLatLng=Ve,He.coordsToLatLngs=qe,He.latLngToCoords=Ge,He.latLngsToCoords=Ke,He.getFeature=Ye,He.asFeature=Xe,$i.mergeOptions({boxZoom:!0});var wn=se.extend({initialize:function(t){this._map=t,this._container=t._container,this._pane=t._panes.overlayPane,this._resetStateTimeout=0,t.on("unload",this._destroy,this)},addHooks:function(){ki(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){Ai(this._container,"mousedown",this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){li(this._pane),delete this._pane},_resetState:function(){this._resetStateTimeout=0,this._moved=!1},_clearDeferredResetState:function(){0!==this._resetStateTimeout&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)},_onMouseDown:function(t){if(!t.shiftKey||1!==t.which&&1!==t.button)return!1;this._clearDeferredResetState(),this._resetState(),Qt(),Ti(),this._startPoint=this._map.mouseEventToContainerPoint(t),ki(document,{contextmenu:Wi,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseMove:function(t){this._moved||(this._moved=!0,this._box=ui("div","leaflet-zoom-box",this._container),mi(this._container,"leaflet-crosshair"),this._map.fire("boxzoomstart")),this._point=this._map.mouseEventToContainerPoint(t);var i=new O(this._point,this._startPoint),e=i.getSize();Pi(this._box,i.min),this._box.style.width=e.x+"px",this._box.style.height=e.y+"px"},_finish:function(){this._moved&&(li(this._box),fi(this._container,"leaflet-crosshair")),ti(),zi(),Ai(document,{contextmenu:Wi,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(t){if((1===t.which||1===t.button)&&(this._finish(),this._moved)){this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(a(this._resetState,this),0);var i=new N(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(i).fire("boxzoomend",{boxZoomBounds:i})}},_onKeyDown:function(t){27===t.keyCode&&this._finish()}});$i.addInitHook("addHandler","boxZoom",wn),$i.mergeOptions({doubleClickZoom:!0});var Pn=se.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(t){var i=this._map,e=i.getZoom(),n=i.options.zoomDelta,o=t.originalEvent.shiftKey?e-n:e+n;"center"===i.options.doubleClickZoom?i.setZoom(o):i.setZoomAround(t.containerPoint,o)}});$i.addInitHook("addHandler","doubleClickZoom",Pn),$i.mergeOptions({dragging:!0,inertia:!rt,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0});var Ln=se.extend({addHooks:function(){if(!this._draggable){var t=this._map;this._draggable=new ce(t._mapPane,t._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),t.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDragWrap,this),t.on("zoomend",this._onZoomEnd,this),t.whenReady(this._onZoomEnd,this))}mi(this._map._container,"leaflet-grab leaflet-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){fi(this._map._container,"leaflet-grab"),fi(this._map._container,"leaflet-touch-drag"),this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},moving:function(){return this._draggable&&this._draggable._moving},_onDragStart:function(){var t=this._map;if(t._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity){var i=D(this._map.options.maxBounds);this._offsetLimit=R(this._map.latLngToContainerPoint(i.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(i.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))}else this._offsetLimit=null;t.fire("movestart").fire("dragstart"),t.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(t){if(this._map.options.inertia){var i=this._lastTime=+new Date,e=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(e),this._times.push(i),this._prunePositions(i)}this._map.fire("move",t).fire("drag",t)},_prunePositions:function(t){for(;1i.max.x&&(t.x=this._viscousLimit(t.x,i.max.x)),t.y>i.max.y&&(t.y=this._viscousLimit(t.y,i.max.y)),this._draggable._newPos=this._draggable._startPos.add(t)}},_onPreDragWrap:function(){var t=this._worldWidth,i=Math.round(t/2),e=this._initialWorldOffset,n=this._draggable._newPos.x,o=(n-i+e)%t+i-e,s=(n+i+e)%t-i-e,r=Math.abs(o+e)i.getMaxZoom()&&1^#TvZgtfA`HxTl>c*ObP^oUZsa0{M3&luCm52}x6iK>}Afju*U6xuDThgSaCbp!1GBcTb&gUXF$;`Z& z7d>zn@1E~`-@V_v=LFhBaa_F?=tnvPJOGsbOX_Ot<0)S(|&l(Jlo) zjW`aZ?G6EWfYDe;PR$<)f949@b1oi|7zOUmA#RKta-N=hCjG9Z!0xY?j!O&xh5tx? zCoI5;znZ_dtMeRK8E^$jg>@w#Whl*)8fuy-AY&WuVFm;N?9<1zte zQ#XDM=zk0RHgCk3ZI$3c8lwLwbTA9>+W8x7NS7@-dw3h$Hm=(B(%4O^QOw@-#wJ@8 z2>cN4I(6kf4~5@>7HzZ~GpBdby=Ao*cAS}GvDWq{FD0JtOUfVgOvxC{>*PkNJUph6 z@`v5iDL}#EnMmjdy4oG7PQbn0Grd-jy$g^4ls_t7cH@|$q$sjhlRyicqU1G>l|L@c ztOx+uCq3gbe^n;WymEs^3v1-Y3H!9?{2g4~1hc`?Fwu_6{JP9pyP9s$keB&2Oi%e> zad0gzX)LtQ?jQ4*^kMo+QMGkgR3mD{34M09G~S5I9@E3U(+00000NkvXXu0mjfGt-1N literal 0 HcmV?d00001 diff --git a/ikony/google_icon.png b/ikony/google_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..f00150dc5f1e07b24b6dcea778b0963c86cd4439 GIT binary patch literal 913 zcmV;C18)3@P)X1^@s6D=Y3@00006VoOIv0RI60 z0RN!9r;`8x14cR=%R=qSS&6Kh{b{tx)Kz@*T#i3CMDQLQ*E0lzA%kLgKZVH8mrjX1e1(O=6#O~ zB}{MbBty;F-ShbU&v)+k5SFk+Tia?4W;#LcL1_W%0RvnR_yy6SoKqMGkDNGLiXmRk ziD-0Hr8T!3=mtVdH38&+w;jvgd-aj8FD)x@@vhcJQTl=AWx#GbXH*}m8Ts~jvC|ZP zB-$fQqI_`$aDcEQ@|4@TATSlZrAmzq0pTSelfVVQaR*d5R6FfFQBojp*{=bO9?(mI zJS!%@zHWG|wr+T=LDK#zQGG<=djLd_B<-m#iN|y9VgdMjS5tfHbZD5x|K#(6KObv2 zd?MksoS*N#Hn1kQc6UDLyc!;i&wJ$vK<=3DKxVYQWB$_y&;^b0e1+3is<2!W9U_$X z+X=v*`!&Se!HsCzrx=>+j*gB0A2@(11OnRtKY-nsB=q=C*qdkKD**@aDTSMhM{laL zRK_OW;SKMC_MX|_1vZoeS0fQ4NWD8Cj-I;0hFu)$4EpbQE>pH7wGslTRvATR+u zzao6$FQ2NO5!dejDpRu!{v7lw65&gQ+C_fldf>9g1W8EdsQ)G-`W--C4X@1I$Uu72 zx#`ecy=Qh5xV6ZYH&(XB1n$nBOsVhUlm>V@xs`$RHGqcKCM%vR7ao0S zev1nZ$mp@|>KOy@aeBjhJE!kpJhyHktgxrGH}>#y@H<~lt~27iyEvkQ@ZV*(kER#S z7lMDdGAu>=BKu=6Ztd#~dcj-w$8O69fBXix&J~(+a=AC5=!7-*#_l)hA-rF?geo5Z zr!Zu3WTO#nSJ;AD1ScQEPDYFKyGNeCY9DS`OK->=O)tQvN3)l&4Dv>q|e5A(o#Jl=WdL@)KhDcv$lQniIGN(Zqsk1acepUIRyi#cN!YvyeBtT{Zn^8^bPh!roAC|N93 zwphAsiG1Z!T^y1^U*Pgw<`QpQ^ zmmluE{`BJGw>MwDfBEtI+ppi>fBpIK`_JEh|Nj5~f5qcbAkb?fB|(0{3@q&2{0d4M z);V@6S0An*ItI&w}MQU33?D#%PnuJ(r z1xReIEOcvQ_zzHQEG#T-Of1xBr6wYY4-yMwaKZ3~Wf$%o3t-vDT-=3|OfoZP&hNWt z=FH>@1=i7(7y)hoQs^tN1z;8!RpAX19v**lcdBqvo=7~N2xl5t0z&^0cbKlI$nEjB ziATA!CU=mI(7rQq0I3pXIC?(O8wfBE-I@57sW8;toydM<9>A)^b_)RZ|4MV#2@tEh z&Hz9R2RHk9`>jIESvuCoW|k4L4yOTQ5DXX(OvSVqSLKrxXlAn1Tg z-hUBRu3iI^S2qi}W$MhpmI4sN>ZQy0ZEXe9c6JQ20EWs3_uuS}rg^@x_4L6AeC zxUy8!zUqf^0D*sTs<7&;7S;d&002ovPDHLkV1lmz BV~_v< literal 0 HcmV?d00001 diff --git a/index.xslt b/index.xslt index bd12c42..9293cb1 100644 --- a/index.xslt +++ b/index.xslt @@ -66,13 +66,9 @@
-

- - 1. - -

+

1.

- + + -
-
-
- - - - required - - - -
+ + + f-group --logged + +
+
+ + has-feedback f-feedback --success has-success + + + + disabled + form-control validate f-control focused + + + + required + + + +
- -
-
- - - - required - - delivery_phone - - -
+
+
+
+ + has-feedback f-feedback --success has-success + + + + disabled + form-control validate f-control focused + + + + required + + delivery_phone + + +
- - +
+ + +
@@ -171,244 +185,320 @@
+
-
-
- - - -
-
-
- -
-
- : - - -
-
- -
- form-group firm-group readonly -
- - required - - - delivery_additional - readonly - - -
-
- - -
- form-group firm-group readonly -
- - - required - - - - readonly - - -
-
+
+ + + + + + + + + +

2.

+ + + + f-group --logged + +
+
+
+ : + + +
+
+ +
+ + form-group firm-group --fade-in + +
+ + has-feedback f-feedback --success has-success + + + required + + disabled + form-control validate f-control focused + + + + delivery_additional + readonly + + +
+
+ + +
+ + form-group firm-group --fade-in - - -
- form-group move_is_firm readonly
- - - - delivery_firstname + + has-feedback f-feedback --success has-success + + + + disabled + form-control validate f-control focused + + + required + + + + readonly + + +
+
+ + +
+
+ + has-feedback f-feedback --success has-success + + + + disabled + form-control validate f-control focused + + + + delivery_firstname + readonly + required + + +
+
+ +
+
+ + has-feedback f-feedback --success has-success + + + + + disabled + form-control validate f-control focused + + + delivery_lastname + readonly + required + + +
+
+ + +
+ form-group readonly +
+ + has-feedback f-feedback --success has-success + + + + disabled + form-control validate f-control focused + + + + readonly + required + + +
+
+
+ +
+
+ + has-feedback f-feedback --success has-success + + + + disabled + form-control validate f-control focused + + + + delivery_street + readonly + required + + +
+
+ +
+
+
+ + zipcode_wrapper col-md-5 has-feedback f-feedback --success has-success + + + + disabled + form-control validate f-control focused + + + delivery_zipcode readonly required -
-
- -
- form-group move_is_firm readonly -
- - - - delivery_lastname - readonly - required - - -
-
- - -
- form-group readonly -
- - - - readonly - required - - -
-
-
- -
- form-group readonly -
- - - - delivery_street +
+ + city_wrapper col-md-7 has-feedback f-feedback --success has-success + + + + + disabled + form-control validate f-control focused + + + delivery_city readonly required -
- -
- form-group readonly -
-
- - - - delivery_zipcode - readonly - required - - -
-
- - - - delivery_city - readonly - required - - -
-
-
- - - - - - - - - - - -
- form-group readonly - -
- + + disabled + + + + + + + +
+ +
+ + f-feedback --success + + -
+ + + + selected + + + + + +
-
- +
+ + - - - - - - - - - - -
- - - - - - - - - - - - - -
- : - -
-
- -
- : - -
-
- -
- : - -
-
- -
- : - -
-
- -
- : - -
-
- -
- : - -
-
-
- : - -
-
- : -   -
-
- : - - - - - - - - - - -
-
- +
@@ -875,7 +697,7 @@
"+e.d+""+iaical_monthNames[e.m-1]+"
")}),$("#selectPickupDayWrapper").show(),$(".pickupl_hour_wrapper").show(),$("#selectPickupDay [name=\"calendar_select_date\"]").eq(1).prop("checked",!0)):($("#selectPickupDayWrapper").hide(),!1)},error:function(){Alertek.show_alert(pickupl_error)}})},setZoom:function(){var o=new google.maps.LatLngBounds;for(var e in pickup_sites.markersArray)o.extend(pickup_sites.markersArray[e].getPosition());pickup_sites.mapa.setCenter(o.getCenter()),pickup_sites.mapa.fitBounds(o),pickup_sites.mapa.setZoom(pickup_sites.mapa.getZoom()),15"+t+"";y+="
"+o+"  "+n+"
",s&&(y+="
"+s+"
"),y+="
"+l+"
",r&&(y+=""),y+="
";var k={title:t,pickupPointID:m};k.position=P,k.map=pickup_sites.mapa,pickup_sites.markerAnimation&&(k.animation=google.maps.Animation.DROP),g&&""!=g?k.icon=g:""!=$("img.marker_face").attr("src")&&markerPickupsCustomIcon&&(k.icon=pickup_sites.markerIcon);var f=new google.maps.Marker(k);pickup_sites.markersArray.push(f),google.maps.event.addListener(f,"click",function(e){return function(t){t.cancelBubble=!0,t.returnValue=!1,t.stopPropagation&&(t.stopPropagation(),t.preventDefault()),pickup_sites.markerInfo.setContent(y),pickup_sites.markerInfo.open(pickup_sites.mapa,e),$(".asideContainer_pickup [value=\""+e.pickupPointID+"\"]").prop("checked",!0),$(".asideContainer_pickup").scrollTop(0),$(".asideContainer_pickup").scrollTop($("#pickup_site [name=\"pickup_point\"]:checked + label").position().top)}}(f,i));var v=$(".asideContainer_pickup [value=\""+f.pickupPointID+"\"]").get(0);$("label[for=\"pickup_point_"+f.pickupPointID+"\"]").show().fadeTo("slow",1),google.maps.event.addDomListener(v,"click",function(t){return function(){$(".asideContainer_pickup [value=\""+t.pickupPointID+"\"]").prop("checked",!0),pickup_sites.markerInfo.setContent(y),pickup_sites.mapa.setCenter(k.position),pickup_sites.mapa.getZoom()=pickup_sites.pickupCount&&setTimeout(function(){$("div.loadingMap").fadeOut("normal",function(){});var n=$(".markerCluster[src*=\"m1.png\"]").attr("src"),e=n.substring(0,n.indexOf("1.png"));pickup_sites.setZoom();var t=!0;pickup_sites.mapa.zoom=pickup_sites.pickupCount&&setTimeout(function(){$("div.loadingMap").fadeOut("normal",function(){});var n=$(".markerCluster[src*=\"m1.png\"]").attr("src"),e=n.substring(0,n.indexOf("1.png")-1);pickup_sites.setZoom();var t=!0;pickup_sites.mapa.zoom${d.price}`),a.find("input[name=pickup_point]").val(d.id),a.find("label").attr("data-latitude",d.coordinates.latitude),a.find("label").attr("data-longitude",d.coordinates.longitude),a.find("label").attr("data-id",d.id),a.find("label").attr("data-requires_client_number",d.requiresClientNumber),a.find("label").attr("for","pickup_point_"+d.id),a.find("label").hide().css("opacity","0"),d.markerIconUrl&&(a.find("label").attr("data-icon",d.markerIconUrl),a.find("label").find("svg").replaceWith("\""+d.id+"\"/")),d.coordinates.longitude?a.find("label .map_dir").attr("href","https://www.google.com/maps/dir/?api=1&destination="+d.coordinates.latitude+","+d.coordinates.longitude):a.find("label .map_dir").attr("href","https://maps.google.com?saddr=Current+Location&daddr="+d.address.street+"+"+d.address.postcode+"+"+d.address.city),a.find("b.headerText").text(d.name);var r=""!=d.address.buildingAndHouseNumber&&null!=d.address.buildingAndHouseNumber?d.address.street+" "+d.address.buildingAndHouseNumber:d.address.street;a.find("span.streetText").text(r),a.find("span.zipcodePickup").html(d.address.postcode+" "+d.address.city+""),a.find("div.moreText").text(d.location),a.find("a.moreLink").attr("href",d.link),a.find(".headerText").before(`

${o}${t}

`),d.requiresClientNumber||a.find("input[name=client_courier_number]").remove(),$("#pickup_site .asideContainer_pickup").append(a.find(" > *"))}pickup_sites.showSel()};function geolocate(){pickup_sites.search_lat="",pickup_sites.search_lng="",navigator.geolocation&&navigator.geolocation.getCurrentPosition(function(n){var e={lat:n.coords.latitude,lng:n.coords.longitude},t=new google.maps.Circle({center:e,radius:n.coords.accuracy});pickup_sites.autocomplete.setBounds(t.getBounds())})}$(document).on("click","#locationField .btn",function(){return $("#mymap").length?(leafletGetTextLocation(),$(".leafleat-suggestions").remove()):pickup_sites.getLocation(),!1}),$(document).on("click","div.morePickup",function(){var t=$("label.pickup_point.moreInfoShow");$(this).parents("label.pickup_point").addClass("moreInfoShow"),t.removeClass("moreInfoShow")}),$(document).on("click","#pickup_site [name=\"pickup_point\"], #pickup_site [name=\"stock\"]",function(){$("#pickup_site [name=\"client_courier_number\"]").prop("disabled",!0),$(this).find("+ label [name=\"client_courier_number\"]").prop("disabled",!1).focus(),pickup_sites.printDates($(this).val())}),app_shop.run(function(){pickup_sites.country_code=app_shop.vars.country_code,pickup_sites.language=app_shop.vars.language,pickup_sites.isCod=app_shop.vars.isCod,pickup_sites.courierId=app_shop.vars.courierId,init_pickupl_site();var o="https://maps.googleapis.com/maps/api/js?key="+app_shop.vars.apiKey+"&libraries=places&callback=pickup_sites.mapInit",e=document.createElement("script");e.setAttribute("src",o),document.body.appendChild(e)},"all","#pickup_site");function MarkerClusterer(r,e,t){this.extend(MarkerClusterer,google.maps.OverlayView),this.map_=r,this.markers_=[],this.clusters_=[],this.sizes=[53,56,66,78,90],this.styles_=[],this.ready_=!1;var o=t||{};this.gridSize_=o.gridSize||60,this.minClusterSize_=o.minimumClusterSize||2,this.maxZoom_=o.maxZoom||null,this.styles_=o.styles||[],this.imagePath_=o.imagePath||this.MARKER_CLUSTER_IMAGE_PATH_,this.imageExtension_=o.imageExtension||this.MARKER_CLUSTER_IMAGE_EXTENSION_,this.zoomOnClick_=!0,null!=o.zoomOnClick&&(this.zoomOnClick_=o.zoomOnClick),this.averageCenter_=!1,null!=o.averageCenter&&(this.averageCenter_=o.averageCenter),this.setupStyles_(),this.setMap(r),this.prevZoom_=this.map_.getZoom();var n=this;google.maps.event.addListener(this.map_,"zoom_changed",function(){var a=n.map_.getZoom(),r=n.map_.minZoom||0,t=Math.min(n.map_.maxZoom||100,n.map_.mapTypes[n.map_.getMapTypeId()].maxZoom);a=Math.min(Math.max(a,r),t),n.prevZoom_!=a&&(n.prevZoom_=a,n.resetViewport())}),google.maps.event.addListener(this.map_,"idle",function(){n.redraw()}),e&&(e.length||Object.keys(e).length)&&this.addMarkers(e,!1)}MarkerClusterer.prototype.MARKER_CLUSTER_IMAGE_PATH_="../images/m",MarkerClusterer.prototype.MARKER_CLUSTER_IMAGE_EXTENSION_="png",MarkerClusterer.prototype.extend=function(o,e){return function(o){for(var e in o.prototype)this.prototype[e]=o.prototype[e];return this}.apply(o,[e])},MarkerClusterer.prototype.onAdd=function(){this.setReady_(!0)},MarkerClusterer.prototype.draw=function(){},MarkerClusterer.prototype.setupStyles_=function(){if(!this.styles_.length)for(var o,n=0;o=this.sizes[n];n++)this.styles_.push({url:this.imagePath_+(n+1)+"."+this.imageExtension_,height:o,width:o})},MarkerClusterer.prototype.fitMapToMarkers=function(){for(var a,r=this.getMarkers(),t=new google.maps.LatLngBounds,o=0;a=r[o];o++)t.extend(a.getPosition());this.map_.fitBounds(t)},MarkerClusterer.prototype.setStyles=function(t){this.styles_=t},MarkerClusterer.prototype.getStyles=function(){return this.styles_},MarkerClusterer.prototype.isZoomOnClick=function(){return this.zoomOnClick_},MarkerClusterer.prototype.isAverageCenter=function(){return this.averageCenter_},MarkerClusterer.prototype.getMarkers=function(){return this.markers_},MarkerClusterer.prototype.getTotalMarkers=function(){return this.markers_.length},MarkerClusterer.prototype.setMaxZoom=function(t){this.maxZoom_=t},MarkerClusterer.prototype.getMaxZoom=function(){return this.maxZoom_},MarkerClusterer.prototype.calculator_=function(r,e){for(var t=0,s=r.length,n=s;0!==n;)n=parseInt(n/10,10),t++;return t=Math.min(t,e),{text:s,index:t}},MarkerClusterer.prototype.setCalculator=function(t){this.calculator_=t},MarkerClusterer.prototype.getCalculator=function(){return this.calculator_},MarkerClusterer.prototype.addMarkers=function(a,e){if(a.length)for(var t,r=0;t=a[r];r++)this.pushMarkerTo_(t);else if(Object.keys(a).length)for(var t in a)this.pushMarkerTo_(a[t]);e||this.redraw()},MarkerClusterer.prototype.pushMarkerTo_=function(o){if(o.isAdded=!1,o.draggable){var e=this;google.maps.event.addListener(o,"dragend",function(){o.isAdded=!1,e.repaint()})}this.markers_.push(o)},MarkerClusterer.prototype.addMarker=function(o,e){this.pushMarkerTo_(o),e||this.redraw()},MarkerClusterer.prototype.removeMarker_=function(a){var e=-1;if(this.markers_.indexOf)e=this.markers_.indexOf(a);else for(var r,s=0;r=this.markers_[s];s++)if(r==a){e=s;break}return-1!=e&&(a.setMap(null),this.markers_.splice(e,1),!0)},MarkerClusterer.prototype.removeMarker=function(n,e){var t=this.removeMarker_(n);return!e&&t&&(this.resetViewport(),this.redraw(),!0)},MarkerClusterer.prototype.removeMarkers=function(r,e){for(var t,l,d=!1,p=0;t=r[p];p++)l=this.removeMarker_(t),d=d||l;if(!e&&d)return this.resetViewport(),this.redraw(),!0},MarkerClusterer.prototype.setReady_=function(t){this.ready_||(this.ready_=t,this.createClusters_())},MarkerClusterer.prototype.getTotalClusters=function(){return this.clusters_.length},MarkerClusterer.prototype.getMap=function(){return this.map_},MarkerClusterer.prototype.setMap=function(t){this.map_=t},MarkerClusterer.prototype.getGridSize=function(){return this.gridSize_},MarkerClusterer.prototype.setGridSize=function(t){this.gridSize_=t},MarkerClusterer.prototype.getMinClusterSize=function(){return this.minClusterSize_},MarkerClusterer.prototype.setMinClusterSize=function(t){this.minClusterSize_=t},MarkerClusterer.prototype.getExtendedBounds=function(d){var e=this.getProjection(),t=new google.maps.LatLng(d.getNorthEast().lat(),d.getNorthEast().lng()),o=new google.maps.LatLng(d.getSouthWest().lat(),d.getSouthWest().lng()),n=e.fromLatLngToDivPixel(t);n.x+=this.gridSize_,n.y-=this.gridSize_;var a=e.fromLatLngToDivPixel(o);a.x-=this.gridSize_,a.y+=this.gridSize_;var r=e.fromDivPixelToLatLng(n),s=e.fromDivPixelToLatLng(a);return d.extend(r),d.extend(s),d},MarkerClusterer.prototype.isMarkerInBounds_=function(o,e){return e.contains(o.getPosition())},MarkerClusterer.prototype.clearMarkers=function(){this.resetViewport(!0),this.markers_=[]},MarkerClusterer.prototype.resetViewport=function(a){for(var e,r=0;e=this.clusters_[r];r++)e.remove();for(var s,r=0;s=this.markers_[r];r++)s.isAdded=!1,a&&s.setMap(null);this.clusters_=[]},MarkerClusterer.prototype.repaint=function(){var n=this.clusters_.slice();this.clusters_.length=0,this.resetViewport(),this.redraw(),window.setTimeout(function(){for(var e,a=0;e=n[a];a++)e.remove()},0)},MarkerClusterer.prototype.redraw=function(){this.createClusters_()},MarkerClusterer.prototype.distanceBetweenPoints_=function(s,e){if(!s||!e)return 0;var t=(e.lat()-s.lat())*Math.PI/180,o=(e.lng()-s.lng())*Math.PI/180,n=Math.sin(t/2)*Math.sin(t/2)+Math.cos(s.lat()*Math.PI/180)*Math.cos(e.lat()*Math.PI/180)*Math.sin(o/2)*Math.sin(o/2),r=2*Math.atan2(Math.sqrt(n),Math.sqrt(1-n));return 6371*r},MarkerClusterer.prototype.addToClosestCluster_=function(d){for(var e,p,_=4e4,m=null,c=d.getPosition(),r=0;e=this.clusters_[r];r++)if(p=e.getCenter(),p){var u=this.distanceBetweenPoints_(p,d.getPosition());u<_&&(_=u,m=e)}if(m&&m.isMarkerInClusterBounds(d))m.addMarker(d);else{var e=new Cluster(this);e.addMarker(d),this.clusters_.push(e)}},MarkerClusterer.prototype.createClusters_=function(){if(this.ready_)for(var a,r=new google.maps.LatLngBounds(this.map_.getBounds().getSouthWest(),this.map_.getBounds().getNorthEast()),t=this.getExtendedBounds(r),o=0;a=this.markers_[o];o++)!a.isAdded&&this.isMarkerInBounds_(a,t)&&this.addToClosestCluster_(a)};function Cluster(t){this.markerClusterer_=t,this.map_=t.getMap(),this.gridSize_=t.getGridSize(),this.minClusterSize_=t.getMinClusterSize(),this.averageCenter_=t.isAverageCenter(),this.center_=null,this.markers_=[],this.bounds_=null,this.clusterIcon_=new ClusterIcon(this,t.getStyles(),t.getGridSize())}Cluster.prototype.isMarkerAlreadyAdded=function(n){if(this.markers_.indexOf)return-1!=this.markers_.indexOf(n);for(var e,a=0;e=this.markers_[a];a++)if(e==n)return!0;return!1},Cluster.prototype.addMarker=function(s){if(this.isMarkerAlreadyAdded(s))return!1;if(!this.center_)this.center_=s.getPosition(),this.calculateBounds_();else if(this.averageCenter_){var e=this.markers_.length+1,t=(this.center_.lat()*(e-1)+s.getPosition().lat())/e,o=(this.center_.lng()*(e-1)+s.getPosition().lng())/e;this.center_=new google.maps.LatLng(t,o),this.calculateBounds_()}s.isAdded=!0,this.markers_.push(s);var n=this.markers_.length;if(n=this.minClusterSize_&&s.setMap(null),this.updateIcon(),!0},Cluster.prototype.getMarkerClusterer=function(){return this.markerClusterer_},Cluster.prototype.getBounds=function(){for(var a,r=new google.maps.LatLngBounds(this.center_,this.center_),t=this.getMarkers(),o=0;a=t[o];o++)r.extend(a.getPosition());return r},Cluster.prototype.remove=function(){this.clusterIcon_.remove(),this.markers_.length=0,delete this.markers_},Cluster.prototype.getSize=function(){return this.markers_.length},Cluster.prototype.getMarkers=function(){return this.markers_},Cluster.prototype.getCenter=function(){return this.center_},Cluster.prototype.calculateBounds_=function(){var t=new google.maps.LatLngBounds(this.center_,this.center_);this.bounds_=this.markerClusterer_.getExtendedBounds(t)},Cluster.prototype.isMarkerInClusterBounds=function(t){return this.bounds_.contains(t.getPosition())},Cluster.prototype.getMap=function(){return this.map_},Cluster.prototype.updateIcon=function(){var s=this.map_.getZoom(),e=this.markerClusterer_.getMaxZoom();if(e&&s>e){for(var t,l=0;t=this.markers_[l];l++)t.setMap(this.map_);return}if(this.markers_.length .pickup_search_here",function(){pickup_sites.search_lat=pickup_sites.mapa.center.lat(),pickup_sites.search_lng=pickup_sites.mapa.center.lng(),pickup_sites.ajaxGetPickup(!0)});var mymap,isLoaded=!1,isWaitingEnd=!1,leafletGetPickups=function(l,e,t){radius=15<=t?1:14==t?2:13==t?4:12==t?7:11==t?10:10==t?15:20;const s=pickup_sites.courierId.split("-")[1],o=document.querySelectorAll(`#osc_order1_${"1"==s?"prepaid":"dvp"} input[data-pickuppoint="y"]`),d=[];o.forEach(o=>{let n;const r=o.value.split("-")[0];n=t?{courierId:r,"location[latitude]":l,"location[longitude]":e,radius:radius,isCod:pickup_sites.isCod}:{courierId:r,"location[latitude]":l,"location[longitude]":e,isCod:pickup_sites.isCod},d.push($.ajax({type:"GET",url:"/ajax/getPickups.php",data:n,dataType:"json"}))}),Promise.all(d).then(n=>{const r={cities:[],pickupPoints:[]};if(n.forEach(t=>{0"+pickupl_nopoints_in_area+"
")):$("div.asideContainer_pickup").prepend("
"+pickupl_nopoints+"
"),$(".loadingMap").hide(),!1;for(i in leafletItems=[],r.pickupPoints){var t=r.pickupPoints[i].coordinates.latitude,l=r.pickupPoints[i].coordinates.longitude;(""==t||""==l)&&($.ajaxSetup({async:!1}),$.get(location.protocol+"//nominatim.openstreetmap.org/search?format=json&q="+r.pickupPoints[i].address.street+", "+r.pickupPoints[i].address.city+" "+r.pickupPoints[i].address.city+" "+r.pickupPoints[i].address.country,function(o){jQuery.isEmptyObject(o)?console.log("nie mog\u0119 znale\u017A\u0107 korodynat\xF3w adresu!"):(t=o[0].lat,l=o[0].lon)})),r.pickupPoints[i].iconOptions=getMarkerIcon(r.pickupPoints[i].courierId),r.pickupPoints[i].price=document.getElementById(`item_${r.pickupPoints[i].courierId}-${s}`).parentElement.querySelector(".price").innerHTML,leafletItems.push({id:r.pickupPoints[i].id,name:r.pickupPoints[i].name,link:r.pickupPoints[i].link,address:r.pickupPoints[i].address,courierId:r.pickupPoints[i].courierId,price:r.pickupPoints[i].price,iconOptions:r.pickupPoints[i].iconOptions,lat:t,lon:l})}setPickupPointsNoMap(r,!1,!0),jQuery.isEmptyObject(leafletItems)||leafletStartMap(leafletItems[0].lat,leafletItems[0].lon,!0)})},leafletMarker=[],leafletItems=[];function leafletDelMarkers(){for(i=0;iOpenStreetMap contributors"}).addTo(mymap),isLoaded=!0,isWaitingEnd=!0),$(".loadingPoints").remove(),i=0;i`+stocks_list_more_txt+``+stocks_list_choose+``,e="";e=null==leafletItems[i].address.street?`
`+leafletItems[i].address+`
`:`
`+leafletItems[i].address.street+` `+leafletItems[i].address.buildingAndHouseNumber+` `+leafletItems[i].address.city+`
`;const t=`${leafletItems[i].price}`,o=document.querySelector(`#item_${leafletItems[i].courierId}-${a}`).parentElement,s=o.querySelector(".name").innerHTML,l=o.querySelector(".photo").innerHTML;let d=`

${l}${s}

`+leafletItems[i].name+`
`+e+t+`
`+r;markersList.push(leafletItems[i].id),markers[leafletItems[i].id]=L.marker([leafletItems[i].lat,leafletItems[i].lon],{icon:leafletItems[i].iconOptions}).addTo(mymap).on("click",leafletOnClick).bindPopup(d)}mymap.setView(new L.LatLng(n,e));let r=$(".asideContainer_pickup label.pickup_point").eq(0).attr("data-id");$(".asideContainer_pickup input[value=\""+r+"\"]").click(),$("img.leaflet-marker-icon").each(function(){var n=$(this).attr("src"),a=n.includes("preview/");a&&(n=n.replace("preview/",""));var t=n.includes("marker-icon");t&&(n=n.replace("-2x","")),$(this).attr("src",n)})},timeoutLeafLet=null;$(document).on("input","#autocomplete_location.autocomplete_nomap",function(){var t=$(this);clearTimeout(timeoutLeafLet),timeoutLeafLet=setTimeout(function(){3 .pickup_search_here_leaflet",function(){var o=mymap.getCenter(),e=mymap.getZoom();leafletDelMarkers(),selected_pickup_point={},leafletGetPickups(o.lat,o.lng,e)}),$(document).on("click","#pickup_site [name=\"pickup_point\"], #pickup_site [name=\"stock\"]",function(){const o=$(this).val();if(markers[o]){let e=markers[o].getLatLng();mymap.setView(new L.LatLng(e.lat,e.lng)),markers[o].openPopup()}});var leafletGetCoords=function(n){let a="",r="";n?$.get(location.protocol+"//nominatim.openstreetmap.org/search?format=json&q="+n,function(t){jQuery.isEmptyObject(t)?($(".asideContainer_pickup label.pickup_point").length&&($(".asideContainer_pickup label.pickup_point").each(function(){var s=$(this).data("id"),e=$(this).find(".headerText").text(),t=$(this).find(".map_dir").attr("href"),o=$(this).find(".streetText").text()+"
"+$(this).find(".zipcodePickup").text(),n=$(this).data("latitude"),a=$(this).data("longitude");leafletItems.push({id:s,name:e,link:t,address:o,lat:n,lon:a})}),leafletStartMap(leafletItems[0].lat,leafletItems[0].lon,!0)),$("div.asideContainer_pickup .menu_messages_message").length&&$("div.asideContainer_pickup .menu_messages_message").remove(),$("div.asideContainer_pickup").prepend("
"+pickupl_nopoints+"
")):(a=t[0].lat,r=t[0].lon,leafletGetPickups(a,r))}):$(".asideContainer_pickup label.pickup_point").length&&($(".asideContainer_pickup label.pickup_point").each(function(){var s=$(this).data("id"),e=$(this).find(".headerText").text(),t=$(this).find(".map_dir").attr("href"),o=$(this).find(".streetText").text()+"
"+$(this).find(".zipcodePickup").text(),n=$(this).data("latitude"),a=$(this).data("longitude");leafletItems.push({id:s,name:e,link:t,address:o,lat:n,lon:a})}),leafletStartMap(leafletItems[0].lat,leafletItems[0].lon,!0))},leafletGetLocation=function(t){$.get(location.protocol+"//nominatim.openstreetmap.org/search?format=json&q="+t,function(t){if(!jQuery.isEmptyObject(t))for(i in $("#locationField").append("
"),t)$(".leafleat-suggestions").append("
"+t[i].display_name+"
");else leafletStartMap(53.428,14.552,!0),$("div.asideContainer_pickup .menu_messages_message").length&&$("div.asideContainer_pickup .menu_messages_message").remove(),$("div.asideContainer_pickup").prepend("
"+pickupl_nopoints+"
")})},leafletGetTextLocation=function(){$("#mymap").prepend(`
${}...
`);var t=$("#autocomplete_location").val();selected_pickup_point={},$.get(location.protocol+"//nominatim.openstreetmap.org/search?format=json&q="+t,function(e){if(!jQuery.isEmptyObject(e))leafletDelMarkers(),leafletGetPickups(e[0].lat,e[0].lon),$("#autocomplete_location").val(e[0].display_name);else{if(t.search(",")){var a=t.split(","),o=a[a.length-1].trim();leafletGetCoords(o)}$("div.asideContainer_pickup .menu_messages_message").length&&$("div.asideContainer_pickup .menu_messages_message").remove(),$("div.asideContainer_pickup").prepend("
"+pickupl_nopoints+"
")}})};app_shop.run(function(){if($("#autocomplete_location").length&&""!=$("#autocomplete_location").val()){let t=$("#autocomplete_location").val();leafletGetCoords(t)}else leafletGetCoords(!1)},"all","#mymap"),app_shop.run(function(){$("#mymap").before($(".map_button_search"))},1,"#mymap"),app_shop.run(function(){$("#mymap").prepend($(".map_button_search"))},[2,3,4],"#mymap"),!function(o,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(o.L={})}(this,function(n){"use strict";function v(e){var o,n,a,d;for(n=1,a=arguments.length;nRt.indexOf(t.target.tagName)))return;go(t)}Q(t,o)});n["_leaflet_touchstart"+a]=t,n.addEventListener(kt,t,!1),Dt||(document.documentElement.addEventListener(kt,W,!0),document.documentElement.addEventListener(At,G,!0),document.documentElement.addEventListener(It,K,!0),document.documentElement.addEventListener(Ot,K,!0),Dt=!0)}(n,t,a):"touchmove"===o?function(n,o,a){function t(t){(t.pointerType!==t.MSPOINTER_TYPE_MOUSE&&"mouse"!==t.pointerType||0!==t.buttons)&&Q(t,o)}n["_leaflet_touchmove"+a]=t,n.addEventListener(At,t,!1)}(n,t,a):"touchend"==o&&function(n,o,a){function t(t){Q(t,o)}n["_leaflet_touchend"+a]=t,n.addEventListener(It,t,!1),n.addEventListener(Ot,t,!1)}(n,t,a),this}function W(t){Nt[t.pointerId]=t,Cn++}function G(t){Nt[t.pointerId]&&(Nt[t.pointerId]=t)}function K(t){delete Nt[t.pointerId],Cn--}function Q(e,o){for(var t in e.touches=[],Nt)e.touches.push(Nt[t]);e.changedTouches=[e],o(e)}function re(n,s,a){function t(n){var o;if(xt){if(!it||"mouse"===n.pointerType)return;o=Cn}else o=n.touches.length;if(!(1=a,l=r}}function o(e){if(c&&!d.cancelBubble){if(xt){if(!it||"mouse"===e.pointerType)return;var o,n,p={};for(n in d)o=d[n],p[n]=o&&o.bind?o.bind(d):o;d=p}d.type="dblclick",d.button=0,s(d),l=null}}var l,d,c=!1;return n["_leaflet_"+An+a]=t,n["_leaflet_"+Ko+a]=o,n["_leaflet_dblclick"+a]=s,n.addEventListener(An,t,!!zt&&{passive:!1}),n.addEventListener(Ko,o,!!zt&&{passive:!1}),n.addEventListener("dblclick",s,!1),this}function Pe(o,a){var t=o["_leaflet_"+An+a],r=o["_leaflet_"+Ko+a],e=o["_leaflet_dblclick"+a];return o.removeEventListener(An,t,!!zt&&{passive:!1}),o.removeEventListener(Ko,r,!!zt&&{passive:!1}),it||o.removeEventListener("dblclick",e,!1),this}function Qe(t){return"string"==typeof t?document.getElementById(t):t}function Pt(e,o){var t=e.style[o]||e.currentStyle&&e.currentStyle[o];if((!t||"auto"===t)&&document.defaultView){var n=document.defaultView.getComputedStyle(e,null);t=n?n[o]:null}return"auto"===t?null:t}function wt(n,o,t){var a=document.createElement(n);return a.className=o||"",t&&t.appendChild(a),a}function Mt(o){var e=o.parentNode;e&&e.removeChild(o)}function Bt(t){for(;t.firstChild;)t.removeChild(t.firstChild)}function Ht(o){var e=o.parentNode;e&&e.lastChild!==o&&e.appendChild(o)}function Wt(o){var e=o.parentNode;e&&e.firstChild!==o&&e.insertBefore(o,e.firstChild)}function Ft(e,o){if(void 0!==e.classList)return e.classList.contains(o);var t=Gt(e);return 0a||n.target._simulatedClick&&!n._simulated?yo(n):void(Jo=t,o(n))}(t,d)}),a.addEventListener(r,t,!1)):"attachEvent"in a&&a.attachEvent("on"+r,t):re(a,t,e),a._leaflet_events=a._leaflet_events||{},a._leaflet_events[e]=t}function _o(a,r,t,s){var e=r+H(t)+(s?"_"+H(s):""),n=a._leaflet_events&&a._leaflet_events[e];return n?void(xt&&0===r.indexOf("touch")?function(n,o,t){var a=n["_leaflet_"+o+t];"touchstart"===o?n.removeEventListener(kt,a,!1):"touchmove"===o?n.removeEventListener(At,a,!1):"touchend"==o&&(n.removeEventListener(It,a,!1),n.removeEventListener(Ot,a,!1))}(a,r,e):!Lt||"dblclick"!==r||xt&&ht?"removeEventListener"in a?"mousewheel"===r?a.removeEventListener("onwheel"in a?"wheel":"mousewheel",n,!!zt&&{passive:!1}):a.removeEventListener("mouseenter"===r?"mouseover":"mouseleave"===r?"mouseout":r,n,!1):"detachEvent"in a&&a.detachEvent("on"+r,n):Pe(a,e),a._leaflet_events[e]=null):this}function mo(t){return t.stopPropagation?t.stopPropagation():t.originalEvent?t.originalEvent._stopped=!0:t.cancelBubble=!0,xo(t),this}function co(t){return po(t,"mousewheel",mo),this}function uo(t){return so(t,"mousedown touchstart dblclick",mo),po(t,"click",vo),this}function go(t){return t.preventDefault?t.preventDefault():t.returnValue=!1,this}function yo(t){return go(t),mo(t),this}function ho(n,o){if(!o)return new y(n.clientX,n.clientY);var t=ro(o),a=t.boundingClientRect;return new y((n.clientX-a.left)/t.x-o.clientLeft,(n.clientY-a.top)/t.y-o.clientTop)}function fo(t){return it?t.wheelDeltaY/2:t.deltaY&&0===t.deltaMode?-t.deltaY/$o:t.deltaY&&1===t.deltaMode?20*-t.deltaY:t.deltaY&&2===t.deltaMode?60*-t.deltaY:t.deltaX||t.deltaZ?0:t.wheelDelta?(t.wheelDeltaY||t.wheelDelta)/2:t.detail&&32765>Math.abs(t.detail)?20*-t.detail:t.detail?60*(t.detail/-32765):0}function vo(t){ln[t.type]=!0}function xo(o){var e=ln[o.type];return ln[o.type]=!1,e}function Po(e,o){var t=o.relatedTarget;if(!t)return!0;try{for(;t&&t!==e;)t=t.parentNode}catch(t){return!1}return t!==e}function ko(t){return new kn(t)}function bo(e,t){if(!t||!e.length)return e.slice();var n=t*t;return e=function(o,a){var t=o.length,r=new("undefined"==typeof Uint8Array?Array:Uint8Array)(t);r[0]=r[t-1]=1,function a(r,t,l,e,n){var o,d,c,u=0;for(d=e+1;d<=n-1;d++)c=me(r[d],r[e],r[n],!0),uo.max.x&&(t|=2),e.yo.max.y&&(t|=8),t}function me(o,a,t,r){var e,s=a.x,l=a.y,d=t.x-s,u=t.y-l,h=d*d+u*u;return 0l;l++){for(c=h[l],a=[],r=0,s=(m=t.length)-1;r=this.min.x&&r.x<=this.max.x&&t.y>=this.min.y&&r.y<=this.max.y},intersects:function(t){t=w(t);var r=this.min,l=this.max,d=t.min,e=t.max,n=e.x>=r.x&&d.x<=l.x,o=e.y>=r.y&&d.y<=l.y;return n&&o},overlaps:function(t){t=w(t);var r=this.min,l=this.max,d=t.min,e=t.max,n=e.x>r.x&&d.xr.y&&d.y=d.lat&&o.lat<=l.lat&&t.lng>=d.lng&&o.lng<=l.lng},intersects:function(t){t=S(t);var r=this._southWest,l=this._northEast,d=t.getSouthWest(),e=t.getNorthEast(),n=e.lat>=r.lat&&d.lat<=l.lat,o=e.lng>=r.lng&&d.lng<=l.lng;return n&&o},overlaps:function(t){t=S(t);var r=this._southWest,l=this._northEast,d=t.getSouthWest(),e=t.getNorthEast(),n=e.lat>r.lat&&d.latr.lng&&d.lngst&&!("AudioNode"in window),at=!!window.opera,ht=N("chrome"),ut=N("gecko")&&!et&&!at&&!J,lt=!ht&&N("safari"),ct=N("phantom"),_t=("OTransition"in X),dt=0===navigator.platform.indexOf("Win"),pt=J&&"transition"in X,mt="WebKitCSSMatrix"in window&&"m11"in new window.WebKitCSSMatrix&&!ot,ft=("MozPerspective"in X),gt=!window.L_DISABLE_3D&&(pt||mt||ft)&&!_t&&!ct,vt="undefined"!=typeof orientation||N("mobile"),yt=!window.PointerEvent&&window.MSPointerEvent,xt=!et&&(window.PointerEvent||yt),Lt=!window.L_NO_TOUCH&&(xt||"ontouchstart"in window||window.DocumentTouch&&document instanceof window.DocumentTouch),bt=vt&&at,Tt=1<(window.devicePixelRatio||window.screen.deviceXDPI/window.screen.logicalXDPI),zt=function(){var t=!1;try{var n=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("testPassiveEventSupport",Y,n),window.removeEventListener("testPassiveEventSupport",Y,n)}catch(t){}return t},Ct=!!document.createElement("canvas").getContext,Et=document.createElementNS&&R("svg").createSVGRect,St=!Et&&function(){try{var o=document.createElement("div");o.innerHTML="";var e=o.firstChild;return e.style.behavior="url(#default#VML)",e&&"object"==typeof e.adj}catch(t){return!1}}(),Zt=(Object.freeze||Object)({ie:J,ielt9:tt,edge:it,webkit:et,android:nt,android23:ot,androidStock:rt,opera:at,chrome:ht,gecko:ut,safari:lt,phantom:ct,opera12:_t,win:dt,ie3d:pt,webkit3d:mt,gecko3d:ft,any3d:gt,mobile:vt,mobileWebkit:vt&&et,mobileWebkit3d:vt&&mt,msPointer:yt,pointer:xt,touch:Lt,mobileOpera:bt,mobileGecko:vt&&ut,retina:Tt,passiveEvents:zt,canvas:Ct,svg:Et,vml:St}),kt=yt?"MSPointerDown":"pointerdown",At=yt?"MSPointerMove":"pointermove",It=yt?"MSPointerUp":"pointerup",Ot=yt?"MSPointerCancel":"pointercancel",Rt=["INPUT","SELECT","OPTION"],Nt={},Dt=!1,Cn=0,An=yt?"MSPointerDown":xt?"pointerdown":"touchstart",Ko=yt?"MSPointerUp":xt?"pointerup":"touchend",Kt=Jt(["transform","webkitTransform","OTransform","MozTransform","msTransform"]),Yt=Jt(["webkitTransition","transition","OTransition","MozTransition","msTransition"]),Yo="webkitTransition"===Yt||"OTransition"===Yt?Yt+"End":"transitionend";if("onselectstart"in document)Bo=function(){so(window,"selectstart",go)},Oo=function(){lo(window,"selectstart",go)};else{var Xo=Jt(["userSelect","WebkitUserSelect","OUserSelect","MozUserSelect","msUserSelect"]);Bo=function(){if(Xo){var t=document.documentElement.style;Ro=t[Xo],t[Xo]="none"}},Oo=function(){Xo&&(document.documentElement.style[Xo]=Ro,Ro=void 0)}}var Jo,Mn=(Object.freeze||Object)({TRANSFORM:Kt,TRANSITION:Yt,TRANSITION_END:Yo,get:Qe,getStyle:Pt,create:wt,remove:Mt,empty:Bt,toFront:Ht,toBack:Wt,hasClass:Ft,addClass:qt,removeClass:Vt,setClass:Ut,getClass:Gt,setOpacity:Xt,testProp:Jt,setTransform:Qt,setPosition:$t,getPosition:eo,disableTextSelection:Bo,enableTextSelection:Oo,disableImageDrag:to,enableImageDrag:oo,preventOutline:no,restoreOutline:ao,getSizedParentNode:io,getScale:ro}),$o=dt&&ht?2*window.devicePixelRatio:ut?window.devicePixelRatio:1,ln={},pn=(Object.freeze||Object)({on:so,off:lo,stopPropagation:mo,disableScrollPropagation:co,disableClickPropagation:uo,preventDefault:go,stop:yo,getMousePosition:ho,getWheelDelta:fo,fakeStop:vo,skipped:xo,isExternalTarget:Po,addListener:so,removeListener:lo}),yn=E.extend({run:function(n,o,t,a){this.stop(),this._el=n,this._inProgress=!0,this._duration=t||.25,this._easeOutPower=1/Math.max(a||.5,.2),this._startPos=eo(n),this._offset=o.subtract(this._startPos),this._startTime=+new Date,this.fire("start"),this._animate()},stop:function(){this._inProgress&&(this._step(!0),this._complete())},_animate:function(){this._animId=ae(this._animate,this),this._step()},_step:function(e){var o=+new Date-this._startTime,t=1e3*this._duration;ot?-18:Math.log(t)}function n(t){return(Math.exp(t)-Math.exp(-t))/2}function T(t){return(Math.exp(t)+Math.exp(-t))/2}function e(e){return f*(T(c)*function(e){return n(e)/T(e)}(c+u*e)-n(c))/l}if(!1===(t=t||{}).animate||!gt)return this.setView(y,b,t);this._stop();var d=this.project(this.getCenter()),p=this.project(y),s=this.getSize(),r=this._zoom;y=M(y),b=void 0===b?r:b;var f=Math.max(s.x,s.y),a=f*this.getZoomScale(r,b),h=p.distanceTo(d)||1,u=1.42,l=u*u,c=o(0),_=Date.now(),m=(o(1)-c)/u,g=t.duration?1e3*t.duration:.8*(1e3*m);return this._moveStart(!0,t.noMoveStart),function a(){var o=(Date.now()-_)/g,t=function(t){return 1-Math.pow(1-t,1.5)}(o)*m;1>=o?(this._flyToFrame=ae(a,this),this._move(this.unproject(d.add(p.subtract(d).multiplyBy(e(t)/h)),r),this.getScaleZoom(f/function(t){return f*(T(c)/T(c+u*t))}(t),r),{flyTo:!0})):this._move(y,b)._moveEnd(!0)}.call(this),this},flyToBounds:function(e,o){var t=this._getBoundsCenterZoom(e,o);return this.flyTo(t.center,t.zoom,o)},setMaxBounds:function(t){return(t=S(t)).isValid()?(this.options.maxBounds&&this.off("moveend",this._panInsideMaxBounds),this.options.maxBounds=t,this._loaded&&this._panInsideMaxBounds(),this.on("moveend",this._panInsideMaxBounds)):(this.options.maxBounds=null,this.off("moveend",this._panInsideMaxBounds))},setMinZoom:function(o){var e=this.options.minZoom;return this.options.minZoom=o,this._loaded&&e!==o&&(this.fire("zoomlevelschange"),this.getZoom()this.options.maxZoom)?this.setZoom(o):this},panInsideBounds:function(n,o){this._enforcingBounds=!0;var t=this.getCenter(),a=this._limitCenter(t,this._zoom,S(n));return t.equals(a)||this.panTo(a,o),this._enforcingBounds=!1,this},panInside:function(c,d){var u=b((d=d||{}).paddingTopLeft||d.padding||[0,0]),p=b(d.paddingBottomRight||d.padding||[0,0]),e=this.getCenter(),n=this.project(e),o=this.project(c),s=this.getPixelBounds(),r=s.getSize().divideBy(2),a=w([s.min.add(u),s.max.subtract(p)]);if(!a.contains(o)){this._enforcingBounds=!0;var _=n.subtract(o),m=b(o.x+_.x,o.y+_.y);(o.xa.max.x)&&(m.x=n.x-_.x,0<_.x?m.x+=r.x-u.x:m.x-=r.x-p.x),(o.ya.max.y)&&(m.y=n.y-_.y,0<_.y?m.y+=r.y-u.y:m.y-=r.y-p.y),this.panTo(this.unproject(m),d),this._enforcingBounds=!1}return this},invalidateSize:function(t){if(!this._loaded)return this;t=v({animate:!1,pan:!0},!0===t?{animate:!0}:t);var s=this.getSize();this._sizeChanged=!0,this._lastCenter=null;var r=this.getSize(),l=s.divideBy(2).round(),e=r.divideBy(2).round(),n=l.subtract(e);return n.x||n.y?(t.animate&&t.pan?this.panBy(n):(t.pan&&this._rawPanBy(n),this.fire("move"),t.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(h(this.fire,this,"moveend"),200)):this.fire("moveend")),this.fire("resize",{oldSize:s,newSize:r})):this},stop:function(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire("viewreset"),this._stop()},locate:function(e){if(e=this._locateOptions=v({timeout:1e4,watch:!1},e),!("geolocation"in navigator))return this._handleGeolocationError({code:0,message:"Geolocation not supported."}),this;var t=h(this._handleGeolocationResponse,this),n=h(this._handleGeolocationError,this);return e.watch?this._locationWatchId=navigator.geolocation.watchPosition(t,n,e):navigator.geolocation.getCurrentPosition(t,n,e),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(e){var o=e.code,t=e.message||(1===o?"permission denied":2===o?"position unavailable":"timeout");this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire("locationerror",{code:o,message:"Geolocation error: "+t+"."})},_handleGeolocationResponse:function(r){var a=new I(r.coords.latitude,r.coords.longitude),t=a.toBounds(2*r.coords.accuracy),l=this._locateOptions;if(l.setView){var e=this.getBoundsZoom(t);this.setView(a,l.maxZoom?Math.min(e,l.maxZoom):e)}var n={latlng:a,bounds:t,timestamp:r.timestamp};for(var o in r.coords)"number"==typeof r.coords[o]&&(n[o]=r.coords[o]);this.fire("locationfound",n)},addHandler:function(e,o){if(!o)return this;var t=this[e]=new o(this);return this._handlers.push(t),this.options[e]&&t.enable(),this},remove:function(){if(this._initEvents(!0),this._containerId!==this._container._leaflet_id)throw new Error("Map container is being reused by another instance");try{delete this._container._leaflet_id,delete this._containerId}catch(t){this._container._leaflet_id=void 0,this._containerId=void 0}for(var t in void 0!==this._locationWatchId&&this.stopLocate(),this._stop(),Mt(this._mapPane),this._clearControlPos&&this._clearControlPos(),this._resizeRequest&&(p(this._resizeRequest),this._resizeRequest=null),this._clearHandlers(),this._loaded&&this.fire("unload"),this._layers)this._layers[t].remove();for(t in this._panes)Mt(this._panes[t]);return this._layers=[],this._panes=[],delete this._mapPane,delete this._renderer,this},createPane:function(e,o){var t=wt("div","leaflet-pane"+(e?" leaflet-"+e.replace("Pane","")+"-pane":""),o||this._mapPane);return e&&(this._panes[e]=t),t},getCenter:function(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?this._lastCenter:this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var t=this.getPixelBounds();return new g(this.unproject(t.getBottomLeft()),this.unproject(t.getTopRight()))},getMinZoom:function(){return void 0===this.options.minZoom?this._layersMinZoom||0:this.options.minZoom},getMaxZoom:function(){return void 0===this.options.maxZoom?void 0===this._layersMaxZoom?1/0:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(e,t,n){e=S(e),n=b(n||[0,0]);var d=this.getZoom()||0,m=this.getMinZoom(),f=this.getMaxZoom(),o=e.getNorthWest(),s=e.getSouthEast(),r=this.getSize().subtract(n),a=w(this.project(s,d),this.project(o,d)).getSize(),h=gt?this.options.zoomSnap:1,u=r.x/a.x,l=r.y/a.y,c=t?Math.max(u,l):Math.min(u,l);return d=this.getScaleZoom(c,d),h&&(d=Math.round(d/(h/100))*(h/100),d=t?Math.ceil(d/h)*h:Math.floor(d/h)*h),Math.max(m,Math.min(f,d))},getSize:function(){return this._size&&!this._sizeChanged||(this._size=new y(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(e,o){var t=this._getTopLeftPoint(e,o);return new C(t,t.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._pixelOrigin},getPixelWorldBounds:function(t){return this.options.crs.getProjectedBounds(void 0===t?this.getZoom():t)},getPane:function(t){return"string"==typeof t?this._panes[t]:t},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(e,o){var a=this.options.crs;return o=void 0===o?this._zoom:o,a.scale(e)/a.scale(o)},getScaleZoom:function(n,o){var r=this.options.crs;o=void 0===o?this._zoom:o;var a=r.zoom(n*r.scale(o));return isNaN(a)?1/0:a},project:function(o,e){return e=void 0===e?this._zoom:e,this.options.crs.latLngToPoint(M(o),e)},unproject:function(o,e){return e=void 0===e?this._zoom:e,this.options.crs.pointToLatLng(b(o),e)},layerPointToLatLng:function(o){var e=b(o).add(this.getPixelOrigin());return this.unproject(e)},latLngToLayerPoint:function(t){return this.project(M(t))._round()._subtract(this.getPixelOrigin())},wrapLatLng:function(t){return this.options.crs.wrapLatLng(M(t))},wrapLatLngBounds:function(t){return this.options.crs.wrapLatLngBounds(S(t))},distance:function(o,e){return this.options.crs.distance(M(o),M(e))},containerPointToLayerPoint:function(t){return b(t).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(t){return b(t).add(this._getMapPanePos())},containerPointToLatLng:function(o){var e=this.containerPointToLayerPoint(b(o));return this.layerPointToLatLng(e)},latLngToContainerPoint:function(t){return this.layerPointToContainerPoint(this.latLngToLayerPoint(M(t)))},mouseEventToContainerPoint:function(t){return ho(t,this._container)},mouseEventToLayerPoint:function(t){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(t))},mouseEventToLatLng:function(t){return this.layerPointToLatLng(this.mouseEventToLayerPoint(t))},_initContainer:function(o){var e=this._container=Qe(o);if(!e)throw new Error("Map container not found.");if(e._leaflet_id)throw new Error("Map container is already initialized.");so(e,"scroll",this._onScroll,this),this._containerId=H(e)},_initLayout:function(){var o=this._container;this._fadeAnimated=this.options.fadeAnimation&>,qt(o,"leaflet-container"+(Lt?" leaflet-touch":"")+(Tt?" leaflet-retina":"")+(tt?" leaflet-oldie":"")+(lt?" leaflet-safari":"")+(this._fadeAnimated?" leaflet-fade-anim":""));var e=Pt(o,"position");"absolute"!==e&&"relative"!==e&&"fixed"!==e&&(o.style.position="relative"),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var t=this._panes={};this._paneRenderers={},this._mapPane=this.createPane("mapPane",this._container),$t(this._mapPane,new y(0,0)),this.createPane("tilePane"),this.createPane("shadowPane"),this.createPane("overlayPane"),this.createPane("markerPane"),this.createPane("tooltipPane"),this.createPane("popupPane"),this.options.markerZoomAnimation||(qt(t.markerPane,"leaflet-zoom-hide"),qt(t.shadowPane,"leaflet-zoom-hide"))},_resetView:function(n,o){$t(this._mapPane,new y(0,0));var r=!this._loaded;this._loaded=!0,o=this._limitZoom(o),this.fire("viewprereset");var a=this._zoom!==o;this._moveStart(a,!1)._move(n,o)._moveEnd(a),this.fire("viewreset"),r&&this.fire("load")},_moveStart:function(o,e){return o&&this.fire("zoomstart"),e||this.fire("movestart"),this},_move:function(n,o,r){void 0===o&&(o=this._zoom);var a=this._zoom!==o;return this._zoom=o,this._lastCenter=n,this._pixelOrigin=this._getNewPixelOrigin(n),(a||r&&r.pinch)&&this.fire("zoom",r),this.fire("move",r)},_moveEnd:function(t){return t&&this.fire("zoomend"),this.fire("moveend")},_stop:function(){return p(this._flyToFrame),this._panAnim&&this._panAnim.stop(),this},_rawPanBy:function(t){$t(this._mapPane,this._getMapPanePos().subtract(t))},_getZoomSpan:function(){return this.getMaxZoom()-this.getMinZoom()},_panInsideMaxBounds:function(){this._enforcingBounds||this.panInsideBounds(this.options.maxBounds)},_checkIfLoaded:function(){if(!this._loaded)throw new Error("Set map center and zoom first.")},_initEvents:function(o){this._targets={};var e=o?lo:so;e((this._targets[H(this._container)]=this)._container,"click dblclick mousedown mouseup mouseover mouseout mousemove contextmenu keypress keydown keyup",this._handleDOMEvent,this),this.options.trackResize&&e(window,"resize",this._onResize,this),gt&&this.options.transform3DLimit&&(o?this.off:this.on).call(this,"moveend",this._onMoveEnd)},_onResize:function(){p(this._resizeRequest),this._resizeRequest=ae(function(){this.invalidateSize({debounceMoveend:!0})},this)},_onScroll:function(){this._container.scrollTop=0,this._container.scrollLeft=0},_onMoveEnd:function(){var t=this._getMapPanePos();Math.max(Math.abs(t.x),Math.abs(t.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(e,n){for(var t,a=[],r="mouseout"===n||"mouseover"===n,s=e.target||e.srcElement,l=!1;s;){if((t=this._targets[H(s)])&&("click"===n||"preclick"===n)&&!e._simulated&&this._draggableMoved(t)){l=!0;break}if(t&&t.listens(n,!0)){if(r&&!Po(s,e))break;if(a.push(t),r)break}if(s===this._container)break;s=s.parentNode}return a.length||l||r||!Po(s,e)||(a=[this]),a},_handleDOMEvent:function(o){if(this._loaded&&!xo(o)){var e=o.type;"mousedown"!==e&&"keypress"!==e&&"keyup"!==e&&"keydown"!==e||no(o.target||o.srcElement),this._fireDOMEvent(o,e)}},_mouseEvents:["click","dblclick","mouseover","mouseout","contextmenu"],_fireDOMEvent:function(e,t,a){if("click"===e.type){var l=v({},e);l.type="preclick",this._fireDOMEvent(l,l.type,a)}if(!e._stopped&&(a=(a||[]).concat(this._findEventTargets(e,t))).length){var d=a[0];"contextmenu"===t&&d.listens(t,!0)&&go(e);var n={originalEvent:e};if("keypress"!==e.type&&"keydown"!==e.type&&"keyup"!==e.type){var o=d.getLatLng&&(!d._radius||10>=d._radius);n.containerPoint=o?this.latLngToContainerPoint(d.getLatLng()):this.mouseEventToContainerPoint(e),n.layerPoint=this.containerPointToLayerPoint(n.containerPoint),n.latlng=o?d.getLatLng():this.layerPointToLatLng(n.layerPoint)}for(var s=0;sthis.options.zoomAnimationThreshold)return!1;var a=this.getZoomScale(o),s=this._getCenterOffset(e)._divideBy(1-1/a);return(!0===t.animate||this.getSize().contains(s))&&(ae(function(){this._moveStart(!0,!1)._animateZoom(e,o,!0)},this),!0)},_animateZoom:function(n,o,t,a){this._mapPane&&(t&&(this._animatingZoom=!0,this._animateToCenter=n,this._animateToZoom=o,qt(this._mapPane,"leaflet-zoom-anim")),this.fire("zoomanim",{center:n,zoom:o,noUpdate:a}),setTimeout(h(this._onZoomTransitionEnd,this),250))},_onZoomTransitionEnd:function(){this._animatingZoom&&(this._mapPane&&Vt(this._mapPane,"leaflet-zoom-anim"),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom),ae(function(){this._moveEnd(!0)},this))}}),kn=c.extend({options:{position:"topright"},initialize:function(t){l(this,t)},getPosition:function(){return this.options.position},setPosition:function(o){var e=this._map;return e&&e.removeControl(this),this.options.position=o,e&&e.addControl(this),this},getContainer:function(){return this._container},addTo:function(n){this.remove(),this._map=n;var o=this._container=this.onAdd(n),t=this.getPosition(),a=n._controlCorners[t];return qt(o,"leaflet-control"),-1===t.indexOf("bottom")?a.appendChild(o):a.insertBefore(o,a.firstChild),this._map.on("unload",this.remove,this),this},remove:function(){return this._map&&(Mt(this._container),this.onRemove&&this.onRemove(this._map),this._map.off("unload",this.remove,this),this._map=null),this},_refocusOnMap:function(t){this._map&&t&&0",a=document.createElement("div");return a.innerHTML=t,a.firstChild},_addItem:function(a){var r,s=document.createElement("label"),l=this._map.hasLayer(a.layer);a.overlay?((r=document.createElement("input")).type="checkbox",r.className="leaflet-control-layers-selector",r.defaultChecked=l):r=this._createRadioElement("leaflet-base-layers_"+H(this),l),this._layerControlInputs.push(r),r.layerId=H(a.layer),so(r,"click",this._onInputClick,this);var e=document.createElement("span");e.innerHTML=" "+a.name;var n=document.createElement("div");return s.appendChild(n),n.appendChild(r),n.appendChild(e),(a.overlay?this._overlaysList:this._baseLayersList).appendChild(s),this._checkDisabledLayers(),s},_onInputClick:function(){var t,s,d=this._layerControlInputs,l=[],e=[];this._handlingClick=!0;for(var n=d.length-1;0<=n;n--)t=d[n],s=this._getLayer(t.layerId).layer,t.checked?l.push(s):t.checked||e.push(s);for(n=0;no.options.maxZoom},_expandIfNotCollapsed:function(){return this._map&&!this.options.collapsed&&this.expand(),this},_expand:function(){return this.expand()},_collapse:function(){return this.collapse()}}),te=kn.extend({options:{position:"topleft",zoomInText:"+",zoomInTitle:"Zoom in",zoomOutText:"−",zoomOutTitle:"Zoom out"},onAdd:function(n){var o=wt("div","leaflet-control-zoom leaflet-bar"),t=this.options;return this._zoomInButton=this._createButton(t.zoomInText,t.zoomInTitle,"leaflet-control-zoom-in",o,this._zoomIn),this._zoomOutButton=this._createButton(t.zoomOutText,t.zoomOutTitle,"leaflet-control-zoom-out",o,this._zoomOut),this._updateDisabled(),n.on("zoomend zoomlevelschange",this._updateDisabled,this),o},onRemove:function(t){t.off("zoomend zoomlevelschange",this._updateDisabled,this)},disable:function(){return this._disabled=!0,this._updateDisabled(),this},enable:function(){return this._disabled=!1,this._updateDisabled(),this},_zoomIn:function(t){!this._disabled&&this._map._zoomthis._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(t.shiftKey?3:1))},_createButton:function(s,a,t,r,e){var n=wt("a",t,r);return n.innerHTML=s,n.href="#",n.title=a,n.setAttribute("role","button"),n.setAttribute("aria-label",a),uo(n),so(n,"click",yo),so(n,"click",e,this),so(n,"click",this._refocusOnMap,this),n},_updateDisabled:function(){var t=this._map;Vt(this._zoomInButton,"leaflet-disabled"),Vt(this._zoomOutButton,"leaflet-disabled"),(this._disabled||t._zoom===t.getMinZoom())&&qt(this._zoomOutButton,"leaflet-disabled"),(this._disabled||t._zoom===t.getMaxZoom())&&qt(this._zoomInButton,"leaflet-disabled")}});fn.mergeOptions({zoomControl:!0}),fn.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new te,this.addControl(this.zoomControl))});var ie=kn.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0},onAdd:function(n){var o=wt("div","leaflet-control-scale"),t=this.options;return this._addScales(t,"leaflet-control-scale-line",o),n.on(t.updateWhenIdle?"moveend":"move",this._update,this),n.whenReady(this._update,this),o},onRemove:function(t){t.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(e,o,t){e.metric&&(this._mScale=wt("div",o,t)),e.imperial&&(this._iScale=wt("div",o,t))},_update:function(){var e=this._map,o=e.getSize().y/2,t=e.distance(e.containerPointToLatLng([0,o]),e.containerPointToLatLng([this.options.maxWidth,o]));this._updateScales(t)},_updateScales:function(t){this.options.metric&&t&&this._updateMetric(t),this.options.imperial&&t&&this._updateImperial(t)},_updateMetric:function(e){var o=this._getRoundNum(e),t=1e3>o?o+" m":o/1e3+" km";this._updateScale(this._mScale,t,o/e)},_updateImperial:function(e){var o,n,a,d=3.2808399*e;5280Leaflet"},initialize:function(t){l(this,t),this._attributions={}},onAdd:function(o){for(var e in(o.attributionControl=this)._container=wt("div","leaflet-control-attribution"),uo(this._container),o._layers)o._layers[e].getAttribution&&this.addAttribution(o._layers[e].getAttribution());return this._update(),this._container},setPrefix:function(t){return this.options.prefix=t,this._update(),this},addAttribution:function(t){return t&&(this._attributions[t]||(this._attributions[t]=0),this._attributions[t]++,this._update()),this},removeAttribution:function(t){return t&&this._attributions[t]&&(this._attributions[t]--,this._update()),this},_update:function(){if(this._map){var e=[];for(var o in this._attributions)this._attributions[o]&&e.push(o);var t=[];this.options.prefix&&t.push(this.options.prefix),e.length&&t.push(e.join(", ")),this._container.innerHTML=t.join(" | ")}}});fn.mergeOptions({attributionControl:!0}),fn.addInitHook(function(){this.options.attributionControl&&new ee().addTo(this)}),kn.Layers=Sn,kn.Zoom=te,kn.Scale=ie,kn.Attribution=ee,ko.layers=function(e,o,t){return new Sn(e,o,t)},ko.zoom=function(t){return new te(t)},ko.scale=function(t){return new ie(t)},ko.attribution=function(t){return new ee(t)};var ne=c.extend({initialize:function(t){this._map=t},enable:function(){return this._enabled||(this._enabled=!0,this.addHooks()),this},disable:function(){return this._enabled&&(this._enabled=!1,this.removeHooks()),this},enabled:function(){return!!this._enabled}});ne.addTo=function(o,e){return o.addHandler(e,this),this};var oe,Bn,On=Lt?"touchstart mousedown":"mousedown",En={mousedown:"mouseup",touchstart:"touchend",pointerdown:"touchend",MSPointerDown:"touchend"},he={mousedown:"mousemove",touchstart:"touchmove",pointerdown:"touchmove",MSPointerDown:"touchmove"},ue=E.extend({options:{clickTolerance:3},initialize:function(n,o,t,a){l(this,a),this._element=n,this._dragStartTarget=o||n,this._preventOutline=t},enable:function(){this._enabled||(so(this._dragStartTarget,On,this._onDown,this),this._enabled=!0)},disable:function(){this._enabled&&(ue._dragging===this&&this.finishDrag(),lo(this._dragStartTarget,On,this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(e){if(!e._simulated&&this._enabled&&(this._moved=!1,!Ft(this._element,"leaflet-zoom-anim")&&!(ue._dragging||e.shiftKey||1!==e.which&&1!==e.button&&!e.touches||((ue._dragging=this)._preventOutline&&no(this._element),to(),Bo(),this._moving)))){this.fire("down");var o=e.touches?e.touches[0]:e,t=io(this._element);this._startPoint=new y(o.clientX,o.clientY),this._parentScale=ro(t),so(document,he[e.type],this._onMove,this),so(document,En[e.type],this._onUp,this)}},_onMove:function(e){if(!e._simulated&&this._enabled)if(e.touches&&1c&&1e-7this._layersMaxZoom&&this.setZoom(this._layersMaxZoom),void 0===this.options.minZoom&&this._layersMinZoom&&this.getZoom()n.opacity&&this._updateOpacity(),r&&this.getPane().appendChild(this._icon),this._initInteraction(),s&&l&&this.getPane(n.shadowPane).appendChild(this._shadow)},_removeIcon:function(){this.options.riseOnHover&&this.off({mouseover:this._bringToFront,mouseout:this._resetZIndex}),Mt(this._icon),this.removeInteractiveTarget(this._icon),this._icon=null},_removeShadow:function(){this._shadow&&Mt(this._shadow),this._shadow=null},_setPos:function(t){this._icon&&$t(this._icon,t),this._shadow&&$t(this._shadow,t),this._zIndex=t.y+this.options.zIndexOffset,this._resetZIndex()},_updateZIndex:function(t){this._icon&&(this._icon.style.zIndex=this._zIndex+t)},_animateZoom:function(o){var e=this._map._latLngToNewLayerPoint(this._latlng,o.zoom,o.center).round();this._setPos(e)},_initInteraction:function(){if(this.options.interactive&&(qt(this._icon,"leaflet-interactive"),this.addInteractiveTarget(this._icon),Be)){var t=this.options.draggable;this.dragging&&(t=this.dragging.enabled(),this.dragging.disable()),this.dragging=new Be(this),t&&this.dragging.enable()}},setOpacity:function(t){return this.options.opacity=t,this._map&&this._updateOpacity(),this},_updateOpacity:function(){var t=this.options.opacity;this._icon&&Xt(this._icon,t),this._shadow&&Xt(this._shadow,t)},_bringToFront:function(){this._updateZIndex(this.options.riseOffset)},_resetZIndex:function(){this._updateZIndex(0)},_getPopupAnchor:function(){return this.options.icon.options.popupAnchor},_getTooltipAnchor:function(){return this.options.icon.options.tooltipAnchor}}),Ie=Ce.extend({options:{stroke:!0,color:"#3388ff",weight:3,opacity:1,lineCap:"round",lineJoin:"round",dashArray:null,dashOffset:null,fill:!1,fillColor:null,fillOpacity:.2,fillRule:"evenodd",interactive:!0,bubblingMouseEvents:!0},beforeAdd:function(t){this._renderer=t.getRenderer(this)},onAdd:function(){this._renderer._initPath(this),this._reset(),this._renderer._addPath(this)},onRemove:function(){this._renderer._removePath(this)},redraw:function(){return this._map&&this._renderer._updatePath(this),this},setStyle:function(t){return l(this,t),this._renderer&&(this._renderer._updateStyle(this),this.options.stroke&&t&&t.hasOwnProperty("weight")&&this._updateBounds()),this},bringToFront:function(){return this._renderer&&this._renderer._bringToFront(this),this},bringToBack:function(){return this._renderer&&this._renderer._bringToBack(this),this},getElement:function(){return this._path},_reset:function(){this._project(),this._update()},_clickTolerance:function(){return(this.options.stroke?this.options.weight/2:0)+this._renderer.options.tolerance}}),Oe=Ie.extend({options:{fill:!0,radius:10},initialize:function(o,e){l(this,e),this._latlng=M(o),this._radius=this.options.radius},setLatLng:function(o){var e=this._latlng;return this._latlng=M(o),this.redraw(),this.fire("move",{oldLatLng:e,latlng:this._latlng})},getLatLng:function(){return this._latlng},setRadius:function(t){return this.options.radius=this._radius=t,this.redraw()},getRadius:function(){return this._radius},setStyle:function(o){var e=o&&o.radius||this._radius;return Ie.prototype.setStyle.call(this,o),this.setRadius(e),this},_project:function(){this._point=this._map.latLngToLayerPoint(this._latlng),this._updateBounds()},_updateBounds:function(){var n=this._radius,o=this._radiusY||n,t=this._clickTolerance(),a=[n+t,o+t];this._pxBounds=new C(this._point.subtract(a),this._point.add(a))},_update:function(){this._map&&this._updatePath()},_updatePath:function(){this._renderer._updateCircle(this)},_empty:function(){return this._radius&&!this._renderer._bounds.intersects(this._pxBounds)},_containsPoint:function(t){return t.distanceTo(this._point)<=this._radius+this._clickTolerance()}}),Re=Oe.extend({initialize:function(e,o,a){if("number"==typeof o&&(o=v({},a,{radius:o})),l(this,o),this._latlng=M(e),isNaN(this.options.radius))throw new Error("Circle radius cannot be NaN");this._mRadius=this.options.radius},setRadius:function(t){return this._mRadius=t,this.redraw()},getRadius:function(){return this._mRadius},getBounds:function(){var t=[this._radius,this._radiusY||this._radius];return new g(this._map.layerPointToLatLng(this._point.subtract(t)),this._map.layerPointToLatLng(this._point.add(t)))},setStyle:Ie.prototype.setStyle,_project:function(){var l=this._latlng.lng,d=this._latlng.lat,t=this._map,p=t.options.crs;if(p.distance===Mo.distance){var e=Math.PI/180,n=this._mRadius/Mo.R/e,o=t.project([d+n,l]),s=t.project([d-n,l]),r=o.add(s).divideBy(2),a=t.unproject(r).lat,_=Math.acos((Math.cos(n*e)-Math.sin(d*e)*Math.sin(a*e))/(Math.cos(d*e)*Math.cos(a*e)))/e;(isNaN(_)||0===_)&&(_=n/Math.cos(Math.PI/180*d)),this._point=r.subtract(t.getPixelOrigin()),this._radius=isNaN(_)?0:r.x-t.project([a,l-_]).x,this._radiusY=r.y-o.y}else{var c=p.unproject(p.project(this._latlng).subtract([this._mRadius,0]));this._point=t.latLngToLayerPoint(this._latlng),this._radius=this._point.x-t.latLngToLayerPoint(c).x}this._updateBounds()}}),Ne=Ie.extend({options:{smoothFactor:1,noClip:!1},initialize:function(o,e){l(this,e),this._setLatLngs(o)},getLatLngs:function(){return this._latlngs},setLatLngs:function(t){return this._setLatLngs(t),this.redraw()},isEmpty:function(){return!this._latlngs.length},closestLayerPoint:function(e){for(var o,n,r=1/0,l=null,d=me,c=0,u=this._parts.length;ce.y!=a.y>e.y&&e.x<(a.x-n.x)*(e.y-n.y)/(a.y-n.y)+n.x&&(v=!v);return v||Ne.prototype._containsPoint.call(this,e,!0)}}),je=Se.extend({initialize:function(o,e){l(this,e),this._layers={},o&&this.addData(o)},addData:function(e){var n,a,r,_=Ao(e)?e:e.features;if(_){for(n=0,a=_.length;nthis.options.opacity&&this._updateOpacity()),this.options.interactive&&(qt(this._image,"leaflet-interactive"),this.addInteractiveTarget(this._image)),this.getPane().appendChild(this._image),this._reset()},onRemove:function(){Mt(this._image),this.options.interactive&&this.removeInteractiveTarget(this._image)},setOpacity:function(t){return this.options.opacity=t,this._image&&this._updateOpacity(),this},setStyle:function(t){return t.opacity&&this.setOpacity(t.opacity),this},bringToFront:function(){return this._map&&Ht(this._image),this},bringToBack:function(){return this._map&&Wt(this._image),this},setUrl:function(t){return this._url=t,this._image&&(this._image.src=t),this},setBounds:function(t){return this._bounds=S(t),this._map&&this._reset(),this},getEvents:function(){var t={zoom:this._reset,viewreset:this._reset};return this._zoomAnimated&&(t.zoomanim=this._animateZoom),t},setZIndex:function(t){return this.options.zIndex=t,this._updateZIndex(),this},getBounds:function(){return this._bounds},getElement:function(){return this._image},_initImage:function(){var o="IMG"===this._url.tagName,e=this._image=o?this._url:wt("img");qt(e,"leaflet-image-layer"),this._zoomAnimated&&qt(e,"leaflet-zoom-animated"),this.options.className&&qt(e,this.options.className),e.onselectstart=Y,e.onmousemove=Y,e.onload=h(this.fire,this,"load"),e.onerror=h(this._overlayOnError,this,"error"),(this.options.crossOrigin||""===this.options.crossOrigin)&&(e.crossOrigin=!0===this.options.crossOrigin?"":this.options.crossOrigin),this.options.zIndex&&this._updateZIndex(),o?this._url=e.src:(e.src=this._url,e.alt=this.options.alt)},_animateZoom:function(e){var o=this._map.getZoomScale(e.zoom),t=this._map._latLngBoundsToNewLayerBounds(this._bounds,e.zoom,e.center).min;Qt(this._image,t,o)},_reset:function(){var e=this._image,o=new C(this._map.latLngToLayerPoint(this._bounds.getNorthWest()),this._map.latLngToLayerPoint(this._bounds.getSouthEast())),t=o.getSize();$t(e,o.min),e.style.width=t.x+"px",e.style.height=t.y+"px"},_updateOpacity:function(){Xt(this._image,this.options.opacity)},_updateZIndex:function(){this._image&&void 0!==this.options.zIndex&&null!==this.options.zIndex&&(this._image.style.zIndex=this.options.zIndex)},_overlayOnError:function(){this.fire("error");var t=this.options.errorOverlayUrl;t&&this._url!==t&&(this._url=t,this._image.src=t)}}),Je=He.extend({options:{autoplay:!0,loop:!0,keepAspectRatio:!0},_initImage:function(){var o="VIDEO"===this._url.tagName,a=this._image=o?this._url:wt("video");if(qt(a,"leaflet-image-layer"),this._zoomAnimated&&qt(a,"leaflet-zoom-animated"),this.options.className&&qt(a,this.options.className),a.onselectstart=Y,a.onmousemove=Y,a.onloadeddata=h(this.fire,this,"load"),o){for(var t=a.getElementsByTagName("source"),r=[],e=0;ea.x&&(_=n.x+p-a.x+r.x),0>n.x-_-s.x&&(_=n.x-s.x),n.y+t+r.y>a.y&&(c=n.y+t-a.y+r.y),0>n.y-c-s.y&&(c=n.y-s.y),(_||c)&&l.fire("autopanstart").panBy([_,c])}},_onCloseButtonClick:function(t){this._close(),yo(t)},_getAnchor:function(){return b(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}});fn.mergeOptions({closePopupOnClick:!0}),fn.include({openPopup:function(e,t,n){return e instanceof nn||(e=new nn(n).setContent(e)),t&&e.setLatLng(t),this.hasLayer(e)?this:(this._popup&&this._popup.options.autoClose&&this.closePopup(),this._popup=e,this.addLayer(e))},closePopup:function(t){return t&&t!==this._popup||(t=this._popup,this._popup=null),t&&this.removeLayer(t),this}}),Ce.include({bindPopup:function(o,e){return o instanceof nn?(l(o,e),(this._popup=o)._source=this):(this._popup&&!e||(this._popup=new nn(e,this)),this._popup.setContent(o)),this._popupHandlersAdded||(this.on({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!0),this},unbindPopup:function(){return this._popup&&(this.off({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,this._popup=null),this},openPopup:function(o,e){return this._popup&&this._map&&(e=this._popup._prepareOpen(this,o,e),this._map.openPopup(this._popup,e)),this},closePopup:function(){return this._popup&&this._popup._close(),this},togglePopup:function(t){return this._popup&&(this._popup._map?this.closePopup():this.openPopup(t)),this},isPopupOpen:function(){return!!this._popup&&this._popup.isOpen()},setPopupContent:function(t){return this._popup&&this._popup.setContent(t),this},getPopup:function(){return this._popup},_openPopup:function(o){var e=o.layer||o.target;this._popup&&this._map&&(yo(o),e instanceof Ie?this.openPopup(o.layer||o.target,o.latlng):this._map.hasLayer(this._popup)&&this._popup._source===e?this.closePopup():this.openPopup(e,o.latlng))},_movePopup:function(t){this._popup.setLatLng(t.latlng)},_onKeyPress:function(t){13===t.originalEvent.keyCode&&this._openPopup(t)}});var on=en.extend({options:{pane:"tooltipPane",offset:[0,0],direction:"auto",permanent:!1,sticky:!1,interactive:!1,opacity:.9},onAdd:function(t){en.prototype.onAdd.call(this,t),this.setOpacity(this.options.opacity),t.fire("tooltipopen",{tooltip:this}),this._source&&this._source.fire("tooltipopen",{tooltip:this},!0)},onRemove:function(t){en.prototype.onRemove.call(this,t),t.fire("tooltipclose",{tooltip:this}),this._source&&this._source.fire("tooltipclose",{tooltip:this},!0)},getEvents:function(){var t=en.prototype.getEvents.call(this);return Lt&&!this.options.permanent&&(t.preclick=this._close),t},_close:function(){this._map&&this._map.closeTooltip(this)},_initLayout:function(){var t="leaflet-tooltip "+(this.options.className||"")+" leaflet-zoom-"+(this._zoomAnimated?"animated":"hide");this._contentNode=this._container=wt("div",t)},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(t){var s=this._map,d=this._container,p=s.latLngToContainerPoint(s.getCenter()),e=s.layerPointToContainerPoint(t),n=this.options.direction,c=d.offsetWidth,_=d.offsetHeight,r=b(this.options.offset),a=this._getAnchor();t="top"===n?t.add(b(-c/2+r.x,-_+r.y+a.y,!0)):"bottom"===n?t.subtract(b(c/2-r.x,-r.y,!0)):"center"===n?t.subtract(b(c/2+r.x,_/2-a.y+r.y,!0)):"right"===n||"auto"===n&&e.xn?a=!0:(l.active?s=!0:this._onOpaqueTile(l),l.active=!0)}}s&&!this._noPrune&&this._pruneTiles(),a&&(p(this._fadeFrame),this._fadeFrame=ae(this._updateOpacity,this))}},_onOpaqueTile:Y,_initContainer:function(){this._container||(this._container=wt("div","leaflet-layer "+(this.options.className||"")),this._updateZIndex(),1>this.options.opacity&&this._updateOpacity(),this.getPane().appendChild(this._container))},_updateLevels:function(){var o=this._tileZoom,n=this.options.maxZoom;if(void 0!==o){for(var t in this._levels)this._levels[t].el.children.length||t===o?(this._levels[t].el.style.zIndex=n-Math.abs(o-t),this._onUpdateLevel(t)):(Mt(this._levels[t].el),this._removeTilesAtZoom(t),this._onRemoveLevel(t),delete this._levels[t]);var a=this._levels[o],r=this._map;return a||((a=this._levels[o]={}).el=wt("div","leaflet-tile-container leaflet-zoom-animated",this._container),a.el.style.zIndex=n,a.origin=r.project(r.unproject(r.getPixelOrigin()),o).round(),a.zoom=o,this._setZoomTransform(a,r.getCenter(),r.getZoom()),a.el.offsetWidth,this._onCreateLevel(a)),this._level=a}},_onUpdateLevel:Y,_onRemoveLevel:Y,_onCreateLevel:Y,_pruneTiles:function(){if(this._map){var t,n,s=this._map.getZoom();if(s>this.options.maxZoom||sthis.options.maxZoom||void 0!==this.options.minZoom&&et.max.x)||!o.wrapLat&&(n.yt.max.y))return!1}if(!this.options.bounds)return!0;var a=this._tileCoordsToBounds(n);return S(this.options.bounds).overlaps(a)},_keyToBounds:function(t){return this._tileCoordsToBounds(this._keyToTileCoords(t))},_tileCoordsToNwSe:function(o){var a=this._map,t=this.getTileSize(),r=o.scaleBy(t),e=r.add(t);return[a.unproject(r,o.z),a.unproject(e,o.z)]},_tileCoordsToBounds:function(e){var o=this._tileCoordsToNwSe(e),t=new g(o[0],o[1]);return this.options.noWrap||(t=this._map.wrapLatLngBounds(t)),t},_tileCoordsToKey:function(t){return t.x+":"+t.y+":"+t.z},_keyToTileCoords:function(e){var o=e.split(":"),t=new y(+o[0],+o[1]);return t.z=+o[2],t},_removeTile:function(o){var e=this._tiles[o];e&&(Mt(e.el),delete this._tiles[o],this.fire("tileunload",{tile:e.el,coords:this._keyToTileCoords(o)}))},_initTile:function(o){qt(o,"leaflet-tile");var e=this.getTileSize();o.style.width=e.x+"px",o.style.height=e.y+"px",o.onselectstart=Y,o.onmousemove=Y,tt&&1>this.options.opacity&&Xt(o,this.options.opacity),nt&&!ot&&(o.style.WebkitBackfaceVisibility="hidden")},_addTile:function(o,a){var t=this._getTilePos(o),r=this._tileCoordsToKey(o),e=this.createTile(this._wrapCoords(o),h(this._tileReady,this,o));this._initTile(e),2>this.createTile.length&&ae(h(this._tileReady,this,o,null,e)),$t(e,t),this._tiles[r]={el:e,coords:o,current:!0},a.appendChild(e),this.fire("tileloadstart",{tile:e,coords:o})},_tileReady:function(e,o,t){o&&this.fire("tileerror",{error:o,tile:t,coords:e});var n=this._tileCoordsToKey(e);(t=this._tiles[n])&&(t.loaded=+new Date,this._map._fadeAnimated?(Xt(t.el,0),p(this._fadeFrame),this._fadeFrame=ae(this._updateOpacity,this)):(t.active=!0,this._pruneTiles()),o||(qt(t.el,"leaflet-tile-loaded"),this.fire("tileload",{tile:t.el,coords:e})),this._noTilesToLoad()&&(this._loading=!1,this.fire("load"),tt||!this._map._fadeAnimated?ae(this._pruneTiles,this):setTimeout(h(this._pruneTiles,this),250)))},_getTilePos:function(t){return t.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(o){var e=new y(this._wrapX?V(o.x,this._wrapX):o.x,this._wrapY?V(o.y,this._wrapY):o.y);return e.z=o.z,e},_pxBoundsToTileRange:function(o){var e=this.getTileSize();return new C(o.min.unscaleBy(e).floor(),o.max.unscaleBy(e).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var t in this._tiles)if(!this._tiles[t].loaded)return!1;return!0}}),an=rn.extend({options:{minZoom:0,maxZoom:18,subdomains:"abc",errorTileUrl:"",zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1},initialize:function(o,e){this._url=o,(e=l(this,e)).detectRetina&&Tt&&0")}}catch(t){return function(t){return document.createElement("<"+t+" xmlns=\"urn:schemas-microsoft.com:vml\" class=\"lvml\">")}}}(),dn=St?_n:R,mn=un.extend({getEvents:function(){var t=un.prototype.getEvents.call(this);return t.zoomstart=this._onZoomStart,t},_initContainer:function(){this._container=dn("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=dn("g"),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){Mt(this._container),lo(this._container),delete this._container,delete this._rootGroup,delete this._svgSize},_onZoomStart:function(){this._update()},_update:function(){if(!this._map._animatingZoom||!this._bounds){un.prototype._update.call(this);var e=this._bounds,o=e.getSize(),t=this._container;this._svgSize&&this._svgSize.equals(o)||(this._svgSize=o,t.setAttribute("width",o.x),t.setAttribute("height",o.y)),$t(t,e.min),t.setAttribute("viewBox",[e.min.x,e.min.y,o.x,o.y].join(" ")),this.fire("update")}},_initPath:function(o){var e=o._path=dn("path");o.options.className&&qt(e,o.options.className),o.options.interactive&&qt(e,"leaflet-interactive"),this._updateStyle(o),this._layers[H(o)]=o},_addPath:function(t){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(t._path),t.addInteractiveTarget(t._path)},_removePath:function(t){Mt(t._path),t.removeInteractiveTarget(t._path),delete this._layers[H(t)]},_updatePath:function(t){t._project(),t._update()},_updateStyle:function(e){var o=e._path,t=e.options;o&&(t.stroke?(o.setAttribute("stroke",t.color),o.setAttribute("stroke-opacity",t.opacity),o.setAttribute("stroke-width",t.weight),o.setAttribute("stroke-linecap",t.lineCap),o.setAttribute("stroke-linejoin",t.lineJoin),t.dashArray?o.setAttribute("stroke-dasharray",t.dashArray):o.removeAttribute("stroke-dasharray"),t.dashOffset?o.setAttribute("stroke-dashoffset",t.dashOffset):o.removeAttribute("stroke-dashoffset")):o.setAttribute("stroke","none"),t.fill?(o.setAttribute("fill",t.fillColor||t.color),o.setAttribute("fill-opacity",t.fillOpacity),o.setAttribute("fill-rule",t.fillRule||"evenodd")):o.setAttribute("fill","none"))},_updatePoly:function(o,e){this._setPath(o,D(o._parts,e))},_updateCircle:function(o){var a=o._point,t=Math.max(Math.round(o._radius),1),r="a"+t+","+(Math.max(Math.round(o._radiusY),1)||t)+" 0 1,0 ",e=o._empty()?"M0 0":"M"+(a.x-t)+","+a.y+r+2*t+",0 "+r+2*-t+",0 ";this._setPath(o,e)},_setPath:function(o,e){o._path.setAttribute("d",e)},_bringToFront:function(t){Ht(t._path)},_bringToBack:function(t){Wt(t._path)}});St&&mn.include({_initContainer:function(){this._container=wt("div","leaflet-vml-container")},_update:function(){this._map._animatingZoom||(un.prototype._update.call(this),this.fire("update"))},_initPath:function(o){var e=o._container=_n("shape");qt(e,"leaflet-vml-shape "+(this.options.className||"")),e.coordsize="1 1",o._path=_n("path"),e.appendChild(o._path),this._updateStyle(o),this._layers[H(o)]=o},_addPath:function(o){var e=o._container;this._container.appendChild(e),o.options.interactive&&o.addInteractiveTarget(e)},_removePath:function(o){var e=o._container;Mt(e),o.removeInteractiveTarget(e),delete this._layers[H(o)]},_updateStyle:function(e){var o=e._stroke,a=e._fill,l=e.options,s=e._container;s.stroked=!!l.stroke,s.filled=!!l.fill,l.stroke?(o||(o=e._stroke=_n("stroke")),s.appendChild(o),o.weight=l.weight+"px",o.color=l.color,o.opacity=l.opacity,o.dashStyle=l.dashArray?Ao(l.dashArray)?l.dashArray.join(" "):l.dashArray.replace(/( *, *)/g," "):"",o.endcap=l.lineCap.replace("butt","flat"),o.joinstyle=l.lineJoin):o&&(s.removeChild(o),e._stroke=null),l.fill?(a||(a=e._fill=_n("fill")),s.appendChild(a),a.color=l.fillColor||l.color,a.opacity=l.fillOpacity):a&&(s.removeChild(a),e._fill=null)},_updateCircle:function(n){var o=n._point.round(),t=Math.round(n._radius),a=Math.round(n._radiusY||t);this._setPath(n,n._empty()?"M0 0":"AL "+o.x+","+o.y+" "+t+","+a+" 0,23592600")},_setPath:function(o,e){o._path.v=e},_bringToFront:function(t){Ht(t._container)},_bringToBack:function(t){Wt(t._container)}}),fn.include({getRenderer:function(o){var e=o.options.renderer||this._getPaneRenderer(o.options.pane)||this.options.renderer||this._renderer;return e||(e=this._renderer=this._createRenderer()),this.hasLayer(e)||this.addLayer(e),e},_getPaneRenderer:function(o){if("overlayPane"===o||void 0===o)return!1;var e=this._paneRenderers[o];return void 0===e&&(e=this._createRenderer({pane:o}),this._paneRenderers[o]=e),e},_createRenderer:function(t){return this.options.preferCanvas&&$e(t)||To(t)}});var gn=De.extend({initialize:function(o,e){De.prototype.initialize.call(this,this._boundsToLatLngs(o),e)},setBounds:function(t){return this.setLatLngs(this._boundsToLatLngs(t))},_boundsToLatLngs:function(t){return[(t=S(t)).getSouthWest(),t.getNorthWest(),t.getNorthEast(),t.getSouthEast()]}});mn.create=dn,mn.pointsToPath=D,je.geometryToLayer=ye,je.coordsToLatLng=Fe,je.coordsToLatLngs=Ue,je.latLngToCoords=Ve,je.latLngsToCoords=qe,je.getFeature=Ge,je.asFeature=Ke,fn.mergeOptions({boxZoom:!0});var vn=ne.extend({initialize:function(t){this._map=t,this._container=t._container,this._pane=t._panes.overlayPane,this._resetStateTimeout=0,t.on("unload",this._destroy,this)},addHooks:function(){so(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){lo(this._container,"mousedown",this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){Mt(this._pane),delete this._pane},_resetState:function(){this._resetStateTimeout=0,this._moved=!1},_clearDeferredResetState:function(){0!==this._resetStateTimeout&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)},_onMouseDown:function(t){return!!(t.shiftKey&&(1===t.which||1===t.button))&&void(this._clearDeferredResetState(),this._resetState(),Bo(),to(),this._startPoint=this._map.mouseEventToContainerPoint(t),so(document,{contextmenu:yo,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this))},_onMouseMove:function(e){this._moved||(this._moved=!0,this._box=wt("div","leaflet-zoom-box",this._container),qt(this._container,"leaflet-crosshair"),this._map.fire("boxzoomstart")),this._point=this._map.mouseEventToContainerPoint(e);var o=new C(this._point,this._startPoint),t=o.getSize();$t(this._box,o.min),this._box.style.width=t.x+"px",this._box.style.height=t.y+"px"},_finish:function(){this._moved&&(Mt(this._box),Vt(this._container,"leaflet-crosshair")),Oo(),oo(),lo(document,{contextmenu:yo,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(o){if((1===o.which||1===o.button)&&(this._finish(),this._moved)){this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(h(this._resetState,this),0);var e=new g(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(e).fire("boxzoomend",{boxZoomBounds:e})}},_onKeyDown:function(t){27===t.keyCode&&this._finish()}});fn.addInitHook("addHandler","boxZoom",vn),fn.mergeOptions({doubleClickZoom:!0});var xn=ne.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(o){var a=this._map,t=a.getZoom(),r=a.options.zoomDelta,e=o.originalEvent.shiftKey?t-r:t+r;"center"===a.options.doubleClickZoom?a.setZoom(e):a.setZoomAround(o.containerPoint,e)}});fn.addInitHook("addHandler","doubleClickZoom",xn),fn.mergeOptions({dragging:!0,inertia:!ot,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0});var wn=ne.extend({addHooks:function(){if(!this._draggable){var t=this._map;this._draggable=new ue(t._mapPane,t._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),t.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDragWrap,this),t.on("zoomend",this._onZoomEnd,this),t.whenReady(this._onZoomEnd,this))}qt(this._map._container,"leaflet-grab leaflet-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){Vt(this._map._container,"leaflet-grab"),Vt(this._map._container,"leaflet-touch-drag"),this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},moving:function(){return this._draggable&&this._draggable._moving},_onDragStart:function(){var o=this._map;if(o._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity){var e=S(this._map.options.maxBounds);this._offsetLimit=w(this._map.latLngToContainerPoint(e.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(e.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))}else this._offsetLimit=null;o.fire("movestart").fire("dragstart"),o.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(e){if(this._map.options.inertia){var o=this._lastTime=+new Date,t=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(t),this._times.push(o),this._prunePositions(o)}this._map.fire("move",e).fire("drag",e)},_prunePositions:function(t){for(;1e.max.x&&(o.x=this._viscousLimit(o.x,e.max.x)),o.y>e.max.y&&(o.y=this._viscousLimit(o.y,e.max.y)),this._draggable._newPos=this._draggable._startPos.add(o)}},_onPreDragWrap:function(){var r=this._worldWidth,a=Math.round(r/2),t=this._initialWorldOffset,l=this._draggable._newPos.x,e=(l-a+t)%r+a-t,n=(l+a+t)%r-a-t,o=Math.abs(e+t)this._times.length;if(d.fire("dragend",_),p)d.fire("moveend");else{this._prunePositions(+new Date);var e=this._lastPos.subtract(this._positions[0]),n=(this._lastTime-this._times[0])/1e3,o=t.easeLinearity,s=e.multiplyBy(o/n),r=s.distanceTo([0,0]),a=Math.min(t.inertiaMaxSpeed,r),m=s.multiplyBy(a/r),u=a/(t.inertiaDeceleration*o),l=m.multiplyBy(-u/2).round();l.x||l.y?(l=d._limitOffset(l,d.options.maxBounds),ae(function(){d.panBy(l,{duration:u,easeLinearity:o,noMoveStart:!0,animate:!0})})):d.fire("moveend")}}});fn.addInitHook("addHandler","dragging",wn),fn.mergeOptions({keyboard:!0,keyboardPanDelta:80});var Pn=ne.extend({keyCodes:{left:[37],right:[39],down:[40],up:[38],zoomIn:[187,107,61,171],zoomOut:[189,109,54,173]},initialize:function(t){this._map=t,this._setPanDelta(t.options.keyboardPanDelta),this._setZoomDelta(t.options.zoomDelta)},addHooks:function(){var t=this._map._container;0>=t.tabIndex&&(t.tabIndex="0"),so(t,{focus:this._onFocus,blur:this._onBlur,mousedown:this._onMouseDown},this),this._map.on({focus:this._addHooks,blur:this._removeHooks},this)},removeHooks:function(){this._removeHooks(),lo(this._map._container,{focus:this._onFocus,blur:this._onBlur,mousedown:this._onMouseDown},this),this._map.off({focus:this._addHooks,blur:this._removeHooks},this)},_onMouseDown:function(){if(!this._focused){var n=document.body,o=document.documentElement,t=n.scrollTop||o.scrollTop,a=n.scrollLeft||o.scrollLeft;this._map._container.focus(),window.scrollTo(a,t)}},_onFocus:function(){this._focused=!0,this._map.fire("focus")},_onBlur:function(){this._focused=!1,this._map.fire("blur")},_setPanDelta:function(e){var o,a,l=this._panKeys={},s=this.keyCodes;for(o=0,a=s.left.length;oe||this._zoom>a.getMaxZoom()&&1 +
+ +
+
+

${}

+ + + + + + +
+
+
+ }" value=""> + ${} +
+
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
`; + + // funkcja wyszukująca markery na mapie + function runSearchPickup() { + if (typeof mymap !== 'undefined') { + mymap.eachLayer(function (layer) { + if (layer._icon !== undefined) { + mymap.removeLayer(layer); + } + }); + leafletGetTextLocation(); + } + document.querySelector('.asideContainer_pickup').innerHTML = ''; + } + + // Funkcja obsługująca dostawy z mapą + function createEventsInpost(ITEM_ID) { + var ITEM_FOR_MAP = '#item_' + ITEM_ID; + var oscItem = document.querySelector(ITEM_FOR_MAP).closest('.osc_item'); + + document.querySelector(ITEM_FOR_MAP).addEventListener('click', function (e) { + const deliveryValue = ITEM_FOR_MAP.slice(1); + + // Weź adres klienta do mapy(zalogowany lub niezalogowany: zwykly lub dostawa na inny adres) + const clientStreet = getAddressInfo("street"); + const clientZipCode = getAddressInfo("zipcode"); + const clientCity = getAddressInfo("city"); + + // Jesli nie ma informacji potrzebnej do mapy, zapisz wiadomosc do errora + let errorMessage = ""; + + if(!clientStreet) errorMessage += `${}
`; + if(!clientZipCode) errorMessage += `${}
`; + if(!clientCity) errorMessage += `${}`; + + // Zablokuj wybranie mapy jak nie ma adresu + if(errorMessage !== ""){ + Alertek.show_alert(errorMessage); + const scrolledToElement = document.getElementById("deliver_to_billingaddr").checked ? document.getElementById("delivery_firstname") : document.getElementById("client_firstname"); + scrollToHeight(scrolledToElement); + e.target.checked = false; + checkPrevShipping(); + return false; + } + app_shop.vars.courierId = ITEM_ID; + + if (oscItem.querySelector('.finpost_loading')) oscItem.querySelector('.finpost_loading').style.display = "block"; + + // Pokaż/Wstaw mapę + if (finpostjs){ + document.getElementById("fbs_z02_cover").style.display = "block"; + disablePageScroll(); + } + else { + document.querySelector('body').insertAdjacentHTML("beforeend",htmlContent); + disablePageScroll(); + + // Naprawienie searchu w leaflet(stackuja sie wyniki bez tego) + document.getElementById("autocomplete_location").addEventListener("keyup", (e) => { + const suggestions = document.querySelector(".leafleat-suggestions"); + if(!suggestions) return; + else suggestions.remove(); + }); + htmlContent = ''; + } + + // Wstaw adres klienta + const searchField = document.getElementById("autocomplete_location"); + searchField.value = `${clientStreet} ${clientZipCode} ${clientCity}`; + + // Zamknij popup + document.getElementById("fbs_z02_close").addEventListener('click', closeMap); + document.getElementById("fbs_z02_cover").addEventListener('click', function (e) { + if (e.target.closest('#fbs_z02_wrapper')) return; + closeMap(); + }); + + // Zmiana miejsca przycisku "szukaj na tym obszarze" na mobile + if (window.innerWidth < 757) document.getElementById("pickup_list_form").insertAdjacentElement("beforebegin",document.querySelector('.map_button_search')); + if (!oscItem.querySelector('.fselectedPoint')) oscItem.insertAdjacentHTML("beforeend",``); + + // wyszukiwanie punktów odbioru na mapie + if (finpostjs) { + pickup_sites.courierId = ITEM_ID; + runSearchPickup(); + } + if (!finpostjs) { + console.log("pickup_sites_list.js loaded"); + finpostjs = true; + pickup_sites.courierId = ITEM_ID; + runSearchPickup(); + + document.querySelector('#locationField .btn').click(); + // Wybranie punktu i wstawienie go koło dostawy + document.querySelector('.asideContainer_pickup').addEventListener("change", (e) => { + if(e.target.type !== "radio") return; + + //Wyczyść poprzednie punkty odbioru + clearSelectedPoints(); + + // Wybierz dobrą metode dostawy + const courierId = document.querySelector(`#pickup_list_form .asideContainer_pickup label[data-id="${e.target.value}"]`).dataset.courierId; + const prepaidValue = document.getElementById("payitem_cash").checked ? 0 : 1 + const courierInput = document.querySelector(`#item_${courierId}-${prepaidValue}`); + courierInput.checked = true; + changeCurrentShippingInfo(courierInput); + + const selectedPoint = document.querySelector('[name="shipping"]:checked').closest('.osc_item').querySelector('.fselectedPoint'); + selectedPoint.innerHTML = ""; + + // utworzenie informacji o punkcie odbioru + const deliveryId = document.querySelector('[name="pickup_point"]:checked').value; + const chosenPoint = document.querySelector(`.asideContainer_pickup label[data-id="${deliveryId}"]`); + const pickupName = chosenPoint.querySelector(".headerText").innerHTML; + const streetName = chosenPoint.querySelector(".streetText").innerHTML; + const cityName = chosenPoint.querySelector(".cityText").innerHTML; + const zipCodeName = chosenPoint.querySelector(".zipcodePickup").innerHTML.slice(0, chosenPoint.querySelector(".zipcodePickup").innerHTML.search(" { + if(!e.target.classList.contains("fbs02_btn")) return; + closeMap(); + }); + } + changeCurrentShippingInfo(e.target); + }); + } + deliveryPickupPoints.forEach(point => createEventsInpost(point)); +} +// zamknięcie mapy +function closeMap(){ + document.getElementById("fbs_z02_cover").style.display = "none"; + enablePageScroll(); +} +// Zdobądź wartość adresu, kodu pocztowego i miasta +function getAddressInfo(query){ + if(document.getElementById("deliver_to_billingaddr").checked){ + if(document.getElementById(`delivery_${query}`).value.trim()) return document.getElementById(`delivery_${query}`).value; + }; + return document.getElementById(`client_${query}`).value; +} +// utworzenie informacji o punkcie odbioru +function createPickuppointInfo(selectedPoint, deliveryPointId, name, streetText, cityText, zipcodeText, courierId){ + // Pokazanie elementu fselectedPoint + selectedPoint.style.display = "block"; + + // Wstawienie danych w punkt odbioru + selectedPoint.dataset.courierId = courierId; + selectedPoint.dataset.deliveryPointId = deliveryPointId; + selectedPoint.dataset.name = name; + selectedPoint.dataset.street = streetText; + selectedPoint.dataset.city = cityText; + selectedPoint.dataset.zipcode = zipcodeText; + + // Wstawienie danych o punkcie odbioru + selectedPoint.insertAdjacentHTML("beforeend", ` + + + `); +} + +// Zmiana widoku listy, mapy na mobilce +function toggleMapList(e){ + const ifList = e.target.dataset.show === "list"; + e.target.innerHTML = ifList ? "Pokaż Mapę" : "Pokaż Listę"; + + // Schowaj/ Pokaż mapę i listę + if(ifList){ + document.querySelector(".map_button_search").classList.add("--hide-map-el"); + document.getElementById("mymap").classList.add("--hide-map-el"); + document.querySelector(".asideContainer_pickup").classList.remove("--hide-map-el"); + }else{ + document.querySelector(".map_button_search").classList.remove("--hide-map-el"); + document.getElementById("mymap").classList.remove("--hide-map-el"); + document.querySelector(".asideContainer_pickup").classList.add("--hide-map-el"); + } + + e.target.dataset.show = ifList ? "map" : "list"; +} +/////////////////////////////////////////////////////////////////////////// +// DANE KLIENTA + +document.getElementById("cop_seection1").addEventListener("click", (e) => { + // Pokazanie się okna od logowania + if(e.target.classList.contains("get_signin")) showSigninModal(); + + // Sprawdzenie czy kliknięcie było na "Załóź konto w sklepie Opcjonalnie" + if(e.target.id === "register_client_checkbox"){ + const registerForm = document.querySelector(".register__form"); + if(e.target.checked) registerForm.classList.add("--fade-in"); + else registerForm.classList.remove("--fade-in"); + return; + } + + // Ukrycie/Pokazanie hasła + if(e.target.id === "toggle_password") return togglePassword(e.target); + + // Sprawdzenie czy kliknięcie było na firmę, czy na osobę prywatną + if(e.target.id === "client_type1") return document.querySelectorAll("#cop_seection1 .firm-group").forEach(el => el.classList.add("--fade-in")); + if(e.target.id === "client_type2") return document.querySelectorAll("#cop_seection1 .firm-group").forEach(el => el.classList.remove("--fade-in")); + + // Sprawdzenie czy dostawa na inny adres czy nie + if(e.target.id === "deliver_to_billingaddr"){ + let ifBillingaddr = false; + if(e.target.checked) ifBillingaddr = true; + return showDeliveryForm(ifBillingaddr); + } + + // Sprawdzenie czy kliknięcie będzie na guzik "Wybierz z listy adresów" i pokazanie popupa + if(e.target.classList.contains("delivery__address-list-button")){ + app_shop.fn.addressModal = new Modal({ + element: $(".delivery__address-list-container"), + classList: "--fade-in-modal", + afterShow: () => { + disablePageScroll(); + document.querySelector(".delivery__address-list").addEventListener("click", handleClickAddressList); + }, + beforeClose: () => { + enablePageScroll(); + document.querySelector(".delivery__address-list").removeEventListener("click", handleClickAddressList); + }, + }); + return; + } +}); + +// Pokaż/schowaj hasło +function togglePassword(el){ + const passwordInput = document.querySelector(".register__password"); + let showPassword = false; + if(passwordInput.type === "password") showPassword = true; + + passwordInput.type = showPassword ? "text" : "password"; + el.classList.remove(showPassword ? "register__show-password" : "register__hide-password"); + el.classList.add(showPassword ? "register__hide-password" : "register__show-password"); + el.innerHTML = showPassword ? `${}` : `${}`; +} + +// Pokaż popup logowania +function showSigninModal(){ + app_shop.fn.signinModal = new Modal({ + element: $("#signin-form-ajax"), + classList: "--fade-in-modal", + afterShow: ()=>{ + disablePageScroll(); + document.querySelector(".signin_login_input").addEventListener("keydown", logInOnEnter); + document.querySelector(".signin_pass_input").addEventListener("keydown", logInOnEnter); + }, + beforeClose: ()=>{ + enablePageScroll(); + document.querySelector(".signin_login_input").removeEventListener("keydown", logInOnEnter); + document.querySelector(".signin_pass_input").removeEventListener("keydown", logInOnEnter); + }, + }); +} + +// Pokaż(true)/Schowaj(false) formularz dostawy na inny adres +function showDeliveryForm(style){ + const deliveryWrapper = document.querySelector(".ajax_cop #client_new_additional .delivery_box.cn_wrapper"); + if((style && deliveryWrapper.classList.contains("--more")) || (!style && !deliveryWrapper.classList.contains("--more"))) return; + + // formularz dostawy na inny adres + style ? deliveryWrapper.classList.add("--more") : deliveryWrapper.classList.remove("--more"); + + // przycisk od wybierania z listy adresów + listBtn = document.querySelector(".delivery__address-list-button"); + if(listBtn) style ? listBtn.classList.add("--fade-in") : listBtn.classList.remove("--fade-in"); + + // Zmiana regionu jeśli region klienta różni się od regionu dostawy + const deliveryRegion = document.getElementById("delivery_region").value; + const clientRegion = document.getElementById("client_region").value; + if(deliveryRegion !== clientRegion) changeRegion(); +} + +// EventListener listy adresów +function handleClickAddressList(e){ + const addressLi = e.target.closest("li"); + if(!addressLi) return; + + // Uzupełnienie informacji o formularzu + const addressForm = document.querySelector(".delivery_box.cn_wrapper"); + changeDeliveryValue("#delivery_firstname", addressLi.dataset.firstname); + changeDeliveryValue("#delivery_lastname", addressLi.dataset.lastname); + + const firmName = addressForm.querySelector("#delivery_additional"); + if(addressLi.dataset.additional) { + firmName.value = addressLi.dataset.additional; + firmName.classList.add("focused"); + addSuccess(firmName); + } + else { + firmName.value = ""; + firmName.classList.remove("focused"); + clearValidation(firmName); + } + changeDeliveryValue("#delivery_street", addressLi.dataset.street); + changeDeliveryValue("#delivery_zipcode", addressLi.dataset.zipcode); + changeDeliveryValue("#delivery_city", addressLi.dataset.city); + changeDeliveryValue("#delivery_phone", addressLi.dataset.phone); + + // Zmień państwo i przeładuj metody płatności jeśli jest inny + const deliveryRegion = addressForm.querySelector("#delivery_region"); + if(deliveryRegion.value !== addressLi.dataset.region_id) { + addressForm.querySelector("#delivery_region").value = addressLi.dataset.region_id; + changeRegion(); + } + + // nadanie klasy aktywnemu adresowi + e.target.closest("ul").querySelectorAll("li").forEach(el => el.classList.remove("--active-address")); + addressLi.classList.add("--active-address"); + + // Zamkniencie modala + setTimeout(() => app_shop.fn.addressModal.closeModal(),100) +} + +// Zmień wartości pól input delivery +function changeDeliveryValue(selector, newValue){ + const selectedInput = document.querySelector(selector); + selectedInput.value = newValue; + addSuccess(selectedInput); + selectedInput.classList.add("focused") +} + +// OBSŁUGA LOGOWANIA +const SIGNIN = (signinInput) => JSON.stringify({ + query: `mutation { + login(${signinInput}) { + status + } + }`, +}); + +function logInOnEnter(e){ + if(e.key==="Enter") logInToAccount(false) +} +const signinForm = document.querySelector(".signin-form_box_text form"); +if(signinForm) signinForm.addEventListener("submit", logInToAccount); + +async function logInToAccount(event){ + if(event) event.preventDefault(); + const login = document.querySelector(".signin_login_input").value; + const password = document.querySelector(".signin_pass_input").value; + const loginStatus = await fetchData({ + data: SIGNIN(` + login: "${login.replace(/"/g, '\\"')}", + password: "${password.replace(/"/g, '\\"')}", + `), + linkParameter: '?mutation=signin', + alert: false, + }); + if (loginStatus.errors) { + Alertek.show_alert(`${}`); + return; + } + app_shop.fn.signinModal.closeModal(); + getClientNew(); + + if(document.querySelector(".order2_terms_wrapper_sub.email")) document.querySelector(".order2_terms_wrapper_sub.email").remove(); + if(document.querySelector(".order2_terms_wrapper_sub.sms")) document.querySelector(".order2_terms_wrapper_sub.sms").remove(); +} + +// Zalogowanie/inicjacja użytkownika +function getClientNew(){ + console.log("fn: getClientNew"); + app_shop.fn.ajaxLoadSite(1); + + // Przygotowanie jesli użytkownik nie jest zalogowany + if(!document.querySelector(".--logged")) document.getElementById("client_form").remove(); + document.querySelector(".step1_sub").insertAdjacentHTML("beforeend",''); + $.ajax({ + url: "/client-new.php?ajax=true&set_render=content", + timeout: 16e3, + complete: function (e, a) { + throwAjaxError(a); + app_shop.fn.ajaxLoadSite(0); + }, + success: function (e, a) { + app_shop.fn.load( + "place-order.php", + [["#cop_seection1", "#cop_seection1"]], + function () { + history.go(-1); + }, + "?set_render=content" + ).then(() => { + changeRegion(); + }) + }, + }); +}; + +///////////////////////////////////////////////////////////////////////////////////////////////////////// +// WALIDACJA + +// wyczyść klasy walidacji +function clearValidation(input){ + const wrapper = input.closest(".has-feedback") + wrapper.classList.remove('--success', '--error', 'has-error', 'has-success'); +}; +// wyczyść wiadomość błędu +function removeErrorMessage(input) { + const valMessage = input.closest('.has-feedback').querySelector('.validate_message'); + if(valMessage) valMessage.remove(); +}; +// dodaj klasy błędu +function addError(input){ + clearValidation(input); + removeErrorMessage(input); + const wrapper = input.closest(".has-feedback"); + clearValidation(wrapper); + wrapper.classList.add('--error', 'has-error'); +}; +// dodaj klasy sukcesu +function addSuccess(input){ + clearValidation(input); + removeErrorMessage(input); + const wrapper = input.closest(".has-feedback"); + clearValidation(wrapper); + wrapper.classList.add('--success', 'has-success'); +}; +// dodaj error wraz z wiadomością +function addErrorMessage(input, message){ + addError(input); + input.closest('.has-feedback').insertAdjacentHTML("beforeend",`${message}.`); +} +// waliduj elementy wymagające wysłania requesta (zipcode, nip) +async function validateRequest(target, order=false){ + const wrapper = target.closest(".has-feedback"); + let reqData = `${target.name}=${target.value}`; + + if(target.dataset.serialize) { + const serializeEl = document.querySelector(target.dataset.serialize); + reqData += '&' + `${serializeEl.name}=${encodeURIComponent(serializeEl.value)}`; + } + if(target.dataset.revalidate) { + target.dataset.revalidate.split(",").forEach(elQuery => { + validateRequest(document.querySelector(elQuery)); + }) + } + if(target.value === '') { + addErrorMessage(target, ); + return false; + } + + const resData = await $.ajax({ + url: '/ajax/client-new.php?validAjax=true', + type: 'POST', + timeout: 16000, + dataType: 'JSON', + data: reqData, + }); + + if(resData.errno) { + let error_message = ''; + if (resData.message.error_code) { + if (resData.message.zipcode_pattern && (resData.message.error_code === 'incorect_zipcode' || resData.message.error_code === 'incorect_delivery_zipcode')) { + error_message = clientNewErrorCode[resData.message.error_code] + ' ' + `${}]:` + ' '; + error_message += resData.message.zipcode_pattern.join(', '); + } + else if (clientNewErrorCode[resData.message.error_code]) error_message = clientNewErrorCode[resData.message.error_code]; + } + addError(target); + if (error_message) addErrorMessage(target, error_message); +return false + }else{ + addSuccess(target); + if (target.name==="client_email" && !order) { + $.ajax({ + url: '/ajax/client-new.php?checkClientExists=true', + type: 'POST', + timeout: 16000, + dataType: 'JSON', + data: {'client_mail': target.value}, + }).then(function succesFn(resData) { + if(resData.client_exists === true || resData.login) showEmailPopup(resData); + }); + } +return true; + } + }; +// Pokaż popup jeśli użytkownik wpisał email który posiada już konto +function showEmailPopup(resData){ + app_shop.fn.emailModal = new Modal({ + html: ` +
+
+ ${} + ${}: +
+ ${resData.mail} +
+
+

+ ${} +

+
+ + + +
+
`, + classList: "--fade-in-modal", + afterShow: disablePageScroll, + beforeClose: enablePageScroll, + }); + return; +} +function handleShowSigninModalFromEmailModal(e){ + e.preventDefault(); + app_shop.fn.emailModal.closeModal(); + showSigninModal(); +} + +// event listener zmian w kontenerze cop_seection1 +const validateRequestId = ["client_zipcode", "delivery_zipcode", "client_nip", "client_email"]; +const notEmptyFieldsId = ["client_firstname", "client_lastname", "client_city", "delivery_firstname", "delivery_lastname", "delivery_city", "client_firm"]; +document.getElementById("cop_seection1").addEventListener("change", (e) => { + // walidacja zipcode, nipu i emaila + if(validateRequestId.includes(e.target.id)) return validateRequest(e.target); + + // zmiana regionu + if(e.target.name === "client_region" || e.target.name === "delivery_region") { + const clientType = e.target.name.split("_")[0]; + validateRequest(document.getElementById(`${clientType}_zipcode`)); + if(clientType === "client" && document.getElementById("client_type1").checked === true) validateRequest(document.getElementById("client_nip")); + changeRegion(); + return; + } + + // Walidacja ulicy i numeru domu + if(e.target.id === "client_street" || e.target.id === "delivery_street") validateStreet(e.target); + // Walidacja numeru telefonu + if(e.target.id === "client_phone" || e.target.id === "delivery_phone") validatePhone(e.target); + // Walidacja loginu i hasła rejestracji + if(e.target.classList.contains("register__login")) testLogin(); + if(e.target.classList.contains("register__password")) testPassword(); + // Walidacja imienia nazwiska miasta i firmy(wymagające po prostu nie bycia pustym) + if(notEmptyFieldsId.includes(e.target.id)) validateNotEmpty(e.target); + + // Sprawdzenie czy firma w dostawie na inny adres została wpisana + if(e.target.id === "delivery_additional"){ + if(e.target.value.length > 0) addSuccess(e.target); + else clearValidation(e.target); + }; +}); +// funkcje walidacji poszczególnych elementów +function validateStreet(streetEl){ + const streetParts = streetEl.value.split(" "); + const addressNumber = Number(streetParts[streetParts.length-1][0]); + if(streetEl.value.length === 0 || (streetEl.value.length > 0 && (!addressNumber || streetParts.length < 2))){ + addErrorMessage(streetEl, ); + return false; + }else{ + addSuccess(streetEl); + return true; + } +} +function validatePhone(streetEl){ + const phoneNumber = streetEl.value.replaceAll(" ",""); + if(phoneNumber.length===0 || (phoneNumber.length > 0 && !(Number(phoneNumber)) || phoneNumber.length<9)){ + addErrorMessage(streetEl, ); + return false; + }else { + addSuccess(streetEl); + return true; + } +} +function validateNotEmpty(checkEl){ + if(checkEl.value.length < 1) { + addErrorMessage(checkEl, ); + return false; + } + else{ + addSuccess(checkEl); + return true; + } +} + +// Sprawdzenie loginu i hasla +function testLogin(){ + const login = document.querySelector(".register__login"); + if(login.value.trim().length < 1){ + addErrorMessage(login, ); + return false; + } + else if(!/^[A-Za-z0-9@._-]*$/.test(login.value.trim()) || Number(login.value.trim()) || login.value.trim().length<3){ + addErrorMessage(login, ); + return false; + }else{ + addSuccess(login); + return true; + } +} +function testPassword(){ + const repeatPassword = document.getElementById("repeat_password"); + const password = document.querySelector(".register__password"); + repeatPassword.value = password.value; + if(password.value.trim().length < 1){ + addError(password); + password.closest('.has-feedback').insertAdjacentHTML("beforeend", `${}.`); + return false; + } + if(password.value.trim().length < 6){ + addError(password); + password.closest('.has-feedback').insertAdjacentHTML("beforeend", `${}.`); + return false; + }else{ + addSuccess(password); + return true; + } +} + +// Obsługa przesuwających się labelek +document.querySelector("body").addEventListener("change", (e) => { + if(e.target.classList.contains("f-control")){ + if(e.target.value.length > 0) e.target.classList.add("focused"); + else e.target.classList.remove("focused"); + } +}) + +/////////////////////////////////////////////////////////////////////// +// DOSTAWA I PŁATNOSĆI + +const SET_REGION = (setRegionInput) => JSON.stringify({ + query: `mutation { + setRegion(${setRegionInput}) { + status + error { + code + message + } + } + }`, +}); + +// Zmiana regionu dostawy +async function changeRegion(payAndDelData = null, firstLoad = false) { + console.log("fn: changeRegion"); + + // Pobranie informacji o regionie z formularza + const clientRegion = document.getElementById("client_region").value; + const deliveryRegion = document.getElementById("deliver_to_billingaddr").checked ? document.getElementById("delivery_region").value : clientRegion; + + + + // Zmiana regionu + const regionStatus = await this.fetchData({ + data: SET_REGION(`SetRegionInput: { + billingRegionId: ${clientRegion}, + deliveryRegionId: ${deliveryRegion}, + areForced: true + }`), + linkParameter: '?mutation=setRegion', + }); + const { status } = regionStatus?.data?.setRegion || {}; + if (status !== 'success') return alert("Błąd podczas zmiany kraju. Przeładuj stronę jeszcze raz."); + + // Pobranie nowych metod płatności i dostaw + getNewPaymentsAndDeliveries(payAndDelData, firstLoad); +}; + +// załadowanie metod dostaw i płatności +function getNewPaymentsAndDeliveries(data = null, firstLoad = false) { + console.log("fn: order1_new"); + // Wyczyszczenie zapisanych poprzednich metod płatności + prevPayment = undefined; + prevShipping = undefined; + // Wyczyszczenie punktow odbioru + deliveryPickupPoints.length = 0; + app_shop.fn.ajaxLoadSite(1); + + // Dane do uzupełnienia przy edycji + let paymentValue, deliveryId; + if(data){ + paymentValue = data.paymentMethodId; + deliveryId = `item_${data.deliveryMethodId}-${paymentValue === "cash" ? "0" : "1"}`; + } + + // Pobranie metod płatności i dostawy + $.ajax({ + url: "/ajax/get-deliveries.php?mode=productAndBasket&prepaids=true", + dataType: "json", + timeout: 1e4, + async: !0, + complete: function (e, a) { + throwAjaxError(a); + app_shop.fn.ajaxLoadSite(0); + }, + success: function (e) { + let prepaidMarkup = ""; + + // Stworzenie markupa dla metod dostaw + e.prepaid.forEach(function (method) { + prepaidMarkup += prepareDeliveryMarkup(method, deliveryId); + }); + + // Stworzenie markupa dla metod dostaw (dla płatności przy odbiorze) + let dvpMarkup = ""; + e.dvp.forEach(function (method) { + dvpMarkup += prepareDeliveryMarkup(method, deliveryId); + }); + + // Wstawienie metod dostaw na strone + const deliveryMarkup = `
${prepaidMarkup}
${dvpMarkup}
`; + const previousDeliveries = document.getElementById("osc_order1"); + if(previousDeliveries) previousDeliveries.remove(); + document.querySelector(".ajax_cop .step2_sub").insertAdjacentHTML("beforeend",deliveryMarkup); + + // Stworzenie metod płatności + let prepaidsMethodMarkup = ""; + let prepaidsTransferMarkup = createPaymentContainerMarkup("transfer"); + let prepaidsCardMarkup = createPaymentContainerMarkup("card"); + + // Sprawdzenie czy sklep ma możliwość płatności bankiem/kartą + let ifPaymentTransfer = false; + let ifPaymentCard = false; + + // Przygotowanie Płatności + e.prepaids_method.forEach(function (method) { + const markup = ` + `; + + // Przygotowanie metod dla przelewów online/kart płatności + if(method.group === "transfer") { + prepaidsTransferMarkup += markup; + ifPaymentTransfer = true; + } + else if(method.group === "card"){ + prepaidsCardMarkup += markup; + ifPaymentCard = true; + } + else{ + prepaidsMethodMarkup += markup; + // okienko vouchera + if(method.id === 2){ + prepaidsMethodMarkup += ` +
+
+ Bon towarowy + Zapłać za zakupy bonem towarowym +
+
+
+
+ + + +
+
+
+
+ +
+ Jeżeli posiadasz więcej bonów, możesz wpisać ich numery przy podsumowaniu zamówienia. +
` + } + } + }); + prepaidsTransferMarkup +="
"; + prepaidsCardMarkup +="
"; + + // Dołączenie metody płatność przy odbiorze + if(e.dvp.length) prepaidsMethodMarkup += ` + `; + + // Wstawienie metod płatności na stronę + const previousPayments = document.getElementById("osc_prepaids_method"); + if(previousPayments) previousPayments.remove(); + document.querySelector(".ajax_cop #checkout_step3_1 .step3_sub").insertAdjacentHTML("beforeend", `
${ifPaymentTransfer ? prepaidsTransferMarkup : ""}${ifPaymentCard ? prepaidsCardMarkup : ""}${prepaidsMethodMarkup}
`); + + // Wstawienie błędu jeśli metody płatności są puste + const currentPayments = document.getElementById("osc_prepaids_method"); + if(document.getElementById("osc_prepaids_method").innerHTML === "") currentPayments.insertAdjacentHTML("beforeend",'"); + + // Wstawienie pickuppoint jeśli edycja i istnieje + if(data?.pickupData !== undefined && data?.pickupData !== null){ + const selectedShipping = document.querySelector(`#cop_seection2 input#${deliveryId}`); + const pointExists = checkPrevPickupPoint( + selectedShipping.parentElement.querySelector(".fselectedPoint"), + data.pickupData.id, + data.pickupData.name, + `${data.pickupData.address.street} ${data.pickupData.address.buildingAndHouseNumber}`, + data.pickupData.address.city, + data.pickupData.address.postcode, + data.deliveryMethodId + ); + + // Odznaczenie punktu jeśli punkt odbioru nie istnieje(Wcześniej był zaznaczony przy edycji) + if(!pointExists) selectedShipping.checked = false; + + }// Sprawdzenie czy użytkownik ma zapisane poprzednio użyte metody w przeglądarce(tylko przy pierwszym załadowaniu strony) + else if(localStorage.getItem("prevPaymentMethod") && localStorage.getItem("prevDeliveryMethod") && firstLoad){ + const prevPaymentMethod = JSON.parse(localStorage.getItem("prevPaymentMethod")); + + // Zaznaczenie metod płatności które nie tworzą popupa + if(prevPaymentMethod.id !== "payitem_2" && prevPaymentMethod.group !== "card" && prevPaymentMethod.group !== "transfer") document.getElementById(prevPaymentMethod.id).click(); + else if(prevPaymentMethod.group === "card" || prevPaymentMethod.group === "transfer"){ + const paymentMethodId = prevPaymentMethod.id.replace("-clone", ""); + cloneElement(document.getElementById(paymentMethodId)); + } + + // poprzednia dostawa + const prevDeliveryMethod = JSON.parse(localStorage.getItem("prevDeliveryMethod")); + const prevDeliveryInput = document.querySelector(`input#${prevDeliveryMethod.id}`); + + // Sprawdzenie czy istnieje metoda płatności(na wypadek gdyby była usunięta lub klient zamawiał do innego kraju) + if(prevDeliveryInput){ + // sprawdzenie czy dostawa miała punkt odbioru + if(prevDeliveryMethod.fselectedPoint){ + const pointExists = checkPrevPickupPoint( + prevDeliveryInput.parentElement.querySelector(".fselectedPoint"), + prevDeliveryMethod.fselectedPoint.deliveryPointId, + prevDeliveryMethod.fselectedPoint.name, + prevDeliveryMethod.fselectedPoint.street, + prevDeliveryMethod.fselectedPoint.city, + prevDeliveryMethod.fselectedPoint.zipcode, + prevDeliveryMethod.fselectedPoint.courierId + ); + if(pointExists) prevDeliveryInput.checked = true; + }else{ + prevDeliveryInput.checked = true; + } + } + } + // Przeładowanie mapy + loadMap(); + // Przeliczenie kosztu dostawy + calculateBasketCost(); + // Zmiana daty dostawy i pokazanych opcji dostawy + const firstInput = document.getElementById("osc_order1 input"); + if(firstInput) deliveryDate(firstInput.value, firstInput.dataset.delivery, firstInput.dataset.pickuppoint); + calculateBasketCost(); + app_shop.fn.ajaxLoadSite(0); + }, + }); +}; +// Stworzenie kontenera na "przelewy online" lub "karta platnicza" +function createPaymentContainerMarkup(method){ + const operationName = method === "transfer" ? : ; + const methodName = method === "transfer" ? "banków" : "kart płatniczych"; + return `
");$(".loadingMap").hide();return false}else{$(".mapContainer_pickup, .asideContainer_pickup, .pickupl_submit, #pickup_map").show()}pickup_sites.search_lat=place.geometry.location.lat();pickup_sites.search_lng=place.geometry.location.lng();for(var i=0;i'+pickupl_select_adress+"
");$(".loadingMap").hide();return false}else{$(".mapContainer_pickup, .asideContainer_pickup, .pickupl_submit, #pickup_map").show()}$("label.pickup_point").hide();$("div.loadingMap").fadeIn("normal",function(){});$("span.loadingMarkers").hide();var options={courierId:pickup_sites.courierId,"location[latitude]":pickup_sites.search_lat,"location[longitude]":pickup_sites.search_lng,isCod:pickup_sites.isCod};if(radius){function getRadius(){var curr_zoom=pickup_sites.mapa.getZoom();if(curr_zoom>=15){return 1}else if(curr_zoom==14){return 2}else if(curr_zoom==13){return 4}else if(curr_zoom==12){return 7}else if(curr_zoom==11){return 10}else if(curr_zoom==10){return 15}else{return 20}}var options={courierId:pickup_sites.courierId,"location[latitude]":pickup_sites.search_lat,"location[longitude]":pickup_sites.search_lng,radius:getRadius(),isCod:pickup_sites.isCod}}$.ajax({type:"GET",url:"/ajax/getPickups.php",data:options,dataType:"json",success:function(json){if(!jQuery.isEmptyObject(selected_pickup_point)){for(i in json.pickupPoints){if(json.pickupPoints[i].id==selected_pickup_point.id){delete json.pickupPoints[i]}}json.pickupPoints.unshift(selected_pickup_point)}if(!json.pickupPoints.length){if(radius){$("div.asideContainer_pickup").prepend('")}else{$("div.asideContainer_pickup").prepend('")}$(".loadingMap").hide();return false}if(!pickup_sites.adress.route){for(i in json.pickupPoints){if($.trim(json.pickupPoints[i].address.city).toLowerCase()==$.trim(pickup_sites.adress.locality).toLowerCase()){options.radius=30;$.ajax({type:"GET",url:"/ajax/getPickups.php",data:options,dataType:"json",success:function(json){setPickupPoints(json,true)},error:function(){}});return false}}}setPickupPoints(json,false)},error:function(){$("div.asideContainer_pickup").prepend('")}})},showSel:function(){pickup_sites.pickupCount=$(".asideContainer_pickup .pickup_point").length;pickup_sites.pickupIteration=0;$("div.loadingMap").fadeIn("normal",function(){});$("span.loadingMap").hide();$("span.loadingMarkers").css("display","block");$("span.loadingMarkersCount").text(pickup_sites.pickupCount);$("span.loadingMarkersComplete").text(pickup_sites.pickupIteration);pickup_sites.markersArray=[];var adresData=[];$(".asideContainer_pickup .pickup_point").each(function(index){$this=$(this);adresData[index]={};adresData[index].idek=$this.data("id");adresData[index].headerText=$.trim($this.find(".headerText").text());adresData[index].streetText=$this.find(".streetText").text();adresData[index].cityText=$.trim($this.find(".cityText").text());adresData[index].moreText=$.trim($this.find(".moreLink").text());adresData[index].moreLink=$.trim($this.find(".moreLink").attr("href"));adresData[index].infoText=$.trim($this.find(".infoText").text());adresData[index].timeText=$.trim($this.find(".timeText").text());adresData[index].latitude=$.trim($this.data("latitude"));adresData[index].longitude=$.trim($this.data("longitude"));adresData[index].icon=$.trim($this.data("icon"))});var adresRow="";while(adresRow=adresData.pop()){if(adresRow.latitude&&adresRow.longitude){pickup_sites.findAdres(adresRow.headerText,adresRow.streetText,adresRow.cityText,adresRow.moreText,adresRow.moreLink,adresRow.infoText,adresRow.timeText,"none","another",false,adresRow.idek,adresRow.latitude,adresRow.longitude,adresRow.icon)}else{(function(adresRow){setTimeout(function(){pickup_sites.findAdres(adresRow.headerText,adresRow.streetText,adresRow.cityText,adresRow.moreText,adresRow.moreLink,adresRow.infoText,adresRow.timeText,"none","another",false,adresRow.idek,adresRow.latitude,adresRow.longitude,adresRow.icon)},pickup_sites.timeout)})(adresRow)}}},printDates:function(stockId){if(!$("#selectPickupDay").size())return false;var postData={stock_id:stockId};$.ajax({type:"GET",url:"/ajax/basket-delivery.php",data:postData,dataType:"json",success:function(json){if(!json){$("#selectPickupDayWrapper").hide();return false}$("#selectPickupDay").html("");$.each(json,function(index,data){$("#selectPickupDay").append('")});$("#selectPickupDayWrapper").show();$(".pickupl_hour_wrapper").show();$('#selectPickupDay [name="calendar_select_date"]').eq(1).prop("checked",true)},error:function(){Alertek.show_alert(pickupl_error)}})},setZoom:function(){var bounds=new google.maps.LatLngBounds;for(var i in pickup_sites.markersArray){bounds.extend(pickup_sites.markersArray[i].getPosition())}pickup_sites.mapa.setCenter(bounds.getCenter());pickup_sites.mapa.fitBounds(bounds);pickup_sites.mapa.setZoom(pickup_sites.mapa.getZoom());if(pickup_sites.mapa.getZoom()>15){pickup_sites.mapa.setZoom(15)}},mapInit:function(){if($("#mymap").length){return false}if($("#autocomplete_location").size()&&!$("#mymap").size()){pickup_sites.autocomplete=new google.maps.places.Autocomplete(document.getElementById("autocomplete_location"));$("label.pickup_point").hide()}pickup_sites.zoom=pickupsZoom;pickup_sites.geokoder=new google.maps.Geocoder;var wspolrzedne=new google.maps.LatLng(parseInt(bCordPickups),parseInt(lCordPickups));if(markersAnimationPickups!="")pickup_sites.markerAnimation=true;else pickup_sites.markerAnimation=false;if(markerPickupsCustomIcon!="")markerPickupsCustomIcon=true;else markerPickupsCustomIcon=false;if(mapTypePickups=="ROADMAP")var mapStyle=google.maps.MapTypeId.ROADMAP;else if(mapTypePickups=="SATELLITE")var mapStyle=google.maps.MapTypeId.SATELLITE;else if(mapTypePickups=="HYBRID")var mapStyle=google.maps.MapTypeId.HYBRID;else if(mapTypePickups=="TERRAIN")var mapStyle=google.maps.MapTypeId.TERRAIN;else var mapStyle=google.maps.MapTypeId.ROADMAP;if(navControlPickups!="")navControlPickups=true;else navControlPickups=false;if(mapTypeControlPickups!="")mapTypeControlPickups=true;else mapTypeControlPickups=false;if(scControlPickups!="")scControlPickups=true;else scControlPickups=false;if(controlTypePickups=="ZOOM_PAN")var controlStyle=google.maps.NavigationControlStyle.ZOOM_PAN;else if(controlTypePickups=="SMALL")var controlStyle=google.maps.NavigationControlStyle.SMALL;else if(controlTypePickups=="ANDROID")var controlStyle=google.maps.NavigationControlStyle.ANDROID;else var controlStyle=google.maps.NavigationControlStyle.ZOOM_PAN;if(mapTypeControlStylePickups=="DROPDOWN_MENU")var TypeControlStyle=google.maps.MapTypeControlStyle.DROPDOWN_MENU;else if(mapTypeControlStylePickups=="HORIZONTAL_BAR")var TypeControltyle=google.maps.MapTypeControlStyle.HORIZONTAL_BAR;else var TypeControlStyle=google.maps.MapTypeControlStyle.DROPDOWN_MENU;if($("img.marker_face").attr("src")!=""&&markerPickupsCustomIcon){var markerIconSize=new google.maps.Size($("img.marker_face").width(),$("img.marker_face").height());var punkt_startowy=new google.maps.Point(0,0);var punkt_zaczepienia=new google.maps.Point(parseInt($("img.marker_face").width()/2),parseInt($("img.marker_face").height()/2));pickup_sites.markerIcon=new google.maps.MarkerImage($("img.marker_face").attr("src"),markerIconSize,punkt_startowy,punkt_zaczepienia)}if(window["google_map_style_array"]){var mapOptions={gestureHandling:"cooperative",zoom:pickup_sites.zoom,center:wspolrzedne,mapTypeId:mapStyle,navigationControl:navControlPickups,mapTypeControl:mapTypeControlPickups,scaleControl:scControlPickups,styles:google_map_style_array,navigationControlOptions:{style:controlStyle},mapTypeControlOptions:{style:TypeControlStyle}}}else{var mapOptions={gestureHandling:"cooperative",zoom:pickup_sites.zoom,center:wspolrzedne,mapTypeId:mapStyle,navigationControl:navControlPickups,mapTypeControl:mapTypeControlPickups,scaleControl:scControlPickups,navigationControlOptions:{style:controlStyle},mapTypeControlOptions:{style:TypeControlStyle}}}if(pickup_sites.google_api_key===""){$(".pickupl_sel").removeAttr("disabled");$("div#ps_other").css("opacity","1.0");$("div#ps_other").css("cursor","pointer")}pickup_sites.mapa=new google.maps.Map(document.getElementById("pickup_map"),mapOptions);pickup_sites.markerInfo=new google.maps.InfoWindow;google.maps.event.addListener(pickup_sites.mapa,"idle",function(){$("span.loadingMap").text($("span.loadingNav").text())});if(pickup_sites.autocomplete){pickup_sites.autocomplete.addListener("place_changed",function(){var place=pickup_sites.autocomplete.getPlace();pickup_sites.fillInAddress(place,false);pickup_sites.getLocation()});pickup_sites.getLocation()}else{pickup_sites.showSel()}},markerClickFunction:function(latlng,content){return function(e){e.cancelBubble=true;e.returnValue=false;if(e.stopPropagation){e.stopPropagation();e.preventDefault()}pickup_sites.infoWindow.setContent(content);pickup_sites.infoWindow.setPosition(latlng);pickup_sites.infoWindow.open(pickup_sites.mapa)}},geokoderPrepare:function(point,status,headerText,streetText,cityText,moreText,moreLink,infoText,timeText,className,other,open,idek,latitude,longitude,icon){if(status==google.maps.GeocoderStatus.OK){pickup_sites.timeout=100;pickup_sites.pickupIteration++;pickup_sites.pickupFind++;var content='
'+headerText+"";content+='
'+streetText+"  "+cityText+"
";if(infoText){content+='
'+infoText+"
"}content+='
'+timeText+"
";if(moreLink){if(mapTooltipLink_class==="")content+='";else content+='"}content+="
";var opcjeMarkera={title:headerText,pickupPointID:idek};opcjeMarkera.position=point;opcjeMarkera.map=pickup_sites.mapa;if(pickup_sites.markerAnimation)opcjeMarkera.animation=google.maps.Animation.DROP;if(icon&&icon!=""){opcjeMarkera.icon=icon}else{if($("img.marker_face").attr("src")!=""&&markerPickupsCustomIcon){opcjeMarkera.icon=pickup_sites.markerIcon}}var marker=new google.maps.Marker(opcjeMarkera);pickup_sites.markersArray.push(marker);google.maps.event.addListener(marker,"click",function(marker,i){return function(e){e.cancelBubble=true;e.returnValue=false;if(e.stopPropagation){e.stopPropagation();e.preventDefault()}pickup_sites.markerInfo.setContent(content);pickup_sites.markerInfo.open(pickup_sites.mapa,marker);$('.asideContainer_pickup [value="'+marker.pickupPointID+'"]').prop("checked",true);$(".asideContainer_pickup").scrollTop(0);$(".asideContainer_pickup").scrollTop($('#pickup_site [name="pickup_point"]:checked + label').position().top)}}(marker,i));var pickupItem=$('.asideContainer_pickup [value="'+marker.pickupPointID+'"]').get(0);$('label[for="pickup_point_'+marker.pickupPointID+'"]').show().fadeTo("slow",1);google.maps.event.addDomListener(pickupItem,"click",function(marker,i){return function(e){$('.asideContainer_pickup [value="'+marker.pickupPointID+'"]').prop("checked",true);pickup_sites.markerInfo.setContent(content);pickup_sites.mapa.setCenter(opcjeMarkera.position);if(pickup_sites.mapa.getZoom()=pickup_sites.pickupCount){setTimeout(function(){$("div.loadingMap").fadeOut("normal",function(){});var _src=$('.markerCluster[src*="m1.png"]').attr("src");var _imagePath=_src.substring(0,_src.indexOf("1.png"));pickup_sites.setZoom();var create_map_selected_point=true;if(pickup_sites.mapa.zoom=pickup_sites.pickupCount){setTimeout(function(){$("div.loadingMap").fadeOut("normal",function(){});var _src=$('.markerCluster[src*="m1.png"]').attr("src");var _imagePath=_src.substring(0,_src.indexOf("1.png")-1);pickup_sites.setZoom();var create_map_selected_point=true;if(pickup_sites.mapa.zoom')}if(pickup.coordinates.longitude){pickup_clone.find("label .map_dir").attr("href","https://www.google.com/maps/dir/?api=1&destination="+pickup.coordinates.latitude+","+pickup.coordinates.longitude)}else{pickup_clone.find("label .map_dir").attr("href","https://maps.google.com?saddr=Current+Location&daddr="+pickup.address.street+"+"+pickup.address.postcode+"+"+pickup.address.city)}pickup_clone.find("b.headerText").text(pickup.name);var pickup_street=pickup.address.buildingAndHouseNumber!=""&&pickup.address.buildingAndHouseNumber!=null?pickup.address.street+" "+pickup.address.buildingAndHouseNumber:pickup.address.street;pickup_clone.find("span.streetText").text(pickup_street);pickup_clone.find("span.zipcodePickup").html(pickup.address.postcode+' '+pickup.address.city+"");pickup_clone.find("div.moreText").text(pickup.location);pickup_clone.find("a.moreLink").attr("href",pickup.link);if(pickup.requiresClientNumber){}else{pickup_clone.find("input[name=client_courier_number]").remove()}$("#pickup_site .asideContainer_pickup").append(pickup_clone.find(" > *"))}pickup_sites.showSel()};function geolocate(){pickup_sites.search_lat="";pickup_sites.search_lng="";if(navigator.geolocation){navigator.geolocation.getCurrentPosition(function(position){var geolocation={lat:position.coords.latitude,lng:position.coords.longitude};var circle=new google.maps.Circle({center:geolocation,radius:position.coords.accuracy});pickup_sites.autocomplete.setBounds(circle.getBounds())})}}$(document).on("click","#locationField .btn",function(){if(!$("#mymap").length){pickup_sites.getLocation()}else{leafletGetTextLocation();$(".leafleat-suggestions").remove()}return false});$(document).on("click","div.morePickup",function(){var activePoints=$("label.pickup_point.moreInfoShow");$(this).parents("label.pickup_point").addClass("moreInfoShow");activePoints.removeClass("moreInfoShow")});$(document).on("click",'#pickup_site [name="pickup_point"], #pickup_site [name="stock"]',function(){$('#pickup_site [name="client_courier_number"]').prop("disabled",true);$(this).find('+ label [name="client_courier_number"]').prop("disabled",false).focus();pickup_sites.printDates($(this).val())});app_shop.run(function(){pickup_sites.country_code=app_shop.vars.country_code;pickup_sites.language=app_shop.vars.language;pickup_sites.isCod=app_shop.vars.isCod;pickup_sites.courierId=app_shop.vars.courierId;init_pickupl_site();var mapLink="https://maps.googleapis.com/maps/api/js?key="+app_shop.vars.apiKey+"&libraries=places&callback=pickup_sites.mapInit";var pickup_src=document.createElement("script");pickup_src.setAttribute("src",mapLink);document.body.appendChild(pickup_src)},"all","#pickup_site");function MarkerClusterer(map,opt_markers,opt_options){this.extend(MarkerClusterer,google.maps.OverlayView);this.map_=map;this.markers_=[];this.clusters_=[];this.sizes=[53,56,66,78,90];this.styles_=[];this.ready_=false;var options=opt_options||{};this.gridSize_=options["gridSize"]||60;this.minClusterSize_=options["minimumClusterSize"]||2;this.maxZoom_=options["maxZoom"]||null;this.styles_=options["styles"]||[];this.imagePath_=options["imagePath"]||this.MARKER_CLUSTER_IMAGE_PATH_;this.imageExtension_=options["imageExtension"]||this.MARKER_CLUSTER_IMAGE_EXTENSION_;this.zoomOnClick_=true;if(options["zoomOnClick"]!=undefined){this.zoomOnClick_=options["zoomOnClick"]}this.averageCenter_=false;if(options["averageCenter"]!=undefined){this.averageCenter_=options["averageCenter"]}this.setupStyles_();this.setMap(map);this.prevZoom_=this.map_.getZoom();var that=this;google.maps.event.addListener(this.map_,"zoom_changed",function(){var zoom=that.map_.getZoom();var minZoom=that.map_.minZoom||0;var maxZoom=Math.min(that.map_.maxZoom||100,that.map_.mapTypes[that.map_.getMapTypeId()].maxZoom);zoom=Math.min(Math.max(zoom,minZoom),maxZoom);if(that.prevZoom_!=zoom){that.prevZoom_=zoom;that.resetViewport()}});google.maps.event.addListener(this.map_,"idle",function(){that.redraw()});if(opt_markers&&(opt_markers.length||Object.keys(opt_markers).length)){this.addMarkers(opt_markers,false)}}MarkerClusterer.prototype.MARKER_CLUSTER_IMAGE_PATH_="../images/m";MarkerClusterer.prototype.MARKER_CLUSTER_IMAGE_EXTENSION_="png";MarkerClusterer.prototype.extend=function(obj1,obj2){return function(object){for(var property in object.prototype){this.prototype[property]=object.prototype[property]}return this}.apply(obj1,[obj2])};MarkerClusterer.prototype.onAdd=function(){this.setReady_(true)};MarkerClusterer.prototype.draw=function(){};MarkerClusterer.prototype.setupStyles_=function(){if(this.styles_.length){return}for(var i=0,size;size=this.sizes[i];i++){this.styles_.push({url:this.imagePath_+(i+1)+"."+this.imageExtension_,height:size,width:size})}};MarkerClusterer.prototype.fitMapToMarkers=function(){var markers=this.getMarkers();var bounds=new google.maps.LatLngBounds;for(var i=0,marker;marker=markers[i];i++){bounds.extend(marker.getPosition())}this.map_.fitBounds(bounds)};MarkerClusterer.prototype.setStyles=function(styles){this.styles_=styles};MarkerClusterer.prototype.getStyles=function(){return this.styles_};MarkerClusterer.prototype.isZoomOnClick=function(){return this.zoomOnClick_};MarkerClusterer.prototype.isAverageCenter=function(){return this.averageCenter_};MarkerClusterer.prototype.getMarkers=function(){return this.markers_};MarkerClusterer.prototype.getTotalMarkers=function(){return this.markers_.length};MarkerClusterer.prototype.setMaxZoom=function(maxZoom){this.maxZoom_=maxZoom};MarkerClusterer.prototype.getMaxZoom=function(){return this.maxZoom_};MarkerClusterer.prototype.calculator_=function(markers,numStyles){var index=0;var count=markers.length;var dv=count;while(dv!==0){dv=parseInt(dv/10,10);index++}index=Math.min(index,numStyles);return{text:count,index:index}};MarkerClusterer.prototype.setCalculator=function(calculator){this.calculator_=calculator};MarkerClusterer.prototype.getCalculator=function(){return this.calculator_};MarkerClusterer.prototype.addMarkers=function(markers,opt_nodraw){if(markers.length){for(var i=0,marker;marker=markers[i];i++){this.pushMarkerTo_(marker)}}else if(Object.keys(markers).length){for(var marker in markers){this.pushMarkerTo_(markers[marker])}}if(!opt_nodraw){this.redraw()}};MarkerClusterer.prototype.pushMarkerTo_=function(marker){marker.isAdded=false;if(marker["draggable"]){var that=this;google.maps.event.addListener(marker,"dragend",function(){marker.isAdded=false;that.repaint()})}this.markers_.push(marker)};MarkerClusterer.prototype.addMarker=function(marker,opt_nodraw){this.pushMarkerTo_(marker);if(!opt_nodraw){this.redraw()}};MarkerClusterer.prototype.removeMarker_=function(marker){var index=-1;if(this.markers_.indexOf){index=this.markers_.indexOf(marker)}else{for(var i=0,m;m=this.markers_[i];i++){if(m==marker){index=i;break}}}if(index==-1){return false}marker.setMap(null);this.markers_.splice(index,1);return true};MarkerClusterer.prototype.removeMarker=function(marker,opt_nodraw){var removed=this.removeMarker_(marker);if(!opt_nodraw&&removed){this.resetViewport();this.redraw();return true}else{return false}};MarkerClusterer.prototype.removeMarkers=function(markers,opt_nodraw){var removed=false;for(var i=0,marker;marker=markers[i];i++){var r=this.removeMarker_(marker);removed=removed||r}if(!opt_nodraw&&removed){this.resetViewport();this.redraw();return true}};MarkerClusterer.prototype.setReady_=function(ready){if(!this.ready_){this.ready_=ready;this.createClusters_()}};MarkerClusterer.prototype.getTotalClusters=function(){return this.clusters_.length};MarkerClusterer.prototype.getMap=function(){return this.map_};MarkerClusterer.prototype.setMap=function(map){this.map_=map};MarkerClusterer.prototype.getGridSize=function(){return this.gridSize_};MarkerClusterer.prototype.setGridSize=function(size){this.gridSize_=size};MarkerClusterer.prototype.getMinClusterSize=function(){return this.minClusterSize_};MarkerClusterer.prototype.setMinClusterSize=function(size){this.minClusterSize_=size};MarkerClusterer.prototype.getExtendedBounds=function(bounds){var projection=this.getProjection();var tr=new google.maps.LatLng(bounds.getNorthEast().lat(),bounds.getNorthEast().lng());var bl=new google.maps.LatLng(bounds.getSouthWest().lat(),bounds.getSouthWest().lng());var trPix=projection.fromLatLngToDivPixel(tr);trPix.x+=this.gridSize_;trPix.y-=this.gridSize_;var blPix=projection.fromLatLngToDivPixel(bl);blPix.x-=this.gridSize_;blPix.y+=this.gridSize_;var ne=projection.fromDivPixelToLatLng(trPix);var sw=projection.fromDivPixelToLatLng(blPix);bounds.extend(ne);bounds.extend(sw);return bounds};MarkerClusterer.prototype.isMarkerInBounds_=function(marker,bounds){return bounds.contains(marker.getPosition())};MarkerClusterer.prototype.clearMarkers=function(){this.resetViewport(true);this.markers_=[]};MarkerClusterer.prototype.resetViewport=function(opt_hide){for(var i=0,cluster;cluster=this.clusters_[i];i++){cluster.remove()}for(var i=0,marker;marker=this.markers_[i];i++){marker.isAdded=false;if(opt_hide){marker.setMap(null)}}this.clusters_=[]};MarkerClusterer.prototype.repaint=function(){var oldClusters=this.clusters_.slice();this.clusters_.length=0;this.resetViewport();this.redraw();window.setTimeout(function(){for(var i=0,cluster;cluster=oldClusters[i];i++){cluster.remove()}},0)};MarkerClusterer.prototype.redraw=function(){this.createClusters_()};MarkerClusterer.prototype.distanceBetweenPoints_=function(p1,p2){if(!p1||!p2){return 0}var R=6371;var dLat=(p2.lat()-p1.lat())*Math.PI/180;var dLon=(p2.lng()-p1.lng())*Math.PI/180;var a=Math.sin(dLat/2)*Math.sin(dLat/2)+Math.cos(p1.lat()*Math.PI/180)*Math.cos(p2.lat()*Math.PI/180)*Math.sin(dLon/2)*Math.sin(dLon/2);var c=2*Math.atan2(Math.sqrt(a),Math.sqrt(1-a));var d=R*c;return d};MarkerClusterer.prototype.addToClosestCluster_=function(marker){var distance=4e4;var clusterToAddTo=null;var pos=marker.getPosition();for(var i=0,cluster;cluster=this.clusters_[i];i++){var center=cluster.getCenter();if(center){var d=this.distanceBetweenPoints_(center,marker.getPosition());if(d=this.minClusterSize_){marker.setMap(null)}this.updateIcon();return true};Cluster.prototype.getMarkerClusterer=function(){return this.markerClusterer_};Cluster.prototype.getBounds=function(){var bounds=new google.maps.LatLngBounds(this.center_,this.center_);var markers=this.getMarkers();for(var i=0,marker;marker=markers[i];i++){bounds.extend(marker.getPosition())}return bounds};Cluster.prototype.remove=function(){this.clusterIcon_.remove();this.markers_.length=0;delete this.markers_};Cluster.prototype.getSize=function(){return this.markers_.length};Cluster.prototype.getMarkers=function(){return this.markers_};Cluster.prototype.getCenter=function(){return this.center_};Cluster.prototype.calculateBounds_=function(){var bounds=new google.maps.LatLngBounds(this.center_,this.center_);this.bounds_=this.markerClusterer_.getExtendedBounds(bounds)};Cluster.prototype.isMarkerInClusterBounds=function(marker){return this.bounds_.contains(marker.getPosition())};Cluster.prototype.getMap=function(){return this.map_};Cluster.prototype.updateIcon=function(){var zoom=this.map_.getZoom();var mz=this.markerClusterer_.getMaxZoom();if(mz&&zoom>mz){for(var i=0,marker;marker=this.markers_[i];i++){marker.setMap(this.map_)}return}if(this.markers_.length0&&this.anchor_[0]0&&this.anchor_[1] .pickup_search_here",function(){pickup_sites.search_lat=pickup_sites.mapa.center.lat();pickup_sites.search_lng=pickup_sites.mapa.center.lng();pickup_sites.ajaxGetPickup(true)});var mymap;var isLoaded=false;var isWaitingEnd=false;var leafletGetPickups=function(lat,long,current_zoom){if(current_zoom>=15){radius=1}else if(current_zoom==14){radius=2}else if(current_zoom==13){radius=4}else if(current_zoom==12){radius=7}else if(current_zoom==11){radius=10}else if(current_zoom==10){radius=15}else{radius=20}if(current_zoom){var options={courierId:pickup_sites.courierId,"location[latitude]":lat,"location[longitude]":long,radius:radius,isCod:pickup_sites.isCod}}else{var options={courierId:pickup_sites.courierId,"location[latitude]":lat,"location[longitude]":long,isCod:pickup_sites.isCod}}$.ajax({type:"GET",url:"/ajax/getPickups.php",data:options,dataType:"json",success:function(json){if(!jQuery.isEmptyObject(selected_pickup_point)){for(i in json.pickupPoints){if(json.pickupPoints[i].id==selected_pickup_point.id){delete json.pickupPoints[i]}}json.pickupPoints.unshift(selected_pickup_point);console.log("pickupPoints unshift")}if(!json.pickupPoints.length){if($("div.asideContainer_pickup .menu_messages_message").length)$("div.asideContainer_pickup .menu_messages_message").remove();if(radius){if($("div.asideContainer_pickup .menu_messages_message").length)$("div.asideContainer_pickup .menu_messages_message").remove();$("div.asideContainer_pickup").prepend('")}else{$("div.asideContainer_pickup").prepend('")}$(".loadingMap").hide();return false}leafletItems=[];for(i in json.pickupPoints){var pickupLat=json.pickupPoints[i].coordinates.latitude;var pickupLon=json.pickupPoints[i].coordinates.longitude;if(pickupLat==""||pickupLon==""){$.ajaxSetup({async:false});$.get(location.protocol+"//nominatim.openstreetmap.org/search?format=json&q="+json.pickupPoints[i].address.street+", "+json.pickupPoints[i].address.city+" "+json.pickupPoints[i].address.city+" "+json.pickupPoints[i].address.country,function(data){if(!jQuery.isEmptyObject(data)){pickupLat=data[0].lat;pickupLon=data[0].lon}else{console.log("nie mogę znaleźć korodynatów adresu!")}})}leafletItems.push({id:json.pickupPoints[i].id,name:json.pickupPoints[i].name,link:json.pickupPoints[i].link,address:json.pickupPoints[i].address,lat:pickupLat,lon:pickupLon})}setPickupPointsNoMap(json,false,true);if(!jQuery.isEmptyObject(leafletItems)){leafletStartMap(leafletItems[0].lat,leafletItems[0].lon,true)}},error:function(){if($("div.asideContainer_pickup .menu_messages_message").length)$("div.asideContainer_pickup .menu_messages_message").remove();$("div.asideContainer_pickup").prepend('");$(".asideContainer_pickup label.pickup_point").each(function(){var aId=$(this).data("id");var aName=$(this).find(".headerText").text();var aLink=$(this).find(".map_dir").attr("href");var aAddress=$(this).find(".streetText").text()+"
"+$(this).find(".zipcodePickup").text();var aLat=$(this).data("latitude");var aLon=$(this).data("longitude");leafletItems.push({id:aId,name:aName,link:aLink,address:aAddress,lat:aLat,lon:aLon})});if(leafletItems[0].lat&&leafletItems[0].lon)leafletStartMap(leafletItems[0].lat,leafletItems[0].lon,true)}})};var leafletMarker=new Array;var leafletItems=[];function leafletDelMarkers(){for(i=0;iOpenStreetMap contributors'}).addTo(mymap);isLoaded=true;isWaitingEnd=true}$(".loadingPoints").remove();for(i=0;i`+stocks_list_more_txt+``+stocks_list_choose+``;let addressTxt="";if(leafletItems[i].address.street!=undefined){addressTxt=`
`+leafletItems[i].address.street+` `+leafletItems[i].address.buildingAndHouseNumber+` `+leafletItems[i].address.city+`
`}else{addressTxt=`
`+leafletItems[i].address+`
`}let button_text=``+leafletItems[i].name+`
`+addressTxt+`
`+href;markersList.push(leafletItems[i].id);markers[leafletItems[i].id]=L.marker([leafletItems[i].lat,leafletItems[i].lon],{icon:newMarkerIcon}).addTo(mymap).on("click",leafletOnClick).bindPopup(button_text)}mymap.setView(new L.LatLng(lat,long));let pointId=$(".asideContainer_pickup label.pickup_point").eq(0).attr("data-id");$('.asideContainer_pickup input[value="'+pointId+'"]').click();$("img.leaflet-marker-icon").each(function(){var href=$(this).attr("src");var href_prev=href.includes("preview/");if(href_prev)href=href.replace("preview/","");var href_2x=href.includes("marker-icon");if(href_2x)href=href.replace("-2x","");$(this).attr("src",href)})};var timeoutLeafLet=null;$(document).on("input","#autocomplete_location.autocomplete_nomap",function(){var that=$(this);clearTimeout(timeoutLeafLet);timeoutLeafLet=setTimeout(function(){if(that.val().length>3){leafletGetLocation(that.val())}},500)});$(document).off("click.suggestions").on("click.suggestions",".leafleat-suggestions div",function(){$("#autocomplete_location").val($(this).text());$(".leafleat-suggestions").remove();const lat=$(this).attr("data-lat");const lon=$(this).attr("data-lon");leafletDelMarkers();selected_pickup_point={};leafletGetPickups(lat,lon)});$(document).on("click",".map_button_search > .pickup_search_here_leaflet",function(){var cords=mymap.getCenter();var zoom=mymap.getZoom();leafletDelMarkers();selected_pickup_point={};leafletGetPickups(cords.lat,cords.lng,zoom)});$(document).on("click",'#pickup_site [name="pickup_point"], #pickup_site [name="stock"]',function(){const id=$(this).val();if(markers[id]){let thatMarkerCoords=markers[id].getLatLng();mymap.setView(new L.LatLng(thatMarkerCoords.lat,thatMarkerCoords.lng));markers[id].openPopup()}});var leafletGetCoords=function(address){let mymapLat="",mymapLong="";if(address){$.get(location.protocol+"//nominatim.openstreetmap.org/search?format=json&q="+address,function(data){if(!jQuery.isEmptyObject(data)){mymapLat=data[0].lat;mymapLong=data[0].lon;leafletGetPickups(mymapLat,mymapLong)}else{if($(".asideContainer_pickup label.pickup_point").length){$(".asideContainer_pickup label.pickup_point").each(function(){var aId=$(this).data("id");var aName=$(this).find(".headerText").text();var aLink=$(this).find(".map_dir").attr("href");var aAddress=$(this).find(".streetText").text()+"
"+$(this).find(".zipcodePickup").text();var aLat=$(this).data("latitude");var aLon=$(this).data("longitude");leafletItems.push({id:aId,name:aName,link:aLink,address:aAddress,lat:aLat,lon:aLon})});leafletStartMap(leafletItems[0].lat,leafletItems[0].lon,true)}if($("div.asideContainer_pickup .menu_messages_message").length)$("div.asideContainer_pickup .menu_messages_message").remove();$("div.asideContainer_pickup").prepend('")}})}else{if($(".asideContainer_pickup label.pickup_point").length){$(".asideContainer_pickup label.pickup_point").each(function(){var aId=$(this).data("id");var aName=$(this).find(".headerText").text();var aLink=$(this).find(".map_dir").attr("href");var aAddress=$(this).find(".streetText").text()+"
"+$(this).find(".zipcodePickup").text();var aLat=$(this).data("latitude");var aLon=$(this).data("longitude");leafletItems.push({id:aId,name:aName,link:aLink,address:aAddress,lat:aLat,lon:aLon})});leafletStartMap(leafletItems[0].lat,leafletItems[0].lon,true)}}};var leafletGetLocation=function(address){$.get(location.protocol+"//nominatim.openstreetmap.org/search?format=json&q="+address,function(data){if(!jQuery.isEmptyObject(data)){$("#locationField").append('
');for(i in data){$(".leafleat-suggestions").append('
'+data[i].display_name+"
")}}else{leafletStartMap(53.428,14.552,true);if($("div.asideContainer_pickup .menu_messages_message").length)$("div.asideContainer_pickup .menu_messages_message").remove();$("div.asideContainer_pickup").prepend('")}})};var leafletGetTextLocation=function(){$("#mymap").prepend(`
${}...
`);var text=$("#autocomplete_location").val();selected_pickup_point={};$.get(location.protocol+"//nominatim.openstreetmap.org/search?format=json&q="+text,function(data){if(!jQuery.isEmptyObject(data)){leafletDelMarkers();leafletGetPickups(data[0].lat,data[0].lon);$("#autocomplete_location").val(data[0].display_name)}else{if(text.search(",")){var srp=text.split(",");var new_address=srp[srp.length-1].trim();leafletGetCoords(new_address)}if($("div.asideContainer_pickup .menu_messages_message").length)$("div.asideContainer_pickup .menu_messages_message").remove();$("div.asideContainer_pickup").prepend('")}})};app_shop.run(function(){if($("#autocomplete_location").length&&$("#autocomplete_location").val()!=""){let leafletAddress=$("#autocomplete_location").val();leafletGetCoords(leafletAddress)}else{leafletGetCoords(false)}},"all","#mymap");app_shop.run(function(){$("#mymap").before($(".map_button_search"))},1,"#mymap");app_shop.run(function(){$("#mymap").prepend($(".map_button_search"))},[2,3,4],"#mymap");!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i(t.L={})}(this,function(t){"use strict";var i=Object.freeze;function h(t){var i,e,n,o;for(e=1,n=arguments.length;e=this.min.x&&e.x<=this.max.x&&i.y>=this.min.y&&e.y<=this.max.y},intersects:function(t){t=R(t);var i=this.min,e=this.max,n=t.min,o=t.max,s=o.x>=i.x&&n.x<=e.x,r=o.y>=i.y&&n.y<=e.y;return s&&r},overlaps:function(t){t=R(t);var i=this.min,e=this.max,n=t.min,o=t.max,s=o.x>i.x&&n.xi.y&&n.y=n.lat&&e.lat<=o.lat&&i.lng>=n.lng&&e.lng<=o.lng},intersects:function(t){t=D(t);var i=this._southWest,e=this._northEast,n=t.getSouthWest(),o=t.getNorthEast(),s=o.lat>=i.lat&&n.lat<=e.lat,r=o.lng>=i.lng&&n.lng<=e.lng;return s&&r},overlaps:function(t){t=D(t);var i=this._southWest,e=this._northEast,n=t.getSouthWest(),o=t.getNorthEast(),s=o.lat>i.lat&&n.lati.lng&&n.lng';var i=t.firstChild;return i.style.behavior="url(#default#VML)",i&&"object"==typeof i.adj}catch(t){return!1}}();function Bt(t){return 0<=navigator.userAgent.toLowerCase().indexOf(t)}var At=(Object.freeze||Object)({ie:it,ielt9:et,edge:nt,webkit:ot,android:st,android23:rt,androidStock:ht,opera:ut,chrome:lt,gecko:ct,safari:_t,phantom:dt,opera12:pt,win:mt,ie3d:ft,webkit3d:gt,gecko3d:vt,any3d:yt,mobile:xt,mobileWebkit:wt,mobileWebkit3d:Pt,msPointer:Lt,pointer:bt,touch:Tt,mobileOpera:zt,mobileGecko:Mt,retina:Ct,passiveEvents:Et,canvas:St,svg:Zt,vml:kt}),It=Lt?"MSPointerDown":"pointerdown",Ot=Lt?"MSPointerMove":"pointermove",Rt=Lt?"MSPointerUp":"pointerup",Nt=Lt?"MSPointerCancel":"pointercancel",Dt=["INPUT","SELECT","OPTION"],jt={},Wt=!1,Ht=0;function Ft(t,i,e,n){return"touchstart"===i?function(t,i,e){var n=a(function(t){if("mouse"!==t.pointerType&&t.MSPOINTER_TYPE_MOUSE&&t.pointerType!==t.MSPOINTER_TYPE_MOUSE){if(!(Dt.indexOf(t.target.tagName)<0))return;ji(t)}Gt(t,i)});t["_leaflet_touchstart"+e]=n,t.addEventListener(It,n,!1),Wt||(document.documentElement.addEventListener(It,Ut,!0),document.documentElement.addEventListener(Ot,Vt,!0),document.documentElement.addEventListener(Rt,qt,!0),document.documentElement.addEventListener(Nt,qt,!0),Wt=!0)}(t,e,n):"touchmove"===i?function(t,i,e){function n(t){(t.pointerType!==t.MSPOINTER_TYPE_MOUSE&&"mouse"!==t.pointerType||0!==t.buttons)&&Gt(t,i)}t["_leaflet_touchmove"+e]=n,t.addEventListener(Ot,n,!1)}(t,e,n):"touchend"===i&&function(t,i,e){function n(t){Gt(t,i)}t["_leaflet_touchend"+e]=n,t.addEventListener(Rt,n,!1),t.addEventListener(Nt,n,!1)}(t,e,n),this}function Ut(t){jt[t.pointerId]=t,Ht++}function Vt(t){jt[t.pointerId]&&(jt[t.pointerId]=t)}function qt(t){delete jt[t.pointerId],Ht--}function Gt(t,i){for(var e in t.touches=[],jt)t.touches.push(jt[e]);t.changedTouches=[t],i(t)}var Kt=Lt?"MSPointerDown":bt?"pointerdown":"touchstart",Yt=Lt?"MSPointerUp":bt?"pointerup":"touchend",Xt="_leaflet_";function Jt(t,o,i){var s,r,a=!1;function e(t){var i;if(bt){if(!nt||"mouse"===t.pointerType)return;i=Ht}else i=t.touches.length;if(!(1this.options.maxZoom)?this.setZoom(t):this},panInsideBounds:function(t,i){this._enforcingBounds=!0;var e=this.getCenter(),n=this._limitCenter(e,this._zoom,D(t));return e.equals(n)||this.panTo(n,i),this._enforcingBounds=!1,this},panInside:function(t,i){var e=I((i=i||{}).paddingTopLeft||i.padding||[0,0]),n=I(i.paddingBottomRight||i.padding||[0,0]),o=this.getCenter(),s=this.project(o),r=this.project(t),a=this.getPixelBounds(),h=a.getSize().divideBy(2),u=R([a.min.add(e),a.max.subtract(n)]);if(!u.contains(r)){this._enforcingBounds=!0;var l=s.subtract(r),c=I(r.x+l.x,r.y+l.y);(r.xu.max.x)&&(c.x=s.x-l.x,0u.max.y)&&(c.y=s.y-l.y,0=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(t,i){for(var e,n=[],o="mouseout"===i||"mouseover"===i,s=t.target||t.srcElement,r=!1;s;){if((e=this._targets[u(s)])&&("click"===i||"preclick"===i)&&!t._simulated&&this._draggableMoved(e)){r=!0;break}if(e&&e.listens(i,!0)){if(o&&!Yi(s,t))break;if(n.push(e),o)break}if(s===this._container)break;s=s.parentNode}return n.length||r||o||!Yi(s,t)||(n=[this]),n},_handleDOMEvent:function(t){if(this._loaded&&!Ki(t)){var i=t.type;"mousedown"!==i&&"keypress"!==i&&"keyup"!==i&&"keydown"!==i||Mi(t.target||t.srcElement),this._fireDOMEvent(t,i)}},_mouseEvents:["click","dblclick","mouseover","mouseout","contextmenu"],_fireDOMEvent:function(t,i,e){if("click"===t.type){var n=h({},t);n.type="preclick",this._fireDOMEvent(n,n.type,e)}if(!t._stopped&&(e=(e||[]).concat(this._findEventTargets(t,i))).length){var o=e[0];"contextmenu"===i&&o.listens(i,!0)&&ji(t);var s={originalEvent:t};if("keypress"!==t.type&&"keydown"!==t.type&&"keyup"!==t.type){var r=o.getLatLng&&(!o._radius||o._radius<=10);s.containerPoint=r?this.latLngToContainerPoint(o.getLatLng()):this.mouseEventToContainerPoint(t),s.layerPoint=this.containerPointToLayerPoint(s.containerPoint),s.latlng=r?o.getLatLng():this.layerPointToLatLng(s.layerPoint)}for(var a=0;athis.options.zoomAnimationThreshold)return!1;var n=this.getZoomScale(i),o=this._getCenterOffset(t)._divideBy(1-1/n);return!(!0!==e.animate&&!this.getSize().contains(o))&&(M(function(){this._moveStart(!0,!1)._animateZoom(t,i,!0)},this),!0)},_animateZoom:function(t,i,e,n){this._mapPane&&(e&&(this._animatingZoom=!0,this._animateToCenter=t,this._animateToZoom=i,mi(this._mapPane,"leaflet-zoom-anim")),this.fire("zoomanim",{center:t,zoom:i,noUpdate:n}),setTimeout(a(this._onZoomTransitionEnd,this),250))},_onZoomTransitionEnd:function(){this._animatingZoom&&(this._mapPane&&fi(this._mapPane,"leaflet-zoom-anim"),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom),M(function(){this._moveEnd(!0)},this))}});function Qi(t){return new te(t)}var te=S.extend({options:{position:"topright"},initialize:function(t){p(this,t)},getPosition:function(){return this.options.position},setPosition:function(t){var i=this._map;return i&&i.removeControl(this),this.options.position=t,i&&i.addControl(this),this},getContainer:function(){return this._container},addTo:function(t){this.remove(),this._map=t;var i=this._container=this.onAdd(t),e=this.getPosition(),n=t._controlCorners[e];return mi(i,"leaflet-control"),-1!==e.indexOf("bottom")?n.insertBefore(i,n.firstChild):n.appendChild(i),this._map.on("unload",this.remove,this),this},remove:function(){return this._map&&(li(this._container),this.onRemove&&this.onRemove(this._map),this._map.off("unload",this.remove,this),this._map=null),this},_refocusOnMap:function(t){this._map&&t&&0",n=document.createElement("div");return n.innerHTML=e,n.firstChild},_addItem:function(t){var i,e=document.createElement("label"),n=this._map.hasLayer(t.layer);t.overlay?((i=document.createElement("input")).type="checkbox",i.className="leaflet-control-layers-selector",i.defaultChecked=n):i=this._createRadioElement("leaflet-base-layers_"+u(this),n),this._layerControlInputs.push(i),i.layerId=u(t.layer),ki(i,"click",this._onInputClick,this);var o=document.createElement("span");o.innerHTML=" "+t.name;var s=document.createElement("div");return e.appendChild(s),s.appendChild(i),s.appendChild(o),(t.overlay?this._overlaysList:this._baseLayersList).appendChild(e),this._checkDisabledLayers(),e},_onInputClick:function(){var t,i,e=this._layerControlInputs,n=[],o=[];this._handlingClick=!0;for(var s=e.length-1;0<=s;s--)t=e[s],i=this._getLayer(t.layerId).layer,t.checked?n.push(i):t.checked||o.push(i);for(s=0;si.options.maxZoom},_expandIfNotCollapsed:function(){return this._map&&!this.options.collapsed&&this.expand(),this},_expand:function(){return this.expand()},_collapse:function(){return this.collapse()}}),ee=te.extend({options:{position:"topleft",zoomInText:"+",zoomInTitle:"Zoom in",zoomOutText:"−",zoomOutTitle:"Zoom out"},onAdd:function(t){var i="leaflet-control-zoom",e=ui("div",i+" leaflet-bar"),n=this.options;return this._zoomInButton=this._createButton(n.zoomInText,n.zoomInTitle,i+"-in",e,this._zoomIn),this._zoomOutButton=this._createButton(n.zoomOutText,n.zoomOutTitle,i+"-out",e,this._zoomOut),this._updateDisabled(),t.on("zoomend zoomlevelschange",this._updateDisabled,this),e},onRemove:function(t){t.off("zoomend zoomlevelschange",this._updateDisabled,this)},disable:function(){return this._disabled=!0,this._updateDisabled(),this},enable:function(){return this._disabled=!1,this._updateDisabled(),this},_zoomIn:function(t){!this._disabled&&this._map._zoomthis._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(t.shiftKey?3:1))},_createButton:function(t,i,e,n,o){var s=ui("a",e,n);return s.innerHTML=t,s.href="#",s.title=i,s.setAttribute("role","button"),s.setAttribute("aria-label",i),Di(s),ki(s,"click",Wi),ki(s,"click",o,this),ki(s,"click",this._refocusOnMap,this),s},_updateDisabled:function(){var t=this._map,i="leaflet-disabled";fi(this._zoomInButton,i),fi(this._zoomOutButton,i),!this._disabled&&t._zoom!==t.getMinZoom()||mi(this._zoomOutButton,i),!this._disabled&&t._zoom!==t.getMaxZoom()||mi(this._zoomInButton,i)}});$i.mergeOptions({zoomControl:!0}),$i.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new ee,this.addControl(this.zoomControl))});var ne=te.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0},onAdd:function(t){var i="leaflet-control-scale",e=ui("div",i),n=this.options;return this._addScales(n,i+"-line",e),t.on(n.updateWhenIdle?"moveend":"move",this._update,this),t.whenReady(this._update,this),e},onRemove:function(t){t.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(t,i,e){t.metric&&(this._mScale=ui("div",i,e)),t.imperial&&(this._iScale=ui("div",i,e))},_update:function(){var t=this._map,i=t.getSize().y/2,e=t.distance(t.containerPointToLatLng([0,i]),t.containerPointToLatLng([this.options.maxWidth,i]));this._updateScales(e)},_updateScales:function(t){this.options.metric&&t&&this._updateMetric(t),this.options.imperial&&t&&this._updateImperial(t)},_updateMetric:function(t){var i=this._getRoundNum(t),e=i<1e3?i+" m":i/1e3+" km";this._updateScale(this._mScale,e,i/t)},_updateImperial:function(t){var i,e,n,o=3.2808399*t;5280Leaflet'},initialize:function(t){p(this,t),this._attributions={}},onAdd:function(t){for(var i in(t.attributionControl=this)._container=ui("div","leaflet-control-attribution"),Di(this._container),t._layers)t._layers[i].getAttribution&&this.addAttribution(t._layers[i].getAttribution());return this._update(),this._container},setPrefix:function(t){return this.options.prefix=t,this._update(),this},addAttribution:function(t){return t&&(this._attributions[t]||(this._attributions[t]=0),this._attributions[t]++,this._update()),this},removeAttribution:function(t){return t&&this._attributions[t]&&(this._attributions[t]--,this._update()),this},_update:function(){if(this._map){var t=[];for(var i in this._attributions)this._attributions[i]&&t.push(i);var e=[];this.options.prefix&&e.push(this.options.prefix),t.length&&e.push(t.join(", ")),this._container.innerHTML=e.join(" | ")}}});$i.mergeOptions({attributionControl:!0}),$i.addInitHook(function(){this.options.attributionControl&&(new oe).addTo(this)});te.Layers=ie,te.Zoom=ee,te.Scale=ne,te.Attribution=oe,Qi.layers=function(t,i,e){return new ie(t,i,e)},Qi.zoom=function(t){return new ee(t)},Qi.scale=function(t){return new ne(t)},Qi.attribution=function(t){return new oe(t)};var se=S.extend({initialize:function(t){this._map=t},enable:function(){return this._enabled||(this._enabled=!0,this.addHooks()),this},disable:function(){return this._enabled&&(this._enabled=!1,this.removeHooks()),this},enabled:function(){return!!this._enabled}});se.addTo=function(t,i){return t.addHandler(i,this),this};var re,ae={Events:Z},he=Tt?"touchstart mousedown":"mousedown",ue={mousedown:"mouseup",touchstart:"touchend",pointerdown:"touchend",MSPointerDown:"touchend"},le={mousedown:"mousemove",touchstart:"touchmove",pointerdown:"touchmove",MSPointerDown:"touchmove"},ce=k.extend({options:{clickTolerance:3},initialize:function(t,i,e,n){p(this,n),this._element=t,this._dragStartTarget=i||t,this._preventOutline=e},enable:function(){this._enabled||(ki(this._dragStartTarget,he,this._onDown,this),this._enabled=!0)},disable:function(){this._enabled&&(ce._dragging===this&&this.finishDrag(),Ai(this._dragStartTarget,he,this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(t){if(!t._simulated&&this._enabled&&(this._moved=!1,!pi(this._element,"leaflet-zoom-anim")&&!(ce._dragging||t.shiftKey||1!==t.which&&1!==t.button&&!t.touches||((ce._dragging=this)._preventOutline&&Mi(this._element),Ti(),Qt(),this._moving)))){this.fire("down");var i=t.touches?t.touches[0]:t,e=Ei(this._element);this._startPoint=new B(i.clientX,i.clientY),this._parentScale=Si(e),ki(document,le[t.type],this._onMove,this),ki(document,ue[t.type],this._onUp,this)}},_onMove:function(t){if(!t._simulated&&this._enabled)if(t.touches&&1i.max.x&&(e|=2),t.yi.max.y&&(e|=8),e}function ge(t,i,e,n){var o,s=i.x,r=i.y,a=e.x-s,h=e.y-r,u=a*a+h*h;return 0this._layersMaxZoom&&this.setZoom(this._layersMaxZoom),void 0===this.options.minZoom&&this._layersMinZoom&&this.getZoom()t.y!=n.y>t.y&&t.x<(n.x-e.x)*(t.y-e.y)/(n.y-e.y)+e.x&&(u=!u);return u||je.prototype._containsPoint.call(this,t,!0)}});var He=ke.extend({initialize:function(t,i){p(this,i),this._layers={},t&&this.addData(t)},addData:function(t){var i,e,n,o=v(t)?t:t.features;if(o){for(i=0,e=o.length;iu.x&&(l=s.x+n-u.x+h.x),s.x-l-a.x<0&&(l=s.x-a.x),s.y+e+h.y>u.y&&(c=s.y+e-u.y+h.y),s.y-c-a.y<0&&(c=s.y-a.y),(l||c)&&t.fire("autopanstart").panBy([l,c])}},_onCloseButtonClick:function(t){this._close(),Wi(t)},_getAnchor:function(){return I(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}});$i.mergeOptions({closePopupOnClick:!0}),$i.include({openPopup:function(t,i,e){return t instanceof sn||(t=new sn(e).setContent(t)),i&&t.setLatLng(i),this.hasLayer(t)?this:(this._popup&&this._popup.options.autoClose&&this.closePopup(),this._popup=t,this.addLayer(t))},closePopup:function(t){return t&&t!==this._popup||(t=this._popup,this._popup=null),t&&this.removeLayer(t),this}}),Se.include({bindPopup:function(t,i){return t instanceof sn?(p(t,i),(this._popup=t)._source=this):(this._popup&&!i||(this._popup=new sn(i,this)),this._popup.setContent(t)),this._popupHandlersAdded||(this.on({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!0),this},unbindPopup:function(){return this._popup&&(this.off({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,this._popup=null),this},openPopup:function(t,i){return this._popup&&this._map&&(i=this._popup._prepareOpen(this,t,i),this._map.openPopup(this._popup,i)),this},closePopup:function(){return this._popup&&this._popup._close(),this},togglePopup:function(t){return this._popup&&(this._popup._map?this.closePopup():this.openPopup(t)),this},isPopupOpen:function(){return!!this._popup&&this._popup.isOpen()},setPopupContent:function(t){return this._popup&&this._popup.setContent(t),this},getPopup:function(){return this._popup},_openPopup:function(t){var i=t.layer||t.target;this._popup&&this._map&&(Wi(t),i instanceof Re?this.openPopup(t.layer||t.target,t.latlng):this._map.hasLayer(this._popup)&&this._popup._source===i?this.closePopup():this.openPopup(i,t.latlng))},_movePopup:function(t){this._popup.setLatLng(t.latlng)},_onKeyPress:function(t){13===t.originalEvent.keyCode&&this._openPopup(t)}});var rn=on.extend({options:{pane:"tooltipPane",offset:[0,0],direction:"auto",permanent:!1,sticky:!1,interactive:!1,opacity:.9},onAdd:function(t){on.prototype.onAdd.call(this,t),this.setOpacity(this.options.opacity),t.fire("tooltipopen",{tooltip:this}),this._source&&this._source.fire("tooltipopen",{tooltip:this},!0)},onRemove:function(t){on.prototype.onRemove.call(this,t),t.fire("tooltipclose",{tooltip:this}),this._source&&this._source.fire("tooltipclose",{tooltip:this},!0)},getEvents:function(){var t=on.prototype.getEvents.call(this);return Tt&&!this.options.permanent&&(t.preclick=this._close),t},_close:function(){this._map&&this._map.closeTooltip(this)},_initLayout:function(){var t="leaflet-tooltip "+(this.options.className||"")+" leaflet-zoom-"+(this._zoomAnimated?"animated":"hide");this._contentNode=this._container=ui("div",t)},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(t){var i=this._map,e=this._container,n=i.latLngToContainerPoint(i.getCenter()),o=i.layerPointToContainerPoint(t),s=this.options.direction,r=e.offsetWidth,a=e.offsetHeight,h=I(this.options.offset),u=this._getAnchor();t="top"===s?t.add(I(-r/2+h.x,-a+h.y+u.y,!0)):"bottom"===s?t.subtract(I(r/2-h.x,-h.y,!0)):"center"===s?t.subtract(I(r/2+h.x,a/2-u.y+h.y,!0)):"right"===s||"auto"===s&&o.xthis.options.maxZoom||ethis.options.maxZoom||void 0!==this.options.minZoom&&oe.max.x)||!i.wrapLat&&(t.ye.max.y))return!1}if(!this.options.bounds)return!0;var n=this._tileCoordsToBounds(t);return D(this.options.bounds).overlaps(n)},_keyToBounds:function(t){return this._tileCoordsToBounds(this._keyToTileCoords(t))},_tileCoordsToNwSe:function(t){var i=this._map,e=this.getTileSize(),n=t.scaleBy(e),o=n.add(e);return[i.unproject(n,t.z),i.unproject(o,t.z)]},_tileCoordsToBounds:function(t){var i=this._tileCoordsToNwSe(t),e=new N(i[0],i[1]);return this.options.noWrap||(e=this._map.wrapLatLngBounds(e)),e},_tileCoordsToKey:function(t){return t.x+":"+t.y+":"+t.z},_keyToTileCoords:function(t){var i=t.split(":"),e=new B(+i[0],+i[1]);return e.z=+i[2],e},_removeTile:function(t){var i=this._tiles[t];i&&(li(i.el),delete this._tiles[t],this.fire("tileunload",{tile:i.el,coords:this._keyToTileCoords(t)}))},_initTile:function(t){mi(t,"leaflet-tile");var i=this.getTileSize();t.style.width=i.x+"px",t.style.height=i.y+"px",t.onselectstart=l,t.onmousemove=l,et&&this.options.opacity<1&&yi(t,this.options.opacity),st&&!rt&&(t.style.WebkitBackfaceVisibility="hidden")},_addTile:function(t,i){var e=this._getTilePos(t),n=this._tileCoordsToKey(t),o=this.createTile(this._wrapCoords(t),a(this._tileReady,this,t));this._initTile(o),this.createTile.length<2&&M(a(this._tileReady,this,t,null,o)),Pi(o,e),this._tiles[n]={el:o,coords:t,current:!0},i.appendChild(o),this.fire("tileloadstart",{tile:o,coords:t})},_tileReady:function(t,i,e){i&&this.fire("tileerror",{error:i,tile:e,coords:t});var n=this._tileCoordsToKey(t);(e=this._tiles[n])&&(e.loaded=+new Date,this._map._fadeAnimated?(yi(e.el,0),C(this._fadeFrame),this._fadeFrame=M(this._updateOpacity,this)):(e.active=!0,this._pruneTiles()),i||(mi(e.el,"leaflet-tile-loaded"),this.fire("tileload",{tile:e.el,coords:t})),this._noTilesToLoad()&&(this._loading=!1,this.fire("load"),et||!this._map._fadeAnimated?M(this._pruneTiles,this):setTimeout(a(this._pruneTiles,this),250)))},_getTilePos:function(t){return t.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(t){var i=new B(this._wrapX?r(t.x,this._wrapX):t.x,this._wrapY?r(t.y,this._wrapY):t.y);return i.z=t.z,i},_pxBoundsToTileRange:function(t){var i=this.getTileSize();return new O(t.min.unscaleBy(i).floor(),t.max.unscaleBy(i).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var t in this._tiles)if(!this._tiles[t].loaded)return!1;return!0}});var un=hn.extend({options:{minZoom:0,maxZoom:18,subdomains:"abc",errorTileUrl:"",zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1},initialize:function(t,i){this._url=t,(i=p(this,i)).detectRetina&&Ct&&0')}}catch(t){return function(t){return document.createElement("<"+t+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}}(),fn={_initContainer:function(){this._container=ui("div","leaflet-vml-container")},_update:function(){this._map._animatingZoom||(_n.prototype._update.call(this),this.fire("update"))},_initPath:function(t){var i=t._container=mn("shape");mi(i,"leaflet-vml-shape "+(this.options.className||"")),i.coordsize="1 1",t._path=mn("path"),i.appendChild(t._path),this._updateStyle(t),this._layers[u(t)]=t},_addPath:function(t){var i=t._container;this._container.appendChild(i),t.options.interactive&&t.addInteractiveTarget(i)},_removePath:function(t){var i=t._container;li(i),t.removeInteractiveTarget(i),delete this._layers[u(t)]},_updateStyle:function(t){var i=t._stroke,e=t._fill,n=t.options,o=t._container;o.stroked=!!n.stroke,o.filled=!!n.fill,n.stroke?(i||(i=t._stroke=mn("stroke")),o.appendChild(i),i.weight=n.weight+"px",i.color=n.color,i.opacity=n.opacity,n.dashArray?i.dashStyle=v(n.dashArray)?n.dashArray.join(" "):n.dashArray.replace(/( *, *)/g," "):i.dashStyle="",i.endcap=n.lineCap.replace("butt","flat"),i.joinstyle=n.lineJoin):i&&(o.removeChild(i),t._stroke=null),n.fill?(e||(e=t._fill=mn("fill")),o.appendChild(e),e.color=n.fillColor||n.color,e.opacity=n.fillOpacity):e&&(o.removeChild(e),t._fill=null)},_updateCircle:function(t){var i=t._point.round(),e=Math.round(t._radius),n=Math.round(t._radiusY||e);this._setPath(t,t._empty()?"M0 0":"AL "+i.x+","+i.y+" "+e+","+n+" 0,23592600")},_setPath:function(t,i){t._path.v=i},_bringToFront:function(t){_i(t._container)},_bringToBack:function(t){di(t._container)}},gn=kt?mn:$,vn=_n.extend({getEvents:function(){var t=_n.prototype.getEvents.call(this);return t.zoomstart=this._onZoomStart,t},_initContainer:function(){this._container=gn("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=gn("g"),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){li(this._container),Ai(this._container),delete this._container,delete this._rootGroup,delete this._svgSize},_onZoomStart:function(){this._update()},_update:function(){if(!this._map._animatingZoom||!this._bounds){_n.prototype._update.call(this);var t=this._bounds,i=t.getSize(),e=this._container;this._svgSize&&this._svgSize.equals(i)||(this._svgSize=i,e.setAttribute("width",i.x),e.setAttribute("height",i.y)),Pi(e,t.min),e.setAttribute("viewBox",[t.min.x,t.min.y,i.x,i.y].join(" ")),this.fire("update")}},_initPath:function(t){var i=t._path=gn("path");t.options.className&&mi(i,t.options.className),t.options.interactive&&mi(i,"leaflet-interactive"),this._updateStyle(t),this._layers[u(t)]=t},_addPath:function(t){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(t._path),t.addInteractiveTarget(t._path)},_removePath:function(t){li(t._path),t.removeInteractiveTarget(t._path),delete this._layers[u(t)]},_updatePath:function(t){t._project(),t._update()},_updateStyle:function(t){var i=t._path,e=t.options;i&&(e.stroke?(i.setAttribute("stroke",e.color),i.setAttribute("stroke-opacity",e.opacity),i.setAttribute("stroke-width",e.weight),i.setAttribute("stroke-linecap",e.lineCap),i.setAttribute("stroke-linejoin",e.lineJoin),e.dashArray?i.setAttribute("stroke-dasharray",e.dashArray):i.removeAttribute("stroke-dasharray"),e.dashOffset?i.setAttribute("stroke-dashoffset",e.dashOffset):i.removeAttribute("stroke-dashoffset")):i.setAttribute("stroke","none"),e.fill?(i.setAttribute("fill",e.fillColor||e.color),i.setAttribute("fill-opacity",e.fillOpacity),i.setAttribute("fill-rule",e.fillRule||"evenodd")):i.setAttribute("fill","none"))},_updatePoly:function(t,i){this._setPath(t,Q(t._parts,i))},_updateCircle:function(t){var i=t._point,e=Math.max(Math.round(t._radius),1),n="a"+e+","+(Math.max(Math.round(t._radiusY),1)||e)+" 0 1,0 ",o=t._empty()?"M0 0":"M"+(i.x-e)+","+i.y+n+2*e+",0 "+n+2*-e+",0 ";this._setPath(t,o)},_setPath:function(t,i){t._path.setAttribute("d",i)},_bringToFront:function(t){_i(t._path)},_bringToBack:function(t){di(t._path)}});function yn(t){return Zt||kt?new vn(t):null}kt&&vn.include(fn),$i.include({getRenderer:function(t){var i=t.options.renderer||this._getPaneRenderer(t.options.pane)||this.options.renderer||this._renderer;return i||(i=this._renderer=this._createRenderer()),this.hasLayer(i)||this.addLayer(i),i},_getPaneRenderer:function(t){if("overlayPane"===t||void 0===t)return!1;var i=this._paneRenderers[t];return void 0===i&&(i=this._createRenderer({pane:t}),this._paneRenderers[t]=i),i},_createRenderer:function(t){return this.options.preferCanvas&&pn(t)||yn(t)}});var xn=We.extend({initialize:function(t,i){We.prototype.initialize.call(this,this._boundsToLatLngs(t),i)},setBounds:function(t){return this.setLatLngs(this._boundsToLatLngs(t))},_boundsToLatLngs:function(t){return[(t=D(t)).getSouthWest(),t.getNorthWest(),t.getNorthEast(),t.getSouthEast()]}});vn.create=gn,vn.pointsToPath=Q,He.geometryToLayer=Fe,He.coordsToLatLng=Ve,He.coordsToLatLngs=qe,He.latLngToCoords=Ge,He.latLngsToCoords=Ke,He.getFeature=Ye,He.asFeature=Xe,$i.mergeOptions({boxZoom:!0});var wn=se.extend({initialize:function(t){this._map=t,this._container=t._container,this._pane=t._panes.overlayPane,this._resetStateTimeout=0,t.on("unload",this._destroy,this)},addHooks:function(){ki(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){Ai(this._container,"mousedown",this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){li(this._pane),delete this._pane},_resetState:function(){this._resetStateTimeout=0,this._moved=!1},_clearDeferredResetState:function(){0!==this._resetStateTimeout&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)},_onMouseDown:function(t){if(!t.shiftKey||1!==t.which&&1!==t.button)return!1;this._clearDeferredResetState(),this._resetState(),Qt(),Ti(),this._startPoint=this._map.mouseEventToContainerPoint(t),ki(document,{contextmenu:Wi,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseMove:function(t){this._moved||(this._moved=!0,this._box=ui("div","leaflet-zoom-box",this._container),mi(this._container,"leaflet-crosshair"),this._map.fire("boxzoomstart")),this._point=this._map.mouseEventToContainerPoint(t);var i=new O(this._point,this._startPoint),e=i.getSize();Pi(this._box,i.min),this._box.style.width=e.x+"px",this._box.style.height=e.y+"px"},_finish:function(){this._moved&&(li(this._box),fi(this._container,"leaflet-crosshair")),ti(),zi(),Ai(document,{contextmenu:Wi,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(t){if((1===t.which||1===t.button)&&(this._finish(),this._moved)){this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(a(this._resetState,this),0);var i=new N(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(i).fire("boxzoomend",{boxZoomBounds:i})}},_onKeyDown:function(t){27===t.keyCode&&this._finish()}});$i.addInitHook("addHandler","boxZoom",wn),$i.mergeOptions({doubleClickZoom:!0});var Pn=se.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(t){var i=this._map,e=i.getZoom(),n=i.options.zoomDelta,o=t.originalEvent.shiftKey?e-n:e+n;"center"===i.options.doubleClickZoom?i.setZoom(o):i.setZoomAround(t.containerPoint,o)}});$i.addInitHook("addHandler","doubleClickZoom",Pn),$i.mergeOptions({dragging:!0,inertia:!rt,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0});var Ln=se.extend({addHooks:function(){if(!this._draggable){var t=this._map;this._draggable=new ce(t._mapPane,t._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),t.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDragWrap,this),t.on("zoomend",this._onZoomEnd,this),t.whenReady(this._onZoomEnd,this))}mi(this._map._container,"leaflet-grab leaflet-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){fi(this._map._container,"leaflet-grab"),fi(this._map._container,"leaflet-touch-drag"),this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},moving:function(){return this._draggable&&this._draggable._moving},_onDragStart:function(){var t=this._map;if(t._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity){var i=D(this._map.options.maxBounds);this._offsetLimit=R(this._map.latLngToContainerPoint(i.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(i.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))}else this._offsetLimit=null;t.fire("movestart").fire("dragstart"),t.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(t){if(this._map.options.inertia){var i=this._lastTime=+new Date,e=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(e),this._times.push(i),this._prunePositions(i)}this._map.fire("move",t).fire("drag",t)},_prunePositions:function(t){for(;1i.max.x&&(t.x=this._viscousLimit(t.x,i.max.x)),t.y>i.max.y&&(t.y=this._viscousLimit(t.y,i.max.y)),this._draggable._newPos=this._draggable._startPos.add(t)}},_onPreDragWrap:function(){var t=this._worldWidth,i=Math.round(t/2),e=this._initialWorldOffset,n=this._draggable._newPos.x,o=(n-i+e)%t+i-e,s=(n+i+e)%t-i-e,r=Math.abs(o+e)i.getMaxZoom()&&1}"> ${}
-
+
@@ -110,56 +122,48 @@ function loadMap() { var oscItem = document.querySelector(ITEM_FOR_MAP).closest('.osc_item'); document.querySelector(ITEM_FOR_MAP).addEventListener('click', function (e) { - const deliveryValue = `item_${oscItem.querySelector("input").value}`; + const deliveryValue = ITEM_FOR_MAP.slice(1); // Weź adres klienta do mapy(zalogowany lub niezalogowany: zwykly lub dostawa na inny adres) - const clientStreet = (document.querySelector(`.delivery_box.cn_wrapper:not([style*='display: none']) #delivery_street`) !== null ? document.querySelector(`.delivery_box.cn_wrapper:not([style*='display: none']) #delivery_street`).value : false) || - (document.querySelector(".client_street_logg") ? document.querySelector(".client_street_logg").innerHTML : false) || - document.querySelector("#client_street").value; - const clientZipCode = (document.querySelector(`.delivery_box.cn_wrapper:not([style*='display: none']) #delivery_zipcode`) !== null ? document.querySelector(`.delivery_box.cn_wrapper:not([style*='display: none']) #delivery_zipcode`).value : false) || - (document.querySelector(".client_zipcode_logg") ? document.querySelector(".client_zipcode_logg").innerHTML : false) || - document.querySelector("#client_zipcode").value; - const clientCity = (document.querySelector(`.delivery_box.cn_wrapper:not([style*='display: none']) #delivery_city`) !== null ? document.querySelector(`.delivery_box.cn_wrapper:not([style*='display: none']) #delivery_city`).value : false) || - (document.querySelector(".client_city_logg") ? document.querySelector(".client_city_logg").innerHTML : false) || - document.querySelector("#client_city").value; + const clientStreet = getAddressInfo("street"); + const clientZipCode = getAddressInfo("zipcode"); + const clientCity = getAddressInfo("city"); // Jesli nie ma informacji potrzebnej do mapy, zapisz wiadomosc do errora let errorMessage = ""; - if(!clientStreet) errorMessage+=`${}
`; - if(!clientZipCode) errorMessage+=`${}
`; - if(!clientCity) errorMessage+=`${}`; + + if(!clientStreet) errorMessage += `${}
`; + if(!clientZipCode) errorMessage += `${}
`; + if(!clientCity) errorMessage += `${}`; // Zablokuj wybranie mapy jak nie ma adresu if(errorMessage !== ""){ Alertek.show_alert(errorMessage); - const scrolledToElement = document.querySelector("#deliver_to_billingaddr").checked ? document.querySelector("#delivery_firstname") : document.querySelector("#client_firstname") - scrolledToElement.scrollIntoView({behavior: "smooth"}); + const scrolledToElement = document.getElementById("deliver_to_billingaddr").checked ? document.getElementById("delivery_firstname") : document.getElementById("client_firstname"); + scrollToHeight(scrolledToElement); e.target.checked = false; checkPrevShipping(); return false; } - app_shop.vars.courierId = ITEM_ID; // Customowe markery dla konkretnych dostawców - if(ITEM_ID === "100153-1") newMarkerIcon = mapMarkerUrls.inpost; - else if(ITEM_ID === "100411-1" || ITEM_ID === "100411-0") newMarkerIcon = mapMarkerUrls.orlen; - else newMarkerIcon = mapMarkerUrls.default; + newMarkerIcon = getMarkerIcon(ITEM_ID.split("-")[0]); if (oscItem.querySelector('.finpost_loading')) oscItem.querySelector('.finpost_loading').style.display = "block"; // Pokaż/Wstaw mapę if (finpostjs){ - document.querySelector('#fbs_z02_cover').style.display = "block"; + document.getElementById("fbs_z02_cover").style.display = "block"; disablePageScroll(); } else { document.querySelector('body').insertAdjacentHTML("beforeend",htmlContent); disablePageScroll(); - //Naprawienie searchu w leaflet(stackuja sie wyniki bez tego) - document.getElementById("autocomplete_location").addEventListener("keyup", (e)=>{ - const suggestions = document.querySelector(".leafleat-suggestions") ; + // Naprawienie searchu w leaflet(stackuja sie wyniki bez tego) + document.getElementById("autocomplete_location").addEventListener("keyup", (e) => { + const suggestions = document.querySelector(".leafleat-suggestions"); if(!suggestions) return; else suggestions.remove(); }); @@ -167,23 +171,18 @@ function loadMap() { } // Wstaw adres klienta - const searchField = document.querySelector("#autocomplete_location"); + const searchField = document.getElementById("autocomplete_location"); searchField.value = `${clientStreet} ${clientZipCode} ${clientCity}`; // Zamknij popup - document.querySelector('#fbs_z02_close').addEventListener('click', ()=>{ - document.querySelector('#fbs_z02_cover').style.display = "none" - enablePageScroll(); - }); - document.querySelector('#fbs_z02_cover').addEventListener('click', function (e) { - if (!e.target.closest('#fbs_z02_wrapper')){ - document.querySelector('#fbs_z02_cover').style.display = "none"; - enablePageScroll(); - } + document.getElementById("fbs_z02_close").addEventListener('click', closeMap); + document.getElementById("fbs_z02_cover").addEventListener('click', function (e) { + if (e.target.closest('#fbs_z02_wrapper')) return; + closeMap(); }); // Zmiana miejsca przycisku "szukaj na tym obszarze" na mobile - if (window.innerWidth < 757) document.querySelector('#pickup_list_form').insertAdjacentElement("beforebegin",document.querySelector('.map_button_search')); + if (window.innerWidth < 757) document.getElementById("pickup_list_form").insertAdjacentElement("beforebegin",document.querySelector('.map_button_search')); if (!oscItem.querySelector('.fselectedPoint')) oscItem.insertAdjacentHTML("beforeend",``); // wyszukiwanie punktów odbioru na mapie @@ -198,8 +197,8 @@ function loadMap() { runSearchPickup(); document.querySelector('#locationField .btn').click(); - //Wybranie punktu i wstawienie go koło dostawy - document.querySelector('.asideContainer_pickup').addEventListener("change",(e)=>{ + // Wybranie punktu i wstawienie go koło dostawy + document.querySelector('.asideContainer_pickup').addEventListener("change", (e) => { if(e.target.type !== "radio") return; const selectedPoint = document.querySelector('[name="shipping"]:checked').closest('.osc_item').querySelector('.fselectedPoint'); @@ -215,9 +214,10 @@ function loadMap() { createPickuppointInfo(selectedPoint, deliveryId, pickupName, streetName, cityName, zipCodeName, ITEM_ID.split("-")[0]); }); - document.getElementById("pickup_list_form").addEventListener("click",e=>{ - if(!e.target.classList.contains("fbs02_btn") && !e.target.closest(".pickupl_submit")) return; - document.querySelector('#fbs_z02_close').click(); + // Wyjście z mapy po kliknięciu na "Wybierz" + document.getElementById("pickup_list_form").addEventListener("click",e => { + if(!e.target.classList.contains("fbs02_btn")) return; + closeMap(); }); } changeCurrentShippingInfo(e.target); @@ -225,9 +225,21 @@ function loadMap() { } deliveryPickupPoints.forEach(point => createEventsInpost(point)); } +// zamknięcie mapy +function closeMap(){ + document.getElementById("fbs_z02_cover").style.display = "none"; + enablePageScroll(); +} +// Zdobądź wartość adresu, kodu pocztowego i miasta +function getAddressInfo(query){ + if(document.getElementById("deliver_to_billingaddr").checked){ + if(document.getElementById(`delivery_${query}`).value.trim()) return document.getElementById(`delivery_${query}`).value; + }; + return document.getElementById(`client_${query}`).value; +} // utworzenie informacji o punkcie odbioru function createPickuppointInfo(selectedPoint, deliveryPointId, name, streetText, cityText, zipcodeText, courierId){ - //Pokazanie elementu fselectedPoint + // Pokazanie elementu fselectedPoint selectedPoint.style.display = "block"; // Wstawienie danych w punkt odbioru @@ -253,26 +265,31 @@ function createPickuppointInfo(selectedPoint, deliveryPointId, name, streetText,
- `) + `); } // Zmiana widoku listy, mapy na mobilce function toggleMapList(e){ const ifList = e.target.dataset.show === "list"; - e.target.innerHTML = ifList ? "Pokaż Mapę" : "Pokaż Listę" + e.target.innerHTML = ifList ? "Pokaż Mapę" : "Pokaż Listę"; - //Schowaj/ Pokaż mapę - document.querySelector(".map_button_search").style.display = ifList ? "none" : "block"; - document.querySelector("#mymap").style.display = ifList ? "none" : "block"; - - //Schowaj/Pokaż listę - document.querySelector(".asideContainer_pickup").style.display = ifList ? "block" : "none"; + // Schowaj/ Pokaż mapę i listę + if(ifList){ + document.querySelector(".map_button_search").classList.add("--hide-map-el"); + document.getElementById("mymap").classList.add("--hide-map-el"); + document.querySelector(".asideContainer_pickup").classList.remove("--hide-map-el"); + }else{ + document.querySelector(".map_button_search").classList.remove("--hide-map-el"); + document.getElementById("mymap").classList.remove("--hide-map-el"); + document.querySelector(".asideContainer_pickup").classList.add("--hide-map-el"); + } e.target.dataset.show = ifList ? "map" : "list"; } /////////////////////////////////////////////////////////////////////////// // DANE KLIENTA -document.querySelector("#cop_seection1").addEventListener("click", (e)=>{ + +document.getElementById("cop_seection1").addEventListener("click", (e) => { // Pokazanie się okna od logowania if(e.target.classList.contains("get_signin")) showSigninModal(); @@ -285,32 +302,17 @@ document.querySelector("#cop_seection1").addEventListener("click", (e)=>{ } // Ukrycie/Pokazanie hasła - if(e.target.id === "toggle_password"){ - const passwordInput = document.querySelector(".register__password"); - if(passwordInput.type === "password") { - passwordInput.type = "text"; - e.target.classList.remove("register__show-password") - e.target.classList.add("register__hide-password") - e.target.innerHTML = `${}` - } - else { - passwordInput.type = "password"; - e.target.classList.remove("register__hide-password") - e.target.classList.add("register__show-password") - e.target.innerHTML = `${}` - } - return; - } + if(e.target.id === "toggle_password") return togglePassword(e.target); // Sprawdzenie czy kliknięcie było na firmę, czy na osobę prywatną - if(e.target.id === "client_type1") return document.querySelectorAll("#cop_seection1 .firm-group").forEach(el=>el.classList.add("--fade-in")); - if(e.target.id === "client_type2") return document.querySelectorAll("#cop_seection1 .firm-group").forEach(el=>el.classList.remove("--fade-in")); + if(e.target.id === "client_type1") return document.querySelectorAll("#cop_seection1 .firm-group").forEach(el => el.classList.add("--fade-in")); + if(e.target.id === "client_type2") return document.querySelectorAll("#cop_seection1 .firm-group").forEach(el => el.classList.remove("--fade-in")); // Sprawdzenie czy dostawa na inny adres czy nie if(e.target.id === "deliver_to_billingaddr"){ let ifBillingaddr = false; if(e.target.checked) ifBillingaddr = true; - return showDeliveryForm(ifBillingaddr) + return showDeliveryForm(ifBillingaddr); } // Sprawdzenie czy kliknięcie będzie na guzik "Wybierz z listy adresów" i pokazanie popupa @@ -318,22 +320,47 @@ document.querySelector("#cop_seection1").addEventListener("click", (e)=>{ app_shop.fn.addressModal = new Modal({ element: $(".delivery__address-list-container"), classList: "--fade-in-modal", - afterShow: ()=>{ + afterShow: () => { disablePageScroll(); document.querySelector(".delivery__address-list").addEventListener("click", handleClickAddressList); }, - beforeClose: ()=>{ + beforeClose: () => { enablePageScroll(); document.querySelector(".delivery__address-list").removeEventListener("click", handleClickAddressList); }, - }) + }); return; } -}) +}); + +// Pokaż/schowaj hasło +function togglePassword(el){ + const passwordInput = document.querySelector(".register__password"); + let showPassword = false; + if(passwordInput.type === "password") showPassword = true; + + passwordInput.type = showPassword ? "text" : "password"; + el.classList.remove(showPassword ? "register__show-password" : "register__hide-password"); + el.classList.add(showPassword ? "register__hide-password" : "register__show-password"); + el.innerHTML = showPassword ? `${}` : `${}`; +} // Pokaż popup logowania function showSigninModal(){ - app_shop.fn.signinModal = new Modal({element: $("#signin-form-ajax"), classList: "--fade-in-modal", afterShow: disablePageScroll, beforeClose: enablePageScroll}); + app_shop.fn.signinModal = new Modal({ + element: $("#signin-form-ajax"), + classList: "--fade-in-modal", + afterShow: ()=>{ + disablePageScroll(); + document.querySelector(".signin_login_input").addEventListener("keydown", logInOnEnter); + document.querySelector(".signin_pass_input").addEventListener("keydown", logInOnEnter); + }, + beforeClose: ()=>{ + enablePageScroll(); + document.querySelector(".signin_login_input").removeEventListener("keydown", logInOnEnter); + document.querySelector(".signin_pass_input").removeEventListener("keydown", logInOnEnter); + }, + }); } // Pokaż(true)/Schowaj(false) formularz dostawy na inny adres @@ -341,26 +368,25 @@ function showDeliveryForm(style){ const deliveryWrapper = document.querySelector(".ajax_cop #client_new_additional .delivery_box.cn_wrapper"); if((style && deliveryWrapper.classList.contains("--more")) || (!style && !deliveryWrapper.classList.contains("--more"))) return; - // Pokazanie się/Schowanie formularza dostawy na inny adres - if(style) deliveryWrapper.classList.add("--more"); - else deliveryWrapper.classList.remove("--more"); + // formularz dostawy na inny adres + style ? deliveryWrapper.classList.add("--more") : deliveryWrapper.classList.remove("--more"); - // Pokazanie się/Schowanie przycisku od wybierania z listy adresów + // przycisk od wybierania z listy adresów listBtn = document.querySelector(".delivery__address-list-button"); if(listBtn) style ? listBtn.classList.add("--fade-in") : listBtn.classList.remove("--fade-in"); // Zmiana regionu jeśli region klienta różni się od regionu dostawy const deliveryRegion = document.getElementById("delivery_region").value; - const clientRegion = document.getElementById("client_region") ? document.getElementById("client_region").value : document.querySelector("#cop_seection1 input[name='client_region_logg']").value; + const clientRegion = document.getElementById("client_region").value; if(deliveryRegion !== clientRegion) changeRegion(); } // EventListener listy adresów function handleClickAddressList(e){ - const addressLi = e.target.closest("li") + const addressLi = e.target.closest("li"); if(!addressLi) return; - // Uzupełnienie informacji o formularzu (brak państwa jeszcze) + // Uzupełnienie informacji o formularzu const addressForm = document.querySelector(".delivery_box.cn_wrapper"); changeDeliveryValue("#delivery_firstname", addressLi.dataset.firstname); changeDeliveryValue("#delivery_lastname", addressLi.dataset.lastname); @@ -374,7 +400,7 @@ function handleClickAddressList(e){ else { firmName.value = ""; firmName.classList.remove("focused"); - clearValidation(firmName) + clearValidation(firmName); } changeDeliveryValue("#delivery_street", addressLi.dataset.street); changeDeliveryValue("#delivery_zipcode", addressLi.dataset.zipcode); @@ -389,11 +415,11 @@ function handleClickAddressList(e){ } // nadanie klasy aktywnemu adresowi - e.target.closest("ul").querySelectorAll("li").forEach(el=>el.classList.remove("--active-address")); + e.target.closest("ul").querySelectorAll("li").forEach(el => el.classList.remove("--active-address")); addressLi.classList.add("--active-address"); // Zamkniencie modala - setTimeout(()=> app_shop.fn.addressModal.closeModal(),100) + setTimeout(() => app_shop.fn.addressModal.closeModal(),100) } // Zmień wartości pól input delivery @@ -412,9 +438,15 @@ const SIGNIN = (signinInput) => JSON.stringify({ } }`, }); -const signinForm = document.querySelector(".signin-form_box_text form") -if(signinForm) signinForm.addEventListener("submit", async(event)=>{ - event.preventDefault(); + +function logInOnEnter(e){ + if(e.key==="Enter") logInToAccount(false) +} +const signinForm = document.querySelector(".signin-form_box_text form"); +if(signinForm) signinForm.addEventListener("submit", logInToAccount); + +async function logInToAccount(event){ + if(event) event.preventDefault(); const login = document.querySelector(".signin_login_input").value; const password = document.querySelector(".signin_pass_input").value; const loginStatus = await fetchData({ @@ -427,14 +459,14 @@ if(signinForm) signinForm.addEventListener("submit", async(event)=>{ }); if (loginStatus.errors) { Alertek.show_alert(`${}`); - return; + return; } app_shop.fn.signinModal.closeModal(); getClientNew(); if(document.querySelector(".order2_terms_wrapper_sub.email")) document.querySelector(".order2_terms_wrapper_sub.email").remove(); if(document.querySelector(".order2_terms_wrapper_sub.sms")) document.querySelector(".order2_terms_wrapper_sub.sms").remove(); -}); +} // Zalogowanie/inicjacja użytkownika function getClientNew(){ @@ -442,7 +474,7 @@ function getClientNew(){ app_shop.fn.ajaxLoadSite(1); // Przygotowanie jesli użytkownik nie jest zalogowany - if(document.getElementById("client_new_form") && document.getElementById("client_new_form").childElementCount) document.getElementById("client_new_form").remove(); + if(!document.querySelector(".--logged")) document.getElementById("client_form").remove(); document.querySelector(".step1_sub").insertAdjacentHTML("beforeend",''); $.ajax({ url: "/client-new.php?ajax=true&set_render=content", @@ -459,17 +491,16 @@ function getClientNew(){ history.go(-1); }, "?set_render=content" - ).then(()=>{ + ).then(() => { changeRegion(); - changeCountryPaddingLeft(); }) }, }); }; - ///////////////////////////////////////////////////////////////////////////////////////////////////////// // WALIDACJA + // wyczyść klasy walidacji function clearValidation(input){ const wrapper = input.closest(".has-feedback") @@ -502,45 +533,47 @@ function addErrorMessage(input, message){ input.closest('.has-feedback').insertAdjacentHTML("beforeend",`${message}.`); } // waliduj elementy wymagające wysłania requesta (zipcode, nip) -function validateRequest(target){ +async function validateRequest(target, order=false){ const wrapper = target.closest(".has-feedback"); - let reqData = `${target.name}=${target.value}` + let reqData = `${target.name}=${target.value}`; if(target.dataset.serialize) { - const serializeEl = document.querySelector(target.dataset.serialize) + const serializeEl = document.querySelector(target.dataset.serialize); reqData += '&' + `${serializeEl.name}=${encodeURIComponent(serializeEl.value)}`; } if(target.dataset.revalidate) { - target.dataset.revalidate.split(",").forEach(elQuery=>{ - const revalidateEl = document.querySelector(elQuery); - validateRequest(revalidateEl) + target.dataset.revalidate.split(",").forEach(elQuery => { + validateRequest(document.querySelector(elQuery)); }) } if(target.value === '') { - addErrorMessage(target, ) + addErrorMessage(target, ); return false; } - $.ajax({ + + const resData = await $.ajax({ url: '/ajax/client-new.php?validAjax=true', type: 'POST', timeout: 16000, dataType: 'JSON', data: reqData, - }).then(function succesFn(resData) { - if (resData.errno) { - let error_message = ''; - if (resData.message.error_code) { - if (resData.message.zipcode_pattern && (resData.message.error_code == 'incorect_zipcode' || resData.message.error_code == 'incorect_delivery_zipcode')) { - error_message = clientNewErrorCode[resData.message.error_code] + ' ' + `${}]:` + ' '; - error_message += resData.message.zipcode_pattern.join(', '); - } - else if (clientNewErrorCode[resData.message.error_code]) error_message = clientNewErrorCode[resData.message.error_code]; - } - addError(target); - if (error_message) addErrorMessage(target, error_message) + }); + + if(resData.errno) { + let error_message = ''; + if (resData.message.error_code) { + if (resData.message.zipcode_pattern && (resData.message.error_code === 'incorect_zipcode' || resData.message.error_code === 'incorect_delivery_zipcode')) { + error_message = clientNewErrorCode[resData.message.error_code] + ' ' + `${}]:` + ' '; + error_message += resData.message.zipcode_pattern.join(', '); + } + else if (clientNewErrorCode[resData.message.error_code]) error_message = clientNewErrorCode[resData.message.error_code]; + } + addError(target); + if (error_message) addErrorMessage(target, error_message); + return false }else{ addSuccess(target); - if (target.name==="client_email") { + if (target.name==="client_email" && !order) { $.ajax({ url: '/ajax/client-new.php?checkClientExists=true', type: 'POST', @@ -550,11 +583,11 @@ function validateRequest(target){ }).then(function succesFn(resData) { if(resData.client_exists === true || resData.login) showEmailPopup(resData); }); - } + } + return true; } - }); }; - +// Pokaż popup jeśli użytkownik wpisał email który posiada już konto function showEmailPopup(resData){ app_shop.fn.emailModal = new Modal({ html: ` @@ -587,68 +620,84 @@ function showEmailPopup(resData){
`, - afterShow: disablePageScroll, beforeClose: enablePageScroll + classList: "--fade-in-modal", + afterShow: disablePageScroll, + beforeClose: enablePageScroll, }); return; } - function handleShowSigninModalFromEmailModal(e){ e.preventDefault(); - app_shop.fn.emailModal.closeModal() + app_shop.fn.emailModal.closeModal(); showSigninModal(); } // event listener zmian w kontenerze cop_seection1 -document.querySelector("#cop_seection1").addEventListener("change", (e)=>{ - // walidacja zipcode - if(e.target.id === 'client_zipcode' || e.target.id === "delivery_zipcode") return validateRequest(e.target); - // walidacja nipu - if(e.target.id === 'client_nip') return validateRequest(e.target); +const validateRequestId = ["client_zipcode", "delivery_zipcode", "client_nip", "client_email"]; +const notEmptyFieldsId = ["client_firstname", "client_lastname", "client_city", "delivery_firstname", "delivery_lastname", "delivery_city", "client_firm"]; +document.getElementById("cop_seection1").addEventListener("change", (e) => { + // walidacja zipcode, nipu i emaila + if(validateRequestId.includes(e.target.id)) return validateRequest(e.target); + // zmiana regionu if(e.target.name === "client_region" || e.target.name === "delivery_region") { const clientType = e.target.name.split("_")[0]; - validateRequest(document.querySelector(`#${clientType}_zipcode`)); - if(clientType === "client") validateRequest(document.querySelector("#client_nip")); + validateRequest(document.getElementById(`${clientType}_zipcode`)); + if(clientType === "client" && document.getElementById("client_type1").checked === true) validateRequest(document.getElementById("client_nip")); changeRegion(); return; } - // walidacja maila - if(e.target.id === "client_email"){ - validateRequest(e.target) - }; + // Walidacja ulicy i numeru domu - if(e.target.id === "client_street" || e.target.id === "delivery_street"){ - const streetParts = e.target.value.split(" "); - const addressNumber = Number(streetParts[streetParts.length-1][0]) - if(e.target.value.length === 0 || (e.target.value.length > 0 && (!addressNumber || streetParts.length < 2))){ - addErrorMessage(e.target, ) - }else addSuccess(e.target); - return; - } + if(e.target.id === "client_street" || e.target.id === "delivery_street") validateStreet(e.target); // Walidacja numeru telefonu - if(e.target.id === "client_phone" || e.target.id === "delivery_phone"){ - const phoneNumber = e.target.value.replaceAll(" ",""); - if(phoneNumber.length===0 || (phoneNumber.length > 0 && !(Number(phoneNumber)) || phoneNumber.length<9)){ - addErrorMessage(e.target, ) - }else addSuccess(e.target); - return; - } + if(e.target.id === "client_phone" || e.target.id === "delivery_phone") validatePhone(e.target); // Walidacja loginu i hasła rejestracji if(e.target.classList.contains("register__login")) testLogin(); if(e.target.classList.contains("register__password")) testPassword(); - // Walidacja imienia nazwiska i miasta(wymagające po prostu nie bycia pustym) - const notEmptyFieldsId = ["client_firstname", "client_lastname", "client_city", "delivery_firstname", "delivery_lastname", "delivery_city"]; - if(notEmptyFieldsId.includes(e.target.id)){ - if(e.target.value.length < 1) addErrorMessage(e.target, ) - else addSuccess(e.target); - return; - }; - if(e.target.id === "delivery_additional" || e.target.id === "client_firm"){ + // Walidacja imienia nazwiska miasta i firmy(wymagające po prostu nie bycia pustym) + if(notEmptyFieldsId.includes(e.target.id)) validateNotEmpty(e.target); + + // Sprawdzenie czy firma w dostawie na inny adres została wpisana + if(e.target.id === "delivery_additional"){ if(e.target.value.length > 0) addSuccess(e.target); else clearValidation(e.target); }; -}) -// Walidacja loginu +}); +// funkcje walidacji poszczególnych elementów +function validateStreet(streetEl){ + const streetParts = streetEl.value.split(" "); + const addressNumber = Number(streetParts[streetParts.length-1][0]); + if(streetEl.value.length === 0 || (streetEl.value.length > 0 && (!addressNumber || streetParts.length < 2))){ + addErrorMessage(streetEl, ); + return false; + }else{ + addSuccess(streetEl); + return true; + } +} +function validatePhone(streetEl){ + const phoneNumber = streetEl.value.replaceAll(" ",""); + if(phoneNumber.length===0 || (phoneNumber.length > 0 && !(Number(phoneNumber)) || phoneNumber.length<9)){ + addErrorMessage(streetEl, ); + return false; + }else { + addSuccess(streetEl); + return true; + } +} +function validateNotEmpty(checkEl){ + if(checkEl.value.length < 1) { + addErrorMessage(checkEl, ); + return false; + } + else{ + addSuccess(checkEl); + return true; + } +} + +// Sprawdzenie loginu i hasla function testLogin(){ const login = document.querySelector(".register__login"); if(login.value.trim().length < 1){ @@ -663,10 +712,8 @@ function testLogin(){ return true; } } - -// Walidacja rejestracji function testPassword(){ - const repeatPassword = document.querySelector("#repeat_password") + const repeatPassword = document.getElementById("repeat_password"); const password = document.querySelector(".register__password"); repeatPassword.value = password.value; if(password.value.trim().length < 1){ @@ -685,7 +732,7 @@ function testPassword(){ } // Obsługa przesuwających się labelek -document.querySelector("body").addEventListener("change", (e)=>{ +document.querySelector("body").addEventListener("change", (e) => { if(e.target.classList.contains("f-control")){ if(e.target.value.length > 0) e.target.classList.add("focused"); else e.target.classList.remove("focused"); @@ -694,6 +741,7 @@ document.querySelector("body").addEventListener("change", (e)=>{ /////////////////////////////////////////////////////////////////////// // DOSTAWA I PŁATNOSĆI + const SET_REGION = (setRegionInput) => JSON.stringify({ query: `mutation { setRegion(${setRegionInput}) { @@ -711,8 +759,10 @@ async function changeRegion(payAndDelData = null, firstLoad = false) { console.log("fn: changeRegion"); // Pobranie informacji o regionie z formularza - const clientRegion = document.querySelector(".client_region_logg input[name='client_region_logg']") ? document.querySelector(".client_region_logg input[name='client_region_logg']").value : document.querySelector("#client_region").value; - const deliveryRegion = document.querySelector("#deliver_to_billingaddr").checked ? document.querySelector("#delivery_region").value : clientRegion; + const clientRegion = document.getElementById("client_region").value; + const deliveryRegion = document.getElementById("deliver_to_billingaddr").checked ? document.getElementById("delivery_region").value : clientRegion; + + // Zmiana regionu const regionStatus = await this.fetchData({ @@ -729,14 +779,14 @@ async function changeRegion(payAndDelData = null, firstLoad = false) { // Pobranie nowych metod płatności i dostaw getNewPaymentsAndDeliveries(payAndDelData, firstLoad); }; -///////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//załadowanie metod dostaw i płatności + +// załadowanie metod dostaw i płatności function getNewPaymentsAndDeliveries(data = null, firstLoad = false) { console.log("fn: order1_new"); // Wyczyszczenie zapisanych poprzednich metod płatności - prevPayment=undefined; - prevShipping=undefined; - // Wyczyść punkty odbioru + prevPayment = undefined; + prevShipping = undefined; + // Wyczyszczenie punktow odbioru deliveryPickupPoints.length = 0; app_shop.fn.ajaxLoadSite(1); @@ -758,23 +808,22 @@ function getNewPaymentsAndDeliveries(data = null, firstLoad = false) { app_shop.fn.ajaxLoadSite(0); }, success: function (e) { - console.log("DOSTAWY I PŁATNOSCI", e) let prepaidMarkup = ""; // Stworzenie markupa dla metod dostaw e.prepaid.forEach(function (method) { - prepaidMarkup+=prepareDeliveryMarkup(method, deliveryId); + prepaidMarkup += prepareDeliveryMarkup(method, deliveryId); }); // Stworzenie markupa dla metod dostaw (dla płatności przy odbiorze) let dvpMarkup = ""; e.dvp.forEach(function (method) { - dvpMarkup+=prepareDeliveryMarkup(method, deliveryId); + dvpMarkup += prepareDeliveryMarkup(method, deliveryId); }); // Wstawienie metod dostaw na strone const deliveryMarkup = `
${prepaidMarkup}
${dvpMarkup}
`; - const previousDeliveries = document.querySelector("#osc_order1"); + const previousDeliveries = document.getElementById("osc_order1"); if(previousDeliveries) previousDeliveries.remove(); document.querySelector(".ajax_cop .step2_sub").insertAdjacentHTML("beforeend",deliveryMarkup); @@ -783,9 +832,10 @@ function getNewPaymentsAndDeliveries(data = null, firstLoad = false) { let prepaidsTransferMarkup = createPaymentContainerMarkup("transfer"); let prepaidsCardMarkup = createPaymentContainerMarkup("card"); - //Sprawdzenie czy sklep ma możliwość płatności bankiem/kartą - let ifPaymentTransfer=false; - let ifPaymentCard=false; + // Sprawdzenie czy sklep ma możliwość płatności bankiem/kartą + let ifPaymentTransfer = false; + let ifPaymentCard = false; + // Przygotowanie Płatności e.prepaids_method.forEach(function (method) { const markup = ` @@ -799,22 +849,22 @@ function getNewPaymentsAndDeliveries(data = null, firstLoad = false) { ${2 == method.id ? '' : ""}
${method.description}
- ` + `; // Przygotowanie metod dla przelewów online/kart płatności if(method.group === "transfer") { prepaidsTransferMarkup += markup; - ifPaymentTransfer=true; + ifPaymentTransfer = true; } else if(method.group === "card"){ - prepaidsCardMarkup +=markup; - ifPaymentCard=true; + prepaidsCardMarkup += markup; + ifPaymentCard = true; } else{ prepaidsMethodMarkup += markup; // okienko vouchera if(method.id === 2){ - prepaidsMethodMarkup+=` + prepaidsMethodMarkup += `
Bon towarowy @@ -853,56 +903,70 @@ function getNewPaymentsAndDeliveries(data = null, firstLoad = false) { `; // Wstawienie metod płatności na stronę - const previousPayments = document.querySelector("#osc_prepaids_method"); + const previousPayments = document.getElementById("osc_prepaids_method"); if(previousPayments) previousPayments.remove(); document.querySelector(".ajax_cop #checkout_step3_1 .step3_sub").insertAdjacentHTML("beforeend", `
${ifPaymentTransfer ? prepaidsTransferMarkup : ""}${ifPaymentCard ? prepaidsCardMarkup : ""}${prepaidsMethodMarkup}
`); // Wstawienie błędu jeśli metody płatności są puste - const currentPayments = document.querySelector("#osc_prepaids_method"); - if(document.querySelector("#osc_prepaids_method").innerHTML === "") currentPayments.insertAdjacentHTML("beforeend",'"); + const currentPayments = document.getElementById("osc_prepaids_method"); + if(document.getElementById("osc_prepaids_method").innerHTML === "") currentPayments.insertAdjacentHTML("beforeend",'"); // Wstawienie pickuppoint jeśli edycja i istnieje if(data?.pickupData !== undefined && data?.pickupData !== null){ const selectedShipping = document.querySelector(`#cop_seection2 input#${deliveryId}`); - const pointExists = checkPrevPickupPoint(selectedShipping.parentElement.querySelector(".fselectedPoint"), data.pickupData.id, data.pickupData.name, `${data.pickupData.address.street} ${data.pickupData.address.buildingAndHouseNumber}`, data.pickupData.address.city, data.pickupData.address.postcode, data.deliveryMethodId); + const pointExists = checkPrevPickupPoint( + selectedShipping.parentElement.querySelector(".fselectedPoint"), + data.pickupData.id, + data.pickupData.name, + `${data.pickupData.address.street} ${data.pickupData.address.buildingAndHouseNumber}`, + data.pickupData.address.city, + data.pickupData.address.postcode, + data.deliveryMethodId + ); + // Odznaczenie punktu jeśli punkt odbioru nie istnieje(Wcześniej był zaznaczony przy edycji) if(!pointExists) selectedShipping.checked = false; + }// Sprawdzenie czy użytkownik ma zapisane poprzednio użyte metody w przeglądarce(tylko przy pierwszym załadowaniu strony) else if(localStorage.getItem("prevPaymentMethod") && localStorage.getItem("prevDeliveryMethod") && firstLoad){ const prevPaymentMethod = JSON.parse(localStorage.getItem("prevPaymentMethod")); // Zaznaczenie metod płatności które nie tworzą popupa if(prevPaymentMethod.id !== "payitem_2" && prevPaymentMethod.group !== "card" && prevPaymentMethod.group !== "transfer") document.getElementById(prevPaymentMethod.id).click(); - - // Wybranie karty/banku - else if(prevPayment.group === "card" || prevPayment.group === "transfer"){ - const paymentMethodId = prevPayment.id.replace("-clone", ""); + else if(prevPaymentMethod.group === "card" || prevPaymentMethod.group === "transfer"){ + const paymentMethodId = prevPaymentMethod.id.replace("-clone", ""); cloneElement(document.getElementById(paymentMethodId)); } // poprzednia dostawa - const prevDelivery = JSON.parse(localStorage.getItem("prevDeliveryMethod")); - const prevDeliveryInput = document.querySelector(`input#${prevDelivery.id}`); - console.log(prevDelivery, prevDeliveryInput) + const prevDeliveryMethod = JSON.parse(localStorage.getItem("prevDeliveryMethod")); + const prevDeliveryInput = document.querySelector(`input#${prevDeliveryMethod.id}`); + // Sprawdzenie czy istnieje metoda płatności(na wypadek gdyby była usunięta lub klient zamawiał do innego kraju) if(prevDeliveryInput){ - //sprawdzenie czy dostawa miała punkt odbioru - if(prevDelivery.fselectedPoint){ - console.log(prevDelivery); - const pointExists = checkPrevPickupPoint(prevDeliveryInput.parentElement.querySelector(".fselectedPoint"), prevDelivery.fselectedPoint.deliveryPointId, prevDelivery.fselectedPoint.name, prevDelivery.fselectedPoint.street, prevDelivery.fselectedPoint.city, prevDelivery.fselectedPoint.zipcode, prevDelivery.fselectedPoint.courierId); + // sprawdzenie czy dostawa miała punkt odbioru + if(prevDeliveryMethod.fselectedPoint){ + const pointExists = checkPrevPickupPoint( + prevDeliveryInput.parentElement.querySelector(".fselectedPoint"), + prevDeliveryMethod.fselectedPoint.deliveryPointId, + prevDeliveryMethod.fselectedPoint.name, + prevDeliveryMethod.fselectedPoint.street, + prevDeliveryMethod.fselectedPoint.city, + prevDeliveryMethod.fselectedPoint.zipcode, + prevDeliveryMethod.fselectedPoint.courierId + ); if(pointExists) prevDeliveryInput.checked = true; }else{ prevDeliveryInput.checked = true; } } } - // Przeładowanie mapy loadMap(); // Przeliczenie kosztu dostawy calculateBasketCost(); // Zmiana daty dostawy i pokazanych opcji dostawy - const firstInput = document.querySelector("#osc_order1 input"); + const firstInput = document.getElementById("osc_order1 input"); if(firstInput) deliveryDate(firstInput.value, firstInput.dataset.delivery, firstInput.dataset.pickuppoint); calculateBasketCost(); app_shop.fn.ajaxLoadSite(0); @@ -924,8 +988,7 @@ function createPaymentContainerMarkup(method){

Lista ${methodName}

Wybierz z ${methodName} -
- ` +
`; } // Przygotowanie html dla metod dostaw @@ -939,12 +1002,11 @@ function prepareDeliveryMarkup(method, deliveryId){ // Obliczenie daty dostawy let date = new Date(); - date.setDate(date.getDate()+method.time) + date.setDate(date.getDate()+method.time); const deliveryDate = date.toLocaleDateString('en-GB').replaceAll("/", "."); // uzupełnienie markupa dla metod dostaw dvp - return ` -
${}: @@ -996,7 +1056,7 @@ async function checkPrevPickupPoint(selectedPoint, deliveryPointId, name, street // Sprawdzenie czy poprzedni punkt dalej istnieje let pointExists = false; - resultData.data.searchPickupPoints.forEach(point=>{ + resultData.data.searchPickupPoints.forEach(point => { if(point.data.includes(deliveryPointId)) pointExists = true; }) // Utworzenie nowego punktu odbioru @@ -1010,27 +1070,31 @@ let prevShipping; function checkPrevShipping(){ if(prevShipping){ prevShipping.checked=true; - changeCurrentShippingInfo(prevShipping) + changeCurrentShippingInfo(prevShipping); } } +// Przeliczenie kosztu i czasu dostawy i zapisanie nowej metody dostawy function changeCurrentShippingInfo(shippingMethod){ calculateBasketCost(); deliveryDate(shippingMethod.value, shippingMethod.dataset.delivery, shippingMethod.dataset.pickuppoint); app_shop.vars.checkedShipping = shippingMethod.value; } -document.querySelector("#cop_seection2").addEventListener("click", e=>{ +document.getElementById("cop_seection2").addEventListener("click", e => { // kliknięcie na dostawe if(e.target.name === "shipping"){ // Wyczyszczenie wszystkich zaznaczonych punktów odbioru clearSelectedPoints(); + // Nie robienie niczego jeśli kliknąłeś na ten sam element if(app_shop.vars.checkedShipping === e.target.value) return; if(e.target.dataset.working_days) e.target.dataset.working_days.split("#").map(function (e) {return parseInt(e, 10);}); + // zapisanie jako poprzednia metoda płatności jeśli nie wymaga wyboru punktu odbioru if(e.target.dataset.pickuppoint === "n"){ prevShipping=e.target; + // Przeliczenie kosztu dostawy i czasu dostawy - changeCurrentShippingInfo(e.target) + changeCurrentShippingInfo(e.target); } return; } @@ -1039,18 +1103,22 @@ document.querySelector("#cop_seection2").addEventListener("click", e=>{ if(e.target.name === "payform_id"){ // Usunięcie klona poprzedniego przelewu online/ karty płatniczej removePrevClone(); + // Wyskakujące okienko od vouchera if(e.target.value === "2" && (e.target.parentElement.querySelector(".voucher-value") && e.target.parentElement.querySelector(".voucher-value").style.display === "none")) { app_shop.fn.voucherModal = new Modal({ element: $(".order__voucher_container"), classList: "--fade-in-modal", - afterShow: ()=>{ + afterShow: () => { disablePageScroll(); + document.getElementById("order_voucher_id").addEventListener("keydown", handleClickVoucherEnter); document.querySelector(".order__voucher_button").addEventListener("click", handleClickVoucherSubmit); }, - beforeClose: ()=>{ + beforeClose: () => { enablePageScroll(); + document.getElementById("order_voucher_id").removeEventListener("keydown", handleClickVoucherEnter); document.querySelector(".order__voucher_button").removeEventListener("click", handleClickVoucherSubmit); + // Odznacz/Zaznacz poprzedzni jeśli użytkownik nie podał poprawnego kodu if(e.target.parentElement.querySelector(".voucher-value").style.display === "none"){ if(prevPayment) prevPayment.checked = true; @@ -1060,11 +1128,13 @@ document.querySelector("#cop_seection2").addEventListener("click", e=>{ }); return; } + // Przelewy online i karty płatnosci if(e.target.dataset.group === "transfer" || e.target.dataset.group === "card"){ if(!e.target.closest(".osc_item-modal")) showPaymentMethodModal(e.target.dataset.group); return; } + // Inne metody płatności if(e.target.value !== "2" && e.target.dataset.group !== "transfer" && e.target.dataset.group !== "card"){ const voucherOptionContainer = document.getElementById("payitem_2").parentElement; @@ -1072,6 +1142,7 @@ document.querySelector("#cop_seection2").addEventListener("click", e=>{ voucherOptionContainer.querySelector(".voucher-value").style.display = "none"; voucherOptionContainer.querySelector(".voucher-value").innerHTML = ``; } + // Zmien metody dostawy pomiedzy prepaid a dvp if(!prevPayment && e.target.id === "payitem_cash") changeDeliveryOptions(); if(prevPayment && e.target.id !== prevPayment.id && (e.target.id === "payitem_cash" || prevPayment.id==="payitem_cash")) changeDeliveryOptions(); @@ -1084,7 +1155,7 @@ function removePrevClone(){ const prevClone = document.querySelector(".osc_item-clone"); if(!prevClone) return; const cloneGroupName = prevClone.querySelector("input").dataset.group; - document.querySelector(`#payitem_${cloneGroupName}`).closest(".osc_item").style.display="flex"; + document.getElementById(`payitem_${cloneGroupName}`).closest(".osc_item").style.display="flex"; prevClone.remove(); } @@ -1094,16 +1165,16 @@ function showPaymentMethodModal(method){ app_shop.fn.paymentModal = new Modal({ element: $(`.${method}__methods`), classList: "--fade-in-modal", - afterShow: ()=>{ + afterShow: () => { disablePageScroll(); - document.querySelectorAll(`.${method}__methods .osc_item input`).forEach(el=>{ + document.querySelectorAll(`.${method}__methods .osc_item input`).forEach(el => { el.addEventListener("click", handlePaymentMethodClick); }) }, - beforeClose: ()=>{ + beforeClose: () => { enablePageScroll(); - if(!ifChosenNewPaymentMethod) prevPayment ? prevPayment.checked = true : document.querySelector(`#payitem_${method}`).checked = false; - document.querySelectorAll(`.${method}__methods .osc_item input`).forEach(el=>{ + if(!ifChosenNewPaymentMethod) prevPayment ? prevPayment.checked = true : document.getElementById(`payitem_${method}`).checked = false; + document.querySelectorAll(`.${method}__methods .osc_item input`).forEach(el => { el.removeEventListener("click", handlePaymentMethodClick); }) ifChosenNewPaymentMethod=false; @@ -1113,11 +1184,11 @@ function showPaymentMethodModal(method){ // Metoda oblugujaca kliknieca w metody platnosci w popupie function handlePaymentMethodClick(e){ - // usuń poprzedzni klon jeśli istnieje + // usuń poprzedni klon i stwórz nowy removePrevClone(); + cloneElement(e.target); - cloneElement(e.target) - //zamkniecie modala + // zamkniecie modala ifChosenNewPaymentMethod = true; app_shop.fn.paymentModal.closeModal(); return false; @@ -1126,33 +1197,34 @@ function cloneElement(originalPaymentElement){ // sklonowanie kliknietego elementu const clonedMethod = originalPaymentElement.closest(".osc_item").cloneNode(true); const clonedInput = clonedMethod.querySelector("input"); + // Zmiana id i klasy sklonowanego elementu dla rozróżnienia clonedInput.id = clonedInput.id+"-clone"; clonedMethod.setAttribute("for", clonedInput.id); clonedMethod.classList.add("osc_item-clone"); - //Wstawienie klona po "przelewy online" lub "karta platnicza" - const standInEl = document.querySelector(`#payitem_${clonedInput.dataset.group}`).closest(".osc_item"); + + // Wstawienie klona po "przelewy online" lub "karta platnicza" + const standInEl = document.getElementById(`payitem_${clonedInput.dataset.group}`).closest(".osc_item"); standInEl.after(clonedMethod); standInEl.style.display = "none"; clonedInput.checked = true; } -///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Zmiana opcji dostawy zależnie od płatności function changeDeliveryOptions(){ - console.log("ZMIANA DVP PREPAID"); - if(document.querySelector("#payitem_cash") && document.querySelector("#payitem_cash").checked) changePrepaidDvp("none", "block"); + if(document.getElementById("payitem_cash") && document.getElementById("payitem_cash").checked) changePrepaidDvp("none", "block"); else changePrepaidDvp("block", "none"); - document.querySelectorAll("#checkout_step2_1 input").forEach((el)=>el.checked = false); + document.querySelectorAll("#checkout_step2_1 input").forEach((el) => el.checked = false); app_shop.vars.checkedShipping = ""; calculateBasketCost(); } // zmień pokazane metody dostawy function changePrepaidDvp(prepaidStyle, dvpStyle){ - const prepaid = document.querySelector("#osc_order1_prepaid"); - const dvp = document.querySelector("#osc_order1_dvp"); + const prepaid = document.getElementById("osc_order1_prepaid"); + const dvp = document.getElementById("osc_order1_dvp"); prepaid.style.display = prepaidStyle; dvp.style.display = dvpStyle; clearSelectedPoints(); @@ -1161,11 +1233,15 @@ function changePrepaidDvp(prepaidStyle, dvpStyle){ // Wyczyszczenie informacji o punktach odbioru function clearSelectedPoints(){ const fSelectedPoints = document.querySelectorAll("#osc_order1 .fselectedPoint"); - fSelectedPoints.forEach(el=>{ + fSelectedPoints.forEach(el => { el.innerHTML=""; el.style.display="none"; }); } +// Zatwierdź bon towarowy enterem +function handleClickVoucherEnter(e){ + if(e.key === "Enter") handleClickVoucherSubmit(); +} // Zatwierdź bon towarowy function handleClickVoucherSubmit(){ @@ -1186,24 +1262,29 @@ function handleClickVoucherSubmit(){ addErrorMessage(voucherNumber, ); return; } + // Zmien z dvp na prepaid jesli wcześniej była zapłata za pobraniem if(prevPayment && voucherRadioButton.id !== prevPayment.id && prevPayment.id === "payitem_cash") changeDeliveryOptions(); prevPayment = e.target; + // Pokaż cenę voucherOptionContainer.querySelector(".comment").style.display = "none"; voucherOptionContainer.querySelector(".voucher-value").style.display = "block"; - voucherOptionContainer.querySelector(".voucher-value").innerHTML = `${e.result.value} ${e.result.currency}` + voucherOptionContainer.querySelector(".voucher-value").innerHTML = `${e.result.value} ${e.result.currency}`; + // Wyczyść walidacje removeErrorMessage(voucherNumber); clearValidation(voucherNumber); + // Zamknij modal app_shop.fn.voucherModal.closeModal(); }, }) } -/////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////// // PODSUMOWANIE + // Przeliczenie i pokazanie ceny w podsumowaniu let xhrs; const productsWorthPriceEl = document.querySelector("#order2_products_worth .operation_value"); @@ -1213,8 +1294,8 @@ const insuranceValueEl = document.querySelector("#order2_insurance_value .operat const totalRebateEl = document.querySelector("#order2_total_rebate .operation_value"); const saldoValueEl = document.querySelector("#order2_saldo_value .operation_value"); const productsPointsEl = document.querySelector("#order2_products_points .operation_value"); -const summaryCostEl = document.querySelector("#order2_summaryprice #summary-cost"); -const summaryPointsEl = document.querySelector("#order2_summaryprice #summary-points"); +const summaryCostEl = document.getElementById("summary-cost"); +const summaryPointsEl = document.getElementById("summary-points"); function calculateBasketCost() { // przygotowanie informacji o metodzie dostawy i platnosci const orderInfo = { @@ -1228,6 +1309,7 @@ function calculateBasketCost() { data: orderInfo, success: function (t) { productsWorthPriceEl.innerHTML = formatPrice(t.products_worth, t.currency_sign) + "" + orderTxt.gross + ""; + // Sprawdź cene dostawy if(t.shipping_undefined) deliveryCostEl.parentElement.style.display = "none"; else { @@ -1247,16 +1329,18 @@ function calculateBasketCost() { checkShowPrice(insuranceValueEl, Number(t.insurance_cost), t.currency_sign); checkShowPrice(totalRebateEl, Number(t.total_rebate_without_shipping), t.currency_sign); checkShowPrice(saldoValueEl, Number(t.payment_amount_from_client_balance), t.currency_sign); + // punkty zamówienia if(t.products_worth_at_points){ productsPointsEl.innerHTML = `${t.products_worth_at_points} ${}.`; productsPointsEl.parentElement.style.display = "flex"; - summaryPointsEl.innerHTML = `+ ${t.products_worth_at_points} ${}.` - summaryPointsEl.style.display = "block" + summaryPointsEl.innerHTML = `+ ${t.products_worth_at_points} ${}.`; + summaryPointsEl.style.display = "block"; }else { productsPointsEl.parentElement.style.display = "none"; - summaryPointsEl.style.display = "none" + summaryPointsEl.style.display = "none"; } + // Cena całkowita summaryCostEl.innerHTML = formatPrice(t.total_to_pay, t.currency_sign) + "" + + ""; }, @@ -1280,11 +1364,12 @@ const deliveryMessageEl = document.querySelector("#order2_shiptime span:not(.ope const deliveryDateEl = document.querySelector("#order2_shiptime .operation_value"); function deliveryDate(deliveryVal, delivery, pickuppoint) { const date = delivery.split("#"); + // Wybranie nazwy zaleznie czy dostawa jest do twojego mieszkania czy nie if(deliveryVal === "0-0" || deliveryVal === "0-1" || pickuppoint === "y") deliveryMessageEl.innerHTML = `${}:`; else deliveryMessageEl.innerHTML = `${}:`; - if(date[4]>0) deliveryDateEl.innerHTML = `${} ` + parseInt(date[5]) + ` ${} ` + if(date[4]>0) deliveryDateEl.innerHTML = `${} ` + parseInt(date[5]) + ` ${} `; else{ if(parseInt(date[5]) === 0) deliveryDateEl.innerHTML = ; else deliveryDateEl.innerHTML = orderTxt[`shipping${parseInt(date[3])}`]; @@ -1293,27 +1378,28 @@ function deliveryDate(deliveryVal, delivery, pickuppoint) { // Obsługa klilnięć na elementy w podsumowaniu const productsContainer = document.getElementById("checkout_step3_3"); -document.querySelector("#cop_seection3").addEventListener("click", (e)=>{ +document.getElementById("cop_seection3").addEventListener("click", (e) => { + // Kliknięcie na przyciski "Pokaż pozozostałe produkty" i "Zwiń listę" - const togggleProducts = e.target.closest(".order_products_action") + const togggleProducts = e.target.closest(".order_products_action"); if(togggleProducts){ if(productsContainer.className.includes("--more")){ productsContainer.classList.remove("--more"); - togggleProducts.querySelector("span").innerHTML = `${}` + togggleProducts.querySelector("span").innerHTML = `${}`; }else{ productsContainer.classList.add("--more"); - togggleProducts.querySelector("span").innerHTML = `${}` + togggleProducts.querySelector("span").innerHTML = `${}`; } } - //Kliknięcie na checkbox(nie zaznacz wszystkie i nie kod rabatowy) + // Kliknięcie na checkbox(nie zaznacz wszystkie i nie kod rabatowy) if(e.target.type === "checkbox" && e.target.id !== "checkall-terms" && e.target.id !== "rebate_option"){ const checkboxAllTerms = document.getElementById("checkall-terms"); if(e.target.checked === false) checkboxAllTerms.checked = false; else{ const termsInputs = document.querySelectorAll(".order2_terms_wrapper input:not(#checkall-terms)"); let checkedCount = 0; - termsInputs.forEach(el=>el.checked === true ? checkedCount++ : ""); + termsInputs.forEach(el => el.checked === true ? checkedCount++ : ""); if(checkedCount === termsInputs.length) checkboxAllTerms.checked = true; } } @@ -1323,7 +1409,7 @@ document.querySelector("#cop_seection3").addEventListener("click", (e)=>{ const termsInputs = document.querySelectorAll(".order2_terms_wrapper input:not(#checkall-terms)"); let checkAll = false; - termsInputs.forEach(el=>el.checked === false ? checkAll = true : ""); + termsInputs.forEach(el => el.checked === false ? checkAll = true : ""); termsInputs.forEach(function (el) { if(checkAll) el.checked = true; else el.checked = false; @@ -1341,6 +1427,7 @@ document.querySelector("#cop_seection3").addEventListener("click", (e)=>{ //////////////////////////////////////////////////////////////////////////////// // KOD RABATOWY (funkcje) + // Funkcje do przerobienia kodu rabatowego const ACTIVATE_REBATE_CODE = (code) => JSON.stringify({ query: `mutation { @@ -1364,32 +1451,27 @@ const DEACTIVATE_REBATE_CODE = () => JSON.stringify({ } }`, }) + // aktywacja kodu rabatowego -const rebateCode = document.querySelector("#rebate_code"); +const rebateCode = document.getElementById("rebate_code"); async function updateCode(){ if(rebateCode.value.trim() === ""){ addError(rebateCode); rebateCode.insertAdjacentHTML("afterend",`${}.`); return; } - app_shop.fn.ajaxLoadSite(1) + app_shop.fn.ajaxLoadSite(1); // Wysłanie kodu do aktywacji - const rebateStatus = await $.ajax({ + const rebateStatus = await fetchData({ data: ACTIVATE_REBATE_CODE(rebateCode.value), - url: `${app_shop.urls.graphql || '/graphql/v1/'}?mutation=activateRebateCode`, - timeout: 16000, - type: "POST", - headers: { - 'Content-Type': 'application/json', - Accept: 'application/json', - }, - dataType: 'JSON', + linkParameter: "?mutation=activateRebateCode", }); - const { status } = rebateStatus?.data?.activateRebateCode; - app_shop.fn.ajaxLoadSite(0) - //Przeliczenie kosztu koszyka jeśli sukces + const { status } = rebateStatus?.data?.activateRebateCode; + app_shop.fn.ajaxLoadSite(0); + + // Przeliczenie kosztu koszyka jeśli sukces if (status === 'success') { toggleActiveCode(true); calculateBasketCost(); @@ -1400,24 +1482,21 @@ async function updateCode(){ const { message } = rebateStatus?.data?.activateRebateCode?.error; addError(rebateCode); rebateCode.insertAdjacentHTML("afterend",`${message}.`); - hideCodeOnError(); + // Schowaj kod (show=false, error=true) + toggleActiveCode(false, true); } // usunięcie aktywnego kodu rabatowego async function removeCode(){ - app_shop.fn.ajaxLoadSite(1) - const rebateStatus = await $.ajax({ + app_shop.fn.ajaxLoadSite(1); + + const rebateStatus = await fetchData({ data: DEACTIVATE_REBATE_CODE(), - url: `${app_shop.urls.graphql || '/graphql/v1/'}?mutation=deactivateRebateCode`, - timeout: 16000, - type: "POST", - headers: { - 'Content-Type': 'application/json', - Accept: 'application/json', - }, - dataType: 'JSON', + linkParameter: "?mutation=deactivateRebateCode", }); - app_shop.fn.ajaxLoadSite(0) + + app_shop.fn.ajaxLoadSite(0); + const { status } = rebateStatus?.data?.deactivateRebateCode; if (status === 'success') { toggleActiveCode(false); @@ -1431,94 +1510,103 @@ const rebateCodeContainer = document.querySelector(".rebate__code"); const rebateActiveWrapper = document.querySelector(".rebate__active"); const activeCodeEl = document.getElementById("active-code"); const rebateOptionEl = document.getElementById("rebate_option"); -function toggleActiveCode(show){ +function toggleActiveCode(show, error=false){ // Wyczyść walidacje - removeErrorMessage(rebateCode); - clearValidation(rebateCode); - + if(!error){ + removeErrorMessage(rebateCode); + clearValidation(rebateCode); + } + // zmień widoczność rebateOptionWrapper.style.display = show ? "none" : "flex"; - rebateCodeContainer.classList.remove("--fade-in") rebateActiveWrapper.style.display = show ? "block" : "none"; - // zmień wartości - showInput = false; - activeCodeEl.innerHTML = show ? rebateCode.value : ""; - rebateCode.value = ""; - rebateOptionEl.checked = false; -} - -// Ukryj kod jeśli error(pokaż kod rabatowy) -function hideCodeOnError(){ - // zmień widoczność - rebateOptionWrapper.style.display = "flex"; - rebateCodeContainer.classList.add("--fade-in") - rebateActiveWrapper.style.display = "none"; + if(!error)rebateCodeContainer.classList.remove("--fade-in"); + else rebateCodeContainer.classList.add("--fade-in"); // zmień wartości - showInput = true; - activeCodeEl.innerHTML =""; - rebateOptionEl.checked = true; + activeCodeEl.innerHTML = show ? rebateCode.value : ""; + showInput = error ? true : false; + rebateOptionEl.checked = error ? true : false; + if(!error) rebateCode.value = ""; + else activeCodeEl.innerHTML = ""; } // eventListenery dla kodu rabatowego let showInput = false; const rebateCodeWrapper = document.querySelector(".rebate"); -rebateCodeWrapper.addEventListener("click", (e)=>{ +rebateCodeWrapper.addEventListener("click", (e) => { // Rozwinięcie opcji rabatowej if(e.target.id === "rebate_option" || e.target.classList.contains("rebate__active_change")){ - showInput = !showInput + showInput = !showInput; if(showInput) rebateCodeContainer.classList.add("--fade-in"); else rebateCodeContainer.classList.remove("--fade-in"); } - // Kliknięcie na zrealizuj + + // Kliknięcie na zrealizuj i dezaktywuj if(e.target.className.includes("rebate__code-realize")) updateCode(); - // Kliknięcie na dezaktywuj if(e.target.classList.contains("rebate__active_remove")) removeCode(); }); -/////////////////////////////////////////////////////////////////////////////////////////// +// Aktywacja kodu po naciśnięciu na enter +rebateCode.addEventListener("keydown", e=>{ + if(e.key === "Enter") updateCode(); +}) + +/////////////////////////////////////////////////////////////////////// // ZŁOŻENIE ZAMÓWIENIA -// funkcja od sprawdzania czy wartosci inputow sa poprawne przed zlozeniem zamowienia -function checkAllInputData() { - app_shop.vars.validation = 1; - let inputsContainer; - let notIncluded = ":not(#client_firm)"; + +// Zwaliduj wszystkie dostępne inputy zawierające dane klienta i dane adresowe +function validateAllInputs(){ + // Zmienna trzymająca informację czy wystąpił jakiś błąd + let allGood = true; - // Wybranie kontenera inputow (z firma czy bez) - if(document.getElementById("deliver_to_billingaddr").checked) inputsContainer = document.querySelector("#client_new_form") ? document.querySelector("#client_new_form") : document.querySelector("#client_new_additional") - else inputsContainer = document.querySelector("#client_new_client") ? document.querySelector("#client_new_client") : document.querySelector(".client_biling_data") - - // wybranie czy nip jest wykluczony czy nie - if(!document.querySelector(".client_biling_data ") && !document.getElementById("client_type1").checked) notIncluded += ":not(#client_nip)"; - const allInputs = inputsContainer.querySelectorAll(`input[required]${notIncluded}`); - - // sprawdzenie czy pola nie maja błędów - allInputs.forEach(inp=>checkSingleInput(inp)); - - //Sprawdzenie dla email i telefonu jeśli użytkownik nie zalogowany - if(!app_shop.vars.user.login) document.querySelectorAll("#client_contact_info input[required]").forEach(inp=>checkSingleInput(inp)); -}; -function checkSingleInput(input){ - const inputContainer = input.closest(".has-feedback"); - if (input.type !== "checkbox" && input.type !=="radio" ) { - if(input.value === ""){ - app_shop.vars.validation = 0; - inputContainer.classList.add("has-error", "--error"); - }else if(inputContainer.childElementCount){ - if(inputContainer.classList.contains("has-success")) app_shop.vars.validation = 1; - else if(inputContainer.classList.contains("has-error")) app_shop.vars.validation = 0; - } else app_shop.vars.validation = 0 + // Sprawdzenie loginu i hasła jeśli zaznaczone + if(document.getElementById("register_client_checkbox") && document.getElementById("register_client_checkbox").checked){ + allGood = testLogin() && allGood; + allGood = testPassword() && allGood; + } + if(!document.querySelector(".--logged")){ + // Sprawdzenie emaila i telefonu + allGood = validateRequest(document.getElementById("client_email"), true) && allGood; + allGood = validatePhone(document.getElementById("client_phone")) && allGood; + // Sprawdzenie nazwy firmy i nipu + if(document.getElementById("client_type1").checked){ + allGood = validateNotEmpty(document.getElementById("client_firm")) && allGood; + allGood = validateRequest(document.getElementById("client_nip"), true) && allGood; } + // Sprawdzenie reszty pól + allGood = validateFormInputs("client") && allGood; + } + // Sprawdzanie pól dostawy na inny adres + if(document.getElementById("deliver_to_billingaddr").checked){ + allGood = validateFormInputs("delivery") && allGood; + allGood = validatePhone(document.getElementById("delivery_phone")) && allGood; + } + return allGood } +function validateFormInputs(query){ + let isFormGood = true; + + isFormGood = validateNotEmpty(document.getElementById(`${query}_firstname`)) && isFormGood; + isFormGood = validateNotEmpty(document.getElementById(`${query}_lastname`)) && isFormGood; + isFormGood = validateStreet(document.getElementById(`${query}_street`)) && isFormGood; + isFormGood = validateRequest(document.getElementById(`${query}_zipcode`),true) && isFormGood; + isFormGood = validateNotEmpty(document.getElementById(`${query}_city`)) && isFormGood; + + return isFormGood; +} + // Obsługa złożenia zamówienia const termsConditionsInput = document.getElementById("order2_terms_conditions"); const cancelConditionsInput = document.getElementById("order2_cancel"); document.querySelector(".order2_button_order").addEventListener("click", () => { try { app_shop.fn.ajaxLoadSite(1); - checkAllInputData(); + app_shop.vars.validation = 1; + // Sprawdzenie pól formularza + if(validateAllInputs() === false) app_shop.vars.validation = 0; // znalezienie obecnie zaznaczonej metody dostawy i płatności const deliveryMethod = document.querySelector(".ajax_cop [name=shipping]:checked"); @@ -1526,7 +1614,7 @@ document.querySelector(".order2_button_order").addEventListener("click", () => { // sprawdzenie czy użytkownik zaakceptował regulamin if(!termsConditionsInput.checked || !cancelConditionsInput.checked){ - app_shop.vars.validation = 0 + app_shop.vars.validation = 0; showTermsError(termsConditionsInput); showTermsError(cancelConditionsInput); }// sprawdzenie czy użytkownik wybrał metodę dostawy i płatności (też sprawdzenie czy wybrał paczkomat i wpisał voucher) @@ -1543,22 +1631,22 @@ document.querySelector(".order2_button_order").addEventListener("click", () => { let registerError = ""; const registerCheckbox = document.getElementById("register_client_checkbox"); if(registerCheckbox && registerCheckbox.checked){ - if(!testLogin()) registerError += `${}
` + if(!testLogin()) registerError += `${}
`; if(!testPassword()) registerError += `${}`; if(registerError.length > 0){ orderValidationError(registerError); - document.querySelector(".register").scrollIntoView({behavior: "smooth"}); + scrollToHeight(document.querySelector(".register")); } } // przerwanie składania zamówienia jeśli w trakcie walidacji wystąpił błąd if (app_shop.vars.validation === 0) { - const errorEl = document.querySelector(".--error.has-error"); // scroll do elementów z błędem - if(document.querySelector("#order2_terms_conditions").checked && document.querySelector("#order2_cancel").checked){ - if(errorEl) errorEl.scrollIntoView({behavior: "smooth"}); - else if(!document.querySelector(`input[name="payform_id"]:checked`)) document.querySelector("#checkout_step3_1 h2").scrollIntoView({behavior: "smooth"}); - else if(!document.querySelector(`input[name="shipping"]:checked`)) document.querySelector("#checkout_step2_1 h2").scrollIntoView({behavior: "smooth"}); + if(document.getElementById("order2_terms_conditions").checked && document.getElementById("order2_cancel").checked){ + const errorEl = document.querySelector(".--error.has-error"); + if(errorEl) scrollToHeight(errorEl) + else if(!document.querySelector(`input[name="payform_id"]:checked`)) scrollToHeight(document.querySelector("#checkout_step3_1 h2")); + else if(!document.querySelector(`input[name="shipping"]:checked`)) scrollToHeight(document.querySelector("#checkout_step2_1 h2")); } Alertek.show_alert(`${}`); return app_shop.fn.ajaxLoadSite(0), !1; @@ -1577,6 +1665,13 @@ document.querySelector(".order2_button_order").addEventListener("click", () => { alert("blad"); } }); +// Przescrolluj do +function scrollToHeight(scrollToEl){ + const yOffset = -45; + const y = scrollToEl.getBoundingClientRect().top + window.pageYOffset + yOffset; + window.scrollTo({top: y, behavior: 'smooth'}); +} + // Schowaj/Pokaż error na warunkach regulaminun function showTermsError(input){ if(!input.checked){ @@ -1587,57 +1682,56 @@ function showTermsError(input){ // złożenie zamówienia function createOrder(deliveryMethod, paymentMethod){ // Weź dane klienta - const clientType = document.querySelector('.ajax_cop [name="client_type_logg"]') ? document.querySelector('.ajax_cop [name="client_type_logg"]').value : document.querySelector('.ajax_cop [name="client_type"]:checked').value; - const firmname = clientType === "firm" ? getClientTextOrValue(".ajax_cop .client_firm_logg", ".ajax_cop [name=client_firm]") : ""; - const nip = clientType === "firm" ? getClientTextOrValue(".ajax_cop .client_nip_logg", ".ajax_cop [name=client_nip]") : ""; - const email = getClientTextOrValue(".ajax_cop .client_email_logg", ".ajax_cop [name=client_email]"); - let firstname = getClientTextOrValue(".ajax_cop .client_firstname_logg", ".ajax_cop [name=client_firstname]"); - let lastname = getClientTextOrValue(".ajax_cop .client_lastname_logg", ".ajax_cop [name=client_lastname]"); - const street = getClientTextOrValue(".ajax_cop .client_street_logg", ".ajax_cop [name=client_street]"); - const city = getClientTextOrValue(".ajax_cop .client_city_logg", ".ajax_cop [name=client_city]"); - const zipcode = getClientTextOrValue(".ajax_cop .client_zipcode_logg", ".ajax_cop [name=client_zipcode]"); - const phone = getClientTextOrValue(".ajax_cop .client_phone_logg", ".ajax_cop [name=client_phone]"); - const region = document.querySelector('.ajax_cop [name="client_region_logg"]') ? document.querySelector('.ajax_cop [name="client_region_logg"]').value : document.querySelector(".ajax_cop [name=client_region]").value; + const email = document.getElementById("client_email").value; + const phone = document.getElementById("client_phone").value; + const clientType = document.querySelector('.ajax_cop [name="client_type"]:checked').value; + const firmname = clientType === "firm" ? document.getElementById("client_firm").value : ""; + const nip = clientType === "firm" ? document.getElementById("client_nip").value : ""; + let firstname = document.getElementById("client_firstname").value; + let lastname = document.getElementById("client_lastname").value; + const street = document.getElementById("client_street").value; + const city = document.getElementById("client_city").value; + const zipcode = document.getElementById("client_zipcode").value; + const region = document.getElementById("client_region").value; + // Weź dane dostawy z innego adresu jeśli jest zaznaczone let deliveryFirstname, deliveryLastname, deliveryFirmName, deliveryStreet, deliveryCity, deliveryZipcode, deliveryPhone, deliveryRegion; if (document.getElementById("deliver_to_billingaddr").checked){ - deliveryFirstname = document.querySelector(".ajax_cop [name=delivery_firstname]").value; - deliveryLastname = document.querySelector(".ajax_cop [name=delivery_lastname]").value; - deliveryFirmName = document.querySelector(".ajax_cop [name=delivery_additional]").value; - deliveryStreet = document.querySelector(".ajax_cop [name=delivery_street]").value; - deliveryCity = document.querySelector(".ajax_cop [name=delivery_city]").value; - deliveryZipcode = document.querySelector(".ajax_cop [name=delivery_zipcode]").value; - deliveryPhone = document.querySelector(".ajax_cop [name=delivery_phone]").value; - deliveryRegion = document.querySelector(".ajax_cop [name=delivery_region]").value; - } - // Informacje o newsletterze - let clientMailing; - if(document.querySelector(".ajax_cop [name=client_mailing_logg]")) clientMailing = document.querySelector(".ajax_cop [name=client_mailing_logg]").value ? 1 : 0; - else if(document.querySelector("#client_mailing")) clientMailing = document.querySelector("#client_mailing").checked ? 1 : 0; - else clientMailing = 0; + deliveryFirstname = document.getElementById("delivery_firstname").value; + deliveryLastname = document.getElementById("delivery_lastname").value; + deliveryFirmName = document.getElementById("delivery_additional").value; + deliveryStreet = document.getElementById("delivery_street").value; + deliveryCity = document.getElementById("delivery_city").value; + deliveryZipcode = document.getElementById("delivery_zipcode").value; + deliveryPhone = document.getElementById("delivery_phone").value; + deliveryRegion = document.getElementById("delivery_region").value; + }; + + // Informacje o newsletterze + const clientMailing = checkNewsletter("client_mailing_logg","#client_mailing"); + const clientSms = checkNewsletter("client_send_sms_logg", "#client_sms"); - let clientSms; - if(document.querySelector(".ajax_cop [name=client_send_sms_logg]")) clientSms = document.querySelector(".ajax_cop [name=client_send_sms_logg]").value ? 1 : 0; - else if(document.querySelector("#client_sms")) clientSms = document.querySelector("#client_sms").checked ? 1 : 0; - else clientSms = 0; // Kod rabatowy i kod vouchera let rebateCode; - if (document.querySelector("#active-code")) rebateCode = document.querySelector("#active-code").innerHTML; + if (document.getElementById("active-code")) rebateCode = document.getElementById("active-code").innerHTML; else rebateCode = ""; let voucherCode; - if(document.querySelector(".ajax_cop #payitem_2") && document.querySelector(".ajax_cop #payitem_2").checked) voucherCode = document.querySelector(".ajax_cop #order_voucher_id").value + if(document.querySelector(".ajax_cop #payitem_2") && document.querySelector(".ajax_cop #payitem_2").checked) voucherCode = document.querySelector(".ajax_cop #order_voucher_id").value; + // Jeśli zalogowany użytkownik jest firmą i nie ma imienia i nazwiska - if (document.querySelector('.ajax_cop [name="client_type_logg"]') && document.querySelector('.ajax_cop [name="client_type_logg"]').value === "firm") { + if (clientType.disabled && clientType.value === "firm") { if (!firstname) firstname = (deliveryFirstname) ? deliveryFirstname : 'Klient'; if (!lastname) lastname = (deliveryLastname) ? deliveryLastname : 'Firma'; } + // czyszczenie imienia i nazwiska ze znaków specjalnych firstname = firstname.replace(/[&\/\\#,+()$~%.'":*?<>{}!@~`^_]/g, ""); lastname = lastname.replace(/[&\/\\#,+()$~%.'":*?<>{}!@~`^_]/g, ""); + // dodatkowe informacje (uwagi, faktura, punkt odbioru) - const shopRemarks = document.querySelector("#shop_remarks").checked ? document.querySelector(".ajax_cop [name=remarks]").value : ""; - const deliveryRemarks = document.querySelector("#courier_remarks").checked ? document.querySelector(".ajax_cop [name=deliverer_remarks]").value : ""; + const shopRemarks = document.getElementById("shop_remarks").checked ? document.querySelector(".ajax_cop [name=remarks]").value : ""; + const deliveryRemarks = document.getElementById("courier_remarks").checked ? document.querySelector(".ajax_cop [name=deliverer_remarks]").value : ""; const invoiceOption = document.querySelector("input[name=invoice]:checked").value; const pickuppoint = document.querySelector("#osc_order1 input:checked").dataset.pickuppoint === "y" ? document.querySelector("#osc_order1 input:checked").parentElement.querySelector("label [name=pickup_point]").value : ""; @@ -1678,10 +1772,22 @@ function createOrder(deliveryMethod, paymentMethod){ delivery_remarks: deliveryRemarks, }, }; + // złóż zamówienie jako zalogowany/niezalogowany użytkownik. - if (document.querySelector(".client_biling_data")) sendOrder(order); + if (document.querySelector(".--logged")) sendOrder(order); else { - const clientData = new FormData($("form#client_new_form").get(0)); + const clientData = new FormData(); + if(firmname) clientData.append("client_firm", firmname); + if(nip) clientData.append("client_nip", nip); + clientData.append("client_firstname", firstname); + clientData.append("client_lastname", lastname); + clientData.append("client_street", street); + clientData.append("client_zipcode", zipcode); + clientData.append("client_city", city); + clientData.append("client_region", region); + clientData.append("client_email", email); + clientData.append("client_phone", phone); + $.ajax({ url: "/client-new.php?operation=onceorder", type: "POST", @@ -1700,9 +1806,11 @@ function createOrder(deliveryMethod, paymentMethod){ }); } } -// Funkcja wybierająca jako wartość tekst lub value -function getClientTextOrValue(textSelector, valueSelector){ - return document.querySelector(textSelector) ? document.querySelector(textSelector).innerHTML : document.querySelector(valueSelector).value + +function checkNewsletter(logged, regular){ + if(document.querySelector(`.ajax_cop [name=${logged}]`)) return document.querySelector(`.ajax_cop [name=${logged}]`).value ? 1 : 0; + else if(document.querySelector(regular)) return document.querySelector(regular).checked ? 1 : 0; + else return 0; } // Funkcja wysyłająca zamówienie function sendOrder(data){ @@ -1717,7 +1825,7 @@ function sendOrder(data){ }, success: function (e) { if(e.location){ - // // Zapisanie płatności i dostawy na następny raz + // Zapisanie płatności i dostawy na następny raz const paymentInput = document.querySelector(`input[name="payform_id"]:checked`) const usedPaymentMethod = { id: paymentInput.id, @@ -1737,11 +1845,12 @@ function sendOrder(data){ city: selectedPoint.dataset.city, courierId: selectedPoint.dataset.courierId } : false - } + }; localStorage.setItem("prevPaymentMethod", JSON.stringify(usedPaymentMethod)); localStorage.setItem("prevDeliveryMethod", JSON.stringify(usedDeliveryMethod)); + // Przeniesienie na stonę informacji o zamóieniu window.location.href = e.location; return; } @@ -1752,6 +1861,8 @@ function sendOrder(data){ }, }); } + +// REJESTRACJA KLIENTA const REGISTER_CLIENT = (registerClientInput) => JSON.stringify({ query: `mutation { registerClient(${registerClientInput}) { @@ -1768,11 +1879,12 @@ async function addClient(succes, error){ const clientType = document.querySelector("input[name=client_type]:checked").value; const saveToMailing = document.getElementById("client_mailing"); let saveToMailingData = false; - if(saveToMailing && saveToMailing.checked) saveToMailingData = true + if(saveToMailing && saveToMailing.checked) saveToMailingData = true; const saveToSms = document.getElementById("client_sms"); let saveToSmsData = false; if(saveToSms && saveToSms.checked) saveToSmsData = true; + const registerClientData = await fetchData({ data: REGISTER_CLIENT(`RegisterClientInput: { clientData: { @@ -1788,7 +1900,7 @@ async function addClient(succes, error){ } ${ document.getElementById("deliver_to_billingaddr").checked ? `clientDeliveryOtherAddressData: { - companyName: "${document.getElementById(".delivery_additional").value}", + companyName: "${document.getElementById("delivery_additional").value}", firstname: "${document.getElementById("delivery_firstname").value}", lastname: "${document.getElementById("delivery_lastname").value}", street: "${document.getElementById("delivery_street").value}", @@ -1799,7 +1911,7 @@ async function addClient(succes, error){ }` : "" } type: ${clientType}, - ${clientType === "firm" ? `taxNumberData: "${document.querySelector(".client_nip").value}",` : ""} + ${clientType === "firm" ? `taxNumber: "${document.getElementById("client_nip").value}",` : ""} email: "${document.getElementById("client_email").value}", saveToMailingAfterOrder: ${saveToMailingData}, saveToSmsAfterOrder: ${saveToSmsData}, @@ -1813,12 +1925,13 @@ async function addClient(succes, error){ }`), linkParameter: '?mutation=registerClient', }); - if(!registerClientData?.data?.registerClient?.error) succes(); + if(!registerClientData?.data?.registerClient?.error || registerClientData?.error?.message) succes(); else { - Alertek.show_alert(registerClientData.data.registerClient.error?.message) + Alertek.show_alert(registerClientData.data.registerClient.error?.message); app_shop.fn.ajaxLoadSite(0); } } + // Zmiana informacji formularza w url params function serializeFormData(form){ const formData = new FormData(form); @@ -1829,16 +1942,49 @@ function serializeFormData(form){ serializedString = serializedString.slice(0,-1); return serializedString; } + // Pokaz error (płatności, dostawy, zalozenie nowego konta) function orderValidationError(text){ app_shop.vars.validation = 0; Alertek.show_alert(`${text}`); } - /////////////////////////////////////////////////////////////////// // RESZTA -// Funkcja od paska ładowania + +// Wyłącz scrollowanie dla strony +function disablePageScroll(){ + const documentBody = document.querySelector("body"); + documentBody.style.paddingRight = `${15 + window.innerWidth - documentBody.clientWidth}px`; + documentBody.style.overflowY = "hidden"; +} +function enablePageScroll(){ + const documentBody = document.querySelector("body"); + documentBody.style.paddingRight = "15px"; + documentBody.style.overflowY = "auto"; +} + +// Zmiana funkcji by naprawić bugi +app_shop.fn.load = function(_url,target,callback,paramets) { + if(app_shop.vars.xhr && app_shop.vars.xhr.readystate != 4) app_shop.vars.xhr.abort(); + $(target).addClass('load-content'); + for(var i=0; target.length > i ; i++) $(target[i][0]).addClass('load-content'); + + app_shop.vars.xhr = $.ajax({ + url: _url+paramets, + timeout: 16000, + success: function(data,textStatus) { + for(var i=0; target.length > i ; i++) $(target[i][0]).removeClass('load-content').html($(data).find(target[i][1]).html()); + app_shop.fn.change_url(_url); + app_shop.fn.evalJSFromHtml(data); + if(callback) callback(); + }, + error: function(data) { + window.location.href = _url; + } + }); + return app_shop.vars.xhr; +}; function throwAjaxError(e) { -1 !== $.inArray(e, ["nocontent", "error", "timeout", "abort", "parsererror"]) && (console.log("Error:" + e), Alertek.show_alert( "Błąd podczas logowania, proszę spróbować ponownie" + " (" + e + ": " + $.now() + ")"), $.cookie("off_opc", !0)); }; @@ -1874,11 +2020,9 @@ async function fetchData(options = {}) { } // element z numerem edycji jeśli jest const editNumber = document.getElementById("edit-number"); -// Jeśli ajax_cop nie jest puste zlap za klienta (init) -if(document.querySelector(".ajax_cop").childElementCount && !editNumber){ - changeRegion(null, true); - changeCountryPaddingLeft(); -} + +if(document.querySelector(".ajax_cop").childElementCount && !editNumber) changeRegion(null, true); + // Jeśli edycja zamówienia uzupełnij dane (niewiadomo jak z voucherem bo go się nie da edytować) if(editNumber){ const ORDER_DETAILS = (orderNumber) => JSON.stringify({ @@ -1967,24 +2111,25 @@ if(editNumber){ requestSource: order_edit } `), - linkParameter: "?query=orderDetails" - }) - console.log(data); - if(!data?.data?.orderDetails) { - changeRegion(); - changeCountryPaddingLeft(); - return; - } + linkParameter: "?query=orderDetails", + alert: false, + }); + // Jesli error to zatrzymaj funkcje + if(!data?.data?.orderDetails) return changeRegion(); // Wstawienie danych insertEditData(data.data.orderDetails); - changeCountryPaddingLeft(); } function insertEditData(orderDetails){ + const orderData = { + paymentMethodId: orderDetails.payment.paymentMethod.id, + deliveryMethodId: orderDetails.shipping.courier.id, + pickupData: orderDetails.shipping.pickupData, + }; // Sprawdzenie czy użytkownik miał inny adres Dostawy niż Billingowy. let differentDelivery = false; for(const [key, value] of Object.entries(orderDetails.client.billingData)){ - if(key !== "taxNumber"){ + if(key !== "taxNumber" && key !== "companyName"){ if(value !== orderDetails.client.deliveryData[key]) differentDelivery = true; } } @@ -1996,36 +2141,24 @@ if(editNumber){ document.getElementById("deliver_to_billingaddr").checked = true; document.querySelector(".ajax_cop #client_new_additional .delivery_box.cn_wrapper").classList.add("--more"); document.querySelector(".delivery__address-list-button").classList.add("--fade-in"); - fillInput(document.querySelector("#delivery_firstname"), orderDetails.client.deliveryData.firstname); - fillInput(document.querySelector("#delivery_lastname"), orderDetails.client.deliveryData.lastname); - fillInput(document.querySelector("#delivery_street"), orderDetails.client.deliveryData.street); - fillInput(document.querySelector("#delivery_zipcode"), orderDetails.client.deliveryData.zipcode); - fillInput(document.querySelector("#delivery_city"), orderDetails.client.deliveryData.city); - fillInput(document.querySelector("#delivery_phone"), orderDetails.client.deliveryData.phone); - if(orderDetails.client.deliveryData.companyName) fillInput(document.querySelector("#delivery_additional"), orderDetails.client.deliveryData.companyName); - document.querySelectorAll("#delivery_region option").forEach(opt=>{ - if(opt.text === orderDetails.client.deliveryData.countryName) document.querySelector("#delivery_region").value = opt.value; + + fillInput(document.getElementById("delivery_firstname"), orderDetails.client.deliveryData.firstname); + fillInput(document.getElementById("delivery_lastname"), orderDetails.client.deliveryData.lastname); + fillInput(document.getElementById("delivery_street"), orderDetails.client.deliveryData.street); + fillInput(document.getElementById("delivery_zipcode"), orderDetails.client.deliveryData.zipcode); + fillInput(document.getElementById("delivery_city"), orderDetails.client.deliveryData.city); + fillInput(document.getElementById("delivery_phone"), orderDetails.client.deliveryData.phone); + + if(orderDetails.client.deliveryData.companyName) fillInput(document.getElementById("delivery_additional"), orderDetails.client.deliveryData.companyName); + document.querySelectorAll("#delivery_region option").forEach(opt => { + if(opt.text === orderDetails.client.deliveryData.countryName) document.getElementById("delivery_region").value = opt.value; }); // Metody płatności i dostaw - if(document.querySelector("#delivery_region").value !== document.querySelector(".client_region_logg input").value) changeRegion({ - paymentMethodId: orderDetails.payment.paymentMethod.id, - deliveryMethodId: orderDetails.shipping.courier.id, - pickupData: orderDetails.shipping.pickupData, - }) - else getNewPaymentsAndDeliveries({ - paymentMethodId: orderDetails.payment.paymentMethod.id, - deliveryMethodId: orderDetails.shipping.courier.id, - pickupData: orderDetails.shipping.pickupData, - }, true); + if(document.getElementById("delivery_region").value !== document.getElementById("client_region").value) changeRegion(orderData); + else getNewPaymentsAndDeliveries(orderData, true); // Jeśli nie było dostawy na inny adres uzupełnij metody dostaw i płatności - }else{ - getNewPaymentsAndDeliveries({ - paymentMethodId: orderDetails.payment.paymentMethod.id, - deliveryMethodId: orderDetails.shipping.courier.id, - pickupData: orderDetails.shipping.pickupData, - }, true); - } + }else getNewPaymentsAndDeliveries(orderData, true); // Uzupełnienie uwag dla sklepu/kuriera if(orderDetails.remarks){ @@ -2043,66 +2176,6 @@ if(editNumber){ function fillInput(input, value){ input.value = value; input.classList.add("focused"); - input.parentElement.classList.add("--success", "has-success") + input.parentElement.classList.add("--success", "has-success"); } -} - -// Zmiana paddingu dla kraju nowego klienta -function changeCountryPaddingLeft(){ - const containers = document.querySelectorAll(".form-group.--region"); - if(containers.length === 0) return; - - containers.forEach(cont=>{ - const newPaddingLeft = `${cont.querySelector("label").offsetWidth + 26}px!important` - cont.querySelector("select").setAttribute("style", `padding-left:${newPaddingLeft};`) - }) -} - -// Wyłącz scrollowanie dla strony -function disablePageScroll(){ - const documentBody = document.querySelector("body"); - documentBody.style.paddingRight = `${15 + window.innerWidth - documentBody.clientWidth}px`; - documentBody.style.overflowY = "hidden" -} -function enablePageScroll(){ - const documentBody = document.querySelector("body"); - documentBody.style.paddingRight = "15px" - documentBody.style.overflowY = "auto" -} - -// Zmiana funkcji by naprawić bugi -app_shop.fn.load = function(_url,target,callback,paramets) { - if(app_shop.vars.xhr && app_shop.vars.xhr.readystate != 4) app_shop.vars.xhr.abort(); - $(target).addClass('load-content'); - for(var i=0; target.length > i ; i++) $(target[i][0]).addClass('load-content'); - - app_shop.vars.xhr = $.ajax({ - url: _url+paramets, - timeout: 16000, - success: function(data,textStatus) { - for(var i=0; target.length > i ; i++) $(target[i][0]).removeClass('load-content').html($(data).find(target[i][1]).html()); - app_shop.fn.change_url(_url); - app_shop.fn.evalJSFromHtml(data); - if(callback) callback(); - }, - error: function(data) { - window.location.href = _url; - } - }); - return app_shop.vars.xhr; -}; // funkcja do zaladowania strony po load -// Przenoszenie do klikniętego elementu na mobilce/tablecie -// document.querySelector("body").addEventListener("click", e=>{ -// if(e.target.classList.contains("form-control") && (app_shop.vars.view===1 || app_shop.vars.view===2)){ -// // Jeśli element wyżej niż połowa ekranu(mniej więcej wielkość klawiatury na telefonie) nie scrolluj -// if(e.target.getBoundingClientRect().top < (screen.height/2)) return; -// e.target.scrollIntoView(); - -// document.querySelector("body").insertAdjacentHTML("afterend", `
`) -// } -// }) -// VisualViewport.addEventListener("resize", ()=>{ -// const h = event.target.height; -// const inputEl = document.querySelector("input.form-control:focus"); -// document.body.insertAdjacentHTML("afterend", `
height:${h}|el:${inputEl.getAttribute("name")}
`); -// }) \ No newline at end of file +} \ No newline at end of file