aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--js/lib/ui.js18
1 files changed, 18 insertions, 0 deletions
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-<id>
+ * The id of the element being toggled is elgg-togglee-<id>
+ *
+ * @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");