From: Aleksander Ɓukasz Date: Wed, 20 Nov 2013 16:25:37 +0000 (+0100) Subject: linting X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/2c0f5a6242a51bab12bd383b0097cba6027020dd linting --- diff --git a/src/editor/modules/documentCanvas/canvas/canvas.test.js b/src/editor/modules/documentCanvas/canvas/canvas.test.js index 10a2376..35ad728 100644 --- a/src/editor/modules/documentCanvas/canvas/canvas.test.js +++ b/src/editor/modules/documentCanvas/canvas/canvas.test.js @@ -1,36 +1,35 @@ 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('
Alice has a cat!'), 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) { @@ -55,10 +54,11 @@ describe('Cursor', function() { 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'); diff --git a/src/editor/modules/documentCanvas/canvas/utils.js b/src/editor/modules/documentCanvas/canvas/utils.js index 327b0b0..9f5ee46 100644 --- a/src/editor/modules/documentCanvas/canvas/utils.js +++ b/src/editor/modules/documentCanvas/canvas/utils.js @@ -10,6 +10,7 @@ var nearestInDocumentOrder = function(selector, direction, element) { 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); }); @@ -17,14 +18,14 @@ var nearestInDocumentOrder = function(selector, direction, element) { 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()); } }; @@ -37,11 +38,12 @@ var findCanvasElementInParent = function(wlxmlChildNode, wlxmlParentNode) { 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, diff --git a/src/editor/modules/documentCanvas/canvas/utils.test.js b/src/editor/modules/documentCanvas/canvas/utils.test.js index c93e74b..2488535 100644 --- a/src/editor/modules/documentCanvas/canvas/utils.test.js +++ b/src/editor/modules/documentCanvas/canvas/utils.test.js @@ -1,10 +1,14 @@ 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; diff --git a/src/editor/modules/documentCanvas/documentCanvas.js b/src/editor/modules/documentCanvas/documentCanvas.js index 3ca4e46..6331922 100644 --- a/src/editor/modules/documentCanvas/documentCanvas.js +++ b/src/editor/modules/documentCanvas/documentCanvas.js @@ -1,10 +1,11 @@ // 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'; @@ -34,7 +35,7 @@ return function(sandbox) { /* public api */ return { start: function() { sandbox.publish('ready'); }, - getView: function() { + getView: function() { return canvasWrapper; }, setDocument: function(wlxmlDocument) {