I’ve currently got a load of jQuery functions for a site I’m currently front-ending on. I’m not really a jQuery ‘ninja’ (I have finally started reading the sitepoint book though) so I’m sure this code is probably badly written and could be a little cleaner, meaner and leaner.
Here’s the code –
// add hasJS to html to allow for CSS fallbacks
jQuery(function($) {
$('html').addClass('hasJS');
});
// ENDS
// show/hide/kill the upload files modal box
$('.upload').click(function(){
$('.uploader').toggle();
});
$('.creategroup').click(function(){
$('.createnewgroup').toggle();
return false;
});
$('.adduser').click(function(){
$('.addnewuser').toggle();
return false;
});
$('#tap-menu').click(function() {
$('#left-column, #settings, #ortibi, #userprofile').toggle();
});
$('.cancel').click(function(){
$('.uploader, .shareform').hide();
});
$('.connection-type').click(function(){
$('.connectform').toggle();
});
$('.shareit').click(function(){
$('.shareform').show();
});
$(function() {
$('article .folder-items').hide();
$("p.folder").click(function () {
$(this).parent().next(".folder-items").slideToggle("slow");
});
});
$(document).ready(function(){
$('#scrollbar1').tinyscrollbar();
});
// ENDS
$('textarea#txtarea_Message"').autoResize({
// On resize:
onResize : function() {
$(this).css({opacity:0.8});
},
// After resize:
animateCallback : function() {
$(this).css({opacity:1});
},
// Quite slow animation:
animateDuration : 300,
// More extra space:
extraSpace : 40
});
$("input:checkbox").uniform();
$("#check1").live("click", function(){
var two = $("#check2").attr("checked", this.checked);
$.uniform.update(two);
});
Now I’m probably doing a lot wrong here. What can I do to improve this code? All help appreciated :o)
something like this?