Skip to content

Commit

Permalink
Patch app.js to work with jquery v1.9.0
Browse files Browse the repository at this point in the history
Ideally this would be fixed in yard. I've opened a PR [1] with the fix,
but haven't yet had any response at all - hence why I'm patching this.

Note that we now have to checkout both app.js & jquery.js after the docs
are generated in order to override the versions of these files generated
by yard.

[1]: lsegal/yard#1351
  • Loading branch information
floehopper committed Sep 25, 2020
1 parent dd5eeed commit 1b76e4d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
5 changes: 3 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,13 @@ if ENV['MOCHA_GENERATE_DOCS']
`git checkout docs/CNAME`
end

task 'checkout_docs_jquery' do
task 'checkout_docs_js' do
`git checkout docs/js/app.js`
`git checkout docs/js/jquery.js`
end

desc 'Generate documentation'
task 'generate_docs' => %w[clobber_yardoc yardoc checkout_docs_cname checkout_docs_jquery]
task 'generate_docs' => %w[clobber_yardoc yardoc checkout_docs_cname checkout_docs_js]
end

task 'release' => 'default'
34 changes: 30 additions & 4 deletions docs/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,36 @@ var localStorage = {}, sessionStorage = {};
try { localStorage = window.localStorage; } catch (e) { }
try { sessionStorage = window.sessionStorage; } catch (e) { }

jQuery.fn.oldToggle = function( fn, fn2 ) {
// Save reference to arguments for access in closure
var args = arguments,
guid = fn.guid || jQuery.guid++,
i = 0,
toggler = function( event ) {
// Figure out which function to execute
var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );

// Make sure that clicks stop
event.preventDefault();

// and execute the function
return args[ lastToggle ].apply( this, arguments ) || false;
};

// link all the functions, so any of them can unbind this click handler
toggler.guid = guid;
while ( i < args.length ) {
args[ i++ ].guid = guid;
}

return this.click( toggler );
};

function createSourceLinks() {
$('.method_details_list .source_code').
before("<span class='showSource'>[<a href='#' class='toggleSource'>View source</a>]</span>");
$('.toggleSource').toggle(function() {
$('.toggleSource').oldToggle(function() {
$(this).parent().nextAll('.source_code').slideDown(100);
$(this).text("Hide source");
},
Expand All @@ -20,7 +46,7 @@ function createSourceLinks() {
function createDefineLinks() {
var tHeight = 0;
$('.defines').after(" <a href='#' class='toggleDefines'>more...</a>");
$('.toggleDefines').toggle(function() {
$('.toggleDefines').oldToggle(function() {
tHeight = $(this).parent().prev().height();
$(this).prev().css('display', 'inline');
$(this).parent().prev().height($(this).parent().height());
Expand All @@ -35,7 +61,7 @@ function createDefineLinks() {

function createFullTreeLinks() {
var tHeight = 0;
$('.inheritanceTree').toggle(function() {
$('.inheritanceTree').oldToggle(function() {
tHeight = $(this).parent().prev().height();
$(this).parent().toggleClass('showAll');
$(this).text("(hide)");
Expand Down Expand Up @@ -216,7 +242,7 @@ function generateTOC() {
html = '<div id="toc"><p class="title hide_toc"><a href="#"><strong>Table of Contents</strong></a></p></div>';
$('#content').prepend(html);
$('#toc').append(_toc);
$('#toc .hide_toc').toggle(function() {
$('#toc .hide_toc').oldToggle(function() {
$('#toc .top').slideUp('fast');
$('#toc').toggleClass('hidden');
$('#toc .title small').toggle();
Expand Down
5 changes: 3 additions & 2 deletions docs/js/jquery.js

Large diffs are not rendered by default.

0 comments on commit 1b76e4d

Please sign in to comment.