Get 'mvn clean site' to work.
[commons-testing.git] / target / site / js / site.js
1 /*
2 Licensed to the Apache Software Foundation (ASF) under one or more
3 contributor license agreements. See the NOTICE file distributed with
4 this work for additional information regarding copyright ownership.
5 The ASF licenses this file to You under the Apache License, Version 2.0
6 (the "License"); you may not use this file except in compliance with
7 the License. You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16 */
17
18 /* Executed on page load. */
19 $(document).ready(function() {
20
21 //
22 // This is a hack to enable google-code-prettify to work with maven.
23 //
24 // The problem is that maven, when building the site, replaces:
25 // <pre class="prettyprint">...</pre>
26 // with:
27 // <div class="prettyprint"><pre>...</pre></div>
28 //
29 // Effectively, it removes the class parameter from the <pre> element, which
30 // is required for google-code-prettify to work.
31 //
32 // This hack restores the class of all <pre> elements which are the child of
33 // a <div class="prettyprint">.
34 //
35 $('pre').each(function() {
36 var parent = $(this).parent();
37
38 if (parent.hasClass('prettyprint')) {
39 parent.removeClass('prettyprint');
40 $(this).addClass('prettyprint');
41 }
42
43 if (parent.hasClass('linenums')) {
44 parent.removeClass('linenums');
45 $(this).addClass('linenums');
46 }
47 })
48
49 // Hack to add default visuals to tables
50 $('table').each(function() {
51 if ($(this).hasClass('bodyTable')) {
52
53 // Remove border="1" which is added by maven
54 this.border = 0;
55
56 // Add bootstrap table styling
57 $(this).addClass('table table-striped table-bordered');
58 }
59 });
60
61 // Render tabs
62 $('.auto-tabs').each(function(groupid) {
63
64 // Find tab bar
65 $(this).find('ul').each(function() {
66
67 // Add styling
68 $(this).addClass('nav nav-tabs');
69
70 // Go tab bar items
71 $(this).find('li').each(function(itemid) {
72
73 // Set first tab as active
74 if (itemid == 0) {
75 $(this).addClass('active');
76 }
77
78 // Replace text with a link to tab contents
79 var name = $(this).html();
80 var link = $('<a>')
81 .attr('href', '#' + 'tab-' + groupid + '-' + itemid)
82 .attr('data-toggle', 'tab')
83 .html(name);
84 $(this).html(link);
85 });
86 });
87
88 // Find tab contents
89 $(this).find('.tab-content .tab-pane').each(function(itemid) {
90
91 // Set first tab as active
92 if (itemid == 0) {
93 $(this).addClass('active');
94 }
95
96 // Set the tab id
97 $(this).attr('id', 'tab-' + groupid + '-' + itemid);
98 });
99 });
100
101 // Make external links open in new tab
102 $('a.external').attr('target', '_blank');
103
104 // Trigger prettyprint
105 prettyPrint();
106 });