editor: removing unsued code (canvas grid)
[fnpeditor.git] / src / editor / modules / documentCanvas / canvas / canvas.js
index ab31ee1..d4e16ad 100644 (file)
@@ -60,7 +60,8 @@ $.extend(TextHandler.prototype, {
 });
 
 
-var Canvas = function(wlxmlDocument, elements) {
+var Canvas = function(wlxmlDocument, elements, metadata) {
+    this.metadata = metadata || {};
     this.elementsRegister = new ElementsRegister(documentElement.DocumentNodeElement, nullElement);
 
     elements = [
@@ -137,8 +138,10 @@ $.extend(Canvas.prototype, Backbone.Events, {
     },
 
     reloadRoot: function() {
+        if(this.rootElement) {
+            this.rootElement.detach();
+        }
         this.rootElement = this.createElement(this.wlxmlDocument.root);
-        this.rootWrapper.empty();
         this.rootWrapper.append(this.rootElement.dom);
     },
 
@@ -346,7 +349,7 @@ $.extend(Canvas.prototype, Backbone.Events, {
             if(byBrowser && byBrowser.parent().sameNode(nodeToLand)) {
                 return byBrowser;
             }
-            return e.getVerticallyFirstTextElement();
+            return _.isFunction(e.getVerticallyFirstTextElement) ? e.getVerticallyFirstTextElement({considerChildren: false}) : null;
         }.bind(this);
         var _markAsCurrent = function(element) {
             if(element instanceof documentElement.DocumentTextElement) {
@@ -415,14 +418,6 @@ $.extend(Canvas.prototype, Backbone.Events, {
         if(position.element) {
             this._moveCaretToTextElement(position.element, position.offset);
         }
-    },
-
-    toggleGrid: function() {
-        this.rootWrapper.toggleClass('grid-on');
-        this.trigger('changed');
-    },
-    isGridToggled: function() {
-        return this.rootWrapper.hasClass('grid-on');
     }
 });
 
@@ -614,8 +609,8 @@ $.extend(Cursor.prototype, {
 });
 
 return {
-    fromXMLDocument: function(wlxmlDocument, elements) {
-        return new Canvas(wlxmlDocument, elements);
+    fromXMLDocument: function(wlxmlDocument, elements, metadata) {
+        return new Canvas(wlxmlDocument, elements, metadata);
     }
 };