aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/twbs/bootstrap/js/dist/button.js
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2019-12-12 14:51:10 +0000
committerMario <mario@mariovavti.com>2019-12-12 14:51:10 +0000
commit544ef3bc588d4180d7ecad15bdacd43813a7c5c5 (patch)
tree62372d0af859287235f62f20d0cf55b5b5b1ace3 /vendor/twbs/bootstrap/js/dist/button.js
parent124cc4396247c75c14280136cfaa95415860ad4c (diff)
downloadvolse-hubzilla-544ef3bc588d4180d7ecad15bdacd43813a7c5c5.tar.gz
volse-hubzilla-544ef3bc588d4180d7ecad15bdacd43813a7c5c5.tar.bz2
volse-hubzilla-544ef3bc588d4180d7ecad15bdacd43813a7c5c5.zip
update composer libs and minor notifications display fixes
Diffstat (limited to 'vendor/twbs/bootstrap/js/dist/button.js')
-rw-r--r--vendor/twbs/bootstrap/js/dist/button.js97
1 files changed, 72 insertions, 25 deletions
diff --git a/vendor/twbs/bootstrap/js/dist/button.js b/vendor/twbs/bootstrap/js/dist/button.js
index e8dfecbaf..92a3640fc 100644
--- a/vendor/twbs/bootstrap/js/dist/button.js
+++ b/vendor/twbs/bootstrap/js/dist/button.js
@@ -1,5 +1,5 @@
/*!
- * Bootstrap button.js v4.3.1 (https://getbootstrap.com/)
+ * Bootstrap button.js v4.4.1 (https://getbootstrap.com/)
* Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
@@ -7,7 +7,7 @@
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery')) :
typeof define === 'function' && define.amd ? define(['jquery'], factory) :
(global = global || self, global.Button = factory(global.jQuery));
-}(this, function ($) { 'use strict';
+}(this, (function ($) { 'use strict';
$ = $ && $.hasOwnProperty('default') ? $['default'] : $;
@@ -34,7 +34,7 @@
*/
var NAME = 'button';
- var VERSION = '4.3.1';
+ var VERSION = '4.4.1';
var DATA_KEY = 'bs.button';
var EVENT_KEY = "." + DATA_KEY;
var DATA_API_KEY = '.data-api';
@@ -46,21 +46,23 @@
};
var Selector = {
DATA_TOGGLE_CARROT: '[data-toggle^="button"]',
- DATA_TOGGLE: '[data-toggle="buttons"]',
+ DATA_TOGGLES: '[data-toggle="buttons"]',
+ DATA_TOGGLE: '[data-toggle="button"]',
+ DATA_TOGGLES_BUTTONS: '[data-toggle="buttons"] .btn',
INPUT: 'input:not([type="hidden"])',
ACTIVE: '.active',
BUTTON: '.btn'
};
var Event = {
CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY,
- FOCUS_BLUR_DATA_API: "focus" + EVENT_KEY + DATA_API_KEY + " " + ("blur" + EVENT_KEY + DATA_API_KEY)
- /**
- * ------------------------------------------------------------------------
- * Class Definition
- * ------------------------------------------------------------------------
- */
-
+ FOCUS_BLUR_DATA_API: "focus" + EVENT_KEY + DATA_API_KEY + " " + ("blur" + EVENT_KEY + DATA_API_KEY),
+ LOAD_DATA_API: "load" + EVENT_KEY + DATA_API_KEY
};
+ /**
+ * ------------------------------------------------------------------------
+ * Class Definition
+ * ------------------------------------------------------------------------
+ */
var Button =
/*#__PURE__*/
@@ -76,7 +78,7 @@
_proto.toggle = function toggle() {
var triggerChangeEvent = true;
var addAriaPressed = true;
- var rootElement = $(this._element).closest(Selector.DATA_TOGGLE)[0];
+ var rootElement = $(this._element).closest(Selector.DATA_TOGGLES)[0];
if (rootElement) {
var input = this._element.querySelector(Selector.INPUT);
@@ -92,13 +94,16 @@
$(activeElement).removeClass(ClassName.ACTIVE);
}
}
+ } else if (input.type === 'checkbox') {
+ if (this._element.tagName === 'LABEL' && input.checked === this._element.classList.contains(ClassName.ACTIVE)) {
+ triggerChangeEvent = false;
+ }
+ } else {
+ // if it's not a radio button or checkbox don't add a pointless/invalid checked property to the input
+ triggerChangeEvent = false;
}
if (triggerChangeEvent) {
- if (input.hasAttribute('disabled') || rootElement.hasAttribute('disabled') || input.classList.contains('disabled') || rootElement.classList.contains('disabled')) {
- return;
- }
-
input.checked = !this._element.classList.contains(ClassName.ACTIVE);
$(input).trigger('change');
}
@@ -108,12 +113,14 @@
}
}
- if (addAriaPressed) {
- this._element.setAttribute('aria-pressed', !this._element.classList.contains(ClassName.ACTIVE));
- }
+ if (!(this._element.hasAttribute('disabled') || this._element.classList.contains('disabled'))) {
+ if (addAriaPressed) {
+ this._element.setAttribute('aria-pressed', !this._element.classList.contains(ClassName.ACTIVE));
+ }
- if (triggerChangeEvent) {
- $(this._element).toggleClass(ClassName.ACTIVE);
+ if (triggerChangeEvent) {
+ $(this._element).toggleClass(ClassName.ACTIVE);
+ }
}
};
@@ -155,18 +162,58 @@
$(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE_CARROT, function (event) {
- event.preventDefault();
var button = event.target;
if (!$(button).hasClass(ClassName.BUTTON)) {
- button = $(button).closest(Selector.BUTTON);
+ button = $(button).closest(Selector.BUTTON)[0];
}
- Button._jQueryInterface.call($(button), 'toggle');
+ if (!button || button.hasAttribute('disabled') || button.classList.contains('disabled')) {
+ event.preventDefault(); // work around Firefox bug #1540995
+ } else {
+ var inputBtn = button.querySelector(Selector.INPUT);
+
+ if (inputBtn && (inputBtn.hasAttribute('disabled') || inputBtn.classList.contains('disabled'))) {
+ event.preventDefault(); // work around Firefox bug #1540995
+
+ return;
+ }
+
+ Button._jQueryInterface.call($(button), 'toggle');
+ }
}).on(Event.FOCUS_BLUR_DATA_API, Selector.DATA_TOGGLE_CARROT, function (event) {
var button = $(event.target).closest(Selector.BUTTON)[0];
$(button).toggleClass(ClassName.FOCUS, /^focus(in)?$/.test(event.type));
});
+ $(window).on(Event.LOAD_DATA_API, function () {
+ // ensure correct active class is set to match the controls' actual values/states
+ // find all checkboxes/readio buttons inside data-toggle groups
+ var buttons = [].slice.call(document.querySelectorAll(Selector.DATA_TOGGLES_BUTTONS));
+
+ for (var i = 0, len = buttons.length; i < len; i++) {
+ var button = buttons[i];
+ var input = button.querySelector(Selector.INPUT);
+
+ if (input.checked || input.hasAttribute('checked')) {
+ button.classList.add(ClassName.ACTIVE);
+ } else {
+ button.classList.remove(ClassName.ACTIVE);
+ }
+ } // find all button toggles
+
+
+ buttons = [].slice.call(document.querySelectorAll(Selector.DATA_TOGGLE));
+
+ for (var _i = 0, _len = buttons.length; _i < _len; _i++) {
+ var _button = buttons[_i];
+
+ if (_button.getAttribute('aria-pressed') === 'true') {
+ _button.classList.add(ClassName.ACTIVE);
+ } else {
+ _button.classList.remove(ClassName.ACTIVE);
+ }
+ }
+ });
/**
* ------------------------------------------------------------------------
* jQuery
@@ -183,5 +230,5 @@
return Button;
-}));
+})));
//# sourceMappingURL=button.js.map