redbox 1.0.3
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.
- data/.gitignore +1 -0
- data/README.markdown +105 -0
- data/Rakefile +48 -0
- data/VERSION +1 -0
- data/generators/redbox_static_files/USAGE +1 -0
- data/generators/redbox_static_files/redbox_static_files_generator.rb +9 -0
- data/generators/redbox_static_files/templates/redbox.css +36 -0
- data/generators/redbox_static_files/templates/redbox.js +119 -0
- data/generators/redbox_static_files/templates/redbox_spinner.gif +0 -0
- data/images/redbox_spinner.gif +0 -0
- data/init.rb +1 -0
- data/javascripts/redbox.js +119 -0
- data/lib/redbox.rb +1 -0
- data/lib/redbox_helper.rb +78 -0
- data/rails/init.rb +4 -0
- data/rails/install.rb +10 -0
- data/redbox.gemspec +59 -0
- data/stylesheets/redbox.css +36 -0
- data/tasks/redbox_tasks.rake +4 -0
- data/test/redbox_test.rb +8 -0
- metadata +83 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pkg/
|
data/README.markdown
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
## Redbox, the GemPlugin
|
2
|
+
|
3
|
+
I've GemPlugin-ized the Redbox library, as I much prefer using gems than I do using plugins.
|
4
|
+
|
5
|
+
## Using the Gem:
|
6
|
+
|
7
|
+
Install the gem from GemCutter
|
8
|
+
|
9
|
+
`gem install redbox`
|
10
|
+
|
11
|
+
Require the gem in your `config/environment.rb`
|
12
|
+
|
13
|
+
`config.gem 'redbox'`
|
14
|
+
|
15
|
+
Redbox requires some static files (an image, a CSS file, and a JS file) to run. Copy those over:
|
16
|
+
|
17
|
+
`$ script/genrate redbox_static_files`
|
18
|
+
|
19
|
+
Make sure you're loading the `redbox.css` and `redbox.js` files in your templates:
|
20
|
+
|
21
|
+
`javascript_include_tag 'redbox'`
|
22
|
+
`stylesheet_link_tag 'redbox'`
|
23
|
+
|
24
|
+
Then use the methods described below.
|
25
|
+
|
26
|
+
The original README follows:
|
27
|
+
|
28
|
+
## Redbox
|
29
|
+
|
30
|
+
Redbox is a very simple lightbox library, which is a way of display a model popup window which may contain any html, while the rest
|
31
|
+
of the page is faded out behind it. There are already many such libraries around for this, but:
|
32
|
+
|
33
|
+
* Often they do a little more than I wanted
|
34
|
+
* Many of them require a large javascript library that isn't prototype/scriptaculous. While I don't really have an opinion on which library is better, prototype is generally the one that we're using for rails, so I wanted a lightbox that took advantage of that, rather than forcing me to include another library which might class.
|
35
|
+
* Many of them where not compatible with rails' ajax system. I wanted to be able to do multi-page forms within a lightbox, using form_remote_tag, or any other means of reloading the lightbox div using ajax.
|
36
|
+
|
37
|
+
And of course, I wanted it all packaged as a nice rails plugin with handy helpers to use it.
|
38
|
+
|
39
|
+
|
40
|
+
## Credits
|
41
|
+
|
42
|
+
Much of the design, and some of the javascript and css are shamelessly ripped from the Thickbox library, by Cody Lindley.
|
43
|
+
|
44
|
+
This library should be considered to be a derivative work of Thickbox, and is also released under the MIT licence.
|
45
|
+
|
46
|
+
http://jquery.com/demo/thickbox/
|
47
|
+
|
48
|
+
Redbox Rails plugin development by Craig Ambrose
|
49
|
+
|
50
|
+
http://www.craigambrose.com
|
51
|
+
|
52
|
+
Additional code submissions, testing and bugfixes by:
|
53
|
+
* Brandon Keepers
|
54
|
+
* Niko Dittmann
|
55
|
+
* Randy Parker
|
56
|
+
* Julien Coupard
|
57
|
+
* Erin Staniland
|
58
|
+
(and many more)
|
59
|
+
|
60
|
+
## License
|
61
|
+
|
62
|
+
MIT License
|
63
|
+
|
64
|
+
http://www.opensource.org/licenses/mit-license.php
|
65
|
+
|
66
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so.
|
67
|
+
|
68
|
+
|
69
|
+
## Usage
|
70
|
+
|
71
|
+
Examine the public methods of `redbox_helper.rb`. They will all look familiar, much like the existing link helpers, except that they work with redboxes. You should not need to interact with the javascript directly.
|
72
|
+
|
73
|
+
Redbox provides three helpers which are used instead of a regular `link_to` helper when linking to a redbox.
|
74
|
+
|
75
|
+
`link_to_redbox(name, id, html_options = {})`
|
76
|
+
|
77
|
+
This is used if you already have an HTML element in your page (presumably hidden, but it doesn’t have to be) and you wish to use it for your redbox. Specify it by it’s id, and you’re in business.
|
78
|
+
|
79
|
+
`link_to_component_redbox(name, url_options = {}, html_options = {})`
|
80
|
+
|
81
|
+
This serves essentially the same purpose, but it uses the url_options supplied to load another page from your app into a hidden div on page load. This saves you having to do it yourself, but beware that there are definite performance implications to using components.
|
82
|
+
|
83
|
+
`link_to_remote_redbox(name, link_to_remote_options = {}, html_options = {})`
|
84
|
+
|
85
|
+
This waits until the link is clicked on to load the redbox using ajax, and displays loading graphics while it’s waiting.
|
86
|
+
|
87
|
+
`link_to_close_redbox(name, html_options = {})`
|
88
|
+
|
89
|
+
Allows you to put a link (presumably inside the redbox) to close it. Other way to close it is to refresh the entire page, but obviously closing it with javascript is spiffier.
|
90
|
+
|
91
|
+
## More Info
|
92
|
+
|
93
|
+
A static page is maintained for this plugin at:
|
94
|
+
|
95
|
+
http://www.craigambrose.com/projects/redbox
|
96
|
+
|
97
|
+
Updates are always posted at:
|
98
|
+
|
99
|
+
http://blog.craigambrose.com
|
100
|
+
|
101
|
+
Bugs, once you have tracked down the exact problem and can reproduce a failure case, can be reported to:
|
102
|
+
|
103
|
+
craig@craigambrose.com
|
104
|
+
|
105
|
+
If you find this plugin useful, you can give something back to the community by examining your own code and seeing what bits of functionality are generic enough to be useful as a rails plugin. Releasing rails plugins is dead simple, and helps us all do better work.
|
data/Rakefile
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
require 'ftools'
|
5
|
+
|
6
|
+
desc 'Default: run unit tests.'
|
7
|
+
task :default => :test
|
8
|
+
|
9
|
+
desc 'Test the redbox plugin.'
|
10
|
+
Rake::TestTask.new(:test) do |t|
|
11
|
+
t.libs << 'lib'
|
12
|
+
t.pattern = 'test/**/*_test.rb'
|
13
|
+
t.verbose = true
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'Generate documentation for the redbox plugin.'
|
17
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
18
|
+
rdoc.rdoc_dir = 'rdoc'
|
19
|
+
rdoc.title = 'Redbox'
|
20
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
21
|
+
rdoc.rdoc_files.include('README')
|
22
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "Update redbox javascript and css files"
|
26
|
+
task :update_scripts => [] do |t|
|
27
|
+
redbox_dir = File.expand_path(".")
|
28
|
+
root_dir = File.join(redbox_dir, '..', '..', '..')
|
29
|
+
File.copy File.join(redbox_dir, 'javascripts', 'redbox.js'), File.join(root_dir, 'public', 'javascripts', 'redbox.js')
|
30
|
+
File.copy File.join(redbox_dir, 'stylesheets', 'redbox.css'), File.join(root_dir, 'public', 'stylesheets', 'redbox.css')
|
31
|
+
File.copy File.join(redbox_dir, 'images', 'redbox_spinner.gif'), File.join(root_dir, 'public', 'images', 'redbox_spinner.gif')
|
32
|
+
|
33
|
+
puts "Updated Scripts."
|
34
|
+
end
|
35
|
+
|
36
|
+
begin
|
37
|
+
require 'jeweler'
|
38
|
+
Jeweler::Tasks.new do |gemspec|
|
39
|
+
gemspec.name = "redbox"
|
40
|
+
gemspec.summary = "A rails-compatible lightbox effect."
|
41
|
+
gemspec.description = "Provides helper methods to call and dismiss a lightbox-style page overlay."
|
42
|
+
gemspec.email = %w(jon@joncanady.com craig@craigambrose.com)
|
43
|
+
gemspec.homepage = "http://github.com/joncanady/redbox"
|
44
|
+
gemspec.authors = ["Craig Ambrose"]
|
45
|
+
end
|
46
|
+
rescue LoadError
|
47
|
+
puts "Jeweler not available. Install it with: gem install jeweler"
|
48
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.3
|
@@ -0,0 +1 @@
|
|
1
|
+
Copies the Redbox images, stylesheets, and javascript into the proper places under your public/ dir.
|
@@ -0,0 +1,9 @@
|
|
1
|
+
class RedboxStaticFilesGenerator < Rails::Generator::Base
|
2
|
+
def manifest
|
3
|
+
record do |m|
|
4
|
+
m.file "redbox.css", "public/stylesheets/redbox.css"
|
5
|
+
m.file "redbox.js", "public/javascripts/redbox.js"
|
6
|
+
m.file "redbox_spinner.gif", "public/images/redbox_spinner.gif"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#RB_overlay {
|
2
|
+
position: absolute;
|
3
|
+
z-index:100;
|
4
|
+
width: 100%;
|
5
|
+
height: 100%;
|
6
|
+
top: 0;
|
7
|
+
left: 0;
|
8
|
+
right: 0;
|
9
|
+
bottom: 0;
|
10
|
+
min-height:100%;
|
11
|
+
background-color: #000;
|
12
|
+
opacity: .6;
|
13
|
+
filter: alpha(opacity=60);
|
14
|
+
}
|
15
|
+
|
16
|
+
#RB_loading {
|
17
|
+
z-index: 101;
|
18
|
+
width: 70px;
|
19
|
+
margin-left: auto;
|
20
|
+
margin-right: auto;
|
21
|
+
margin-top: 200px;
|
22
|
+
padding-bottom: 30px;
|
23
|
+
text-align: center;
|
24
|
+
background: url(../images/redbox_spinner.gif) no-repeat bottom center;
|
25
|
+
}
|
26
|
+
|
27
|
+
#RB_window {
|
28
|
+
z-index: 102;
|
29
|
+
background-color: #FFFFFF;
|
30
|
+
display: block;
|
31
|
+
text-align: left;
|
32
|
+
overflow: hidden;
|
33
|
+
margin: 20px auto 0 auto;
|
34
|
+
position:fixed;
|
35
|
+
position: absolute;
|
36
|
+
}
|
@@ -0,0 +1,119 @@
|
|
1
|
+
|
2
|
+
var RedBox = {
|
3
|
+
|
4
|
+
showInline: function(id)
|
5
|
+
{
|
6
|
+
this.showOverlay();
|
7
|
+
new Effect.Appear('RB_window', {duration: 0.4, queue: 'end'});
|
8
|
+
Element.scrollTo('RB_window');
|
9
|
+
this.cloneWindowContents(id);
|
10
|
+
},
|
11
|
+
|
12
|
+
loading: function()
|
13
|
+
{
|
14
|
+
this.showOverlay();
|
15
|
+
Element.show('RB_loading');
|
16
|
+
this.setWindowPosition();
|
17
|
+
},
|
18
|
+
|
19
|
+
addHiddenContent: function(id)
|
20
|
+
{
|
21
|
+
this.removeChildrenFromNode($('RB_window'));
|
22
|
+
this.moveChildren($(id), $('RB_window'));
|
23
|
+
Element.hide('RB_loading');
|
24
|
+
new Effect.Appear('RB_window', {duration: 0.4, queue: 'end'});
|
25
|
+
Element.scrollTo('RB_window');
|
26
|
+
this.setWindowPosition();
|
27
|
+
},
|
28
|
+
|
29
|
+
close: function()
|
30
|
+
{
|
31
|
+
new Effect.Fade('RB_window', {duration: 0.4});
|
32
|
+
new Effect.Fade('RB_overlay', {duration: 0.4});
|
33
|
+
},
|
34
|
+
|
35
|
+
showOverlay: function()
|
36
|
+
{
|
37
|
+
if ($('RB_redbox'))
|
38
|
+
{
|
39
|
+
Element.update('RB_redbox', "");
|
40
|
+
new Insertion.Top($('RB_redbox'), '<div id="RB_window" style="display: none;"></div><div id="RB_overlay" style="display: none;"></div>');
|
41
|
+
}
|
42
|
+
else
|
43
|
+
{
|
44
|
+
new Insertion.Bottom(document.body, '<div id="RB_redbox" align="center"><div id="RB_window" style="display: none;"></div><div id="RB_overlay" style="display: none;"></div></div>');
|
45
|
+
}
|
46
|
+
new Insertion.Top('RB_overlay', '<div id="RB_loading" style="display: none"></div>');
|
47
|
+
|
48
|
+
this.setOverlaySize();
|
49
|
+
new Effect.Appear('RB_overlay', {duration: 0.4, to: 0.6, queue: 'end'});
|
50
|
+
},
|
51
|
+
|
52
|
+
setOverlaySize: function()
|
53
|
+
{
|
54
|
+
if (window.innerHeight && window.scrollMaxY)
|
55
|
+
{
|
56
|
+
yScroll = window.innerHeight + window.scrollMaxY;
|
57
|
+
}
|
58
|
+
else if (document.body.scrollHeight > document.body.offsetHeight)
|
59
|
+
{ // all but Explorer Mac
|
60
|
+
yScroll = document.body.scrollHeight;
|
61
|
+
}
|
62
|
+
else
|
63
|
+
{ // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
|
64
|
+
yScroll = document.body.offsetHeight;
|
65
|
+
}
|
66
|
+
$("RB_overlay").style['height'] = yScroll +"px";
|
67
|
+
},
|
68
|
+
|
69
|
+
setWindowPosition: function()
|
70
|
+
{
|
71
|
+
var pagesize = this.getPageSize();
|
72
|
+
|
73
|
+
$("RB_window").style['width'] = 'auto';
|
74
|
+
$("RB_window").style['height'] = 'auto';
|
75
|
+
|
76
|
+
var dimensions = Element.getDimensions($("RB_window"));
|
77
|
+
var width = dimensions.width;
|
78
|
+
var height = dimensions.height;
|
79
|
+
|
80
|
+
$("RB_window").style['left'] = ((pagesize[0] - width)/2) + "px";
|
81
|
+
$("RB_window").style['top'] = ((pagesize[1] - height)/2) + "px";
|
82
|
+
},
|
83
|
+
|
84
|
+
|
85
|
+
getPageSize: function() {
|
86
|
+
var de = document.documentElement;
|
87
|
+
var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
|
88
|
+
var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
|
89
|
+
|
90
|
+
arrayPageSize = new Array(w,h)
|
91
|
+
return arrayPageSize;
|
92
|
+
},
|
93
|
+
|
94
|
+
removeChildrenFromNode: function(node)
|
95
|
+
{
|
96
|
+
while (node.hasChildNodes())
|
97
|
+
{
|
98
|
+
node.removeChild(node.firstChild);
|
99
|
+
}
|
100
|
+
},
|
101
|
+
|
102
|
+
moveChildren: function(source, destination)
|
103
|
+
{
|
104
|
+
while (source.hasChildNodes())
|
105
|
+
{
|
106
|
+
destination.appendChild(source.firstChild);
|
107
|
+
}
|
108
|
+
},
|
109
|
+
|
110
|
+
cloneWindowContents: function(id)
|
111
|
+
{
|
112
|
+
var content = $(id).cloneNode(true);
|
113
|
+
content.style['display'] = 'block';
|
114
|
+
$('RB_window').appendChild(content);
|
115
|
+
|
116
|
+
this.setWindowPosition();
|
117
|
+
}
|
118
|
+
|
119
|
+
}
|
Binary file
|
Binary file
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'rails/init.rb'
|
@@ -0,0 +1,119 @@
|
|
1
|
+
|
2
|
+
var RedBox = {
|
3
|
+
|
4
|
+
showInline: function(id)
|
5
|
+
{
|
6
|
+
this.showOverlay();
|
7
|
+
new Effect.Appear('RB_window', {duration: 0.4, queue: 'end'});
|
8
|
+
Element.scrollTo('RB_window');
|
9
|
+
this.cloneWindowContents(id);
|
10
|
+
},
|
11
|
+
|
12
|
+
loading: function()
|
13
|
+
{
|
14
|
+
this.showOverlay();
|
15
|
+
Element.show('RB_loading');
|
16
|
+
this.setWindowPosition();
|
17
|
+
},
|
18
|
+
|
19
|
+
addHiddenContent: function(id)
|
20
|
+
{
|
21
|
+
this.removeChildrenFromNode($('RB_window'));
|
22
|
+
this.moveChildren($(id), $('RB_window'));
|
23
|
+
Element.hide('RB_loading');
|
24
|
+
new Effect.Appear('RB_window', {duration: 0.4, queue: 'end'});
|
25
|
+
Element.scrollTo('RB_window');
|
26
|
+
this.setWindowPosition();
|
27
|
+
},
|
28
|
+
|
29
|
+
close: function()
|
30
|
+
{
|
31
|
+
new Effect.Fade('RB_window', {duration: 0.4});
|
32
|
+
new Effect.Fade('RB_overlay', {duration: 0.4});
|
33
|
+
},
|
34
|
+
|
35
|
+
showOverlay: function()
|
36
|
+
{
|
37
|
+
if ($('RB_redbox'))
|
38
|
+
{
|
39
|
+
Element.update('RB_redbox', "");
|
40
|
+
new Insertion.Top($('RB_redbox'), '<div id="RB_window" style="display: none;"></div><div id="RB_overlay" style="display: none;"></div>');
|
41
|
+
}
|
42
|
+
else
|
43
|
+
{
|
44
|
+
new Insertion.Bottom(document.body, '<div id="RB_redbox" align="center"><div id="RB_window" style="display: none;"></div><div id="RB_overlay" style="display: none;"></div></div>');
|
45
|
+
}
|
46
|
+
new Insertion.Top('RB_overlay', '<div id="RB_loading" style="display: none"></div>');
|
47
|
+
|
48
|
+
this.setOverlaySize();
|
49
|
+
new Effect.Appear('RB_overlay', {duration: 0.4, to: 0.6, queue: 'end'});
|
50
|
+
},
|
51
|
+
|
52
|
+
setOverlaySize: function()
|
53
|
+
{
|
54
|
+
if (window.innerHeight && window.scrollMaxY)
|
55
|
+
{
|
56
|
+
yScroll = window.innerHeight + window.scrollMaxY;
|
57
|
+
}
|
58
|
+
else if (document.body.scrollHeight > document.body.offsetHeight)
|
59
|
+
{ // all but Explorer Mac
|
60
|
+
yScroll = document.body.scrollHeight;
|
61
|
+
}
|
62
|
+
else
|
63
|
+
{ // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
|
64
|
+
yScroll = document.body.offsetHeight;
|
65
|
+
}
|
66
|
+
$("RB_overlay").style['height'] = yScroll +"px";
|
67
|
+
},
|
68
|
+
|
69
|
+
setWindowPosition: function()
|
70
|
+
{
|
71
|
+
var pagesize = this.getPageSize();
|
72
|
+
|
73
|
+
$("RB_window").style['width'] = 'auto';
|
74
|
+
$("RB_window").style['height'] = 'auto';
|
75
|
+
|
76
|
+
var dimensions = Element.getDimensions($("RB_window"));
|
77
|
+
var width = dimensions.width;
|
78
|
+
var height = dimensions.height;
|
79
|
+
|
80
|
+
$("RB_window").style['left'] = ((pagesize[0] - width)/2) + "px";
|
81
|
+
$("RB_window").style['top'] = ((pagesize[1] - height)/2) + "px";
|
82
|
+
},
|
83
|
+
|
84
|
+
|
85
|
+
getPageSize: function() {
|
86
|
+
var de = document.documentElement;
|
87
|
+
var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
|
88
|
+
var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
|
89
|
+
|
90
|
+
arrayPageSize = new Array(w,h)
|
91
|
+
return arrayPageSize;
|
92
|
+
},
|
93
|
+
|
94
|
+
removeChildrenFromNode: function(node)
|
95
|
+
{
|
96
|
+
while (node.hasChildNodes())
|
97
|
+
{
|
98
|
+
node.removeChild(node.firstChild);
|
99
|
+
}
|
100
|
+
},
|
101
|
+
|
102
|
+
moveChildren: function(source, destination)
|
103
|
+
{
|
104
|
+
while (source.hasChildNodes())
|
105
|
+
{
|
106
|
+
destination.appendChild(source.firstChild);
|
107
|
+
}
|
108
|
+
},
|
109
|
+
|
110
|
+
cloneWindowContents: function(id)
|
111
|
+
{
|
112
|
+
var content = $(id).cloneNode(true);
|
113
|
+
content.style['display'] = 'block';
|
114
|
+
$('RB_window').appendChild(content);
|
115
|
+
|
116
|
+
this.setWindowPosition();
|
117
|
+
}
|
118
|
+
|
119
|
+
}
|
data/lib/redbox.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Redbox
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module RedboxHelper
|
2
|
+
|
3
|
+
def link_to_redbox(name, id, html_options = {})
|
4
|
+
@uses_redbox = true
|
5
|
+
link_to_function name, "RedBox.showInline('#{id.to_s}')", html_options
|
6
|
+
end
|
7
|
+
|
8
|
+
def link_to_component_redbox(name, url_options = {}, html_options = {})
|
9
|
+
@uses_redbox = true
|
10
|
+
id = id_from_url(url_options, html_options[:id])
|
11
|
+
link_to_redbox(name, id, html_options) + content_tag("span", render_component(url_options), :id => id, :style => 'display: none;')
|
12
|
+
end
|
13
|
+
|
14
|
+
def link_to_remote_redbox(name, link_to_remote_options = {}, html_options = {})
|
15
|
+
@uses_redbox = true
|
16
|
+
id = id_from_url(link_to_remote_options[:url], html_options[:id])
|
17
|
+
hidden_content_id = "hidden_content_#{id}"
|
18
|
+
link_to_remote_options = redbox_remote_options(link_to_remote_options, hidden_content_id)
|
19
|
+
|
20
|
+
return build_hidden_content(hidden_content_id) + link_to_remote(name, link_to_remote_options, html_options)
|
21
|
+
end
|
22
|
+
|
23
|
+
def link_to_close_redbox(name, html_options = {})
|
24
|
+
@uses_redbox = true
|
25
|
+
link_to_function name, 'RedBox.close()', html_options
|
26
|
+
end
|
27
|
+
|
28
|
+
def button_to_close_redbox(name, html_options = {})
|
29
|
+
@uses_redbox = true
|
30
|
+
button_to_function name, 'RedBox.close()', html_options
|
31
|
+
end
|
32
|
+
|
33
|
+
def launch_remote_redbox(link_to_remote_options = {}, html_options = {})
|
34
|
+
@uses_redbox = true
|
35
|
+
id = id_from_url(link_to_remote_options[:url], html_options[:id])
|
36
|
+
hidden_content_id = "hidden_content_#{id}"
|
37
|
+
hidden_content = build_hidden_content(hidden_content_id)
|
38
|
+
link_to_remote_options = redbox_remote_options(link_to_remote_options, hidden_content_id)
|
39
|
+
|
40
|
+
return build_hidden_content(hidden_content_id) + javascript_tag(remote_function(link_to_remote_options))
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def id_from_url(url_options, link_id)
|
46
|
+
result = ''
|
47
|
+
result = link_id.to_s + '_' unless link_id.nil?
|
48
|
+
|
49
|
+
if url_options.nil?
|
50
|
+
raise ArgumentError, 'You are trying to create a RedBox link without specifying a valid url.'
|
51
|
+
elsif url_options.is_a? String
|
52
|
+
result + url_options.delete(":/")
|
53
|
+
else
|
54
|
+
result + url_to_id_string(url_options.values.join('_'))
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def url_to_id_string(value)
|
59
|
+
value.sub(/[?=&]/, '')
|
60
|
+
end
|
61
|
+
|
62
|
+
def build_hidden_content(hidden_content_id)
|
63
|
+
content_tag("div", '', :id => hidden_content_id, :style => 'display: none;')
|
64
|
+
end
|
65
|
+
|
66
|
+
def redbox_remote_options(remote_options, hidden_content_id)
|
67
|
+
remote_options[:update] = hidden_content_id unless remote_options.key?(:update)
|
68
|
+
remote_options[:loading] = "RedBox.loading();" + remote_options[:loading].to_s
|
69
|
+
if remote_options[:update]
|
70
|
+
remote_options[:complete] = "RedBox.addHiddenContent('#{hidden_content_id}'); " + remote_options[:complete].to_s
|
71
|
+
else
|
72
|
+
remote_options[:complete] = "RedBox.activateRBWindow(); " + remote_options[:complete].to_s
|
73
|
+
end
|
74
|
+
remote_options
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
end
|
data/rails/init.rb
ADDED
data/rails/install.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# Install hook code here
|
2
|
+
|
3
|
+
require 'ftools'
|
4
|
+
|
5
|
+
redbox_dir = File.dirname(__FILE__)
|
6
|
+
root_dir = File.join(redbox_dir, '..', '..', '..')
|
7
|
+
|
8
|
+
File.copy File.join(redbox_dir, 'javascripts', 'redbox.js'), File.join(root_dir, 'public', 'javascripts', 'redbox.js')
|
9
|
+
File.copy File.join(redbox_dir, 'stylesheets', 'redbox.css'), File.join(root_dir, 'public', 'stylesheets', 'redbox.css')
|
10
|
+
File.copy File.join(redbox_dir, 'images', 'redbox_spinner.gif'), File.join(root_dir, 'public', 'images', 'redbox_spinner.gif')
|
data/redbox.gemspec
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{redbox}
|
8
|
+
s.version = "1.0.3"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Craig Ambrose"]
|
12
|
+
s.date = %q{2010-03-17}
|
13
|
+
s.description = %q{Provides helper methods to call and dismiss a lightbox-style page overlay.}
|
14
|
+
s.email = ["jon@joncanady.com", "craig@craigambrose.com"]
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.markdown"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
".gitignore",
|
20
|
+
"README.markdown",
|
21
|
+
"Rakefile",
|
22
|
+
"VERSION",
|
23
|
+
"generators/redbox_static_files/USAGE",
|
24
|
+
"generators/redbox_static_files/redbox_static_files_generator.rb",
|
25
|
+
"generators/redbox_static_files/templates/redbox.css",
|
26
|
+
"generators/redbox_static_files/templates/redbox.js",
|
27
|
+
"generators/redbox_static_files/templates/redbox_spinner.gif",
|
28
|
+
"images/redbox_spinner.gif",
|
29
|
+
"init.rb",
|
30
|
+
"javascripts/redbox.js",
|
31
|
+
"lib/redbox.rb",
|
32
|
+
"lib/redbox_helper.rb",
|
33
|
+
"rails/init.rb",
|
34
|
+
"rails/install.rb",
|
35
|
+
"redbox.gemspec",
|
36
|
+
"stylesheets/redbox.css",
|
37
|
+
"tasks/redbox_tasks.rake",
|
38
|
+
"test/redbox_test.rb"
|
39
|
+
]
|
40
|
+
s.homepage = %q{http://github.com/joncanady/redbox}
|
41
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
42
|
+
s.require_paths = ["lib"]
|
43
|
+
s.rubygems_version = %q{1.3.6}
|
44
|
+
s.summary = %q{A rails-compatible lightbox effect.}
|
45
|
+
s.test_files = [
|
46
|
+
"test/redbox_test.rb"
|
47
|
+
]
|
48
|
+
|
49
|
+
if s.respond_to? :specification_version then
|
50
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
51
|
+
s.specification_version = 3
|
52
|
+
|
53
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
54
|
+
else
|
55
|
+
end
|
56
|
+
else
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#RB_overlay {
|
2
|
+
position: absolute;
|
3
|
+
z-index:100;
|
4
|
+
width: 100%;
|
5
|
+
height: 100%;
|
6
|
+
top: 0;
|
7
|
+
left: 0;
|
8
|
+
right: 0;
|
9
|
+
bottom: 0;
|
10
|
+
min-height:100%;
|
11
|
+
background-color: #000;
|
12
|
+
opacity: .6;
|
13
|
+
filter: alpha(opacity=60);
|
14
|
+
}
|
15
|
+
|
16
|
+
#RB_loading {
|
17
|
+
z-index: 101;
|
18
|
+
width: 70px;
|
19
|
+
margin-left: auto;
|
20
|
+
margin-right: auto;
|
21
|
+
margin-top: 200px;
|
22
|
+
padding-bottom: 30px;
|
23
|
+
text-align: center;
|
24
|
+
background: url(../images/redbox_spinner.gif) no-repeat bottom center;
|
25
|
+
}
|
26
|
+
|
27
|
+
#RB_window {
|
28
|
+
z-index: 102;
|
29
|
+
background-color: #FFFFFF;
|
30
|
+
display: block;
|
31
|
+
text-align: left;
|
32
|
+
overflow: hidden;
|
33
|
+
margin: 20px auto 0 auto;
|
34
|
+
position:fixed;
|
35
|
+
position: absolute;
|
36
|
+
}
|
data/test/redbox_test.rb
ADDED
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: redbox
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 0
|
8
|
+
- 3
|
9
|
+
version: 1.0.3
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Craig Ambrose
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-03-17 00:00:00 -04:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: Provides helper methods to call and dismiss a lightbox-style page overlay.
|
22
|
+
email:
|
23
|
+
- jon@joncanady.com
|
24
|
+
- craig@craigambrose.com
|
25
|
+
executables: []
|
26
|
+
|
27
|
+
extensions: []
|
28
|
+
|
29
|
+
extra_rdoc_files:
|
30
|
+
- README.markdown
|
31
|
+
files:
|
32
|
+
- .gitignore
|
33
|
+
- README.markdown
|
34
|
+
- Rakefile
|
35
|
+
- VERSION
|
36
|
+
- generators/redbox_static_files/USAGE
|
37
|
+
- generators/redbox_static_files/redbox_static_files_generator.rb
|
38
|
+
- generators/redbox_static_files/templates/redbox.css
|
39
|
+
- generators/redbox_static_files/templates/redbox.js
|
40
|
+
- generators/redbox_static_files/templates/redbox_spinner.gif
|
41
|
+
- images/redbox_spinner.gif
|
42
|
+
- init.rb
|
43
|
+
- javascripts/redbox.js
|
44
|
+
- lib/redbox.rb
|
45
|
+
- lib/redbox_helper.rb
|
46
|
+
- rails/init.rb
|
47
|
+
- rails/install.rb
|
48
|
+
- redbox.gemspec
|
49
|
+
- stylesheets/redbox.css
|
50
|
+
- tasks/redbox_tasks.rake
|
51
|
+
- test/redbox_test.rb
|
52
|
+
has_rdoc: true
|
53
|
+
homepage: http://github.com/joncanady/redbox
|
54
|
+
licenses: []
|
55
|
+
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options:
|
58
|
+
- --charset=UTF-8
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
segments:
|
66
|
+
- 0
|
67
|
+
version: "0"
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
segments:
|
73
|
+
- 0
|
74
|
+
version: "0"
|
75
|
+
requirements: []
|
76
|
+
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 1.3.6
|
79
|
+
signing_key:
|
80
|
+
specification_version: 3
|
81
|
+
summary: A rails-compatible lightbox effect.
|
82
|
+
test_files:
|
83
|
+
- test/redbox_test.rb
|