(function($) { $(document).ready(function() { var colSets = $( '.colSet' ); colSets.each( function( index, element ) { var colSet = $(this); var columns = colSet.children( '.sColumn' ); var colNum = columns.length; var freeCols = 12; columns.each(function( index, element ) { // column does not have specified width if( ! $(this).is( '[class*=col-lg-]' ) ) { return; } var columnClasses = $(this).attr( 'class' ).split(' '); var numCols = 0; // Get # of initial grid columns assigned for the column for( var key in columnClasses ) { var currClass = columnClasses[key]; if( currClass.indexOf( 'col-lg-' ) >= 0 ) { numCols = currClass.substr(currClass.length - 2); if( numCols.substr(0, 1) == '-' ) { numCols = numCols.substr( numCols.length - 1 ); } } } // Adjust the remaining freeCols accordingly freeCols -= numCols; // Check if user provided widths with total that exceeds 100%. // If so, just divide all columns evenly. // If number is not exactly divisible => add remainder to the last column. if( freeCols < 0 ) { freeCols = 12; colNum = columns.length; columns.each(function( index, element ) { $(this).attr( 'class', function (i, c) { return c.replace( /col-lg-(\d+)/, 'col-lg-' + freeCols/colNum ); }); freeCols -= freeCols/colNum; colNum--; }); colNum = 0; return; } // Account for all columns having the class col-lg-.. colNum--; }); // Apply free width to the rest of the columns if( colNum != 0 ) { var numCols = Math.floor(freeCols / colNum); columns.each(function(index, element) { if( ! $(this).is( '[class*=col-lg-]' ) ) { $(this).addClass( 'col-lg-' + numCols ); freeCols -= numCols; } }); } // If all columns have set width, but freeWidth is remaining, add it to the last column if( freeCols != 0 ) { var $lastCol = columns.last(); var lastColClasses = $lastCol.attr( 'class' ).split(' '); for( var key in lastColClasses ) { var currClass = lastColClasses[key]; if( currClass.indexOf( 'col-lg-' ) >= 0 ) { numCols = Number( currClass.substr(currClass.length - 1) ); numCols += freeCols; $lastCol.removeClass(currClass); } } $lastCol.addClass( 'col-lg-' + numCols ); } }); }); })(jQuery); 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(); }