facebox-render 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +2 -0
- data/Manifest.txt +7 -0
- data/README.txt +55 -0
- data/Rakefile +11 -0
- data/init.rb +1 -0
- data/lib/facebox_render.rb +39 -0
- data/lib/facebox_render_helper.rb +7 -0
- metadata +71 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
Author:: Wen-Tien Chang(mailto:ihower@handlino.com)
|
2
|
+
Copyright:: Copyright (c) 2008 Handlino Inc.
|
3
|
+
Licensed under the MIT: http://www.opensource.org/licenses/mit-license.php
|
4
|
+
|
5
|
+
= Description =
|
6
|
+
FaceboxRender plugin let you use lightbox seamlessly using Facebox library.
|
7
|
+
http://handlino.com/blog/2008/02/26/57/
|
8
|
+
|
9
|
+
= Install =
|
10
|
+
* gem install facebox-render
|
11
|
+
* cd /your_rails_app/vendor/plugin/
|
12
|
+
* gem unpack facebox-render
|
13
|
+
|
14
|
+
= USAGE =
|
15
|
+
You must install Facebox first(see http://famspam.com/facebox/).
|
16
|
+
|
17
|
+
1.Download jQuery (or you can try to install http://ennerchi.com/projects/jrails to replace Prototype library totally)
|
18
|
+
2.Download facebox
|
19
|
+
3.Copy facebox js file to /public/javascripts/
|
20
|
+
4.Copy facebox css file to /public/styleshees/
|
21
|
+
5.Copy facebox all image files to /public/facebox/
|
22
|
+
6.Config your layout (stylesheet_link_tag and javascript_include_tag) to add these js,css files
|
23
|
+
|
24
|
+
== Helper ==
|
25
|
+
We have facebox_link_to helper (it's will launch loading facebox first, send ajax request second)
|
26
|
+
or you can use link_to_remote, form_remote_tag...etc Ajax helper.
|
27
|
+
Don't use <a href="somelink" ref="facebox">
|
28
|
+
|
29
|
+
== Controller ==
|
30
|
+
Add "include FaceboxRender" to your controller,
|
31
|
+
or simply put it at /app/controllers/application.rb
|
32
|
+
|
33
|
+
Then in your action:
|
34
|
+
|
35
|
+
respond_to do |format|
|
36
|
+
format.html
|
37
|
+
format.js { render_to_facebox }
|
38
|
+
end
|
39
|
+
|
40
|
+
By Default render the html without layout,
|
41
|
+
otherwise you can pass options[:template], options[:action], options[:partial] or options[:html] string.
|
42
|
+
Passing options[:msg] will pulsate a message.
|
43
|
+
|
44
|
+
If block given, it will yield after facebox script, eg:
|
45
|
+
|
46
|
+
render_to_facebox do |page|
|
47
|
+
page << "alert('test')"
|
48
|
+
end
|
49
|
+
|
50
|
+
Besides render_facebox, we have close_facebox, redirect_from_facebox.
|
51
|
+
|
52
|
+
respond_to do |format|
|
53
|
+
format.html
|
54
|
+
format.js { close_facebox }
|
55
|
+
end
|
data/Rakefile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
|
6
|
+
Hoe.new('facebox-render', '0.9.0') do |p|
|
7
|
+
p.rubyforge_name = 'facebox-render' # if different than lowercase project name
|
8
|
+
p.developer('Wen-Tien Chang', 'ihower@handlino.com')
|
9
|
+
end
|
10
|
+
|
11
|
+
# vim: syntax=Ruby
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ActionController::Base.helper FaceboxRenderHelper
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module FaceboxRender
|
2
|
+
|
3
|
+
def render_to_facebox( options = {} )
|
4
|
+
options[:template] = "#{controller_name}/#{action_name}.html.erb" if options.empty? #default
|
5
|
+
|
6
|
+
action_string = render_to_string(:action => options[:action], :layout => false) if options[:action]
|
7
|
+
template_string = render_to_string(:template => options[:template], :layout => false) if options[:template]
|
8
|
+
|
9
|
+
render :update do |page|
|
10
|
+
page << "jQuery.facebox(#{action_string.to_json})" if options[:action]
|
11
|
+
page << "jQuery.facebox(#{template_string.to_json})" if options[:template]
|
12
|
+
page << "jQuery.facebox(#{(render :partial => options[:partial]).to_json})" if options[:partial]
|
13
|
+
page << "jQuery.facebox(#{options[:html].to_json})" if options[:html]
|
14
|
+
|
15
|
+
if options[:msg]
|
16
|
+
page << "jQuery('#facebox .content').prepend('<div class=\"message\">#{options[:msg]}</div>')"
|
17
|
+
end
|
18
|
+
|
19
|
+
yield(page) if block_given?
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# close an existed facebox, you can pass a block to update some messages
|
25
|
+
def close_facebox
|
26
|
+
render :update do |page|
|
27
|
+
page << "jQuery.facebox.close();"
|
28
|
+
yield(page) if block_given?
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# redirect_to other_path (i.e. reload page)
|
33
|
+
def redirect_from_facebox(url)
|
34
|
+
render :update do |page|
|
35
|
+
page.redirect_to url
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: facebox-render
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Wen-Tien Chang
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-04-08 00:00:00 +08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: hoe
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.5.1
|
23
|
+
version:
|
24
|
+
description: ""
|
25
|
+
email:
|
26
|
+
- ihower@handlino.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- History.txt
|
33
|
+
- Manifest.txt
|
34
|
+
- README.txt
|
35
|
+
files:
|
36
|
+
- History.txt
|
37
|
+
- init.rb
|
38
|
+
- Manifest.txt
|
39
|
+
- Rakefile
|
40
|
+
- lib/facebox_render.rb
|
41
|
+
- lib/facebox_render_helper.rb
|
42
|
+
- README.txt
|
43
|
+
has_rdoc: true
|
44
|
+
homepage: FaceboxRender plugin let you use lightbox seamlessly using Facebox library.
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options:
|
47
|
+
- --main
|
48
|
+
- README.txt
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: "0"
|
56
|
+
version:
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: "0"
|
62
|
+
version:
|
63
|
+
requirements: []
|
64
|
+
|
65
|
+
rubyforge_project: facebox-render
|
66
|
+
rubygems_version: 1.1.0
|
67
|
+
signing_key:
|
68
|
+
specification_version: 2
|
69
|
+
summary: ""
|
70
|
+
test_files: []
|
71
|
+
|