/*globals jQuery, icl_vars, wpml_xdomain_data */ (function () { "use strict"; jQuery(document).ready(function () { jQuery('.' + wpml_xdomain_data.css_selector + ' a').on('click', function (event) { var originalUrl; var currentUrl = window.location.href; var targetUrl = jQuery(this).attr('href'); if ('#' !== targetUrl && currentUrl !== targetUrl) { event.preventDefault(); originalUrl = jQuery(this).attr('href'); // Filter out xdomain_data if already in the url originalUrl = originalUrl.replace(/&xdomain_data(=[^&]*)?(?=&|$)|xdomain_data(=[^&]*)?(&|$)/, ''); originalUrl = originalUrl.replace(/\?$/, ''); /** @namespace icl_vars.current_language */ jQuery.ajax({ url: wpml_xdomain_data.ajax_url, type: 'post', dataType: 'json', data: { action: 'switching_language', from_language: wpml_xdomain_data.current_language }, success: function (response) { var argsGlue; var url; var hash; var urlSplit; var xdomain; var form; if (response.data.xdomain_data) { if (response.success) { if ('post' === response.data.method) { // POST form = jQuery('