Skip to content

Commit

Permalink
Adds profiles JS events
Browse files Browse the repository at this point in the history
so that sites/themes can add their own functionality if needed:

- "profiles:fetching"
- "profiles:fetched"
- "profiles:filtering"
- "profiles:filtered"
  • Loading branch information
wunc committed Feb 15, 2022
1 parent 4aaf070 commit 448b916
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions public/js/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ var profile_reader = (function($, undefined) {
$support_section[persons[i]] = $profile_container.find('#' + escaped_person + ' .profile-support');
$awards_section[persons[i]] = $profile_container.find('#' + escaped_person + ' .profile-awards');
}
$profile_template.hide()
$profile_template.hide();
$profile_container.trigger('profiles:fetching');
this.get(api_url);
}
};
Expand Down Expand Up @@ -160,6 +161,7 @@ var profile_reader = (function($, undefined) {
// Handle the returned API results
var handleResults = function(results) {
if (typeof results === 'object' && results.hasOwnProperty('profile')) {
$profile_container.trigger('profiles:fetched', results);
for (var k = 0; k < results.profile.length; k++) {
setPublications(results.profile[k]);

Expand Down Expand Up @@ -243,11 +245,13 @@ jQuery(document).ready(function($) {
});

$('.filter-selector').on('change', function(){
var container = $(this).parents('.profiles-plugin.profiles-container')
var container = $(this).parents('.profiles-plugin.profiles-container');
container.trigger('profiles:filtering', this.value);
container.find('.profiles-plugin.profile').show();
if(this.value){
container.find('.profiles-plugin.profile:not(.' + this.value + ')').hide();
}
container.trigger('profiles:filtered', this.value);
});

});

0 comments on commit 448b916

Please sign in to comment.