define([
+'libs/jquery',
'libs/chai',
+'libs/sinon',
'modules/documentCanvas/canvas/canvas',
'modules/documentCanvas/canvas/documentElement',
'modules/documentCanvas/canvas/utils',
'wlxml/wlxml'
-], function(chai, canvas, documentElement, utils, wlxml) {
+], function($, chai, sinon, canvas, documentElement, utils, wlxml) {
'use strict';
+/* global describe, it, beforeEach, afterEach */
var expect = chai.expect;
-
-var nodeFromXML = function(xml) {
- return wlxml.WLXMLElementNodeFromXML(xml);
-};
-
var getCanvasFromXML = function(xml) {
return canvas.fromXMLDocument(wlxml.WLXMLDocumentFromXML(xml));
};
var wait = function(callback, timeout) {
return window.setTimeout(callback, timeout || 0.5);
-}
+};
+
describe('new Canvas', function() {
it('abc', function() {
var doc = wlxml.WLXMLDocumentFromXML('<section>Alice <span>has</span> a cat!</div>'),
c = canvas.fromXMLDocument(doc);
- expect(c.doc().children()).to.have.length(3)
+ expect(c.doc().children()).to.have.length(3);
});
-})
+});
describe('Handling empty text nodes', function() {
it('puts zero width space into node with about to be remove text', function(done) {
var nodes = inside.find(':not(iframe)').addBack().contents().filter(function() {
return this.nodeType === Node.TEXT_NODE && this.data === text;
});
- if(nodes.length)
+ if(nodes.length) {
return nodes[0];
+ }
return null;
- }
+ };
beforeEach(function() {
getSelection = sinon.stub(window, 'getSelection');
parent = parents.length ? $(parents[parents.length-1]) : element;
var adj = parent.find(selector).filter(function() {
+ /*jshint bitwise: false*/
return this.compareDocumentPosition(element) & (direction === 'above' ? Node.DOCUMENT_POSITION_FOLLOWING : Node.DOCUMENT_POSITION_PRECEDING);
});
return adj[direction === 'above' ? adj.length-1 : 0];
}
return null;
-}
+};
var findCanvasElement = function(node) {
if(node.nodeType === Node.ELEMENT_NODE) {
return node.getData('canvasElement');
}
if(node.nodeType === Node.TEXT_NODE) {
- return findCanvasElementInParent(node, node.parent())
+ return findCanvasElementInParent(node, node.parent());
}
};
var parentElement = findCanvasElement(wlxmlParentNode),
toret;
parentElement.children().forEach(function(child) {
- if(child.data('wlxmlNode').sameNode(wlxmlChildNode))
+ if(child.data('wlxmlNode').sameNode(wlxmlChildNode)) {
toret = child;
+ }
});
return toret;
-}
+};
return {
nearestInDocumentOrder: nearestInDocumentOrder,
define([
+'libs/jquery',
'libs/chai',
'modules/documentCanvas/canvas/utils'
-], function(chai, utils) {
+], function($, chai, utils) {
'use strict';
+/* jshint multistr:true */
+/* global describe, it */
+
var expect = chai.expect;
// Module that implements main WYSIWIG edit area
define([
+'libs/jquery',
'libs/underscore',
'./canvas/canvas',
'./commands',
-'libs/text!./template.html'], function(_, canvas3, commands, template) {
+'libs/text!./template.html'], function($, _, canvas3, commands, template) {
'use strict';
/* public api */
return {
start: function() { sandbox.publish('ready'); },
- getView: function() {
+ getView: function() {
return canvasWrapper;
},
setDocument: function(wlxmlDocument) {