//scripts for COSTS PAGE
//scripts for charts
var tuitionCanvas = document.getElementById('tuitionComparision').getContext('2d');
Chart.defaults.global.defaultFontColor = '#474747';
Chart.defaults.global.defaultFontFamily = 'Arial, sans-serif';
Chart.defaults.global.defaultFontSize = '16';
Chart.defaults.global.layout = {"padding": {left: 0, right: 0,top: 0,bottom: 0 }};
var tuitionChart = new Chart(tuitionCanvas, {
"type":"horizontalBar",
"data":{
"labels":["Arizona State University", "Utah Tech University" ,"Northern Arizona University" ,"Southern Utah University" ,"University of Utah" ,"UNLV" ,"Utah State University" ,"Utah Valley University", "Weber State University"],
"datasets":[{
"data":[4060,1530,2790,1800,1560,1995,2067,1560,1905],
"fill":true,
"backgroundColor": ["#e1e1e1", "#ba1c21", "#dedede", "#ccc", "#bebebe", "#aeaeae" ,"#929292" ,"#747474" ,"#474747"]
}]//end dataset
},//end data
"options": {
"responsive": true,
"maintainAspectRatio": false,
"legend": { "display": false },
"scales": {
"xAxes": [{
"type":"linear",
"ticks": {
"padding":20,
"beginAtZero": true,
"stepSize":500,
"max":4000,
"callback" : function(value, index, values) {
'use strict';
return value.toLocaleString("en-US",{style:"currency", currency:"USD"}).slice(0, -3);
}
},
"gridLines":{
"display":true,
"drawBorder":false,
"lineWidth":5,
"borderDash":[10,20],
"color":"#e1e1e1",
"zeroLineWidth":0,
"zeroLineColor":"rgba(255,255,255,0)"
}
}],//end yAxis config
"yAxes": [{
"gridLines":{
"display":false,
"drawBorder":false
},
"scaleLabel":{
"padding":0
},
"ticks":{
"fontColor": '#747474',
"fontSize":16,
"autoSkip":false
}
}]//end xAxis config
},//end scales
"animation":{
"duration":1000
},//end animation config
"tooltips":{
"enabled":true,
"backgroundColor":"#000",
"position":"nearest",
"titleFontFamily":"Arial, sans-serif",
"titleFontSize": 20,
"titleFontColor": '#fff',
"bodyFontFamily":"Arial, sans-serif",
"bodyFontSize": 16,
"bodyFontColor": '#fff',
"footerFontFamily":"Arial, sans-serif",
"footerFontColor": '#f1f1f1',
"footerFontSize": 14,
"footerFontStyle":"italic",
"displayColors":false,
"xPadding":20,
"yPadding":20,
"footerSpacing":6,
"bodySpacing":2,
"callbacks": {
"title":function(tooltip,data){
'use strict';
var title = data.labels[tooltip[0].index];
return title;
},
"label": function(tooltipItem, data) {
'use strict';
var title = data.labels[tooltipItem.index];
var value = data.datasets[0].data[tooltipItem.index];
var dollars = value.toLocaleString("en-US",{style:"currency", currency:"USD"}).slice(0, -3);
return dollars + " " + costNotes[tooltipItem.index];
// return "costs " + dollars + " " + costNotes[tooltipItem.index];
},
"footer": function(tooltip, data){
'use strict';
return notes[tooltip[0].index];
}
}//end callbacks
},//end tooltips,
"plugins": {
"deferred": {
"enabled": false,// enabled by default
"yOffset": '100%', // defer until 50% of the canvas height are inside the viewport
"delay": 5000 // delay of 500 ms after the canvas is considered inside the viewport
}//end deferred
}//end plugins
}//end options
});//end chart
var notes = ["$3,586 tuition & fees for AZ residents", "Costs are the same for residents & non-residents" ,"Costs are the same for residents & non-residents" ,"Costs are the same for residents & non-residents" ,"Costs are the same for residents & non-residents" ,"$1,575 tuition & fees for NV residents" ,"$2,292 tuition & fees / non-residents" ,"Costs are the same for residents & non-residents", "$2,036 tuition & fees / non-residents"];
var costNotes = ['tuition & fees', 'tuition, with general student fees waived', 'tuition & fees', 'tuition & fees', 'tuition & fees', 'tuition & fees', 'tuition & fees', 'tuition & fees', 'tuition & fees'];
//mobile tuition chart nav
jQuery(document).ready(function($){
'use strict';
$('#creditHours').change(function(){ launchStats(); });
$('#launchMobileTuition').click(function(){ launchStats(); });
$(document).on('click','#tuitionStats tr.open', function(){
$("#tuitionStats tr").removeClass('open');
});
$(document).on('click', function (e) {
if(!$(e.target).hasClass('open') && !$(e.target).is('input, select, option') ){
if ( $(e.target).closest("#tuitionStats tr").length === 0 ) {
$("#tuitionStats tr").removeClass('open');
}
}
});
function launchStats(){
var selectedCredit = $('#creditHours option:selected').val().replace('+','');
var selectedStats = $('#tuitionStats td:first-child' ).filter( function(index) {
return $(this).text() === selectedCredit;
});
if(selectedStats.length <= 0){
alert('Sorry, we couldn\'t load the information for that number of credit hours. Check our official tuition page at catalog.utahtech.edu/tuitionfees');
}
else{
//var top = $(selectedStats).parent().scrollTop();
$(selectedStats).parent().addClass('open');
}
}
});