Refactoring: removing mutation observer
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 18 Jun 2013 09:33:14 +0000 (11:33 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 18 Jun 2013 09:33:14 +0000 (11:33 +0200)
modules/documentCanvas/documentCanvas.js

index 9d2e725..bd959fe 100644 (file)
@@ -50,23 +50,6 @@ return function(sandbox) {
                     view.insertNewNode(null, null);\r
                 }\r
             });\r
                     view.insertNewNode(null, null);\r
                 }\r
             });\r
-            \r
-            \r
-            var observer = new MutationObserver(function(mutations) {\r
-              mutations.forEach(function(mutation) {\r
-                _.each(mutation.addedNodes, function(node) {\r
-                    node = $(node);\r
-                    node.parent().find('[wlxml-tag]').each(function() {\r
-                        var tag = $(this);\r
-                        if(!tag.attr('id'))\r
-                            tag.attr('id', 'xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {var r = Math.random()*16|0,v=c=='x'?r:r&0x3|0x8;return v.toString(16);}));\r
-                    });\r
-                });\r
-              });    \r
-            });\r
-            var config = { attributes: true, childList: true, characterData: true, subtree: true };\r
-            observer.observe(this.node.find('#rng-module-documentCanvas-contentWrapper')[0], config);\r
-            \r
             this.gridToggled = false;\r
         },\r
         _createNode: function(wlxmlTag, wlxmlClass) {\r
             this.gridToggled = false;\r
         },\r
         _createNode: function(wlxmlTag, wlxmlClass) {\r
@@ -76,6 +59,7 @@ return function(sandbox) {
             toret.attr('wlxml-tag', wlxmlTag);\r
             if(wlxmlClass)\r
                 toret.attr('wlxml-class', wlxmlClass);\r
             toret.attr('wlxml-tag', wlxmlTag);\r
             if(wlxmlClass)\r
                 toret.attr('wlxml-class', wlxmlClass);\r
+            toret.attr('id', 'xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {var r = Math.random()*16|0,v=c=='x'?r:r&0x3|0x8;return v.toString(16);}));\r
             return toret;\r
         },\r
         insertNewNode: function(wlxmlTag, wlxmlClass) {\r
             return toret;\r
         },\r
         insertNewNode: function(wlxmlTag, wlxmlClass) {\r