silverstripe-webpack/app/client/dist/js/app_SilverShop.Page.CheckoutPageController.js
2020-12-28 06:37:21 +07:00

1 line
12 KiB
JavaScript

!function(){"use strict";var e={609:function(e){e.exports=jQuery}},t={};function __webpack_require__(o){if(t[o])return t[o].exports;var n=t[o]={exports:{}};return e[o](n,n.exports,__webpack_require__),n.exports}__webpack_require__.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=function(e,t){for(var o in t)__webpack_require__.o(t,o)&&!__webpack_require__.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},__webpack_require__.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){var e=__webpack_require__(609),t=__webpack_require__.n(e),o="ajax-load",n="load",r="map-loaded",a="map-api-loaded",i="map-marker-click",s="map-popup-close";function _typeof(e){return(_typeof="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function _typeof(e){return typeof e}:function _typeof(e){return e&&"function"===typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _defineProperties(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(e,t){return e.__proto__=t,e})(e,t)}function _createSuper(e){var t=function _isNativeReflectConstruct(){if("undefined"===typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"===typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function _createSuperInternal(){var o,n=_getPrototypeOf(e);if(t){var r=_getPrototypeOf(this).constructor;o=Reflect.construct(n,arguments,r)}else o=n.apply(this,arguments);return _possibleConstructorReturn(this,o)}}function _possibleConstructorReturn(e,t){return!t||"object"!==_typeof(t)&&"function"!==typeof t?_assertThisInitialized(e):t}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _getPrototypeOf(e){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var c={init:function init(){return function(e){!function _inherits(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&_setPrototypeOf(e,t)}(GoogleMapsHtmlOverlay,google.maps.OverlayView);var o=_createSuper(GoogleMapsHtmlOverlay);function GoogleMapsHtmlOverlay(e){var t;!function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,GoogleMapsHtmlOverlay);var n=_assertThisInitialized(t=o.call(this));return n.setMap(e.map),n.position=e.position,n.html=e.html?e.html:'<div class="mapboxgl-marker"><i class="marker-icon fas fa-map-marker-alt"></i></div>',n.divClass=e.divClass,n.align=e.align,n.isDebugMode=e.debug,n.onClick=e.onClick,n.onMouseOver=e.onMouseOver,n.isBoolean=function(e){return"boolean"===typeof e},n.isNotUndefined=function(e){return"undefined"!==typeof e},n.hasContent=function(e){return e.length>0},n.isString=function(e){return"string"===typeof e},n.isFunction=function(e){return"function"===typeof e},t}return function _createClass(e,t,o){return t&&_defineProperties(e.prototype,t),o&&_defineProperties(e,o),e}(GoogleMapsHtmlOverlay,[{key:"onAdd",value:function onAdd(){var e=this;e.div=document.createElement("div"),e.div.style.position="absolute",e.isNotUndefined(e.divClass)&&e.hasContent(e.divClass)&&(e.div.className=e.divClass),e.isNotUndefined(e.html)&&e.hasContent(e.html)&&e.isString(e.html)&&(e.div.innerHTML=e.html),e.isBoolean(e.isDebugMode)&&e.isDebugMode&&(e.div.className="debug-mode",e.div.innerHTML='<div style="height: 10px; width: 10px; background: red; border-radius: 100%;"></div><div style="position: absolute; top: 5px; padding: 5px; width: 130px; text-align: center; font-size: 18px; text-transform: uppercase; font-weight: bolder; background: red; color: white; font-family: Arial;">Debug mode</div>',e.div.setAttribute("style","position: absolute;border: 5px dashed red;height: 150px;width: 150px;display: flex;justify-content: center;align-items: center;")),e.getPanes().overlayMouseTarget.appendChild(e.div),google.maps.event.addDomListener(e.div,"click",(function(t){google.maps.event.trigger(e,"click"),e.isFunction(e.onClick)&&e.onClick(),t.stopPropagation()})),google.maps.event.addDomListener(e.div,"mouseover",(function(t){google.maps.event.trigger(e,"mouseover"),e.isFunction(e.onMouseOver)&&e.onMouseOver(),t.stopPropagation()}))}},{key:"draw",value:function draw(){var e=this,o=t()(e.div).find(".mapboxgl-marker,.marker-pin,.mapboxgl-popup,.popup");o.length||(o=t()(e.div));var n=e.getProjection().fromLatLngToDivPixel(new google.maps.LatLng(e.position)),r={y:void 0,x:void 0},a=o.outerWidth(),i=o.outerHeight();switch(Array.isArray(e.align)?e.align.join(" "):""){case"left top":r.y=i,r.x=a;break;case"left center":r.y=i/2,r.x=a;break;case"left bottom":r.y=0,r.x=a;break;case"center top":r.y=i,r.x=a/2;break;case"center center":r.y=i/2,r.x=a/2;break;case"center bottom":r.y=0,r.x=a/2;break;case"right top":r.y=i,r.x=0;break;case"right center":r.y=i/2,r.x=0;break;case"right bottom":r.y=0,r.x=0;break;default:r.y=i/2,r.x=a/2}e.div.style.top="".concat(n.y-r.y,"px"),e.div.style.left="".concat(n.x-r.x,"px")}},{key:"getPosition",value:function getPosition(){return this.position}},{key:"getDiv",value:function getDiv(){return this.div}},{key:"setPosition",value:function setPosition(e,t){var o=this;o.position=e,o.align=t,o.draw()}}]),GoogleMapsHtmlOverlay}()}};function _map_google_defineProperties(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var $,l={ENVS:["xs","sm","md","lg","xl","xxl","xxxl"],MAP_DRIVER:($=t(),function(){function GoogleMapsDriver(){!function _map_google_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,GoogleMapsDriver)}return function _map_google_createClass(e,t,o){return t&&_map_google_defineProperties(e.prototype,t),o&&_map_google_defineProperties(e,o),e}(GoogleMapsDriver,[{key:"getName",value:function getName(){return"GoogleMapsDriver"}},{key:"init",value:function init(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],o=this,n=window;o.$el=e,o.config=t,o.markers=[],n["init".concat(o.getName())]=function(){o.googleApiLoaded()},$("body").append('<script async defer src="https://maps.googleapis.com/maps/api/js?key='.concat(t.key,"&callback=init").concat(o.getName(),'"><\/script>'))}},{key:"googleApiLoaded",value:function googleApiLoaded(){var e=this,t=e.$el,o=e.config,n=t.find(".mapAPI-map"),r=o.mapZoom?o.mapZoom:10,i=o.center?{lat:o.center[1],lng:o.center[0]}:{lat:0,lng:0},s=o.style?o.style:null;console.log("".concat(e.getName(),": API is loaded")),e.MarkerUI=c.init($),e.map=new google.maps.Map(n[0],{zoom:r,center:i,fullscreenControl:!0,styles:s}),e.default_zoom=r,n.addClass("mapboxgl-map"),e.popup=new e.MarkerUI({map:e.map,align:["center","top"],divClass:"mapboxgl-popup popup mapboxgl-popup-anchor-bottom d-none",html:'<div class="mapboxgl-popup-tip"></div><div class="mapboxgl-popup-content"><div class="mapboxgl-popup-close-button" type="button" aria-label="Close popup">\xd7</div><div class="html"></div></div>'}),e.geocoder=new google.maps.Geocoder,t.trigger(a)}},{key:"addMarker",value:function addMarker(e,t){var o=this,n={lat:e[1],lng:e[0]},r=new o.MarkerUI({position:n,map:o.map,align:["center","top"],html:'<div class="mapboxgl-marker"><div id="Marker'.concat(t.id,'" data-id="').concat(t.id,'" class="marker">').concat(t.icon,"</div></div>"),onClick:function onClick(){var e=$("#Marker".concat(t.id));o.showPopup(n,t.content),e.trigger(i)}});return o.markers.push(r),r}},{key:"showPopup",value:function showPopup(e,t){var o=this,n=$(o.popup.getDiv());o.config.flyToMarker&&(o.map.setCenter(e),o.config.noZoom||o.map.setZoom(18)),n.css({opacity:"0"}),n.removeClass("d-none"),n.find(".mapboxgl-popup-content .html").html(t),n.find(".mapboxgl-popup-close-button").on("click",(function(e){e.preventDefault(),o.hidePopup()})),o.popup.setPosition(e,["center","top"]),n.css({"margin-top":"-1rem",opacity:"1"})}},{key:"hidePopup",value:function hidePopup(){var e=this;$(e.popup.getDiv()).addClass("d-none"),e.config.noRestoreBounds&&!e.config.flyToBounds||e.restoreBounds(),e.$el.trigger(s)}},{key:"geocode",value:function geocode(e,t){var o=this;o.geocoder.geocode({address:e},(function(e,n){if("OK"===n)return"function"===typeof t&&t(e),e;console.error("".concat(o.getName(),": Geocode was not successful for the following reason: ").concat(n))}))}},{key:"reverseGeocode",value:function reverseGeocode(e,t){var o=this;o.geocoder.geocode({location:latlng},(function(e,n){if("OK"===n)return"function"===typeof t&&t(e),e;console.error("".concat(o.getName(),": Reverse Geocoding was not successful for the following reason: ").concat(n))}))}},{key:"addGeoJson",value:function addGeoJson(e){var t=this,o=(e.geojson.features[0].geometry.coordinates,new google.maps.LatLngBounds);e.geojson.features.forEach((function(n){var r=n.id,a=n.geometry.coordinates,i=n.properties.content;t.addMarker(a,{id:r,content:i,icon:n.icon,flyToMarker:e.flyToMarker}),o.extend({lat:a[1],lng:a[0]})})),t.markers.length>1?t.map.fitBounds(o,{padding:30}):t.markers[0]&&t.map.setCenter(t.markers[0].getPosition()),t.default_bounds=o,t.default_zoom=t.map.getZoom()}},{key:"getMap",value:function getMap(){return this.map}},{key:"getPopup",value:function getPopup(){return this.popup}},{key:"restoreBounds",value:function restoreBounds(){var e=this;e.default_bounds&&e.markers.length>1?e.map.fitBounds(e.default_bounds,{padding:30}):(e.markers[0]&&e.map.setCenter(e.markers[0].getPosition()),e.restoreZoom())}},{key:"restoreZoom",value:function restoreZoom(){this.map.setZoom(this.default_zoom)}}]),GoogleMapsDriver}())},jQuery=__webpack_require__(609);function _ui_map_api_defineProperties(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}!function($){var e="jsMapAPI",t=e,i=$("body"),s=l.MAP_DRIVER,c=window,p=function(){function MapAPI(o){!function _ui_map_api_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,MapAPI);var n=this,c=new s;n.$el=$(o);var l=n.$el,p=l.data();p.center=[p.lng?p.lng:i.data("default-lng"),p.lat?p.lat:i.data("default-lat")],p.style=p.style?jQuery.parseJSON(p.style):null,p["font-family"]=i.css("font-family"),p.icon||(p.icon='<i class="fas fa-map-marker-alt"></i>'),console.log("".concat(e,": init ").concat(c.getName(),"...")),c.init(l,p),n.drv=c,l.on(a,(function(o){if(n.map=c.getMap(),p.geojson)console.log("".concat(e,": setting up geocode data")),c.addGeoJson(p);else if(p.address)console.log(p.address),console.log("".concat(e,": setting up address marker")),c.geocode(p.address,(function(t){console.log(t);var o=t[0].geometry.location.lat(),r=t[0].geometry.location.lng();console.log("".concat(e,": setting up single lat/lng marker lat: ").concat(o," lng: ").concat(r)),c.addMarker([r,o],p),n.map.setCenter({lat:o,lng:r})}));else if(p.lat&&p.lng){var a=p.lat,i=p.lng;console.log("".concat(e,": setting up single lat/lng marker lat: ").concat(a," lng: ").concat(i)),c.addMarker([i,a],p)}l.data(t,n),l.addClass("".concat(e,"-active")),l.trigger(r),console.log("".concat(e,": Map is loaded"))}))}return function _ui_map_api_createClass(e,t,o){return t&&_ui_map_api_defineProperties(e.prototype,t),o&&_ui_map_api_defineProperties(e,o),e}(MapAPI,[{key:"getMap",value:function getMap(){return ui.map}},{key:"dispose",value:function dispose(){var o=this;o.$el=null,$.removeData(o.$el[0],t),o.$el.removeClass("".concat(e,"-active"))}}],[{key:"_jQueryInterface",value:function _jQueryInterface(){var e=this;if("undefined"!==typeof c.localStorage)return this.each((function(){var o=$(e),n=o.data(t);n||(n=new MapAPI(e),o.data(t,n))}))}}]),MapAPI}();$.fn[e]=p._jQueryInterface,$.fn[e].Constructor=p,$.fn[e].noConflict=function(){return $.fn[e]=JQUERY_NO_CONFLICT,p._jQueryInterface},$(c).on("".concat(o," ").concat(n),(function(){$(".mapAPI-map-container").jsMapAPI()}))}(t())}()}();