app/helpers/admin/node_helper.rb in radiant-0.6.4 vs app/helpers/admin/node_helper.rb in radiant-0.6.5
- old
+ new
@@ -1,7 +1,7 @@
module Admin::NodeHelper
-
+
def render_node(page, locals = {})
@current_node = page
locals.reverse_merge!(:level => 0, :simple => false).merge!(:page => page)
render :partial => 'node', :locals => locals
end
@@ -11,28 +11,31 @@
end
def expanded_rows
unless @expanded_rows
@expanded_rows = case
- when row_string = (cookies['expanded_rows'] || []).first
- row_string.split(',').map { |x| Integer(x) rescue nil }.compact
+ when rows = cookies[:expanded_rows]
+ rows.split(',').map { |x| Integer(x) rescue nil }.compact
else
[]
end
- (@expanded_rows << homepage.id).uniq if homepage
+
+ if homepage and !@expanded_rows.include?(homepage.id)
+ @expanded_rows << homepage.id
+ end
end
@expanded_rows
end
-
+
def expanded
show_all? || expanded_rows.include?(@current_node.id)
end
-
+
def padding_left(level)
(level * 22) + 4
end
-
+
def children_class
unless @current_node.children.empty?
if expanded
" children-visible"
else
@@ -40,45 +43,45 @@
end
else
" no-children"
end
end
-
+
def virtual_class
@current_node.virtual? ? " virtual": ""
end
-
+
def expander
unless @current_node.children.empty?
- image((expanded ? "collapse" : "expand"),
- :class => "expander", :alt => 'toggle children',
+ image((expanded ? "collapse" : "expand"),
+ :class => "expander", :alt => 'toggle children',
:title => '')
else
""
end
end
-
+
def icon
icon_name = @current_node.virtual? ? 'virtual-page' : 'page'
image(icon_name, :class => "icon", :alt => 'page-icon', :title => '')
end
-
+
def node_title
%{<span class="title">#{ @current_node.title }</span>}
end
-
+
def page_type
display_name = @current_node.class.display_name
if display_name == 'Page'
""
else
%{<small class="info">(#{ display_name })</small>}
end
end
-
+
def spinner
- image('spinner.gif',
- :class => 'busy', :id => "busy-#{@current_node.id}",
- :alt => "", :title => "",
+ image('spinner.gif',
+ :class => 'busy', :id => "busy-#{@current_node.id}",
+ :alt => "", :title => "",
:style => 'display: none;')
end
end