<commit_before>var _ = require('underscore')
var $ = require('jquery')
var Backbone = require('backbone')
var utils = require('../utils')
var Snap = require('snap')
var lang = require('../translations')

// Allow hiding of sitebar if at list this number of docs
var minDocsForHide = 3

var AsideView = Backbone.View.extend({
  el: 'body',

  initialize: function () {
    _.bindAll(this, 'show', 'hide', 'toggle', 'desktopShow', 'desktopHide', 'handleSnapper', 'triggerOpening')

    this.$sidebar = this.$('aside')

    this.collection
      .on('add', this.desktopShow)
      .on('remove', this.desktopShow)
      .on('change:title', this.desktopShow)

    this.initSnapper()
    this.setFooter()
  },

  initSnapper: function () {
    this.snapper = new Snap({
      element: this.$('#snap-content')[0],
      disable: 'right',
      maxPosition: 265
    })

    this.snapper.on('end', this.triggerOpening)

    this.handleSnapper()
    $(window).on('resize', this.handleSnapper)
  },

  triggerOpening: function () {
    this.trigger('opening')
  },

  show: function () {
    if (utils.isDesktop) {
      this.$el.addClass('show-aside')
      return
    }
    this.snapper.open('left')
  },

  hide: function () {
    if (utils.isMobile) {
      this.snapper.close()
      return
    }
    // Hide sidebar when 3 or more docs and the open doc is not empty
    if (this.collection.length < minDocsForHide || this.model.isEmpty()) {
      return
    }
    this.$el.removeClass('show-aside')
  },

  toggle: function () {
    if (utils.isDesktop) {<commit_msg>Only trigger opening event when snapper is actually opening. Fixes #298<commit_after>var _ = require('underscore')
var $ = require('jquery')
var Backbone = require('backbone')
var utils = require('../utils')
var Snap = require('snap')
var lang = require('../translations')

// Allow hiding of sitebar if at list this number of docs
var minDocsForHide = 3

var AsideView = Backbone.View.extend({
  el: 'body',

  initialize: function () {
    _.bindAll(this, 'show', 'hide', 'toggle', 'desktopShow', 'desktopHide', 'handleSnapper', 'triggerOpening')

    this.$sidebar = this.$('aside')

    this.collection
      .on('add', this.desktopShow)
      .on('remove', this.desktopShow)
      .on('change:title', this.desktopShow)

    this.initSnapper()
    this.setFooter()
  },

  initSnapper: function () {
    this.snapper = new Snap({
      element: this.$('#snap-content')[0],
      disable: 'right',
      maxPosition: 265
    })

    this.snapper.on('end', this.triggerOpening)

    this.handleSnapper()
    $(window).on('resize', this.handleSnapper)
  },

  triggerOpening: function () {
    if (this.snapper.state().info.opening) {
      this.trigger('opening')
    }
  },

  show: function () {
    if (utils.isDesktop) {
      this.$el.addClass('show-aside')
      return
    }
    this.snapper.open('left')
  },

  hide: function () {
    if (utils.isMobile) {
      this.snapper.close()
      return
    }
    // Hide sidebar when 3 or more docs and the open doc is not empty
    if (this.collection.length < minDocsForHide || this.model.isEmpty()) {
      return
    }
    this.$el.removeClass('show-aside')
  },

  toggle: function () {
    if (utils.isDesktop) {
{'fraction_non_alphanumeric': 0.15950540958268933, 'fraction_numerical': 0.00463678516228748, 'mean_word_length': 2.995061728395062, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '4849180', 'n_tokens_mistral': 1099, 'n_tokens_neox': 1019, 'n_words': 236}