| 1 |
|
| 2 |
* GoingsOn - Viewport / UI Mode Module |
| 3 |
* |
| 4 |
* Single source of truth for which UI mode the app is rendering. |
| 5 |
* Mode is set ONCE at boot by the inline detection script in index.html; |
| 6 |
* never changes at runtime. Code that wants to make layout decisions |
| 7 |
* (which DOM to render, which behavior path to take) should consult this |
| 8 |
* module instead of measuring window.innerWidth or sniffing user agents. |
| 9 |
* |
| 10 |
* Input-capability decisions (hover suppression, drag vs long-press) are |
| 11 |
* SEPARATE and live in GoingsOn.touch — do not collapse them into here. |
| 12 |
* |
| 13 |
* Dev override: set ?ui=mobile or ?ui=desktop in the URL, or run |
| 14 |
* localStorage.setItem('goingson.uiMode', 'mobile') |
| 15 |
* and reload. Production builds will eventually ignore these (phase 5). |
| 16 |
|
| 17 |
|
| 18 |
(function () { |
| 19 |
'use strict'; |
| 20 |
|
| 21 |
var mode = window.__GO_UI_MODE__ === 'mobile' ? 'mobile' : 'desktop'; |
| 22 |
|
| 23 |
GoingsOn.viewport = { |
| 24 |
mode: mode, |
| 25 |
isMobile: function () { return mode === 'mobile'; }, |
| 26 |
isDesktop: function () { return mode === 'desktop'; }, |
| 27 |
|
| 28 |
|
| 29 |
* Dev helper — set the UI mode override and reload. Available from |
| 30 |
* the JS console for testing. |
| 31 |
* @param {'mobile'|'desktop'|null} m - null clears the override |
| 32 |
|
| 33 |
setOverride: function (m) { |
| 34 |
if (m === null) { |
| 35 |
localStorage.removeItem('goingson.uiMode'); |
| 36 |
} else if (m === 'mobile' || m === 'desktop') { |
| 37 |
localStorage.setItem('goingson.uiMode', m); |
| 38 |
} else { |
| 39 |
return; |
| 40 |
} |
| 41 |
location.reload(); |
| 42 |
}, |
| 43 |
}; |
| 44 |
})(); |
| 45 |
|