Elgg  Version 1.11
Functions | Variables
ui.widgets.js File Reference

Go to the source code of this file.

Functions

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

Variables

elgg ui widgets init
 Widgets initialization. More...
 
elgg ui widgets add
 Adds a new widget. More...
 
elgg ui widgets move
 Persist the widget's new position. More...
 
elgg ui widgets remove
 Removes a widget from the layout. More...
 
elgg ui widgets collapseToggle
 Toggle the collapse state of the widget. More...
 
elgg ui widgets saveSettings
 Save a widget's settings. More...
 
elgg ui widgets setMinHeight
 Set the min-height so that all widget column bottoms are the same. More...
 

Function Documentation

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

Variable Documentation

elgg ui widgets add
Initial value:
= function(event) {
var type = $(this).data('elgg-widget-type');
var multiple = $(this).attr('class').indexOf('elgg-widget-multiple') != -1;
if (multiple === false) {
$(this).addClass('elgg-state-unavailable');
$(this).removeClass('elgg-state-available');
$(this).unbind('click', elgg.ui.widgets.add);
}
elgg.action('widgets/add', {
data: {
handler: type,
page_owner_guid: elgg.get_page_owner_guid(),
context: $("input[name='widget_context']").val(),
show_access: $("input[name='show_access']").val(),
default_widgets: $("input[name='default_widgets']").val() || 0
},
success: function(json) {
$('#elgg-widget-col-1').prepend(json.output);
}
});
event.preventDefault();
}
elgg message elgg state success
Definition: admin.php:252
elgg
Definition: install.js:23
list style type
Definition: admin.php:748

Adds a new widget.

Makes Ajax call to persist new widget and inserts the widget html

Parameters
{Object}event
Returns
void

Definition at line 44 of file ui.widgets.js.

elgg ui widgets collapseToggle
Initial value:
= function(event) {
$(this).toggleClass('elgg-widget-collapsed');
$(this).parent().parent().find('.elgg-body').slideToggle('medium');
event.preventDefault();
}

Toggle the collapse state of the widget.

Parameters
{Object}event
Returns
void

Definition at line 143 of file ui.widgets.js.

elgg ui widgets init
Initial value:
= function() {
if ($(".elgg-widgets").length === 0) {
return;
}
$(".elgg-widgets").sortable({
items: 'div.elgg-module-widget.elgg-state-draggable',
connectWith: '.elgg-widgets',
handle: '.elgg-widget-handle',
forcePlaceholderSize: true,
placeholder: 'elgg-widget-placeholder',
opacity: 0.8,
revert: 500,
stop: elgg.ui.widgets.move
});
$('.elgg-widgets-add-panel li.elgg-state-available').click(elgg.ui.widgets.add);
$('a.elgg-widget-delete-button').live('click', elgg.ui.widgets.remove);
$('.elgg-widget-edit > form ').live('submit', elgg.ui.widgets.saveSettings);
$('a.elgg-widget-collapse-button').live('click', elgg.ui.widgets.collapseToggle);
elgg.ui.widgets.setMinHeight(".elgg-widgets");
}
elgg
Definition: install.js:23
elgg module widget elgg state draggable elgg widget handle
Definition: admin.php:1209
elgg widget placeholder
Definition: admin.php:1248
function elgg combo checkbox click(function(){if($(this).is(':checked')){$(this).prev().attr('disabled', true);$(this).prev().val('');}else{$(this).prev().attr('disabled', false);}})

Widgets initialization.

Returns
void jqueryui.sortable

Definition at line 9 of file ui.widgets.js.

elgg ui widgets move
Initial value:
= function(event, ui) {
var guidString = ui.item.attr('id');
guidString = guidString.substr(guidString.indexOf('elgg-widget-') + "elgg-widget-".length);
var col = ui.item.parent().attr('id');
col = col.substr(col.indexOf('elgg-widget-col-') + "elgg-widget-col-".length);
elgg.action('widgets/move', {
data: {
widget_guid: guidString,
column: col,
position: ui.item.index()
}
});
ui.item.css('top', 0);
ui.item.css('left', 0);
}
elgg
Definition: install.js:23
clearfix elgg elgg elgg elgg page elgg page elgg elgg elgg col
Definition: admin.php:127
list style position
Definition: typography.php:154

Persist the widget's new position.

Parameters
{Object}event
{Object}ui
Returns
void

Definition at line 78 of file ui.widgets.js.

elgg ui widgets remove
Initial value:
= function(event) {
if (confirm(elgg.echo('deleteconfirm')) === false) {
event.preventDefault();
return;
}
var $widget = $(this).closest('.elgg-module-widget');
var type = $(this).data('elgg-widget-type');
$container = $(this).parents('.elgg-layout-widgets').first();
$button = $('[data-elgg-widget-type="' + type + '"]', $container);
var multiple = $button.attr('class').indexOf('elgg-widget-multiple') != -1;
if (multiple === false) {
$button.addClass('elgg-state-available');
$button.removeClass('elgg-state-unavailable');
$button.unbind('click', elgg.ui.widgets.add);
$button.click(elgg.ui.widgets.add);
}
$widget.remove();
elgg.action($(this).attr('href'));
event.preventDefault();
}
elgg
Definition: install.js:23
$widget
Definition: delete.php:9
if($entity) $container
Definition: access.php:62
list style type
Definition: admin.php:748

Removes a widget from the layout.

Event callback the uses Ajax to delete the widget and removes its HTML

Parameters
{Object}event
Returns
void

Definition at line 109 of file ui.widgets.js.

elgg ui widgets saveSettings
Initial value:
= function(event) {
$(this).parent().slideToggle('medium');
var $widgetContent = $(this).parent().parent().children('.elgg-widget-content');
var $loader = $('#elgg-widget-loader').clone();
$loader.attr('id', '#elgg-widget-active-loader');
$loader.removeClass('hidden');
$widgetContent.html($loader);
var default_widgets = $("input[name='default_widgets']").val() || 0;
if (default_widgets) {
$(this).append('<input type="hidden" name="default_widgets" value="1">');
}
elgg.action('widgets/save', {
data: $(this).serialize(),
success: function(json) {
$widgetContent.html(json.output);
if (typeof(json.title) != "undefined") {
var $widgetTitle = $widgetContent.parent().parent().find('.elgg-widget-title');
$widgetTitle.html(json.title);
}
}
});
event.preventDefault();
}
elgg message elgg state success
Definition: admin.php:252
elgg
Definition: install.js:23
$loader
Definition: ajax_loader.php:32

Save a widget's settings.

Uses Ajax to save the settings and updates the HTML.

Parameters
{Object}event
Returns
void

Definition at line 157 of file ui.widgets.js.

elgg ui widgets setMinHeight
Initial value:
= function(selector) {
var maxBottom = 0;
$(selector).each(function() {
var bottom = parseInt($(this).offset().top + $(this).height());
if (bottom > maxBottom) {
maxBottom = bottom;
}
});
$(selector).each(function() {
var bottom = parseInt($(this).offset().top + $(this).height());
if (bottom < maxBottom) {
var newMinHeight = parseInt($(this).height() + (maxBottom - bottom));
$(this).css('min-height', newMinHeight + 'px');
}
});
}
border top
Definition: admin.php:386
margin bottom
Definition: admin.php:38
line height
Definition: admin.php:82

Set the min-height so that all widget column bottoms are the same.

This addresses the issue of trying to drag a widget into a column that does not have any widgets or many fewer widgets than other columns.

Parameters
{String}selector
Returns
void

Definition at line 194 of file ui.widgets.js.