-
/**
* First we will load all of this project's JavaScript dependencies which
* includes Vue and other libraries. It is a great starting point when
require('./bootstrap');
require('./menu');
+require('../../vendor/cubist/cms-back/src/public/emailobfuscator/emailobfuscator');
window.Vue = require('vue');
window.eventBus = new Vue();
import PortalVue from 'portal-vue';
+
Vue.use(PortalVue);
/**
el: '#app',
data: {
- items: {}, // Populated from data attribute on root element so we can pass data from PHP
+ items: {}, // Populated from data attribute on root element so we can pass data from PHP
},
beforeMount() {
- this.items = JSON.parse(this.$el.dataset.cartItems);
+ this.items = JSON.parse(this.$el.dataset.cartItems);
},
mounted() {
},
computed: {
- cartItemCount() {
- // Todo: See if this should count just number of items or make a sum of all quantities? What is more useful? The sum of quantities can be found using map/reduce functions but this needs to be adapted for the object structure using Object.keys as the source.
- return Object.keys(this.items).length;
- },
-
- cartData() {
- return JSON.stringify(this.items.reduce((obj, item) => Object.assign(obj, { [item.id]: item.quantity }), {}));
- }
+ cartItemCount() {
+ // Todo: See if this should count just number of items or make a sum of all quantities? What is more useful? The sum of quantities can be found using map/reduce functions but this needs to be adapted for the object structure using Object.keys as the source.
+ return Object.keys(this.items).length;
+ },
+
+ cartData() {
+ return JSON.stringify(this.items.reduce((obj, item) => Object.assign(obj, {[item.id]: item.quantity}), {}));
+ }
},
methods: {
- saveCart(data) {
- let root = this;
-
- axios.post('/ajax/cart', data)
- .then(function(response) {
- //console.log('Cart updated');
- //console.table(response.data);
- root.items = response.data;
- })
- .catch(function(error) {
- console.error('Error saving cart!', error);
- });
- },
-
- openCart() {
- document.body.classList.add('cart-open');
- },
- closeCart() {
- document.body.classList.remove('cart-open');
- },
+ saveCart(data) {
+ let root = this;
+
+ axios.post('/ajax/cart', data)
+ .then(function (response) {
+ //console.log('Cart updated');
+ //console.table(response.data);
+ root.items = response.data;
+ })
+ .catch(function (error) {
+ console.error('Error saving cart!', error);
+ });
+ },
+
+ openCart() {
+ document.body.classList.add('cart-open');
+ },
+ closeCart() {
+ document.body.classList.remove('cart-open');
+ },
}
-
});
-