forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopen-url.js
More file actions
62 lines (54 loc) · 1.36 KB
/
open-url.js
File metadata and controls
62 lines (54 loc) · 1.36 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
58
59
60
61
62
import Platform from '../plugins/Platform.js'
import { noop } from '../utils/event.js'
function parseFeatures (winFeatures) {
const cfg = Object.assign({ noopener: true }, winFeatures)
const feat = []
for (const key in cfg) {
if (cfg[ key ] === true) {
feat.push(key)
}
}
return feat.join(',')
}
function openWindow (url, reject, windowFeatures) {
let open = window.open
if (Platform.is.cordova === true) {
if (cordova !== void 0 && cordova.InAppBrowser !== void 0 && cordova.InAppBrowser.open !== void 0) {
open = cordova.InAppBrowser.open
}
else if (navigator !== void 0 && navigator.app !== void 0) {
return navigator.app.loadUrl(url, {
openExternal: true
})
}
}
const win = open(url, '_blank', parseFeatures(windowFeatures))
if (win) {
Platform.is.desktop && win.focus()
return win
}
else {
reject && reject()
}
}
export default (url, reject, windowFeatures) => {
if (
Platform.is.ios === true
&& window.SafariViewController !== void 0
) {
window.SafariViewController.isAvailable(available => {
if (available) {
window.SafariViewController.show(
{ url },
noop,
reject
)
}
else {
openWindow(url, reject, windowFeatures)
}
})
return
}
return openWindow(url, reject, windowFeatures)
}