-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding a new command to the contextual menu and tool bar #257
Comments
The basic scenario - you take one of the commands/buttons from https://github.com/Studio-42/elFinder/tree/2.x/js/commands and redefine it or add your own based on them. extending connector is also not a hard task, just inherit and extend the base classes |
I'm try extend the info command (infoextended) and, add a string 'infoextended' in my array of cammands. var myCommands = elFinder.prototype._options.commands; The plugins is initialized but the button is not showed. Att |
I know this is an old topic, but just want to share some of my experiences adding a new context menu:
// Customize elfinder with new menu
elFinder.prototype._options.commands.push('ftpsend')
elFinder.prototype._options.contextmenu.files.push('ftpsend')
elFinder.prototype.i18.en.messages['cmdftpsend'] = 'Send file using FTP' |
To add a custom command you must follow this steps:
$().ready(function() {
var elf = $('#elfinder').elfinder({
url : 'php/connector.php',
commands : [
'custom','open', 'reload', 'home', 'up', 'back', 'forward', 'getfile', 'quicklook',
'download', 'rm', 'duplicate', 'rename', 'mkdir', 'mkfile', 'upload', 'copy',
'cut', 'paste', 'edit', 'extract', 'archive', 'search', 'info', 'view', 'help', 'resize', 'sort', 'netmount'
],
contextmenu : {
// navbarfolder menu
navbar : ['open', '|', 'copy', 'cut', 'paste', 'duplicate', '|', 'rm', '|', 'info'],
// current directory menu
cwd : ['reload', 'back', '|', 'upload', 'mkdir', 'mkfile', 'paste', '|', 'sort', '|', 'info'],
// current directory file menu
files : ['getfile', '|','custom', 'quicklook', '|', 'download', '|', 'copy', 'cut', 'paste', 'duplicate', '|', 'rm', '|', 'edit', 'rename', 'resize', '|', 'archive', 'extract', '|', 'info']
},
}).elfinder('instance');
});
'cmdcustom' : 'Custom command',
elFinder.prototype.commands.custom= function() {
this.exec = function(hashes) {
//implement what the custom command should do here
}
}
.elfinder-button-icon-custom{ //css here } |
Thanks, added to wiki https://github.com/Studio-42/elFinder/wiki/Custom-context-menu-command |
Hi, Can the context menu item be displayed only for selecting one file? Thanks in advance. |
Yes you can. Just check the selection length in the getState function of you command and return -1 if you selected multiple files. this.getstate = function(select) {
let numberOfSelectedFilesAndFolders = this.files(select).length,
return numberOfSelectedFilesAndFolders == 1 ? 0 : -1;
}; If you want to filter out folders you can look at the elFinder/js/commands/getfile.js Line 12 in de16dc6
|
Thank you very much. You have done a great job.
…On Thu, Feb 8, 2018 at 9:17 PM, Razvan Dinicut ***@***.***> wrote:
Yes you can. Just check the selection length in the getState function of
you command and return -1 if you selected multiple files.
this.getstate = function(select) { let numberOfSelectedFilesAndFolders =
this.files(select).length, return numberOfSelectedFilesAndFolders == 1 ?
0 : -1; };
If you want fo filter out folders you can look at the getfile command for
inspiration:
https://github.com/Studio-42/elFinder/blob/de16dc6b61ea22f783e614ee37525b
a58523e2c6/js/commands/getfile.js#L12
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#257 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AOTJPRCbZfJwRSxHbuWyY7AW0tzyhWxsks5tSxccgaJpZM4AAgP6>
.
--
*Biswajit Paul, Asst. Manager - **Software Development*
B3NET Technologies PVT. LTD.
|
In order to use elfinder in my application I would need to create a new command and tie it to a specific action. Is there any documentation available on how to add a new command?
The text was updated successfully, but these errors were encountered: