These are chat archives for jescalan/roots

6th
Jul 2015
Henry Snopek
@hhsnopek
Jul 06 2015 02:56
@t0t
# Active current menu item
splitHref = window.location.href.split('/')[3]

$('.nav-main__menu a').each ->
  href = $(this).attr('href')

  if href is splitHref or href is '/'
    $(this).parent().addClass('active')
Sergio Forés
@t0t
Jul 06 2015 09:35
Hello @hhsnopek now home is always .active because always href is always '/' jaja. Don't worrie, I'll learn a bit more on Jade and will do in the static way. This task should be simple. ;)
Thanks
Henry Snopek
@hhsnopek
Jul 06 2015 12:41
sorry it should be if href is splitHref or !href
because we're splitting by / we don't have / before our href attr either
so it becomes
splitHref = window.location.href.split('/')[3]

$('.nav-main__menu a').each ->
  href = $(this).attr('href').split('/')[0]

  if href is splitHref or !href
    $(this).parent().addClass('active')
Sergio Forés
@t0t
Jul 06 2015 13:53
Don't worry, I'm doing by hand
block navmain

  mixin navmenu(menu_items)

    nav.nav-main

      label(for="hamenu")

      input.nav-main--icon(
        type="checkbox"
        id="hamenu"
        checked=(true===false ? "checked" : undefined)
      )

      ul.nav-main__menu
        each item in menu_items
          li(class=['btn', 'btn--nav'])
            if item.title === current
              a('href' = item.link , 'class' = 'xxxx')
                =item.title
            else
              a(href=item.link)
                =item.title

  +navmenu([
    { 'title': 'Home', 'link': '/'},  
    { 'title': 'Productos', 'link': 'productos'},  
    { 'title': 'Empresa', 'link': 'empresa'},  
    { 'title': 'Aplicaciones', 'link': 'aplicaciones'},  
    { 'title': 'Contacto', 'link': 'contacto' },
  ])
Then if I create a - var current = "the_name" on each page individually it should work. ;)
Henry Snopek
@hhsnopek
Jul 06 2015 13:57
nice work!