yard 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of yard might be problematic. Click here for more details.

Files changed (68) hide show
  1. data/README.md +14 -2
  2. data/Rakefile +5 -10
  3. data/benchmarks/parsing.rb +2 -2
  4. data/docs/WhatsNew.md +43 -5
  5. data/lib/rubygems_plugin.rb +49 -45
  6. data/lib/yard.rb +1 -1
  7. data/lib/yard/cli/base.rb +4 -0
  8. data/lib/yard/cli/yard_graph.rb +1 -0
  9. data/lib/yard/cli/yardoc.rb +24 -2
  10. data/lib/yard/cli/yri.rb +1 -0
  11. data/lib/yard/code_objects/base.rb +9 -0
  12. data/lib/yard/code_objects/class_object.rb +1 -1
  13. data/lib/yard/code_objects/method_object.rb +20 -4
  14. data/lib/yard/core_ext/file.rb +6 -0
  15. data/lib/yard/core_ext/hash.rb +1 -1
  16. data/lib/yard/core_ext/string.rb +3 -1
  17. data/lib/yard/handlers/ruby/attribute_handler.rb +22 -18
  18. data/lib/yard/handlers/ruby/legacy/attribute_handler.rb +21 -17
  19. data/lib/yard/handlers/ruby/legacy/method_handler.rb +8 -0
  20. data/lib/yard/handlers/ruby/method_handler.rb +8 -1
  21. data/lib/yard/logging.rb +1 -1
  22. data/lib/yard/parser/c_parser.rb +10 -17
  23. data/lib/yard/parser/ruby/legacy/statement_list.rb +7 -0
  24. data/lib/yard/parser/ruby/ruby_parser.rb +2 -1
  25. data/lib/yard/parser/source_parser.rb +20 -3
  26. data/lib/yard/templates/helpers/html_helper.rb +48 -22
  27. data/lib/yard/templates/template.rb +6 -1
  28. data/spec/cli/yardoc_spec.rb +22 -0
  29. data/spec/code_objects/base_spec.rb +34 -1
  30. data/spec/code_objects/method_object_spec.rb +35 -0
  31. data/spec/core_ext/hash_spec.rb +4 -0
  32. data/spec/core_ext/string_spec.rb +5 -1
  33. data/spec/handlers/attribute_handler_spec.rb +9 -1
  34. data/spec/handlers/examples/attribute_handler_001.rb.txt +8 -0
  35. data/spec/handlers/examples/method_handler_001.rb.txt +6 -0
  36. data/spec/handlers/method_handler_spec.rb +10 -0
  37. data/spec/parser/source_parser_spec.rb +29 -26
  38. data/spec/spec_helper.rb +1 -1
  39. data/spec/templates/engine_spec.rb +1 -0
  40. data/spec/templates/examples/class001.html +4 -0
  41. data/spec/templates/examples/class001.txt +5 -0
  42. data/spec/templates/examples/module001.dot +1 -1
  43. data/spec/templates/examples/module001.html +92 -12
  44. data/spec/templates/helpers/html_helper_spec.rb +25 -5
  45. data/spec/templates/module_spec.rb +3 -1
  46. data/spec/templates/template_spec.rb +11 -1
  47. data/templates/default/class/html/subclasses.erb +1 -1
  48. data/templates/default/class/setup.rb +10 -3
  49. data/templates/default/class/text/subclasses.erb +1 -1
  50. data/templates/default/fulldoc/html/css/full_list.css +38 -11
  51. data/templates/default/fulldoc/html/css/style.css +6 -1
  52. data/templates/default/fulldoc/html/frames.erb +13 -0
  53. data/templates/default/fulldoc/html/full_list.erb +20 -22
  54. data/templates/default/fulldoc/html/full_list_class.erb +2 -0
  55. data/templates/default/fulldoc/html/full_list_files.erb +5 -0
  56. data/templates/default/fulldoc/html/full_list_methods.erb +12 -0
  57. data/templates/default/fulldoc/html/js/app.js +10 -2
  58. data/templates/default/fulldoc/html/js/full_list.js +76 -9
  59. data/templates/default/fulldoc/html/setup.rb +37 -2
  60. data/templates/default/layout/html/breadcrumb.erb +3 -1
  61. data/templates/default/layout/html/layout.erb +4 -0
  62. data/templates/default/layout/html/search.erb +1 -1
  63. data/templates/default/layout/html/setup.rb +13 -2
  64. data/templates/default/module/dot/info.erb +1 -1
  65. data/templates/default/module/html/attribute_details.erb +1 -1
  66. data/templates/default/module/html/constant_summary.erb +1 -1
  67. data/templates/default/module/html/item_summary.erb +2 -2
  68. metadata +6 -2
