Elgg  Version 5.1
dropdown.js
Go to the documentation of this file.
1 
6 define(['jquery', 'elgg', 'elgg/popup'], function ($, elgg, popup) {
7 
8  var dropdown = {
9 
10  init: function () {
11  // handles clicking on a menu item that has a dropdown menu
12  $(document).on('click', '.elgg-menu-item-has-dropdown > a', function (e) {
13  var $trigger = $(this);
14  if ($trigger.data('dropdownMenu')) {
15  var $target = $trigger.data('dropdownMenu');
16  } else {
17  var $target = $trigger.siblings('.elgg-child-menu').eq(0);
18  $trigger.data('dropdownMenu', $target);
19 
20  $target.on('open', function () {
21  $trigger.addClass('elgg-menu-opened')
22  .removeClass('elgg-menu-closed');
23  $trigger.parent().addClass('elgg-state-selected');
24  $target.find('a:first').focus();
25  });
26 
27  $target.on('close', function () {
28  $trigger.addClass('elgg-menu-closed')
29  .removeClass('elgg-menu-opened');
30  $trigger.parent().removeClass('elgg-state-selected');
31  });
32  }
33 
34  if (!$trigger.length || !$target.length) {
35  return;
36  }
37 
38  e.preventDefault();
39 
40  $target.addClass('elgg-menu-hover');
41  var position = $target.data('position') || {
42  at: 'center bottom',
43  my: 'center top',
44  collision: 'fit fit'
45  };
46  position.of = $trigger;
47 
48  popup.open($trigger, $target, position);
49  });
50 
51  // if an anchor also has its own link the text acts as the link, the before pseudo element handles the toggle
52  $(document).on('click', '.elgg-menu-item-has-dropdown > a > .elgg-anchor-label', function (e) {
53  var $anchor = $(this).closest('a');
54  var href = $anchor.attr('href');
55 
56  if ($anchor.hasClass('elgg-non-link') || !href) {
57  return;
58  }
59 
60  document.location = href;
61 
62  e.preventDefault();
63  e.stopImmediatePropagation();
64  });
65 
66  dropdown.init = function() {};
67  }
68  };
69 
70  dropdown.init();
71 
72  return dropdown;
73 });
if(!$comment instanceof\ElggComment||!$comment->canEdit()) $target
Definition: edit.php:15
Bundled plugins(the contents of the"/mod"directory) are available only under the GPLv2 license.The remainder of the project is available under either MIT or GPLv2.Both licenses can be found below.More info 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: LICENSE.txt:96
var elgg
Definition: elgglib.js:4