growl-rails 1.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5fb7792ea79989ec4958a6b791e18404c8feb6f8
4
+ data.tar.gz: edb22c75858babcdf7cc50e9d984fe97314a105b
5
+ SHA512:
6
+ metadata.gz: 0f5a37111a83339bd4ded1d60bc2993e442cbb057ef0c4da594a8bac71ee56910c0417e5bb6802e6f2601f4928b28b86120902f440f239960c8da1a738b65d0c
7
+ data.tar.gz: a3a534be535d1ec95fce39e9875b1184f05baa5f277d28f4c9a426757bc2951bd1ed5f6db18b338c657a3a34c0ccf2954ad332b9ae748b8d894c08b578844dbb
data/.DS_Store ADDED
Binary file
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in growl-rails.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Joshua Tyree
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # Gem growl-rails
2
+
3
+ The gem `growl-rails` leverages the popular jQuery library `jquery.growl` to make flash messages come alive.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'growl-rails'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install growl-rails
20
+
21
+ ## Usage
22
+
23
+ Require the growl assets in your javascript/css files.
24
+
25
+ JavaScript
26
+ ```javascript
27
+ //= require growl
28
+ ```
29
+
30
+ CSS
31
+ ```css
32
+ /*
33
+ *= require growl
34
+ */
35
+ ```
36
+
37
+ SASS
38
+ ```sass
39
+ @import 'growl'
40
+ ```
41
+
42
+
43
+ Set a flash message in rails.
44
+
45
+ ```ruby
46
+ def create
47
+ @user = User.new(user_params)
48
+ if @user.save
49
+ flash[:success] = "User created successfully"
50
+ redirect_to user_path(@user)
51
+ else
52
+ flash[:error] = "Please check the errors below"
53
+ render :new
54
+ end
55
+ end
56
+ ```
57
+
58
+
59
+ ## Contributing
60
+
61
+ Bug reports and pull requests are welcome on GitHub at https://github.com/JoshuaTyree/growl-rails.
62
+
63
+
64
+ ## License
65
+
66
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "growl/rails"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'growl/rails/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "growl-rails"
8
+ spec.version = Growl::Rails::VERSION
9
+ spec.authors = ["Joshua Tyree"]
10
+ spec.email = ["joshuat@createthebridge.com"]
11
+
12
+ spec.summary = %q{Flash messages backed by jQuery Growl}
13
+ spec.homepage = "https://github.com/JoshuaTyree/growl-rails.git"
14
+ spec.license = "MIT"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ # if spec.respond_to?(:metadata)
19
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
20
+ # else
21
+ # raise "RubyGems 2.0 or newer is required to protect against " \
22
+ # "public gem pushes."
23
+ # end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
26
+ f.match(%r{^(test|spec|features)/})
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ spec.add_development_dependency "bundler", "~> 1.13"
33
+ spec.add_development_dependency "rake", "~> 10.0"
34
+ spec.add_dependency "railties"
35
+ end
@@ -0,0 +1,10 @@
1
+ require "growl/rails/version"
2
+ require "growl/rails/helper"
3
+
4
+ module Growl
5
+ module Rails
6
+ class Engine < ::Rails::Engine
7
+ ActionView::Base.send :include, Helper
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,16 @@
1
+ module Growl
2
+ module Rails
3
+ module Helper
4
+
5
+ def flash_notification_tag
6
+ jscript = []
7
+ flash.each do |k,v|
8
+ jscript.push "$.growl({ title: '#{k.to_s.humanize.titleize}', message: '#{v}', style: '#{k.to_s}' });"
9
+ end
10
+
11
+ javascript_tag jscript.join("\n")
12
+ end
13
+
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,5 @@
1
+ module Growl
2
+ module Rails
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
data/vendor/.DS_Store ADDED
Binary file
@@ -0,0 +1,272 @@
1
+ // Generated by CoffeeScript 1.10.0
2
+
3
+ /*
4
+ jQuery Growl
5
+ Copyright 2015 Kevin Sylvestre
6
+ 1.3.2
7
+ */
8
+
9
+ (function() {
10
+ "use strict";
11
+ var $, Animation, Growl,
12
+ bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
13
+
14
+ $ = jQuery;
15
+
16
+ Animation = (function() {
17
+ function Animation() {}
18
+
19
+ Animation.transitions = {
20
+ "webkitTransition": "webkitTransitionEnd",
21
+ "mozTransition": "mozTransitionEnd",
22
+ "oTransition": "oTransitionEnd",
23
+ "transition": "transitionend"
24
+ };
25
+
26
+ Animation.transition = function($el) {
27
+ var el, ref, result, type;
28
+ el = $el[0];
29
+ ref = this.transitions;
30
+ for (type in ref) {
31
+ result = ref[type];
32
+ if (el.style[type] != null) {
33
+ return result;
34
+ }
35
+ }
36
+ };
37
+
38
+ return Animation;
39
+
40
+ })();
41
+
42
+ Growl = (function() {
43
+ Growl.settings = {
44
+ namespace: 'growl',
45
+ duration: 3200,
46
+ close: "&#215;",
47
+ location: "default",
48
+ style: "default",
49
+ size: "medium",
50
+ delayOnHover: true
51
+ };
52
+
53
+ Growl.growl = function(settings) {
54
+ if (settings == null) {
55
+ settings = {};
56
+ }
57
+ this.initialize();
58
+ return new Growl(settings);
59
+ };
60
+
61
+ Growl.initialize = function() {
62
+ return $("body:not(:has(#growls))").append('<div id="growls" />');
63
+ };
64
+
65
+ function Growl(settings) {
66
+ if (settings == null) {
67
+ settings = {};
68
+ }
69
+ this.container = bind(this.container, this);
70
+ this.content = bind(this.content, this);
71
+ this.html = bind(this.html, this);
72
+ this.$growl = bind(this.$growl, this);
73
+ this.$growls = bind(this.$growls, this);
74
+ this.animate = bind(this.animate, this);
75
+ this.remove = bind(this.remove, this);
76
+ this.dismiss = bind(this.dismiss, this);
77
+ this.present = bind(this.present, this);
78
+ this.waitAndDismiss = bind(this.waitAndDismiss, this);
79
+ this.cycle = bind(this.cycle, this);
80
+ this.close = bind(this.close, this);
81
+ this.click = bind(this.click, this);
82
+ this.mouseLeave = bind(this.mouseLeave, this);
83
+ this.mouseEnter = bind(this.mouseEnter, this);
84
+ this.unbind = bind(this.unbind, this);
85
+ this.bind = bind(this.bind, this);
86
+ this.render = bind(this.render, this);
87
+ this.settings = $.extend({}, Growl.settings, settings);
88
+ this.$growls().attr('class', this.settings.location);
89
+ this.render();
90
+ }
91
+
92
+ Growl.prototype.render = function() {
93
+ var $growl;
94
+ $growl = this.$growl();
95
+ this.$growls().append($growl);
96
+ if (this.settings.fixed) {
97
+ this.present();
98
+ } else {
99
+ this.cycle();
100
+ }
101
+ };
102
+
103
+ Growl.prototype.bind = function($growl) {
104
+ if ($growl == null) {
105
+ $growl = this.$growl();
106
+ }
107
+ $growl.on("click", this.click);
108
+ if (this.settings.delayOnHover) {
109
+ $growl.on("mouseenter", this.mouseEnter);
110
+ $growl.on("mouseleave", this.mouseLeave);
111
+ }
112
+ return $growl.on("contextmenu", this.close).find("." + this.settings.namespace + "-close").on("click", this.close);
113
+ };
114
+
115
+ Growl.prototype.unbind = function($growl) {
116
+ if ($growl == null) {
117
+ $growl = this.$growl();
118
+ }
119
+ $growl.off("click", this.click);
120
+ if (this.settings.delayOnHover) {
121
+ $growl.off("mouseenter", this.mouseEnter);
122
+ $growl.off("mouseleave", this.mouseLeave);
123
+ }
124
+ return $growl.off("contextmenu", this.close).find("." + this.settings.namespace + "-close").off("click", this.close);
125
+ };
126
+
127
+ Growl.prototype.mouseEnter = function(event) {
128
+ var $growl;
129
+ $growl = this.$growl();
130
+ return $growl.stop(true, true);
131
+ };
132
+
133
+ Growl.prototype.mouseLeave = function(event) {
134
+ return this.waitAndDismiss();
135
+ };
136
+
137
+ Growl.prototype.click = function(event) {
138
+ if (this.settings.url != null) {
139
+ event.preventDefault();
140
+ event.stopPropagation();
141
+ return window.open(this.settings.url);
142
+ }
143
+ };
144
+
145
+ Growl.prototype.close = function(event) {
146
+ var $growl;
147
+ event.preventDefault();
148
+ event.stopPropagation();
149
+ $growl = this.$growl();
150
+ return $growl.stop().queue(this.dismiss).queue(this.remove);
151
+ };
152
+
153
+ Growl.prototype.cycle = function() {
154
+ var $growl;
155
+ $growl = this.$growl();
156
+ return $growl.queue(this.present).queue(this.waitAndDismiss());
157
+ };
158
+
159
+ Growl.prototype.waitAndDismiss = function() {
160
+ var $growl;
161
+ $growl = this.$growl();
162
+ return $growl.delay(this.settings.duration).queue(this.dismiss).queue(this.remove);
163
+ };
164
+
165
+ Growl.prototype.present = function(callback) {
166
+ var $growl;
167
+ $growl = this.$growl();
168
+ this.bind($growl);
169
+ return this.animate($growl, this.settings.namespace + "-incoming", 'out', callback);
170
+ };
171
+
172
+ Growl.prototype.dismiss = function(callback) {
173
+ var $growl;
174
+ $growl = this.$growl();
175
+ this.unbind($growl);
176
+ return this.animate($growl, this.settings.namespace + "-outgoing", 'in', callback);
177
+ };
178
+
179
+ Growl.prototype.remove = function(callback) {
180
+ this.$growl().remove();
181
+ return typeof callback === "function" ? callback() : void 0;
182
+ };
183
+
184
+ Growl.prototype.animate = function($element, name, direction, callback) {
185
+ var transition;
186
+ if (direction == null) {
187
+ direction = 'in';
188
+ }
189
+ transition = Animation.transition($element);
190
+ $element[direction === 'in' ? 'removeClass' : 'addClass'](name);
191
+ $element.offset().position;
192
+ $element[direction === 'in' ? 'addClass' : 'removeClass'](name);
193
+ if (callback == null) {
194
+ return;
195
+ }
196
+ if (transition != null) {
197
+ $element.one(transition, callback);
198
+ } else {
199
+ callback();
200
+ }
201
+ };
202
+
203
+ Growl.prototype.$growls = function() {
204
+ return this.$_growls != null ? this.$_growls : this.$_growls = $('#growls');
205
+ };
206
+
207
+ Growl.prototype.$growl = function() {
208
+ return this.$_growl != null ? this.$_growl : this.$_growl = $(this.html());
209
+ };
210
+
211
+ Growl.prototype.html = function() {
212
+ return this.container(this.content());
213
+ };
214
+
215
+ Growl.prototype.content = function() {
216
+ return "<div class='" + this.settings.namespace + "-close'>" + this.settings.close + "</div>\n<div class='" + this.settings.namespace + "-title'>" + this.settings.title + "</div>\n<div class='" + this.settings.namespace + "-message'>" + this.settings.message + "</div>";
217
+ };
218
+
219
+ Growl.prototype.container = function(content) {
220
+ return "<div class='" + this.settings.namespace + " " + this.settings.namespace + "-" + this.settings.style + " " + this.settings.namespace + "-" + this.settings.size + "'>\n " + content + "\n</div>";
221
+ };
222
+
223
+ return Growl;
224
+
225
+ })();
226
+
227
+ this.Growl = Growl;
228
+
229
+ $.growl = function(options) {
230
+ if (options == null) {
231
+ options = {};
232
+ }
233
+ return Growl.growl(options);
234
+ };
235
+
236
+ $.growl.error = function(options) {
237
+ var settings;
238
+ if (options == null) {
239
+ options = {};
240
+ }
241
+ settings = {
242
+ title: "Error!",
243
+ style: "error"
244
+ };
245
+ return $.growl($.extend(settings, options));
246
+ };
247
+
248
+ $.growl.notice = function(options) {
249
+ var settings;
250
+ if (options == null) {
251
+ options = {};
252
+ }
253
+ settings = {
254
+ title: "Notice!",
255
+ style: "notice"
256
+ };
257
+ return $.growl($.extend(settings, options));
258
+ };
259
+
260
+ $.growl.warning = function(options) {
261
+ var settings;
262
+ if (options == null) {
263
+ options = {};
264
+ }
265
+ settings = {
266
+ title: "Warning!",
267
+ style: "warning"
268
+ };
269
+ return $.growl($.extend(settings, options));
270
+ };
271
+
272
+ }).call(this);
@@ -0,0 +1,85 @@
1
+ /* jQuery Growl
2
+ * Copyright 2015 Kevin Sylvestre
3
+ * 1.3.2
4
+ */
5
+ #growls {
6
+ z-index: 50000;
7
+ position: fixed; }
8
+ #growls.default {
9
+ top: 10px;
10
+ right: 10px; }
11
+ #growls.tl {
12
+ top: 10px;
13
+ left: 10px; }
14
+ #growls.tr {
15
+ top: 10px;
16
+ right: 10px; }
17
+ #growls.bl {
18
+ bottom: 10px;
19
+ left: 10px; }
20
+ #growls.br {
21
+ bottom: 10px;
22
+ right: 10px; }
23
+ #growls.tc {
24
+ top: 10px;
25
+ right: 10px;
26
+ left: 10px; }
27
+ #growls.bc {
28
+ bottom: 10px;
29
+ right: 10px;
30
+ left: 10px; }
31
+ #growls.tc .growl, #growls.bc .growl {
32
+ margin-left: auto;
33
+ margin-right: auto; }
34
+
35
+ .growl {
36
+ opacity: 0.8;
37
+ filter: alpha(opacity=80);
38
+ position: relative;
39
+ border-radius: 4px;
40
+ -webkit-transition: all 0.4s ease-in-out;
41
+ -moz-transition: all 0.4s ease-in-out;
42
+ transition: all 0.4s ease-in-out; }
43
+ .growl.growl-incoming {
44
+ opacity: 0;
45
+ filter: alpha(opacity=0); }
46
+ .growl.growl-outgoing {
47
+ opacity: 0;
48
+ filter: alpha(opacity=0); }
49
+ .growl.growl-small {
50
+ width: 200px;
51
+ padding: 5px;
52
+ margin: 5px; }
53
+ .growl.growl-medium {
54
+ width: 250px;
55
+ padding: 10px;
56
+ margin: 10px; }
57
+ .growl.growl-large {
58
+ width: 300px;
59
+ padding: 15px;
60
+ margin: 15px; }
61
+ .growl.growl-default {
62
+ color: #FFF;
63
+ background: #7f8c8d; }
64
+ .growl.growl-error {
65
+ color: #FFF;
66
+ background: #C0392B; }
67
+ .growl.growl-notice {
68
+ color: #FFF;
69
+ background: #2ECC71; }
70
+ .growl.growl-warning {
71
+ color: #FFF;
72
+ background: #F39C12; }
73
+ .growl .growl-close {
74
+ cursor: pointer;
75
+ float: right;
76
+ font-size: 14px;
77
+ line-height: 18px;
78
+ font-weight: normal;
79
+ font-family: helvetica, verdana, sans-serif; }
80
+ .growl .growl-title {
81
+ font-size: 18px;
82
+ line-height: 24px; }
83
+ .growl .growl-message {
84
+ font-size: 14px;
85
+ line-height: 18px; }
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: growl-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Joshua Tyree
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-10-08 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.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: railties
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description:
56
+ email:
57
+ - joshuat@createthebridge.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".DS_Store"
63
+ - ".gitignore"
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - bin/console
69
+ - bin/setup
70
+ - growl-rails.gemspec
71
+ - lib/growl/rails.rb
72
+ - lib/growl/rails/helper.rb
73
+ - lib/growl/rails/version.rb
74
+ - vendor/.DS_Store
75
+ - vendor/assets/javascripts/growl.js
76
+ - vendor/assets/stylesheets/growl.css
77
+ homepage: https://github.com/JoshuaTyree/growl-rails.git
78
+ licenses:
79
+ - MIT
80
+ metadata: {}
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 2.5.1
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: Flash messages backed by jQuery Growl
101
+ test_files: []