diff --git a/src/canvas/view/FrameView.js b/src/canvas/view/FrameView.js index 00a49d473..64e4cd3be 100644 --- a/src/canvas/view/FrameView.js +++ b/src/canvas/view/FrameView.js @@ -21,7 +21,7 @@ function(Backbone) { render: function() { this.$el.attr({ - style: 'width: 50%; display: block; height: 80%; border: medium none; margin: 50px auto 0; background-color: white', + style: 'width: 50%; display: block; height: 80%; border: medium none; margin: 0 auto 0; background-color: white', }); return this; }, diff --git a/src/commands/view/SelectPosition.js b/src/commands/view/SelectPosition.js index 6c5b5a999..2052e591c 100644 --- a/src/commands/view/SelectPosition.js +++ b/src/commands/view/SelectPosition.js @@ -19,6 +19,7 @@ define(function() { pfx: this.ppfx, direction: 'a', document: doc, + wmargin: 1, nested: 1, }); var offDim = this.getOffsetDim(); @@ -79,6 +80,28 @@ define(function() { this.canvasTool.style.left = '-' + this.bodyEl.scrollLeft + 'px'; }, + /** + * Check if the pointer is near to the float component + * @param {number} index + * @param {string} method + * @param {Array} dims + * @return {Boolean} + * @private + * */ + nearToFloat: function(index, method, dims) { + var i = index || 0; + var m = method || 'before'; + var len = dims.length; + var isLast = len !== 0 && m == 'after' && i == len; + if(len !== 0 && ( + (!isLast && !dims[i][4]) || + (dims[i-1] && !dims[i-1][4]) || + (isLast && !dims[i-1][4]) ) ) + return 1; + else + return 0; + }, + run: function() { this.enable(); diff --git a/src/dom_components/main.js b/src/dom_components/main.js index d8be5834c..064039fff 100644 --- a/src/dom_components/main.js +++ b/src/dom_components/main.js @@ -61,13 +61,12 @@ define(function(require) { component.get('components').add(c.components); - var obj = { + this.c = c; + + var componentView = new ComponentView({ model: component, config: c, - }; - - this.c = c; - var componentView = new ComponentView(obj); + }); return { diff --git a/src/dom_components/model/Components.js b/src/dom_components/model/Components.js index 9d3f0f6fe..d45e2473c 100644 --- a/src/dom_components/model/Components.js +++ b/src/dom_components/model/Components.js @@ -49,6 +49,7 @@ define([ 'backbone', 'require'], }, add: function(models, opt){ + console.log(models, opt); if(typeof models === 'string'){ var parsed = this.editor.Parser.parseHtml(models); models = parsed.html; diff --git a/src/editor/model/Editor.js b/src/editor/model/Editor.js index c5e917840..9ba4ce5d6 100644 --- a/src/editor/model/Editor.js +++ b/src/editor/model/Editor.js @@ -235,12 +235,9 @@ define([ this.Components = this.cmp; if(this.stm.isAutosave()){ - var md = this.cmp.getComponent(); - this.updateComponents( md, null, { avoidStore : 1 }); - // Call UndoManager here so it's possible to call it also for children inside this.initUndoManager(); - this.initChildrenComp(md); + this.initChildrenComp(this.cmp.getWrapper()); } this.set('Components', this.cmp); @@ -548,14 +545,12 @@ define([ */ initChildrenComp: function(model) { var comps = model.get('components'); - if(comps.length){ - comps.each(function(md){ - this.updateComponents(md, null, { avoidStore : 1 }); - this.initChildrenComp(md); - if(this.um) - this.um.register(md); - }, this); - } + this.updateComponents(model, null, { avoidStore : 1 }); + comps.each(function(md){ + this.initChildrenComp(md); + if(this.um) + this.um.register(md); + }, this); }, /** diff --git a/src/utils/Sorter.js b/src/utils/Sorter.js index a66928415..bb9ab36bf 100644 --- a/src/utils/Sorter.js +++ b/src/utils/Sorter.js @@ -24,6 +24,7 @@ define(['backbone'], this.relative = o.relative || 0; this.plh = o.placer || ''; // Frame offset + this.wmargin = o.wmargin || 0; this.offTop = o.offsetTop || 0; this.offleft = o.offsetLeft || 0; this.document = o.document || document; @@ -140,8 +141,8 @@ define(['backbone'], // Cache all necessary positions var eO = this.offset(this.el); - this.elT = this.offTop ? Math.abs(eO.top) : eO.top; - this.elL = this.offLeft ? Math.abs(eO.left): eO.left; + this.elT = this.wmargin ? Math.abs(eO.top) : eO.top; + this.elL = this.wmargin ? Math.abs(eO.left): eO.left; this.rY = (e.pageY - this.elT) + this.el.scrollTop; this.rX = (e.pageX - this.elL) + this.el.scrollLeft; var dims = this.dimsFromTarget(e.target, this.rX, this.rY); @@ -274,8 +275,8 @@ define(['backbone'], */ getDim: function(el){ var o = this.offset(el); - var top = this.relative ? el.offsetTop : o.top - (this.offTop ? -1 : 1) * this.elT; - var left = this.relative ? el.offsetLeft : o.left - (this.offLeft ? -1 : 1) * this.elL; + var top = this.relative ? el.offsetTop : o.top - (this.wmargin ? -1 : 1) * this.elT; + var left = this.relative ? el.offsetLeft : o.left - (this.wmargin ? -1 : 1) * this.elL; return [top, left, el.offsetHeight, el.offsetWidth]; },