Browse Source

Rename makePosition* to create*.

Piotr Jasiun 10 years ago
parent
commit
5e237482a1

+ 5 - 5
packages/ckeditor5-utils/src/document/position.js

@@ -54,7 +54,7 @@ CKEDITOR.define( [ 'utils', 'ckeditorerror' ], function( utils, CKEditorError )
 		 * @param {document.Element} parent Position parent element.
 		 * @param {Number} offset Position offset.
 		 */
-		static makePositionFromParentAndOffset( parent, offset ) {
+		static createFromParentAndOffset( parent, offset ) {
 			var path = parent.getPath();
 
 			path.push( offset );
@@ -67,7 +67,7 @@ CKEDITOR.define( [ 'utils', 'ckeditorerror' ], function( utils, CKEditorError )
 		 *
 		 * @param {document.node} node Node the position should be directly before.
 		 */
-		static makePositionBefore( node ) {
+		static createBefore( node ) {
 			if ( !node.parent ) {
 				/**
 				 * You can not make position before root.
@@ -78,7 +78,7 @@ CKEDITOR.define( [ 'utils', 'ckeditorerror' ], function( utils, CKEditorError )
 				throw new CKEditorError( 'position-before-root: You can not make position before root.', { root: node } );
 			}
 
-			return Position.makePositionFromParentAndOffset( node.parent, node.positionInParent );
+			return Position.createFromParentAndOffset( node.parent, node.positionInParent );
 		}
 
 		/**
@@ -86,7 +86,7 @@ CKEDITOR.define( [ 'utils', 'ckeditorerror' ], function( utils, CKEditorError )
 		 *
 		 * @param {document.node} node Node the position should be directly after.
 		 */
-		static makePositionAfter( node ) {
+		static createAfter( node ) {
 			if ( !node.parent ) {
 				/**
 				 * You can not make position after root.
@@ -97,7 +97,7 @@ CKEDITOR.define( [ 'utils', 'ckeditorerror' ], function( utils, CKEditorError )
 				throw new CKEditorError( 'position-after-root: You can not make position after root.', { root: node } );
 			}
 
-			return Position.makePositionFromParentAndOffset( node.parent, node.positionInParent + 1 );
+			return Position.createFromParentAndOffset( node.parent, node.positionInParent + 1 );
 		}
 
 		/**

+ 6 - 6
packages/ckeditor5-utils/src/document/positioniterator.js

@@ -77,15 +77,15 @@ CKEDITOR.define( [
 			var nodeAfter = position.nodeAfter;
 
 			if ( nodeAfter instanceof Element ) {
-				this.position = Position.makePositionFromParentAndOffset( nodeAfter, 0 );
+				this.position = Position.createFromParentAndOffset( nodeAfter, 0 );
 
 				return formatReturnValue( OPENING_TAG, nodeAfter );
 			} else if ( nodeAfter instanceof Character ) {
-				this.position = Position.makePositionFromParentAndOffset( parent, position.offset + 1 );
+				this.position = Position.createFromParentAndOffset( parent, position.offset + 1 );
 
 				return formatReturnValue( CHARACTER, nodeAfter );
 			} else {
-				this.position = Position.makePositionFromParentAndOffset( parent.parent, parent.positionInParent + 1 );
+				this.position = Position.createFromParentAndOffset( parent.parent, parent.positionInParent + 1 );
 
 				return formatReturnValue( CLOSING_TAG, this.position.nodeBefore );
 			}
@@ -117,15 +117,15 @@ CKEDITOR.define( [
 			var nodeBefore = position.nodeBefore;
 
 			if ( nodeBefore instanceof Element ) {
-				this.position = Position.makePositionFromParentAndOffset( nodeBefore, nodeBefore.getChildCount() );
+				this.position = Position.createFromParentAndOffset( nodeBefore, nodeBefore.getChildCount() );
 
 				return formatReturnValue( CLOSING_TAG, nodeBefore );
 			} else if ( nodeBefore instanceof Character ) {
-				this.position = Position.makePositionFromParentAndOffset( parent, position.offset - 1 );
+				this.position = Position.createFromParentAndOffset( parent, position.offset - 1 );
 
 				return formatReturnValue( CHARACTER, nodeBefore );
 			} else {
-				this.position = Position.makePositionFromParentAndOffset( parent.parent, parent.positionInParent );
+				this.position = Position.createFromParentAndOffset( parent.parent, parent.positionInParent );
 
 				return formatReturnValue( OPENING_TAG, this.position.nodeAfter );
 			}

+ 33 - 33
packages/ckeditor5-utils/tests/document/position.js

@@ -72,40 +72,40 @@ describe( 'position', function() {
 	it( 'should make positions form node and offset', function() {
 		var Position = modules[ 'document/position' ];
 
-		expect( Position.makePositionFromParentAndOffset( root, 0 ) ).to.have.property( 'path' ).that.deep.equals( [ 0 ] );
-		expect( Position.makePositionFromParentAndOffset( root, 1 ) ).to.have.property( 'path' ).that.deep.equals( [ 1 ] );
-		expect( Position.makePositionFromParentAndOffset( root, 2 ) ).to.have.property( 'path' ).that.deep.equals( [ 2 ] );
+		expect( Position.createFromParentAndOffset( root, 0 ) ).to.have.property( 'path' ).that.deep.equals( [ 0 ] );
+		expect( Position.createFromParentAndOffset( root, 1 ) ).to.have.property( 'path' ).that.deep.equals( [ 1 ] );
+		expect( Position.createFromParentAndOffset( root, 2 ) ).to.have.property( 'path' ).that.deep.equals( [ 2 ] );
 
-		expect( Position.makePositionFromParentAndOffset( p, 0 ) ).to.have.property( 'path' ).that.deep.equals( [ 0, 0 ] );
+		expect( Position.createFromParentAndOffset( p, 0 ) ).to.have.property( 'path' ).that.deep.equals( [ 0, 0 ] );
 
-		expect( Position.makePositionFromParentAndOffset( ul, 0 ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0 ] );
-		expect( Position.makePositionFromParentAndOffset( ul, 1 ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1 ] );
-		expect( Position.makePositionFromParentAndOffset( ul, 2 ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 2 ] );
+		expect( Position.createFromParentAndOffset( ul, 0 ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0 ] );
+		expect( Position.createFromParentAndOffset( ul, 1 ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1 ] );
+		expect( Position.createFromParentAndOffset( ul, 2 ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 2 ] );
 
-		expect( Position.makePositionFromParentAndOffset( li1, 0 ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 0 ] );
-		expect( Position.makePositionFromParentAndOffset( li1, 1 ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 1 ] );
-		expect( Position.makePositionFromParentAndOffset( li1, 2 ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 2 ] );
-		expect( Position.makePositionFromParentAndOffset( li1, 3 ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 3 ] );
+		expect( Position.createFromParentAndOffset( li1, 0 ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 0 ] );
+		expect( Position.createFromParentAndOffset( li1, 1 ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 1 ] );
+		expect( Position.createFromParentAndOffset( li1, 2 ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 2 ] );
+		expect( Position.createFromParentAndOffset( li1, 3 ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 3 ] );
 	} );
 
 	it( 'should make positions before elements', function() {
 		var Position = modules[ 'document/position' ];
 
-		expect( Position.makePositionBefore( p ) ).to.have.property( 'path' ).that.deep.equals( [ 0 ] );
+		expect( Position.createBefore( p ) ).to.have.property( 'path' ).that.deep.equals( [ 0 ] );
 
-		expect( Position.makePositionBefore( ul ) ).to.have.property( 'path' ).that.deep.equals( [ 1 ] );
+		expect( Position.createBefore( ul ) ).to.have.property( 'path' ).that.deep.equals( [ 1 ] );
 
-		expect( Position.makePositionBefore( li1 ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0 ] );
+		expect( Position.createBefore( li1 ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0 ] );
 
-		expect( Position.makePositionBefore( f ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 0 ] );
-		expect( Position.makePositionBefore( o ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 1 ] );
-		expect( Position.makePositionBefore( z ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 2 ] );
+		expect( Position.createBefore( f ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 0 ] );
+		expect( Position.createBefore( o ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 1 ] );
+		expect( Position.createBefore( z ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 2 ] );
 
-		expect( Position.makePositionBefore( li2 ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1 ] );
+		expect( Position.createBefore( li2 ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1 ] );
 
-		expect( Position.makePositionBefore( b ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 0 ] );
-		expect( Position.makePositionBefore( a ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 1 ] );
-		expect( Position.makePositionBefore( r ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 2 ] );
+		expect( Position.createBefore( b ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 0 ] );
+		expect( Position.createBefore( a ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 1 ] );
+		expect( Position.createBefore( r ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 2 ] );
 	} );
 
 	it( 'should throw error if one try to make positions before root', function() {
@@ -113,28 +113,28 @@ describe( 'position', function() {
 		var CKEditorError = modules.ckeditorerror;
 
 		expect( function() {
-			Position.makePositionBefore( root );
+			Position.createBefore( root );
 		} ).to.throw( CKEditorError, /position-before-root/ );
 	} );
 
 	it( 'should make positions after elements', function() {
 		var Position = modules[ 'document/position' ];
 
-		expect( Position.makePositionAfter( p ) ).to.have.property( 'path' ).that.deep.equals( [ 1 ] );
+		expect( Position.createAfter( p ) ).to.have.property( 'path' ).that.deep.equals( [ 1 ] );
 
-		expect( Position.makePositionAfter( ul ) ).to.have.property( 'path' ).that.deep.equals( [ 2 ] );
+		expect( Position.createAfter( ul ) ).to.have.property( 'path' ).that.deep.equals( [ 2 ] );
 
-		expect( Position.makePositionAfter( li1 ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1 ] );
+		expect( Position.createAfter( li1 ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1 ] );
 
-		expect( Position.makePositionAfter( f ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 1 ] );
-		expect( Position.makePositionAfter( o ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 2 ] );
-		expect( Position.makePositionAfter( z ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 3 ] );
+		expect( Position.createAfter( f ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 1 ] );
+		expect( Position.createAfter( o ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 2 ] );
+		expect( Position.createAfter( z ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 3 ] );
 
-		expect( Position.makePositionAfter( li2 ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 2 ] );
+		expect( Position.createAfter( li2 ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 2 ] );
 
-		expect( Position.makePositionAfter( b ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 1 ] );
-		expect( Position.makePositionAfter( a ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 2 ] );
-		expect( Position.makePositionAfter( r ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 3 ] );
+		expect( Position.createAfter( b ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 1 ] );
+		expect( Position.createAfter( a ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 2 ] );
+		expect( Position.createAfter( r ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 3 ] );
 	} );
 
 	it( 'should throw error if one try to make positions after root', function() {
@@ -142,7 +142,7 @@ describe( 'position', function() {
 		var CKEditorError = modules.ckeditorerror;
 
 		expect( function() {
-			Position.makePositionAfter( root );
+			Position.createAfter( root );
 		} ).to.throw( CKEditorError, /position-after-root/ );
 	} );