From fb8befbb76d37a32317ef82324cecc5dd5208c08 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Tue, 23 Apr 2013 13:44:43 +0200 Subject: [PATCH 1/1] Fix: Editing nodes with XNodeAttributes might lead to data corruption If node was saved via the save button, the blur event handler was not unbound and was called on the next blur event. If this blur event resulted from clicking the edit button on another node, the XNodeAttributes from that node were set to the old one handled by unbound event handler, because those attributes were always taken from the currently edited node. --- redakcja/static/js/wiki/view_editor_wysiwyg.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/redakcja/static/js/wiki/view_editor_wysiwyg.js b/redakcja/static/js/wiki/view_editor_wysiwyg.js index cb7c40f8..c08945ce 100644 --- a/redakcja/static/js/wiki/view_editor_wysiwyg.js +++ b/redakcja/static/js/wiki/view_editor_wysiwyg.js @@ -413,13 +413,14 @@ }); $overlay.append($attributes); + var overlayParent = $box[0].offsetParent || $box.parent(); $overlay.css({ position: 'absolute', height: h, left: x, top: y, width: w - }).appendTo($box[0].offsetParent || $box.parent()).show(); + }).appendTo(overlayParent).show(); if ($origin.is('.motyw')) { @@ -498,7 +499,7 @@ } /* Set attributres back to the node */ var attrs = {}; - $(".html-editarea-attributes [name]") + $(".html-editarea-attributes [name]", overlayParent) .each(function(i, textField) { attrs[textField.name] = textField.value; }); @@ -564,6 +565,7 @@ $('.accept-button', $overlay).click(function(){ save(); + $(document).unbind('click.blur-overlay'); }); $(document).bind('click.blur-overlay', function(event){ -- 2.20.1