Skip to content

Instantly share code, notes, and snippets.

@thotbox
Last active August 29, 2015 14:04
Show Gist options
  • Save thotbox/a9f150a8f63bc86e688f to your computer and use it in GitHub Desktop.
Save thotbox/a9f150a8f63bc86e688f to your computer and use it in GitHub Desktop.
JavaScript: Popup Confirm Close
// Vote Submit
function voteShare (pageURL,title,w,h) {
var left = (window.screen.width/2)-(w/2);
var top = (window.screen.height/2)-(h/2);
var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
var pollTimer = window.setInterval(function() {
if (targetWin.closed !== false) {
window.clearInterval(pollTimer);
setTimeout(function () {
$('#vote').submit();
}, 1000);
}
}, 200);
}
$('#vote-submit').click(function() {
event.preventDefault();
var shareLink = $(this).attr('data-link');
voteShare(shareLink, 'Share',700,400);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment