I have a strange error I'm struggling with. Please bear in mind I'm new to web development, and my code is in a messy and experimental phase
The following Javascript runs fine, however if I move the startTimer() function call to anywhere else, or put anything in front of it, I get no errors but my CSS fails.
Code:
$(document).ready(function() {
//timer stuff
startTimer();
$(document).bind("mousemove", function() { resetTimer(); });
$(document).bind("touchstart", function() { resetTimer(); });
query();
});
//query function
function query() {
//script for iPhone portrait
if(Modernizr.mq('all and (max-width: 320px)')) {
clearTimeout ( alertTimerId );
clearTimeout ( counterId );
}
//script for iPhone landscape
if(Modernizr.mq('all and (min-width: 321px)')) {
clearTimeout ( alertTimerId );
clearTimeout ( counterId );
}
//script for iPad portrait
if(Modernizr.mq('(max-device-width: 768px) and (orientation: portrait)')) {
clearTimeout ( alertTimerId );
clearTimeout ( counterId );
}
//script for iPad landscape
if(Modernizr.mq('(max-device-width: 1024px) and (orientation: landscape)')) {
clearTimeout ( alertTimerId );
clearTimeout ( counterId );
}
//script for dekstops etc
//make sure the timer is going
startTimer();
$(document).bind("mousemove", function() { resetTimer(); });
$(document).bind("touchstart", function() { resetTimer(); });
if(Modernizr.mq('all and (min-width: 1028px)')) {
//script to keep the main content in the center
$(window).resize(function(){
$('#mainBodyList').css({
position:'absolute',
left: ($(window).width() - $('#mainBodyList').outerWidth())/2 + 35,
top: ($(window).height() - $('#mainBodyList').outerHeight())/1.9
});
});
//call the centering function
$(window).resize();
//vars
var line1 = document.getElementById("designLine");
var line2 = document.getElementById("codeLine");
var designHover = document.getElementById("dMenu");
var codeHover = document.getElementById("cMenu");
var designHeight = $("#dMenu")[0].scrollHeight;
var codeHeight = $("#cMenu")[0].scrollHeight;
//code for the design menu hover
$(designHover).hover(function(){
TweenLite.to( $('#designLine'), 1, {css:{height:designHeight - 100, bottom:designHeight - 175}, ease:Expo.easeOut});
TweenLite.to( $('.designMenu'), 1, {css:{top:(designHeight -75) * -1, height:designHeight+100}, ease:Expo.easeOut});
},function(){
TweenLite.to( $('#designLine'), 1, {css:{height:'150px', bottom:'75px'}, ease:Expo.easeOut});
TweenLite.to( $('.designMenu'), 1, {css:{top:'0', height:'100px'}, ease:Expo.easeOut});
});
//code for the code menu hover
$(codeHover).hover(function(){
TweenLite.to( $('#codeLine'), 1, {css:{height:codeHeight - 100, bottom:codeHeight - 175}, ease:Expo.easeOut});
TweenLite.to( $('.codeMenu'), 1, {css:{top:(codeHeight -75) * -1, height:codeHeight+100}, ease:Expo.easeOut});
},function(){
TweenLite.to( $('#codeLine'), 1, {css:{height:'150px', bottom:'75px'}, ease:Expo.easeOut});
TweenLite.to( $('.codeMenu'), 1, {css:{top:'0', height:'100px'}, ease:Expo.easeOut});
});
}
};
//time functions and tweening opacity functions
var timerId = 0;
var counterId = 0;
function startTimer()
{
alertTimerId = setTimeout('fadeGUI()',60000);
};
function resetTimer()
{
clearTimeout ( alertTimerId );
clearTimeout ( counterId );
startTimer();
fadeGUIIn();
};
function fadeGUI()
{
TweenLite.to( $('#logo'), 4, {css:{opacity:0}, ease:Expo.easeOut});
TweenLite.to( $('#mainBodyList'), 4, {css:{opacity:0}, ease:Expo.easeOut});
};
function fadeGUIIn()
{
TweenLite.to( $('#logo'), 2, {css:{opacity:0.99}, ease:Expo.easeOut});
TweenLite.to( $('#mainBodyList'), 2, {css:{opacity:0.99}, ease:Expo.easeOut});
};
function iPhonePortrait()
{
TweenLite.to( $('#contactInfo'), 2, {css:{paddingLeft:60}, ease:Expo.easeOut});
};
Bookmarks