aboutsummaryrefslogtreecommitdiffstats
path: root/view/js
diff options
context:
space:
mode:
authorAndrew Manning <andrewmanning@grid.reticu.li>2017-08-23 03:33:03 +0000
committerAndrew Manning <andrewmanning@grid.reticu.li>2017-08-23 03:33:03 +0000
commit6c388575022cc10f28ed99e8e414fbc76a67bb00 (patch)
tree49bc3d01e54023855ae95a124efda3d822ab576a /view/js
parent9d5b6858ea627b5eb6115cacd870ef0277f87b2a (diff)
downloadvolse-hubzilla-6c388575022cc10f28ed99e8e414fbc76a67bb00.tar.gz
volse-hubzilla-6c388575022cc10f28ed99e8e414fbc76a67bb00.tar.bz2
volse-hubzilla-6c388575022cc10f28ed99e8e414fbc76a67bb00.zip
Repaired and extended support for help page translations including table of contents files at the top level. Moved help module javascript to mod_help.js.
Diffstat (limited to 'view/js')
-rw-r--r--view/js/mod_help.js74
1 files changed, 74 insertions, 0 deletions
diff --git a/view/js/mod_help.js b/view/js/mod_help.js
new file mode 100644
index 000000000..0f85af462
--- /dev/null
+++ b/view/js/mod_help.js
@@ -0,0 +1,74 @@
+function docoTocToggle() {
+ if ($('#doco-top-toc').is(':visible')) {
+ $('#doco-toc-toggle').removeClass('fa-cog').addClass('fa-caret-right');
+ } else {
+ $('#doco-toc-toggle').removeClass('fa-caret-right').addClass('fa-caret-down');
+ }
+ $('#doco-top-toc').toggle();
+
+ return false;
+}
+
+toc = {};
+// Generate the table of contents in the side nav menu (see view/tpl/help.tpl)
+$(document).ready(function () {
+ // Generate the table of contents in the side nav menu (see view/tpl/help.tpl)
+ $('#doco-top-toc').toc({content: "#doco-content", headings: "h3,h4,h5,h6"});
+
+ $(".doco-section").find('a').each(function () {
+ var url = document.createElement('a');
+ url.href = window.location;
+ var pageName = url.href.split('/').pop().split('#').shift().split('?').shift();
+ var linkName = $(this).attr('href').split('/').pop();
+ if (pageName === linkName) {
+ var tocUl = $(this).closest('a').append('<ul>').find('ul');
+ tocUl.removeClass(); // Classes are automatically added to <ul> elements by something else
+ tocUl.toc({content: "#doco-content", headings: "h3"});
+ tocUl.addClass('toc-content');
+ tocUl.addClass('list-unstyled');
+ tocUl.attr('id', 'doco-side-toc');
+
+ }
+ });
+
+ $(document.body).trigger("sticky_kit:recalc");
+
+ toc.contentTop = [];
+ toc.edgeMargin = 20; // margin above the top or margin from the end of the page
+ toc.topRange = 200; // measure from the top of the viewport to X pixels down
+ // Set up content an array of locations
+ $('#doco-side-toc').find('a').each(function () {
+ toc.contentTop.push($('#' + $(this).attr('href').split('#').pop()).offset().top);
+ });
+
+
+ // adjust side menu
+ $(window).scroll(function () {
+ var winTop = $(window).scrollTop(),
+ bodyHt = $(document).height(),
+ vpHt = $(window).height() + toc.edgeMargin; // viewport height + margin
+ $.each(toc.contentTop, function (i, loc) {
+ if ((loc > winTop - toc.edgeMargin && (loc < winTop + toc.topRange || (winTop + vpHt) >= bodyHt))) {
+ $('#doco-side-toc li')
+ .removeClass('selected-doco-nav')
+ .eq(i).addClass('selected-doco-nav');
+ if (typeof ($('#doco-side-toc li').eq(i).find('a').attr('href').split('#')[1]) !== 'undefined') {
+ window.history.pushState({}, '', location.href.split('#')[0] + '#' + $('#doco-side-toc li').eq(i).find('a').attr('href').split('#')[1]);
+ }
+ }
+ });
+ });
+
+ // When the page loads, it does not scroll to the section specified in the URL because it
+ // has not been constructed yet by the script. This will reload the URL
+ if (typeof (location.href.split('#')[1]) !== 'undefined') {
+ var p = document.createElement('a');
+ p.href = location.href;
+ var portstr = '';
+ if (p.port !== '') {
+ portstr = ':' + p.port;
+ }
+ var newref = p.protocol + '//' + p.hostname + portstr + p.pathname + p.hash.split('?').shift();
+ location.replace(newref)
+ }
+});