blob: 6c415da3864c273255457b494b5555d6289f0ee2 [file] [log] [blame]
(function($, document) {
// When the user clicks on the Subscription tab,
// We load the list of newsletters only once.
// We prevent the data to be reloaded by adding a "loaded" class to the body
$(document).on('shown.bs.tab', function (e) {
function subscription_form(){
$("#subscription-form-submit").click(function() {
var text = $(this).text().toLowerCase();
$(this).html('<i class="fa fa-spinner fa-pulse"></i> ' + text);
var posting = $.post(url, {
form_name: 'mailchimp_form',
stage: 'mailchimp_' + text,
});
posting.done(function(data) {
$(target_id).html(data).addClass('loaded');
subscription_form();
});
return;
});
}
var target_id = $(e.target).attr('href');
if ($(e.target).attr('id') == 'tab-subscriptions' && $(target_id).attr('class').indexOf("loaded") <= 0) {
var url = $(e.target).attr('data-url');
if (url.startsWith("https://dev.eclipse.org") || url.startsWith("https://dev.eclipse.local")) {
// load the URL's html to the target's body
$.get(url, function(data) {
$(target_id).html(data).addClass('loaded');
subscription_form();
});
}
}
});
})(jQuery, document);