MediaWiki:FR2015/Resources/MobileLocalize.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/** MediaWiki:FR2015/Resources/MobileLocalize.js
* Do various things to localize mobile banners
*
* Dependencies:
* MediaWiki:FR2015/Resources/MethodLocalize.js
*/
$(document).ready(function() {
/* --- Allow overriding country --- */
if( mw.util.getParamValue("country") ) {
Geo.country = mw.util.getParamValue("country");
}
var currency = getCurrency(Geo.country);
var language = mw.config.get('wgUserLanguage');
/* --- Links (in smallprint) --- */
$('a.localize, .frbanner-footer a').each(function() {
// Add parameters for LandingCheck
var uri = new mw.Uri( $(this).attr("href") );
uri.extend({
country: Geo.country,
language: language,
uselang: language
});
$(this).attr( "href", uri.toString() );
// Make links open in new tab
$(this).attr("target", "_blank");
});
/* --- Legal text variant --- */
if (Geo.country === 'US') {
$('.informationsharing-US').show();
$('.informationsharing-NL').hide();
$('.informationsharing-nonUS').hide();
}
if (Geo.country === 'NL') {
$('.informationsharing-US').hide();
$('.informationsharing-NL').show();
$('.informationsharing-nonUS').hide();
}
/* --- Amounts --- */
/* Main amount buttons */
var asks = fundraisingAmounts.pick(fundraisingAmounts.mobileAsks, currency, Geo.country);
$('.frbanner-amounts .amount-btn input').each(function(index) {
var $input = $(this);
var $label = $('label[for="' + $input.attr('id') + '"]');
var amount = asks[index];
$input.val( amount );
$label.html( currencyLocalize( currency, amount, language) );
});
/* "Other" box. Doesn't yet work for symbol after number */
$('#amount_total_8 label .currencySymbol').html(
currencyLocalize( currency, '', language )
);
// Find instances of %AVERAGE% in banner text, and replace with correct average for currency & country
$(".frbanner-message, .frbanner2-message, .frbanner3-message").each(function(index){
var avgString = getAverage(currency, Geo.country, language).replace(/\.$/, ''); // strip any period from end for use in running text
var newHtml = $(this).html().replace(/%AVERAGE%/g, avgString );
$(this).html(newHtml);
});
// Find instances of %MINIMUM% in banner text, and replace with correct minimum for currency & country
$(".frbanner-message, .frbanner2-message, .frbanner3-message").each(function(index){
var ifString = getMinimumString(currency, Geo.country, language).replace(/\.$/, ''); // strip any period from end for use in running text
var newHtml = $(this).html().replace(/%MINIMUM%/g, ifString );
$(this).html(newHtml);
});
/* Payment methods */
{{MediaWiki:FR2015/Resources/MethodLocalize.js}}
});
/* end of MediaWiki:FR2014/Resources/MobileLocalize.js */