From da63469210a1c6492b5a0b832b1a54109f248a86 Mon Sep 17 00:00:00 2001 From: cash Date: Sun, 12 Dec 2010 20:40:31 +0000 Subject: added toggler function git-svn-id: http://code.elgg.org/elgg/trunk@7607 36083f99-b078-4883-b0ff-0f9b5a30f544 --- js/lib/ui.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'js/lib/ui.js') diff --git a/js/lib/ui.js b/js/lib/ui.js index a9315883f..1ebc3bca6 100644 --- a/js/lib/ui.js +++ b/js/lib/ui.js @@ -5,6 +5,8 @@ elgg.ui.init = function () { $('.elgg-system-messages li').live('click', function() { $(this).stop().fadeOut('fast'); }); + + $('.elgg-toggle').click(elgg.ui.toggle); $('a.collapsibleboxlink').click(elgg.ui.toggleCollapsibleBox); @@ -21,6 +23,22 @@ elgg.ui.init = function () { }); }; +/** + * Toggles an element based on clicking a separate element + * + * Use .elgg-toggle on the toggler element + * The id of the toggler is elgg-toggler- + * The id of the element being toggled is elgg-togglee- + * + * @param {Object} event + * @return void + */ +elgg.ui.toggle = function(event) { + var id = $(this).attr('id').replace('toggler', 'togglee'); + $('#' + id).slideToggle('medium'); + event.preventDefault(); +} + // reusable generic hidden panel elgg.ui.toggleCollapsibleBox = function () { $(this.parentNode.parentNode).children(".collapsible_box").slideToggle("fast"); -- cgit v1.2.3