Skip to content

Commit eebecbd

Browse files
committed
reference js building
1 parent c5b67e4 commit eebecbd

File tree

4 files changed

+20
-159
lines changed

4 files changed

+20
-159
lines changed

build-js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
closure-compiler --js_output_file resources/public/js/reference.min.js --compilation_level SIMPLE `find ./js-src/ -name '*.js'`

resources/public/css/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ pre.prettyprint ol{
569569
.collapse-group{
570570
margin-top: 10px;
571571
}
572-
.collapse-group a{
572+
.collapse-group > a{
573573
font-size: 14px;
574574
background: #FCFCFC;
575575
border: 1px solid #ddd;

resources/public/js/main.js

Lines changed: 9 additions & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,22 @@
11
(function() {
22
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+
84
}
95

106
function getEntryFromUrl(path) {
11-
path = cleanupPath(path);
12-
return path.match("^/[^/]+/(.*)$")[1];
7+
138
}
149

1510
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+
2912
}
3013

3114
function scrollTreeToEntry(entry, opt_hash) {
32-
var sel = entry + (opt_hash ? ("#" + opt_hash) : "");
3315

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);
3816
}
3917

4018
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+
5520
}
5621

5722
function loadPage(target, opt_add, opt_scrollTree) {
@@ -122,76 +87,25 @@
12287
}
12388

12489
function fixLinks() {
125-
$("#content a.type-link").click(typeLinkClickWithTreeScroll);
12690
}
12791

12892
function fixListings() {
129-
prettyPrint();
93+
13094
}
13195

13296
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+
14798
}
14899

149100
function doExpandInTree(entry, opt_hash) {
150-
$("#tree .active").removeClass("active");
151-
152-
var parts = entry.split(".");
153101

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-
}
166102
}
167103

168104
function expandInTree(path) {
169-
path = cleanupPath(path);
170-
var entry = path.match("^/[^/]+/(.*)$")[1];
171-
if (entry)
172-
doExpandInTree(entry);
105+
173106
}
174107

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+
195109

196110
function updateContentScrolling() {
197111

@@ -247,70 +161,7 @@
247161

248162
$(function() {
249163

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+
314165
// search
315166

316167
$.get("/"+version+"/data/search.json", function(data) {

resources/public/js/reference.min.js

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)