Created
May 6, 2011 10:08
-
-
Save codespore/958719 to your computer and use it in GitHub Desktop.
Sample Quicksand + TinySort
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> | |
<head> | |
<title>jquery quicksand + tinysort</title> | |
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> | |
<script type="text/javascript" src="scripts/jquery-1.4.1.min.js"></script> | |
<script type="text/javascript" src="scripts/jquery.tinysort.js"></script> | |
<script type="text/javascript" src="scripts/jquery.quicksand.js"></script> | |
<style type="text/css"> | |
ul { | |
list-style-type: none; | |
padding: 0; | |
margin: 0; | |
border: 1px solid #ccc; | |
border-bottom: 0; | |
width: 200px; | |
} | |
ul li { | |
padding: 5px; | |
width: 200px; | |
border-bottom: 1px solid #ccc; | |
} | |
</style> | |
</head> | |
<body> | |
<input type="textfield" id="name"> | |
<select id="status"> | |
<option value="online">Online</option> | |
<option value="offline">Offline</option> | |
<option value="away">Away</option> | |
<option value="invisible">Online</option> | |
</select> | |
<button id="add">Add</button> | |
<button id="sort">Sort</button> | |
<br><br> | |
<ul id="list"> | |
<li data-id="1" status="online">Adrian [online]</li> | |
<li data-id="2" status="offline">Benjamin [offline]</li> | |
<li data-id="3" status="online">Claris [online]</li> | |
<li data-id="4" status="away">Baba [away]</li> | |
</ul> | |
<script> | |
var status_arr = {online: 0, away: 1, dnd: 2, invisible: 3, offline: 4}; | |
//$.tinysort.defaults.returns = true; | |
jQuery(function($) { | |
$('ul#list li').each(function(){ | |
$(this).attr('data-status-id',status_arr[$(this).attr('status')]); | |
}); | |
$('#add').click(function(){ | |
$('ul#list').append('<li status='+ $('#status').val() +'>'+ $('#name').val() +' ['+$('#status').val()+']</li>') | |
}); | |
$('#sort').click(function(){ | |
$original = $('ul#list'); | |
$sorted = $original.clone(); | |
$sorted.children().tsort({order:"asc",attr:"data-status-id"}); | |
$original.quicksand($sorted, { | |
duration: 800, | |
easing: 'easeInOutQuad' | |
}); | |
}); | |
}) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment