Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STILL CANT FIND THE THING #12

Open
wants to merge 2 commits into
base: gh-pages
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions js/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
$(function(){
//list cache
$list = $('ul');

//just to make it look neat.
$('li').hide().each(function (i){
$(this).delay(450 * i).fadeIn(1600);
});

function updateItemCount(){
var ItemCount = $("li").length;
$("#counter").text(ItemCount);
}



updateItemCount();




$('#newItemButton').show();
$('#newItemForm').hide();

$('showForm').on("click", function(){
$("#newItemButton").hide();
$("#newItemForm").show();
});

//New List Item and addit when we click the add button.
$("#add").on("click", function(e){
e.preventDefault();
var text = $('#itemDescription').val();
$list.append("<li>"+ text + "</li>");
$("#itemDescription").val("");
updateItemCount();
$("#newItemForm").hide();
$("#newItemButton").show();

});

// CLick Handler so thaqt we can grey out list items as they are done
$('li').on("click", function() {

var $li = $(this);
if ($li.hasClass("complete")){
$li.animate({
opacity:0.0,
paddingLeft: '+=180'

}, 500, 'swing', function(){
$li.remove();
updateItemCount();
});


}
else{
$li.addClass("complete");
$list.append($li).hide().fadeIn(300);
}

});
});