').appendTo('body');
window.location = url;
};
var targetWindow = _targetWindow || 'prefer-popup',
lastPopup = false;
$(document.body).on('click', 'a[data-plugin="nsl"][data-action="connect"],a[data-plugin="nsl"][data-action="link"]', function (e) {
if (lastPopup && !lastPopup.closed) {
e.preventDefault();
lastPopup.focus();
} else {
var $target = $(this),
href = $target.attr('href'),
success = false;
if (href.indexOf('?') !== -1) {
href += '&';
} else {
href += '?';
}
var redirectTo = $target.data('redirect');
if (redirectTo === 'current') {
href += 'redirect=' + encodeURIComponent(window.location.href) + '&';
} else if (redirectTo && redirectTo !== '') {
href += 'redirect=' + encodeURIComponent(redirectTo) + '&';
}
if (targetWindow !== 'prefer-same-window' && checkWebView()) {
targetWindow = 'prefer-same-window';
}
if (targetWindow === 'prefer-popup') {
lastPopup = NSLPopup(href + 'display=popup', 'nsl-social-connect', $target.data('popupwidth'), $target.data('popupheight'));
if (lastPopup) {
success = true;
e.preventDefault();
}
} else if (targetWindow === 'prefer-new-tab') {
var newTab = window.open(href + 'display=popup', '_blank');
if (newTab) {
if (window.focus) {
newTab.focus();
}
success = true;
e.preventDefault();
}
}
if (!success) {
window.location = href;
e.preventDefault();
}
}
});
var googleLoginButton = $('a[data-plugin="nsl"][data-provider="google"]');
if (googleLoginButton.length && checkWebView() && !isAllowedWebViewForUserAgent()) {
googleLoginButton.remove();
}
});})();