Elgg  Version 4.3
/root/Elgg/views/default/core/js/deprecated.js

This forces an inheriting class to implement the method or it will throw an error.AbstractClass.prototype.toBeImplemented = elgg.abstractMethod;

elgg.global = this;
elgg.ACCESS_PRIVATE = 0;
elgg.nullFunction = function() {};
elgg.abstractMethod = function() {
throw new Error("Oops... you forgot to implement an abstract method!");
};
elgg.extend = jQuery.extend;
elgg.isArray = jQuery.isArray;
elgg.isFunction = jQuery.isFunction;
elgg.isPlainObject = jQuery.isPlainObject;
elgg.isString = function(val) {
return typeof val === 'string';
};
elgg.isNumber = function(val) {
return typeof val === 'number';
};
elgg.isObject = function(val) {
return typeof val === 'object';
};
elgg.isUndefined = function(val) {
return val === undefined;
};
elgg.isNull = function(val) {
return val === null;
};
elgg.isNullOrUndefined = function(val) {
return val == null;
};
elgg.require = 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 (cur === undefined) {
throw new Error("Missing package: " + pkg);
}
}
};
elgg.provide = function(pkg, opt_context) {
var parts,
context = opt_context || elgg.global,
part, i;
if (Array.isArray(pkg)) {
parts = pkg;
} else {
elgg.assertTypeOf('string', pkg);
parts = pkg.split('.');
}
for (i = 0; i < parts.length; i += 1) {
part = parts[i];
context[part] = context[part] || {};
context = context[part];
}
};
// register provides for backwards compatibility
elgg.provide('elgg.config');
elgg.provide('elgg.session');
elgg.provide('elgg.ui');
elgg.provide('elgg.security.token');
elgg.provide('elgg.config.translations');
elgg.provide('elgg.config.hooks');
elgg.provide('elgg.config.instant_hooks');
elgg.provide('elgg.config.triggered_hooks');
elgg.session.cookie = function(name, value, options) {
var cookies = [], cookie = [], i = 0, date, valid = true;
//elgg.session.cookie()
if (name === undefined) {
return document.cookie;
}
//elgg.session.cookie(name)
if (value === undefined) {
if (document.cookie && document.cookie !== '') {
cookies = document.cookie.split(';');
for (i = 0; i < cookies.length; i += 1) {
cookie = jQuery.trim(cookies[i]).split('=');
if (cookie[0] === name) {
return decodeURIComponent(cookie[1]);
}
}
}
return undefined;
}
// elgg.session.cookie(name, value[, opts])
options = options || {};
if (value === null) {
value = '';
options.expires = -1;
}
cookies.push(name + '=' + value);
if (options.expires) {
if (typeof options.expires === 'number') {
date = new Date();
date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
} else if (options.expires.toUTCString) {
date = options.expires;
}
if (date) {
cookies.push('expires=' + date.toUTCString());
}
}
// CAUTION: Needed to parenthesize options.path and options.domain
// in the following expressions, otherwise they evaluate to undefined
// in the packed version for some reason.
if (options.path) {
cookies.push('path=' + (options.path));
}
if (options.domain) {
cookies.push('domain=' + (options.domain));
}
if (options.secure) {
cookies.push('secure');
}
document.cookie = cookies.join('; ');
};
elgg.system_messages = function(msgs, delay, type) {
require(['elgg/system_messages'], function(messages) {
messages.showMessage(msgs, delay, type);
});
};
elgg.clear_system_messages = function() {
require(['elgg/system_messages'], function(messages) {
messages.clear();
});
};
elgg.system_message = function(msgs, delay) {
require(['elgg/system_messages'], function(messages) {
messages.success(msgs, delay);
});
};
elgg.register_error = function(errors, delay) {
require(['elgg/system_messages'], function(messages) {
messages.error(errors, delay);
});
};
elgg.security.addToken = function (data) {
var security = require('elgg/security');
return security.addToken(data);
};
elgg.inherit = function(Child, Parent) {
Child.prototype = new Parent();
Child.prototype.constructor = Child;
};
elgg.ElggEntity = function(o) {
$.extend(this, o);
};
elgg.ElggUser = function(o) {
elgg.ElggEntity.call(this, o);
};
elgg.inherit(elgg.ElggUser, elgg.ElggEntity);
elgg.ElggUser.prototype.isAdmin = function() {
return this.admin;
};
// This just has to happen after ElggUser is defined, however it's probably
// better to have this procedural code here than in ElggUser.js
if (elgg.session.user) {
elgg.session.user = new elgg.ElggUser(elgg.session.user);
}
elgg.get_logged_in_user_entity = function() {
return elgg.session.user;
};
elgg.get_page_owner_guid = function() {
return elgg.page_owner ? elgg.page_owner.guid : 0;
};
elgg.add_translation = function(lang, translations) {
var i18n = require('elgg/i18n');
i18n.addTranslation(lang, translations);
};
elgg.get_language = function() {
return elgg.config.current_language;
};
elgg.echo = function(key, argv, language) {
var i18n = require('elgg/i18n');
return i18n.echo(key, argv, language);
};
elgg.ui.registerTogglableMenuItems = function(menuItemNameA, menuItemNameB) {
require(['navigation/menu/elements/item_toggle'], function() {
menuItemNameA = menuItemNameA.replace('_', '-');
menuItemNameB = menuItemNameB.replace('_', '-');
$('.elgg-menu-item-' + menuItemNameA + ' a').not('[data-toggle]').attr('data-toggle', menuItemNameB);
$('.elgg-menu-item-' + menuItemNameB + ' a').not('[data-toggle]').attr('data-toggle', menuItemNameA);
});
};