Sha256: 68aaa1b77bfa84c0700dedce2e6a784b7dc921f890b99dfa6ec4d7fecc118cbe

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 KB

Contents

win = @

class @NE.PhotoPlayer
  constructor : (photoId, titleId, descId, photogId, locId ) ->
    @photo        = document.getElementById( photoId )
    @title        = document.getElementById( titleId )
    @description  = document.getElementById( descId )
    @photographer = document.getElementById( photogId )
    @location     = document.getElementById( locId )

    @photos      = []
    @displayTime = 10000
    @cursor      = 0

    win.addEventListener 'load:program', @onLoad, false

  render : =>
    return unless photo = @nextPhoto()

    @renderPhoto       photo.image_url
    @renderTitle       photo.title
    @renderDescription photo.description
    @renderPhotog      photo.photographer
    @renderLocation    photo.location

  renderPhoto : (url) ->
    @photo.setAttribute 'src', url

  renderTitle : (title) ->
    @title.innerHTML = title

  renderDescription : (desc) ->
    @description.innerHTML = desc

  renderPhotog : (photog) ->
    @photographer.innerHTML = photog

  renderLocation : (location) ->
    @location.innerHTML = location

  nextPhoto : ->
    @cursor = 0 if @cursor > @photos.length - 1

    p = @photos[@cursor]

    @cursor++

    p

  onLoad : (e) =>
    @photos = e.detail.data.photos

    setInterval @render, @displayTime

    @render()

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
network_executive-0.0.8 app/assets/javascripts/network_executive/components/photo_player.coffee
network_executive-0.0.7 app/assets/javascripts/network_executive/components/photo_player.coffee