Disable table reloads while renaming
This commit is contained in:
@ -28,8 +28,8 @@
|
|||||||
var ENTER_KEYCODE = 13;
|
var ENTER_KEYCODE = 13;
|
||||||
|
|
||||||
var _path = null;
|
var _path = null;
|
||||||
var _reloading = false;
|
|
||||||
var _pendingReloads = [];
|
var _pendingReloads = [];
|
||||||
|
var _reloadingDisabled = 0;
|
||||||
|
|
||||||
function formatFileSize(bytes) {
|
function formatFileSize(bytes) {
|
||||||
if (bytes >= 1000000000) {
|
if (bytes >= 1000000000) {
|
||||||
@ -49,15 +49,27 @@ function _showError(message, textStatus, errorThrown) {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _disableReloads() {
|
||||||
|
_reloadingDisabled += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
function _enableReloads() {
|
||||||
|
_reloadingDisabled -= 1;
|
||||||
|
|
||||||
|
if (_pendingReloads.length > 0) {
|
||||||
|
_reload(_pendingReloads.shift());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function _reload(path) {
|
function _reload(path) {
|
||||||
if (_reloading) {
|
if (_reloadingDisabled) {
|
||||||
if ($.inArray(path, _pendingReloads) < 0) {
|
if ($.inArray(path, _pendingReloads) < 0) {
|
||||||
_pendingReloads.push(path);
|
_pendingReloads.push(path);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_reloading = true;
|
_disableReloads();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: 'list',
|
url: 'list',
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
@ -109,6 +121,15 @@ function _reload(path) {
|
|||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}, {
|
}, {
|
||||||
|
onedit: function(settings, original) {
|
||||||
|
_disableReloads();
|
||||||
|
},
|
||||||
|
onsubmit: function(settings, original) {
|
||||||
|
_enableReloads();
|
||||||
|
},
|
||||||
|
onreset: function(settings, original) {
|
||||||
|
_enableReloads();
|
||||||
|
},
|
||||||
tooltip: 'Click to rename...'
|
tooltip: 'Click to rename...'
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -149,10 +170,7 @@ function _reload(path) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
}).always(function() {
|
}).always(function() {
|
||||||
_reloading = false;
|
_enableReloads();
|
||||||
if (_pendingReloads.length > 0) {
|
|
||||||
_reload(_pendingReloads.shift());
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user