typus_treeview 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  module TypusTreeviewHelper
2
- def treeview
2
+ def treeview open = false
3
3
  model = @object_name.classify.constantize
4
4
  if model.respond_to?(:roots) && method = Typus.treeview[@object_name.to_sym]
5
5
  res = ''
@@ -7,7 +7,7 @@ module TypusTreeviewHelper
7
7
  res << stylesheet_link_tag("jquery.treeview")
8
8
  res << (content_tag :ul, :id => "treeview" do
9
9
  model.roots.map do |root|
10
- treeview_draw(root, method)
10
+ treeview_draw(root, method, open)
11
11
  end.join.html_safe
12
12
  end)
13
13
  res << javascript_tag('$(document).ready(function(){$("#treeview").treeview({persist: "location"});});')
@@ -15,8 +15,8 @@ module TypusTreeviewHelper
15
15
  end
16
16
  end
17
17
 
18
- def treeview_draw node, method
19
- content_tag :li, :class => "closed" do
18
+ def treeview_draw node, method, open
19
+ content_tag :li, :class => open ? nil : "closed" do
20
20
  res = ''
21
21
  name = method.is_a?(Proc) ? method.call(node) : node.send(method)
22
22
  res << content_tag(:span, link_to(name, { :action => "edit",
@@ -27,7 +27,7 @@ module TypusTreeviewHelper
27
27
  if node.children.size > 0
28
28
  res << (content_tag :ul do
29
29
  node.children.map do |child|
30
- treeview_draw(child, method)
30
+ treeview_draw(child, method, open)
31
31
  end.join.html_safe
32
32
  end)
33
33
  end
@@ -1,3 +1,3 @@
1
1
  module TypusTreeview
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: typus_treeview
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.1.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Nick Recobra
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-24 00:00:00 +04:00
13
+ date: 2011-06-27 00:00:00 +04:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency