flajax 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +27 -0
- data/Rakefile +27 -0
- data/app/assets/javascripts/bootstrap.js.coffee +4 -0
- data/app/assets/javascripts/flajax.js +21 -0
- data/app/assets/javascripts/flajax/application.js +15 -0
- data/app/assets/stylesheets/application.css +7 -0
- data/app/assets/stylesheets/flajax/application.css +13 -0
- data/app/helpers/flajax/flajax_helper.rb +20 -0
- data/app/helpers/flajax_helper.rb +20 -0
- data/app/views/flajax/_messages.html.haml +13 -0
- data/config/routes.rb +2 -0
- data/lib/flajax.rb +4 -0
- data/lib/flajax/engine.rb +11 -0
- data/lib/flajax/version.rb +3 -0
- data/lib/generators/flajax_partial/USAGE +8 -0
- data/lib/generators/flajax_partial/flajax_partial_generator.rb +7 -0
- data/lib/tasks/flajax_tasks.rake +7 -0
- metadata +211 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2012 YOURNAME
|
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.rdoc
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
= Flajax
|
2
|
+
|
3
|
+
== Description
|
4
|
+
|
5
|
+
Gem that provides ajax flash messages for you rails app.
|
6
|
+
|
7
|
+
== Installation
|
8
|
+
|
9
|
+
Add flajax to your gemfile
|
10
|
+
|
11
|
+
gem flajax
|
12
|
+
|
13
|
+
To get flajax working you should replace your messages partial with the one that flajax provides. You can customize this partial as much as you want and use it in your layout just make sure to preserve 4 containers with the following clases: x-flash-error, x-flash-warning, x-flash-notice and x-flash-mesagge with span.text inside so that flajax can find a place to insert the text.
|
14
|
+
|
15
|
+
you can generate the partial with the following command:
|
16
|
+
|
17
|
+
$ rails g flajax_partial
|
18
|
+
|
19
|
+
Make sure to render this partial!
|
20
|
+
|
21
|
+
Flajax also needs some js to work. In app/assets/javascript/application.js add:
|
22
|
+
|
23
|
+
//= require flajax
|
24
|
+
|
25
|
+
And thats it ... now you are able to flash in post/get ajax requests.
|
26
|
+
|
27
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'Flajax'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
Bundler::GemHelper.install_tasks
|
27
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
// Place all the behaviors and hooks related to the matching controller here.
|
2
|
+
// All this logic will automatically be available in application.js.
|
3
|
+
$(document).ready(function(event, request){
|
4
|
+
$('.hide').hide();
|
5
|
+
});
|
6
|
+
|
7
|
+
$(document).ajaxComplete(function(event, request){
|
8
|
+
scrollTop = request.getResponseHeader('X-Scroll-Top');
|
9
|
+
|
10
|
+
if(scrollTop){
|
11
|
+
$("html, body").animate({ scrollTop: 0 }, "slow");
|
12
|
+
}
|
13
|
+
|
14
|
+
$(['Error','Warning','Notice','Message']).each(function(i, header){
|
15
|
+
alertbox = $('.x-flash-' +header.toLowerCase())
|
16
|
+
value = request.getResponseHeader('X-Flash-' + header);
|
17
|
+
if(value){
|
18
|
+
alertbox.fadeIn().find('span.text').html(value);
|
19
|
+
}
|
20
|
+
});
|
21
|
+
});
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// the compiled file.
|
9
|
+
//
|
10
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
|
+
// GO AFTER THE REQUIRES BELOW.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require_tree .
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll automatically include all the stylesheets available in this directory
|
3
|
+
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
|
4
|
+
* the top of the compiled file, but it's generally better to create a new file per style scope.
|
5
|
+
*= require_self
|
6
|
+
*= require_tree .
|
7
|
+
*/
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Flajax
|
2
|
+
module FlajaxHelper
|
3
|
+
|
4
|
+
def add_flajax
|
5
|
+
# only run this in case it's an Ajax request.
|
6
|
+
return unless request.xhr?
|
7
|
+
|
8
|
+
# add different flashes to header
|
9
|
+
response.headers['X-Flash-Error'] = flash[:error] unless flash[:error].blank?
|
10
|
+
response.headers['X-Flash-Warning'] = flash[:warning] unless flash[:warning].blank?
|
11
|
+
response.headers['X-Flash-Notice'] = flash[:notice] unless flash[:notice].blank?
|
12
|
+
response.headers['X-Flash-Message'] = flash[:message] unless flash[:message].blank?
|
13
|
+
|
14
|
+
response.headers['X-Scroll-Top'] = true
|
15
|
+
|
16
|
+
# make sure flash does not appear on the next page
|
17
|
+
flash.discard
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Flajax
|
2
|
+
module FlajaxHelper
|
3
|
+
|
4
|
+
def add_flajax
|
5
|
+
# only run this in case it's an Ajax request.
|
6
|
+
return unless request.xhr?
|
7
|
+
|
8
|
+
# add different flashes to header
|
9
|
+
response.headers['X-Flash-Error'] = flash[:error] unless flash[:error].blank?
|
10
|
+
response.headers['X-Flash-Warning'] = flash[:warning] unless flash[:warning].blank?
|
11
|
+
response.headers['X-Flash-Notice'] = flash[:notice] unless flash[:notice].blank?
|
12
|
+
response.headers['X-Flash-Message'] = flash[:message] unless flash[:message].blank?
|
13
|
+
|
14
|
+
response.headers['X-Scroll-Top'] = true
|
15
|
+
|
16
|
+
# make sure flash does not appear on the next page
|
17
|
+
flash.discard
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
- {'error' => 'error', 'warning' => 'warning',
|
2
|
+
'notice' => 'success', 'message' => 'info'}.each do |header, classname|
|
3
|
+
%p{ :class => "alert alert-#{classname} x-flash-#{header} hide" }
|
4
|
+
%span.text
|
5
|
+
%a.close( data-dismiss="alert" ) ×
|
6
|
+
|
7
|
+
- flash.each do |name, msg|
|
8
|
+
- if msg.is_a?(String)
|
9
|
+
%div{:class => "alert alert-#{name == :notice ? "success" : "error"}"}
|
10
|
+
%a.close{"data-dismiss" => "alert"} ×
|
11
|
+
= content_tag :div, msg, :id => "flash_#{name}"
|
12
|
+
|
13
|
+
|
data/config/routes.rb
ADDED
data/lib/flajax.rb
ADDED
metadata
ADDED
@@ -0,0 +1,211 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: flajax
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Alan Moran
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-15 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.1'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.1'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: jquery-rails
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
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
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: haml
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec-rails
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: capybara
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: capybara-webkit
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: launchy
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: sqlite3
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: debugger
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
type: :development
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
description: ! ' Rails 3 engine that provides ajax flash messages for your rails
|
159
|
+
app.
|
160
|
+
|
161
|
+
'
|
162
|
+
email:
|
163
|
+
- bonzofenix@gmail.com
|
164
|
+
executables: []
|
165
|
+
extensions: []
|
166
|
+
extra_rdoc_files: []
|
167
|
+
files:
|
168
|
+
- app/assets/javascripts/bootstrap.js.coffee
|
169
|
+
- app/assets/javascripts/flajax/application.js
|
170
|
+
- app/assets/javascripts/flajax.js
|
171
|
+
- app/assets/stylesheets/application.css
|
172
|
+
- app/assets/stylesheets/flajax/application.css
|
173
|
+
- app/helpers/flajax/flajax_helper.rb
|
174
|
+
- app/helpers/flajax_helper.rb
|
175
|
+
- app/views/flajax/_messages.html.haml
|
176
|
+
- config/routes.rb
|
177
|
+
- lib/flajax/engine.rb
|
178
|
+
- lib/flajax/version.rb
|
179
|
+
- lib/flajax.rb
|
180
|
+
- lib/generators/flajax_partial/flajax_partial_generator.rb
|
181
|
+
- lib/generators/flajax_partial/USAGE
|
182
|
+
- lib/tasks/flajax_tasks.rake
|
183
|
+
- MIT-LICENSE
|
184
|
+
- Rakefile
|
185
|
+
- README.rdoc
|
186
|
+
homepage: https://github.com/bonzofenix/flajax
|
187
|
+
licenses: []
|
188
|
+
post_install_message:
|
189
|
+
rdoc_options: []
|
190
|
+
require_paths:
|
191
|
+
- lib
|
192
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
193
|
+
none: false
|
194
|
+
requirements:
|
195
|
+
- - ! '>='
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
version: '0'
|
198
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
199
|
+
none: false
|
200
|
+
requirements:
|
201
|
+
- - ! '>='
|
202
|
+
- !ruby/object:Gem::Version
|
203
|
+
version: '0'
|
204
|
+
requirements: []
|
205
|
+
rubyforge_project:
|
206
|
+
rubygems_version: 1.8.24
|
207
|
+
signing_key:
|
208
|
+
specification_version: 3
|
209
|
+
summary: Provides ajax flash messages for your rails app
|
210
|
+
test_files: []
|
211
|
+
has_rdoc:
|