Team:Wageningen UR/JS/notebook.js
From 2013.igem.org
(Difference between revisions)
Karrenbelt (Talk | contribs) |
Karrenbelt (Talk | contribs) |
||
(25 intermediate revisions not shown) | |||
Line 3: | Line 3: | ||
$('#container h2:first-of-type .editsection a').html('edit entries'); | $('#container h2:first-of-type .editsection a').html('edit entries'); | ||
- | + | var $container = $('#container'); | |
$container.imagesLoaded(function(){ | $container.imagesLoaded(function(){ | ||
Line 9: | Line 9: | ||
itemSelector: '.item', | itemSelector: '.item', | ||
columnWidth: 320, | columnWidth: 320, | ||
- | isFitWidth: | + | isFitWidth: false |
}); | }); | ||
}); | }); | ||
Line 34: | Line 34: | ||
}); | }); | ||
- | var firstDate = $('#container .date | + | var firstDate = $('#container .date').eq(0).attr('id'); |
- | $('#filters .bydate .iconsweek').children('a.' + firstDate).addClass(' | + | $('#filters .bydate .iconsweek').children('a.'+firstDate).addClass('active'); |
$('#filters .bydate .iconsweek a').click(function(e){ | $('#filters .bydate .iconsweek a').click(function(e){ | ||
e.preventDefault(); | e.preventDefault(); | ||
$('html, body').stop().animate({ | $('html, body').stop().animate({ | ||
- | scrollTop: $($(this).attr('href')).offset().top - 95}, 800); | + | scrollTop: $($(this).attr('href')).offset().top-95}, 800); |
}); | }); | ||
Line 59: | Line 59: | ||
for (var i=0; i < aArray.length; i++) { | for (var i=0; i < aArray.length; i++) { | ||
var theID = aArray[i]; | var theID = aArray[i]; | ||
- | var divPos = $('#' + theID).offset().top - 95; // get the offset of the div from the top of page | + | if(theID != aArray[0]){ |
- | + | var divPos = $('#' + theID).offset().top-95; // get the offset of the div from the top of page | |
- | + | ||
} else { | } else { | ||
- | var | + | var divPos = 0; |
+ | } | ||
+ | |||
+ | if( theID != 'january' || theID != 'februari' || theID != 'march') { | ||
+ | var divHeight = $('#container').children('.date').eq(i+1).offset().top-95; | ||
+ | } else { | ||
+ | var divHeight = docHeight; | ||
} | } | ||
var divHeight = divHeight - divPos; | var divHeight = divHeight - divPos; |
Latest revision as of 19:44, 23 April 2014
$(document).ready(function() {
$('#container h2:first-of-type .editsection a').html('edit entries');
var $container = $('#container');
$container.imagesLoaded(function(){ $container.masonry({ itemSelector: '.item', columnWidth: 320, isFitWidth: false }); });
$('#filters .bysubject a').click(function () {
var ourClass = $(this).attr('class');
if (ourClass.indexOf("active") >= 1) {
ourClass = ourClass.substring(0, ourClass.indexOf("active")); $(this).removeClass('active'); $('#container').children('div.' + ourClass).show().css({opacity: 0}).addClass('item'); setTimeout(function() { $container.masonry('reload'); setTimeout(function() {$('#container').children('div.' + ourClass).css({opacity: 1});},100); }, 350);
} else {
$(this).addClass('active'); $('#container').children('div.' + ourClass).hide('fast').removeClass('item'); $container.masonry('reload');
}
});
var firstDate = $('#container .date').eq(0).attr('id'); $('#filters .bydate .iconsweek').children('a.'+firstDate).addClass('active');
$('#filters .bydate .iconsweek a').click(function(e){
e.preventDefault(); $('html, body').stop().animate({ scrollTop: $($(this).attr('href')).offset().top-95}, 800);
});
var aChildren = $("#container").children('.date'); // find the a children of the list items var aArray = []; // create the empty aArray for (var i=0; i < aChildren.length; i++) { var aChild = aChildren[i]; var ahref = $(aChild).attr('id'); aArray.push(ahref); }
$(window).scroll(function(){
var windowPos = $(window).scrollTop(); // get the offset of the window from the top of page var windowHeight = $(window).height(); // get the height of the window var docHeight = $(document).height();
for (var i=0; i < aArray.length; i++) { var theID = aArray[i]; if(theID != aArray[0]){ var divPos = $('#' + theID).offset().top-95; // get the offset of the div from the top of page } else { var divPos = 0; }
if( theID != 'january' || theID != 'februari' || theID != 'march') { var divHeight = $('#container').children('.date').eq(i+1).offset().top-95; } else { var divHeight = docHeight; } var divHeight = divHeight - divPos; if (windowPos >= divPos && windowPos < (divPos + divHeight)) { $('.iconsweek a.' + theID ).addClass("on"); } else { $('.iconsweek a.' + theID ).removeClass("on"); } }
});
});