jQuery(document).ready(function() { //columns var colSets = jQuery(".columnSet"); colSets.each(function(index, element) { var colSet = jQuery(this); var totalWidth = colSet.width(); var columns = colSet.children(".stackableColumn"); var colNum = columns.length; var freeWidth = 100; //calculate available free width and fix everything to percent columns.each(function(index, element) { var colWidth = this.style.width; if(colWidth == '') { return; } if(colWidth.charAt(colWidth.length-1) == '%') { colWidth = Number(colWidth.match(/\d+/)[0]); freeWidth -= colWidth; jQuery(this).css("width",colWidth+"%"); colNum --; } else { colWidth = Number(colWidth.match(/\d+/)[0]); colWidth = Math.floor((colWidth/totalWidth)*100); freeWidth -= colWidth; jQuery(this).css("width",colWidth+"%"); colNum --; } }); //apply free width to the rest of the columns if(colNum != 0) { var widthPerCol = freeWidth/colNum; columns.each(function(index, element) { if(this.style.width == '') { jQuery(this).css("width",widthPerCol+"%"); } }); } }); }); jQuery(document).ready(function() { //collapses var titles = jQuery(".collapsableContent .collapsableTitle, .collapsableTextContent .collapsableTextTitle"); titles.each(function(index, element) { var heightTitle = jQuery(this).outerHeight() jQuery(this).click(function(e) { var jQueryparent = jQuery(this).parent(); if(jQueryparent.hasClass("contentOpened")) { var heightTitle = jQuery(this).outerHeight(); jQueryparent.animate({"height":heightTitle}, 500); } else { var oldHeight = jQueryparent.height(); var newHeight = jQueryparent.css("height","auto").height(); jQueryparent .css("height",oldHeight) .animate({"height":newHeight},{duration: 500, complete: function(){ jQuery(this).height(""); }}); } jQueryparent.toggleClass("contentOpened"); }); var jQueryparent = jQuery(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; jQuery("html, body") .animate({ scrollTop: (offset-heightTitle)+"px" }); jQueryparent.toggleClass("contentOpened"); return; } } jQueryparent.height(heightTitle); }); // When using find on sprys, open them up. jQuery('.collapsableContent').scroll(function(){ var $this = jQuery(this); if (! $this.hasClass('contentOpened')) { jQuery(this).children('.collapsableTitle, .collapsableTextTitle').click(); } }); }); 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(); } jQuery(document).ready(function(){ //Dumb IE 8 fix jQuery('.altRows p:nth-child(2n+1)').addClass('odd'); //Navigation JS jQuery('.menu-item-type-custom.menu-item-has-children:not(.current-menu-ancestor) > a').toggle(function(){jQuery(this).parent().toggleClass('current-menu-ancestor');},function(){jQuery(this).parent().toggleClass('current-menu-ancestor');}); //Academic Calendar jQuery(".academicCalendar ul").css("list-style", "none"); jQuery(".academicCalendar li").css({height:"50px", padding: "5px", border: "1px solid #000", margin: "0", background: "none" }); jQuery(".academicCalendar li:even").css({ float: "left", width: "25%", margin: "0 10px 0 0" }); jQuery(".academicCalendar li:odd").css({ width: "95%" }); jQuery(".academicCalendar ul li:nth-child(4n+3)").css("background", "#eee"); jQuery(".academicCalendar ul li:nth-child(4n)").css("background", "#eee"); }); // Report percentage scrolled (function($) { var maxScroll = 0; $(document).ready(function(){ $(document).scroll(); }); $(document).scroll(function(){ var totalHeight = $(document).outerHeight(); var windowHeight = $(window).outerHeight(); var windowPos = $(window).scrollTop(); var percentScrolled = Math.round(((windowPos+windowHeight)/totalHeight)*10000)/100; maxScroll = Math.max(percentScrolled, maxScroll); }); $(window).on('beforeunload', function(){ ga('send', 'event', 'page', 'scroll-percent', maxScroll); }); })(jQuery); function getStyle(oElm, strCssRule) { var strValue = ""; if(document.defaultView && document.defaultView.getComputedStyle) { strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule); } else if(oElm.currentStyle) { strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1) { return p1.toUpperCase(); }); strValue = oElm.currentStyle[strCssRule]; } return strValue; } var counter = 0; function setBaseFontSize(increment) { var allTags = new Array ( new Array("p", ""), new Array("h2", ""), new Array("h3", ""), new Array("h4", ""), new Array("div", "CollapsiblePanelTab"), new Array("th", ""), new Array("a", "") ); if (counter === 0) { defaultMain = getStyle(document.getElementById('leftCol'), 'font-size'); defaultMain = defaultMain.replace('px', ''); for(i = 0; i < allTags.length; i++) { if( (document.getElementById('leftCol').getElementsByTagName(allTags[i][0]).length !== 0) ) { eval(allTags[i][0] + "Tags = new Array();"); eval(allTags[i][0] + "Tags = document.getElementById('leftCol').getElementsByTagName('" + allTags[i][0] + "');"); if(!allTags[i][1]) { eval("default" + allTags[i][0] + "= getStyle(" + allTags[i][0] + "Tags[0], 'font-size');"); eval("default" + allTags[i][0] + "= default" + allTags[i][0] + ".replace('px','');"); } else { for(a = 0; a < (eval(allTags[i][0] + "Tags")).length; a++) { if((eval(allTags[i][0] + "Tags"))[a].className == allTags[i][1]) { eval("default" + allTags[i][0] + allTags[i][1] + "= getStyle(" + allTags[i][0] + "Tags[a], 'font-size');"); eval("default" + allTags[i][0] + allTags[i][1] + "= default" + allTags[i][0] + allTags[i][1] + ".replace('px','');"); } } } } } counter++; } document.getElementById('leftCol').style.fontSize = (parseInt(defaultMain,10) + parseInt(increment,10)) + "px"; for(j = 0; j < allTags.length; j++) { if(document.getElementById('leftCol').getElementsByTagName(allTags[j][0]).length !== 0) { for (k = 0; k < (eval(allTags[j][0] + "Tags")).length; k++) { if(!allTags[j][1]) { (eval(allTags[j][0] + "Tags"))[k].style.fontSize = (parseInt(eval("default" + allTags[j][0]),10) + parseInt(increment,10)) + "px"; } else { for(m = 0; m < (eval(allTags[j][0] + "Tags")).length; m++) { if((eval(allTags[j][0] + "Tags"))[m].className == allTags[j][1]) { (eval(allTags[j][0] + "Tags"))[m].style.fontSize = (parseInt(eval("default" + allTags[j][0] + allTags[j][1]),10) + parseInt(increment,10)) + "px"; } } } } } } }