diff --git a/rowers/plannedsessions.py b/rowers/plannedsessions.py index da035b17..6428378e 100644 --- a/rowers/plannedsessions.py +++ b/rowers/plannedsessions.py @@ -32,6 +32,34 @@ import courses from rowers.tasks import handle_check_race_course +def get_todays_micro(plan): + thismicro = None + + thismacro = TrainingMacroCycle.objects.filter( + plan=plan, + startdate__lte = date.today(), + enddate__gte = date.today() + ) + + if thismacro: + thismeso = TrainingMesoCycle.objects.filter( + plan=thismacro[0], + startdate__lte = date.today(), + enddate__gte = date.today() + ) + + if thismeso: + thismicro = TrainingMicroCycle.objects.filter( + plan=thismeso[0], + startdate__lte = date.today(), + enddate__gte = date.today() + ) + + if thismicro: + thismicro = thismicro[0] + + return thismicro + # Low Level functions - to be called by higher level methods def add_workouts_plannedsession(ws,ps,r): result = 0 diff --git a/rowers/templates/menu_analytics.html b/rowers/templates/menu_analytics.html index 7c3557c6..ba495712 100644 --- a/rowers/templates/menu_analytics.html +++ b/rowers/templates/menu_analytics.html @@ -71,6 +71,7 @@ {% if user.is_authenticated and user|is_manager %}

 

