window_rails 0.1.4 → 0.1.5

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/lib/window_rails.rb CHANGED
@@ -1 +1,5 @@
1
1
  require 'window_rails/version'
2
+
3
+ if(defined?(Rails))
4
+ require File.join(File.dirname(__FILE__), '..', 'init')
5
+ end
@@ -1,3 +1,3 @@
1
1
  module WindowRails
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
@@ -56,7 +56,7 @@ module WindowRailsGenerators
56
56
  # error:: Will throw an alert if window is not found
57
57
  # Checks for a window of the given name. If a block is provided, it will be executed
58
58
  # if the window is found
59
- def check_for_window(name, error)
59
+ def check_for_window(name, error=true)
60
60
  if(name.blank?)
61
61
  self << "if(Windows.windows.values().size() > 0){"
62
62
  else
@@ -96,6 +96,30 @@ module WindowRailsGenerators
96
96
  end
97
97
  end
98
98
 
99
+ # win:: Name of window
100
+ # Will maximize the window. If no name provided, topmost window will be maximized
101
+ def maximize_window(win=nil)
102
+ check_for_window(name) do
103
+ if(name)
104
+ self << "Windows.getWindowByName('#{escape_javascript(win)}').maximize();"
105
+ else
106
+ self << "Windows.windows.values().last().maximize();"
107
+ end
108
+ end
109
+ end
110
+
111
+ # win:: Name of window
112
+ # Will minimize the window. If no name provided, topmost window will be minimized
113
+ def minimize_window(win)
114
+ check_for_window(name) do
115
+ if(name)
116
+ self << "Windows.getWindowByName('#{escape_javascript(win)}').minimize();"
117
+ else
118
+ self << "Windows.windows.values().last().minimize();"
119
+ end
120
+ end
121
+ end
122
+
99
123
  # key:: Content key location
100
124
  # win:: Name of window
101
125
  # options:: Options to be passed onto window
@@ -169,7 +193,7 @@ module WindowRailsGenerators
169
193
  options[:url] = @context.url_for(content[:url])
170
194
  content = nil
171
195
  else
172
- content = render(content)
196
+ content = @context.render(content)
173
197
  end
174
198
  end
175
199
  options[:width] ||= 300
@@ -199,7 +223,7 @@ module WindowRailsGenerators
199
223
  def store_content(content)
200
224
  key = rand.to_s
201
225
  key.slice!(0,2)
202
- c = content.is_a?(Hash) ? render(content) : content.to_s
226
+ c = content.is_a?(Hash) ? @context.render(content) : content.to_s
203
227
  self << "if(typeof(window_rails_contents) == 'undefined'){ var window_rails_contents = new Hash(); }"
204
228
  self << "window_rails_contents.set('#{key}', '#{escape_javascript(c)}')"
205
229
  key
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: window_rails
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
5
- prerelease: false
4
+ hash: 17
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 4
10
- version: 0.1.4
9
+ - 5
10
+ version: 0.1.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Chris Roberts
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-25 00:00:00 -08:00
18
+ date: 2011-03-08 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -257,7 +257,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
257
257
  requirements: []
258
258
 
259
259
  rubyforge_project:
260
- rubygems_version: 1.3.7
260
+ rubygems_version: 1.5.1
261
261
  signing_key:
262
262
  specification_version: 3
263
263
  summary: Windows for Rails