/* Escape Velocity by HTML5 UP html5up.net | @ajlkn Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) */ (function($) { skel .breakpoints({ desktop: '(min-width: 737px)', tablet: '(min-width: 737px) and (max-width: 1200px)', mobile: '(max-width: 736px)' }) .viewport({ breakpoints: { tablet: { width: 1080 } } }); $(function() { var $window = $(window), $body = $('body'); // Disable animations/transitions until the page has loaded. $body.addClass('is-loading'); $window.on('load', function() { $body.removeClass('is-loading'); }); // Fix: Placeholder polyfill. $('form').placeholder(); // CSS polyfills (IE<9). if (skel.vars.IEVersion < 9) $(':last-child').addClass('last-child'); // Prioritize "important" elements on mobile. skel.on('+mobile -mobile', function() { $.prioritize( '.important\\28 mobile\\29', skel.breakpoint('mobile').active ); }); // Dropdowns. $('#nav > ul').dropotron({ mode: 'fade', noOpenerFade: true, alignment: 'center', detach: false }); // Off-Canvas Navigation. // Title Bar. $( '
' + ''+'Menu'+'' + '
' ) .appendTo($body); // Navigation Panel. $( '' ) .appendTo($body) .panel({ delay: 500, hideOnClick: true, hideOnSwipe: true, resetScroll: true, resetForms: true, side: 'left', target: $body, visibleClass: 'navPanel-visible' }); // Fix: Remove navPanel transitions on WP<10 (poor/buggy performance). if (skel.vars.os == 'wp' && skel.vars.osVersion < 10) $('#titleBar, #navPanel, #page-wrapper') .css('transition', 'none'); }); })(jQuery); jQuery(document).ready(function() { jQuery(".tabs-menu a").click(function(event) { event.preventDefault(); jQuery(this).parent().addClass("current"); jQuery(this).parent().siblings().removeClass("current"); var tab = jQuery(this).attr("href"); jQuery(".tab-content").not(tab).css("display", "none"); jQuery(tab).fadeIn(); }); jQuery('.top-lists-menu > li > a').click(function(e) { e.preventDefault(); jQuery(this).next().slideToggle(); }); jQuery('.top-lists-menu li li a').click(function(e) { e.preventDefault(); jQuery('.top-lists-menu li li a').removeClass('active'); jQuery(this).addClass('active'); // Must load ajax content here discipline_id = jQuery(this).data('id'); year = jQuery('#top-lists').data('year'); season = jQuery('#top-lists .tabs-menu .current a').data('season'); gender = jQuery(this).data('gender'); genderTitle = (gender=='m')? 'hommes' : 'femmes'; title = jQuery(this).html() + ' ' + genderTitle; parentTabContent = jQuery(this).parents('.tab-content'); loadDisciplineTopList(discipline_id, year, season, gender, title, parentTabContent); return false; }); jQuery('#best-results-more-button').click(function(e) { more_button = jQuery(this); counter = more_button.data('counter'); year = jQuery('#best-results').data('year'); season_id = jQuery('#best-results').data('season-id'); count = (counter+1) * 50; // Change here if more than 50 new items jQuery.ajax({ dataType: "html", url: '/ajax/resultsPerYear.php', data: { top_results: true, year: year, season_id: season_id, count: count }, success: function(data, textStatus, jqXHR) { jQuery('#best-results tbody').html(data); // Increase counter more_button.data('counter', counter+1); } }); return false; }); jQuery(document).on('click', '#results-per-discipline-show-all-button', function() { season_id = jQuery('#results_per_discipline_container').data('season-id'); discipline_id = jQuery('#results_per_discipline_container').data('discipline-id'); loadAllResultsForDiscipline(season_id, discipline_id, true) return false; }); // Load default top lists loadDefaultDiscipline(469, '100 m', 'outdoor', 'm'); loadDefaultDiscipline(441, '60 m', 'indoor', 'm') if(jQuery(window).width()<736) { jQuery('#top-lists h2').click(function(e){ e.preventDefault; jQuery('.top-lists-menu-container').show(); return false; }); // Change best results td order jQuery('.best-results tr').find('td:eq(1)').each(function() { jQuery(this).insertBefore(jQuery(this).prev()); }); } // Check if mobile var is_mobile = false; if( $('#titleBar').css('display')!='none') { is_mobile = true; jQuery('html').addClass('mobile'); } updateImgPathForMobile(is_mobile); }); // Autocomplete fields jQuery('#myAthleteProfile').autocomplete({ serviceUrl: '/ajax/autocomplete/athletes.php', onSelect: function (suggestion) { // Load table with athlete's information displayAthleteInformationLine(suggestion.data); } }); jQuery('#athleteField, #opponentField').autocomplete({ serviceUrl: '/ajax/autocomplete/athletes.php', onSelect: function (suggestion) { jQuery(this).attr('data-id', suggestion.data); } }); jQuery('#athleteProfile').autocomplete({ serviceUrl: '/ajax/autocomplete/athletes.php', onSelect: function (suggestion) { ga('send', 'event', { eventCategory: 'Access athlete profile', eventAction: 'click', eventLabel: 'Id:'+suggestion.data }); window.location = 'athlete.php?id='+suggestion.data; } }); function displayAthleteInformationLine(athlete_id) { // load athlete information jQuery.ajax({ dataType: "html", url: '/ajax/athleteData.php', data: { athlete_id: athlete_id, function: 'listing' }, success: function(data, textStatus, jqXHR) { athleteInformation = JSON.parse(data); var html = "

"+ 'Is it really you?' +"

"; html += "
" + athleteInformation.name + "" +athleteInformation.birthDate + "" + athleteInformation.club + "" + athleteInformation.gender + "
"; html += ''; jQuery('#athlete-profile').html(html); } }); } function showFirstLinesOfTable(parentTab, nbLines) { var trs = parentTab.find(".top-list tbody tr"); var btnMore = parentTab.find("#seeMoreRecords"); var trsLength = trs.length; var currentIndex = nbLines; trs.hide(); trs.slice(0, nbLines).show(); btnMore.click(function (e) { e.preventDefault(); trs.slice(0, trsLength).show(); btnMore.hide(); }); } function loadDisciplineTopList(discipline_id, year, season, gender, title, parentTabContent) { jQuery.ajax({ dataType: "html", url: '/ajax/disciplineData.php', data: { discipline_id: discipline_id, year: year, season: season, gender: gender, all_results: false, swiss_only: false }, success: function(data, textStatus, jqXHR) { html = '

'+ title +'

'; parentTabContent.find('.top-list-results').html(html + data); showFirstLinesOfTable(parentTabContent, 30) } }); if(jQuery(window).width()<736) { jQuery('.top-lists-menu-container').hide(); } } function loadDefaultDiscipline(discipline_id, discipline_title, season, gender) { year = jQuery('#top-lists').data('year'); genderTitle = (gender=='m')? 'hommes' : 'femmes'; title = discipline_title + ' ' + genderTitle; parentTabContent = jQuery('#tab-'+season); loadDisciplineTopList(discipline_id, year, season, gender, title, parentTabContent); } /* function loadResultsPerYear() { season_id = jQuery('input[name=results_per_year_meetingType]:checked').val(); discipline_id = jQuery('#results_per_year_discipline option:selected').val(); year = jQuery('.results_per_year_change_year.active').val(); jQuery.ajax({ url: '../ajax/resultsPerYear.php', data: { athlete_id: jQuery('#athletes').data('athlete-id'), season_id: season_id, discipline_id: discipline_id, year: year }, success: function(data) { jQuery('#results_per_year_container').html(data); drawYearlyProgressionCharts(); } }); }*/ function loadAllResultsForDiscipline(season_id, discipline_id, show_all) { count = (show_all)? false : 10; jQuery.ajax({ url: '../ajax/resultsPerDiscipline.php', data: { athlete_id: jQuery('#athletes').data('athlete-id'), season_id: season_id, discipline_id: discipline_id, count: count }, success: function(data) { jQuery('#results_per_discipline_container') .html(data) .data('season-id', season_id) .data('discipline-id', discipline_id); if(!show_all) { jQuery('html, body').animate({ scrollTop: jQuery("#results_per_discipline_container").offset().top }, 1500); } } }); } function loadResults(season_id, discipline_id, year) { jQuery.ajax({ url: '../ajax/resultsPerYear.php', data: { athlete_id: jQuery('#athletes').data('athlete-id'), season_id: season_id, discipline_id: discipline_id, year: year }, success: function(data) { jQuery('#results_per_year_container').html(data); drawYearlyProgressionCharts(); jQuery('html, body').animate({ scrollTop: jQuery("#results_per_year_container").offset().top }, 1500); } }); } function loadDisciplinesPerSeason(season) { firstSelected = false; if(season == 'indoor') { jQuery.each(jQuery('#results_per_year_discipline option'), function(key, val){ if(jQuery(this).text().indexOf('indoor') >-1) { if(!firstSelected) {jQuery(this).prop('selected', true); firstSelected = true;} jQuery(this).show(); } else { jQuery(this).hide(); } }); } else { jQuery.each(jQuery('#results_per_year_discipline option'), function(key, val){ if(jQuery(this).text().indexOf('indoor') == -1) { if(!firstSelected) {jQuery(this).prop('selected', true); firstSelected = true;} jQuery(this).show(); } else { jQuery(this).hide(); } }); } // Select first one //jQuery('#results_per_year_discipline option').not(':hidden').eq(0).prop('selected', true); } function updateImgPathForMobile(isMobile) { if(isMobile) { jQuery('img.fit').each(function(){ imgSrc = jQuery(this).attr('src'); jQuery(this).attr('src', imgSrc.replace('/images/athletes/', '/images/athletes/mobile/')); }); } } function getParameterByName(name, url) { if (!url) url = window.location.href; name = name.replace(/[\[\]]/g, "\\$&"); var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), results = regex.exec(url); if (!results) return null; if (!results[2]) return ''; return decodeURIComponent(results[2].replace(/\+/g, " ")); } function scrollToElement(elemId) { jQuery([document.documentElement, document.body]).animate({ scrollTop: jQuery(elemId).offset().top }, 1000); }