Team:Newcastle/script/calendar.js
From 2013.igem.org
Line 23: | Line 23: | ||
if($(this).find('.titles').length) | if($(this).find('.titles').length) | ||
{ | { | ||
+ | var height = (($('#pop_up_display').height() / 100) * $(window).height()) - 40; | ||
var description = $(this).find('.details').html(); | var description = $(this).find('.details').html(); | ||
var titleText = $(this).find('.titles').attr('alt'); | var titleText = $(this).find('.titles').attr('alt'); | ||
window.location.hash = titleText; | window.location.hash = titleText; | ||
$('#pop_up_content').html('<h2>' + titleText + '</h2>' + description); | $('#pop_up_content').html('<h2>' + titleText + '</h2>' + description); | ||
+ | $('#pop_up_content').css('height', height); | ||
$('#pop_up').fadeIn(); | $('#pop_up').fadeIn(); | ||
} | } | ||
}); | }); | ||
+ | /* | ||
+ | $(window).resize(function (){ | ||
+ | var height = (($('#pop_up_display').height() / 100) * $(window).height()) - 40; | ||
+ | $('#pop_up_content').css('height', height); | ||
+ | });*/ | ||
}); | }); | ||
Revision as of 19:11, 2 October 2013
$(function(){
initCalendar();
if(location.hash) {
var height = (($('#pop_up_display').height() / 100) * $(window).height()) - 40; alert(height);
var date = (location.hash).split("/"); var id = date[1] + "-" + date[0].replace("#", "");
var description = $(this).find('#'+id).parent().find('.details').html(); var titleText = $(this).find('#'+id).parent().find('.titles').attr('alt');
$('#pop_up_content').html('' + titleText + '
' + description); $('').insertAfter('#pop_up_content');$('#pop_up_content').css('height', height);
$('#pop_up').fadeIn(); }
$('td').click(function(){ if($(this).find('.titles').length) {
var height = (($('#pop_up_display').height() / 100) * $(window).height()) - 40;
var description = $(this).find('.details').html(); var titleText = $(this).find('.titles').attr('alt'); window.location.hash = titleText;
$('#pop_up_content').html('' + titleText + '
' + description);$('#pop_up_content').css('height', height);
$('#pop_up').fadeIn(); } });
/* $(window).resize(function (){ var height = (($('#pop_up_display').height() / 100) * $(window).height()) - 40; $('#pop_up_content').css('height', height); });*/
});
function initCalendar() { $('#toc').remove(); var numMonths = parseInt($('#calendar-data').find('h2').length);
//alert(numMonths);
var daysChecked = 0; for(var i = 0; i < numMonths; i++) { //alert("Inside Months"); var currentH2 = $('h2')[i]; var nextH2= $('h2')[i + 1];
var currentMonth = parseInt($('#calendar-data').find('h2').eq(i).find('.mw-headline').text());
var numDays = parseInt($('#calendar-data').find('h2').eq(i).nextUntil('h2', 'h3').length); //alert(numDays); for(var j = 0; j < numDays; j++) { //alert("inside days"); var currentH3 = $('h3')[j + daysChecked]; var temp = $('h3'); var nextH3 = $('h3')[j + 1 + daysChecked];
var currentDay = parseInt($('#calendar-data').find(temp).eq(j + daysChecked).find('.mw-headline').text()); //alert(currentDay); var titlesH4 = $('h4')[((j + daysChecked) * 2)]; var detailsH4 = $('h4')[((j + daysChecked) * 2) + 1];
var tempTitles = $('#calendar-data').children('h4').eq(((j + daysChecked) * 2)).next('div').html(); var tempDetails = $('#calendar-data').children('h4').eq(((j + daysChecked) * 2) + 1).next('div').html();
//alert(tempTitles);
var dateID = $('#' + currentMonth + '-' + currentDay);
var dateDisp = currentDay + "/" + currentMonth + "/13";
//alert(details);
//var dateHTML = '$('#calendar-container').find(dateID).parent().append(dateHTML); }
daysChecked += numDays; }
$('body').find('#calendar-data').remove();
}