Created
April 23, 2014 21:52
-
-
Save jkereako/11233714 to your computer and use it in GitHub Desktop.
Provides a callback parameter to the Thickbox function tb_remove(). The callback will be executed after Thickbox has left the screen.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Define this at the beginning of your JavaScript file. | |
// Use thusly: tb_remove( function(){ console.log( "Thickbox has left the building" )} ); | |
var tb_removeOriginal = window.tb_remove; | |
window.tb_remove = function( callback ) { | |
tb_removeOriginal(); | |
var obj = {}; | |
// Check that "callback" is actually a function. | |
// @see: http://stackoverflow.com/questions/5999998/how-can-i-check-if-a-javascript-variable-is-function-type#7356528 | |
if ( callback && "[object Function]" === obj.toString.call( callback ) ) { | |
// The event "tb_unload" is triggered after the animation. | |
jQuery( "#TB_window" ).bind( "tb_unload", function( event ) { | |
// Execute the callback. | |
callback(); | |
}); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment