Module: Admin::NodeHelper

Included in:
PagesHelper
Defined in:
app/helpers/admin/node_helper.rb

Instance Method Summary collapse

Instance Method Details

#children_classObject



37
38
39
40
41
42
43
44
45
46
47
# File 'app/helpers/admin/node_helper.rb', line 37

def children_class
  unless @current_node.children.empty?
    if expanded
      " children_visible"
    else
      " children_hidden"
    end
  else
    " no_children"
  end
end

#expandedObject



29
30
31
# File 'app/helpers/admin/node_helper.rb', line 29

def expanded
  show_all? || expanded_rows.include?(@current_node.id)
end

#expanded_rowsObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/helpers/admin/node_helper.rb', line 13

def expanded_rows
  unless @expanded_rows
    @expanded_rows = case
    when rows = cookies[:expanded_rows]
      rows.split(',').map { |x| Integer(x) rescue nil }.compact
    else
      []
    end

    if homepage and !@expanded_rows.include?(homepage.id)
      @expanded_rows << homepage.id
    end
  end
  @expanded_rows
end

#expander(level) ⇒ Object



53
54
55
56
57
58
59
60
61
# File 'app/helpers/admin/node_helper.rb', line 53

def expander(level)
  unless @current_node.children.empty? or level == 0
    image((expanded ? "collapse" : "expand"),
          :class => "expander", :alt => 'toggle children',
          :title => '')
  else
    ""
  end.html_safe
end

#iconObject



63
64
65
66
# File 'app/helpers/admin/node_helper.rb', line 63

def icon
  icon_name = @current_node.virtual? ? 'virtual_page' : 'page'
  image(icon_name, :class => "icon", :alt => '', :title => '')
end

#node_titleObject



68
69
70
# File 'app/helpers/admin/node_helper.rb', line 68

def node_title
  %{<span class="title">#{ h(@current_node.title) }</span>}
end

#padding_left(level) ⇒ Object



33
34
35
# File 'app/helpers/admin/node_helper.rb', line 33

def padding_left(level)
  (level * 23) + 9
end

#page_typeObject



72
73
74
75
76
77
78
79
# File 'app/helpers/admin/node_helper.rb', line 72

def page_type
  display_name = @current_node.class.display_name
  if display_name == 'Page'
    ""
  else
    %{<span class="info">(#{ h(display_name) })</span>}.html_safe
  end
end

#render_node(page, locals = {}) ⇒ Object



3
4
5
6
7
# File 'app/helpers/admin/node_helper.rb', line 3

def render_node(page, locals = {})
  @current_node = page
  locals.reverse_merge!(:level => 0, :simple => false).merge!(:page => page)
  render :partial => 'node', :locals =>  locals
end

#show_all?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'app/helpers/admin/node_helper.rb', line 9

def show_all?
  controller.action_name == 'remove'
end

#spinnerObject



81
82
83
84
85
86
# File 'app/helpers/admin/node_helper.rb', line 81

def spinner
  image('spinner.gif',
          :class => 'busy', :id => "busy_#{@current_node.id}",
          :alt => "",  :title => "",
          :style => 'display: none;')
end

#virtual_classObject



49
50
51
# File 'app/helpers/admin/node_helper.rb', line 49

def virtual_class
  @current_node.virtual? ? " virtual": ""
end