bootstrap 4.3.1 → 5.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +55 -0
- data/CHANGELOG.md +2 -14
- data/README.md +28 -5
- data/assets/javascripts/bootstrap/alert.js +54 -163
- data/assets/javascripts/bootstrap/base-component.js +83 -0
- data/assets/javascripts/bootstrap/button.js +44 -152
- data/assets/javascripts/bootstrap/carousel.js +289 -569
- data/assets/javascripts/bootstrap/collapse.js +170 -349
- data/assets/javascripts/bootstrap/dom/data.js +62 -0
- data/assets/javascripts/bootstrap/dom/event-handler.js +236 -0
- data/assets/javascripts/bootstrap/dom/manipulator.js +71 -0
- data/assets/javascripts/bootstrap/dom/selector-engine.js +103 -0
- data/assets/javascripts/bootstrap/dropdown.js +303 -496
- data/assets/javascripts/bootstrap/modal.js +229 -559
- data/assets/javascripts/bootstrap/offcanvas.js +245 -0
- data/assets/javascripts/bootstrap/popover.js +61 -226
- data/assets/javascripts/bootstrap/scrollspy.js +217 -317
- data/assets/javascripts/bootstrap/tab.js +220 -212
- data/assets/javascripts/bootstrap/toast.js +145 -229
- data/assets/javascripts/bootstrap/tooltip.js +421 -782
- data/assets/javascripts/bootstrap/util/backdrop.js +139 -0
- data/assets/javascripts/bootstrap/util/component-functions.js +41 -0
- data/assets/javascripts/bootstrap/util/config.js +67 -0
- data/assets/javascripts/bootstrap/util/focustrap.js +113 -0
- data/assets/javascripts/bootstrap/util/index.js +281 -0
- data/assets/javascripts/bootstrap/util/sanitizer.js +110 -0
- data/assets/javascripts/bootstrap/util/scrollbar.js +112 -0
- data/assets/javascripts/bootstrap/util/swipe.js +134 -0
- data/assets/javascripts/bootstrap/util/template-factory.js +150 -0
- data/assets/javascripts/bootstrap-global-this-define.js +6 -0
- data/assets/javascripts/bootstrap-global-this-undefine.js +2 -0
- data/assets/javascripts/bootstrap-sprockets.js +23 -7
- data/assets/javascripts/bootstrap.js +3690 -3639
- data/assets/javascripts/bootstrap.min.js +4 -4
- data/assets/stylesheets/_bootstrap-grid.scss +53 -20
- data/assets/stylesheets/_bootstrap-reboot.scss +5 -7
- data/assets/stylesheets/_bootstrap.scss +21 -13
- data/assets/stylesheets/bootstrap/_accordion.scss +158 -0
- data/assets/stylesheets/bootstrap/_alert.scss +32 -15
- data/assets/stylesheets/bootstrap/_badge.scss +15 -31
- data/assets/stylesheets/bootstrap/_breadcrumb.scss +23 -24
- data/assets/stylesheets/bootstrap/_button-group.scss +27 -48
- data/assets/stylesheets/bootstrap/_buttons.scss +139 -69
- data/assets/stylesheets/bootstrap/_card.scss +91 -141
- data/assets/stylesheets/bootstrap/_carousel.scss +86 -39
- data/assets/stylesheets/bootstrap/_close.scss +51 -29
- data/assets/stylesheets/bootstrap/_containers.scss +41 -0
- data/assets/stylesheets/bootstrap/_dropdown.scss +131 -72
- data/assets/stylesheets/bootstrap/_forms.scss +9 -330
- data/assets/stylesheets/bootstrap/_functions.scss +244 -28
- data/assets/stylesheets/bootstrap/_grid.scss +18 -31
- data/assets/stylesheets/bootstrap/_helpers.scss +12 -0
- data/assets/stylesheets/bootstrap/_images.scss +3 -3
- data/assets/stylesheets/bootstrap/_list-group.scss +101 -53
- data/assets/stylesheets/bootstrap/_maps.scss +174 -0
- data/assets/stylesheets/bootstrap/_mixins.scss +13 -18
- data/assets/stylesheets/bootstrap/_modal.scss +120 -112
- data/assets/stylesheets/bootstrap/_nav.scss +113 -24
- data/assets/stylesheets/bootstrap/_navbar.scss +145 -150
- data/assets/stylesheets/bootstrap/_offcanvas.scss +146 -0
- data/assets/stylesheets/bootstrap/_pagination.scss +74 -38
- data/assets/stylesheets/bootstrap/_placeholders.scss +51 -0
- data/assets/stylesheets/bootstrap/_popover.scss +99 -74
- data/assets/stylesheets/bootstrap/_progress.scss +40 -15
- data/assets/stylesheets/bootstrap/_reboot.scss +342 -215
- data/assets/stylesheets/bootstrap/_root.scss +174 -9
- data/assets/stylesheets/bootstrap/_spinners.scss +52 -22
- data/assets/stylesheets/bootstrap/_tables.scss +101 -115
- data/assets/stylesheets/bootstrap/_toasts.scss +54 -25
- data/assets/stylesheets/bootstrap/_tooltip.scss +67 -63
- data/assets/stylesheets/bootstrap/_transitions.scss +8 -1
- data/assets/stylesheets/bootstrap/_type.scss +42 -61
- data/assets/stylesheets/bootstrap/_utilities.scss +806 -17
- data/assets/stylesheets/bootstrap/_variables-dark.scss +85 -0
- data/assets/stylesheets/bootstrap/_variables.scss +1235 -615
- data/assets/stylesheets/bootstrap/bootstrap-utilities.scss +19 -0
- data/assets/stylesheets/bootstrap/forms/_floating-labels.scss +94 -0
- data/assets/stylesheets/bootstrap/forms/_form-check.scss +188 -0
- data/assets/stylesheets/bootstrap/forms/_form-control.scss +214 -0
- data/assets/stylesheets/bootstrap/forms/_form-range.scss +91 -0
- data/assets/stylesheets/bootstrap/forms/_form-select.scss +80 -0
- data/assets/stylesheets/bootstrap/forms/_form-text.scss +11 -0
- data/assets/stylesheets/bootstrap/forms/_input-group.scss +132 -0
- data/assets/stylesheets/bootstrap/forms/_labels.scss +36 -0
- data/assets/stylesheets/bootstrap/forms/_validation.scss +12 -0
- data/assets/stylesheets/bootstrap/helpers/_color-bg.scss +8 -0
- data/assets/stylesheets/bootstrap/helpers/_colored-links.scss +30 -0
- data/assets/stylesheets/bootstrap/helpers/_focus-ring.scss +5 -0
- data/assets/stylesheets/bootstrap/helpers/_icon-link.scss +25 -0
- data/assets/stylesheets/bootstrap/helpers/_position.scss +36 -0
- data/assets/stylesheets/bootstrap/helpers/_ratio.scss +26 -0
- data/assets/stylesheets/bootstrap/helpers/_stacks.scss +15 -0
- data/assets/stylesheets/bootstrap/helpers/_stretched-link.scss +15 -0
- data/assets/stylesheets/bootstrap/helpers/_text-truncation.scss +7 -0
- data/assets/stylesheets/bootstrap/helpers/_visually-hidden.scss +8 -0
- data/assets/stylesheets/bootstrap/helpers/_vr.scss +8 -0
- data/assets/stylesheets/bootstrap/mixins/_alert.scss +11 -6
- data/assets/stylesheets/bootstrap/mixins/_backdrop.scss +14 -0
- data/assets/stylesheets/bootstrap/mixins/_banner.scss +7 -0
- data/assets/stylesheets/bootstrap/mixins/_border-radius.scss +37 -22
- data/assets/stylesheets/bootstrap/mixins/_box-shadow.scss +7 -9
- data/assets/stylesheets/bootstrap/mixins/_breakpoints.scss +20 -16
- data/assets/stylesheets/bootstrap/mixins/_buttons.scss +60 -97
- data/assets/stylesheets/bootstrap/mixins/_caret.scss +34 -27
- data/assets/stylesheets/bootstrap/mixins/_clearfix.scss +2 -0
- data/assets/stylesheets/bootstrap/mixins/_color-mode.scss +21 -0
- data/assets/stylesheets/bootstrap/mixins/_color-scheme.scss +7 -0
- data/assets/stylesheets/bootstrap/mixins/_container.scss +11 -0
- data/assets/stylesheets/bootstrap/mixins/_forms.scss +77 -116
- data/assets/stylesheets/bootstrap/mixins/_gradients.scss +13 -11
- data/assets/stylesheets/bootstrap/mixins/_grid.scss +133 -33
- data/assets/stylesheets/bootstrap/mixins/_image.scss +0 -20
- data/assets/stylesheets/bootstrap/mixins/_list-group.scss +7 -2
- data/assets/stylesheets/bootstrap/mixins/_pagination.scss +7 -19
- data/assets/stylesheets/bootstrap/mixins/_reset-text.scss +2 -2
- data/assets/stylesheets/bootstrap/mixins/_table-variants.scss +24 -0
- data/assets/stylesheets/bootstrap/mixins/_transition.scss +18 -8
- data/assets/stylesheets/bootstrap/mixins/_utilities.scss +97 -0
- data/assets/stylesheets/bootstrap/mixins/_visually-hidden.scss +33 -0
- data/assets/stylesheets/bootstrap/utilities/_api.scss +47 -0
- data/assets/stylesheets/bootstrap/vendor/_rfs.scss +276 -132
- data/bootstrap.gemspec +4 -6
- data/lib/bootstrap/version.rb +2 -2
- data/tasks/updater/js.rb +31 -7
- data/tasks/updater/network.rb +10 -4
- data/tasks/updater/scss.rb +1 -1
- data/tasks/updater.rb +2 -2
- data/test/dummy_rails/app/assets/config/manifest.js +3 -0
- data/test/dummy_rails/app/assets/javascripts/application.js +4 -3
- data/test/dummy_rails/app/assets/stylesheets/.browserslistrc +1 -0
- data/test/dummy_rails/app/views/layouts/application.html.erb +3 -1
- data/test/dummy_rails/app/views/pages/root.html +89 -0
- data/test/dummy_rails/config/application.rb +0 -3
- data/test/gemfiles/rails_5_2.gemfile +8 -0
- data/test/gemfiles/rails_6_0.gemfile +7 -0
- data/test/gemfiles/rails_6_1.gemfile +7 -0
- data/test/gemfiles/rails_7_0.gemfile +7 -0
- data/test/support/dummy_rails_integration.rb +3 -1
- data/test/test_helper.rb +18 -12
- metadata +86 -84
- data/.travis.yml +0 -17
- data/assets/javascripts/bootstrap/util.js +0 -171
- data/assets/stylesheets/bootstrap/_code.scss +0 -48
- data/assets/stylesheets/bootstrap/_custom-forms.scss +0 -507
- data/assets/stylesheets/bootstrap/_input-group.scss +0 -193
- data/assets/stylesheets/bootstrap/_jumbotron.scss +0 -17
- data/assets/stylesheets/bootstrap/_media.scss +0 -8
- data/assets/stylesheets/bootstrap/_print.scss +0 -141
- data/assets/stylesheets/bootstrap/mixins/_background-variant.scss +0 -21
- data/assets/stylesheets/bootstrap/mixins/_badge.scss +0 -17
- data/assets/stylesheets/bootstrap/mixins/_float.scss +0 -14
- data/assets/stylesheets/bootstrap/mixins/_grid-framework.scss +0 -66
- data/assets/stylesheets/bootstrap/mixins/_hover.scss +0 -37
- data/assets/stylesheets/bootstrap/mixins/_nav-divider.scss +0 -10
- data/assets/stylesheets/bootstrap/mixins/_screen-reader.scss +0 -33
- data/assets/stylesheets/bootstrap/mixins/_size.scss +0 -7
- data/assets/stylesheets/bootstrap/mixins/_table-row.scss +0 -39
- data/assets/stylesheets/bootstrap/mixins/_text-emphasis.scss +0 -16
- data/assets/stylesheets/bootstrap/mixins/_text-hide.scss +0 -11
- data/assets/stylesheets/bootstrap/mixins/_visibility.scss +0 -8
- data/assets/stylesheets/bootstrap/utilities/_align.scss +0 -8
- data/assets/stylesheets/bootstrap/utilities/_background.scss +0 -19
- data/assets/stylesheets/bootstrap/utilities/_borders.scss +0 -75
- data/assets/stylesheets/bootstrap/utilities/_display.scss +0 -26
- data/assets/stylesheets/bootstrap/utilities/_embed.scss +0 -39
- data/assets/stylesheets/bootstrap/utilities/_flex.scss +0 -51
- data/assets/stylesheets/bootstrap/utilities/_float.scss +0 -11
- data/assets/stylesheets/bootstrap/utilities/_overflow.scss +0 -5
- data/assets/stylesheets/bootstrap/utilities/_position.scss +0 -32
- data/assets/stylesheets/bootstrap/utilities/_screenreaders.scss +0 -11
- data/assets/stylesheets/bootstrap/utilities/_shadows.scss +0 -6
- data/assets/stylesheets/bootstrap/utilities/_sizing.scss +0 -20
- data/assets/stylesheets/bootstrap/utilities/_spacing.scss +0 -73
- data/assets/stylesheets/bootstrap/utilities/_stretched-link.scss +0 -19
- data/assets/stylesheets/bootstrap/utilities/_text.scss +0 -72
- data/assets/stylesheets/bootstrap/utilities/_visibility.scss +0 -13
- data/test/dummy_rails/app/views/pages/root.html.slim +0 -58
- /data/assets/stylesheets/bootstrap/{utilities → helpers}/_clearfix.scss +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1297df4a046b73652d3beb2a4edea3d3964b185320d890661af5f7ea8f420236
|
4
|
+
data.tar.gz: 9552130734b9698ce8cf99a92617e8df11664dc1d2bc24a9c1e306de646a1f48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4553a9d115f51a7516243cb392aa9c2f3b1e07f75c315f0400dd62772abd37b907ed3d9b40b37dfd42ec8c1bc809ab60ce7528784485374166d61416df882116
|
7
|
+
data.tar.gz: e01e045f2dd4616399a52dcef1037f177a625d7141b424b9b793fbc203e6b8315634296189af57fcbb7ad004fed61193be04d1d1101115df0cd1364351bd42b3
|
@@ -0,0 +1,55 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
pull_request:
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
test:
|
9
|
+
env:
|
10
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
11
|
+
strategy:
|
12
|
+
fail-fast: false
|
13
|
+
matrix:
|
14
|
+
ruby_version: ['2.5', '2.6', '2.7', '3.0', '3.1']
|
15
|
+
gemfile:
|
16
|
+
- test/gemfiles/rails_5_0.gemfile
|
17
|
+
- test/gemfiles/rails_5_1.gemfile
|
18
|
+
- test/gemfiles/rails_5_2.gemfile
|
19
|
+
- test/gemfiles/rails_6_0.gemfile
|
20
|
+
- test/gemfiles/rails_6_1.gemfile
|
21
|
+
- test/gemfiles/rails_7_0.gemfile
|
22
|
+
include:
|
23
|
+
- ruby_version: '2.5'
|
24
|
+
gemfile: test/gemfiles/rails_4_2.gemfile
|
25
|
+
- ruby_version: '2.6'
|
26
|
+
gemfile: test/gemfiles/rails_4_2.gemfile
|
27
|
+
exclude:
|
28
|
+
- ruby_version: '2.5'
|
29
|
+
gemfile: test/gemfiles/rails_7_0.gemfile
|
30
|
+
- ruby_version: '2.6'
|
31
|
+
gemfile: test/gemfiles/rails_7_0.gemfile
|
32
|
+
- ruby_version: '3.0'
|
33
|
+
gemfile: test/gemfiles/rails_5_0.gemfile
|
34
|
+
- ruby_version: '3.0'
|
35
|
+
gemfile: test/gemfiles/rails_5_1.gemfile
|
36
|
+
- ruby_version: '3.0'
|
37
|
+
gemfile: test/gemfiles/rails_5_2.gemfile
|
38
|
+
- ruby_version: '3.1'
|
39
|
+
gemfile: test/gemfiles/rails_5_0.gemfile
|
40
|
+
- ruby_version: '3.1'
|
41
|
+
gemfile: test/gemfiles/rails_5_1.gemfile
|
42
|
+
- ruby_version: '3.1'
|
43
|
+
gemfile: test/gemfiles/rails_5_2.gemfile
|
44
|
+
- ruby_version: '3.1'
|
45
|
+
gemfile: test/gemfiles/rails_6_0.gemfile
|
46
|
+
runs-on: ubuntu-latest
|
47
|
+
steps:
|
48
|
+
- uses: actions/checkout@v3
|
49
|
+
- name: Set up Ruby
|
50
|
+
uses: ruby/setup-ruby@v1
|
51
|
+
with:
|
52
|
+
ruby-version: ${{ matrix.ruby_version }}
|
53
|
+
bundler-cache: true # 'bundle install' and cache
|
54
|
+
- name: Build and test with Rake
|
55
|
+
run: bundle exec rake --trace
|
data/CHANGELOG.md
CHANGED
@@ -6,21 +6,9 @@ The changelog only includes changes specific to the RubyGem.
|
|
6
6
|
The Bootstrap framework changes can be found in [the Releases section of twbs/bootstrap](https://github.com/twbs/bootstrap/releases).
|
7
7
|
Release announcement posts on [the official Bootstrap blog](http://blog.getbootstrap.com) contain summaries of the most noteworthy changes made in each release of Bootstrap.
|
8
8
|
|
9
|
-
# 4.
|
9
|
+
# 4.2.1
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
# 4.1.0
|
14
|
-
|
15
|
-
No gem-specific changes.
|
16
|
-
|
17
|
-
# 4.0.0
|
18
|
-
|
19
|
-
No gem-specific changes.
|
20
|
-
|
21
|
-
# 4.0.0.beta3
|
22
|
-
|
23
|
-
No gem-specific changes.
|
11
|
+
* Bootstrap rubygem now depends on SassC instead of Sass.
|
24
12
|
|
25
13
|
# 4.0.0.beta2.1
|
26
14
|
|
data/README.md
CHANGED
@@ -1,9 +1,13 @@
|
|
1
|
-
# Bootstrap Ruby Gem [![
|
1
|
+
# Bootstrap Ruby Gem [![CI](https://github.com/twbs/bootstrap-rubygem/actions/workflows/ci.yml/badge.svg)](https://github.com/twbs/bootstrap-rubygem/actions/workflows/ci.yml) [![Gem](https://img.shields.io/gem/v/bootstrap.svg)](https://rubygems.org/gems/bootstrap)
|
2
2
|
|
3
|
-
[Bootstrap
|
3
|
+
[Bootstrap 5][bootstrap-home] ruby gem for Ruby on Rails (*Sprockets*/*Importmaps*) and Hanami (formerly Lotus).
|
4
4
|
|
5
5
|
For Sass versions of Bootstrap 3 and 2 see [bootstrap-sass](https://github.com/twbs/bootstrap-sass) instead.
|
6
6
|
|
7
|
+
**Ruby on Rails Note**: Newer releases of Rails have added additional ways for
|
8
|
+
assets to be processed. The `twbs/bootstrap-rubygem` is for use with Importmaps
|
9
|
+
or Sprockets, but not Webpack.
|
10
|
+
|
7
11
|
## Installation
|
8
12
|
|
9
13
|
Please see the appropriate guide for your environment of choice:
|
@@ -17,7 +21,7 @@ Please see the appropriate guide for your environment of choice:
|
|
17
21
|
Add `bootstrap` to your Gemfile:
|
18
22
|
|
19
23
|
```ruby
|
20
|
-
gem 'bootstrap', '~>
|
24
|
+
gem 'bootstrap', '~> 5.3.0'
|
21
25
|
```
|
22
26
|
|
23
27
|
Ensure that `sprockets-rails` is at least v2.3.2.
|
@@ -44,8 +48,8 @@ Then, remove all the `*= require` and `*= require_tree` statements from the Sass
|
|
44
48
|
|
45
49
|
Do not use `*= require` in Sass or your other stylesheets will not be able to access the Bootstrap mixins and variables.
|
46
50
|
|
47
|
-
Bootstrap JavaScript
|
48
|
-
If you're using Rails 5.1+, add the `jquery-rails` gem to your Gemfile:
|
51
|
+
Bootstrap JavaScript can optionally use jQuery.
|
52
|
+
If you're using Rails 5.1+, you can add the `jquery-rails` gem to your Gemfile:
|
49
53
|
|
50
54
|
```ruby
|
51
55
|
gem 'jquery-rails'
|
@@ -55,6 +59,25 @@ Bootstrap tooltips and popovers depend on [popper.js] for positioning.
|
|
55
59
|
The `bootstrap` gem already depends on the
|
56
60
|
[popper_js](https://github.com/glebm/popper_js-rubygem) gem.
|
57
61
|
|
62
|
+
#### Importmaps
|
63
|
+
|
64
|
+
You can pin either `bootstrap.js` or `bootstrap.min.js` in `config/importmap.rb`
|
65
|
+
as well as `popper.js`:
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
pin "bootstrap", to: "bootstrap.min.js", preload: true
|
69
|
+
pin "@popperjs/core", to: "popper.js", preload: true
|
70
|
+
```
|
71
|
+
|
72
|
+
Whichever files you pin will need to be added to `config.assets.precompile`:
|
73
|
+
|
74
|
+
```ruby
|
75
|
+
# config/initializers/assets.rb
|
76
|
+
Rails.application.config.assets.precompile += %w(bootstrap.min.js popper.js)
|
77
|
+
```
|
78
|
+
|
79
|
+
#### Sprockets
|
80
|
+
|
58
81
|
Add Bootstrap dependencies and Bootstrap to your `application.js`:
|
59
82
|
|
60
83
|
```js
|
@@ -1,197 +1,88 @@
|
|
1
1
|
/*!
|
2
|
-
* Bootstrap alert.js
|
3
|
-
* Copyright 2011-
|
4
|
-
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/
|
2
|
+
* Bootstrap alert.js v5.3.0 (https://getbootstrap.com/)
|
3
|
+
* Copyright 2011-2023 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
4
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
5
5
|
*/
|
6
6
|
(function (global, factory) {
|
7
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('
|
8
|
-
typeof define === 'function' && define.amd ? define(['
|
9
|
-
(global = global || self, global.Alert = factory(global.
|
10
|
-
}(this, function (
|
7
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./base-component.js'), require('./dom/event-handler.js'), require('./util/component-functions.js'), require('./util/index.js')) :
|
8
|
+
typeof define === 'function' && define.amd ? define(['./base-component', './dom/event-handler', './util/component-functions', './util/index'], factory) :
|
9
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Alert = factory(global.BaseComponent, global.EventHandler, global.ComponentFunctions, global.Index));
|
10
|
+
})(this, (function (BaseComponent, EventHandler, componentFunctions_js, index_js) { 'use strict';
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
19
|
-
descriptor.configurable = true;
|
20
|
-
if ("value" in descriptor) descriptor.writable = true;
|
21
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
22
|
-
}
|
23
|
-
}
|
12
|
+
/**
|
13
|
+
* --------------------------------------------------------------------------
|
14
|
+
* Bootstrap alert.js
|
15
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
16
|
+
* --------------------------------------------------------------------------
|
17
|
+
*/
|
24
18
|
|
25
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
26
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
27
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
28
|
-
return Constructor;
|
29
|
-
}
|
30
19
|
|
31
20
|
/**
|
32
|
-
* ------------------------------------------------------------------------
|
33
21
|
* Constants
|
34
|
-
* ------------------------------------------------------------------------
|
35
22
|
*/
|
36
23
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
DISMISS: '[data-dismiss="alert"]'
|
45
|
-
};
|
46
|
-
var Event = {
|
47
|
-
CLOSE: "close" + EVENT_KEY,
|
48
|
-
CLOSED: "closed" + EVENT_KEY,
|
49
|
-
CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
|
50
|
-
};
|
51
|
-
var ClassName = {
|
52
|
-
ALERT: 'alert',
|
53
|
-
FADE: 'fade',
|
54
|
-
SHOW: 'show'
|
55
|
-
/**
|
56
|
-
* ------------------------------------------------------------------------
|
57
|
-
* Class Definition
|
58
|
-
* ------------------------------------------------------------------------
|
59
|
-
*/
|
60
|
-
|
61
|
-
};
|
62
|
-
|
63
|
-
var Alert =
|
64
|
-
/*#__PURE__*/
|
65
|
-
function () {
|
66
|
-
function Alert(element) {
|
67
|
-
this._element = element;
|
68
|
-
} // Getters
|
24
|
+
const NAME = 'alert';
|
25
|
+
const DATA_KEY = 'bs.alert';
|
26
|
+
const EVENT_KEY = `.${DATA_KEY}`;
|
27
|
+
const EVENT_CLOSE = `close${EVENT_KEY}`;
|
28
|
+
const EVENT_CLOSED = `closed${EVENT_KEY}`;
|
29
|
+
const CLASS_NAME_FADE = 'fade';
|
30
|
+
const CLASS_NAME_SHOW = 'show';
|
69
31
|
|
32
|
+
/**
|
33
|
+
* Class definition
|
34
|
+
*/
|
70
35
|
|
71
|
-
|
36
|
+
class Alert extends BaseComponent {
|
37
|
+
// Getters
|
38
|
+
static get NAME() {
|
39
|
+
return NAME;
|
40
|
+
}
|
72
41
|
|
73
42
|
// Public
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
if (element) {
|
78
|
-
rootElement = this._getRootElement(element);
|
79
|
-
}
|
80
|
-
|
81
|
-
var customEvent = this._triggerCloseEvent(rootElement);
|
82
|
-
|
83
|
-
if (customEvent.isDefaultPrevented()) {
|
43
|
+
close() {
|
44
|
+
const closeEvent = EventHandler.trigger(this._element, EVENT_CLOSE);
|
45
|
+
if (closeEvent.defaultPrevented) {
|
84
46
|
return;
|
85
47
|
}
|
48
|
+
this._element.classList.remove(CLASS_NAME_SHOW);
|
49
|
+
const isAnimated = this._element.classList.contains(CLASS_NAME_FADE);
|
50
|
+
this._queueCallback(() => this._destroyElement(), this._element, isAnimated);
|
51
|
+
}
|
86
52
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
} // Private
|
94
|
-
;
|
95
|
-
|
96
|
-
_proto._getRootElement = function _getRootElement(element) {
|
97
|
-
var selector = Util.getSelectorFromElement(element);
|
98
|
-
var parent = false;
|
99
|
-
|
100
|
-
if (selector) {
|
101
|
-
parent = document.querySelector(selector);
|
102
|
-
}
|
103
|
-
|
104
|
-
if (!parent) {
|
105
|
-
parent = $(element).closest("." + ClassName.ALERT)[0];
|
106
|
-
}
|
107
|
-
|
108
|
-
return parent;
|
109
|
-
};
|
110
|
-
|
111
|
-
_proto._triggerCloseEvent = function _triggerCloseEvent(element) {
|
112
|
-
var closeEvent = $.Event(Event.CLOSE);
|
113
|
-
$(element).trigger(closeEvent);
|
114
|
-
return closeEvent;
|
115
|
-
};
|
116
|
-
|
117
|
-
_proto._removeElement = function _removeElement(element) {
|
118
|
-
var _this = this;
|
119
|
-
|
120
|
-
$(element).removeClass(ClassName.SHOW);
|
121
|
-
|
122
|
-
if (!$(element).hasClass(ClassName.FADE)) {
|
123
|
-
this._destroyElement(element);
|
124
|
-
|
125
|
-
return;
|
126
|
-
}
|
127
|
-
|
128
|
-
var transitionDuration = Util.getTransitionDurationFromElement(element);
|
129
|
-
$(element).one(Util.TRANSITION_END, function (event) {
|
130
|
-
return _this._destroyElement(element, event);
|
131
|
-
}).emulateTransitionEnd(transitionDuration);
|
132
|
-
};
|
133
|
-
|
134
|
-
_proto._destroyElement = function _destroyElement(element) {
|
135
|
-
$(element).detach().trigger(Event.CLOSED).remove();
|
136
|
-
} // Static
|
137
|
-
;
|
53
|
+
// Private
|
54
|
+
_destroyElement() {
|
55
|
+
this._element.remove();
|
56
|
+
EventHandler.trigger(this._element, EVENT_CLOSED);
|
57
|
+
this.dispose();
|
58
|
+
}
|
138
59
|
|
139
|
-
|
60
|
+
// Static
|
61
|
+
static jQueryInterface(config) {
|
140
62
|
return this.each(function () {
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
if (!data) {
|
145
|
-
data = new Alert(this);
|
146
|
-
$element.data(DATA_KEY, data);
|
63
|
+
const data = Alert.getOrCreateInstance(this);
|
64
|
+
if (typeof config !== 'string') {
|
65
|
+
return;
|
147
66
|
}
|
148
|
-
|
149
|
-
|
150
|
-
data[config](this);
|
67
|
+
if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
|
68
|
+
throw new TypeError(`No method named "${config}"`);
|
151
69
|
}
|
70
|
+
data[config](this);
|
152
71
|
});
|
153
|
-
}
|
154
|
-
|
155
|
-
Alert._handleDismiss = function _handleDismiss(alertInstance) {
|
156
|
-
return function (event) {
|
157
|
-
if (event) {
|
158
|
-
event.preventDefault();
|
159
|
-
}
|
160
|
-
|
161
|
-
alertInstance.close(this);
|
162
|
-
};
|
163
|
-
};
|
164
|
-
|
165
|
-
_createClass(Alert, null, [{
|
166
|
-
key: "VERSION",
|
167
|
-
get: function get() {
|
168
|
-
return VERSION;
|
169
|
-
}
|
170
|
-
}]);
|
72
|
+
}
|
73
|
+
}
|
171
74
|
|
172
|
-
return Alert;
|
173
|
-
}();
|
174
75
|
/**
|
175
|
-
*
|
176
|
-
* Data Api implementation
|
177
|
-
* ------------------------------------------------------------------------
|
76
|
+
* Data API implementation
|
178
77
|
*/
|
179
78
|
|
79
|
+
componentFunctions_js.enableDismissTrigger(Alert, 'close');
|
180
80
|
|
181
|
-
$(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert()));
|
182
81
|
/**
|
183
|
-
* ------------------------------------------------------------------------
|
184
82
|
* jQuery
|
185
|
-
* ------------------------------------------------------------------------
|
186
83
|
*/
|
187
84
|
|
188
|
-
|
189
|
-
$.fn[NAME].Constructor = Alert;
|
190
|
-
|
191
|
-
$.fn[NAME].noConflict = function () {
|
192
|
-
$.fn[NAME] = JQUERY_NO_CONFLICT;
|
193
|
-
return Alert._jQueryInterface;
|
194
|
-
};
|
85
|
+
index_js.defineJQueryPlugin(Alert);
|
195
86
|
|
196
87
|
return Alert;
|
197
88
|
|
@@ -0,0 +1,83 @@
|
|
1
|
+
/*!
|
2
|
+
* Bootstrap base-component.js v5.3.0 (https://getbootstrap.com/)
|
3
|
+
* Copyright 2011-2023 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
4
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
5
|
+
*/
|
6
|
+
(function (global, factory) {
|
7
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/data.js'), require('./dom/event-handler.js'), require('./util/config.js'), require('./util/index.js')) :
|
8
|
+
typeof define === 'function' && define.amd ? define(['./dom/data', './dom/event-handler', './util/config', './util/index'], factory) :
|
9
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.BaseComponent = factory(global.Data, global.EventHandler, global.Config, global.Index));
|
10
|
+
})(this, (function (Data, EventHandler, Config, index_js) { 'use strict';
|
11
|
+
|
12
|
+
/**
|
13
|
+
* --------------------------------------------------------------------------
|
14
|
+
* Bootstrap base-component.js
|
15
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
16
|
+
* --------------------------------------------------------------------------
|
17
|
+
*/
|
18
|
+
|
19
|
+
|
20
|
+
/**
|
21
|
+
* Constants
|
22
|
+
*/
|
23
|
+
|
24
|
+
const VERSION = '5.3.0';
|
25
|
+
|
26
|
+
/**
|
27
|
+
* Class definition
|
28
|
+
*/
|
29
|
+
|
30
|
+
class BaseComponent extends Config {
|
31
|
+
constructor(element, config) {
|
32
|
+
super();
|
33
|
+
element = index_js.getElement(element);
|
34
|
+
if (!element) {
|
35
|
+
return;
|
36
|
+
}
|
37
|
+
this._element = element;
|
38
|
+
this._config = this._getConfig(config);
|
39
|
+
Data.set(this._element, this.constructor.DATA_KEY, this);
|
40
|
+
}
|
41
|
+
|
42
|
+
// Public
|
43
|
+
dispose() {
|
44
|
+
Data.remove(this._element, this.constructor.DATA_KEY);
|
45
|
+
EventHandler.off(this._element, this.constructor.EVENT_KEY);
|
46
|
+
for (const propertyName of Object.getOwnPropertyNames(this)) {
|
47
|
+
this[propertyName] = null;
|
48
|
+
}
|
49
|
+
}
|
50
|
+
_queueCallback(callback, element, isAnimated = true) {
|
51
|
+
index_js.executeAfterTransition(callback, element, isAnimated);
|
52
|
+
}
|
53
|
+
_getConfig(config) {
|
54
|
+
config = this._mergeConfigObj(config, this._element);
|
55
|
+
config = this._configAfterMerge(config);
|
56
|
+
this._typeCheckConfig(config);
|
57
|
+
return config;
|
58
|
+
}
|
59
|
+
|
60
|
+
// Static
|
61
|
+
static getInstance(element) {
|
62
|
+
return Data.get(index_js.getElement(element), this.DATA_KEY);
|
63
|
+
}
|
64
|
+
static getOrCreateInstance(element, config = {}) {
|
65
|
+
return this.getInstance(element) || new this(element, typeof config === 'object' ? config : null);
|
66
|
+
}
|
67
|
+
static get VERSION() {
|
68
|
+
return VERSION;
|
69
|
+
}
|
70
|
+
static get DATA_KEY() {
|
71
|
+
return `bs.${this.NAME}`;
|
72
|
+
}
|
73
|
+
static get EVENT_KEY() {
|
74
|
+
return `.${this.DATA_KEY}`;
|
75
|
+
}
|
76
|
+
static eventName(name) {
|
77
|
+
return `${name}${this.EVENT_KEY}`;
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
return BaseComponent;
|
82
|
+
|
83
|
+
}));
|