From ebcbf0cb3b4c4053565adc089acfb8bc96605701 Mon Sep 17 00:00:00 2001 From: cash Date: Thu, 18 Nov 2010 23:01:39 +0000 Subject: Added functions to support moving and adding widgets git-svn-id: http://code.elgg.org/elgg/trunk@7340 36083f99-b078-4883-b0ff-0f9b5a30f544 --- js/lib/ui.widgets.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'js') diff --git a/js/lib/ui.widgets.js b/js/lib/ui.widgets.js index b1e7b2a99..507a1a1a8 100644 --- a/js/lib/ui.widgets.js +++ b/js/lib/ui.widgets.js @@ -1,7 +1,7 @@ elgg.provide('elgg.ui.widgets'); elgg.ui.widgets.init = function() { - $(".widget_column" ).sortable({ + $(".widget_column").sortable({ items: 'div.widget', connectWith: '.widget_column', handle: 'div.drag_handle', @@ -27,11 +27,23 @@ elgg.ui.widgets.init = function() { }); event.preventDefault(); }); + + elgg.ui.widgets.equalHeight(".widget_column"); }; // insert a widget into the layout elgg.ui.widgets.insert = function(html) { - $('.widget_first_col').prepend(html); + $('.widget_col_1').prepend(html); +} + +elgg.ui.widgets.equalHeight = function(selector) { + var maxHeight = 0; + $(selector).each(function() { + if ($(this).height() > maxHeight) { + maxHeight = $(this).height(); + } + }) + $(selector).css('min-height', maxHeight); } //List active widgets for each page column @@ -85,7 +97,7 @@ elgg.ui.widgets.toggleContent = function(e) { // set cookie for widget panel open-state thisWidgetName = $(this.parentNode.parentNode.parentNode).attr('id'); - elgg.session.cookie(thisWidgetName, 'expanded', {expires: 365 }); + elgg.session.cookie(thisWidgetName, 'expanded', {expires: 365}); } else { targetContent.slideUp(400); @@ -96,7 +108,7 @@ elgg.ui.widgets.toggleContent = function(e) { // set cookie for widget panel closed-state thisWidgetName = $(this.parentNode.parentNode.parentNode).attr('id'); - elgg.session.cookie(thisWidgetName, 'collapsed', { expires: 365 }); + elgg.session.cookie(thisWidgetName, 'collapsed', {expires: 365}); } return false; }; -- cgit v1.2.3