MediaWiki:Centralnotice-template-B15 0323 enUS mob b

From Meta, a Wikimedia project coordination wiki

<script> /* MediaWiki:FR2014/Resources/SeenCountB.js

* Track the total number of banners the user has seen
* DEPRECATED: better to use impression diet campaign mixin for this now
*/

(function(mw) {

   var cookieCount = parseInt($.cookie('centralnotice_bannercount_fr15')) || 0;

   if(!mw.centralNotice.bannerData.hideResult) {
       cookieCount += 1;
   }

   $.cookie('centralnotice_bannercount_fr15', cookieCount, { expires: 365, path: '/' });
   mw.centralNotice.bannerData.cookieCount = cookieCount;

})(mediaWiki); /** Provides alterImpressionData hook for CentralNotice

*  This info will be sent back with Special:RecordImpression
*/

mediaWiki.centralNotice.bannerData.alterImpressionData = function( impressionData ) {

   // Returning true from this function indicates the banner was shown
   if (mediaWiki.centralNotice.bannerData.hideReason) {
       impressionData.reason = mediaWiki.centralNotice.bannerData.hideReason;
   }
   if (mediaWiki.centralNotice.bannerData.cookieCount) {
       impressionData.banner_count = mediaWiki.centralNotice.bannerData.cookieCount;
   }
   
   return !mediaWiki.centralNotice.bannerData.hideResult;

}; </script>

<style>

  1. centralNotice.collapsed #{{{banner}}}{
   display: none;

}

.overlay-enabled #{{{banner}}} {

   display: none;

}

  1. {{{banner}}} {
   background: #ffcc00;
   width: 100%;
   z-index: 100;
   top: 0;
   left: 0;

}

  1. {{{banner}}}-main {
   padding: 8px;
   cursor: pointer;

}

.{{{banner}}}-expanded {

   bottom: 0;

}

  1. {{{banner}}}-message {
   margin-right: 22px;
   text-align: justify;

}

.{{{banner}}}-highlight {

   background: yellow;
   padding: 1px 1px;

}

div#{{{banner}}} span.{{{banner}}}-close {

   position: absolute;
   background: url(//upload.wikimedia.org/wikipedia/donate/1/1e/Small-black-close.png) no-repeat center center;
   display: block;
   width: 30px;
   height: 30px;
   right: 0;
   top: 0;
   cursor: pointer;
   z-index: 999;

}

  1. {{{banner}}} fieldset {
   border: 0;
   margin: 0;
   padding: 0;

}

  1. {{{banner}}} #donate-amount-buttons,
  2. {{{banner}}} #donate-payment-buttons {
   margin: 0 0 4px 16px;

}

  1. {{{banner}}} .donate-button {
   display: inline-block;
   font-size: 16px;
   color: #fff;
   background: #7E7E7E;
   border: 2px solid #fff;
   border-radius: 8px;
   padding: 2px 0;
   white-space: nowrap;
   cursor: pointer;
   width: 100%;
   margin: 2px 0;
   text-align: center;

}

  1. {{{banner}}} #donate-payment-buttons .donate-button {
 text-transform: uppercase;

}

  1. {{{banner}}} #donate-amount-buttons input[type="radio"] {
   display: none;

}

  1. {{{banner}}} #donate-amount-buttons input[type="radio"]:checked + label,
  2. {{{banner}}} #donate-payment-buttons button:active {
   background-color: #bbb !important;
   border-color: #0645ad !important;

}

  1. {{{banner}}} .donate-legal-text {
   font-size: smaller;
   line-height: 1;
   position: absolute;
   bottom: 0;
   padding: 4px 8px;

}

.{{{banner}}}-arrow {

   width: 20px;
   height: 20px;
   display: inline-block;

} .{{{banner}}}-arrow-down {

   background: url(//upload.wikimedia.org/wikipedia/donate/f/f1/Circle-down-arrow.png) no-repeat;

} .{{{banner}}}-arrow-up {

   background: url(//upload.wikimedia.org/wikipedia/donate/d/d1/Circle-up-arrow.png) no-repeat;

}

.ban-col-1-3, .ban-col-1-1 {

   float: left;
   -webkit-box-sizing: border-box;
   -moz-box-sizing: border-box;
   box-sizing: border-box;

}

.ban-col-1-3 {

   width: 33.3%;

}

.ban-col-1-1 {

   width: 100%;

}

[class*='ban-col-'] {

   padding-right: 16px;

}

@media only screen and (min-height: 500px) {

   /* iPhone 5 or larger */
   #{{{banner}}} .donate-button {
       font-size: 20px;
       padding: 8px 0;
       margin: 4px 0;
   }
   #B14_0324_enUS_mob_b #donate-amount-buttons,
   #B14_0324_enUS_mob_b #donate-payment-buttons {
       margin: 0 0 16px 16px;
   }

} </style>

