PageSourceSearch

https://www.duhs.edu.pk/wp-content/plugins/wp-expand-tabs-free/public/assets/js/tab.js

js duhs.edu.pk collected 2026-09-24 09:50:22 UTC 13,182 bytes, 403 lines download raw bytes

1/*!
2  * Bootstrap tab.js v4.3.1 (https://getbootstrap.com/)
3  * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
4  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
5  */
6(function (global, factory) {
7  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery'), require('./util.js')) :
8    typeof define === 'function' && define.amd ? define(['jquery', './util.js'], factory) :
9      (global = global || self, global.SP_WP_Tabs = factory(global.jQuery, global.Util));
10}(this, function ($, Util) {
11  'use strict';
12
13  $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
14  Util = Util && Util.hasOwnProperty('default') ? Util['default'] : Util;
15
16  function _defineProperties(target, props) {
17    for (var i = 0; i < props.length; i++) {
18      var descriptor = props[i];
19      descriptor.enumerable = descriptor.enumerable || false;
20      descriptor.configurable = true;
21      if ("value" in descriptor) descriptor.writable = true;
22      Object.defineProperty(target, descriptor.key, descriptor);
23    }
24  }
25
26  function _createClass(Constructor, protoProps, staticProps) {
27    if (protoProps) _defineProperties(Constructor.prototype, protoProps);
28    if (staticProps) _defineProperties(Constructor, staticProps);
29    return Constructor;
30  }
31
32  var TRANSITION_END = 'transitionend';
33  var MILLISECONDS_MULTIPLIER = 1000; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
34
35  function getSpecialTransitionEndEvent() {
36    return {
37      bindType: TRANSITION_END,
38      delegateType: TRANSITION_END,
39      handle: function handle(event) {
40        if ($(event.target).is(this)) {
41          return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params
42        }
43
44        return undefined; // eslint-disable-line no-undefined
45      }
46    };
47  }
48
49  function transitionEndEmulator(duration) {
50    var _this = this;
51
52    var called = false;
53    $(this).one(Util.TRANSITION_END, function () {
54      called = true;
55    });
56    setTimeout(function () {
57      if (!called) {
58        Util.triggerTransitionEnd(_this);
59      }
60    }, duration);
61    return this;
62  }
63
64  function setTransitionEndSupport() {
65    $.fn.emulateTransitionEnd = transitionEndEmulator;
66    $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent();
67  }
68
69  /**
70   * --------------------------------------------------------------------------
71   * Public Util Api
72   * --------------------------------------------------------------------------
73   */
74  var Util = {
75    TRANSITION_END: 'bsTransitionEnd',
76    getUID: function getUID(prefix) {
77      do {
78        // eslint-disable-next-line no-bitwise
79        prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here
80      } while (document.getElementById(prefix));
81
82      return prefix;
83    },
84    getSelectorFromElement: function getSelectorFromElement(element) {
85      var selector = element.getAttribute('data-target');
86
87      if (!selector || selector === '#') {
88        var forAttr = element.getAttribute('for');
89        selector = forAttr && forAttr !== '#' ? forAttr.trim() : '';
90      }
91
92      try {
93        return document.querySelector(selector) ? selector : null;
94      } catch (err) {
95        return null;
96      }
97    },
98    getTransitionDurationFromElement: function getTransitionDurationFromElement(element) {
99      if (!element) {
100        return 0;
101      } // Get transition-duration of the element
102
103
104      var transitionDuration = $(element).css('transition-duration');
105      var transitionDelay = $(element).css('transition-delay');
106      var floatTransitionDuration = parseFloat(transitionDuration);
107      var floatTransitionDelay = parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
108
109      if (!floatTransitionDuration && !floatTransitionDelay) {
110        return 0;
111      } // If multiple durations are defined, take the first
112
113      transitionDuration = transitionDuration.split(',')[0];
114      transitionDelay = transitionDelay.split(',')[0];
115      return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
116    },
117    reflow: function reflow(element) {
118      return element.offsetHeight;
119    },
120    triggerTransitionEnd: function triggerTransitionEnd(element) {
121      $(element).trigger(TRANSITION_END);
122    },
123    // TODO: Remove in v5
124    supportsTransitionEnd: function supportsTransitionEnd() {
125      return Boolean(TRANSITION_END);
126    },
127    isElement: function isElement(obj) {
128      return (obj[0] || obj).nodeType;
129    },
130    typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) {
131      for (var property in configTypes) {
132        if (Object.prototype.hasOwnProperty.call(configTypes, property)) {
133          var expectedTypes = configTypes[property];
134          var value = config[property];
135          var valueType = value && Util.isElement(value) ? 'element' : toType(value);
136
137          if (!new RegExp(expectedTypes).test(valueType)) {
138            throw new Error(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\"."));
139          }
140        }
141      }
142    },
143    findShadowRoot: function findShadowRoot(element) {
144      if (!document.documentElement.attachShadow) {
145        return null;
146      } // Can find the shadow root otherwise it'll return the document
147
148
149      if (typeof element.getRootNode === 'function') {
150        var root = element.getRootNode();
151        return root instanceof ShadowRoot ? root : null;
152      }
153
154      if (element instanceof ShadowRoot) {
155        return element;
156      } // when we don't find a shadow root
157
158
159      if (!element.parentNode) {
160        return null;
161      }
162
163      return Util.findShadowRoot(element.parentNode);
164    }
165  };
166  setTransitionEndSupport();
167
168  /**
169   * ------------------------------------------------------------------------
170   * Constants
171   * ------------------------------------------------------------------------
172   */
173  var NAME = 'sp_tab';
174  var VERSION = '4.3.1';
175  var DATA_KEY = 'sp.tab';
176  var EVENT_KEY = "." + DATA_KEY;
177  var DATA_API_KEY = '.data-api';
178  var JQUERY_NO_CONFLICT = $.fn[NAME];
179  var Event = {
180    HIDE: "hide" + EVENT_KEY,
181    HIDDEN: "hidden" + EVENT_KEY,
182    SHOW: "show" + EVENT_KEY,
183    SHOWN: "shown" + EVENT_KEY,
184    CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
185  };
186  var ClassName = {
187    DROPDOWN_MENU: 'sp-tab__dropdown-menu',
188    ACTIVE: 'sp-tab__active',
189    DISABLED: 'sp-tab__disabled',
190    FADE: 'sp-tab__fade',
191    SHOW: 'sp-tab__show'
192  };
193  var Selector = {
194    DROPDOWN: '.sp-tab__dropdown',
195    NAV_LIST_GROUP: '.sp-tab__nav, .list-group',
196    ACTIVE: '.sp-tab__active',
197    ACTIVE_UL: '> li > .sp-tab__active',
198    DATA_TOGGLE: '[data-sptoggle="tab"], [data-sptoggle="pill"], [data-sptoggle="list"]',
199    DROPDOWN_TOGGLE: '.sp-tab__dropdown-toggle',
200    DROPDOWN_ACTIVE_CHILD: '> .sp-tab__dropdown-menu .sp-tab__active'
201    /**
202     * ------------------------------------------------------------------------
203     * Class Definition
204     * ------------------------------------------------------------------------
205     */
206
207  };
208
209  var SP_WP_Tabs =
210    /*#__PURE__*/
211    function () {
212      function SP_WP_Tabs(element) {
213        this._element = element;
214      } // Getters
215
216
217      var _proto = SP_WP_Tabs.prototype;
218
219      // Public
220      _proto.show = function show() {
221        var _this = this;
222
223        if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && $(this._element).hasClass(ClassName.ACTIVE) || $(this._element).hasClass(ClassName.DISABLED)) {
224          return;
225        }
226
227        var target;
228        var previous;
229        var listElement = $(this._element).closest(Selector.NAV_LIST_GROUP)[0];
230        var selector = Util.getSelectorFromElement(this._element);
231
232        if (listElement) {
233          var itemSelector = listElement.nodeName === 'UL' || listElement.nodeName === 'OL' ? Selector.ACTIVE_UL : Selector.ACTIVE;
234          previous = $.makeArray($(listElement).find(itemSelector));
235          previous = previous[previous.length - 1];
236        }
237
238        var hideEvent = $.Event(Event.HIDE, {
239          relatedTarget: this._element
240        });
241        var showEvent = $.Event(Event.SHOW, {
242          relatedTarget: previous
243        });
244
245        if (previous) {
246          $(previous).trigger(hideEvent);
247        }
248
249        $(this._element).trigger(showEvent);
250
251        if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) {
252          return;
253        }
254
255        if (selector) {
256          target = document.querySelector(selector);
257        }
258
259        this._activate(this._element, listElement);
260
261        var complete = function complete() {
262          var hiddenEvent = $.Event(Event.HIDDEN, {
263            relatedTarget: _this._element
264          });
265          var shownEvent = $.Event(Event.SHOWN, {
266            relatedTarget: previous
267          });
268          $(previous).trigger(hiddenEvent);
269          $(_this._element).trigger(shownEvent);
270        };
271
272        if (target) {
273          this._activate(target, target.parentNode, complete);
274        } else {
275          complete();
276        }
277      };
278
279      _proto.dispose = function dispose() {
280        $.removeData(this._element, DATA_KEY);
281        this._element = null;
282      } // Private
283        ;
284
285      _proto._activate = function _activate(element, container, callback) {
286        var _this2 = this;
287
288        var activeElements = container && (container.nodeName === 'UL' || container.nodeName === 'OL') ? $(container).find(Selector.ACTIVE_UL) : $(container).children(Selector.ACTIVE);
289        var active = activeElements[0];
290        var isTransitioning = callback && active && $(active).hasClass(ClassName.FADE);
291
292        var complete = function complete() {
293          return _this2._transitionComplete(element, active, callback);
294        };
295
296        if (active && isTransitioning) {
297          var transitionDuration = Util.getTransitionDurationFromElement(active);
298          $(active).removeClass(ClassName.SHOW).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
299        } else {
300          complete();
301        }
302      };
303
304      _proto._transitionComplete = function _transitionComplete(element, active, callback) {
305        if (active) {
306          $(active).removeClass(ClassName.ACTIVE);
307          var dropdownChild = $(active.parentNode).find(Selector.DROPDOWN_ACTIVE_CHILD)[0];
308
309          if (dropdownChild) {
310            $(dropdownChild).removeClass(ClassName.ACTIVE);
311          }
312
313          if (active.getAttribute('role') === 'sptab') {
314            active.setAttribute('aria-selected', false);
315          }
316        }
317
318        $(element).addClass(ClassName.ACTIVE);
319
320        if (element.getAttribute('role') === 'sptab') {
321          element.setAttribute('aria-selected', true);
322        }
323
324        Util.reflow(element);
325
326        if (element.classList.contains(ClassName.FADE)) {
327          element.classList.add(ClassName.SHOW);
328        }
329
330        if (element.parentNode && $(element.parentNode).hasClass(ClassName.DROPDOWN_MENU)) {
331          var dropdownElement = $(element).closest(Selector.DROPDOWN)[0];
332
333          if (dropdownElement) {
334            var dropdownToggleList = [].slice.call(dropdownElement.querySelectorAll(Selector.DROPDOWN_TOGGLE));
335            $(dropdownToggleList).addClass(ClassName.ACTIVE);
336          }
337
338          element.setAttribute('aria-expanded', true);
339        }
340
341        if (callback) {
342          callback();
343        }
344      } // Static
345        ;
346
347      SP_WP_Tabs._jQueryInterface = function _jQueryInterface(config) {
348        return this.each(function () {
349          var $this = $(this);
350          var data = $this.data(DATA_KEY);
351
352          if (!data) {
353            data = new SP_WP_Tabs(this);
354            $this.data(DATA_KEY, data);
355          }
356
357          if (typeof config === 'string') {
358            if (typeof data[config] === 'undefined') {
359              throw new TypeError("No method named \"" + config + "\"");
360            }
361
362            data[config]();
363          }
364        });
365      };
366
367      _createClass(SP_WP_Tabs, null, [{
368        key: "VERSION",
369        get: function get() {
370          return VERSION;
371        }
372      }]);
373
374      return SP_WP_Tabs;
375    }();
376  /**
377   * ------------------------------------------------------------------------
378   * Data Api implementation
379   * ------------------------------------------------------------------------
380   */
381
382  $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) {
383    event.preventDefault();
384
385    SP_WP_Tabs._jQueryInterface.call($(this), 'show');
386  });
387  /**
388   * ------------------------------------------------------------------------
389   * jQuery
390   * ------------------------------------------------------------------------
391   */
392
393  $.fn[NAME] = SP_WP_Tabs._jQueryInterface;
394  $.fn[NAME].Constructor = SP_WP_Tabs;
395
396  $.fn[NAME].noConflict = function () {
397    $.fn[NAME] = JQUERY_NO_CONFLICT;
398    return SP_WP_Tabs._jQueryInterface;
399  };
400
401  return SP_WP_Tabs;
402
403}));

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.