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() {
23 * Highlight the spoted element
25 highlightBlock(currentAnchor());
34 $
(document
.createElement("a"))
38 .css("cursor", "pointer")
40 if($
(this).find("a.fold").html() == "+") {
41 $
(this).find("a.fold").html("-");
43 $
(this).find("a.fold").html("+");
45 $
(this).nextAll().toggle();
48 // Insert search field
51 $
(document
.createElement("li"))
53 $
(document
.createElement("form"))
55 $
(document
.createElement("input"))
60 value
: "quick search..."
68 // Select previous result on "Up"
70 // If already on first result, focus search input
71 if(currentIndex
== 0) {
72 $
("#search").val($
(currentTable
.find("tr")[currentIndex]).data("searchDetails").name
);
74 // Else select previous result
75 } else if(currentIndex
> 0) {
76 $
(currentTable
.find("tr")[currentIndex]).removeClass("activeSearchResult");
78 $
(currentTable
.find("tr")[currentIndex]).addClass("activeSearchResult");
79 $
("#search").val($
(currentTable
.find("tr")[currentIndex]).data("searchDetails").name
);
84 // Select next result on "Down"
86 if(currentIndex
< currentTable
.find("tr").length
- 1) {
87 $
(currentTable
.find("tr")[currentIndex]).removeClass("activeSearchResult");
89 $
(currentTable
.find("tr")[currentIndex]).addClass("activeSearchResult");
90 $
("#search").val($
(currentTable
.find("tr")[currentIndex]).data("searchDetails").name
);
94 // Go to url on "Enter"
96 if(currentIndex
> -1) {
97 window
.location
= $
(currentTable
.find("tr")[currentIndex]).data("searchDetails").url
;
100 if($
("#search").val().length
== 0)
103 window
.location
= "full-index.html#q=" + $
("#search").val();
104 if(window
.location
.href
.indexOf("full-index.html") > -1) {
110 // Hide results preview on "Escape"
113 if(currentTable
!= null) {
114 currentTable
.remove();
120 if($
("#search").val().length
== 0) {
124 // Remove previous table
125 if(currentTable
!= null) {
126 currentTable
.remove();
129 // Build results table
131 currentTable
= $
(document
.createElement("table"));
133 // Escape regexp related characters in query
134 var query
= $
("#search").val();
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
, "\\(");
142 query
= query
.replace(/\
)/gi
, "\\)");
143 query
= query
.replace(/&/gi
, "&&");
144 query
= query
.replace(/>/gi
, ">");
145 query
= query
.replace(/</gi
, "<");
148 var regexp
= new RegExp("^" + query
, "i");
149 for(var entry
in entries
) {
153 var result
= entry
.match(regexp
);
155 for(var i
= 0; i
< entries
[entry].length
; i
++) {
160 $
(document
.createElement("tr"))
161 .data("searchDetails", {name
: entry
, url
: entries
[entry][i]["url"]})
162 .data("index", index
)
163 .append($
(document
.createElement("td")).html(entry
))
165 $
(document
.createElement("td"))
166 .addClass("entryInfo")
167 .html(entries
[entry][i]["txt"] + " »"))
168 .mouseover( function() {
169 $
(currentTable
.find("tr")[currentIndex]).removeClass("activeSearchResult");
170 $
(this).addClass("activeSearchResult");
171 currentIndex
= $
(this).data("index");
173 .mouseout( function() {
174 $
(this).removeClass("activeSearchResult");
177 window
.location
= $
(this).data("searchDetails")["url"];
185 // Initialize table properties
186 currentTable
.attr("id", "searchTable");
187 currentTable
.css("position", "absolute");
188 currentTable
.width($
("#search").outerWidth());
189 $
("header").append(currentTable
);
190 currentTable
.offset({left
: $
("#search").offset().left
+ ($
("#search").outerWidth() - currentTable
.outerWidth()), top
: $
("#search").offset().top
+ $
("#search").outerHeight()});
192 // Preselect first entry
193 if(currentTable
.find("tr").length
> 0) {
195 $
(currentTable
.find("tr")[currentIndex]).addClass("activeSearchResult");
196 $
("#search").focus();
201 .focusout(function() {
202 if($
(this).val() == "") {
203 $
(this).addClass("notUsed");
204 $
(this).val("quick search...");
207 .focusin(function() {
208 if($
(this).val() == "quick search...") {
209 $
(this).removeClass("notUsed");
214 .submit( function() {
220 // Close quicksearch list on click
221 $
(document
).click(function(e
) {
222 if(e
.target
!= $
("#search")[0] && e
.target
!= $
("#searchTable")[0]) {
223 if(currentTable
!= null) {
224 currentTable
.remove();
230 // Insert filter field
231 $
("article.filterable h2, nav.filterable h3")
233 $
(document
.createElement("div"))
236 $
(document
.createElement("input"))
243 $
(this).parent().parent().find("ul li:not(:icontains('" + $
(this).val() + "'))").addClass("hide");
244 $
(this).parent().parent().find("ul li:icontains('" + $
(this).val() + "')").removeClass("hide");
246 .focusout(function() {
247 if($
(this).val() == "") {
248 $
(this).addClass("notUsed");
249 $
(this).val("filter...");
252 .focusin(function() {
253 if($
(this).val() == "filter...") {
254 $
(this).removeClass("notUsed");
261 // Filter toggle between H I R in nav porperties list
262 $
("nav.properties.filterable .filter")
264 $
(document
.createElement("a"))
267 title
: "hide inherited properties"
270 if($
(this).hasClass("hidden")) {
271 $
(this).parent().parent().find("li.inherit").show();
273 $
(this).parent().parent().find("li.inherit").hide();
276 $
(this).toggleClass("hidden");
280 $
(document
.createElement("a"))
283 title
: "hide redefined properties"
286 if($
(this).hasClass("hidden")) {
287 $
(this).parent().parent().find("li.redef").show();
289 $
(this).parent().parent().find("li.redef").hide();
292 $
(this).toggleClass("hidden");
296 $
(document
.createElement("a"))
299 title
: "hide introduced properties"
302 if($
(this).hasClass("hidden")) {
303 $
(this).parent().parent().find("li.intro").show();
305 $
(this).parent().parent().find("li.intro").hide();
308 $
(this).toggleClass("hidden");
312 // Filter toggle between I R in
313 $
("article.properties.filterable .filter, article.classes.filterable .filter")
315 $
(document
.createElement("a"))
318 title
: "hide introduced properties"
321 if($
(this).hasClass("hidden")) {
322 $
(this).parent().parent().find("li.intro").show();
324 $
(this).parent().parent().find("li.intro").hide();
327 $
(this).toggleClass("hidden");
331 $
(document
.createElement("a"))
334 title
: "hide redefined properties"
337 if($
(this).hasClass("hidden")) {
338 $
(this).parent().parent().find("li.redef").show();
340 $
(this).parent().parent().find("li.redef").hide();
343 $
(this).toggleClass("hidden");
350 $
("a[href*='#']").click( function() {
351 highlightBlock($
(this).attr("href").split(/#
/)[1]);
354 //Preload filter fields with query string
357 //Copy to clipboard utility on signatures
358 $
(".signature").each(function(){
360 $
("<button class='copyButton' data-clipboard-text='" + $
(this).attr("data-untyped-signature") + "'></button>")
361 .append($
("<img src='./resources/icons/copy.png' />"))
365 var clip
= new ZeroClipboard($
(".copyButton"), {
366 moviePath
: "./ZeroClipboard.swf"
370 /* Parse current URL and return anchor name */
371 function currentAnchor() {
372 var index
= document
.location
.hash
.indexOf("#");
374 return document
.location
.hash
.substring(index
+ 1);
379 /* Prealod filters field using search query */
380 function preloadFilters() {
381 // Parse URL and get query string
382 var search
= currentAnchor();
384 if(search
== null || search
.indexOf("q=") == -1)
387 search
= search
.substring(2, search
.length
);
389 if(search
== "" || search
== "undefined")
392 $
(":text").val(search
);
394 .removeClass("notUsed")
399 /* Hightlight the spoted block */
400 function highlightBlock(a
) {
405 $
(".highlighted").removeClass("highlighted");
407 var target
= $
("#" + a
);
409 if(target
.is("article")) {
410 target
.parent().addClass("highlighted");
413 target
.addClass("highlighted");