<commit_before>define [
  'jquery'
  'underscore'
  'backbone'
  'marionette'
  'cs!session'
  'cs!collections/content'
  'hbs!templates/workspace/menu/auth'
  'bootstrapTooltip'
], ($, _, Backbone, Marionette, session, content, authTemplate) ->

  _hasChanged = false

  # Default Auth View
  # -------
  # The top-right of each page should have either:
  #
  # 1. a Sign-up/Login link if not logged in
  # 2. a logoff link with the current user name if logged in
  #
  # This view updates when the login state changes
  return class AuthView extends Marionette.ItemView
    template: (serializedModel) ->
      return authTemplate
        authenticated: session.authenticated()
        user: session.user()
        changed: _hasChanged

    events:
      'click #sign-out':      'signOut'
      'click #save-content':  'saveContent'

    initialize: () ->
      @listenTo(session, 'login logout', @render)
      # When a model has changed (triggered `dirty`) update the Save button
      @listenTo content, 'dirty', (model, options) => @changed()

      # Bind a function to the window if the user tries to navigate away from this page
      $(window).on 'beforeunload', () ->
        return 'You have unsaved changes. Are you sure you want to leave this page?' if _hasChanged

    onRender: () ->
      @$el.html(@template) # FIXME: Why is marionnete not loading the template correctly
      # Enable tooltip
      @$el.find('#save-content').tooltip()<commit_msg>Change the save button when new content is created<commit_after>define [
  'jquery'
  'underscore'
  'backbone'
  'marionette'
  'cs!session'
  'cs!collections/content'
  'hbs!templates/workspace/menu/auth'
  'bootstrapTooltip'
], ($, _, Backbone, Marionette, session, content, authTemplate) ->

  _hasChanged = false

  # Default Auth View
  # -------
  # The top-right of each page should have either:
  #
  # 1. a Sign-up/Login link if not logged in
  # 2. a logoff link with the current user name if logged in
  #
  # This view updates when the login state changes
  return class AuthView extends Marionette.ItemView
    template: (serializedModel) ->
      return authTemplate
        authenticated: session.authenticated()
        user: session.user()
        changed: _hasChanged

    events:
      'click #sign-out':      'signOut'
      'click #save-content':  'saveContent'

    initialize: () ->
      @listenTo(session, 'login logout', @render)

      # When a model has changed (triggered `dirty`) update the Save button
      @listenTo content, 'dirty', (model, options) => @changed()
      # Update the Save button when new Folder/Book/Module is created (added to `content`)
      @listenTo content, 'add remove', (model, collection, options) =>
        @changed() if not (options.loading or options.parse)

      # Bind a function to the window if the user tries to navigate away from this page
      $(window).on 'beforeunload', () ->
        return 'You have unsaved changes. Are you sure you want to leave this page?' if _hasChanged

    onRender: () ->
      @$el.html(@template) # FIXME: Why is marionnete not loading the template correctly
      # Enable tooltip
      @$el.find('#save-content').tooltip()
{'fraction_non_alphanumeric': 0.1111807077983088, 'fraction_numerical': 0.001252740369558409, 'mean_word_length': 3.0176100628930818, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, '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': '5145617', 'n_tokens_mistral': 942, 'n_tokens_neox': 916, 'n_words': 326}