Team:SDU-Denmark/core/scripts
From 2013.igem.org
(Difference between revisions)
Heidi.Wille (Talk | contribs) |
Heidi.Wille (Talk | contribs) |
||
Line 78: | Line 78: | ||
- | + | var url = window.location.pathname; | |
+ | var tourIndex = url.toLowerCase().indexOf('tour'); | ||
+ | if (tourIndex > 0) { | ||
+ | if (isInt(url.charAt(tourIndex +4))) { | ||
+ | parentIndex = url.charAt(tourIndex +4); | ||
+ | } | ||
+ | if (isInt(url.charAt(tourIndex + 5))) { | ||
+ | childIndex = url.charAt(tourIndex + 5); | ||
+ | } | ||
+ | } | ||
// Not a tour-site | // Not a tour-site | ||
Line 85: | Line 94: | ||
$('.tourBoundingBox').css('position', 'fixed'); | $('.tourBoundingBox').css('position', 'fixed'); | ||
return; | return; | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
} | } | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
} | } | ||
Revision as of 15:30, 8 September 2013
function isInt(n) {
return (n+"").match(/^\d+$/);
} function handleStickyTopBar() {
var viewportHeight = $(window).height(); var totalPageHeight = $(document).height(); if (totalPageHeight > viewportHeight) { $(".MainLayout").css("margin-bottom", "100px"); } else { $(".MainLayout").css("margin-bottom", "0"); }
var window_top = $(window).scrollTop(); var div_top = $('#sticky-anchor').offset().top; if (window_top > div_top) { $('.top').addClass('stick'); $('.tourBoundingBox').addClass('stick2'); $('.tourBoundingBoxInner').css('margin-left', 13); $(".topMargin").css("margin-top", "113px"); } else { $('.top').removeClass('stick'); $('.tourBoundingBox').removeClass('stick2'); $('.tourBoundingBoxInner').css('margin-left', 0); $(".topMargin").css("margin-top", "25px"); }
} function enableMenuDropdown() {
$('#btnMenu, .menuPopup, #btnMenu2').hover( function () { $('.menuPopup').show(); }, function () { $('.menuPopup').hide(); } );
} function styleIGEMTopMenu() {
$('.left-menu').children().first().children().last().css('color', ); $('.left-menu').children().first().children().last().css('font-size', '10px'); $('#menubar').bind("mouseover", function () { $(this).css("background", "transparent"); $('#menubar').css("background", "transparent"); });
}
function hideTestElementsOnLiveSite() {
var pathname = window.location.pathname; if (pathname.toLowerCase().indexOf('test') < 0) { $('.testing').hide(); }
}
function HandleSelectedTourItems(allItems, selectedIndex, isClosed) { for (var i = 0; i < allItems.length; i++) { var currentSelected = allItems.eq(i); if (i < selectedIndex) { if (i == selectedIndex - 1 && isClosed) { currentSelected.addClass('itemLastSelected'); currentSelected.children('.tourItemLabel').first().addClass('tourItemLabelSelected'); } else { currentSelected.addClass('itemSelected'); currentSelected.removeClass('tourItemLabelSelected'); } } else { currentSelected.removeClass('itemLastSelected'); currentSelected.removeClass('itemSelected'); currentSelected.removeClass('tourItemLabelSelected'); } } } function ToggleTourMenu() { var parentIndex = 0; var childIndex = 0;
var url = window.location.pathname; var tourIndex = url.toLowerCase().indexOf('tour'); if (tourIndex > 0) { if (isInt(url.charAt(tourIndex +4))) { parentIndex = url.charAt(tourIndex +4); } if (isInt(url.charAt(tourIndex + 5))) { childIndex = url.charAt(tourIndex + 5); } }
// Not a tour-site if (parentIndex == 0) { $('.tourBoundingBox').hide(); $('.tourBoundingBox').css('position', 'fixed'); return; }
}
$(document).ready(function () {
styleIGEMTopMenu(); $(window).scroll(handleStickyTopBar); enableMenuDropdown();
ToggleTourMenu();
hideTestElementsOnLiveSite();
});