Skip to content

Instantly share code, notes, and snippets.

@v9n
Forked from 140bytes/LICENSE.txt
Created August 2, 2011 14:53
Show Gist options
  • Save v9n/1120350 to your computer and use it in GitHub Desktop.
Save v9n/1120350 to your computer and use it in GitHub Desktop.
Element Filter

140byt.es

A tweet-sized, fork-to-play, community-curated collection of JavaScript.

How to play

  1. Click the Fork button above to fork this gist.
  2. Modify all the files to according to the rules below.
  3. Save your entry and tweet it up!

Keep in mind that thanks to the awesome sensibilities of the GitHub team, gists are just repos. So feel free to clone yours and work locally for a more comfortable environment, and to allow commit messages.

Rules

All entries must exist in an index.js file, whose contents are

  1. an assignable, valid Javascript expression that
  2. contains no more than 140 bytes, and
  3. does not leak to the global scope.

All entries must also be licensed under the WTFPL or equally permissive license.

For more information

See the 140byt.es site for a showcase of entries (built itself using 140-byte entries!), and follow @140bytes on Twitter.

To learn about byte-saving hacks for your own code, or to contribute what you've learned, head to the wiki.

140byt.es is brought to you by Jed Schmidt, with help from Alex Kloss. It was inspired by work from Thomas Fuchs and Dustin Diaz.

