2018-06-17 16:07:19 +00:00
|
|
|
/**
|
|
|
|
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
|
|
|
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
2014-04-11 20:07:18 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents a list of {@link CKEDITOR.dom.node} objects.
|
2018-06-17 16:07:19 +00:00
|
|
|
* It is a wrapper for a native nodes list.
|
2014-04-11 20:07:18 +00:00
|
|
|
*
|
|
|
|
* var nodeList = CKEDITOR.document.getBody().getChildren();
|
|
|
|
* alert( nodeList.count() ); // number [0;N]
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @constructor Creates a document class instance.
|
|
|
|
* @param {Object} nativeList
|
|
|
|
*/
|
|
|
|
CKEDITOR.dom.nodeList = function( nativeList ) {
|
|
|
|
this.$ = nativeList;
|
|
|
|
};
|
|
|
|
|
|
|
|
CKEDITOR.dom.nodeList.prototype = {
|
|
|
|
/**
|
2018-06-17 16:07:19 +00:00
|
|
|
* Gets the count of nodes in this list.
|
2014-04-11 20:07:18 +00:00
|
|
|
*
|
|
|
|
* @returns {Number}
|
|
|
|
*/
|
|
|
|
count: function() {
|
|
|
|
return this.$.length;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2018-06-17 16:07:19 +00:00
|
|
|
* Gets the node from the list.
|
2014-04-11 20:07:18 +00:00
|
|
|
*
|
|
|
|
* @returns {CKEDITOR.dom.node}
|
|
|
|
*/
|
|
|
|
getItem: function( index ) {
|
|
|
|
if ( index < 0 || index >= this.$.length )
|
|
|
|
return null;
|
|
|
|
|
|
|
|
var $node = this.$[ index ];
|
|
|
|
return $node ? new CKEDITOR.dom.node( $node ) : null;
|
2018-06-17 16:07:19 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a node list as an array.
|
|
|
|
*
|
|
|
|
* @returns {CKEDITOR.dom.node[]}
|
|
|
|
*/
|
|
|
|
toArray: function() {
|
|
|
|
return CKEDITOR.tools.array.map( this.$, function( nativeEl ) {
|
|
|
|
return new CKEDITOR.dom.node( nativeEl );
|
|
|
|
} );
|
2014-04-11 20:07:18 +00:00
|
|
|
}
|
|
|
|
};
|