Added onHide and onShow callbacks to be executed when window changes visibility