Skip to content

Commit 55dfbc9

Browse files
authored
fixes site js (Codeception#307)
1 parent e1c8d14 commit 55dfbc9

File tree

4 files changed

+91
-61
lines changed

4 files changed

+91
-61
lines changed

_layouts/bootstrap.html

+91-2
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,92 @@ <h4>they support us_</h4>
302302
{% include js.html %}
303303

304304
<!-- SCRIPTS -->
305+
<script>
306+
$(document).ready(function () {
307+
function randomCarousel(id) {
308+
var num = $(id + ' .item').length;
309+
var slide = Math.floor((Math.random() * num));
310+
$(id + ' .item').each(function (index) {
311+
if (index == slide) {
312+
$(this).addClass('active');
313+
} else {
314+
$(this).removeClass('active');
315+
}
316+
});
317+
}
318+
319+
randomCarousel('#carousel-tweets');
320+
randomCarousel('#carousel-companies');
321+
});
322+
</script>
323+
324+
<script>
325+
$(document).ready(function () {
326+
var toc = $('#toc');
327+
if(toc.length) {
328+
toc.toc({
329+
'selectors': 'h2',
330+
'prefix': 'toc',
331+
'container': '#page',
332+
'anchorName': function (i, heading, prefix) { //custom function for anchor name
333+
return $(heading).text().replace(/\s/g, '-').replace(/[^\w-]/g, '');
334+
},
335+
});
336+
}
337+
});
338+
</script>
339+
340+
<script>
341+
$(document).ready(function () {
342+
var cpContainer = $(".cp:contains('<?php')");
343+
var cpContains = $(".cp:contains('?>')");
344+
var page = $('#page table');
345+
var tocNext = $('#toc');
346+
var tocNextUl = $('#toc > ul');
347+
var tocNextUlLi = $('#toc ul.list li a');
348+
349+
if(cpContainer.length) {
350+
cpContainer.css({ visibility : 'hidden' });
351+
}
352+
353+
if(cpContains.length) {
354+
cpContains.css({ visibility : 'hidden' });
355+
}
356+
357+
if(page.length) {
358+
page.addClass('table table-striped table-bordered');
359+
}
360+
361+
if(tocNext.length) {
362+
tocNext.toc({
363+
'selectors': 'h2,h3,h4',
364+
'prefix': 'toc',
365+
'container': '#page',
366+
//custom function for anchor name
367+
'anchorName': function(i, heading, prefix) {
368+
return $(heading).text().replace(/\s/g, '-').replace(/[^\w-]/g, '');
369+
},
370+
});
371+
}
372+
373+
// List.js
374+
if(tocNextUl.length) {
375+
tocNextUl.addClass('list');
376+
}
377+
378+
if(tocNextUlLi.length) {
379+
tocNextUlLi.addClass('searchitem');
380+
}
381+
382+
var options = {
383+
valueNames: [ 'searchitem' ]
384+
};
385+
var userList = new List('searchable', options);
386+
// end List.js
387+
388+
}); // docrdy
389+
</script>
390+
305391
<script>
306392
var _gaq = _gaq || [];
307393
_gaq.push(['_setAccount', 'UA-1899308-9']);
@@ -320,9 +406,12 @@ <h4>they support us_</h4>
320406
<script>
321407
// Adding this layout functionality for mobile views with the homepage hero
322408
$(document).ready(function(){
323-
$('.navbar-toggle').click(function(){
324-
$('.row.home').toggleClass('no-padding-top');
409+
var navbarToggle = $('.navbar-toggle')
410+
if(navbarToggle.length) {
411+
navbarToggle.click(function(){
412+
$('.row.home').toggleClass('no-padding-top');
325413
});
414+
}
326415
});
327416
</script>
328417

_layouts/doc.html

-28
Original file line numberDiff line numberDiff line change
@@ -70,34 +70,6 @@ <h1 class="page-title">Search</h1>
7070
<!-- toc.js generated nav... -->
7171
<div id="toc" class="nav"></div>
7272

73-
<script>
74-
$(document).ready(function () {
75-
$(".cp:contains('<?php')").css({ visibility : 'hidden' });
76-
$(".cp:contains('?>')").css({ visibility : 'hidden' });
77-
$('#page table').addClass('table table-striped table-bordered');
78-
$('#toc').toc({
79-
'selectors': 'h2,h3,h4',
80-
'prefix': 'toc',
81-
'container': '#page',
82-
//custom function for anchor name
83-
'anchorName': function(i, heading, prefix) {
84-
return $(heading).text().replace(/\s/g, '-').replace(/[^\w-]/g, '');
85-
},
86-
});
87-
// List.js
88-
$('#toc > ul').addClass('list');
89-
$('#toc ul.list li a').addClass('searchitem');
90-
var options = {
91-
valueNames: [ 'searchitem' ]
92-
};
93-
var userList = new List('searchable', options);
94-
// end List.js
95-
96-
}); // docrdy
97-
</script>
98-
99-
100-
10173
</div>
10274
</div>
10375

_layouts/page.html

-13
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,3 @@
5353
</div>
5454
</div>
5555
</div>
56-
57-
<script>
58-
$(document).ready(function () {
59-
$('#toc').toc({
60-
'selectors': 'h2',
61-
'prefix': 'toc',
62-
'container': '#page',
63-
'anchorName': function (i, heading, prefix) { //custom function for anchor name
64-
return $(heading).text().replace(/\s/g, '-').replace(/[^\w-]/g, '');
65-
},
66-
});
67-
});
68-
</script>

index.html

-18
Original file line numberDiff line numberDiff line change
@@ -190,24 +190,6 @@ <h3 class="text-center">Trusted By_</h3>
190190
</div>
191191
</div>
192192
</div>
193-
<script>
194-
$(document).ready(function () {
195-
function randomCarousel(id) {
196-
var num = $(id + ' .item').length;
197-
var slide = Math.floor((Math.random() * num));
198-
$(id + ' .item').each(function (index) {
199-
if (index == slide) {
200-
$(this).addClass('active');
201-
} else {
202-
$(this).removeClass('active');
203-
}
204-
});
205-
}
206-
207-
randomCarousel('#carousel-tweets');
208-
randomCarousel('#carousel-companies');
209-
});
210-
</script>
211193

212194
<div class="bg-grey">
213195
<div class="container">

0 commit comments

Comments
 (0)