Skip to content

Commit

Permalink
Adds bourbon, basic style and fixes to widgets
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 22, 2012
1 parent d14f9eb commit 9af7613
Show file tree
Hide file tree
Showing 19 changed files with 768 additions and 51 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ gem 'remotipart'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'

gem 'bourbon'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'execjs'
gem 'eco'
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ GEM
nokogiri (<= 1.5.0)
uuidtools (~> 2.1)
bcrypt-ruby (3.0.1)
bourbon (1.4.0)
sass (>= 3.1)
builder (3.0.0)
bushido (0.0.36)
highline (>= 1.6.1)
Expand Down Expand Up @@ -228,6 +230,7 @@ PLATFORMS

DEPENDENCIES
aws-sdk
bourbon
bushido
capybara
coffee-rails (~> 3.2.1)
Expand Down
6 changes: 3 additions & 3 deletions app/assets/javascripts/backbone/kandan.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ window.Kandan =

chat_area = new Kandan.Views.ChatArea({channels: channels})
create_channel = new Kandan.Views.CreateChannel()
$(".create_channel").html create_channel.render().el
# $(".create_channel").html create_channel.render().el

# TODO move broadcast subscription to a helper
# TODO change this to use the broadcaster from the settings
Expand All @@ -46,9 +46,9 @@ window.Kandan =
Kandan.Plugins.init_all()


$(".container").html(chat_area.render().el)
$(".main-area").html(chat_area.render().el)
chatbox = new Kandan.Views.Chatbox()
$(".container").append(chatbox.render().el)
$(".main-area").append(chatbox.render().el)
$('#channels').tabs({select: (event, ui)->
$(document).data('active_channel_id',
Kandan.Helpers.Channels.get_channel_id_from_tab_index(ui.index))
Expand Down
7 changes: 3 additions & 4 deletions app/assets/javascripts/backbone/plugins/attachments.js.coffee
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
class Kandan.Plugins.Attachments

@widget_title: "Attachments"
@widget_name: "attachments"
@widget_title: "Media"
@plugin_namespace: "Kandan.Plugins.Attachments"

@template: _.template('''
Expand Down Expand Up @@ -48,9 +47,9 @@ class Kandan.Plugins.Attachments


@init: ()->
Kandan.Widgets.register @widget_name, @plugin_namespace
Kandan.Widgets.register @plugin_namespace
Kandan.Data.Channels.register_callback "change", ()=>
Kandan.Widgets.render(@widget_name)
Kandan.Widgets.render @plugin_namespace


Kandan.Plugins.register "Kandan.Plugins.Attachments"
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class Kandan.Plugins.MusicPlayer

@plugin_namespace: "Kandan.Plugins.MusicPlayer"
@plugin_id: ""
@widget_name: "music_player"
@widget_title: "Player"
@play_regex: /^\/play .+/
@stop_regex: /^\/stop/
@local_song_data: false
Expand Down Expand Up @@ -49,7 +49,7 @@ class Kandan.Plugins.MusicPlayer


@register_widget: ()->
Kandan.Widgets.register @widget_name, @plugin_namespace
Kandan.Widgets.register @plugin_namespace


@register_modifier: ()->
Expand All @@ -72,7 +72,7 @@ class Kandan.Plugins.MusicPlayer
Kandan.Store.set @plugin_id, {
success: (data)->
@local_song_data = data
Kandan.Widgets.render_widget @widget_name
Kandan.Widgets.render_widget @plugin_namespace
}
})

Expand Down
7 changes: 4 additions & 3 deletions app/assets/javascripts/backbone/plugins/user_list.js.coffee
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
class Kandan.Plugins.UserList

@widget_title: "Users"
@widget_title: "People"
@widget_name: "users"
@plugin_namespace: "Kandan.Plugins.UserList"

@render: ($el)->
$users = $("<ul></ul>")
Expand All @@ -12,8 +13,8 @@ class Kandan.Plugins.UserList


@init: ()->
Kandan.Widgets.register(@widget_name, "Kandan.Plugins.UserList")
Kandan.Widgets.register @plugin_namespace
Kandan.Data.ActiveUsers.register_callback "change", ()=>
Kandan.Widgets.render(@widget_name)
Kandan.Widgets.render @plugin_namespace

Kandan.Plugins.register "Kandan.Plugins.UserList"
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ class Kandan.Routers.Main extends Backbone.Router

index: ()->
view = new Kandan.Views.ChatArea()
$('.container').html(view.render().el)
$('.main-area').html(view.render().el)
$('.channels').tabs()
38 changes: 22 additions & 16 deletions app/assets/javascripts/backbone/widgets.js.coffee
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
class Kandan.Widgets
@widgets: {}

@register: (widget_name, callback)->
@widgets[widget_name] = callback
@register: (widget_namespace)->
@widgets[widget_namespace] = "widget_#{Object.size(@widgets)}"

@all: ()->
@widgets

@widget_names: ()->
widget_names = []
for widget_name of @all()
widget_names.push(widget_name) if @all().hasOwnProperty(widget_name)
widget_names

@init_all: ()->
@init(widget_name) for widget_name in @widget_names()
$.each @widgets, (widget_namespace, el_name)=>
@init(widget_namespace)

@template: _.template '''
<div class="widget" id="widget_<%= element_id %>">
<div class="title"><%= title %></div>
<div class="content" id="<%= element_id %>"></div>
</div>
'''

@init: (widget_namespace)->
widget = eval(widget_namespace)
$(".sidebar .widgets").append(@template({
element_id: @widgets[widget_namespace],
title: widget.widget_title
}))
@render(widget_namespace)

@init: (widget_name)->
# TODO use the widget_name property on the plugin module to get the title
$(".sidebar").append("<h3>#{widget_name}</h3><div class='#{widget_name}'></div>")
@render(widget_name)

@render: (widget_name)->
$widget_el = $(".sidebar .#{widget_name}")
eval(@widgets[widget_name]).render($widget_el) if $widget_el != []
@render: (widget_namespace)->
$widget_el = $("##{@widgets[widget_namespace]}")
eval(widget_namespace).render($widget_el) if $widget_el != []
5 changes: 5 additions & 0 deletions app/assets/javascripts/lib/object.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Object.size = (obj)->
size = 0
for key of obj
size++ if (obj.hasOwnProperty(key))
return size;
Binary file not shown.
Binary file not shown.
Binary file not shown.
16 changes: 0 additions & 16 deletions app/assets/stylesheets/application.css

This file was deleted.

Empty file.
Loading

0 comments on commit 9af7613

Please sign in to comment.