Skip to content

Commit e6d2492

Browse files
committed
Fix usages of jquery toggle function removed in v1.9.0
I've defined a jquery function called oldToggle closely based on the code in the jquery-migrate plugin [1] as recommended here [2]. I'm sure this code could be made a lot better, but this seems to fix my current problem. [1]: https://github.com/jquery/jquery-migrate/blob/1.x-stable/src/event.js#L72-L103 [2]: https://github.com/jquery/jquery-migrate/blob/1.x-stable/warnings.md#jqmigrate-jqueryfntogglehandler-handler-is-deprecated
1 parent 065d5dc commit e6d2492

File tree

1 file changed

+30
-4
lines changed
  • templates/default/fulldoc/html/js

1 file changed

+30
-4
lines changed

templates/default/fulldoc/html/js/app.js

+30-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,36 @@ var localStorage = {}, sessionStorage = {};
44
try { localStorage = window.localStorage; } catch (e) { }
55
try { sessionStorage = window.sessionStorage; } catch (e) { }
66

7+
jQuery.fn.oldToggle = function( fn, fn2 ) {
8+
// Save reference to arguments for access in closure
9+
var args = arguments,
10+
guid = fn.guid || jQuery.guid++,
11+
i = 0,
12+
toggler = function( event ) {
13+
// Figure out which function to execute
14+
var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
15+
jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
16+
17+
// Make sure that clicks stop
18+
event.preventDefault();
19+
20+
// and execute the function
21+
return args[ lastToggle ].apply( this, arguments ) || false;
22+
};
23+
24+
// link all the functions, so any of them can unbind this click handler
25+
toggler.guid = guid;
26+
while ( i < args.length ) {
27+
args[ i++ ].guid = guid;
28+
}
29+
30+
return this.click( toggler );
31+
};
32+
733
function createSourceLinks() {
834
$('.method_details_list .source_code').
935
before("<span class='showSource'>[<a href='#' class='toggleSource'>View source</a>]</span>");
10-
$('.toggleSource').toggle(function() {
36+
$('.toggleSource').oldToggle(function() {
1137
$(this).parent().nextAll('.source_code').slideDown(100);
1238
$(this).text("Hide source");
1339
},
@@ -20,7 +46,7 @@ function createSourceLinks() {
2046
function createDefineLinks() {
2147
var tHeight = 0;
2248
$('.defines').after(" <a href='#' class='toggleDefines'>more...</a>");
23-
$('.toggleDefines').toggle(function() {
49+
$('.toggleDefines').oldToggle(function() {
2450
tHeight = $(this).parent().prev().height();
2551
$(this).prev().css('display', 'inline');
2652
$(this).parent().prev().height($(this).parent().height());
@@ -35,7 +61,7 @@ function createDefineLinks() {
3561

3662
function createFullTreeLinks() {
3763
var tHeight = 0;
38-
$('.inheritanceTree').toggle(function() {
64+
$('.inheritanceTree').oldToggle(function() {
3965
tHeight = $(this).parent().prev().height();
4066
$(this).parent().toggleClass('showAll');
4167
$(this).text("(hide)");
@@ -216,7 +242,7 @@ function generateTOC() {
216242
html = '<div id="toc"><p class="title hide_toc"><a href="#"><strong>Table of Contents</strong></a></p></div>';
217243
$('#content').prepend(html);
218244
$('#toc').append(_toc);
219-
$('#toc .hide_toc').toggle(function() {
245+
$('#toc .hide_toc').oldToggle(function() {
220246
$('#toc .top').slideUp('fast');
221247
$('#toc').toggleClass('hidden');
222248
$('#toc .title small').toggle();

0 commit comments

Comments
 (0)