Free and Open source Web Builder Framework. Next generation tool for building templates without coding
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

40 lines
957 B

const $ = Backbone.$;
module.exports = {
run(editor, sender, opts = {}) {
const modal = editor.Modal;
const am = editor.AssetManager;
const config = am.getConfig();
const title = opts.modalTitle || config.modalTitle || '';
var types = opts.types;
var accept = opts.accept;
am.setTarget(opts.target);
am.onClick(opts.onClick);
am.onDblClick(opts.onDblClick);
am.onSelect(opts.onSelect);
if (!this.rendered || types || accept) {
var $html;
var assets;
if (types) {
assets = am.getAll().filter(asset => {
return types.indexOf(asset.get('type')) != -1
});
} else {
assets = am.getAll();
}
$html = $(am.render(assets));
if (accept) $html.find(`input#${config.stylePrefix}uploadFile`).attr('accept', accept);
this.rendered = 1;
}
modal.setTitle(title);
modal.setContent(am.getContainer());
modal.open();
}
};