bootstrap 4.0.0.beta → 4.0.0.beta2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of bootstrap might be problematic. Click here for more details.

Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/Gemfile +1 -1
  4. data/README.md +10 -43
  5. data/Rakefile +1 -1
  6. data/assets/javascripts/bootstrap-sprockets.js +5 -5
  7. data/assets/javascripts/bootstrap.js +1561 -1542
  8. data/assets/javascripts/bootstrap.min.js +6 -5
  9. data/assets/javascripts/bootstrap/alert.js +31 -38
  10. data/assets/javascripts/bootstrap/button.js +23 -30
  11. data/assets/javascripts/bootstrap/carousel.js +72 -81
  12. data/assets/javascripts/bootstrap/collapse.js +72 -68
  13. data/assets/javascripts/bootstrap/dropdown.js +97 -85
  14. data/assets/javascripts/bootstrap/modal.js +104 -101
  15. data/assets/javascripts/bootstrap/popover.js +55 -68
  16. data/assets/javascripts/bootstrap/scrollspy.js +63 -68
  17. data/assets/javascripts/bootstrap/tab.js +54 -49
  18. data/assets/javascripts/bootstrap/tooltip.js +102 -116
  19. data/assets/javascripts/bootstrap/util.js +20 -30
  20. data/assets/stylesheets/_bootstrap-grid.scss +7 -9
  21. data/assets/stylesheets/_bootstrap-reboot.scss +7 -4
  22. data/assets/stylesheets/_bootstrap.scss +2 -1
  23. data/assets/stylesheets/bootstrap/_alert.scss +4 -3
  24. data/assets/stylesheets/bootstrap/_badge.scss +1 -2
  25. data/assets/stylesheets/bootstrap/_breadcrumb.scss +4 -4
  26. data/assets/stylesheets/bootstrap/_button-group.scss +33 -24
  27. data/assets/stylesheets/bootstrap/_buttons.scss +24 -29
  28. data/assets/stylesheets/bootstrap/_card.scss +58 -22
  29. data/assets/stylesheets/bootstrap/_carousel.scss +6 -0
  30. data/assets/stylesheets/bootstrap/_close.scss +2 -2
  31. data/assets/stylesheets/bootstrap/_custom-forms.scss +11 -8
  32. data/assets/stylesheets/bootstrap/_dropdown.scss +16 -41
  33. data/assets/stylesheets/bootstrap/_forms.scss +12 -44
  34. data/assets/stylesheets/bootstrap/_functions.scss +6 -10
  35. data/assets/stylesheets/bootstrap/_grid.scss +0 -1
  36. data/assets/stylesheets/bootstrap/_input-group.scss +17 -7
  37. data/assets/stylesheets/bootstrap/_mixins.scss +1 -0
  38. data/assets/stylesheets/bootstrap/_modal.scss +12 -1
  39. data/assets/stylesheets/bootstrap/_nav.scss +5 -5
  40. data/assets/stylesheets/bootstrap/_navbar.scss +27 -5
  41. data/assets/stylesheets/bootstrap/_pagination.scss +2 -4
  42. data/assets/stylesheets/bootstrap/_popover.scss +16 -17
  43. data/assets/stylesheets/bootstrap/_print.scss +2 -3
  44. data/assets/stylesheets/bootstrap/_progress.scss +4 -6
  45. data/assets/stylesheets/bootstrap/_reboot.scss +39 -16
  46. data/assets/stylesheets/bootstrap/_root.scss +19 -0
  47. data/assets/stylesheets/bootstrap/_tables.scss +40 -28
  48. data/assets/stylesheets/bootstrap/_tooltip.scss +6 -6
  49. data/assets/stylesheets/bootstrap/_transitions.scss +2 -0
  50. data/assets/stylesheets/bootstrap/_type.scss +2 -0
  51. data/assets/stylesheets/bootstrap/_variables.scss +467 -476
  52. data/assets/stylesheets/bootstrap/mixins/_alert.scss +1 -1
  53. data/assets/stylesheets/bootstrap/mixins/_background-variant.scss +8 -0
  54. data/assets/stylesheets/bootstrap/mixins/_badge.scss +2 -2
  55. data/assets/stylesheets/bootstrap/mixins/_breakpoints.scss +18 -4
  56. data/assets/stylesheets/bootstrap/mixins/_buttons.scss +27 -16
  57. data/assets/stylesheets/bootstrap/mixins/_caret.scss +35 -0
  58. data/assets/stylesheets/bootstrap/mixins/_float.scss +2 -0
  59. data/assets/stylesheets/bootstrap/mixins/_forms.scss +31 -4
  60. data/assets/stylesheets/bootstrap/mixins/_gradients.scss +8 -0
  61. data/assets/stylesheets/bootstrap/mixins/_grid-framework.scss +14 -1
  62. data/assets/stylesheets/bootstrap/mixins/_grid.scss +10 -5
  63. data/assets/stylesheets/bootstrap/mixins/_hover.scss +13 -12
  64. data/assets/stylesheets/bootstrap/mixins/_image.scss +3 -3
  65. data/assets/stylesheets/bootstrap/mixins/_list-group.scss +0 -2
  66. data/assets/stylesheets/bootstrap/mixins/_navbar-align.scss +2 -1
  67. data/assets/stylesheets/bootstrap/mixins/_reset-text.scss +1 -2
  68. data/assets/stylesheets/bootstrap/mixins/_screen-reader.scss +2 -2
  69. data/assets/stylesheets/bootstrap/mixins/_text-emphasis.scss +2 -0
  70. data/assets/stylesheets/bootstrap/mixins/_visibility.scss +2 -0
  71. data/assets/stylesheets/bootstrap/utilities/_align.scss +2 -0
  72. data/assets/stylesheets/bootstrap/utilities/_background.scss +16 -3
  73. data/assets/stylesheets/bootstrap/utilities/_borders.scss +5 -3
  74. data/assets/stylesheets/bootstrap/utilities/_display.scss +3 -0
  75. data/assets/stylesheets/bootstrap/utilities/_flex.scss +2 -0
  76. data/assets/stylesheets/bootstrap/utilities/_position.scss +12 -1
  77. data/assets/stylesheets/bootstrap/utilities/_sizing.scss +2 -0
  78. data/assets/stylesheets/bootstrap/utilities/_spacing.scss +24 -14
  79. data/assets/stylesheets/bootstrap/utilities/_text.scss +7 -4
  80. data/bootstrap.gemspec +2 -3
  81. data/lib/bootstrap.rb +0 -16
  82. data/lib/bootstrap/version.rb +2 -2
  83. data/tasks/updater/js.rb +31 -4
  84. data/tasks/updater/scss.rb +0 -12
  85. data/test/dummy_rails/config/application.rb +0 -1
  86. metadata +16 -27
  87. data/templates/project/_bootstrap-variables.scss +0 -834
  88. data/templates/project/manifest.rb +0 -18
  89. data/templates/project/styles.scss +0 -10
  90. data/test/compass_test.rb +0 -14
