<commit_before>define (require) ->
  _ = require('underscore')
  Backbone = require('backbone')
  BaseView = require('cs!helpers/backbone/views/base')
  MailPopoverView = require('cs!./popovers/mail/mail')
  template = require('hbs!./title-template')
  require('less!./title')

  return class MediaTitleView extends BaseView
    template: template
    templateHelpers: () ->
      title = @model.get('title')
      currentPage = @model.get('currentPage')
      if currentPage
        # Set information used for social media links
        share =
          url: Backbone.history.fragment
          source: @model.get('source') or currentPage.get('source') or 'OpenStax College'
          summary: @model.get('summary') or currentPage.get('summary') or 'An OpenStax College book.'
          title: title or currentPage.get('title')
          image: @model.get('image') or currentPage.get('image') or "#{Backbone.history.location.host}/images/logo.png"

      # Encode all of the shared values for a URI
      _.each share, (value, key, list) ->
        list[key] = encodeURI(value)

      return {share: share, encodedTitle: encodeURI(title)}

    initialize: () ->
      super()
      @listenTo(@model, 'change:title change:authors change:id', @render) if @model

    onRender: () ->
      $share = @$el.find('.share')
      @attachPopover new MailPopoverView({owner: $share.find('.mail'), model: @model})<commit_msg>Don't try to load sharing mail popover view<commit_after>define (require) ->
  _ = require('underscore')
  Backbone = require('backbone')
  BaseView = require('cs!helpers/backbone/views/base')
  #MailPopoverView = require('cs!./popovers/mail/mail')
  template = require('hbs!./title-template')
  require('less!./title')

  return class MediaTitleView extends BaseView
    template: template
    templateHelpers: () ->
      title = @model.get('title')
      currentPage = @model.get('currentPage')
      if currentPage
        # Set information used for social media links
        share =
          url: Backbone.history.fragment
          source: @model.get('source') or currentPage.get('source') or 'OpenStax College'
          summary: @model.get('summary') or currentPage.get('summary') or 'An OpenStax College book.'
          title: title or currentPage.get('title')
          image: @model.get('image') or currentPage.get('image') or "#{Backbone.history.location.host}/images/logo.png"

      # Encode all of the shared values for a URI
      _.each share, (value, key, list) ->
        list[key] = encodeURI(value)

      return {share: share, encodedTitle: encodeURI(title)}

    initialize: () ->
      super()
      @listenTo(@model, 'change:title change:authors change:id', @render) if @model

    #onRender: () ->
    #  $share = @$el.find('.share')
    #  @attachPopover new MailPopoverView({owner: $share.find('.mail'), model: @model})
{'fraction_non_alphanumeric': 0.14619678995115143, 'fraction_numerical': 0.0, 'mean_word_length': 3.2919161676646707, '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': '4814078', 'n_tokens_mistral': 847, 'n_tokens_neox': 833, 'n_words': 208}