Elgg  Version 4.3
Functions
tabs.js File Reference

Go to the source code of this file.

Functions

 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. More...
 

Function Documentation

define ( 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.