dvl-flashes 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.ruby-version +1 -0
- data/Gemfile +2 -0
- data/LICENSE.md +20 -0
- data/README.md +36 -0
- data/dvl-flashes.gemspec +27 -0
- data/lib/dvl/flashes/version.rb +5 -0
- data/lib/dvl/flashes/views/flashes.rb +16 -0
- data/lib/dvl/flashes.rb +12 -0
- data/preview/app.rb +49 -0
- data/script/bootstrap +43 -0
- data/script/preview +3 -0
- data/vendor/assets/javascripts/dvl/flashes.coffee +44 -0
- data/vendor/assets/stylesheets/dvl/flashes.scss +73 -0
- metadata +155 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 24a6068bf2afaa7eb4db3b7696f4fa6048696328
|
4
|
+
data.tar.gz: f6b2a1ea0c0cdfb88ee6ad09cb13cd6967c06614
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e5f03d05b079d3990aa2de9bb122ff6caa0798da30849696aeebd76fc5ba84faa97d90fc05eeae32c62be25b8e25deffde96e4d49dc377d0d76f36cbf19e9498
|
7
|
+
data.tar.gz: c17fab77e892d9421d6900c8674dad50f2f2c4358c3ba9e7bb8a7bc4a0c328618e366d93abfbebbf592e44a9511a88fc9284aa8958592c961310b3624f523470
|
data/.gitignore
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.1
|
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2014 Department of Better Technology
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
dvl-flashes
|
2
|
+
====
|
3
|
+
|
4
|
+
Flash alerts for the DOBT View Layer.
|
5
|
+
|
6
|
+
## Usage
|
7
|
+
|
8
|
+
```
|
9
|
+
# Gemfile
|
10
|
+
gem 'dvl-flashes'
|
11
|
+
```
|
12
|
+
|
13
|
+
```
|
14
|
+
# assets/javascripts/application.css.scss
|
15
|
+
@import 'dvl/flashes';
|
16
|
+
```
|
17
|
+
|
18
|
+
```
|
19
|
+
# assets/javascripts/application.js
|
20
|
+
//= require dvl/flashes
|
21
|
+
```
|
22
|
+
|
23
|
+
```
|
24
|
+
# layouts/application.rb
|
25
|
+
widget Dvl::Flashes::Views::Flashes.new(flash: flash)
|
26
|
+
```
|
27
|
+
|
28
|
+
## Development
|
29
|
+
|
30
|
+
1. `script/bootstrap`
|
31
|
+
2. `script/preview`
|
32
|
+
3. Open http://localhost:4567 in your web browser
|
33
|
+
|
34
|
+
## License
|
35
|
+
|
36
|
+
MIT
|
data/dvl-flashes.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
$:.push File.expand_path('../lib', __FILE__)
|
2
|
+
|
3
|
+
# Maintain your gem's version:
|
4
|
+
require 'dvl/flashes/version'
|
5
|
+
|
6
|
+
# Describe your gem and declare its dependencies:
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = 'dvl-flashes'
|
9
|
+
s.version = Dvl::Flashes::VERSION
|
10
|
+
s.required_ruby_version = Gem::Requirement.new('>= 2.0.0')
|
11
|
+
s.authors = ['Adam Becker']
|
12
|
+
s.summary = 'Flash alerts for the DOBT View Layer.'
|
13
|
+
s.email = 'adam@dobt.co'
|
14
|
+
s.license = 'MIT'
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {features,spec}/*`.split("\n")
|
17
|
+
s.homepage = 'http://github.com/dobtco/dvl-flashes'
|
18
|
+
|
19
|
+
s.add_dependency 'activesupport'
|
20
|
+
s.add_dependency 'coffee-script'
|
21
|
+
s.add_dependency 'erector-rails4'
|
22
|
+
s.add_dependency 'sass'
|
23
|
+
|
24
|
+
s.add_development_dependency 'rerun', '0.10.0'
|
25
|
+
s.add_development_dependency 'sinatra', '1.4.5'
|
26
|
+
s.add_development_dependency 'sinatra-assetpack', '0.3.3'
|
27
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Dvl::Flashes::Views
|
2
|
+
class Flashes < Erector::Widget
|
3
|
+
|
4
|
+
needs :flash
|
5
|
+
|
6
|
+
def content
|
7
|
+
@flash.select { |k, v| k.to_s.in?(%w(success error info)) && v.present? }.each do |k, v|
|
8
|
+
div(class: "flash flash_#{k}") {
|
9
|
+
a.close '×'.html_safe
|
10
|
+
text v
|
11
|
+
}
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
data/lib/dvl/flashes.rb
ADDED
data/preview/app.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'sinatra/base'
|
2
|
+
require 'sinatra/assetpack'
|
3
|
+
require 'erector'
|
4
|
+
require 'active_support/all'
|
5
|
+
require 'dvl/flashes'
|
6
|
+
|
7
|
+
class App < Sinatra::Base
|
8
|
+
|
9
|
+
set :root, File.dirname(__FILE__)
|
10
|
+
|
11
|
+
register Sinatra::AssetPack
|
12
|
+
|
13
|
+
assets do
|
14
|
+
serve '/js', from: '../vendor/assets/javascripts'
|
15
|
+
serve '/css', from: '../vendor/assets/stylesheets'
|
16
|
+
end
|
17
|
+
|
18
|
+
get '/' do
|
19
|
+
Erector.inline {
|
20
|
+
rawtext '<!doctype html>'
|
21
|
+
html {
|
22
|
+
head {
|
23
|
+
link href: '/css/dvl/flashes.css', rel: 'stylesheet', type: 'text/css', media: 'all'
|
24
|
+
}
|
25
|
+
body {
|
26
|
+
# Uncomment to test rendering from existing HTML
|
27
|
+
# widget Dvl::Flashes::Views::Flashes.new(flash: { success: 'You did it!' })
|
28
|
+
|
29
|
+
ul {
|
30
|
+
li {
|
31
|
+
a 'Success', href: 'javascript:DvlFlash("success", "You did it!")'
|
32
|
+
}
|
33
|
+
li {
|
34
|
+
a 'Info', href: 'javascript:DvlFlash("info", "An informational message...")'
|
35
|
+
}
|
36
|
+
li {
|
37
|
+
a 'Error', href: 'javascript:DvlFlash("error", "Oh no, an error occured!")'
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
script src: '//code.jquery.com/jquery-1.11.1.min.js'
|
42
|
+
script src: '/js/dvl/flashes.js'
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}.to_html
|
46
|
+
end
|
47
|
+
|
48
|
+
run! if app_file == $0
|
49
|
+
end
|
data/script/bootstrap
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
#! /bin/bash
|
2
|
+
|
3
|
+
## Make sure we're in the project root
|
4
|
+
cd $(dirname "$0")/..
|
5
|
+
|
6
|
+
## Check dependencies
|
7
|
+
printf "Checking dependencies... "
|
8
|
+
|
9
|
+
deps=(
|
10
|
+
ruby
|
11
|
+
bundler
|
12
|
+
git
|
13
|
+
)
|
14
|
+
|
15
|
+
for i in "${deps[@]}"
|
16
|
+
do
|
17
|
+
:
|
18
|
+
if [ ! $(which $i) ]; then
|
19
|
+
printf "\nDependency check failed, file not in PATH: $i\n"
|
20
|
+
exit 1
|
21
|
+
fi
|
22
|
+
done
|
23
|
+
|
24
|
+
## Create .ruby-gemset if it doesn't exist
|
25
|
+
printf "Checking for .ruby-gemset... "
|
26
|
+
|
27
|
+
if [ ! -f .ruby-gemset ]; then
|
28
|
+
printf "\nWriting .ruby-gemset..."
|
29
|
+
printf 'dvl-flashes' >> .ruby-gemset
|
30
|
+
fi
|
31
|
+
|
32
|
+
printf "OK\n"
|
33
|
+
|
34
|
+
## Ensure RVM is using our ruby + gemset
|
35
|
+
source ~/.rvm/scripts/rvm
|
36
|
+
rvm use `cat .ruby-version`
|
37
|
+
rvm gemset use --create `cat .ruby-gemset`
|
38
|
+
|
39
|
+
## Bundle
|
40
|
+
printf "Bundling...\n"
|
41
|
+
bundle install
|
42
|
+
|
43
|
+
printf "\n\nSuccess!\n\n"
|
data/script/preview
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
TRANSITION_LENGTH = 300
|
2
|
+
FLASH_ALERT_LENGTH = 3500
|
3
|
+
|
4
|
+
# Grab alerts rendered by the server and apply our behavior to them
|
5
|
+
$ ->
|
6
|
+
$('.flash').each ->
|
7
|
+
DvlFlash $(@)
|
8
|
+
|
9
|
+
window.DvlFlash = (alertType, message, lengthInMilliseconds) ->
|
10
|
+
# Initialize from an existing alert
|
11
|
+
if alertType instanceof jQuery
|
12
|
+
$alert = alertType
|
13
|
+
else
|
14
|
+
$alert = $("""
|
15
|
+
<div class="flash flash_#{alertType}">
|
16
|
+
<a class='close'>×</a>
|
17
|
+
#{message}
|
18
|
+
</div>
|
19
|
+
""").appendTo("body")
|
20
|
+
|
21
|
+
setTimeout ( -> $alert.addClass 'in' ), 0
|
22
|
+
|
23
|
+
mousedOver = undefined
|
24
|
+
timeoutExpired = undefined
|
25
|
+
|
26
|
+
hide = ->
|
27
|
+
$alert.removeClass 'in'
|
28
|
+
setTimeout ( -> $alert.remove() ), TRANSITION_LENGTH
|
29
|
+
|
30
|
+
setTimeout ->
|
31
|
+
hide() unless mousedOver
|
32
|
+
timeoutExpired = true
|
33
|
+
, lengthInMilliseconds || FLASH_ALERT_LENGTH
|
34
|
+
|
35
|
+
$alert.on 'mouseover', ->
|
36
|
+
mousedOver = true
|
37
|
+
|
38
|
+
$alert.one 'mouseout', ->
|
39
|
+
mousedOver = undefined
|
40
|
+
hide() if timeoutExpired
|
41
|
+
|
42
|
+
$alert.on 'click', '.close', ->
|
43
|
+
mousedOver = undefined
|
44
|
+
hide()
|
@@ -0,0 +1,73 @@
|
|
1
|
+
$dvlFlashBackground: #efefef !default;
|
2
|
+
$dvlFlashCloseDarkColor: #aaa !default;
|
3
|
+
$dvlFlashCloseDarkHoverColor: #777 !default;
|
4
|
+
$dvlFlashCloseLightColor: #e5e5e5 !default;
|
5
|
+
$dvlFlashCloseLightHoverColor: #fff !default;
|
6
|
+
$dvlFlashErrorColor: #c12f2e !default;
|
7
|
+
$dvlFlashSuccessColor: #2aa828 !default;
|
8
|
+
$dvlFlashZIndex: 1031 !default; // above modal backdrop..
|
9
|
+
|
10
|
+
.flash {
|
11
|
+
position: fixed;
|
12
|
+
top: -100px;
|
13
|
+
transition: top 0.3s linear;
|
14
|
+
width: 95%;
|
15
|
+
left: 2.5%;
|
16
|
+
z-index: $dvlFlashZIndex;
|
17
|
+
background: $dvlFlashBackground;
|
18
|
+
padding: 0.5rem 1.5rem 0.5rem 1rem;
|
19
|
+
font-size: 0.9rem;
|
20
|
+
color: #333;
|
21
|
+
box-shadow: 1px 1px 1px 0 #333;
|
22
|
+
|
23
|
+
a {
|
24
|
+
color: #222;
|
25
|
+
text-decoration: underline;
|
26
|
+
font-weight: bold;
|
27
|
+
&:hover {
|
28
|
+
text-decoration: none;
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
.close {
|
33
|
+
position: absolute;
|
34
|
+
top: 1px;
|
35
|
+
right: 8px;
|
36
|
+
color: $dvlFlashCloseDarkColor;
|
37
|
+
font-size: 1.5rem;
|
38
|
+
text-decoration: none;
|
39
|
+
&:hover {
|
40
|
+
color: $dvlFlashCloseDarkHoverColor;
|
41
|
+
}
|
42
|
+
}
|
43
|
+
&.flash_error, &.flash_success {
|
44
|
+
color: #fff;
|
45
|
+
a {
|
46
|
+
color: #fff;
|
47
|
+
}
|
48
|
+
.close {
|
49
|
+
color: $dvlFlashCloseLightColor;
|
50
|
+
&:hover {
|
51
|
+
color: $dvlFlashCloseLightHoverColor;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
}
|
55
|
+
&.flash_error {
|
56
|
+
background: $dvlFlashErrorColor;
|
57
|
+
}
|
58
|
+
|
59
|
+
&.flash_success{
|
60
|
+
background: $dvlFlashSuccessColor;
|
61
|
+
}
|
62
|
+
&.in {
|
63
|
+
top: 14px;
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
@media only screen and (min-width: 768px) {
|
68
|
+
.flash {
|
69
|
+
width: 700px;
|
70
|
+
margin-left: -350px;
|
71
|
+
left: 50%;
|
72
|
+
}
|
73
|
+
}
|
metadata
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dvl-flashes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Adam Becker
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: coffee-script
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: erector-rails4
|
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
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: sass
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rerun
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.10.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.10.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: sinatra
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.4.5
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.4.5
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: sinatra-assetpack
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.3.3
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.3.3
|
111
|
+
description:
|
112
|
+
email: adam@dobt.co
|
113
|
+
executables: []
|
114
|
+
extensions: []
|
115
|
+
extra_rdoc_files: []
|
116
|
+
files:
|
117
|
+
- ".gitignore"
|
118
|
+
- ".ruby-version"
|
119
|
+
- Gemfile
|
120
|
+
- LICENSE.md
|
121
|
+
- README.md
|
122
|
+
- dvl-flashes.gemspec
|
123
|
+
- lib/dvl/flashes.rb
|
124
|
+
- lib/dvl/flashes/version.rb
|
125
|
+
- lib/dvl/flashes/views/flashes.rb
|
126
|
+
- preview/app.rb
|
127
|
+
- script/bootstrap
|
128
|
+
- script/preview
|
129
|
+
- vendor/assets/javascripts/dvl/flashes.coffee
|
130
|
+
- vendor/assets/stylesheets/dvl/flashes.scss
|
131
|
+
homepage: http://github.com/dobtco/dvl-flashes
|
132
|
+
licenses:
|
133
|
+
- MIT
|
134
|
+
metadata: {}
|
135
|
+
post_install_message:
|
136
|
+
rdoc_options: []
|
137
|
+
require_paths:
|
138
|
+
- lib
|
139
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: 2.0.0
|
144
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - ">="
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
requirements: []
|
150
|
+
rubyforge_project:
|
151
|
+
rubygems_version: 2.2.2
|
152
|
+
signing_key:
|
153
|
+
specification_version: 4
|
154
|
+
summary: Flash alerts for the DOBT View Layer.
|
155
|
+
test_files: []
|