fourth batch: fixing blocking span - passing all tests, linting
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 31 Mar 2014 14:02:24 +0000 (16:02 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 6 May 2014 09:37:47 +0000 (11:37 +0200)
src/editor/modules/documentCanvas/canvas/genericElement.js

index 7d5d986..8b7d2fb 100644 (file)
@@ -2,7 +2,8 @@ define(function(require) {
     
 'use strict';
 
     
 'use strict';
 
-var documentElement = require('./documentElement'),
+var $ = require('libs/jquery'),
+    documentElement = require('./documentElement'),
     utils = require('./utils'),
     wlxmlUtils = require('utils/wlxml');
 
     utils = require('./utils'),
     wlxmlUtils = require('utils/wlxml');
 
@@ -143,6 +144,19 @@ var generic = {
         this.wlxmlNode.contents().forEach(function(node) {
             this._container().append(this.canvas.createElement(node).dom());
         }.bind(this));
         this.wlxmlNode.contents().forEach(function(node) {
             this._container().append(this.canvas.createElement(node).dom());
         }.bind(this));
+        this.refresh();
+
+    },
+    refresh: function() {
+        if(this.wlxmlNode.getTagName() === 'span') {
+            if(this.containsBlock()) {
+                this.displayAsBlock();
+            } else {
+                this.displayInline();
+            }
+        } else {
+            this.displayAsBlock();
+        }
     },
     containsBlock: function() {
         return this.children()
     },
     containsBlock: function() {
         return this.children()