diff --git a/app/assets/javascripts/backbone/broadcasters/faye.js.coffee b/app/assets/javascripts/backbone/broadcasters/faye.js.coffee index bd491af0..15e47de5 100644 --- a/app/assets/javascripts/backbone/broadcasters/faye.js.coffee +++ b/app/assets/javascripts/backbone/broadcasters/faye.js.coffee @@ -28,13 +28,11 @@ class Kandan.Broadcasters.FayeBroadcaster @faye_client.subscribe "/app/channel_activities", (data)=> # TODO action makes way for channel rename to be added later - console.log data Kandan.Helpers.Channels.deleteChannelById(data.channel.id) if data.action == "delete" subscribe: (channel)-> subscription = @faye_client.subscribe channel, (data)=> - console.log "faye", data Kandan.Helpers.Channels.add_activity(data) subscription.errback(()-> alert "Oops! could not connect to the server" diff --git a/app/assets/javascripts/backbone/helpers/channels.js.coffee b/app/assets/javascripts/backbone/helpers/channels.js.coffee index 85f4bb63..be7bb396 100644 --- a/app/assets/javascripts/backbone/helpers/channels.js.coffee +++ b/app/assets/javascripts/backbone/helpers/channels.js.coffee @@ -2,7 +2,7 @@ class Kandan.Helpers.Channels @options: autoScrollThreshold: 0.90 - maxActivities: 10 + maxActivities: 5 @replaceCreateButton: ()-> $tabNav = $(".create_channel").parent().parent() @@ -17,10 +17,10 @@ class Kandan.Helpers.Channels scrollPercentage > @options.autoScrollThreshold @scrollToLatestMessage: (channelId)-> - $("#channels-#{channelId}").scrollTop(100000) + @channel_activities_el(channelId).parent().scrollTop(100000) @currentScrollPosition: (channelId)-> - $("#channels-#{channelId}").scrollTop() + @channel_activities_el(channelId).parent().scrollTop() @channel_activities_el: (channelId)-> $("#channel-activities-#{channelId}") @@ -28,14 +28,6 @@ class Kandan.Helpers.Channels @channel_pagination_el: (channelId)-> $("#channels-#{channelId} .pagination") - @getTabIndexByChannelId: (channelId)-> - $("#channels-#{channelId}").prev("div").length - - @getChannelIdByTabIndex: (tabIndex)-> - $("#channels .ui-tabs-panel") - .eq(tabIndex) - .data('channel_id') - @selected_tab: ()-> $('#channels').tabs('option', 'selected') @@ -47,23 +39,19 @@ class Kandan.Helpers.Channels else return $(document).data('active_channel_id') + @confirmDeletion: ()-> - confirmDeletion = confirm("Really delete the channel?") - return false if confirmDeletion == false - confirmAgain = confirm("Are you damn sure?") - return confirmAgain + reply = confirm("Really delete the channel?") + return reply + @flushActivities: (channelId)-> $channelActivities = $("#channel-activities-#{channelId}") - if $channelActivities.children().length > @options.maxActivities + if $channelActivities.children().length == @options.maxActivities + 1 oldest = $channelActivities.children().first().data("activity_id") $channelActivities.children().first().remove() $channelActivities.prev().data("oldest", oldest) - @deleteChannelById: (channelId)-> - if @channelExists(channelId) - tabIndex = @getTabIndexByChannelId(channelId) - @deleteChannelByTabIndex(tabIndex, true) @confirmAndDeleteChannel: (channel, tabIndex)-> return false if @confirmDeletion() == false @@ -71,13 +59,31 @@ class Kandan.Helpers.Channels $("#channels").tabs("remove", tabIndex) }) + + @getChannelIdByTabIndex: (tabIndex)-> + $("#channels .ui-tabs-panel") + .eq(tabIndex) + .data('channel_id') + + @getTabIndexByChannelId: (channelId)-> + $("#channels-#{channelId}").prevAll("div").length + + @deleteChannelById: (channelId)-> + if @channelExists(channelId) + tabIndex = @getTabIndexByChannelId(channelId) + @deleteChannelByTabIndex(tabIndex, true) + @deleteChannelByTabIndex: (tabIndex, deleted)-> deleted = deleted || false + console.log "try deleting #{tabIndex}" channelId = @getChannelIdByTabIndex(tabIndex) + console.log "d ", channelId channel = new Kandan.Models.Channel({id: channelId}) return @confirmAndDeleteChannel(channel, tabIndex) if not deleted + console.log "TAB INDEX", tabIndex $("#channels").tabs("remove", tabIndex) + @channelExists: (channelId)-> return true if $("#channels-#{channelId}").length > 0 false @@ -89,8 +95,8 @@ class Kandan.Helpers.Channels $("#channels").tabs('add', channelArea, "#{channel.get("name")}", totalTabs) Kandan.Helpers.Channels.replaceCreateButton() - view = new Kandan.Views.ListActivities({channel: channel}) - $(channelArea).html $(view.render().el).html() + view = new Kandan.Views.ChannelPane({channel: channel}) + view.render $(channelArea) $(channelArea).data('channel_id', channel.get('id')) @@ -99,20 +105,20 @@ class Kandan.Helpers.Channels activityView = new Kandan.Views.ShowActivity({activity: activity}) return activityView + @createChannelIfNotExists: (activityAttributes)-> + if activityAttributes.channel && (not @channelExists(activityAttributes.channel_id)) + @createChannelArea(new Kandan.Models.Channel(activityAttributes.channel)) - @add_activity: (activity_attributes, state)-> - if activity_attributes.channel!=undefined && (not @channelExists(activity_attributes.channel_id)) - @createChannelArea(new Kandan.Models.Channel(activity_attributes.channel)) - if activity_attributes.channel_id - @add_message(activity_attributes, state) - else - @add_notification(activity_attributes) + @add_activity: (activityAttributes, state)-> + @createChannelIfNotExists(activityAttributes) - if activity_attributes.channel_id - channelId = activity_attributes.channel_id + if activityAttributes.channel_id + @add_message(activityAttributes, state) else - channelId = @getActiveChannelId() + @add_notification(activityAttributes) + + channelId = activityAttributes.channel_id || @getActiveChannelId() @scrollToLatestMessage(channelId) if @pastAutoScrollThreshold(channelId) @@ -120,7 +126,7 @@ class Kandan.Helpers.Channels @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")) + @flushActivities(activityAttributes.channel_id) @add_notification: (activityAttributes)-> @@ -130,6 +136,7 @@ class Kandan.Helpers.Channels $(el).append(@new_activity_view(activityAttributes).render().el) @flushActivities($(el).parent().data("channel_id")) + @set_pagination_state: (channelId, moreActivities, oldest)-> @channel_pagination_el(channelId).data('oldest', oldest) if moreActivities == true diff --git a/app/assets/javascripts/backbone/plugins/attachments.js.coffee b/app/assets/javascripts/backbone/plugins/attachments.js.coffee index 7e4b476a..ad6df414 100644 --- a/app/assets/javascripts/backbone/plugins/attachments.js.coffee +++ b/app/assets/javascripts/backbone/plugins/attachments.js.coffee @@ -48,7 +48,6 @@ class Kandan.Plugins.Attachments $widget_el.next().html($upload_form) @init_dropzone @channel_id() - console.log $widget_el.next() $widget_el.next(".action_block").html($upload_form) attachments = new Kandan.Collections.Attachments([], {channel_id: @channel_id()}) diff --git a/app/assets/javascripts/backbone/plugins/user_list.js.coffee b/app/assets/javascripts/backbone/plugins/user_list.js.coffee index c2bdc829..34be08bf 100644 --- a/app/assets/javascripts/backbone/plugins/user_list.js.coffee +++ b/app/assets/javascripts/backbone/plugins/user_list.js.coffee @@ -13,6 +13,7 @@ class Kandan.Plugins.UserList @render: ($el)-> $users = $("
") + $el.next().hide(); for user in Kandan.Data.ActiveUsers.all() console.log "hash", user.gravatar_hash diff --git a/app/assets/javascripts/backbone/views/channel_pane.js.coffee b/app/assets/javascripts/backbone/views/channel_pane.js.coffee index 72c0b3ea..9966c45c 100644 --- a/app/assets/javascripts/backbone/views/channel_pane.js.coffee +++ b/app/assets/javascripts/backbone/views/channel_pane.js.coffee @@ -1,15 +1,21 @@ class Kandan.Views.ChannelPane extends Backbone.View tagName: 'div' - render: ()-> - @channel = @options.channel - - paginatedActivitiesView = new Kandan.Views.PaginatedActivities({channel: @channel}) - $(@el).html paginatedActivitiesView.render().el - - chatbox = new Kandan.Views.Chatbox({channel: @channel}) - $(@el).append chatbox.render().el - - $(@el).attr "id", "channels-#{@channel.get("id")}" - $(@el).data "channel_id", @channel.get('id') - @ \ No newline at end of file + render: (container)-> + container = container || $(@el) + $(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 diff --git a/app/assets/javascripts/backbone/views/chatarea.js.coffee b/app/assets/javascripts/backbone/views/chatarea.js.coffee index 15ccc8bb..20938ae2 100644 --- a/app/assets/javascripts/backbone/views/chatarea.js.coffee +++ b/app/assets/javascripts/backbone/views/chatarea.js.coffee @@ -27,5 +27,6 @@ class Kandan.Views.ChatArea extends Backbone.View console.log "create channel: #{channelName}" deleteChannel: (event)-> - channelIndex = $(event.target).parent().prev().length - Kandan.Helpers.Channels.deleteChannelByTabIndex channelIndex if channelIndex != 0 \ No newline at end of file + channelIndex = $(event.target).parent().prevAll().length + console.log "request for deletion", channelIndex + Kandan.Helpers.Channels.deleteChannelByTabIndex(channelIndex) if channelIndex != 0 \ No newline at end of file diff --git a/app/assets/javascripts/backbone/views/chatbox.js.coffee b/app/assets/javascripts/backbone/views/chatbox.js.coffee index 69aa9601..9cae079e 100644 --- a/app/assets/javascripts/backbone/views/chatbox.js.coffee +++ b/app/assets/javascripts/backbone/views/chatbox.js.coffee @@ -1,29 +1,29 @@ class Kandan.Views.Chatbox extends Backbone.View - template: JST['chatbox'] - tagName: 'div' + template: JST['chatbox'] + tagName: 'div' className: 'chatbox' events: - "keypress textarea": 'postMessageOnEnter' - "click button" : 'postMessage' + "keypress .chat-input": 'postMessageOnEnter' + "click .post" : 'postMessage' postMessageOnEnter: (event)-> - @postMessage() if event.keyCode== 13 + @postMessage(event) if event.keyCode== 13 postMessage: (event)-> - $chatbox = $(@el).find('textarea') + $chatbox = $(event.target).parent().find(".chat-input") activity = new Kandan.Models.Activity({ 'content': $chatbox.val(), 'action': 'message', 'channel_id': @channel.get('id') }) - activity.save({},{success: ()-> - $chatbox = $(@el).find('textarea') + activity.save({},{success: ()=> + $chatbox.val("") }) render: ()-> diff --git a/app/assets/stylesheets/_base.scss b/app/assets/stylesheets/_base.scss index 055e3bbb..7da989f5 100644 --- a/app/assets/stylesheets/_base.scss +++ b/app/assets/stylesheets/_base.scss @@ -7,14 +7,21 @@ @include box-sizing(border-box); } +.logo { + position: fixed; + top: 0px; + left: 0px; + z-index: 1; +} + html { @include full-height; } body { background: $page-bg; - height: 90%; - min-height: 90%; + height: 100%; + min-height: 100%; font-size: 13px; font-family: 'PT Sans', sans-serif; } diff --git a/app/assets/stylesheets/_chat_area.scss b/app/assets/stylesheets/_chat_area.scss index 6124ba7d..61cc189a 100644 --- a/app/assets/stylesheets/_chat_area.scss +++ b/app/assets/stylesheets/_chat_area.scss @@ -1,15 +1,23 @@ #channels { - border-right: 1px solid #CDD1D4; margin-top: 0px; } .ui-widget-header { @include background-image(linear-gradient($header-bg-1, $header-bg-2)); @include border-radius(0px); - height: $header-height; border: none; + + .ui-state-active { + background: $active-tab-bg; + border: none; + + a { + color: $active-tab-color; + } + } } + .ui-tabs { padding: 0px; margin-top: 0px; @@ -19,31 +27,37 @@ .ui-tabs-nav { border-right: 1px solid #404A4D; position: fixed; - width: 100% - } + width: 100%; + padding-top: 6px; + top: 0px; - .ui-tabs-panel { - margin-top: $header-height + 10; - margin-right: 20px; - margin-left: 20px; - padding: 0px; - } + li:first-child { + margin-left: 50px; + } - .ui-widget-content { - margin-top: 20px; - bottom: 80px; - height: 100%; - } + .ui-tab-selected { + background: $active-tab-bg; + border: none; + + a { + color: $active-tab-color; + } + } - .ui-tabs-nav - { - position: relative; - width: 100%; - top: 0px; li a { padding: 3px; } } + + .ui-tabs-panel { + padding-right: 20px; + padding-left: 20px; + border-right: 1px solid #CDD1D4; + } + + .ui-widget-content { + height: 95%; + } } .ui-corner-all .ui-corner-bottom, .ui-corner-bottom, .ui-corner-left, .ui-corner-right, .ui-corner-bl, .ui-corner-br { @@ -71,6 +85,7 @@ height: 88%; background: #FFF; padding: 10px; + margin-top: 37px; .pagination { text-decoration: underline; @@ -116,5 +131,3 @@ height: 40px; } } - - diff --git a/app/assets/stylesheets/_sidebar.scss b/app/assets/stylesheets/_sidebar.scss index 43c2302f..79fc5fe3 100644 --- a/app/assets/stylesheets/_sidebar.scss +++ b/app/assets/stylesheets/_sidebar.scss @@ -27,15 +27,8 @@ background: $search-bg; color: $search-color; border: 2px solid darken($search-bg, 10%); - // @include box-shadow(inset -5px -5px -5px #505A5D); } } - - .logo { - text-align: right; - float: left; - width: 50%; - } } .widgets { @@ -74,6 +67,7 @@ } .content { + @include border-bottom-radius(7px); float: left; width: 100%; clear: both; diff --git a/app/assets/stylesheets/_variables.scss b/app/assets/stylesheets/_variables.scss index 6d8d6508..1b87552d 100644 --- a/app/assets/stylesheets/_variables.scss +++ b/app/assets/stylesheets/_variables.scss @@ -1,3 +1,6 @@ +$page-bg: #E6EBEE; +$main-area-width: 80%; + $panel-bg: #E6EBEE; $chatbox-bg-1: #F3F8F9; $chatbox-bg-2: #DBDFE0; @@ -16,6 +19,8 @@ $sidebar-bg: #E6EBEE; $search-bg: #5D676B; $search-color: #CCC; -$page-bg: #E6EBEE; -$main-area-width: 80%; +$inactive-tab-color: #54595B; +$inactive-tab-bg: #99A2A5; +$active-tab-color: #82898B; +$active-tab-bg: $page-bg; diff --git a/app/assets/templates/chatbox.jst.eco b/app/assets/templates/chatbox.jst.eco index 304822ab..3dacc2c7 100644 --- a/app/assets/templates/chatbox.jst.eco +++ b/app/assets/templates/chatbox.jst.eco @@ -1,2 +1,2 @@ - - + + diff --git a/app/views/main/index.html.erb b/app/views/main/index.html.erb index f2b19e32..0d0fe3c1 100644 --- a/app/views/main/index.html.erb +++ b/app/views/main/index.html.erb @@ -6,6 +6,8 @@ + +