Permalink
Browse files

feature(js): elgg.ui.toggle now triggers jQuery event

After a toggle is activated, an event is fired on the toggle element. Listeners
receive a jQuery-wrapped reference to the target element(s).
  • Loading branch information...
mrclay committed Nov 28, 2015
1 parent 8d2a4b2 commit 941b49adabbe846f83c1fd259baded8d9a19d2aa
Showing with 10 additions and 4 deletions.
  1. +10 −4 js/lib/ui.js
View
@@ -55,24 +55,30 @@ elgg.ui.init = function () {
elgg.ui.toggles = function(event) {
event.preventDefault();
var $this = $(this),
target = $this.data().toggleSelector;
selector = $this.data().toggleSelector;
if (!target) {
if (!selector) {
// @todo we can switch to elgg.getSelectorFromUrlFragment() in 1.x if
// we also extend it to support href=".some-class"
target = $this.attr('href');
selector = $this.attr('href');
}
var $elements = $(selector);
$this.toggleClass('elgg-state-active');
$(target).each(function(index, elem) {
$elements.each(function(index, elem) {
var $elem = $(elem);
if ($elem.data().toggleSlide != false) {
$elem.slideToggle('medium');
} else {
$elem.toggle();
}
});
$this.trigger('elgg_ui_toggle', [{
$toggled_elements: $elements
}]);
};
/**

0 comments on commit 941b49a

Please sign in to comment.