Merge "Introduce helper functions."

This commit is contained in:
jenkins-bot 2013-03-22 19:28:34 +00:00 committed by Gerrit Code Review
commit f34407b31a

View file

@ -211,7 +211,7 @@ ve.ce.getOffsetFromElementNode = function ( domNode, domOffset, addOuterLength )
if ( addOuterLength === true ) {
return nodeModel.getOffset() + nodeModel.getOuterLength();
} else {
return nodeModel.getOffset();
return nodeModel.getOffset() + (nodeModel.isWrapped() ? 1 : 0);
}
} else {
node = $domNode.contents().last()[0];
@ -247,3 +247,15 @@ ve.ce.getOffsetOfSlug = function ( $node ) {
throw new Error( 'Incorrect slug location' );
}
};
ve.ce.isLeftOrRightArrowKey = function ( keyCode ) {
return keyCode === ve.Keys.DOM_VK_LEFT || keyCode === ve.Keys.DOM_VK_RIGHT;
};
ve.ce.isUpOrDownArrowKey = function ( keyCode ) {
return keyCode === ve.Keys.DOM_VK_UP || keyCode === ve.Keys.DOM_VK_DOWN;
};
ve.ce.isArrowKey = function ( keyCode ) {
return ve.ce.isLeftOrRightArrowKey( keyCode ) || ve.ce.isUpOrDownArrowKey( keyCode );
};