app/assets/javascripts/_main.js.coffee
43b171a9
 this.App =
52ef7688
   debug: (msg) ->
     console.log msg
 
43b171a9
   UI:
1ec65f29
     setAutoHeight: ->
43b171a9
       height = $(window).height()
       $("#height-setter-1").css({height: height - 50})
       $("#height-setter-2").css({height: height - $('#tabbar').outerHeight() - $('#msg-writer').outerHeight() - 57})
ff94bdbf
 
   Com:
b27f285a
     connect: (callback) ->
       App._dispatcher = new WebSocketRails('www.xmpp.dev:3000/websocket')
       App._dispatcher.on_open = =>
         @_setupBackboneComponents()
52ef7688
         @_bindEvents()
b27f285a
         callback?()
ff94bdbf
 
     fetch: (options) ->
b27f285a
       _.defaults(options, {data: {} })
ff94bdbf
       App._dispatcher.trigger(options.event, options.data, options.success, options.error)
b27f285a
 
52ef7688
     initRoster: ->
       App.Com.fetch(
         event: 'app.roster.initRoster'
         success: (data) ->
           _.each(data.contacts, (jid) ->
             newContact = new Xmpp.Models.Contact(id: jid, jid: jid)
b27f285a
             App.Collections.Contacts.add newContact
           )
52ef7688
       )
 
     startFetchingVcards: ->
       App.Com.fetch(event: 'app.roster.startFetchingVcards')
 
     startPollingRoster: ->
       App.Com.fetch(event: 'app.roster.startPolling')
b27f285a
 
43ad79fa
     setPresence: ->
       App.Com.fetch(event: 'app.roster.setPresence')
 
b27f285a
     _setupBackboneComponents: ->
       App.Collections.Contacts = new Xmpp.Collections.ContactsCollection()
 
52ef7688
     _bindEvents: ->
       App._dispatcher.bind('app.roster.statusChanged', (result) ->
         App.debug 'change contact state'
         App.Collections.Contacts.updateStatus(result)
       )
 
       App._dispatcher.bind('app.roster.vcard', (result) ->
         App.debug 'got vcard'
         App.Collections.Contacts.udpateVcard(result)
       )
 
b27f285a
   Collections:
     Contacts: null