From 1c5f8ba740d91261f547e8b4c58ee7b46ba0c2d4 Mon Sep 17 00:00:00 2001 From: briandunnigan Date: Fri, 11 Mar 2016 11:14:43 -0500 Subject: [PATCH] hot hot fix for people page --- functions.php | 11 +++----- js/custom.js | 63 +++++++++++++++----------------------------- js/min/custom.min.js | 2 +- 3 files changed, 25 insertions(+), 51 deletions(-) diff --git a/functions.php b/functions.php index 0c62b16..a21a53c 100644 --- a/functions.php +++ b/functions.php @@ -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(); @@ -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 ); @@ -89,10 +88,6 @@ function processPosts( $queryPosts, $queryHavePosts, $expertsFlag = false ){ } else { $people[$i]['divid'] = ''; } - - if( $expertsFlag == true ){ - $people[$i]['expertise'] = $fields['expertise']; - } } } diff --git a/js/custom.js b/js/custom.js index 8039367..deaf390 100644 --- a/js/custom.js +++ b/js/custom.js @@ -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 ); } @@ -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); @@ -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){ @@ -112,16 +117,7 @@ jQuery(document).ready(function($) { text: v.title }).appendTo( colNameTitle ); - if( expertsFlag && specificExpertise ){ - var expertiseDiv = $('
', { - class: 'directory-expertise', - text: specificExpertise - }).appendTo( colNameTitle ); - $('', { - class: 'expertise', - text: "Expertise: " - }).prependTo( expertiseDiv ); - } else if( expertsFlag ){ + if( displayExpertiseFlag ){ var expertiseDiv = $('
', { class: 'directory-expertise', text: v.expertise @@ -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 ); } } } @@ -209,6 +196,7 @@ 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 { @@ -216,18 +204,9 @@ jQuery(document).ready(function($) { } 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 ); } }); } diff --git a/js/min/custom.min.js b/js/min/custom.min.js index a95305f..2c62a65 100644 --- a/js/min/custom.min.js +++ b/js/min/custom.min.js @@ -1 +1 @@ -jQuery(document).ready(function(e){if(e("#directory-dropdown").length>0){var t=!1;screen.width>767&&(t=!0,e(".directory-face-wrap").each(function(t,a){var i=e(a).height(),r=e(a).find(".directory-name-title-wrap"),o=r.height();i>o&&r.css("padding-top",(i-o)/2)}));var a=function(){function a(a,i,r,o){i.empty(),e.each(a,function(a,n){var c=e("
",{id:n.divid,"class":"directory-person"}).appendTo(i),s=e("
",{"class":"row"}).appendTo(c),p=e("
",{"class":"col-sm-5 directory-face-wrap"}).appendTo(s),d=e("
",{"class":"directory-photo"}).appendTo(p);e("",{href:n.permalink,html:n.photo}).appendTo(d);var l=e("
",{"class":"directory-name-title-wrap"}).appendTo(p),h=e("
",{"class":"directory-name"}).appendTo(l);if(e("",{href:n.permalink,text:n.name}).appendTo(h),e("
",{"class":"directory-title",text:n.title}).appendTo(l),r&&o){var f=e("
",{"class":"directory-expertise",text:o}).appendTo(l);e("",{"class":"expertise",text:"Expertise: "}).prependTo(f)}else if(r){var f=e("
",{"class":"directory-expertise",text:n.expertise}).appendTo(l);e("",{"class":"expertise",text:"Expertise: "}).prependTo(f)}var u=e("
",{"class":"col-sm-3 directory-contact-wrap"}).appendTo(s);e("
",{"class":"directory-phone",text:n.phone}).appendTo(u);var v=e("
",{"class":"directory-email"}).appendTo(u),y=(e("",{href:"mailto:"+n.email,text:n.email}).appendTo(v),e("
",{"class":"col-sm-4 directory-office-wrap"}).appendTo(s));if(e("
",{"class":"directory-officeLabel",text:"Office"}).appendTo(y),e("
",{"class":"directory-office",text:n.office_location}).appendTo(y),t){var x=p.height(),g=l.height();x>g&&l.css("padding-top",(x-g)/2)}})}var i={},r=e("#directory-list"),o=e("#directory-list-loading-text"),n={type:"POST",url:neag_object.ajaxurl,timeout:1e4,beforeSend:function(){o.show()},complete:function(e,t){"success"===t?o.hide():"timeout"===t?o.text("Request has timed out, please refresh this page"):o.text("Error: "+t)}};return i.setFaculty=function(t,i){n.data=t,n.success=function(e){e=JSON.parse(e),0!=Object.keys(e).length&&(-1!=i.indexOf("Faculty Expert")?a(e,r,!0,i):a(e,r))},e.ajax(n)},i.setFacultyExperts=function(t){n.data=t,n.success=function(e){e=JSON.parse(e),0!=Object.keys(e).length&&a(e,r,!0)},e.ajax(n)},i}(),i=window.location.hash;if(i.length>1){i=i.replace(/_/g," ").substr(1);var r=e("#directory-dropdownMenu").children("option:contains('"+i+"')");if(0!=r.length){var o=r[0].value;if(e("#directory-dropdownMenu")[0].selectedIndex=r[0].index,0!=o)if("faculty-expert"==o){var n={action:"neag_get_experts"};a.setFacultyExperts(n)}else{var n={action:"neag_get_people",categoryID:o};a.setFaculty(n,i)}}}e("#directory-dropdownMenu").on("change",function(e){e.preventDefault();var t=this.options[this.options.selectedIndex].text;if(window.location.hash=0!=this.value?"#"+t.replace(/\s/g,"_"):"","faculty-expert"==this.value){var i={action:"neag_get_experts"};a.setFacultyExperts(i)}else{var i={action:"neag_get_people",categoryID:this.value};a.setFaculty(i,t)}})}var c=new Date,s=c.getMonth()+1,p=c.getFullYear();e(".widget_archives").append("

Archives ›

"),e("#page-news .panel-grid:nth-child(5) .panel-grid-cell:nth-child(1) .widget_siteorigin-panels-postloop").append("

News Archives ›

"),e("h4.panel-title a").addClass("accordion-closed"),e("h4.panel-title a").click(function(){e(this).addClass("accordion-open")})}); \ No newline at end of file +jQuery(document).ready(function(e){if(e("#directory-dropdown").length>0){var t=!1;screen.width>767&&(t=!0,e(".directory-face-wrap").each(function(t,a){var i=e(a).height(),o=e(a).find(".directory-name-title-wrap"),r=o.height();i>r&&o.css("padding-top",(i-r)/2)}));var a=function(){function a(a,i,o){i.empty(),e.each(a,function(a,r){var n=e("
",{id:r.divid,"class":"directory-person"}).appendTo(i),c=e("
",{"class":"row"}).appendTo(n),s=e("
",{"class":"col-sm-5 directory-face-wrap"}).appendTo(c),d=e("
",{"class":"directory-photo"}).appendTo(s);e("",{href:r.permalink,html:r.photo}).appendTo(d);var p=e("
",{"class":"directory-name-title-wrap"}).appendTo(s),l=e("
",{"class":"directory-name"}).appendTo(p);if(e("",{href:r.permalink,text:r.name}).appendTo(l),e("
",{"class":"directory-title",text:r.title}).appendTo(p),o){var h=e("
",{"class":"directory-expertise",text:r.expertise}).appendTo(p);e("",{"class":"expertise",text:"Expertise: "}).prependTo(h)}var u=e("
",{"class":"col-sm-3 directory-contact-wrap"}).appendTo(c);e("
",{"class":"directory-phone",text:r.phone}).appendTo(u);var f=e("
",{"class":"directory-email"}).appendTo(u),v=(e("",{href:"mailto:"+r.email,text:r.email}).appendTo(f),e("
",{"class":"col-sm-4 directory-office-wrap"}).appendTo(c));if(e("
",{"class":"directory-officeLabel",text:"Office"}).appendTo(v),e("
",{"class":"directory-office",text:r.office_location}).appendTo(v),t){var y=s.height(),g=p.height();y>g&&p.css("padding-top",(y-g)/2)}})}var i={},o=e("#directory-list"),r=e("#directory-list-loading-text"),n={type:"POST",url:neag_object.ajaxurl,timeout:1e4,beforeSend:function(){r.show()},complete:function(e,t){"success"===t?r.hide():"timeout"===t?r.text("Request has timed out, please refresh this page"):r.text("Error: "+t)}};return i.setFaculty=function(t,i){n.data={action:"neag_get_people",categoryID:t},n.success=function(e){e=JSON.parse(e),0!=Object.keys(e).length&&(-1!=i.indexOf("Faculty Expert")?a(e,o,!0):a(e,o))},e.ajax(n)},i.setFacultyExperts=function(){n.data={action:"neag_get_experts"},n.success=function(e){e=JSON.parse(e),0!=Object.keys(e).length&&a(e,o,!0)},e.ajax(n)},i}(),i=window.location.hash;if(i.length>1){i=i.replace(/_/g," ").substr(1);var o=e("#directory-dropdownMenu").children("option:contains('"+i+"')");if(0!=o.length){e("#directory-dropdownMenu")[0].selectedIndex=o[0].index;var r=o[0].value;0!=r&&("faculty-expert"==r?a.setFacultyExperts():a.setFaculty(r,i))}}e("#directory-dropdownMenu").on("change",function(e){e.preventDefault();var t=this.options[this.options.selectedIndex].text;window.location.hash=0!=this.value?"#"+t.replace(/\s/g,"_"):"","faculty-expert"==this.value?a.setFacultyExperts():a.setFaculty(this.value,t)})}var n=new Date,c=n.getMonth()+1,s=n.getFullYear();e(".widget_archives").append("

Archives ›

"),e("#page-news .panel-grid:nth-child(5) .panel-grid-cell:nth-child(1) .widget_siteorigin-panels-postloop").append("

News Archives ›

"),e("h4.panel-title a").addClass("accordion-closed"),e("h4.panel-title a").click(function(){e(this).addClass("accordion-open")})}); \ No newline at end of file