Elgg
Version 2.3
|
Go to the source code of this file.
Functions | |
define ('elgg/popup', ['elgg', 'jquery', 'jquery-ui'], function(elgg,$){var popup={init:function(){$(document).on('click', function(e){var $eventTargets=$(e.target).parents().andSelf();if($eventTargets.is('.elgg-state-popped')){return;}popup.close();});popup.init=elgg.nullFunction;}, bind:function($triggers){$triggers.off('click.popup').on('click.popup', function(e){if(e.isDefaultPrevented()){return;}e.preventDefault();e.stopPropagation();popup.open($(this));});}, open:function($trigger, $target, position){if(typeof $trigger=== 'undefined'||!$trigger.length){return;}if(typeof $target=== 'undefined'){var href=$trigger.attr('href')||$trigger.data('href')|| '';var targetSelector=elgg.getSelectorFromUrlFragment(href);$target=$(targetSelector);}else{$target.uniqueId();var targetSelector= '#'+$target.attr('id');}if(!$target.length){return;}var params={targetSelector:targetSelector, target:$target, source:$trigger};position=position||{my: 'center top', at: 'center bottom', of:$trigger, collision: 'fit fit'};$.extend(position, $trigger.data('position'));position=elgg.trigger_hook('getOptions', 'ui.popup', params, position);if(!position){return;}popup.init();if($target.is('.elgg-state-popped')){popup.close($target);return;}popup.close();$target.data('trigger', $trigger);$target.data('position', position);if(!$trigger.is('.elgg-popup-inline')){$target.appendTo('body');}$target.fadeIn().addClass('elgg-state-active elgg-state-popped').position(position);$trigger.addClass('elgg-state-active');$target.trigger('open');}, close:function($targets){if(typeof $targets=== 'undefined'){$targets=$('.elgg-state-popped');}if(!$targets.length){return;}$targets.each(function(){var $target=$(this);if(!$target.is(':visible')){return;}var $trigger=$target.data('trigger');if($trigger.length){$trigger.removeClass('elgg-state-active');}$target.fadeOut().removeClass('elgg-state-active elgg-state-popped');$target.trigger('close');});}};return popup;}) | |
We use a named AMD module that is inlined in elgg.js, as this module is loaded on each page request and we do not want to issue an additional HTTP request. More... | |
define | ( | 'elgg/popup' | , |
function(elgg,$){var popup={init:function(){$(document).on('click', function(e){var $eventTargets=$(e.target).parents().andSelf();if($eventTargets.is('.elgg-state-popped')){return;}popup.close();});popup.init=elgg.nullFunction;}, bind:function($triggers){$triggers.off('click.popup').on('click.popup', function(e){if(e.isDefaultPrevented()){return;}e.preventDefault();e.stopPropagation();popup.open($(this));});}, open:function($trigger, $target, position){if(typeof $trigger=== 'undefined'||!$trigger.length){return;}if(typeof $target=== 'undefined'){var href=$trigger.attr('href')||$trigger.data('href')|| '';var targetSelector=elgg.getSelectorFromUrlFragment(href);$target=$(targetSelector);}else{$target.uniqueId();var targetSelector= '#'+$target.attr('id');}if(!$target.length){return;}var params={targetSelector:targetSelector, target:$target, source:$trigger};position=position||{my: 'center top', at: 'center bottom', of:$trigger, collision: 'fit fit'};$.extend(position, $trigger.data('position'));position=elgg.trigger_hook('getOptions', 'ui.popup', params, position);if(!position){return;}popup.init();if($target.is('.elgg-state-popped')){popup.close($target);return;}popup.close();$target.data('trigger', $trigger);$target.data('position', position);if(!$trigger.is('.elgg-popup-inline')){$target.appendTo('body');}$target.fadeIn().addClass('elgg-state-active elgg-state-popped').position(position);$trigger.addClass('elgg-state-active');$target.trigger('open');}, close:function($targets){if(typeof $targets=== 'undefined'){$targets=$('.elgg-state-popped');}if(!$targets.length){return;}$targets.each(function(){var $target=$(this);if(!$target.is(':visible')){return;}var $trigger=$target.data('trigger');if($trigger.length){$trigger.removeClass('elgg-state-active');}$target.fadeOut().removeClass('elgg-state-active elgg-state-popped');$target.trigger('close');});}};return popup;} | |||
) |
We use a named AMD module that is inlined in elgg.js, as this module is loaded on each page request and we do not want to issue an additional HTTP request.
elgg/popup
function(elgg,$){var | popup={init:function(){.on('click', function(e){var $eventTargets=$(e.target).parents().andSelf();if($eventTargets.is('.elgg-state-popped')){return;}popup.close();});popup.init=elgg.nullFunction;}, bind:function($triggers){$triggers.off('click.popup').on('click.popup', function(e){if(e.isDefaultPrevented()){return;}e.preventDefault();e.stopPropagation();popup.open();});}, open:function($trigger, $target, position){if(typeof $trigger=== 'undefined'||!$trigger.length){return;}if(typeof $target=== 'undefined'){var href=$trigger.attr('href')||$trigger.data('href')|| '';var targetSelector=elgg.getSelectorFromUrlFragment(href);$target=;}else{$target.uniqueId();var targetSelector= '#'+$target.attr('id');}if(!$target.length){return;}var params={targetSelector:targetSelector, target:$target, source:$trigger};position=position||{my: 'center top', at: 'center bottom', of:$trigger, collision: 'fit fit'};$.extend(position, $trigger.data('position'));position=elgg.trigger_hook('getOptions', 'ui.popup', params, position);if(!position){return;}popup.init();if($target.is('.elgg-state-popped')){popup.close($target);return;}popup.close();$target.data('trigger', $trigger);$target.data('position', position);if(!$trigger.is('.elgg-popup-inline')){$target.appendTo('body');}$target.fadeIn().addClass('elgg-state-active elgg-state-popped').position(position);$trigger.addClass('elgg-state-active');$target.trigger('open');}, close:function($targets){if(typeof $targets=== 'undefined'){$targets=$('.elgg-state-popped');}if(!$targets.length){return;}$targets.each(function(){var $target=;if(!$target.is(':visible')){return;}var $trigger=$target.data('trigger');if($trigger.length){$trigger.removeClass('elgg-state-active');}$target.fadeOut().removeClass('elgg-state-active elgg-state-popped');$target.trigger('close');});}};return popup;} Initializes a popup module and binds an event to hide visible popup modules on a click event outside of their DOM stack. |
This method is called before the popup module is displayed.
Shortcut to bind a click event on a set of $triggers.