+{% if user|team_members %} {% endif %} +{% endif %} diff --git a/rowers/templates/menu_plan.html b/rowers/templates/menu_plan.html index 70cd7191..018fd7d7 100644 --- a/rowers/templates/menu_plan.html +++ b/rowers/templates/menu_plan.html @@ -13,6 +13,13 @@  Manage Plans + {% for plan in rower|trainingplans %} +
  • + +  {{ plan.name }} + +
  • + {% endfor %}
  • @@ -63,9 +70,70 @@
  • +

     

    + + + + {% if user.is_authenticated and user|is_manager %}

     

    +{% if user|team_members %} {% endif %} +{% endif %} diff --git a/rowers/templates/menu_profile.html b/rowers/templates/menu_profile.html index 88c78261..8bcdfc7c 100644 --- a/rowers/templates/menu_profile.html +++ b/rowers/templates/menu_profile.html @@ -31,7 +31,7 @@ {% if user.is_authenticated and user|is_manager %}

     

    - +{% if user|team_members %} {% endif %} +{% endif %} diff --git a/rowers/templates/menu_workouts.html b/rowers/templates/menu_workouts.html index 0370e37a..54f1189c 100644 --- a/rowers/templates/menu_workouts.html +++ b/rowers/templates/menu_workouts.html @@ -40,7 +40,7 @@ {% if user.is_authenticated and user|is_manager %}

     

    - +{% if user|team_members %| {% endif %} +{% endif %} diff --git a/rowers/templates/trainingplan.html b/rowers/templates/trainingplan.html index cc17460f..f62ab943 100644 --- a/rowers/templates/trainingplan.html +++ b/rowers/templates/trainingplan.html @@ -1,197 +1,72 @@ -{% extends "base.html" %} +{% extends "newbase.html" %} {% load staticfiles %} {% load rowerfilters %} {% block title %}Rowsandall Training Plans{% endblock %} -{% block scripts %} -{% endblock %} +{% block main %} +

    Training Plan - {{ plan.name }}

    +

    This plan starts on {{ plan.startdate }} and ends on {{ plan.enddate }}. + {% if plan.target %} + The training plan target is: {{ plan.target.name }} on {{ plan.target.date }}. + {% endif %} +

    +

    Edit the plan

    -{% block content %} -
    -
    -

    Training Plan - {{ plan.name }}

    -

    This plan starts on {{ plan.startdate }} and ends on {{ plan.enddate }}. The training plan target is: {{ plan.target.name }} on {{ plan.target.date }}.

    -

    Edit the plan

    -
    -
    -

    Macro Cycles

    -
    -
    -

    Meso Cycles

    -
    -
    -

    Micro Cycles

    -
    -
    +

    Plan Macro, Meso and Micro Cycles

    - -
    - {% now "Y-m-d" as todays_date %} - - {% for key,macrocycle in cycles.items %} - -
    - - {% if macrocycle.0.type == 'filler' %} -
    - {% else %} -
    - {% endif %} - -
    - - - - - {% if macrocycle.0.type == 'userdefined' %} - - - - - - - - - - - - - - - - - - - - - - {% endif %} - {% if todays_date <= macrocycle.0.enddate|date:"Y-m-d" %} - - - - - - - {% else %} - - - - - - - {% endif %} -
    - {{ macrocycle.0.name }} ({{ macrocycle.0.startdate }} - {{ macrocycle.0.enddate }}) -
    dist (m)t (min)rScoreTRIMP
    plan{{ macrocycle.0.plandistance }}{{ macrocycle.0.plantime }}{{ macrocycle.0.planrscore }}{{ macrocycle.0.plantrimp }}
    actual{{ macrocycle.0.actualdistance }}{{ macrocycle.0.actualtime }}{{ macrocycle.0.actualrscore }}{{ macrocycle.0.actualtrimp }}
     
    - edit - / - delete - / - sessions -
     
    - sessions -
    -
    - -
    - - -
    - - {% for key, mesocycle in macrocycle.1.items %} - -
    - - {% if mesocycle.0.type == 'filler' %} -
    - {% else %} -
    - {% endif %} - -
    - - - - - {% if mesocycle.0.type == 'userdefined' %} - - - - - - - - - - - - - - - - - - - - - - {% endif %} - {% if todays_date <= mesocycle.0.enddate|date:"Y-m-d" %} - {% if mesocycle.0.plan.type == 'userdefined' %} - - - - - - - {% endif %} - {% else %} - {% if mesocycle.0.plan.type == 'userdefined' %} - - - - - - - {% endif %} - {% endif %} -
    - {{ mesocycle.0.name }} ({{ mesocycle.0.startdate }} - {{ mesocycle.0.enddate }}) -
    dist (m)t (min)rScoreTRIMP
    plan{{ mesocycle.0.plandistance }}{{ mesocycle.0.plantime }}{{ mesocycle.0.planrscore }}{{ mesocycle.0.plantrimp }}
    actual{{ mesocycle.0.actualdistance }}{{ mesocycle.0.actualtime }}{{ mesocycle.0.actualrscore }}{{ mesocycle.0.actualtrimp }}
     
    - edit - / - delete - / - sessions -
     
    - sessions -
    -
    - -
    - - -
    - - {% for microcycle in mesocycle.1 %} - - {% if microcycle.type == 'filler' %} -
    - {% else %} -
    - {% endif %} - +
      + + {% for key, macrocycle in cycles.items %} +
    • + + +
        +
      • + {% if macrocycle.0.type == 'filler' %} +
        - {% if microcycle.type == 'userdefined' %} + {% if todays_date <= macrocycle.0.enddate|date:"Y-m-d" %} + +   + + + + + {% else %} + +   + + + sessions + + {% endif %} +
        - {{ microcycle.name }} ({{ microcycle.startdate }} - {{ microcycle.enddate }}) + {{ macrocycle.0.name }} ({{ macrocycle.0.startdate }} - {{ macrocycle.0.enddate }})
        + edit + / + delete + / + sessions +
        +
        +
        + {% else %} +
        +
        + + + + + {% if macrocycle.0.type == 'userdefined' %} @@ -201,90 +76,340 @@ - - - - + + + + - - - - + + + + {% endif %} - {% if todays_date <= microcycle.enddate|date:"Y-m-d" %} - {% if microcycle.plan.type == 'userdefined' %} + {% if todays_date <= macrocycle.0.enddate|date:"Y-m-d" %} + + {% else %} + + + + + {% endif %} - {% else %} - {% if microcycle.plan.type == 'userdefined' %} - - - - - - - {% endif %} - {% endif %}
        + {{ macrocycle.0.name }} ({{ macrocycle.0.startdate }} - {{ macrocycle.0.enddate }}) +
        dist (m)
        plan{{ microcycle.plandistance }}{{ microcycle.plantime }}{{ microcycle.planrscore }}{{ microcycle.plantrimp }}{{ macrocycle.0.plandistance }}{{ macrocycle.0.plantime }}{{ macrocycle.0.planrscore }}{{ macrocycle.0.plantrimp }}
        actual{{ microcycle.actualdistance }}{{ microcycle.actualtime }}{{ microcycle.actualrscore }}{{ microcycle.actualtrimp }}{{ macrocycle.0.actualdistance }}{{ macrocycle.0.actualtime }}{{ macrocycle.0.actualrscore }}{{ macrocycle.0.actualtrimp }}
         
        - edit + edit / - delete + delete / - sessions + sessions +
         
        + sessions
         
        - sessions -
        -
        - - {% endfor %} - -
    - -
    - - {% endfor %} - -
    - -
    - + {% endif %} + +
  • + + +
      + + {% for key, mesocycle in macrocycle.1.items %} +
    • + {% if mesocycle.0.type == 'filler' %} +
      +
      + + + + + {% if todays_date <= mesocycle.0.enddate|date:"Y-m-d" %} + {% if mesocycle.0.plan.type == 'userdefined' %} + +   + + + + + {% endif %} + {% else %} + +   + + + sessions + + {% endif %} +
      + Meso {{ mesocycle.0.name }} ({{ mesocycle.0.startdate }} - {{ mesocycle.0.enddate }}) +
      + edit + / + delete + / + sessions +
      +
      +
      + {% else %} +
      +
      + + + + + {% if mesocycle.0.type == 'userdefined' %} + + + + + + + + + + + + + + + + + + + + + + {% endif %} + {% if todays_date <= mesocycle.0.enddate|date:"Y-m-d" %} + + + + + + + {% else %} + + + + + + + {% endif %} +
      + Meso {{ mesocycle.0.name }} ({{ mesocycle.0.startdate }} - {{ mesocycle.0.enddate }}) +
      dist (m)t (min)rScoreTRIMP
      plan{{ mesocycle.0.plandistance }}{{ mesocycle.0.plantime }}{{ mesocycle.0.planrscore }}{{ mesocycle.0.plantrimp }}
      actual{{ mesocycle.0.actualdistance }}{{ mesocycle.0.actualtime }}{{ mesocycle.0.actualrscore }}{{ mesocycle.0.actualtrimp }}
       
      + edit + / + delete + / + sessions +
       
      + sessions +
      +
      +
      + {% endif %} +
    • +
    • + + +
        + + {% for microcycle in mesocycle.1 %} +
      • + {% if microcycle.type == 'filler' %} +
        +
        + + + + + {% if todays_date <= microcycle.enddate|date:"Y-m-d" %} + {% if microcycle.plan.type == 'userdefined' %} + + + + + + + {% endif %} + {% else %} + {% if microcycle.plan.type == 'userdefined' %} + + + + + + + {% endif %} + {% endif %} +
        + Micro {{ microcycle.name }} ({{ microcycle.startdate }} - {{ microcycle.enddate }}) +
         
        + edit + / + delete + / + sessions +
         
        + sessions +
        +
        +
        + {% else %} +
        +
        + + + + + + + + + + + + + + + + + + + + + + + + + + {% if todays_date <= microcycle.enddate|date:"Y-m-d" %} + + + + + + + {% else %} + + + + + + + {% endif %} +
        + Micro {{ microcycle.name }} ({{ microcycle.startdate }} - {{ microcycle.enddate }}) +
        dist (m)t (min)rScoreTRIMP
        plan{{ microcycle.plandistance }}{{ microcycle.plantime }}{{ microcycle.planrscore }}{{ microcycle.plantrimp }}
        actual{{ microcycle.actualdistance }}{{ microcycle.actualtime }}{{ microcycle.actualrscore }}{{ microcycle.actualtrimp }}
         
        + edit + / + delete + / + sessions +
         
        + sessions +
        +
        +
        + {% endif %} +
      • + {% endfor %} + +
      +
    • + {% endfor %} + +
    +
  • + + {% endfor %} - -
    - -
    -

    Click on the plan cycles to edit their names, start and end dates. - The gray "filler" - cycles are generated, adjusted and deleted automatically to - ensure the entire plan - duration is covered with non-overlapping cycles. - Once you edit a filler cycle, it become a user-defined - cycle, which cannot be deleted - by the system.

    -

    Filler cycles which have a filler cycle as a parent cannot be edited - or deleted. You have to edit the parent cycle first. The reason is - that children of filler cycles are not safe. They are deleted when - their parent is deleted by the system.

    -

    Click on "Sessions" in the cycle of your interest to see details - of the individual training sessions planned for this period.

    -

    A good way to organize the plan is to think of micro - cycles as training weeks. Macro cycles - are typically used to address specific phases of preparation - and to indicate the racing - season and may span several months. - Meso cycles can be used to group sequences of three to five - light, medium and - hard weeks. It is recommended to work from left to right, - starting with the macro cycles.

    -
    + + + +

    Click on the cycle to fold out its contents.

    + +

    Click on the plan cycles to edit their names, start and end dates. + The gray "filler" + cycles are generated, adjusted and deleted automatically to + ensure the entire plan + duration is covered with non-overlapping cycles. + Once you edit a filler cycle, it become a user-defined + cycle, which cannot be deleted + by the system.

    +

    Filler cycles which have a filler cycle as a parent cannot be edited + or deleted. You have to edit the parent cycle first. The reason is + that children of filler cycles are not safe. They are deleted when + their parent is deleted by the system.

    +

    Click on "Sessions" in the cycle of your interest to see details + of the individual training sessions planned for this period.

    +

    A good way to organize the plan is to think of micro + cycles as training weeks. Macro cycles + are typically used to address specific phases of preparation + and to indicate the racing + season and may span several months. + Meso cycles can be used to group sequences of three to five + light, medium and + hard weeks. It is recommended to work from left to right, + starting with the macro cycles.

    +{% endblock %} + +{% block scripts %} +{% if thismicro %} + + +{% elif thismeso %} + + +{% endif %} +{% if thismacro %} + + +{% endif %} +{% endblock %} + +{% block sidebar %} +{% include 'menu_plan.html' %} {% endblock %} diff --git a/rowers/templatetags/rowerfilters.py b/rowers/templatetags/rowerfilters.py index 30a23bc7..223736a2 100644 --- a/rowers/templatetags/rowerfilters.py +++ b/rowers/templatetags/rowerfilters.py @@ -185,7 +185,7 @@ def get_field_id(id,s,form): field_name = s+str(id) return form.__getitem__(field_name) -from rowers.models import Rower,Team +from rowers.models import Rower,Team,TrainingPlan,TrainingTarget from rowers.views import ispromember @register.filter @@ -350,3 +350,23 @@ def userurl(path,member): replaced = path+userstring return replaced + +@register.filter +def timeurl(path,timestring): + pattern = re.compile('\?when=w.*') + timeurl = '?when=%s' % timestring + replaced = '' + + if pattern.search(path) is not None: + replaced = pattern.sub(timeurl,path) + + if not replaced: + replaced = path+timeurl + + return replaced + +@register.filter +def trainingplans(rower): + plans = TrainingPlan.objects.filter(rower=rower).order_by("-startdate") + + return plans diff --git a/rowers/urls.py b/rowers/urls.py index 34607d96..510e2008 100644 --- a/rowers/urls.py +++ b/rowers/urls.py @@ -413,13 +413,20 @@ urlpatterns = [ # url(r'^workout/compare/(?P\d+)/(?P\d+)/(?P\w+.*)/(?P[\w\ ]+.*)/$',views.workout_comparison_view2), url(r'^test\_callback',views.rower_process_testcallback), url(r'^createplan/$',views.rower_create_trainingplan), - url(r'^createplan/user/(?P\d+)$',views.rower_create_trainingplan), + url(r'^createplan/user/(?P\d+)/$',views.rower_create_trainingplan), url(r'^deleteplan/(?P\d+)$',views.TrainingPlanDelete.as_view()), url(r'^deletemicrocycle/(?P\d+)$',views.MicroCycleDelete.as_view()), url(r'^deletemesocycle/(?P\d+)$',views.MesoCycleDelete.as_view()), url(r'^deletemacrocycle/(?P\d+)$',views.MacroCycleDelete.as_view()), # url(r'^deleteplan/(?P\d+)$',views.rower_delete_trainingplan), - url(r'^plan/(?P\d+)$',views.rower_trainingplan_view), + url(r'^plan/(?P\d+)/$',views.rower_trainingplan_view), + url(r'^plan/(?P\d+)/user/(?P\d+)/$',views.rower_trainingplan_view), + url(r'^plan/(?P\d+)/micro/(?P\d+)/$',views.rower_trainingplan_view), + url(r'^plan/(?P\d+)/micro/(?P\d+)/user/(?P\d+)/$',views.rower_trainingplan_view), + url(r'^plan/(?P\d+)/meso/(?P\d+)/$',views.rower_trainingplan_view), + url(r'^plan/(?P\d+)/meso/(?P\d+)/user/(?P\d+)/$',views.rower_trainingplan_view), + url(r'^plan/(?P\d+)/macro/(?P\d+)/$',views.rower_trainingplan_view), + url(r'^plan/(?P\d+)/macro/(?P\d+)/user/(?P\d+)/$',views.rower_trainingplan_view), url(r'^macrocycle/(?P\d+)$',views.TrainingMacroCycleUpdate.as_view()), url(r'^mesocycle/(?P\d+)$',views.TrainingMesoCycleUpdate.as_view()), url(r'^microcycle/(?P\d+)$',views.TrainingMicroCycleUpdate.as_view()), diff --git a/rowers/views.py b/rowers/views.py index 64b0711c..1289cec3 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -209,6 +209,8 @@ class JSONResponse(HttpResponse): def getrequestrower(request,rowerid=0,userid=0,notpermanent=False): + userid = int(userid) + rowerid = int(rowerid) if notpermanent == False: if rowerid == 0 and 'rowerid' in request.session: @@ -15506,12 +15508,27 @@ def rower_create_trainingplan(request,userid=0): plans = TrainingPlan.objects.filter(rower=therower).order_by("-startdate") form = TrainingPlanForm(targets=targets) - + breadcrumbs = [ + { + 'url':reverse(plannedsessions_view, + kwargs={'userid':userid}), + 'name': 'Plan' + }, + { + 'url':reverse(rower_create_trainingplan, + kwargs={'userid':userid}), + 'name': 'Manage Plans and Targets' + } + ] + + return render(request,'trainingplan_create.html', { 'form':form, 'rower':therower, + 'breadcrumbs':breadcrumbs, 'plans':plans, + 'active':'nav-plan', 'targets':targets, 'targetform':targetform, }) @@ -15570,9 +15587,11 @@ class MicroCycleDelete(DeleteView): def get_success_url(self): plan = self.object.plan.plan.plan createmacrofillers(plan) + thismesoid = self.object.plan.pk return reverse(rower_trainingplan_view, kwargs = { - 'id':plan.id + 'id':plan.id, + 'thismesoid':thismesoid }) def get_object(self, *args, **kwargs): @@ -15588,10 +15607,12 @@ class MesoCycleDelete(DeleteView): def get_success_url(self): plan = self.object.plan.plan + thismacroid = self.object.plan.pk createmacrofillers(plan) return reverse(rower_trainingplan_view, kwargs = { - 'id':plan.id + 'id':plan.id, + 'thismacroid':thismacroid, }) def get_object(self, *args, **kwargs): @@ -15723,11 +15744,18 @@ class MacroCycleDelete(DeleteView): @user_passes_test(hasplannedsessions,login_url="/", redirect_field_name=None) -def rower_trainingplan_view(request,id=0): +def rower_trainingplan_view(request, + id=0, + userid=0, + thismicroid=0, + thismacroid=0, + thismesoid=0): try: plan = TrainingPlan.objects.get(id=id) except TrainingPlan.DoesNotExist: raise Http404("Training Plan Does Not Exist") + + r = getrequestrower(request,userid=userid) if not checkaccessuser(request.user,plan.rower): raise PermissionDenied("Access denied") @@ -15854,11 +15882,51 @@ def rower_trainingplan_view(request,id=0): cycles[count] = (m,mesos) count += 1 + breadcrumbs = [ + { + 'url':reverse(plannedsessions_view, + kwargs={'userid':userid}), + 'name': 'Plan' + }, + { + 'url':reverse(rower_trainingplan_view, + kwargs={'userid':userid, + 'id':id}), + 'name': plan.name + } + ] + + if thismicroid: + thismicro = TrainingMicroCycle.objects.get(id=int(thismicroid)) + else: + if not thismacroid and not thismesoid: + thismicro = get_todays_micro(plan) + else: + thismicro = None + + if thismacroid: + thismacro = TrainingMacroCycle.objects.get(id=int(thismacroid)) + else: + thismacro = None + + if thismesoid: + thismeso = TrainingMesoCycle.objects.get(id=int(thismesoid)) + else: + thismeso = None + + print thismacro,thismeso,thismicro,'aap' + return render(request,'trainingplan.html', { 'plan':plan, + 'active':'nav-plan', + 'breadcrumbs':breadcrumbs, + 'rower':r, 'cycles':cycles, + 'thismicro':thismicro, + 'thismacro':thismacro, + 'thismeso':thismeso, } ) @@ -15873,7 +15941,8 @@ class TrainingMacroCycleUpdate(UpdateView): createmacrofillers(plan) return reverse(rower_trainingplan_view, kwargs = { - 'id':plan.id + 'id':plan.id, + 'thismacro':self.object.id, } ) @@ -15904,7 +15973,8 @@ class TrainingMesoCycleUpdate(UpdateView): createmesofillers(plan) return reverse(rower_trainingplan_view, kwargs = { - 'id':plan.plan.id + 'id':plan.plan.id, + 'thismesoid':self.object.id, } ) @@ -15938,7 +16008,8 @@ class TrainingMicroCycleUpdate(UpdateView): createmicrofillers(plan) return reverse(rower_trainingplan_view, kwargs = { - 'id':plan.plan.plan.id + 'id':plan.plan.plan.id, + 'thismicroid':self.object.pk } ) def form_valid(self, form): diff --git a/static/css/rowsandall2.css b/static/css/rowsandall2.css index b4147b22..60a14cc3 100644 --- a/static/css/rowsandall2.css +++ b/static/css/rowsandall2.css @@ -626,6 +626,45 @@ th.rotate > div > span { } +/* palegreen */ +.palegreen { + background: palegreen; + box-shadow:inset 0px 0px 0px 6px #fff; + -moz-box-shadow:inset 0px 0px 0px 6px #fff; + box-shadow:inset 0px 0px 0px 6px #fff; +} + +/* paleblue */ +.paleblue { +# padding: 8px; + background: aliceblue; + box-shadow:inset 0px 0px 0px 6px #fff; + -moz-box-shadow:inset 0px 0px 0px 6px #fff; + box-shadow:inset 0px 0px 0px 6px #fff; +} + +/* lightsalmon */ +.lightsalmon { +# padding: 4px; + background: lightsalmon; + box-shadow:inset 0px 0px 0px 6px #fff; + -moz-box-shadow:inset 0px 0px 0px 6px #fff; + box-shadow:inset 0px 0px 0px 6px #fff; +} + +/* filler */ +.filler { + background: darkgray; + box-shadow:inset 0px 0px 0px 6px #fff; + -moz-box-shadow:inset 0px 0px 0px 6px #fff; + box-shadow:inset 0px 0px 0px 6px #fff; +} + +.padded { + padding: 10px; +} + + .input { font: 1.1em/1.5em sans-serif; text-decoration: none; @@ -753,44 +792,6 @@ th.rotate > div > span { } -/* palegreen */ -.palegreen { - background: palegreen; - box-shadow:inset 0px 0px 0px 6px #fff; - -moz-box-shadow:inset 0px 0px 0px 6px #fff; - box-shadow:inset 0px 0px 0px 6px #fff; -} - -/* paleblue */ -.paleblue { -# padding: 8px; - background: aliceblue; - box-shadow:inset 0px 0px 0px 6px #fff; - -moz-box-shadow:inset 0px 0px 0px 6px #fff; - box-shadow:inset 0px 0px 0px 6px #fff; -} - -/* lightsalmon */ -.lightsalmon { -# padding: 4px; - background: lightsalmon; - box-shadow:inset 0px 0px 0px 6px #fff; - -moz-box-shadow:inset 0px 0px 0px 6px #fff; - box-shadow:inset 0px 0px 0px 6px #fff; -} - -/* filler */ -.filler { - background: darkgray; - box-shadow:inset 0px 0px 0px 6px #fff; - -moz-box-shadow:inset 0px 0px 0px 6px #fff; - box-shadow:inset 0px 0px 0px 6px #fff; -} - -.padded { - padding: 10px; -} - /* pink */ .pink { color: #feeef5; diff --git a/static/css/styles2.css b/static/css/styles2.css index 32bb9c12..c2a3040a 100644 --- a/static/css/styles2.css +++ b/static/css/styles2.css @@ -201,7 +201,6 @@ aside .cd-accordion-menu label { cursor: pointer; - background: #35383d; } @@ -223,6 +222,84 @@ display: block; } + + main .cd-accordion-menu { + width: 100%; + max-width: 600px; + } + + main .cd-accordion-menu ul { + /* by default hide all sub menus */ + display: none; + } + + main .cd-accordion-menu li { + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + } + + main .cd-accordion-menu input[type=checkbox] { + /* hide native checkbox */ + position: absolute; + opacity: 0; + } + + main .cd-accordion-menu label { + position: relative; + display: block; + font-size: 1.0em; + } + + + + main .cd-accordion-menu ul, + main .cd-accordion-menu li { + list-style: none; + } + + main .cd-accordion-menu label::before + { + /* icons */ + font: normal normal normal 1.0em/1 FontAwesome; + font-size: inherit; + text-rendering: auto; + content: '\f0da'; + display: inline-block; + width: 16px; + height: 16px; + + -webkit-transform: translateY(0%); + -moz-transform: translateY(0%); + -ms-transform: translateY(0%); + -o-transform: translateY(0%); + transform: translateY(0%); + } + + main .cd-accordion-menu label { + cursor: pointer; + } + + + main .cd-accordion-menu input[type=checkbox]:checked + label::before { + /* rotate arrow */ + -webkit-transform: translateY(20%) rotate(90deg); + -moz-transform: translateY(20%) rotate(90deg); + -ms-transform: translateY(20%) rotate(90deg); + -o-transform: translateY(20%) rotate(90deg); + transform: translateY(20%) rotate(90deg); + + } + + + main .cd-accordion-menu input[type=checkbox]:checked + label + ul, + main .cd-accordion-menu input[type=checkbox]:checked + label:nth-of-type(n) + ul { + /* use label:nth-of-type(n) to fix a bug on safari (<= 8.0.8) with multiple adjacent-sibling selectors*/ + /* show children when item is checked */ + display: block; + } + user ul {