Team:Wageningen UR/JS/notebook.js

From 2013.igem.org

(Difference between revisions)
(Replaced content with "<html> <script> </script> </html>")
Line 1: Line 1:
<html>
<html>
<script>
<script>
-
$(document).ready(function() {
 
-
$('#container h2:first-of-type .editsection a').html('edit entries');
 
-
 
-
  var container = document.querySelector('#container');
 
-
var msnry = new Masonry( container, {
 
-
  // options
 
-
  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:first').attr('id');
 
-
$('#filters .bydate .iconsweek').children('a.' + firstDate).addClass('on');
 
-
 
-
$('#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') {
 
-
            var divHeight = $('#' + theID).parent().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");
 
-
        }
 
-
    }
 
-
 
-
});
 
-
 
-
});
 
</script>
</script>
</html>
</html>

Revision as of 13:44, 2 September 2013