1 | $(document).ready(function() {
|
2 |
|
3 | vis.createBreadcrumbs($(".container.full").first());
|
4 | vis.initSiteSearch();
|
5 | vis.initKeywords();
|
6 |
|
7 | $("#tipue_search_input").keyup(checkInput)
|
8 | vis.typingTimeout = 0;
|
9 |
|
10 | });
|
11 |
|
12 | function checkInput() {
|
13 | if (document.getElementById("tipue_search_input").value.length > 3) {
|
14 | clearTimeout(vis.typingTimeout);
|
15 | vis.typingTimeout = setTimeout(function () {vis.initSiteSearch(true)},200);
|
16 | }
|
17 | else {
|
18 | var title = document.title.replace(/(\(.+\) )/g,"");
|
19 | document.title = title;
|
20 | document.getElementById("search-results-wrapper").style.display = "none";
|
21 | }
|
22 | }
|
23 |
|
24 |
|
25 | var vis = {};
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | vis.createBreadcrumbs = function(container) {
|
33 |
|
34 |
|
35 | var crumbs = location.pathname.split('/');
|
36 |
|
37 |
|
38 | var stepbackIndex = crumbs.length-1;
|
39 | var breadcrumbs = $.map(crumbs, function(crumb, i) {
|
40 |
|
41 |
|
42 | if(!crumb) return;
|
43 |
|
44 | stepbackIndex--;
|
45 |
|
46 | if(/\.html$/.test(crumb)) {
|
47 |
|
48 |
|
49 | return "<span>" + crumb.replace(/\.html$/, "") + "</span>";
|
50 |
|
51 | } else {
|
52 |
|
53 |
|
54 | for(var ref=crumb+"/", j=0; j<stepbackIndex; j++, ref="../"+ref);
|
55 |
|
56 | return "<a href='" + ref + "'>" + crumb + "</a>";
|
57 | }
|
58 | }).join("") || "Home";
|
59 |
|
60 |
|
61 | $(container).prepend("<div id=\"breadcrumbs\">" + breadcrumbs + "</div>");
|
62 |
|
63 | };
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 | vis.initSiteSearch = function(dynamic) {
|
76 | $("#tipue_search_input").tipuesearch({
|
77 | "mode": "live",
|
78 | "show": 3,
|
79 | },dynamic);
|
80 |
|
81 |
|
82 | var hasSearchMessage = $("#tipue_search_content").children().length > 0;
|
83 | if(hasSearchMessage) {
|
84 |
|
85 | if ($("#search-results-wrapper").css("display") === 'none') {
|
86 | $("#search-results-wrapper").css("display", "block");
|
87 | }
|
88 |
|
89 | var keywords = $("#tipue_search_input").val().replace(/\s/g, ",");
|
90 |
|
91 | $(".tipue_search_content_url a, .tipue_search_content_title a").each(function() {
|
92 | $(this).attr("href", $(this).attr("href") + "?keywords=" + keywords);
|
93 | });
|
94 | } else {
|
95 | $("#search-results-wrapper").css("display", "none");
|
96 | }
|
97 |
|
98 | };
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 | vis.initKeywords = function() {
|
112 |
|
113 |
|
114 | var keywords = url("?keywords");
|
115 |
|
116 | if(keywords) {
|
117 |
|
118 |
|
119 | keywords = keywords.split(",");
|
120 | for(var i = 0; i < keywords.length; i++) {
|
121 | $("body").highlight(keywords[i]);
|
122 | }
|
123 |
|
124 |
|
125 |
|
126 | $("[role=presentation][targetnode=fullOptions]").click();
|
127 | $("tr.toggle:not(collapsible)").click();
|
128 |
|
129 |
|
130 | $("#keyword-info").css("display", "block");
|
131 | $("#keyword-count").text($(".highlight").length);
|
132 | $("#keyword-jumper-button").on('click', function(event) {
|
133 | event.preventDefault();
|
134 |
|
135 |
|
136 | var firstHit = $(".highlight:visible").first();
|
137 | if(firstHit.length) {
|
138 | $("html, body").animate({ scrollTop: $(firstHit).offset().top }, 2000);
|
139 | }
|
140 | });
|
141 |
|
142 | }
|
143 |
|
144 | }; |
\ | No newline at end of file |