Module: WindowRails::Generators

Includes:
ActionView::Helpers::JavaScriptHelper, ActionView::Helpers::TagHelper, RailsJavaScriptHelpers
Included in:
Holder
Defined in:
lib/window_rails/generators.rb

Overview

Generator methods for dialogs

Instance Method Summary collapse

Instance Method Details

#close_alert_windowTrueClass

Close the alert dialog

Returns:

  • (TrueClass)


25
26
27
28
# File 'lib/window_rails/generators.rb', line 25

def close_alert_window
  self << 'window_rails.alert.close();'
  true
end

#close_confirm_windowTrueClass

Close the confirm dialog

Returns:

  • (TrueClass)


45
46
47
48
# File 'lib/window_rails/generators.rb', line 45

def close_confirm_window
  self << 'window_rails.confirm.close();'
  true
end

#close_window(name) ⇒ TrueClass

Close the window

Parameters:

  • name (String)

    window name

Returns:

  • (TrueClass)


93
94
95
96
# File 'lib/window_rails/generators.rb', line 93

def close_window(name)
  self << "window_rails.close_window('#{name}');"
  true
end

#create_window(options = {}) ⇒ TrueClass

Create a new window

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :name (String)

    name of window

  • :title (String)

    title of window

  • :content (String)

    content of window

  • :footer (String)

    content of footer

  • :size (String)

    size of window (‘large’ or ‘small’)

  • :auto_open (TrueClass, Falsey)

    automatically open window (defaults true)

Returns:

  • (TrueClass)


72
73
74
75
76
77
78
# File 'lib/window_rails/generators.rb', line 72

def create_window(options={})
  self << "window_rails.create_window(#{format_type_to_js(options)});"
  if(options.fetch(:auto_open, true))
    self << "window_rails.open_window('#{options[:name]}', #{format_type_to_js(options)});"
  end
  true
end

#open_alert_window(msg, options = {}) ⇒ TrueClass

Display alert dialog

Parameters:

  • msg (String)

    message contents for dialog

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :title (String)

Returns:

  • (TrueClass)


17
18
19
20
# File 'lib/window_rails/generators.rb', line 17

def open_alert_window(msg, options={})
  options[:content] = msg
  self << "window_rails.alert.open(#{format_type_to_js(options)});"
end

#open_confirm_window(msg, options = {}) ⇒ TrueClass

Display confirmation dialog

Parameters:

  • msg (String)

    message contents for dialog

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :title (String)

Returns:

  • (TrueClass)


36
37
38
39
40
# File 'lib/window_rails/generators.rb', line 36

def open_confirm_window(msg, options={})
  options[:content] = msg
  self << "window_rails.confirm.open(#{format_type_to_js(options)});"
  true
end

#open_info_window(msg, options = {}) ⇒ TrueClass

Display information dialog

Parameters:

  • msg (String)

    message contents for dialog

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :title (String)

Returns:

  • (TrueClass)


56
57
58
59
60
# File 'lib/window_rails/generators.rb', line 56

def open_info_window(msg, options={})
  options[:content] = msg
  self << "window_rails.info.open(#{format_type_to_js(options)});"
  true
end

#open_window(name) ⇒ TrueClass

Open the window

Parameters:

  • name (String)

    window name

Returns:

  • (TrueClass)


84
85
86
87
# File 'lib/window_rails/generators.rb', line 84

def open_window(name)
  self << "window_rails.open_window('#{name}');"
  true
end

#popover(element, options = {}) ⇒ TrueClass

Add popover support

Parameters:

  • options (Hash) (defaults to: {})

Returns:

  • (TrueClass)


112
113
114
115
# File 'lib/window_rails/generators.rb', line 112

def popover(element, options={})
  self << "$('#{element}').popover(#{format_type_to_js(options)});"
  true
end

#update_window(name, options = {}) ⇒ Object

Update the contents of the window

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :title (String)

    title of window

  • :content (String)

    content of window

  • :footer (String)

    content of footer



104
105
106
# File 'lib/window_rails/generators.rb', line 104

def update_window(name, options={})
  create_window(options.merge(:name => name, :show => false))
end