@@ -1,66 +1,54 @@
1
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
1
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
2
2
 
3
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
4
-
5
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
6
4
 
7
5
  /**
8
6
  * --------------------------------------------------------------------------
9
- * Bootstrap (v4.0.0-beta): collapse.js
7
+ * Bootstrap (v4.0.0-beta.2): collapse.js
10
8
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
11
9
  * --------------------------------------------------------------------------
12
10
  */
13
-
14
- var Collapse = function ($) {
15
-
11
+ var Collapse = function () {
16
12
  /**
17
13
  * ------------------------------------------------------------------------
18
14
  * Constants
19
15
  * ------------------------------------------------------------------------
20
16
  */
21
-
22
17
  var NAME = 'collapse';
23
- var VERSION = '4.0.0-beta';
18
+ var VERSION = '4.0.0-beta.2';
24
19
  var DATA_KEY = 'bs.collapse';
25
- var EVENT_KEY = '.' + DATA_KEY;
20
+ var EVENT_KEY = "." + DATA_KEY;
26
21
  var DATA_API_KEY = '.data-api';
27
22
  var JQUERY_NO_CONFLICT = $.fn[NAME];
28
23
  var TRANSITION_DURATION = 600;
29
-
30
24
  var Default = {
31
25
  toggle: true,
32
26
  parent: ''
33
27
  };
34
-
35
28
  var DefaultType = {
36
29
  toggle: 'boolean',
37
- parent: 'string'
30
+ parent: '(string|element)'
38
31
  };
39
-
40
32
  var Event = {
41
- SHOW: 'show' + EVENT_KEY,
42
- SHOWN: 'shown' + EVENT_KEY,
43
- HIDE: 'hide' + EVENT_KEY,
44
- HIDDEN: 'hidden' + EVENT_KEY,
45
- CLICK_DATA_API: 'click' + EVENT_KEY + DATA_API_KEY
33
+ SHOW: "show" + EVENT_KEY,
34
+ SHOWN: "shown" + EVENT_KEY,
35
+ HIDE: "hide" + EVENT_KEY,
36
+ HIDDEN: "hidden" + EVENT_KEY,
37
+ CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
46
38
  };
47
-
48
39
  var ClassName = {
49
40
  SHOW: 'show',
50
41
  COLLAPSE: 'collapse',
51
42
  COLLAPSING: 'collapsing',
52
43
  COLLAPSED: 'collapsed'
53
44
  };
54
-
55
45
  var Dimension = {
56
46
  WIDTH: 'width',
57
47
  HEIGHT: 'height'
58
48
  };
59
-
60
49
  var Selector = {
61
50
  ACTIVES: '.show, .collapsing',
62
51
  DATA_TOGGLE: '[data-toggle="collapse"]'
63
-
64
52
  /**
65
53
  * ------------------------------------------------------------------------
66
54
  * Class Definition
@@ -68,18 +56,21 @@ var Collapse = function ($) {
68
56
  */
69
57
 
70
58
  };
71
- var Collapse = function () {
72
- function Collapse(element, config) {
73
- _classCallCheck(this, Collapse);
74
59
 
60
+ var Collapse =
61
+ /*#__PURE__*/
62
+ function () {
63
+ function Collapse(element, config) {
75
64
  this._isTransitioning = false;
76
65
  this._element = element;
77
66
  this._config = this._getConfig(config);
78
- this._triggerArray = $.makeArray($('[data-toggle="collapse"][href="#' + element.id + '"],' + ('[data-toggle="collapse"][data-target="#' + element.id + '"]')));
67
+ this._triggerArray = $.makeArray($("[data-toggle=\"collapse\"][href=\"#" + element.id + "\"]," + ("[data-toggle=\"collapse\"][data-target=\"#" + element.id + "\"]")));
79
68
  var tabToggles = $(Selector.DATA_TOGGLE);
69
+
80
70
  for (var i = 0; i < tabToggles.length; i++) {
81
71
  var elem = tabToggles[i];
82
72
  var selector = Util.getSelectorFromElement(elem);
73
+
83
74
  if (selector !== null && $(selector).filter(element).length > 0) {
84
75
  this._triggerArray.push(elem);
85
76
  }
@@ -94,13 +85,13 @@ var Collapse = function ($) {
94
85
  if (this._config.toggle) {
95
86
  this.toggle();
96
87
  }
97
- }
88
+ } // getters
98
89
 
99
- // getters
100
90
 
101
- // public
91
+ var _proto = Collapse.prototype;
102
92
 
103
- Collapse.prototype.toggle = function toggle() {
93
+ // public
94
+ _proto.toggle = function toggle() {
104
95
  if ($(this._element).hasClass(ClassName.SHOW)) {
105
96
  this.hide();
106
97
  } else {
@@ -108,18 +99,19 @@ var Collapse = function ($) {
108
99
  }
109
100
  };
110
101
 
111
- Collapse.prototype.show = function show() {
102
+ _proto.show = function show() {
112
103
  var _this = this;
113
104
 
114
105
  if (this._isTransitioning || $(this._element).hasClass(ClassName.SHOW)) {
115
106
  return;
116
107
  }
117
108
 
118
- var actives = void 0;
119
- var activesData = void 0;
109
+ var actives;
110
+ var activesData;
120
111
 
121
112
  if (this._parent) {
122
113
  actives = $.makeArray($(this._parent).children().children(Selector.ACTIVES));
114
+
123
115
  if (!actives.length) {
124
116
  actives = null;
125
117
  }
@@ -127,6 +119,7 @@ var Collapse = function ($) {
127
119
 
128
120
  if (actives) {
129
121
  activesData = $(actives).data(DATA_KEY);
122
+
130
123
  if (activesData && activesData._isTransitioning) {
131
124
  return;
132
125
  }
@@ -134,12 +127,14 @@ var Collapse = function ($) {
134
127
 
135
128
  var startEvent = $.Event(Event.SHOW);
136
129
  $(this._element).trigger(startEvent);
130
+
137
131
  if (startEvent.isDefaultPrevented()) {
138
132
  return;
139
133
  }
140
134
 
141
135
  if (actives) {
142
136
  Collapse._jQueryInterface.call($(actives), 'hide');
137
+
143
138
  if (!activesData) {
144
139
  $(actives).data(DATA_KEY, null);
145
140
  }
@@ -148,7 +143,6 @@ var Collapse = function ($) {
148
143
  var dimension = this._getDimension();
149
144
 
150
145
  $(this._element).removeClass(ClassName.COLLAPSE).addClass(ClassName.COLLAPSING);
151
-
152
146
  this._element.style[dimension] = 0;
153
147
 
154
148
  if (this._triggerArray.length) {
@@ -159,7 +153,6 @@ var Collapse = function ($) {
159
153
 
160
154
  var complete = function complete() {
161
155
  $(_this._element).removeClass(ClassName.COLLAPSING).addClass(ClassName.COLLAPSE).addClass(ClassName.SHOW);
162
-
163
156
  _this._element.style[dimension] = '';
164
157
 
165
158
  _this.setTransitioning(false);
@@ -173,14 +166,12 @@ var Collapse = function ($) {
173
166
  }
174
167
 
175
168
  var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
176
- var scrollSize = 'scroll' + capitalizedDimension;
177
-
169
+ var scrollSize = "scroll" + capitalizedDimension;
178
170
  $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION);
179
-
180
- this._element.style[dimension] = this._element[scrollSize] + 'px';
171
+ this._element.style[dimension] = this._element[scrollSize] + "px";
181
172
  };
182
173
 
183
- Collapse.prototype.hide = function hide() {
174
+ _proto.hide = function hide() {
184
175
  var _this2 = this;
185
176
 
186
177
  if (this._isTransitioning || !$(this._element).hasClass(ClassName.SHOW)) {
@@ -189,24 +180,25 @@ var Collapse = function ($) {
189
180
 
190
181
  var startEvent = $.Event(Event.HIDE);
191
182
  $(this._element).trigger(startEvent);
183
+
192
184
  if (startEvent.isDefaultPrevented()) {
193
185
  return;
194
186
  }
195
187
 
196
188
  var dimension = this._getDimension();
197
189
 
198
- this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + 'px';
199
-
190
+ this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px";
200
191
  Util.reflow(this._element);
201
-
202
192
  $(this._element).addClass(ClassName.COLLAPSING).removeClass(ClassName.COLLAPSE).removeClass(ClassName.SHOW);
203
193
 
204
194
  if (this._triggerArray.length) {
205
195
  for (var i = 0; i < this._triggerArray.length; i++) {
206
196
  var trigger = this._triggerArray[i];
207
197
  var selector = Util.getSelectorFromElement(trigger);
198
+
208
199
  if (selector !== null) {
209
200
  var $elem = $(selector);
201
+
210
202
  if (!$elem.hasClass(ClassName.SHOW)) {
211
203
  $(trigger).addClass(ClassName.COLLAPSED).attr('aria-expanded', false);
212
204
  }
@@ -218,6 +210,7 @@ var Collapse = function ($) {
218
210
 
219
211
  var complete = function complete() {
220
212
  _this2.setTransitioning(false);
213
+
221
214
  $(_this2._element).removeClass(ClassName.COLLAPSING).addClass(ClassName.COLLAPSE).trigger(Event.HIDDEN);
222
215
  };
223
216
 
@@ -231,48 +224,56 @@ var Collapse = function ($) {
231
224
  $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION);
232
225
  };
233
226
 
234
- Collapse.prototype.setTransitioning = function setTransitioning(isTransitioning) {
227
+ _proto.setTransitioning = function setTransitioning(isTransitioning) {
235
228
  this._isTransitioning = isTransitioning;
236
229
  };
237
230
 
238
- Collapse.prototype.dispose = function dispose() {
231
+ _proto.dispose = function dispose() {
239
232
  $.removeData(this._element, DATA_KEY);
240
-
241
233
  this._config = null;
242
234
  this._parent = null;
243
235
  this._element = null;
244
236
  this._triggerArray = null;
245
237
  this._isTransitioning = null;
246
- };
238
+ }; // private
247
239
 
248
- // private
249
240
 
250
- Collapse.prototype._getConfig = function _getConfig(config) {
241
+ _proto._getConfig = function _getConfig(config) {
251
242
  config = $.extend({}, Default, config);
252
243
  config.toggle = Boolean(config.toggle); // coerce string values
244
+
253
245
  Util.typeCheckConfig(NAME, config, DefaultType);
254
246
  return config;
255
247
  };
256
248
 
257
- Collapse.prototype._getDimension = function _getDimension() {
249
+ _proto._getDimension = function _getDimension() {
258
250
  var hasWidth = $(this._element).hasClass(Dimension.WIDTH);
259
251
  return hasWidth ? Dimension.WIDTH : Dimension.HEIGHT;
260
252
  };
261
253
 
262
- Collapse.prototype._getParent = function _getParent() {
254
+ _proto._getParent = function _getParent() {
263
255
  var _this3 = this;
264
256
 
265
- var parent = $(this._config.parent)[0];
266
- var selector = '[data-toggle="collapse"][data-parent="' + this._config.parent + '"]';
257
+ var parent = null;
258
+
259
+ if (Util.isElement(this._config.parent)) {
260
+ parent = this._config.parent; // it's a jQuery object
261
+
262
+ if (typeof this._config.parent.jquery !== 'undefined') {
263
+ parent = this._config.parent[0];
264
+ }
265
+ } else {
266
+ parent = $(this._config.parent)[0];
267
+ }
267
268
 
269
+ var selector = "[data-toggle=\"collapse\"][data-parent=\"" + this._config.parent + "\"]";
268
270
  $(parent).find(selector).each(function (i, element) {
269
271
  _this3._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]);
270
272
  });
271
-
272
273
  return parent;
273
274
  };
274
275
 
275
- Collapse.prototype._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
276
+ _proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
276
277
  if (element) {
277
278
  var isOpen = $(element).hasClass(ClassName.SHOW);
278
279
 
@@ -280,9 +281,8 @@ var Collapse = function ($) {
280
281
  $(triggerArray).toggleClass(ClassName.COLLAPSED, !isOpen).attr('aria-expanded', isOpen);
281
282
  }
282
283
  }
283
- };
284
+ }; // static
284
285
 
285
- // static
286
286
 
287
287
  Collapse._getTargetFromElement = function _getTargetFromElement(element) {
288
288
  var selector = Util.getSelectorFromElement(element);
@@ -293,7 +293,8 @@ var Collapse = function ($) {
293
293
  return this.each(function () {
294
294
  var $this = $(this);
295
295
  var data = $this.data(DATA_KEY);
296
- var _config = $.extend({}, Default, $this.data(), (typeof config === 'undefined' ? 'undefined' : _typeof(config)) === 'object' && config);
296
+
297
+ var _config = $.extend({}, Default, $this.data(), typeof config === 'object' && config);
297
298
 
298
299
  if (!data && _config.toggle && /show|hide/.test(config)) {
299
300
  _config.toggle = false;
@@ -305,21 +306,22 @@ var Collapse = function ($) {
305
306
  }
306
307
 
307
308
  if (typeof config === 'string') {
308
- if (data[config] === undefined) {
309
- throw new Error('No method named "' + config + '"');
309
+ if (typeof data[config] === 'undefined') {
310
+ throw new Error("No method named \"" + config + "\"");
310
311
  }
312
+
311
313
  data[config]();
312
314
  }
313
315
  });
314
316
  };
315
317
 
316
318
  _createClass(Collapse, null, [{
317
- key: 'VERSION',
319
+ key: "VERSION",
318
320
  get: function get() {
319
321
  return VERSION;
320
322
  }
321
323
  }, {
322
- key: 'Default',
324
+ key: "Default",
323
325
  get: function get() {
324
326
  return Default;
325
327
  }
@@ -327,15 +329,16 @@ var Collapse = function ($) {
327
329
 
328
330
  return Collapse;
329
331
  }();
330
-
331
332
  /**
332
333
  * ------------------------------------------------------------------------
333
334
  * Data Api implementation
334
335
  * ------------------------------------------------------------------------
335
336
  */
336
337
 
338
+
337
339
  $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) {
338
- if (!/input|textarea/i.test(event.target.tagName)) {
340
+ // preventDefault only for <a> elements (which change the URL) not inside the collapsible element
341
+ if (event.currentTarget.tagName === 'A') {
339
342
  event.preventDefault();
340
343
  }
341
344
 
@@ -345,10 +348,10 @@ var Collapse = function ($) {
345
348
  var $target = $(this);
346
349
  var data = $target.data(DATA_KEY);
347
350
  var config = data ? 'toggle' : $trigger.data();
351
+
348
352
  Collapse._jQueryInterface.call($target, config);
349
353
  });
350
354
  });
351
-
352
355
  /**
353
356
  * ------------------------------------------------------------------------
354
357
  * jQuery
@@ -357,10 +360,11 @@ var Collapse = function ($) {
357
360
 
358
361
  $.fn[NAME] = Collapse._jQueryInterface;
359
362
  $.fn[NAME].Constructor = Collapse;
363
+
360
364
  $.fn[NAME].noConflict = function () {
361
365
  $.fn[NAME] = JQUERY_NO_CONFLICT;
362
366
  return Collapse._jQueryInterface;
363
367
  };
364
368
 
365
369
  return Collapse;
366
- }(jQuery);
370
+ }($);
@@ -1,18 +1,14 @@
1
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
1
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
2
2
 
3
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
4
-
5
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
6
4
 
7
5
  /**
8
6
  * --------------------------------------------------------------------------
9
- * Bootstrap (v4.0.0-beta): dropdown.js
7
+ * Bootstrap (v4.0.0-beta.2): dropdown.js
10
8
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
11
9
  * --------------------------------------------------------------------------
12
10
  */
13
-
14
- var Dropdown = function ($) {
15
-
11
+ var Dropdown = function () {
16
12
  /**
17
13
  * Check for Popper dependency
18
14
  * Popper - https://popper.js.org
@@ -20,38 +16,42 @@ var Dropdown = function ($) {
20
16
  if (typeof Popper === 'undefined') {
21
17
  throw new Error('Bootstrap dropdown require Popper.js (https://popper.js.org)');
22
18
  }
23
-
24
19
  /**
25
20
  * ------------------------------------------------------------------------
26
21
  * Constants
27
22
  * ------------------------------------------------------------------------
28
23
  */
29
24
 
25
+
30
26
  var NAME = 'dropdown';
31
- var VERSION = '4.0.0-beta';
27
+ var VERSION = '4.0.0-beta.2';
32
28
  var DATA_KEY = 'bs.dropdown';
33
- var EVENT_KEY = '.' + DATA_KEY;
29
+ var EVENT_KEY = "." + DATA_KEY;
34
30
  var DATA_API_KEY = '.data-api';
35
31
  var JQUERY_NO_CONFLICT = $.fn[NAME];
36
32
  var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key
33
+
37
34
  var SPACE_KEYCODE = 32; // KeyboardEvent.which value for space key
35
+
38
36
  var TAB_KEYCODE = 9; // KeyboardEvent.which value for tab key
37
+
39
38
  var ARROW_UP_KEYCODE = 38; // KeyboardEvent.which value for up arrow key
39
+
40
40
  var ARROW_DOWN_KEYCODE = 40; // KeyboardEvent.which value for down arrow key
41
+
41
42
  var RIGHT_MOUSE_BUTTON_WHICH = 3; // MouseEvent.which value for the right button (assuming a right-handed mouse)
42
- var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEYCODE + '|' + ARROW_DOWN_KEYCODE + '|' + ESCAPE_KEYCODE);
43
43
 
44
+ var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEYCODE + "|" + ARROW_DOWN_KEYCODE + "|" + ESCAPE_KEYCODE);
44
45
  var Event = {
45
- HIDE: 'hide' + EVENT_KEY,
46
- HIDDEN: 'hidden' + EVENT_KEY,
47
- SHOW: 'show' + EVENT_KEY,
48
- SHOWN: 'shown' + EVENT_KEY,
49
- CLICK: 'click' + EVENT_KEY,
50
- CLICK_DATA_API: 'click' + EVENT_KEY + DATA_API_KEY,
51
- KEYDOWN_DATA_API: 'keydown' + EVENT_KEY + DATA_API_KEY,
52
- KEYUP_DATA_API: 'keyup' + EVENT_KEY + DATA_API_KEY
46
+ HIDE: "hide" + EVENT_KEY,
47
+ HIDDEN: "hidden" + EVENT_KEY,
48
+ SHOW: "show" + EVENT_KEY,
49
+ SHOWN: "shown" + EVENT_KEY,
50
+ CLICK: "click" + EVENT_KEY,
51
+ CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY,
52
+ KEYDOWN_DATA_API: "keydown" + EVENT_KEY + DATA_API_KEY,
53
+ KEYUP_DATA_API: "keyup" + EVENT_KEY + DATA_API_KEY
53
54
  };
54
-
55
55
  var ClassName = {
56
56
  DISABLED: 'disabled',
57
57
  SHOW: 'show',
@@ -59,7 +59,6 @@ var Dropdown = function ($) {
59
59
  MENURIGHT: 'dropdown-menu-right',
60
60
  MENULEFT: 'dropdown-menu-left'
61
61
  };
62
-
63
62
  var Selector = {
64
63
  DATA_TOGGLE: '[data-toggle="dropdown"]',
65
64
  FORM_CHILD: '.dropdown form',
@@ -67,25 +66,19 @@ var Dropdown = function ($) {
67
66
  NAVBAR_NAV: '.navbar-nav',
68
67
  VISIBLE_ITEMS: '.dropdown-menu .dropdown-item:not(.disabled)'
69
68
  };
70
-
71
69
  var AttachmentMap = {
72
70
  TOP: 'top-start',
73
71
  TOPEND: 'top-end',
74
72
  BOTTOM: 'bottom-start',
75
73
  BOTTOMEND: 'bottom-end'
76
74
  };
77
-
78
75
  var Default = {
79
- placement: AttachmentMap.BOTTOM,
80
76
  offset: 0,
81
77
  flip: true
82
78
  };
83
-
84
79
  var DefaultType = {
85
- placement: 'string',
86
- offset: '(number|string)',
80
+ offset: '(number|string|function)',
87
81
  flip: 'boolean'
88
-
89
82
  /**
90
83
  * ------------------------------------------------------------------------
91
84
  * Class Definition
@@ -93,10 +86,11 @@ var Dropdown = function ($) {
93
86
  */
94
87
 
95
88
  };
96
- var Dropdown = function () {
97
- function Dropdown(element, config) {
98
- _classCallCheck(this, Dropdown);
99
89
 
90
+ var Dropdown =
91
+ /*#__PURE__*/
92
+ function () {
93
+ function Dropdown(element, config) {
100
94
  this._element = element;
101
95
  this._popper = null;
102
96
  this._config = this._getConfig(config);
@@ -104,18 +98,19 @@ var Dropdown = function ($) {
104
98
  this._inNavbar = this._detectNavbar();
105
99
 
106
100
  this._addEventListeners();
107
- }
101
+ } // getters
108
102
 
109
- // getters
110
103
 
111
- // public
104
+ var _proto = Dropdown.prototype;
112
105
 
113
- Dropdown.prototype.toggle = function toggle() {
106
+ // public
107
+ _proto.toggle = function toggle() {
114
108
  if (this._element.disabled || $(this._element).hasClass(ClassName.DISABLED)) {
115
109
  return;
116
110
  }
117
111
 
118
112
  var parent = Dropdown._getParentFromElement(this._element);
113
+
119
114
  var isActive = $(this._menu).hasClass(ClassName.SHOW);
120
115
 
121
116
  Dropdown._clearMenus();
@@ -128,135 +123,147 @@ var Dropdown = function ($) {
128
123
  relatedTarget: this._element
129
124
  };
130
125
  var showEvent = $.Event(Event.SHOW, relatedTarget);
131
-
132
126
  $(parent).trigger(showEvent);
133
127
 
134
128
  if (showEvent.isDefaultPrevented()) {
135
129
  return;
136
130
  }
137
131
 
138
- var element = this._element;
139
- // for dropup with alignment we use the parent as popper container
132
+ var element = this._element; // for dropup with alignment we use the parent as popper container
133
+
140
134
  if ($(parent).hasClass(ClassName.DROPUP)) {
141
135
  if ($(this._menu).hasClass(ClassName.MENULEFT) || $(this._menu).hasClass(ClassName.MENURIGHT)) {
142
136
  element = parent;
143
137
  }
144
138
  }
145
- this._popper = new Popper(element, this._menu, this._getPopperConfig());
146
139
 
147
- // if this is a touch-enabled device we add extra
140
+ this._popper = new Popper(element, this._menu, this._getPopperConfig()); // if this is a touch-enabled device we add extra
148
141
  // empty mouseover listeners to the body's immediate children;
149
142
  // only needed because of broken event delegation on iOS
150
143
  // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
144
+
151
145
  if ('ontouchstart' in document.documentElement && !$(parent).closest(Selector.NAVBAR_NAV).length) {
152
146
  $('body').children().on('mouseover', null, $.noop);
153
147
  }
154
148
 
155
149
  this._element.focus();
150
+
156
151
  this._element.setAttribute('aria-expanded', true);
157
152
 
158
153
  $(this._menu).toggleClass(ClassName.SHOW);
159
154
  $(parent).toggleClass(ClassName.SHOW).trigger($.Event(Event.SHOWN, relatedTarget));
160
155
  };
161
156
 
162
- Dropdown.prototype.dispose = function dispose() {
157
+ _proto.dispose = function dispose() {
163
158
  $.removeData(this._element, DATA_KEY);
164
159
  $(this._element).off(EVENT_KEY);
165
160
  this._element = null;
166
161
  this._menu = null;
162
+
167
163
  if (this._popper !== null) {
168
164
  this._popper.destroy();
169
165
  }
166
+
170
167
  this._popper = null;
171
168
  };
172
169
 
173
- Dropdown.prototype.update = function update() {
170
+ _proto.update = function update() {
174
171
  this._inNavbar = this._detectNavbar();
172
+
175
173
  if (this._popper !== null) {
176
174
  this._popper.scheduleUpdate();
177
175
  }
178
- };
176
+ }; // private
179
177
 
180
- // private
181
178
 
182
- Dropdown.prototype._addEventListeners = function _addEventListeners() {
179
+ _proto._addEventListeners = function _addEventListeners() {
183
180
  var _this = this;
184
181
 
185
182
  $(this._element).on(Event.CLICK, function (event) {
186
183
  event.preventDefault();
187
184
  event.stopPropagation();
185
+
188
186
  _this.toggle();
189
187
  });
190
188
  };
191
189
 
192
- Dropdown.prototype._getConfig = function _getConfig(config) {
193
- var elementData = $(this._element).data();
194
- if (elementData.placement !== undefined) {
195
- elementData.placement = AttachmentMap[elementData.placement.toUpperCase()];
196
- }
197
-
190
+ _proto._getConfig = function _getConfig(config) {
198
191
  config = $.extend({}, this.constructor.Default, $(this._element).data(), config);
199
-
200
192
  Util.typeCheckConfig(NAME, config, this.constructor.DefaultType);
201
-
202
193
  return config;
203
194
  };
204
195
 
205
- Dropdown.prototype._getMenuElement = function _getMenuElement() {
196
+ _proto._getMenuElement = function _getMenuElement() {
206
197
  if (!this._menu) {
207
198
  var parent = Dropdown._getParentFromElement(this._element);
199
+
208
200
  this._menu = $(parent).find(Selector.MENU)[0];
209
201
  }
202
+
210
203
  return this._menu;
211
204
  };
212
205
 
213
- Dropdown.prototype._getPlacement = function _getPlacement() {
206
+ _proto._getPlacement = function _getPlacement() {
214
207
  var $parentDropdown = $(this._element).parent();
215
- var placement = this._config.placement;
208
+ var placement = AttachmentMap.BOTTOM; // Handle dropup
216
209
 
217
- // Handle dropup
218
- if ($parentDropdown.hasClass(ClassName.DROPUP) || this._config.placement === AttachmentMap.TOP) {
210
+ if ($parentDropdown.hasClass(ClassName.DROPUP)) {
219
211
  placement = AttachmentMap.TOP;
212
+
220
213
  if ($(this._menu).hasClass(ClassName.MENURIGHT)) {
221
214
  placement = AttachmentMap.TOPEND;
222
215
  }
223
216
  } else if ($(this._menu).hasClass(ClassName.MENURIGHT)) {
224
217
  placement = AttachmentMap.BOTTOMEND;
225
218
  }
219
+
226
220
  return placement;
227
221
  };
228
222
 
229
- Dropdown.prototype._detectNavbar = function _detectNavbar() {
223
+ _proto._detectNavbar = function _detectNavbar() {
230
224
  return $(this._element).closest('.navbar').length > 0;
231
225
  };
232
226
 
233
- Dropdown.prototype._getPopperConfig = function _getPopperConfig() {
227
+ _proto._getPopperConfig = function _getPopperConfig() {
228
+ var _this2 = this;
229
+
230
+ var offsetConf = {};
231
+
232
+ if (typeof this._config.offset === 'function') {
233
+ offsetConf.fn = function (data) {
234
+ data.offsets = $.extend({}, data.offsets, _this2._config.offset(data.offsets) || {});
235
+ return data;
236
+ };
237
+ } else {
238
+ offsetConf.offset = this._config.offset;
239
+ }
240
+
234
241
  var popperConfig = {
235
242
  placement: this._getPlacement(),
236
243
  modifiers: {
237
- offset: {
238
- offset: this._config.offset
239
- },
244
+ offset: offsetConf,
240
245
  flip: {
241
246
  enabled: this._config.flip
242
247
  }
243
- }
248
+ } // Disable Popper.js for Dropdown in Navbar
249
+
250
+ };
244
251
 
245
- // Disable Popper.js for Dropdown in Navbar
246
- };if (this._inNavbar) {
252
+ if (this._inNavbar) {
247
253
  popperConfig.modifiers.applyStyle = {
248
254
  enabled: !this._inNavbar
249
255
  };
250
256
  }
257
+
251
258
  return popperConfig;
252
- };
259
+ }; // static
253
260
 
254
- // static
255
261
 
256
262
  Dropdown._jQueryInterface = function _jQueryInterface(config) {
257
263
  return this.each(function () {
258
264
  var data = $(this).data(DATA_KEY);
259
- var _config = (typeof config === 'undefined' ? 'undefined' : _typeof(config)) === 'object' ? config : null;
265
+
266
+ var _config = typeof config === 'object' ? config : null;
260
267
 
261
268
  if (!data) {
262
269
  data = new Dropdown(this, _config);
@@ -264,9 +271,10 @@ var Dropdown = function ($) {
264
271
  }
265
272
 
266
273
  if (typeof config === 'string') {
267
- if (data[config] === undefined) {
268
- throw new Error('No method named "' + config + '"');
274
+ if (typeof data[config] === 'undefined') {
275
+ throw new Error("No method named \"" + config + "\"");
269
276
  }
277
+
270
278
  data[config]();
271
279
  }
272
280
  });
@@ -278,8 +286,10 @@ var Dropdown = function ($) {
278
286
  }
279
287
 
280
288
  var toggles = $.makeArray($(Selector.DATA_TOGGLE));
289
+
281
290
  for (var i = 0; i < toggles.length; i++) {
282
291
  var parent = Dropdown._getParentFromElement(toggles[i]);
292
+
283
293
  var context = $(toggles[i]).data(DATA_KEY);
284
294
  var relatedTarget = {
285
295
  relatedTarget: toggles[i]
@@ -290,6 +300,7 @@ var Dropdown = function ($) {
290
300
  }
291
301
 
292
302
  var dropdownMenu = context._menu;
303
+
293
304
  if (!$(parent).hasClass(ClassName.SHOW)) {
294
305
  continue;
295
306
  }
@@ -300,25 +311,25 @@ var Dropdown = function ($) {
300
311
 
301
312
  var hideEvent = $.Event(Event.HIDE, relatedTarget);
302
313
  $(parent).trigger(hideEvent);
314
+
303
315
  if (hideEvent.isDefaultPrevented()) {
304
316
  continue;
305
- }
306
-
307
- // if this is a touch-enabled device we remove the extra
317
+ } // if this is a touch-enabled device we remove the extra
308
318
  // empty mouseover listeners we added for iOS support
319
+
320
+
309
321
  if ('ontouchstart' in document.documentElement) {
310
322
  $('body').children().off('mouseover', null, $.noop);
311
323
  }
312
324
 
313
325
  toggles[i].setAttribute('aria-expanded', 'false');
314
-
315
326
  $(dropdownMenu).removeClass(ClassName.SHOW);
316
327
  $(parent).removeClass(ClassName.SHOW).trigger($.Event(Event.HIDDEN, relatedTarget));
317
328
  }
318
329
  };
319
330
 
320
331
  Dropdown._getParentFromElement = function _getParentFromElement(element) {
321
- var parent = void 0;
332
+ var parent;
322
333
  var selector = Util.getSelectorFromElement(element);
323
334
 
324
335
  if (selector) {
@@ -341,10 +352,10 @@ var Dropdown = function ($) {
341
352
  }
342
353
 
343
354
  var parent = Dropdown._getParentFromElement(this);
355
+
344
356
  var isActive = $(parent).hasClass(ClassName.SHOW);
345
357
 
346
358
  if (!isActive && (event.which !== ESCAPE_KEYCODE || event.which !== SPACE_KEYCODE) || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) {
347
-
348
359
  if (event.which === ESCAPE_KEYCODE) {
349
360
  var toggle = $(parent).find(Selector.DATA_TOGGLE)[0];
350
361
  $(toggle).trigger('focus');
@@ -380,17 +391,17 @@ var Dropdown = function ($) {
380
391
  };
381
392
 
382
393
  _createClass(Dropdown, null, [{
383
- key: 'VERSION',
394
+ key: "VERSION",
384
395
  get: function get() {
385
396
  return VERSION;
386
397
  }
387
398
  }, {
388
- key: 'Default',
399
+ key: "Default",
389
400
  get: function get() {
390
401
  return Default;
391
402
  }
392
403
  }, {
393
- key: 'DefaultType',
404
+ key: "DefaultType",
394
405
  get: function get() {
395
406
  return DefaultType;
396
407
  }
@@ -398,21 +409,21 @@ var Dropdown = function ($) {
398
409
 
399
410
  return Dropdown;
400
411
  }();
401
-
402
412
  /**
403
413
  * ------------------------------------------------------------------------
404
414
  * Data Api implementation
405
415
  * ------------------------------------------------------------------------
406
416
  */
407
417
 
408
- $(document).on(Event.KEYDOWN_DATA_API, Selector.DATA_TOGGLE, Dropdown._dataApiKeydownHandler).on(Event.KEYDOWN_DATA_API, Selector.MENU, Dropdown._dataApiKeydownHandler).on(Event.CLICK_DATA_API + ' ' + Event.KEYUP_DATA_API, Dropdown._clearMenus).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) {
418
+
419
+ $(document).on(Event.KEYDOWN_DATA_API, Selector.DATA_TOGGLE, Dropdown._dataApiKeydownHandler).on(Event.KEYDOWN_DATA_API, Selector.MENU, Dropdown._dataApiKeydownHandler).on(Event.CLICK_DATA_API + " " + Event.KEYUP_DATA_API, Dropdown._clearMenus).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) {
409
420
  event.preventDefault();
410
421
  event.stopPropagation();
422
+
411
423
  Dropdown._jQueryInterface.call($(this), 'toggle');
412
424
  }).on(Event.CLICK_DATA_API, Selector.FORM_CHILD, function (e) {
413
425
  e.stopPropagation();
414
426
  });
415
-
416
427
  /**
417
428
  * ------------------------------------------------------------------------
418
429
  * jQuery
@@ -421,10 +432,11 @@ var Dropdown = function ($) {
421
432
 
422
433
  $.fn[NAME] = Dropdown._jQueryInterface;
423
434
  $.fn[NAME].Constructor = Dropdown;
435
+
424
436
  $.fn[NAME].noConflict = function () {
425
437
  $.fn[NAME] = JQUERY_NO_CONFLICT;
426
438
  return Dropdown._jQueryInterface;
427
439
  };
428
440
 
429
441
  return Dropdown;
430
- }(jQuery); /* global Popper */
442
+ }($, Popper);