Elgg  Version 3.0
Functions | Variables
ui.js File Reference

Go to the source code of this file.

Functions

elgg provide ('elgg.ui')
 
elgg register_hook_handler ('init', 'system', elgg.ui.init)
 

Variables

elgg ui init
 
elgg ui toggles
 Toggles an element based on clicking a separate element. More...
 
elgg ui initHoverMenu
 Initialize the hover menu. More...
 
elgg ui requiresConfirmation
 Calls a confirm() and returns false if denied. More...
 
elgg ui registerTogglableMenuItems
 This function registers two menu items that are actions that are the opposite of each other and ajaxifies them. More...
 

Function Documentation

elgg provide ( 'elgg.ui'  )
elgg register_hook_handler ( 'init ,
'system ,
elgg.ui.  init 
)

Variable Documentation

elgg ui init

Definition at line 3 of file ui.js.

elgg ui initHoverMenu

Initialize the hover menu.

Parameters
{Object}parent
Returns
void

Definition at line 87 of file ui.js.

elgg ui registerTogglableMenuItems
Initial value:
= 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);
});
}
elgg require
Throw an error if the required package isn't present.
Definition: elgglib.js:164

This function registers two menu items that are actions that are the opposite of each other and ajaxifies them.

E.g. like/unlike, friend/unfriend, ban/unban, etc.

You can also add the data parameter 'data-toggle' to menu items to have them automatically registered as toggleable without the need to call this function.

Definition at line 201 of file ui.js.

elgg ui requiresConfirmation
Initial value:
= function(e) {
var confirmText = $(this).data('confirm') || elgg.echo('question:areyousure');
if (!confirm(confirmText)) {
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
return false;
}
}
var elgg
Definition: elgglib.js:4

Calls a confirm() and returns false if denied.

Parameters
{Object}e
Returns
void

Definition at line 184 of file ui.js.

elgg ui toggles
Initial value:
= function(event) {
event.preventDefault();
var $this = $(this),
selector = $this.data().toggleSelector;
if (!selector) {
selector = $this.attr('href');
}
var $elements = $(selector);
$this.toggleClass('elgg-state-active');
$elements.each(function(index, elem) {
var $elem = $(elem);
if ($elem.data().toggleSlide != false) {
$elem.slideToggle('medium');
} else {
$elem.toggle();
}
});
$this.trigger('elgg_ui_toggle', [{
$toggled_elements: $elements
}]);
}

Toggles an element based on clicking a separate element.

Use rel="toggle" on the toggler element Set the href to target the item you want to toggle () or use data-toggle-selector="your_jquery_selector" to have an advanced selection method By default elements perform a slideToggle. If you want a normal toggle (hide/show) you can add data-toggle-slide="0" on the elements to prevent a slide. {Object} event void

Definition at line 52 of file ui.js.