<script> /**

* NOTE: The following currency mapping is WMF-specific based on payment
* provider availability, NOT necessarily the official currency of the country
*/

function getCurrency() {

   switch(Geo.country) {
       // Big 5 at the top for speed
       case "US": return "USD";
       case "CA": return "CAD";
       case "GB": return "GBP";
       case "AU": return "AUD";
       case "NZ": return "NZD";
       // Euro countries
       case "AD":
       case "AL":
       case "AM":
       case "AT":
       case "AW":
       case "AZ":
       case "BE":
       case "BY":
       case "CI":
       case "CY":
       case "DE":
       case "EE":
       case "ES":
       case "FI":
       case "FR":
       case "GF":
       case "GR":
       case "IE":
       case "IT":
       case "LT":
       case "LU":
       case "LV":
       case "LY":
       case "MC":
       case "ME":
       case "MG":
       case "MT":
       case "NL":
       case "PT":
       case "RE":
       case "RS":
       case "SI":
       case "SK":
       case "SM":
       case "SR":
       case "VA":
           return "EUR";
       // The rest
       case "AE": return "AED";
       case "AR": return "ARS";
       case "BA": return "BAM";
       case "BB": return "BBD";
       case "BD": return "BDT";
       case "BG": return "BGN";
       case "BH": return "BHD";
       case "BM": return "BMD";
       case "BO": return "BOB";
       case "BR": return "BRL";
       case "BZ": return "BZD";
       case "CH": return "CHF";
       case "CK": return "NZD";
       case "CL": return "CLP";
       case "CN": return "CNY";
       case "CO": return "COP";
       case "CR": return "CRC";
       case "CZ": return "CZK";
       case "DK": return "DKK";
       case "DO": return "DOP";
       case "DZ": return "DZD";
       case "EG": return "EGP";
       case "FJ": return "FJD";
       case "FO": return "DKK";
       case "GL": return "DKK";
       case "GT": return "GTQ";
       case "HK": return "HKD";
       case "HN": return "HNL";
       case "HR": return "HRK";
       case "HU": return "HUF";
       case "ID": return "IDR";
       case "IL": return "ILS";
       case "IN": return "INR";
       case "IS": return "ISK";
       case "JM": return "JMD";
       case "JO": return "JOD";
       case "JP": return "JPY";
       case "KE": return "KES";
       case "KI": return "AUD";
       case "KR": return "KRW";
       case "KZ": return "KZT";
       case "LB": return "LBP";
       case "LI": return "CHF";
       case "LK": return "LKR";
       case "MA": return "MAD";
       case "MK": return "MKD";
       case "MV": return "MVR";
       case "MW": return "GBP";
       case "MX": return "MXN";
       case "MY": return "MYR";
       case "NI": return "NIO";
       case "NO": return "NOK";
       case "NP": return "INR";
       case "NR": return "AUD";
       case "OM": return "OMR";
       case "PA": return "PAB";
       case "PE": return "PEN";
       case "PG": return "AUD";
       case "PH": return "PHP";
       case "PK": return "PKR";
       case "PL": return "PLN";
       case "PY": return "PYG";
       case "QA": return "QAR";
       case "RO": return "RON";
       case "RU": return "RUB";
       case "SA": return "SAR";
       case "SD": return "GBP";
       case "SE": return "SEK";
       case "SG": return "SGD";
       case "TH": return "THB";
       case "TM": return "RUB";
       case "TN": return "TND";
       case "TR": return "TRY";
       case "TT": return "TTD";
       case "TW": return "TWD";
       case "UA": return "UAH";
       case "UY": return "UYU";
       case "UZ": return "RUB";
       case "VE": return "VEF";
       case "VN": return "VND";
       case "VU": return "AUD";
       case "ZA": return "ZAR";
       // small multi-country currencies
       case "CW":
       case "SX":
           return "ANG";
       case "AG":
       case "DM":
       case "GD":
       case "KN":
       case "LC":
           return "XCD";
       case "BJ":
       case "BF":
       case "CI":
       case "GW":
       case "ML":
       case "NE":
       case "SN":
       case "TG":
           return "XOF";
       case "PF":
       case "NC":
       case "WF":
           return "XPF";
       // fall back to USD
       default:
           return "USD";
   }

} </script> <script> function getMinimum(currency){

   var minimums = {
       'ADF' : 5.95,
       'ADP' : 150.87,
       'AED' : 3.67,
       'AFA' : 60.47,
       'AFN' : 60.47,
       'ALL' : 124.74,
       'AMD' : 473.47,
       'ANG' : 1.82,
       'AOA' : 122.35,
       'AON' : 122.35,
       'ARS' : 14, // Astropay
       'ATS' : 12.48,
       'AUD' : 1.35,
       'AWG' : 1.79,
       'AZM' : 3926.19,
       'AZN' : 1.05,
       'BAM' : 1.77,
       'BBD' : 2,
       'BDT' : 76.04,
       'BEF' : 36.58,
       'BGL' : 1.77,
       'BGN' : 1.77,
       'BHD' : 0.37,
       'BIF' : 1599.65,
       'BMD' : 1,
       'BND' : 1.33,
       'BOB' : 6.71,
       'BRL' : 3.2,
       'BSD' : 0.99,
       'BTN' : 63.52,
       'BWP' : 9.89,
       'BYR' : 15378.7,
       'BZD' : 1.96,
       'CAD' : 1.27,
       'CDF' : 912.52,
       'CHF' : 0.95,
       'CLP' : 980, // Astropay
       'CNY' : 6.09,
       'COP' : 4000, // Astropay
       'CRC' : 523.08,
       'CUC' : 1,
       'CUP' : 23.15,
       'CVE' : 99.81,
       'CYP' : 0.53,
       'CZK' : 24.59,
       'DEM' : 1.77,
       'DJF' : 177.72,
       'DKK' : 6.77,
       'DOP' : 44.46,
       'DZD' : 99.04,
       'ECS' : 25588.54,
       'EEK' : 14.19,
       'EGP' : 7.81,
       'ESP' : 150.87,
       'ETB' : 20.5,
       'EUR' : 0.91,
       'FIM' : 5.39,
       'FJD' : 2.11,
       'FKP' : 0.65,
       'FRF' : 5.95,
       'GBP' : 0.65,
       'GEL' : 2.25,
       'GHC' : 37964.2,
       'GHS' : 3.8,
       'GIP' : 0.65,
       'GMD' : 38.45,
       'GNF' : 7251.79,
       'GRD' : 308.97,
       'GTQ' : 7.43,
       'GYD' : 197.27,
       'HKD' : 7.75,
       'HNL' : 21.27,
       'HRK' : 6.87,
       'HTG' : 52.41,
       'HUF' : 287.8,
       'IDR' : 13333.3,
       'IEP' : 0.71,
       'ILS' : 3.79,
       'INR' : 63.39,
       'IQD' : 1141.95,
       'IRR' : 29360,
       'ISK' : 133.46,
       'ITL' : 1755.66,
       'JMD' : 113.71,
       'JOD' : 0.71,
       'JPY' : 121.58,
       'KES' : 98.48,
       'KGS' : 62.13,
       'KHR' : 3995.54,
       'KMF' : 445,
       'KPW' : 135.01,
       'KRW' : 1134.04,
       'KWD' : 0.3,
       'KYD' : 0.82,
       'KZT' : 183.31,
       'LAK' : 7923.05,
       'LBP' : 1480.9,
       'LKR' : 130.3,
       'LRD' : 85,
       'LSL' : 12.5,
       'LTL' : 3.13,
       'LUF' : 36.58,
       'LVL' : 0.64,
       'LYD' : 1.34,
       'MAD' : 9.77,
       'MDL' : 18.71,
       'MGA' : 3252.88,
       'MGF' : 9149.13,
       'MKD' : 55.45,
       'MMK' : 1111.03,
       'MNT' : 1958,
       'MOP' : 7.79,
       'MRO' : 320.47,
       'MTL' : 0.39,
       'MUR' : 34.3,
       'MVR' : 14.97,
       'MWK' : 441.83,
       'MXN' : 24, // Astropay
       'MYR' : 3.8,
       'MZM' : 38000,
       'MZN' : 38,
       'NAD' : 12.5,
       'NGN' : 196.44,
       'NIO' : 26.24,
       'NLG' : 2,
       'NOK' : 8.2,
       'NPR' : 99.74,
       'NZD' : 1.5,
       'OMR' : 0.38,
       'PAB' : 1,
       'PEN' : 3.12,
       'PGK' : 2.68,
       'PHP' : 45.15,
       'PKR' : 100.4,
       'PLN' : 3.83,
       'PTE' : 181.78,
       'PYG' : 5065.03,
       'QAR' : 3.64,
       'ROL' : 40637.3,
       'RON' : 4.06,
       'RSD' : 108.68,
       'RUB' : 57.16,
       'RWF' : 721.7,
       'SAR' : 3.75,
       'SBD' : 7.83,
       'SCR' : 12.33,
       'SDD' : 592.4,
       'SDG' : 5.92,
       'SDP' : 2272.21,
       'SEK' : 8.5,
       'SGD' : 1.35,
       'SHP' : 0.62,
       'SIT' : 217.29,
       'SKK' : 27.32,
       'SLL' : 4158,
       'SOS' : 673,
       'SRD' : 3.24,
       'SRG' : 3240,
       'STD' : 22115.7,
       'SVC' : 8.54,
       'SYP' : 217.65,
       'SZL' : 12.5,
       'THB' : 33.94,
       'TJS' : 6.26,
       'TMM' : 14285.71,
       'TMT' : 2.85,
       'TND' : 1.97,
       'TOP' : 2.16,
       'TRL' : 2687990,
       'TRY' : 2.69,
       'TTD' : 6.25,
       'TWD' : 31.04,
       'TZS' : 2185.91,
       'UAH' : 21.25,
       'UGX' : 3454.24,
       'USD' : 1,
       'UYU' : 40, // Astropay
       'UZS' : 2541,
       'VEB' : 6290.36,
       'VEF' : 6.29,
       'VND' : 21482.8,
       'VUV' : 104.5,
       'WST' : 2.36,
       'XAF' : 595.84,
       'XAG' : 0.07,
       'XAU' : 0,
       'XCD' : 2.69,
       'XEU' : 0.91,
       'XOF' : 595.83,
       'XPD' : 0,
       'XPF' : 108.27,
       'XPT' : 0,
       'YER' : 214.8,
       'YUN' : 108.68,
       'ZAR' : 12.5,
       'ZMK' : 5327.65,
       'ZWD' : 376.36
   };
   if($.inArray(currency, minimums)){
       return minimums[currency];
   }
   return 1;

} </script> <script> /**

* Javascript for mobile banners.
* This version assumes checkboxes for amount, buttons for payment method
*
* Dependencies: MediaWiki:FR2013/Resources/Country2Currency.js
*/

