Fix: Editing nodes with XNodeAttributes might lead to data corruption
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 23 Apr 2013 11:44:43 +0000 (13:44 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 23 Apr 2013 11:44:43 +0000 (13:44 +0200)
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

index cb7c40f..c08945c 100644 (file)
              });
        $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')) {
                             }
                            /* 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;
                                });
 
                 $('.accept-button', $overlay).click(function(){
                     save();
+                    $(document).unbind('click.blur-overlay');
                 });
 
                 $(document).bind('click.blur-overlay', function(event){