diff options
Diffstat (limited to 'js/classes')
| -rw-r--r-- | js/classes/ElggEntity.js | 20 | ||||
| -rw-r--r-- | js/classes/ElggPriorityList.js | 60 | ||||
| -rw-r--r-- | js/classes/ElggUser.js | 14 | 
3 files changed, 94 insertions, 0 deletions
diff --git a/js/classes/ElggEntity.js b/js/classes/ElggEntity.js new file mode 100644 index 000000000..9461a463f --- /dev/null +++ b/js/classes/ElggEntity.js @@ -0,0 +1,20 @@ +/** + * Create a new ElggEntity + *  + * @class Represents an ElggEntity + * @property {number} guid + * @property {string} type + * @property {string} subtype + * @property {number} owner_guid + * @property {number} site_guid + * @property {number} container_guid + * @property {number} access_id + * @property {number} time_created + * @property {number} time_updated + * @property {number} last_action + * @property {string} enabled + *  + */ +elgg.ElggEntity = function(o) { +	$.extend(this, o); +};
\ No newline at end of file diff --git a/js/classes/ElggPriorityList.js b/js/classes/ElggPriorityList.js new file mode 100644 index 000000000..521fbbb64 --- /dev/null +++ b/js/classes/ElggPriorityList.js @@ -0,0 +1,60 @@ +elgg.ElggPriorityList = function() { +	this.length = 0; +	this.priorities_ = []; +}; + +elgg.ElggPriorityList.prototype.insert = function(obj, opt_priority) { +	if (opt_priority == undefined) { +		opt_priority = 500; +	}  + +	opt_priority = parseInt(opt_priority); +	if (opt_priority < 0) { +		opt_priority = 0; +	} +	 +	if (this.priorities_[opt_priority] == undefined) { +		this.priorities_[opt_priority] = []; +	} +	 +	this.priorities_[opt_priority].push(obj); +	this.length++; +}; + +elgg.ElggPriorityList.prototype.forEach = function(callback) { +	elgg.assertTypeOf('function', callback); + +	var index = 0; +	for (var p in this.priorities_) { +		var elems = this.priorities_[p]; +		for (var i in elems) { +			callback(elems[i], index); +			index++; +		} +	} +}; + +elgg.ElggPriorityList.prototype.every = function(callback) { +	elgg.assertTypeOf('function', callback); +	 +	var index = 0; +	for (var p in this.priorities_) { +		var elems = this.priorities_[p]; +		for (var i in elems) { +			if (!callback(elems[i], index)) { +				return false; +			}; +		} +	} +	 +	return true; +}; + +elgg.ElggPriorityList.prototype.remove = function(obj) { +	this.priorities_.forEach(function(elems, priority) { +		var index; +		while ((index = elems.indexOf(obj)) != -1) { +			elems.splice(index, 1); +		} +	}); +};
\ No newline at end of file diff --git a/js/classes/ElggUser.js b/js/classes/ElggUser.js new file mode 100644 index 000000000..8a7a8b7eb --- /dev/null +++ b/js/classes/ElggUser.js @@ -0,0 +1,14 @@ +/** + * Create a new ElggUser + * + * @param {Object} o + * @extends ElggEntity + * @class Represents an ElggUser + * @property {string} name + * @property {string} username + */ +elgg.ElggUser = function(o) { +	elgg.ElggEntity.call(this, o); +}; + +elgg.inherit(elgg.ElggUser, elgg.ElggEntity);
\ No newline at end of file  | 
