bootstrap-growl-rails 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +51 -0
- data/lib/bootstrap/growl/rails.rb +10 -0
- data/lib/bootstrap/growl/rails/version.rb +7 -0
- data/vendor/assets/javascripts/bootstrap-growl.js +257 -0
- metadata +79 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9425af1de196edc669ff1be804e12c388f8e50ba
|
4
|
+
data.tar.gz: 67fc56ae3f366ba7434c6bb12f754c9140427095
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f92bd43d78729117f00d3af794aa74107344e9d9c6d6fc981151cdcee80b7ef488163e16e1bd5f41625d1dba2173b0832f8465a7a0dfc4c9135195fb23a0e6e6
|
7
|
+
data.tar.gz: 8af7454ee51f08ced115eb1276941e2e241fabfa03244374c08646e761da3c3cbb9e776aa622816aebd1e4ab972605afe78cac23933180732ff001a4b2f486af
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Dennis Baskin
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# Bootstrap::Growl::Rails
|
2
|
+
|
3
|
+
## Information
|
4
|
+
|
5
|
+
This gem is just an asset wrapper for bootstrap-growl JavaScript plugin by mouse0270 (https://github.com/mouse0270/bootstrap-growl). Please visit http://bootstrap-growl.remabledesigns.com/ for more details and social media praise.
|
6
|
+
|
7
|
+
### Current Version
|
8
|
+
|
9
|
+
2.0.0
|
10
|
+
|
11
|
+
## Documentation
|
12
|
+
|
13
|
+
Documentation can be found at http://bootstrap-growl.remabledesigns.com/#growl-documentation
|
14
|
+
|
15
|
+
## Demo
|
16
|
+
|
17
|
+
Demo can be found at http://bootstrap-growl.remabledesigns.com/
|
18
|
+
|
19
|
+
## Installation
|
20
|
+
|
21
|
+
Add this line to your application's Gemfile:
|
22
|
+
|
23
|
+
gem 'bootstrap-growl-rails'
|
24
|
+
|
25
|
+
And then execute:
|
26
|
+
|
27
|
+
$ bundle
|
28
|
+
|
29
|
+
Or install it yourself as:
|
30
|
+
|
31
|
+
$ gem install bootstrap-growl-rails
|
32
|
+
|
33
|
+
## Usage
|
34
|
+
|
35
|
+
Add the following directive to your Javascript manifest file (application.js):
|
36
|
+
|
37
|
+
//= require bootstrap-growl
|
38
|
+
|
39
|
+
*Please see the documentation at http://bootstrap-growl.remabledesigns.com/#growl-documentation for plugin usage instructions.*
|
40
|
+
|
41
|
+
## Versioning
|
42
|
+
|
43
|
+
bootstrap-growl-rails 2.0.0 == bootstrap-growl.js 2.0.0
|
44
|
+
|
45
|
+
## Contributing
|
46
|
+
|
47
|
+
1. Fork it ( https://github.com/[my-github-username]/bootstrap-growl-rails/fork )
|
48
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
49
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
50
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
51
|
+
5. Create a new Pull Request
|
@@ -0,0 +1,257 @@
|
|
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">×</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 );
|
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bootstrap-growl-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dennis Baskin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: 'This Gem is intended as an asset wrapper for bootstrap-growl: https://github.com/mouse0270/bootstrap-growl.
|
42
|
+
It turns Bootstrap alerts into "Growl-like" notifications. '
|
43
|
+
email:
|
44
|
+
- dennis@dennisbaskin.com
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- lib/bootstrap/growl/rails/version.rb
|
50
|
+
- lib/bootstrap/growl/rails.rb
|
51
|
+
- vendor/assets/javascripts/bootstrap-growl.js
|
52
|
+
- LICENSE.txt
|
53
|
+
- README.md
|
54
|
+
homepage: https://github.com/dennisbaskin/bootstrap-growl-rails
|
55
|
+
licenses:
|
56
|
+
- MIT
|
57
|
+
metadata: {}
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options: []
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
requirements: []
|
73
|
+
rubyforge_project:
|
74
|
+
rubygems_version: 2.0.6
|
75
|
+
signing_key:
|
76
|
+
specification_version: 4
|
77
|
+
summary: Asset wrapper for bootstrap-growl, a plugin that turns Bootstrap alerts into
|
78
|
+
"Growl-like" notifications.
|
79
|
+
test_files: []
|