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') | ||||
import AppComponent from '../vue/App' | import AppComponent from '../vue/App' | ||||
import MenuComponent from '../vue/Widgets/Menu' | import MenuComponent from '../vue/Widgets/Menu' | ||||
import SupportForm from '../vue/Widgets/SupportForm' | import SupportForm from '../vue/Widgets/SupportForm' | ||||
import store from './store' | import store from './store' | ||||
import { loadLangAsync, i18n } from './locale' | |||||
const loader = '<div class="app-loader"><div class="spinner-border" role="status"><span class="sr-only">Loading</span></div></div>' | const loader = '<div class="app-loader"><div class="spinner-border" role="status"><span class="sr-only">Loading</span></div></div>' | ||||
let isLoading = 0 | let isLoading = 0 | ||||
// Lock the UI with the 'loading...' element | // Lock the UI with the 'loading...' element | ||||
const startLoading = () => { | const startLoading = () => { | ||||
isLoading++ | isLoading++ | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | window.router.afterEach((to, from) => { | ||||
// When changing a page remove old: | // When changing a page remove old: | ||||
// - error page | // - error page | ||||
// - modal backdrop | // - modal backdrop | ||||
$('#error-page,.modal-backdrop.show').remove() | $('#error-page,.modal-backdrop.show').remove() | ||||
}) | }) | ||||
const app = new Vue({ | const app = new Vue({ | ||||
el: '#app', | |||||
components: { | components: { | ||||
AppComponent, | AppComponent, | ||||
MenuComponent, | MenuComponent, | ||||
}, | }, | ||||
i18n, | |||||
store, | store, | ||||
router: window.router, | router: window.router, | ||||
data() { | data() { | ||||
return { | return { | ||||
isAdmin: window.isAdmin, | isAdmin: window.isAdmin, | ||||
appName: window.config['app.name'], | appName: window.config['app.name'], | ||||
appUrl: window.config['app.url'], | appUrl: window.config['app.url'], | ||||
themeDir: '/themes/' + window.config['app.theme'] | themeDir: '/themes/' + window.config['app.theme'] | ||||
▲ Show 20 Lines • Show All 281 Lines • ▼ Show 20 Lines | methods: { | ||||
// Add 'class' attribute to the body, different for each page | // Add 'class' attribute to the body, different for each page | ||||
// so, we can apply page-specific styles | // so, we can apply page-specific styles | ||||
let className = 'page-' + (name || this.pageName()).replace(/\/.*$/, '') | let className = 'page-' + (name || this.pageName()).replace(/\/.*$/, '') | ||||
$(document.body).removeClass().addClass(className) | $(document.body).removeClass().addClass(className) | ||||
} | } | ||||
} | } | ||||
}) | }) | ||||
// Fetch the locale file and the start the app | |||||
loadLangAsync().then(() => app.$mount('#app')) | |||||
// Add a axios request interceptor | // Add a axios request interceptor | ||||
window.axios.interceptors.request.use( | window.axios.interceptors.request.use( | ||||
config => { | config => { | ||||
// This is the only way I found to change configuration options | // This is the only way I found to change configuration options | ||||
// on a running application. We need this for browser testing. | // on a running application. We need this for browser testing. | ||||
config.headers['X-Test-Payment-Provider'] = window.config.paymentProvider | config.headers['X-Test-Payment-Provider'] = window.config.paymentProvider | ||||
return config | return config | ||||
▲ Show 20 Lines • Show All 96 Lines • Show Last 20 Lines |