Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
fd32da33af
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
250 lines (203 sloc) 7.03 KB
jQuery(document).ready(function($) {
if( $( "#directory-dropdown" ).length > 0 ){
var screenWidthFlag = false; // True if screen width is greater than 767
if( screen.width > 767 ){
screenWidthFlag = true;
$(".directory-face-wrap").each(function(i,el){
var divHeight = $(el).height();
var nameTitle = $(el).find( ".directory-name-title-wrap" );
var nameTitleHeight = nameTitle.height();
if( divHeight > nameTitleHeight ){
nameTitle.css( "padding-top", (divHeight - nameTitleHeight)/2 );
}
});
}
var directory = (function() {
var mod = {};
var directoryList = $("#directory-list");
var loadingText = $("#directory-list-loading-text");
var ajaxReqSettings = {
type: "POST",
url: neag_object.ajaxurl,
timeout: 10000, // 10,000ms = 10s
beforeSend: function(){
loadingText.show();
},
complete: function( jqXHR, textStatus ){
if( textStatus === 'success' ){
loadingText.hide();
} else if( textStatus === 'timeout' ) {
loadingText.text("Request has timed out, please refresh this page");
} else {
loadingText.text("Error: " + textStatus);
}
},
};
mod.setFaculty = function ( data, categoryName ){
ajaxReqSettings.data = data;
ajaxReqSettings.success = function(response){
response = JSON.parse(response);
if( Object.keys(response).length != 0 ){
if( categoryName.indexOf( "Faculty Expert" ) != -1 ){ // User selected specific type of faculty expert
modifyDirectoryList( response, directoryList, true, categoryName );
} else {
modifyDirectoryList( response, directoryList );
}
}
};
$.ajax( ajaxReqSettings );
};
mod.setFacultyExperts = function ( data ) {
ajaxReqSettings.data = data;
ajaxReqSettings.success = function(response){
response = JSON.parse(response);
if( Object.keys(response).length != 0 ){
modifyDirectoryList( response, directoryList, true );
}
};
$.ajax( ajaxReqSettings );
};
function modifyDirectoryList ( response, directoryList, expertsFlag, specificExpertise ){
directoryList.empty();
$.each(response, function(i,v){
var directoryRow = $('<div/>', {
id: v.divid,
class: 'directory-person'
}).appendTo( directoryList );
var topLevelRow = $('<div/>', {
class: 'row'
}).appendTo( directoryRow );
var faceWrap = $('<div />', {
class: 'col-sm-5 directory-face-wrap'
}).appendTo( topLevelRow );
var directoryPhoto = $('<div/>', {
class: 'directory-photo'
}).appendTo( faceWrap ); // add photo to html
$('<a />', {
href: v.permalink,
html: v.photo
}).appendTo( directoryPhoto );
var colNameTitle = $('<div />', {
class: 'directory-name-title-wrap'
}).appendTo( faceWrap );
var directoryName = $('<div />', {
class: 'directory-name'
}).appendTo( colNameTitle );
$('<a />', {
href: v.permalink,
text: v.name
}).appendTo( directoryName );
$('<div />', {
class: 'directory-title',
text: v.title
}).appendTo( colNameTitle );
if( expertsFlag && specificExpertise ){
var expertiseDiv = $('<div />', {
class: 'directory-expertise',
text: specificExpertise
}).appendTo( colNameTitle );
$('<span />', {
class: 'expertise',
text: "Expertise: "
}).prependTo( expertiseDiv );
} else if( expertsFlag ){
var expertiseDiv = $('<div />', {
class: 'directory-expertise',
text: v.expertise
}).appendTo( colNameTitle );
$('<span />', {
class: 'expertise',
text: "Expertise: "
}).prependTo( expertiseDiv );
}
var colPhoneEmail = $('<div />', {
class: 'col-sm-3 directory-contact-wrap'
}).appendTo( topLevelRow );
$('<div />', {
class: 'directory-phone',
text: v.phone
}).appendTo( colPhoneEmail );
var emailDiv = $('<div />', {
class: 'directory-email'
}).appendTo( colPhoneEmail );
var emailLink = $('<a />', {
href: "mailto:"+v.email,
text: v.email
}).appendTo( emailDiv );
var colOffice = $('<div />', {
class: 'col-sm-4 directory-office-wrap'
}).appendTo( topLevelRow );
$('<div />', {
class: 'directory-officeLabel',
text: "Office"
}).appendTo( colOffice );
$('<div />', {
class: 'directory-office',
text: v.office_location
}).appendTo( colOffice );
if( screenWidthFlag ){
var faceWrapHeight = faceWrap.height();
var nameTitleHeight = colNameTitle.height();
if( faceWrapHeight > nameTitleHeight ){
colNameTitle.css( 'padding-top', (faceWrapHeight - nameTitleHeight)/2 );
}
}
});
}
return mod;
}());
var hash = window.location.hash;
if( hash.length > 1 ){
hash = hash.replace( /_/g, ' ' ).substr(1);
var category = $("#directory-dropdownMenu").children( "option:contains('" + hash + "')" );
if( category.length != 0 ){
var categoryID = category[0].value;
$("#directory-dropdownMenu")[0].selectedIndex = category[0].index;
if( categoryID != 0 ){ // categoryID == 0 is All Faculty & Staff, which loads by default
if( categoryID == "faculty-expert" ){
var data = {
'action': 'neag_get_experts',
};
directory.setFacultyExperts( data );
} else {
var data = {
'action': 'neag_get_people',
'categoryID': categoryID
};
directory.setFaculty( data, hash );
}
}
}
}
$("#directory-dropdownMenu").on('change', function(event){
event.preventDefault();
if( this.value == "faculty-expert" ){
var data = {
'action': 'neag_get_experts',
};
directory.setFacultyExperts( data );
} else {
var categoryName = this.options[this.options.selectedIndex].text;
if( this.value != 0 ){
window.location.hash = "#" + categoryName.replace( /\s/g, '_' );
} else {
window.location.hash = "";
}
var data = {
'action': 'neag_get_people',
'categoryID': this.value
};
directory.setFaculty( data, categoryName );
}
});
}
var d = new Date(),
n = d.getMonth()+1,
y = d.getFullYear();
$( ".widget_archives" ).append( "<p><a href='/"+y+"/"+n+"'>Archives &rsaquo;</a></p>" );
$( "#page-news .panel-grid:nth-child(5) .panel-grid-cell:nth-child(1) .widget_siteorigin-panels-postloop" ).append( "<p><a href='/news-archive'>News Archives &rsaquo;</a></p>" );
$("h4.panel-title a").addClass("accordion-closed");
$("h4.panel-title a").click(function() {
$(this).addClass("accordion-open");
});
});