]>
git.r.bdr.sh - rbdr/lyricli.rb/blob - doc/js/app.js
c150289298c5acdcb0aa8afd7426bea8e56eada3
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() {
107 localStorage
.summaryCollapsed
= $(this).text();
109 $('.summary_toggle').each(function() {
110 $(this).text($(this).text() == "collapse" ? "expand" : "collapse");
111 var next
= $(this).parent().parent().nextAll('ul.summary').first();
112 if (next
.hasClass('compact')) {
114 next
.nextAll('ul.summary').first().toggle();
116 else if (next
.hasClass('summary')) {
117 var list
= $('<ul class="summary compact" />');
118 list
.html(next
.html());
119 list
.find('.summary_desc, .note').remove();
120 list
.find('a').each(function() {
121 $(this).html($(this).find('strong').html());
122 $(this).parent().html($(this)[0].outerHTML
);
131 if (localStorage
.summaryCollapsed
== "collapse") {
132 $('.summary_toggle').first().click();
134 else localStorage
.summaryCollapsed
= "expand";
138 function fixOutsideWorldLinks() {
139 $('a').each(function() {
140 if (window
.location
.host
!= this.host
) this.target
= '_parent';
144 function generateTOC() {
145 if ($('#filecontents').length
=== 0) return;
146 var _toc
= $('<ol class="top"></ol>');
150 var tags
= ['h2', 'h3', 'h4', 'h5', 'h6'];
152 if ($('#filecontents h1').length
> 1) tags
.unshift('h1');
153 for (i
= 0; i
< tags
.length
; i
++) { tags
[i
] = '#filecontents ' + tags
[i
]; }
154 var lastTag
= parseInt(tags
[0][1], 10);
155 $(tags
.join(', ')).each(function() {
156 if ($(this).parents('.method_details .docstring').length
!= 0) return;
157 if (this.id
== "filecontents") return;
159 var thisTag
= parseInt(this.tagName
[1], 10);
160 if (this.id
.length
=== 0) {
161 var proposedId
= $(this).attr('toc-id');
162 if (typeof(proposedId
) != "undefined") this.id
= proposedId
;
164 var proposedId
= $(this).text().replace(/[^a-z0-9-]/ig, '_');
165 if ($('#' + proposedId
).length
> 0) { proposedId
+= counter
; counter
++; }
166 this.id
= proposedId
;
169 if (thisTag
> lastTag
) {
170 for (i
= 0; i
< thisTag
- lastTag
; i
++) {
171 var tmp
= $('<ol/>'); toc
.append(tmp
); toc
= tmp
;
174 if (thisTag
< lastTag
) {
175 for (i
= 0; i
< lastTag
- thisTag
; i
++) toc
= toc
.parent();
177 var title
= $(this).attr('toc-title');
178 if (typeof(title
) == "undefined") title
= $(this).text();
179 toc
.append('<li><a href="#' + this.id
+ '">' + title
+ '</a></li>');
183 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>';
184 $('#content').prepend(html
);
185 $('#toc').append(_toc
);
186 $('#toc .hide_toc').toggle(function() {
187 $('#toc .top').slideUp('fast');
188 $('#toc').toggleClass('hidden');
189 $('#toc .title small').toggle();
191 $('#toc .top').slideDown('fast');
192 $('#toc').toggleClass('hidden');
193 $('#toc .title small').toggle();
195 $('#toc .float_toc').toggle(function() {
196 $(this).text('float');
197 $('#toc').toggleClass('nofloat');
199 $(this).text('left');
200 $('#toc').toggleClass('nofloat');
205 $(createSourceLinks
);
206 $(createDefineLinks
);
207 $(createFullTreeLinks
);
208 $(fixBoxInfoHeights
);
211 $(keyboardShortcuts
);
213 $(fixOutsideWorldLinks
);