Skip to content

Commit 4ae86aa

Browse files
author
Julien Bouquillon
authored
Merge pull request #54 from jeremejazz/master
Add Filter
2 parents 6bc2641 + 5a8e1c0 commit 4ae86aa

File tree

2 files changed

+73
-11
lines changed

2 files changed

+73
-11
lines changed

css/pythonbooks.css

+28-8
Original file line numberDiff line numberDiff line change
@@ -1231,14 +1231,34 @@ a.jsbookslinks {
12311231
color: #3775a9;
12321232
text-decoration: none;
12331233
}
1234-
.pythonbooks {
1234+
.jsbooks {
12351235
background-color: transparent;
1236-
margin: 0 0 30px;
1236+
margin: 18px 0 0px;
12371237
}
1238-
.pythonbooks > * {
1238+
.jsbooks > * {
12391239
display: inline;
12401240
margin-right: 10px;
12411241
}
1242+
#filterBy {
1243+
float: left;
1244+
overflow: hidden;
1245+
margin: 0 0 30px;
1246+
}
1247+
#filterBy li {
1248+
float: left;
1249+
margin: 0 0 0 10px;
1250+
list-style: none;
1251+
}
1252+
#filterBy li:first-child {
1253+
margin-left: 0;
1254+
}
1255+
#filterBy a {
1256+
color: #0b4d84;
1257+
}
1258+
#filterBy .active {
1259+
color: #2f99f1;
1260+
}
1261+
12421262
.booksection {
12431263
margin-bottom: 30px;
12441264
}
@@ -1325,19 +1345,19 @@ hr {
13251345
border-top: 1px solid #dfdddd;
13261346
border-bottom: 1px solid white;
13271347
}
1328-
ul {
1348+
ul#social_buttons {
13291349
list-style-type: none;
13301350
position: absolute;
13311351
top: 50%;
13321352
margin-top: -10px;
13331353
right: 40px;
13341354
height: 20px;
13351355
}
1336-
ul li {
1356+
ul#social_buttons li {
13371357
display: inline;
13381358
height: 20px;
13391359
}
1340-
ul li a {
1360+
ul#social_buttons li a {
13411361
vertical-align: top;
13421362
color: grey;
13431363
text-shadow: 1px 0 0 rgba(255, 255, 255, 0.4);
@@ -1348,7 +1368,7 @@ ul li a {
13481368
-ms-transition: all .2s linear;
13491369
transition: all .2s linear;
13501370
}
1351-
ul li a:hover {
1371+
ul#social_buttons li a:hover {
13521372
text-decoration: none;
13531373
color: black;
13541374
text-shadow:none;
@@ -1685,7 +1705,7 @@ ul li a:hover {
16851705
ul {
16861706
margin-top: -10px;
16871707
}
1688-
ul li:first-child {
1708+
ul#social_buttons li:first-child {
16891709
display: none;
16901710
}
16911711
}

index.html

+45-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<img src="./img/logo_pythonbooks.png" alt="python tutorials" width="300" height="50">
3232
<h1>The best free Python resources</h1>
3333
<a href="http://www.revolunet.com" target="_blank" title="revolunet" id="headerlink">by revolunet - rich web apps for desktop and mobile</a>
34-
<ul>
34+
<ul id="social_buttons">
3535
<li>
3636
<a href="https://twitter.com/share" class="twitter-share-button" data-text="Here are the best Python ressources to learn #python for free ! #webdevelopment #python" data-via="revolunet"></a>
3737
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
@@ -54,7 +54,24 @@ <h1>The best free Python resources</h1>
5454
</div>
5555
</div>
5656
-->
57-
<p>&nbsp;</p>
57+
<div class="row">
58+
<div class="jsbooks span12">
59+
<p>See also :</p>
60+
<a href="http://jsbooks.revolunet.com/" target="_blank">
61+
<img src="./img/logo_jsbooks.png" alt="Javascript Books" title="Learn Javascript for free !" width="" height="14">
62+
</a>
63+
</div>
64+
65+
<div class="span12 row-fluid">
66+
<p class="span1">Filter by :</p>
67+
<ul id="filterBy">
68+
<li><a href="#" data-level="any" class="active" title="filter books by All">All</a></li>
69+
<li><a href="#" data-level="Beginner" title="filter books by Beginner">Beginner</a></li>
70+
<li><a href="#" data-level="Intermediate" title="filter books by Intermediate">Intermediate</a></li>
71+
<li><a href="#" data-level="Advanced" title="filter books by Advanced">Advanced</a></li>
72+
</ul>
73+
</div>
74+
</div>
5875

5976
<!-- ///////// BOOKS -->
6077
<div class="row" id="issueswrap"></div>
@@ -85,12 +102,37 @@ <h1>The best free Python resources</h1>
85102
return (Math.round(Math.random())-0.5);
86103
}
87104

105+
function filterBy() {
106+
var // var's sort by
107+
active = 'active',
108+
btFilterBy = $('#filterBy').find('a'),
109+
booksection = $('.booksection');
110+
111+
// interaction filter by level
112+
btFilterBy.on('click', function(e) {
113+
e.preventDefault();
114+
var level = $(this).data('level');
115+
if (level==='any') {
116+
// restore all books
117+
booksection.show();
118+
} else {
119+
booksection.not('.' + level).fadeOut('fast');
120+
booksection.filter('.' + level).fadeIn('fast');
121+
}
122+
123+
btFilterBy.removeClass(active);
124+
$(this).addClass(active);
125+
});
126+
}
127+
128+
88129
$(document).ready(function() {
89130
$.getJSON('./issues.json?' + Math.random(), function(data) {
90131
var template = $('#booktpl').html();
91132
data.books.sort(randOrd);
92133
var html = Mustache.to_html(template, data);
93134
$('#issueswrap').html(html);
135+
filterBy();
94136
});
95137
$('#mod_infos').hide();
96138
$('a.#infos').on('click', function(){
@@ -101,7 +143,7 @@ <h1>The best free Python resources</h1>
101143

102144
<script id="booktpl" type="text/template">
103145
{{#books}}
104-
<div class="span4 booksection">
146+
<div class="span4 booksection {{ level }}">
105147
<a target="_blank" href="{{url}}">
106148
<div class="view"></div>
107149
<div title="{{ title }}" id="cover" style="background:black url('{{cover}}') no-repeat center;-webkit-background-size:cover;-moz-background-size:cover;background-size:cover;">

0 commit comments

Comments
 (0)