@apicart/vue-components
Version:
Apicart Vue.Js components for simple e-commerce platform development
8 lines (6 loc) • 7.02 kB
JavaScript
/**
* @apicart/vue-components v1.0.0-alpha7
* (c) 2018-2020 Apicart Company
* Released under the MIT License.
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("@apicart/core-sdk"),require("../.."),require("./..")):"function"==typeof define&&define.amd?define(["@apicart/core-sdk","../..","./.."],e):(t=t||self).ApicartDialog=e(t.Apicart,t.src,t.components)}(this,(function(t,e,o){"use strict";t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;let i=!1;if("undefined"!=typeof window){const t={get passive(){i=!0}};window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}const a="undefined"!=typeof window&&window.navigator&&window.navigator.platform&&(/iP(ad|hone|od)/.test(window.navigator.platform)||"MacIntel"===window.navigator.platform&&window.navigator.maxTouchPoints>1);let n,r,s=[],l=!1,d=-1;const c=t=>s.some(e=>!(!e.options.allowTouchMove||!e.options.allowTouchMove(t))),p=t=>{const e=t||window.event;return!!c(e.target)||(e.touches.length>1||(e.preventDefault&&e.preventDefault(),!1))},u=(t,e)=>{if(a){if(!t)return void console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.");if(t&&!s.some(e=>e.targetElement===t)){const o={targetElement:t,options:e||{}};s=[...s,o],t.ontouchstart=t=>{1===t.targetTouches.length&&(d=t.targetTouches[0].clientY)},t.ontouchmove=e=>{1===e.targetTouches.length&&((t,e)=>{const o=t.targetTouches[0].clientY-d;!c(t.target)&&(e&&0===e.scrollTop&&o>0||(t=>!!t&&t.scrollHeight-t.scrollTop<=t.clientHeight)(e)&&o<0?p(t):t.stopPropagation())})(e,t)},l||(document.addEventListener("touchmove",p,i?{passive:!1}:void 0),l=!0)}}else{(t=>{setTimeout(()=>{if(void 0===r){const e=!!t&&!0===t.reserveScrollBarGap,o=window.innerWidth-document.documentElement.clientWidth;e&&o>0&&(r=document.body.style.paddingRight,document.body.style.paddingRight=o+"px")}void 0===n&&(n=document.body.style.overflow,document.body.style.overflow="hidden")})})(e);const o={targetElement:t,options:e||{}};s=[...s,o]}},g=t=>{if(a){if(!t)return void console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.");t.ontouchstart=null,t.ontouchmove=null,s=s.filter(e=>e.targetElement!==t),l&&0===s.length&&(document.removeEventListener("touchmove",p,i?{passive:!1}:void 0),l=!1)}else s=s.filter(e=>e.targetElement!==t),s.length||setTimeout(()=>{void 0!==r&&(document.body.style.paddingRight=r,r=void 0),void 0!==n&&(document.body.style.overflow=n,n=void 0)})};var f={name:"apicart-dialog",i18n:(t.VueComponentsTranslator||e.Translator).getI18n(),components:{"apicart-button":"undefined"!=typeof window&&window.ApicartButton?window.ApicartButton:o.ApicartButton},props:{closeOnBgClick:{type:Boolean,default:!0},showTopCloseButton:{type:Boolean,default:!1}},data:function(){return{visible:!1}},methods:{open:function(){this.visible=!0,this.$emit("open"),u(this.$el,{reserveScrollBarGap:!0})},closeByClickOnBg:function(){this.closeOnBgClick&&this.close()},close:function(){this.visible=!1,this.$emit("close"),g(this.$el)},toggle:function(){this.visible?(this.close(),g(this.$el)):this.open()}}};!function(t,e){void 0===e&&(e={});var o=e.insertAt;if(t&&"undefined"!=typeof document){var i=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===o&&i.firstChild?i.insertBefore(a,i.firstChild):i.appendChild(a),a.styleSheet?a.styleSheet.cssText=t:a.appendChild(document.createTextNode(t))}}('.apicart-dialog{font-family:-apple-system,"Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Helvetica Neue",Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";-webkit-font-smoothing:antialiased;box-sizing:border-box;outline:0}.apicart-dialog *{box-sizing:border-box;outline:0}.apicart-dialog__mask{position:fixed;z-index:9998;top:0;left:0;width:100%;height:100%;background-color:rgba(0,0,0,.32);display:table;transition:opacity .3s ease}.apicart-dialog__wrapper{display:table-cell;vertical-align:middle}.apicart-dialog__container{position:relative;width:94vw;max-width:1000px;margin:0 auto;padding:12px 16px;background-color:#fff;border-radius:2px;box-shadow:0 11px 15px -7px rgba(0,0,0,.2),0 24px 38px 3px rgba(0,0,0,.14),0 9px 46px 8px rgba(0,0,0,.12);transition:all .3s ease;font-family:Helvetica,Arial,sans-serif}@media (min-width:768px){.apicart-dialog__container{padding:20px 30px}}.apicart-dialog__close-button{position:absolute;right:0;text-align:center;font-size:38px;cursor:pointer;width:60px;display:inline-block;line-height:60px;top:0}.apicart-dialog__header{margin-top:0}.apicart-dialog__title{font-size:34px}.apicart-dialog__body{margin:20px 0}.apicart-dialog__footer-default-button-wrapper{display:flex;justify-content:space-around}.apicart-dialog-enter{opacity:0}.apicart-dialog-leave-active{opacity:0}.apicart-dialog-enter .apicart-dialog-container,.apicart-dialog-leave-active .apicart-dialog-container{-webkit-transform:scale(1.1);transform:scale(1.1)}');return function(t,e,o,i,a,n,r,s,l,d){"boolean"!=typeof r&&(l=s,s=r,r=!1);const c="function"==typeof o?o.options:o;let p;if(t&&t.render&&(c.render=t.render,c.staticRenderFns=t.staticRenderFns,c._compiled=!0,a&&(c.functional=!0)),i&&(c._scopeId=i),n?(p=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),e&&e.call(this,l(t)),t&&t._registeredComponents&&t._registeredComponents.add(n)},c._ssrRegister=p):e&&(p=r?function(t){e.call(this,d(t,this.$root.$options.shadowRoot))}:function(t){e.call(this,s(t))}),p)if(c.functional){const t=c.render;c.render=function(e,o){return p.call(o),t(e,o)}}else{const t=c.beforeCreate;c.beforeCreate=t?[].concat(t,p):[p]}return o}({render:function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("transition",{attrs:{name:"apicart-dialog"}},[o("div",{directives:[{name:"show",rawName:"v-show",value:t.visible,expression:"visible"}],staticClass:"apicart-dialog apicart-dialog__mask"},[o("div",{staticClass:"apicart-dialog__wrapper",on:{click:t.closeByClickOnBg}},[o("div",{staticClass:"apicart-dialog__container",on:{click:function(t){t.stopPropagation()}}},[t._t("default",[o("div",{staticClass:"apicart-dialog__header"},[t._t("header")],2),o("div",{staticClass:"apicart-dialog__body"},[t._t("body")],2),o("div",{staticClass:"apicart-dialog__footer"},[t._t("footer",[o("div",{staticClass:"apicart-dialog__footer-default-button-wrapper"},[t._t("footer-buttons",[o("apicart-button",{attrs:{type:"outlined"},nativeOn:{click:function(e){return t.close(e)}}},[t._v(" "+t._s(t.$t("dialog.okButton"))+" ")])])],2)])],2)]),t.showTopCloseButton?o("a",{staticClass:"apicart-dialog__close-button",attrs:{role:"button"},on:{click:t.close}},[o("span",{staticClass:"apicart-icon-x"})]):t._e()],2)])])])},staticRenderFns:[]},void 0,f,void 0,!1,void 0,!1,void 0,void 0,void 0)}));