|
|
@ -6,6 +6,7 @@ module.exports = Backbone.View.extend({ |
|
|
events: { |
|
|
events: { |
|
|
mousedown: 'startDrag', |
|
|
mousedown: 'startDrag', |
|
|
dragstart: 'handleDragStart', |
|
|
dragstart: 'handleDragStart', |
|
|
|
|
|
drag: 'handleDrag', |
|
|
dragend: 'handleDragEnd' |
|
|
dragend: 'handleDragEnd' |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
@ -34,7 +35,8 @@ module.exports = Backbone.View.extend({ |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
handleDragStart(ev) { |
|
|
handleDragStart(ev) { |
|
|
const content = this.model.get('content'); |
|
|
const { em, model } = this; |
|
|
|
|
|
const content = model.get('content'); |
|
|
const isObj = isObject(content); |
|
|
const isObj = isObject(content); |
|
|
const type = isObj ? 'text/json' : 'text'; |
|
|
const type = isObj ? 'text/json' : 'text'; |
|
|
const data = isObj ? JSON.stringify(content) : content; |
|
|
const data = isObj ? JSON.stringify(content) : content; |
|
|
@ -43,7 +45,12 @@ module.exports = Backbone.View.extend({ |
|
|
// but will use dragContent as I need it for the Sorter context
|
|
|
// but will use dragContent as I need it for the Sorter context
|
|
|
// IE11 supports only 'text' data type
|
|
|
// IE11 supports only 'text' data type
|
|
|
ev.dataTransfer.setData('text', data); |
|
|
ev.dataTransfer.setData('text', data); |
|
|
this.em.set('dragContent', content); |
|
|
em.set('dragContent', content); |
|
|
|
|
|
em.trigger('block:drag:start', model, ev); |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
handleDrag(ev) { |
|
|
|
|
|
this.em.trigger('block:drag', this.model, ev); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
handleDragEnd() { |
|
|
handleDragEnd() { |
|
|
@ -72,6 +79,8 @@ module.exports = Backbone.View.extend({ |
|
|
dragResult: null, |
|
|
dragResult: null, |
|
|
dragContent: null |
|
|
dragContent: null |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
em.trigger('block:drag:stop', result, model); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
|