(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); (function($) { $(document).ready(function() { var titles = $(".collapsableContent .collapsableTitle, .collapsableTextContent .collapsableTextTitle"); var width = $(window).width(); var height = $(window).height(); // Loop through each spry titles.each(function(index, element) { $(this).find('span .fa-chevron-up').hide(); $(this).find('span .fa-chevron-down').show(); var heightTitle = $(this).outerHeight(); // Click listener // Expands & closes the content section accordingly $(this).click(function(e) { var $this = $(this); animate_spry($this); }); // Deal with anchor functionality targeting sprys IDs var jQueryparent = $(this).parent(); var theID = jQueryparent.attr("id"); if(theID) { var paramPattern = new RegExp("[?|&]"+theID+"=","i"); if(paramPattern.exec(window.location.search)) { var offset = jQueryparent.offset().top; $("html, body") .animate({ scrollTop: (offset-heightTitle)+"px" }); jQueryparent.toggleClass("contentOpened"); return; } } jQueryparent.height(heightTitle); }); // When using find on sprys, open them up. $('.collapsableContent').scroll(function(){ var $this = $(this); if (! $this.hasClass('contentOpened') ) { $this.children('.collapsableTitle, .collapsableTextTitle').click(); } }); // Open spry on keydown $('.collapsableContent').keydown(function(e){ if (event.which == 13 || event.keyCode == 13) { var $this = $(this); $this.children('.collapsableTitle, .collapsableTextTitle').click(); } }); // Recalculate height when resizing $( window ).resize(function() { if($(window).width() == width && $(window).height() == height){ return; } titles.each(function(index, element) { var $this = $(this); var heightTitle = $this.outerHeight(); var jQueryparent = $this.parent(); if( jQueryparent.hasClass("contentOpened") ){ // do not collapse the item that is open jQueryparent.css("height", "auto"); return; } jQueryparent.height(heightTitle); }); }); // Function to collapse / hide spry based on current state of the spry animate_spry = function(curr_el) { var jQueryparent = curr_el.parent(); if(jQueryparent.hasClass("contentOpened")) { curr_el.find('span .fa-chevron-up').hide(); curr_el.find('span .fa-chevron-down').show(); var heightTitle = $(curr_el).outerHeight(); jQueryparent.animate({"height":heightTitle}, 500); } else { curr_el.find('span .fa-chevron-up').show(); curr_el.find('span .fa-chevron-down').hide(); var oldHeight = jQueryparent.height(); var newHeight = jQueryparent.css("height", "auto").height(); jQueryparent .css("height", oldHeight) .animate({"height":newHeight},{duration: 500, complete: function(){ $(curr_el).height(""); }}); } jQueryparent.toggleClass("contentOpened"); } // pass a URL paramater to expand all sprys var getUrlParameter = function getUrlParameter(sParam) { var sPageURL = decodeURIComponent(window.location.search.substring(1)), sURLVariables = sPageURL.split('&'), sParameterName, i; for (i = 0; i < sURLVariables.length; i++) { sParameterName = sURLVariables[i].split('='); if (sParameterName[0] === sParam) { return sParameterName[1] === undefined ? true : sParameterName[1]; } } }; var expand = getUrlParameter('expandAll'); if( true === expand ) { //open sprys $( ".collapsableContent" ).each(function( i ) { $(".collapsableContent").addClass('contentOpened'); $(".collapsableContent").css("height", "auto"); }); } }); })(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(); }