diff --git a/src/asset_manager/view/AssetImageView.js b/src/asset_manager/view/AssetImageView.js index b63bdd26c..ccf3fea95 100644 --- a/src/asset_manager/view/AssetImageView.js +++ b/src/asset_manager/view/AssetImageView.js @@ -1,3 +1,5 @@ +import { isFunction } from 'underscore'; + module.exports = require('./AssetView').extend({ events: { 'click [data-toggle=asset-remove]': 'onRemove', @@ -44,7 +46,7 @@ module.exports = require('./AssetView').extend({ this.collection.trigger('deselectAll'); this.$el.addClass(this.pfx + 'highlight'); - if (typeof onClick === 'function') { + if (isFunction(onClick)) { onClick(model); } else { this.updateTarget(this.collection.target); @@ -56,11 +58,10 @@ module.exports = require('./AssetView').extend({ * @private * */ onDblClick() { - const em = this.em; - var onDblClick = this.config.onDblClick; - var model = this.model; + const { em, model } = this; + const onDblClick = this.config.onDblClick; - if (typeof onDblClick === 'function') { + if (isFunction(onDblClick)) { onDblClick(model); } else { this.updateTarget(this.collection.target); @@ -68,9 +69,7 @@ module.exports = require('./AssetView').extend({ } var onSelect = this.collection.onSelect; - if (typeof onSelect == 'function') { - onSelect(this.model); - } + isFunction(onSelect) && onSelect(model); }, /** diff --git a/src/style_manager/view/PropertyFileView.js b/src/style_manager/view/PropertyFileView.js index 06021b496..ee3379fdf 100644 --- a/src/style_manager/view/PropertyFileView.js +++ b/src/style_manager/view/PropertyFileView.js @@ -113,19 +113,20 @@ module.exports = PropertyView.extend({ * @return void * */ openAssetManager(e) { - var that = this; - var em = this.em; - var editor = em ? em.get('Editor') : ''; + const that = this; + const { em, modal } = this; + const editor = em ? em.get('Editor') : ''; if (editor) { - this.modal.setTitle('Select image'); - this.modal.setContent(this.am.getContainer()); - this.am.setTarget(null); editor.runCommand('open-assets', { - target: this.model, - onSelect(target) { - that.modal.close(); - that.spreadUrl(target.get('src')); + types: ['image'], + accept: 'image/*', + target: this.getTargetModel(), + onClick() {}, + onDblClick() {}, + onSelect(asset) { + modal.close(); + that.spreadUrl(asset.get('src')); } }); }