1 | // © 2009â2010 EPFL/LAMP |
---|
2 | // code by Gilles Dubochet with contributions by Pedro Furlanetto |
---|
3 | |
---|
4 | $(document).ready(function(){ |
---|
5 | var isHiddenClass; |
---|
6 | if (document.title == 'scala.AnyRef') { |
---|
7 | isHiddenClass = function (name) { |
---|
8 | return name == 'scala.Any'; |
---|
9 | }; |
---|
10 | } else { |
---|
11 | isHiddenClass = function (name) { |
---|
12 | return name == 'scala.Any' || name == 'scala.AnyRef'; |
---|
13 | }; |
---|
14 | } |
---|
15 | |
---|
16 | $("#linearization li").filter(function(){ |
---|
17 | return isHiddenClass($(this).attr("name")); |
---|
18 | }).removeClass("in").addClass("out"); |
---|
19 | filter(); |
---|
20 | |
---|
21 | var input = $("#textfilter input"); |
---|
22 | input.bind("keyup", function(event) { |
---|
23 | if (event.keyCode == 27) { // escape |
---|
24 | input.attr("value", ""); |
---|
25 | } |
---|
26 | filter(); |
---|
27 | }); |
---|
28 | input.focus(function(event) { input.select(); }); |
---|
29 | $("#textfilter > .post").click(function(){ |
---|
30 | $("#textfilter input").attr("value", ""); |
---|
31 | filter(); |
---|
32 | }); |
---|
33 | |
---|
34 | $("#linearization li").click(function(){ |
---|
35 | if ($(this).hasClass("in")) { |
---|
36 | $(this).removeClass("in"); |
---|
37 | $(this).addClass("out"); |
---|
38 | } |
---|
39 | else if ($(this).hasClass("out")) { |
---|
40 | $(this).removeClass("out"); |
---|
41 | $(this).addClass("in"); |
---|
42 | }; |
---|
43 | filter(); |
---|
44 | }); |
---|
45 | $("#ancestors > ol > li.hideall").click(function() { |
---|
46 | $("#linearization li.in").removeClass("in").addClass("out"); |
---|
47 | $("#linearization li:first").removeClass("out").addClass("in"); |
---|
48 | filter(); |
---|
49 | }) |
---|
50 | $("#ancestors > ol > li.showall").click(function() { |
---|
51 | var filtered = |
---|
52 | $("#linearization li.out").filter(function() { |
---|
53 | return ! isHiddenClass($(this).attr("name")); |
---|
54 | }); |
---|
55 | filtered.removeClass("out").addClass("in"); |
---|
56 | filter(); |
---|
57 | }); |
---|
58 | $("#visbl > ol > li.public").click(function() { |
---|
59 | if ($(this).hasClass("out")) { |
---|
60 | $(this).removeClass("out").addClass("in"); |
---|
61 | $("#visbl > ol > li.all").removeClass("in").addClass("out"); |
---|
62 | filter(); |
---|
63 | }; |
---|
64 | }) |
---|
65 | $("#visbl > ol > li.all").click(function() { |
---|
66 | if ($(this).hasClass("out")) { |
---|
67 | $(this).removeClass("out").addClass("in"); |
---|
68 | $("#visbl > ol > li.public").removeClass("in").addClass("out"); |
---|
69 | filter(); |
---|
70 | }; |
---|
71 | }); |
---|
72 | $("#order > ol > li.alpha").click(function() { |
---|
73 | if ($(this).hasClass("out")) { |
---|
74 | $(this).removeClass("out").addClass("in"); |
---|
75 | $("#order > ol > li.inherit").removeClass("in").addClass("out"); |
---|
76 | orderAlpha(); |
---|
77 | }; |
---|
78 | }) |
---|
79 | $("#order > ol > li.inherit").click(function() { |
---|
80 | if ($(this).hasClass("out")) { |
---|
81 | $(this).removeClass("out").addClass("in"); |
---|
82 | $("#order > ol > li.alpha").removeClass("in").addClass("out"); |
---|
83 | orderInherit(); |
---|
84 | }; |
---|
85 | }); |
---|
86 | initInherit(); |
---|
87 | |
---|
88 | // Create tooltips |
---|
89 | $(".extype").add(".defval").tooltip({ |
---|
90 | tip: "#tooltip", |
---|
91 | position:"top center", |
---|
92 | predelay: 500, |
---|
93 | onBeforeShow: function(ev) { |
---|
94 | $(this.getTip()).text(this.getTrigger().attr("name")); |
---|
95 | } |
---|
96 | }); |
---|
97 | |
---|
98 | /* Add toggle arrows */ |
---|
99 | var docAllSigs = $("#template li").has(".fullcomment").find(".signature"); |
---|
100 | |
---|
101 | function commentToggleFct(signature){ |
---|
102 | var parent = signature.parent(); |
---|
103 | var shortComment = $(".shortcomment", parent); |
---|
104 | var fullComment = $(".fullcomment", parent); |
---|
105 | var vis = $(":visible", fullComment); |
---|
106 | signature.toggleClass("closed").toggleClass("opened"); |
---|
107 | if (vis.length > 0) { |
---|
108 | shortComment.slideDown(100); |
---|
109 | fullComment.slideUp(100); |
---|
110 | } |
---|
111 | else { |
---|
112 | shortComment.slideUp(100); |
---|
113 | fullComment.slideDown(100); |
---|
114 | } |
---|
115 | }; |
---|
116 | docAllSigs.addClass("closed"); |
---|
117 | docAllSigs.click(function() { |
---|
118 | commentToggleFct($(this)); |
---|
119 | }); |
---|
120 | |
---|
121 | /* Linear super types and known subclasses */ |
---|
122 | function toggleShowContentFct(outerElement){ |
---|
123 | var content = $(".hiddenContent", outerElement); |
---|
124 | var vis = $(":visible", content); |
---|
125 | if (vis.length > 0) { |
---|
126 | content.slideUp(100); |
---|
127 | $(".showElement", outerElement).show(); |
---|
128 | $(".hideElement", outerElement).hide(); |
---|
129 | } |
---|
130 | else { |
---|
131 | content.slideDown(100); |
---|
132 | $(".showElement", outerElement).hide(); |
---|
133 | $(".hideElement", outerElement).show(); |
---|
134 | } |
---|
135 | }; |
---|
136 | $(".toggleContainer").click(function() { |
---|
137 | toggleShowContentFct($(this)); |
---|
138 | }); |
---|
139 | |
---|
140 | // Set parent window title |
---|
141 | windowTitle(); |
---|
142 | }); |
---|
143 | |
---|
144 | function orderAlpha() { |
---|
145 | $("#template > div.parent").hide(); |
---|
146 | $("#ancestors").show(); |
---|
147 | filter(); |
---|
148 | }; |
---|
149 | |
---|
150 | function orderInherit() { |
---|
151 | $("#template > div.parent").show(); |
---|
152 | $("#ancestors").hide(); |
---|
153 | filter(); |
---|
154 | }; |
---|
155 | |
---|
156 | /** Prepares the DOM for inheritance-based display. To do so it will: |
---|
157 | * - hide all statically-generated parents headings; |
---|
158 | * - copy all members from the value and type members lists (flat members) to corresponding lists nested below the |
---|
159 | * parent headings (inheritance-grouped members); |
---|
160 | * - initialises a control variable used by the filter method to control whether filtering happens on flat members |
---|
161 | * or on inheritance-grouped members. */ |
---|
162 | function initInherit() { |
---|
163 | // parents is a map from fully-qualified names to the DOM node of parent headings. |
---|
164 | var parents = new Object(); |
---|
165 | $("#template > div.parent").each(function(){ |
---|
166 | parents[$(this).attr("name")] = $(this); |
---|
167 | }); |
---|
168 | // |
---|
169 | $("#types > ol > li").each(function(){ |
---|
170 | var qualName = $(this).attr("name"); |
---|
171 | var owner = qualName.slice(0, qualName.indexOf("#")); |
---|
172 | var name = qualName.slice(qualName.indexOf("#") + 1); |
---|
173 | var parent = parents[owner]; |
---|
174 | if (parent != undefined) { |
---|
175 | var types = $("> .types > ol", parent); |
---|
176 | if (types.length == 0) { |
---|
177 | parent.append("<div class='types members'><h3>Type Members</h3><ol></ol></div>"); |
---|
178 | types = $("> .types > ol", parent); |
---|
179 | } |
---|
180 | types.append($(this).clone()); |
---|
181 | } |
---|
182 | }); |
---|
183 | $("#values > ol > li").each(function(){ |
---|
184 | var qualName = $(this).attr("name"); |
---|
185 | var owner = qualName.slice(0, qualName.indexOf("#")); |
---|
186 | var name = qualName.slice(qualName.indexOf("#") + 1); |
---|
187 | var parent = parents[owner]; |
---|
188 | if (parent != undefined) { |
---|
189 | var values = $("> .values > ol", parent); |
---|
190 | if (values.length == 0) { |
---|
191 | parent.append("<div class='values members'><h3>Value Members</h3><ol></ol></div>"); |
---|
192 | values = $("> .values > ol", parent); |
---|
193 | } |
---|
194 | values.append($(this).clone()); |
---|
195 | } |
---|
196 | }); |
---|
197 | $("#template > div.parent").each(function(){ |
---|
198 | if ($("> div.members", this).length == 0) { $(this).remove(); }; |
---|
199 | }); |
---|
200 | $("#template > div.parent").each(function(){ |
---|
201 | $(this).hide(); |
---|
202 | }); |
---|
203 | }; |
---|
204 | |
---|
205 | function filter() { |
---|
206 | var query = $("#textfilter input").attr("value").toLowerCase(); |
---|
207 | var queryRegExp = new RegExp(query, "i"); |
---|
208 | var inheritHides = null |
---|
209 | if ($("#order > ol > li.inherit").hasClass("in")) { |
---|
210 | inheritHides = $("#linearization > li:gt(0)"); |
---|
211 | } |
---|
212 | else { |
---|
213 | inheritHides = $("#linearization > li.out"); |
---|
214 | } |
---|
215 | var outOwners = |
---|
216 | inheritHides.map(function(){ |
---|
217 | var r = $(this).attr("name"); |
---|
218 | return r |
---|
219 | }).get(); |
---|
220 | var prtVisbl = $("#visbl > ol > li.all").hasClass("in"); |
---|
221 | $(".members > ol > li").each(function(){ |
---|
222 | var vis1 = $(this).attr("visbl"); |
---|
223 | var qualName1 = $(this).attr("name"); |
---|
224 | //var name1 = qualName1.slice(qualName1.indexOf("#") + 1); |
---|
225 | var showByOwned = true; |
---|
226 | if ($(this).parents(".parent").length == 0) { |
---|
227 | // owner filtering must not happen in "inherited from" member lists |
---|
228 | var ownerIndex = qualName1.indexOf("#"); |
---|
229 | if (ownerIndex < 0) { ownerIndex = qualName1.lastIndexOf("."); } |
---|
230 | var owner1 = qualName1.slice(0, ownerIndex); |
---|
231 | for (out in outOwners) { |
---|
232 | if (outOwners[out] == owner1) { |
---|
233 | showByOwned = false; |
---|
234 | }; |
---|
235 | }; |
---|
236 | }; |
---|
237 | var showByVis = true; |
---|
238 | if (vis1 == "prt") { |
---|
239 | showByVis = prtVisbl; |
---|
240 | }; |
---|
241 | var showByName = true; |
---|
242 | if (query != "") { |
---|
243 | var content = $(this).attr("name") + $("> .fullcomment .cmt", this).text(); |
---|
244 | showByName = queryRegExp.test(content); |
---|
245 | }; |
---|
246 | if (showByOwned && showByVis && showByName) { |
---|
247 | $(this).show(); |
---|
248 | } |
---|
249 | else { |
---|
250 | $(this).hide(); |
---|
251 | }; |
---|
252 | }); |
---|
253 | $(".members").each(function(){ |
---|
254 | $(this).show(); |
---|
255 | if ($(" > ol > li:visible", this).length == 0) { $(this).hide(); } |
---|
256 | }); |
---|
257 | return false |
---|
258 | }; |
---|
259 | |
---|
260 | function windowTitle() |
---|
261 | { |
---|
262 | try { |
---|
263 | parent.document.title=document.title; |
---|
264 | } |
---|
265 | catch(e) { |
---|
266 | // Chrome doesn't allow settings the parent's title when |
---|
267 | // used on the local file system. |
---|
268 | } |
---|
269 | }; |
---|