Sha256: 10fa0da8bacaa49a986b61cdb9dd80fdd09a5088bace6e1178b14654d86b72ad

Contents?: true

Size: 1.13 KB

Versions: 23

Compression:

Stored size: 1.13 KB

Contents

class App.Views.User.Rooms.Show extends App.Views.Base
  constructor: (opts = {}) ->
    super opts
    @roomId = opts.id

  render: ->
    this.connectWith App.Models.Room
    this._handleSendingMessage()

  renderMembers: (members) ->
    for member in members
      this._memberJoined member

  receivedMessage: (message, author) ->
    $('#messages').append "<p><b>#{author}</b>: #{message}</p>"

  receivedSignal: (signal, data) ->
    switch signal
      when "Room member_joined"
        return if data.room_id isnt @roomId
        this._memberJoined data.member
      when "Room member_left"
        return if data.room_id isnt @roomId
        this._memberLeft data.member

  _handleSendingMessage: ->
    $(document).on 'keypress', '[data-behavior~=room-speaker]', (event) =>
      return if event.keyCode isnt 13
      event.preventDefault()
      App.Env.loco.emit signal: 'message', txt: event.target.value, room_id: @roomId
      event.target.value = ''

  _memberJoined: (member) ->
    $('#members').append "<li id='user_#{member.id}'>#{member.username}</li>"

  _memberLeft: (member) ->
    $('#members').find("li#user_#{member.id}").remove()

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
loco-rails-3.0.3 test/dummy/app/assets/javascripts/views/user/rooms/show.coffee
loco-rails-2.5.3 test/dummy/app/assets/javascripts/views/user/rooms/show.coffee
loco-rails-2.5.2 test/dummy/app/assets/javascripts/views/user/rooms/show.coffee
loco-rails-3.0.2 test/dummy/app/assets/javascripts/views/user/rooms/show.coffee
loco-rails-3.0.1 test/dummy/app/assets/javascripts/views/user/rooms/show.coffee
loco-rails-2.5.1 test/dummy/app/assets/javascripts/views/user/rooms/show.coffee
loco-rails-2.5.0 test/dummy/app/assets/javascripts/views/user/rooms/show.coffee
loco-rails-2.4.0 test/dummy/app/assets/javascripts/views/user/rooms/show.coffee
loco-rails-2.3.0 test/dummy/app/assets/javascripts/views/user/rooms/show.coffee
loco-rails-3.0.0 test/dummy/app/assets/javascripts/views/user/rooms/show.coffee
loco-rails-2.2.2 test/dummy/app/assets/javascripts/views/user/rooms/show.coffee
loco-rails-2.2.1 test/dummy/app/assets/javascripts/views/user/rooms/show.coffee
loco-rails-2.2.0 test/dummy/app/assets/javascripts/views/user/rooms/show.coffee
loco-rails-2.1.0 test/dummy/app/assets/javascripts/views/user/rooms/show.coffee
loco-rails-2.0.0 test/dummy/app/assets/javascripts/views/user/rooms/show.coffee
loco-rails-1.5.2 test/dummy/app/assets/javascripts/views/user/rooms/show.coffee
loco-rails-1.5.1 test/dummy/app/assets/javascripts/views/user/rooms/show.coffee
loco-rails-1.5.0 test/dummy/app/assets/javascripts/views/user/rooms/show.coffee
loco-rails-1.4.0 test/dummy/app/assets/javascripts/views/user/rooms/show.coffee
loco-rails-1.3.3 test/dummy/app/assets/javascripts/views/user/rooms/show.coffee