fnp
/
fnpeditor.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
4ddf364
)
linting
author
Aleksander Łukasz
<aleksander.lukasz@nowoczesnapolska.org.pl>
Wed, 20 Nov 2013 16:25:37 +0000
(17:25 +0100)
committer
Aleksander Łukasz
<aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 2 Dec 2013 13:50:53 +0000
(14:50 +0100)
src/editor/modules/documentCanvas/canvas/canvas.test.js
patch
|
blob
|
history
src/editor/modules/documentCanvas/canvas/utils.js
patch
|
blob
|
history
src/editor/modules/documentCanvas/canvas/utils.test.js
patch
|
blob
|
history
src/editor/modules/documentCanvas/documentCanvas.js
patch
|
blob
|
history
diff --git
a/src/editor/modules/documentCanvas/canvas/canvas.test.js
b/src/editor/modules/documentCanvas/canvas/canvas.test.js
index
10a2376
..
35ad728
100644
(file)
--- a/
src/editor/modules/documentCanvas/canvas/canvas.test.js
+++ b/
src/editor/modules/documentCanvas/canvas/canvas.test.js
@@
-1,36
+1,35
@@
define([
define([
+'libs/jquery',
'libs/chai',
'libs/chai',
+'libs/sinon',
'modules/documentCanvas/canvas/canvas',
'modules/documentCanvas/canvas/documentElement',
'modules/documentCanvas/canvas/utils',
'wlxml/wlxml'
'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';
'use strict';
+/* global describe, it, beforeEach, afterEach */
var expect = chai.expect;
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);
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);
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) {
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;
});
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 nodes[0];
+ }
return null;
return null;
- }
+ }
;
beforeEach(function() {
getSelection = sinon.stub(window, 'getSelection');
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
(file)
--- 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() {
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 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;
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) {
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) {
var parentElement = findCanvasElement(wlxmlParentNode),
toret;
parentElement.children().forEach(function(child) {
- if(child.data('wlxmlNode').sameNode(wlxmlChildNode))
+ if(child.data('wlxmlNode').sameNode(wlxmlChildNode))
{
toret = child;
toret = child;
+ }
});
return toret;
});
return toret;
-}
+}
;
return {
nearestInDocumentOrder: nearestInDocumentOrder,
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
(file)
--- a/
src/editor/modules/documentCanvas/canvas/utils.test.js
+++ b/
src/editor/modules/documentCanvas/canvas/utils.test.js
@@
-1,10
+1,14
@@
define([
define([
+'libs/jquery',
'libs/chai',
'modules/documentCanvas/canvas/utils'
'libs/chai',
'modules/documentCanvas/canvas/utils'
-], function(chai, utils) {
+], function(
$,
chai, utils) {
'use strict';
'use strict';
+/* jshint multistr:true */
+/* global describe, it */
+
var expect = chai.expect;
var expect = chai.expect;
diff --git
a/src/editor/modules/documentCanvas/documentCanvas.js
b/src/editor/modules/documentCanvas/documentCanvas.js
index
3ca4e46
..
6331922
100644
(file)
--- 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([
// Module that implements main WYSIWIG edit area
define([
+'libs/jquery',
'libs/underscore',
'./canvas/canvas',
'./commands',
'libs/underscore',
'./canvas/canvas',
'./commands',
-'libs/text!./template.html'], function(_, canvas3, commands, template) {
+'libs/text!./template.html'], function(
$,
_, canvas3, commands, template) {
'use strict';
'use strict';
@@
-34,7
+35,7
@@
return function(sandbox) {
/* public api */
return {
start: function() { sandbox.publish('ready'); },
/* public api */
return {
start: function() { sandbox.publish('ready'); },
- getView: function() {
+ getView: function() {
return canvasWrapper;
},
setDocument: function(wlxmlDocument) {
return canvasWrapper;
},
setDocument: function(wlxmlDocument) {