「MediaWiki:Mobile.js」の版間の差分

提供: Vikipedia
ナビゲーションに移動 検索に移動
タグ: モバイル編集モバイルウェブ編集
タグ: モバイル編集モバイルウェブ編集
1行目: 1行目:
 
(function () {
 
(function () {
     var mobileStartup = "mobile.startup";
+
     var startup = mw.mobileFrontend.require("mobile.startup");
 +
    if (startup.mediaViewer) {
 +
        console.info("No longer needed 'mediaViewer' polyfill.");
 +
        return;
 +
    }
 +
 
 
     var mobileMediaViewer = "mobile.mediaViewer";
 
     var mobileMediaViewer = "mobile.mediaViewer";
    var modules = [mobileStartup, mobileMediaViewer];
 
    mw.loader.load(modules);
 
  
     mw.loader
+
     var patch = function () {
        .using(modules)
+
        startup.mediaViewer = {
        .then(function () {
+
             overlay: mw.mobileFrontend.require(mobileMediaViewer + "/ImageOverlay")
            var startup = mfModules[mobileStartup];
+
        }
             if (startup.mediaViewer) {
+
    };
                console.info("No longer needed 'mediaViewer' polyfill.");
 
                return;
 
            }
 
  
            var overlay = mw.mobileFrontend.require(mobileMediaViewer + "/ImageOverlay");
+
    var state = mw.loader.getState(mobileMediaViewer);
             startup.mediaViewer = {
+
    switch (state) {
                 overlay: overlay
+
        case "ready":
             };
+
            patch();
         });
+
             break;
 +
        case "registered":
 +
            mw.loader
 +
                .using(mobileMediaViewer)
 +
                 .then(patch);
 +
             break;
 +
         default:
 +
            startup
 +
                .rlModuleLoader
 +
                .loadModule(mobileMediaViewer)
 +
                .then(patch);
 +
    }
 
})();
 
})();
  

2019年8月27日 (火) 00:20時点における版

(function () {
    var startup = mw.mobileFrontend.require("mobile.startup");
    if (startup.mediaViewer) {
        console.info("No longer needed 'mediaViewer' polyfill.");
        return;
    }

    var mobileMediaViewer = "mobile.mediaViewer";

    var patch = function () {
        startup.mediaViewer = {
            overlay: mw.mobileFrontend.require(mobileMediaViewer + "/ImageOverlay")
        }
    };

    var state = mw.loader.getState(mobileMediaViewer);
    switch (state) {
        case "ready":
            patch();
            break;
        case "registered":
            mw.loader
                .using(mobileMediaViewer)
                .then(patch);
            break;
        default:
            startup
                .rlModuleLoader
                .loadModule(mobileMediaViewer)
                .then(patch);
    }
})();

(function () {
    var disableMobileUI = false
        || window.localStorage.getItem("disableMobileUI")
        || window.sessionStorage.getItem("disableMobileUI")
    if (disableMobileUI) {
        return;
    }

    var wgScript = mw.config.get("wgScript");

    var builderURL = wgScript
        + "?"
        + new URLSearchParams({
            title: "MediaWiki:MobileUI.js",
            action: "raw",
            ctype: "text/javascript"
        })
        .toString();

    var builderThread = mw.loader
        .getScript(builderURL)
        .then(function () {
            return new MobileUIBuilder(mw)
                .prebuild();
        });

    var dataURL = wgScript
        + "?"
        + new URLSearchParams({
            title: "MediaWiki:MobileUI.json",
            action: "raw",
            ctype: "application/json"
        })
        .toString();

    var dataThread = $
        .getJSON(dataURL)
        .then(Object);

    $
        .when(builderThread, dataThread)
        .done(function (builder, data) {
            builder.build(data);
        });
})();