mirror of
https://github.com/tenrok/bootstrap.git
synced 2026-06-08 17:22:31 +03:00
Merge branch 'v4-dev' into carousel
This commit is contained in:
+1
-1
@@ -90,7 +90,7 @@ const Button = (($) => {
|
||||
|
||||
if (triggerChangeEvent) {
|
||||
input.checked = !$(this._element).hasClass(ClassName.ACTIVE)
|
||||
$(this._element).trigger('change')
|
||||
$(input).trigger('change')
|
||||
}
|
||||
|
||||
input.focus()
|
||||
|
||||
+10
-14
@@ -120,9 +120,10 @@ const Carousel = (($) => {
|
||||
// public
|
||||
|
||||
next() {
|
||||
if (!this._isSliding) {
|
||||
this._slide(Direction.NEXT)
|
||||
if (this._isSliding) {
|
||||
throw new Error('Carousel is sliding')
|
||||
}
|
||||
this._slide(Direction.NEXT)
|
||||
}
|
||||
|
||||
nextWhenVisible() {
|
||||
@@ -133,9 +134,10 @@ const Carousel = (($) => {
|
||||
}
|
||||
|
||||
prev() {
|
||||
if (!this._isSliding) {
|
||||
this._slide(Direction.PREVIOUS)
|
||||
if (this._isSliding) {
|
||||
throw new Error('Carousel is sliding')
|
||||
}
|
||||
this._slide(Direction.PREVIOUS)
|
||||
}
|
||||
|
||||
pause(event) {
|
||||
@@ -236,11 +238,10 @@ const Carousel = (($) => {
|
||||
}
|
||||
|
||||
_keydown(event) {
|
||||
event.preventDefault()
|
||||
|
||||
if (/input|textarea/i.test(event.target.tagName)) {
|
||||
return
|
||||
}
|
||||
event.preventDefault()
|
||||
|
||||
switch (event.which) {
|
||||
case ARROW_LEFT_KEYCODE:
|
||||
@@ -372,15 +373,10 @@ const Carousel = (($) => {
|
||||
$(activeElement)
|
||||
.one(Util.TRANSITION_END, () => {
|
||||
$(nextElement)
|
||||
.removeClass(directionalClassName)
|
||||
.removeClass(orderClassName)
|
||||
.removeClass(`${directionalClassName} ${orderClassName}`)
|
||||
.addClass(ClassName.ACTIVE)
|
||||
|
||||
$(nextElement).addClass(ClassName.ACTIVE)
|
||||
|
||||
$(activeElement)
|
||||
.removeClass(ClassName.ACTIVE)
|
||||
.removeClass(orderClassName)
|
||||
.removeClass(directionalClassName)
|
||||
$(activeElement).removeClass(`${ClassName.ACTIVE} ${orderClassName} ${directionalClassName}`)
|
||||
|
||||
this._isSliding = false
|
||||
|
||||
|
||||
+10
-4
@@ -112,8 +112,11 @@ const Collapse = (($) => {
|
||||
}
|
||||
|
||||
show() {
|
||||
if (this._isTransitioning ||
|
||||
$(this._element).hasClass(ClassName.ACTIVE)) {
|
||||
if (this._isTransitioning) {
|
||||
throw new Error('Collapse is transitioning')
|
||||
}
|
||||
|
||||
if ($(this._element).hasClass(ClassName.ACTIVE)) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -193,8 +196,11 @@ const Collapse = (($) => {
|
||||
}
|
||||
|
||||
hide() {
|
||||
if (this._isTransitioning ||
|
||||
!$(this._element).hasClass(ClassName.ACTIVE)) {
|
||||
if (this._isTransitioning) {
|
||||
throw new Error('Collapse is transitioning')
|
||||
}
|
||||
|
||||
if (!$(this._element).hasClass(ClassName.ACTIVE)) {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
+1
-5
@@ -239,11 +239,7 @@ const Dropdown = (($) => {
|
||||
return
|
||||
}
|
||||
|
||||
let items = $.makeArray($(Selector.VISIBLE_ITEMS))
|
||||
|
||||
items = items.filter((item) => {
|
||||
return item.offsetWidth || item.offsetHeight
|
||||
})
|
||||
const items = $(parent).find(Selector.VISIBLE_ITEMS).get()
|
||||
|
||||
if (!items.length) {
|
||||
return
|
||||
|
||||
+25
-10
@@ -87,6 +87,7 @@ const Modal = (($) => {
|
||||
this._isShown = false
|
||||
this._isBodyOverflowing = false
|
||||
this._ignoreBackdropClick = false
|
||||
this._isTransitioning = false
|
||||
this._originalBodyPadding = 0
|
||||
this._scrollbarWidth = 0
|
||||
}
|
||||
@@ -110,6 +111,14 @@ const Modal = (($) => {
|
||||
}
|
||||
|
||||
show(relatedTarget) {
|
||||
if (this._isTransitioning) {
|
||||
throw new Error('Modal is transitioning')
|
||||
}
|
||||
|
||||
if (Util.supportsTransitionEnd() &&
|
||||
$(this._element).hasClass(ClassName.FADE)) {
|
||||
this._isTransitioning = true
|
||||
}
|
||||
const showEvent = $.Event(Event.SHOW, {
|
||||
relatedTarget
|
||||
})
|
||||
@@ -152,8 +161,17 @@ const Modal = (($) => {
|
||||
event.preventDefault()
|
||||
}
|
||||
|
||||
const hideEvent = $.Event(Event.HIDE)
|
||||
if (this._isTransitioning) {
|
||||
throw new Error('Modal is transitioning')
|
||||
}
|
||||
|
||||
const transition = Util.supportsTransitionEnd() &&
|
||||
$(this._element).hasClass(ClassName.FADE)
|
||||
if (transition) {
|
||||
this._isTransitioning = true
|
||||
}
|
||||
|
||||
const hideEvent = $.Event(Event.HIDE)
|
||||
$(this._element).trigger(hideEvent)
|
||||
|
||||
if (!this._isShown || hideEvent.isDefaultPrevented()) {
|
||||
@@ -172,9 +190,7 @@ const Modal = (($) => {
|
||||
$(this._element).off(Event.CLICK_DISMISS)
|
||||
$(this._dialog).off(Event.MOUSEDOWN_DISMISS)
|
||||
|
||||
if (Util.supportsTransitionEnd() &&
|
||||
$(this._element).hasClass(ClassName.FADE)) {
|
||||
|
||||
if (transition) {
|
||||
$(this._element)
|
||||
.one(Util.TRANSITION_END, (event) => this._hideModal(event))
|
||||
.emulateTransitionEnd(TRANSITION_DURATION)
|
||||
@@ -186,10 +202,7 @@ const Modal = (($) => {
|
||||
dispose() {
|
||||
$.removeData(this._element, DATA_KEY)
|
||||
|
||||
$(window).off(EVENT_KEY)
|
||||
$(document).off(EVENT_KEY)
|
||||
$(this._element).off(EVENT_KEY)
|
||||
$(this._backdrop).off(EVENT_KEY)
|
||||
$(window, document, this._element, this._backdrop).off(EVENT_KEY)
|
||||
|
||||
this._config = null
|
||||
this._element = null
|
||||
@@ -243,6 +256,7 @@ const Modal = (($) => {
|
||||
if (this._config.focus) {
|
||||
this._element.focus()
|
||||
}
|
||||
this._isTransitioning = false
|
||||
$(this._element).trigger(shownEvent)
|
||||
}
|
||||
|
||||
@@ -290,7 +304,8 @@ const Modal = (($) => {
|
||||
|
||||
_hideModal() {
|
||||
this._element.style.display = 'none'
|
||||
this._element.setAttribute('aria-hidden', true)
|
||||
this._element.setAttribute('aria-hidden', 'true')
|
||||
this._isTransitioning = false
|
||||
this._showBackdrop(() => {
|
||||
$(document.body).removeClass(ClassName.OPEN)
|
||||
this._resetAdjustments()
|
||||
@@ -489,7 +504,7 @@ const Modal = (($) => {
|
||||
const config = $(target).data(DATA_KEY) ?
|
||||
'toggle' : $.extend({}, $(target).data(), $(this).data())
|
||||
|
||||
if (this.tagName === 'A') {
|
||||
if (this.tagName === 'A' || this.tagName === 'AREA') {
|
||||
event.preventDefault()
|
||||
}
|
||||
|
||||
|
||||
+1
-3
@@ -117,9 +117,7 @@ const Popover = (($) => {
|
||||
this.setElementContent($tip.find(Selector.TITLE), this.getTitle())
|
||||
this.setElementContent($tip.find(Selector.CONTENT), this._getContent())
|
||||
|
||||
$tip
|
||||
.removeClass(ClassName.FADE)
|
||||
.removeClass(ClassName.ACTIVE)
|
||||
$tip.removeClass(`${ClassName.FADE} ${ClassName.ACTIVE}`)
|
||||
|
||||
this.cleanupTether()
|
||||
}
|
||||
|
||||
+1
-1
@@ -221,7 +221,7 @@ const ScrollSpy = (($) => {
|
||||
return
|
||||
}
|
||||
|
||||
if (this._activeTarget && scrollTop < this._offsets[0]) {
|
||||
if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) {
|
||||
this._activeTarget = null
|
||||
this._clear()
|
||||
return
|
||||
|
||||
+32
-14
@@ -46,7 +46,8 @@ const Tooltip = (($) => {
|
||||
selector : false,
|
||||
placement : 'top',
|
||||
offset : '0 0',
|
||||
constraints : []
|
||||
constraints : [],
|
||||
container : false
|
||||
}
|
||||
|
||||
const DefaultType = {
|
||||
@@ -59,7 +60,8 @@ const Tooltip = (($) => {
|
||||
selector : '(string|boolean)',
|
||||
placement : '(string|function)',
|
||||
offset : 'string',
|
||||
constraints : 'array'
|
||||
constraints : 'array',
|
||||
container : '(string|element|boolean)'
|
||||
}
|
||||
|
||||
const AttachmentMap = {
|
||||
@@ -121,11 +123,12 @@ const Tooltip = (($) => {
|
||||
constructor(element, config) {
|
||||
|
||||
// private
|
||||
this._isEnabled = true
|
||||
this._timeout = 0
|
||||
this._hoverState = ''
|
||||
this._activeTrigger = {}
|
||||
this._tether = null
|
||||
this._isEnabled = true
|
||||
this._timeout = 0
|
||||
this._hoverState = ''
|
||||
this._activeTrigger = {}
|
||||
this._isTransitioning = false
|
||||
this._tether = null
|
||||
|
||||
// protected
|
||||
this.element = element
|
||||
@@ -222,6 +225,7 @@ const Tooltip = (($) => {
|
||||
$.removeData(this.element, this.constructor.DATA_KEY)
|
||||
|
||||
$(this.element).off(this.constructor.EVENT_KEY)
|
||||
$(this.element).closest('.modal').off('hide.bs.modal')
|
||||
|
||||
if (this.tip) {
|
||||
$(this.tip).remove()
|
||||
@@ -242,9 +246,12 @@ const Tooltip = (($) => {
|
||||
if ($(this.element).css('display') === 'none') {
|
||||
throw new Error('Please use show on visible elements')
|
||||
}
|
||||
const showEvent = $.Event(this.constructor.Event.SHOW)
|
||||
|
||||
const showEvent = $.Event(this.constructor.Event.SHOW)
|
||||
if (this.isWithContent() && this._isEnabled) {
|
||||
if (this._isTransitioning) {
|
||||
throw new Error('Tooltip is transitioning')
|
||||
}
|
||||
$(this.element).trigger(showEvent)
|
||||
|
||||
const isInTheDom = $.contains(
|
||||
@@ -274,9 +281,11 @@ const Tooltip = (($) => {
|
||||
|
||||
const attachment = this._getAttachment(placement)
|
||||
|
||||
const container = this.config.container === false ? document.body : $(this.config.container)
|
||||
|
||||
$(tip)
|
||||
.data(this.constructor.DATA_KEY, this)
|
||||
.appendTo(document.body)
|
||||
.appendTo(container)
|
||||
|
||||
$(this.element).trigger(this.constructor.Event.INSERTED)
|
||||
|
||||
@@ -298,7 +307,8 @@ const Tooltip = (($) => {
|
||||
|
||||
const complete = () => {
|
||||
const prevHoverState = this._hoverState
|
||||
this._hoverState = null
|
||||
this._hoverState = null
|
||||
this._isTransitioning = false
|
||||
|
||||
$(this.element).trigger(this.constructor.Event.SHOWN)
|
||||
|
||||
@@ -308,6 +318,7 @@ const Tooltip = (($) => {
|
||||
}
|
||||
|
||||
if (Util.supportsTransitionEnd() && $(this.tip).hasClass(ClassName.FADE)) {
|
||||
this._isTransitioning = true
|
||||
$(this.tip)
|
||||
.one(Util.TRANSITION_END, complete)
|
||||
.emulateTransitionEnd(Tooltip._TRANSITION_DURATION)
|
||||
@@ -321,6 +332,9 @@ const Tooltip = (($) => {
|
||||
hide(callback) {
|
||||
const tip = this.getTipElement()
|
||||
const hideEvent = $.Event(this.constructor.Event.HIDE)
|
||||
if (this._isTransitioning) {
|
||||
throw new Error('Tooltip is transitioning')
|
||||
}
|
||||
const complete = () => {
|
||||
if (this._hoverState !== HoverState.ACTIVE && tip.parentNode) {
|
||||
tip.parentNode.removeChild(tip)
|
||||
@@ -328,6 +342,7 @@ const Tooltip = (($) => {
|
||||
|
||||
this.element.removeAttribute('aria-describedby')
|
||||
$(this.element).trigger(this.constructor.Event.HIDDEN)
|
||||
this._isTransitioning = false
|
||||
this.cleanupTether()
|
||||
|
||||
if (callback) {
|
||||
@@ -345,7 +360,7 @@ const Tooltip = (($) => {
|
||||
|
||||
if (Util.supportsTransitionEnd() &&
|
||||
$(this.tip).hasClass(ClassName.FADE)) {
|
||||
|
||||
this._isTransitioning = true
|
||||
$(tip)
|
||||
.one(Util.TRANSITION_END, complete)
|
||||
.emulateTransitionEnd(TRANSITION_DURATION)
|
||||
@@ -373,9 +388,7 @@ const Tooltip = (($) => {
|
||||
|
||||
this.setElementContent($tip.find(Selector.TOOLTIP_INNER), this.getTitle())
|
||||
|
||||
$tip
|
||||
.removeClass(ClassName.FADE)
|
||||
.removeClass(ClassName.ACTIVE)
|
||||
$tip.removeClass(`${ClassName.FADE} ${ClassName.ACTIVE}`)
|
||||
|
||||
this.cleanupTether()
|
||||
}
|
||||
@@ -452,6 +465,11 @@ const Tooltip = (($) => {
|
||||
(event) => this._leave(event)
|
||||
)
|
||||
}
|
||||
|
||||
$(this.element).closest('.modal').on(
|
||||
'hide.bs.modal',
|
||||
() => this.hide()
|
||||
)
|
||||
})
|
||||
|
||||
if (this.config.selector) {
|
||||
|
||||
Reference in New Issue
Block a user