Browse Source

Update blocks

pull/36/head
Artur Arseniev 10 years ago
parent
commit
ce55d201af
  1. 6
      src/block_manager/view/BlocksView.js
  2. 6
      src/dom_components/view/ComponentImageView.js
  3. 2
      src/dom_components/view/ComponentTextView.js
  4. 19
      src/editor/config/config.js
  5. 8
      src/utils/Sorter.js

6
src/block_manager/view/BlocksView.js

@ -80,10 +80,14 @@ function(Backbone, BlockView) {
* Callback when block is dropped * Callback when block is dropped
* @private * @private
*/ */
onDrop: function(){ onDrop: function(model){
this.em.runDefault(); this.em.runDefault();
this.em.get('Canvas').getBody().style.cursor = ''; this.em.get('Canvas').getBody().style.cursor = '';
document.body.style.cursor = ''; document.body.style.cursor = '';
if(model && model.get('activeOnRender')){
model.trigger('active');
model.set('activeOnRender', 0);
}
}, },
/** /**

6
src/dom_components/view/ComponentImageView.js

@ -11,8 +11,8 @@ define(['backbone', './ComponentView'],
initialize: function(o){ initialize: function(o){
ComponentView.prototype.initialize.apply(this, arguments); ComponentView.prototype.initialize.apply(this, arguments);
this.listenTo( this.model, 'change:src', this.updateSrc); this.listenTo( this.model, 'change:src', this.updateSrc);
this.listenTo( this.model, 'dblclick', this.openModal); this.listenTo( this.model, 'dblclick active', this.openModal);
this.classEmpty = this.ppfx + 'plh-image'; this.classEmpty = this.ppfx + 'plh-image';
if(this.config.modal) if(this.config.modal)
@ -61,6 +61,8 @@ define(['backbone', './ComponentView'],
if(!this.model.get('src')) if(!this.model.get('src'))
this.$el.attr('class', this.classEmpty); this.$el.attr('class', this.classEmpty);
// Avoid strange behaviours while try to drag
this.$el.attr('onmousedown', 'return false');
return this; return this;
}, },
}); });

2
src/dom_components/view/ComponentTextView.js

@ -10,7 +10,7 @@ define(['backbone', './ComponentView'],
initialize: function(o){ initialize: function(o){
ComponentView.prototype.initialize.apply(this, arguments); ComponentView.prototype.initialize.apply(this, arguments);
_.bindAll(this,'disableEditing'); _.bindAll(this,'disableEditing');
this.listenTo(this.model, 'focus', this.enableEditing); this.listenTo(this.model, 'focus active', this.enableEditing);
this.rte = this.config.rte || ''; this.rte = this.config.rte || '';
}, },

19
src/editor/config/config.js

@ -110,7 +110,24 @@ define(function () {
},{ },{
id: 'b3', id: 'b3',
label: 'Block3', label: 'Block3',
content: '<h3>Block 3</h3>', content: '<div>Block 3</div>',
},{
id: 'text',
label: 'Text',
content: '<div style="padding:5px">Insert your text here</div>',
},{
id: 'text2',
label: 'Text2',
content: {
type:'text',
content:'Insert your text here',
style: { padding: '10px' },
activeOnRender: 1
},
},{
id: 'image',
label: 'Image',
content: {type:'image', activeOnRender: 1},
}], }],
}, },

8
src/utils/Sorter.js

@ -476,6 +476,7 @@ define(['backbone'],
* @return void * @return void
* */ * */
endMove: function(e){ endMove: function(e){
var created;
this.$el.off('mousemove', this.onMove); this.$el.off('mousemove', this.onMove);
$(this.document).off('mouseup', this.endMove); $(this.document).off('mouseup', this.endMove);
$(this.document).off('keypress', this.rollback); $(this.document).off('keypress', this.rollback);
@ -484,14 +485,14 @@ define(['backbone'],
if(this.eV) if(this.eV)
this.eV.className = this.eV.className.replace(clsReg, ''); this.eV.className = this.eV.className.replace(clsReg, '');
if(this.moved) if(this.moved)
this.move(this.target, this.eV, this.lastPos); created = this.move(this.target, this.eV, this.lastPos);
if(this.plh) if(this.plh)
this.plh.style.display = 'none'; this.plh.style.display = 'none';
this.helperEl = ''; this.helperEl = '';
if(this.helper) if(this.helper)
this.helper.parentNode.removeChild(this.helper); this.helper.parentNode.removeChild(this.helper);
if(typeof this.onEndMove === 'function') if(typeof this.onEndMove === 'function')
this.onEndMove(); this.onEndMove(created);
}, },
/** /**
@ -521,7 +522,7 @@ define(['backbone'],
modelToDrop = this.dropContent; modelToDrop = this.dropContent;
opts.silent = false; opts.silent = false;
} }
targetCollection.add(modelToDrop, opts); var created = targetCollection.add(modelToDrop, opts);
if(!this.dropContent){ if(!this.dropContent){
targetCollection.remove(modelTemp); targetCollection.remove(modelTemp);
}else{ }else{
@ -529,6 +530,7 @@ define(['backbone'],
} }
// This will cause to recalculate children dimensions // This will cause to recalculate children dimensions
this.prevTarget = null; this.prevTarget = null;
return created;
}else }else
console.warn("Invalid target position"); console.warn("Invalid target position");
}, },

Loading…
Cancel
Save