Team:WITS-CSIR SA/client/CalendarModel.js
From 2011.igem.org
Line 209: | Line 209: | ||
week = new Week({ name: 'Week 1' }); | week = new Week({ name: 'Week 1' }); | ||
- | week.days.add(new Day({ name: 'Monday', content: '< | + | week.days.add(new Day({ name: 'Friday', content: '<li>This is a test</li>' })); |
- | week.days.add(new Day({ name: 'Wednesday', content: '< | + | week.days.add(new Day({ name: 'Saturday', content: '<li>This is a test</li>' })); |
+ | month.weeks.add(week); | ||
+ | |||
+ | week = new Week({ name: 'Week 2' }); | ||
+ | week.days.add(new Day({ name: 'Monday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Tuesday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Wednesday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Thursday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Friday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Saturday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Sunday', content: '<li>This is a test</li>' })); | ||
+ | |||
+ | month.weeks.add(week); | ||
+ | |||
+ | week = new Week({ name: 'Week 3' }); | ||
+ | week.days.add(new Day({ name: 'Monday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Tuesday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Wednesday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Thursday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Friday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Saturday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Sunday', content: '<li>This is a test</li>' })); | ||
+ | month.weeks.add(week); | ||
+ | |||
+ | week = new Week({ name: 'Week 4' }); | ||
+ | week.days.add(new Day({ name: 'Monday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Tuesday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Wednesday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Thursday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Friday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Saturday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Sunday', content: '<li>This is a test</li>' })); | ||
+ | month.weeks.add(week); | ||
+ | |||
+ | week = new Week({ name: 'Week 5' }); | ||
+ | week.days.add(new Day({ name: 'Monday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Tuesday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Wednesday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Thursday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Friday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Saturday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Sunday', content: '<li>This is a test</li>' })); | ||
+ | month.weeks.add(week); | ||
+ | |||
+ | week = new Week({ name: 'Week 6' }); | ||
+ | week.days.add(new Day({ name: 'Sunday', content: '<li>This is a test</li>' })); | ||
month.weeks.add(week); | month.weeks.add(week); | ||
month = calendar.year.getMonth('august'); | month = calendar.year.getMonth('august'); | ||
+ | |||
+ | week = new Week({ name: 'Week 1' }); | ||
+ | week.days.add(new Day({ name: 'Friday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Saturday', content: '<li>This is a test</li>' })); | ||
+ | month.weeks.add(week); | ||
week = new Week({ name: 'Week 2' }); | week = new Week({ name: 'Week 2' }); | ||
- | week.days.add(new Day({ name: 'Monday', content: '< | + | week.days.add(new Day({ name: 'Monday', content: '<li>This is a test</li>' })); |
- | week.days.add(new Day({ name: 'Wednesday', content: '< | + | week.days.add(new Day({ name: 'Tuesday', content: '<li>This is a test</li>' })); |
+ | week.days.add(new Day({ name: 'Wednesday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Thursday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Friday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Saturday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Sunday', content: '<li>This is a test</li>' })); | ||
+ | |||
+ | month.weeks.add(week); | ||
+ | |||
+ | week = new Week({ name: 'Week 3' }); | ||
+ | week.days.add(new Day({ name: 'Monday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Tuesday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Wednesday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Thursday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Friday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Saturday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Sunday', content: '<li>This is a test</li>' })); | ||
+ | month.weeks.add(week); | ||
+ | |||
+ | week = new Week({ name: 'Week 4' }); | ||
+ | week.days.add(new Day({ name: 'Monday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Tuesday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Wednesday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Thursday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Friday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Saturday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Sunday', content: '<li>This is a test</li>' })); | ||
+ | month.weeks.add(week); | ||
+ | |||
+ | week = new Week({ name: 'Week 5' }); | ||
+ | week.days.add(new Day({ name: 'Monday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Tuesday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Wednesday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Thursday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Friday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Saturday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Sunday', content: '<li>This is a test</li>' })); | ||
+ | month.weeks.add(week); | ||
+ | |||
+ | week = new Week({ name: 'Week 6' }); | ||
+ | week.days.add(new Day({ name: 'Sunday', content: '<li>This is a test</li>' })); | ||
month.weeks.add(week); | month.weeks.add(week); | ||
month = calendar.year.getMonth('september'); | month = calendar.year.getMonth('september'); | ||
+ | |||
+ | week = new Week({ name: 'Week 1' }); | ||
+ | week.days.add(new Day({ name: 'Friday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Saturday', content: '<li>This is a test</li>' })); | ||
+ | month.weeks.add(week); | ||
week = new Week({ name: 'Week 2' }); | week = new Week({ name: 'Week 2' }); | ||
- | week.days.add(new Day({ name: 'Monday', content: '< | + | week.days.add(new Day({ name: 'Monday', content: '<li>This is a test</li>' })); |
- | week.days.add(new Day({ name: 'Wednesday', content: '< | + | week.days.add(new Day({ name: 'Tuesday', content: '<li>This is a test</li>' })); |
+ | week.days.add(new Day({ name: 'Wednesday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Thursday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Friday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Saturday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Sunday', content: '<li>This is a test</li>' })); | ||
+ | |||
+ | month.weeks.add(week); | ||
+ | |||
+ | week = new Week({ name: 'Week 3' }); | ||
+ | week.days.add(new Day({ name: 'Monday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Tuesday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Wednesday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Thursday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Friday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Saturday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Sunday', content: '<li>This is a test</li>' })); | ||
+ | month.weeks.add(week); | ||
+ | |||
+ | week = new Week({ name: 'Week 4' }); | ||
+ | week.days.add(new Day({ name: 'Monday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Tuesday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Wednesday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Thursday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Friday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Saturday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Sunday', content: '<li>This is a test</li>' })); | ||
+ | month.weeks.add(week); | ||
+ | |||
+ | week = new Week({ name: 'Week 5' }); | ||
+ | week.days.add(new Day({ name: 'Monday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Tuesday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Wednesday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Thursday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Friday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Saturday', content: '<li>This is a test</li>' })); | ||
+ | week.days.add(new Day({ name: 'Sunday', content: '<li>This is a test</li>' })); | ||
+ | month.weeks.add(week); | ||
+ | |||
+ | week = new Week({ name: 'Week 6' }); | ||
+ | week.days.add(new Day({ name: 'Sunday', content: '<li>This is a test</li>' })); | ||
month.weeks.add(week); | month.weeks.add(week); | ||
Revision as of 21:03, 20 September 2011
/// <reference path="../../js/lib/backbone.js" /> /// <reference path="../../js/lib/underscore.js" /> /// <reference path="../../js/lib/jlayout.border.js" /> /// <reference path="../../js/lib/jquery-1.5.1.min.js" /> /// <reference path="../../js/lib/jquery-ui-1.8.14.custom.min.js" /> /// <reference path="../../js/lib/jQuery.BlockUI.js" /> /// <reference path="../../js/lib/jquery.fling.js" /> /// <reference path="../../js/lib/jquery.jlayout.js" /> /// <reference path="../../js/lib/jquery.sizes.js" /> /// <reference path="../../js/lib/modernizr-1.7.min.js" /> /// <reference path="../../js/lib/sammy-latest.min.js" /> /// <reference path="../../js/common.js" />
$(function () {
var Day = Backbone.Model.extend({ name: null, content: null });
var Days = Backbone.Collection.extend({ initialize: function (models, options) { this.opts = options; }, hasContent: function () { return this.length > 0; } });
var Week = Backbone.Model.extend({ initialize: function () { this.days = new Days(null, { Week: this }); }, name: null, hasContent: function () { return this.days.hasContent(); } });
var Weeks = Backbone.Collection.extend({ initialize: function (models, options) { this.opts = options; }, hasContent: function () { for (var i = 0; i < this.length; i++) if (this.models[i].hasContent()) { return true; }
return false; } });
var Month = Backbone.Model.extend({ initialize: function () { this.weeks = new Weeks(null, { Month: this }); }, name: null, hasContent: function () { return this.weeks.hasContent(); } });
var Months = Backbone.Collection.extend({ initialize: function (models, options) { this.opts = options; } });
var Year = Backbone.Model.extend({ initialize: function () { this.months = new Months(null, { Year: this }); this.months.add(new Month({ name: 'February' })); this.months.add(new Month({ name: 'March' })); this.months.add(new Month({ name: 'April' })); this.months.add(new Month({ name: 'May' })); this.months.add(new Month({ name: 'June' })); this.months.add(new Month({ name: 'July' })); this.months.add(new Month({ name: 'August' })); this.months.add(new Month({ name: 'September' }));
}, year: null, getMonth: function (name) { var caller = this; var m = $.grep(caller.months.models, function (n, i) { return n.get('name').toLowerCase() == name.toLowerCase(); });
return m.length > 0 ? m[0] : null; }, hasContent: function () { return this.months.hasContent(); } });
var Calendar = Backbone.View.extend({ el: $('div.calendar'), initialize: function () { this.year = new Year({ year: 2011 });this.template = '
' +
'
' <% } %>' + ' <% }); %>' +' ' + ' | ' +
' ' +
' <% _.forEach(year.months.models, function(month) { %>' + ' <% if(month.hasContent()){ %>' + ' <div class="month <%= month.get(\'name\') %>" id="<%= month.get(\'name\') + \'_\' + month.cid %>">' +'
' <% }); %>' +' ' + ' <% _.forEach(month.weeks.models, function(week) { %>' + ' <div id="<%= month.get(\'name\') + \'_week_\' + week.cid %>">' + ' <% _.forEach(week.days.models, function(day) { %>' +' <%= day.get(\'name\') %>' +' <%= day.get(\'content\') %>' + ' <% }); %>' + ' </div>' + ' <% }); %>' + ' </div>' + ' <% } %>' + ' <% }); %>' +' | ' +
'