10 define(
'elgg/widgets', [
'elgg',
'jquery'],
function (
elgg, $) {
20 widgets.init =
function () {
23 if ($(
".elgg-widgets").length === 0) {
27 $(
".elgg-widgets").sortable({
28 items:
'div.elgg-module-widget.elgg-state-draggable',
29 connectWith:
'.elgg-widgets',
30 handle:
'.elgg-widget-handle',
31 forcePlaceholderSize:
true,
38 $(
'.elgg-widgets-add-panel li.elgg-state-available').
click(widgets.add);
40 $(
document).
on(
'click',
'a.elgg-widget-delete-button', widgets.remove);
41 $(
document).
on(
'submit',
'.elgg-widget-edit > form ', widgets.saveSettings);
42 $(
document).
on(
'click',
'a.elgg-widget-collapse-button', widgets.collapseToggle);
44 widgets.setMinHeight(
".elgg-widgets");
55 widgets.add =
function (event) {
56 var
type = $(
this).data(
'elgg-widget-type');
59 var multiple = $(
this).attr(
'class').indexOf(
'elgg-widget-multiple') != -1;
60 if (multiple ===
false) {
61 $(
this).addClass(
'elgg-state-unavailable');
62 $(
this).removeClass(
'elgg-state-available');
63 $(
this).unbind(
'click', widgets.add);
66 var
$layout = $(
this).closest(
'.elgg-layout-widgets');
67 var page_owner_guid = $layout.data(
'pageOwnerGuid') ||
elgg.get_page_owner_guid();
69 elgg.action(
'widgets/add', {
72 page_owner_guid: page_owner_guid,
73 context: $(
"input[name='widget_context']").val(),
74 show_access: $(
"input[name='show_access']").val(),
75 default_widgets: $(
"input[name='default_widgets']").val() || 0
78 $(
'#elgg-widget-col-1').prepend(json.output);
81 event.preventDefault();
92 widgets.move =
function (event, ui) {
95 var guidString = ui.item.attr(
'id');
96 guidString = guidString.substr(guidString.indexOf(
'elgg-widget-') +
"elgg-widget-".length);
99 var
col = ui.item.parent().attr(
'id');
100 col = col.substr(col.indexOf(
'elgg-widget-col-') +
"elgg-widget-col-".length);
102 elgg.action(
'widgets/move', {
104 widget_guid: guidString,
111 ui.item.css(
'top', 0);
112 ui.item.css(
'left', 0);
123 widgets.remove =
function (event) {
124 if (confirm(
elgg.echo(
'deleteconfirm')) ===
false) {
125 event.preventDefault();
129 var
$widget = $(
this).closest(
'.elgg-module-widget');
132 var type = $(
this).data(
'elgg-widget-type');
133 $container = $(
this).parents(
'.elgg-layout-widgets').first();
134 $button = $(
'[data-elgg-widget-type="' + type +
'"]',
$container);
135 var multiple = $button.attr(
'class').indexOf(
'elgg-widget-multiple') != -1;
136 if (multiple ===
false) {
137 $button.addClass(
'elgg-state-available');
138 $button.removeClass(
'elgg-state-unavailable');
139 $button.unbind(
'click', widgets.add);
140 $button.click(widgets.add);
146 elgg.action($(
this).attr(
'href'));
148 event.preventDefault();
157 widgets.collapseToggle =
function (event) {
158 $(
this).toggleClass(
'elgg-widget-collapsed');
159 $(
this).parent().parent().find(
'.elgg-body').slideToggle(
'medium');
160 event.preventDefault();
171 widgets.saveSettings =
function (event) {
172 $(
this).parent().slideToggle(
'medium');
173 var $widgetContent = $(
this).parent().parent().children(
'.elgg-widget-content');
176 var
$loader = $(
'#elgg-widget-loader').clone();
177 $loader.attr(
'id',
'#elgg-widget-active-loader');
178 $loader.removeClass(
'hidden');
179 $widgetContent.html($loader);
181 var default_widgets = $(
"input[name='default_widgets']").val() || 0;
182 if (default_widgets) {
183 $(
this).append(
'<input type="hidden" name="default_widgets" value="1">');
186 elgg.action(
'widgets/save', {
187 data: $(
this).serialize(),
189 $widgetContent.html(json.output);
190 if (typeof (json.title) !=
"undefined") {
191 var $widgetTitle = $widgetContent.parent().parent().find(
'.elgg-widget-title');
192 $widgetTitle.html(json.title);
196 event.preventDefault();
208 widgets.setMinHeight =
function (selector) {
210 $(selector).each(
function () {
212 if (bottom > maxBottom) {
216 $(selector).each(
function () {
217 var bottom = parseInt($(
this).offset().
top + $(
this).
height());
218 if (bottom < maxBottom) {
219 var newMinHeight = parseInt($(
this).
height() + (maxBottom - bottom));
220 $(
this).css(
'min-height', newMinHeight +
'px');
clearfix elgg elgg elgg elgg page elgg page elgg elgg elgg col
elgg module widget elgg state draggable elgg widget handle
elgg layout widgets elgg widgets
define('elgg/widgets', ['elgg', 'jquery'], function(elgg,$){var widgets={};widgets.init=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:widgets.move});$('.elgg-widgets-add-panel li.elgg-state-available').click(widgets.add);$(document).on('click', 'a.elgg-widget-delete-button', widgets.remove);$(document).on('submit', '.elgg-widget-edit > form ', widgets.saveSettings);$(document).on('click', 'a.elgg-widget-collapse-button', widgets.collapseToggle);widgets.setMinHeight(".elgg-widgets");};widgets.add=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', widgets.add);}var $layout=$(this).closest('.elgg-layout-widgets');var page_owner_guid=$layout.data('pageOwnerGuid')||elgg.get_page_owner_guid();elgg.action('widgets/add',{data:{handler:type, page_owner_guid: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();};widgets.move=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);};widgets.remove=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', widgets.add);$button.click(widgets.add);}$widget.remove();elgg.action($(this).attr('href'));event.preventDefault();};widgets.collapseToggle=function(event){$(this).toggleClass('elgg-widget-collapsed');$(this).parent().parent().find('.elgg-body').slideToggle('medium');event.preventDefault();};widgets.saveSettings=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();};widgets.setMinHeight=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');}});};return widgets;})
To implement a BC solution and deprecated elgg.ui.widgets, we use a named AMD module that is inlined ...
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(isset($httpCodes[$type])) $layout
function elgg combo checkbox click(function(){if($(this).is(':checked')){$(this).prev().attr('disabled', true);$(this).prev().val('');}else{$(this).prev().attr('disabled', false);}})
GNU GENERAL PUBLIC LICENSE June Free Software Inc Franklin Fifth MA USA Everyone is permitted to copy and distribute verbatim copies of this license document
elgg message elgg state success