Skip to content

Instantly share code, notes, and snippets.

@mspanish
Created August 20, 2013 03:56
Show Gist options
  • Select an option

  • Save mspanish/6276958 to your computer and use it in GitHub Desktop.

Select an option

Save mspanish/6276958 to your computer and use it in GitHub Desktop.

Revisions

  1. mspanish created this gist Aug 20, 2013.
    65 changes: 65 additions & 0 deletions new_gist_file
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,65 @@
    jQuery(function() {
    // Create our namespace and related organizers
    window.DartsLeague = {};
    DartsLeague.Models = {};
    DartsLeague.Collections = {};
    DartsLeague.Views = {};

    DartsLeague.TourneysApp = new Backbone.Marionette.Application({});

    /********************************************
    * Models and Collections
    ********************************************/

    // Member model/collection
    DartsLeague.Models.Member = Backbone.Model.extend({
    });

    DartsLeague.Collections.Members = Backbone.Collection.extend({
    model: DartsLeague.Models.Member
    });

    // Team model/collection
    DartsLeague.Models.Team = Backbone.Model.extend({
    initialize: function(){
    var teamMembers = new DartsLeague.Collections.Members(this.get("teamMembers"));
    this.set("teamMembers", teamMembers);
    }
    });

    DartsLeague.Collections.Teams = Backbone.Collection.extend({
    model: DartsLeague.Models.Team
    });

    // Game model, no collection
    DartsLeague.Models.Game = Backbone.Model.extend({
    });

    // TourneyGame model/collection
    DartsLeague.Models.TourneyGame = Backbone.Model.extend({
    initialize: function(){
    var game = new DartsLeague.Models.Game(this.get('game'));
    var teams = new DartsLeague.Collections.Teams(this.get('teams'));
    this.set('game', game);
    this.set('teams', teams);
    }
    });

    DartsLeague.Collections.TourneyGames = Backbone.Collection.extend({
    model: DartsLeague.Models.TourneyGame
    });

    // Tourney model/collection
    DartsLeague.Models.Tourney = Backbone.Model.extend({
    initialize: function(){
    var tourneyGames = new DartsLeague.Collections.TourneyGames(this.get("tourneyGames"));
    this.set("tourneyGames", tourneyGames);
    }
    });

    DartsLeague.Collections.Tourneys = Backbone.Collection.extend({
    model: DartsLeague.Models.Tourney,
    url: './assets/json/mock-darts-tourneys.json'
    });

    });