Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap-rubygem.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'assets/javascripts/bootstrap/tab.js')
-rw-r--r--assets/javascripts/bootstrap/tab.js357
1 files changed, 231 insertions, 126 deletions
diff --git a/assets/javascripts/bootstrap/tab.js b/assets/javascripts/bootstrap/tab.js
index 8d5361f..8b175ea 100644
--- a/assets/javascripts/bootstrap/tab.js
+++ b/assets/javascripts/bootstrap/tab.js
@@ -1,155 +1,260 @@
-/* ========================================================================
- * Bootstrap: tab.js v3.3.5
- * http://getbootstrap.com/javascript/#tabs
- * ========================================================================
- * Copyright 2011-2015 Twitter, Inc.
+'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; }; })();
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
+
+/**
+ * --------------------------------------------------------------------------
+ * Bootstrap (v4.0.0): tab.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
- * ======================================================================== */
+ * --------------------------------------------------------------------------
+ */
+
+var Tab = (function ($) {
+
+ /**
+ * ------------------------------------------------------------------------
+ * Constants
+ * ------------------------------------------------------------------------
+ */
+
+ var NAME = 'tab';
+ var VERSION = '4.0.0';
+ var DATA_KEY = 'bs.tab';
+ var EVENT_KEY = '.' + DATA_KEY;
+ var DATA_API_KEY = '.data-api';
+ var JQUERY_NO_CONFLICT = $.fn[NAME];
+ var TRANSITION_DURATION = 150;
+
+ var Event = {
+ HIDE: 'hide' + EVENT_KEY,
+ HIDDEN: 'hidden' + EVENT_KEY,
+ SHOW: 'show' + EVENT_KEY,
+ SHOWN: 'shown' + EVENT_KEY,
+ CLICK_DATA_API: 'click' + EVENT_KEY + DATA_API_KEY
+ };
+
+ var ClassName = {
+ DROPDOWN_MENU: 'dropdown-menu',
+ ACTIVE: 'active',
+ FADE: 'fade',
+ IN: 'in'
+ };
+
+ var Selector = {
+ A: 'a',
+ LI: 'li',
+ DROPDOWN: '.dropdown',
+ UL: 'ul:not(.dropdown-menu)',
+ FADE_CHILD: '> .nav-item .fade, > .fade',
+ ACTIVE: '.active',
+ ACTIVE_CHILD: '> .nav-item > .active, > .active',
+ DATA_TOGGLE: '[data-toggle="tab"], [data-toggle="pill"]',
+ DROPDOWN_TOGGLE: '.dropdown-toggle',
+ DROPDOWN_ACTIVE_CHILD: '> .dropdown-menu .active'
+ };
+
+ /**
+ * ------------------------------------------------------------------------
+ * Class Definition
+ * ------------------------------------------------------------------------
+ */
+
+ var Tab = (function () {
+ function Tab(element) {
+ _classCallCheck(this, Tab);
+
+ this._element = element;
+ }
+ /**
+ * ------------------------------------------------------------------------
+ * Data Api implementation
+ * ------------------------------------------------------------------------
+ */
-+function ($) {
- 'use strict';
+ // getters
- // TAB CLASS DEFINITION
- // ====================
+ _createClass(Tab, [{
+ key: 'show',
- var Tab = function (element) {
- // jscs:disable requireDollarBeforejQueryAssignment
- this.element = $(element)
- // jscs:enable requireDollarBeforejQueryAssignment
- }
+ // public
- Tab.VERSION = '3.3.5'
+ value: function show() {
+ var _this = this;
- Tab.TRANSITION_DURATION = 150
+ if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && $(this._element).hasClass(ClassName.ACTIVE)) {
+ return;
+ }
- Tab.prototype.show = function () {
- var $this = this.element
- var $ul = $this.closest('ul:not(.dropdown-menu)')
- var selector = $this.data('target')
+ var target = undefined;
+ var previous = undefined;
+ var ulElement = $(this._element).closest(Selector.UL)[0];
+ var selector = Util.getSelectorFromElement(this._element);
- if (!selector) {
- selector = $this.attr('href')
- selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
- }
+ if (ulElement) {
+ previous = $.makeArray($(ulElement).find(Selector.ACTIVE));
+ previous = previous[previous.length - 1];
+ }
- if ($this.parent('li').hasClass('active')) return
-
- var $previous = $ul.find('.active:last a')
- var hideEvent = $.Event('hide.bs.tab', {
- relatedTarget: $this[0]
- })
- var showEvent = $.Event('show.bs.tab', {
- relatedTarget: $previous[0]
- })
-
- $previous.trigger(hideEvent)
- $this.trigger(showEvent)
-
- if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) return
-
- var $target = $(selector)
-
- this.activate($this.closest('li'), $ul)
- this.activate($target, $target.parent(), function () {
- $previous.trigger({
- type: 'hidden.bs.tab',
- relatedTarget: $this[0]
- })
- $this.trigger({
- type: 'shown.bs.tab',
- relatedTarget: $previous[0]
- })
- })
- }
-
- Tab.prototype.activate = function (element, container, callback) {
- var $active = container.find('> .active')
- var transition = callback
- && $.support.transition
- && ($active.length && $active.hasClass('fade') || !!container.find('> .fade').length)
-
- function next() {
- $active
- .removeClass('active')
- .find('> .dropdown-menu > .active')
- .removeClass('active')
- .end()
- .find('[data-toggle="tab"]')
- .attr('aria-expanded', false)
-
- element
- .addClass('active')
- .find('[data-toggle="tab"]')
- .attr('aria-expanded', true)
-
- if (transition) {
- element[0].offsetWidth // reflow for transition
- element.addClass('in')
- } else {
- element.removeClass('fade')
- }
+ var hideEvent = $.Event(Event.HIDE, {
+ relatedTarget: this._element
+ });
+
+ var showEvent = $.Event(Event.SHOW, {
+ relatedTarget: previous
+ });
+
+ if (previous) {
+ $(previous).trigger(hideEvent);
+ }
+
+ $(this._element).trigger(showEvent);
+
+ if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) {
+ return;
+ }
+
+ if (selector) {
+ target = $(selector)[0];
+ }
- if (element.parent('.dropdown-menu').length) {
- element
- .closest('li.dropdown')
- .addClass('active')
- .end()
- .find('[data-toggle="tab"]')
- .attr('aria-expanded', true)
+ this._activate(this._element, ulElement);
+
+ var complete = function complete() {
+ var hiddenEvent = $.Event(Event.HIDDEN, {
+ relatedTarget: _this._element
+ });
+
+ var shownEvent = $.Event(Event.SHOWN, {
+ relatedTarget: previous
+ });
+
+ $(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;
}
- callback && callback()
- }
+ // private
- $active.length && transition ?
- $active
- .one('bsTransitionEnd', next)
- .emulateTransitionEnd(Tab.TRANSITION_DURATION) :
- next()
+ }, {
+ 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]));
- $active.removeClass('in')
- }
+ var complete = $.proxy(this._transitionComplete, this, element, active, isTransitioning, callback);
+ if (active && isTransitioning) {
+ $(active).one(Util.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION);
+ } else {
+ complete();
+ }
- // TAB PLUGIN DEFINITION
- // =====================
+ if (active) {
+ $(active).removeClass(ClassName.IN);
+ }
+ }
+ }, {
+ key: '_transitionComplete',
+ value: function _transitionComplete(element, active, isTransitioning, callback) {
+ if (active) {
+ $(active).removeClass(ClassName.ACTIVE);
+
+ var dropdownChild = $(active).find(Selector.DROPDOWN_ACTIVE_CHILD)[0];
- function Plugin(option) {
- return this.each(function () {
- var $this = $(this)
- var data = $this.data('bs.tab')
+ if (dropdownChild) {
+ $(dropdownChild).removeClass(ClassName.ACTIVE);
+ }
- if (!data) $this.data('bs.tab', (data = new Tab(this)))
- if (typeof option == 'string') data[option]()
- })
- }
+ active.setAttribute('aria-expanded', false);
+ }
- var old = $.fn.tab
+ $(element).addClass(ClassName.ACTIVE);
+ element.setAttribute('aria-expanded', true);
- $.fn.tab = Plugin
- $.fn.tab.Constructor = Tab
+ if (isTransitioning) {
+ Util.reflow(element);
+ $(element).addClass(ClassName.IN);
+ } else {
+ $(element).removeClass(ClassName.FADE);
+ }
+ if (element.parentNode && $(element.parentNode).hasClass(ClassName.DROPDOWN_MENU)) {
- // TAB NO CONFLICT
- // ===============
+ var dropdownElement = $(element).closest(Selector.DROPDOWN)[0];
+ if (dropdownElement) {
+ $(dropdownElement).find(Selector.DROPDOWN_TOGGLE).addClass(ClassName.ACTIVE);
+ }
- $.fn.tab.noConflict = function () {
- $.fn.tab = old
- return this
- }
+ element.setAttribute('aria-expanded', true);
+ }
+ if (callback) {
+ callback();
+ }
+ }
- // TAB DATA-API
- // ============
+ // static
- var clickHandler = function (e) {
- e.preventDefault()
- Plugin.call($(this), 'show')
- }
+ }], [{
+ key: '_jQueryInterface',
+ value: function _jQueryInterface(config) {
+ return this.each(function () {
+ var $this = $(this);
+ var data = $this.data(DATA_KEY);
- $(document)
- .on('click.bs.tab.data-api', '[data-toggle="tab"]', clickHandler)
- .on('click.bs.tab.data-api', '[data-toggle="pill"]', clickHandler)
+ if (!data) {
+ data = data = new Tab(this);
+ $this.data(DATA_KEY, data);
+ }
-}(jQuery);
+ if (typeof config === 'string') {
+ data[config]();
+ }
+ });
+ }
+ }, {
+ key: 'VERSION',
+ get: function get() {
+ return VERSION;
+ }
+ }]);
+
+ return Tab;
+ })();
+
+ $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) {
+ event.preventDefault();
+ Tab._jQueryInterface.call($(this), 'show');
+ });
+
+ /**
+ * ------------------------------------------------------------------------
+ * jQuery
+ * ------------------------------------------------------------------------
+ */
+
+ $.fn[NAME] = Tab._jQueryInterface;
+ $.fn[NAME].Constructor = Tab;
+ $.fn[NAME].noConflict = function () {
+ $.fn[NAME] = JQUERY_NO_CONFLICT;
+ return Tab._jQueryInterface;
+ };
+
+ return Tab;
+})(jQuery);
+//# sourceMappingURL=tab.js.map