1 | 'use strict';
|
2 |
|
3 | const getConfirmation = (win, message, callback) => (callback(win.confirm(message)));
|
4 | const isModifiedEvent = (ev) => (ev.metaKey || ev.altKey || ev.ctrlKey || ev.shiftKey);
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | const supportsHistory = (win) => {
|
13 | const ua = win.navigator.userAgent;
|
14 | if ((ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) &&
|
15 | ua.indexOf('Mobile Safari') !== -1 &&
|
16 | ua.indexOf('Chrome') === -1 &&
|
17 | ua.indexOf('Windows Phone') === -1) {
|
18 | return false;
|
19 | }
|
20 | return win.history && 'pushState' in win.history;
|
21 | };
|
22 |
|
23 |
|
24 |
|
25 |
|
26 | const supportsPopStateOnHashChange = (nav) => (nav.userAgent.indexOf('Trident') === -1);
|
27 |
|
28 |
|
29 |
|
30 | const supportsGoWithoutReloadUsingHash = (nav) => (nav.userAgent.indexOf('Firefox') === -1);
|
31 | const isExtraneousPopstateEvent = (nav, event) => (event.state === undefined &&
|
32 | nav.userAgent.indexOf('CriOS') === -1);
|
33 | const storageAvailable = (win, type) => {
|
34 | const storage = win[type];
|
35 | const x = '__storage_test__';
|
36 | try {
|
37 | storage.setItem(x, x);
|
38 | storage.removeItem(x);
|
39 | return true;
|
40 | }
|
41 | catch (e) {
|
42 | return e instanceof DOMException && (
|
43 |
|
44 | e.code === 22 ||
|
45 |
|
46 | e.code === 1014 ||
|
47 |
|
48 |
|
49 | e.name === 'QuotaExceededError' ||
|
50 |
|
51 | e.name === 'NS_ERROR_DOM_QUOTA_REACHED') &&
|
52 |
|
53 | storage.length !== 0;
|
54 | }
|
55 | };
|
56 |
|
57 | exports.getConfirmation = getConfirmation;
|
58 | exports.isExtraneousPopstateEvent = isExtraneousPopstateEvent;
|
59 | exports.isModifiedEvent = isModifiedEvent;
|
60 | exports.storageAvailable = storageAvailable;
|
61 | exports.supportsGoWithoutReloadUsingHash = supportsGoWithoutReloadUsingHash;
|
62 | exports.supportsHistory = supportsHistory;
|
63 | exports.supportsPopStateOnHashChange = supportsPopStateOnHashChange;
|