Changeset 778d53d in OpenWorkouts-current for ow/static


Ignore:
Timestamp:
Mar 5, 2019, 11:45:32 PM (5 years ago)
Author:
Borja Lopez <borja@…>
Branches:
current
Children:
aa6dcaf
Parents:
35953eb
Message:

(#7) Show per-sport stats in the profile page:

  • Show a dropdown list of sports for which the user has activities. By default we choose the sport with most activities.
  • Show a dropdown list of years for which the user has activities. By default we show stats for the current year. If the user picks up a different year, we show the totals (distance, time, elevation, number of workouts) for that year.
  • Show the totals of all time for the chosen sport
Location:
ow/static
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • ow/static/css/main.css

    r35953eb r778d53d  
    642642  background-color: #EE4056;
    643643}
     644/*
     645Very simple way to paint dropdown-like arrows, without
     646using any external dependencies.
     647
     648To use it, add something like this to your html, to display a "down" arrow:
     649
     650  <i class="arrow down"></i>
     651*/
     652i.arrow {
     653  border: solid black;
     654  border-width: 0 3px 3px 0;
     655  display: inline-block;
     656  padding: 3px;
     657  margin: 3px;
     658  margin-left: 6px;
     659  margin-right: 0px;
     660}
     661.right {
     662  transform: rotate(-45deg);
     663  -webkit-transform: rotate(-45deg);
     664}
     665.left {
     666  transform: rotate(135deg);
     667  -webkit-transform: rotate(135deg);
     668}
     669.up {
     670  transform: rotate(-135deg);
     671  -webkit-transform: rotate(-135deg);
     672}
     673.down {
     674  transform: rotate(45deg);
     675  -webkit-transform: rotate(45deg);
     676}
    644677.header-content {
    645678  padding: 1em 1.5em;
     
    14881521  font-size: 13px;
    14891522  font-size: 0.8125rem;
     1523}
     1524.profile-dropdown-sports,
     1525.profile-dropdown-years {
     1526  color: #151515;
     1527  text-decoration: none;
     1528}
     1529.profile-dropdown-sports:hover,
     1530.profile-dropdown-years:hover {
     1531  color: #151515;
     1532}
     1533.profile-dropdown-sports:active,
     1534.profile-dropdown-years:active,
     1535.profile-dropdown-sports:focus,
     1536.profile-dropdown-years:focus {
     1537  outline: 0;
     1538  border: none;
     1539  -moz-outline-style: none;
    14901540}
    14911541.verify-account-content {
  • ow/static/js/ow.js

    r35953eb r778d53d  
    486486
    487487};
     488
     489
     490owjs.sport_stats = function(spec) {
     491
     492    "use strict";
     493
     494    var link_selector = spec.link_selector;
     495    var stats_selector = spec.stats_selector;
     496    var selected = spec.selected;
     497    var dropdown_selector = spec.dropdown_selector;
     498    var current_year = spec.current_year;
     499    var year_link_selector = spec.year_link_selector;
     500
     501    var setup = function setup() {
     502        // Hide all sports stats by default
     503        $(stats_selector).hide();
     504        // Show the pre-selected one
     505        $(selected).show();
     506
     507        $(link_selector).on('click', function(e) {
     508            e.preventDefault();
     509            var selected = $(this).attr('class').split(' ')[1];
     510            var sport = selected.split('-')[1]
     511            // Hide them all
     512            $(stats_selector).hide();
     513            // Show the selected one
     514            $(stats_selector + '.' + selected).show();
     515            // Update the sport on the sports selector widget
     516            $(dropdown_selector + ' strong').html(sport);
     517            // finally "click" on the proper year to be displayed for this sport
     518            $(year_link_selector + sport + '-' + current_year).click();
     519        });
     520    };
     521
     522    var that = {}
     523    that.setup = setup;
     524    return that
     525
     526};
     527
     528
     529owjs.year_stats = function(spec) {
     530
     531    "use strict";
     532
     533    var link_selector = spec.link_selector;
     534    var stats_selector = spec.stats_selector;
     535    var selected = spec.selected;
     536    var dropdown_selector = spec.dropdown_selector;
     537
     538    var setup = function setup() {
     539        // Hide all years stats by default
     540        $(stats_selector).hide();
     541        // Show the pre-selected one
     542        $(selected).show();
     543
     544        $(link_selector).on('click', function(e) {
     545            e.preventDefault();
     546            var selected = $(this).attr('class').split(' ')[1];
     547            var sport = selected.split('-')[1]
     548            var year = selected.split('-')[2]
     549            // Hide them all
     550            $(stats_selector).hide();
     551            // Show the selected one
     552            $(stats_selector + '.' + selected).show();
     553            // Update the year on the years selector widget
     554            $(dropdown_selector + sport + ' strong').html(year);
     555        });
     556    };
     557
     558    var that = {}
     559    that.setup = setup;
     560    return that
     561
     562};
  • ow/static/less/main.less

    r35953eb r778d53d  
    2323@import "ui/form.less";
    2424@import "ui/buttons.less";
     25@import "ui/arrows.less";
    2526
    2627// Modules
  • ow/static/less/pages/profile.less

    r35953eb r778d53d  
    128128        }
    129129}
     130
     131.profile-dropdown-sports,
     132.profile-dropdown-years {
     133    color: @color-main;
     134    text-decoration: none;
     135    &:hover {
     136        color: @color-main;
     137    }
     138    &:active, &:focus {
     139        outline: 0;
     140        border: none;
     141        -moz-outline-style: none;
     142    }
     143}
Note: See TracChangeset for help on using the changeset viewer.