<commit_before>_ = require 'underscore'

View = require 'lib/view'
tpl = require 'templates/layouts/loggedin'

mediator = require('chaplin').mediator

module.exports = class LoggedInLayout extends View
  template: tpl
  autoRender: yes
  container: '#bkts-content'

  regions:
    content: '.page'

  getTemplateData: ->
    _.extend super,
      buckets: mediator.buckets?.toJSON()

  initialize: ->
    super
    @subscribeEvent 'dispatcher:dispatch', @checkNav
    @listenTo mediator.buckets, 'sync add', => @render()

  render: ->
    super
    @$navLinks = @$('.nav-primary a')

  checkNav: (controller, params, route) ->
    @$('.nav-primary li').removeClass 'active'

    return unless route?.path

    for link in @$navLinks
      $link = $(link)
      href = $link.attr('href')
      newURL = "/#{mediator.options.adminSegment}/#{route.path}"
      if newURL.substr(0, href.length) is href
        $link.parent().addClass('active')
        break<commit_msg>Animate nav on render<commit_after>_ = require 'underscore'

View = require 'lib/view'
tpl = require 'templates/layouts/loggedin'

mediator = require('chaplin').mediator

module.exports = class LoggedInLayout extends View
  template: tpl
  autoRender: yes
  container: '#bkts-content'

  regions:
    content: '.page'

  getTemplateData: ->
    _.extend super,
      buckets: mediator.buckets?.toJSON()

  initialize: ->
    super
    @subscribeEvent 'dispatcher:dispatch', @checkNav
    @listenTo mediator.buckets, 'sync add', => @render()

  render: ->
    super
    @$navLinks = @$('.nav-primary a')

    @navTimeline ?= new TimelineLite
    @navTimeline.staggerFrom @$('.nav-primary li'), .2,
      y: '30px'
      opacity: 0
      ease: Back.easeOut
    , .05

    @navTimeline.play()

  checkNav: (controller, params, route) ->
    @$('.nav-primary li').removeClass 'active'

    return unless route?.path

    for link in @$navLinks
      $link = $(link)
      href = $link.attr('href')
      newURL = "/#{mediator.options.adminSegment}/#{route.path}"
      if newURL.substr(0, href.length) is href
        $link.parent().addClass('active')
        break
{'fraction_non_alphanumeric': 0.1466854724964739, 'fraction_numerical': 0.0037611659614480487, 'mean_word_length': 3.0923076923076924, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7309754', 'n_tokens_mistral': 701, 'n_tokens_neox': 681, 'n_words': 161}