MediaWiki:ThankYouPage.js: Difference between revisions

From Donate
Jump to navigation Jump to search
Content deleted Content added
add framebuster code for https://phabricator.wikimedia.org/T176669
different framebuster?
Line 1: Line 1:
// Framebuster for https://phabricator.wikimedia.org/T176669
// Framebuster for https://phabricator.wikimedia.org/T176669
if ( location.href !== top.location.href ) {
if ( self == top ) {
top.location.href = location.href;
top.location = self.location;
}
}



Revision as of 15:49, 3 May 2019

// Framebuster for https://phabricator.wikimedia.org/T176669
if ( self == top ) { 
	top.location = self.location;
}

mw.loader.using( 'mediawiki.util', function() {

    var paymentMethod = mw.util.getParamValue('payment_method'),
        country = mw.util.getParamValue('country');

    if ( paymentMethod === 'bt' ) {
        document.getElementById('ty-banktransfer').style.display = 'block';
    }
    if ( paymentMethod === 'bitcoin' ) {
        document.getElementById('ty-bitcoin').style.display = 'block';
    }
    if ( paymentMethod === 'bpay' ) {
        document.getElementById('ty-bpay').style.display = 'block';
    }

    if ( country === 'US' || country === 'CA' ) {
        document.getElementById('ty-store').style.display = 'block';
    }

});

// Hint to click a share button when icon is clicked
document.getElementsByClassName('ty-share')[0].addEventListener('click', function() {
    var primaryClick = this;
    primaryClick.classList.add('highlight');
    setTimeout(function() {
        primaryClick.classList.remove('highlight');
    }, 400);
});

if ( navigator.share ) {
    $('#ty-web-share').click(function(e) {
        var url = 'https://donate.wikimedia.org/?utm_medium=SocialMedia&utm_campaign=ThankYouPage&utm_source=WebShare'; 
        if ( $(this).data('share-language') ) {
            url += '&uselang=' + $(this).data('share-language');
        }
        navigator.share({
            text: $(this).data('share-text'),
            url: url
        });
        e.preventDefault();
    });
    $('#ty-web-share').show();
}