diff options
author | Gleb Mazovetskiy <glex.spb@gmail.com> | 2016-10-22 09:20:53 +0300 |
---|---|---|
committer | Gleb Mazovetskiy <glex.spb@gmail.com> | 2016-10-22 09:20:53 +0300 |
commit | afd171105704c314bf699810875c72a612988a72 (patch) | |
tree | c6045a971c84ef6eadfe7d5b90044bd33f2b7cbe /assets/javascripts/bootstrap/collapse.js | |
parent | d527714693edb72688eb8c239228b2db66e56ded (diff) |
rake update[v4.0.0-alpha.5]
Diffstat (limited to 'assets/javascripts/bootstrap/collapse.js')
-rw-r--r-- | assets/javascripts/bootstrap/collapse.js | 366 |
1 files changed, 176 insertions, 190 deletions
diff --git a/assets/javascripts/bootstrap/collapse.js b/assets/javascripts/bootstrap/collapse.js index 60b953a..cd3caa7 100644 --- a/assets/javascripts/bootstrap/collapse.js +++ b/assets/javascripts/bootstrap/collapse.js @@ -1,17 +1,17 @@ -'use strict'; +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; -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"); } } /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.4): collapse.js + * Bootstrap (v4.0.0-alpha.5): collapse.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ -var Collapse = (function ($) { +var Collapse = function ($) { /** * ------------------------------------------------------------------------ @@ -20,7 +20,7 @@ var Collapse = (function ($) { */ var NAME = 'collapse'; - var VERSION = '4.0.0-alpha.4'; + var VERSION = '4.0.0-alpha.5'; var DATA_KEY = 'bs.collapse'; var EVENT_KEY = '.' + DATA_KEY; var DATA_API_KEY = '.data-api'; @@ -58,7 +58,7 @@ var Collapse = (function ($) { }; var Selector = { - ACTIVES: '.panel > .in, .panel > .collapsing', + ACTIVES: '.card > .in, .card > .collapsing', DATA_TOGGLE: '[data-toggle="collapse"]' }; @@ -68,7 +68,7 @@ var Collapse = (function ($) { * ------------------------------------------------------------------------ */ - var Collapse = (function () { + var Collapse = function () { function Collapse(element, config) { _classCallCheck(this, Collapse); @@ -88,240 +88,220 @@ var Collapse = (function ($) { } } - /** - * ------------------------------------------------------------------------ - * Data Api implementation - * ------------------------------------------------------------------------ - */ - // getters - _createClass(Collapse, [{ - key: 'toggle', + // public + + Collapse.prototype.toggle = function toggle() { + if ($(this._element).hasClass(ClassName.IN)) { + this.hide(); + } else { + this.show(); + } + }; - // public + Collapse.prototype.show = function show() { + var _this = this; + + if (this._isTransitioning || $(this._element).hasClass(ClassName.IN)) { + return; + } - value: function toggle() { - if ($(this._element).hasClass(ClassName.IN)) { - this.hide(); - } else { - this.show(); + var actives = void 0; + var activesData = void 0; + + if (this._parent) { + actives = $.makeArray($(Selector.ACTIVES)); + if (!actives.length) { + actives = null; } } - }, { - key: 'show', - value: function show() { - var _this = this; - if (this._isTransitioning || $(this._element).hasClass(ClassName.IN)) { + if (actives) { + activesData = $(actives).data(DATA_KEY); + if (activesData && activesData._isTransitioning) { return; } + } - var actives = undefined; - var activesData = undefined; + var startEvent = $.Event(Event.SHOW); + $(this._element).trigger(startEvent); + if (startEvent.isDefaultPrevented()) { + return; + } - if (this._parent) { - actives = $.makeArray($(Selector.ACTIVES)); - if (!actives.length) { - actives = null; - } + if (actives) { + Collapse._jQueryInterface.call($(actives), 'hide'); + if (!activesData) { + $(actives).data(DATA_KEY, null); } + } - if (actives) { - activesData = $(actives).data(DATA_KEY); - if (activesData && activesData._isTransitioning) { - return; - } - } + var dimension = this._getDimension(); - var startEvent = $.Event(Event.SHOW); - $(this._element).trigger(startEvent); - if (startEvent.isDefaultPrevented()) { - return; - } + $(this._element).removeClass(ClassName.COLLAPSE).addClass(ClassName.COLLAPSING); - if (actives) { - Collapse._jQueryInterface.call($(actives), 'hide'); - if (!activesData) { - $(actives).data(DATA_KEY, null); - } - } + this._element.style[dimension] = 0; + this._element.setAttribute('aria-expanded', true); - var dimension = this._getDimension(); + if (this._triggerArray.length) { + $(this._triggerArray).removeClass(ClassName.COLLAPSED).attr('aria-expanded', true); + } - $(this._element).removeClass(ClassName.COLLAPSE).addClass(ClassName.COLLAPSING); + this.setTransitioning(true); - this._element.style[dimension] = 0; - this._element.setAttribute('aria-expanded', true); + var complete = function complete() { + $(_this._element).removeClass(ClassName.COLLAPSING).addClass(ClassName.COLLAPSE).addClass(ClassName.IN); - if (this._triggerArray.length) { - $(this._triggerArray).removeClass(ClassName.COLLAPSED).attr('aria-expanded', true); - } + _this._element.style[dimension] = ''; - this.setTransitioning(true); + _this.setTransitioning(false); - var complete = function complete() { - $(_this._element).removeClass(ClassName.COLLAPSING).addClass(ClassName.COLLAPSE).addClass(ClassName.IN); + $(_this._element).trigger(Event.SHOWN); + }; - _this._element.style[dimension] = ''; + if (!Util.supportsTransitionEnd()) { + complete(); + return; + } - _this.setTransitioning(false); + var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1); + var scrollSize = 'scroll' + capitalizedDimension; - $(_this._element).trigger(Event.SHOWN); - }; + $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION); - if (!Util.supportsTransitionEnd()) { - complete(); - return; - } + this._element.style[dimension] = this._element[scrollSize] + 'px'; + }; - var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1); - var scrollSize = 'scroll' + capitalizedDimension; + Collapse.prototype.hide = function hide() { + var _this2 = this; - $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION); + if (this._isTransitioning || !$(this._element).hasClass(ClassName.IN)) { + return; + } - this._element.style[dimension] = this._element[scrollSize] + 'px'; + var startEvent = $.Event(Event.HIDE); + $(this._element).trigger(startEvent); + if (startEvent.isDefaultPrevented()) { + return; } - }, { - key: 'hide', - value: function hide() { - var _this2 = this; - if (this._isTransitioning || !$(this._element).hasClass(ClassName.IN)) { - return; - } + var dimension = this._getDimension(); + var offsetDimension = dimension === Dimension.WIDTH ? 'offsetWidth' : 'offsetHeight'; - var startEvent = $.Event(Event.HIDE); - $(this._element).trigger(startEvent); - if (startEvent.isDefaultPrevented()) { - return; - } + this._element.style[dimension] = this._element[offsetDimension] + 'px'; - var dimension = this._getDimension(); - var offsetDimension = dimension === Dimension.WIDTH ? 'offsetWidth' : 'offsetHeight'; + Util.reflow(this._element); - this._element.style[dimension] = this._element[offsetDimension] + 'px'; + $(this._element).addClass(ClassName.COLLAPSING).removeClass(ClassName.COLLAPSE).removeClass(ClassName.IN); - Util.reflow(this._element); + this._element.setAttribute('aria-expanded', false); - $(this._element).addClass(ClassName.COLLAPSING).removeClass(ClassName.COLLAPSE).removeClass(ClassName.IN); + if (this._triggerArray.length) { + $(this._triggerArray).addClass(ClassName.COLLAPSED).attr('aria-expanded', false); + } - this._element.setAttribute('aria-expanded', false); + this.setTransitioning(true); - if (this._triggerArray.length) { - $(this._triggerArray).addClass(ClassName.COLLAPSED).attr('aria-expanded', false); - } + var complete = function complete() { + _this2.setTransitioning(false); + $(_this2._element).removeClass(ClassName.COLLAPSING).addClass(ClassName.COLLAPSE).trigger(Event.HIDDEN); + }; - this.setTransitioning(true); + this._element.style[dimension] = ''; - var complete = function complete() { - _this2.setTransitioning(false); - $(_this2._element).removeClass(ClassName.COLLAPSING).addClass(ClassName.COLLAPSE).trigger(Event.HIDDEN); - }; + if (!Util.supportsTransitionEnd()) { + complete(); + return; + } - this._element.style[dimension] = 0; + $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION); + }; - if (!Util.supportsTransitionEnd()) { - complete(); - return; - } + Collapse.prototype.setTransitioning = function setTransitioning(isTransitioning) { + this._isTransitioning = isTransitioning; + }; - $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION); - } - }, { - key: 'setTransitioning', - value: function setTransitioning(isTransitioning) { - this._isTransitioning = isTransitioning; - } - }, { - key: 'dispose', - value: function dispose() { - $.removeData(this._element, DATA_KEY); - - this._config = null; - this._parent = null; - this._element = null; - this._triggerArray = null; - this._isTransitioning = null; - } + Collapse.prototype.dispose = function dispose() { + $.removeData(this._element, DATA_KEY); - // private + this._config = null; + this._parent = null; + this._element = null; + this._triggerArray = null; + this._isTransitioning = null; + }; - }, { - key: '_getConfig', - value: function _getConfig(config) { - config = $.extend({}, Default, config); - config.toggle = Boolean(config.toggle); // coerce string values - Util.typeCheckConfig(NAME, config, DefaultType); - return config; - } - }, { - key: '_getDimension', - value: function _getDimension() { - var hasWidth = $(this._element).hasClass(Dimension.WIDTH); - return hasWidth ? Dimension.WIDTH : Dimension.HEIGHT; - } - }, { - key: '_getParent', - value: function _getParent() { - var _this3 = this; + // private - var parent = $(this._config.parent)[0]; - var selector = '[data-toggle="collapse"][data-parent="' + this._config.parent + '"]'; + Collapse.prototype._getConfig = function _getConfig(config) { + config = $.extend({}, Default, config); + config.toggle = Boolean(config.toggle); // coerce string values + Util.typeCheckConfig(NAME, config, DefaultType); + return config; + }; - $(parent).find(selector).each(function (i, element) { - _this3._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]); - }); + Collapse.prototype._getDimension = function _getDimension() { + var hasWidth = $(this._element).hasClass(Dimension.WIDTH); + return hasWidth ? Dimension.WIDTH : Dimension.HEIGHT; + }; - return parent; - } - }, { - key: '_addAriaAndCollapsedClass', - value: function _addAriaAndCollapsedClass(element, triggerArray) { - if (element) { - var isOpen = $(element).hasClass(ClassName.IN); - element.setAttribute('aria-expanded', isOpen); - - if (triggerArray.length) { - $(triggerArray).toggleClass(ClassName.COLLAPSED, !isOpen).attr('aria-expanded', isOpen); - } + Collapse.prototype._getParent = function _getParent() { + var _this3 = this; + + var parent = $(this._config.parent)[0]; + var selector = '[data-toggle="collapse"][data-parent="' + this._config.parent + '"]'; + + $(parent).find(selector).each(function (i, element) { + _this3._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]); + }); + + return parent; + }; + + Collapse.prototype._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) { + if (element) { + var isOpen = $(element).hasClass(ClassName.IN); + element.setAttribute('aria-expanded', isOpen); + + if (triggerArray.length) { + $(triggerArray).toggleClass(ClassName.COLLAPSED, !isOpen).attr('aria-expanded', isOpen); } } + }; - // static + // static - }], [{ - key: '_getTargetFromElement', - value: function _getTargetFromElement(element) { - var selector = Util.getSelectorFromElement(element); - return selector ? $(selector)[0] : null; - } - }, { - key: '_jQueryInterface', - value: function _jQueryInterface(config) { - return this.each(function () { - var $this = $(this); - var data = $this.data(DATA_KEY); - var _config = $.extend({}, Default, $this.data(), typeof config === 'object' && config); - - if (!data && _config.toggle && /show|hide/.test(config)) { - _config.toggle = false; - } + Collapse._getTargetFromElement = function _getTargetFromElement(element) { + var selector = Util.getSelectorFromElement(element); + return selector ? $(selector)[0] : null; + }; - if (!data) { - data = new Collapse(this, _config); - $this.data(DATA_KEY, data); - } + Collapse._jQueryInterface = function _jQueryInterface(config) { + return this.each(function () { + var $this = $(this); + var data = $this.data(DATA_KEY); + var _config = $.extend({}, Default, $this.data(), (typeof config === 'undefined' ? 'undefined' : _typeof(config)) === 'object' && config); - if (typeof config === 'string') { - if (data[config] === undefined) { - throw new Error('No method named "' + config + '"'); - } - data[config](); + if (!data && _config.toggle && /show|hide/.test(config)) { + _config.toggle = false; + } + + if (!data) { + data = new Collapse(this, _config); + $this.data(DATA_KEY, data); + } + + if (typeof config === 'string') { + if (data[config] === undefined) { + throw new Error('No method named "' + config + '"'); } - }); - } - }, { + data[config](); + } + }); + }; + + _createClass(Collapse, null, [{ key: 'VERSION', get: function get() { return VERSION; @@ -334,7 +314,13 @@ var Collapse = (function ($) { }]); return Collapse; - })(); + }(); + + /** + * ------------------------------------------------------------------------ + * Data Api implementation + * ------------------------------------------------------------------------ + */ $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { event.preventDefault(); @@ -360,4 +346,4 @@ var Collapse = (function ($) { }; return Collapse; -})(jQuery); +}(jQuery); |