/* Allow overriding country */ mw.loader.using(['mediawiki.util']).then(function() {

   if( mw.util.getParamValue("country") ) {
       Geo.country = mw.util.getParamValue("country");
   }

});

var fundraisingBanner = fundraisingBanner || {};

fundraisingBanner.validateForm = function(form) {

   /* Check the form, especially the amount submitted
    * Return the amount if valid, otherwise return false
    */
   var error = true;
   var amount = null;
   // If there are some amount radio buttons, then look for the checked one
   if (form.amount) {
       for (var i = 0; i < form.amount.length; i++) {
           if (form.amount[i].checked) {
               amount = form.amount[i].value;
           }
       }
   }
   // Check the "other" amount box
   if (form.amountGiven.value !== ) {
       var otherAmount = form.amountGiven.value;
       otherAmount = otherAmount.replace(/[,.](\d)$/, ':$10');
       otherAmount = otherAmount.replace(/[,.](\d)(\d)$/, ':$1$2');
       otherAmount = otherAmount.replace(/[$£€¥,.]/g, );
       otherAmount = otherAmount.replace(/:/, '.');
       form.amountGiven.value = otherAmount;
       amount = otherAmount;
   }
   // Check amount is a real number
   error = ( amount == null || isNaN(amount) || amount.value <= 0 );
   // Check amount is at least the minimum
   var currency = form.currency_code.value;
   if (amount < getMinimum(currency) || error) {
       alert('You must contribute at least $1'.replace('$1', getMinimum(currency) + ' ' + currency));
       error = true;
   }
   if ( error ) {
       return false;
   } else {
       return amount;
   }

};

