Elgg  Version 1.9
Namespaces | Variables
elgglib.js File Reference

Go to the source code of this file.

Namespaces

 Singleton
 object for holding the Elgg javascript library
 

Variables

var elgg = elgg || {}
 
elgg global = this
 Pointer to the global context. More...
 
elgg ACCESS_PRIVATE = 0
 Duplicate of the server side ACCESS_PRIVATE access level. More...
 
elgg nullFunction = function() {}
 Convenience reference to an empty function. More...
 
elgg abstractMethod
 
elgg extend = jQuery.extend
 Merges two or more objects together and returns the result. More...
 
elgg isArray = jQuery.isArray
 Check if the value is an array. More...
 
elgg isFunction = jQuery.isFunction
 Check if the value is a function. More...
 
elgg isPlainObject = jQuery.isPlainObject
 Check if the value is a "plain" object (i.e., created by {} or new Object()) More...
 
elgg isString
 Check if the value is a string. More...
 
elgg isNumber
 Check if the value is a number. More...
 
elgg isObject
 Check if the value is an object. More...
 
elgg isUndefined
 Check if the value is undefined. More...
 
elgg isNull
 Check if the value is null. More...
 
elgg isNullOrUndefined
 Check if the value is either null or undefined. More...
 
elgg assertTypeOf
 Throw an exception of the type doesn't match. More...
 
elgg require
 Throw an error if the required package isn't present. More...
 
elgg provide
 
elgg inherit
 
elgg system_message
 Wrapper function for system_messages. More...
 
elgg register_error
 Wrapper function for system_messages. More...
 
elgg deprecated_notice
 Logs a notice about use of a deprecated function or capability. More...
 
elgg forward
 Meant to mimic the php forward() function by simply redirecting the user to another page. More...
 
elgg parse_url
 Parse a URL into its parts. More...
 
elgg parse_str
 Returns an object with key/values of the parsed query string. More...
 
elgg getSelectorFromUrlFragment
 Returns a jQuery selector from a URL's fragement. More...
 
elgg push_to_object_array
 Adds child to object[parent] array. More...
 
elgg is_in_object_array
 Tests if object[parent] contains child. More...
 

Variable Documentation

elgg abstractMethod
Initial value:
= function() {
throw new Error("Oops... you forgot to implement an abstract method!");
}

Definition at line 35 of file elgglib.js.

elgg ACCESS_PRIVATE = 0

Duplicate of the server side ACCESS_PRIVATE access level.

This is a temporary hack to prevent having to mix up js and PHP in js views.

Definition at line 19 of file elgglib.js.

elgg assertTypeOf
Initial value:
= function(type, val) {
if (typeof val !== type) {
throw new TypeError("Expecting param of " +
arguments.caller + "to be a(n) " + type + "." +
" Was actually a(n) " + typeof val + ".");
}
}
list style type
Definition: admin.php:724

Throw an exception of the type doesn't match.

Definition at line 151 of file elgglib.js.

elgg deprecated_notice
Initial value:
= function(msg, dep_version) {
if (elgg.is_admin_logged_in()) {
var parts = elgg.release.split('.');
var elgg_major_version = parseInt(parts[0], 10);
var elgg_minor_version = parseInt(parts[1], 10);
var dep_major_version = Math.floor(dep_version);
var dep_minor_version = 10 * (dep_version - dep_major_version);
msg = "Deprecated in Elgg " + dep_version + ": " + msg;
if ((dep_major_version < elgg_major_version) || (dep_minor_version < elgg_minor_version)) {
elgg.register_error(msg);
} else {
if (typeof console !== "undefined") {
console.warn(msg);
}
}
}
}
var elgg
Definition: elgglib.js:4

Logs a notice about use of a deprecated function or capability.

Parameters
{String}msg The deprecation message to display
{Number}dep_version The version the function was deprecated for
Since
1.9

Definition at line 393 of file elgglib.js.

