Skip to content

Commit c9bedeb

Browse files
committed
hide/show pod by class toggle
1 parent fccb310 commit c9bedeb

File tree

5 files changed

+24
-23
lines changed

5 files changed

+24
-23
lines changed

root/source.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
</div>
4646
</li>
4747
<% IF module.sloc > 0 %>
48-
<li><div><a href="javascript:togglePod(<% module.pod_lines.json %>)"><i class="fa fa-exchange fa-fw black"></i>Toggle pod</a></div></li>
48+
<li><div><button class="btn-link" onclick="togglePod()"><i class="fa fa-exchange fa-fw black"></i>Toggle pod</button></div></li>
4949
<% END %>
5050
<li class="nav-header">Info</li>
5151
<li><% module.sloc %> lines of code</li>
@@ -67,7 +67,8 @@
6767
//SyntaxHighlighter.all();
6868
$(document).ready(function() {
6969
<% IF module.sloc > 0 %>
70-
togglePod(<% module.pod_lines.json %>);
70+
setPodLines(<% module.pod_lines.json %>);
71+
togglePod();
7172
<% END %>
7273
if(document.location.hash)
7374
document.location.href = document.location.href;

root/static/js/cpan.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,6 @@ $.extend({
2626
}
2727
});
2828

29-
var podVisible = false;
30-
31-
function togglePod(lines) {
32-
var toggle = podVisible ? 'none' : 'block';
33-
podVisible = !podVisible;
34-
if (!lines || !lines.length) return;
35-
for (var i = 0; i < lines.length; i++) {
36-
var start = lines[i][0],
37-
length = lines[i][1];
38-
var sourceC = $('.container')[0].children;
39-
var linesC = $('.gutter')[0].children;
40-
var x;
41-
for (x = start; x < start + length; x++) {
42-
sourceC[x].style.display = toggle;
43-
linesC[x].style.display = toggle;
44-
}
45-
46-
}
47-
}
48-
4929
function togglePanel(side) {
5030
var panel = $('#' + side + '-panel');
5131
var shower = $('#show-' + side + '-panel');

root/static/js/syntaxhighlighter.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,20 @@ $(function () {
143143
SyntaxHighlighter.highlight(config, source);
144144
});
145145
});
146+
147+
function setPodLines (lines) {
148+
if (!lines || !lines.length) return;
149+
for (var i = 0; i < lines.length; i++) {
150+
var start = lines[i][0];
151+
var length = lines[i][1];
152+
var selectors = [];
153+
for (var x = start; x < start + length; x++) {
154+
selectors.push('.number' + (x+1));
155+
}
156+
$('#source .syntaxhighlighter .line').filter(selectors.join(', ')).addClass('pod-line');
157+
}
158+
}
159+
160+
function togglePod() {
161+
$('.syntaxhighlighter').toggleClass('pod-hidden');
162+
}

root/static/less/global.less

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ ul {
238238
/* Contributors list on release pages
239239
* see /release/Plack for example
240240
*/
241-
242241
#contributors {
243242
min-height: 40px;
244243

root/static/less/syntaxhighlighter.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@ pre code {
2424
.syntaxhighlighter .container:after {
2525
content: none !important;
2626
}
27+
28+
.pod-hidden .pod-line {
29+
display: none;
30+
}

0 commit comments

Comments
 (0)