Skip to content

Commit

Permalink
Merges master and solves conflicts
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 Mar 28, 2012
2 parents bb9ec49 + 84ed0d6 commit cbb5873
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 53 deletions.
17 changes: 15 additions & 2 deletions app/assets/javascripts/backbone/broadcasters/faye.js.coffee
Expand Up @@ -10,15 +10,28 @@ class Kandan.Broadcasters.FayeBroadcaster
auth_token: Kandan.Helpers.Users.current_user().auth_token
}
callback(message)

incoming: (message, callback)->
console.log "incoming", message
callback(message)
}
@faye_client.addExtension(auth_extension)

@faye_client.bind "transport:down", ()->
console.log "Comm link to Cybertron is down!"

@faye_client.bind "transport:up", ()->
console.log "Comm link is up!"

@faye_client.addExtension(auth_extension)
@faye_client.subscribe "/app/activities", (data)=>

@faye_client.subscribe "/app/user_activities", (data)=>
$(document).data('active_users', data.data.active_users)
Kandan.Helpers.Channels.add_activity({
user: data.data.user,
action: data.event.split("#")[1]
})

@faye_client.subscribe "/app/channel_activities", (data)=>
$(document).data('active_users', data.data.active_users)
Kandan.Helpers.Channels.add_activity({
user: data.data.user,
Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/backbone/data/active_users.js.coffee
Expand Up @@ -7,10 +7,10 @@ class Kandan.Data.ActiveUsers
@register_callback: (event, callback)->
@callbacks[event].push(callback)

@run_callbacks: (event)->
@runCallbacks: (event)->
callback() for callback in @callbacks[event]

@unregister_callback: (event, callback)->
@unregisterCallback: (event, callback)->
delete @callbacks[@callbacks.indexOf(callback)]
@callbacks.filter (element, index, array)->
element!=undefined
8 changes: 4 additions & 4 deletions app/assets/javascripts/backbone/data/channels.js.coffee
@@ -1,15 +1,15 @@
class Kandan.Data.Channels
@callbacks: {"change": [] }

@active_channel_id: ()->
Kandan.Helpers.Channels.get_active_channel_id()
@activeChannelId: ()->
Kandan.Helpers.Channels.getActiveChannelId()

@all: (callbacks)->
attachments = new Kandan.Collections.Attachments([], {
channel_id: @active_channel_id()
channel_id: @activeChannelId()
})

@run_callbacks: (event)->
@runCallbacks: (event)->
callback() for callback in @callbacks[event]

@register_callback: (event, callback)->
Expand Down
78 changes: 39 additions & 39 deletions app/assets/javascripts/backbone/helpers/channels.js.coffee
Expand Up @@ -10,33 +10,33 @@ class Kandan.Helpers.Channels
$tabNav.find(".create_channel").parent().remove()
$tabNav.append("<li>"+$createButton+"</li>")

@pastAutoScrollThreshold: (channel_id)->
currentPosition = @currentScrollPosition channel_id
@pastAutoScrollThreshold: (channelId)->
currentPosition = @currentScrollPosition channelId
totalHeight = $(document).height() - $(window).height()
scrollPercentage = (currentPosition) / (totalHeight)
scrollPercentage > @options.autoScrollThreshold

@scrollToLatestMessage: (channel_id)->
$("#channels-#{channel_id}").scrollTop(100000)
@scrollToLatestMessage: (channelId)->
$("#channels-#{channelId}").scrollTop(100000)

@currentScrollPosition: (channel_id)->
$("#channels-#{channel_id}").scrollTop()
@currentScrollPosition: (channelId)->
$("#channels-#{channelId}").scrollTop()

@channel_activities_el: (channel_id)->
$("#channel-activities-#{channel_id}")
@channel_activities_el: (channelId)->
$("#channel-activities-#{channelId}")

@channel_pagination_el: (channel_id)->
$("#channels-#{channel_id} .pagination")
@channel_pagination_el: (channelId)->
$("#channels-#{channelId} .pagination")

@get_channel_id_from_tab_index: (tab_index)->
@getChannelIdFromTabIndex: (tabIndex)->
$("#channels .ui-tabs-panel")
.eq(tab_index)
.eq(tabIndex)
.data('channel_id')

@selected_tab: ()->
$('#channels').tabs('option', 'selected')

@get_active_channel_id: ()->
@getActiveChannelId: ()->
if $(document).data('active_channel_id') == undefined
return $("#channels .ui-tabs-panel")
.eq(@selected_tab())
Expand All @@ -58,16 +58,16 @@ class Kandan.Helpers.Channels
$channelActivities.prev().data("oldest", oldest)

@deleteChannel: (channelIndex)->
channelID = @get_channel_id_from_tab_index(channelIndex)
channel = new Kandan.Models.Channel({id: channelID})
channelId = @getChannelIdFromTabIndex(channelIndex)
channel = new Kandan.Models.Channel({id: channelId})
return false if @confirmDeletion() == false

channel.destroy({success: ()=>
$("#channels").tabs("remove", channelIndex)
})

@channel_not_exists: (channel_id)->
$("#channels-#{channel_id}").length == 0
@channel_not_exists: (channelId)->
$("#channels-#{channelId}").length == 0


@create_channel_area: (channel)->
Expand All @@ -81,10 +81,10 @@ class Kandan.Helpers.Channels
$(channel_area).data('channel_id', channel.get('id'))


@new_activity_view: (activity_attributes)->
activity = new Kandan.Models.Activity(activity_attributes)
activity_view = new Kandan.Views.ShowActivity({activity: activity})
return activity_view
@new_activity_view: (activityAttributes)->
activity = new Kandan.Models.Activity(activityAttributes)
activityView = new Kandan.Views.ShowActivity({activity: activity})
return activityView


@add_activity: (activity_attributes, state)->
Expand All @@ -97,32 +97,32 @@ class Kandan.Helpers.Channels
@add_notification(activity_attributes)

if activity_attributes.channel_id
channel_id = activity_attributes.channel_id
channelId = activity_attributes.channel_id
else
channel_id = @get_active_channel_id()
@scrollToLatestMessage(channel_id) if @pastAutoScrollThreshold(channel_id)
channelId = @getActiveChannelId()
@scrollToLatestMessage(channelId) if @pastAutoScrollThreshold(channelId)

@add_message: (activity_attributes, state)->
@channel_activities_el(activity_attributes.channel_id)
.append(@new_activity_view(activity_attributes).render().el)
@set_pagination_data(activity_attributes.channel_id)

@add_message: (activityAttributes, state)->
@channel_activities_el(activityAttributes.channel_id)
.append(@new_activity_view(activityAttributes).render().el)
@set_pagination_data(activityAttributes.channel_id)
# @flushActivities($(el).parent().data("channel_id"))


@add_notification: (activity_attributes)->
$channel_elements = $(".channel-activities")
activity_attributes["created_at"] = new Date()
for el in $channel_elements
$(el).append(@new_activity_view(activity_attributes).render().el)
@add_notification: (activityAttributes)->
$channelElements = $(".channel-activities")
activityAttributes["created_at"] = new Date()
for el in $channelElements
$(el).append(@new_activity_view(activityAttributes).render().el)
@flushActivities($(el).parent().data("channel_id"))


@set_pagination_state: (channel_id, more_activities, oldest)->
@channel_pagination_el(channel_id).data('oldest', oldest)
if more_activities == true
@channel_pagination_el(channel_id).show()
@set_pagination_state: (channelId, moreActivities, oldest)->
@channel_pagination_el(channelId).data('oldest', oldest)
if moreActivities == true
@channel_pagination_el(channelId).show()
else
@channel_pagination_el(channel_id).hide()
@channel_pagination_el(channelId).hide()


@set_pagination_data: (channel_id)->
Expand Down
6 changes: 3 additions & 3 deletions app/assets/javascripts/backbone/kandan.js.coffee
Expand Up @@ -49,7 +49,7 @@ window.Kandan =

$(document).bind 'changeData', (element, name, value)->
if(name=="active_users")
Kandan.Data.ActiveUsers.run_callbacks('change')
Kandan.Data.ActiveUsers.runCallbacks('change')

active_users = new Kandan.Collections.ActiveUsers()
active_users.fetch({
Expand All @@ -73,9 +73,9 @@ window.Kandan =
$('#channels').tabs({
select: (event, ui)->
$(document).data('active_channel_id',
Kandan.Helpers.Channels.get_channel_id_from_tab_index(ui.index))
Kandan.Helpers.Channels.getChannelIdFromTabIndex(ui.index))
console.log "channel changed to index", ui.index
Kandan.Data.Channels.run_callbacks('change')
Kandan.Data.Channels.runCallbacks('change')
})

$("#channels").tabs 'option', 'tabTemplate', '''
Expand Down
Expand Up @@ -19,7 +19,7 @@ class Kandan.Plugins.Attachments
!!(window.File && window.FileList && window.FileReader)

@channel_id: ()->
Kandan.Data.Channels.active_channel_id()
Kandan.Data.Channels.activeChannelId()

@csrf_param: ->
$('meta[name=csrf-param]').attr('content')
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/backbone/views/chatbox.js.coffee
Expand Up @@ -19,7 +19,7 @@ class Kandan.Views.Chatbox extends Backbone.View
activity = new Kandan.Models.Activity({
'content': $chatbox.val(),
'action': 'message',
'channel_id': Kandan.Helpers.Channels.get_active_channel_id()
'channel_id': Kandan.Helpers.Channels.getActiveChannelId()
})

activity.save({},{success: ()->
Expand Down
1 change: 0 additions & 1 deletion lib/faye_extensions/devise_auth.rb
@@ -1,7 +1,6 @@
class DeviseAuth
def incoming(message, callback)
if message['channel'] == "/meta/subscribe"
puts "MESSAGE: #{message.inspect}"
auth_token = message['ext']['auth_token']
user = User.find_by_authentication_token(auth_token)
if user
Expand Down

0 comments on commit cbb5873

Please sign in to comment.