summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
b6d0750)
(cherry picked from commit
215b225)
return this.getSelectionAnchor();
},
getSelectionStart: function() {
return this.getSelectionAnchor();
},
getSelectionStart: function() {
- return this.getSelectionBoundry('start');
+ return this.getSelectionBoundary('start');
},
getSelectionEnd: function() {
},
getSelectionEnd: function() {
- return this.getSelectionBoundry('end');
+ return this.getSelectionBoundary('end');
},
getSelectionAnchor: function() {
},
getSelectionAnchor: function() {
- return this.getSelectionBoundry('anchor');
+ return this.getSelectionBoundary('anchor');
},
getSelectionFocus: function() {
},
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),
/* globals window */
var selection = window.getSelection(),
anchorElement = this.canvas.getDocumentElement(selection.anchorNode),
- 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 = {
var c = getCanvasFromXML('<section>Alice <span>has</span> a <span>big</span> cat</section>'),
dom = c.doc().dom,
text = {
- 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 = {
var c = getCanvasFromXML('<section>Alice <span>has</span> a <span>big</span> cat</section>'),
dom = c.doc().dom,
text = {
- 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});
parent = params.fragment.startNode.parent();
if(parent && parent.is(createParams.klass) || parent.isInside(createParams.klass)) {
return _.extend(state, {allowed: false});
}
if(params.fragment instanceof params.fragment.TextRangeFragment) {
}
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 {
return {allowed: false};
}
return {
allowed: params.fragment &&
params.fragment.isValid() &&
params.fragment instanceof params.fragment.TextRangeFragment &&
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'}),
params.fragment.startNode.isInside('exercise.gap') &&
!params.fragment.startNode.isInside({tagName: 'aside', klass: 'gap'}),
allowed: params.fragment &&
params.fragment.isValid() &&
params.fragment instanceof params.fragment.TextRangeFragment &&
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'}),
params.fragment.startNode.isInside('exercise.replace') &&
!params.fragment.startNode.isInside({tagName: 'span', klass: 'answer'}),
if(!params.fragment || !params.fragment.isValid()) {
return {allowed: false};
}
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'),
return {
allowed: true,
description: gettext('Create footnote from selection'),
/* globals gettext, interpolate */
/* globals gettext, interpolate */
-var getBoundriesForAList = function(fragment) {
+var getBoundariesForAList = function(fragment) {
- 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();
}
if(fragment instanceof fragment.NodeFragment) {
node = fragment.node.getNearestElementNode();
-var countItems = function(boundries) {
- var ptr = boundries.node1,
+var countItems = function(boundaries) {
+ var ptr = boundaries.node1,
- while(ptr && !ptr.sameNode(boundries.node2)) {
+ while(ptr && !ptr.sameNode(boundaries.node2)) {
var execute = {
add: function(callback, params) {
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;
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');
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');
}
}
}
iterNode = newNode;
} else {
throw new Error('Invalid element');
}
}
- if(iterNode.sameNode(boundries.node2))
+ if(iterNode.sameNode(boundaries.node2))
break;
iterNode = iterNode.next();
}
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, //
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});
}
if(text) {
return doc.createFragment(doc.CaretFragment, {node: text, offset:0});
}
success: callback
});
} else {
success: callback
});
} else {
- throw new Error('Invalid boundries');
+ throw new Error('Invalid boundaries');
}
},
remove: function(callback, params) {
}
},
remove: function(callback, params) {
- 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 {
while(true) {
if(!iterNode.is({tagName: 'div', klass: 'p'}) && !iterNode.is({tagName: 'header'})) {
return {
description: gettext('Invalid element for a list item')
}
}
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,
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
};
}
execute: execute.add
};
}
this.startNode = this.document.getNodeByPath(this.startNodePath);
this.endNode = this.document.getNodeByPath(this.endNodePath);
},
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);
},
return this.isValid() && this.startNode.isSiblingOf(this.endNode);
},
- hasSameBoundries: function() {
+ hasSameBoundaries: function() {
return this.isValid() && this.startNode.sameNode(this.endNode);
},
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() {
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();
}
if(siblingParents) {
return siblingParents.node1.parent();
}
expect(child3.contents()[0].getText()).to.equal('cat');
});
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];
var doc = getDocumentFromXML('<section>Alice<span>has</span>a cat</section>'),
textNode1 = doc.root.contents()[0],
textNode2 = doc.root.contents()[2];
expect(node.contents()[0].getText()).to.equal('Alice ');
expect(node.contents()[2].getText()).to.equal(' a cat');
});
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 ');
});
var node = nodeFromXML('<span> Alice has a cat </span>');
expect(node.contents()[0].getText()).to.equal(' Alice has a cat ');
});