Difference between revisions of "MediaWiki:Common.js"

From Wikimedia District of Columbia
Jump to navigation Jump to search
(minor tweaks)
(Hide first heading when using color bar heading)
Line 1: Line 1:
/* Sidebar modifications for anonymous users */
+
/* Interface modifications for anonymous users */
   
 
function removeSidebarSection(section) {
 
function removeSidebarSection(section) {
Line 24: Line 24:
 
addOnloadHook(customizeTopbarForAnon);
 
addOnloadHook(customizeTopbarForAnon);
 
}
 
}
  +
  +
/* Hide the default page heading on pages using the color bar heading format */
  +
  +
function removeFirstHeading() {
  +
if ($("div.colorbar").length) {
  +
document.getElementById("firstHeading").className += " nodisplay";
  +
document.getElementById("contentSub").className += " nodisplay";
  +
}
  +
}
  +
  +
addOnloadHook(removeFirstHeading);
   
 
/* Add a membership payment button */
 
/* Add a membership payment button */

Revision as of 23:00, 21 April 2013

/* Interface modifications for anonymous users */

function removeSidebarSection(section) {
  try {
    var target = "p-" + section;
    var sidebar = document.getElementById("mw-panel");
    var element = document.getElementById(target);
    sidebar.removeChild(element);
  } catch (e) {
    return;
   }
}

function customizeSidebarForAnon() {
  removeSidebarSection("tb");
}

function customizeTopbarForAnon() {
  mw.util.addPortletLink( 'p-personal', '/wiki/Membership', 'Join now', 'pt-join', 'Join Wikimedia DC and help support our mission!', 'j', '#pt-createaccount' );
}

if (wgUserName == null) {
  addOnloadHook(customizeSidebarForAnon);
  addOnloadHook(customizeTopbarForAnon);
}

/* Hide the default page heading on pages using the color bar heading format */

function removeFirstHeading() {
    if ($("div.colorbar").length) {
        document.getElementById("firstHeading").className += " nodisplay";
        document.getElementById("contentSub").className += " nodisplay";
    }
}

addOnloadHook(removeFirstHeading);

/* Add a membership payment button */
if ( ( mw.config.get('wgPageName') == 'Membership' ) && ( wgNamespaceNumber == 0 ) ) {
  $('#membershipbutton').html('<form action="https://www.paypal.com/cgi-bin/webscr" method="post"><input type="hidden" name="cmd" value="_s-xclick"><input type="hidden" name="hosted_button_id" value="R9RT2GWXZZWXL"><table><tr><td><input type="hidden" name="on0" value="Donation Options"></td></tr><tr><td><select name="os0"><option value="Regular Membership">Regular Membership : $10.00 USD - yearly</option><option value="Bronze Sponsor">Bronze Sponsor : $25.00 USD - yearly</option><option value="Silver Sponsor">Silver Sponsor : $50.00 USD - yearly</option><option value="Gold Sponsor">Gold Sponsor : $100.00 USD - yearly</option></select></td></tr></table><input type="hidden" name="currency_code" value="USD"><input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"><img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"></form>');
}

/* Add a donate button */
if ( ( mw.config.get('wgPageName') == 'Donate' ) && ( wgNamespaceNumber == 0 ) ) {
  $('#donatebutton').html('<form action="https://www.paypal.com/cgi-bin/webscr" method="post"><input type="hidden" name="cmd" value="_s-xclick"><input type="hidden" name="hosted_button_id" value="PSCZL9L3NKNRQ"><input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"><img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"></form>');
}

/* Add a few links to the toolbox */
addOnloadHook(function() {
  mw.util.addPortletLink( 'p-tb', '/wiki/Internal:Dashboard', 'Dashboard', 't-dashboard', 'Dashboard ', 'r', '#t-whatlinkshere' );
  mw.util.addPortletLink( 'p-tb', '/wiki/Special:RecentChanges', 'Recent changes', 't-recentchanges', 'Recent changes ', 'r', '#t-recentchangeslinked' );
  mw.util.addPortletLink( 'p-tb', '/wiki/Special:AllPages', 'All pages', 't-allpages', 'All pages ', 'p', '#t-recentchanges' );
});