Module: Skyline::ApplicationHelper

Defined in:
app/helpers/skyline/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#has_js_layout?Boolean

Does this template have a Skyline JS Layout set?

Returns:

  • (Boolean)


25
26
27
# File 'app/helpers/skyline/application_helper.rb', line 25

def has_js_layout?
  @_js_layout.present?
end

#message(type, message, options = {}) ⇒ Object

You can use this method to place a message directly in your view. This also works directly from a render(:update) or an update_page block.

Parameters:

  • type (Symbol)

    The type of the message (:error,:notification,:success)

  • message (String)

    The message to show

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

    ({}) Options to be passed to the MessageGenerator (javascript)



43
44
45
# File 'app/helpers/skyline/application_helper.rb', line 43

def message(type,message,options={})
  Skyline::MessageGenerator.new(type,message,options)
end

#notification(type, message, options = {}) ⇒ Object

You can use this method to place a notification directly in your view. This also works directly from a render(:update) or an update_page block.

Parameters:

  • type (Symbol)

    The type of the message (:error,:notification,:success)

  • message (String)

    The message to show

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

    ({}) Options to be passed to the MessageGenerator (javascript)



53
54
55
# File 'app/helpers/skyline/application_helper.rb', line 53

def notification(type,message,options={})
  Skyline::NotificationGenerator.new(type,message,options)    
end

#render_js_layoutObject

TODO:

Currently only implemented in EntopicEditor plugin

Actually render the JS code to initialize the previously set Skyline JS Layout.



32
33
34
35
# File 'app/helpers/skyline/application_helper.rb', line 32

def render_js_layout
  return unless @_js_layout
  raise "TO BE IMPLEMENTED"
end

#render_messages(options = {}) ⇒ Object

Actually render the messages on screen.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :generator (Class) — default: Skyline::MessageGenerator

    The generator to use to render the messages.



60
61
62
# File 'app/helpers/skyline/application_helper.rb', line 60

def render_messages(options={})
  javascript_tag render_messages_javascript(options)
end

#render_messages_javascript(options = {}) ⇒ Object



71
72
73
# File 'app/helpers/skyline/application_helper.rb', line 71

def render_messages_javascript(options={})
  _render_volatiles(self.messages,options)    
end

#render_notifications(options = {}) ⇒ Object

Actually render the notifications on screen.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :generator (Class) — default: Skyline::NotificationGenerator

    The generator to use to render the messages.



67
68
69
# File 'app/helpers/skyline/application_helper.rb', line 67

def render_notifications(options={})
  javascript_tag render_notifications_javascript(options)
end

#render_notifications_javascript(options = {}) ⇒ Object



75
76
77
78
# File 'app/helpers/skyline/application_helper.rb', line 75

def render_notifications_javascript(options={})
  options.reverse_merge! :generator => Skyline::NotificationGenerator
  _render_volatiles(self.notifications,options)
end

#tick_image(bool, options = {}) ⇒ Object

Place a tick or a cross depending on the value of bool

Parameters:

  • bool (Boolean)

    The value of the tick/cross

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

    ({}) Options will be passed to the image_tag method



6
7
8
9
10
11
12
13
# File 'app/helpers/skyline/application_helper.rb', line 6

def tick_image(bool,options={})
  name = bool ? "true" : "false"
  src = "/skyline/images/icons/#{name}.gif"
  
  options.reverse_merge! :alt => t(name, :scope => [:icons]) 
  
  image_tag(src,options)
end

#use_js_layout(name) ⇒ Object

Set the Skyline JS layout to use. Used in templates so the layout can initialize the correct layout.

Parameters:

  • name (Symbol)

    The name of the js layout to use @see #render_js_layout



18
19
20
# File 'app/helpers/skyline/application_helper.rb', line 18

def use_js_layout(name)
  @_js_layout = name
end