function(
n, //Navigation jQuery object.
s, //Source Object
d, //Destination Object
l //String item selector
){
n.click(function(){
d
.empty() //remove all current item of destination
.append( //then clone the matched element from source, and add them to destination
$(l.concat('.',$(this).attr('class')),s).clone(1)
)
.fadeOut('fast') //You done but we still have some more chars so do small effect :p
.fadeIn('slow')}
)
}
function(n,s,d,l){n.click(function(){d.empty().append($(l.concat('.',$(this).attr('class')),s).clone(1)).fadeOut('fast').fadeIn('slow')})}
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
{
"name": "filter",
"description": "Filter Elements",
"keywords": [
"gallery",
"filter",
"container",
"quicksand",
"isotope"
]
}
<!DOCTYPE html>
<head>
<style>
a {text-decoration: none; margin: 5px;}
li {display: inline-block;}
#portfolio-nav > a {height: 20px; font-size: 1.2em; color: red;}
#portfolio-nav > a:target {color: magenta;}
ul > li {margin: 10px; list-style: none}
ul:after {content: ""; display: block; clear: both}
</style>
</head>
<body>
<title>Element Filter</title>
<p>
Simple kind of <a href="http://razorjack.net/quicksand/">jQuery Quicksand</a>. The same effect without many animations,
but easy to implement ;). View source to learn more.
It's hard to name this kind of effect but you can take a look <a href="http://axcoto.com/labs/140byt/filter/v1/test.html#magento">here</a>
</p>
<div id="portfolio-nav">
<a id="all" class="all" href="test.html#all">All</a>
<a id="app" class="webapp" href="test.html#app">Web/App</a>
<a id="wordpress" class="wordpress" href="test.html#wordpress">Wordpress</a>
<a id="ee" class="ee" href="test.html#ee">ExpressionEngine</a>
<a id="joomla" class="joomla" href="test.html#joomla">Joomla</a>
<a id="magento" class="magento" href="test.html#magento">Magento</a>
</div>
</div>
<ul id="portfolio-source" style="display: none">
<li class="start all wordpress">
<a href="#" >Asia</a>
</li>
<li class=" all zendcart">
<a href="#" >Bagvine</a>
</li>
<li class=" all joomla">
<a href="#" >Broadway</a>
</li>
<li class="last all zendcart">
<a href="#" >carkey</a>
</li>
<li class="start all webapp">
<a href="#" >Freshbox</a>
</li>
<li class=" all webapp">
<a href="#" >AGBA</a>
</li>
<li class=" all joomla">
<a href="#" >HueCt</a>
</li>
<li class="last all zendcart">
<a href="#" >Moda</a>
</li>
<li class="start all wordpress">
<a href="#" >QuickTIme</a>
</li>
<li class=" all zendcart">
<a href="#" >Plaza</a>
</li>
<li class=" all zendcart">
<a href="#" >SolarLink</a>
</li>
<li class="last all wordpress">
<a href="#" >WBC</a>
</li>
<li class="start all wordpress">
<a href="#" >FKC</a>
</li>
<li class=" all ee">
<a href="#" >EE</a>
</li>
<li class=" all magento">
<a href="#" >GReen Boom</a>
</li>
<li class="last all wordpress">
<a href="#" >Hospital</a>
</li>
<li class="start all webapp">
<a href="#" >Alta</a>
</li>
<li class=" all ee">
<a href="#" >EFL</a>
</li>
<li class=" all wordpress">
<a href="#" >FBC</a>
</li>
<li class="last all wordpress">
<a href="#" >Greenworld</a>
</li>
<li class="start all wordpress">
<a href="#" >Happy Hour</a>
</li>
<li class=" all ee">
<a href="#" >InfoCreek</a>
</li>
<li class=" all wordpress">
<a href="#" >Just Stance</a>
</li>
<li class="last all wordpress">
<a href="#" >Wayout Tech</a>
</li>
<li class="start all webapp">
<a href="#" >Ritelogic</a>
</li>
<li class=" all webapp">
<a href="#" >Twbadge</a>
</li>
<li class=" all webapp">
<a href="#" >Pocoo</a>
</li>
<li class="last all webapp">
<a href="#" >MangaAndMe</a>
</li>
<li class="start all wordpress">
<a href="#" >DMV</a>
</li>
<li class=" all webapp">
<a href="#" >Buzz</a>
</li>
</ul>
<ul id="portfolio">
<li class="start all wordpress">
<a href="#" >Asia</a>
</li>
<li class=" all zendcart">
<a href="#" >Bagvine</a>
</li>
<li class=" all joomla">
<a href="#" >Broadway</a>
</li>
<li class="last all zendcart">
<a href="#" >carkey</a>
</li>
<li class="start all webapp">
<a href="#" >Freshbox</a>
</li>
<li class=" all webapp">
<a href="#" >AGBA</a>
</li>
<li class=" all joomla">
<a href="#" >HueCt</a>
</li>
<li class="last all zendcart">
<a href="#" >Moda</a>
</li>
<li class="start all wordpress">
<a href="#" >QuickTIme</a>
</li>
<li class=" all zendcart">
<a href="#" >Plaza</a>
</li>
<li class=" all zendcart">
<a href="#" >SolarLink</a>
</li>
<li class="last all wordpress">
<a href="#" >WBC</a>
</li>
<li class="start all wordpress">
<a href="#" >FKC</a>
</li>
<li class=" all ee">
<a href="#" >EE</a>
</li>
<li class=" all magento">
<a href="#" >GReen Boom</a>
</li>
<li class="last all wordpress">
<a href="#" >Hospital</a>
</li>
<li class="start all webapp">
<a href="#" >Alta</a>
</li>
<li class=" all ee">
<a href="#" >EFL</a>
</li>
<li class=" all wordpress">
<a href="#" >FBC</a>
</li>
<li class="last all wordpress">
<a href="#" >Greenworld</a>
</li>
<li class="start all wordpress">
<a href="#" >Happy Hour</a>
</li>
<li class=" all ee">
<a href="#" >InfoCreek</a>
</li>
<li class=" all wordpress">
<a href="#" >Just Stance</a>
</li>
<li class="last all wordpress">
<a href="#" >Wayout Tech</a>
</li>
<li class="start all webapp">
<a href="#" >Ritelogic</a>
</li>
<li class=" all webapp">
<a href="#" >Twbadge</a>
</li>
<li class=" all webapp">
<a href="#" >Pocoo</a>
</li>
<li class="last all webapp">
<a href="#" >MangaAndMe</a>
</li>
<li class="start all wordpress">
<a href="#" >DMV</a>
</li>
<li class=" all webapp">
<a href="#" >Buzz</a>
</li>
</ul>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="http://axcoto.com/assets/js/transform/dist/jquery.transform-0.9.3.min.js"></script>
<script>
$(document).ready(function () {
/**
n: nav
s: source
d: destination
l: sub item selector
*/
var filterElements = function(n,s,d,l){n.click(function(){d.empty().append($(l.concat('.',$(this).attr('class')),s).clone(1)).fadeOut('fast').fadeIn('slow')})}
var buttons = $('#portfolio-nav > a');
var folioContainer = $('#portfolio');
var sFolio = $('#portfolio-source');
filterElements(buttons, sFolio, folioContainer, 'li');
})
</script>
</body>
</html>
@v9n
Copy link
Author

v9n commented Aug 3, 2011

Sorry. I didn't know that :(! I will try to make a JavaScript version wo using framework. Thanks

@atk
Copy link

atk commented Aug 3, 2011

It's still pretty awesome, just not really conforming to all the rules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment