jQuery(document).ready(function() { //banner links jQuery('a.bannerDetailed').click(bClassGetDetailed); jQuery('.ajaxLoading').hide(); }); function bClassGetDetailed() { a_semester = jQuery(this).attr('data-semester'); a_subject = jQuery(this).attr('data-subject'); a_id = jQuery(this).attr('data-id'); a_type = jQuery(this).attr('data-type'); a_attribute = jQuery(this).attr('data-attribute'); elementID = jQuery(this).attr('id'); jQuerytarget = jQuery(this).parent().children('.bClassDetails'); if(jQuerytarget.hasClass("animating")) return; jQuerytarget.addClass("animating"); if('' == jQuerytarget.html()) { var data = { action: 'get_banner_detail', type: a_type, semester: a_semester, subject: a_subject, id: a_id, attribute: a_attribute, htmlID: elementID }; jQuery(this).parent().children('.ajaxLoading').show(); jQuery.post(ajaxurl, data, function(response) { jQuerytarget = jQuery('#'+response.id).parent().children('.bClassDetails'); jQuerytarget.parent().children('.ajaxLoading').hide(); jQuerytarget.html(response.data); jQuery('a.bannerDetailed').click(bClassGetDetailed); var totalHeight = jQuerytarget.css('display','inline-block').outerHeight(); jQuerytarget.height(0).animate({'height':totalHeight+'px'},500, function(){jQuery(this).css("height",""); jQuery(this).removeClass("animating");}); },'json'); } else { var totalHeight = jQuerytarget.height(); if(totalHeight > 1) { jQuerytarget.animate({'height':0},500, function(){jQuery(this).css("display","").removeClass("animating");}); } else { totalHeight = jQuerytarget.css('display','inline-block').height("auto").outerHeight(); jQuerytarget.height(0).animate({'height':totalHeight+'px'},500, function(){jQuery(this).css("height",""); jQuery(this).removeClass("animating");}); } } // make sure that spry height gets adjusted accordingly for the new theme jQuery('a.bannerDetailed').closest( 'div.contentOpened' ).css("height", "auto").height(); }