Difference between revisions of "MediaWiki:Common.js"

From Wikimedia District of Columbia
Jump to navigation Jump to search
(Working)
(Working)
Line 49: Line 49:
 
viewPortTag.id="viewport";
 
viewPortTag.id="viewport";
 
viewPortTag.name = "viewport";
 
viewPortTag.name = "viewport";
viewPortTag.content = "width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;";
+
viewPortTag.content = "width=320; initial-scale=0.5; maximum-scale=0.5; user-scalable=1;";
 
document.getElementsByTagName('head')[0].appendChild(viewPortTag);
 
document.getElementsByTagName('head')[0].appendChild(viewPortTag);

Revision as of 05:42, 6 June 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);
}

/* Add a membership payment button */
if ( ( mw.config.get('wgPageName') == 'Membership' ) ) {
  $('#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"><input type="hidden" name="on0" value="Donation Options"><input type="hidden" name="currency_code" value="USD"><div style="padding-bottom:0.3em;"><span style="padding-right:0.5em;"><input type="image" src="http://wikimediadc.org/w/images/3/38/Payment_button_-_10.png" border="0" name="os0" value="Regular Membership" alt="Member dues: $10 per year"></span><span style="padding-right:0.5em;"><input type="image" src="http://wikimediadc.org/w/images/9/99/Payment_button_-_25.png" border="0" name="os0" value="Bronze Sponsor" alt="Member dues with Bronze Sponsorship: $25 per year"></span><span style="padding-right:0.5em;"><input type="image" src="http://wikimediadc.org/w/images/e/ec/Payment_button_-_50.png" border="0" name="os0" value="Silver Sponsor" alt="Member dues with Silver Sponsorship: $50 per year"></span><span><input type="image" src="http://wikimediadc.org/w/images/1/1d/Payment_button_-_100.png" border="0" name="os0" value="Gold Sponsor" alt="Member dues with Gold Sponsorship: $100 per year"></span></div></form>');
}

/* Add donation buttons */
if ( ( mw.config.get('wgPageName') == 'Donate' ) ) {
  var formId = 'donateform';
  $('#donatebutton').html('<div class="plainlinks"><form id="donateform10" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top"><input type="hidden" name="cmd" value="_s-xclick"><input type="hidden" name="hosted_button_id" value="S7YX2BAZDVSAE"><a href="#" onclick="document.getElementById(formId + 10).submit()"><span class="btn btn-large btn-primary" style="width:60px; color:white !important; font-size:200% !important;">$10</span></a></form><div style="padding: 0.3em;"></div><form id="donateform25" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top"><input type="hidden" name="cmd" value="_s-xclick"><input type="hidden" name="hosted_button_id" value="J3RV9PVMSRH8Y"><a href="#" onclick="document.getElementById(formId + 25).submit()"><span class="btn btn-large btn-primary" style="width:60px; color:white !important; font-size:200% !important;">$25</span></a></form><div style="padding: 0.3em;"></div><form id="donateform50" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top"><input type="hidden" name="cmd" value="_s-xclick"><input type="hidden" name="hosted_button_id" value="3E66M99JDV836"><a href="#" onclick="document.getElementById(formId + 50).submit()"><span class="btn btn-large btn-primary" style="width:60px; color:white !important; font-size:200% !important;">$50</span></a></form><div style="padding: 0.3em;"></div><form id="donateform100" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top"><input type="hidden" name="cmd" value="_s-xclick"><input type="hidden" name="hosted_button_id" value="GNEQ7GUKNF9BS"><a href="#" onclick="document.getElementById(formId + 100).submit()"><span class="btn btn-large btn-primary" style="width:60px; color:white !important; font-size:200% !important;">$100</span></a></form><div style="padding: 0.3em;"></div><form id="donateform200" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top"><input type="hidden" name="cmd" value="_s-xclick"><input type="hidden" name="hosted_button_id" value="BU3YMWQSVJ9HW"><a href="#" onclick="document.getElementById(formId + 200).submit()"><span class="btn btn-large btn-primary" style="width:60px; color:white !important; font-size:200% !important;">$200</span></a></form></div>');
}


/* 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' );
});

/* For mobile devices */

var viewPortTag=document.createElement('meta');
viewPortTag.id="viewport";
viewPortTag.name = "viewport";
viewPortTag.content = "width=320; initial-scale=0.5; maximum-scale=0.5; user-scalable=1;";
document.getElementsByTagName('head')[0].appendChild(viewPortTag);