Changeset View
Changeset View
Standalone View
Standalone View
src/resources/js/app.js
/** | /** | ||||
* First we will load all of this project's JavaScript dependencies which | * First we will load all of this project's JavaScript dependencies which | ||||
* includes Vue and other libraries. It is a great starting point when | * includes Vue and other libraries. It is a great starting point when | ||||
* building robust, powerful web applications using Vue and Laravel. | * building robust, powerful web applications using Vue and Laravel. | ||||
*/ | */ | ||||
require('./bootstrap') | require('./bootstrap') | ||||
window.Vue = require('vue') | |||||
import AppComponent from '../vue/App' | import AppComponent from '../vue/App' | ||||
import MenuComponent from '../vue/Menu' | import MenuComponent from '../vue/Menu' | ||||
import router from './routes' | import router from './routes' | ||||
import store from './store' | import store from './store' | ||||
import FontAwesomeIcon from './fontawesome' | import FontAwesomeIcon from './fontawesome' | ||||
import VueToastr from '@deveodk/vue-toastr' | import VueToastr from '@deveodk/vue-toastr' | ||||
window.Vue = require('vue') | |||||
Vue.component('svg-icon', FontAwesomeIcon) | Vue.component('svg-icon', FontAwesomeIcon) | ||||
Vue.use(VueToastr, { | Vue.use(VueToastr, { | ||||
defaultPosition: 'toast-bottom-right', | defaultPosition: 'toast-bottom-right', | ||||
defaultTimeout: 5000 | defaultTimeout: 5000 | ||||
}) | }) | ||||
const vTooltip = (el, binding) => { | |||||
const t = [] | |||||
if (binding.modifiers.focus) t.push('focus') | |||||
if (binding.modifiers.hover) t.push('hover') | |||||
if (binding.modifiers.click) t.push('click') | |||||
if (!t.length) t.push('hover') | |||||
$(el).tooltip({ | |||||
title: binding.value, | |||||
placement: binding.arg || 'top', | |||||
trigger: t.join(' '), | |||||
html: !!binding.modifiers.html, | |||||
}); | |||||
} | |||||
Vue.directive('tooltip', { | |||||
bind: vTooltip, | |||||
update: vTooltip, | |||||
unbind (el) { | |||||
$(el).tooltip('dispose') | |||||
} | |||||
}) | |||||
// Add a response interceptor for general/validation error handler | // Add a response interceptor for general/validation error handler | ||||
// This have to be before Vue and Router setup. Otherwise we would | // This have to be before Vue and Router setup. Otherwise we would | ||||
// not be able to handle axios responses initiated from inside | // not be able to handle axios responses initiated from inside | ||||
// components created/mounted handlers (e.g. signup code verification link) | // components created/mounted handlers (e.g. signup code verification link) | ||||
window.axios.interceptors.response.use( | window.axios.interceptors.response.use( | ||||
response => { | response => { | ||||
// Do nothing | // Do nothing | ||||
return response | return response | ||||
▲ Show 20 Lines • Show All 156 Lines • ▼ Show 20 Lines | methods: { | ||||
errorHandler(error) { | errorHandler(error) { | ||||
this.stopLoading() | this.stopLoading() | ||||
if (error.response.status === 401) { | if (error.response.status === 401) { | ||||
this.logoutUser() | this.logoutUser() | ||||
} else { | } else { | ||||
this.errorPage(error.response.status, error.response.statusText) | this.errorPage(error.response.status, error.response.statusText) | ||||
} | } | ||||
}, | |||||
price(price) { | |||||
return (price/100).toLocaleString('en', { style: 'currency', currency: 'CHF' }) | |||||
} | } | ||||
} | } | ||||
}) | }) |