Commit f39cf22d authored by radiolips's avatar radiolips Committed by GitHub
Browse files

Merge pull request #765 from silverwind/preserve-styles

Preserve inline styles when moving/cloning items
parents 2037a70f 21db4200
......@@ -106,6 +106,13 @@
height = parseFloat(match[1]);
}
return {height: height, unit: heightUnit};
},
removePositioningStyles: function(el) {
var style = el[0].style;
if (style.position) style.removeProperty('position');
if (style.left) style.removeProperty('left');
if (style.top) style.removeProperty('top');
}
};
......@@ -869,13 +876,14 @@
$(ui.helper).remove();
node.el = el;
self.placeholder.hide();
Utils.removePositioningStyles(el);
el
.attr('data-gs-x', node.x)
.attr('data-gs-y', node.y)
.attr('data-gs-width', node.width)
.attr('data-gs-height', node.height)
.addClass(self.opts.itemClass)
.removeAttr('style')
.enableSelection()
.removeData('draggable')
.removeClass('ui-draggable ui-draggable-dragging ui-draggable-disabled')
......@@ -1170,19 +1178,19 @@
} else {
self._clearRemovingTimeout(el);
if (!node._temporaryRemoved) {
Utils.removePositioningStyles(o);
o
.attr('data-gs-x', node.x)
.attr('data-gs-y', node.y)
.attr('data-gs-width', node.width)
.attr('data-gs-height', node.height)
.removeAttr('style');
.attr('data-gs-height', node.height);
} else {
Utils.removePositioningStyles(o);
o
.attr('data-gs-x', node._beforeDragX)
.attr('data-gs-y', node._beforeDragY)
.attr('data-gs-width', node.width)
.attr('data-gs-height', node.height)
.removeAttr('style');
.attr('data-gs-height', node.height);
node.x = node._beforeDragX;
node.y = node._beforeDragY;
self.grid.addNode(node);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment