From 35f80bb12e4e71fd777ee60ffa43711d8f84b1a6 Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Thu, 10 Aug 2017 20:56:35 -0700 Subject: bump to beta --- js/src/dropdown.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/src/dropdown.js') diff --git a/js/src/dropdown.js b/js/src/dropdown.js index 234d23447..5e792a527 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -5,7 +5,7 @@ import Util from './util' /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.6): dropdown.js + * Bootstrap (v4.0.0-beta): dropdown.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ @@ -27,7 +27,7 @@ const Dropdown = (($) => { */ const NAME = 'dropdown' - const VERSION = '4.0.0-alpha.6' + const VERSION = '4.0.0-beta' const DATA_KEY = 'bs.dropdown' const EVENT_KEY = `.${DATA_KEY}` const DATA_API_KEY = '.data-api' -- 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/dropdown.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/src/dropdown.js') 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]() -- cgit v1.2.3 From 9936bf59444c402b653f28449529eab83794e911 Mon Sep 17 00:00:00 2001 From: Johann-S Date: Tue, 29 Aug 2017 21:16:00 +0200 Subject: Create a bundled release of Bootstrap with Popper.js inside --- js/src/dropdown.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'js/src/dropdown.js') diff --git a/js/src/dropdown.js b/js/src/dropdown.js index e1c48ac6e..adb54f0f2 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -1,5 +1,5 @@ -/* global Popper */ - +import $ from 'jquery' +import Popper from 'popper.js' import Util from './util' @@ -10,7 +10,7 @@ import Util from './util' * -------------------------------------------------------------------------- */ -const Dropdown = (($) => { +const Dropdown = (() => { /** * Check for Popper dependency @@ -445,6 +445,6 @@ const Dropdown = (($) => { return Dropdown -})(jQuery) +})(jQuery, Popper) export default Dropdown -- cgit v1.2.3 From b822b5a17f87c62000ec3a058e3f2ccca8a10d3e Mon Sep 17 00:00:00 2001 From: Johann-S Date: Thu, 7 Sep 2017 12:47:43 +0200 Subject: Remove placement attribute from our Dropdown plugin --- js/src/dropdown.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'js/src/dropdown.js') diff --git a/js/src/dropdown.js b/js/src/dropdown.js index adb54f0f2..f76f84ef0 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -75,13 +75,11 @@ const Dropdown = (() => { } const Default = { - placement : AttachmentMap.BOTTOM, offset : 0, flip : true } const DefaultType = { - placement : 'string', offset : '(number|string)', flip : 'boolean' } @@ -203,11 +201,6 @@ const Dropdown = (() => { } _getConfig(config) { - const elementData = $(this._element).data() - if (typeof elementData.placement !== 'undefined') { - elementData.placement = AttachmentMap[elementData.placement.toUpperCase()] - } - config = $.extend( {}, this.constructor.Default, @@ -234,10 +227,10 @@ const Dropdown = (() => { _getPlacement() { const $parentDropdown = $(this._element).parent() - let placement = this._config.placement + let placement = AttachmentMap.BOTTOM // Handle dropup - if ($parentDropdown.hasClass(ClassName.DROPUP) || this._config.placement === AttachmentMap.TOP) { + if ($parentDropdown.hasClass(ClassName.DROPUP)) { placement = AttachmentMap.TOP if ($(this._menu).hasClass(ClassName.MENURIGHT)) { placement = AttachmentMap.TOPEND -- cgit v1.2.3 From 527f55c2f3fecfbc1e991263d646a32de4ffcded Mon Sep 17 00:00:00 2001 From: Roman O Date: Tue, 3 Oct 2017 15:34:44 +0300 Subject: Offset option for dropdown can be function (#24222) * Offset option can be function (Popper.js) * Fix...add function type for offset option * Remove constants for popper config * Optimize code. Remove foreach loop. * Refactoring. Remove getOffset method --- js/src/dropdown.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'js/src/dropdown.js') diff --git a/js/src/dropdown.js b/js/src/dropdown.js index f76f84ef0..6681df668 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -80,7 +80,7 @@ const Dropdown = (() => { } const DefaultType = { - offset : '(number|string)', + offset : '(number|string|function)', flip : 'boolean' } @@ -246,12 +246,19 @@ const Dropdown = (() => { } _getPopperConfig() { + const offsetConf = {} + if (typeof this._config.offset === 'function') { + offsetConf.fn = (data) => { + data.offsets = $.extend({}, data.offsets, this._config.offset(data.offsets) || {}) + return data + } + } else { + offsetConf.offset = this._config.offset + } const popperConfig = { placement : this._getPlacement(), modifiers : { - offset : { - offset : this._config.offset - }, + offset : offsetConf, flip : { enabled : this._config.flip } -- cgit v1.2.3 From b29b1e155880ac953899889c9cbb67f7f7df0529 Mon Sep 17 00:00:00 2001 From: Johann-S Date: Tue, 3 Oct 2017 14:27:36 +0200 Subject: Use imported jQuery object --- js/src/dropdown.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/src/dropdown.js') diff --git a/js/src/dropdown.js b/js/src/dropdown.js index 6681df668..3a910996b 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -445,6 +445,6 @@ const Dropdown = (() => { return Dropdown -})(jQuery, Popper) +})($, Popper) export default Dropdown -- cgit v1.2.3