Index: branches/5.2.x/core/admin_templates/js/jquery/thickbox/thickbox.js =================================================================== diff -u -N -r13840 -r14092 --- branches/5.2.x/core/admin_templates/js/jquery/thickbox/thickbox.js (.../thickbox.js) (revision 13840) +++ branches/5.2.x/core/admin_templates/js/jquery/thickbox/thickbox.js (.../thickbox.js) (revision 14092) @@ -63,7 +63,7 @@ // function called when the user clicks on a thickbox link TB.show = function (params) { TB.lastParams = params; -// caption, url, imageGroup, onDataReceived, onAfterShow, postParams +// caption, url, imageGroup, onDataReceived, onAfterShow, onAfterClose, postParams if (TB.imgLoader === undefined) { // loader image is set from $(document).ready(...) and when some slow javascript @@ -377,6 +377,10 @@ TB.position(); $('#TB_load').remove(); $('#' + TB.getId('TB_window')).css('display', 'block'); + + if ( $.isFunction(params.onAfterShow) ) { + params.onAfterShow(); + } } else if (params.url.indexOf('TB_iframe') != -1) { TB.position(); if ($.browser.safari) { @@ -479,8 +483,17 @@ } TB.remove = function ($e, $on_close) { + if (TB.useStack && TB.windows.length == 0) { + // no windows opened, but TB.remove called -> ignore + return ; + } + var $last_window = TB.useStack && TB.windows.length <= 1; + if ( !$.isFunction($on_close) && $.isFunction(TB.lastParams.onAfterClose) ) { + $on_close = TB.lastParams.onAfterClose; + } + $('#TB_imageOff').unbind('click'); $('#' + TB.getId('TB_closeWindowButton')).unbind('click');