1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
| <!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Isotope - filtering, vanilla JS</title>
<meta name="Author" content="NoSmoking">
<style>
body {
font:normal 1.0em/1.5em Verdana,Arial,Helvetica,sans-serif;
}
#main {
width:60em;
margin:auto;
}
h1 {
color:#069;
}
div {
box-sizing:border-box;
}
ul {
display:table;
margin:1em auto;
padding:0;
list-style:none;
text-align:center;
width: 100%;
}
/*---- button ----*/
.button {
display:table-cell;
line-height:2em;
background:#EEE;
background-image:linear-gradient( to bottom,hsla(0,0%,0%,0),hsla(0,0%,0%,0.2) );
text-shadow:0 1px white;
cursor:pointer;
width: 12.5%;
}
/*-- effet sur bouton --*/
.button:hover {
background-color:#8CF;
text-shadow:0 1px hsla(0,0%,100%,0.5);
}
.button:active,.button.is-checked {
background-color:#28F;
}
.button.is-checked {
color:white;
text-shadow:0 -1px hsla(0,0%,0%,0.8);
}
.button:active {
box-shadow: inset 0 1px 10px hsla(0,0%,0%,0.8);
}
/*---- conteneur isotope ----*/
.isotope {
width:80%;
margin:auto;
}
/* ---- .vignette ---- */
.vignette {
position:relative;
float:left;
width:100px;
height:100px;
margin:10px;
padding:10px;
border: 1px solid #ABC;
}
</style>
<script src="http://isotope.metafizzy.co/beta/isotope.pkgd.js"></script>
<script src="http://isotope.metafizzy.co/beta/bower_components/classie/classie.js"></script>
<script>
// external js
// http://isotope.metafizzy.co/beta/isotope.pkgd.js
// http://isotope.metafizzy.co/beta/bower_components/classie/classie.js
// ----- ----- //
docReady( function() {
// init Isotope
var iso = new Isotope( '.isotope', {
itemSelector: '.vignette',
layoutMode: 'fitRows'
});
// bind filter button click
var filtersElem = document.querySelector('#filters');
eventie.bind( filtersElem, 'click', function( event ) {
// only work with buttons
if ( !matchesSelector( event.target, 'li' ) ) {
return;
}
var filterValue = event.target.getAttribute('data-filter');
iso.arrange({ filter: filterValue });
});
// change is-checked class on buttons
var buttonGroups = document.querySelectorAll('.button-group');
for ( var i=0, len = buttonGroups.length; i < len; i++ ) {
var buttonGroup = buttonGroups[i];
radioButtonGroup( buttonGroup );
}
});
function radioButtonGroup( buttonGroup ) {
eventie.bind( buttonGroup, 'click', function( event ) {
// only work with buttons
if ( !matchesSelector( event.target, 'li' ) ) {
return;
}
classie.remove( buttonGroup.querySelector('.is-checked'), 'is-checked' );
classie.add( event.target, 'is-checked' );
});
}
</script>
</head>
<body>
<div id="main">
<h1>Isotope - filtering, vanilla JS</h1>
<a href="http://isotope.metafizzy.co/filtering.html">La documentation</a>
<div id="filters" class="button-group">
<ul>
<li class="button is-checked" data-filter="*">Tout</li>
<li class="button" data-filter=".cours">Cours</li>
<li class="button" data-filter=".livres">Livres</li>
<li class="button" data-filter=".xhtml">XHTML</li>
<li class="button" data-filter=".css">CSS</li>
<li class="button" data-filter=".javascript">JS</li>
<li class="button" data-filter=".faq">Les FAQ</li>
<li class="button" data-filter=":not(.javascript)">Not JS</li>
</ul>
</div>
<div class="isotope">
<div class="vignette cours xhtml">
<img src="http://club.developpez.com/webdesign/Rubriques/Web/XHTML/logo_cours_xhtml.gif" alt="">
</div>
<div class="vignette cours css">
<img src="http://club.developpez.com/webdesign/Rubriques/Web/CSS/logo_cours_css.gif" alt="">
</div>
<div class="vignette cours javascript">
<img src="http://club.developpez.com/webdesign/Rubriques/Web/JavaScript/logo_cours_javascript.gif" alt="">
</div>
<div class="vignette livres xhtml">
<img src="http://club.developpez.com/webdesign/Rubriques/Web/XHTML/logo_livres_xhtml.gif" alt="">
</div>
<div class="vignette livres css">
<img src="http://club.developpez.com/webdesign/Rubriques/Web/CSS/logo_livres_css.gif" alt="">
</div>
<div class="vignette livres javascript">
<img src="http://club.developpez.com/webdesign/Rubriques/Web/JavaScript/logo_livres_javascript.gif" alt="">
</div>
<div class="vignette faq xhtml">
<img src="http://club.developpez.com/webdesign/Rubriques/Web/XHTML/logo_faq_xhtml.gif" alt="">
</div>
<div class="vignette faq css">
<img src="http://club.developpez.com/webdesign/Rubriques/Web/CSS/logo_faq_css.gif" alt="">
</div>
<div class="vignette faq javascript">
<img src="http://club.developpez.com/webdesign/Rubriques/Web/JavaScript/logo_faq_javascript.gif" alt="">
</div>
</div>
</div>
</body>
</html> |