Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Bootstrap
bootstrap
Commits
9201a805
Commit
9201a805
authored
6 years ago
by
Johann-S
Browse files
Options
Download
Email Patches
Plain Diff
some cleaning and changes for readability
parent
fab1dea9
main
cleanup-floating-forms
cssvar-function
dependabot/npm_and_yarn/stylelint-and-stylelint-config-twbs-bootstrap-15.3.0
extend-snippets
feat/data-target
floating-always-visible
floating-labels-icons
fod-main-banner
form-controls-with-icons
github/fork/719media/patch-13
github/fork/719media/patch-14
github/fork/719media/patch-9
github/fork/ChellyAhmed/fix-typo-reboot.md
github/fork/ChellyAhmed/offcanvas-scroll-back
github/fork/CtrlAltLilith/main
github/fork/Elysiome/offcanvas-optional-window-resizing
github/fork/JanSargsyan/main
github/fork/LunicLynx/support-different-line-height-for-buttons
github/fork/Psixodelik/main
github/fork/Ronid1/ronid1/offcanvas_static_backdrop
github/fork/RyanBerliner/tooltip-accessibility
github/fork/SantiagoPVazquez/Feature-default-border-bottom-to-dropdown-item
github/fork/Sir-Genius/utils
github/fork/Sumit-Singh-8/main
github/fork/Viktor-VERA2020/offcanvas-slide
github/fork/Zivangu9/input-group-for-form-control-plaintext
github/fork/alpadev/alpadev/call-dispose-on-component-reinstantiation
github/fork/astagi/fix/tree-shake-modules
github/fork/compnerd/dark-accordion-icon
github/fork/derSascha/dropdown-dont-close-on-input-click
github/fork/dev-ph1l/main
github/fork/donquixote/issue-33861-utl-mixin
github/fork/florianlacreuse/mixin-make-row-gutter-y
github/fork/gregorw/main
github/fork/iteggmbh/transitionend-dispose-race
github/fork/jdelStrother/patch-1
github/fork/jonnysp/form-floating
github/fork/jonnysp/independent-offcanvas
github/fork/jonnysp/theme-dark-on-card-and-modal-fix
github/fork/josefdlange/floating-label-placeholder-opacity
github/fork/julien-deramond/enhance-change-version.js
github/fork/julien-deramond/main-jd-fix-offset-content
github/fork/julien-deramond/main-jd-issue-with-utitlies
github/fork/julien-deramond/main-xmr-pa11y-ci-jd-add-hideElements
github/fork/kyletsang/fix-tooltip-padding
github/fork/lacutah/CheckboxCenteringDocumentation
github/fork/lekoala/patch-3
github/fork/louismaximepiton/main-kld-lmp-collapse-proposal
github/fork/louismaximepiton/main-lmp-card-inner-border-radius-fix
github/fork/louismaximepiton/main-lmp-carousel-multiple-images
github/fork/louismaximepiton/main-lmp-css-var-init
github/fork/louismaximepiton/main-lmp-disabled-floating-label-fix
github/fork/louismaximepiton/main-lmp-input-range-fix
github/fork/louismaximepiton/main-lmp-shift-color
github/fork/louismaximepiton/main-lmp-table-active-tr-fix
github/fork/maciek-szn/switch
github/fork/michael-roth/feature/19964-multiple-tab-targets
github/fork/mistic100/dom-utils
github/fork/nkdas91/accordion
github/fork/nstungcom/fix-missing-modal-open-class
github/fork/oraliahdz/animation-utilities
github/fork/pine3ree/patch-7
github/fork/pouwerkerk/unindent-scss-docs-shortcode
github/fork/smares/smares-no-scolling-on-modal-close
github/fork/tgm-git/patch-1
gs-forms
gs-toasts-with-animated-progress-bar
gs/add-history-helper
gs/change-version-dir-on-docs
gs/data-must-set-onlu-one-instance
gs/docs/fix-drop-down-error
gs/event-handler-2
gs/make-docs-js-build
gs/make-simple-attribute-toggler
gs/popover-fix-doc
gs/provide-steConfig-method
gs/scrollspy-smoothscroll-option-use-browser-history
gs/streamline-jqueryInterface
gs/support-drop-down-in-navbar
gs/test-js-generic-trigger
gs/try-web-components
gs/tweak-collapse-js-selector
gs/use-event-handler-in-cocmponent
gs/use-rollup-replace-for-version
jo-docs-thanks-page
jo-ssr-friendly
logical-props-spacing-utils
main-fod-disabled-form-check-label
main-fod-nested-accordion
main-fod-simpler-table-structure
main-fod-table-separator
main-fod-utilities-contrast
main-jd-abbr-title
main-jd-add-chips
main-jd-add-doc-for-sass-custom-colors
main-jd-add-enable-host-to-handle-web-components
main-jd-browserstack-fine-tune
main-jd-browserstack-updates
main-jd-docs-consistent-usage-of-css-sections-step-2
main-jd-fix-docs-headers-in-white
main-jd-fix-highlight-docs-border-radius
main-jd-fix-placeholder-color-background-params-for-img-markup
main-jd-glossary-experiment
main-jd-postcss-drop-empty-css-vars
main-jd-proto-doc-astro
main-jd-skip-navigation-component
main-jd-stackblitz-for-examples
main-jd-upgrade-browserlistrc
main-jd-use-host
main-lmp-dark-theme-customization
main-lmp-handle-scroll-target
main-lmp-tab-fix
main-mc-opensearch
main-xmr-bundlewatch-action
main-xmr-eslint-plugin-compat
main-xmr-hugo-docs-vendor
main-xmr-hugo-rm-ver
main-xmr-linkinator-prod
main-xmr-min-mangle
main-xmr-pa11y-ci
more-darkmode-examples
nested-dropdowns
patrickhlauke-issue37428
patrickhlauke-use-of-color-tweaks
pr/34102
pr/37590
previous-next-docs-links
sticky-thead
utilities-functions-mixin
v4-dev
v4-dev-dropdown-hide-method
v530-dev
v6-postcss-custom-media
v6-spinner-dots
v6/gs/use-floating-ui-in-place-of-popper
xmr/dev
xmr/docs-png
xmr/docs-svgs
xmr/hugo-reorg-files
xmr/js-2
xmr/markdownlint
xmr/prepare-530-alpha2
xmr/xo
v5.3.0-alpha1
v5.2.3
v5.2.2
v5.2.1
v5.2.0
v5.2.0-beta1
v5.1.3
v5.1.2
v5.1.1
v5.1.0
v5.0.2
v5.0.1
v5.0.0
v5.0.0-beta3
v5.0.0-beta2
v5.0.0-beta1
v5.0.0-alpha3
v5.0.0-alpha2
v5.0.0-alpha1
v4.6.2
v4.6.1
v4.6.0
v4.5.3
v4.5.2
v4.5.1
v4.5.0
v4.4.1
v4.4.0
v4.3.1
v4.3.0
v4.2.1
v4.2.0
1 merge request
!28721
Hot test
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
js/src/alert.js
+3
-3
js/src/alert.js
js/src/button.js
+2
-2
js/src/button.js
js/src/carousel.js
+2
-5
js/src/carousel.js
js/src/collapse.js
+7
-4
js/src/collapse.js
js/src/dropdown.js
+25
-23
js/src/dropdown.js
js/src/modal.js
+8
-8
js/src/modal.js
js/src/popover.js
+3
-3
js/src/popover.js
js/src/scrollspy.js
+10
-12
js/src/scrollspy.js
js/src/tab.js
+10
-14
js/src/tab.js
js/src/toast.js
+165
-169
js/src/toast.js
js/src/tooltip.js
+37
-39
js/src/tooltip.js
js/src/util.js
+1
-2
js/src/util.js
with
273 additions
and
284 deletions
+273
-284
js/src/alert.js
+
3
-
3
View file @
9201a805
import
$
from
'
jquery
'
import
Util
from
'
./util
'
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.1.3): alert.js
...
...
@@ -8,6 +5,9 @@ import Util from './util'
* --------------------------------------------------------------------------
*/
import
$
from
'
jquery
'
import
Util
from
'
./util
'
/**
* ------------------------------------------------------------------------
* Constants
...
...
This diff is collapsed.
Click to expand it.
js/src/button.js
+
2
-
2
View file @
9201a805
import
$
from
'
jquery
'
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.1.3): button.js
...
...
@@ -7,6 +5,8 @@ import $ from 'jquery'
* --------------------------------------------------------------------------
*/
import
$
from
'
jquery
'
/**
* ------------------------------------------------------------------------
* Constants
...
...
This diff is collapsed.
Click to expand it.
js/src/carousel.js
+
2
-
5
View file @
9201a805
...
...
@@ -60,10 +60,7 @@ const Event = {
TOUCHMOVE
:
`touchmove
${
EVENT_KEY
}
`
,
TOUCHEND
:
`touchend
${
EVENT_KEY
}
`
,
POINTERDOWN
:
`pointerdown
${
EVENT_KEY
}
`
,
POINTERMOVE
:
`pointermove
${
EVENT_KEY
}
`
,
POINTERUP
:
`pointerup
${
EVENT_KEY
}
`
,
POINTERLEAVE
:
`pointerleave
${
EVENT_KEY
}
`
,
POINTERCANCEL
:
`pointercancel
${
EVENT_KEY
}
`
,
DRAG_START
:
`dragstart
${
EVENT_KEY
}
`
,
LOAD_DATA_API
:
`load
${
EVENT_KEY
}${
DATA_API_KEY
}
`
,
CLICK_DATA_API
:
`click
${
EVENT_KEY
}${
DATA_API_KEY
}
`
...
...
@@ -280,7 +277,7 @@ class Carousel {
}
const
start
=
(
event
)
=>
{
if
(
this
.
_pointerEvent
&&
(
event
.
originalEvent
.
pointerType
===
PointerType
.
TOUCH
||
event
.
originalEvent
.
pointerType
===
PointerType
.
PEN
)
)
{
if
(
this
.
_pointerEvent
&&
PointerType
[
event
.
originalEvent
.
pointerType
.
toUpperCase
()]
)
{
this
.
touchStartX
=
event
.
originalEvent
.
clientX
}
else
if
(
!
this
.
_pointerEvent
)
{
this
.
touchStartX
=
event
.
originalEvent
.
touches
[
0
].
clientX
...
...
@@ -297,7 +294,7 @@ class Carousel {
}
const
end
=
(
event
)
=>
{
if
(
this
.
_pointerEvent
&&
(
event
.
originalEvent
.
pointerType
===
PointerType
.
TOUCH
||
event
.
originalEvent
.
pointerType
===
PointerType
.
PEN
)
)
{
if
(
this
.
_pointerEvent
&&
PointerType
[
event
.
originalEvent
.
pointerType
.
toUpperCase
()]
)
{
this
.
touchDeltaX
=
event
.
originalEvent
.
clientX
-
this
.
touchStartX
}
...
...
This diff is collapsed.
Click to expand it.
js/src/collapse.js
+
7
-
4
View file @
9201a805
import
$
from
'
jquery
'
import
Util
from
'
./util
'
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.1.3): collapse.js
...
...
@@ -8,6 +5,9 @@ import Util from './util'
* --------------------------------------------------------------------------
*/
import
$
from
'
jquery
'
import
Util
from
'
./util
'
/**
* ------------------------------------------------------------------------
* Constants
...
...
@@ -67,10 +67,11 @@ class Collapse {
this
.
_isTransitioning
=
false
this
.
_element
=
element
this
.
_config
=
this
.
_getConfig
(
config
)
this
.
_triggerArray
=
$
.
makeArray
(
document
.
querySelectorAll
(
this
.
_triggerArray
=
[].
slice
.
call
(
document
.
querySelectorAll
(
`[data-toggle="collapse"][href="#
${
element
.
id
}
"],`
+
`[data-toggle="collapse"][data-target="#
${
element
.
id
}
"]`
))
const
toggleList
=
[].
slice
.
call
(
document
.
querySelectorAll
(
Selector
.
DATA_TOGGLE
))
for
(
let
i
=
0
,
len
=
toggleList
.
length
;
i
<
len
;
i
++
)
{
const
elem
=
toggleList
[
i
]
...
...
@@ -227,6 +228,7 @@ class Collapse {
for
(
let
i
=
0
;
i
<
triggerArrayLength
;
i
++
)
{
const
trigger
=
this
.
_triggerArray
[
i
]
const
selector
=
Util
.
getSelectorFromElement
(
trigger
)
if
(
selector
!==
null
)
{
const
$elem
=
$
([].
slice
.
call
(
document
.
querySelectorAll
(
selector
)))
if
(
!
$elem
.
hasClass
(
ClassName
.
SHOW
))
{
...
...
@@ -375,6 +377,7 @@ $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) {
const
$trigger
=
$
(
this
)
const
selector
=
Util
.
getSelectorFromElement
(
this
)
const
selectors
=
[].
slice
.
call
(
document
.
querySelectorAll
(
selector
))
$
(
selectors
).
each
(
function
()
{
const
$target
=
$
(
this
)
const
data
=
$target
.
data
(
DATA_KEY
)
...
...
This diff is collapsed.
Click to expand it.
js/src/dropdown.js
+
25
-
23
View file @
9201a805
import
$
from
'
jquery
'
import
Popper
from
'
popper.js
'
import
Util
from
'
./util
'
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.1.3): dropdown.js
...
...
@@ -9,6 +5,10 @@ import Util from './util'
* --------------------------------------------------------------------------
*/
import
$
from
'
jquery
'
import
Popper
from
'
popper.js
'
import
Util
from
'
./util
'
/**
* ------------------------------------------------------------------------
* Constants
...
...
@@ -41,13 +41,13 @@ const Event = {
}
const
ClassName
=
{
DISABLED
:
'
disabled
'
,
SHOW
:
'
show
'
,
DROPUP
:
'
dropup
'
,
DROPRIGHT
:
'
dropright
'
,
DROPLEFT
:
'
dropleft
'
,
MENURIGHT
:
'
dropdown-menu-right
'
,
MENULEFT
:
'
dropdown-menu-left
'
,
DISABLED
:
'
disabled
'
,
SHOW
:
'
show
'
,
DROPUP
:
'
dropup
'
,
DROPRIGHT
:
'
dropright
'
,
DROPLEFT
:
'
dropleft
'
,
MENURIGHT
:
'
dropdown-menu-right
'
,
MENULEFT
:
'
dropdown-menu-left
'
,
POSITION_STATIC
:
'
position-static
'
}
...
...
@@ -71,19 +71,19 @@ const AttachmentMap = {
}
const
Default
=
{
offset
:
0
,
flip
:
true
,
boundary
:
'
scrollParent
'
,
reference
:
'
toggle
'
,
display
:
'
dynamic
'
offset
:
0
,
flip
:
true
,
boundary
:
'
scrollParent
'
,
reference
:
'
toggle
'
,
display
:
'
dynamic
'
}
const
DefaultType
=
{
offset
:
'
(number|string|function)
'
,
flip
:
'
boolean
'
,
boundary
:
'
(string|element)
'
,
reference
:
'
(string|element)
'
,
display
:
'
string
'
offset
:
'
(number|string|function)
'
,
flip
:
'
boolean
'
,
boundary
:
'
(string|element)
'
,
reference
:
'
(string|element)
'
,
display
:
'
string
'
}
/**
...
...
@@ -203,8 +203,8 @@ class Dropdown {
relatedTarget
:
this
.
_element
}
const
showEvent
=
$
.
Event
(
Event
.
SHOW
,
relatedTarget
)
const
parent
=
Dropdown
.
_getParentFromElement
(
this
.
_element
)
$
(
parent
).
trigger
(
showEvent
)
if
(
showEvent
.
isDefaultPrevented
())
{
...
...
@@ -226,8 +226,8 @@ class Dropdown {
relatedTarget
:
this
.
_element
}
const
hideEvent
=
$
.
Event
(
Event
.
HIDE
,
relatedTarget
)
const
parent
=
Dropdown
.
_getParentFromElement
(
this
.
_element
)
$
(
parent
).
trigger
(
hideEvent
)
if
(
hideEvent
.
isDefaultPrevented
())
{
...
...
@@ -287,6 +287,7 @@ class Dropdown {
_getMenuElement
()
{
if
(
!
this
.
_menu
)
{
const
parent
=
Dropdown
.
_getParentFromElement
(
this
.
_element
)
if
(
parent
)
{
this
.
_menu
=
parent
.
querySelector
(
Selector
.
MENU
)
}
...
...
@@ -382,6 +383,7 @@ class Dropdown {
}
const
toggles
=
[].
slice
.
call
(
document
.
querySelectorAll
(
Selector
.
DATA_TOGGLE
))
for
(
let
i
=
0
,
len
=
toggles
.
length
;
i
<
len
;
i
++
)
{
const
parent
=
Dropdown
.
_getParentFromElement
(
toggles
[
i
])
const
context
=
$
(
toggles
[
i
]).
data
(
DATA_KEY
)
...
...
This diff is collapsed.
Click to expand it.
js/src/modal.js
+
8
-
8
View file @
9201a805
import
$
from
'
jquery
'
import
Util
from
'
./util
'
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.1.3): modal.js
...
...
@@ -8,6 +5,9 @@ import Util from './util'
* --------------------------------------------------------------------------
*/
import
$
from
'
jquery
'
import
Util
from
'
./util
'
/**
* ------------------------------------------------------------------------
* Constants
...
...
@@ -59,11 +59,11 @@ const ClassName = {
}
const
Selector
=
{
DIALOG
:
'
.modal-dialog
'
,
DATA_TOGGLE
:
'
[data-toggle="modal"]
'
,
DATA_DISMISS
:
'
[data-dismiss="modal"]
'
,
FIXED_CONTENT
:
'
.fixed-top, .fixed-bottom, .is-fixed, .sticky-top
'
,
STICKY_CONTENT
:
'
.sticky-top
'
DIALOG
:
'
.modal-dialog
'
,
DATA_TOGGLE
:
'
[data-toggle="modal"]
'
,
DATA_DISMISS
:
'
[data-dismiss="modal"]
'
,
FIXED_CONTENT
:
'
.fixed-top, .fixed-bottom, .is-fixed, .sticky-top
'
,
STICKY_CONTENT
:
'
.sticky-top
'
}
/**
...
...
This diff is collapsed.
Click to expand it.
js/src/popover.js
+
3
-
3
View file @
9201a805
import
$
from
'
jquery
'
import
Tooltip
from
'
./tooltip
'
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.1.3): popover.js
...
...
@@ -8,6 +5,9 @@ import Tooltip from './tooltip'
* --------------------------------------------------------------------------
*/
import
$
from
'
jquery
'
import
Tooltip
from
'
./tooltip
'
/**
* ------------------------------------------------------------------------
* Constants
...
...
This diff is collapsed.
Click to expand it.
js/src/scrollspy.js
+
10
-
12
View file @
9201a805
import
$
from
'
jquery
'
import
Util
from
'
./util
'
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.1.3): scrollspy.js
...
...
@@ -8,6 +5,9 @@ import Util from './util'
* --------------------------------------------------------------------------
*/
import
$
from
'
jquery
'
import
Util
from
'
./util
'
/**
* ------------------------------------------------------------------------
* Constants
...
...
@@ -242,12 +242,9 @@ class ScrollSpy {
this
.
_clear
()
let
queries
=
this
.
_selector
.
split
(
'
,
'
)
// eslint-disable-next-line arrow-body-style
queries
=
queries
.
map
((
selector
)
=>
{
return
`
${
selector
}
[data-target="
${
target
}
"],`
+
`
${
selector
}
[href="
${
target
}
"]`
})
const
queries
=
this
.
_selector
.
split
(
'
,
'
)
.
map
((
selector
)
=>
`
${
selector
}
[data-target="
${
target
}
"],
${
selector
}
[href="
${
target
}
"]`
)
const
$link
=
$
([].
slice
.
call
(
document
.
querySelectorAll
(
queries
.
join
(
'
,
'
))))
...
...
@@ -270,8 +267,9 @@ class ScrollSpy {
}
_clear
()
{
const
nodes
=
[].
slice
.
call
(
document
.
querySelectorAll
(
this
.
_selector
))
$
(
nodes
).
filter
(
Selector
.
ACTIVE
).
removeClass
(
ClassName
.
ACTIVE
)
[].
slice
.
call
(
document
.
querySelectorAll
(
this
.
_selector
))
.
filter
((
node
)
=>
node
.
classList
.
contains
(
ClassName
.
ACTIVE
))
.
forEach
((
node
)
=>
node
.
classList
.
remove
(
ClassName
.
ACTIVE
))
}
// Static
...
...
@@ -304,8 +302,8 @@ class ScrollSpy {
$
(
window
).
on
(
Event
.
LOAD_DATA_API
,
()
=>
{
const
scrollSpys
=
[].
slice
.
call
(
document
.
querySelectorAll
(
Selector
.
DATA_SPY
))
const
scrollSpysLength
=
scrollSpys
.
length
for
(
let
i
=
scrollSpysLength
;
i
--
;)
{
const
$spy
=
$
(
scrollSpys
[
i
])
ScrollSpy
.
_jQueryInterface
.
call
(
$spy
,
$spy
.
data
())
...
...
This diff is collapsed.
Click to expand it.
js/src/tab.js
+
10
-
14
View file @
9201a805
import
$
from
'
jquery
'
import
Util
from
'
./util
'
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.1.3): tab.js
...
...
@@ -8,6 +5,9 @@ import Util from './util'
* --------------------------------------------------------------------------
*/
import
$
from
'
jquery
'
import
Util
from
'
./util
'
/**
* ------------------------------------------------------------------------
* Constants
...
...
@@ -141,17 +141,12 @@ class Tab {
// Private
_activate
(
element
,
container
,
callback
)
{
let
activeElements
if
(
container
&&
container
.
nodeName
===
'
UL
'
)
{
activeElements
=
$
(
container
).
find
(
Selector
.
ACTIVE_UL
)
}
else
{
activeElements
=
$
(
container
).
children
(
Selector
.
ACTIVE
)
}
const
activeElements
=
container
&&
container
.
nodeName
===
'
UL
'
?
$
(
container
).
find
(
Selector
.
ACTIVE_UL
)
:
$
(
container
).
children
(
Selector
.
ACTIVE
)
const
active
=
activeElements
[
0
]
const
isTransitioning
=
callback
&&
(
active
&&
$
(
active
).
hasClass
(
ClassName
.
FADE
))
const
isTransitioning
=
callback
&&
(
active
&&
$
(
active
).
hasClass
(
ClassName
.
FADE
))
const
complete
=
()
=>
this
.
_transitionComplete
(
element
,
active
,
...
...
@@ -195,11 +190,12 @@ class Tab {
Util
.
reflow
(
element
)
$
(
element
).
addClass
(
ClassName
.
SHOW
)
if
(
element
.
parentNode
&&
$
(
element
.
parentNode
).
hasClass
(
ClassName
.
DROPDOWN_MENU
))
{
if
(
element
.
parentNode
&&
$
(
element
.
parentNode
).
hasClass
(
ClassName
.
DROPDOWN_MENU
))
{
const
dropdownElement
=
$
(
element
).
closest
(
Selector
.
DROPDOWN
)[
0
]
if
(
dropdownElement
)
{
const
dropdownToggleList
=
[].
slice
.
call
(
dropdownElement
.
querySelectorAll
(
Selector
.
DROPDOWN_TOGGLE
))
$
(
dropdownToggleList
).
addClass
(
ClassName
.
ACTIVE
)
}
...
...
This diff is collapsed.
Click to expand it.
js/src/toast.js
+
165
-
169
View file @
9201a805
import
$
from
'
jquery
'
import
Util
from
'
./util
'
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.1.3): toast.js
...
...
@@ -8,215 +5,214 @@ import Util from './util'
* --------------------------------------------------------------------------
*/
const
Toast
=
((
$
)
=>
{
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const
NAME
=
'
toast
'
const
VERSION
=
'
4.1.3
'
const
DATA_KEY
=
'
bs.toast
'
const
EVENT_KEY
=
`.
${
DATA_KEY
}
`
const
JQUERY_NO_CONFLICT
=
$
.
fn
[
NAME
]
const
Event
=
{
CLICK_DISMISS
:
`click.dismiss
${
EVENT_KEY
}
`
,
HIDE
:
`hide
${
EVENT_KEY
}
`
,
HIDDEN
:
`hidden
${
EVENT_KEY
}
`
,
SHOW
:
`show
${
EVENT_KEY
}
`
,
SHOWN
:
`shown
${
EVENT_KEY
}
`
}
import
$
from
'
jquery
'
import
Util
from
'
./util
'
const
ClassName
=
{
FADE
:
'
fade
'
,
HIDE
:
'
hide
'
,
SHOW
:
'
show
'
}
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const
DefaultType
=
{
animation
:
'
boolean
'
,
autohide
:
'
boolean
'
,
delay
:
'
number
'
}
const
NAME
=
'
toast
'
const
VERSION
=
'
4.1.3
'
const
DATA_KEY
=
'
bs.toast
'
const
EVENT_KEY
=
`.
${
DATA_KEY
}
`
const
JQUERY_NO_CONFLICT
=
$
.
fn
[
NAME
]
const
Event
=
{
CLICK_DISMISS
:
`click.dismiss
${
EVENT_KEY
}
`
,
HIDE
:
`hide
${
EVENT_KEY
}
`
,
HIDDEN
:
`hidden
${
EVENT_KEY
}
`
,
SHOW
:
`show
${
EVENT_KEY
}
`
,
SHOWN
:
`shown
${
EVENT_KEY
}
`
}
const
ClassName
=
{
FADE
:
'
fade
'
,
HIDE
:
'
hide
'
,
SHOW
:
'
show
'
}
const
DefaultType
=
{
animation
:
'
boolean
'
,
autohide
:
'
boolean
'
,
delay
:
'
number
'
}
const
Default
=
{
animation
:
true
,
autohide
:
true
,
delay
:
500
}
const
Selector
=
{
DATA_DISMISS
:
'
[data-dismiss="toast"]
'
}
const
Default
=
{
animation
:
true
,
autohide
:
true
,
delay
:
500
}
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
const
Selector
=
{
DATA_DISMISS
:
'
[data-dismiss="toast"]
'
class
Toast
{
constructor
(
element
,
config
)
{
this
.
_element
=
element
this
.
_config
=
this
.
_getConfig
(
config
)
this
.
_timeout
=
null
this
.
_setListeners
()
}
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
class
Toast
{
constructor
(
element
,
config
)
{
this
.
_element
=
element
this
.
_config
=
this
.
_getConfig
(
config
)
this
.
_timeout
=
null
this
.
_setListeners
()
}
// Getters
// Getters
static
get
VERSION
()
{
return
VERSION
}
static
get
VERSION
()
{
return
VERSION
}
static
get
DefaultType
()
{
return
DefaultType
}
static
get
DefaultType
()
{
return
DefaultType
}
// Public
// Public
show
()
{
$
(
this
.
_element
).
trigger
(
Event
.
SHOW
)
show
()
{
$
(
this
.
_element
).
trigger
(
Event
.
SHOW
)
if
(
this
.
_config
.
animation
)
{
this
.
_element
.
classList
.
add
(
ClassName
.
FADE
)
}
if
(
this
.
_config
.
animation
)
{
this
.
_element
.
classList
.
add
(
ClassName
.
FADE
)
}
const
complete
=
()
=>
{
$
(
this
.
_element
).
trigger
(
Event
.
SHOWN
)
const
complete
=
()
=>
{
$
(
this
.
_element
).
trigger
(
Event
.
SHOWN
)
if
(
this
.
_config
.
autohide
)
{
this
.
hide
()
}
if
(
this
.
_config
.
autohide
)
{
this
.
hide
()
}
}
this
.
_element
.
classList
.
add
(
ClassName
.
SHOW
)
if
(
this
.
_config
.
animation
)
{
const
transitionDuration
=
Util
.
getTransitionDurationFromElement
(
this
.
_element
)
this
.
_element
.
classList
.
add
(
ClassName
.
SHOW
)
if
(
this
.
_config
.
animation
)
{
const
transitionDuration
=
Util
.
getTransitionDurationFromElement
(
this
.
_element
)
$
(
this
.
_element
)
.
one
(
Util
.
TRANSITION_END
,
complete
)
.
emulateTransitionEnd
(
transitionDuration
)
}
else
{
complete
()
}
$
(
this
.
_element
)
.
one
(
Util
.
TRANSITION_END
,
complete
)
.
emulateTransitionEnd
(
transitionDuration
)
}
else
{
complete
()
}
}
hide
(
withoutTimeout
)
{
if
(
!
this
.
_element
.
classList
.
contains
(
ClassName
.
SHOW
))
{
return
}
hide
(
withoutTimeout
)
{
if
(
!
this
.
_element
.
classList
.
contains
(
ClassName
.
SHOW
))
{
return
}
$
(
this
.
_element
).
trigger
(
Event
.
HIDE
)
$
(
this
.
_element
).
trigger
(
Event
.
HIDE
)
if
(
withoutTimeout
)
{
if
(
withoutTimeout
)
{
this
.
_close
()
}
else
{
this
.
_timeout
=
setTimeout
(()
=>
{
this
.
_close
()
}
else
{
this
.
_timeout
=
setTimeout
(()
=>
{
this
.
_close
()
},
this
.
_config
.
delay
)
}
},
this
.
_config
.
delay
)
}
}
dispose
()
{
clearTimeout
(
this
.
_timeout
)
this
.
_timeout
=
null
if
(
this
.
_element
.
classList
.
contains
(
ClassName
.
SHOW
))
{
this
.
_element
.
classList
.
remove
(
ClassName
.
SHOW
)
}
$
(
this
.
_element
).
off
(
Event
.
CLICK_DISMISS
)
dispose
()
{
clearTimeout
(
this
.
_timeout
)
this
.
_timeout
=
null
$
.
removeData
(
this
.
_element
,
DATA_KEY
)
this
.
_element
=
null
this
.
_config
=
null
if
(
this
.
_element
.
classList
.
contains
(
ClassName
.
SHOW
))
{
this
.
_element
.
classList
.
remove
(
ClassName
.
SHOW
)
}
// Private
_getConfig
(
config
)
{
config
=
{
...
Default
,
...
$
(
this
.
_element
).
data
(),
...
typeof
config
===
'
object
'
&&
config
?
config
:
{}
}
$
(
this
.
_element
).
off
(
Event
.
CLICK_DISMISS
)
Util
.
typeCheckConfig
(
NAME
,
config
,
this
.
constructor
.
DefaultType
)
$
.
removeData
(
this
.
_element
,
DATA_KEY
)
this
.
_element
=
null
this
.
_config
=
null
}
return
config
}
// Private
_setListeners
()
{
$
(
this
.
_element
).
on
(
Event
.
CLICK_DISMISS
,
Selector
.
DATA_DISMISS
,
()
=>
this
.
hide
(
true
)
)
_getConfig
(
config
)
{
config
=
{
...
Default
,
...
$
(
this
.
_element
).
data
(),
...
typeof
config
===
'
object
'
&&
config
?
config
:
{}
}
_close
()
{
const
complete
=
()
=>
{
$
(
this
.
_element
).
trigger
(
Event
.
HIDDEN
)
}
Util
.
typeCheckConfig
(
NAME
,
config
,
this
.
constructor
.
DefaultType
)
this
.
_element
.
classList
.
remove
(
ClassName
.
SHOW
)
return
config
}
if
(
this
.
_config
.
animation
)
{
const
transitionDuration
=
Util
.
getTransitionDurationFromElement
(
this
.
_element
)
_setListeners
()
{
$
(
this
.
_element
).
on
(
Event
.
CLICK_DISMISS
,
Selector
.
DATA_DISMISS
,
()
=>
this
.
hide
(
true
)
)
}
$
(
this
.
_element
)
.
one
(
Util
.
TRANSITION_END
,
complete
)
.
emulateTransitionEnd
(
transitionDuration
)
}
else
{
complete
()
}
_close
()
{
const
complete
=
()
=>
{
$
(
this
.
_element
).
trigger
(
Event
.
HIDDEN
)
}
// Static
this
.
_element
.
classList
.
remove
(
ClassName
.
SHOW
)
static
_jQueryInterface
(
config
)
{
return
this
.
each
(
function
()
{
const
$element
=
$
(
this
)
let
data
=
$element
.
data
(
DATA_KEY
)
const
_config
=
typeof
config
===
'
object
'
&&
config
if
(
this
.
_config
.
animation
)
{
const
transitionDuration
=
Util
.
getTransitionDurationFromElement
(
this
.
_element
)
if
(
!
data
)
{
data
=
new
Toast
(
this
,
_config
)
$element
.
data
(
DATA_KEY
,
data
)
}
$
(
this
.
_element
)
.
one
(
Util
.
TRANSITION_END
,
complete
)
.
emulateTransitionEnd
(
transitionDuration
)
}
else
{
complete
()
}
}
if
(
typeof
config
===
'
string
'
)
{
if
(
typeof
data
[
config
]
===
'
undefined
'
)
{
throw
new
TypeError
(
`No method named "
${
config
}
"`
)
}
// Static
static
_jQueryInterface
(
config
)
{
return
this
.
each
(
function
()
{
const
$element
=
$
(
this
)
let
data
=
$element
.
data
(
DATA_KEY
)
const
_config
=
typeof
config
===
'
object
'
&&
config
if
(
!
data
)
{
data
=
new
Toast
(
this
,
_config
)
$element
.
data
(
DATA_KEY
,
data
)
}
data
[
config
](
this
)
if
(
typeof
config
===
'
string
'
)
{
if
(
typeof
data
[
config
]
===
'
undefined
'
)
{
throw
new
TypeError
(
`No method named "
${
config
}
"`
)
}
})
}
}
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
*/
$
.
fn
[
NAME
]
=
Toast
.
_jQueryInterface
$
.
fn
[
NAME
].
Constructor
=
Toast
$
.
fn
[
NAME
].
noConflict
=
()
=>
{
$
.
fn
[
NAME
]
=
JQUERY_NO_CONFLICT
return
Toast
.
_jQueryInterface
data
[
config
](
this
)
}
})
}
}
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
*/
return
Toast
})(
$
)
$
.
fn
[
NAME
]
=
Toast
.
_jQueryInterface
$
.
fn
[
NAME
].
Constructor
=
Toast
$
.
fn
[
NAME
].
noConflict
=
()
=>
{
$
.
fn
[
NAME
]
=
JQUERY_NO_CONFLICT
return
Toast
.
_jQueryInterface
}
export
default
Toast
This diff is collapsed.
Click to expand it.
js/src/tooltip.js
+
37
-
39
View file @
9201a805
import
$
from
'
jquery
'
import
Popper
from
'
popper.js
'
import
Util
from
'
./util
'
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.1.3): tooltip.js
...
...
@@ -9,6 +5,10 @@ import Util from './util'
* --------------------------------------------------------------------------
*/
import
$
from
'
jquery
'
import
Popper
from
'
popper.js
'
import
Util
from
'
./util
'
/**
* ------------------------------------------------------------------------
* Constants
...
...
@@ -24,18 +24,18 @@ const CLASS_PREFIX = 'bs-tooltip'
const
BSCLS_PREFIX_REGEX
=
new
RegExp
(
`(^|\\s)
${
CLASS_PREFIX
}
\\S+`
,
'
g
'
)
const
DefaultType
=
{
animation
:
'
boolean
'
,
template
:
'
string
'
,
title
:
'
(string|element|function)
'
,
trigger
:
'
string
'
,
delay
:
'
(number|object)
'
,
html
:
'
boolean
'
,
selector
:
'
(string|boolean)
'
,
placement
:
'
(string|function)
'
,
offset
:
'
(number|string)
'
,
container
:
'
(string|element|boolean)
'
,
fallbackPlacement
:
'
(string|array)
'
,
boundary
:
'
(string|element)
'
animation
:
'
boolean
'
,
template
:
'
string
'
,
title
:
'
(string|element|function)
'
,
trigger
:
'
string
'
,
delay
:
'
(number|object)
'
,
html
:
'
boolean
'
,
selector
:
'
(string|boolean)
'
,
placement
:
'
(string|function)
'
,
offset
:
'
(number|string)
'
,
container
:
'
(string|element|boolean)
'
,
fallbackPlacement
:
'
(string|array)
'
,
boundary
:
'
(string|element)
'
}
const
AttachmentMap
=
{
...
...
@@ -47,20 +47,20 @@ const AttachmentMap = {
}
const
Default
=
{
animation
:
true
,
template
:
'
<div class="tooltip" role="tooltip">
'
+
'
<div class="arrow"></div>
'
+
'
<div class="tooltip-inner"></div></div>
'
,
trigger
:
'
hover focus
'
,
title
:
''
,
delay
:
0
,
html
:
false
,
selector
:
false
,
placement
:
'
top
'
,
offset
:
0
,
container
:
false
,
fallbackPlacement
:
'
flip
'
,
boundary
:
'
scrollParent
'
animation
:
true
,
template
:
'
<div class="tooltip" role="tooltip">
'
+
'
<div class="arrow"></div>
'
+
'
<div class="tooltip-inner"></div></div>
'
,
trigger
:
'
hover focus
'
,
title
:
''
,
delay
:
0
,
html
:
false
,
selector
:
false
,
placement
:
'
top
'
,
offset
:
0
,
container
:
false
,
fallbackPlacement
:
'
flip
'
,
boundary
:
'
scrollParent
'
}
const
HoverState
=
{
...
...
@@ -303,9 +303,7 @@ class Tooltip {
this
.
_handlePopperPlacementChange
(
data
)
}
},
onUpdate
:
(
data
)
=>
{
this
.
_handlePopperPlacementChange
(
data
)
}
onUpdate
:
(
data
)
=>
this
.
_handlePopperPlacementChange
(
data
)
})
$
(
tip
).
addClass
(
ClassName
.
SHOW
)
...
...
@@ -510,19 +508,19 @@ class Tooltip {
_fixTitle
()
{
const
titleType
=
typeof
this
.
element
.
getAttribute
(
'
data-original-title
'
)
if
(
this
.
element
.
getAttribute
(
'
title
'
)
||
titleType
!==
'
string
'
)
{
if
(
this
.
element
.
getAttribute
(
'
title
'
)
||
titleType
!==
'
string
'
)
{
this
.
element
.
setAttribute
(
'
data-original-title
'
,
this
.
element
.
getAttribute
(
'
title
'
)
||
''
)
this
.
element
.
setAttribute
(
'
title
'
,
''
)
}
}
_enter
(
event
,
context
)
{
const
dataKey
=
this
.
constructor
.
DATA_KEY
context
=
context
||
$
(
event
.
currentTarget
).
data
(
dataKey
)
if
(
!
context
)
{
...
...
@@ -539,8 +537,7 @@ class Tooltip {
]
=
true
}
if
(
$
(
context
.
getTipElement
()).
hasClass
(
ClassName
.
SHOW
)
||
context
.
_hoverState
===
HoverState
.
SHOW
)
{
if
(
$
(
context
.
getTipElement
()).
hasClass
(
ClassName
.
SHOW
)
||
context
.
_hoverState
===
HoverState
.
SHOW
)
{
context
.
_hoverState
=
HoverState
.
SHOW
return
}
...
...
@@ -563,7 +560,6 @@ class Tooltip {
_leave
(
event
,
context
)
{
const
dataKey
=
this
.
constructor
.
DATA_KEY
context
=
context
||
$
(
event
.
currentTarget
).
data
(
dataKey
)
if
(
!
context
)
{
...
...
@@ -673,9 +669,11 @@ class Tooltip {
_fixTransition
()
{
const
tip
=
this
.
getTipElement
()
const
initConfigAnimation
=
this
.
config
.
animation
if
(
tip
.
getAttribute
(
'
x-placement
'
)
!==
null
)
{
return
}
$
(
tip
).
removeClass
(
ClassName
.
FADE
)
this
.
config
.
animation
=
false
this
.
hide
()
...
...
This diff is collapsed.
Click to expand it.
js/src/util.js
+
1
-
2
View file @
9201a805
import
$
from
'
jquery
'
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.1.3): util.js
...
...
@@ -7,6 +5,7 @@ import $ from 'jquery'
* --------------------------------------------------------------------------
*/
import
$
from
'
jquery
'
/**
* ------------------------------------------------------------------------
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets