Browse Source

Don't trigger `component:add` when components are just moved. Fixes #868

pull/934/merge
Artur Arseniev 8 years ago
parent
commit
1fe03ddcee
  1. 20
      src/asset_manager/view/FileUploader.js
  2. 11
      src/dom_components/view/ComponentsView.js
  3. 1
      src/utils/Sorter.js

20
src/asset_manager/view/FileUploader.js

@ -289,26 +289,6 @@ module.exports = Backbone.View.extend(
videoNode.src = fileURL
*/
/*
// Show local video files, http://jsfiddle.net/dsbonev/cCCZ2/embedded/result,js,html,css/
var URL = window.URL || window.webkitURL
var file = this.files[0]
var type = file.type
var videoNode = document.createElement('video');
var canPlay = videoNode.canPlayType(type) // can use also for 'audio' types
if (canPlay === '') canPlay = 'no'
var message = 'Can play type "' + type + '": ' + canPlay
var isError = canPlay === 'no'
displayMessage(message, isError)
if (isError) {
return
}
var fileURL = URL.createObjectURL(file)
videoNode.src = fileURL
*/
// If it's an image, try to find its size
if (type === 'image') {
const data = {

11
src/dom_components/view/ComponentsView.js

@ -11,18 +11,17 @@ module.exports = Backbone.View.extend({
/**
* Add to collection
* @param {Object} Model
*
* @return void
* @param {Model} model
* @param {Collection} coll
* @param {Object} opts
* @private
* */
addTo(model) {
addTo(model, coll = {}, opts = {}) {
const em = this.config.em;
const i = this.collection.indexOf(model);
this.addToCollection(model, null, i);
if (em && !model.opt.temporary) {
em.trigger('add:component', model); // @deprecated
if (em && !opts.temporary) {
em.trigger('component:add', model);
}
},

1
src/utils/Sorter.js

@ -969,6 +969,7 @@ module.exports = Backbone.View.extend({
if (!dropContent) {
// Putting `avoidStore` here will make the UndoManager behave wrong
opts.temporary = 1;
modelTemp = targetCollection.add({}, { ...opts });
if (model) {

Loading…
Cancel
Save