Elgg  Version 2.3
Variables
ElggPriorityList.js File Reference

Go to the source code of this file.

Variables

elgg ElggPriorityList
 Priority lists allow you to create an indexed list that can be iterated through in a specific order. More...
 
elgg ElggPriorityList prototype insert
 Inserts an element into the priority list at the priority specified. More...
 
elgg ElggPriorityList prototype forEach
 Iterates through each element in order. More...
 
elgg ElggPriorityList prototype every
 Iterates through each element in order. More...
 
elgg ElggPriorityList prototype remove
 Removes an element from the priority list. More...
 

Variable Documentation

Initial value:
= function() {
this.length = 0;
this.priorities_ = [];
}

Priority lists allow you to create an indexed list that can be iterated through in a specific order.

Definition at line 5 of file ElggPriorityList.js.

Initial value:
= function(callback) {
elgg.assertTypeOf('function', callback);
var index = 0;
return this.priorities_.every(function(elems) {
return elems.every(function(elem) {
return callback(elem, index++);
});
});
}
elgg
Definition: install.js:23
z index
Definition: admin.css.php:358

Iterates through each element in order.

Unlike forEach, this returns the value of the callback and will break on false.

Parameters
{Function}callback The callback function to pass each element through. See Array.prototype.every() for details.
Returns
{Object}

Definition at line 66 of file ElggPriorityList.js.

Initial value:
= function(callback) {
elgg.assertTypeOf('function', callback);
var index = 0;
this.priorities_.forEach(function(elems) {
elems.forEach(function(elem) {
callback(elem, index++);
});
});
return this;
}
elgg
Definition: install.js:23
z index
Definition: admin.css.php:358

Iterates through each element in order.

Unlike every, this ignores the return value of the callback.

Parameters
{Function}callback The callback function to pass each element through. See Array.prototype.every() for details.
Returns
{Object}

Definition at line 43 of file ElggPriorityList.js.

Initial value:
= function(obj, opt_priority) {
var priority = 500;
if (arguments.length == 2 && opt_priority !== undefined) {
priority = parseInt(opt_priority, 10);
}
priority = Math.max(priority, 0);
if (elgg.isUndefined(this.priorities_[priority])) {
this.priorities_[priority] = [];
}
this.priorities_[priority].push(obj);
this.length++;
}
elgg
Definition: install.js:23

Inserts an element into the priority list at the priority specified.

Parameters
{Object}obj The object to insert
{Number}opt_priority An optional priority to insert at.
Returns
{Void}

Definition at line 18 of file ElggPriorityList.js.

Initial value:
= function(obj) {
this.priorities_.forEach(function(elems) {
var index;
while ((index = elems.indexOf(obj)) !== -1) {
elems.splice(index, 1);
this.length--;
}
});
}
z index
Definition: admin.css.php:358

Removes an element from the priority list.

Parameters
{Object}obj The object to remove.
Returns
{Void}

Definition at line 84 of file ElggPriorityList.js.