5643e33352e423d2c831762e541b8486b9262256
2 * JQuery Case Insensitive :icontains selector
4 $
.expr
[':'].icontains
= function(obj
, index
, meta
, stack
){
5 return (obj
.textContent
.replace(/\
[[0-9]+\
]/g
, "") || obj
.innerText
.replace(/\
[[0-9]+\
]/g
, "") ||
jQuery(obj
).text().replace(/\
[[0-9]+\
]/g
, "") ||
'').toLowerCase().indexOf(meta
[3].toLowerCase()) >= 0;
8 * Quick Search global vars
11 // Current search results preview table
12 var currentTable
= null;
14 //Hightlighted index in search result preview table
15 var currentIndex
= -1;
18 * Add folding and filtering facilities to class description page.
20 $
(document
).ready(function() {
29 $
(document
.createElement("a"))
33 .css("cursor", "pointer")
35 if($
(this).find("a.fold").html() == "+") {
36 $
(this).find("a.fold").html("-");
38 $
(this).find("a.fold").html("+");
40 $
(this).nextAll().toggle();
43 // Insert search field
46 $
(document
.createElement("li"))
48 $
(document
.createElement("form"))
50 $
(document
.createElement("input"))
55 value
: "quick search..."
62 // Select previous result on "Up"
64 // If already on first result, focus search input
65 if(currentIndex
== 0) {
66 $
("#search").val($
(currentTable
.find("tr")[currentIndex]).data("searchDetails").name
);
68 // Else select previous result
69 } else if(currentIndex
> 0) {
70 $
(currentTable
.find("tr")[currentIndex]).removeClass("activeSearchResult");
72 $
(currentTable
.find("tr")[currentIndex]).addClass("activeSearchResult");
73 $
("#search").val($
(currentTable
.find("tr")[currentIndex]).data("searchDetails").name
);
78 // Select next result on "Down"
80 if(currentIndex
< currentTable
.find("tr").length
- 1) {
81 if($
(currentTable
.find("tr")[currentIndex
+ 1]).hasClass("overflow")) {
84 $
(currentTable
.find("tr")[currentIndex]).removeClass("activeSearchResult");
86 $
(currentTable
.find("tr")[currentIndex]).addClass("activeSearchResult");
87 $
("#search").val($
(currentTable
.find("tr")[currentIndex]).data("searchDetails").name
);
91 // Go to url on "Enter"
93 if(currentIndex
> -1) {
94 window
.location
= $
(currentTable
.find("tr")[currentIndex]).data("searchDetails").url
;
97 if($
("#search").val().length
== 0)
100 window
.location
= "search.html#q=" + $
("#search").val();
101 if(window
.location
.href
.indexOf("search.html") > -1) {
107 // Hide results preview on "Escape"
110 if(currentTable
!= null) {
111 currentTable
.remove();
117 if($
("#search").val().length
== 0) {
121 // Remove previous table
122 if(currentTable
!= null) {
123 currentTable
.remove();
126 // Build results table
128 currentTable
= $
(document
.createElement("table"));
130 // Escape regexp related characters in query
131 var origQuery
= $
("#search").val();
132 var query
= origQuery
;
133 query
= query
.replace(/\\/gi
, "\\\\");
134 query
= query
.replace(/\
[/gi
, "\\[");
135 query
= query
.replace(/\|
/gi
, "\\|");
136 query
= query
.replace(/\*/gi
, "\\*");
137 query
= query
.replace(/\
+/gi
, "\\+");
138 query
= query
.replace(/\?/gi
, "\\?");
139 query
= query
.replace(/\
(/gi
, "\\(");
140 query
= query
.replace(/\
)/gi
, "\\)");
141 query
= query
.replace(/&/gi
, "&&");
144 var regexp
= new RegExp("^" + query
);
146 for(var entry
in entries
) {
147 var result
= entry
.match(regexp
);
149 for(var i
= 0; i
< entries
[entry].length
; i
++) {
155 $
(document
.createElement("tr"))
156 .data("searchDetails", {name
: entry
, url
: entries
[entry][i]["url"]})
157 .data("index", index
)
158 .append($
(document
.createElement("td")).html(entry
))
160 $
(document
.createElement("td"))
161 .addClass("entryInfo")
162 .html(entries
[entry][i]["txt"] + " »"))
163 .mouseover( function() {
164 $
(currentTable
.find("tr")[currentIndex]).removeClass("activeSearchResult");
165 $
(this).addClass("activeSearchResult");
166 currentIndex
= $
(this).data("index");
168 .mouseout( function() {
169 $
(this).removeClass("activeSearchResult");
172 window
.location
= $
(this).data("searchDetails")["url"];
181 $
("<tr class='overflow'>")
183 $
("<td colspan='2'>")
185 $
("<a href='#' title='Show all results' data-query='"+ origQuery
+"'>" + overflow
+ " more results for '" + origQuery
+ "'</a>")
187 window
.location
= "search.html#q=" + $
(this).attr("data-query");
188 if(window
.location
.href
.indexOf("search.html") > -1) {
197 // Initialize table properties
198 currentTable
.attr("id", "searchTable");
199 currentTable
.css("position", "absolute");
200 currentTable
.width($
("#search").outerWidth());
201 $
("header").append(currentTable
);
202 currentTable
.offset({left
: $
("#search").offset().left
+ ($
("#search").outerWidth() - currentTable
.outerWidth()), top
: $
("#search").offset().top
+ $
("#search").outerHeight()});
204 // Preselect first entry
205 if(currentTable
.find("tr").length
> 0) {
207 $
(currentTable
.find("tr")[currentIndex]).addClass("activeSearchResult");
208 $
("#search").focus();
213 .focusout(function() {
214 if($
(this).val() == "") {
215 $
(this).addClass("notUsed");
216 $
(this).val("quick search...");
219 .focusin(function() {
220 if($
(this).val() == "quick search...") {
221 $
(this).removeClass("notUsed");
226 .submit( function() {
232 // Close quicksearch list on click
233 $
(document
).click(function(e
) {
234 if(e
.target
!= $
("#search")[0] && e
.target
!= $
("#searchTable")[0]) {
235 if(currentTable
!= null) {
236 currentTable
.remove();
242 // Insert filter field
243 $
("article.filterable h2, nav.filterable h3")
245 $
(document
.createElement("div"))
248 $
(document
.createElement("input"))
255 $
(this).parent().parent().find("ul li:not(:icontains('" + $
(this).val() + "'))").addClass("hide");
256 $
(this).parent().parent().find("ul li:icontains('" + $
(this).val() + "')").removeClass("hide");
258 .focusout(function() {
259 if($
(this).val() == "") {
260 $
(this).addClass("notUsed");
261 $
(this).val("filter...");
264 .focusin(function() {
265 if($
(this).val() == "filter...") {
266 $
(this).removeClass("notUsed");
273 // Filter toggle between H I R in nav porperties list
274 $
("nav.properties.filterable .filter")
276 $
(document
.createElement("a"))
279 title
: "hide inherited properties"
282 if($
(this).hasClass("hidden")) {
283 $
(this).parent().parent().find("li.inherit").show();
285 $
(this).parent().parent().find("li.inherit").hide();
288 $
(this).toggleClass("hidden");
292 $
(document
.createElement("a"))
295 title
: "hide redefined properties"
298 if($
(this).hasClass("hidden")) {
299 $
(this).parent().parent().find("li.redef").show();
301 $
(this).parent().parent().find("li.redef").hide();
304 $
(this).toggleClass("hidden");
308 $
(document
.createElement("a"))
311 title
: "hide introduced properties"
314 if($
(this).hasClass("hidden")) {
315 $
(this).parent().parent().find("li.intro").show();
317 $
(this).parent().parent().find("li.intro").hide();
320 $
(this).toggleClass("hidden");
324 // Filter toggle between I R in
325 $
("article.properties.filterable .filter, article.classes.filterable .filter")
327 $
(document
.createElement("a"))
330 title
: "hide introduced properties"
333 if($
(this).hasClass("hidden")) {
334 $
(this).parent().parent().find("li.intro").show();
336 $
(this).parent().parent().find("li.intro").hide();
339 $
(this).toggleClass("hidden");
343 $
(document
.createElement("a"))
346 title
: "hide redefined properties"
349 if($
(this).hasClass("hidden")) {
350 $
(this).parent().parent().find("li.redef").show();
352 $
(this).parent().parent().find("li.redef").hide();
355 $
(this).toggleClass("hidden");
359 //Preload filter fields with query string
362 //Copy to clipboard utility on signatures
363 $
(".signature").each(function(){
365 $
("<button class='copyButton' data-clipboard-text='" + $
(this).attr("data-untyped-signature") + "'></button>")
366 .append($
("<img src='./resources/icons/copy.png' />"))
370 var clip
= new ZeroClipboard($
(".copyButton"), {
371 moviePath
: "./ZeroClipboard.swf"
375 /* Parse current URL and return anchor name */
376 function currentAnchor() {
377 var index
= document
.location
.hash
.indexOf("#");
379 return document
.location
.hash
.substring(index
+ 1);
384 /* Prealod filters field using search query */
385 function preloadFilters() {
386 // Parse URL and get query string
387 var search
= currentAnchor();
389 if(search
== null || search
.indexOf("q=") == -1)
392 search
= search
.substring(2, search
.length
);
394 if(search
== "" || search
== "undefined")
397 $
(":text").val(search
);
399 .removeClass("notUsed")