<commit_before>define [
  'jquery'
  'timezone'
  'underscore'
  'Backbone'
  'compiled/str/splitAssetString'
  'jst/wiki/WikiPage'
  'compiled/views/StickyHeaderMixin'
  'compiled/views/wiki/WikiPageDeleteDialog'
  'compiled/views/wiki/WikiPageReloadView'
  'compiled/views/PublishButtonView'
  'i18n!pages'
], ($, tz, _, Backbone, splitAssetString, template, StickyHeaderMixin, WikiPageDeleteDialog, WikiPageReloadView, PublishButtonView, I18n) ->

  class WikiPageView extends Backbone.View

    @mixin StickyHeaderMixin

    template: template

    els:
      '.publish-button': '$publishButton'
      '.header-bar-outer-container': '$headerBarOuterContainer'
      '.page-changed-alert': '$pageChangedAlert'

    events:
      'click .delete_page': 'deleteWikiPage'

    @optionProperty 'modules_path'
    @optionProperty 'wiki_pages_path'
    @optionProperty 'wiki_page_edit_path'
    @optionProperty 'wiki_page_history_path'
    @optionProperty 'WIKI_RIGHTS'
    @optionProperty 'PAGE_RIGHTS'
    @optionProperty 'course_id'
    @optionProperty 'course_home'
    @optionProperty 'course_title'

    initialize: ->
      @model.on 'change', => @render()
      super
      @WIKI_RIGHTS ||= {}
      @PAGE_RIGHTS ||= {}

    render: ->
      # detach elements to preserve data/events
      @publishButtonView?.$el.detach()
      @$sequenceFooter?.detach()

      super

      # attach/re-attach the publish button
      unless @publishButtonView
        @publishButtonView = new PublishButtonView model: @model
        @model.view = @
      @publishButtonView.$el.appendTo(@$publishButton)
      @publishButtonView.render()

      # attach/re-attach the sequence footer (if this is a course, but not the home page)
      unless @$sequenceFooter || @course_home || !@course_id
        @$sequenceFooter ||= $('<div></div>').hide()
        @$sequenceFooter.moduleSequenceFooter(
          courseID: @course_id
          assetType: 'Page'
          assetID: @model.get('url')
          location: location
        )
      else
        @$sequenceFooter?.msfAnimation(false)
      @$sequenceFooter.appendTo(@$el) if @$sequenceFooter

    afterRender: ->
      super
      @reloadView = new WikiPageReloadView
        el: @$pageChangedAlert
        model: @model
        reloadMessage: I18n.t 'reload_viewing_page', 'This page has changed since you started viewing it. *Reload*', wrapper: '<a class="reload" href="#">$1</a>'
      @reloadView.on 'changed', =>
        @$headerBarOuterContainer.addClass('page-changed')
      @reloadView.on 'reload', =>
        @render()
      @reloadView.pollForChanges()
<commit_msg>scroll to link anchor after wiki page renders<commit_after>define [
  'jquery'
  'timezone'
  'underscore'
  'Backbone'
  'compiled/str/splitAssetString'
  'jst/wiki/WikiPage'
  'compiled/views/StickyHeaderMixin'
  'compiled/views/wiki/WikiPageDeleteDialog'
  'compiled/views/wiki/WikiPageReloadView'
  'compiled/views/PublishButtonView'
  'i18n!pages'
], ($, tz, _, Backbone, splitAssetString, template, StickyHeaderMixin, WikiPageDeleteDialog, WikiPageReloadView, PublishButtonView, I18n) ->

  class WikiPageView extends Backbone.View

    @mixin StickyHeaderMixin

    template: template

    els:
      '.publish-button': '$publishButton'
      '.header-bar-outer-container': '$headerBarOuterContainer'
      '.page-changed-alert': '$pageChangedAlert'

    events:
      'click .delete_page': 'deleteWikiPage'

    @optionProperty 'modules_path'
    @optionProperty 'wiki_pages_path'
    @optionProperty 'wiki_page_edit_path'
    @optionProperty 'wiki_page_history_path'
    @optionProperty 'WIKI_RIGHTS'
    @optionProperty 'PAGE_RIGHTS'
    @optionProperty 'course_id'
    @optionProperty 'course_home'
    @optionProperty 'course_title'

    initialize: ->
      @model.on 'change', => @render()
      super
      @WIKI_RIGHTS ||= {}
      @PAGE_RIGHTS ||= {}

    render: ->
      # detach elements to preserve data/events
      @publishButtonView?.$el.detach()
      @$sequenceFooter?.detach()

      super

      # attach/re-attach the publish button
      unless @publishButtonView
        @publishButtonView = new PublishButtonView model: @model
        @model.view = @
      @publishButtonView.$el.appendTo(@$publishButton)
      @publishButtonView.render()

      # attach/re-attach the sequence footer (if this is a course, but not the home page)
      unless @$sequenceFooter || @course_home || !@course_id
        @$sequenceFooter ||= $('<div></div>').hide()
        @$sequenceFooter.moduleSequenceFooter(
          courseID: @course_id
          assetType: 'Page'
          assetID: @model.get('url')
          location: location
        )
      else
        @$sequenceFooter?.msfAnimation(false)
      @$sequenceFooter.appendTo(@$el) if @$sequenceFooter

    navigateToLinkAnchor: ->
      anchor_name = window.location.hash.replace(/^#/, "")
      if anchor_name.length
        $anchor = $("#wiki_page_show .user_content ##{anchor_name}")
        $anchor = $("#wiki_page_show .user_content a[name='#{anchor_name}']") unless $anchor.length
        if $anchor.length
          $('html, body').scrollTo($anchor)

    afterRender: ->
      super
      @navigateToLinkAnchor()
      @reloadView = new WikiPageReloadView
        el: @$pageChangedAlert
        model: @model
        reloadMessage: I18n.t 'reload_viewing_page', 'This page has changed since you started viewing it. *Reload*', wrapper: '<a class="reload" href="#">$1</a>'
      @reloadView.on 'changed', =>
        @$headerBarOuterContainer.addClass('page-changed')
      @reloadView.on 'reload', =>
        @render()
      @reloadView.pollForChanges()

{'fraction_non_alphanumeric': 0.12539851222104145, 'fraction_numerical': 0.002479631597591215, 'mean_word_length': 3.2394894894894897, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 26, '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': '7313274', 'n_tokens_mistral': 1780, 'n_tokens_neox': 1723, 'n_words': 337}