Module: WindowRailsView

Defined in:
lib/window_rails/window_rails_view.rb

Instance Method Summary collapse

Instance Method Details

name

Name of the link

options

Hash of options values.

Creates a link to a window. Content is defined by a url in the options hash using :url or :iframe. If :url is used, the content is loaded into the window within the page. If :iframe is used the content is loaded into the window within an IFrame on the page. Generally, if you are calling a method that simply renders out a partial, you want to use :url. If you are calling something that returns an entire page, :iframe will likely be the ticket.



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/window_rails/window_rails_view.rb', line 10

def link_to_window(name, options={}, html_opts={})
  frame_url = options.has_key?(:iframe) ? url_for(options.delete(:iframe)) : nil
  window_url = options.has_key?(:url) ? url_for(options.delete(:url)) : nil
  link_to_remote(
    name, {:url => 
    open_window_path(
      :window_url => window_url,
      :iframe_url => frame_url,
      :window_options => options
    )},
    html_opts
  )
end

#open_window_deprecated(options = {}) ⇒ Object

options

Options hash supplied to windowing system

Extra options include :method and :delay. :delay is the number of seconds to wait after page load to open window



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/window_rails/window_rails_view.rb', line 27

def open_window_deprecated(options={})
  frame_url = options.has_key?(:iframe) ? url_for(options.delete(:iframe)) : nil
  window_url = options.has_key?(:url) ? url_for(options.delete(:url)) : nil
  method = options.delete(:method) || 'get'
  delay = options.delete(:delay) || 0.5
  delay = delay * 1000
  url = open_window_path(
    :window_url => window_url,
    :iframe_url => frame_url,
    :window_options => options
  ).html_safe
  javascript_tag{
    "setTimeout(function(){
      jQuery.#{method}('#{url}');
     }, #{delay.to_i});".html_safe
  }
end