mirror of https://github.com/kivy/kivy.git
118 lines
3.5 KiB
JavaScript
118 lines
3.5 KiB
JavaScript
$(document).ready(function () {
|
|
var height = $(document).height();
|
|
$('#content').css('min-height', function(){ return height; });
|
|
|
|
var bodyshortcut = false;
|
|
function ensure_bodyshortcut() {
|
|
if ( bodyshortcut == true )
|
|
return;
|
|
var bsc = $('<div class="bodyshortcut"> </div>');
|
|
bsc.insertAfter($('div.body h1:first'));
|
|
bodyshortcut = true;
|
|
};
|
|
|
|
// if it's an API page, show the module name.
|
|
var pagename = location.pathname.split('/');
|
|
pagename = pagename[pagename.length - 1];
|
|
if (pagename.search('api-') == 0) {
|
|
pagename = pagename.substr(4, pagename.length - 9);
|
|
|
|
ensure_bodyshortcut();
|
|
var modulename = $('<div class="left">Module: <a href="#">' + pagename + '</a></div>')
|
|
modulename.appendTo($('div.bodyshortcut'));
|
|
}
|
|
|
|
// insert breaker only for the first data/class/function found.
|
|
var apibreaker = false;
|
|
$('div.body dl[class]').each(function (i1, elem) {
|
|
// theses are first level class: attribute and method are inside class.
|
|
if (!$(elem).hasClass('data') &&
|
|
!$(elem).hasClass('class') &&
|
|
!$(elem).hasClass('exception') &&
|
|
!$(elem).hasClass('function'))
|
|
return;
|
|
// dont accept dl inside dl
|
|
if ($(elem).parents().filter('dl').length > 0)
|
|
return;
|
|
|
|
$(elem).addClass('api-level');
|
|
|
|
if ( apibreaker == true )
|
|
return;
|
|
$('<div id="api"></div>')
|
|
.attr('id', 'api')
|
|
.html(
|
|
$('<h2>API ' +
|
|
'<a id="api-toggle-all" class="showed">Collapse All ⇑</a>' +
|
|
'<a id="api-toggle-desc" class="showed">Hide Description ⇑</a>' +
|
|
'</h2>')
|
|
)
|
|
.insertBefore(elem);
|
|
apibreaker = true;
|
|
});
|
|
|
|
|
|
$('div.body dl[class] dt').hover(
|
|
function() { $(this).addClass('hover'); },
|
|
function() { $(this).removeClass('hover'); }
|
|
);
|
|
|
|
if ( apibreaker == true ) {
|
|
ensure_bodyshortcut();
|
|
var apilink = $('<div class="right"><a id="api-link" href="#api">Jump to API</a> ⇓</div>');
|
|
apilink.appendTo($('div.bodyshortcut'));
|
|
}
|
|
|
|
$('#api-toggle-all').click(function() {
|
|
if ($(this).hasClass('showed')) {
|
|
$('div.body dl.api-level > dd').slideUp();
|
|
$(this).removeClass('showed');
|
|
$(this).html('Expand All ⇓');
|
|
$.cookie('kivy.toggleall', 'true');
|
|
} else {
|
|
$('div.body dl.api-level > dd').slideDown();
|
|
$(this).addClass('showed');
|
|
$(this).html('Collapse All ⇑');
|
|
$.cookie('kivy.toggleall', 'false');
|
|
}
|
|
});
|
|
|
|
$('#api-toggle-desc').click(function() {
|
|
if ($(this).hasClass('showed')) {
|
|
$('div.body dl.api-level > dd > dl > dd').slideUp();
|
|
$(this).removeClass('showed');
|
|
$(this).html('Show Descriptions ⇓');
|
|
$.cookie('kivy.toggledesc', 'true');
|
|
} else {
|
|
$('div.body dl.api-level > dd > dl > dd').slideDown();
|
|
$(this).addClass('showed');
|
|
$(this).html('Hide Descriptions ⇑');
|
|
$.cookie('kivy.toggledesc', 'false');
|
|
}
|
|
console.log($.cookie('kivy.toggledesc'));
|
|
});
|
|
|
|
$('div.body dl dt').click(function() {
|
|
$(this).next().slideToggle();
|
|
});
|
|
|
|
if ( $.cookie('kivy.toggledesc') == 'true' ) {
|
|
$('div.body dl.api-level > dd > dl > dd').hide();
|
|
$('#api-toggle-desc').removeClass('showed');
|
|
$('#api-toggle-desc').html('Show Descriptions ⇓');
|
|
}
|
|
|
|
if ( $.cookie('kivy.toggleall') == 'true' ) {
|
|
$('div.body dl.api-level > dd').hide();
|
|
$('#api-toggle').removeClass('showed');
|
|
$('#api-toggle').html('Expand All ⇓');
|
|
}
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
// Image reflexions
|
|
//----------------------------------------------------------------------------
|
|
|
|
$('div.body img').reflect({'opacity': .35, 'height': 40});
|
|
});
|