r96865 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96864‎ | r96865 | r96866 >
Date:16:50, 12 September 2011
Author:tparscal
Status:deferred
Tags:
Comment:
Added getIndex to container items to support comparison in es.Location
Modified paths:
  • /trunk/parsers/wikidom/lib/synth/bases/es.ModelContainerItem.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/bases/es.ViewContainerItem.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/synth/bases/es.ModelContainerItem.js
@@ -54,6 +54,26 @@
5555 };
5656
5757 /**
 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+/**
5878 * Gets the previous item in container.
5979 *
6080 * @method
Index: trunk/parsers/wikidom/lib/synth/bases/es.ViewContainerItem.js
@@ -28,6 +28,18 @@
2929 return this.model;
3030 };
3131
 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+
3244 /* Inheritance */
3345
3446 es.extend( es.ViewContainerItem, es.EventEmitter );

Status & tagging log