This file contains hidden or 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
| # lib/collections/games.coffee | |
| @Games = new Mongo.Collection('games') |
This file contains hidden or 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
| # server/fixtures.coffee | |
| if Teams.find().count() == 0 | |
| _([ | |
| {name: 'Barcelona'} | |
| {name: 'Manchester City'} | |
| ]).each (data) -> Teams.insert(data) | |
| if Games.find().count() == 0 | |
| game = { |
This file contains hidden or 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
| # client/views/games.coffee | |
| Template.games.helpers | |
| games: -> Games.find() |
This file contains hidden or 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
| <!-- client/views/games.html --> | |
| <template name="games"> | |
| <h3>Games</h3> | |
| {{#if creating}} | |
| <form class="form-create"> | |
| <select name="teamOne"> | |
| {{#each teams}} | |
| <option value="{{_id}}">{{name}}</option> | |
| {{/each}} |
This file contains hidden or 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
| # client/views/games.coffee | |
| Template.games.helpers | |
| teams: -> Teams.find() | |
| games: -> Games.find() | |
| creating: -> Session.get 'creating-game' | |
| Template.games.events | |
| "click .create": (e, tpl) -> | |
| e.preventDefault() |
This file contains hidden or 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
| # client/views/games.coffee | |
| Template.games.helpers | |
| teams: Teams.find() | |
| games: Games.find() | |
| creating: -> Session.get 'creating-game' | |
| Template.games.events | |
| "click .create": (e, tpl) -> | |
| e.preventDefault() |
This file contains hidden or 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
| # client/views/game.coffee | |
| Template.game.events | |
| "click .finish-game": (e, tpl) -> | |
| e.preventDefault() | |
| Games.update({_id: @_id}, {$set: {completed: true}}) | |
| "click .delete-game": (e, tpl) -> | |
| Games.remove(@_id) |
This file contains hidden or 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
| function MyClass(){ | |
| } | |
| MyClass.prototype.method = function(){} | |
| function MySubClass(){ | |
| // use MyClass as the constructor | |
| MyClass.call(this); | |
| } |
This file contains hidden or 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
| // if we keep using Object.create(parent), we might want the parent to | |
| // have a constructor function so all children turn out the same | |
| parent = { | |
| constructor: function(name) { | |
| this._name = name; | |
| } | |
| } | |
| child1 = Object.create(parent); |
This file contains hidden or 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
| var Engine = famous.core.Engine; | |
| var Surface = famous.core.Surface; | |
| var View = famous.core.View; | |
| var Modifier = famous.core.Modifier; | |
| var MyView = function(){ | |
| // Run View as constructor first | |
| View.call(this, arguments); | |
| this.rootMod = new Modifier({ |