]>
Commit | Line | Data |
---|---|---|
3332bebe IB |
1 | /** |
2 | * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved. | |
3 | * For licensing, see LICENSE.md or http://ckeditor.com/license | |
4 | */ | |
5 | ||
6 | /** | |
7 | * Represents a list of {@link CKEDITOR.dom.node} objects. | |
8 | * It's a wrapper for native nodes list. | |
9 | * | |
10 | * var nodeList = CKEDITOR.document.getBody().getChildren(); | |
11 | * alert( nodeList.count() ); // number [0;N] | |
12 | * | |
13 | * @class | |
14 | * @constructor Creates a document class instance. | |
15 | * @param {Object} nativeList | |
16 | */ | |
17 | CKEDITOR.dom.nodeList = function( nativeList ) { | |
18 | this.$ = nativeList; | |
19 | }; | |
20 | ||
21 | CKEDITOR.dom.nodeList.prototype = { | |
22 | /** | |
23 | * Get count of nodes in this list. | |
24 | * | |
25 | * @returns {Number} | |
26 | */ | |
27 | count: function() { | |
28 | return this.$.length; | |
29 | }, | |
30 | ||
31 | /** | |
32 | * Get node from the list. | |
33 | * | |
34 | * @returns {CKEDITOR.dom.node} | |
35 | */ | |
36 | getItem: function( index ) { | |
37 | if ( index < 0 || index >= this.$.length ) | |
38 | return null; | |
39 | ||
40 | var $node = this.$[ index ]; | |
41 | return $node ? new CKEDITOR.dom.node( $node ) : null; | |
42 | } | |
43 | }; |