Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding invitations and list of who invited you to race
- Loading branch information
Showing
19 changed files
with
124 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Place all the behaviors and hooks related to the matching controller here. | ||
// All this logic will automatically be available in application.js. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,20 @@ | ||
CodeRacer.Views.Online = Backbone.View.extend({ | ||
initialize: function () { | ||
this.listenTo(this.collection, 'add', this.render); | ||
}, | ||
|
||
template: JST['users/online'], | ||
|
||
render: function () { | ||
var content = this.template({ | ||
users: this.collection | ||
}); | ||
|
||
var content = this.template(); | ||
this.$el.html(content); | ||
|
||
this.collection.each(function (user) { | ||
var view = new CodeRacer.Views.OnlineItem({ | ||
model: user | ||
}); | ||
this.$('ul').append(view.render().$el); | ||
}, this); | ||
return this; | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
CodeRacer.Views.OnlineItem = Backbone.View.extend({ | ||
template: JST['users/online_item'], | ||
tagName: "li", | ||
className: "list-group-item clearfix", | ||
events: { | ||
'click .invite': 'invite' | ||
}, | ||
|
||
invite: function () { | ||
var stageUrl = $('.big-input').val(); | ||
$.ajax({ | ||
url: "/api/invitations", | ||
type: "POST", | ||
data: { | ||
id: this.model.id, | ||
url: stageUrl, | ||
nickname: CURRENT_RACER.nickname | ||
} | ||
}); | ||
}, | ||
|
||
render: function () { | ||
var content = this.template({ | ||
user: this.model | ||
}); | ||
|
||
this.$el.html(content); | ||
return this; | ||
}, | ||
}); |
2 changes: 1 addition & 1 deletion
2
app/assets/stylesheets/api/online_users.scss → app/assets/stylesheets/api/invitations.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
// Place all the styles related to the Api/OnlineUsers controller here. | ||
// Place all the styles related to the Api/Invitations controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -173,3 +173,11 @@ html, body { | |
.timer-right { | ||
text-align: right | ||
} | ||
|
||
.start-race { | ||
margin: 0 auto; | ||
} | ||
|
||
.invite { | ||
float: right; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
<h4>Who's online?</h4> | ||
|
||
<ul class="list-group"> | ||
<% users.each(function(user) { %> | ||
<li class="list-group-item"> | ||
<%= user.escape("nickname") %> | ||
</li> | ||
<% }) %> | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<%= user.escape("nickname") %> | ||
<button class="invite btn btn-success btn-sm">Invite</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module Api | ||
class InvitationsController < ApplicationController | ||
def create | ||
Pusher['presence'].trigger('invite', params) | ||
render json: params | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module Api::InvitationsHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe Api::InvitationsController, :type => :controller do | ||
|
||
end |