1(function ($) { 2Drupal.settings.views = Drupal.settings.views || {'ajax_path': '/views/ajax'}; 3 4Drupal.quicktabs = Drupal.quicktabs || {}; 5 6Drupal.quicktabs.getQTName = function (el) { 7 return el.id.substring(el.id.indexOf('-') +1); 8} 9 10Drupal.behaviors.quicktabs = { 11 attach: function (context, settings) { 12 $.extend(true, Drupal.settings, settings); 13 $('.quicktabs-wrapper', context).once(function(){ 14 Drupal.quicktabs.prepare(this); 15 }); 16 } 17} 18 19// Setting up the inital behaviours 20Drupal.quicktabs.prepare = function(el) { 21 // el.id format: "quicktabs-$name" 22 var qt_name = Drupal.quicktabs.getQTName(el); 23 var $ul = $(el).find('ul.quicktabs-tabs:first'); 24 25 $("ul.quicktabs-tabs li a span#active-quicktabs-tab").remove(); 26 27 $ul.find('li a').each(function(i, element){ 28 element.myTabIndex = i; 29 element.qt_name = qt_name; 30 31 var tab = new Drupal.quicktabs.tab(element); 32 var parent_li = $(element).parents('li').get(0); 33 if ($(parent_li).hasClass('active')) { 34 $(element).addClass('quicktabs-loaded'); 35 $(element).append('<span id="active-quicktabs-tab" class="element-invisible">' + Drupal.t('(active tab)') + '</span>'); 36 } 37 $(element).once(function() {$(this).bind('click', {tab: tab}, Drupal.quicktabs.clickHandler);}); 38 }); 39} 40 41Drupal.quicktabs.clickHandler = function(event) { 42 var tab = event.data.tab; 43 var element = this; 44 // Set clicked tab to active. 45 $(this).parents('li').siblings().removeClass('active'); 46 $(this).parents('li').addClass('active'); 47 48 $("ul.quicktabs-tabs li a span#active-quicktabs-tab").remove(); 49 $(this).append('<span id="active-quicktabs-tab" class="element-invisible">' + Drupal.t('(active tab)') + '</span>'); 50 51 // Hide all tabpages. 52 tab.container.children().addClass('quicktabs-hide'); 53 54 if (!tab.tabpage.hasClass("quicktabs-tabpage")) { 55 tab = new Drupal.quicktabs.tab(element); 56 } 57 58 tab.tabpage.removeClass('quicktabs-hide'); 59 $(element).trigger('switchtab'); 60 return false; 61} 62 63// Constructor for an individual tab 64Drupal.quicktabs.tab = function (el) { 65 this.element = el; 66 this.tabIndex = el.myTabIndex; 67 var qtKey = 'qt_' + el.qt_name; 68 var i = 0; 69 for (var key in Drupal.settings.quicktabs[qtKey].tabs) { 70 if (i == this.tabIndex) { 71 this.tabObj = Drupal.settings.quicktabs[qtKey].tabs[key]; 72 this.tabKey = key; 73 } 74 i++; 75 } 76 this.tabpage_id = 'quicktabs-tabpage-' + el.qt_name + '-' + this.tabKey; 77 this.container = $('#quicktabs-container-' + el.qt_name); 78 this.tabpage = this.container.find('#' + this.tabpage_id); 79} 80 81if (Drupal.ajax) { 82 /** 83 * Handle an event that triggers an AJAX response. 84 * 85 * We unfortunately need to override this function, which originally comes from 86 * misc/ajax.js, in order to be able to cache loaded tabs, i.e. once a tab 87 * content has loaded it should not need to be loaded again. 88 * 89 * I have removed all comments that were in the original core function, so that 90 * the only comments inside this function relate to the Quicktabs modification 91 * of it. 92 */ 93 Drupal.ajax.prototype.eventResponse = function (element, event) { 94 var ajax = this; 95 96 if (ajax.ajaxing) { 97 return false; 98 } 99 100 try { 101 if (ajax.form) { 102 if (ajax.setClick) { 103 element.form.clk = element; 104 } 105 106 ajax.form.ajaxSubmit(ajax.options); 107 } 108 else { 109 // Do not perform an ajax request for already loaded Quicktabs content. 110 if (!$(element).hasClass('quicktabs-loaded')) { 111 ajax.beforeSerialize(ajax.element, ajax.options); 112 $.ajax(ajax.options); 113 if ($(element).parents('ul').hasClass('quicktabs-tabs')) { 114 $(element).addClass('quicktabs-loaded'); 115 } 116 } 117 } 118 } 119 catch (e) { 120 ajax.ajaxing = false; 121 alert("An error occurred while attempting to process " + ajax.options.url + ": " + e.message); 122 } 123 return false; 124 }; 125} 126 127 128})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.