Elgg  Version 2.3
tabs.js
Go to the documentation of this file.
1 
6 define(function (require) {
7 
8  var elgg = require('elgg');
9  require('elgg/ready');
10  var $ = require('jquery');
11  var Ajax = require('elgg/Ajax');
12  var ajax = new Ajax(false);
13 
14  function changeTab($tab) {
15 
16  $tab.siblings().andSelf().removeClass('elgg-state-selected');
17  $tab.addClass('elgg-state-selected');
18 
19  var $target = $tab.data('target');
20  if (!$target || !$target.length) {
21  return false;
22  }
23 
24  $target.siblings().addClass('hidden').removeClass('elgg-state-active');
25  $target.removeClass('hidden').addClass('elgg-state-active');
26 
27  return true;
28  }
29 
30  $(document).on('click', '.elgg-tabs-component .elgg-tabs > li > a', function (e) {
31  e.preventDefault();
32 
33  var $link = $(this);
34  var $tab = $(this).parent();
35  var $component = $(this).closest('.elgg-tabs-component');
36  var $content = $component.find('.elgg-tabs-content');
37 
38  var href = $link.data('ajaxHref') || $link.attr('href');
39  var $target = $tab.data('target');
40 
41  if (href.indexOf('#') === 0) {
42  // Open inline tab
43  if (!$target || !$target.length) {
44  var $target = $content.find(href);
45  $tab.data('target', $target);
46  }
47 
48  if (changeTab($tab)) {
49  $tab.trigger('open');
50  return;
51  }
52  } else {
53  // Load an ajax tab
54  if (!$target || !$target.length) {
55  var $target = $('<div>').addClass('elgg-content hidden');
56  $content.append($target);
57  $tab.data('target', $target);
58  }
59 
60  if ($tab.data('loaded') && !$link.data('ajaxReload')) {
61  if (changeTab($tab)) {
62  $tab.trigger('open');
63  return;
64  }
65  }
66 
67  ajax.path(href, {
68  data: $link.data('ajaxQuery') || {},
69  beforeSend: function () {
70  changeTab($tab);
71  $target.addClass('elgg-ajax-loader');
72  }
73  }).done(function (output, statusText, jqXHR) {
74  $tab.data('loaded', true);
75  $target.removeClass('elgg-ajax-loader');
76  if (jqXHR.AjaxData.status === -1) {
77  $target.html(elgg.echo('ajax:error'));
78  return;
79  } else {
80  $target.html(output);
81  }
82 
83  if (changeTab($tab)) {
84  $tab.trigger('open');
85  }
86  });
87  }
88  });
89 
90  // Open selected tabs
91  // This will load any selected tabs that link to ajax views
92  $('.elgg-tabs-component .elgg-tabs > li.elgg-state-selected > a').trigger('click');
93 });
94 
elgg
Definition: install.js:23
$link
Definition: container.php:14
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 ajax
Wrapper function for jQuery.ajax which ensures that the url being called is relative to the elgg site...
Definition: ajax.js:19
if(!($comment instanceof\ElggComment)||!$comment->canEdit()) $target
Definition: edit.php:17
elgg require
Throw an error if the required package isn&#39;t present.
Definition: elgglib.js:164
elgg output
define(function(require){var elgg=require('elgg');require('elgg/ready');var $=require('jquery');var Ajax=require('elgg/Ajax');var ajax=new Ajax(false);function changeTab($tab){$tab.siblings().andSelf().removeClass('elgg-state-selected');$tab.addClass('elgg-state-selected');var $target=$tab.data('target');if(!$target||!$target.length){return false;}$target.siblings().addClass('hidden').removeClass('elgg-state-active');$target.removeClass('hidden').addClass('elgg-state-active');return true;}$(document).on('click', '.elgg-tabs-component.elgg-tabs > li > a', function(e){e.preventDefault();var $link=$(this);var $tab=$(this).parent();var $component=$(this).closest('.elgg-tabs-component');var $content=$component.find('.elgg-tabs-content');var href=$link.data('ajaxHref')||$link.attr('href');var $target=$tab.data('target');if(href.indexOf('#')===0){if(!$target||!$target.length){var $target=$content.find(href);$tab.data('target', $target);}if(changeTab($tab)){$tab.trigger('open');return;}}else{if(!$target||!$target.length){var $target=$('< div >').addClass('elgg-content hidden');$content.append($target);$tab.data('target', $target);}if($tab.data('loaded')&&!$link.data('ajaxReload')){if(changeTab($tab)){$tab.trigger('open');return;}}ajax.path(href,{data:$link.data('ajaxQuery')||{}, beforeSend:function(){changeTab($tab);$target.addClass('elgg-ajax-loader');}}).done(function(output, statusText, jqXHR){$tab.data('loaded', true);$target.removeClass('elgg-ajax-loader');if(jqXHR.AjaxData.status===-1){$target.html(elgg.echo('ajax:error'));return;}else{$target.html(output);}if(changeTab($tab)){$tab.trigger('open');}});}});$('.elgg-tabs-component.elgg-tabs > li.elgg-state-selected > a').trigger('click');})
Tabbed module.
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
$content
Set robots.txt action.
Definition: set_robots.php:6