Elgg  Version 2.3
popup.js
Go to the documentation of this file.
1 
8 define('elgg/popup', ['elgg', 'jquery', 'jquery-ui'], function (elgg, $) {
9 
10  var popup = {
19  init: function () {
20  $(document).on('click', function (e) {
21  var $eventTargets = $(e.target).parents().andSelf();
22  if ($eventTargets.is('.elgg-state-popped')) {
23  return;
24  }
25  popup.close();
26  });
27  // Bind events only once
28  popup.init = elgg.nullFunction;
29  },
42  bind: function ($triggers) {
43  $triggers.off('click.popup')
44  .on('click.popup', function (e) {
45  if (e.isDefaultPrevented()) {
46  return;
47  }
48  e.preventDefault();
49  e.stopPropagation();
50  popup.open($(this));
51  });
52  },
71  open: function ($trigger, $target, position) {
72  if (typeof $trigger === 'undefined' || !$trigger.length) {
73  return;
74  }
75 
76  if (typeof $target === 'undefined') {
77  var href = $trigger.attr('href') || $trigger.data('href') || '';
78  var targetSelector = elgg.getSelectorFromUrlFragment(href);
79  $target = $(targetSelector);
80  } else {
81  $target.uniqueId();
82  var targetSelector = '#' + $target.attr('id');
83  }
84 
85  if (!$target.length) {
86  return;
87  }
88 
89  // emit a hook to allow plugins to position and control popups
90  var params = {
91  targetSelector: targetSelector,
92  target: $target,
93  source: $trigger
94  };
95 
96  position = position || {
97  my: 'center top',
98  at: 'center bottom',
99  of: $trigger,
100  collision: 'fit fit'
101  };
102 
103  $.extend(position, $trigger.data('position'));
104 
105  position = elgg.trigger_hook('getOptions', 'ui.popup', params, position);
106 
107  if (!position) {
108  return;
109  }
110 
111  popup.init();
112 
113  // If the user is clicking on the trigger while the popup is open
114  // we should just close the popup
115  if ($target.is('.elgg-state-popped')) {
116  popup.close($target);
117  return;
118  }
119 
120  popup.close(); // close any open popup modules
121 
122  $target.data('trigger', $trigger); // used to remove elgg-state-active class when popup is closed
123  $target.data('position', position); // used to reposition the popup module on window manipulations
124 
125  if (!$trigger.is('.elgg-popup-inline')) {
126  $target.appendTo('body');
127  }
128 
129  $target.fadeIn()
130  .addClass('elgg-state-active elgg-state-popped')
131  .position(position);
132 
133  $trigger.addClass('elgg-state-active');
134 
135  $target.trigger('open');
136  },
143  close: function ($targets) {
144  if (typeof $targets === 'undefined') {
145  $targets = $('.elgg-state-popped');
146  }
147  if (!$targets.length) {
148  return;
149  }
150  $targets.each(function () {
151  var $target = $(this);
152  if (!$target.is(':visible')) {
153  return;
154  }
155 
156  var $trigger = $target.data('trigger');
157  if ($trigger.length) {
158  $trigger.removeClass('elgg-state-active');
159  }
160 
161  // @todo: use css transitions instead of $.fadeOut()
162  $target.fadeOut().removeClass('elgg-state-active elgg-state-popped');
163 
164  $target.trigger('close');
165  });
166  }
167  };
168 
169  return popup;
170 });
elgg
Definition: install.js:23
elgg comments init
Initialize comment inline editing.
Definition: comments.js:122
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two distribute and or modify the software for each author s protection and we want to make certain that everyone understands that there is no warranty for this free software If the software is modified by someone else and passed on
Definition: GPL-LICENSE.txt:43
elgg module popup
Definition: admin.css.php:355
if(!($comment instanceof\ElggComment)||!$comment->canEdit()) $target
Definition: edit.php:17
GNU GENERAL PUBLIC LICENSE June Free Software Inc Franklin Fifth MA USA Everyone is permitted to copy and distribute verbatim copies of this license document
Definition: GPL-LICENSE.txt:4
list style position