Skip to content

Commit

Permalink
Merge branch 'main' into main-lmp-list-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-deramond authored May 31, 2022
2 parents 7d3d243 + f66fec2 commit 55cedc6
Show file tree
Hide file tree
Showing 117 changed files with 4,292 additions and 2,420 deletions.
8 changes: 4 additions & 4 deletions .bundlewatch.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
},
{
"path": "./dist/css/boosted.css",
"maxSize": "34.5 kB"
"maxSize": "35.75 kB"
},
{
"path": "./dist/css/boosted.min.css",
"maxSize": "31.75 kB"
"maxSize": "32.75 kB"
},
{
"path": "./dist/js/boosted.bundle.js",
Expand All @@ -42,7 +42,7 @@
},
{
"path": "./dist/js/boosted.esm.js",
"maxSize": "32.5 kB"
"maxSize": "32.75 kB"
},
{
"path": "./dist/js/boosted.esm.min.js",
Expand All @@ -54,7 +54,7 @@
},
{
"path": "./dist/js/boosted.min.js",
"maxSize": "17.5 kB"
"maxSize": "17.75 kB"
}
],
"ci": {
Expand Down
2 changes: 2 additions & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"btnradio",
"callout",
"callouts",
"camelCase",
"clearfix",
"clic",
"Codesniffer",
Expand Down Expand Up @@ -69,6 +70,7 @@
"markdownify",
"mediaqueries",
"minifiers",
"misfunction",
"monospace",
"mouseleave",
"navbars",
Expand Down
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.

## Our Standards

Expand Down
72 changes: 35 additions & 37 deletions js/src/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,19 @@ const KEY_TO_DIRECTION = {
const Default = {
interval: 5000,
keyboard: true,
slide: false,
pause: 'hover',
wrap: true,
touch: true
ride: false,
touch: true,
wrap: true
}

const DefaultType = {
interval: '(number|boolean)',
keyboard: 'boolean',
slide: '(boolean|string)',
ride: '(boolean|string)',
pause: '(string|boolean)',
wrap: 'boolean',
touch: 'boolean'
touch: 'boolean',
wrap: 'boolean'
}

/**
Expand All @@ -108,7 +108,6 @@ class Carousel extends BaseComponent {

this._interval = null
this._activeElement = null
this._stayPaused = false
this._isSliding = false
this.touchTimeout = null
this._swipeHelper = null
Expand All @@ -118,6 +117,10 @@ class Carousel extends BaseComponent {
this._playPauseButton = SelectorEngine.findOne(`${SELECTOR_CONTROL_PAUSE}[${SELECTOR_CAROUSEL_TO_PAUSE}="#${this._element.id}"]`) // Boosted mod

this._addEventListeners()

if (this._config.ride === CLASS_NAME_CAROUSEL) {
this.cycle()
}
}

// Getters
Expand Down Expand Up @@ -151,7 +154,7 @@ class Carousel extends BaseComponent {
this._slide(ORDER_PREV)
}

pause(event) {
pause() {
// Boosted mod: reset the animation on progress indicator
if (this._indicatorsElement) {
this._element.classList.add(CLASS_NAME_PAUSED)
Expand All @@ -168,19 +171,14 @@ class Carousel extends BaseComponent {
}
// End mod

if (!event) {
this._stayPaused = true
}

if (this._isSliding) {
triggerTransitionEnd(this._element)
this.cycle(true)
}

this._clearInterval()
}

cycle(event) {
cycle() {
// Boosted mod: restart the animation on progress indicator
if (this._indicatorsElement) {
this._element.classList.remove(CLASS_NAME_PAUSED)
Expand All @@ -197,16 +195,23 @@ class Carousel extends BaseComponent {
}
// End mod

if (!event) {
this._stayPaused = false
}

this._clearInterval()
if (this._config.interval && !this._stayPaused) {
this._updateInterval()
this._updateInterval()

this._interval = setInterval(() => this.nextWhenVisible(), this._config.interval)
}

this._interval = setInterval(() => this.nextWhenVisible(), this._config.interval)
_maybeEnableCycle() {
if (!this._config.ride) {
return
}

if (this._isSliding) {
EventHandler.one(this._element, EVENT_SLID, () => this.cycle())
return
}

this.cycle()
}

to(index) {
Expand All @@ -228,8 +233,6 @@ class Carousel extends BaseComponent {

const activeIndex = this._getItemIndex(this._getActive())
if (activeIndex === index) {
this.pause()
this.cycle()
return
}

Expand Down Expand Up @@ -258,8 +261,8 @@ class Carousel extends BaseComponent {
}

if (this._config.pause === 'hover') {
EventHandler.on(this._element, EVENT_MOUSEENTER, event => this.pause(event))
EventHandler.on(this._element, EVENT_MOUSELEAVE, event => this.cycle(event))
EventHandler.on(this._element, EVENT_MOUSEENTER, () => this.pause())
EventHandler.on(this._element, EVENT_MOUSELEAVE, () => this._maybeEnableCycle())
}

if (this._config.touch && Swipe.isSupported()) {
Expand Down Expand Up @@ -290,7 +293,7 @@ class Carousel extends BaseComponent {
clearTimeout(this.touchTimeout)
}

this.touchTimeout = setTimeout(event => this.cycle(event), TOUCHEVENT_COMPAT_WAIT + this._config.interval)
this.touchTimeout = setTimeout(() => this._maybeEnableCycle(), TOUCHEVENT_COMPAT_WAIT + this._config.interval)
}

const swipeConfig = {
Expand Down Expand Up @@ -436,12 +439,10 @@ class Carousel extends BaseComponent {
return
}

this._isSliding = true

const isCycling = Boolean(this._interval)
if (isCycling) {
this.pause()
}
this.pause()

this._isSliding = true

this._setActiveIndicatorElement(nextElementIndex)
this._activeElement = nextElement
Expand Down Expand Up @@ -554,12 +555,6 @@ class Carousel extends BaseComponent {
}

data[config]()
return
}

if (data._config.interval && data._config.ride) {
data.pause()
data.cycle()
}
})
}
Expand All @@ -583,15 +578,18 @@ EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_SLIDE, function (e

if (slideIndex) {
carousel.to(slideIndex)
carousel._maybeEnableCycle()
return
}

if (Manipulator.getDataAttribute(this, 'slide') === 'next') {
carousel.next()
carousel._maybeEnableCycle()
return
}

carousel.prev()
carousel._maybeEnableCycle()
})

EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_CONTROL_PAUSE, Carousel.PauseCarousel) // Boosted mod
Expand Down
4 changes: 2 additions & 2 deletions js/src/dom/event-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const customEvents = {
mouseenter: 'mouseover',
mouseleave: 'mouseout'
}
const customEventsRegex = /^(mouseenter|mouseleave)/i

const nativeEvents = new Set([
'click',
'dblclick',
Expand Down Expand Up @@ -150,7 +150,7 @@ function addHandler(element, originalTypeEvent, handler, delegationFunction, one

// in case of mouseenter or mouseleave wrap the handler within a function that checks for its DOM position
// this prevents the handler from being dispatched the same way as mouseover or mouseout does
if (customEventsRegex.test(originalTypeEvent)) {
if (originalTypeEvent in customEvents) {
const wrapFunction = fn => {
return function (event) {
if (!event.relatedTarget || (event.relatedTarget !== event.delegateTarget && !event.delegateTarget.contains(event.relatedTarget))) {
Expand Down
12 changes: 10 additions & 2 deletions js/src/dom/manipulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,15 @@ function normalizeData(value) {
return null
}

return value
if (typeof value !== 'string') {
return value
}

try {
return JSON.parse(decodeURIComponent(value))
} catch {
return value
}
}

function normalizeDataKey(key) {
Expand All @@ -44,7 +52,7 @@ const Manipulator = {
}

const attributes = {}
const bsKeys = Object.keys(element.dataset).filter(key => key.startsWith('bs'))
const bsKeys = Object.keys(element.dataset).filter(key => key.startsWith('bs') && !key.startsWith('bsConfig'))

for (const key of bsKeys) {
let pureKey = key.replace(/^bs/, '')
Expand Down
9 changes: 9 additions & 0 deletions js/src/offcanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const EVENT_SHOWN = `shown${EVENT_KEY}`
const EVENT_HIDE = `hide${EVENT_KEY}`
const EVENT_HIDE_PREVENTED = `hidePrevented${EVENT_KEY}`
const EVENT_HIDDEN = `hidden${EVENT_KEY}`
const EVENT_RESIZE = `resize${EVENT_KEY}`
const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`
const EVENT_KEYDOWN_DISMISS = `keydown.dismiss${EVENT_KEY}`

Expand Down Expand Up @@ -263,6 +264,14 @@ EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
}
})

EventHandler.on(window, EVENT_RESIZE, () => {
for (const element of SelectorEngine.find('[aria-modal][class*=show][class*=offcanvas-]')) {
if (getComputedStyle(element).position !== 'fixed') {
Offcanvas.getOrCreateInstance(element).hide()
}
}
})

enableDismissTrigger(Offcanvas)

/**
Expand Down
7 changes: 5 additions & 2 deletions js/src/tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,11 @@ class Tab extends BaseComponent {
event.stopPropagation()// stopPropagation/preventDefault both added to support up/down keys without scrolling the page
event.preventDefault()
const isNext = [ARROW_RIGHT_KEY, ARROW_DOWN_KEY].includes(event.key)
const nextActiveElement = getNextActiveElement(this._getChildren(), event.target, isNext, true)
Tab.getOrCreateInstance(nextActiveElement).show()
const nextActiveElement = getNextActiveElement(this._getChildren().filter(element => !isDisabled(element)), event.target, isNext, true)

if (nextActiveElement) {
Tab.getOrCreateInstance(nextActiveElement).show()
}
}

_getChildren() { // collection of inner elements
Expand Down
8 changes: 6 additions & 2 deletions js/src/toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class Toast extends BaseComponent {
}

hide() {
if (!this._element.classList.contains(CLASS_NAME_SHOW)) {
if (!this.isShown()) {
return
}

Expand All @@ -123,13 +123,17 @@ class Toast extends BaseComponent {
dispose() {
this._clearTimeout()

if (this._element.classList.contains(CLASS_NAME_SHOW)) {
if (this.isShown()) {
this._element.classList.remove(CLASS_NAME_SHOW)
}

super.dispose()
}

isShown() {
return this._element.classList.contains(CLASS_NAME_SHOW)
}

// Private

_maybeScheduleHide() {
Expand Down
3 changes: 3 additions & 0 deletions js/src/util/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ class Config {
}

_mergeConfigObj(config, element) {
const jsonConfig = isElement(element) ? Manipulator.getDataAttribute(element, 'config') : {} // try to parse

return {
...this.constructor.Default,
...(typeof jsonConfig === 'object' ? jsonConfig : {}),
...(isElement(element) ? Manipulator.getDataAttributes(element) : {}),
...(typeof config === 'object' ? config : {})
}
Expand Down
Loading

0 comments on commit 55cedc6

Please sign in to comment.