Browse files

Fixes, Fixes and Fixes. And then merges 'master' into 'tweaks'

* Changes jQuery events to backbone events
* Fixes channel deletion
* Fixes channels helper and deletes unnecessary methods
* Renames chatarea template to channel_tabs
* Fixes channel notification processing
* Uses a backbone view instead of directly appending channel tabs html

Conflicts:
	app/assets/javascripts/backbone/helpers/channels.js.coffee
	app/assets/javascripts/backbone/views/chatarea.js.coffee

Signed-off-by: Akash Manohar J <akash@akash.im>
  • Loading branch information...
2 parents c5de3c7 + 7fc3f7a commit 109eda17a52f6c041c7fed28f3d07fb2f80f1274 @HashNuke HashNuke committed Apr 5, 2012
View
2 app/assets/javascripts/backbone/broadcasters/faye.js.coffee
@@ -22,7 +22,7 @@ class Kandan.Broadcasters.FayeBroadcaster
@faye_client.subscribe "/app/activities", (data)=>
[entityName, eventName] = data.event.split("#")
@processEventsForUser(eventName, data) if entityName == "user"
- @processEventsForUser(eventName, data) if entityName == "channel"
+ @processEventsForChannel(eventName, data) if entityName == "channel"
processEventsForUser: (eventName, data)->
View
26 app/assets/javascripts/backbone/helpers/channels.js.coffee
@@ -4,26 +4,19 @@ class Kandan.Helpers.Channels
autoScrollThreshold: 0.90
maxActivities: 5
- @replaceCreateButton: ()->
- $tabNav = $(".create_channel").parent().parent()
- $tabNav.find(".create_channel").parent().remove()
- $tabNav.append JST['create_channel']()
-
@pastAutoScrollThreshold: (channelId)->
currentPosition = @currentScrollPosition channelId
totalHeight = $(document).height() - $(window).height()
scrollPercentage = (currentPosition) / (totalHeight)
scrollPercentage > @options.autoScrollThreshold
@scrollToLatestMessage: (channelId)->
- console.log("scrolling to last message");
- $('document').scrollTop($('docoument').height())
- #@channel_activities_el(channelId).parent().scrollTop(100000)
+ console.log("scrolling to last message")
+ $(document).scrollTop($(document).height()+9000)
@currentScrollPosition: (channelId)->
- console.log("current scroll position");
- $('document').scrollTop()
- #@channel_activities_el(channelId).parent().scrollTop()
+ console.log("current scroll position")
+ $(document).scrollTop()
@channel_activities_el: (channelId)->
$("#channel-activities-#{channelId}")
@@ -77,12 +70,15 @@ class Kandan.Helpers.Channels
@deleteChannelByTabIndex(tabIndex, true)
@deleteChannelByTabIndex: (tabIndex, deleted)->
+ # NOTE gotcha, 0 index being passed a natural index from the html views
deleted = deleted || false
- console.log "try deleting #{tabIndex}"
channelId = @getChannelIdByTabIndex(tabIndex)
- console.log "d ", channelId
+ throw "NO CHANNEL ID" if channelId == 'undefined'
+
channel = new Kandan.Models.Channel({id: channelId})
return @confirmAndDeleteChannel(channel, tabIndex) if not deleted
+
+ # NOTE this is for participating users who do not require confirmation
console.log "TAB INDEX", tabIndex
$("#kandan").tabs("remove", tabIndex)
@@ -95,9 +91,9 @@ class Kandan.Helpers.Channels
@createChannelArea: (channel)->
channelArea = "#channels-#{channel.get('id')}"
totalTabs = $("#kandan").tabs("length")
-
+ $createTab = $(".create_channel").parents('li').detach()
$("#kandan").tabs('add', channelArea, "#{channel.get("name")}", totalTabs)
- Kandan.Helpers.Channels.replaceCreateButton()
+ $createTab.appendTo('ul.ui-tabs-nav')
view = new Kandan.Views.ChannelPane({channel: channel})
view.render $(channelArea)
$(channelArea).data('channel_id', channel.get('id'))
View
7 app/assets/javascripts/backbone/kandan.js.coffee
@@ -35,7 +35,7 @@ window.Kandan =
registerAppEvents: ()->
Kandan.Data.ActiveUsers.registerCallback "change", (data)->
Kandan.Helpers.Channels.add_activity({
- user: data.user,
+ user: data.entity,
action: data.event.split("#")[1]
})
@@ -50,6 +50,9 @@ window.Kandan =
$(document).data('active_channel_id',
Kandan.Helpers.Channels.getChannelIdByTabIndex(ui.index))
Kandan.Data.Channels.runCallbacks('change')
+ add: (event, ui) ->
+ $('.header .ui-tabs-panel:last').detach().appendTo('#channels')
+ $('#kandan').tabs('option', 'disabled', [])
})
$("#kandan").tabs 'option', 'tabTemplate', '''
@@ -66,6 +69,8 @@ window.Kandan =
initChatArea: (channels)->
chatArea = new Kandan.Views.ChatArea({channels: channels})
$(".main-area").html(chatArea.render().el)
+ $(document).scrollTop($(document).height()+9000)
+
onFetchActiveUsers: (channels)=>
return (activeUsers)=>
View
7 app/assets/javascripts/backbone/views/channel_pane.js.coffee
@@ -3,19 +3,20 @@ class Kandan.Views.ChannelPane extends Backbone.View
render: (container)->
container = container || $(@el)
+ console.log("channel view render", container);
$(container).html @paginatedActivitiesView()
$(container).append @chatboxView()
@setIdAndData(container)
@
-
+
setIdAndData: (container)->
$(container).attr "id", "channels-#{@options.channel.get("id")}"
$(container).data "channel_id", @options.channel.get('id')
-
+
paginatedActivitiesView: ()->
view = new Kandan.Views.PaginatedActivities({channel: @options.channel})
view.render().el
-
+
chatboxView: ()->
view = new Kandan.Views.Chatbox({channel: @options.channel})
view.render().el
View
6 app/assets/javascripts/backbone/views/channel_tabs.js.coffee
@@ -1,5 +1,5 @@
class Kandan.Views.ChannelTabs extends Backbone.View
- template: JST['chatarea']
+ template: JST['channel_tabs']
tagName: 'ul'
events:
@@ -23,7 +23,5 @@ class Kandan.Views.ChannelTabs extends Backbone.View
console.log "create channel: #{channelName}"
deleteChannel: (event)->
- console.log "deleteChannel"
- channelIndex = $(event.target).parent().prevAll().length
- console.log "request for deletion", channelIndex
+ channelIndex = $(event.target).closest('li').prevAll().length
Kandan.Helpers.Channels.deleteChannelByTabIndex(channelIndex) if channelIndex != 0
View
2 app/assets/javascripts/backbone/views/chatarea.js.coffee
@@ -1,6 +1,6 @@
class Kandan.Views.ChatArea extends Backbone.View
- render: ()->
+ render: ->
tabView = new Kandan.Views.ChannelTabs({channels: @options.channels})
$('.header .logo').after(tabView.render().el)
View
16 app/assets/stylesheets/_base.sass
@@ -21,6 +21,7 @@
padding: 0 5px
+box-shadow(inset 0px -7px 6px -5px #3a4547)
border-bottom: 1px solid #FFF
+ margin-top: -2px
.user_menu_link
float: right
@@ -43,13 +44,16 @@
background-color: $header-bg-1
+background-image(linear-gradient($header-bg-1, $header-bg-2))
+border-radius(4px)
- position: absolute
+ position: fixed
right: 0px
+ top: 0px
z-index: 9000
- height: auto
+ height: 32px
width: 100px
padding: 5px
display: none
+ bottom: -24px
+ margin-top: 31px
a
color: #FFF
@@ -68,20 +72,20 @@
html
+full-height
+ width: 100%
body
background: $page-bg url(image_path('page_bg.png')) repeat
height: 100%
min-height: 100%
+ width: 100%
font-size: 13px
font-family: 'PT Sans', sans-serif
.main-area
- +full-height
width: $main-area-width
float: left
border-right: 1px solid #CDD1D4
+ padding-bottom: 70px
+ padding-top: 22px
-
-.main-area, .sidebar
- padding-top: 15px
View
19 app/assets/stylesheets/_chat_area.sass
@@ -84,7 +84,6 @@ html body .ui-tabs .ui-tabs-nav li
height: 88%
background: #FFF
padding: 10px
- padding-bottom: 72px
.pagination
text-decoration: underline
cursor: pointer
@@ -93,14 +92,16 @@ html body .ui-tabs .ui-tabs-nav li
.chatbox
+border-bottom-radius(4px)
- +background-image(linear-gradient($chatbox-bg-1, $chatbox-bg-2))
+box-shadow(5px 0px 5px -3px #cccccc, -5px 0px 5px -3px #cccccc, 0px 5px 5px 0px #cccccc)
float: left
- border-top: 1px solid #EBEFF1
+ border-top: 1px solid #f5f8f9
padding: 10px 0px 10px 10px
- width: 77%
+ width: 77.2%
position: fixed
bottom: 0px
+ margin-bottom: 20px
+ background: #e6edef
+ z-index: 600
textarea
+border-top-left-radius(4px)
+border-bottom-left-radius(4px)
@@ -123,3 +124,13 @@ html body .ui-tabs .ui-tabs-nav li
margin: 0px
height: 40px
font-size: 16px
+
+#mask
+ position: fixed
+ z-index: 100
+ bottom: 0
+ display: block
+ height: 30px
+ margin-left: -16px
+ width: 81%
+ background: #E6EBEE url("/assets/page_bg.png") repeat
View
0 app/assets/templates/chatarea.jst.eco → app/assets/templates/channel_tabs.jst.eco
File renamed without changes.
View
13 app/views/main/index.html.erb
@@ -15,9 +15,7 @@
<div class="user"></div>
</a>
- <div class="user_menu">
- <a href="<%= destroy_user_session_path %>">logout</a>
- </div>
+
<div class="search">
<form method="get" action="/search" target="_blank">
@@ -27,11 +25,18 @@
</div>
<div id="app_body">
- <div class="main-area"></div>
+ <div class="main-area"> </div>
<div class="sidebar">
<div class="widgets"></div>
</div>
</div>
+
+ <div id="mask">&nbsp;</div>
+
+ <div class="user_menu">
+ <a href="<%= destroy_user_session_path %>">logout</a>
+ </div>
+
</div>

0 comments on commit 109eda1

Please sign in to comment.