fundraisingBanner.redirectPayment = function(paymentMethod, paymentSubMethod, skipValidation) {

   if ( skipValidation || fundraisingBanner.validateForm(document.paypalcontribution) ) {
       if (typeof paymentSubMethod == 'undefined') {
           paymentSubMethod = ;
       }
       var form = document.paypalcontribution; // we should really change this some day
       var paymentsURL = 'https://payments.wikimedia.org/index.php/Special:GatewayFormChooser';
       form.action = paymentsURL;
       if ( form.language.value === 'pt' && Geo.country === 'BR' ) {
           form.language.value = 'pt-br';
       }


       // WorldPay override for cc
       if( paymentMethod === 'cc-wp' ) {
           paymentMethod = 'cc';
           form.payment_method.value = 'cc';
           form.gateway.value = 'worldpay';
           form.ffname.value = 'worldpay';
       }
       
       // Adyen override for cc
       if( paymentMethod === 'cc-adyen' ) {
           paymentMethod = 'cc';
           form.payment_method.value = 'cc';
           form.gateway.value = 'adyen';
           form.ffname.value = 'adyen';
       }
       
       // Express Checkout override for PayPal
       if( paymentMethod === 'paypal-ec' ) {
           paymentMethod = 'paypal';
           form.payment_method.value = 'paypal';
           form.gateway.value = 'paypal_ec';
       }
       var frequency = $("input[name='frequency']:checked").val();
       if( frequency !== 'monthly' ){
           frequency = 'onetime';
           form.recurring.value = 'false';
       } else {
           form.recurring.value = 'true';
       }
       var mixins = mw.centralNotice.getDataProperty( 'mixins' );
       if ( mixins && mixins.bannerHistoryLogger ) {
           form.bannerhistlog.value = mw.centralNotice.bannerHistoryLogger.id;
       }
       form.utm_key.value = mw.centralNotice.bannerData.cookieCount || 0;
       form.payment_method.value = paymentMethod;
       form.payment_submethod.value = paymentSubMethod;
       
       var full_dotted_payment_method = paymentMethod;
       if ( form.recurring.value == 'true' ) {
           full_dotted_payment_method = 'r' + full_dotted_payment_method;
       }
       if ( paymentSubMethod ) {
           full_dotted_payment_method = form.payment_method.value + '.' + paymentSubMethod;
       }
       form.utm_source.value += '.no-LP.' + full_dotted_payment_method;
       $('.frbanner-submit button, .frbanner-continue button, .frbanner3-continue button').attr('disabled', 'disabled'); // Disable to prevent double submission
       if ( mixins && mixins.bannerHistoryLogger ) {
           mw.centralNotice.bannerHistoryLogger.ensureLogSent().always(function() {
               form.submit();
           });
       } else {
           form.submit();
       }
       
   }

};

