enumerable-statistics 0.1.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -0
  3. data/CHANGELOG.md +15 -0
  4. data/LICENSE +21 -0
  5. data/README.md +60 -4
  6. data/Rakefile +11 -0
  7. data/bench/mean.rb +27 -0
  8. data/bench/sum.rb +26 -0
  9. data/bench/variance.rb +30 -0
  10. data/enumerable-statistics.gemspec +1 -0
  11. data/ext/enumerable/statistics/extension/statistics.c +811 -46
  12. data/images/benchmark.png +0 -0
  13. data/lib/enumerable/statistics/version.rb +1 -1
  14. data/yard/templates/mathjax/class/dot/setup.rb +6 -0
  15. data/yard/templates/mathjax/class/dot/superklass.erb +3 -0
  16. data/yard/templates/mathjax/class/html/constructor_details.erb +8 -0
  17. data/yard/templates/mathjax/class/html/setup.rb +1 -0
  18. data/yard/templates/mathjax/class/html/subclasses.erb +4 -0
  19. data/yard/templates/mathjax/class/setup.rb +36 -0
  20. data/yard/templates/mathjax/class/text/setup.rb +11 -0
  21. data/yard/templates/mathjax/class/text/subclasses.erb +5 -0
  22. data/yard/templates/mathjax/constant/text/header.erb +11 -0
  23. data/yard/templates/mathjax/constant/text/setup.rb +3 -0
  24. data/yard/templates/mathjax/docstring/html/abstract.erb +4 -0
  25. data/yard/templates/mathjax/docstring/html/deprecated.erb +1 -0
  26. data/yard/templates/mathjax/docstring/html/index.erb +5 -0
  27. data/yard/templates/mathjax/docstring/html/note.erb +6 -0
  28. data/yard/templates/mathjax/docstring/html/private.erb +4 -0
  29. data/yard/templates/mathjax/docstring/html/returns_void.erb +1 -0
  30. data/yard/templates/mathjax/docstring/html/text.erb +1 -0
  31. data/yard/templates/mathjax/docstring/html/todo.erb +6 -0
  32. data/yard/templates/mathjax/docstring/setup.rb +51 -0
  33. data/yard/templates/mathjax/docstring/text/abstract.erb +2 -0
  34. data/yard/templates/mathjax/docstring/text/deprecated.erb +2 -0
  35. data/yard/templates/mathjax/docstring/text/index.erb +2 -0
  36. data/yard/templates/mathjax/docstring/text/note.erb +4 -0
  37. data/yard/templates/mathjax/docstring/text/private.erb +2 -0
  38. data/yard/templates/mathjax/docstring/text/returns_void.erb +1 -0
  39. data/yard/templates/mathjax/docstring/text/text.erb +1 -0
  40. data/yard/templates/mathjax/docstring/text/todo.erb +4 -0
  41. data/yard/templates/mathjax/fulldoc/html/css/common.css +1 -0
  42. data/yard/templates/mathjax/fulldoc/html/css/full_list.css +58 -0
  43. data/yard/templates/mathjax/fulldoc/html/css/style.css +481 -0
  44. data/yard/templates/mathjax/fulldoc/html/frames.erb +17 -0
  45. data/yard/templates/mathjax/fulldoc/html/full_list.erb +37 -0
  46. data/yard/templates/mathjax/fulldoc/html/full_list_class.erb +2 -0
  47. data/yard/templates/mathjax/fulldoc/html/full_list_file.erb +7 -0
  48. data/yard/templates/mathjax/fulldoc/html/full_list_method.erb +10 -0
  49. data/yard/templates/mathjax/fulldoc/html/js/app.js +243 -0
  50. data/yard/templates/mathjax/fulldoc/html/js/full_list.js +216 -0
  51. data/yard/templates/mathjax/fulldoc/html/js/jquery.js +4 -0
  52. data/yard/templates/mathjax/fulldoc/html/setup.rb +242 -0
  53. data/yard/templates/mathjax/layout/dot/header.erb +6 -0
  54. data/yard/templates/mathjax/layout/dot/setup.rb +14 -0
  55. data/yard/templates/mathjax/layout/html/breadcrumb.erb +11 -0
  56. data/yard/templates/mathjax/layout/html/files.erb +11 -0
  57. data/yard/templates/mathjax/layout/html/footer.erb +5 -0
  58. data/yard/templates/mathjax/layout/html/headers.erb +15 -0
  59. data/yard/templates/mathjax/layout/html/index.erb +2 -0
  60. data/yard/templates/mathjax/layout/html/layout.erb +38 -0
  61. data/yard/templates/mathjax/layout/html/listing.erb +4 -0
  62. data/yard/templates/mathjax/layout/html/objects.erb +32 -0
  63. data/yard/templates/mathjax/layout/html/script_setup.erb +4 -0
  64. data/yard/templates/mathjax/layout/html/search.erb +13 -0
  65. data/yard/templates/mathjax/layout/html/setup.rb +87 -0
  66. data/yard/templates/mathjax/method/html/header.erb +17 -0
  67. data/yard/templates/mathjax/method/setup.rb +3 -0
  68. data/yard/templates/mathjax/method/text/header.erb +1 -0
  69. data/yard/templates/mathjax/method_details/html/header.erb +3 -0
  70. data/yard/templates/mathjax/method_details/html/method_signature.erb +25 -0
  71. data/yard/templates/mathjax/method_details/html/source.erb +10 -0
  72. data/yard/templates/mathjax/method_details/setup.rb +10 -0
  73. data/yard/templates/mathjax/method_details/text/header.erb +10 -0
  74. data/yard/templates/mathjax/method_details/text/method_signature.erb +12 -0
  75. data/yard/templates/mathjax/method_details/text/setup.rb +10 -0
  76. data/yard/templates/mathjax/module/dot/child.erb +1 -0
  77. data/yard/templates/mathjax/module/dot/dependencies.erb +3 -0
  78. data/yard/templates/mathjax/module/dot/header.erb +6 -0
  79. data/yard/templates/mathjax/module/dot/info.erb +14 -0
  80. data/yard/templates/mathjax/module/dot/setup.rb +14 -0
  81. data/yard/templates/mathjax/module/html/attribute_details.erb +10 -0
  82. data/yard/templates/mathjax/module/html/attribute_summary.erb +8 -0
  83. data/yard/templates/mathjax/module/html/box_info.erb +43 -0
  84. data/yard/templates/mathjax/module/html/children.erb +8 -0
  85. data/yard/templates/mathjax/module/html/constant_summary.erb +11 -0
  86. data/yard/templates/mathjax/module/html/defines.erb +3 -0
  87. data/yard/templates/mathjax/module/html/header.erb +5 -0
  88. data/yard/templates/mathjax/module/html/inherited_attributes.erb +14 -0
  89. data/yard/templates/mathjax/module/html/inherited_constants.erb +8 -0
  90. data/yard/templates/mathjax/module/html/inherited_methods.erb +19 -0
  91. data/yard/templates/mathjax/module/html/item_summary.erb +40 -0
  92. data/yard/templates/mathjax/module/html/method_details_list.erb +9 -0
  93. data/yard/templates/mathjax/module/html/method_summary.erb +14 -0
  94. data/yard/templates/mathjax/module/html/methodmissing.erb +12 -0
  95. data/yard/templates/mathjax/module/html/pre_docstring.erb +1 -0
  96. data/yard/templates/mathjax/module/setup.rb +164 -0
  97. data/yard/templates/mathjax/module/text/children.erb +10 -0
  98. data/yard/templates/mathjax/module/text/class_meths_list.erb +8 -0
  99. data/yard/templates/mathjax/module/text/extends.erb +8 -0
  100. data/yard/templates/mathjax/module/text/header.erb +7 -0
  101. data/yard/templates/mathjax/module/text/includes.erb +8 -0
  102. data/yard/templates/mathjax/module/text/instance_meths_list.erb +8 -0
  103. data/yard/templates/mathjax/module/text/setup.rb +12 -0
  104. data/yard/templates/mathjax/onefile/html/files.erb +5 -0
  105. data/yard/templates/mathjax/onefile/html/headers.erb +6 -0
  106. data/yard/templates/mathjax/onefile/html/layout.erb +29 -0
  107. data/yard/templates/mathjax/onefile/html/readme.erb +3 -0
  108. data/yard/templates/mathjax/onefile/html/setup.rb +61 -0
  109. data/yard/templates/mathjax/root/dot/child.erb +3 -0
  110. data/yard/templates/mathjax/root/dot/setup.rb +5 -0
  111. data/yard/templates/mathjax/root/html/setup.rb +1 -0
  112. data/yard/templates/mathjax/tags/html/example.erb +11 -0
  113. data/yard/templates/mathjax/tags/html/index.erb +3 -0
  114. data/yard/templates/mathjax/tags/html/option.erb +24 -0
  115. data/yard/templates/mathjax/tags/html/overload.erb +14 -0
  116. data/yard/templates/mathjax/tags/html/see.erb +8 -0
  117. data/yard/templates/mathjax/tags/html/tag.erb +20 -0
  118. data/yard/templates/mathjax/tags/setup.rb +55 -0
  119. data/yard/templates/mathjax/tags/text/example.erb +12 -0
  120. data/yard/templates/mathjax/tags/text/index.erb +1 -0
  121. data/yard/templates/mathjax/tags/text/option.erb +20 -0
  122. data/yard/templates/mathjax/tags/text/overload.erb +19 -0
  123. data/yard/templates/mathjax/tags/text/see.erb +11 -0
  124. data/yard/templates/mathjax/tags/text/tag.erb +13 -0
  125. metadata +134 -2
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="<%= charset %>">
5
+ <title><%= options.title %></title>
6
+ </head>
7
+ <script type="text/javascript" charset="utf-8">
8
+ var match = unescape(window.location.hash).match(/^#!(.+)/);
9
+ var name = match ? match[1] : '<%= url_for_main %>';
10
+ name = name.replace(/^(\w+):\/\//, '').replace(/^\/\//, '');
11
+ window.top.location = name;
12
+ </script>
13
+ <noscript>
14
+ <h1>Oops!</h1>
15
+ <h2>YARD requires JavaScript!</h2>
16
+ </noscript>
17
+ </html>
@@ -0,0 +1,37 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
5
+ <meta charset="<%= charset %>" />
6
+ <% stylesheets_full_list.each do |stylesheet| %>
7
+ <link rel="stylesheet" href="<%= url_for(stylesheet) %>" type="text/css" media="screen" charset="utf-8" />
8
+ <% end %>
9
+
10
+ <% javascripts_full_list.each do |javascript| %>
11
+ <script type="text/javascript" charset="utf-8" src="<%= url_for(javascript) %>"></script>
12
+ <% end %>
13
+
14
+ <title><%= @list_title %></title>
15
+ <base id="base_target" target="_parent" />
16
+ </head>
17
+ <body>
18
+ <div id="content">
19
+ <div class="fixed_header">
20
+ <h1 id="full_list_header"><%= @list_title %></h1>
21
+ <div id="full_list_nav">
22
+ <% menu_lists.each do |list| %>
23
+ <span><a target="_self" href="<%= url_for_list list[:type] %>">
24
+ <%= list[:title] %>
25
+ </a></span>
26
+ <% end %>
27
+ </div>
28
+
29
+ <div id="search">Search: <input type="text" /></div>
30
+ </div>
31
+
32
+ <ul id="full_list" class="<%= @list_class || @list_type %>">
33
+ <%= erb "full_list_#{@list_type}" %>
34
+ </ul>
35
+ </div>
36
+ </body>
37
+ </html>
@@ -0,0 +1,2 @@
1
+ <li id="object_" class="odd"><div class="item" style="padding-left:30px"><%= link_object(Registry.root, Registry.root.title, nil, false) %></div></li>
2
+ <%= class_list %>
@@ -0,0 +1,7 @@
1
+ <% even_odd = 'odd' %>
2
+ <% @items.each do |item| %>
3
+ <li id="object_<%= item.path %>" class="<%= even_odd %>">
4
+ <div class="item"><span class="object_link"><%= link_file item %></span></div>
5
+ </li>
6
+ <% even_odd = (even_odd == 'even' ? 'odd' : 'even') %>
7
+ <% end %>
@@ -0,0 +1,10 @@
1
+ <% even_odd = 'odd' %>
2
+ <% @items.each do |item| %>
3
+ <li class="<%= even_odd %> <%= item.has_tag?(:deprecated) ? 'deprecated' : '' %>">
4
+ <div class="item">
5
+ <%= linkify item, h(item.name(true)) %>
6
+ <small><%= item.namespace.title %></small>
7
+ </div>
8
+ </li>
9
+ <% even_odd = (even_odd == 'even' ? 'odd' : 'even') %>
10
+ <% end %>
@@ -0,0 +1,243 @@
1
+ (function() {
2
+
3
+ var localStorage = {}, sessionStorage = {};
4
+ try { localStorage = window.localStorage; } catch (e) { }
5
+ try { sessionStorage = window.sessionStorage; } catch (e) { }
6
+
7
+ function createSourceLinks() {
8
+ $('.method_details_list .source_code').
9
+ before("<span class='showSource'>[<a href='#' class='toggleSource'>View source</a>]</span>");
10
+ $('.toggleSource').toggle(function() {
11
+ $(this).parent().nextAll('.source_code').slideDown(100);
12
+ $(this).text("Hide source");
13
+ },
14
+ function() {
15
+ $(this).parent().nextAll('.source_code').slideUp(100);
16
+ $(this).text("View source");
17
+ });
18
+ }
19
+
20
+ function createDefineLinks() {
21
+ var tHeight = 0;
22
+ $('.defines').after(" <a href='#' class='toggleDefines'>more...</a>");
23
+ $('.toggleDefines').toggle(function() {
24
+ tHeight = $(this).parent().prev().height();
25
+ $(this).prev().css('display', 'inline');
26
+ $(this).parent().prev().height($(this).parent().height());
27
+ $(this).text("(less)");
28
+ },
29
+ function() {
30
+ $(this).prev().hide();
31
+ $(this).parent().prev().height(tHeight);
32
+ $(this).text("more...");
33
+ });
34
+ }
35
+
36
+ function createFullTreeLinks() {
37
+ var tHeight = 0;
38
+ $('.inheritanceTree').toggle(function() {
39
+ tHeight = $(this).parent().prev().height();
40
+ $(this).parent().toggleClass('showAll');
41
+ $(this).text("(hide)");
42
+ $(this).parent().prev().height($(this).parent().height());
43
+ },
44
+ function() {
45
+ $(this).parent().toggleClass('showAll');
46
+ $(this).parent().prev().height(tHeight);
47
+ $(this).text("show all");
48
+ });
49
+ }
50
+
51
+ function searchFrameButtons() {
52
+ $('.full_list_link').click(function() {
53
+ toggleSearchFrame(this, $(this).attr('href'));
54
+ return false;
55
+ });
56
+ window.addEventListener('message', function(e) {
57
+ if (e.data === 'navEscape') {
58
+ $('#search_frame').slideUp(100);
59
+ $('#search a').removeClass('active inactive');
60
+ $(window).focus();
61
+ }
62
+ });
63
+
64
+ $(window).resize(function() {
65
+ if ($('#search:visible').length === 0) {
66
+ $('#search_frame').slideUp(100);
67
+ $('#search a').removeClass('active inactive');
68
+ $(window).focus();
69
+ }
70
+ });
71
+ }
72
+
73
+ function toggleSearchFrame(id, link) {
74
+ var frame = $('#search_frame');
75
+ $('#search a').removeClass('active').addClass('inactive');
76
+ if (frame.attr('src') === link && frame.css('display') !== "none") {
77
+ frame.slideUp(100);
78
+ $('#search a').removeClass('active inactive');
79
+ }
80
+ else {
81
+ $(id).addClass('active').removeClass('inactive');
82
+ if (frame.attr('src') !== link) frame.attr('src', link);
83
+ frame.slideDown(100);
84
+ }
85
+ }
86
+
87
+ function linkSummaries() {
88
+ $('.summary_signature').click(function() {
89
+ document.location = $(this).find('a').attr('href');
90
+ });
91
+ }
92
+
93
+ function summaryToggle() {
94
+ $('.summary_toggle').click(function(e) {
95
+ e.preventDefault();
96
+ localStorage.summaryCollapsed = $(this).text();
97
+ $('.summary_toggle').each(function() {
98
+ $(this).text($(this).text() == "collapse" ? "expand" : "collapse");
99
+ var next = $(this).parent().parent().nextAll('ul.summary').first();
100
+ if (next.hasClass('compact')) {
101
+ next.toggle();
102
+ next.nextAll('ul.summary').first().toggle();
103
+ }
104
+ else if (next.hasClass('summary')) {
105
+ var list = $('<ul class="summary compact" />');
106
+ list.html(next.html());
107
+ list.find('.summary_desc, .note').remove();
108
+ list.find('a').each(function() {
109
+ $(this).html($(this).find('strong').html());
110
+ $(this).parent().html($(this)[0].outerHTML);
111
+ });
112
+ next.before(list);
113
+ next.toggle();
114
+ }
115
+ });
116
+ return false;
117
+ });
118
+ if (localStorage.summaryCollapsed == "collapse") {
119
+ $('.summary_toggle').first().click();
120
+ } else { localStorage.summaryCollapsed = "expand"; }
121
+ }
122
+
123
+ function generateTOC() {
124
+ if ($('#filecontents').length === 0) return;
125
+ var _toc = $('<ol class="top"></ol>');
126
+ var show = false;
127
+ var toc = _toc;
128
+ var counter = 0;
129
+ var tags = ['h2', 'h3', 'h4', 'h5', 'h6'];
130
+ var i;
131
+ if ($('#filecontents h1').length > 1) tags.unshift('h1');
132
+ for (i = 0; i < tags.length; i++) { tags[i] = '#filecontents ' + tags[i]; }
133
+ var lastTag = parseInt(tags[0][1], 10);
134
+ $(tags.join(', ')).each(function() {
135
+ if ($(this).parents('.method_details .docstring').length != 0) return;
136
+ if (this.id == "filecontents") return;
137
+ show = true;
138
+ var thisTag = parseInt(this.tagName[1], 10);
139
+ if (this.id.length === 0) {
140
+ var proposedId = $(this).attr('toc-id');
141
+ if (typeof(proposedId) != "undefined") this.id = proposedId;
142
+ else {
143
+ var proposedId = $(this).text().replace(/[^a-z0-9-]/ig, '_');
144
+ if ($('#' + proposedId).length > 0) { proposedId += counter; counter++; }
145
+ this.id = proposedId;
146
+ }
147
+ }
148
+ if (thisTag > lastTag) {
149
+ for (i = 0; i < thisTag - lastTag; i++) {
150
+ var tmp = $('<ol/>'); toc.append(tmp); toc = tmp;
151
+ }
152
+ }
153
+ if (thisTag < lastTag) {
154
+ for (i = 0; i < lastTag - thisTag; i++) toc = toc.parent();
155
+ }
156
+ var title = $(this).attr('toc-title');
157
+ if (typeof(title) == "undefined") title = $(this).text();
158
+ toc.append('<li><a href="#' + this.id + '">' + title + '</a></li>');
159
+ lastTag = thisTag;
160
+ });
161
+ if (!show) return;
162
+ html = '<div id="toc"><p class="title hide_toc"><a href="#"><strong>Table of Contents</strong></a></p></div>';
163
+ $('#content').prepend(html);
164
+ $('#toc').append(_toc);
165
+ $('#toc .hide_toc').toggle(function() {
166
+ $('#toc .top').slideUp('fast');
167
+ $('#toc').toggleClass('hidden');
168
+ $('#toc .title small').toggle();
169
+ }, function() {
170
+ $('#toc .top').slideDown('fast');
171
+ $('#toc').toggleClass('hidden');
172
+ $('#toc .title small').toggle();
173
+ });
174
+ }
175
+
176
+ function navResizeFn(e) {
177
+ if (e.which !== 1) {
178
+ navResizeFnStop();
179
+ return;
180
+ }
181
+
182
+ sessionStorage.navWidth = e.pageX.toString();
183
+ $('.nav_wrap').css('width', e.pageX);
184
+ $('.nav_wrap').css('-ms-flex', 'inherit');
185
+ }
186
+
187
+ function navResizeFnStop() {
188
+ $(window).unbind('mousemove', navResizeFn);
189
+ window.removeEventListener('message', navMessageFn, false);
190
+ }
191
+
192
+ function navMessageFn(e) {
193
+ if (e.data.action === 'mousemove') navResizeFn(e.data.event);
194
+ if (e.data.action === 'mouseup') navResizeFnStop();
195
+ }
196
+
197
+ function navResizer() {
198
+ $('#resizer').mousedown(function(e) {
199
+ e.preventDefault();
200
+ $(window).mousemove(navResizeFn);
201
+ window.addEventListener('message', navMessageFn, false);
202
+ });
203
+ $(window).mouseup(navResizeFnStop);
204
+
205
+ if (sessionStorage.navWidth) {
206
+ navResizeFn({which: 1, pageX: parseInt(sessionStorage.navWidth, 10)});
207
+ }
208
+ }
209
+
210
+ function navExpander() {
211
+ var done = false, timer = setTimeout(postMessage, 500);
212
+ function postMessage() {
213
+ if (done) return;
214
+ clearTimeout(timer);
215
+ var opts = { action: 'expand', path: pathId };
216
+ document.getElementById('nav').contentWindow.postMessage(opts, '*');
217
+ done = true;
218
+ }
219
+
220
+ window.addEventListener('message', function(event) {
221
+ if (event.data === 'navReady') postMessage();
222
+ return false;
223
+ }, false);
224
+ }
225
+
226
+ function mainFocus() {
227
+ $('#main')[0].focus();
228
+ }
229
+
230
+ $(document).ready(function() {
231
+ navResizer();
232
+ navExpander();
233
+ createSourceLinks();
234
+ createDefineLinks();
235
+ createFullTreeLinks();
236
+ searchFrameButtons();
237
+ linkSummaries();
238
+ summaryToggle();
239
+ generateTOC();
240
+ mainFocus();
241
+ });
242
+
243
+ })();
@@ -0,0 +1,216 @@
1
+ (function() {
2
+
3
+ var $clicked = $(null);
4
+ var searchTimeout = null;
5
+ var searchCache = [];
6
+ var caseSensitiveMatch = false;
7
+ var ignoreKeyCodeMin = 8;
8
+ var ignoreKeyCodeMax = 46;
9
+ var commandKey = 91;
10
+
11
+ RegExp.escape = function(text) {
12
+ return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
13
+ }
14
+
15
+ function escapeShortcut() {
16
+ $(document).keydown(function(evt) {
17
+ if (evt.which == 27) {
18
+ window.parent.postMessage('navEscape', '*');
19
+ }
20
+ });
21
+ }
22
+
23
+ function navResizer() {
24
+ $(window).mousemove(function(e) {
25
+ window.parent.postMessage({
26
+ action: 'mousemove', event: {pageX: e.pageX, which: e.which}
27
+ }, '*');
28
+ }).mouseup(function(e) {
29
+ window.parent.postMessage({action: 'mouseup'}, '*');
30
+ });
31
+ window.parent.postMessage("navReady", "*");
32
+ }
33
+
34
+ function clearSearchTimeout() {
35
+ clearTimeout(searchTimeout);
36
+ searchTimeout = null;
37
+ }
38
+
39
+ function enableLinks() {
40
+ // load the target page in the parent window
41
+ $('#full_list li').on('click', function(evt) {
42
+ $('#full_list li').removeClass('clicked');
43
+ $clicked = $(this);
44
+ $clicked.addClass('clicked');
45
+ evt.stopPropagation();
46
+
47
+ if (evt.target.tagName === 'A') return true;
48
+
49
+ var elem = $clicked.find('> .item .object_link a')[0];
50
+ var e = evt.originalEvent;
51
+ var newEvent = new MouseEvent(evt.originalEvent.type);
52
+ newEvent.initMouseEvent(e.type, e.canBubble, e.cancelable, e.view, e.detail, e.screenX, e.screenY, e.clientX, e.clientY, e.ctrlKey, e.altKey, e.shiftKey, e.metaKey, e.button, e.relatedTarget);
53
+ elem.dispatchEvent(newEvent);
54
+ evt.preventDefault();
55
+ return false;
56
+ });
57
+ }
58
+
59
+ function enableToggles() {
60
+ // show/hide nested classes on toggle click
61
+ $('#full_list a.toggle').on('click', function(evt) {
62
+ evt.stopPropagation();
63
+ evt.preventDefault();
64
+ $(this).parent().parent().toggleClass('collapsed');
65
+ highlight();
66
+ });
67
+ }
68
+
69
+ function populateSearchCache() {
70
+ $('#full_list li .item').each(function() {
71
+ var $node = $(this);
72
+ var $link = $node.find('.object_link a');
73
+ if ($link.length > 0) {
74
+ searchCache.push({
75
+ node: $node,
76
+ link: $link,
77
+ name: $link.text(),
78
+ fullName: $link.attr('title').split(' ')[0]
79
+ });
80
+ }
81
+ });
82
+ }
83
+
84
+ function enableSearch() {
85
+ $('#search input').keyup(function(event) {
86
+ if (ignoredKeyPress(event)) return;
87
+ if (this.value === "") {
88
+ clearSearch();
89
+ } else {
90
+ performSearch(this.value);
91
+ }
92
+ });
93
+
94
+ $('#full_list').after("<div id='noresults' style='display:none'></div>");
95
+ }
96
+
97
+ function ignoredKeyPress(event) {
98
+ if (
99
+ (event.keyCode > ignoreKeyCodeMin && event.keyCode < ignoreKeyCodeMax) ||
100
+ (event.keyCode == commandKey)
101
+ ) {
102
+ return true;
103
+ } else {
104
+ return false;
105
+ }
106
+ }
107
+
108
+ function clearSearch() {
109
+ clearSearchTimeout();
110
+ $('#full_list .found').removeClass('found').each(function() {
111
+ var $link = $(this).find('.object_link a');
112
+ $link.text($link.text());
113
+ });
114
+ $('#full_list, #content').removeClass('insearch');
115
+ $clicked.parents().removeClass('collapsed');
116
+ highlight();
117
+ }
118
+
119
+ function performSearch(searchString) {
120
+ clearSearchTimeout();
121
+ $('#full_list, #content').addClass('insearch');
122
+ $('#noresults').text('').hide();
123
+ partialSearch(searchString, 0);
124
+ }
125
+
126
+ function partialSearch(searchString, offset) {
127
+ var lastRowClass = '';
128
+ var i = null;
129
+ for (i = offset; i < Math.min(offset + 50, searchCache.length); i++) {
130
+ var item = searchCache[i];
131
+ var searchName = (searchString.indexOf('::') != -1 ? item.fullName : item.name);
132
+ var matchString = buildMatchString(searchString);
133
+ var matchRegexp = new RegExp(matchString, caseSensitiveMatch ? "" : "i");
134
+ if (searchName.match(matchRegexp) == null) {
135
+ item.node.removeClass('found');
136
+ item.link.text(item.link.text());
137
+ }
138
+ else {
139
+ item.node.addClass('found');
140
+ item.node.removeClass(lastRowClass).addClass(lastRowClass == 'r1' ? 'r2' : 'r1');
141
+ lastRowClass = item.node.hasClass('r1') ? 'r1' : 'r2';
142
+ item.link.html(item.name.replace(matchRegexp, "<strong>$&</strong>"));
143
+ }
144
+ }
145
+ if(i == searchCache.length) {
146
+ searchDone();
147
+ } else {
148
+ searchTimeout = setTimeout(function() {
149
+ partialSearch(searchString, i);
150
+ }, 0);
151
+ }
152
+ }
153
+
154
+ function searchDone() {
155
+ searchTimeout = null;
156
+ highlight();
157
+ if ($('#full_list li:visible').size() === 0) {
158
+ $('#noresults').text('No results were found.').hide().fadeIn();
159
+ } else {
160
+ $('#noresults').text('').hide();
161
+ }
162
+ $('#content').removeClass('insearch');
163
+ }
164
+
165
+ function buildMatchString(searchString, event) {
166
+ caseSensitiveMatch = searchString.match(/[A-Z]/) != null;
167
+ var regexSearchString = RegExp.escape(searchString);
168
+ if (caseSensitiveMatch) {
169
+ regexSearchString += "|" +
170
+ $.map(searchString.split(''), function(e) { return RegExp.escape(e); }).
171
+ join('.+?');
172
+ }
173
+ return regexSearchString;
174
+ }
175
+
176
+ function highlight() {
177
+ $('#full_list li:visible').each(function(n) {
178
+ $(this).removeClass('even odd').addClass(n % 2 == 0 ? 'odd' : 'even');
179
+ });
180
+ }
181
+
182
+ /**
183
+ * Expands the tree to the target element and its immediate
184
+ * children.
185
+ */
186
+ function expandTo(path) {
187
+ var $target = $(document.getElementById('object_' + path));
188
+ $target.addClass('clicked');
189
+ $target.removeClass('collapsed');
190
+ $target.parentsUntil('#full_list', 'li').removeClass('collapsed');
191
+ if($target[0]) {
192
+ window.scrollTo(window.scrollX, $target.offset().top - 250);
193
+ highlight();
194
+ }
195
+ }
196
+
197
+ function windowEvents(event) {
198
+ var msg = event.data;
199
+ if (msg.action === "expand") {
200
+ expandTo(msg.path);
201
+ }
202
+ return false;
203
+ }
204
+
205
+ window.addEventListener("message", windowEvents, false);
206
+
207
+ $(document).ready(function() {
208
+ escapeShortcut();
209
+ navResizer();
210
+ enableLinks();
211
+ enableToggles();
212
+ populateSearchCache();
213
+ enableSearch();
214
+ });
215
+
216
+ })();