Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
hot hot fix for people page
  • Loading branch information
briandunnigan authored and briandunnigan committed Mar 11, 2016
1 parent ccdd6b5 commit 1c5f8ba
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 51 deletions.
11 changes: 3 additions & 8 deletions functions.php
Expand Up @@ -54,10 +54,8 @@ function neag_sort_by_last_then_first( $a, $b ){
function processPosts( $queryPosts, $queryHavePosts, $expertsFlag = false ){
usort( $queryPosts, 'neag_sort_by_last_then_first' );

$fields = array( 'first_name' => '', 'middle_name' => '', 'last_name' => '', 'title' => '', 'email' => '', 'phone' => '', 'office_location' => '' );
if( $expertsFlag == true ){
$fields['expertise'] = '';
}
$fields = array( 'first_name' => '', 'middle_name' => '', 'last_name' => '', 'title' => '', 'email' => '', 'phone' => '', 'office_location' => '', 'expertise' => '' );

$alphabet = array_fill_keys( range('A', 'Z'), '' );

$people = array();
Expand All @@ -76,6 +74,7 @@ function processPosts( $queryPosts, $queryHavePosts, $expertsFlag = false ){
$people[$i]['email'] = $fields['email'];
$people[$i]['office_location'] = $fields['office_location'];
$people[$i]['photo'] = get_the_post_thumbnail( $id, array(115, 115) );
$people[$i]['expertise'] = $fields['expertise'];

$nameLetter = substr( $fields['last_name'], 0, 1 );

Expand All @@ -89,10 +88,6 @@ function processPosts( $queryPosts, $queryHavePosts, $expertsFlag = false ){
} else {
$people[$i]['divid'] = '';
}

if( $expertsFlag == true ){
$people[$i]['expertise'] = $fields['expertise'];
}
}
}

Expand Down
63 changes: 21 additions & 42 deletions js/custom.js
Expand Up @@ -39,15 +39,18 @@ jQuery(document).ready(function($) {
},
};

mod.setFaculty = function ( data, categoryName ){
ajaxReqSettings.data = data;
mod.setFaculty = function ( categoryID, categoryName ){
ajaxReqSettings.data = {
'action': 'neag_get_people',
'categoryID': categoryID
};

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 );
modifyDirectoryList( response, directoryList, true );
} else {
modifyDirectoryList( response, directoryList );
}
Expand All @@ -57,8 +60,10 @@ jQuery(document).ready(function($) {
$.ajax( ajaxReqSettings );
};

mod.setFacultyExperts = function ( data ) {
ajaxReqSettings.data = data;
mod.setFacultyExperts = function () {
ajaxReqSettings.data = {
'action': 'neag_get_experts',
};

ajaxReqSettings.success = function(response){
response = JSON.parse(response);
Expand All @@ -70,7 +75,7 @@ jQuery(document).ready(function($) {
$.ajax( ajaxReqSettings );
};

function modifyDirectoryList ( response, directoryList, expertsFlag, specificExpertise ){
function modifyDirectoryList ( response, directoryList, displayExpertiseFlag ){
directoryList.empty();

$.each(response, function(i,v){
Expand Down Expand Up @@ -112,16 +117,7 @@ jQuery(document).ready(function($) {
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 ){
if( displayExpertiseFlag ){
var expertiseDiv = $('<div />', {
class: 'directory-expertise',
text: v.expertise
Expand Down Expand Up @@ -182,24 +178,15 @@ jQuery(document).ready(function($) {
var category = $("#directory-dropdownMenu").children( "option:contains('" + hash + "')" );

if( category.length != 0 ){
var categoryID = category[0].value;

$("#directory-dropdownMenu")[0].selectedIndex = category[0].index;

var categoryID = category[0].value;

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.setFacultyExperts();
} else {
directory.setFaculty( categoryID, hash );
}
}
}
Expand All @@ -209,25 +196,17 @@ jQuery(document).ready(function($) {
event.preventDefault();

var categoryName = this.options[this.options.selectedIndex].text;

if( this.value != 0 ){
window.location.hash = "#" + categoryName.replace( /\s/g, '_' );
} else {
window.location.hash = "";
}

if( this.value == "faculty-expert" ){
var data = {
'action': 'neag_get_experts',
};

directory.setFacultyExperts( data );
} else {
var data = {
'action': 'neag_get_people',
'categoryID': this.value
};

directory.setFaculty( data, categoryName );
directory.setFacultyExperts();
} else {
directory.setFaculty( this.value, categoryName );
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion js/min/custom.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1c5f8ba

Please sign in to comment.