// Sliding Panel $(document).ready(function() { $('.navigation-panel-button,.navigation-fade-screen,.navigation-panel-close').on('click touchstart', function(e) { $('.navigation-menu,.navigation-fade-screen').toggleClass('is-visible'); e.preventDefault(); }); }); // Tooltip $(document).ready(function() { // Tooltip only Text $('.masterTooltip').hover(function(){ // Hover over code var title = $(this).attr('title'); $(this).data('tipText', title).removeAttr('title'); $('
') .text(title) .appendTo('body') .fadeIn('slow'); }, function() { // Hover out code $(this).attr('title', $(this).data('tipText')); $('.tooltip').remove(); }).mousemove(function(e) { var mousex = e.pageX + 20; //Get X coordinates var mousey = e.pageY + 10; //Get Y coordinates $('.tooltip') .css({ top: mousey, left: mousex }) }); }); // Highlight $(document).ready(function() { hljs.configure({ languages: ["scala", "bash"] }) hljs.registerLanguage("scala", highlightDotty); hljs.initHighlighting(); }); // Show Blog $(".hide").click(function() { $(this).parent().hide(); // hide only the parent element of this button updatePointer(); }); //Tweet feed in frontpage $('#tweet-feed').tweetMachine('', { backendScript: '/webscripts/ajax/getFromTwitter.php', endpoint: 'statuses/user_timeline', user_name: 'scala_lang', include_retweets: true, exclude_replies: false, limit: 6, pageLimit: 3, autoRefresh: false, animateIn: false, tweetFormat: ` ` }, function(tweets, tweetsDisplayed) { $('.slider-twitter').unslider({}); }); // Scaladex autocomplete search var scaladexUrlBase = 'https://index.scala-lang.org'; function scaladexUrl(item) { return scaladexUrlBase + "/" + item.organization + "/" + item.repository; } $('#scaladex-search').keypress(function(e){ var RETURN = 13; if (e.which == RETURN ) { e.stopImmediatePropagation(); e.preventDefault(); window.open(scaladexUrlBase + "/search?q=" + e.target.value); } }); $('#scaladex-search').autocomplete({ paramName: 'q', serviceUrl: scaladexUrlBase + '/api/autocomplete', dataType: 'json', transformResult: function(response) { return { suggestions: $.map(response, function(dataItem) { return { value: dataItem.organization + " / " + dataItem.repository, data: dataItem }; }) }; }, noCache: true, onSelect: function (suggestion) { window.open(scaladexUrl(suggestion.data), '_blank'); }, formatResult: function(suggestion){ var item = suggestion.data; var url = scaladexUrl(item); var title = item.organization + " / " + item.repository; return '' + '\n' + '' + title + '
' + '\n' + ' ' + '\n' + item.description ' ' + '\n' + ''; } }); // TOC: $(document).ready(function() { if ($("#sidebar-toc").length) { $('#sidebar-toc').toc({exclude: 'h1, h5, h6', context: '.inner-box', autoId: true, numerate: false}); toggleStickyToc(); } }) $(window).resize(function() { toggleStickyToc(); }); var toggleStickyToc = function() { if ($("#sidebar-toc").length) { if ($(window).width() <= 992) { $(".sidebar-toc-wrapper").unstick(); } else { $(".sidebar-toc-wrapper").sticky({ topSpacing: 0, bottomSpacing: 500 }); } } } // Blog search $(document).ready(function() { if ($("#blog-search-bar").length) { SimpleJekyllSearch({ searchInput: document.getElementById('blog-search-bar'), resultsContainer: document.getElementById('result-container'), json: '/resources/json/search.json', searchResultTemplate: '' + training.location + '
' + '' + training.organizer + '
' + '