boundries → boundaries
authorJan Szejko <janek37@gmail.com>
Wed, 22 Feb 2017 16:22:55 +0000 (17:22 +0100)
committerJan Szejko <janek37@gmail.com>
Tue, 27 Mar 2018 15:00:17 +0000 (17:00 +0200)
(cherry picked from commit 215b225)

src/editor/modules/documentCanvas/canvas/canvas.js
src/editor/modules/documentCanvas/canvas/canvas.test.js
src/editor/plugins/core/core.js
src/editor/plugins/core/edumed/gaps/actions.js
src/editor/plugins/core/edumed/replace/actions.js
src/editor/plugins/core/footnote.js
src/editor/plugins/core/lists.js
src/smartxml/fragments.js
src/wlxml/extensions/list/list.test.js
src/wlxml/wlxml.test.js

index fffc61d..2776edb 100644 (file)
@@ -549,18 +549,18 @@ $.extend(Cursor.prototype, {
         return this.getSelectionAnchor();
     },
     getSelectionStart: function() {
-        return this.getSelectionBoundry('start');
+        return this.getSelectionBoundary('start');
     },
     getSelectionEnd: function() {
-        return this.getSelectionBoundry('end');
+        return this.getSelectionBoundary('end');
     },
     getSelectionAnchor: function() {
-        return this.getSelectionBoundry('anchor');
+        return this.getSelectionBoundary('anchor');
     },
     getSelectionFocus: function() {
-        return this.getSelectionBoundry('focus');
+        return this.getSelectionBoundary('focus');
     },
-    getSelectionBoundry: function(which) {
+    getSelectionBoundary: function(which) {
         /* globals window */
         var selection = window.getSelection(),
             anchorElement = this.canvas.getDocumentElement(selection.anchorNode),
index be4a8b9..028c767 100644 (file)
@@ -489,7 +489,7 @@ describe('Cursor', function() {
         });
     });
 
-    it('returns boundries of selection when browser selection not collapsed', function() {
+    it('returns boundaries of selection when browser selection not collapsed', function() {
         var c = getCanvasFromXML('<section>Alice <span>has</span> a <span>big</span> cat</section>'),
             dom = c.doc().dom,
             text = {
@@ -521,7 +521,7 @@ describe('Cursor', function() {
         });
     });
 
-    it('recognizes when browser selection boundries lies in sibling DocumentTextElements', function() {
+    it('recognizes when browser selection boundaries lies in sibling DocumentTextElements', function() {
         var c = getCanvasFromXML('<section>Alice <span>has</span> a <span>big</span> cat</section>'),
             dom = c.doc().dom,
             text = {
index 8ac4f63..6cb39e2 100644 (file)
@@ -486,7 +486,7 @@ var createWrapTextAction = function(createParams) {
                 });
             }
 
-            if(params.fragment instanceof params.fragment.TextRangeFragment && params.fragment.hasSiblingBoundries()) {
+            if(params.fragment instanceof params.fragment.TextRangeFragment && params.fragment.hasSiblingBoundaries()) {
                 parent = params.fragment.startNode.parent();
                 if(parent && parent.is(createParams.klass) || parent.isInside(createParams.klass)) {
                     return _.extend(state, {allowed: false});
@@ -618,7 +618,7 @@ var linkAction = {
         }
 
         if(params.fragment instanceof params.fragment.TextRangeFragment) {
-            if(!params.fragment.hasSiblingBoundries() || params.fragment.startNode.parent().is('link')) {
+            if(!params.fragment.hasSiblingBoundaries() || params.fragment.startNode.parent().is('link')) {
                 return {allowed: false};
             }
             return {
index e91faa4..e4d4e8a 100644 (file)
@@ -41,7 +41,7 @@ var createGap = {
             allowed: params.fragment &&
                         params.fragment.isValid() &&
                         params.fragment instanceof params.fragment.TextRangeFragment &&
-                        params.fragment.hasSiblingBoundries() &&
+                        params.fragment.hasSiblingBoundaries() &&
                         params.fragment.startNode.isInside('exercise.gap') &&
                         !params.fragment.startNode.isInside({tagName: 'aside', klass: 'gap'}),
                         
index be4782a..29eceb5 100644 (file)
@@ -54,7 +54,7 @@ var markToReplace = {
             allowed: params.fragment &&
                         params.fragment.isValid() &&
                         params.fragment instanceof params.fragment.TextRangeFragment &&
-                        params.fragment.hasSameBoundries() &&
+                        params.fragment.hasSameBoundaries() &&
                         params.fragment.startNode.isInside('exercise.replace') &&
                         !params.fragment.startNode.isInside({tagName: 'span', klass: 'answer'}),
                         
index 2fa314a..6c3004f 100644 (file)
@@ -45,7 +45,7 @@ var footnoteAction =  {
         if(!params.fragment || !params.fragment.isValid()) {
             return {allowed: false};
         }
-        if(params.fragment instanceof params.fragment.TextRangeFragment && params.fragment.hasSiblingBoundries()) {
+        if(params.fragment instanceof params.fragment.TextRangeFragment && params.fragment.hasSiblingBoundaries()) {
             return {
                 allowed: true,
                 description: gettext('Create footnote from selection'),
index 151103d..1ff6ccd 100644 (file)
@@ -4,11 +4,11 @@ define(function() {
 /* globals gettext, interpolate */
 
 
-var getBoundriesForAList = function(fragment) {
+var getBoundariesForAList = function(fragment) {
     var node;
 
-    if(fragment instanceof fragment.RangeFragment && fragment.hasSiblingBoundries()) {
-        return fragment.startNode.hasSameContextRoot(fragment.endNode) && fragment.boundriesSiblingParents();
+    if(fragment instanceof fragment.RangeFragment && fragment.hasSiblingBoundaries()) {
+        return fragment.startNode.hasSameContextRoot(fragment.endNode) && fragment.boundariesSiblingParents();
     }
     if(fragment instanceof fragment.NodeFragment) {
         node = fragment.node.getNearestElementNode();
@@ -23,10 +23,10 @@ var getBoundriesForAList = function(fragment) {
     }
 };
 
-var countItems = function(boundries) {
-    var ptr = boundries.node1,
+var countItems = function(boundaries) {
+    var ptr = boundaries.node1,
         c = 1;
-    while(ptr && !ptr.sameNode(boundries.node2)) {
+    while(ptr && !ptr.sameNode(boundaries.node2)) {
         c++;
         ptr = ptr.next();
     }
@@ -37,39 +37,39 @@ var toggleListAction = function(type) {
     
     var execute = {
         add: function(callback, params) {
-            var boundries = getBoundriesForAList(params.fragment),
+            var boundaries = getBoundariesForAList(params.fragment),
                 listParams = {klass: type === 'Bullet' ? 'list' : 'list.enum'},
                 action = this;
 
-            if(boundries && boundries.node1) {
-                boundries.node1.document.transaction(function() {
-                    var iterNode = boundries.node1;
+            if(boundaries && boundaries.node1) {
+                boundaries.node1.document.transaction(function() {
+                    var iterNode = boundaries.node1;
                     while(true) {
                         if(!iterNode.is({tagName: 'div', klass: 'p'})) {
                             if(iterNode.is({tagName: 'header'})) {
                                 var newNode = iterNode.setTag('div');
                                 newNode.setClass('p');
-                                if(iterNode.sameNode(boundries.node1)) {
-                                    boundries.node1 = newNode;
+                                if(iterNode.sameNode(boundaries.node1)) {
+                                    boundaries.node1 = newNode;
                                 }
-                                if(iterNode.sameNode(boundries.node2)) {
-                                    boundries.node2 = newNode;
+                                if(iterNode.sameNode(boundaries.node2)) {
+                                    boundaries.node2 = newNode;
                                 }
                                 iterNode = newNode;
                             } else {
                                 throw new Error('Invalid element');
                             }
                         }
-                        if(iterNode.sameNode(boundries.node2))
+                        if(iterNode.sameNode(boundaries.node2))
                             break;
                         iterNode = iterNode.next();
                     }
-                    listParams.node1 = boundries.node1;
-                    listParams.node2 = boundries.node2;
-                    var list = boundries.node1.document.createList(listParams),
+                    listParams.node1 = boundaries.node1;
+                    listParams.node2 = boundaries.node2;
+                    var list = boundaries.node1.document.createList(listParams),
                         item1 = list.object.getItem(0),
                         text = item1 ? item1.contents()[0] : undefined, //
-                        doc = boundries.node1.document;
+                        doc = boundaries.node1.document;
                     if(text) {
                         return doc.createFragment(doc.CaretFragment, {node: text, offset:0});
                     }
@@ -81,7 +81,7 @@ var toggleListAction = function(type) {
                     success: callback
                 });
             } else {
-                throw new Error('Invalid boundries');
+                throw new Error('Invalid boundaries');
             }
         },
         remove: function(callback, params) {
@@ -197,9 +197,9 @@ var toggleListAction = function(type) {
                 };
 
             }
-            var boundries = getBoundriesForAList(params.fragment);
-            if(boundries && boundries.node1.hasSameContextRoot(boundries.node2)) {
-                var iterNode = boundries.node1;
+            var boundaries = getBoundariesForAList(params.fragment);
+            if(boundaries && boundaries.node1.hasSameContextRoot(boundaries.node2)) {
+                var iterNode = boundaries.node1;
                 while(true) {
                     if(!iterNode.is({tagName: 'div', klass: 'p'}) && !iterNode.is({tagName: 'header'})) {
                         return {
@@ -207,14 +207,14 @@ var toggleListAction = function(type) {
                             description: gettext('Invalid element for a list item')
                         }
                     }
-                    if(iterNode.sameNode(boundries.node2))
+                    if(iterNode.sameNode(boundaries.node2))
                         break;
                     iterNode = iterNode.next();
                 }
 
                 return {
                     allowed: true,
-                    description: interpolate(gettext('Make %s fragment(s) into list'), [countItems(getBoundriesForAList(params.fragment))]),
+                    description: interpolate(gettext('Make %s fragment(s) into list'), [countItems(getBoundariesForAList(params.fragment))]),
                     execute: execute.add
                 };
             }
index d932592..f15a9e8 100644 (file)
@@ -76,20 +76,20 @@ $.extend(RangeFragment.prototype, {
         this.startNode = this.document.getNodeByPath(this.startNodePath);
         this.endNode = this.document.getNodeByPath(this.endNodePath);
     },
-    hasSiblingBoundries: function() {
+    hasSiblingBoundaries: function() {
         return this.isValid() && this.startNode.isSiblingOf(this.endNode);
     },
-    hasSameBoundries: function() {
+    hasSameBoundaries: function() {
         return this.isValid() && this.startNode.sameNode(this.endNode);
     },
-    boundriesSiblingParents: function() {
+    boundariesSiblingParents: function() {
         return this.startNode.document.getSiblingParents({
             node1: this.startNode,
             node2: this.endNode
         });
     },
     getCommonParent: function() {
-        var siblingParents = this.boundriesSiblingParents();
+        var siblingParents = this.boundariesSiblingParents();
         if(siblingParents) {
             return siblingParents.node1.parent();
         }
index 277e828..2887b4f 100644 (file)
@@ -60,7 +60,7 @@ describe('Lists extension', function() {
             expect(child3.contents()[0].getText()).to.equal('cat');
         });
 
-        it('Handles text nodes on the boundries', function() {
+        it('Handles text nodes on the boundaries', function() {
             var doc = getDocumentFromXML('<section>Alice<span>has</span>a cat</section>'),
                 textNode1 = doc.root.contents()[0],
                 textNode2 = doc.root.contents()[2];
index 93b6df9..c0ddff7 100644 (file)
@@ -55,7 +55,7 @@ describe('WLXMLDocument', function() {
             expect(node.contents()[0].getText()).to.equal('Alice ');
             expect(node.contents()[2].getText()).to.equal(' a cat');
         });
-        it('normalizes string of white characters to one space at the inline element boundries', function() {
+        it('normalizes string of white characters to one space at the inline element boundaries', function() {
             var node = nodeFromXML('<span>   Alice has a cat   </span>');
             expect(node.contents()[0].getText()).to.equal(' Alice has a cat ');
         });