Class: WindowRailsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/window_rails_controller.rb

Instance Method Summary collapse

Instance Method Details

#open_windowObject

Opens a new window NOTE: It is important to note that the contents of the window will be opened within an IFrame. This means links within the window will not be able to communicate with the page around it (like closing the window)



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/controllers/window_rails_controller.rb', line 25

def open_window
  respond_to do |format|
    format.html do
      redirect_to '/'
    end
    format.js do
      opts = {}
      content = nil
      if(params[:window_url].blank?)
        content = {:url => params[:iframe_url]}
      else
        content = {:content_url => params[:window_url]}
      end
      base_key = params[:window_options] ? :window_options : 'window_options'
      if(params[base_key])
        params[base_key].keys.each do |key|
          opts[key.to_sym] = params[base_key][key]
        end
      end
      render :update do |page|
        page.open_window(content, opts || {})
      end
    end
  end
end

#redirect_outObject



8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/window_rails_controller.rb', line 8

def redirect_out
  respond_to do |format|
    format.html do
      redirect_to '/'
    end
    format.js do
      render :update do |page|
        page.redirect_to '/'
      end
    end
  end
end