Team:WITS-CSIR SA/client/SideMenu.js
From 2011.igem.org
/// <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" />
var SideMenuItem = null, SideMenuItems = null, SideMenuView = null;
$(function () {
SideMenuItem = Backbone.Model.extend({ initialize: function () { }, text: null, path: null });
SideMenuItems = Backbone.Collection.extend({ initialize: function (models, options) { } });
SideMenuView = Backbone.View.extend({ el: null, initialize: function (element) { this.el = element; this.items = new SideMenuItems(null, { view: this });this.template = '
- ' +
' <% _.forEach(models, function(model) { %><li onclick="location=\'<%= model.get(\'path\') %>\';"><a <%= (location.toString().indexOf(model.get(\'name\')) > -1) ? \'class="current"\' : \'\' %> href="<%= model.get(\'path\') %>"><%= model.get(\'text\') %></a><% }); %>' +
'
}, add: function (text, path) { this.items.add(new SideMenuItem({ text: text, path: path })); }, render: function () { var html = _.template(this.template, this.items); this.el.html(html); var str = location.toString(); str = str.substr(str.indexOf('Team:WITS-CSIR_SA/') + 'Team:WITS-CSIR_SA/'.length, str.length);
$('ul.sideMenu > li > a').each(function () { if ($(this).attr('href').toLowerCase().indexOf(str.toLowerCase()) > -1) { $(this).parent().addClass('current'); } });
FormatButtons(); } });
$.fling('subscribe', 'ready', function () { if (location.toString().toLowerCase().indexOf('diary') > -1) BuildDiaryMenu(); if (location.toString().toLowerCase().indexOf('aboutus') > -1) BuildAboutUsMenu(); if (location.toString().toLowerCase().indexOf('project') > -1) BuildProjectMenu(); if (location.toString().toLowerCase().indexOf('outreach') > -1) BuildOutreachMenu(); });
});
function BuildDiaryMenu() {
var menu = new SideMenuView($('.west'));
menu.add('Minutes', 'https://2011.igem.org/Team:WITS-CSIR_SA/Diary/Minutes'); menu.add('Gallery', 'https://2011.igem.org/Team:WITS-CSIR_SA/Diary/Gallery'); menu.add('Videos', 'https://2011.igem.org/Team:WITS-CSIR_SA/Diary/Videos');
menu.render();
}
function BuildAboutUsMenu() {
var menu = new SideMenuView($('.west'));
menu.add('Meet The Team', 'https://2011.igem.org/Team:WITS-CSIR_SA/AboutUs/MeetTheTeam'); menu.add('Meet Our Bugs!', 'https://2011.igem.org/Team:WITS-CSIR_SA/AboutUs/MeetOurBugs'); menu.add('Contact Us', 'https://2011.igem.org/Team:WITS-CSIR_SA/AboutUs/ContactUs');
menu.render();
}
function BuildProjectMenu() {
var menu = new SideMenuView($('.west')); menu.add('Abstract', 'https://2011.igem.org/Team:WITS-CSIR_SA/Project/Abstract'); menu.add('Introduction', 'https://2011.igem.org/Team:WITS-CSIR_SA/Project/Concept'); menu.add('Bacterial Chemotaxis', 'https://2011.igem.org/Team:WITS-CSIR_SA/Project/Motility'); menu.add('Lab Project', 'https://2011.igem.org/Team:WITS-CSIR_SA/Project/Send'); menu.add('Characterization', 'https://2011.igem.org/Team:WITS-CSIR_SA/Project/Characterization'); menu.add('Modelling', 'https://2011.igem.org/Team:WITS-CSIR_SA/Project/Modelling'); menu.add('Lab Notebook', 'https://2011.igem.org/Team:WITS-CSIR_SA/Project/Notebook'); menu.add('Potential Applications', 'https://2011.igem.org/Team:WITS-CSIR_SA/Project/Applications'); menu.add('Parts Submitted', 'https://2011.igem.org/Team:WITS-CSIR_SA/Project/Parts'); menu.add('Safety', 'https://2011.igem.org/Team:WITS-CSIR_SA/Project/Safety'); menu.add('Protocols', 'https://2011.igem.org/Team:WITS-CSIR_SA/Project/Protocols');
menu.render();
}
function BuildOutreachMenu() {
var menu = new SideMenuView($('.west'));
menu.add('SciBono Experience', 'https://2011.igem.org/Team:WITS-CSIR_SA/Outreach/SciBono'); menu.add('Survey', 'https://2011.igem.org/Team:WITS-CSIR_SA/Outreach/Survey');
menu.render();
}