window_rails 0.2.12 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/{CHANGELOG.rdoc → CHANGELOG.md} +25 -18
- data/LICENSE +1 -2
- data/README.md +69 -0
- data/app/assets/javascripts/window_rails.js +1 -0
- data/app/assets/javascripts/window_rails/base.js +458 -0
- data/app/assets/stylesheets/window_rails.css +3 -0
- data/app/assets/stylesheets/window_rails/csspinner.css +472 -0
- data/lib/window_rails.rb +8 -9
- data/lib/window_rails/engine.rb +4 -8
- data/lib/window_rails/generators.rb +118 -0
- data/lib/window_rails/holder.rb +40 -0
- data/lib/window_rails/version.rb +2 -6
- data/lib/window_rails/windows.rb +28 -0
- metadata +35 -30
- data/README.rdoc +0 -111
- data/app/controllers/window_rails_controller.rb +0 -50
- data/config/routes.rb +0 -9
- data/lib/window_rails/window_rails_generators.rb +0 -451
- data/lib/window_rails/window_rails_view.rb +0 -46
- data/lib/window_rails/window_rails_windows.rb +0 -47
- data/rails/init.rb +0 -1
data/lib/window_rails.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
require 'window_rails/version'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
%w(window_rails_windows window_rails_view).each do |part|
|
10
|
-
require "window_rails/#{part}"
|
11
|
-
end
|
3
|
+
# Windowing helper for Rails
|
4
|
+
module WindowRails
|
5
|
+
autoload :Engine, 'window_rails/engine'
|
6
|
+
autoload :Windows, 'window_rails/windows'
|
7
|
+
autoload :Holder, 'window_rails/holder'
|
8
|
+
autoload :Generators, 'window_rails/generators'
|
12
9
|
end
|
10
|
+
|
11
|
+
require 'window_rails/engine'
|
data/lib/window_rails/engine.rb
CHANGED
@@ -1,14 +1,10 @@
|
|
1
|
+
require 'window_rails'
|
2
|
+
|
1
3
|
module WindowRails
|
4
|
+
# Hook helpers into rails
|
2
5
|
class Engine < Rails::Engine
|
3
|
-
|
4
|
-
# We do all our setup in here
|
5
6
|
config.to_prepare do
|
6
|
-
|
7
|
-
require 'window_rails/window_rails_generators'
|
8
|
-
end
|
9
|
-
%w(window_rails_windows window_rails_view).each do |part|
|
10
|
-
require "window_rails/#{part}"
|
11
|
-
end
|
7
|
+
require 'window_rails/windows'
|
12
8
|
end
|
13
9
|
end
|
14
10
|
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
require 'rails_javascript_helpers'
|
2
|
+
|
3
|
+
module WindowRails
|
4
|
+
# Generator methods for dialogs
|
5
|
+
module Generators
|
6
|
+
|
7
|
+
include RailsJavaScriptHelpers
|
8
|
+
include ActionView::Helpers::JavaScriptHelper
|
9
|
+
include ActionView::Helpers::TagHelper
|
10
|
+
|
11
|
+
# Display alert dialog
|
12
|
+
#
|
13
|
+
# @param msg [String] message contents for dialog
|
14
|
+
# @param options [Hash]
|
15
|
+
# @option options [String] :title
|
16
|
+
# @return [TrueClass]
|
17
|
+
def open_alert_window(msg, options={})
|
18
|
+
options[:content] = msg
|
19
|
+
self << "window_rails.alert.open(#{format_type_to_js(options)});"
|
20
|
+
end
|
21
|
+
|
22
|
+
# Close the alert dialog
|
23
|
+
#
|
24
|
+
# @return [TrueClass]
|
25
|
+
def close_alert_window
|
26
|
+
self << 'window_rails.alert.close();'
|
27
|
+
true
|
28
|
+
end
|
29
|
+
|
30
|
+
# Display confirmation dialog
|
31
|
+
#
|
32
|
+
# @param msg [String] message contents for dialog
|
33
|
+
# @param options [Hash]
|
34
|
+
# @option options [String] :title
|
35
|
+
# @return [TrueClass]
|
36
|
+
def open_confirm_window(msg, options={})
|
37
|
+
options[:content] = msg
|
38
|
+
self << "window_rails.confirm.open(#{format_type_to_js(options)});"
|
39
|
+
true
|
40
|
+
end
|
41
|
+
|
42
|
+
# Close the confirm dialog
|
43
|
+
#
|
44
|
+
# @return [TrueClass]
|
45
|
+
def close_confirm_window
|
46
|
+
self << 'window_rails.confirm.close();'
|
47
|
+
true
|
48
|
+
end
|
49
|
+
|
50
|
+
# Display information dialog
|
51
|
+
#
|
52
|
+
# @param msg [String] message contents for dialog
|
53
|
+
# @param options [Hash]
|
54
|
+
# @option options [String] :title
|
55
|
+
# @return [TrueClass]
|
56
|
+
def open_info_window(msg, options={})
|
57
|
+
options[:content] = msg
|
58
|
+
self << "window_rails.info.open(#{format_type_to_js(options)});"
|
59
|
+
true
|
60
|
+
end
|
61
|
+
|
62
|
+
# Create a new window
|
63
|
+
#
|
64
|
+
# @param options [Hash]
|
65
|
+
# @option options [String] :name name of window
|
66
|
+
# @option options [String] :title title of window
|
67
|
+
# @option options [String] :content content of window
|
68
|
+
# @option options [String] :footer content of footer
|
69
|
+
# @option options [String] :size size of window ('large' or 'small')
|
70
|
+
# @option options [TrueClass, Falsey] :auto_open automatically open window (defaults true)
|
71
|
+
# @return [TrueClass]
|
72
|
+
def create_window(options={})
|
73
|
+
self << "window_rails.create_window(#{format_type_to_js(options)});"
|
74
|
+
if(options.fetch(:auto_open, true))
|
75
|
+
self << "window_rails.open_window('#{options[:name]}', #{format_type_to_js(options)});"
|
76
|
+
end
|
77
|
+
true
|
78
|
+
end
|
79
|
+
|
80
|
+
# Open the window
|
81
|
+
#
|
82
|
+
# @param name [String] window name
|
83
|
+
# @return [TrueClass]
|
84
|
+
def open_window(name)
|
85
|
+
self << "window_rails.open_window('#{name}');"
|
86
|
+
true
|
87
|
+
end
|
88
|
+
|
89
|
+
# Close the window
|
90
|
+
#
|
91
|
+
# @param name [String] window name
|
92
|
+
# @return [TrueClass]
|
93
|
+
def close_window(name)
|
94
|
+
self << "window_rails.close_window('#{name}');"
|
95
|
+
true
|
96
|
+
end
|
97
|
+
|
98
|
+
# Update the contents of the window
|
99
|
+
#
|
100
|
+
# @param options [Hash]
|
101
|
+
# @option options [String] :title title of window
|
102
|
+
# @option options [String] :content content of window
|
103
|
+
# @option options [String] :footer content of footer
|
104
|
+
def update_window(name, options={})
|
105
|
+
create_window(options.merge(:name => name, :show => false))
|
106
|
+
end
|
107
|
+
|
108
|
+
# Add popover support
|
109
|
+
#
|
110
|
+
# @param options [Hash]
|
111
|
+
# @return [TrueClass]
|
112
|
+
def popover(element, options={})
|
113
|
+
self << "$('#{element}').popover(#{format_type_to_js(options)});"
|
114
|
+
true
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'window_rails'
|
2
|
+
|
3
|
+
module WindowRails
|
4
|
+
# Content container
|
5
|
+
class Holder
|
6
|
+
|
7
|
+
include WindowRails::Generators
|
8
|
+
|
9
|
+
# @return [Context] current context
|
10
|
+
attr_accessor :context
|
11
|
+
|
12
|
+
# Create new instance
|
13
|
+
#
|
14
|
+
# @param args [Hash]
|
15
|
+
# @option args [Context] :context
|
16
|
+
def initialize(args={})
|
17
|
+
@context = args[:context]
|
18
|
+
@buffer = ''
|
19
|
+
end
|
20
|
+
|
21
|
+
# Add string to buffer
|
22
|
+
#
|
23
|
+
# @param string [String]
|
24
|
+
# @return [self]
|
25
|
+
def << (string)
|
26
|
+
@buffer << string.to_s
|
27
|
+
self
|
28
|
+
end
|
29
|
+
|
30
|
+
# Clear current buffer and return content
|
31
|
+
#
|
32
|
+
# @return [String]
|
33
|
+
def window_flush
|
34
|
+
buf = @buffer.dup
|
35
|
+
@buffer = ''
|
36
|
+
buf
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
data/lib/window_rails/version.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'window_rails'
|
2
|
+
|
3
|
+
module WindowRails
|
4
|
+
# Loads windowing helper methods into class
|
5
|
+
module Windows
|
6
|
+
|
7
|
+
def self.included(base)
|
8
|
+
WindowRails::Generators.instance_methods(false).each do |method|
|
9
|
+
base.class_eval do
|
10
|
+
|
11
|
+
def _window_rails_holder
|
12
|
+
@_window_rails_holder ||= WindowRails::Holder.new
|
13
|
+
end
|
14
|
+
|
15
|
+
define_method method do |*args|
|
16
|
+
_window_rails_holder.context = self
|
17
|
+
_window_rails_holder.send(method, *args)
|
18
|
+
_window_rails_holder.window_flush.html_safe
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
ActionView::Base.send(:include, WindowRails::Windows)
|
metadata
CHANGED
@@ -1,82 +1,87 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: window_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Chris Roberts
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-12-13 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rails
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
19
|
+
version: '3.0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
25
27
|
- !ruby/object:Gem::Dependency
|
26
28
|
name: rails_javascript_helpers
|
27
|
-
requirement:
|
28
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
|
-
- - ~>
|
31
|
+
- - "~>"
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: '1.0'
|
33
34
|
type: :runtime
|
34
35
|
prerelease: false
|
35
|
-
version_requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
36
41
|
description: Windows for Rails
|
37
|
-
email:
|
42
|
+
email: code@chrisroberts.org
|
38
43
|
executables: []
|
39
44
|
extensions: []
|
40
45
|
extra_rdoc_files:
|
41
|
-
- README.
|
46
|
+
- README.md
|
42
47
|
- LICENSE
|
43
|
-
- CHANGELOG.
|
48
|
+
- CHANGELOG.md
|
44
49
|
files:
|
50
|
+
- CHANGELOG.md
|
45
51
|
- LICENSE
|
46
|
-
- README.
|
47
|
-
-
|
48
|
-
- app/
|
49
|
-
-
|
52
|
+
- README.md
|
53
|
+
- app/assets/javascripts/window_rails.js
|
54
|
+
- app/assets/javascripts/window_rails/base.js
|
55
|
+
- app/assets/stylesheets/window_rails.css
|
56
|
+
- app/assets/stylesheets/window_rails/csspinner.css
|
57
|
+
- lib/window_rails.rb
|
50
58
|
- lib/window_rails/engine.rb
|
59
|
+
- lib/window_rails/generators.rb
|
60
|
+
- lib/window_rails/holder.rb
|
51
61
|
- lib/window_rails/version.rb
|
52
|
-
- lib/window_rails/
|
53
|
-
- lib/window_rails/window_rails_generators.rb
|
54
|
-
- lib/window_rails.rb
|
55
|
-
- rails/init.rb
|
56
|
-
- config/routes.rb
|
62
|
+
- lib/window_rails/windows.rb
|
57
63
|
homepage: http://github.com/chrisroberts/window_rails
|
58
64
|
licenses: []
|
65
|
+
metadata: {}
|
59
66
|
post_install_message:
|
60
67
|
rdoc_options: []
|
61
68
|
require_paths:
|
62
69
|
- lib
|
63
70
|
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
-
none: false
|
65
71
|
requirements:
|
66
|
-
- -
|
72
|
+
- - ">="
|
67
73
|
- !ruby/object:Gem::Version
|
68
74
|
version: '0'
|
69
75
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
-
none: false
|
71
76
|
requirements:
|
72
|
-
- -
|
77
|
+
- - ">="
|
73
78
|
- !ruby/object:Gem::Version
|
74
79
|
version: '0'
|
75
80
|
requirements: []
|
76
81
|
rubyforge_project:
|
77
|
-
rubygems_version:
|
82
|
+
rubygems_version: 2.2.2
|
78
83
|
signing_key:
|
79
|
-
specification_version:
|
84
|
+
specification_version: 4
|
80
85
|
summary: Windows for Rails
|
81
86
|
test_files: []
|
82
87
|
has_rdoc:
|
data/README.rdoc
DELETED
@@ -1,111 +0,0 @@
|
|
1
|
-
== WindowRails (for jQuery)
|
2
|
-
|
3
|
-
WindowRails is a plugin for Rails that provides easy to use AJAXy windows. It is based
|
4
|
-
completely on {jQueryUI}[http://jquery-ui.com] with helpers for Rails to make it easy to
|
5
|
-
use from a Rails app.
|
6
|
-
|
7
|
-
WindowRails is now happily compatible with Rails 2 and Rails 3 (and now 3.1).
|
8
|
-
|
9
|
-
== Requirements
|
10
|
-
|
11
|
-
* jQuery
|
12
|
-
* jQuery-UI with Dialog widget enabled
|
13
|
-
|
14
|
-
== Installation
|
15
|
-
|
16
|
-
Add window_rails to your application Gemfile:
|
17
|
-
|
18
|
-
gem 'window_rails'
|
19
|
-
|
20
|
-
=== Basic examples to get you started
|
21
|
-
|
22
|
-
=== Remote calls to create a window
|
23
|
-
|
24
|
-
# view
|
25
|
-
<%= link_to_remote('Link', :url => my_route_path) %>
|
26
|
-
|
27
|
-
|
28
|
-
# controller
|
29
|
-
|
30
|
-
def action
|
31
|
-
respond_to do |format|
|
32
|
-
format.html
|
33
|
-
format.js do
|
34
|
-
render :update do |page|
|
35
|
-
page.open_window(
|
36
|
-
{:partial => 'action_partial'},
|
37
|
-
:width => 400,
|
38
|
-
:height => 500,
|
39
|
-
:title => 'My Window',
|
40
|
-
:window => 'unique_window_name'
|
41
|
-
)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
# or via JS template:
|
48
|
-
# app/views/my_resources/action.js.erb
|
49
|
-
|
50
|
-
<%=
|
51
|
-
open_window(
|
52
|
-
{:partial => 'action_partial'},
|
53
|
-
:width => 400,
|
54
|
-
:height => 500,
|
55
|
-
:title => 'My Window',
|
56
|
-
:window => 'unique_window_name'
|
57
|
-
)
|
58
|
-
%>
|
59
|
-
|
60
|
-
== Window Interactions
|
61
|
-
|
62
|
-
Examples are shown using the old generator style. For rails 3.1 and beyond, the methods should be defined
|
63
|
-
within the JS views
|
64
|
-
|
65
|
-
==== Opening a window via AJAX
|
66
|
-
def open_my_window
|
67
|
-
respond_to do |format|
|
68
|
-
format.html
|
69
|
-
format.js do
|
70
|
-
render :update do |page|
|
71
|
-
page.open_window({:partial => 'my_partial'}, :width => 400, :height => 200, :window => 'my_window')
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
==== Updating a window via AJAX
|
78
|
-
def update_my_window
|
79
|
-
respond_to do |format|
|
80
|
-
format.html
|
81
|
-
format.js do
|
82
|
-
render :update do |page|
|
83
|
-
page.update_window({:partial => 'new_partial'}, :window => 'my_window')
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
==== Closing a window via AJAX
|
90
|
-
def close_my_window
|
91
|
-
respond_to do |format|
|
92
|
-
format.html
|
93
|
-
format.js do
|
94
|
-
render :update do |page|
|
95
|
-
page.close_window(:window => 'my_window')
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
== Documentation
|
102
|
-
|
103
|
-
{WindowRails documentation}[http://chrisroberts.github.com/window_rails]
|
104
|
-
|
105
|
-
== Bugs/Features
|
106
|
-
|
107
|
-
{Issues}[http://github.com/chrisroberts/window_rails/issues]
|
108
|
-
|
109
|
-
== License
|
110
|
-
|
111
|
-
* WindowRails is released under an MIT license
|