<commit_before>goog.provide 'acorn.shells.SplicedShell'

goog.require 'acorn.shells.CollectionShell'


CollectionShell = acorn.shells.CollectionShell


SplicedShell = acorn.shells.SplicedShell =

  id: 'acorn.SplicedShell'
  title: 'Spliced'
  description: 'Media spliced together'
  icon: 'icon-play'



class SplicedShell.Model extends CollectionShell.Model


  transition: @property('transition')


  title: =>
    super or @shells().first()?.title() or ''



class SplicedShell.MediaView extends CollectionShell.MediaView


  className: @classNameExtend 'spliced-shell'


  defaults: => _.extend super,
    playOnReady: true
    subshellPlayOnReady: false
    showSubshellControls: false
    showSubshellSummary: false
    autoAdvanceOnEnd: true


  initializeControlsView: =>

    @initializeElapsedTimeView()

    # construct a ControlToolbar for the acorn controls
    @controlsView = new ControlToolbarView
      extraClasses: ['shell-controls']
      buttons: ['Play', 'Pause', @elapsedTimeView]
      eventhub: @eventhub

    @controlsView.on 'PlayControl:Click', => @play()
    @controlsView.on 'PauseControl:Click', => @pause()


  initializeElapsedTimeView: =>

    tvModel = new Backbone.Model
      elapsed: 0
      total: @duration() or 0

    @elapsedTimeView = new acorn.player.controls.ElapsedTimeControlView
      eventhub: @eventhub
      model: tvModel

    tvModel.listenTo @, 'Media:Progress', (view, elapsed, total) =>
      tvModel.set 'elapsed', elapsed
      tvModel.set 'total', total or 0


  remove: =>
    @controlsView.off 'PlayControl:Click'
    @controlsView.off 'PauseControl:Click'
    super


  render: =>
    super
    # render all pieces in order to get them fully ready
    # this will be expensive as the # of pieces incs.
    _.each _.range(1, @shellViews.length), (index) =>
      @showView index
      @shellViews[index].pause()
      @hideView index
    @showView 0
    @


  onMediaDidPlay: =>
    super<commit_msg>Spliced: toggle play/pause on click.<commit_after>goog.provide 'acorn.shells.SplicedShell'

goog.require 'acorn.shells.CollectionShell'


CollectionShell = acorn.shells.CollectionShell


SplicedShell = acorn.shells.SplicedShell =

  id: 'acorn.SplicedShell'
  title: 'Spliced'
  description: 'Media spliced together'
  icon: 'icon-play'



class SplicedShell.Model extends CollectionShell.Model


  transition: @property('transition')


  title: =>
    super or @shells().first()?.title() or ''



class SplicedShell.MediaView extends CollectionShell.MediaView


  className: @classNameExtend 'spliced-shell'


  events: => _.extend super,
    'click .click-capture': => @togglePlayPause()


  defaults: => _.extend super,
    playOnReady: true
    subshellPlayOnReady: false
    showSubshellControls: false
    showSubshellSummary: false
    autoAdvanceOnEnd: true


  initializeControlsView: =>

    @initializeElapsedTimeView()

    # construct a ControlToolbar for the acorn controls
    @controlsView = new ControlToolbarView
      extraClasses: ['shell-controls']
      buttons: ['Play', 'Pause', @elapsedTimeView]
      eventhub: @eventhub

    @controlsView.on 'PlayControl:Click', => @play()
    @controlsView.on 'PauseControl:Click', => @pause()


  initializeElapsedTimeView: =>

    tvModel = new Backbone.Model
      elapsed: 0
      total: @duration() or 0

    @elapsedTimeView = new acorn.player.controls.ElapsedTimeControlView
      eventhub: @eventhub
      model: tvModel

    tvModel.listenTo @, 'Media:Progress', (view, elapsed, total) =>
      tvModel.set 'elapsed', elapsed
      tvModel.set 'total', total or 0


  remove: =>
    @controlsView.off 'PlayControl:Click'
    @controlsView.off 'PauseControl:Click'
    super


  render: =>
    super
    # render all pieces in order to get them fully ready
    # this will be expensive as the # of pieces incs.
    _.each _.range(1, @shellViews.length), (index) =>
      @showView index
      @shellViews[index].pause()
      @hideView index
    @showView 0
    @$el.append $('<div>').addClass('click-capture')
    @


  onMediaDidPlay: =>
    super
{'fraction_non_alphanumeric': 0.1097770154373928, 'fraction_numerical': 0.002450379808870375, 'mean_word_length': 3.510497237569061, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 28, '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': '807160', 'n_tokens_mistral': 1313, 'n_tokens_neox': 1240, 'n_words': 301}