Skip to content

Commit

Permalink
Adds events for attachments
Browse files Browse the repository at this point in the history
Signed-off-by: Akash Manohar J <akash@akash.im>
  • Loading branch information
HashNuke committed Apr 10, 2012
1 parent 41b5042 commit b8c3e00
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion app/assets/javascripts/backbone/data/attachments.js.coffee
@@ -1,2 +1,23 @@
class Kandan.Data.Attachments
# TODO use this for the file list plugin
@callbacks: { "change": [] }
@cache: []


@all: (callback)->
attachments = new Kandan.Collections.Attachments([], {
channel_id: Kandan.Data.Channels.activeChannelId()
})
attachments.fetch({ success: callback })

@registerCallback: (event, callback)->
@callbacks[event].push(callback)

@runCallbacks: (event, data)->
@cache = data.extra.attachments
callback(data) for callback in @callbacks[event]


@unregisterCallback: (event, callback)->
delete @callbacks[@callbacks.indexOf(callback)]
@callbacks.filter (element, index, array)->
element!=undefined

0 comments on commit b8c3e00

Please sign in to comment.