var settings = { contentListHighlight: true, //Highlights current page in the contentlist. define a ".active" css class to fire it up (it might need "!important") contentListCollapse: true, //Hides the content list on the left. add "@import url("hidecontent.css");" to the beginning of style.css (and of course add the file as well) contentList_onCover: true, //if this is set true, the contentlist will always be opened on the cover page smoothScroll: true, //changes the scrolling into a CSS transition which makes the user experience much smoother, it also removes the scroll bar smoothScrollDuration: 500, localiseLogos: false //Automatically swaps logos depending on the manual language. logo filname needs to be "logo_lang.png" (exampl.: "logo_it.png") if no file is found, it uses default (logo.png) } //------------------------------------------------------------ //------------------------------------------------------------ //------------- Webmanual extra Features by Kris ------------- //------------------------------------------------------------ //------------------------------------------------------------ var ids = []; var currentMousePos = { x: 100, y: 100 }; $(function() { $(window).mousemove(function(event) { currentMousePos.x = event.pageX; currentMousePos.y = event.pageY; }); }) //returns true or false $.fn.is_on_screen = function(){ var win = $(window); var viewport = { top : win.scrollTop(), left : win.scrollLeft() }; viewport.right = viewport.left + win.width(); viewport.bottom = viewport.top + win.height(); var bounds = this.offset(); bounds.right = bounds.left + this.outerWidth(); bounds.bottom = bounds.top + this.outerHeight(); return (!(viewport.right < bounds.left || viewport.left > bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom -40)); }; //create array called "ids" with spread IDs function createIdsArray() { ids = []; $("body>*").each(function() { var n = $(this); if (n.attr("id") == undefined) { } else if (n.attr("id") == "cover") { } else if (n.attr("id") == "generation_errors") { } else { ids.push ($(this).attr("id")) }; }); } $(function() { createIdsArray(); }) //------------------------------------------------------------ //------- Highlight current spread in the Contentlist -------- //------------------------------------------------------------ function contentListHighlight() { $.each(ids, function (index, spreadX) { var i = "#" + spreadX; var c = "." + spreadX; if ($(i + " " + ".smoothScroll").is_on_screen()) { $(c).addClass('active'); $(i).addClass('activeSpread'); } else { $(c).removeClass('active'); $(i).removeClass('activeSpread'); }; // Keep parent title highlighted when subitem is active if ($(i + " " + ".smoothScroll").is_on_screen()) { if ($(c).hasClass('subitem')) { $(c).parents("li").find(".item").addClass('active'); }; } else { $(c).removeClass('active'); }; }); } if (settings.contentListHighlight && !settings.smoothScroll) { $(window).scroll(function() { contentListHighlight(); }); } //------------------------------------------------------------ //----------------- ContentList Collapse --------------------- //------------------------------------------------------------ if (settings.contentListCollapse) { var trigger = 60; //number of pixels left of the window function hideContent() { if(!$('#manual h2').hasClass('contentHeader_hidden')) { $('#manual h2').addClass('contentHeader_hidden'); $('#contentscolumns div').addClass('contentList_hidden'); $('.pageboundary').css('left', '60px'); if (!$('header h1, #external').hasClass('hideheader')) { setTimeout(function() { if (currentMousePos.y - $(window).scrollTop() > 100) { $('header h1, #external').addClass('hideheader'); } }, 1000); }; trigger = 60; } } function showContent() { if($('#manual h2').hasClass('contentHeader_hidden')) { $('#manual h2').removeClass('contentHeader_hidden'); $('#contentscolumns div').removeClass('contentList_hidden'); $('.pageboundary').css('left', '300px'); $('header h1, #external').removeClass('hideheader'); trigger = 350; } } function showHeaderOnly() { $('header h1, #external').removeClass('hideheader'); } function contentListHandler() { var cover = $('#cover a'); if (!cover.is_on_screen()) { if (currentMousePos.x < trigger) { return true; } } else { if (settings.contentList_onCover) { return true; } else { if (currentMousePos.x < trigger) { return true; } else { return false; } } } } jQuery(function($) { $(window).mousemove(function(event) { if (contentListHandler()) { showContent(); } else { hideContent(); } if (currentMousePos.y - $(document).scrollTop() < 50) { showHeaderOnly(); } }); $(window).scroll(function() { if (contentListHandler()){ showContent(); } else { hideContent(); } }); if (contentListHandler()){ showContent(); } else { hideContent(); } }); } //------------------------------------------------------------ //--------------------- Smoothscroll ------------------------- //------------------------------------------------------------ if (settings.smoothScroll) { $(function() { var currentTopPos = $('#cover').offset().top; var spreadOnScreen = "cover"; var prevSpread; var nextSpread; var enableScroll = true; //Disable default scroll functionality (the one in manuals.js) $(document).off('click', 'a.smoothScroll'); //and replacing it with the new one $('a.smoothScroll').on('click', function(event) { event.preventDefault(); href = $(this).attr('href'); window.history.pushState(null, null, href); moveTo(href); }); //if user uses adblock, deleete the div, and create new arrays with spread IDs function isAdblock() { if ($('#adverts').height() < 150) { $('#adverts').remove(); setPositionVars(); createIdsArray(); return true; } else { return false; } } isAdblock(); $('.spread').css({ webkitTransitionProperty: 'all', webkitTransitionDuration: settings.smoothScrollDuration + 'ms', webkitTransitionTimingFunction: 'ease-in-out', msTransitionProperty: 'all', msTransitionDuration: settings.smoothScrollDuration + 'ms', msTransitionTimingFunction: 'ease-in-out', MozTransitionProperty: 'all', MozTransitionDuration: settings.smoothScrollDuration + 'ms', MozTransitionTimingFunction: 'ease-in-out', TransitionProperty: 'all', TransitionDuration: settings.smoothScrollDuration + 'ms', TransitionTimingFunction: 'ease-in-out' }); $('body').css('overflow', 'hidden'); // Go to specific # url if ((location.hash !== "#cover")) { $(window).scrollTop(0); hash = location.hash; location.hash = "#cover"; $(window).load(function() { enableScroll = true; moveTo(hash); window.history.pushState(null, null, hash); }); }; // MoveTo on hashchange $(window).on('hashchange', function(event) { event.preventDefault(); moveTo(location.hash); }); function setPositionVars() { $.each($('.spread'), function(val) { spread = $(this).attr('id'); if ($('#' + spread + " .smoothScroll").is_on_screen()) { spreadOnScreen = spread; }; }); prevSpread = $("#" + spreadOnScreen).prev("div").attr('id'); nextSpread = $("#" + spreadOnScreen).next("div").attr('id'); } function moveUP() { if (prevSpread != undefined) { moveTo("#" + prevSpread); } }; function movedown() { if (nextSpread != undefined) { moveTo("#" + nextSpread); } }; function moveTo(href) { if (enableScroll) { $(window).scrollTop(0); targetTopPos = currentTopPos - $(href).offset().top; $('.spread').css({ WebkitTransform: 'translate(0px, ' + targetTopPos + 'px)', msTransform: 'translate(0px, ' + targetTopPos + 'px)', transform: 'translate(0px, ' + targetTopPos + 'px)', mozTransform: 'translate(0px, ' + targetTopPos + 'px)' }); if ("#" + spreadOnScreen !== href) { enableScroll = false; } } }; //Do this when scrolling animation is done $('#cover').bind('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(event) { if (contentListHandler()){ showContent(); } else { hideContent(); } currentTopPos = $('#cover').offset().top; setPositionVars(); if (settings.contentListHighlight) { contentListHighlight(); } enableScroll = true; if (location.hash !== "#" + spreadOnScreen) { window.history.pushState(null, null, "#" + spreadOnScreen); } }); //bind keyboard arrows and space/backspace for navigation $(document).keydown(function(e) { switch(e.which) { case 32: movedown(); break; case 38: moveUP(); break; case 8: moveUP(); break; case 40: movedown(); break; default: return; } e.preventDefault(); }); //bind mousewheel navigation $(document).bind('mousewheel DOMMouseScroll MozMousePixelScroll', function(event) { event.preventDefault(); var delta = event.originalEvent.wheelDelta || -event.originalEvent.detail; if (delta < -45) { movedown(); } else if (delta > 45) { moveUP(); } // console.log(delta); }); setPositionVars(); }); } //------------------------------------------------------------ //--------------- Autoswap localised logos ------------------- //------------------------------------------------------------ if (settings.localiseLogos) { $(function() { $('#cover h2 img').css('opacity', '0'); var lang = $("html").attr('lang'); var img = $("#cover h2 img:first-child"); img.attr('src', 'logo_' + lang + '.png'); img.error(function() { img.attr('src', 'logo.png'); }); img.load(function() { $(this).css('opacity', '100'); }); }); }