Code Optimization & Safari Syntax Error
Hey all, I would consider myself an intermediate jQuery developer. I'm
building a new site and as part of it, there's a lot of a jQuery code
I wrote to handle animations and other interface elements of the site.
In Safari, I'm getting thrown a SyntaxError with no line number when
the clickDo(); and clickUndo(); functions run. Additionally, I wanted
to see if anyone knew how to prevent those same functions from firing
if someone say, clicks the trigger object a bunch of times.
Here's the code in question:
$(document).ready(function(){
function clickUndo() {
$(".toggle").bind('click',function() {
var togLink = $(this).attr("rel");
var togText = $(this).attr("title");
$(togLink).fadeOut();
$("#header").animate({ width: '200px' }, 500, 'easeInBack', function
() {
$("#main").fadeTo(350, 1);
});
$("#nav ul li").not($(this).parent()).animate({ left: '0px' }, 500,
'easeOutExpo');
$(this).removeClass("expanded")
.html(togText)
.unbind('click');
clickDo();
});
}
function clickDo() {
$(".toggle").bind('click',function() {
var togLink = $(this).attr("rel");
$(togLink).fadeIn();
$("#main").fadeTo(300, 0.35, function() {
$("#header").animate({ width: '835px' }, 500, 'easeOutExpo');
});
$("#nav ul li").not($(this).parent()).animate({ left: '-850px' },
500, 'easeOutExpo');
$(this).addClass("expanded")
.html('Close <img src="http://specik.theatypical.net/wp-content/
themes/smoke/img/ico_close.png" class="ico" />')
.unbind('click');
clickUndo();
});
}
clickDo();
});
--