diff options
Diffstat (limited to 'js/dist/tab.js')
-rw-r--r-- | js/dist/tab.js | 250 |
1 files changed, 120 insertions, 130 deletions
diff --git a/js/dist/tab.js b/js/dist/tab.js index e2e6116c1e..6bbafb58b4 100644 --- a/js/dist/tab.js +++ b/js/dist/tab.js @@ -1,8 +1,6 @@ -'use strict'; +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * -------------------------------------------------------------------------- @@ -11,7 +9,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons * -------------------------------------------------------------------------- */ -var Tab = (function ($) { +var Tab = function ($) { /** * ------------------------------------------------------------------------ @@ -61,176 +59,162 @@ var Tab = (function ($) { * ------------------------------------------------------------------------ */ - var Tab = (function () { + var Tab = function () { function Tab(element) { _classCallCheck(this, Tab); this._element = element; } - /** - * ------------------------------------------------------------------------ - * Data Api implementation - * ------------------------------------------------------------------------ - */ - // getters - _createClass(Tab, [{ - key: 'show', - - // public + // public - value: function show() { - var _this = this; + Tab.prototype.show = function show() { + var _this = this; - if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && $(this._element).hasClass(ClassName.ACTIVE)) { - return; - } + if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && $(this._element).hasClass(ClassName.ACTIVE)) { + return; + } - var target = undefined; - var previous = undefined; - var ulElement = $(this._element).closest(Selector.UL)[0]; - var selector = Util.getSelectorFromElement(this._element); + var target = void 0; + var previous = void 0; + var ulElement = $(this._element).closest(Selector.UL)[0]; + var selector = Util.getSelectorFromElement(this._element); - if (ulElement) { - previous = $.makeArray($(ulElement).find(Selector.ACTIVE)); - previous = previous[previous.length - 1]; - } + if (ulElement) { + previous = $.makeArray($(ulElement).find(Selector.ACTIVE)); + previous = previous[previous.length - 1]; + } - var hideEvent = $.Event(Event.HIDE, { - relatedTarget: this._element - }); + var hideEvent = $.Event(Event.HIDE, { + relatedTarget: this._element + }); - var showEvent = $.Event(Event.SHOW, { - relatedTarget: previous - }); + var showEvent = $.Event(Event.SHOW, { + relatedTarget: previous + }); - if (previous) { - $(previous).trigger(hideEvent); - } + if (previous) { + $(previous).trigger(hideEvent); + } - $(this._element).trigger(showEvent); + $(this._element).trigger(showEvent); - if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) { - return; - } + if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) { + return; + } - if (selector) { - target = $(selector)[0]; - } + if (selector) { + target = $(selector)[0]; + } - this._activate(this._element, ulElement); + this._activate(this._element, ulElement); - var complete = function complete() { - var hiddenEvent = $.Event(Event.HIDDEN, { - relatedTarget: _this._element - }); + var complete = function complete() { + var hiddenEvent = $.Event(Event.HIDDEN, { + relatedTarget: _this._element + }); - var shownEvent = $.Event(Event.SHOWN, { - relatedTarget: previous - }); + var shownEvent = $.Event(Event.SHOWN, { + relatedTarget: previous + }); - $(previous).trigger(hiddenEvent); - $(_this._element).trigger(shownEvent); - }; + $(previous).trigger(hiddenEvent); + $(_this._element).trigger(shownEvent); + }; - if (target) { - this._activate(target, target.parentNode, complete); - } else { - complete(); - } - } - }, { - key: 'dispose', - value: function dispose() { - $.removeClass(this._element, DATA_KEY); - this._element = null; + if (target) { + this._activate(target, target.parentNode, complete); + } else { + complete(); } + }; - // private + Tab.prototype.dispose = function dispose() { + $.removeClass(this._element, DATA_KEY); + this._element = null; + }; - }, { - key: '_activate', - value: function _activate(element, container, callback) { - var active = $(container).find(Selector.ACTIVE_CHILD)[0]; - var isTransitioning = callback && Util.supportsTransitionEnd() && (active && $(active).hasClass(ClassName.FADE) || Boolean($(container).find(Selector.FADE_CHILD)[0])); + // private - var complete = $.proxy(this._transitionComplete, this, element, active, isTransitioning, callback); + Tab.prototype._activate = function _activate(element, container, callback) { + var active = $(container).find(Selector.ACTIVE_CHILD)[0]; + var isTransitioning = callback && Util.supportsTransitionEnd() && (active && $(active).hasClass(ClassName.FADE) || Boolean($(container).find(Selector.FADE_CHILD)[0])); - if (active && isTransitioning) { - $(active).one(Util.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION); - } else { - complete(); - } + var complete = $.proxy(this._transitionComplete, this, element, active, isTransitioning, callback); - if (active) { - $(active).removeClass(ClassName.IN); - } + if (active && isTransitioning) { + $(active).one(Util.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION); + } else { + complete(); } - }, { - key: '_transitionComplete', - value: function _transitionComplete(element, active, isTransitioning, callback) { - if (active) { - $(active).removeClass(ClassName.ACTIVE); - var dropdownChild = $(active).find(Selector.DROPDOWN_ACTIVE_CHILD)[0]; + if (active) { + $(active).removeClass(ClassName.IN); + } + }; - if (dropdownChild) { - $(dropdownChild).removeClass(ClassName.ACTIVE); - } + Tab.prototype._transitionComplete = function _transitionComplete(element, active, isTransitioning, callback) { + if (active) { + $(active).removeClass(ClassName.ACTIVE); + + var dropdownChild = $(active).find(Selector.DROPDOWN_ACTIVE_CHILD)[0]; - active.setAttribute('aria-expanded', false); + if (dropdownChild) { + $(dropdownChild).removeClass(ClassName.ACTIVE); } - $(element).addClass(ClassName.ACTIVE); - element.setAttribute('aria-expanded', true); + active.setAttribute('aria-expanded', false); + } - if (isTransitioning) { - Util.reflow(element); - $(element).addClass(ClassName.IN); - } else { - $(element).removeClass(ClassName.FADE); - } + $(element).addClass(ClassName.ACTIVE); + element.setAttribute('aria-expanded', true); - if (element.parentNode && $(element.parentNode).hasClass(ClassName.DROPDOWN_MENU)) { + if (isTransitioning) { + Util.reflow(element); + $(element).addClass(ClassName.IN); + } else { + $(element).removeClass(ClassName.FADE); + } - var dropdownElement = $(element).closest(Selector.DROPDOWN)[0]; - if (dropdownElement) { - $(dropdownElement).find(Selector.DROPDOWN_TOGGLE).addClass(ClassName.ACTIVE); - } + if (element.parentNode && $(element.parentNode).hasClass(ClassName.DROPDOWN_MENU)) { - element.setAttribute('aria-expanded', true); + var dropdownElement = $(element).closest(Selector.DROPDOWN)[0]; + if (dropdownElement) { + $(dropdownElement).find(Selector.DROPDOWN_TOGGLE).addClass(ClassName.ACTIVE); } - if (callback) { - callback(); - } + element.setAttribute('aria-expanded', true); } - // static + if (callback) { + callback(); + } + }; - }], [{ - key: '_jQueryInterface', - value: function _jQueryInterface(config) { - return this.each(function () { - var $this = $(this); - var data = $this.data(DATA_KEY); + // static - if (!data) { - data = data = new Tab(this); - $this.data(DATA_KEY, data); - } + Tab._jQueryInterface = function _jQueryInterface(config) { + return this.each(function () { + var $this = $(this); + var data = $this.data(DATA_KEY); - if (typeof config === 'string') { - if (data[config] === undefined) { - throw new Error('No method named "' + config + '"'); - } - data[config](); + if (!data) { + data = data = new Tab(this); + $this.data(DATA_KEY, data); + } + + if (typeof config === 'string') { + if (data[config] === undefined) { + throw new Error('No method named "' + config + '"'); } - }); - } - }, { + data[config](); + } + }); + }; + + _createClass(Tab, null, [{ key: 'VERSION', get: function get() { return VERSION; @@ -238,7 +222,13 @@ var Tab = (function ($) { }]); return Tab; - })(); + }(); + + /** + * ------------------------------------------------------------------------ + * Data Api implementation + * ------------------------------------------------------------------------ + */ $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { event.preventDefault(); @@ -259,5 +249,5 @@ var Tab = (function ($) { }; return Tab; -})(jQuery); +}(jQuery); //# sourceMappingURL=tab.js.map |