From: Jan Szejko Date: Wed, 22 Feb 2017 16:22:55 +0000 (+0100) Subject: boundries → boundaries X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/215b225ef3f6716982d4bdc873c08f8561533a3d boundries → boundaries --- diff --git a/src/editor/modules/documentCanvas/canvas/canvas.js b/src/editor/modules/documentCanvas/canvas/canvas.js index bc7e2a7..7ebecc8 100644 --- a/src/editor/modules/documentCanvas/canvas/canvas.js +++ b/src/editor/modules/documentCanvas/canvas/canvas.js @@ -554,18 +554,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), diff --git a/src/editor/modules/documentCanvas/canvas/canvas.test.js b/src/editor/modules/documentCanvas/canvas/canvas.test.js index be4a8b9..028c767 100644 --- a/src/editor/modules/documentCanvas/canvas/canvas.test.js +++ b/src/editor/modules/documentCanvas/canvas/canvas.test.js @@ -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('
Alice has a big cat
'), 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('
Alice has a big cat
'), dom = c.doc().dom, text = { diff --git a/src/editor/plugins/core/core.js b/src/editor/plugins/core/core.js index c56c5db..bc74e6b 100644 --- a/src/editor/plugins/core/core.js +++ b/src/editor/plugins/core/core.js @@ -488,7 +488,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}); @@ -616,7 +616,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 { diff --git a/src/editor/plugins/core/edumed/gaps/actions.js b/src/editor/plugins/core/edumed/gaps/actions.js index e91faa4..e4d4e8a 100644 --- a/src/editor/plugins/core/edumed/gaps/actions.js +++ b/src/editor/plugins/core/edumed/gaps/actions.js @@ -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'}), diff --git a/src/editor/plugins/core/edumed/replace/actions.js b/src/editor/plugins/core/edumed/replace/actions.js index be4782a..29eceb5 100644 --- a/src/editor/plugins/core/edumed/replace/actions.js +++ b/src/editor/plugins/core/edumed/replace/actions.js @@ -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'}), diff --git a/src/editor/plugins/core/footnote.js b/src/editor/plugins/core/footnote.js index 2fa314a..6c3004f 100644 --- a/src/editor/plugins/core/footnote.js +++ b/src/editor/plugins/core/footnote.js @@ -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'), diff --git a/src/editor/plugins/core/lists.js b/src/editor/plugins/core/lists.js index 151103d..1ff6ccd 100644 --- a/src/editor/plugins/core/lists.js +++ b/src/editor/plugins/core/lists.js @@ -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 }; } diff --git a/src/smartxml/fragments.js b/src/smartxml/fragments.js index d932592..f15a9e8 100644 --- a/src/smartxml/fragments.js +++ b/src/smartxml/fragments.js @@ -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(); } diff --git a/src/wlxml/extensions/list/list.test.js b/src/wlxml/extensions/list/list.test.js index 277e828..2887b4f 100644 --- a/src/wlxml/extensions/list/list.test.js +++ b/src/wlxml/extensions/list/list.test.js @@ -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('
Alicehasa cat
'), textNode1 = doc.root.contents()[0], textNode2 = doc.root.contents()[2]; diff --git a/src/wlxml/wlxml.test.js b/src/wlxml/wlxml.test.js index 93b6df9..c0ddff7 100644 --- a/src/wlxml/wlxml.test.js +++ b/src/wlxml/wlxml.test.js @@ -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(' Alice has a cat '); expect(node.contents()[0].getText()).to.equal(' Alice has a cat '); });