]>
git.r.bdr.sh - rbdr/lyricli.rb/blob - doc/js/app.js
3bbd61ed42fbbcbaedbaf47aa47527d31b52dee2
1 function createSourceLinks() {
2 $('.method_details_list .source_code').
3 before("<span class='showSource'>[<a href='#' class='toggleSource'>View source</a>]</span>");
4 $('.toggleSource').toggle(function() {
5 $(this).parent().nextAll('.source_code').slideDown(100);
6 $(this).text("Hide source");
9 $(this).parent().nextAll('.source_code').slideUp(100);
10 $(this).text("View source");
14 function createDefineLinks() {
16 $('.defines').after(" <a href='#' class='toggleDefines'>more...</a>");
17 $('.toggleDefines').toggle(function() {
18 tHeight
= $(this).parent().prev().height();
19 $(this).prev().show();
20 $(this).parent().prev().height($(this).parent().height());
21 $(this).text("(less)");
24 $(this).prev().hide();
25 $(this).parent().prev().height(tHeight
);
26 $(this).text("more...");
30 function createFullTreeLinks() {
32 $('.inheritanceTree').toggle(function() {
33 tHeight
= $(this).parent().prev().height();
34 $(this).parent().toggleClass('showAll');
35 $(this).text("(hide)");
36 $(this).parent().prev().height($(this).parent().height());
39 $(this).parent().toggleClass('showAll');
40 $(this).parent().prev().height(tHeight
);
41 $(this).text("show all");
45 function fixBoxInfoHeights() {
46 $('dl.box dd.r1, dl.box dd.r2').each(function() {
47 $(this).prev().height($(this).height());
51 function searchFrameLinks() {
52 $('.full_list_link').click(function() {
53 toggleSearchFrame(this, $(this).attr('href'));
58 function toggleSearchFrame(id
, link
) {
59 var frame
= $('#search_frame');
60 $('#search a').removeClass('active').addClass('inactive');
61 if (frame
.attr('src') == link
&& frame
.css('display') != "none") {
63 $('#search a').removeClass('active inactive');
66 $(id
).addClass('active').removeClass('inactive');
67 frame
.attr('src', link
).slideDown(100);
71 function linkSummaries() {
72 $('.summary_signature').click(function() {
73 document
.location
= $(this).find('a').attr('href');
77 function framesInit() {
79 document
.body
.className
= 'frames';
80 $('#menu .noframes a').attr('href', document
.location
);
81 window
.top
.document
.title
= $('html head title').text();
84 $('#menu .noframes a').text('frames').attr('href', framesUrl
);
88 function keyboardShortcuts() {
89 if (window
.top
.frames
.main
) return;
90 $(document
).keypress(function(evt
) {
91 if (evt
.altKey
|| evt
.ctrlKey
|| evt
.metaKey
|| evt
.shiftKey
) return;
92 if (typeof evt
.target
!== "undefined" &&
93 (evt
.target
.nodeName
== "INPUT" ||
94 evt
.target
.nodeName
== "TEXTAREA")) return;
95 switch (evt
.charCode
) {
96 case 67: case 99: $('#class_list_link').click(); break; // 'c'
97 case 77: case 109: $('#method_list_link').click(); break; // 'm'
98 case 70: case 102: $('#file_list_link').click(); break; // 'f'
104 function summaryToggle() {
105 $('.summary_toggle').click(function() {
106 localStorage
.summaryCollapsed
= $(this).text();
107 $(this).text($(this).text() == "collapse" ? "expand" : "collapse");
108 var next
= $(this).parent().parent().nextAll('ul.summary').first();
109 if (next
.hasClass('compact')) {
111 next
.nextAll('ul.summary').first().toggle();
113 else if (next
.hasClass('summary')) {
114 var list
= $('<ul class="summary compact" />');
115 list
.html(next
.html());
116 list
.find('.summary_desc, .note').remove();
117 list
.find('a').each(function() {
118 $(this).html($(this).find('strong').html());
119 $(this).parent().html($(this)[0].outerHTML
);
127 if (localStorage
.summaryCollapsed
== "collapse") $('.summary_toggle').click();
128 else localStorage
.summaryCollapsed
= "expand";
132 function fixOutsideWorldLinks() {
133 $('a').each(function() {
134 if (window
.location
.host
!= this.host
) this.target
= '_parent';
138 function generateTOC() {
139 if ($('#filecontents').length
=== 0) return;
140 var _toc
= $('<ol class="top"></ol>');
144 var tags
= ['h2', 'h3', 'h4', 'h5', 'h6'];
146 if ($('#filecontents h1').length
> 1) tags
.unshift('h1');
147 for (i
= 0; i
< tags
.length
; i
++) { tags
[i
] = '#filecontents ' + tags
[i
]; }
148 var lastTag
= parseInt(tags
[0][1], 10);
149 $(tags
.join(', ')).each(function() {
150 if ($(this).parents('.method_details .docstring').length
!= 0) return;
151 if (this.id
== "filecontents") return;
153 var thisTag
= parseInt(this.tagName
[1], 10);
154 if (this.id
.length
=== 0) {
155 var proposedId
= $(this).attr('toc-id');
156 if (typeof(proposedId
) != "undefined") this.id
= proposedId
;
158 var proposedId
= $(this).text().replace(/[^a-z0-9-]/ig, '_');
159 if ($('#' + proposedId
).length
> 0) { proposedId
+= counter
; counter
++; }
160 this.id
= proposedId
;
163 if (thisTag
> lastTag
) {
164 for (i
= 0; i
< thisTag
- lastTag
; i
++) {
165 var tmp
= $('<ol/>'); toc
.append(tmp
); toc
= tmp
;
168 if (thisTag
< lastTag
) {
169 for (i
= 0; i
< lastTag
- thisTag
; i
++) toc
= toc
.parent();
171 var title
= $(this).attr('toc-title');
172 if (typeof(title
) == "undefined") title
= $(this).text();
173 toc
.append('<li><a href="#' + this.id
+ '">' + title
+ '</a></li>');
177 html
= '<div id="toc"><p class="title"><a class="hide_toc" href="#"><strong>Table of Contents</strong></a> <small>(<a href="#" class="float_toc">left</a>)</small></p></div>';
178 $('#content').prepend(html
);
179 $('#toc').append(_toc
);
180 $('#toc .hide_toc').toggle(function() {
181 $('#toc .top').slideUp('fast');
182 $('#toc').toggleClass('hidden');
183 $('#toc .title small').toggle();
185 $('#toc .top').slideDown('fast');
186 $('#toc').toggleClass('hidden');
187 $('#toc .title small').toggle();
189 $('#toc .float_toc').toggle(function() {
190 $(this).text('float');
191 $('#toc').toggleClass('nofloat');
193 $(this).text('left');
194 $('#toc').toggleClass('nofloat');
199 $(createSourceLinks
);
200 $(createDefineLinks
);
201 $(createFullTreeLinks
);
202 $(fixBoxInfoHeights
);
205 $(keyboardShortcuts
);
207 $(fixOutsideWorldLinks
);