diff --git a/src/commands/view/CreateComponent.js b/src/commands/view/CreateComponent.js index 457da6f90..ddb2135cd 100644 --- a/src/commands/view/CreateComponent.js +++ b/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(); }, diff --git a/src/commands/view/MoveComponent.js b/src/commands/view/MoveComponent.js index afb0f3dbf..c481c02a7 100644 --- a/src/commands/view/MoveComponent.js +++ b/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(); diff --git a/src/commands/view/SelectPosition.js b/src/commands/view/SelectPosition.js index a9dbca1ed..2e9ef6ee2 100644 --- a/src/commands/view/SelectPosition.js +++ b/src/commands/view/SelectPosition.js @@ -16,8 +16,7 @@ define(function() { * @return {Object} Placeholder * @private * */ - getPositionPlaceholder: function() - { + getPositionPlaceholder: function() { return this.$plh; }, diff --git a/src/commands/view/SwitchVisibility.js b/src/commands/view/SwitchVisibility.js index 167e60638..703b334b5 100644 --- a/src/commands/view/SwitchVisibility.js +++ b/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'); } }; diff --git a/src/utils/Sorter.js b/src/utils/Sorter.js index 1ea505537..130e7ae22 100644 --- a/src/utils/Sorter.js +++ b/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]; }, /**