bootstrap-growl-rails 2.0.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap-growl-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dennis Baskin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-28 00:00:00.000000000 Z
11
+ date: 2015-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -48,7 +48,8 @@ extra_rdoc_files: []
48
48
  files:
49
49
  - lib/bootstrap/growl/rails/version.rb
50
50
  - lib/bootstrap/growl/rails.rb
51
- - vendor/assets/javascripts/bootstrap-growl.js
51
+ - vendor/assets/javascripts/bootstrap-notify.js
52
+ - vendor/assets/stylesheets/animate.css
52
53
  - LICENSE.txt
53
54
  - README.md
54
55
  homepage: https://github.com/dennisbaskin/bootstrap-growl-rails
@@ -1,257 +0,0 @@
1
- /*
2
- * Project: Bootstrap Growl - v2.0.0
3
- * Description: Turns standard Bootstrap alerts into "Growl-like" notifications.
4
- * Author: Mouse0270 aka Robert McIntosh
5
- * License: MIT License
6
- * Website: https://github.com/mouse0270/bootstrap-growl
7
- */
8
- ;(function ( $, window, document, undefined ) {
9
- // Create the defaults once
10
- var pluginName = "growl",
11
- dataKey = "plugin_" + pluginName,
12
- defaults = {
13
- element: 'body',
14
- type: "info",
15
- allow_dismiss: true,
16
- placement: {
17
- from: "top",
18
- align: "right"
19
- },
20
- offset: 20,
21
- spacing: 10,
22
- z_index: 1031,
23
- delay: 5000,
24
- timer: 1000,
25
- url_target: '_blank',
26
- mouse_over: false,
27
- animate: {
28
- enter: 'animated fadeInDown',
29
- exit: 'animated fadeOutUp'
30
- },
31
- icon_type: 'class',
32
- template: '<div data-growl="container" class="alert" role="alert"><button type="button" class="close" data-growl="dismiss"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button><span data-growl="icon"></span><span data-growl="title"></span><span data-growl="message"></span><a href="#" data-growl="url"></a></div>'
33
- };
34
-
35
- // The actual plugin constructor
36
- var setDefaults = function(element, options) {
37
- defaults = $.extend(true, {}, defaults, options);
38
- },
39
- Plugin = function (element, content, options) {
40
- var content = {
41
- content: {
42
- message: typeof content == 'object' ? content.message : content,
43
- title: content.title ? content.title : null,
44
- icon: content.icon ? content.icon : null,
45
- url: content.url ? content.url : null
46
- }
47
- };
48
-
49
- options = $.extend(true, {}, content, options);
50
- this.settings = $.extend(true, {}, defaults, options);
51
- plugin = this;
52
- init(options, this.settings, plugin);
53
- this.$template = $template;
54
- },
55
- init = function (options, settings, plugin) {
56
-
57
- var base = {
58
- settings: settings,
59
- $element: $(settings.element),
60
- template: settings.template
61
- };
62
-
63
- $template = buildGrowl(base);
64
- addContent($template, base.settings);
65
- placement($template, base.settings);
66
- bindControls($template, base.settings,plugin);
67
- },
68
- buildGrowl = function(base) {
69
-
70
- var $template = $(base.settings.template);
71
-
72
- $template.addClass('alert-' + base.settings.type);
73
- $template.attr('data-growl-position', base.settings.placement.from + '-' + base.settings.placement.align);
74
-
75
- $template.find('[data-growl="dismiss"]').css('display', 'none');
76
- if (base.settings.allow_dismiss) {
77
- $template.find('[data-growl="dismiss"]').css('display', 'inline-block');
78
- }
79
-
80
- return $template;
81
- },
82
- addContent = function($template, settings) {
83
-
84
- $template.find('[data-growl="dismiss"]').css({
85
- 'position': 'absolute',
86
- 'top': '5px',
87
- 'right': '10px',
88
- 'z-index': ((settings.z_index-1) >= 1 ? (settings.z_index-1) : 1)
89
- });
90
-
91
- if (settings.content.icon) {
92
- if (settings.icon_type.toLowerCase() == 'class') {
93
- $template.find('[data-growl="icon"]').addClass(settings.content.icon);
94
- }else{
95
- if ($template.find('[data-growl="icon"]').is('img')) {
96
- $template.find('[data-growl="icon"]').attr('src', settings.content.icon);
97
- }else{
98
- $template.find('[data-growl="icon"]').append('<img src="'+settings.content.icon+'" />');
99
- }
100
- }
101
- }
102
-
103
- if (settings.content.title) {
104
- $template.find('[data-growl="title"]').html(settings.content.title);
105
- }
106
-
107
- if (settings.content.message) {
108
- $template.find('[data-growl="message"]').html(settings.content.message);
109
- }
110
-
111
- if (settings.content.url) {
112
- $template.find('[data-growl="url"]').attr('href', settings.content.url).attr('target', settings.url_target);
113
- $template.find('[data-growl="url"]').css({
114
- 'position': 'absolute',
115
- 'top': '0px',
116
- 'left': '0px',
117
- 'width': '100%',
118
- 'height': '100%',
119
- 'z-index': ((settings.z_index-2) >= 1 ? (settings.z_index-2) : 1)
120
- });
121
- }
122
- },
123
- placement = function($template, settings) {
124
- var offsetAmt = settings.offset,
125
- gCSS = {
126
- 'position': (settings.element === 'body' ? 'fixed' : 'absolute'),
127
- 'margin': 0,
128
- 'z-index': settings.z_index,
129
- 'display': 'inline-block'
130
- }
131
-
132
- $('[data-growl-position="' + settings.placement.from + '-' + settings.placement.align + '"]').each(function() {
133
- return offsetAmt = Math.max(offsetAmt, parseInt($(this).css(settings.placement.from)) + $(this).outerHeight() + settings.spacing);
134
- });
135
-
136
- gCSS[settings.placement.from] = offsetAmt + "px";
137
- $template.css(gCSS);
138
- $(settings.element).append($template);
139
-
140
- switch (settings.placement.align) {
141
- case 'center':
142
- $template.css({
143
- 'left': '50%',
144
- 'marginLeft': -($template.outerWidth() / 2) + 'px'
145
- });
146
- break;
147
- case 'left':
148
- $template.css('left', settings.offset + 'px');
149
- break;
150
- case 'right':
151
- $template.css('right', settings.offset + 'px');
152
- break;
153
- }
154
- $template.addClass('growl-animated');
155
- },
156
- bindControls = function($template, settings, plugin) {
157
- $template.addClass(settings.animate.enter);
158
-
159
- $template.find('[data-growl="dismiss"]').on('click', function() {
160
- plugin.close();
161
- });
162
-
163
- $template.on('mouseover', function(e) {
164
- $template.addClass('hovering');
165
- }).on('mouseout', function() {
166
- $template.removeClass('hovering');
167
- });
168
-
169
- if (settings.delay >= 1) {
170
- $template.data('growl-delay', settings.delay);
171
- var timer = setInterval(function() {
172
-
173
- var delay = parseInt($template.data('growl-delay')) - settings.timer;
174
- if ((!$template.hasClass('hovering') && settings.mouse_over == 'pause') || settings.mouse_over != 'pause') {
175
- $template.data('growl-delay', delay);
176
- }
177
-
178
- if (delay <= 0) {
179
- clearInterval(timer);
180
- plugin.close();
181
- }
182
- }, settings.timer);
183
- }
184
- };
185
-
186
- // Avoid Plugin.prototype conflicts
187
- Plugin.prototype = {
188
- update: function(command, update) {
189
- switch (command) {
190
- case 'icon':
191
- if (this.settings.icon_type.toLowerCase() == 'class') {
192
- this.$template.find('[data-growl="icon"]').removeClass(this.settings.content.icon);
193
- this.$template.find('[data-growl="icon"]').addClass(update);
194
- }else{
195
- if (this.$template.find('[data-growl="icon"]').is('img')) {
196
- this.$template.find('[data-growl="icon"]')
197
- }else{
198
- this.$template.find('[data-growl="icon"]').find('img').attr().attr('src', update);
199
- }
200
- }
201
- break;
202
- case 'url':
203
- this.$template.find('[data-growl="url"]').attr('href', update);
204
- break;
205
- case 'type':
206
- this.$template.removeClass('alert-' + this.settings.type);
207
- this.$template.addClass('alert-' + update);
208
- break;
209
- default:
210
- this.$template.find('[data-growl="' + command +'"]').html(update);
211
- }
212
-
213
- return this;
214
- },
215
- close: function() {
216
- var base = this.$template,
217
- settings = this.settings,
218
- posX = base.css(settings.placement.from),
219
- hasAnimation = false;
220
-
221
- base.addClass(this.settings.animate.exit);
222
-
223
- base.nextAll('[data-growl-position="' + this.settings.placement.from + '-' + this.settings.placement.align + '"]').each(function() {
224
- $(this).css(settings.placement.from, posX);
225
- posX = (parseInt(posX)+(settings.spacing)) + $(this).outerHeight();
226
- });
227
-
228
- base.one('webkitAnimationStart oanimationstart MSAnimationStart animationstart', function(event) {
229
- hasAnimation = true;
230
- });
231
-
232
- base.one('webkitAnimationEnd oanimationend MSAnimationEnd animationend', function(event) {
233
- $(this).remove();
234
- });
235
-
236
- setTimeout(function() {
237
- if (!hasAnimation) {
238
- base.remove();
239
- }
240
- }, 100);
241
-
242
- return this;
243
- }
244
- };
245
-
246
- // A really lightweight plugin wrapper around the constructor,
247
- // preventing against multiple instantiations
248
- $.growl = function ( content, options ) {
249
- if (content == false) {
250
- setDefaults(this, options);
251
- return false;
252
- }
253
- var plugin = new Plugin( this, content, options );
254
- return plugin;
255
- };
256
-
257
- })( jQuery, window, document );