Team:WITS-CSIR SA/client/SideMenu.js
From 2011.igem.org
(28 intermediate revisions not shown) | |||
Line 43: | Line 43: | ||
var html = _.template(this.template, this.items); | var html = _.template(this.template, this.items); | ||
this.el.html(html); | 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(); | FormatButtons(); | ||
- | |||
} | } | ||
}); | }); | ||
Line 63: | Line 67: | ||
var menu = new SideMenuView($('.west')); | var menu = new SideMenuView($('.west')); | ||
- | menu.add('Minutes', ' | + | menu.add('Minutes', 'https://2011.igem.org/Team:WITS-CSIR_SA/Diary/Minutes'); |
- | menu.add('Gallery', ' | + | menu.add('Gallery', 'https://2011.igem.org/Team:WITS-CSIR_SA/Diary/Gallery'); |
- | menu.add('Videos', ' | + | menu.add('Videos', 'https://2011.igem.org/Team:WITS-CSIR_SA/Diary/Videos'); |
menu.render(); | menu.render(); | ||
Line 73: | Line 77: | ||
var menu = new SideMenuView($('.west')); | var menu = new SideMenuView($('.west')); | ||
- | menu.add('Meet The Team', ' | + | menu.add('Meet The Team', 'https://2011.igem.org/Team:WITS-CSIR_SA/AboutUs/MeetTheTeam'); |
- | menu.add('Meet Our Bugs!', ' | + | menu.add('Attributions', 'https://2011.igem.org/Team:WITS-CSIR_SA/AboutUs/Attributions'); |
- | menu.add('Contact Us', ' | + | menu.add('Acknowledgements', 'https://2011.igem.org/Team:WITS-CSIR_SA/AboutUs/Acknowledgements'); |
+ | 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(); | menu.render(); | ||
Line 82: | Line 88: | ||
function BuildProjectMenu() { | function BuildProjectMenu() { | ||
var menu = new SideMenuView($('.west')); | var menu = new SideMenuView($('.west')); | ||
- | + | menu.add('Overview', 'https://2011.igem.org/Team:WITS-CSIR_SA/Project/Concept'); | |
- | menu.add(' | + | menu.add('Modelling', 'https://2011.igem.org/Team:WITS-CSIR_SA/Project/Modelling'); |
- | menu.add(' | + | menu.add('Safety', 'https://2011.igem.org/Team:WITS-CSIR_SA/Project/Safety'); |
- | menu.add(' | + | 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(' | + | menu.add('Achievements', 'https://2011.igem.org/Team:WITS-CSIR_SA/Project/Achievements'); |
- | + | menu.add('Protocols', 'https://2011.igem.org/Team:WITS-CSIR_SA/Project/Protocols'); | |
- | menu.add(' | + | |
- | + | ||
- | menu.add(' | + | |
- | + | ||
- | menu.add('Protocols', ' | + | |
menu.render(); | menu.render(); | ||
Line 101: | Line 102: | ||
var menu = new SideMenuView($('.west')); | var menu = new SideMenuView($('.west')); | ||
- | menu.add(' | + | menu.add('SciBono experience', 'https://2011.igem.org/Team:WITS-CSIR_SA/Outreach/SciBono'); |
- | menu.add(' | + | menu.add('Synthetic biology forum', 'https://2011.igem.org/Team:WITS-CSIR_SA/Outreach/Forum'); |
- | menu.add('Survey', ' | + | menu.add('Survey', 'https://2011.igem.org/Team:WITS-CSIR_SA/Outreach/Survey'); |
+ | menu.add('Public relations', 'https://2011.igem.org/Team:WITS-CSIR_SA/Outreach/PublicRelations'); | ||
+ | |||
+ | |||
menu.render(); | menu.render(); | ||
} | } |
Latest revision as of 10:20, 18 October 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" />
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('Attributions', 'https://2011.igem.org/Team:WITS-CSIR_SA/AboutUs/Attributions'); menu.add('Acknowledgements', 'https://2011.igem.org/Team:WITS-CSIR_SA/AboutUs/Acknowledgements'); 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('Overview', 'https://2011.igem.org/Team:WITS-CSIR_SA/Project/Concept'); menu.add('Modelling', 'https://2011.igem.org/Team:WITS-CSIR_SA/Project/Modelling'); menu.add('Safety', 'https://2011.igem.org/Team:WITS-CSIR_SA/Project/Safety'); 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('Achievements', 'https://2011.igem.org/Team:WITS-CSIR_SA/Project/Achievements'); 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('Synthetic biology forum', 'https://2011.igem.org/Team:WITS-CSIR_SA/Outreach/Forum'); menu.add('Survey', 'https://2011.igem.org/Team:WITS-CSIR_SA/Outreach/Survey');
menu.add('Public relations', 'https://2011.igem.org/Team:WITS-CSIR_SA/Outreach/PublicRelations');
menu.render();
}