@@ -14,17 +14,21 @@ describe YARD::Templates::Helpers::HtmlHelper do
14
14
  describe '#fix_typewriter' do
15
15
  it "should use #fix_typewriter to convert +text+ to <tt>text</tt>" do
16
16
  fix_typewriter("Some +typewriter text+.").should ==
17
- "Some <tt>t\x04y\x04p\x04e\x04w\x04r\x04i\x04t\x04e\x04r\x04" +
18
- " \x04t\x04e\x04x\x04t\x04</tt>."
17
+ "Some <tt>typewriter" +
18
+ " text</tt>."
19
19
  fix_typewriter("Not +typewriter text.").should ==
20
20
  "Not +typewriter text."
21
21
  fix_typewriter("Alternating +type writer+ text +here+.").should ==
22
- "Alternating <tt>t\x04y\x04p\x04e\x04 \x04w\x04r\x04i\x04t\x04e\x04r" +
23
- "\x04</tt> text <tt>h\x04e\x04r\x04e\x04</tt>."
22
+ "Alternating <tt>type writer" +
23
+ "</tt> text <tt>here</tt>."
24
24
  fix_typewriter("No ++problem.").should ==
25
25
  "No ++problem."
26
26
  fix_typewriter("Math + stuff +is ok+").should ==
27
- "Math + stuff <tt>i\x04s\x04 \x04o\x04k\x04</tt>"
27
+ "Math + stuff <tt>is ok</tt>"
28
+ end
29
+
30
+ it "should not apply to code blocks" do
31
+ fix_typewriter("<code>+hello+</code>").should == "<code>+hello+</code>"
28
32
  end
29
33
  end
30
34
 
@@ -70,6 +74,10 @@ describe YARD::Templates::Helpers::HtmlHelper do
70
74
  end
71
75
 
72
76
  describe "#link_object" do
77
+ before do
78
+ stub!(:object).and_return(CodeObjects::NamespaceObject.new(nil, :YARD))
79
+ end
80
+
73
81
  it "should return the object path if there's no serializer and no title" do
74
82
  stub!(:serializer).and_return nil
75
83
  link_object(CodeObjects::NamespaceObject.new(nil, :YARD)).should == "YARD"
@@ -269,4 +277,16 @@ describe YARD::Templates::Helpers::HtmlHelper do
269
277
  html_syntax_highlight("!!!NAME\ndef x; end").should == "def x; end"
270
278
  end
271
279
  end
280
+
281
+ describe '#resolve_links' do
282
+ it "should resolve {Name}" do
283
+ should_receive(:link_file).with('TEST', 'TEST', nil).and_return('')
284
+ resolve_links("{file:TEST}")
285
+ end
286
+
287
+ it "should resolve ({Name})" do
288
+ should_receive(:link_file).with('TEST', 'TEST', nil).and_return('')
289
+ resolve_links("({file:TEST})")
290
+ end
291
+ end
272
292
  end
@@ -23,6 +23,8 @@ describe YARD::Templates::Engine.template(:default, :method) do
23
23
  # @return [void]
24
24
  attr_accessor :attr3
25
25
 
26
+ attr_writer :attr4
27
+
26
28
  def self.a; end
27
29
  def a; end
28
30
  alias b a
@@ -46,7 +48,7 @@ describe YARD::Templates::Engine.template(:default, :method) do
46
48
  class X; end
47
49
  module Z; end
48
50
  CONSTANT = 'value'
49
- @@cvar = 'value'
51
+ @@cvar = 'value' # @deprecated
50
52
  end
