Renamed helpers to correspond to renamed Controller classes.
[merb_radiant.git] / app / helpers / admin / .svn / text-base / node_helper.rb.svn-base
blob25aa83faf04a069f78f360b422b232956ce6afe3
1 module Admin::NodeHelper
2   
3   def render_node(page, locals = {})
4     @current_node = page
5     locals.reverse_merge!(:level => 0, :simple => false).merge!(:page => page)
6     render :partial => 'node', :locals =>  locals
7   end
9   def show_all?
10     @controller.action_name == 'remove'
11   end
13   def expanded_rows
14     unless @expanded_rows
15       @expanded_rows = case
16       when rows = cookies[:expanded_rows]
17         rows.split(',').map { |x| Integer(x) rescue nil }.compact
18       else
19         []
20       end
22       if homepage and !@expanded_rows.include?(homepage.id)
23         @expanded_rows << homepage.id
24       end
25     end
26     @expanded_rows
27   end
28   
29   def expanded
30     show_all? || expanded_rows.include?(@current_node.id)
31   end
32   
33   def padding_left(level)
34     (level * 22) + 4
35   end
36   
37   def children_class
38     unless @current_node.children.empty?
39       if expanded
40         " children-visible"
41       else
42         " children-hidden"
43       end
44     else
45       " no-children"
46     end
47   end
48   
49   def virtual_class
50     @current_node.virtual? ? " virtual": ""
51   end
52   
53   def expander
54     unless @current_node.children.empty?
55       image((expanded ? "collapse" : "expand"), 
56             :class => "expander", :alt => 'toggle children', 
57             :title => '')
58     else
59       ""
60     end
61   end
62   
63   def icon
64     icon_name = @current_node.virtual? ? 'virtual-page' : 'page'
65     image(icon_name, :class => "icon", :alt => 'page-icon', :title => '')
66   end
67   
68   def node_title
69     %{<span class="title">#{ @current_node.title }</span>}
70   end
71   
72   def page_type
73     display_name = @current_node.class.display_name
74     if display_name == 'Page'
75       ""
76     else
77       %{<small class="info">(#{ display_name })</small>}
78     end
79   end
80   
81   def spinner
82     image('spinner.gif', 
83             :class => 'busy', :id => "busy-#{@current_node.id}", 
84             :alt => "",  :title => "", 
85             :style => 'display: none;')
86   end
87 end