var elgg = elgg || {}

Definition at line 4 of file elgglib.js.

elgg extend = jQuery.extend

Merges two or more objects together and returns the result.

Definition at line 42 of file elgglib.js.

elgg forward
Initial value:
= function(url) {
location.href = elgg.normalize_url(url);
}
$CONFIG url
The full URL where Elgg is installed.
Definition: config.php:94
var elgg
Definition: elgglib.js:4

Meant to mimic the php forward() function by simply redirecting the user to another page.

Parameters
{String}url The url to forward to

Definition at line 419 of file elgglib.js.

elgg getSelectorFromUrlFragment
Initial value:
= function(url) {
var fragment = url.split('#')[1];
if (fragment) {
if (fragment.indexOf('.') > -1) {
return fragment;
}
else {
return '#' + fragment;
}
}
return '';
}
$CONFIG url
The full URL where Elgg is installed.
Definition: config.php:94

Returns a jQuery selector from a URL's fragement.

Defaults to expecting an ID.

Examples: http://elgg.org/download.php returns '' http://elgg.org/download.php#id returns #id http://elgg.org/download.php#.class-name return .class-name http://elgg.org/download.php#a.class-name return a.class-name

Parameters
{String}url The URL
Returns
{String} The selector

Definition at line 543 of file elgglib.js.

elgg global = this

Pointer to the global context.

See also
elgg.require
elgg.provide
Examples:
/root/Elgg/engine/lib/cache.php, /root/Elgg/engine/lib/output.php, and /root/Elgg/engine/lib/views.php.

Definition at line 12 of file elgglib.js.

elgg inherit
Initial value:
= function(Child, Parent) {
Child.prototype = new Parent();
Child.prototype.constructor = Child;
}

Definition at line 237 of file elgglib.js.

elgg is_in_object_array
Initial value:
= function(object, parent, value) {
elgg.assertTypeOf('object', object);
elgg.assertTypeOf('string', parent);
return typeof(object[parent]) != 'undefined' && $.inArray(value, object[parent]) >= 0;
}
var elgg
Definition: elgglib.js:4

Tests if object[parent] contains child.

Parameters
{Object}object The object to add to
{String}parent The parent array to add to.
{Mixed}value The value

Definition at line 589 of file elgglib.js.

elgg isArray = jQuery.isArray

Check if the value is an array.

No sense in reinventing the wheel!

Parameters
{*}val
Returns
boolean

Definition at line 53 of file elgglib.js.

elgg isFunction = jQuery.isFunction

Check if the value is a function.

No sense in reinventing the wheel!

Parameters
{*}val
Returns
boolean

Definition at line 64 of file elgglib.js.

elgg isNull
Initial value:
= function(val) {
return val === null;
}

Check if the value is null.

Parameters
{*}val
Returns
boolean

Definition at line 131 of file elgglib.js.

elgg isNullOrUndefined
Initial value:
= function(val) {
return val == null;
}

Check if the value is either null or undefined.

Parameters
{*}val
Returns
boolean

Definition at line 142 of file elgglib.js.

elgg isNumber
Initial value:
= function(val) {
return typeof val === 'number';
}

Check if the value is a number.

Parameters
{*}val
Returns
boolean

Definition at line 95 of file elgglib.js.

elgg isObject
Initial value:
= function(val) {
return typeof val === 'object';
}

Check if the value is an object.

Note
This returns true for functions and arrays! If you want to return true only for "plain" objects (created using {} or new Object()) use elgg.isPlainObject.
Parameters
{*}val
Returns
boolean

Definition at line 109 of file elgglib.js.

elgg isPlainObject = jQuery.isPlainObject

Check if the value is a "plain" object (i.e., created by {} or new Object())

No sense in reinventing the wheel!

Parameters
{*}val
Returns
boolean

Definition at line 75 of file elgglib.js.

elgg isString
Initial value:
= function(val) {
return typeof val === 'string';
}