51
53
  eof
52
54
  end
@@ -5,12 +5,22 @@ describe YARD::Templates::Template do
5
5
  YARD::Templates::Engine.template!(path, '/full/path/' + path.to_s)
6
6
  end
7
7
 
8
- describe '#initialize' do
8
+ describe '.include_parent' do
9
9
  it "should not include parent directory if parent directory is a template root path" do
10
10
  mod = template('q')
11
11
  mod.should_not include(template(''))
12
12
  end
13
13
 
14
+ it "should include overridden parent directory" do
15
+ Engine.stub!(:template_paths).and_return(['/foo', '/bar'])
16
+ File.should_receive(:directory?).with('/foo/a/b').and_return(true)
17
+ File.should_receive(:directory?).with('/bar/a/b').and_return(false)
18
+ File.should_receive(:directory?).with('/foo/a').at_least(1).times.and_return(true)
19
+ File.should_receive(:directory?).with('/bar/a').at_least(1).times.and_return(true)
20
+ ancestors = Engine.template('a/b').ancestors.map {|c| c.class_name }
21
+ ancestors[0, 3].should == %w( Template__foo_a_b Template__bar_a Template__foo_a )
22
+ end
23
+
14
24
  it "should include parent directory template if exists" do
15
25
  mod1 = template('x')
16
26
  mod2 = template('x/y')
@@ -1,4 +1,4 @@
1
1
  <div id="subclasses">
2
2
  <h2>Direct Known Subclasses</h2>
3
- <p class="children"><%= @subclasses.map {|child| linkify(child) }.join(", ") %></p>
3
+ <p class="children"><%= @subclasses.map {|name, child| linkify(child, name) }.join(", ") %></p>
4
4
  </div>
@@ -14,16 +14,23 @@ def constructor_details
14
14
  end
15
15
 
16
16
  def subclasses
17
+ return if object.path == "Object" # don't show subclasses for Object
17
18
  if !defined? @@subclasses
18
19
  @@subclasses = {}
19
20
  list = run_verifier Registry.all(:class)
20
21
  list.each do |o|
21
- (@@subclasses[o.superclass] ||= []) << o if o.superclass
22
+ (@@subclasses[o.superclass.path] ||= []) << o if o.superclass
22
23
  end
23
24
  end
24
25
 
25
- @subclasses = @@subclasses[object]
26
+ @subclasses = @@subclasses[object.path]
26
27
  return if @subclasses.nil? || @subclasses.empty?
27
- @subclasses = @subclasses.sort_by {|o| o.path }
28
+ @subclasses = @subclasses.sort_by {|o| o.path }.map do |child|
29
+ name = child.path
30
+ if object.namespace
31
+ name = object.relative_path(child)
32
+ end
33
+ [name, child]
34
+ end
28
35
  erb(:subclasses)
29
36
  end
@@ -1,5 +1,5 @@
1
1
  Direct Known Subclasses:
2
2
  ------------------------
3
3
 
4
- <%= indent(wrap(@subclasses.map {|child| linkify(child) }.join(", "))) %>
4
+ <%= indent(wrap(@subclasses.map {|name, child| name }.join(", "))) %>
5
5
 
@@ -3,21 +3,48 @@ body {
3
3
  font-family: "Lucida Sans", "Lucida Grande", Verdana, Arial, sans-serif;
4
4
  font-size: 13px;
5
5
  height: 101%;
6
+ overflow-x: hidden;
6
7
  }
7
- html { overflow-y: scroll; }
8
8
 
9
- h1 { padding: 0; margin: 5px; margin-top: 12px; margin-left: 10px; margin-bottom: 0; font-size: 1.4em; }
9
+ h1 { padding: 12px 10px; padding-bottom: 0; margin: 0; font-size: 1.4em; }
10
10
  .clear { clear: both; }
11
11
  #search { position: absolute; right: 5px; top: 9px; }
12
12
  #full_list { padding: 0; list-style: none; margin-left: 0; }
