Browse Source

Update sorter

pull/36/head
Artur Arseniev 10 years ago
parent
commit
32dacbc67c
  1. 19
      src/commands/view/CreateComponent.js
  2. 3
      src/commands/view/MoveComponent.js
  3. 3
      src/commands/view/SelectPosition.js
  4. 6
      src/commands/view/SwitchVisibility.js
  5. 16
      src/utils/Sorter.js

19
src/commands/view/CreateComponent.js

@ -50,6 +50,8 @@ define(['backbone','./SelectPosition'],
SelectPosition.enable.apply(this, arguments);
this.$el.css('cursor','crosshair');
this.enableToDraw();
if(this.sorter)
this.sorter.startSort();
},
/**
@ -269,9 +271,24 @@ define(['backbone','./SelectPosition'],
* */
afterCreation: function(model){},
run: function(em, sender){
run: function(editor, sender, opts){
this.editor = editor;
this.sender = sender;
this.$el = this.$wrapper;
/*
var utils = editor.Utils;
if(utils && utils.Sorter && !this.sorter)
this.sorter = new utils.Sorter({
container: this.$canvas.get(0),
containerSel: '*',
itemSel: '*',
pfx: this.ppfx,
//onEndMove: this.onEndMove,
direction: 'a',
nested: 1,
});
*/
this.enable();
},

3
src/commands/view/MoveComponent.js

@ -4,7 +4,7 @@ define(['backbone', './SelectComponent','./SelectPosition'],
* @class MoveComponent
* @private
* */
return _.extend({},SelectComponent, SelectPosition,{
return _.extend({},SelectComponent, SelectPosition, {
init: function(o){
SelectComponent.init.apply(this, arguments);
@ -94,7 +94,6 @@ define(['backbone', './SelectComponent','./SelectPosition'],
onEndMove: this.onEndMove,
direction: 'a',
nested: 1,
freezeClass: this.freezClass,
});
this.enable();

3
src/commands/view/SelectPosition.js

@ -16,8 +16,7 @@ define(function() {
* @return {Object} Placeholder
* @private
* */
getPositionPlaceholder: function()
{
getPositionPlaceholder: function() {
return this.$plh;
},

6
src/commands/view/SwitchVisibility.js

@ -5,13 +5,11 @@ define(function() {
* */
return {
run: function()
{
run: function() {
this.$canvas.addClass(this.pfx + 'dashed');
},
stop: function()
{
stop: function() {
this.$canvas.removeClass(this.pfx + 'dashed');
}
};

16
src/utils/Sorter.js

@ -9,7 +9,6 @@ define(['backbone'],
this.elT = 0;
this.elL = 0;
this.borderOffset = o.borderOffset || 10;
this.freezeClass = o.freezeClass || 'opac50';
var el = o.container;
this.el = typeof el === 'string' ? document.querySelector(o.container) : el;
@ -18,9 +17,11 @@ define(['backbone'],
this.itemSel = o.itemSel || 'div';
this.nested = o.nested || 0;
this.pfx = o.pfx || '';
this.freezeClass = o.freezeClass || this.pfx + 'freezed';
this.onEndMove = o.onEndMove || '';
this.direction = o.direction || 'v'; // v (vertical), h (horizontal), a (auto)
this.onMoveClb = o.onMove || '';
this.relative = o.relative || 0;
this.dropContent = '';
},
@ -101,7 +102,7 @@ define(['backbone'],
this.moved = 0;
this.eV = trg;
if(!this.matches(trg, this.itemSel + ',' + this.containerSel))
if(trg && !this.matches(trg, this.itemSel + ',' + this.containerSel))
this.eV = this.closest(trg, this.itemSel);
// Create placeholder if not exists
@ -110,9 +111,12 @@ define(['backbone'],
this.el.appendChild(this.plh);
}
this.eV.className += ' ' + this.freezeClass;
if(this.eV){
this.eV.className += ' ' + this.freezeClass;
$(document).on('mouseup',this.endMove);
}
this.$el.on('mousemove',this.onMove);
$(document).on('mouseup',this.endMove);
$(document).on('keypress',this.rollback);
},
@ -187,7 +191,9 @@ define(['backbone'],
*/
getDim: function(el){
var o = this.offset(el);
return [o.top - this.elT, o.left - this.elL, el.offsetHeight, el.offsetWidth];
var top = this.relative ? el.offsetTop : o.top - this.elT;
var left = this.relative ? el.offsetLeft : o.left - this.elL;
return [top, left, el.offsetHeight, el.offsetWidth];
},
/**

Loading…
Cancel
Save