26 elgg.nullFunction =
function() {};
35 elgg.abstractMethod =
function() {
36 throw new Error(
"Oops... you forgot to implement an abstract method!");
84 elgg.isString =
function(val) {
85 return typeof val ===
'string';
95 elgg.isNumber =
function(val) {
96 return typeof val ===
'number';
109 elgg.isObject =
function(val) {
110 return typeof val ===
'object';
120 elgg.isUndefined =
function(val) {
121 return val === undefined;
142 elgg.isNullOrUndefined =
function(val) {
152 if (typeof val !==
type) {
153 throw new TypeError(
"Expecting param of " +
154 arguments.caller +
"to be a(n) " +
type +
"." +
155 " Was actually a(n) " + typeof val +
".");
165 elgg.assertTypeOf(
'string', pkg);
167 var parts = pkg.split(
'.'),
171 for (i = 0; i < parts.length; i += 1) {
174 if (
elgg.isUndefined(cur)) {
175 throw new Error(
"Missing package: " + pkg);
212 elgg.provide =
function(pkg, opt_context) {
214 context = opt_context ||
elgg.global,
217 if (
elgg.isArray(pkg)) {
220 elgg.assertTypeOf(
'string', pkg);
221 parts = pkg.split(
'.');
224 for (i = 0; i < parts.length; i += 1) {
226 context[part] = context[part] || {};
227 context = context[part];
254 elgg.inherit =
function(Child, Parent) {
255 Child.prototype =
new Parent();
256 Child.prototype.constructor = Child;
274 elgg.assertTypeOf(
'string',
url);
276 function validate(
url) {
279 url.scheme =
url.scheme.toLowerCase();
281 if (
url.scheme ==
'http' ||
url.scheme ==
'https') {
286 if (!(
new RegExp(
"^([a-zA-Z0-9][a-zA-Z0-9\\-\\.]*)$",
"i")).test(
url.host) ||
url.host.charAt(-1) ==
'.') {
291 if (!
url.scheme || !
url.host &&
url.scheme !=
'mailto' &&
url.scheme !=
'news' &&
url.scheme !=
'file') {
298 if (
url.indexOf(
'http:') === 0 ||
299 url.indexOf(
'https:') === 0 ||
300 url.indexOf(
'javascript:') === 0 ||
301 url.indexOf(
'mailto:') === 0 ) {
306 else if (validate(
url)) {
312 else if ((
new RegExp(
"^(\\#|\\?|//)",
"i")).test(
url)) {
320 else if ((
new RegExp(
"^[^\/]*\\.php(\\?.*)?$",
"i")).test(
url)) {
321 return elgg.config.wwwroot +
url.ltrim(
'/');
325 else if ((
new RegExp(
"^[^/]*\\.",
"i")).test(
url)) {
326 return 'http://' +
url;
333 return elgg.config.wwwroot +
url.ltrim(
'/');
345 elgg.system_messages =
function(msgs, delay,
type) {
346 if (
elgg.isUndefined(msgs)) {
350 var classes = [
'elgg-message'],
352 appendMessage =
function(msg) {
353 messages_html.push(
'<li class="' + classes.join(
' ') +
'"><p>' + msg +
'</p></li>');
355 systemMessages = $(
'ul.elgg-system-messages'),
359 delay = parseInt(delay || 6000, 10);
360 if (isNaN(delay) || delay <= 0) {
365 if (!
elgg.isArray(msgs)) {
369 if (
type ===
'error') {
370 classes.push(
'elgg-state-error');
372 classes.push(
'elgg-state-success');
375 msgs.forEach(appendMessage);
377 if (
type !=
'error') {
378 $(messages_html.join(
'')).appendTo(systemMessages)
379 .animate({opacity:
'1.0'}, delay).fadeOut(
'slow');
381 $(messages_html.join(
'')).appendTo(systemMessages);
390 elgg.system_message =
function(msgs, delay) {
391 elgg.system_messages(msgs, delay,
"message");
399 elgg.register_error =
function(errors, delay) {
400 elgg.system_messages(errors, delay,
"error");
410 elgg.deprecated_notice =
function(msg, dep_version) {
411 if (
elgg.is_admin_logged_in()) {
412 msg =
"Deprecated in Elgg " + dep_version +
": " + msg;
413 if (typeof console !==
"undefined") {
426 var dest =
elgg.normalize_url(
url);
428 if (dest == location.href) {
434 $(window).
on(
'hashchange',
function () {
438 location.href = dest;
450 elgg.parse_url =
function(
url, component, expand) {
454 expand = expand ||
false;
455 component = component ||
false;
459 '^(?:(?![^:@]+:[^:@/]*@)([^:/?#.]+):)?(?://)?' 461 +
'((?:(([^:@]*)(?::([^:@]*))?)?@)?' 463 +
'([^:/?#]*)(?::(\\d*))?)' 465 +
'(((/(?:[^?#](?![^?#/]*\\.[^?#/.]+(?:[?#]|$)))*/?)?([^?#/]*))' 482 if (
url.indexOf(
'mailto:') === 0) {
483 results[
'scheme'] =
'mailto';
484 results[
'path'] =
url.replace(
'mailto:',
'');
488 if (
url.indexOf(
'javascript:') === 0) {
489 results[
'scheme'] =
'javascript';
490 results[
'path'] =
url.replace(
'javascript:',
'');
494 var re =
new RegExp(re_str);
495 var matches = re.exec(
url);
497 for (var
i in keys) {
499 results[keys[
i]] = matches[
i];
503 if (expand && typeof(results[
'query']) !=
'undefined') {
504 results[
'query'] =
elgg.parse_str(results[
'query']);
508 if (typeof(results[component]) !=
'undefined') {
509 return results[component];
523 elgg.parse_str =
function(string) {
528 re = /([^&=]+)=?([^&]*)/g,
532 while (result = re.exec(
string)) {
533 key = decodeURIComponent(result[1].replace(/\+/g,
' '));
534 value = decodeURIComponent(result[2].replace(/\+/g,
' '));
537 key = key.replace(re2,
'');
541 params[key].push(value);
562 elgg.getSelectorFromUrlFragment =
function(
url) {
563 var fragment =
url.split(
'#')[1];
567 if (fragment.indexOf(
'.') > -1) {
573 return '#' + fragment;
586 elgg.push_to_object_array =
function(object, parent, value) {
587 elgg.assertTypeOf(
'object',
object);
588 elgg.assertTypeOf(
'string', parent);
590 if (!(
object[parent] instanceof Array)) {
594 if ($.inArray(value,
object[parent]) < 0) {
595 return object[parent].push(value);
608 elgg.is_in_object_array =
function(object, parent, value) {
609 elgg.assertTypeOf(
'object',
object);
610 elgg.assertTypeOf(
'string', parent);
612 return typeof(
object[parent]) !=
'undefined' && $.inArray(value,
object[parent]) >= 0;
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
if(!$site) if(!($site instanceof ElggSite)) $site url