我向 elFinder 添加了一个新的工具栏按钮和一个新的上下文菜单项。
效果很好,但只有在选择了一个普通文件时才应启用此项目。So should be dimmed when no file selected and should be dimmed when multiple files are selected or if is selected an directory.
我学到了比elFinder.prototype.commands.mycmd
我应该将this.getstate
返回值设置为:
0
如果应启用工具栏/上下文菜单项,并且-1
如果它应该被禁用
所以,现在有了这个:
埃尔
Finder.prototype.commands.mycmd= function() {
var self = this,
fm = self.fm;
self.disableOnSearch = true;
self.title = 'mycmd';
self.getstate = function() {
// need help here to add the "directory is selected check"
return fm.selected().length == 1 ? 0 : -1;
}
self.exec = function() {
alert("hello");
}
}
不幸的是,我只知道 Perl,所以我很难通过所有 elFinder 的 javascript 代码来弄清楚如何掌握条件。
认识elFinder
足够深入的人来帮助我解决这种情况吗?