Fix for Uporzadkuj.
[redakcja.git] / redakcja / static / js / wiki / view_editor_wysiwyg.js
index 7c0bb0e..c08945c 100644 (file)
     function getXNodeAttributes(node) {
        var m = {}
        $.map(node.attributes, function(attrNode) {
     function getXNodeAttributes(node) {
        var m = {}
        $.map(node.attributes, function(attrNode) {
-           if (attrNode.nodeName.startsWith('data-wlf-')) {
+           if (attrNode.nodeName.indexOf('data-wlf-') === 0) {
                var n = attrNode.nodeName.substr(9);
                var v = attrNode.nodeValue;
                m[n] = v;
                var n = attrNode.nodeName.substr(9);
                var v = attrNode.nodeValue;
                m[n] = v;
     function setXNodeAttributes(node, attrs) {
        $.map(node.attributes, function(attrNode) {
            var xName = attrNode.nodeName.substr(9);
     function setXNodeAttributes(node, attrs) {
        $.map(node.attributes, function(attrNode) {
            var xName = attrNode.nodeName.substr(9);
-           if (attrNode.nodeName.startsWith('data-wlf-')
+           if (attrNode.nodeName.indexOf('data-wlf-') === 0
                && xName in attrs) {
                attrNode.nodeValue = attrs[xName];
            }
                && xName in attrs) {
                attrNode.nodeValue = attrs[xName];
            }
-           if (attrNode.nodeName.startsWith('x-attr-name-') 
+           if (attrNode.nodeName.indexOf('x-attr-name-') === 0
                && attrNode.nodeValue in attrs) {
                node.setAttribute('x-attr-value-' + attrNode.nodeName.substr("x-attr-name-".length),
                                  attrs[attrNode.nodeValue]);
                && attrNode.nodeValue in attrs) {
                node.setAttribute('x-attr-value-' + attrNode.nodeName.substr("x-attr-name-".length),
                                  attrs[attrNode.nodeValue]);
              });
        $overlay.append($attributes);
 
              });
        $overlay.append($attributes);
 
+    var overlayParent = $box[0].offsetParent || $box.parent();
        $overlay.css({
             position: 'absolute',
             height: h,
             left: x,
             top: y,
             width: w
        $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')) {
         
 
         if ($origin.is('.motyw')) {
                             }
                            /* Set attributres back to the node */
                            var attrs = {};
                             }
                            /* 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;
                                });
                                .each(function(i, textField) {
                                    attrs[textField.name] = textField.value;
                                });
 
                 $('.accept-button', $overlay).click(function(){
                     save();
 
                 $('.accept-button', $overlay).click(function(){
                     save();
+                    $(document).unbind('click.blur-overlay');
                 });
 
                 $(document).bind('click.blur-overlay', function(event){
                 });
 
                 $(document).bind('click.blur-overlay', function(event){