Elgg  Version 3.0
Go to the documentation of this file.
4 define(['elgg', 'jquery'], function (elgg, $) {
5  // This function toggles a menu item that has a related toggleable menu item
6  $(document).on('click', '.elgg-menu a[data-toggle]', function(event) {
7  var $item_clicked = $(this).closest('li');
8  var $menu = $item_clicked.closest('.elgg-menu');
9  var other_menuitem_name = $(this).data().toggle.replace('_', '-');
10  var $other_item = $menu.find('.elgg-menu-item-' + other_menuitem_name).eq(0);
12  if (!$other_item) {
13  return;
14  }
16  var $both_items = $item_clicked.add($other_item);
17  // Be optimistic about success
18  $both_items.toggleClass('hidden');
19  $other_item.focus();
21  // Send the ajax request
22  elgg.action($(this).attr('href'), {
23  success: function(json) {
24  if (json.system_messages.error.length) {
25  // Something went wrong, so undo the optimistic changes
26  $both_items.toggleClass('hidden');
27  $item_clicked.focus();
28  } else {
29  // let others know we toggled the menu item
30  elgg.trigger_hook('toggle', 'menu_item', {
31  itemClicked: $item_clicked,
32  itemToggled: $other_item,
33  menu: $menu,
34  data: json
35  });
36  }
37  },
38  error: function() {
39  // Something went wrong, so undo the optimistic changes
40  $both_items.toggleClass('hidden');
41  $item_clicked.focus();
42  }
43  });
45  // Don't want to actually click the link
46  return false;
47  });
48 });
Admin sidebar – just outputs the page menus.
Definition: sidebar.php:6
$result error
define(['elgg', 'jquery'], function(elgg,$){$(document).on('click', '.elgg-menu a[data-toggle]', function(event){var $item_clicked=$(this).closest('li');var $menu=$item_clicked.closest('.elgg-menu');var other_menuitem_name=$(this).data().toggle.replace('_', '-');var $other_item=$menu.find('.elgg-menu-item-'+other_menuitem_name).eq(0);if(!$other_item){return;}var $both_items=$item_clicked.add($other_item);$both_items.toggleClass('hidden');$other_item.focus();elgg.action($(this).attr('href'),{success:function(json){if(json.system_messages.error.length){$both_items.toggleClass('hidden');$item_clicked.focus();}else{elgg.trigger_hook('toggle', 'menu_item',{itemClicked:$item_clicked, itemToggled:$other_item, menu:$menu, data:json});}}, error:function(){$both_items.toggleClass('hidden');$item_clicked.focus();}});return false;});})
Adds menu item toggle features.
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