PageSourceSearch

https://pitb.gov.pk/sites/all/modules/quicktabs/js/quicktabs.js?tfldve

js pitb.gov.pk collected 2026-10-01 12:21:40 UTC 3,537 bytes, 118 lines download raw bytes

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  $ul.find('li a').each(function(i, element){
25    element.myTabIndex = i;
26    element.qt_name = qt_name;
27    var tab = new Drupal.quicktabs.tab(element);
28    var parent_li = $(element).parents('li').get(0);
29    if ($(parent_li).hasClass('active')) {
30      $(element).addClass('quicktabs-loaded');
31    }
32    $(element).once(function() {$(this).bind('click', {tab: tab}, Drupal.quicktabs.clickHandler);});
33  });
34}
35
36Drupal.quicktabs.clickHandler = function(event) {
37  var tab = event.data.tab;
38  var element = this;
39  // Set clicked tab to active.
40  $(this).parents('li').siblings().removeClass('active');
41  $(this).parents('li').addClass('active');
42
43  // Hide all tabpages.
44  tab.container.children().addClass('quicktabs-hide');
45  
46  if (!tab.tabpage.hasClass("quicktabs-tabpage")) {
47    tab = new Drupal.quicktabs.tab(element);
48  }
49
50  tab.tabpage.removeClass('quicktabs-hide');
51  return false;
52}
53
54// Constructor for an individual tab
55Drupal.quicktabs.tab = function (el) {
56  this.element = el;
57  this.tabIndex = el.myTabIndex;
58  var qtKey = 'qt_' + el.qt_name;
59  var i = 0;
60  for (var i = 0; i < Drupal.settings.quicktabs[qtKey].tabs.length; i++) {
61    if (i == this.tabIndex) {
62      this.tabObj = Drupal.settings.quicktabs[qtKey].tabs[i];
63      this.tabKey = i;
64    }
65  }
66  this.tabpage_id = 'quicktabs-tabpage-' + el.qt_name + '-' + this.tabKey;
67  this.container = $('#quicktabs-container-' + el.qt_name);
68  this.tabpage = this.container.find('#' + this.tabpage_id);
69}
70
71if (Drupal.ajax) {
72  /**
73   * Handle an event that triggers an AJAX response.
74   *
75   * We unfortunately need to override this function, which originally comes from
76   * misc/ajax.js, in order to be able to cache loaded tabs, i.e. once a tab
77   * content has loaded it should not need to be loaded again.
78   *
79   * I have removed all comments that were in the original core function, so that
80   * the only comments inside this function relate to the Quicktabs modification
81   * of it.
82   */
83  Drupal.ajax.prototype.eventResponse = function (element, event) {
84    var ajax = this;
85
86    if (ajax.ajaxing) {
87      return false;
88    }
89  
90    try {
91      if (ajax.form) {
92        if (ajax.setClick) {
93          element.form.clk = element;
94        }
95  
96        ajax.form.ajaxSubmit(ajax.options);
97      }
98      else {
99        // Do not perform an ajax request for already loaded Quicktabs content.
100        if (!$(element).hasClass('quicktabs-loaded')) {
101          ajax.beforeSerialize(ajax.element, ajax.options);
102          $.ajax(ajax.options);
103          if ($(element).parents('ul').hasClass('quicktabs-tabs')) {
104            $(element).addClass('quicktabs-loaded');
105          }
106        }
107      }
108    }
109    catch (e) {
110      ajax.ajaxing = false;
111      alert("An error occurred while attempting to process " + ajax.options.url + ": " + e.message);
112    }
113    return false;
114  };
115}
116
117
118})(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.