作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我向 elFinder 添加了一个新的工具栏按钮和一个新的上下文菜单项。
效果不错,但只有在选择一个普通文件 时才应启用此项目。所以当没有选择文件时应该变暗,当选择多个文件或选择目录时应该变暗。
我在 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
足够深的人来帮助我解决这个问题吗?
最佳答案
只需在 elFinder 的 download.js
中找到解决方案即可。
这有效 - 至少现在.. ;)
elFinder.prototype.commands.mycmd= function() {
var self = this,
fm = self.fm;
self.disableOnSearch = true;
filter = function(hashes) {
return $.map(self.files(hashes), function(f) { return f.mime == 'directory' ? null : f });
};
self.title = 'mycmd';
self.getstate = function() {
var sel = self.fm.selected(),
cnt = sel.length;
return !self._disabled && cnt == 1 && cnt == filter(sel).length ? 0 : -1;
}
self.exec = function() {
alert("hello");
}
}
关于javascript - 如何在 elFinder 中检测多项选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20251454/
我是一名优秀的程序员,十分优秀!