$(document).ready( function () {

   var currency = getCurrency();
   var language = mw.config.get('wgUserLanguage');
   // set the form fields
   $("input[name='country']").val(Geo.country);
   $("input[name='currency_code']").val(currency);
   $("input[name='language']").val(mw.config.get('wgUserLanguage'));
   $("input[name='return_to']").val("Thank_You/" + mw.config.get('wgUserLanguage'));
   // Add utm_key with banner counter
   mw.centralNotice.events.bannerLoaded.done(function(e){
       $('[name="paypalcontribution"]').append($('<input>', {
           'type': 'hidden', 'name': 'utm_key', 'value': (mw.centralNotice.bannerData.cookieCount || 0)
       }));
   });

}); </script> <script> var fundraisingBanner = fundraisingBanner || {};

fundraisingBanner.expanded = false;

fundraisingBanner.addSpace = function() {

   var bannerHeight = $('#{{{banner}}}-main').outerHeight();
   $('#mw-mf-viewport').css('top', bannerHeight + 'px');

}

fundraisingBanner.show = function() {

   $('#siteNotice').prependTo('body');
   $('#{{{banner}}}').show();
   fundraisingBanner.addSpace();
   $(window).resize(function() {
       fundraisingBanner.addSpace();
   });

}

fundraisingBanner.hide = function() {

   mw.centralNotice.hideBanner();
   $('#mw-mf-viewport').css('top', '0');

}

fundraisingBanner.toggleExpanded = function() {

   if (fundraisingBanner.expanded) {
       $('#{{{banner}}}').removeClass('{{{banner}}}-expanded');
       $('#{{{banner}}}-inner').hide();
       $('.{{{banner}}}-arrow').removeClass('{{{banner}}}-arrow-up').addClass('{{{banner}}}-arrow-down');
       fundraisingBanner.expanded = false;
   } else {
       $('#{{{banner}}}').addClass('{{{banner}}}-expanded');
       $('#{{{banner}}}-inner').show();
       $('.{{{banner}}}-arrow').removeClass('{{{banner}}}-arrow-down').addClass('{{{banner}}}-arrow-up');
       setTimeout(function() { window.scrollTo(0, 1); }, 0); // Hide the address bar
       fundraisingBanner.expanded = true;
   }

}

$(document).ready( function () {

   if (!mw.centralNotice.bannerData.hideResult) {
       fundraisingBanner.show();
   }

}); </script>