PageSourceSearch

https://figureskatingdreams.com/assets/js/orientation-policy.js?v=20260924orientation3

js figureskatingdreams.com collected 2026-10-06 23:51:17 UTC 3,931 bytes, 109 lines download raw bytes

1(function () {
2  "use strict";
3
4  // Meteorflix orientation policy:
5  // - App/site shell: portrait-first / portrait-locked where the platform allows it.
6  // - Video fullscreen: handled separately by player-orientation.js and may lock landscape.
7  // - Never rotate the DOM with CSS transforms and never show a "rotate your phone" overlay.
8
9  var portraitRequestInFlight = false;
10
11  function isCoarseMobile() {
12    try {
13      if (window.matchMedia && window.matchMedia("(pointer: coarse)").matches) return true;
14    } catch (e) {}
15    return /Android|iPhone|iPad|iPod|Mobile/i.test(String(navigator.userAgent || ""));
16  }
17
18  function isStandaloneLike() {
19    try {
20      if (window.matchMedia && window.matchMedia("(display-mode: standalone)").matches) return true;
21    } catch (e) {}
22    return !!navigator.standalone;
23  }
24
25  function anyFullscreenElement() {
26    return document.fullscreenElement || document.webkitFullscreenElement || null;
27  }
28
29  function playerFullscreenActive() {
30    return !!window.__mfPlayerFullscreenOrientationActive || !!anyFullscreenElement();
31  }
32
33  function ensurePortraitHints() {
34    try {
35      document.documentElement.setAttribute("data-mf-orientation-policy", "portrait-shell");
36      var names = ["screen-orientation", "x5-orientation"];
37      names.forEach(function (name) {
38        var meta = document.querySelector('meta[name="' + name + '"]');
39        if (!meta) {
40          meta = document.createElement("meta");
41          meta.setAttribute("name", name);
42          (document.head || document.documentElement).appendChild(meta);
43        }
44        meta.setAttribute("content", "portrait");
45      });
46    } catch (e) {}
47  }
48
49  function requestPortrait() {
50    if (!isCoarseMobile()) return Promise.resolve(false);
51    if (playerFullscreenActive()) return Promise.resolve(false);
52    if (portraitRequestInFlight) return Promise.resolve(false);
53
54    // The Web App Manifest is the reliable shell lock for installed PWA mode.
55    // In normal browser tabs Screen Orientation lock can be rejected by the browser;
56    // this call is intentionally best-effort and silent.
57    try {
58      if (!screen.orientation || typeof screen.orientation.lock !== "function") {
59        return Promise.resolve(false);
60      }
61      portraitRequestInFlight = true;
62      var result = screen.orientation.lock("portrait-primary");
63      if (result && typeof result.then === "function") {
64        return result.then(function () {
65          portraitRequestInFlight = false;
66          return true;
67        }).catch(function () {
68          portraitRequestInFlight = false;
69          return false;
70        });
71      }
72      portraitRequestInFlight = false;
73      return Promise.resolve(true);
74    } catch (e) {
75      portraitRequestInFlight = false;
76      return Promise.resolve(false);
77    }
78  }
79
80  function syncShellOrientation() {
81    if (playerFullscreenActive()) return;
82    requestPortrait();
83  }
84
85  ensurePortraitHints();
86
87  // Installed/PWA mode gets the strongest lock from manifest + this best-effort API request.
88  // Browser tabs are not forcibly rotated; if the browser refuses the lock, Meteorflix does
89  // not counter-rotate the page or display an intrusive rotate prompt.
90  if (isStandaloneLike()) requestPortrait();
91  else requestPortrait();
92
93  window.addEventListener("orientationchange", function () {
94    window.setTimeout(syncShellOrientation, 80);
95  }, { passive: true });
96
97  window.addEventListener("pageshow", syncShellOrientation, { passive: true });
98  document.addEventListener("visibilitychange", function () {
99    if (!document.hidden) syncShellOrientation();
100  });
101  document.addEventListener("fullscreenchange", syncShellOrientation, false);
102  document.addEventListener("webkitfullscreenchange", syncShellOrientation, false);
103
104  window.MeteorOrientationPolicy = {
105    requestPortrait: requestPortrait,
106    sync: syncShellOrientation,
107    isStandaloneLike: isStandaloneLike
108  };
109})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.