[cmd:rm] fix an issue that sometime ignore the delete button and into the trash

This commit is contained in:
nao-pon
2021-07-09 10:49:11 +09:00
parent 8e2fa59c45
commit 5796adf6e4
2 changed files with 32 additions and 24 deletions
+31 -23
View File
@@ -374,35 +374,43 @@ elFinder.prototype.commands.rm = function() {
this.value = 'rm';
this.init = function() {
// re-assign for extended command
self = this;
fm = this.fm;
// bind function of change
self.change(function() {
var update = function(origin) {
var targets;
delete self.extra;
self.title = fm.i18n('cmd' + self.value);
self.className = self.value;
self.button && self.button.children('span.elfinder-button-icon')[self.value === 'trash'? 'addClass' : 'removeClass']('elfinder-button-icon-trash');
if (self.value === 'trash') {
self.extra = {
icon: 'rm',
node: $('<span></span>')
.attr({title: fm.i18n('cmdrm')})
.on('ready', function(e, data) {
targets = data.targets;
})
.on('click touchstart', function(e){
if (e.type === 'touchstart' && e.originalEvent.touches.length > 1) {
return;
}
e.stopPropagation();
e.preventDefault();
fm.getUI().trigger('click'); // to close the context menu immediately
fm.exec('rm', targets, {_userAction: true, forceRm : true});
})
};
if (origin && origin !== 'cwd' && (self.state > -1 || origin === 'navbar')) {
if (self.value === 'trash') {
self.extra = {
icon: 'rm',
node: $('<span></span>')
.attr({title: fm.i18n('cmdrm')})
.on('ready', function(e, data) {
targets = data.targets;
})
.on('click touchstart', function(e){
if (e.type === 'touchstart' && e.originalEvent.touches.length > 1) {
return;
}
e.stopPropagation();
e.preventDefault();
fm.getUI().trigger('click'); // to close the context menu immediately
fm.exec('rm', targets, {_userAction: true, forceRm : true});
})
};
}
}
};
// re-assign for extended command
self = this;
fm = this.fm;
// bind function of change
self.change(function() {
update();
});
fm.bind('contextmenucreate', function(e) {
update(e.data.type);
});
};
+1 -1
View File
@@ -1281,11 +1281,11 @@ $.fn.elfindertree = function(fm, opts) {
arrow.data('dfrd', dfrd);
})
.on('contextmenu', selNavdir, function(e) {
e.stopPropagation();
var self = $(this);
// now dirname editing
if (self.find('input:text').length) {
e.stopPropagation();
return;
}