Changeset 39dc0a6 in OpenWorkouts-current for ow


Ignore:
Timestamp:
Mar 12, 2019, 11:20:44 PM (5 years ago)
Author:
Borja Lopez <borja@…>
Branches:
current
Children:
e52a502
Parents:
3ac70ca
Message:

(#7) Pass in the selector name for the calendar heatmap tooltip container
when building an "instance" of the calendar chart code.

(#7) Fixed a bug in the fade in/out of the heatmap tooltip (tooltip display
were queued so the tooltip keep fading in and out for a while after the
user did stop moving around on the chart)

Location:
ow
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ow/static/js/ow.js

    r3ac70ca r39dc0a6  
    464464
    465465    var chart_selector = spec.chart_selector,
     466        tooltip_selector = spec.tooltip_selector,
    466467        url = spec.url,
    467468        day_names_list = spec.day_names_list;
     
    491492
    492493        // Hide the tooltip
    493         $('.js-calendar-heatmap-tooltip').hide()
     494        $(tooltip_selector).hide()
    494495
    495496        var chart = d3.select(chart_selector);
     
    594595                    d3.select(this).classed('hover', true);
    595596                    var day = find_day(d);
    596                     $('.js-ch-tooltip-date').html(titleFormat(new Date(d)));
     597                    $(tooltip_selector + '-date').html(titleFormat(new Date(d)));
    597598                    if (day != undefined) {
    598                         $('.js-ch-tooltip-workouts').html(day.workouts);
    599                         $('.js-ch-tooltip-time').html(day.time_formatted);
    600                         $('.js-ch-tooltip-distance').html(day.distance_formatted);
    601                         $('.js-ch-tooltip-elevation').html(day.elevation_formatted);
     599                        $(tooltip_selector + '-workouts').html(day.workouts);
     600                        $(tooltip_selector + '-time').html(day.time_formatted);
     601                        $(tooltip_selector + '-distance').html(day.distance_formatted);
     602                        $(tooltip_selector + '-elevation').html(day.elevation_formatted);
    602603                    }
    603604                    else {
    604                         $('.js-ch-tooltip-workouts').html(' - ');
    605                         $('.js-ch-tooltip-time').html(' - ');
    606                         $('.js-ch-tooltip-distance').html(' - ');
    607                         $('.js-ch-tooltip-elevation').html(' - ');
    608                     }
    609                     $('.js-calendar-heatmap-tooltip').fadeIn('fast');
     605                        $(tooltip_selector + '-workouts').html(' - ');
     606                        $(tooltip_selector + '-time').html(' - ');
     607                        $(tooltip_selector + '-distance').html(' - ');
     608                        $(tooltip_selector + '-elevation').html(' - ');
     609                    }
     610                    $(tooltip_selector).stop( true, true ).fadeIn('fast');
    610611                })
    611612                .on("mouseout", function(d) {
    612613                    d3.select(this).classed('hover', false);
    613                     $('.js-calendar-heatmap-tooltip').fadeOut('fast');
     614                    $(tooltip_selector).stop( true, true ).fadeOut('fast');
    614615                })
    615616                .datum(format);
  • ow/templates/profile.pt

    r3ac70ca r39dc0a6  
    5353          <div class="calendar-heatmap js-calendar-heatmap">
    5454          </div>
    55           <div class="calendar-heatmap-tooltip js-calendar-heatmap-tooltip">
     55          <div class="calendar-heatmap-tooltip js-ch-tooltip">
    5656            <ul class="profile-data">
    5757              <li>
     
    489489     var heatmap_chart = owjs.calendar_heatmap_chart({
    490490         chart_selector: 'div.js-calendar-heatmap',
     491         tooltip_selector: '.js-ch-tooltip',
    491492         url: "${request.resource_url(user, 'month')}",
    492493         // Trick to have all those shortened day names translated
Note: See TracChangeset for help on using the changeset viewer.