use detach instead of remove

This commit is contained in:
Sanj 2011-10-21 01:38:04 +01:00
parent 50c51a26af
commit 597bb7aef4

View File

@ -304,10 +304,10 @@ Canvas.prototype.init = function() {
var height = parseInt(r.height) / 2; var height = parseInt(r.height) / 2;
// console.log("heightFOO: " + height); // console.log("heightFOO: " + height);
var width = parseInt(r.width) / 2; var width = parseInt(r.width) / 2;
highest_index = getHighestIndex(c.jq); var highest_index = getHighestIndex(c.jq);
new_index = parseInt(highest_index) + 1; var new_index = parseInt(highest_index) + 1;
// console.log('index: ' + new_index); // console.log('index: ' + new_index);
i = new ImageBox(c, r, {css: {'z-index': "" + new_index, 'top':toPx((ev.pageY - top) - height), 'left': toPx((ev.pageX - left) - width)}}); var i = new ImageBox(c, r, {css: {'z-index': "" + new_index, 'top':toPx((ev.pageY - top) - height), 'left': toPx((ev.pageX - left) - width)}});
} else if (r.mime == 'audio' || r.mime == 'video') { } else if (r.mime == 'audio' || r.mime == 'video') {
that.addMedia(r); that.addMedia(r);
} }
@ -317,15 +317,22 @@ Canvas.prototype.init = function() {
var top = $(this).position().top; var top = $(this).position().top;
var left = $(this).position().left; var left = $(this).position().left;
if (elem.hasClass('arabic')) { if (elem.hasClass('arabic')) {
t = new TextBox(c, {'html': '<p class="textbox_canvas_text">انقر على مربع التحرير</p>', 'css': {'direction': 'rtl'}}); var t = new TextBox(c, {'html': '<p class="textbox_canvas_text">انقر على مربع التحرير</p>', 'css': {
'direction': 'rtl',
'top': toPx((ev.pageY - top) - height),
'left': toPx((ev.pageX - left) - width)
}});
} else { } else {
t = new TextBox(c); var t = new TextBox(c, {'css': {
'top': toPx((ev.pageY - top) - height),
'left': toPx((ev.pageX - left) - width)
}});
} }
width = parseInt(t.jq.css('width') / 2); var width = parseInt(t.jq.css('width') / 2);
height = parseInt(t.jq.css('height') / 2); var height = parseInt(t.jq.css('height') / 2);
t.setCSS({'top':toPx((ev.pageY - top) - height), 'left': toPx((ev.pageX - left) - width)}); t.setCSS({'top':toPx((ev.pageY - top) - height), 'left': toPx((ev.pageX - left) - width)});
highest_index = getHighestIndex(c.jq); var highest_index = getHighestIndex(c.jq);
new_index = parseInt(highest_index) + 1; var new_index = parseInt(highest_index) + 1;
t.setCSS({'z-index': new_index}); t.setCSS({'z-index': new_index});
} }
// console.log('dropper'); // console.log('dropper');
@ -417,13 +424,13 @@ Canvas.prototype.movePage = function(newOrder, dontSave) {
} }
var currentIndex = this.jq.index('.canvas'); var currentIndex = this.jq.index('.canvas');
if (newOrder == 0) { if (newOrder == 0) {
this.jq.remove().insertBefore($('.canvas').eq(0)); this.jq.detach().insertBefore($('.canvas').eq(0));
} else if (newOrder < currentIndex) { } else if (newOrder < currentIndex) {
var prevCanvas = $('.canvas').eq(newOrder - 1); var prevCanvas = $('.canvas').eq(newOrder - 1);
this.jq.remove().insertAfter(prevCanvas); this.jq.detach().insertAfter(prevCanvas);
} else { } else {
var prevCanvas = $('.canvas').eq(newOrder); var prevCanvas = $('.canvas').eq(newOrder);
this.jq.remove().insertAfter(prevCanvas); this.jq.detach().insertAfter(prevCanvas);
} }
reorderEdgeArticle(); reorderEdgeArticle();
if (!dontSave) { if (!dontSave) {