13
- #full_list li { padding: 7px 15px; font-size: 1.1em; }
14
- #noresults { display: none; padding: 7px 15px; }
15
- li { color: #555; }
13
+ #full_list ul { padding: 0; }
14
+ #full_list li { padding: 5px; padding-left: 12px; margin: 0; font-size: 1.1em; list-style: none; }
15
+ #noresults { display: none; padding: 7px 12px; }
16
+ ul.collapsed ul, ul.collapsed li { display: none; }
17
+ li a.toggle { cursor: default; position: relative; left: -5px; top: 4px; text-indent: -999px; width: 10px; height: 9px; margin-left: -10px; display: block; float: left; background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAYAAABb0P4QAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAK8AAACvABQqw0mAAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTM5jWRgMAAAAVdEVYdENyZWF0aW9uIFRpbWUAMy8xNC8wOeNZPpQAAAE2SURBVDiNrZTBccIwEEXfelIAHUA6CZ24BGaWO+FuzZAK4k6gg5QAdGAq+Bxs2Yqx7BzyL7Llp/VfzZeQhCTc/ezuGzKKnKSzpCxXJM8fwNXda3df5RZETlIt6YUzSQDs93sl8w3wBZxCCE10GM1OcWbWjB2mWgEH4Mfdyxm3PSepBHibgQE2wLe7r4HjEidpnXMYdQPKEMJcsZ4zs2POYQOcaPfwMVOo58zsAdMt18BuoVDPxUJRacELbXv3hUIX2vYmOUvi8C8ydz/ThjXrqKqqLbDIAdsCKBd+Wo7GWa7o9qzOQHVVVXeAbs+yHHCH4aTsaCOQqunmUy1yBUAXkdMIfMlgF5EXLo2OpV/c/Up7jG4hhHcYLgWzAZXUc2b2ixsfvc/RmNNfOXD3Q/oeL9axJE1yT9IOoUu6MGUkAAAAAElFTkSuQmCC) no-repeat bottom left; }
18
+ li.collapsed a.toggle { opacity: 0.5; cursor: default; background-position: top left; }
19
+ li { color: #888; cursor: pointer; }
16
20
  li.deprecated { text-decoration: line-through; font-style: italic; }
17
- li.r1 { background: #f0f0f0; border: 1px dotted #f0f0f0; border-left-width: 0; border-right-width: 0; }
18
- li.r2 { background: #fafafa; border: 1px dotted #fafafa; border-left-width: 0; border-right-width: 0; }
19
- li:hover { background: #ffffa5; cursor: pointer; border: 1px dotted #ddddc4; border-left-width: 0; border-right-width: 0; }
20
- li:hover * { position: relative; left: -3px; }
21
+ li.r1 { background: #f0f0f0; }
22
+ li.r2 { background: #fafafa; }
23
+ li:hover { background: #ddd; }
24
+ li small:before { content: "("; }
25
+ li small:after { content: ")"; }
26
+ li small.search_info { display: none; }
21
27
  a:link, a:visited { text-decoration: none; color: #05a; }
22
- a:hover { background: #ffffa5; }
23
- #search input { border: 1px solid #bbb; -moz-border-radius: 3px; -webkit-border-radius: 3px; }
28
+ li.clicked { background: #05a; color: #ccc; }
29
+ li.clicked a:link, li.clicked a:visited { color: #eee; }
30
+ li.clicked a.toggle { opacity: 0.5; background-position: bottom right; }
31
+ li.collapsed.clicked a.toggle { background-position: top right; }
32
+ #search input { border: 1px solid #bbb; -moz-border-radius: 3px; -webkit-border-radius: 3px; }
33
+ #nav { margin-left: 10px; font-size: 0.9em; display: none; color: #aaa; }
34
+ #nav a:link, #nav a:visited { color: #358; }
35
+ #nav a:hover { background: transparent; color: #5af; }
36
+
37
+ .frames #content h1 { margin-top: 0; }
38
+ .frames li { white-space: nowrap; cursor: normal; }
39
+ .frames li small { display: block; font-size: 0.8em; }
40
+ .frames li small:before { content: ""; }
41
+ .frames li small:after { content: ""; }
42
+ .frames li small.search_info { display: none; }
43
+ .frames #search { position: static; margin: 3px; margin-left: 10px; font-size: 0.9em; color: #888; }
44
+ .frames #search input { width: 110px; }
45
+ .frames #nav { display: block; }
46
+
47
+ #full_list.insearch li { display: none; }
48
+ #full_list.insearch li.found { display: list-item; padding-left: 10px; }
49
+ #full_list.insearch li a.toggle { display: none; }
50
+ #full_list.insearch li small.search_info { display: block; }
@@ -3,6 +3,7 @@ body {
3
3
  font-family: "Lucida Sans", "Lucida Grande", Verdana, Arial, sans-serif;
4
4
  font-size: 13px;
5
5
  }
6
+ body.frames { padding: 0 5px; }
6
7
  h1 { font-size: 25px; margin: 1em 0 0.5em; padding-top: 4px; border-top: 1px dotted #d5d5d5; }
7
8
  h1.noborder { border-top: 0px; margin-top: 0; padding-top: 4px; }
8
9
  h1.title { margin-bottom: 10px; }
@@ -188,6 +189,7 @@ ul.fullTree li.next:before { font-size: 1.2em; content: '\2B06'; color: #bbb; di
188
189
  -webkit-border-top-left-radius: 5px; -webkit-border-top-right-radius: 5px;
189
190
  }
190
191
  #search a.inactive { color: #999; }
192
+ .frames #search { display: none; }
191
193
  .inheritanceTree, .toggleDefines { float: right; }
192
194
 
193
195
  #menu { font-size: 1.3em; color: #bbb; top: -5px; position: relative; }
@@ -195,6 +197,8 @@ ul.fullTree li.next:before { font-size: 1.2em; content: '\2B06'; color: #bbb; di
195
197
  #menu .title { color: #555; }
196
198
  #menu a:link, #menu a:visited { color: #333; text-decoration: none; border-bottom: 1px dotted #bbd; }
197
199
  #menu a:hover { color: #05a; }
200
+ #menu .noframes { display: none; }
201
+ .frames #menu .noframes { display: inline; float: right; }
198
202
 
199
203
  #footer { margin-top: 15px; border-top: 1px solid #ccc; text-align: center; padding: 7px 0; color: #999; }
200
204
  #footer a:link, #footer a:visited { color: #444; text-decoration: none; border-bottom: 1px dotted #bbd; }
@@ -203,7 +207,7 @@ ul.fullTree li.next:before { font-size: 1.2em; content: '\2B06'; color: #bbb; di
203
207
  #listing ul.alpha { font-size: 1.1em; }
204
208
  #listing ul.alpha { margin: 0; padding: 0; padding-bottom: 10px; list-style: none; }
205
209
  #listing ul.alpha li.letter { font-size: 1.4em; padding-bottom: 10px; }
206
- #listing ul.alpha ul { margin: 0; padding: 0; }
210
+ #listing ul.alpha ul { margin: 0; padding-left: 15px; }
207
211
  #listing ul small { color: #666; font-size: 0.7em; }
208
212
 
209
213
  li.r1 { background: #f0f0f0; }
@@ -260,4 +264,5 @@ pre.code .gvar,
260
264
  pre.code .id.backref,
261
265
  pre.code .id.nth_ref { color: #6D79DE; }
262
266
  pre.code .regexp, .dregexp { color: #036A07; }
267
+ pre.code a { border-bottom: 1px dotted #bbf; }
263
268
 
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
3
+
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
7
+ <title><%= options[:title] %></title>
8
+ </head>
9
+ <frameset cols="20%,*">
10
+ <frame name="list" src="class_list.html" />
11
+ <frame name="main" src="index.html" />
12
+ </frameset>
13
+ </html>
@@ -7,30 +7,28 @@
7
7
  <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
8
8
  <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
9
9
  <script type="text/javascript" charset="utf-8" src="js/full_list.js"></script>
10
- <base target="_parent" />
10
+ <base id="base_target" target="_parent" />
11
11
  </head>
12
12
  <body>
13
- <h1 id="full_list_header"><%= @list_title %></h1>
14
- <div id="search">Search: <input type="text" /></div>
15
- <div class="clear"></div>
16
- <ul id="full_list">
17
- <% n = 1 %>
18
- <% @items.each do |item| %>
19
- <li class="r<%= n %> <%= item.is_a?(CodeObjects::Base) && item.has_tag?(:deprecated) ? 'deprecated' : '' %>">
20
- <% if @file_list %>
21
- <%= link_file item, File.basename(item).gsub(/\.[^.]+$/, '') %>
22
- <% elsif item.root? %>
23
- <a href="top-level-namespace.html">Top Level Namespace</a>
24
- <% else %>
25
- <%= linkify item, item.name(true) %>
26
- <% if item.namespace && !item.namespace.root? %>
27
- <small>(<%= item.namespace %>)</small>
28
- <% end %>
29
- <% end %>
30
- <% n = n == 2 ? 1 : 2 %>
31
- </li>
32
- <% end %>
33
- </ul>
13
+ <script type="text/javascript" charset="utf-8">
14
+ if (window.top.frames.main) {
15
+ document.getElementById('base_target').target = 'main';
16
+ document.body.className = 'frames';
17
+ }
18
+ </script>
19
+ <div id="content">
20
+ <h1 id="full_list_header"><%= @list_title %></h1>
21
+ <div id="nav">
22
+ <a target="_self" href="class_list.html">Classes</a> |
23
+ <a target="_self" href="method_list.html">Methods</a> |
24
+ <a target="_self" href="file_list.html">Files</a>
25
+ </div>
26
+ <div id="search">Search: <input type="text" /></div>
27
+
28
+ <ul id="full_list" class="<%= @list_type %>">
29
+ <%= erb "full_list_#{@list_type}" %>
30
+ </ul>
31
+ </div>
34
32
  </body>
35
33
  </html>
36
34
 
@@ -0,0 +1,2 @@
1
+ <li><%= link_object(Registry.root, nil, nil, false) %></li>
2
+ <%= class_list %>
@@ -0,0 +1,5 @@
1
+ <% n = 1 %>
2
+ <% @items.each do |item| %>
3
+ <li class="r<%= n %>"><%= link_file item, File.basename(item).gsub(/\.[^.]+$/, '') %></li>
4
+ <% n = n == 2 ? 1 : 2 %>
5
+ <% end %>
@@ -0,0 +1,12 @@
1
+ <% n = 1 %>
2
+ <% @items.each do |item| %>
3
+ <li class="r<%= n %> <%= item.has_tag?(:deprecated) ? 'deprecated' : '' %>">
4
+ <%= linkify item, item.name(true) %>
5
+ <% if item.namespace && !item.namespace.root? %>
6
+ <small><%= item.namespace %></small>
7
+ <% else %>
8
+ <small>Top Level Namespace</small>
9
+ <% end %>
10
+ </li>
11
+ <% n = n == 2 ? 1 : 2 %>
12
+ <% end %>
@@ -79,13 +79,21 @@ function toggleSearchFrame(id, link) {
79
79
 
80
80
  function linkSummaries() {
81
81
  $('.summary_signature').click(function() {
82
- window.parent.location = $(this).find('a').attr('href');
82
+ document.location = $(this).find('a').attr('href');
83
83
  });
84
84
  }
85
85
 
86
+ function framesInit() {
87
+ if (window.top.frames.main) {
88
+ document.body.className = 'frames';
89
+ $('#menu .noframes a').attr('href', document.location);
90
+ }
91
+ }
92
+
93
+ $(framesInit);
86
94
  $(createSourceLinks);
87
95
  $(createDefineLinks);
88
96
  $(createFullTreeLinks);
89
97
  $(fixBoxInfoHeights);
90
98
  $(searchFrameLinks);
91
- $(linkSummaries);
99
+ $(linkSummaries);
@@ -2,20 +2,36 @@ function fullListSearch() {
2
2
  $('#search input').keyup(function() {
3
3
  var value = this.value.toLowerCase();
4
4
  if (value == "") {
5
- $('#full_list li').show();
5
+ $('#full_list').removeClass('insearch');
6
+ $('#full_list li').each(function() {
7
+ var link = $(this).children('a:last');
8
+ link.text(link.text());
9
+ });
10
+ if (clicked) {
11
+ clicked.parents('ul').each(function() {
12
+ $(this).removeClass('collapsed').prev().removeClass('collapsed');
13
+ });
14
+ }
15
+ highlight();
6
16
  }
7
17
  else {
18
+ $('#full_list').addClass('insearch');
8
19
  $('#full_list li').each(function() {
9
- if ($(this).children('a').text().toLowerCase().indexOf(value) == -1) {
10
- $(this).hide();
20
+ var link = $(this).children('a:last');
21
+ var text = link.text();
22
+ if (text.toLowerCase().indexOf(value) == -1) {
23
+ $(this).removeClass('found');
24
+ link.text(link.text());
11
25
  }
12
26
  else {
13
- $(this).show();
27
+ $(this).css('padding-left', '10px').addClass('found');
28
+ link.html(link.text().replace(new RegExp("(" +
29
+ value.replace(/([\/.*+?|()\[\]{}\\])/g, "\\$1") + ")", "ig"),
30
+ '<strong>$1</strong>'));
14
31
  }
15
32
  });
33
+ highlight(true);
16
34
  }
17
- $('#full_list li:even:visible').removeClass('r2').addClass('r1');
18
- $('#full_list li:odd:visible').removeClass('r1').addClass('r2');
19
35
 
20
36
  if ($('#full_list li:visible').size() == 0) {
21
37
  $('#noresults').fadeIn();
@@ -29,11 +45,62 @@ function fullListSearch() {
29
45
  $('#full_list').after("<div id='noresults'>No results were found.</div>")
30
46
  }
31
47
 
48
+ clicked = null;
32
49
  function linkList() {
33
- $('#full_list li').click(function() {
34
- window.parent.location = $(this).find('a').attr('href');
50
+ $('#full_list li, #full_list li a:last').click(function(evt) {
51
+ if ($(this).hasClass('toggle')) return true;
52
+ if (this.tagName.toLowerCase() == "li") {
53
+ var toggle = $(this).children('a.toggle');
54
+ if (toggle.size() > 0 && evt.pageX < toggle.offset().left) {
55
+ toggle.click();
56
+ return false;
57
+ }
58
+ }
59
+ if (clicked) clicked.removeClass('clicked');
60
+ var win = window.parent;
61
+ if (window.top.frames.main) {
62
+ win = window.top.frames.main;
63
+ var title = $('html head title', win.document).text();
64
+ $('html head title', window.parent.document).text(title);
65
+ }
66
+ if (this.tagName.toLowerCase() == "a") {
67
+ clicked = $(this).parent('li').addClass('clicked');
68
+ win.location = this.href;
69
+ }
70
+ else {
71
+ clicked = $(this).addClass('clicked');
72
+ win.location = $(this).find('a:last').attr('href');
73
+ }
74
+ return false;
75
+ });
76
+ }
77
+
78
+ function collapse() {
79
+ if (!$('#full_list').hasClass('class')) return;
80
+ $('#full_list.class a.toggle').click(function() {
81
+ $(this).parent().toggleClass('collapsed').next().toggleClass('collapsed');
82
+ highlight();
83
+ return false;
84
+ });
85
+ $('#full_list.class ul').each(function() {
86
+ $(this).addClass('collapsed').prev().addClass('collapsed');
87
+ });
88
+ $('#full_list.class').children().removeClass('collapsed');
89
+ highlight();
90
+ }
91
+
92
+ function highlight(no_padding) {
93
+ var n = 1;
94
+ $('#full_list li:visible').each(function() {
95
+ var next = n == 1 ? 2 : 1;
96
+ $(this).removeClass("r" + next).addClass("r" + n);
97
+ if (!no_padding && $('#full_list').hasClass('class')) {
98
+ $(this).css('padding-left', (10 + $(this).parents('ul').size() * 15) + 'px');
99
+ }
100
+ n = next;
35
101
  });
36
102
  }
37
103
 
38
104
  $(fullListSearch);
39
- $(linkList);
105
+ $(linkList);
106
+ $(collapse);