Skip to content
Snippets Groups Projects
Commit ef42e386 authored by Jared Hancock's avatar Jared Hancock
Browse files

lock: Fix missing shutdown on navigation

Instead, locking would stay active and would warn you about expiring lock
after navigating away from a locked object.
parent f3244b5b
No related branches found
No related tags found
No related merge requests found
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
// attempt to fetch one (lazily) // attempt to fetch one (lazily)
$(':input', this.$element).on('keyup, change', this.acquire.bind(this)); $(':input', this.$element).on('keyup, change', this.acquire.bind(this));
$(':submit', this.$element).click(this.ensureLocked.bind(this)); $(':submit', this.$element).click(this.ensureLocked.bind(this));
$(document).on('pjax:start', this.shutdown.bind(this));
// If lock already held, assume full time of lock remains, but warn // If lock already held, assume full time of lock remains, but warn
// user about pending expiration // user about pending expiration
...@@ -118,14 +119,18 @@ ...@@ -118,14 +119,18 @@
data: 'delete', data: 'delete',
async: false, async: false,
cache: false, cache: false,
always: $.proxy(this.destroy, this) complete: this.destroy.bind(this)
}); });
}, },
destroy: function() { shutdown: function() {
clearTimeout(this.warning); clearTimeout(this.warning);
clearTimeout(this.retryTimer); clearTimeout(this.retryTimer);
$(window).off('.exclusive'); $(document).off('.exclusive');
},
destroy: function() {
this.shutdown();
delete this.lockId; delete this.lockId;
$(this.options.lockInput, this.$element).val(''); $(this.options.lockInput, this.$element).val('');
}, },
...@@ -141,8 +146,8 @@ ...@@ -141,8 +146,8 @@
} }
if (!this.lockId) { if (!this.lockId) {
// Set up release on away navigation // Set up release on away navigation
$(window).off('.exclusive'); $(document).off('.exclusive');
$(window).on('pjax:click.exclusive', $.proxy(this.release, this)); $(document).on('pjax:click.exclusive', $.proxy(this.release, this));
} }
this.lockId = lock.id; this.lockId = lock.id;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment