forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.js
More file actions
57 lines (49 loc) · 1.35 KB
/
install.js
File metadata and controls
57 lines (49 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import Platform from './features/platform'
import { installEvents } from './features/events'
import { version } from '../package.json'
import { setVue } from './deps'
import { ready } from './utils/dom'
import './polyfills'
function addBodyClasses () {
const cls = [
__THEME__,
Platform.is.desktop ? 'desktop' : 'mobile',
Platform.has.touch ? 'touch' : 'no-touch',
`platform-${Platform.is.ios ? 'ios' : 'mat'}`
]
Platform.within.iframe && cls.push('within-iframe')
Platform.is.cordova && cls.push('cordova')
Platform.is.electron && cls.push('electron')
document.body.classList.add.apply(document.body.classList, cls)
}
export default function (_Vue, opts = {}) {
if (this.installed) {
return
}
this.installed = true
setVue(_Vue)
ready(addBodyClasses)
if (opts.directives) {
Object.keys(opts.directives).forEach(key => {
let d = opts.directives[key]
if (d.name !== undefined && !d.name.startsWith('q-')) {
_Vue.directive(d.name, d)
}
})
}
if (opts.components) {
Object.keys(opts.components).forEach(key => {
let c = opts.components[key]
if (c.name !== undefined && c.name.startsWith('q-')) {
_Vue.component(c.name, c)
}
})
}
const events = installEvents(_Vue)
_Vue.prototype.$q = {
version,
platform: Platform,
theme: __THEME__,
events
}
}