|
1 | 1 | (function() {
|
2 | 2 | function cleanupPath(target) {
|
3 |
| - if (target.indexOf("http") != -1) |
4 |
| - target = target.substr(target.indexOf("/", target.indexOf("//") + 2)); |
5 |
| - if (target.indexOf("#") != -1) |
6 |
| - target = target.substr(0, target.indexOf("#")); |
7 |
| - return target; |
| 3 | + |
8 | 4 | }
|
9 | 5 |
|
10 | 6 | function getEntryFromUrl(path) {
|
11 |
| - path = cleanupPath(path); |
12 |
| - return path.match("^/[^/]+/(.*)$")[1]; |
| 7 | + |
13 | 8 | }
|
14 | 9 |
|
15 | 10 | function scrollToEntry(entry) {
|
16 |
| - $('.method-block').removeClass('active'); |
17 |
| - $('#' + entry).addClass('active'); |
18 |
| - window.setTimeout(function(){ |
19 |
| - $("#content").css('min-height', $("#content").height()); |
20 |
| - $("#content-wrapper").mCustomScrollbar('scrollTo', $('#' + entry), {scrollInertia: 700}); |
21 |
| - $('.panel').on('hide.bs.collapse', function (e) { |
22 |
| - var $methodBlock = $(this).parent().parent(); |
23 |
| - if ($methodBlock.hasClass('selected')) { |
24 |
| - e.preventDefault(); |
25 |
| - $methodBlock.removeClass('selected'); |
26 |
| - } |
27 |
| - }); |
28 |
| - }, 200); |
| 11 | + |
29 | 12 | }
|
30 | 13 |
|
31 | 14 | function scrollTreeToEntry(entry, opt_hash) {
|
32 |
| - var sel = entry + (opt_hash ? ("#" + opt_hash) : ""); |
33 | 15 |
|
34 |
| - var $target = $("#tree li[x-data-name='" + sel + "']"); |
35 |
| - window.setTimeout(function(){ |
36 |
| - $("#tree-wrapper").mCustomScrollbar("scrollTo", $target.offset().top - 120, {scrollInertia: 700}); |
37 |
| - }, 200); |
38 | 16 | }
|
39 | 17 |
|
40 | 18 | function updateBreadcrumb(path) {
|
41 |
| - path = cleanupPath(path); |
42 |
| - $("ol.breadcrumb").html(''); |
43 |
| - var parts = path.split("."); |
44 |
| - for (var i = 0; i < parts.length; i++) { |
45 |
| - var $el; |
46 |
| - if (i < parts.length - 1) { |
47 |
| - var url = parts.slice(0,i+1).join("."); |
48 |
| - $el = $("<li><a href='/" + version + "/"+url+"'>" + parts[i] + "</a></li>"); |
49 |
| - $el.find("a").click(typeLinkClick); |
50 |
| - }else { |
51 |
| - $el = $("<li class='active'>"+parts[i]+"</li>"); |
52 |
| - } |
53 |
| - $("ol.breadcrumb").append($el); |
54 |
| - } |
| 19 | + |
55 | 20 | }
|
56 | 21 |
|
57 | 22 | function loadPage(target, opt_add, opt_scrollTree) {
|
|
122 | 87 | }
|
123 | 88 |
|
124 | 89 | function fixLinks() {
|
125 |
| - $("#content a.type-link").click(typeLinkClickWithTreeScroll); |
126 | 90 | }
|
127 | 91 |
|
128 | 92 | function fixListings() {
|
129 |
| - prettyPrint(); |
| 93 | + |
130 | 94 | }
|
131 | 95 |
|
132 | 96 | function highlightInPage(target, opt_expand, opt_scroll) {
|
133 |
| - var expand = opt_expand == undefined ? true : opt_expand; |
134 |
| - var scroll = opt_scroll == undefined ? true : opt_scroll; |
135 |
| - $(".content-container .active").removeClass("active"); |
136 |
| - if (expand) { |
137 |
| - var entry = getEntryFromUrl(location.pathname); |
138 |
| - doExpandInTree(entry, target); |
139 |
| - } |
140 |
| - if (scroll) { |
141 |
| - setTimeout(function() { |
142 |
| - $("#content-wrapper").mCustomScrollbar("scrollTo", $("#" + target), {scrollInertia: 700}); |
143 |
| - }, 100); |
144 |
| - } |
145 |
| - $("#" + target).parent().addClass("active"); |
146 |
| - location.hash = target; |
| 97 | + |
147 | 98 | }
|
148 | 99 |
|
149 | 100 | function doExpandInTree(entry, opt_hash) {
|
150 |
| - $("#tree .active").removeClass("active"); |
151 |
| - |
152 |
| - var parts = entry.split("."); |
153 | 101 |
|
154 |
| - for (var i = 0; i < parts.length; i++) { |
155 |
| - var path = parts.slice(0, (i+1)).join("."); |
156 |
| - var $el = $("#tree li[x-data-name='" + path + "']"); |
157 |
| - $el.find(">ul").show(); |
158 |
| - $el.find(">a i").removeClass("fa-chevron-right").addClass("fa-chevron-down"); |
159 |
| - $el.addClass("active"); |
160 |
| - } |
161 |
| - |
162 |
| - if (opt_hash) { |
163 |
| - var $el = $("#tree li.item[x-data-name='" + entry + "#" + opt_hash + "']"); |
164 |
| - $el.addClass("active"); |
165 |
| - } |
166 | 102 | }
|
167 | 103 |
|
168 | 104 | function expandInTree(path) {
|
169 |
| - path = cleanupPath(path); |
170 |
| - var entry = path.match("^/[^/]+/(.*)$")[1]; |
171 |
| - if (entry) |
172 |
| - doExpandInTree(entry); |
| 105 | + |
173 | 106 | }
|
174 | 107 |
|
175 |
| - var scrollSettings = (function() { |
176 |
| - var scrollAmount = 80; |
177 |
| - var scrollKeyAmount = 100; |
178 |
| - if (navigator.platform.match(/(Mac|iPhone|iPod|iPad)/i)) { |
179 |
| - scrollAmount = 2; |
180 |
| - scrollKeyAmount = 15; |
181 |
| - } |
182 |
| - return { |
183 |
| - scrollInertia: 0, |
184 |
| - theme: "minimal-dark", |
185 |
| - mouseWheel: { |
186 |
| - enable: true, |
187 |
| - scrollAmount: scrollAmount |
188 |
| - }, |
189 |
| - keyboard: { |
190 |
| - enable: true, |
191 |
| - scrollAmount: scrollKeyAmount, |
192 |
| - scrollType: 'stepless' |
193 |
| - }}; |
194 |
| - })(); |
| 108 | + |
195 | 109 |
|
196 | 110 | function updateContentScrolling() {
|
197 | 111 |
|
|
247 | 161 |
|
248 | 162 | $(function() {
|
249 | 163 |
|
250 |
| - // scrolling |
251 |
| - updateContentScrolling(); |
252 |
| - $("#tree-wrapper").mCustomScrollbar(scrollSettings); |
253 |
| - |
254 |
| - // tree |
255 |
| - $("#tree li.group").each(function() { |
256 |
| - var $ul = $(this).find(">ul"); |
257 |
| - $(this).find(">a").click(function(e) { |
258 |
| - if (e.ctrlKey || e.metaKey) return true; |
259 |
| - $ul.toggle(); |
260 |
| - if ($ul.is(":visible")) |
261 |
| - $(this).find("i").addClass("fa-chevron-down").removeClass("fa-chevron-right"); |
262 |
| - else |
263 |
| - $(this).find("i").addClass("fa-chevron-right").removeClass("fa-chevron-down"); |
264 |
| - return loadPage($(this).attr("href")); |
265 |
| - }); |
266 |
| - }); |
267 |
| - |
268 |
| - $("#tree li.item a").click(function(e) { |
269 |
| - if (e.ctrlKey || e.metaKey) return true; |
270 |
| - return loadPage($(this).attr("href")); |
271 |
| - }); |
272 |
| - |
273 |
| - expandInTree(location.pathname); |
274 |
| - updateBreadcrumb(getEntryFromUrl(location.pathname)); |
275 |
| - scrollTreeToEntry(page, location.hash ? location.hash.substr(1) : null); |
276 |
| - |
277 |
| - // content links |
278 |
| - fixLinks(); |
279 |
| - fixListings(); |
280 |
| - if (location.hash) { |
281 |
| - $("#content-wrapper").mCustomScrollbar("scrollTo", $(location.hash)); |
282 |
| - } |
283 |
| - |
284 |
| - // versions |
285 |
| - $('.versionselect').on('change', function(){ |
286 |
| - location.href = "/" + $(this).find("option:selected").val() + "/try/" + getEntryFromUrl(location.pathname); |
287 |
| - }); |
288 |
| - |
289 |
| - // resize |
290 |
| - $("#size-controller").on("mousedown", function(e) { |
291 |
| - |
292 |
| - var mouseUp = function(e) { |
293 |
| - $("body").off("mouseup", mouseUp); |
294 |
| - $("body").off("mousemove", mouseMove); |
295 |
| - } |
296 |
| - |
297 |
| - var mouseMove = function(e) { |
298 |
| - if (e.pageX > 250 && e.pageX < window.innerWidth - 300) { |
299 |
| - $('#menu-bar').css('width', e.pageX); |
300 |
| - $('#content-wrapper') |
301 |
| - .css('margin-left', e.pageX) |
302 |
| - .css('width', window.innerWidth - e.pageX); |
303 |
| - $('.breadcrumb').css('left', $('#menu-bar').width()); |
304 |
| - } |
305 |
| - return false; |
306 |
| - } |
307 |
| - |
308 |
| - $("body").on("mouseup", mouseUp); |
309 |
| - $("body").on("mousemove", mouseMove); |
310 |
| - |
311 |
| - return false; |
312 |
| - }); |
313 |
| - |
| 164 | + |
314 | 165 | // search
|
315 | 166 |
|
316 | 167 | $.get("/"+version+"/data/search.json", function(data) {
|
|
0 commit comments