templates/default/fulldoc/html/js/app.js in yard-0.5.8 vs templates/default/fulldoc/html/js/app.js in yard-0.6.0
- old
+ new
@@ -85,10 +85,11 @@
function framesInit() {
if (window.top.frames.main) {
document.body.className = 'frames';
$('#menu .noframes a').attr('href', document.location);
+ $('html head title', window.parent.document).text($('html head title').text());
}
}
function keyboardShortcuts() {
if (window.top.frames.main) return;
@@ -104,10 +105,11 @@
});
}
function summaryToggle() {
$('.summary_toggle').click(function() {
+ localStorage.summaryCollapsed = $(this).text();
$(this).text($(this).text() == "collapse" ? "expand" : "collapse");
var next = $(this).parent().parent().next();
if (next.hasClass('compact')) {
next.toggle();
next.next().toggle();
@@ -122,17 +124,81 @@
});
next.before(list);
next.toggle();
}
return false;
- })
+ });
+ if (localStorage) {
+ if (localStorage.summaryCollapsed == "collapse") $('.summary_toggle').click();
+ else localStorage.summaryCollapsed = "expand";
+ }
}
+function fixOutsideWorldLinks() {
+ $('a').each(function() {
+ if (window.location.host != this.host) this.target = '_parent';
+ });
+}
+
+function generateTOC() {
+ if ($('#filecontents').length == 0) return;
+ var _toc = $('<ol class="top"></ol>');
+ var show = false;
+ var toc = _toc;
+ var counter = 0;
+ var tags = ['h2', 'h3', 'h4', 'h5', 'h6'];
+ if ($('#filecontents h1').length > 1) tags.unshift('h1');
+ for (i in tags) { tags[i] = '#filecontents ' + tags[i] }
+ var lastTag = parseInt(tags[0][1]);
+ $(tags.join(', ')).each(function() {
+ if (this.id == "filecontents") return;
+ show = true;
+ var thisTag = parseInt(this.tagName[1]);
+ if (this.id.length == 0) {
+ var proposedId = $(this).text().replace(/[^a-z]/ig, '_');
+ if ($('#' + proposedId).length > 0) proposedId += counter++;
+ this.id = proposedId;
+ }
+ if (thisTag > lastTag) {
+ for (var i = 0; i < thisTag - lastTag; i++) {
+ var tmp = $('<ol/>'); toc.append(tmp); toc = tmp;
+ }
+ }
+ if (thisTag < lastTag) {
+ for (var i = 0; i < lastTag - thisTag; i++) toc = toc.parent();
+ }
+ toc.append('<li><a href="#' + this.id + '">' + $(this).text() + '</a></li>');
+ lastTag = thisTag;
+ });
+ if (!show) return;
+ 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>';
+ $('#content').prepend(html);
+ $('#toc').append(_toc);
+ $('#toc .hide_toc').toggle(function() {
+ $('#toc .top').slideUp('fast');
+ $('#toc').toggleClass('hidden');
+ $('#toc .title small').toggle();
+ }, function() {
+ $('#toc .top').slideDown('fast');
+ $('#toc').toggleClass('hidden');
+ $('#toc .title small').toggle();
+ });
+ $('#toc .float_toc').toggle(function() {
+ $(this).text('float');
+ $('#toc').toggleClass('nofloat');
+ }, function() {
+ $(this).text('left')
+ $('#toc').toggleClass('nofloat');
+ });
+}
+
$(framesInit);
$(createSourceLinks);
$(createDefineLinks);
$(createFullTreeLinks);
$(fixBoxInfoHeights);
$(searchFrameLinks);
$(linkSummaries);
$(keyboardShortcuts);
$(summaryToggle);
+$(fixOutsideWorldLinks);
+$(generateTOC);
\ No newline at end of file