2012-07-19 14:25:01 +00:00
|
|
|
|
// js/modules/dashboard.js
|
|
|
|
|
// Module reference argument, assigned at the bottom
|
|
|
|
|
|
|
|
|
|
(function (Dashboard) {
|
|
|
|
|
|
|
|
|
|
// Dependencies
|
2012-07-19 21:45:22 +00:00
|
|
|
|
var Util = app.module("util"),
|
|
|
|
|
Room = app.module("room");
|
2012-07-19 14:25:01 +00:00
|
|
|
|
|
|
|
|
|
Dashboard.Model = Backbone.Model.extend({
|
|
|
|
|
defaults: {
|
|
|
|
|
rooms: Room.List
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Dashboard.View = Backbone.View.extend({
|
|
|
|
|
el: $('#content'),
|
|
|
|
|
initialize: function () {
|
|
|
|
|
// load the data -- dummy -- struts/node backend
|
|
|
|
|
this.rooms = new Room.List(dataModel.rooms);
|
|
|
|
|
},
|
|
|
|
|
render: function () {
|
|
|
|
|
this.$el.html('');
|
|
|
|
|
_.each(this.rooms.models, function (room) {
|
|
|
|
|
this.renderRoom(room);
|
|
|
|
|
}, this);
|
|
|
|
|
return this;
|
|
|
|
|
},
|
|
|
|
|
renderRoom: function (room) {
|
|
|
|
|
var roomView = new Room.View({
|
|
|
|
|
model: room
|
|
|
|
|
});
|
|
|
|
|
this.$el.append(roomView.render().el);
|
|
|
|
|
},
|
|
|
|
|
renderRoomWithId: function (roomId) {
|
|
|
|
|
this.$el.html('');
|
|
|
|
|
_.each(this.rooms.models, function (room) {
|
|
|
|
|
if (room.get('roomId') == roomId) {
|
|
|
|
|
this.renderRoom(room);
|
|
|
|
|
}
|
|
|
|
|
}, this);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})(app.module("dashboard"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|