simple_flash_helper 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/app/assets/javascripts/flash_helper.js +35 -0
- data/app/assets/stylesheets/flash_helper.css.scss +23 -0
- data/app/helpers/flash_helper.rb +28 -0
- data/flash_helper.gemspec +23 -0
- data/lib/flash_helper/engine.rb +6 -0
- data/lib/flash_helper/version.rb +3 -0
- data/lib/flash_helper.rb +6 -0
- metadata +90 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 John Koht
|
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,29 @@
|
|
1
|
+
# FlashHelper
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'flash_helper'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install flash_helper
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,35 @@
|
|
1
|
+
$(document).ready(function() {
|
2
|
+
|
3
|
+
// Remove the flash notice on click
|
4
|
+
$('#flash_helper > div').live('click', function(e) {
|
5
|
+
$(this).fadeOut(function() {
|
6
|
+
$(this).hide();
|
7
|
+
});
|
8
|
+
});
|
9
|
+
|
10
|
+
// Automatically remove the div after 4.5 seconds
|
11
|
+
$('#flash_helper > div').delay(4500).fadeOut('fast', function(){
|
12
|
+
$(this).remove();
|
13
|
+
});
|
14
|
+
|
15
|
+
});
|
16
|
+
|
17
|
+
// Utility methods for the flash_helper
|
18
|
+
var flash_helper = {
|
19
|
+
|
20
|
+
// Dynamically create a flash notice
|
21
|
+
create: function(message, type){
|
22
|
+
var type = type ? "alert-" + type : "alert-success";
|
23
|
+
var $new_message = $('<div class="alert ' + type + '">'+message+'</div>');
|
24
|
+
$new_message.delay(2500).fadeOut('fast', function(){
|
25
|
+
$(this).remove();
|
26
|
+
});
|
27
|
+
$('#flash_helper').append($new_message)
|
28
|
+
},
|
29
|
+
|
30
|
+
// Clear all the flash notices
|
31
|
+
clear: function() {
|
32
|
+
$('#flash_helper').html('');
|
33
|
+
}
|
34
|
+
|
35
|
+
};
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#flash_helper {
|
2
|
+
position: fixed;
|
3
|
+
width: 700px;
|
4
|
+
top: 5px;
|
5
|
+
left: 50%;
|
6
|
+
margin-left: -350px;
|
7
|
+
z-index: 5101;
|
8
|
+
height: auto;
|
9
|
+
}
|
10
|
+
|
11
|
+
#flash_helper div {
|
12
|
+
border-radius: 4px;
|
13
|
+
display: block;
|
14
|
+
clear: both;
|
15
|
+
z-index: 5001;
|
16
|
+
height: auto;
|
17
|
+
background-color: rgba(0, 0, 0, .75);
|
18
|
+
margin-bottom:10px;
|
19
|
+
cursor:pointer;
|
20
|
+
padding: 10px;
|
21
|
+
color: $white;
|
22
|
+
text-align: center;
|
23
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module FlashHelper
|
2
|
+
|
3
|
+
# Flash Helper
|
4
|
+
# ------------------------------------------------------------------------------------------------------
|
5
|
+
|
6
|
+
# a robust method to display flash messages
|
7
|
+
def flash_helper keys=[:notice, :alert, :error]
|
8
|
+
# allow keys to be a symbol or an array of symbols
|
9
|
+
keys = [keys] unless keys.kind_of? Array
|
10
|
+
|
11
|
+
# Alias classes, mostly so that a notice can be a success, alert a notice, etc.
|
12
|
+
classes = {
|
13
|
+
notice: "alert-success",
|
14
|
+
alert: "alert-notice",
|
15
|
+
error: "alert-error"
|
16
|
+
}
|
17
|
+
|
18
|
+
# html from each message
|
19
|
+
html = ''
|
20
|
+
flash.each do |key, msg|
|
21
|
+
css_class = classes[key] || key
|
22
|
+
html = html + content_tag(:div, raw(msg + close_alert_btn), :class => "alert #{css_class}") if keys.index key
|
23
|
+
end
|
24
|
+
|
25
|
+
return (content_tag :div, html, id: "flash_helper").html_safe
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'flash_helper/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "simple_flash_helper"
|
8
|
+
spec.version = FlashHelper::VERSION
|
9
|
+
spec.authors = ["John Koht"]
|
10
|
+
spec.email = ["john@kohactive.com"]
|
11
|
+
spec.description = "Simple Flash Helper and Front-end Utilities"
|
12
|
+
spec.summary = "Simple Flash Helper and Front-end Utilities"
|
13
|
+
spec.homepage = "http://www.github.com/johnkoht/flash_helper"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
data/lib/flash_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: simple_flash_helper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- John Koht
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-07-18 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.3'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.3'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: Simple Flash Helper and Front-end Utilities
|
47
|
+
email:
|
48
|
+
- john@kohactive.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- Gemfile
|
55
|
+
- LICENSE.txt
|
56
|
+
- README.md
|
57
|
+
- Rakefile
|
58
|
+
- app/assets/javascripts/flash_helper.js
|
59
|
+
- app/assets/stylesheets/flash_helper.css.scss
|
60
|
+
- app/helpers/flash_helper.rb
|
61
|
+
- flash_helper.gemspec
|
62
|
+
- lib/flash_helper.rb
|
63
|
+
- lib/flash_helper/engine.rb
|
64
|
+
- lib/flash_helper/version.rb
|
65
|
+
homepage: http://www.github.com/johnkoht/flash_helper
|
66
|
+
licenses:
|
67
|
+
- MIT
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ! '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 1.8.25
|
87
|
+
signing_key:
|
88
|
+
specification_version: 3
|
89
|
+
summary: Simple Flash Helper and Front-end Utilities
|
90
|
+
test_files: []
|