|
1 | 1 | /*
|
2 |
| - * Bootstrap Alerts v1.0.2, jQuery plugin |
| 2 | + * Bootstrap Alerts v1.2.0, jQuery plugin |
3 | 3 | *
|
4 | 4 | * Copyright(c) 2015, Javier Prieto
|
5 | 5 | * http://jprieton.github.io/bootstrap-alerts/
|
|
8 | 8 | * Licensed under the MIT License
|
9 | 9 | */
|
10 | 10 | (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('×'); |
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('×'); |
| 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 | + }; |
56 | 58 | })(jQuery);
|
0 commit comments