Disable leave confirm when voting for map or server

This commit is contained in:
jamal 2014-10-11 10:04:16 -04:00
parent 3589e226d3
commit 450f821232

View file

@ -1,7 +1,7 @@
<div id="jplayer"></div> <div id="jplayer"></div>
<script type="text/javascript"> <script type="text/javascript">
var played = false; var played = false;
var leaving = false; var leave_confirm = true;
<% if @gatherer and @gatherer.can_destroy? cuser %> <% if @gatherer and @gatherer.can_destroy? cuser %>
var gatherer_id = <%= @gatherer.id %>; var gatherer_id = <%= @gatherer.id %>;
<% else %> <% else %>
@ -59,20 +59,23 @@
}); });
$(window).bind('beforeunload', function(e) { $(window).bind('beforeunload', function(e) {
if (gatherer_id > 0 && !leaving) { if (gatherer_id > 0 && leave_confirm) {
return "You will be removed from the Gather if you leave this page."; return "You will be removed from the Gather if you leave this page.";
} }
}); });
$(window).bind('unload', function() { $(window).bind('unload', function() {
if (gatherer_id > 0 && !leaving) { if (gatherer_id > 0 && leave_confirm) {
updateGathererStatus('leaving'); updateGathererStatus('leaving');
} }
}); });
$('.leave-gather').click(function() { var disable_leave_confirm = function() {
leaving = true; leave_confirm = false;
}); }
$('.leave-gather').click(disable_leave_confirm);
$('#gather-area a').click(disable_leave_confirm);
var afk = false; var afk = false;
var afk_timeout; var afk_timeout;