├── .gitignore ├── LICENSE ├── README.md ├── app.js ├── index.html └── style.css /.gitignore: -------------------------------------------------------------------------------- 1 | exported 2 | raw 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Jason Rhodes 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # tut-functional-js 2 | Functional JS tutorial project code for tutsplus.com 3 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | var beerData = JSON.parse(document.getElementById("beerData").textContent); 2 | var beerTemplate = document.getElementById("tmpl-beer").textContent; 3 | var beerList = document.getElementById("beerList"); 4 | var filters = document.getElementById("filters"); 5 | var filterLinks = filters.querySelectorAll("a"); 6 | 7 | beerList.innerHTML = _.template(beerTemplate)(beerData); 8 | 9 | filters.addEventListener('click', function (e) { 10 | e.preventDefault(); 11 | var beers = beerData.beers; 12 | var clicked = e.target; 13 | var filter = clicked.dataset.filter; 14 | var filteredBeers = []; 15 | var i; 16 | 17 | for (i=0; i 2 | 3 | 4 | 5 | Functional JS 6 | 7 | 8 | 9 | 10 | 11 |
12 | 15 | 16 |

Beer List

17 | 18 |
19 | All 20 | Domestic 21 | Imports 22 | Ales 23 | Lagers 24 | Stouts 25 |
26 | 27 | 28 | 29 | 47 | 48 | 53 | 54 |
55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /style.css: -------------------------------------------------------------------------------- 1 | body { 2 | background: url("http://i.imgur.com/IDJdOFb.jpg") top left repeat; 3 | color: white; 4 | } 5 | 6 | a:link, a:hover, a:active, a:visited { 7 | color: #666; 8 | text-decoration: none; 9 | } 10 | 11 | .site-container { 12 | width: 95%; 13 | margin: 0 auto; 14 | max-width: 500px; 15 | text-align: center; 16 | } 17 | 18 | .fancy { 19 | font-family: 'Rye', Georga, display, serif; 20 | } 21 | 22 | .site-header { 23 | text-align: center; 24 | padding: 1em 0; 25 | } 26 | 27 | a.header-logo { 28 | color: red; 29 | font-size: 3.5em; 30 | text-decoration: none; 31 | text-align: center; 32 | } 33 | 34 | #filters { 35 | line-height: 2.7; 36 | } 37 | 38 | #filters a.btn-active { 39 | background-color: red; 40 | color: white; 41 | border-color: red; 42 | } 43 | 44 | #beerList { 45 | margin: 1em 0; 46 | padding-left: 0; 47 | } 48 | 49 | #beerList li { 50 | list-style: none; 51 | padding-left: 0; 52 | font-size: 2em; 53 | line-height: 1.5; 54 | } 55 | 56 | #beerList li small { 57 | font-size: 0.75em; 58 | color: #bbb; 59 | } --------------------------------------------------------------------------------