Team:WITS-CSIR SA/client/SideMenu.js

From 2011.igem.org

(Difference between revisions)
 
(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);
-
             var link = $('ul.sideMenu > li > a[href="' + location + '"]', this.el);
+
             $('ul.sideMenu > li > a').each(function () {
-
            link.parent().addClass('current');
+
                if ($(this).attr('href').toLowerCase().indexOf(str.toLowerCase()) > -1) {
 +
                    $(this).parent().addClass('current');
 +
                }
 +
            });
             FormatButtons();
             FormatButtons();
-
            layout();
 
         }
         }
     });
     });
Line 63: Line 67:
     var menu = new SideMenuView($('.west'));
     var menu = new SideMenuView($('.west'));
-
     menu.add('Minutes', 'http://www.biotweet.org/diary/minutes.htm');
+
     menu.add('Minutes', 'https://2011.igem.org/Team:WITS-CSIR_SA/Diary/Minutes');
-
     menu.add('Gallery', 'http://www.biotweet.org/diary/gallery.htm');
+
     menu.add('Gallery', 'https://2011.igem.org/Team:WITS-CSIR_SA/Diary/Gallery');
-
     menu.add('Videos', 'http://www.biotweet.org/diary/videos.htm');
+
     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', 'http://www.biotweet.org/aboutus/meettheteam.htm');
+
     menu.add('Meet The Team', 'https://2011.igem.org/Team:WITS-CSIR_SA/AboutUs/MeetTheTeam');
-
     menu.add('Meet Our Bugs!', 'http://www.biotweet.org/aboutus/meetourbugs.htm');
+
    menu.add('Attributions', 'https://2011.igem.org/Team:WITS-CSIR_SA/AboutUs/Attributions');
-
     menu.add('Contact Us', 'http://www.biotweet.org/aboutus/contactus.htm');
+
    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('Concept', 'http://www.biotweet.org/project/concept.htm');
+
     menu.add('Modelling', 'https://2011.igem.org/Team:WITS-CSIR_SA/Project/Modelling');
-
     menu.add('Bacterial Motility', 'http://www.biotweet.org/project/motility.htm');
+
     menu.add('Safety', 'https://2011.igem.org/Team:WITS-CSIR_SA/Project/Safety');
-
     menu.add('Potential Applications', 'http://www.biotweet.org/project/applications.htm');
+
     menu.add('Lab Notebook', 'https://2011.igem.org/Team:WITS-CSIR_SA/Project/Notebook');
-
    menu.add('Project Send', 'http://www.biotweet.org/project/send.htm');
+
     menu.add('Potential Applications', 'https://2011.igem.org/Team:WITS-CSIR_SA/Project/Applications');
-
     menu.add('Project Receive', 'http://www.biotweet.org/project/receive.htm');
+
     menu.add('Achievements', 'https://2011.igem.org/Team:WITS-CSIR_SA/Project/Achievements');
-
    menu.add('Modelling', 'http://www.biotweet.org/project/modelling.htm');
+
     menu.add('Protocols', 'https://2011.igem.org/Team:WITS-CSIR_SA/Project/Protocols');
-
     menu.add('Parts Submitted', 'http://www.biotweet.org/project/parts.htm');
+
-
    menu.add('Characterization', 'http://www.biotweet.org/project/characterization.htm');
+
-
     menu.add('Lab Notebook', 'http://www.biotweet.org/project/notebook.htm');
+
-
    menu.add('Safety', 'http://www.biotweet.org/project/safety.htm');
+
-
     menu.add('Protocols', 'http://www.biotweet.org/project/protocols.htm');
+
     menu.render();
     menu.render();
Line 101: Line 102:
     var menu = new SideMenuView($('.west'));
     var menu = new SideMenuView($('.west'));
-
     menu.add('Workshop', 'http://www.biotweet.org/outreach/workshop.htm');
+
     menu.add('SciBono experience', 'https://2011.igem.org/Team:WITS-CSIR_SA/Outreach/SciBono');
-
     menu.add('Presentation', 'http://www.biotweet.org/outreach/presentation.htm');
+
     menu.add('Synthetic biology forum', 'https://2011.igem.org/Team:WITS-CSIR_SA/Outreach/Forum');
-
     menu.add('Survey', 'http://www.biotweet.org/outreach/survey.htm');
+
     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();

}