Elgg  Version 4.x
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 assertTypeOf
 Throw an exception of the type doesn't match. More...
 
elgg normalize_url
 Converts shorthand urls to absolute urls. More...
 
elgg deprecated_notice
 Informs admin users via a console message 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 fragment. More...
 
elgg get_logged_in_user_guid
 Returns the GUID of the logged in user or 0. More...
 
elgg is_logged_in
 Returns if a user is logged in. More...
 
elgg is_admin_logged_in
 Returns if the currently logged in user is an admin. More...
 
elgg get_site_url
 Returns the current site URL. More...
 
elgg get_simplecache_url
 Get the URL for the cached file. More...
 

Variable Documentation

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 + ".");
}
}

Throw an exception of the type doesn't match.

Definition at line 9 of file elgglib.js.

elgg deprecated_notice
Initial value:
= function(msg, dep_version) {
if (elgg.is_admin_logged_in()) {
msg = "Deprecated in Elgg " + dep_version + ": " + msg;
if (typeof console !== "undefined") {
console.info(msg);
}
}
}
var elgg
Definition: elgglib.js:4

Informs admin users via a console message about use of a deprecated function or capability.

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

Definition at line 95 of file elgglib.js.

var elgg = elgg || {}
Examples:
/root/Elgg/views/default/core/js/deprecated.js.

Definition at line 4 of file elgglib.js.

elgg forward
Initial value:
= function(url) {
var dest = elgg.normalize_url(url);
if (dest == location.href) {
location.reload();
}
$(window).on('hashchange', function () {
location.reload();
});
location.href = dest;
}
Bundled plugins(the contents of the"/mod"directory) are available only under the GPLv2 license.The remainder of the project is available under either MIT or GPLv2.Both licenses can be found below.More info and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two distribute and or modify the software for each author s protection and we want to make certain that everyone understands that there is no warranty for this free software If the software is modified by someone else and passed on
Definition: LICENSE.txt:96
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 110 of file elgglib.js.

elgg get_logged_in_user_guid
Initial value:
= function() {
return elgg.user ? elgg.user.guid : 0;
}
var elgg
Definition: elgglib.js:4

Returns the GUID of the logged in user or 0.

Returns
{number} The GUID of the logged in user

Definition at line 267 of file elgglib.js.

elgg get_simplecache_url
Initial value:
= function(view, subview) {
elgg.assertTypeOf('string', view);
var lastcache, path;
if (elgg.config.simplecache_enabled) {
lastcache = elgg.config.lastcache;
} else {
lastcache = 0;
}
if (!subview) {
path = '/cache/' + lastcache + '/' + elgg.config.viewtype + '/' + view;
} else {
elgg.assertTypeOf('string', subview);
if ((view === 'js' || view === 'css') && 0 === subview.indexOf(view + '/')) {
subview = subview.substr(view.length + 1);
}
path = '/cache/' + lastcache + '/' + elgg.config.viewtype + '/' + view + '/' + subview;
}
return elgg.normalize_url(path);
}
var elgg
Definition: elgglib.js:4

Get the URL for the cached file.

Parameters
{String}view The full view name
{String}subview If the first arg is "css" or "js", the rest of the view name
Returns
{String} The site URL.

Definition at line 305 of file elgglib.js.

elgg get_site_url
Initial value:
= function() {
return elgg.config.wwwroot;
}
var elgg
Definition: elgglib.js:4

Returns the current site URL.

Returns
{String} The site URL.

Definition at line 294 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 '';
}

Returns a jQuery selector from a URL's fragment.

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 247 of file elgglib.js.

elgg is_admin_logged_in
Initial value:
= function() {
return elgg.user ? elgg.user.admin : false;
}
var elgg
Definition: elgglib.js:4

Returns if the currently logged in user is an admin.

Returns
{boolean} Whether there is an admin logged in

Definition at line 285 of file elgglib.js.

elgg is_logged_in
Initial value:
= function() {
return elgg.get_logged_in_user_guid() > 0;
}
var elgg
Definition: elgglib.js:4

Returns if a user is logged in.

Returns
{boolean} Whether there is a user logged in

Definition at line 276 of file elgglib.js.

elgg normalize_url

Converts shorthand urls to absolute urls.

If the url is already absolute or protocol-relative, no change is made.

elgg.normalize_url(''); // 'http://my.site.com/' elgg.normalize_url('dashboard'); // 'http://my.site.com/dashboard' elgg.normalize_url('http://google.com/'); // no change elgg.normalize_url('//google.com/'); // no change

Parameters
{String}url The url to normalize
Returns
{String} The extended url

Definition at line 30 of file elgglib.js.

elgg parse_str
Initial value:
= function(string) {
var params = {},
result,
key,
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;
}
$data value
Definition: default.php:27

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 208 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
{Number}component A component to return
{Boolean}expand Expand the query into an object? Else it's a string.
Returns
{Object} The parsed URL

Definition at line 135 of file elgglib.js.