From 58b54b6c15543dce3aca90e202037fa3b194f72e Mon Sep 17 00:00:00 2001 From: Johann-S Date: Thu, 17 Aug 2017 17:44:09 +0200 Subject: Carousel - do not call next when the carousel or the parent isn't visible --- js/src/carousel.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'js/src') diff --git a/js/src/carousel.js b/js/src/carousel.js index a5d5f143a..27a8f7d3b 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -131,7 +131,9 @@ const Carousel = (($) => { nextWhenVisible() { // Don't call next when the page isn't visible - if (!document.hidden) { + // or the carousel or it's parent isn't visible + if (!document.hidden && + ($(this._element).is(':visible') && $(this._element).css('visibility') !== 'hidden')) { this.next() } } -- cgit v1.2.3 From 74d96392d2370c5e0f54380ddb5c7a09d6c13ac7 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Fri, 18 Aug 2017 16:55:59 +0300 Subject: Update devDependencies and fix a typo in comment. (#23534) --- js/src/carousel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/src') diff --git a/js/src/carousel.js b/js/src/carousel.js index 27a8f7d3b..6bcf470f9 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -131,7 +131,7 @@ const Carousel = (($) => { nextWhenVisible() { // Don't call next when the page isn't visible - // or the carousel or it's parent isn't visible + // or the carousel or its parent isn't visible if (!document.hidden && ($(this._element).is(':visible') && $(this._element).css('visibility') !== 'hidden')) { this.next() -- cgit v1.2.3 From ef8c77d8dcebd13559a141e419d003c2d10cc5f3 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Thu, 27 Jul 2017 13:39:55 +0300 Subject: Tweak ESLint rules. --- js/src/carousel.js | 2 +- js/src/collapse.js | 2 +- js/src/dropdown.js | 4 ++-- js/src/modal.js | 2 +- js/src/popover.js | 2 +- js/src/scrollspy.js | 5 +++-- js/src/tab.js | 2 +- js/src/tooltip.js | 2 +- js/src/util.js | 6 +++--- 9 files changed, 14 insertions(+), 13 deletions(-) (limited to 'js/src') diff --git a/js/src/carousel.js b/js/src/carousel.js index 6bcf470f9..873660519 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -443,7 +443,7 @@ const Carousel = (($) => { if (typeof config === 'number') { data.to(config) } else if (typeof action === 'string') { - if (data[action] === undefined) { + if (typeof data[action] === 'undefined') { throw new Error(`No method named "${action}"`) } data[action]() diff --git a/js/src/collapse.js b/js/src/collapse.js index 2f00b98cb..718630bd3 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -343,7 +343,7 @@ const Collapse = (($) => { } if (typeof config === 'string') { - if (data[config] === undefined) { + if (typeof data[config] === 'undefined') { throw new Error(`No method named "${config}"`) } data[config]() diff --git a/js/src/dropdown.js b/js/src/dropdown.js index 5e792a527..e1c48ac6e 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -204,7 +204,7 @@ const Dropdown = (($) => { _getConfig(config) { const elementData = $(this._element).data() - if (elementData.placement !== undefined) { + if (typeof elementData.placement !== 'undefined') { elementData.placement = AttachmentMap[elementData.placement.toUpperCase()] } @@ -287,7 +287,7 @@ const Dropdown = (($) => { } if (typeof config === 'string') { - if (data[config] === undefined) { + if (typeof data[config] === 'undefined') { throw new Error(`No method named "${config}"`) } data[config]() diff --git a/js/src/modal.js b/js/src/modal.js index 9f17fafc8..d21a137fb 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -507,7 +507,7 @@ const Modal = (($) => { } if (typeof config === 'string') { - if (data[config] === undefined) { + if (typeof data[config] === 'undefined') { throw new Error(`No method named "${config}"`) } data[config](relatedTarget) diff --git a/js/src/popover.js b/js/src/popover.js index 0e8953f77..7639e3e20 100644 --- a/js/src/popover.js +++ b/js/src/popover.js @@ -162,7 +162,7 @@ const Popover = (($) => { } if (typeof config === 'string') { - if (data[config] === undefined) { + if (typeof data[config] === 'undefined') { throw new Error(`No method named "${config}"`) } data[config]() diff --git a/js/src/scrollspy.js b/js/src/scrollspy.js index b70b7e477..588f65298 100644 --- a/js/src/scrollspy.js +++ b/js/src/scrollspy.js @@ -231,7 +231,7 @@ const ScrollSpy = (($) => { for (let i = this._offsets.length; i--;) { const isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] - && (this._offsets[i + 1] === undefined || + && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]) if (isActiveTarget) { @@ -246,6 +246,7 @@ const 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}"]` @@ -287,7 +288,7 @@ const ScrollSpy = (($) => { } if (typeof config === 'string') { - if (data[config] === undefined) { + if (typeof data[config] === 'undefined') { throw new Error(`No method named "${config}"`) } data[config]() diff --git a/js/src/tab.js b/js/src/tab.js index 4c3091495..c32cd3776 100644 --- a/js/src/tab.js +++ b/js/src/tab.js @@ -238,7 +238,7 @@ const Tab = (($) => { } if (typeof config === 'string') { - if (data[config] === undefined) { + if (typeof data[config] === 'undefined') { throw new Error(`No method named "${config}"`) } data[config]() diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 2060cebbb..721f04481 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -698,7 +698,7 @@ const Tooltip = (($) => { } if (typeof config === 'string') { - if (data[config] === undefined) { + if (typeof data[config] === 'undefined') { throw new Error(`No method named "${config}"`) } data[config]() diff --git a/js/src/util.js b/js/src/util.js index 387c7d2ed..69fb8283c 100644 --- a/js/src/util.js +++ b/js/src/util.js @@ -42,7 +42,7 @@ const Util = (($) => { if ($(event.target).is(this)) { return event.handleObj.handler.apply(this, arguments) // eslint-disable-line prefer-rest-params } - return undefined + return undefined // eslint-disable-line no-undefined } } } @@ -55,7 +55,7 @@ const Util = (($) => { const el = document.createElement('bootstrap') for (const name in TransitionEndEvent) { - if (el.style[name] !== undefined) { + if (typeof el.style[name] !== 'undefined') { return { end: TransitionEndEvent[name] } @@ -138,7 +138,7 @@ const Util = (($) => { typeCheckConfig(componentName, config, configTypes) { for (const property in configTypes) { - if (configTypes.hasOwnProperty(property)) { + if (Object.prototype.hasOwnProperty.call(configTypes, property)) { const expectedTypes = configTypes[property] const value = config[property] const valueType = value && isElement(value) ? -- cgit v1.2.3 From 6063b0dc659e7ba3a83cfc9502ad7872f8201a32 Mon Sep 17 00:00:00 2001 From: Johann-S Date: Thu, 27 Jul 2017 12:58:22 +0200 Subject: Enable the `no-return-assign` rule. --- js/src/popover.js | 3 ++- js/src/tooltip.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'js/src') diff --git a/js/src/popover.js b/js/src/popover.js index 7639e3e20..f5820ecbe 100644 --- a/js/src/popover.js +++ b/js/src/popover.js @@ -114,7 +114,8 @@ const Popover = (($) => { } getTipElement() { - return this.tip = this.tip || $(this.config.template)[0] + this.tip = this.tip || $(this.config.template)[0] + return this.tip } setContent() { diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 721f04481..7dfe9dfc0 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -415,7 +415,8 @@ const Tooltip = (($) => { } getTipElement() { - return this.tip = this.tip || $(this.config.template)[0] + this.tip = this.tip || $(this.config.template)[0] + return this.tip } setContent() { -- cgit v1.2.3 From 4571ab0e57a5d2ff251b8c174ab0f693c5892dce Mon Sep 17 00:00:00 2001 From: Johann-S Date: Thu, 24 Aug 2017 09:40:11 +0200 Subject: Fix toggle for Tooltips/Popover which was called even if the Tooltip/Popover was disabled --- js/src/tooltip.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'js/src') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 7dfe9dfc0..37573cf49 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -184,6 +184,10 @@ const Tooltip = (($) => { } toggle(event) { + if (!this._isEnabled) { + return + } + if (event) { const dataKey = this.constructor.DATA_KEY let context = $(event.currentTarget).data(dataKey) @@ -234,8 +238,8 @@ const Tooltip = (($) => { if (this._popper !== null) { this._popper.destroy() } - this._popper = null + this._popper = null this.element = null this.config = null this.tip = null @@ -706,7 +710,6 @@ const Tooltip = (($) => { } }) } - } -- cgit v1.2.3 From 5a90b4aa3e102e387839a39fbf0ab1444eebbc76 Mon Sep 17 00:00:00 2001 From: Johann-S Date: Fri, 25 Aug 2017 10:14:18 +0200 Subject: Collapse - preventDefault only on elements not inside the collapsible element --- js/src/collapse.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'js/src') diff --git a/js/src/collapse.js b/js/src/collapse.js index 718630bd3..7d1ba4c54 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -361,7 +361,8 @@ const Collapse = (($) => { */ $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { - if (!/input|textarea/i.test(event.target.tagName)) { + // preventDefault only for elements (which change the URL) not inside the collapsible element + if (event.target.tagName === 'A' && !$.contains(this, event.target)) { event.preventDefault() } -- cgit v1.2.3 From ba6a6f13691000ffaf22ef8e731513737659447f Mon Sep 17 00:00:00 2001 From: David Bailey Date: Fri, 25 Aug 2017 22:01:41 +0100 Subject: Fix sticky margin when a modal is opened (#23669) * Adjust margin for sticky elements on modal Previously white space was visible to the right of sticky elements due to right padding being added to the body. This fixes #23661. * Add unit tests for margin of sticky elements on modal --- js/src/modal.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'js/src') diff --git a/js/src/modal.js b/js/src/modal.js index d21a137fb..ab73230c8 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -68,6 +68,7 @@ const Modal = (($) => { DATA_TOGGLE : '[data-toggle="modal"]', DATA_DISMISS : '[data-dismiss="modal"]', FIXED_CONTENT : '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top', + STICKY_CONTENT : '.sticky-top', NAVBAR_TOGGLER : '.navbar-toggler' } @@ -441,6 +442,13 @@ const Modal = (($) => { $(element).data('padding-right', actualPadding).css('padding-right', `${parseFloat(calculatedPadding) + this._scrollbarWidth}px`) }) + // Adjust sticky content margin + $(Selector.STICKY_CONTENT).each((index, element) => { + const actualMargin = $(element)[0].style.marginRight + const calculatedMargin = $(element).css('margin-right') + $(element).data('margin-right', actualMargin).css('margin-right', `${parseFloat(calculatedMargin) - this._scrollbarWidth}px`) + }) + // Adjust navbar-toggler margin $(Selector.NAVBAR_TOGGLER).each((index, element) => { const actualMargin = $(element)[0].style.marginRight @@ -464,8 +472,8 @@ const Modal = (($) => { } }) - // Restore navbar-toggler margin - $(Selector.NAVBAR_TOGGLER).each((index, element) => { + // Restore sticky content and navbar-toggler margin + $(`${Selector.STICKY_CONTENT}, ${Selector.NAVBAR_TOGGLER}`).each((index, element) => { const margin = $(element).data('margin-right') if (typeof margin !== 'undefined') { $(element).css('margin-right', margin).removeData('margin-right') -- cgit v1.2.3