*** JAVASCRIPT CODING STANDARDS ***
+* Same formatting standards as PHP.
+
+* All functions should be in the elgg namespace.
+
+* Function expressions should end with a semi-colon:
+
+ elgg.ui.toggles = function(event) {
+ event.preventDefault();
+ $(target).slideToggle('medium');
+ };
+
var selection = ias.getSelection();
elgg.avatarCropper.preview($('#user-avatar-cropper'), selection);
}
-}
+};
/**
* Handler for changing select area.
marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px',
marginTop: '-' + Math.round(scaleY * selection.y1) + 'px'
});
-}
+};
/**
* Handler for updating the form inputs after select ends
$('input[name=x2]').val(selection.x2);
$('input[name=y1]').val(selection.y1);
$('input[name=y2]').val(selection.y2);
-}
+};
elgg.register_hook_handler('init', 'system', elgg.avatarCropper.init);
\ No newline at end of file
*/
elgg.get_site_url = function() {
return elgg.config.wwwroot;
-}
\ No newline at end of file
+};
\ No newline at end of file
}
}
return results;
-}
+};
/**
* Returns an object with key/values of the parsed query string.
}
return false;
-}
+};
/**
* Tests if object[parent] contains child
elgg.assertTypeOf('string', parent);
return typeof(object[parent]) != 'undefined' && object[parent].indexOf(value) >= 0;
-}
+};
/**
* Triggers the init hook when the library is ready
elgg.trigger_hook('init', 'system');
elgg.trigger_hook('ready', 'system');
}
-}
\ No newline at end of file
+};
\ No newline at end of file
elgg.assertTypeOf('string', type);
return elgg.push_to_object_array(elgg.config.instant_hooks, name, type);
-}
+};
/**
* Is this hook registered as an instant hook?
*/
elgg.is_instant_hook = function(name, type) {
return elgg.is_in_object_array(elgg.config.instant_hooks, name, type);
-}
+};
/**
* Records that a hook has been triggered.
*/
elgg.set_triggered_hook = function(name, type) {
return elgg.push_to_object_array(elgg.config.triggered_hooks, name, type);
-}
+};
/**
* Has this hook been triggered yet?
*/
elgg.is_triggered_hook = function(name, type) {
return elgg.is_in_object_array(elgg.config.triggered_hooks, name, type);
-}
+};
elgg.register_instant_hook('init', 'system');
elgg.register_instant_hook('ready', 'system');
if ($('.elgg-input-date').length) {
elgg.ui.initDatePicker();
}
-}
+};
/**
* Toggles an element based on clicking a separate element
var target = $(this).toggleClass('elgg-state-active').attr('href');
$(target).slideToggle('medium');
-}
+};
/**
* Pops up an element based on clicking a separate element
$('body')
.die('click', elgg.ui.popupClose)
.live('click', elgg.ui.popupClose);
-}
+};
/**
* Catches clicks that aren't in a popup and closes all popups.
$('body').die('click', elgg.ui.popClose);
}
-}
+};
/**
* Toggles a child menu when the parent is clicked
$(this).siblings().slideToggle('medium');
$(this).toggleClass('elgg-menu-closed elgg-menu-opened');
event.preventDefault();
-}
+};
/**
* Initialize the hover menu
$(".elgg-menu-hover").fadeOut();
}
});
-}
+};
/**
* Calls a confirm() and prevents default if denied.
}
}
});
-}
+};
elgg.register_hook_handler('init', 'system', elgg.ui.init);
elgg.register_hook_handler('getOptions', 'ui.popup', elgg.ui.LoginHandler);
\ No newline at end of file
}
});
event.preventDefault();
-}
+};
/**
* Persist the widget's new position
// @hack fixes jquery-ui/opera bug where draggable elements jump
ui.item.css('top', 0);
ui.item.css('left', 0);
-}
+};
/**
* Removes a widget from the layout
}
});
event.preventDefault();
-}
+};
/**
* Toggle the collapse state of the widget
$(this).toggleClass('elgg-widget-collapsed');
$(this).parent().parent().find('.elgg-body').slideToggle('medium');
event.preventDefault();
-}
+};
/**
* Save a widget's settings
}
});
event.preventDefault();
-}
+};
/**
* Make all elements have the same min-height
}
})
$(selector).css('min-height', maxHeight);
-}
+};
elgg.register_hook_handler('init', 'system', elgg.ui.widgets.init);
});
$('.elgg-userpicker-remove').live('click', elgg.userpicker.removeUser);
-}
+};
/**
* Adds a user to the select user list
$(this).val('');
event.preventDefault();
-}
+};
/**
* Remove a user from the selected user list
item.remove();
event.preventDefault();
-}
+};
/**
* Render the list item for insertion into the selected user list
html += "</div";
return html;
-}
+};
/**
* Get the parameters to use for autocomplete
} else {
return {'match_on[]': 'users', 'term' : obj.term};
}
-}
+};
elgg.register_hook_handler('init', 'system', elgg.userpicker.init);
\ No newline at end of file
} else {
$(".blog-save-status-time").html(elgg.echo('error'));
}
-}
+};
elgg.blog.saveDraft = function() {
if (typeof(tinyMCE) != 'undefined') {
});
$.post(draftURL, postData, elgg.blog.saveDraftCallback, 'json');
-}
+};
elgg.blog.init = function() {
// get a copy of the body to compare for auto save
var e = $('a.elgg-bookmark-page');
var link = e.attr('href') + '&title=' + encodeURIComponent(title);
e.attr('href', link);
-}
+};
elgg.register_hook_handler('init', 'system', elgg.bookmarks.init);
elgg.dev.init = function() {
$('.developers-form-inspect').live('submit', elgg.dev.inspectSubmit);
-}
+};
/**
* Submit the inspect form through Ajax
});
event.preventDefault();
-}
+};
elgg.register_hook_handler('init', 'system', elgg.dev.init);
\ No newline at end of file
$('.embed-section').live('click', elgg.embed.forward);
$('.elgg-form-embed').live('submit', elgg.embed.submit);
-}
+};
/**
* Inserts data attached to an embed list item in textarea
$.fancybox.close();
event.preventDefault();
-}
+};
/**
* Submit an upload form through Ajax
// this was bubbling up the DOM causing a submission
event.preventDefault();
event.stopPropagation();
-}
+};
/**
* Loads content within the lightbox
elgg.embed.forward = function(event) {
$('.embed-wrapper').parent().load($(this).attr('href'));
event.preventDefault();
-}
+};
elgg.register_hook_handler('init', 'system', elgg.embed.init);
// double whammy for in case the load order changes.
.unbind('click', elgg.ui.requiresConfirmation)
.removeClass('elgg-requires-confirmation');
-}
+};
elgg.messageboard.submit = function(e) {
var form = $(this).parents('form');
});
e.preventDefault();
-}
+};
elgg.messageboard.deletePost = function(e) {
var link = $(this);
}
e.preventDefault();
-}
+};
elgg.register_hook_handler('init', 'system', elgg.messageboard.init);
});
$(".thewire-previous").live('click', elgg.thewire.viewPrevious);
-}
+};
/**
* Update the number of characters left with every keystroke
$("#thewire-submit-button").removeAttr('disabled', 'disabled');
$("#thewire-submit-button").removeClass('elgg-state-disabled');
}
-}
+};
/**
* Display the previous wire post
}
event.preventDefault();
-}
+};
elgg.register_hook_handler('init', 'system', elgg.thewire.init);
tinyMCE.execCommand('mceRemoveControl', false, id);
$(this).html(elgg.echo('tinymce:add'));
}
-}
+};
/**
* TinyMCE initialization script
content_css: elgg.config.wwwroot + 'mod/tinymce/css/elgg_tinymce.css'
});
-}
+};
elgg.register_hook_handler('init', 'system', elgg.tinymce.init);
\ No newline at end of file
$form.attr('action', $(this).attr('href')).submit();
});
-}
+};
elgg.register_hook_handler('init', 'system', elgg.uservalidationbyemail.init);