Skip to content

Commit 9fb1918

Browse files
committed
Added compatibility with Bootstrap 4
1 parent f62212e commit 9fb1918

File tree

4 files changed

+54
-52
lines changed

4 files changed

+54
-52
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Bootstrap Alerts v1.0.1
1+
Bootstrap Alerts v1.2.0
22
===========
33

44
A jQuery plugin for displaying Bootstrap alerts. [Demo](http://jprieton.github.io/bootstrap-alerts)
@@ -8,9 +8,9 @@ Usage
88

99
```javascript
1010
$('#alert-container').bootstrapAlert({
11-
type: 'success', // Required, values: 'success', 'info', 'warning' or 'danger'
11+
type: 'success', // Optional, , default: 'info', values: 'success', 'info', 'warning' or 'danger'
1212
dismissible: true, // Optional, default: true
13-
title: 'My Title', // Optional, default: ''
13+
heading: 'My Heading', // Optional, default: ''
1414
message: 'My message.', // Required,
1515
clear: true // Optional, Clears the container, default: true
1616
});

bootstrap-alerts.js

+48-46
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Bootstrap Alerts v1.0.2, jQuery plugin
2+
* Bootstrap Alerts v1.2.0, jQuery plugin
33
*
44
* Copyright(c) 2015, Javier Prieto
55
* http://jprieton.github.io/bootstrap-alerts/
@@ -8,49 +8,51 @@
88
* Licensed under the MIT License
99
*/
1010
(function ($) {
11-
$.fn.bootstrapAlert = function (options) {
12-
13-
var settings = $.extend({
14-
type: null,
15-
dismissible: true,
16-
title: '',
17-
message: '',
18-
clear: true
19-
}, options);
20-
21-
if (settings.type.lenght === 0) {
22-
console.log('bootstrapAlert: type is empty');
23-
return false;
24-
}
25-
26-
if (settings.message.lenght === 0) {
27-
console.log('bootstrapAlert: message is empty');
28-
return false;
29-
}
30-
31-
var div = $('<div class="alert alert-' + settings.type + '" role="alert">');
32-
33-
if (settings.dismissible) {
34-
$(div).addClass('alert-dismissible');
35-
var button = $('<button type="button" class="close" data-dismiss="alert" aria-label="Close">');
36-
var span = $('<span aria-hidden="true">').html('&times;');
37-
$(span).appendTo(button);
38-
$(button).appendTo(div);
39-
}
40-
41-
if (settings.title.length > 0) {
42-
var title = $('<h4>').html(settings.title);
43-
$(title).appendTo(div);
44-
}
45-
46-
$(div).append(settings.message);
47-
48-
if (settings.clear) {
49-
$(this).empty();
50-
}
51-
52-
$(div).appendTo(this);
53-
54-
return this;
55-
};
11+
'use strict';
12+
13+
$.fn.bootstrapAlert = function (options) {
14+
15+
var settings = $.extend({
16+
type: 'info',
17+
dismissible: true,
18+
heading: '',
19+
message: '',
20+
clear: true
21+
}, options);
22+
23+
if (settings.type.lenght === 0) {
24+
console.log('bootstrapAlert: type is empty');
25+
return false;
26+
}
27+
28+
if (settings.message.lenght === 0) {
29+
console.log('bootstrapAlert: message is empty');
30+
return false;
31+
}
32+
33+
var div = $('<div class="alert alert-' + settings.type + '" role="alert">');
34+
35+
if (settings.dismissible) {
36+
$(div).addClass('alert-dismissible');
37+
var button = $('<button type="button" class="close" data-dismiss="alert" aria-label="Close">');
38+
var span = $('<span aria-hidden="true">').html('&times;');
39+
$(span).appendTo(button);
40+
$(button).appendTo(div);
41+
}
42+
43+
if (settings.heading.length > 0) {
44+
var heading = $('<h4 class="alert-heading">').html(settings.heading);
45+
$(heading).appendTo(div);
46+
}
47+
48+
$(div).append(settings.message);
49+
50+
if (settings.clear) {
51+
$(this).empty();
52+
}
53+
54+
$(div).appendTo(this);
55+
56+
return this;
57+
};
5658
})(jQuery);

bootstrap-alerts.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bootstrap-alerts",
3-
"version": "1.0.2",
3+
"version": "1.2.0",
44
"description": "A jQuery plugin for displaying Bootstrap alerts.",
55
"main": "bootstrap-alerts.js",
66
"keywords": [

0 commit comments

Comments
 (0)