Check if the value is a string.

Parameters
{*}val
Returns
boolean

Definition at line 84 of file elgglib.js.

elgg isUndefined
Initial value:
= function(val) {
return val === undefined;
}

Check if the value is undefined.

Parameters
{*}val
Returns
boolean

Definition at line 120 of file elgglib.js.

elgg nullFunction = function() {}

Convenience reference to an empty function.

Save memory by not generating multiple empty functions.

Definition at line 26 of file elgglib.js.

elgg parse_str
Initial value:
= function(string) {
var params = {},
result,
key,
value,
re = /([^&=]+)=?([^&]*)/g,
re2 = /\[\]$/;
while (result = re.exec(string)) {
key = decodeURIComponent(result[1].replace(/\+/g, ' '));
value = decodeURIComponent(result[2].replace(/\+/g, ' '));
if (re2.test(key)) {
key = key.replace(re2, '');
if (!params[key]) {
params[key] = [];
}
params[key].push(value);
} else {
params[key] = value;
}
}
return params;
}

Returns an object with key/values of the parsed query string.

Parameters
{String}string The string to parse
Returns
{Object} The parsed object string

Definition at line 505 of file elgglib.js.

elgg parse_url

Parse a URL into its parts.

Mimicks http://php.net/parse_url

Parameters
{String}url The URL to parse
{Int}component A component to return
{Bool}expand Expand the query into an object? Else it's a string.
Returns
{Object} The parsed URL

Definition at line 432 of file elgglib.js.

elgg provide
Initial value:
= function(pkg, opt_context) {
elgg.assertTypeOf('string', pkg);
var parts = pkg.split('.'),
context = opt_context || elgg.global,
part, i;
for (i = 0; i < parts.length; i += 1) {
part = parts[i];
context[part] = context[part] || {};
context = context[part];
}
}
i
Definition: admin.php:47
var elgg
Definition: elgglib.js:4

Definition at line 199 of file elgglib.js.

elgg push_to_object_array
Initial value:
= function(object, parent, value) {
elgg.assertTypeOf('object', object);
elgg.assertTypeOf('string', parent);
if (!(object[parent] instanceof Array)) {
object[parent] = [];
}
if ($.inArray(value, object[parent]) < 0) {
return object[parent].push(value);
}
return false;
}
var elgg
Definition: elgglib.js:4

Adds child to object[parent] array.

Parameters
{Object}object The object to add to
{String}parent The parent array to add to.
{Mixed}value The value

Definition at line 567 of file elgglib.js.

elgg register_error
Initial value:
= function(errors, delay) {
elgg.system_messages(errors, delay, "error");
}
var elgg
Definition: elgglib.js:4

Wrapper function for system_messages.

Specifies "errors" as the type of message

Parameters
{String}errors The error message to display
{Number}delay How long to dispaly the error message (milliseconds)

Definition at line 383 of file elgglib.js.

elgg require
Initial value:
= function(pkg) {
elgg.assertTypeOf('string', pkg);
var parts = pkg.split('.'),
cur = elgg.global,
part, i;
for (i = 0; i < parts.length; i += 1) {
part = parts[i];
cur = cur[part];
if (elgg.isUndefined(cur)) {
throw new Error("Missing package: " + pkg);
}
}
}
i
Definition: admin.php:47
var elgg
Definition: elgglib.js:4

Throw an error if the required package isn't present.

Parameters
{String}pkg The required package (e.g., 'elgg.package')

Definition at line 164 of file elgglib.js.

elgg system_message
Initial value:
= function(msgs, delay) {
elgg.system_messages(msgs, delay, "message");
}
var elgg
Definition: elgglib.js:4

Wrapper function for system_messages.

Specifies "messages" as the type of message

Parameters
{String}msgs The message to display
{Number}delay How long to display the message (milliseconds)

Definition at line 374 of file elgglib.js.