Index: trunk/parsers/wikidom/lib/synth/bases/es.ModelContainerItem.js |
— | — | @@ -54,6 +54,26 @@ |
55 | 55 | }; |
56 | 56 | |
57 | 57 | /** |
| 58 | + * Gets the index of this item within it's container. |
| 59 | + * |
| 60 | + * @method |
| 61 | + * @returns {Integer} Index of item in it's container |
| 62 | + * @throws Unknown item error if this item is not in it's container |
| 63 | + * @throws Missing container error if this container can't be accessed. |
| 64 | + */ |
| 65 | +es.ModelContainerItem.prototype.getIndex = function() { |
| 66 | + try { |
| 67 | + var index = this[this._containerName].indexOf( this ); |
| 68 | + if ( index === -1 ) { |
| 69 | + throw 'Unknown item error. Can not get index of item that is not in a container. ' + e; |
| 70 | + } |
| 71 | + return index; |
| 72 | + } catch ( e ) { |
| 73 | + throw 'Missing container error. Can not get index of item in missing container. ' + e; |
| 74 | + } |
| 75 | +}; |
| 76 | + |
| 77 | +/** |
58 | 78 | * Gets the previous item in container. |
59 | 79 | * |
60 | 80 | * @method |
Index: trunk/parsers/wikidom/lib/synth/bases/es.ViewContainerItem.js |
— | — | @@ -28,6 +28,18 @@ |
29 | 29 | return this.model; |
30 | 30 | }; |
31 | 31 | |
| 32 | +/** |
| 33 | + * Gets the index of this item within it's container. |
| 34 | + * |
| 35 | + * This method simply delegates to the model. |
| 36 | + * |
| 37 | + * @method |
| 38 | + * @returns {Integer} Index of item in it's container |
| 39 | + */ |
| 40 | +es.ViewContainerItem.prototype.getIndex = function() { |
| 41 | + return this.model.getIndex(); |
| 42 | +}; |
| 43 | + |
32 | 44 | /* Inheritance */ |
33 | 45 | |
34 | 46 | es.extend( es.ViewContainerItem, es.EventEmitter ); |