Find a Top Music Teacher

Loading Teachers Directory...

Sending...

'; }); osmul_members_list.append(html); // Update members shown count osmul_results_count.html('Showing ' + Object.keys(members).length); // Once done, show the list osmul_members_list.slideDown("slow"); } // Helper function to create the html for a member card function memberCard(member) { var location = ''; if (member.city) location = member.city+', '; if (member.state && (member.state !== member.city)) location += member.state+', '; if (member.country) location += member.country; if (location === '') location = 'Show on map'; return '' + '' + '' + '' + '
' + '' + //'' + member.rank + '' + '' + '' + member.name + '' + //''+member.studio_name+''+ //''+member.studio_description+''+ '' + '' + ' ' + location + '' + '' + '' + //'' + '' + '
'; } /* setup teacher profile modal */ function setupTeacherProfile(member_id) { var member = osmul_members[member_id]; var member_styles = ''; jQuery.each(member.style, function(){ member_styles += '
  • '+osmul_styles[this].name+'
  • '; }); resetAvailabilityTable(); jQuery.each(member.availability, function(){ jQuery("#osmul-teacher-"+this).html(''); }); var location = ''; if (member.country) location = member.country; if (member.state) location += ', '+member.state; if (location === '') location = 'Show on map'; var button = 'Get in touch'; jQuery("#osmul-teacher-avatar").html(''); jQuery("#osmul-teacher-rate").html(member.rate); jQuery("#osmul-teacher-name").html(member.name); jQuery("#osmul-teacher-location").html(location); jQuery("#osmul-teacher-qualifications").html(member.qualifications); jQuery("#osmul-teacher-subjects").html(member_styles); jQuery("#osmul-teacher-first-button").html(button); jQuery("#osmul-teacher-second-button").html(button); } // Helper function to reset the availability table in teacher profile function resetAvailabilityTable() { jQuery('.osmul-availability-flush').html(' '); } /* Get In Touch Modal Setup */ function setupTeacherModal(id) { jQuery("#teacher_id").val(id); jQuery("#osmul-modal-label").html('Get in Touch with '+osmul_members[id].name); } /* Get In Touch Form Submission Action */ // Prevent Default Form Submission jQuery("#teacher-contact").on('submit', function(e) { e.preventDefault(); if (!osmul_busy) { osmul_busy = true; osmul_message_loader.fadeIn(); // Send TopMusicPro Message through Ajax jQuery.post(osmul_ajax_url, { 'action': 'teacher_directory_send_message', 'data': { 'teacher_id': jQuery("#teacher_id").val(), 'name': jQuery("#name").val(), 'email': jQuery("#email").val(), 'phone': jQuery("#phone").val(), 'message': jQuery("#message").val() } }, function (response) { console.log(response); if (response === 'Your message was delivered!') { jQuery('#dismiss-contact-teacher-modal-button').click(); } osmul_message_feedback.html(" "+response); osmul_message_in_progress.slideUp('slow', function() { osmul_message_complete.slideDown('slow'); }); osmul_busy = false; }); } return false; }); function dismissMessageLoaderFeedback() { osmul_message_complete.slideUp('slow', function() { osmul_message_feedback.html(''); osmul_message_loader.fadeOut('fast', function() { osmul_message_in_progress.toggle(); }); }); } // filters // Helper function to check if 2 arrays have common values function hasCommonElement(arr1,arr2) { var bExists = false; jQuery.each(arr2, function(index, value){ if(jQuery.inArray(value,arr1)!==-1){ console.log(value); bExists = true; } if(bExists){ return false; //break } }); return bExists; } function updateFiltersSetup() { var styles = []; jQuery('input.osmul-style-checkbox:checkbox:checked').each(function () { styles.push(jQuery(this).val()); }); var availability = []; jQuery('input.osmul-availability-checkbox:checkbox:checked').each(function () { availability.push(jQuery(this).val()); }); osmul_filters_setup = {'styles':styles,'availability':availability}; if (osmul_filters_setup.styles.length !== 0) { jQuery("#osmul-filter-styles-button") .removeClass('btn-secondary') .addClass('btn-primary') .html('Styles '+osmul_filters_setup.styles.length+''); } else { jQuery("#osmul-filter-styles-button") .removeClass('btn-primary') .addClass('btn-secondary') .html('Styles'); } if (osmul_filters_setup.availability.length !== 0) { jQuery("#osmul-filter-availability-button") .removeClass('btn-secondary') .addClass('btn-primary') .html('Availability '+osmul_filters_setup.availability.length+''); } else { jQuery("#osmul-filter-availability-button") .removeClass('btn-primary') .addClass('btn-secondary') .html('Availability'); } } // Search for members using a keyword and displays results function osmulFilter() { updateFiltersSetup(); // Init results object var results = {}; // Hide the current members grid, on complete perform search osmul_members_list.slideUp("slow", function() { // Only search if no other action is in the way if (!osmul_busy) { // Update members shown count and lock form input osmul_results_count.html('Showing 0'); osmul_submit.attr("disabled", true).fadeTo( "fast" , 0.3); osmul_spinner.fadeIn(); osmul_busy = true; // Foreach search term, check if keyword is found within // the name, address, state or country // Skip keywords that are less then 2 chars long jQuery.each(osmul_results, function (id, member) { // If both filters are active if (osmul_filters_setup.styles.length !== 0 && osmul_filters_setup.availability.length !== 0) { if ( hasCommonElement(osmul_filters_setup.styles,member.style) && hasCommonElement(osmul_filters_setup.availability,member.availability) ) { results[member.ID] = member; } // If only availability filter is active } else if (osmul_filters_setup.styles.length === 0 && osmul_filters_setup.availability.length !== 0) { if (hasCommonElement(osmul_filters_setup.availability, member.availability)) { results[member.ID] = member; } // If only style filter is active } else if (osmul_filters_setup.styles.length !== 0 && osmul_filters_setup.availability.length === 0) { if (hasCommonElement(osmul_filters_setup.styles,member.style)) { results[member.ID] = member; } // If both filters are not active } else { results[member.ID] = member; } }); // Once search is done, populate the list populateMembersList(results); osmul_filtered = results; // Unlock user interaction osmul_busy = false; osmul_spinner.fadeOut(); osmul_submit.attr("disabled", false).fadeTo("fast", 1); jQuery(".close").click(); } }); } // Prevent Default Form Submission jQuery(".osmul-member-filter").on('submit', function(e) { e.preventDefault(); osmulFilter(); return false; }); // Reset Filters jQuery('#osmul-availability-reset').on('click', function (){ var checkbox = jQuery('input.osmul-availability-checkbox'); checkbox.each(function() { jQuery(this).prop( "checked", false ); }); osmulFilter(); jQuery("#osmul-availability-close").click(); }); jQuery('#osmul-styles-reset').on('click', function (){ var checkbox = jQuery('input.osmul-style-checkbox'); checkbox.each(function() { jQuery(this).prop( "checked", false ); }); osmulFilter(); jQuery("#osmul-styles-close").click(); });