diff options
Diffstat (limited to '_build/themes/ninenines')
-rw-r--r-- | _build/themes/ninenines/layouts/index.html | 2 | ||||
-rw-r--r-- | _build/themes/ninenines/layouts/partials/footer.html | 1 | ||||
-rw-r--r-- | _build/themes/ninenines/static/js/custom.js | 99 |
3 files changed, 56 insertions, 46 deletions
diff --git a/_build/themes/ninenines/layouts/index.html b/_build/themes/ninenines/layouts/index.html index 22ec32a7..49eff047 100644 --- a/_build/themes/ninenines/layouts/index.html +++ b/_build/themes/ninenines/layouts/index.html @@ -9,7 +9,7 @@ {{ $.Scratch.Set "projects" 0 }} {{ range $.Site.Data.projects }} <li{{ if eq .name $.Site.Params.main_project }} class="active"{{ end }}> - <a data-slide="{{ $.Scratch.Get "projects" }}" href="{{ .permalink }}">{{ .title }}</a> + <a data-panel="{{ $.Scratch.Get "projects" }}" href="{{ .permalink }}">{{ .title }}</a> {{ $.Scratch.Add "projects" 1 }} </li> {{ end }} diff --git a/_build/themes/ninenines/layouts/partials/footer.html b/_build/themes/ninenines/layouts/partials/footer.html index 0b199856..4f0f6dee 100644 --- a/_build/themes/ninenines/layouts/partials/footer.html +++ b/_build/themes/ninenines/layouts/partials/footer.html @@ -19,7 +19,6 @@ <!-- Javascript --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> - <script src="/js/bootstrap-carousel.js"></script> <script src="/js/bootstrap-dropdown.js"></script> <script src="/js/custom.js"></script> </body> diff --git a/_build/themes/ninenines/static/js/custom.js b/_build/themes/ninenines/static/js/custom.js index 84936d37..7e674540 100644 --- a/_build/themes/ninenines/static/js/custom.js +++ b/_build/themes/ninenines/static/js/custom.js @@ -1,49 +1,60 @@ -var carousel = ""; -$(document).ready(function() {; - // Starting up carousel - carousel = $('.carousel').carousel({ - interval: 9999999999999 - }) - - // Rollover images - $(function() { - $('img[data-hover]').hover(function() { - $(this).attr('tmp', $(this).attr('src')).attr('src', $(this).attr('data-hover')).attr('data-hover', $(this).attr('tmp')).removeAttr('tmp'); - }).each(function() { - $('<img />').attr('src', $(this).attr('data-hover')); - });; - }); - - // Slide selector - $(".navbar .nav li a").click(function() { - function clear_prods() { - $(".navbar .nav li").each(function(){ - $(this).removeClass("active"); - }); - } - carousel.unbind('slide'); - clear_prods(); - $(this).parent().addClass("active"); - carousel.carousel($(this).data()["slide"]); - carousel.carousel('stop'); - carousel.bind('slide', function() { - clear_prods(); - carousel.unbind('slide'); - }); - }); - - if ($("#docs h2").length == 0){ - $("#docs-nav").remove(); - }else{ - $("<ul/>").insertAfter("#docs-nav"); - $("#docs h2").each(function(){ - $("<li><a href=\"#" + $(this).attr("id") + "\">" + $(this).text() + "</a></li>").appendTo("#docs-nav+ul"); +var projects_nav = function() { + var nav = document.querySelectorAll('.navbar .nav li a'); + var panels = document.querySelectorAll('.carousel-inner>div'); + + Array.prototype.forEach.call(nav, function(el) { + el.addEventListener('click', function(ev) { + ev.preventDefault(); + + Array.prototype.forEach.call(nav, function(el) { + el.parentNode.classList.remove('active'); + }); + + Array.prototype.forEach.call(panels, function(el) { + el.classList.remove('active'); + }); + + this.parentNode.classList.add('active'); + document.querySelector('.carousel-inner>div:nth-child(' + + (1 + parseInt(this.dataset.panel, 10)) + ')') + .classList.add('active'); }); - if ($("#_rest_callbacks").length != 0){ - $('<ul id="_rest_callbacks_nav"/>').insertAfter('#docs-nav+ul a[href="#_rest_callbacks"]'); - $('#_rest_callbacks+div h3').each(function(){ - $("<li><a href=\"#" + $(this).attr("id") + "\">" + $(this).text() + "</a></li>").appendTo('#docs-nav+ul a[href="#_rest_callbacks"]+ul'); + }); +}; + +var docs_nav = function() { + var nav = document.querySelector('#docs-nav'); + if (nav === null) { + return; + } + + var docs = document.querySelectorAll('#docs h2'); + if (docs.length == 0) { + nav.parentNode.removeChild(el); + } else { + var navul = document.createElement('ul'); + Array.prototype.forEach.call(docs, function(el) { + navul.insertAdjacentHTML('beforeend', + '<li><a href="#' + el.getAttribute('id') + '">' + + el.textContent + '</a></li>'); + }); + nav.insertAdjacentElement('afterend', navul); + + if (document.querySelector('#_rest_callbacks') !== null) { + var restul = document.createElement('ul'); + var resth3s = document.querySelectorAll('#_rest_callbacks+div h3'); + Array.prototype.forEach.call(resth3s, function(el) { + restul.insertAdjacentHTML('beforeend', + '<li><a href="#' + el.getAttribute('id') + '">' + + el.textContent + '</a></li>'); }); + document.querySelector('#docs-nav+ul a[href="#_rest_callbacks"]') + .insertAdjacentElement('afterend', restul); } } +}; + +document.addEventListener('DOMContentLoaded', function() { + projects_nav(); + docs_nav(); }); |