Skip to content

Commit 8a682b0

Browse files
committed
The new doc styling.
Move the Gem bundling in docker build. Skip the initial copy and link the original folders instead in docker build. Both docker changes should shorten the build a bit.
1 parent 24e226c commit 8a682b0

File tree

85 files changed

+15488
-18301
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+15488
-18301
lines changed

build/.dockerignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
*
2-
!docs-watcher/start.sh
2+
!Gemfile
3+
!docs-watcher/start.sh

build/Dockerfile

+19-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
FROM ruby:2.3.5-alpine3.4
22

3+
RUN mkdir /www
4+
35
COPY docs-watcher/start.sh /
6+
COPY Gemfile /www/
47

58
RUN apk add --update \
69
bash \
@@ -12,11 +15,24 @@ RUN apk add --update \
1215
rsync \
1316
nginx \
1417
nodejs \
15-
&& rm -rf /var/cache/apk/* \
16-
&& npm config set cache /var --global \
18+
&& rm -rf /var/cache/apk/*
19+
20+
RUN npm config set cache /var --global \
1721
&& npm install -g grunt \
1822
&& mkdir /run/nginx \
19-
&& chmod +x /start.sh
23+
&& chmod +x /start.sh \
24+
&& echo "Symlinking folders..." \
25+
&& ln -s /root/docs /www/docs \
26+
&& ln -s /root/NativeScript /www/NativeScript \
27+
&& ln -s /root/nativescript-angular /www/nativescript-angular \
28+
&& ln -s /root/nativescript-sdk-examples-ng /www/nativescript-sdk-examples-ng \
29+
&& ln -s /root/nativescript-sdk-examples-js /www/nativescript-sdk-examples-js \
30+
&& ln -s /root/sidekick-docs /www/sidekick-docs \
31+
&& ln -s /root/nativescript-cli /www/nativescript-cli
32+
33+
RUN cd /www \
34+
&& bundle install \
35+
&& bundle config build.nokogiri --use-system-libraries
2036

2137
ENTRYPOINT [ "/start.sh" ]
2238

build/Gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ gem 'jekyll-assets'
77
gem 'github-markdown'
88
gem 'html-pipeline'
99
gem 'jekyll-unsanitize', '0.4'
10+
gem 'commonmarker'

build/_assets/javascripts/app.js

+136-54
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,22 @@ function preventParentSelection(e) {
5252
}
5353
}
5454

55+
function traverseAnchors(elements, level) {
56+
var html = "<ul>";
57+
58+
elements.each(function(index, anchor) {
59+
if (!anchor.textContent.startsWith("Example")) {
60+
html += '<li><a href="' + anchor.hash + '">' + anchor.textContent + '</a>';
61+
62+
html += traverseAnchors($(anchor.parentElement).nextUntil('h' + level, 'h' + (level + 1)).children("a"), level + 1);
63+
64+
html += "</li>";
65+
}
66+
});
67+
68+
return html + "</ul>";
69+
}
70+
5571
$(function(){
5672

5773
$("pre[lang]").each(function() {
@@ -72,15 +88,19 @@ $(function(){
7288

7389
tabs[0].addClass("k-state-active");
7490

75-
var tabstrip = $("<div>")
91+
var tabstrip = $("<div class='nd-code-container'>")
7692
.insertBefore(this)
7793
.append($("<ul>").append(tabs))
7894
.append(langs);
7995

8096
langs.wrap("<div>");
8197

8298
tabstrip.kendoTabStrip({
83-
animation: false
99+
animation: {
100+
open: {
101+
effects: "fadeIn"
102+
}
103+
}
84104
});
85105
});
86106

@@ -203,22 +223,124 @@ $(function(){
203223

204224
ul.appendTo(this);
205225
});
206-
});
207226

208-
$(function() {
209-
$(document.body)
210-
.on("click", ".hamb", function(e) {
211-
e.preventDefault();
212-
$("#page-nav").toggleClass("expanded");
213-
})
214-
.kendoTouch({
215-
tap: function(e) {
216-
var navigation = $("#page-nav");
217-
if (!$.contains(navigation[0], e.target)) {
218-
navigation.removeClass("expanded");
227+
var options = {
228+
root: null,
229+
rootMargin: "0px",
230+
threshold: 1.0
231+
};
232+
233+
window.addEventListener("scroll", function(e) {
234+
e.target.documentElement.classList[e.target.scrollingElement.scrollTop !== 0 ? "add" : "remove"]("ns-state-scrolled");
235+
}, { passive: true });
236+
237+
var visibleElements = [];
238+
239+
var observer = new IntersectionObserver(function (entries) {
240+
entries.forEach(function(entry) {
241+
if (entry.intersectionRatio < 1) {
242+
visibleElements.splice(visibleElements.indexOf(entry.target), 1);
243+
} else {
244+
visibleElements[entry.intersectionRect.y < entry.rootBounds.height ? "unshift" : "push"](entry.target);
245+
}
246+
});
247+
248+
if (visibleElements[0]) {
249+
var topElement = { offsetTop: 9999999 };
250+
251+
visibleElements.forEach(function (element) {
252+
if (element.offsetTop < topElement.offsetTop) {
253+
topElement = element;
219254
}
255+
});
256+
257+
topElement = $('.right-nav__tree [href$="#' + topElement.id + '"]');
258+
259+
if (topElement[0]) {
260+
$(".right-nav__tree a").removeClass("ns-state-selected");
261+
262+
topElement.addClass("ns-state-selected");
263+
}
264+
}
265+
}, options);
266+
267+
var seeAlso = $("#see-also");
268+
var seeAlsoLinks = seeAlso.next("ul");
269+
270+
seeAlso.remove();
271+
272+
var apiReferences = $("article > p > a[href*=api-reference]");
273+
var rightNavLinks = $(".right-nav__links");
274+
275+
var rightNav = $('\
276+
<div class="right-nav__container">\
277+
<input id="right-nav__toggle" class="right-nav__input" type="checkbox">\
278+
<label for="right-nav__toggle" class="right-nav__label"></label>\
279+
<div class="right-nav__tree"></div>\
280+
<div class="right-nav__sizer"></div>\
281+
</div>')
282+
.insertBefore($("article"))
283+
.children(".right-nav__tree");
284+
285+
var articleAnchors = $(traverseAnchors($("article > h2 > a"), 2));
286+
287+
if (articleAnchors.children()[0]) {
288+
rightNav
289+
.append($("<div class='-allcaps'>In this article</div>"))
290+
.append(articleAnchors);
291+
}
292+
293+
if (seeAlsoLinks[0]) {
294+
rightNav
295+
.append($("<div class='-allcaps'>Related articles</div>"))
296+
.append(seeAlsoLinks);
297+
}
298+
299+
if (apiReferences[0]) {
300+
apiReferences.parent().remove();
301+
302+
rightNav
303+
.append($("<div class='-allcaps'>API Reference</div>"))
304+
.append(apiReferences.wrap("<li></li>").parent().wrapAll("<ul></ul>").parent());
305+
}
306+
307+
if (rightNavLinks[0]) {
308+
rightNav
309+
.append($("<div>Not finding the help you need?</div>"))
310+
.append(rightNavLinks);
311+
}
312+
313+
$(document.documentElement).on("click", function() {
314+
var toggle = $("#right-nav__toggle")[0];
315+
316+
if (toggle) {
317+
toggle.checked = false;
318+
}
319+
});
320+
321+
$(".right-nav__container").on("click", function(e) {
322+
e.stopPropagation();
323+
});
324+
325+
$("article > h2, article > h3").each(function(index, node) {
326+
observer.observe(node);
327+
});
328+
329+
var bodyObserver = new MutationObserver(function(entries) {
330+
entries.forEach(function() {
331+
if (document.body.classList.contains("gsc-overflow-hidden")) {
332+
document.documentElement.classList.add("-overflow-hidden");
333+
} else {
334+
document.documentElement.classList.remove("-overflow-hidden");
220335
}
221336
});
337+
});
338+
339+
bodyObserver.observe(document.body, {
340+
attributes: true,
341+
attributeOldValue: true,
342+
attributeFilter: ["class"]
343+
});
222344
});
223345

224346
$(function() {
@@ -268,43 +390,3 @@ $(function() {
268390
window.setTimeout(handleBanner, 1000);
269391
});
270392

271-
$(function() {
272-
'use strict';
273-
274-
var $searchBtn = $('.Search-open');
275-
var $searchBar = $('.Search-container');
276-
var $searchCancel = $('.Btn--cancel');
277-
var $navLinks = $('.Nav-menu .-fl');
278-
var $navLinksMobileToggle = $('.Nav-open-menu');
279-
280-
// improve menu
281-
$navLinks.find('a').each(function() {
282-
if ($(this).attr('href') === document.location.pathname) {
283-
$(this).addClass('is-current');
284-
}
285-
});
286-
287-
// show search menu
288-
$searchBtn.on('click', function() {
289-
$searchBtn.toggleClass('is-active');
290-
$searchBar.toggle();
291-
$('[name=search]').first().focus();
292-
// hide nav when opening search
293-
$navLinks.removeClass('is-visible');
294-
$navLinksMobileToggle.removeClass('is-active');
295-
});
296-
$searchCancel.on('click', function() {
297-
$searchBar.toggle();
298-
$searchBtn.toggleClass('is-active');
299-
});
300-
301-
// show mobile menu
302-
$navLinksMobileToggle.on('click', function() {
303-
$(this).toggleClass('is-active');
304-
$navLinks.toggleClass('is-visible');
305-
// hide search when opening nav
306-
$searchBar.hide();
307-
$searchBtn.removeClass('is-active');
308-
});
309-
});
310-

build/_assets/javascripts/feedback-form.js

+14-11
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ $(document).ready(function () {
1818
textFeedback: "",
1919
acceptFeedbackContact: false
2020
};
21-
22-
$("#feedback-checkbox-area").click(function (e) {
23-
$("span.k-tooltip-validation").remove();
21+
22+
var checkboxArea = $("#feedback-checkbox-area");
23+
24+
checkboxArea.click(function () {
25+
checkboxArea.find("span.k-tooltip-validation").remove();
26+
checkboxArea.find("textarea").removeClass("k-invalid");
2427
});
2528

2629
var formIsProcessing = false;
@@ -66,7 +69,7 @@ $(document).ready(function () {
6669
};
6770

6871
//Feedback menu controls
69-
var feedbackButtonsContainer = $("#helpful-buttons-container");
72+
var feedbackButtonsContainer = $("#feedback-buttons-container");
7073
var feedbackSubmittedContainer = $("#feedback-submitted-container");
7174
var toggleFeedbackButtons = function (toggle) {
7275
if (toggle) {
@@ -87,8 +90,8 @@ $(document).ready(function () {
8790
//FORM
8891
//Init the form popup window
8992
var win = $("#feedback-form-window").kendoWindow({
90-
title: "Give article feedback",
91-
actions: ["Close"],
93+
title: "Article feedback",
94+
actions: [],
9295
draggable: true,
9396
modal: true,
9497
pinned: false,
@@ -125,7 +128,7 @@ $(document).ready(function () {
125128
//Bind model to form
126129
kendo.bind($("div#feedback-form-window"), formModel);
127130
//Attach to form submit to adjust variables and send request
128-
var emptyFormValidator = $("#feedback-checkbox-area").kendoValidator({
131+
var emptyFormValidator = checkboxArea.kendoValidator({
129132
validateOnBlur: false,
130133
messages: {
131134
// defines a message for the custom validation rule
@@ -294,7 +297,7 @@ $(document).ready(function () {
294297

295298

296299
var windowHeight = $window.height();
297-
var headerHeight = $(".TK-Hat").outerHeight() + $("#page-header").outerHeight();
300+
var headerHeight = $(".TK-Hat").outerHeight() + $(".ns-navigation").outerHeight();
298301
var footerHeight = $("#feedback-section").outerHeight() + $("footer").outerHeight();
299302
var articleHeight = windowHeight - (headerHeight + footerHeight);
300303
var feedbackOffsetTop = document.body.scrollHeight - footerHeight;
@@ -305,7 +308,7 @@ $(document).ready(function () {
305308

306309
function updateVariables() {
307310
windowHeight = $window.height();
308-
headerHeight = $(".TK-Hat").outerHeight() + $("#page-header").outerHeight();
311+
headerHeight = $(".TK-Hat").outerHeight() + $(".ns-navigation").outerHeight();
309312
footerHeight = $("#feedback-section").outerHeight() + $("footer").outerHeight();
310313
articleHeight = windowHeight - (headerHeight + footerHeight);
311314
feedbackOffsetTop = document.body.scrollHeight - footerHeight;
@@ -380,8 +383,8 @@ $(document).ready(function () {
380383
if (!shouldOverlayFeedback || showingFeedbackBar) {
381384
return;
382385
}
383-
384-
if (scrollFold - $("#feedback-section").outerHeight() < feedbackOffsetTop) {
386+
387+
if (scrollFold - $("#feedback-section").outerHeight() * 2 < feedbackOffsetTop) {
385388
Feedback.pinFeedback();
386389
}
387390
else {

0 commit comments

Comments
 (0)