Skip to content

Commit 5796adf

Browse files
committed
[cmd:rm] fix an issue that sometime ignore the delete button and into the trash
1 parent 8e2fa59 commit 5796adf

File tree

2 files changed

+32
-24
lines changed

2 files changed

+32
-24
lines changed

js/commands/rm.js

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -374,35 +374,43 @@ elFinder.prototype.commands.rm = function() {
374374
this.value = 'rm';
375375

376376
this.init = function() {
377-
// re-assign for extended command
378-
self = this;
379-
fm = this.fm;
380-
// bind function of change
381-
self.change(function() {
377+
var update = function(origin) {
382378
var targets;
383379
delete self.extra;
384380
self.title = fm.i18n('cmd' + self.value);
385381
self.className = self.value;
386382
self.button && self.button.children('span.elfinder-button-icon')[self.value === 'trash'? 'addClass' : 'removeClass']('elfinder-button-icon-trash');
387-
if (self.value === 'trash') {
388-
self.extra = {
389-
icon: 'rm',
390-
node: $('<span></span>')
391-
.attr({title: fm.i18n('cmdrm')})
392-
.on('ready', function(e, data) {
393-
targets = data.targets;
394-
})
395-
.on('click touchstart', function(e){
396-
if (e.type === 'touchstart' && e.originalEvent.touches.length > 1) {
397-
return;
398-
}
399-
e.stopPropagation();
400-
e.preventDefault();
401-
fm.getUI().trigger('click'); // to close the context menu immediately
402-
fm.exec('rm', targets, {_userAction: true, forceRm : true});
403-
})
404-
};
383+
if (origin && origin !== 'cwd' && (self.state > -1 || origin === 'navbar')) {
384+
if (self.value === 'trash') {
385+
self.extra = {
386+
icon: 'rm',
387+
node: $('<span></span>')
388+
.attr({title: fm.i18n('cmdrm')})
389+
.on('ready', function(e, data) {
390+
targets = data.targets;
391+
})
392+
.on('click touchstart', function(e){
393+
if (e.type === 'touchstart' && e.originalEvent.touches.length > 1) {
394+
return;
395+
}
396+
e.stopPropagation();
397+
e.preventDefault();
398+
fm.getUI().trigger('click'); // to close the context menu immediately
399+
fm.exec('rm', targets, {_userAction: true, forceRm : true});
400+
})
401+
};
402+
}
405403
}
404+
};
405+
// re-assign for extended command
406+
self = this;
407+
fm = this.fm;
408+
// bind function of change
409+
self.change(function() {
410+
update();
411+
});
412+
fm.bind('contextmenucreate', function(e) {
413+
update(e.data.type);
406414
});
407415
};
408416

js/ui/tree.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1281,11 +1281,11 @@ $.fn.elfindertree = function(fm, opts) {
12811281
arrow.data('dfrd', dfrd);
12821282
})
12831283
.on('contextmenu', selNavdir, function(e) {
1284+
e.stopPropagation();
12841285
var self = $(this);
12851286

12861287
// now dirname editing
12871288
if (self.find('input:text').length) {
1288-
e.stopPropagation();
12891289
return;
12901290
}
12911291

0 commit comments

Comments
 (0)