restbox 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Richard Millan
1
+ Copyright (c) 2009 Richard Millan and Joseph Silvashy
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.rdoc CHANGED
@@ -1,14 +1,14 @@
1
1
  = Restbox
2
2
 
3
- == Prerequisites
4
- JQuery 1.3.2
5
-
6
3
  == Install
7
4
 
8
5
  To install as a Rails plugin, run this command.
9
6
 
10
7
  script/plugin install http://github.com/richardiux/restbox.git
11
8
 
9
+ === Prerequisites
10
+ JQuery 1.3.2
11
+
12
12
  == Setup
13
13
 
14
14
  in your layout after including jQuery:
@@ -16,20 +16,41 @@ in your layout after including jQuery:
16
16
  <%= javascript_include_tag 'restbox' %>
17
17
  <%= stylesheet_link_tag 'restbox' %>
18
18
 
19
- == Example
19
+ == Example on Rails Application
20
+
21
+ === In your application.js
22
+
23
+ $(document).ready(function() {
24
+ jQuery("a.restbox").restbox({})
25
+ }
20
26
 
21
27
  === In your view
22
28
 
23
- link_to "edit", order_path(@order), :class => "restbox"
29
+ <%= link_to "edit", order_path(@order), :class => "restbox" %>
30
+
24
31
 
32
+ === In your controller
33
+
34
+ def edit
35
+ @order = Order.find params[:id]
36
+ respond_to do |format|
37
+ format.html { }
38
+ format.js { }
39
+ end
40
+ end
41
+
42
+ === The JS view for the action (edit.js.erb)
43
+
44
+ You can use the following javascript helpers
25
45
 
26
46
  To put text in the restbox:
27
- <%= restbox({:content => "some text"})%>
47
+ <%= restbox(:content => 'some text') %>
28
48
 
29
49
  To put a partial inside the restbox:
30
- <%= restbox(:content => render(:partial => 'orders')) %>
50
+ <%= restbox(:content => render(:partial => 'form')) %>
31
51
 
32
- === With javascript
52
+
53
+ == With javascript
33
54
 
34
55
  To put content in the restbox
35
56
  $.restbox({content: "some text"})
@@ -38,6 +59,7 @@ To manually display loading restbox
38
59
  $.restbox({})
39
60
 
40
61
  == Upgrading
62
+
41
63
  === Reinstall the plugin
42
64
  script/plugin install http://github.com/richardiux/restbox.git -f
43
65
 
@@ -56,8 +78,6 @@ This project can be found on github at the following URL.
56
78
 
57
79
  http://github.com/richardiux/restbox
58
80
 
59
- Description goes here.
60
-
61
81
  == Note on Patches/Pull Requests
62
82
 
63
83
  * Fork the project.
@@ -71,4 +91,4 @@ Description goes here.
71
91
 
72
92
  == Copyright
73
93
 
74
- Copyright (c) 2009 Richard Millan. See LICENSE for details.
94
+ Copyright (c) 2009 Richard Millan & Joseph Silvashy. See LICENSE for details.
data/VERSION.yml ADDED
@@ -0,0 +1,5 @@
1
+ ---
2
+ :minor: 1
3
+ :patch: 0
4
+ :build:
5
+ :major: 0
@@ -0,0 +1,27 @@
1
+ class RestboxGenerator < Rails::Generator::Base
2
+
3
+ def initialize(*runtime_args)
4
+ super
5
+ end
6
+
7
+ def manifest
8
+ record do |m|
9
+ m.directory File.join('public', 'stylesheets')
10
+ m.template 'stylesheets/restbox.css', File.join('public', 'stylesheets', 'restbox.css')
11
+
12
+ m.directory File.join('public', 'javascripts')
13
+ m.template 'javascripts/restbox.js', File.join('public', 'javascripts', 'restbox.js')
14
+
15
+ m.directory File.join('public', 'images')
16
+ m.template 'images/loader.gif', File.join('public', 'images', 'loader.gif')
17
+ m.template 'images/restbox_close.png', File.join('public', 'images', 'restbox_close.png')
18
+ end
19
+ end
20
+
21
+ protected
22
+
23
+ def banner
24
+ %{Usage: #{$0} #{spec.name}\nCopies restbox.css, restbox.js, and images to it's proper location to public}
25
+ end
26
+
27
+ end
@@ -0,0 +1,79 @@
1
+ /*
2
+ * RestBox - Simple overlay to work with jQuery and Rails
3
+ * Copyright (c) 2009
4
+ * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
5
+ */
6
+
7
+ (function($) {
8
+
9
+ // initialize
10
+ $(function() {
11
+ content = 'loading...'
12
+ $('body').append('<div id=\'restbox_screen\'></div>\n<div id=\'restbox_container\'><div id=\'restbox_content\'></div></div>');
13
+ });
14
+
15
+ // load content
16
+ $.fn.restbox = function(options) {
17
+ return this.unbind("click").click(function(event) {
18
+ $.restbox(options);
19
+ $.ajax({
20
+ url: this.href,
21
+ dataType: "script"
22
+ });
23
+ event.preventDefault();
24
+ })
25
+ }
26
+
27
+ // set defaults
28
+ $.restbox = function(options) {
29
+ options = $.extend({
30
+ loadingClass: "restbox_loading",
31
+ content: $(content)
32
+ }, options);
33
+
34
+ // just fade screen in, load content when reqest includes content param
35
+ if (options.content.length != 0) {
36
+ $('div#restbox_screen').show();
37
+ $('div#restbox_container').show();
38
+ $('div#restbox_container div#restbox_content').removeClass(options.loadingClass).html(options.content);
39
+ $('div#restbox_container div#restbox_content').css({top: -($('div#restbox_content').height() + 100) / 2});
40
+ $('div#restbox_container div#restbox_content').animate({opacity: "100"}, 3000);
41
+
42
+ } else {
43
+ $('div#restbox_screen').fadeIn(120, function() {
44
+ $('div#restbox_container').show()
45
+ $('div#restbox_container div#restbox_content').addClass(options.loadingClass).html(content);
46
+ $('div#restbox_container div#restbox_content').css({top: -($('div#restbox_content').height() + 100) / 2});
47
+ $('div#restbox_container div#restbox_content').animate({opacity: "100"}, 3000);
48
+ });
49
+ }
50
+
51
+ close_button = $("<span id='restbox_close'></span>").click(function(event){
52
+ $.restbox_close();
53
+ event.preventDefault();
54
+ });
55
+
56
+ $('div#restbox_container div#restbox_content').prepend(close_button);
57
+
58
+ $(document).bind('keydown', function(e){
59
+ var keycode = e.keyCode;
60
+ var escapeKey = 27;
61
+ if (keycode == escapeKey) {
62
+ $.restbox_close();
63
+ }
64
+ })
65
+ };
66
+
67
+ $.restbox_close = function() {
68
+ $('div#restbox_screen').hide();
69
+ $('div#restbox_container').hide();
70
+ $('div#restbox_content').html('');
71
+ $(document).unbind('keydown');
72
+ }
73
+
74
+ // initialize
75
+ $(function() {
76
+ $(".restbox").restbox({});
77
+ });
78
+
79
+ })(jQuery);
File without changes
@@ -0,0 +1,14 @@
1
+ body {height:100%;}
2
+
3
+ div#restbox_screen {display:none; background:black; filter:alpha(opacity=50); opacity:.8; height:100%; width:100%; position:fixed; top:0; left:0; overflow:hidden;}
4
+ div#restbox_screen {background:-webkit-gradient(radial, center center, 1500, center center, 10, from(black), to(rgba(0,0,0,.4)), color-stop(0, black));}
5
+ /*div#restbox_screen {background:-moz-radial-gradient(45px 45px, 10px, 52px 50px, 30px, from(#A7D30C), to(rgba(1,159,98,0)), color-stop(0.90, #019F62));}*/
6
+
7
+ div#restbox_container {display:none; text-align:center; vertical-align: middle; position:absolute; top:50%; left:0px; width:100%; }
8
+ div#restbox_container div#restbox_content {width: 350px; position:relative; margin:auto; padding:20px 30px; font-size:13px; text-align:left; line-height:18px; color:#222; background:#fff; -webkit-border-radius:5px; -webkit-box-shadow:0px 1px 16px rgba(0,0,0,.6); -moz-box-shadow:black 0px 1px 8px; -moz-border-radius:5px;}
9
+ div#restbox_container div#restbox_content.restbox_loading {background:;}
10
+
11
+ div#restbox_container div#restbox_content span#restbox_close {position:absolute; top:-12px; left:-12px; height:25px; width:26px; background:url('/images/restbox/restbox_close.png') top left; text-indent:-9999px; cursor:pointer;}
12
+ div#restbox_container div#restbox_content a:active#restbox_close {background-position:bottom;}
13
+
14
+ div#restbox_content {opacity:0;}
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'restbox_view_helper.rb'
data/install.rb ADDED
@@ -0,0 +1 @@
1
+ puts "Run `./script/generate restbox` if you want (copies optional config file and some stylesheets into your app)"
@@ -0,0 +1,23 @@
1
+ require 'action_view'
2
+
3
+ module ActionView
4
+ module Helpers
5
+ module RestBoxHelper
6
+ def self.included(base)
7
+ base.class_eval do
8
+ include InstanceMethods
9
+ end
10
+ end
11
+ module InstanceMethods
12
+ def restbox(options = {})
13
+ content = escape_javascript(options[:content].to_s || '')
14
+ "jQuery.restbox({content: \"#{content}\"});"
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+ ActionView::Base.class_eval do
22
+ include ActionView::Helpers::RestBoxHelper
23
+ end
data/restbox.gemspec ADDED
@@ -0,0 +1,63 @@
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{restbox}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Richard Millan"]
12
+ s.date = %q{2009-11-19}
13
+ s.description = %q{Simple restful ajax overlay to work with jQuery and Rails}
14
+ s.email = %q{richardiux@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION.yml",
26
+ "generators/restbox/restbox_generator.rb",
27
+ "generators/restbox/templates/images/loader.gif",
28
+ "generators/restbox/templates/images/restbox_close.png",
29
+ "generators/restbox/templates/javascripts/restbox.js",
30
+ "generators/restbox/templates/restbox.rb",
31
+ "generators/restbox/templates/stylesheets/restbox.css",
32
+ "init.rb",
33
+ "install.rb",
34
+ "lib/restbox.rb",
35
+ "lib/restbox_view_helper.rb",
36
+ "restbox.gemspec",
37
+ "test/helper.rb",
38
+ "test/test_restbox.rb"
39
+ ]
40
+ s.homepage = %q{http://github.com/richardiux/restbox}
41
+ s.rdoc_options = ["--charset=UTF-8"]
42
+ s.require_paths = ["lib"]
43
+ s.rubygems_version = %q{1.3.5}
44
+ s.summary = %q{Simple restful ajax overlay to work with jQuery and Rails}
45
+ s.test_files = [
46
+ "test/helper.rb",
47
+ "test/test_restbox.rb"
48
+ ]
49
+
50
+ if s.respond_to? :specification_version then
51
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
52
+ s.specification_version = 3
53
+
54
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
55
+ s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
56
+ else
57
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
58
+ end
59
+ else
60
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
61
+ end
62
+ end
63
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Millan
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-03 00:00:00 -08:00
12
+ date: 2009-11-19 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -37,7 +37,18 @@ files:
37
37
  - LICENSE
38
38
  - README.rdoc
39
39
  - Rakefile
40
+ - VERSION.yml
41
+ - generators/restbox/restbox_generator.rb
42
+ - generators/restbox/templates/images/loader.gif
43
+ - generators/restbox/templates/images/restbox_close.png
44
+ - generators/restbox/templates/javascripts/restbox.js
45
+ - generators/restbox/templates/restbox.rb
46
+ - generators/restbox/templates/stylesheets/restbox.css
47
+ - init.rb
48
+ - install.rb
40
49
  - lib/restbox.rb
50
+ - lib/restbox_view_helper.rb
51
+ - restbox.gemspec
41
52
  - test/helper.rb
42
53
  - test/test_restbox.rb
43
54
  has_rdoc: true