MediaWiki:Mobile.js:修订间差异

imported>=海豚=
无编辑摘要
wth
标签移动版编辑 移动版网页编辑
 
(未显示3个用户的23个中间版本)
第1行: 第1行:
// <pre>
/* 这里的任何JavaScript将只在移动端加载 */
/* 这里的任何JavaScript将只在移动端加载 */
(function($, mw) { //使用匿名函数以避免污染顶级变量
(function($, mw) { //使用匿名函数以避免污染顶级变量
    /* capture支持检测 */
    var captureSupported = false;
    try {
        var options = Object.defineProperty({}, "capture", {
            get: function () {
                captureSupported = true;
                return true;
            },
        });
        window.addEventListener("test", null, options);
    } catch (err) { /* */ }
     /* 函数定义体 */
     /* 函数定义体 */
    //用户资料页相关
    function isUserProfile() {
        return mw.config.get('wgCanonicalSpecialPageName') === "UserProfile" && mw.config.get('wgArticleId') === "0";
    }
     //页顶提示模板相关
     //页顶提示模板相关
     function commonBoxs() {
     function commonBoxs() {
第62行: 第68行:
     });
     });
   };
   };
        //需要时载入对应的 scripts
        if (mw.config.get("wgAction") === "edit" || mw.config.get("wgAction") === "submit" || mw.config.get("wgCanonicalSpecialPageName") === "Search") { mw.loader.load("/index.php?title=MediaWiki:Common.js/edit.js&action=raw&ctype=text/javascript"); }
$(function(){mfSidebar();});
$(function(){mfSidebar();});
     /* 函数执行体 */
     /* 函数执行体 */
第67行: 第75行:
         //页顶提示模板相关
         //页顶提示模板相关
         commonBoxs();
         commonBoxs();
        //用户资料页
        if (isUserProfile()) {
            var cardContainer = $('.card-container'),
                containerImage = cardContainer.find('.card'),
                containerImageFile = containerImage.find('a.image'),
                containerImageCaption = containerImage.find('.caption');
            containerImageCaption.css("padding", "0 8px");
            containerImageFile.before('<div id="#containerImage" class="listThumb list-thumb-placeholder" style="text-align: center;"><img src="https://img.moegirl.org.cn/common/a/a4/Placeholder-upload.png" style="height:32px" /></div>');
        }
         //黑幕
         //黑幕
         $('.heimu a').on("click", function() {
         $('.heimu a').on("click", function() {
第85行: 第84行:
             $('.mw-collapsible').makeCollapsible();
             $('.mw-collapsible').makeCollapsible();
         });
         });
        //桌面版页面外链改为移动端域名
          // 桌面版页面外链改为移动端域名
        mw.loader.using("mediawiki.Uri").then(function() {
            document.body.addEventListener("click", function(e) {
            $('a[target="_blank"]').each(function() {
                e.path.forEach(function(ele) {
                var url = new mw.Uri(this.href);
                    if (ele instanceof HTMLAnchorElement) {
                if (url.host === "www.hmoegirl.com" && url.query.mobileaction !== "toggle_view_desktop") {
                        var url = new mw.Uri(ele.href);
                    url.host = "m.hmoegirl.com";
                        if (/www\.hmoegirl\.info?$/.test(url.host) && url.query.mobileaction !== "toggle_view_desktop") {
                    this.href = url;
                            url.host = mw.config.get("wgServer").replace(/^(?:(?:https?:)?\/\/)?www/, "m");
                 }
                            ele.href = url;
             });
                        }
        });
                    }
                 });
             }, captureSupported ? {
                capture: true,
            } : true);
     });
     });
})(jQuery, mediaWiki); //立即执行匿名函数并传递原始变量
})(jQuery, mediaWiki); //立即执行匿名函数并传递原始变量
//页顶加入选项控制
if( mw.config.get('wgNamespaceNumber') != 2){
spanobj=document.createElement("span");
srch=document.getElementById("page-actions");
srch.parentElement.insertBefore(spanobj,srch);
spanobj.innerHTML='<a href="#/talk">讨论</a> · <a href="' + mw.config.get('wgScript') + '?' + $.param({ title: mw.config.get('wgPageName'), action: 'info' }) +'">信息</a> · <a href="' + mw.config.get("wgServer") + mw.config.get("wgScriptPath") + '/特殊:链入页面/' + mw.config.get("wgPageName") + '">相关</a>';
}
// </pre>
// </pre>