Difference between revisions of "MediaWiki:Group-moderator.js"

From Team Fortress Wiki
Jump to: navigation, search
m (Fix "addPortletLink" sometimes returning undefined because of being called before the DOM is loaded (Tark pls))
m (Add 'collapsible' class to Purge link)
 
Line 5: Line 5:
 
     init: function() {
 
     init: function() {
 
         if (mw.config.get("wgIsArticle")) {
 
         if (mw.config.get("wgIsArticle")) {
             mw.util.addPortletLink("p-views",
+
             var purgeBtn = mw.util.addPortletLink("p-views",
 
                 mw.util.wikiScript() + "?" + $.param({ title: mw.config.get("wgPageName"), action: "purge" }),
 
                 mw.util.wikiScript() + "?" + $.param({ title: mw.config.get("wgPageName"), action: "purge" }),
 
                 "Purge",
 
                 "Purge",
Line 11: Line 11:
 
                 "Purge the server cache of this page"
 
                 "Purge the server cache of this page"
 
             );
 
             );
 +
            // Add the 'collapsible' class to the Purge button to move it to the "More >" dropdown when the screen size is reduced. (rare MW win)
 +
            purgeBtn.classList.add("collapsible");
 
         }
 
         }
 
     }
 
     }

Latest revision as of 15:16, 5 September 2023

/* Any JavaScript here will be loaded for moderators only */

// Begin Purge link
var purgeLink = {
    init: function() {
        if (mw.config.get("wgIsArticle")) {
            var purgeBtn = mw.util.addPortletLink("p-views",
                mw.util.wikiScript() + "?" + $.param({ title: mw.config.get("wgPageName"), action: "purge" }),
                "Purge",
                "ca-purge",
                "Purge the server cache of this page"
            );
            // Add the 'collapsible' class to the Purge button to move it to the "More >" dropdown when the screen size is reduced. (rare MW win)
            purgeBtn.classList.add("collapsible");
        }
    }
};
$(purgeLink.init);
// End Purge link