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.
@@ -1,46 +0,0 @@
1
- module WindowRailsView
2
-
3
- # name:: Name of the link
4
- # options:: Hash of options values.
5
- # Creates a link to a window. Content is defined by a url in the options hash using :url or :iframe.
6
- # If :url is used, the content is loaded into the window within the page. If :iframe is used
7
- # the content is loaded into the window within an IFrame on the page. Generally, if you are calling
8
- # a method that simply renders out a partial, you want to use :url. If you are calling something
9
- # that returns an entire page, :iframe will likely be the ticket.
10
- def link_to_window(name, options={}, html_opts={})
11
- frame_url = options.has_key?(:iframe) ? url_for(options.delete(:iframe)) : nil
12
- window_url = options.has_key?(:url) ? url_for(options.delete(:url)) : nil
13
- link_to_remote(
14
- name, {:url =>
15
- open_window_path(
16
- :window_url => window_url,
17
- :iframe_url => frame_url,
18
- :window_options => options
19
- )},
20
- html_opts
21
- )
22
- end
23
-
24
- # options:: Options hash supplied to windowing system
25
- # Extra options include :method and :delay. :delay is the number
26
- # of seconds to wait after page load to open window
27
- def open_window_deprecated(options={})
28
- frame_url = options.has_key?(:iframe) ? url_for(options.delete(:iframe)) : nil
29
- window_url = options.has_key?(:url) ? url_for(options.delete(:url)) : nil
30
- method = options.delete(:method) || 'get'
31
- delay = options.delete(:delay) || 0.5
32
- delay = delay * 1000
33
- url = open_window_path(
34
- :window_url => window_url,
35
- :iframe_url => frame_url,
36
- :window_options => options
37
- ).html_safe
38
- javascript_tag{
39
- "setTimeout(function(){
40
- jQuery.#{method}('#{url}');
41
- }, #{delay.to_i});".html_safe
42
- }
43
- end
44
-
45
- end
46
- ActionView::Base.send :include, WindowRailsView
@@ -1,47 +0,0 @@
1
- require 'window_rails/window_rails_generators'
2
-
3
- module WindowRails
4
- class Holder
5
- include WindowRailsGenerators
6
-
7
- attr_accessor :context
8
-
9
- def initialize(args={})
10
- @context = args[:context]
11
- @buffer = ''
12
- end
13
-
14
- def << (string)
15
- @buffer << string.to_s
16
- end
17
-
18
- def window_flush
19
- buf = @buffer.dup
20
- @buffer = ''
21
- buf
22
- end
23
- end
24
- end
25
-
26
- module WindowRails
27
- module Windows
28
- def self.included(base)
29
- WindowRailsGenerators.instance_methods(false).each do |method|
30
- base.class_eval do
31
- def _window_rails_holder
32
- @_window_rails_holder ||= WindowRails::Holder.new
33
- end
34
-
35
- define_method method do |*args|
36
- _window_rails_holder.context = self
37
- _window_rails_holder.send(method, *args)
38
- _window_rails_holder.window_flush.html_safe
39
- end
40
- end
41
- end
42
-
43
- end
44
- end
45
- end
46
-
47
- ActionView::Base.send(:include, WindowRails::Windows)
data/rails/init.rb DELETED
@@ -1 +0,0 @@
1
- require 'window_rails'