Skip to content

Commit 3708e01

Browse files
committed
Updates for plugins (including Platform)
1 parent 46c9e1f commit 3708e01

File tree

5 files changed

+30
-37
lines changed

5 files changed

+30
-37
lines changed

src/install.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,16 @@ export default function (_Vue, opts = {}) {
2626
this.installed = true
2727

2828
setVue(_Vue)
29-
ready(addBodyClasses)
3029

3130
const Quasar = {
3231
version,
3332
theme: __THEME__
3433
}
3534

35+
// required plugin
36+
Platform.install({ Quasar })
37+
ready(addBodyClasses)
38+
3639
if (opts.directives) {
3740
Object.keys(opts.directives).forEach(key => {
3841
const d = opts.directives[key]
@@ -50,9 +53,6 @@ export default function (_Vue, opts = {}) {
5053
})
5154
}
5255
if (opts.plugins) {
53-
// required plugin
54-
Platform.install({ Quasar })
55-
5656
Object.keys(opts.plugins).forEach(key => {
5757
const p = opts.plugins[key]
5858
if (typeof p.install === 'function') {

src/plugins.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import AddressbarColor from './plugins/addressbar-color'
22
import AppFullscreen from './plugins/app-fullscreen'
33
import AppVisibility from './plugins/app-visibility'
44
import Cookies from './plugins/cookies'
5-
import Cordova from './plugins/cordova'
65
import Platform from './plugins/platform'
76
import { LocalStorage, SessionStorage } from './plugins/web-storage'
87

@@ -11,7 +10,6 @@ export {
1110
AppFullscreen,
1211
AppVisibility,
1312
Cookies,
14-
Cordova,
1513
Platform,
1614
LocalStorage,
1715
SessionStorage

src/plugins/cordova.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/plugins/platform.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,19 +164,19 @@ function getPlatform () {
164164
}
165165

166166
const Platform = {
167-
is: getPlatform(),
168-
has: {
169-
touch: (() => !!('ontouchstart' in document.documentElement) || window.navigator.msMaxTouchPoints > 0)()
170-
},
171-
within: {
172-
iframe: window.self !== window.top
173-
},
174-
175167
__installed: false,
176168
install ({ Quasar }) {
177169
if (this.__installed) { return }
178170
this.__installed = true
179171

172+
Platform.is = getPlatform()
173+
Platform.has = {
174+
touch: (() => !!('ontouchstart' in document.documentElement) || window.navigator.msMaxTouchPoints > 0)()
175+
}
176+
Platform.within = {
177+
iframe: window.self !== window.top
178+
}
179+
180180
Quasar.platform = Platform
181181
}
182182
}

src/utils/escape-key.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,31 @@ import Platform from '../plugins/platform'
22

33
let handlers = []
44

5-
if (Platform.is.desktop) {
6-
window.addEventListener('keyup', evt => {
7-
if (handlers.length === 0) {
8-
return
9-
}
5+
export default {
6+
__installed: false,
7+
__install () {
8+
this.__installed = true
9+
window.addEventListener('keyup', evt => {
10+
if (handlers.length === 0) {
11+
return
12+
}
1013

11-
if (evt.which === 27 || evt.keyCode === 27) {
12-
handlers[handlers.length - 1]()
13-
}
14-
})
15-
}
14+
if (evt.which === 27 || evt.keyCode === 27) {
15+
handlers[handlers.length - 1]()
16+
}
17+
})
18+
},
1619

17-
export default {
1820
register (handler) {
1921
if (Platform.is.desktop) {
22+
if (!this.__installed) {
23+
this.__install()
24+
}
25+
2026
handlers.push(handler)
2127
}
2228
},
29+
2330
pop () {
2431
if (Platform.is.desktop) {
2532
handlers.pop()

0 commit comments

Comments
 (0)