Changeset View
Changeset View
Standalone View
Standalone View
src/resources/js/bootstrap.js
/** | /** | ||||
* We'll load jQuery and the Bootstrap jQuery plugin which provides support | * Import Cash (jQuery replacement) | ||||
* for JavaScript based Bootstrap features such as modals and tabs. This | |||||
* code may be modified to fit the specific needs of your application. | |||||
*/ | */ | ||||
window.Popper = require('popper.js').default | import $ from 'cash-dom' | ||||
window.$ = window.jQuery = require('jquery') | window.$ = $ | ||||
require('bootstrap') | $.fn.focus = function() { | ||||
if (this.length && this[0].focus) { | |||||
this[0].focus() | |||||
} | |||||
return this | |||||
} | |||||
/** | /** | ||||
* We'll load Vue, VueRouter and global components | * Load Vue, VueRouter and global components | ||||
*/ | */ | ||||
import { Tooltip } from 'bootstrap' | |||||
import FontAwesomeIcon from './fontawesome' | import FontAwesomeIcon from './fontawesome' | ||||
import Vue from 'vue' | import Vue from 'vue' | ||||
import VueRouter from 'vue-router' | import VueRouter from 'vue-router' | ||||
import Toast from '../vue/Widgets/Toast' | import Toast from '../vue/Widgets/Toast' | ||||
import store from './store' | import store from './store' | ||||
window.Vue = Vue | window.Vue = Vue | ||||
Vue.component('SvgIcon', FontAwesomeIcon) | Vue.component('SvgIcon', FontAwesomeIcon) | ||||
const vTooltip = (el, binding) => { | const vTooltip = (el, binding) => { | ||||
const t = [] | let t = [] | ||||
if (binding.modifiers.focus) t.push('focus') | if (binding.modifiers.focus) t.push('focus') | ||||
if (binding.modifiers.hover) t.push('hover') | if (binding.modifiers.hover) t.push('hover') | ||||
if (binding.modifiers.click) t.push('click') | if (binding.modifiers.click) t.push('click') | ||||
if (!t.length) t.push('hover') | if (!t.length) t.push('click') | ||||
$(el).tooltip({ | el.tooltip = new Tooltip(el, { | ||||
title: binding.value, | title: binding.value, | ||||
placement: binding.arg || 'top', | placement: binding.arg || 'top', | ||||
trigger: t.join(' '), | trigger: t.join(' '), | ||||
html: !!binding.modifiers.html, | html: !!binding.modifiers.html | ||||
}); | }) | ||||
} | } | ||||
Vue.directive('tooltip', { | Vue.directive('tooltip', { | ||||
bind: vTooltip, | bind: vTooltip, | ||||
update: vTooltip, | update: vTooltip, | ||||
unbind (el) { | unbind (el) { | ||||
$(el).tooltip('dispose') | el.tooltip.dispose() | ||||
} | } | ||||
}) | }) | ||||
Vue.use(Toast) | Vue.use(Toast) | ||||
Vue.use(VueRouter) | Vue.use(VueRouter) | ||||
let vueRouterBase = '/' | let vueRouterBase = '/' | ||||
Show All 10 Lines | window.router = new VueRouter({ | ||||
routes: window.routes, | routes: window.routes, | ||||
scrollBehavior (to, from, savedPosition) { | scrollBehavior (to, from, savedPosition) { | ||||
// Scroll the page to top, but not on Back action | // Scroll the page to top, but not on Back action | ||||
return savedPosition || { x: 0, y: 0 } | return savedPosition || { x: 0, y: 0 } | ||||
} | } | ||||
}) | }) | ||||
/** | /** | ||||
* We'll load the axios HTTP library which allows us to easily issue requests | * Load the axios HTTP library which allows us to easily issue requests | ||||
* to our Laravel back-end. This library automatically handles sending the | * to our Laravel back-end. This library automatically handles sending the | ||||
* CSRF token as a header based on the value of the "XSRF" token cookie. | * CSRF token as a header based on the value of the "XSRF" token cookie. | ||||
*/ | */ | ||||
window.axios = require('axios') | window.axios = require('axios') | ||||
axios.defaults.baseURL = vueRouterBase | axios.defaults.baseURL = vueRouterBase | ||||
axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest' | axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest' |