Elgg  Version 4.3
tabs.js
Go to the documentation of this file.
1 
4 define(['jquery', 'elgg/Ajax'], function ($, Ajax) {
5 
6  var ajax = new Ajax(false);
7 
8  function changeTab($link_item, clearing_tab, trigger_open) {
9 
10  clearing_tab = typeof clearing_tab == 'boolean' ? clearing_tab : false;
11  trigger_open = typeof trigger_open == 'boolean' ? trigger_open : true;
12 
13  var $target = $link_item.data('target');
14  if (!$target || !$target.length) {
15  return false;
16  }
17 
18  // only change tab content if not already showing (or if clearing the tab)
19  if ($target.hasClass('elgg-state-active') && !clearing_tab) {
20  return true;
21  }
22 
23  // find the tabs that have the selected state and remove that state
24  $target.closest('.elgg-tabs-component').find('.elgg-tabs').eq(0).find('.elgg-state-selected').removeClass('elgg-state-selected');
25 
26  $link_item.addClass('elgg-state-selected');
27 
28  $target.siblings().addClass('hidden').removeClass('elgg-state-active');
29  $target.removeClass('hidden').addClass('elgg-state-active');
30 
31  require(['elgg/popup'], function(popup) {
32  popup.close();
33  });
34 
35  if (trigger_open) {
36  $link_item.trigger('open');
37  }
38 
39  return true;
40  };
41 
42  function clickLink(event) {
43 
44  var $link = $(this);
45  if ($link.hasClass('elgg-non-link')) {
46  return;
47  }
48 
49  event.preventDefault();
50 
51  var $tab = $(this).parent();
52  var $content = $('.elgg-tabs-content');
53 
54  var href = $link.data('ajaxHref') || $link.attr('href');
55  var $target = $tab.data('target');
56  if (!$target || !$target.length) {
57  // store $tagret for future use
58  $target = $($link.data('target'));
59  $tab.data('target', $target);
60  }
61 
62  if (href.indexOf('#') === 0) {
63  // Open inline tab
64  if (changeTab($tab)) {
65  return;
66  }
67  } else {
68  // Load an ajax tab
69  if ($tab.data('loaded') && !$link.data('ajaxReload')) {
70  if (changeTab($tab)) {
71  return;
72  }
73  }
74 
75  ajax.path(href, {
76  data: $link.data('ajaxQuery') || {},
77  beforeSend: function () {
78  changeTab($tab, true, false);
79  $target.html('');
80  $target.addClass('elgg-ajax-loader');
81  }
82  }).done(function (output, statusText, jqXHR) {
83  $tab.data('loaded', true);
84  $target.removeClass('elgg-ajax-loader').html(output);
85 
86  changeTab($tab, true);
87  }).fail(function() {
88  require(['elgg/i18n'], function(i18n) {
89  $target.removeClass('elgg-ajax-loader').html(i18n.echo('ajax:error'));
90  });
91  });
92  }
93  };
94 
95  // register click event
96  $(document).on('click', '.elgg-components-tab > a', clickLink);
97 
98  // Open selected tabs
99  // This will load any selected tabs that link to ajax views
100  $('.elgg-tabs-component').each(function() {
101  var $tabs = $(this).find('.elgg-components-tab:not(.elgg-menu-item-has-dropdown)');
102  if (!$tabs.length) {
103  return;
104  }
105 
106  if ($tabs.hasClass('elgg-state-selected')) {
107  $tabs.filter('.elgg-state-selected').eq(0).find(' > a').trigger('click');
108  } else {
109  $tabs.eq(0).find(' > a').trigger('click');
110  }
111  });
112 });
if(!$comment instanceof\ElggComment||!$comment->canEdit()) $target
Definition: edit.php:13
if(!$item instanceof ElggEntity) $link
Definition: container.php:16
elgg require
Throw an error if the required package isn't present.
Definition: deprecated.js:176
define(['jquery', 'elgg/Ajax'], function($, Ajax){var ajax=new Ajax(false);function changeTab($link_item, clearing_tab, trigger_open){clearing_tab=typeof clearing_tab== 'boolean'?clearing_tab:false;trigger_open=typeof trigger_open== 'boolean'?trigger_open:true;var $target=$link_item.data('target');if(!$target||!$target.length){return false;}if($target.hasClass('elgg-state-active')&&!clearing_tab){return true;}$target.closest('.elgg-tabs-component').find('.elgg-tabs').eq(0).find('.elgg-state-selected').removeClass('elgg-state-selected');$link_item.addClass('elgg-state-selected');$target.siblings().addClass('hidden').removeClass('elgg-state-active');$target.removeClass('hidden').addClass('elgg-state-active');require(['elgg/popup'], function(popup){popup.close();});if(trigger_open){$link_item.trigger('open');}return true;};function clickLink(event){var $link=$(this);if($link.hasClass('elgg-non-link')){return;}event.preventDefault();var $tab=$(this).parent();var $content=$('.elgg-tabs-content');var href=$link.data('ajaxHref')||$link.attr('href');var $target=$tab.data('target');if(!$target||!$target.length){$target=$($link.data('target'));$tab.data('target', $target);}if(href.indexOf('#')===0){if(changeTab($tab)){return;}}else{if($tab.data('loaded')&&!$link.data('ajaxReload')){if(changeTab($tab)){return;}}ajax.path(href,{data:$link.data('ajaxQuery')||{}, beforeSend:function(){changeTab($tab, true, false);$target.html('');$target.addClass('elgg-ajax-loader');}}).done(function(output, statusText, jqXHR){$tab.data('loaded', true);$target.removeClass('elgg-ajax-loader').html(output);changeTab($tab, true);}).fail(function(){require(['elgg/i18n'], function(i18n){$target.removeClass('elgg-ajax-loader').html(i18n.echo('ajax:error'));});});}};$(document).on('click', '.elgg-components-tab > a', clickLink);$('.elgg-tabs-component').each(function(){var $tabs=$(this).find('.elgg-components-tab:not(.elgg-menu-item-has-dropdown)');if(!$tabs.length){return;}if($tabs.hasClass('elgg-state-selected')){$tabs.filter('.elgg-state-selected').eq(0).find(' > a').trigger('click');}else{$tabs.eq(0).find(' > a').trigger('click');}});})
Tabbed module.
$content
Set robots.txt action.
Definition: set_robots.php:6
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