Skip to content
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

[js:core] add "execpre.[cmd]" event and make cmd exec cancelable #1817

Closed
nao-pon opened this issue Dec 21, 2016 · 0 comments
Closed

[js:core] add "execpre.[cmd]" event and make cmd exec cancelable #1817

nao-pon opened this issue Dec 21, 2016 · 0 comments

Comments

@nao-pon
Copy link
Member

nao-pon commented Dec 21, 2016

c.f. #1811

e.g. Open confirmation dialog before executing command open, tree. (Live Demo)

fm.bind('request.open request.tree', function(e) {
    var dfrd = $.Deferred(),
        cmd = e.type.substr(8),
        opts = e.data.opts;
    fm.confirm({
        title : 'Command cancel test',
        text  : 'Do you want to continue?',
        accept: {
            label    : 'btnYes',
            callback : function() {
                dfrd.resolve();
            }
        },
        cancel: {
            label    : 'btnNo',
            callback : function() {
                dfrd.reject();
                if (cmd === 'tree') {
                    setTimeout(function() {
                        // restore arrow state
                        $('#' + fm.navHash2Id(opts.target))
                            .removeClass('elfinder-subtree-loaded')
                            .addClass(fm.res('class', 'navcollapse'));
                    }, 10);
                }
            }
        }
    });
    e.data.result = dfrd;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant