├── CNAME ├── .gitignore ├── classes ├── namespaces.md ├── instance_and_static_properties.md ├── index.md └── inheritance.md ├── assets └── hard_rock.jpg ├── _theme ├── assets │ ├── images │ │ └── favicon.ico │ ├── fonts │ │ ├── opensans │ │ │ ├── 300.woff │ │ │ ├── 300i.woff │ │ │ ├── 400.woff │ │ │ ├── 400i.woff │ │ │ ├── 600.woff │ │ │ ├── 600i.woff │ │ │ ├── 700.woff │ │ │ └── 700i.woff │ │ ├── anonymouspro │ │ │ ├── 400.woff │ │ │ ├── 700.woff │ │ │ ├── 400i.woff │ │ │ └── 700i.woff │ │ ├── ebgaramond │ │ │ ├── 400.woff │ │ │ └── 400i.woff │ │ ├── merriweather │ │ │ ├── 250.woff │ │ │ ├── 400.woff │ │ │ ├── 700.woff │ │ │ ├── 900.woff │ │ │ ├── 250i.woff │ │ │ ├── 400i.woff │ │ │ ├── 700i.woff │ │ │ └── 900i.woff │ │ └── fontawesome │ │ │ ├── FontAwesome.otf │ │ │ ├── fontawesome-webfont.eot │ │ │ ├── fontawesome-webfont.ttf │ │ │ └── fontawesome-webfont.woff │ └── jsrepl │ │ ├── sandbox.html │ │ ├── langs │ │ └── javascript │ │ │ └── jsrepl_js.js │ │ └── engines │ │ └── javascript-default.js ├── javascript │ ├── core │ │ ├── events.js │ │ ├── loading.js │ │ ├── state.js │ │ ├── keyboard.js │ │ ├── sidebar.js │ │ ├── exercise.js │ │ ├── progress.js │ │ ├── quiz.js │ │ ├── search.js │ │ └── font-settings.js │ ├── utils │ │ ├── platform.js │ │ ├── appcache.js │ │ ├── storage.js │ │ ├── sharing.js │ │ ├── path.js │ │ └── execute.js │ ├── execute │ │ └── javascript.js │ └── gitbook.js ├── stylesheets │ ├── mixins.less │ ├── vendors │ │ ├── fontawesome │ │ │ ├── fixed-width.less │ │ │ ├── core.less │ │ │ ├── bordered-pulled.less │ │ │ ├── rotated-flipped.less │ │ │ ├── larger.less │ │ │ ├── list.less │ │ │ ├── stacked.less │ │ │ ├── path.less │ │ │ ├── mixins.less │ │ │ ├── spinning.less │ │ │ └── font-awesome.less │ │ └── bootstrap │ │ │ ├── breadcrumbs.less │ │ │ ├── component-animations.less │ │ │ ├── wells.less │ │ │ ├── thumbnails.less │ │ │ ├── utilities.less │ │ │ ├── close.less │ │ │ ├── jumbotron.less │ │ │ ├── media.less │ │ │ ├── pager.less │ │ │ ├── badges.less │ │ │ ├── labels.less │ │ │ ├── code.less │ │ │ ├── bootstrap.less │ │ │ ├── alerts.less │ │ │ ├── print.less │ │ │ ├── pagination.less │ │ │ ├── list-group.less │ │ │ ├── progress-bars.less │ │ │ ├── scaffolding.less │ │ │ ├── tooltip.less │ │ │ ├── input-groups.less │ │ │ ├── popovers.less │ │ │ ├── modals.less │ │ │ ├── buttons.less │ │ │ ├── panels.less │ │ │ ├── carousel.less │ │ │ ├── dropdowns.less │ │ │ ├── tables.less │ │ │ └── navs.less │ ├── main.less │ ├── book │ │ ├── languages.less │ │ ├── exercise.less │ │ ├── quiz.less │ │ ├── navigation.less │ │ ├── highlight │ │ │ ├── white.less │ │ │ ├── night.less │ │ │ └── sepia.less │ │ ├── header.less │ │ ├── progress.less │ │ ├── body.less │ │ └── font-settings.less │ ├── page │ │ └── highlight.less │ ├── print.less │ └── fonts.less └── templates │ ├── langs.html │ ├── includes │ └── book │ │ ├── progress.html │ │ ├── font-settings.html │ │ ├── exercise.html │ │ ├── quiz.html │ │ ├── header.html │ │ └── summary.html │ └── site.html ├── book.json ├── conclusion ├── references.md └── index.md ├── package.json ├── Gruntfile.coffee ├── SUMMARY.md ├── patterns ├── adapter.md ├── observer.md ├── singleton.md ├── factory.md ├── index.md └── decorator.md ├── README.md ├── syntax ├── switch_and_try.md ├── variables.md ├── arrays_and_objects.md ├── loops_and_comprehensions.md ├── flow_control.md ├── index.md ├── operators_and_alises.md └── destructuring_assignment.md └── installation └── index.md /CNAME: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_store 3 | _book 4 | -------------------------------------------------------------------------------- /classes/namespaces.md: -------------------------------------------------------------------------------- 1 | ## Namespaces in CoffeeScript 2 | -------------------------------------------------------------------------------- /assets/hard_rock.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alchaplinsky/hard-rock-coffeescript/HEAD/assets/hard_rock.jpg -------------------------------------------------------------------------------- /_theme/assets/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alchaplinsky/hard-rock-coffeescript/HEAD/_theme/assets/images/favicon.ico -------------------------------------------------------------------------------- /_theme/javascript/core/events.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "jQuery" 3 | ], function($) { 4 | var events = $({}); 5 | 6 | return events; 7 | }); -------------------------------------------------------------------------------- /_theme/assets/fonts/opensans/300.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alchaplinsky/hard-rock-coffeescript/HEAD/_theme/assets/fonts/opensans/300.woff -------------------------------------------------------------------------------- /_theme/assets/fonts/opensans/300i.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alchaplinsky/hard-rock-coffeescript/HEAD/_theme/assets/fonts/opensans/300i.woff -------------------------------------------------------------------------------- /_theme/assets/fonts/opensans/400.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alchaplinsky/hard-rock-coffeescript/HEAD/_theme/assets/fonts/opensans/400.woff -------------------------------------------------------------------------------- /_theme/assets/fonts/opensans/400i.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alchaplinsky/hard-rock-coffeescript/HEAD/_theme/assets/fonts/opensans/400i.woff -------------------------------------------------------------------------------- /_theme/assets/fonts/opensans/600.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alchaplinsky/hard-rock-coffeescript/HEAD/_theme/assets/fonts/opensans/600.woff -------------------------------------------------------------------------------- /_theme/assets/fonts/opensans/600i.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alchaplinsky/hard-rock-coffeescript/HEAD/_theme/assets/fonts/opensans/600i.woff -------------------------------------------------------------------------------- /_theme/assets/fonts/opensans/700.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alchaplinsky/hard-rock-coffeescript/HEAD/_theme/assets/fonts/opensans/700.woff -------------------------------------------------------------------------------- /_theme/assets/fonts/opensans/700i.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alchaplinsky/hard-rock-coffeescript/HEAD/_theme/assets/fonts/opensans/700i.woff -------------------------------------------------------------------------------- /_theme/stylesheets/mixins.less: -------------------------------------------------------------------------------- 1 | .link-inherit { 2 | color: inherit; 3 | 4 | &:hover, &:focus { 5 | color: inherit; 6 | } 7 | } -------------------------------------------------------------------------------- /_theme/assets/fonts/anonymouspro/400.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alchaplinsky/hard-rock-coffeescript/HEAD/_theme/assets/fonts/anonymouspro/400.woff -------------------------------------------------------------------------------- /_theme/assets/fonts/anonymouspro/700.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alchaplinsky/hard-rock-coffeescript/HEAD/_theme/assets/fonts/anonymouspro/700.woff -------------------------------------------------------------------------------- /_theme/assets/fonts/ebgaramond/400.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alchaplinsky/hard-rock-coffeescript/HEAD/_theme/assets/fonts/ebgaramond/400.woff -------------------------------------------------------------------------------- /_theme/assets/fonts/ebgaramond/400i.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alchaplinsky/hard-rock-coffeescript/HEAD/_theme/assets/fonts/ebgaramond/400i.woff -------------------------------------------------------------------------------- /_theme/assets/fonts/merriweather/250.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alchaplinsky/hard-rock-coffeescript/HEAD/_theme/assets/fonts/merriweather/250.woff -------------------------------------------------------------------------------- /_theme/assets/fonts/merriweather/400.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alchaplinsky/hard-rock-coffeescript/HEAD/_theme/assets/fonts/merriweather/400.woff -------------------------------------------------------------------------------- /_theme/assets/fonts/merriweather/700.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alchaplinsky/hard-rock-coffeescript/HEAD/_theme/assets/fonts/merriweather/700.woff -------------------------------------------------------------------------------- /_theme/assets/fonts/merriweather/900.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alchaplinsky/hard-rock-coffeescript/HEAD/_theme/assets/fonts/merriweather/900.woff -------------------------------------------------------------------------------- /_theme/assets/fonts/anonymouspro/400i.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alchaplinsky/hard-rock-coffeescript/HEAD/_theme/assets/fonts/anonymouspro/400i.woff -------------------------------------------------------------------------------- /_theme/assets/fonts/anonymouspro/700i.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alchaplinsky/hard-rock-coffeescript/HEAD/_theme/assets/fonts/anonymouspro/700i.woff -------------------------------------------------------------------------------- /_theme/assets/fonts/merriweather/250i.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alchaplinsky/hard-rock-coffeescript/HEAD/_theme/assets/fonts/merriweather/250i.woff -------------------------------------------------------------------------------- /_theme/assets/fonts/merriweather/400i.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alchaplinsky/hard-rock-coffeescript/HEAD/_theme/assets/fonts/merriweather/400i.woff -------------------------------------------------------------------------------- /_theme/assets/fonts/merriweather/700i.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alchaplinsky/hard-rock-coffeescript/HEAD/_theme/assets/fonts/merriweather/700i.woff -------------------------------------------------------------------------------- /_theme/assets/fonts/merriweather/900i.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alchaplinsky/hard-rock-coffeescript/HEAD/_theme/assets/fonts/merriweather/900i.woff -------------------------------------------------------------------------------- /_theme/assets/fonts/fontawesome/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alchaplinsky/hard-rock-coffeescript/HEAD/_theme/assets/fonts/fontawesome/FontAwesome.otf -------------------------------------------------------------------------------- /_theme/assets/fonts/fontawesome/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alchaplinsky/hard-rock-coffeescript/HEAD/_theme/assets/fonts/fontawesome/fontawesome-webfont.eot -------------------------------------------------------------------------------- /_theme/assets/fonts/fontawesome/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alchaplinsky/hard-rock-coffeescript/HEAD/_theme/assets/fonts/fontawesome/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /_theme/assets/fonts/fontawesome/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alchaplinsky/hard-rock-coffeescript/HEAD/_theme/assets/fonts/fontawesome/fontawesome-webfont.woff -------------------------------------------------------------------------------- /_theme/stylesheets/vendors/fontawesome/fixed-width.less: -------------------------------------------------------------------------------- 1 | // Fixed Width Icons 2 | // ------------------------- 3 | .@{fa-css-prefix}-fw { 4 | width: (18em / 14); 5 | text-align: center; 6 | } 7 | -------------------------------------------------------------------------------- /_theme/javascript/utils/platform.js: -------------------------------------------------------------------------------- 1 | define([], function() { 2 | return { 3 | isMobile: /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) 4 | }; 5 | }); -------------------------------------------------------------------------------- /_theme/assets/jsrepl/sandbox.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | jsREPL Sandbox 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /book.json: -------------------------------------------------------------------------------- 1 | { 2 | "generator": "site", 3 | "title": "Hard Rock CoffeeScript", 4 | "description": "CoffeeScript Bookx", 5 | "home": "http://hardrockcoffeescript.org", 6 | "links": { 7 | "contribute": "https://github.com/alchapone/hard-rock-coffeescript/pulls" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /_theme/javascript/execute/javascript.js: -------------------------------------------------------------------------------- 1 | define(function() { 2 | return { 3 | id: "javascript", 4 | assertCode: "function assert(condition, message) { \nif (!condition) { \n throw message || \"Assertion failed\"; \n } \n }\n", 5 | REPL: JSREPL, 6 | sep: ";\n", 7 | }; 8 | }); 9 | -------------------------------------------------------------------------------- /_theme/stylesheets/vendors/fontawesome/core.less: -------------------------------------------------------------------------------- 1 | // Base Class Definition 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix} { 5 | display: inline-block; 6 | font-family: FontAwesome; 7 | font-style: normal; 8 | font-weight: normal; 9 | line-height: 1; 10 | -webkit-font-smoothing: antialiased; 11 | -moz-osx-font-smoothing: grayscale; 12 | } 13 | -------------------------------------------------------------------------------- /_theme/javascript/core/loading.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "jQuery" 3 | ], function($) { 4 | var showLoading = function(p) { 5 | var $book = $(".book"); 6 | 7 | $book.addClass("is-loading"); 8 | p.always(function() { 9 | $book.removeClass("is-loading"); 10 | }); 11 | 12 | return p; 13 | }; 14 | 15 | return { 16 | show: showLoading 17 | }; 18 | }); -------------------------------------------------------------------------------- /_theme/javascript/utils/appcache.js: -------------------------------------------------------------------------------- 1 | define([], function() { 2 | var isAvailable = (typeof applicationCache !== "undefined"); 3 | 4 | var init = function() { 5 | if (!isAvailable) return; 6 | 7 | window.applicationCache.addEventListener('updateready', function() { 8 | window.location.reload(); 9 | }, false); 10 | }; 11 | 12 | return { 13 | init: init 14 | }; 15 | }); -------------------------------------------------------------------------------- /_theme/stylesheets/vendors/fontawesome/bordered-pulled.less: -------------------------------------------------------------------------------- 1 | // Bordered & Pulled 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix}-border { 5 | padding: .2em .25em .15em; 6 | border: solid .08em @fa-border-color; 7 | border-radius: .1em; 8 | } 9 | 10 | .pull-right { float: right; } 11 | .pull-left { float: left; } 12 | 13 | .@{fa-css-prefix} { 14 | &.pull-left { margin-right: .3em; } 15 | &.pull-right { margin-left: .3em; } 16 | } 17 | -------------------------------------------------------------------------------- /_theme/stylesheets/vendors/fontawesome/rotated-flipped.less: -------------------------------------------------------------------------------- 1 | // Rotated & Flipped Icons 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix}-rotate-90 { .fa-icon-rotate(90deg, 1); } 5 | .@{fa-css-prefix}-rotate-180 { .fa-icon-rotate(180deg, 2); } 6 | .@{fa-css-prefix}-rotate-270 { .fa-icon-rotate(270deg, 3); } 7 | 8 | .@{fa-css-prefix}-flip-horizontal { .fa-icon-flip(-1, 1, 0); } 9 | .@{fa-css-prefix}-flip-vertical { .fa-icon-flip(1, -1, 2); } 10 | -------------------------------------------------------------------------------- /_theme/stylesheets/vendors/fontawesome/larger.less: -------------------------------------------------------------------------------- 1 | // Icon Sizes 2 | // ------------------------- 3 | 4 | /* makes the font 33% larger relative to the icon container */ 5 | .@{fa-css-prefix}-lg { 6 | font-size: (4em / 3); 7 | line-height: (3em / 4); 8 | vertical-align: -15%; 9 | } 10 | .@{fa-css-prefix}-2x { font-size: 2em; } 11 | .@{fa-css-prefix}-3x { font-size: 3em; } 12 | .@{fa-css-prefix}-4x { font-size: 4em; } 13 | .@{fa-css-prefix}-5x { font-size: 5em; } 14 | -------------------------------------------------------------------------------- /_theme/stylesheets/vendors/fontawesome/list.less: -------------------------------------------------------------------------------- 1 | // List Icons 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix}-ul { 5 | padding-left: 0; 6 | margin-left: @fa-li-width; 7 | list-style-type: none; 8 | > li { position: relative; } 9 | } 10 | .@{fa-css-prefix}-li { 11 | position: absolute; 12 | left: -@fa-li-width; 13 | width: @fa-li-width; 14 | top: (2em / 14); 15 | text-align: center; 16 | &.@{fa-css-prefix}-lg { 17 | left: -@fa-li-width + (4em / 14); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /_theme/javascript/core/state.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "jQuery" 3 | ], function() { 4 | var state = {}; 5 | 6 | state.update = function(dom) { 7 | var $book = $(dom.find(".book")); 8 | 9 | state.$book = $book; 10 | state.githubId = $book.data("github"); 11 | state.level = $book.data("level"); 12 | state.basePath = $book.data("basepath"); 13 | state.revision = $book.data("revision"); 14 | }; 15 | 16 | state.update($); 17 | 18 | return state; 19 | }); -------------------------------------------------------------------------------- /conclusion/references.md: -------------------------------------------------------------------------------- 1 | ## References 2 | 3 | 1. CoffeeScript [http://coffeescript.org](http://coffeescript.org) 4 | 1. Little Book on CoffeeScript [http://arcturo.github.io/library/coffeescript/](http://arcturo.github.io/library/coffeescript/) 5 | 3. Smooth CoffeeScript [http://autotelicum.github.io/Smooth-CoffeeScript/](http://autotelicum.github.io/Smooth-CoffeeScript/) 6 | 2. CoffeeScript Quick Reference [http://autotelicum.github.io/Smooth-CoffeeScript/CoffeeScript%20Quick%20Ref.pdf](http://autotelicum.github.io/Smooth-CoffeeScript/CoffeeScript%20Quick%20Ref.pdf) 7 | -------------------------------------------------------------------------------- /_theme/templates/langs.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | 3 | {% block title %}{{ title }}{% endblock %} 4 | 5 | {% block content %} 6 |
7 |
8 |

Choose a language

9 | 10 | 17 |
18 |
19 | {% endblock %} 20 | 21 | {% block javascript %}{% endblock %} -------------------------------------------------------------------------------- /_theme/templates/includes/book/progress.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |
6 | {% for p in progress.chapters %} 7 | 8 | {% endfor %} 9 |
10 |
-------------------------------------------------------------------------------- /_theme/stylesheets/vendors/fontawesome/stacked.less: -------------------------------------------------------------------------------- 1 | // Stacked Icons 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix}-stack { 5 | position: relative; 6 | display: inline-block; 7 | width: 2em; 8 | height: 2em; 9 | line-height: 2em; 10 | vertical-align: middle; 11 | } 12 | .@{fa-css-prefix}-stack-1x, .@{fa-css-prefix}-stack-2x { 13 | position: absolute; 14 | left: 0; 15 | width: 100%; 16 | text-align: center; 17 | } 18 | .@{fa-css-prefix}-stack-1x { line-height: inherit; } 19 | .@{fa-css-prefix}-stack-2x { font-size: 2em; } 20 | .@{fa-css-prefix}-inverse { color: @fa-inverse; } 21 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hard-rock-coffeescript", 3 | "version": "0.9.1", 4 | "description": "", 5 | "repository": { 6 | "type": "git", 7 | "url": "" 8 | }, 9 | "author": "Alex Chaplinsky ", 10 | "license": "MIT", 11 | "dependencies": {}, 12 | "devDependencies": { 13 | "grunt": "~0.4.1", 14 | "load-grunt-tasks": "~0.1.0", 15 | "grunt-contrib-watch": "0.6.1", 16 | "grunt-gitbook": "0.3.2", 17 | "grunt-gh-pages": "0.9.1", 18 | "grunt-contrib-less": "~0.5.0", 19 | "grunt-contrib-clean": "~0.5.0" 20 | }, 21 | "peerDependencies": { 22 | "grunt": "~0.4.1" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /_theme/stylesheets/vendors/bootstrap/breadcrumbs.less: -------------------------------------------------------------------------------- 1 | // 2 | // Breadcrumbs 3 | // -------------------------------------------------- 4 | 5 | 6 | .breadcrumb { 7 | padding: 8px 15px; 8 | margin-bottom: @line-height-computed; 9 | list-style: none; 10 | background-color: @breadcrumb-bg; 11 | border-radius: @border-radius-base; 12 | > li { 13 | display: inline-block; 14 | &+li:before { 15 | content: "/\00a0"; // Unicode space added since inline-block means non-collapsing white-space 16 | padding: 0 5px; 17 | color: @breadcrumb-color; 18 | } 19 | } 20 | > .active { 21 | color: @breadcrumb-active-color; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /_theme/stylesheets/vendors/fontawesome/path.less: -------------------------------------------------------------------------------- 1 | /* FONT PATH 2 | * -------------------------- */ 3 | 4 | @font-face { 5 | font-family: 'FontAwesome'; 6 | src: url('@{fa-font-path}/fontawesome-webfont.eot'); 7 | src: url('@{fa-font-path}/fontawesome-webfont.eot') format('embedded-opentype'), 8 | url('@{fa-font-path}/fontawesome-webfont.woff') format('woff'), 9 | url('@{fa-font-path}/fontawesome-webfont.ttf') format('truetype'), 10 | url('@{fa-font-path}/fontawesome-webfont.svg') format('svg'); 11 | // src: url('@{fa-font-path}/FontAwesome.otf') format('opentype'); // used when developing fonts 12 | font-weight: normal; 13 | font-style: normal; 14 | } 15 | -------------------------------------------------------------------------------- /_theme/assets/jsrepl/langs/javascript/jsrepl_js.js: -------------------------------------------------------------------------------- 1 | (function(){self.JSREPLEngine=function(){function a(d,b,c,a,e,f){this.result=c;this.error=a;this.sandbox=e;this.inspect=this.sandbox.console.inspect;this.functionClass=this.sandbox.Function;this.sandbox.__eval=this.sandbox.eval;f()}a.prototype.Eval=function(d){var b;try{return b=this.sandbox.__eval(d),this.result(b===void 0?"":this.inspect(b))}catch(a){return this.error(a)}};a.prototype.RawEval=function(a){var b;try{return b=this.sandbox.__eval(a),this.result(b)}catch(c){return this.error(c)}};a.prototype.GetNextLineIndent= 2 | function(a){try{return new this.functionClass(a),false}catch(b){return/[\[\{\(]$/.test(a)?1:0}};return a}()}).call(this); 3 | -------------------------------------------------------------------------------- /_theme/stylesheets/vendors/bootstrap/component-animations.less: -------------------------------------------------------------------------------- 1 | // 2 | // Component animations 3 | // -------------------------------------------------- 4 | 5 | // Heads up! 6 | // 7 | // We don't use the `.opacity()` mixin here since it causes a bug with text 8 | // fields in IE7-8. Source: https://github.com/twitter/bootstrap/pull/3552. 9 | 10 | .fade { 11 | opacity: 0; 12 | .transition(opacity .15s linear); 13 | &.in { 14 | opacity: 1; 15 | } 16 | } 17 | 18 | .collapse { 19 | display: none; 20 | &.in { 21 | display: block; 22 | } 23 | } 24 | .collapsing { 25 | position: relative; 26 | height: 0; 27 | overflow: hidden; 28 | .transition(height .35s ease); 29 | } 30 | -------------------------------------------------------------------------------- /_theme/stylesheets/vendors/bootstrap/wells.less: -------------------------------------------------------------------------------- 1 | // 2 | // Wells 3 | // -------------------------------------------------- 4 | 5 | 6 | // Base class 7 | .well { 8 | min-height: 20px; 9 | padding: 19px; 10 | margin-bottom: 20px; 11 | background-color: @well-bg; 12 | border: 1px solid darken(@well-bg, 7%); 13 | border-radius: @border-radius-base; 14 | .box-shadow(inset 0 1px 1px rgba(0,0,0,.05)); 15 | blockquote { 16 | border-color: #ddd; 17 | border-color: rgba(0,0,0,.15); 18 | } 19 | } 20 | 21 | // Sizes 22 | .well-lg { 23 | padding: 24px; 24 | border-radius: @border-radius-large; 25 | } 26 | .well-sm { 27 | padding: 9px; 28 | border-radius: @border-radius-small; 29 | } 30 | -------------------------------------------------------------------------------- /_theme/stylesheets/vendors/bootstrap/thumbnails.less: -------------------------------------------------------------------------------- 1 | // 2 | // Thumbnails 3 | // -------------------------------------------------- 4 | 5 | 6 | // Mixin and adjust the regular image class 7 | .thumbnail { 8 | .img-thumbnail(); 9 | display: block; // Override the inline-block from `.img-thumbnail` 10 | 11 | > img { 12 | .img-responsive(); 13 | } 14 | } 15 | 16 | 17 | // Add a hover state for linked versions only 18 | a.thumbnail:hover, 19 | a.thumbnail:focus { 20 | border-color: @link-color; 21 | } 22 | 23 | // Images and captions 24 | .thumbnail > img { 25 | margin-left: auto; 26 | margin-right: auto; 27 | } 28 | .thumbnail .caption { 29 | padding: @thumbnail-caption-padding; 30 | color: @thumbnail-caption-color; 31 | } 32 | -------------------------------------------------------------------------------- /_theme/stylesheets/vendors/bootstrap/utilities.less: -------------------------------------------------------------------------------- 1 | // 2 | // Utility classes 3 | // -------------------------------------------------- 4 | 5 | 6 | // Floats 7 | // ------------------------- 8 | 9 | .clearfix { 10 | .clearfix(); 11 | } 12 | .pull-right { 13 | float: right !important; 14 | } 15 | .pull-left { 16 | float: left !important; 17 | } 18 | 19 | 20 | // Toggling content 21 | // ------------------------- 22 | 23 | .hide { 24 | display: none !important; 25 | } 26 | .show { 27 | display: block !important; 28 | } 29 | .invisible { 30 | visibility: hidden; 31 | } 32 | .text-hide { 33 | .hide-text(); 34 | } 35 | 36 | 37 | // For Affix plugin 38 | // ------------------------- 39 | 40 | .affix { 41 | position: fixed; 42 | } 43 | -------------------------------------------------------------------------------- /_theme/stylesheets/vendors/fontawesome/mixins.less: -------------------------------------------------------------------------------- 1 | // Mixins 2 | // -------------------------- 3 | 4 | .fa-icon-rotate(@degrees, @rotation) { 5 | filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=@rotation); 6 | -webkit-transform: rotate(@degrees); 7 | -moz-transform: rotate(@degrees); 8 | -ms-transform: rotate(@degrees); 9 | -o-transform: rotate(@degrees); 10 | transform: rotate(@degrees); 11 | } 12 | 13 | .fa-icon-flip(@horiz, @vert, @rotation) { 14 | filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=@rotation, mirror=1); 15 | -webkit-transform: scale(@horiz, @vert); 16 | -moz-transform: scale(@horiz, @vert); 17 | -ms-transform: scale(@horiz, @vert); 18 | -o-transform: scale(@horiz, @vert); 19 | transform: scale(@horiz, @vert); 20 | } 21 | -------------------------------------------------------------------------------- /_theme/stylesheets/vendors/bootstrap/close.less: -------------------------------------------------------------------------------- 1 | // 2 | // Close icons 3 | // -------------------------------------------------- 4 | 5 | 6 | .close { 7 | float: right; 8 | font-size: (@font-size-base * 1.5); 9 | font-weight: @close-font-weight; 10 | line-height: 1; 11 | color: @close-color; 12 | text-shadow: @close-text-shadow; 13 | .opacity(.2); 14 | 15 | &:hover, 16 | &:focus { 17 | color: @close-color; 18 | text-decoration: none; 19 | cursor: pointer; 20 | .opacity(.5); 21 | } 22 | 23 | // Additional properties for button version 24 | // iOS requires the button element instead of an anchor tag. 25 | // If you want the anchor version, it requires `href="#"`. 26 | button& { 27 | padding: 0; 28 | cursor: pointer; 29 | background: transparent; 30 | border: 0; 31 | -webkit-appearance: none; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Gruntfile.coffee: -------------------------------------------------------------------------------- 1 | module.exports = (grunt) => 2 | require('load-grunt-tasks')(grunt) 3 | 4 | grunt.initConfig 5 | less: 6 | development: 7 | options: 8 | compress: true 9 | yuicompress: true 10 | optimization: 2 11 | files: 12 | "_theme/assets/style.css": "_theme/stylesheets/main.less" 13 | "_theme/assets/print.css": "_theme/stylesheets/print.less" 14 | gitbook: 15 | development: 16 | input: "./" 17 | github: "alchapone/hard-rock-coffeescript" 18 | theme: "_theme" 19 | "gh-pages": 20 | options: 21 | base: '_book' 22 | src: ['**'] 23 | clean: 24 | files: '.grunt' 25 | watch: 26 | pages: 27 | files: ["**/*.md"] 28 | tasks: ['gitbook'] 29 | 30 | grunt.registerTask 'publish', ['gitbook', 'gh-pages','clean'] 31 | -------------------------------------------------------------------------------- /_theme/stylesheets/vendors/fontawesome/spinning.less: -------------------------------------------------------------------------------- 1 | // Spinning Icons 2 | // -------------------------- 3 | 4 | .@{fa-css-prefix}-spin { 5 | -webkit-animation: spin 2s infinite linear; 6 | -moz-animation: spin 2s infinite linear; 7 | -o-animation: spin 2s infinite linear; 8 | animation: spin 2s infinite linear; 9 | } 10 | 11 | @-moz-keyframes spin { 12 | 0% { -moz-transform: rotate(0deg); } 13 | 100% { -moz-transform: rotate(359deg); } 14 | } 15 | @-webkit-keyframes spin { 16 | 0% { -webkit-transform: rotate(0deg); } 17 | 100% { -webkit-transform: rotate(359deg); } 18 | } 19 | @-o-keyframes spin { 20 | 0% { -o-transform: rotate(0deg); } 21 | 100% { -o-transform: rotate(359deg); } 22 | } 23 | @-ms-keyframes spin { 24 | 0% { -ms-transform: rotate(0deg); } 25 | 100% { -ms-transform: rotate(359deg); } 26 | } 27 | @keyframes spin { 28 | 0% { transform: rotate(0deg); } 29 | 100% { transform: rotate(359deg); } 30 | } 31 | -------------------------------------------------------------------------------- /_theme/stylesheets/main.less: -------------------------------------------------------------------------------- 1 | @import "vendors/bootstrap/bootstrap.less"; 2 | @import "vendors/fontawesome/font-awesome.less"; 3 | 4 | @import "mixins.less"; 5 | @import "variables.less"; 6 | @import "fonts.less"; 7 | 8 | @import "book/languages.less"; 9 | @import "book/header.less"; 10 | @import "book/summary.less"; 11 | @import "book/font-settings.less"; 12 | @import "book/body.less"; 13 | @import "book/exercise.less"; 14 | @import "book/quiz.less"; 15 | @import "book/markdown.less"; 16 | @import "book/progress.less"; 17 | @import "book/navigation.less"; 18 | 19 | * { 20 | -webkit-overflow-scrolling: touch; 21 | -webkit-tap-highlight-color: transparent; 22 | -webkit-text-size-adjust: none; 23 | -webkit-touch-callout: none; 24 | -webkit-font-smoothing: antialiased; 25 | } 26 | 27 | html, body { 28 | height: 100%; 29 | } 30 | 31 | body { 32 | text-rendering: optimizeLegibility; 33 | font-smoothing: antialiased; 34 | font-family: @font-family-base; 35 | } 36 | -------------------------------------------------------------------------------- /_theme/templates/includes/book/font-settings.html: -------------------------------------------------------------------------------- 1 | 23 | -------------------------------------------------------------------------------- /_theme/javascript/utils/storage.js: -------------------------------------------------------------------------------- 1 | define(function(){ 2 | var baseKey = ""; 3 | 4 | /* 5 | * Simple module for storing data in the browser's local storage 6 | */ 7 | return { 8 | setBaseKey: function(key) { 9 | baseKey = key; 10 | }, 11 | set: function(key, value) { 12 | key = baseKey+":"+key; 13 | localStorage[key] = JSON.stringify(value); 14 | }, 15 | get: function(key, def) { 16 | key = baseKey+":"+key; 17 | if (localStorage[key] === undefined) return def; 18 | try { 19 | var v = JSON.parse(localStorage[key]); 20 | return v == null ? def : v;; 21 | } catch(err) { 22 | console.error(err); 23 | return localStorage[key] || def; 24 | } 25 | }, 26 | remove: function(key) { 27 | key = baseKey+":"+key; 28 | localStorage.removeItem(key); 29 | } 30 | }; 31 | }); -------------------------------------------------------------------------------- /_theme/javascript/core/keyboard.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "jQuery", 3 | "Mousetrap", 4 | "core/navigation", 5 | "core/sidebar", 6 | "core/search" 7 | ], function($, Mousetrap, navigation, sidebar, search){ 8 | // Bind keyboard shortcuts 9 | var init = function() { 10 | // Next 11 | Mousetrap.bind(['right'], function(e) { 12 | navigation.goNext(); 13 | return false; 14 | }); 15 | 16 | // Prev 17 | Mousetrap.bind(['left'], function(e) { 18 | navigation.goPrev(); 19 | return false; 20 | }); 21 | 22 | // Toggle Summary 23 | Mousetrap.bind(['s'], function(e) { 24 | sidebar.toggle(); 25 | return false; 26 | }); 27 | 28 | // Toggle Search 29 | Mousetrap.bind(['f'], function(e) { 30 | search.toggle(); 31 | return false; 32 | }); 33 | }; 34 | 35 | return { 36 | init: init, 37 | search: search 38 | }; 39 | }); -------------------------------------------------------------------------------- /_theme/javascript/utils/sharing.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "jQuery" 3 | ], function($) { 4 | var url = location.href; 5 | var title = $("title").text(); 6 | 7 | var types = { 8 | "twitter": function($el) { 9 | window.open("http://twitter.com/home?status="+encodeURIComponent(title+" "+url)) 10 | }, 11 | "facebook": function($el) { 12 | window.open("http://www.facebook.com/sharer/sharer.php?s=100&p[url]="+encodeURIComponent(url)) 13 | }, 14 | "google-plus": function($el) { 15 | window.open("https://plus.google.com/share?url="+encodeURIComponent(url)) 16 | } 17 | }; 18 | 19 | 20 | // Bind all sharing button 21 | var init = function() { 22 | $(document).on("click", "a[data-sharing]", function(e) { 23 | if (e) e.preventDefault(); 24 | var type = $(this).data("sharing"); 25 | 26 | types[type]($(this)); 27 | }) 28 | }; 29 | 30 | return { 31 | init: init 32 | }; 33 | }); -------------------------------------------------------------------------------- /_theme/stylesheets/vendors/bootstrap/jumbotron.less: -------------------------------------------------------------------------------- 1 | // 2 | // Jumbotron 3 | // -------------------------------------------------- 4 | 5 | 6 | .jumbotron { 7 | padding: @jumbotron-padding; 8 | margin-bottom: @jumbotron-padding; 9 | font-size: (@font-size-base * 1.5); 10 | font-weight: 200; 11 | line-height: (@line-height-base * 1.5); 12 | color: @jumbotron-color; 13 | background-color: @jumbotron-bg; 14 | 15 | h1 { 16 | line-height: 1; 17 | color: @jumbotron-heading-color; 18 | } 19 | p { 20 | line-height: 1.4; 21 | } 22 | 23 | .container & { 24 | border-radius: @border-radius-large; // Only round corners at higher resolutions if contained in a container 25 | } 26 | 27 | @media screen and (min-width: @screen-tablet) { 28 | padding-top: (@jumbotron-padding * 1.6); 29 | padding-bottom: (@jumbotron-padding * 1.6); 30 | 31 | .container & { 32 | padding-left: (@jumbotron-padding * 2); 33 | padding-right: (@jumbotron-padding * 2); 34 | } 35 | 36 | h1 { 37 | font-size: (@font-size-base * 4.5); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /conclusion/index.md: -------------------------------------------------------------------------------- 1 | ## Conclusion 2 | 3 | That's all for this introductory adventure into the world of CoffeeScript and writing syntactically awesome frontend code - I hope you have found it helpful and fun. 4 | 5 | CoffeeScript is a great tool to use for beginners and for experienced developer, as it is quick and easy to learn. 6 | It increases code expressiveness, speeds up development and simplifies maintainability and protects you from running into 7 | multiple pitfalls you have with JavaScript. 8 | 9 | The contents of this book should hopefully provide sufficient information to get started using CoffeeScript in development 10 | of web applications and having fun while working on open source products. 11 | 12 | We've covered object-oriented abilities of CoffeeScript which may make you feel more comfortable in writing and structuring 13 | your frontend code. Designing with classes and objects is more high level, than writing tons of spagetti callback oriented code. 14 | 15 | So if you still haven't written a single line of code on CoffeeScript, I encourage you to get started immediately - you'll love it! 16 | -------------------------------------------------------------------------------- /_theme/templates/includes/book/exercise.html: -------------------------------------------------------------------------------- 1 |
2 |

Exercise

3 |
4 |
5 | Correct! 6 |
7 | 8 |
9 | False! 10 |
11 | 12 |
13 | {% autoescape false %}{{ section.content }}{% endautoescape %} 14 |
15 |
{{ section.code.base }}
16 | 17 | 18 | 19 | {% if section.code.context %} 20 | 21 | {% endif %} 22 | 23 |
24 | Submit 25 | Solution 26 | {% if githubId %} 27 | Have a Question? 28 | {% endif %} 29 |
30 | -------------------------------------------------------------------------------- /_theme/stylesheets/vendors/bootstrap/media.less: -------------------------------------------------------------------------------- 1 | // Media objects 2 | // Source: http://stubbornella.org/content/?p=497 3 | // -------------------------------------------------- 4 | 5 | 6 | // Common styles 7 | // ------------------------- 8 | 9 | // Clear the floats 10 | .media, 11 | .media-body { 12 | overflow: hidden; 13 | zoom: 1; 14 | } 15 | 16 | // Proper spacing between instances of .media 17 | .media, 18 | .media .media { 19 | margin-top: 15px; 20 | } 21 | .media:first-child { 22 | margin-top: 0; 23 | } 24 | 25 | // For images and videos, set to block 26 | .media-object { 27 | display: block; 28 | } 29 | 30 | // Reset margins on headings for tighter default spacing 31 | .media-heading { 32 | margin: 0 0 5px; 33 | } 34 | 35 | 36 | // Media image alignment 37 | // ------------------------- 38 | 39 | .media { 40 | > .pull-left { 41 | margin-right: 10px; 42 | } 43 | > .pull-right { 44 | margin-left: 10px; 45 | } 46 | } 47 | 48 | 49 | // Media list variation 50 | // ------------------------- 51 | 52 | // Undo default ul/ol styles 53 | .media-list { 54 | padding-left: 0; 55 | list-style: none; 56 | } 57 | -------------------------------------------------------------------------------- /_theme/stylesheets/vendors/bootstrap/pager.less: -------------------------------------------------------------------------------- 1 | // 2 | // Pager pagination 3 | // -------------------------------------------------- 4 | 5 | 6 | .pager { 7 | padding-left: 0; 8 | margin: @line-height-computed 0; 9 | list-style: none; 10 | text-align: center; 11 | .clearfix(); 12 | li { 13 | display: inline; 14 | > a, 15 | > span { 16 | display: inline-block; 17 | padding: 5px 14px; 18 | background-color: @pagination-bg; 19 | border: 1px solid @pagination-border; 20 | border-radius: @pager-border-radius; 21 | } 22 | 23 | > a:hover, 24 | > a:focus { 25 | text-decoration: none; 26 | background-color: @pagination-hover-bg; 27 | } 28 | } 29 | 30 | .next { 31 | > a, 32 | > span { 33 | float: right; 34 | } 35 | } 36 | 37 | .previous { 38 | > a, 39 | > span { 40 | float: left; 41 | } 42 | } 43 | 44 | .disabled { 45 | > a, 46 | > a:hover, 47 | > a:focus, 48 | > span { 49 | color: @pager-disabled-color; 50 | background-color: @pagination-bg; 51 | cursor: not-allowed; 52 | } 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /SUMMARY.md: -------------------------------------------------------------------------------- 1 | # Summary 2 | * [Installation](installation/index.md) 3 | * [Syntax](syntax/index.md) 4 | * [Variables and Scope](syntax/variables.md) 5 | * [Functions](syntax/functions.md) 6 | * [Flow control](syntax/flow_control.md) 7 | * [Arrays and objects](syntax/arrays_and_objects.md) 8 | * [Operators and Aliases](syntax/operators_and_alises.md) 9 | * [Loops and comprehensions](syntax/loops_and_comprehensions.md) 10 | * [Switch/Case and Try/Catch](syntax/switch_and_try.md) 11 | * [Destructuring Assignment](syntax/destructuring_assignment.md) 12 | * [Classes](classes/index.md) 13 | * [Inheritance & Super](classes/inheritance.md) 14 | * [Instance & Static properties](classes/instance_and_static_properties.md) 15 | * [Mixins and Extending classes](classes/extending_classes.md) 16 | * [Design Patterns](patterns/index.md) 17 | * [Singleton Pattern](patterns/singleton.md) 18 | * [Observer Pattern](patterns/observer.md) 19 | * [Factory Pattern](patterns/factory.md) 20 | * [Decorator Pattern](patterns/decorator.md) 21 | * [Adapter Pattern](patterns/adapter.md) 22 | * [Conclusion](conclusion/index.md) 23 | * [References](conclusion/references.md) 24 | -------------------------------------------------------------------------------- /_theme/stylesheets/book/languages.less: -------------------------------------------------------------------------------- 1 | .book-langs-index { 2 | width: 100%; 3 | height: 100%; 4 | padding: 40px 0px; 5 | margin: 0px; 6 | overflow: auto; 7 | 8 | @media (max-width: 600px) { 9 | padding: 0px; 10 | } 11 | 12 | .inner { 13 | max-width: 600px; 14 | width: 100%; 15 | 16 | margin: 0px auto; 17 | padding: 30px; 18 | 19 | background: #fff; 20 | border-radius: 3px; 21 | 22 | h3 { 23 | margin: 0px; 24 | } 25 | 26 | .languages { 27 | list-style: none; 28 | padding: 20px 30px; 29 | margin-top: 20px; 30 | border-top: 1px solid #eee; 31 | 32 | .clearfix(); 33 | 34 | li { 35 | width: 50%; 36 | float: left; 37 | padding: 10px 5px; 38 | font-size: 16px; 39 | 40 | a { 41 | 42 | } 43 | 44 | @media (max-width: 600px) { 45 | width: 100%; 46 | max-width: 100%; 47 | } 48 | } 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /_theme/stylesheets/book/exercise.less: -------------------------------------------------------------------------------- 1 | .book .book-body .page-wrapper .page-inner { 2 | section.exercise { 3 | padding: 0px; 4 | margin: 20px 0px; 5 | border: 3px solid #2f8cde; 6 | 7 | .header { 8 | padding: 5px 15px; 9 | 10 | color: #fff; 11 | background: #2f8cde; 12 | 13 | h2 { 14 | margin: 0px; 15 | font-size: 20px; 16 | } 17 | } 18 | 19 | .message { 20 | margin: 5px 15px; 21 | } 22 | 23 | .editor { 24 | min-height: 50px; 25 | font-size: 14px; 26 | border-top: 1px solid #ddd; 27 | border-bottom: 1px solid #ddd; 28 | } 29 | 30 | 31 | .alert { 32 | display: none; 33 | margin: 0px; 34 | margin-bottom: 10px; 35 | padding: 8px 15px; 36 | } 37 | 38 | &.return-error { 39 | .alert-danger { 40 | display: block; 41 | } 42 | } 43 | &.return-success { 44 | .alert-success { 45 | display: block; 46 | } 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /_theme/stylesheets/vendors/bootstrap/badges.less: -------------------------------------------------------------------------------- 1 | // 2 | // Badges 3 | // -------------------------------------------------- 4 | 5 | 6 | // Base classes 7 | .badge { 8 | display: inline-block; 9 | min-width: 10px; 10 | padding: 3px 7px; 11 | font-size: @font-size-small; 12 | font-weight: @badge-font-weight; 13 | color: @badge-color; 14 | line-height: @badge-line-height; 15 | vertical-align: baseline; 16 | white-space: nowrap; 17 | text-align: center; 18 | background-color: @badge-bg; 19 | border-radius: @badge-border-radius; 20 | 21 | // Empty badges collapse automatically (not available in IE8) 22 | &:empty { 23 | display: none; 24 | } 25 | } 26 | 27 | // Hover state, but only for links 28 | a.badge { 29 | &:hover, 30 | &:focus { 31 | color: @badge-link-hover-color; 32 | text-decoration: none; 33 | cursor: pointer; 34 | } 35 | } 36 | 37 | // Quick fix for labels/badges in buttons 38 | .btn .badge { 39 | position: relative; 40 | top: -1px; 41 | } 42 | 43 | // Account for counters in navs 44 | a.list-group-item.active > .badge, 45 | .nav-pills > .active > a > .badge { 46 | color: @badge-active-color; 47 | background-color: @badge-active-bg; 48 | } 49 | .nav-pills > li > a > .badge { 50 | margin-left: 3px; 51 | } 52 | -------------------------------------------------------------------------------- /patterns/adapter.md: -------------------------------------------------------------------------------- 1 | ## Adapter pattern 2 | 3 | The adapter pattern is a software design pattern that allows the interface of an existing class to be used from another 4 | interface. It is often used to make existing classes work with others without modifying their source code. 5 | 6 | Adapters basically allow objects or classes to function together which normally couldn't due to their incompatible interfaces. 7 | The adapter translates calls to its interface into calls to the original interface and the code required to achieve this 8 | is usually quite minimal. 9 | 10 | ```coffeescript 11 | class Guitar 12 | strumTheStrings: -> 13 | "Guitar sound" 14 | 15 | class Drums 16 | hitDrumWithStick: () -> 17 | "Drumkit sound" 18 | 19 | class GuitarAdapter 20 | constructor: (@adaptee) -> 21 | playSound: () -> 22 | @adaptee.strumTheStrings() 23 | 24 | class DrumsAdapter 25 | constructor: (@adaptee) -> 26 | playSound: () -> 27 | @adaptee.hitDrumWithStick() 28 | 29 | class Client 30 | @run: () -> 31 | adaptee = new Guitar() 32 | adapter = new GuitarAdapter adaptee 33 | adapter.playSound() # Guitar sound 34 | 35 | adaptee = new Drums() 36 | adapter = new DrumsAdapter adaptee 37 | adapter.playSound() # Drumkit sound 38 | Client.run() 39 | ``` 40 | -------------------------------------------------------------------------------- /_theme/stylesheets/vendors/bootstrap/labels.less: -------------------------------------------------------------------------------- 1 | // 2 | // Labels 3 | // -------------------------------------------------- 4 | 5 | .label { 6 | display: inline; 7 | padding: .2em .6em .3em; 8 | font-size: 75%; 9 | font-weight: bold; 10 | line-height: 1; 11 | color: @label-color; 12 | text-align: center; 13 | white-space: nowrap; 14 | vertical-align: baseline; 15 | border-radius: .25em; 16 | 17 | // Add hover effects, but only for links 18 | &[href] { 19 | &:hover, 20 | &:focus { 21 | color: @label-link-hover-color; 22 | text-decoration: none; 23 | cursor: pointer; 24 | } 25 | } 26 | 27 | // Empty labels collapse automatically (not available in IE8) 28 | &:empty { 29 | display: none; 30 | } 31 | } 32 | 33 | // Colors 34 | // Contextual variations (linked labels get darker on :hover) 35 | 36 | .label-default { 37 | .label-variant(@label-default-bg); 38 | } 39 | 40 | .label-primary { 41 | .label-variant(@label-primary-bg); 42 | } 43 | 44 | .label-success { 45 | .label-variant(@label-success-bg); 46 | } 47 | 48 | .label-info { 49 | .label-variant(@label-info-bg); 50 | } 51 | 52 | .label-warning { 53 | .label-variant(@label-warning-bg); 54 | } 55 | 56 | .label-danger { 57 | .label-variant(@label-danger-bg); 58 | } 59 | -------------------------------------------------------------------------------- /patterns/observer.md: -------------------------------------------------------------------------------- 1 | ## Observer Pattern 2 | The observer pattern is a software design pattern in which an object, called the subject, maintains a list of its dependents, 3 | called observers, and notifies them automatically of any state changes, usually by calling one of their methods. 4 | 5 | It is mainly used to implement distributed event handling systems. The Observer pattern is also a key part in the 6 | common model–view–controller (MVC) architectural pattern. 7 | 8 | 9 | ```coffeescript 10 | class RecordStudio 11 | constructor: () -> 12 | @subscribers = [] 13 | notifyNewItemReleased: (item) -> 14 | subscriber.callback(item) for subscriber in @subscribers when subscriber.item is item 15 | subscribe: (to, onNewItemReleased) -> 16 | @subscribers.push { item: to, callback: onNewItemReleased } 17 | 18 | class MetallicaFan 19 | onNewAlbum: (album) -> 20 | alert "I've got new '#{album}'" 21 | 22 | class RedHotChiliPeppersFan 23 | onNewAlbum: (album) -> 24 | alert "I've got new '#{album}'" 25 | 26 | EMI = new RecordStudio() 27 | sub1 = new MetallicaFan() 28 | sub2 = new RedHotChiliPeppersFan() 29 | EMI.subscribe "Death Magnetic", sub1.onNewAlbum 30 | EMI.subscribe "I'm with you", sub2.onNewAlbum 31 | EMI.notifyNewItemReleased "Death Magnetic" 32 | EMI.notifyNewItemReleased "I'm with you" 33 | ``` 34 | -------------------------------------------------------------------------------- /_theme/javascript/gitbook.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "jQuery", 3 | "utils/storage", 4 | "utils/sharing", 5 | "utils/appcache", 6 | 7 | "core/events", 8 | "core/font-settings", 9 | "core/state", 10 | "core/keyboard", 11 | "core/navigation", 12 | "core/progress", 13 | "core/sidebar", 14 | "core/search" 15 | ], function($, storage, appCache, sharing, events, fontSettings, state, keyboard, navigation, progress, sidebar, search){ 16 | var start = function(config) { 17 | var $book; 18 | $book = state.$book; 19 | 20 | if (state.githubId) { 21 | // Initialize storage 22 | storage.setBaseKey(state.githubId); 23 | } 24 | 25 | // Init sidebar 26 | sidebar.init(); 27 | 28 | // Load search 29 | search.init(); 30 | 31 | // Init keyboard 32 | keyboard.init(); 33 | 34 | // Init appcache 35 | appCache.init(); 36 | 37 | // Bind sharing button 38 | sharing.init(); 39 | 40 | // Init navigation 41 | navigation.init(); 42 | 43 | //Init font settings 44 | fontSettings.init(); 45 | 46 | events.trigger("start", config); 47 | } 48 | 49 | return { 50 | start: start, 51 | events: events 52 | }; 53 | }); 54 | -------------------------------------------------------------------------------- /_theme/stylesheets/book/quiz.less: -------------------------------------------------------------------------------- 1 | .book .book-body .page-wrapper .page-inner { 2 | section.quiz { 3 | padding: 0px; 4 | margin: 20px 0px; 5 | border: 3px solid #2f8cde; 6 | 7 | .header { 8 | padding: 5px 15px; 9 | 10 | color: #fff; 11 | background: #2f8cde; 12 | 13 | h2 { 14 | margin: 0px; 15 | font-size: 20px; 16 | } 17 | } 18 | 19 | .message { 20 | margin: 15px; 21 | } 22 | 23 | .question { 24 | .question-header { 25 | padding: 5px 15px; 26 | color: #fff; 27 | background: #2f8cde; 28 | } 29 | 30 | .question-inner { 31 | padding: 15px; 32 | .quiz-label { 33 | font-weight: normal; 34 | cursor: pointer; 35 | } 36 | } 37 | 38 | table { 39 | margin-bottom: 10px; 40 | width: 100%; 41 | } 42 | th, td { 43 | padding-right: 5px; 44 | } 45 | li { 46 | list-style-type: none; 47 | input { 48 | margin-right: 10px; 49 | } 50 | } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /patterns/singleton.md: -------------------------------------------------------------------------------- 1 | ## Singleton Pattern 2 | 3 | The Singleton pattern is used to restrict instantiation of a class to a single object. 4 | Usually the Singleton pattern is implemented by creating a class with a method that creates a new instance of the 5 | this class if one doesn't exist. In the case of an instance already exists, it simply returns a reference to that object. 6 | 7 | This is useful when exactly one object is needed to coordinate actions across the system. The Abstract Factory, Builder, 8 | and Prototype patterns can use Singletons in their implementation. Singletons are often preferred to global variables because 9 | they do not pollute the global namespace (or, in languages with namespaces, their containing namespace) with unnecessary variables. 10 | And they permit lazy allocation and initialization, whereas global variables in many languages will always consume resources. 11 | 12 | ```coffeescript 13 | class JimiHendrix 14 | 15 | instance = null 16 | 17 | class PrivateClass 18 | constructor: (@favoriteSong) -> 19 | echo: -> @favoriteSong 20 | 21 | @get: (favoriteSong) -> 22 | instance ?= new PrivateClass(favoriteSong) 23 | 24 | a = JimiHendrix.get "Purple Haze" 25 | a.echo() # => "Purple Haze" 26 | 27 | b = JimiHendrix.get "Welcome to the Jungle" 28 | b.echo() # => "Purple Haze" 29 | 30 | JimiHendrix.instance # => undefined 31 | a.instance # => undefined 32 | JimiHendrix.PrivateClass # => undefined 33 | ``` 34 | -------------------------------------------------------------------------------- /_theme/templates/includes/book/quiz.html: -------------------------------------------------------------------------------- 1 |
2 |

Quiz

3 |
4 | 5 |
6 | {% autoescape false %}{{ section.content }}{% endautoescape %} 7 |
8 | 9 | 10 | {% for quiz in section.quiz %} 11 |
12 |
Question {{ loop.index }} of {{ section.quiz.length }}
13 | 14 |
15 | 18 | 19 | 23 | 24 |
25 | {% autoescape false %}{{ quiz.base }}{% endautoescape %} 26 |
27 |
28 | 29 | 34 |
35 | {% endfor %} 36 | 37 |
38 | Submit 39 | Solution 40 | {% if githubId %} 41 | Have a Question? 42 | {% endif %} 43 |
44 | -------------------------------------------------------------------------------- /_theme/stylesheets/vendors/bootstrap/code.less: -------------------------------------------------------------------------------- 1 | // 2 | // Code (inline and blocK) 3 | // -------------------------------------------------- 4 | 5 | 6 | // Inline and block code styles 7 | code, 8 | pre { 9 | font-family: @font-family-monospace; 10 | } 11 | 12 | // Inline code 13 | code { 14 | padding: 2px 4px; 15 | font-size: 90%; 16 | color: @code-color; 17 | background-color: @code-bg; 18 | white-space: nowrap; 19 | border-radius: @border-radius-base; 20 | } 21 | 22 | // Blocks of code 23 | pre { 24 | display: block; 25 | padding: ((@line-height-computed - 1) / 2); 26 | margin: 0 0 (@line-height-computed / 2); 27 | font-size: (@font-size-base - 1); // 14px to 13px 28 | line-height: @line-height-base; 29 | word-break: break-all; 30 | word-wrap: break-word; 31 | color: @pre-color; 32 | background-color: @pre-bg; 33 | border: 1px solid @pre-border-color; 34 | border-radius: @border-radius-base; 35 | 36 | // Make prettyprint styles more spaced out for readability 37 | &.prettyprint { 38 | margin-bottom: @line-height-computed; 39 | } 40 | 41 | // Account for some code outputs that place code tags in pre tags 42 | code { 43 | padding: 0; 44 | font-size: inherit; 45 | color: inherit; 46 | white-space: pre-wrap; 47 | background-color: transparent; 48 | border: 0; 49 | } 50 | } 51 | 52 | // Enable scrollable blocks of code 53 | .pre-scrollable { 54 | max-height: @pre-scrollable-max-height; 55 | overflow-y: scroll; 56 | } 57 | -------------------------------------------------------------------------------- /_theme/stylesheets/book/navigation.less: -------------------------------------------------------------------------------- 1 | .book .book-body { 2 | .navigation { 3 | position: absolute; 4 | top: 0px; 5 | bottom: 0px; 6 | margin: 0; 7 | max-width: 150px; 8 | min-width: 90px; 9 | 10 | display: flex; 11 | justify-content: center; 12 | align-content: center; 13 | flex-direction: column; 14 | 15 | font-size: 40px; 16 | color: rgba(0,0,0,0.5); 17 | 18 | text-align: center; 19 | 20 | .transition(all 350ms ease); 21 | 22 | &:hover { 23 | background-color: @body-pagination-background; 24 | text-decoration: none; 25 | } 26 | 27 | &.navigation-next { 28 | right: 0px; 29 | } 30 | &.navigation-prev { 31 | left: 0px; 32 | } 33 | } 34 | 35 | @media (max-width: @mobileMaxWidth) { 36 | .navigation { 37 | position: static; 38 | top: auto; 39 | max-width: 50%; 40 | width: 50%; 41 | display: inline-block; 42 | float: left; 43 | 44 | &.navigation-unique { 45 | max-width: 100%; 46 | width: 100%; 47 | } 48 | } 49 | } 50 | } 51 | .book.color-theme-1 .book-body { 52 | .navigation:hover{ 53 | background-color: @body-pagination-background-1; 54 | } 55 | } 56 | .book.color-theme-2 .book-body { 57 | .navigation:hover{ 58 | background-color: @body-pagination-background-2; 59 | } 60 | } -------------------------------------------------------------------------------- /_theme/stylesheets/vendors/fontawesome/font-awesome.less: -------------------------------------------------------------------------------- 1 | /*! 2 | * Font Awesome 4.0.1 3 | * the iconic font designed for Bootstrap 4 | * ------------------------------------------------------------------------------ 5 | * The full suite of pictographic icons, examples, and documentation can be 6 | * found at http://fontawesome.io. Stay up to date on Twitter at 7 | * http://twitter.com/fontawesome. 8 | * 9 | * License 10 | * ------------------------------------------------------------------------------ 11 | * - The Font Awesome font is licensed under SIL OFL 1.1 - 12 | * http://scripts.sil.org/OFL 13 | * - Font Awesome CSS, LESS, and SASS files are licensed under MIT License - 14 | * http://opensource.org/licenses/mit-license.html 15 | * - Font Awesome documentation licensed under CC BY 3.0 - 16 | * http://creativecommons.org/licenses/by/3.0/ 17 | * - Attribution is no longer required in Font Awesome 3.0, but much appreciated: 18 | * "Font Awesome by Dave Gandy - http://fontawesome.io" 19 | * 20 | * Author - Dave Gandy 21 | * ------------------------------------------------------------------------------ 22 | * Email: dave@fontawesome.io 23 | * Twitter: http://twitter.com/davegandy 24 | * Work: Lead Product Designer @ Kyruus - http://kyruus.com 25 | */ 26 | 27 | @import "variables"; 28 | @import "mixins"; 29 | @import "path"; 30 | @import "core"; 31 | @import "larger"; 32 | @import "fixed-width"; 33 | @import "list"; 34 | @import "bordered-pulled"; 35 | @import "spinning"; 36 | @import "rotated-flipped"; 37 | @import "stacked"; 38 | @import "icons"; 39 | -------------------------------------------------------------------------------- /_theme/stylesheets/vendors/bootstrap/bootstrap.less: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap v3.0.0 3 | * 4 | * Copyright 2013 Twitter, Inc 5 | * Licensed under the Apache License v2.0 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Designed and built with all the love in the world by @mdo and @fat. 9 | */ 10 | 11 | // Core variables and mixins 12 | @import "variables.less"; 13 | @import "mixins.less"; 14 | 15 | // Reset 16 | @import "normalize.less"; 17 | //@import "print.less"; 18 | 19 | // Core CSS 20 | @import "scaffolding.less"; 21 | @import "type.less"; 22 | @import "code.less"; 23 | @import "grid.less"; 24 | @import "tables.less"; 25 | @import "forms.less"; 26 | @import "buttons.less"; 27 | 28 | // Components 29 | @import "component-animations.less"; 30 | @import "glyphicons.less"; 31 | @import "dropdowns.less"; 32 | @import "button-groups.less"; 33 | @import "input-groups.less"; 34 | @import "navs.less"; 35 | @import "navbar.less"; 36 | @import "breadcrumbs.less"; 37 | @import "pagination.less"; 38 | @import "pager.less"; 39 | @import "labels.less"; 40 | @import "badges.less"; 41 | @import "jumbotron.less"; 42 | @import "thumbnails.less"; 43 | @import "alerts.less"; 44 | @import "progress-bars.less"; 45 | @import "media.less"; 46 | @import "list-group.less"; 47 | @import "panels.less"; 48 | @import "wells.less"; 49 | @import "close.less"; 50 | 51 | // Components w/ JavaScript 52 | @import "modals.less"; 53 | @import "tooltip.less"; 54 | @import "popovers.less"; 55 | @import "carousel.less"; 56 | 57 | // Utility classes 58 | @import "utilities.less"; 59 | @import "responsive-utilities.less"; 60 | -------------------------------------------------------------------------------- /patterns/factory.md: -------------------------------------------------------------------------------- 1 | ## Factory Method Pattern 2 | 3 | The factory method pattern is a creational pattern which uses factory methods to deal with the problem of creating 4 | objects without specifying the exact class of object that will be created. 5 | 6 | Imagine that we have a UI factory where we are asked to create a type of UI component. Rather than creating this component 7 | directly using the new operator or via another creational constructor, we ask a Factory object for a new component instead. 8 | We inform the Factory what type of object is required (like "Button", "Popup") and it instantiates this, returning it to us 9 | for use. 10 | 11 | This is particularly useful if the object creation process is relatively complex, e.g. if it strongly depends on dynamic 12 | factors or application configuration. 13 | 14 | ```coffeescript 15 | class FenderGuitar 16 | constructor: (model) -> 17 | @type = "Fender #{model}" 18 | class GibsonGuitar 19 | constructor: (model) -> 20 | @type = "Gibson #{model}" 21 | class JacksonGuitar 22 | constructor: (model) -> 23 | @type = "Jackson #{model}" 24 | 25 | class GuitarFactory 26 | makeGuitar: (model) -> 27 | switch model 28 | when "Stratocaster" then new FenderGuitar(model) 29 | when "Les Paul" then new GibsonGuitar(model) 30 | when "Soloist" then new JacksonGuitar(model) 31 | 32 | factory = new GuitarFactory 33 | 34 | factory.makeGuitar("Stratocaster").type # => "Fender Stratocaster" 35 | 36 | factory.makeGuitar("Les Paul").type # => "Gibson Les Paul" 37 | 38 | factory.makeGuitar("Soloist").type # => "Jackson Soloist" 39 | ``` 40 | -------------------------------------------------------------------------------- /patterns/index.md: -------------------------------------------------------------------------------- 1 | ## Design Patterns 2 | 3 | One of the most important aspects of writing maintainable code is being able to notice the recurring themes in that code and 4 | optimize them. This is an area where knowledge of design patterns can prove invaluable. 5 | 6 | A design pattern is a general reusable solution to a commonly occurring problem within a given context in software design. 7 | Another way of looking at patterns are as templates for how we solve problems - ones which can be used in quite a few 8 | different situations. 9 | 10 | So, why is it important to understand patterns and be familiar with them? Design patterns have three main benefits: 11 | 12 | * Patterns are proven solutions: They provide solid approaches to solving issues in software development using proven 13 | techniques that reflect the experience and insights the developers that helped define them bring to the pattern. 14 | * Patterns can be easily reused: A pattern usually reflects an out of the box solution that can be adapted to suit 15 | our own needs. This feature makes them quite robust. 16 | * Patterns can be expressive: When we look at a pattern there’s generally a set structure and vocabulary to the 17 | solution presented that can help express rather large solutions quite elegantly. 18 | 19 | Patterns are not an exact solution. It’s important that we remember the role of a pattern is merely to provide us with a 20 | solution scheme. Patterns don’t solve all design problems nor do they replace good software designers, however, they do 21 | support them. 22 | 23 | So, let's have a look at most common design patterns in JavaScript and how they can be implemented in CoffeeScript. 24 | -------------------------------------------------------------------------------- /patterns/decorator.md: -------------------------------------------------------------------------------- 1 | ## Decorator Pattern 2 | 3 | Decorators are a structural design pattern that aim to promote code re-use. Similar to Mixins, they can be considered 4 | another viable alternative to object sub-classing. 5 | 6 | Classically, Decorators offered the ability to add behaviour to existing classes in a system dynamically. The idea was 7 | that the decoration itself wasn't essential to the base functionality of the class, otherwise it would be baked into 8 | the superclass itself. 9 | 10 | They can be used to modify existing systems where we wish to add additional features to objects without the need to 11 | heavily modify the underlying code using them. A common reason why developers use them is their applications may 12 | contain features requiring a large quantity of distinct types of object. Imagine having to define hundreds of different 13 | object constructors for say, a JavaScript game. 14 | 15 | ```coffeescript 16 | class Component 17 | props: {} 18 | add: (key, val) -> 19 | @props[key] = val 20 | get: () -> 21 | @props 22 | process: () -> 23 | 24 | class ConcreteComponent extends Component 25 | process: () -> 26 | 27 | class Decorator extends Component 28 | constructor: (@component) -> 29 | process: () -> 30 | @component.process() 31 | 32 | class ConcreteDecoratorA extends Decorator 33 | process: () -> 34 | @component.add "concreteDecoratorAProcess", true 35 | super() 36 | 37 | class ConcreteDecoratorB extends Decorator 38 | process: () -> 39 | @component.add "concreteDecoratorBProcess", true 40 | super() 41 | 42 | class Example 43 | @run: () -> 44 | cmpt = new ConcreteDecoratorA new ConcreteDecoratorB new ConcreteComponent() 45 | cmpt.process() 46 | 47 | Example.run() 48 | ``` 49 | -------------------------------------------------------------------------------- /_theme/stylesheets/vendors/bootstrap/alerts.less: -------------------------------------------------------------------------------- 1 | // 2 | // Alerts 3 | // -------------------------------------------------- 4 | 5 | 6 | // Base styles 7 | // ------------------------- 8 | 9 | .alert { 10 | padding: @alert-padding; 11 | margin-bottom: @line-height-computed; 12 | border: 1px solid transparent; 13 | border-radius: @alert-border-radius; 14 | 15 | // Headings for larger alerts 16 | h4 { 17 | margin-top: 0; 18 | // Specified for the h4 to prevent conflicts of changing @headingsColor 19 | color: inherit; 20 | } 21 | // Provide class for links that match alerts 22 | .alert-link { 23 | font-weight: @alert-link-font-weight; 24 | } 25 | 26 | // Improve alignment and spacing of inner content 27 | > p, 28 | > ul { 29 | margin-bottom: 0; 30 | } 31 | > p + p { 32 | margin-top: 5px; 33 | } 34 | } 35 | 36 | // Dismissable alerts 37 | // 38 | // Expand the right padding and account for the close button's positioning. 39 | 40 | .alert-dismissable { 41 | padding-right: (@alert-padding + 20); 42 | 43 | // Adjust close link position 44 | .close { 45 | position: relative; 46 | top: -2px; 47 | right: -21px; 48 | color: inherit; 49 | } 50 | } 51 | 52 | // Alternate styles 53 | // 54 | // Generate contextual modifier classes for colorizing the alert. 55 | 56 | .alert-success { 57 | .alert-variant(@alert-success-bg; @alert-success-border; @alert-success-text); 58 | } 59 | .alert-info { 60 | .alert-variant(@alert-info-bg; @alert-info-border; @alert-info-text); 61 | } 62 | .alert-warning { 63 | .alert-variant(@alert-warning-bg; @alert-warning-border; @alert-warning-text); 64 | } 65 | .alert-danger { 66 | .alert-variant(@alert-danger-bg; @alert-danger-border; @alert-danger-text); 67 | } 68 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Hard Rock CoffeeScript](assets/hard_rock.jpg) 2 | 3 | ## Hard Rock CoffeeScript 4 | 5 | ##### v0.9.1 6 | 7 | CoffeeScript is a little language that compiles to JavaScript created by Jeremy Ashkenas. This is an evolution of JavaScript that hides its bad parts and exposes the good parts. It's syntax is inspired by Ruby and Python and brings many features from these two languages. 8 | 9 | Why is CoffeeScript better than writing pure JavaScript? First of all CoffeeScript allows you to actually write less and do more (yep, exactly like jQuery:smile:). The amount of code that you'll need to write reduces significantly — you're geting rid of curly brackets, semicolons and you are getting lots of syntactic sugar. Moreover it adds usefull features like classes and inheritance which have not yet arrived natively to JavaScript. 10 | 11 | But still, *coffee* code compiles to *JavaScript* so in order to write programs in CoffeeScript you need to know JavaScript. It is impossible to write well structured and good working scripts without understanding basics of JavaScript like closures or prototypical model. Knowledge of design patterns in JavaScript will be also usefull as CoffeeScript is using some patterns like *Module pattern*, *Prototype*. 12 | 13 | ### JavaScript Lint 14 | 15 | JavaScript Lint is a JavaScript code quality tool, and running your programs through it is a great way of improving code quality and best practices. The project was based on a similar tool called JSLint. Check out JSLint's site for a great list of issues that it checks for, including global variables, missing semicolons and weak equality comparisons. 16 | 17 | The good news is that CoffeeScript already 'lints' all of its output, so CoffeeScript generated JavaScript is already JavaScript Lint compatible 18 | -------------------------------------------------------------------------------- /syntax/switch_and_try.md: -------------------------------------------------------------------------------- 1 | ## Switch/When/Else 2 | 3 | Switch statements in JavaScript are a bit awkward. You need to remember to break at the end of every case statement to 4 | avoid accidentally falling through to the default case. CoffeeScript prevents accidental fall-through, and can convert 5 | the ```switch``` into a returnable, assignable expression. The format is: ```switch``` condition, ```when``` clauses, 6 | ```else``` the default case. 7 | 8 | Like in Ruby, switch statements in CoffeeScript can take multiple values for each when clause. If any of the values match, 9 | the clause runs. 10 | 11 | *CoffeeScript* 12 | ``` coffeescript 13 | switch member 14 | when "Jimmy Page" then goPlayGuitar 15 | when "Sid Vicious" then goDrinkBeer 16 | when "Lars Ulrich" then goSmashDrumkit 17 | when "Axl Rose" then goSingAloud 18 | else goHome 19 | ``` 20 | *JavaScript* 21 | ``` javascript 22 | switch (member) { 23 | case "Jimmy Page": 24 | goPlayGuitar; 25 | break; 26 | case "Sid Vicious": 27 | goDrinkBeer; 28 | break; 29 | case "Lars Ulrich": 30 | goSmashDrumkit; 31 | break; 32 | case "Axl Rose": 33 | goSingAloud; 34 | break; 35 | default: 36 | goHome; 37 | } 38 | ``` 39 | 40 | ## Try/Catch/Finally 41 | 42 | Try/catch statements are just about the same as JavaScript, the only difference - they work as expressions. 43 | 44 | *CoffeeScript* 45 | ``` coffeescript 46 | try 47 | listenToAcDc() 48 | notSingAlongWithBrianJohnson() 49 | catch error 50 | console.log error 51 | finally 52 | cleanUp() 53 | ``` 54 | *JavaScript* 55 | ``` javascript 56 | var error; 57 | 58 | try { 59 | listenToAcDc(); 60 | notSingAlongWithBrianJohnson(); 61 | } catch (error) { 62 | console.log(error); 63 | } finally { 64 | cleanUp(); 65 | } 66 | ``` 67 | -------------------------------------------------------------------------------- /_theme/javascript/core/sidebar.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "lodash", 3 | "utils/storage", 4 | "utils/platform", 5 | "core/state" 6 | ], function(_, storage, platform, state) { 7 | var $summary = state.$book.find(".book-summary"); 8 | 9 | // Toggle sidebar with or withour animation 10 | var toggleSidebar = function(_state, animation) { 11 | if (state != null && isOpen() == _state) return; 12 | if (animation == null) animation = true; 13 | 14 | state.$book.toggleClass("without-animation", !animation); 15 | state.$book.toggleClass("with-summary", _state); 16 | 17 | storage.set("sidebar", isOpen()); 18 | }; 19 | 20 | // Return true if sidebar is open 21 | var isOpen = function() { 22 | return state.$book.hasClass("with-summary"); 23 | }; 24 | 25 | // Prepare sidebar: state and toggle button 26 | var init = function() { 27 | // Toggle summary 28 | $(document).on("click", ".book-header .toggle-summary", function(e) { 29 | e.preventDefault(); 30 | toggleSidebar(); 31 | }); 32 | 33 | // Init last state if not mobile 34 | if (!platform.isMobile) { 35 | toggleSidebar(storage.get("sidebar", true), false); 36 | } 37 | }; 38 | 39 | // Filter summary with a list of path 40 | var filterSummary = function(paths) { 41 | $summary.find("li").each(function() { 42 | var path = $(this).data("path"); 43 | var st = paths == null || _.contains(paths, path); 44 | 45 | $(this).toggle(st); 46 | if (st) $(this).parents("li").show(); 47 | }); 48 | }; 49 | 50 | return { 51 | $el: $summary, 52 | init: init, 53 | toggle: toggleSidebar, 54 | filter: filterSummary 55 | } 56 | }); -------------------------------------------------------------------------------- /_theme/stylesheets/page/highlight.less: -------------------------------------------------------------------------------- 1 | /* http://jmblog.github.io/color-themes-for-highlightjs */ 2 | 3 | /* Tomorrow Comment */ 4 | .hljs-comment, 5 | .hljs-title { 6 | color: #8e908c; 7 | } 8 | 9 | /* Tomorrow Red */ 10 | .hljs-variable, 11 | .hljs-attribute, 12 | .hljs-tag, 13 | .hljs-regexp, 14 | .ruby .hljs-constant, 15 | .xml .hljs-tag .hljs-title, 16 | .xml .hljs-pi, 17 | .xml .hljs-doctype, 18 | .html .hljs-doctype, 19 | .css .hljs-id, 20 | .css .hljs-class, 21 | .css .hljs-pseudo { 22 | color: #c82829; 23 | } 24 | 25 | /* Tomorrow Orange */ 26 | .hljs-number, 27 | .hljs-preprocessor, 28 | .hljs-pragma, 29 | .hljs-built_in, 30 | .hljs-literal, 31 | .hljs-params, 32 | .hljs-constant { 33 | color: #f5871f; 34 | } 35 | 36 | /* Tomorrow Yellow */ 37 | .ruby .hljs-class .hljs-title, 38 | .css .hljs-rules .hljs-attribute { 39 | color: #eab700; 40 | } 41 | 42 | /* Tomorrow Green */ 43 | .hljs-string, 44 | .hljs-value, 45 | .hljs-inheritance, 46 | .hljs-header, 47 | .ruby .hljs-symbol, 48 | .xml .hljs-cdata { 49 | color: #718c00; 50 | } 51 | 52 | /* Tomorrow Aqua */ 53 | .css .hljs-hexcolor { 54 | color: #3e999f; 55 | } 56 | 57 | /* Tomorrow Blue */ 58 | .hljs-function, 59 | .python .hljs-decorator, 60 | .python .hljs-title, 61 | .ruby .hljs-function .hljs-title, 62 | .ruby .hljs-title .hljs-keyword, 63 | .perl .hljs-sub, 64 | .javascript .hljs-title, 65 | .coffeescript .hljs-title { 66 | color: #4271ae; 67 | } 68 | 69 | /* Tomorrow Purple */ 70 | .hljs-keyword, 71 | .javascript .hljs-function { 72 | color: #8959a8; 73 | } 74 | 75 | .hljs { 76 | display: block; 77 | background: white; 78 | color: #4d4d4c; 79 | padding: 0.5em; 80 | } 81 | 82 | .coffeescript .javascript, 83 | .javascript .xml, 84 | .tex .hljs-formula, 85 | .xml .javascript, 86 | .xml .vbscript, 87 | .xml .css, 88 | .xml .hljs-cdata { 89 | opacity: 0.5; 90 | } 91 | -------------------------------------------------------------------------------- /_theme/javascript/core/exercise.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "jQuery", 3 | "utils/execute", 4 | "core/events", 5 | "core/state" 6 | ], function($, execute, events, state){ 7 | // Bind an exercise 8 | var prepareExercise = function($exercise) { 9 | var codeSolution = $exercise.find(".code-solution").text(); 10 | var codeValidation = $exercise.find(".code-validation").text(); 11 | var codeContext = $exercise.find(".code-context").text(); 12 | 13 | var editor = ace.edit($exercise.find(".editor").get(0)); 14 | editor.setTheme("ace/theme/tomorrow"); 15 | editor.getSession().setUseWorker(false); 16 | editor.getSession().setMode("ace/mode/javascript"); 17 | 18 | // Submit: test code 19 | $exercise.find(".action-submit").click(function(e) { 20 | e.preventDefault(); 21 | 22 | events.trigger("exercise.submit", {type: "code"}); 23 | 24 | execute("javascript", editor.getValue(), codeValidation, codeContext, function(err, result) { 25 | $exercise.toggleClass("return-error", err != null); 26 | $exercise.toggleClass("return-success", err == null); 27 | if (err) $exercise.find(".alert-danger").text(err.message || err); 28 | }); 29 | }); 30 | 31 | // Set solution 32 | $exercise.find(".action-solution").click(function(e) { 33 | e.preventDefault(); 34 | 35 | editor.setValue(codeSolution); 36 | editor.gotoLine(0); 37 | }); 38 | }; 39 | 40 | // Prepare all exercise 41 | var init = function() { 42 | state.$book.find("section.exercise").each(function() { 43 | prepareExercise($(this)); 44 | }); 45 | }; 46 | 47 | return { 48 | init: init, 49 | prepare: prepareExercise 50 | }; 51 | }); -------------------------------------------------------------------------------- /_theme/stylesheets/book/highlight/white.less: -------------------------------------------------------------------------------- 1 | /* http://jmblog.github.com/color-themes-for-google-code-highlightjs */ 2 | 3 | /* Tomorrow Comment */ 4 | .hljs-comment, 5 | .hljs-title { 6 | color: #8e908c; 7 | } 8 | 9 | /* Tomorrow Red */ 10 | .hljs-variable, 11 | .hljs-attribute, 12 | .hljs-tag, 13 | .hljs-regexp, 14 | .ruby .hljs-constant, 15 | .xml .hljs-tag .hljs-title, 16 | .xml .hljs-pi, 17 | .xml .hljs-doctype, 18 | .html .hljs-doctype, 19 | .css .hljs-id, 20 | .css .hljs-class, 21 | .css .hljs-pseudo { 22 | color: #c82829; 23 | } 24 | 25 | /* Tomorrow Orange */ 26 | .hljs-number, 27 | .hljs-preprocessor, 28 | .hljs-pragma, 29 | .hljs-built_in, 30 | .hljs-literal, 31 | .hljs-params, 32 | .hljs-constant { 33 | color: #f5871f; 34 | } 35 | 36 | /* Tomorrow Yellow */ 37 | .ruby .hljs-class .hljs-title, 38 | .css .hljs-rules .hljs-attribute { 39 | color: #eab700; 40 | } 41 | 42 | /* Tomorrow Green */ 43 | .hljs-string, 44 | .hljs-value, 45 | .hljs-inheritance, 46 | .hljs-header, 47 | .ruby .hljs-symbol, 48 | .xml .hljs-cdata { 49 | color: #718c00; 50 | } 51 | 52 | /* Tomorrow Aqua */ 53 | .css .hljs-hexcolor { 54 | color: #3e999f; 55 | } 56 | 57 | /* Tomorrow Blue */ 58 | .hljs-function, 59 | .python .hljs-decorator, 60 | .python .hljs-title, 61 | .ruby .hljs-function .hljs-title, 62 | .ruby .hljs-title .hljs-keyword, 63 | .perl .hljs-sub, 64 | .javascript .hljs-title, 65 | .coffeescript .hljs-title { 66 | color: #4271ae; 67 | } 68 | 69 | /* Tomorrow Purple */ 70 | .hljs-keyword, 71 | .javascript .hljs-function { 72 | color: #8959a8; 73 | } 74 | 75 | .hljs { 76 | display: block; 77 | background: white; 78 | color: #4d4d4c; 79 | padding: 0.5em; 80 | } 81 | 82 | .coffeescript .javascript, 83 | .javascript .xml, 84 | .tex .hljs-formula, 85 | .xml .javascript, 86 | .xml .vbscript, 87 | .xml .css, 88 | .xml .hljs-cdata { 89 | opacity: 0.5; 90 | } -------------------------------------------------------------------------------- /_theme/templates/includes/book/header.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | {% if options.links.home !== false and (options.links.home != null or githubId) %} 4 | 5 | {% endif %} 6 | 7 | 8 | 9 | 10 | 11 | {% include "./font-settings.html" %} 12 | 13 | 14 | 15 | {% if options.links.sharing.google !== false %} 16 | 17 | {% endif %} 18 | {% if options.links.sharing.facebook !== false %} 19 | 20 | {% endif %} 21 | {% if options.links.sharing.twitter !== false %} 22 | 23 | {% endif %} 24 | 25 | {% if githubId %} 26 | 27 | 28 | {% endif %} 29 | 30 | 31 |

32 | 33 | {{ title }} 34 |

35 |
36 | -------------------------------------------------------------------------------- /_theme/javascript/utils/path.js: -------------------------------------------------------------------------------- 1 | define([], function() { 2 | // Joins path segments. Preserves initial "/" and resolves ".." and "." 3 | // Does not support using ".." to go above/outside the root. 4 | // This means that join("foo", "../../bar") will not resolve to "../bar" 5 | function join(/* path segments */) { 6 | // Split the inputs into a list of path commands. 7 | var parts = []; 8 | for (var i = 0, l = arguments.length; i < l; i++) { 9 | parts = parts.concat(arguments[i].split("/")); 10 | } 11 | // Interpret the path commands to get the new resolved path. 12 | var newParts = []; 13 | for (i = 0, l = parts.length; i < l; i++) { 14 | var part = parts[i]; 15 | // Remove leading and trailing slashes 16 | // Also remove "." segments 17 | if (!part || part === ".") continue; 18 | // Interpret ".." to pop the last segment 19 | if (part === "..") newParts.pop(); 20 | // Push new path segments. 21 | else newParts.push(part); 22 | } 23 | // Preserve the initial slash if there was one. 24 | if (parts[0] === "") newParts.unshift(""); 25 | // Turn back into a single string path. 26 | return newParts.join("/") || (newParts.length ? "/" : "."); 27 | } 28 | 29 | // A simple function to get the dirname of a path 30 | // Trailing slashes are ignored. Leading slash is preserved. 31 | function dirname(path) { 32 | return join(path, ".."); 33 | } 34 | 35 | // test if a path or url is absolute 36 | function isAbsolute(path) { 37 | if (!path) return false; 38 | 39 | return (path[0] == "/" || path.indexOf("http://") == 0 || path.indexOf("https://") == 0); 40 | } 41 | 42 | return { 43 | dirname: dirname, 44 | join: join, 45 | isAbsolute: isAbsolute 46 | }; 47 | }) -------------------------------------------------------------------------------- /_theme/stylesheets/book/highlight/night.less: -------------------------------------------------------------------------------- 1 | /* Tomorrow Night Bright Theme */ 2 | /* Original theme - https://github.com/chriskempson/tomorrow-theme */ 3 | /* http://jmblog.github.com/color-themes-for-google-code-highlightjs */ 4 | 5 | /* Tomorrow Comment */ 6 | .hljs-comment, 7 | .hljs-title { 8 | color: #969896; 9 | } 10 | 11 | /* Tomorrow Red */ 12 | .hljs-variable, 13 | .hljs-attribute, 14 | .hljs-tag, 15 | .hljs-regexp, 16 | .ruby .hljs-constant, 17 | .xml .hljs-tag .hljs-title, 18 | .xml .hljs-pi, 19 | .xml .hljs-doctype, 20 | .html .hljs-doctype, 21 | .css .hljs-id, 22 | .css .hljs-class, 23 | .css .hljs-pseudo { 24 | color: #d54e53; 25 | } 26 | 27 | /* Tomorrow Orange */ 28 | .hljs-number, 29 | .hljs-preprocessor, 30 | .hljs-pragma, 31 | .hljs-built_in, 32 | .hljs-literal, 33 | .hljs-params, 34 | .hljs-constant { 35 | color: #e78c45; 36 | } 37 | 38 | /* Tomorrow Yellow */ 39 | .ruby .hljs-class .hljs-title, 40 | .css .hljs-rules .hljs-attribute { 41 | color: #e7c547; 42 | } 43 | 44 | /* Tomorrow Green */ 45 | .hljs-string, 46 | .hljs-value, 47 | .hljs-inheritance, 48 | .hljs-header, 49 | .ruby .hljs-symbol, 50 | .xml .hljs-cdata { 51 | color: #b9ca4a; 52 | } 53 | 54 | /* Tomorrow Aqua */ 55 | .css .hljs-hexcolor { 56 | color: #70c0b1; 57 | } 58 | 59 | /* Tomorrow Blue */ 60 | .hljs-function, 61 | .python .hljs-decorator, 62 | .python .hljs-title, 63 | .ruby .hljs-function .hljs-title, 64 | .ruby .hljs-title .hljs-keyword, 65 | .perl .hljs-sub, 66 | .javascript .hljs-title, 67 | .coffeescript .hljs-title { 68 | color: #7aa6da; 69 | } 70 | 71 | /* Tomorrow Purple */ 72 | .hljs-keyword, 73 | .javascript .hljs-function { 74 | color: #c397d8; 75 | } 76 | 77 | .hljs { 78 | display: block; 79 | background: black; 80 | color: #eaeaea; 81 | padding: 0.5em; 82 | } 83 | 84 | .coffeescript .javascript, 85 | .javascript .xml, 86 | .tex .hljs-formula, 87 | .xml .javascript, 88 | .xml .vbscript, 89 | .xml .css, 90 | .xml .hljs-cdata { 91 | opacity: 0.5; 92 | } -------------------------------------------------------------------------------- /_theme/stylesheets/vendors/bootstrap/print.less: -------------------------------------------------------------------------------- 1 | // 2 | // Basic print styles 3 | // -------------------------------------------------- 4 | // Source: https://github.com/h5bp/html5-boilerplate/blob/master/css/main.css 5 | 6 | @media print { 7 | 8 | * { 9 | text-shadow: none !important; 10 | color: #000 !important; // Black prints faster: h5bp.com/s 11 | background: transparent !important; 12 | box-shadow: none !important; 13 | } 14 | 15 | a, 16 | a:visited { 17 | text-decoration: underline; 18 | } 19 | 20 | a[href]:after { 21 | content: " (" attr(href) ")"; 22 | } 23 | 24 | abbr[title]:after { 25 | content: " (" attr(title) ")"; 26 | } 27 | 28 | // Don't show links for images, or javascript/internal links 29 | .ir a:after, 30 | a[href^="javascript:"]:after, 31 | a[href^="#"]:after { 32 | content: ""; 33 | } 34 | 35 | pre, 36 | blockquote { 37 | border: 1px solid #999; 38 | page-break-inside: avoid; 39 | } 40 | 41 | thead { 42 | display: table-header-group; // h5bp.com/t 43 | } 44 | 45 | tr, 46 | img { 47 | page-break-inside: avoid; 48 | } 49 | 50 | img { 51 | max-width: 100% !important; 52 | } 53 | 54 | @page { 55 | margin: 2cm .5cm; 56 | } 57 | 58 | p, 59 | h2, 60 | h3 { 61 | orphans: 3; 62 | widows: 3; 63 | } 64 | 65 | h2, 66 | h3 { 67 | page-break-after: avoid; 68 | } 69 | 70 | // Bootstrap components 71 | .navbar { 72 | display: none; 73 | } 74 | .table { 75 | td, 76 | th { 77 | background-color: #fff !important; 78 | } 79 | } 80 | .btn, 81 | .dropup > .btn { 82 | > .caret { 83 | border-top-color: #000 !important; 84 | } 85 | } 86 | .label { 87 | border: 1px solid #000; 88 | } 89 | 90 | .table { 91 | border-collapse: collapse !important; 92 | } 93 | .table-bordered { 94 | th, 95 | td { 96 | border: 1px solid #ddd !important; 97 | } 98 | } 99 | 100 | } 101 | -------------------------------------------------------------------------------- /_theme/javascript/core/progress.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "lodash", 3 | "jQuery", 4 | "utils/storage", 5 | "core/state" 6 | ], function(_, $, storage, state) { 7 | // Get current level 8 | var getCurrentLevel = function() { 9 | return state.level; 10 | }; 11 | 12 | // Return all levels 13 | var getLevels = function () { 14 | var levels = $(".book-summary li[data-level]"); 15 | 16 | return _.map(levels, function(level) { 17 | return $(level).data("level").toString(); 18 | }); 19 | }; 20 | 21 | // Return a map chapter -> number (timestamp) 22 | var getProgress = function () { 23 | // Current level 24 | var progress = storage.get("progress", {}); 25 | 26 | // Levels 27 | var levels = getLevels(); 28 | 29 | _.each(levels, function(level) { 30 | progress[level] = progress[level] || 0; 31 | }); 32 | 33 | return progress; 34 | }; 35 | 36 | // Change value of progress for a level 37 | var markProgress = function (level, state) { 38 | var progress = getProgress(); 39 | 40 | if (state == null) { 41 | state = true; 42 | } 43 | 44 | progress[level] = state 45 | ? Date.now() 46 | : 0; 47 | 48 | storage.set("progress", progress); 49 | }; 50 | 51 | // Show progress 52 | var showProgress = function () { 53 | var progress = getProgress(); 54 | var $summary = $(".book-summary"); 55 | 56 | _.each(progress, function (value, level) { 57 | $summary.find("li[data-level='"+level+"']").toggleClass("done", value > 0); 58 | }); 59 | 60 | // Mark current progress if we have not already 61 | if (!progress[getCurrentLevel()]) { 62 | markProgress(getCurrentLevel(), true); 63 | } 64 | }; 65 | 66 | return { 67 | 'current': getCurrentLevel, 68 | 'levels': getLevels, 69 | 'get': getProgress, 70 | 'mark': markProgress, 71 | 'show': showProgress 72 | }; 73 | }); -------------------------------------------------------------------------------- /_theme/javascript/core/quiz.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "jQuery", 3 | "utils/execute", 4 | "core/events", 5 | "core/state" 6 | ], function($, execute, events, state){ 7 | // Bind an exercise 8 | var prepareQuiz = function($quiz) { 9 | 10 | $quiz.find(".quiz-answers input").click(function(e) { 11 | e.preventDefault(); 12 | }); 13 | 14 | // Submit: test code 15 | $quiz.find(".action-submit").click(function(e) { 16 | e.preventDefault(); 17 | events.trigger("exercise.submit", {type: "quiz"}); 18 | $quiz.find("tr.alert-danger,li.alert-danger").removeClass("alert-danger"); 19 | $quiz.find(".alert-success,.alert-danger").addClass("hidden"); 20 | 21 | $quiz.find(".question").each(function(q) { 22 | var result = true; 23 | 24 | var $questions = $(this).find(".question-content").find("input[type=radio], input[type=checkbox]"); 25 | var $answers = $(this).find(".question-answers").find("input[type=radio], input[type=checkbox]"); 26 | 27 | $questions.each(function(i) { 28 | var correct = $(this).is(":checked") === $answers.slice(i).first().is(":checked"); 29 | result = result && correct; 30 | if (!correct) { 31 | $(this).closest("tr, li").addClass("alert-danger"); 32 | } 33 | }); 34 | $(this).find(result ? "div.alert-success" : "div.alert-danger").toggleClass("hidden"); 35 | }); 36 | 37 | }); 38 | 39 | $quiz.find(".action-solution").click(function(e) { 40 | e.preventDefault(); 41 | $quiz.find(".question-content, .question-answers").toggleClass("hidden"); 42 | }); 43 | }; 44 | 45 | // Prepare all exercise 46 | var init = function() { 47 | state.$book.find("section.quiz").each(function() { 48 | prepareQuiz($(this)); 49 | }); 50 | }; 51 | 52 | return { 53 | init: init, 54 | prepare: prepareQuiz 55 | }; 56 | }); -------------------------------------------------------------------------------- /_theme/stylesheets/book/highlight/sepia.less: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Orginal Style from ethanschoonover.com/solarized (c) Jeremy Hull 4 | 5 | */ 6 | 7 | .hljs { 8 | display: block; 9 | padding: 0.5em; 10 | background: #fdf6e3; 11 | color: #657b83; 12 | } 13 | 14 | .hljs-comment, 15 | .hljs-template_comment, 16 | .diff .hljs-header, 17 | .hljs-doctype, 18 | .hljs-pi, 19 | .lisp .hljs-string, 20 | .hljs-javadoc { 21 | color: #93a1a1; 22 | } 23 | 24 | /* Solarized Green */ 25 | .hljs-keyword, 26 | .hljs-winutils, 27 | .method, 28 | .hljs-addition, 29 | .css .hljs-tag, 30 | .hljs-request, 31 | .hljs-status, 32 | .nginx .hljs-title { 33 | color: #859900; 34 | } 35 | 36 | /* Solarized Cyan */ 37 | .hljs-number, 38 | .hljs-command, 39 | .hljs-string, 40 | .hljs-tag .hljs-value, 41 | .hljs-rules .hljs-value, 42 | .hljs-phpdoc, 43 | .tex .hljs-formula, 44 | .hljs-regexp, 45 | .hljs-hexcolor, 46 | .hljs-link_url { 47 | color: #2aa198; 48 | } 49 | 50 | /* Solarized Blue */ 51 | .hljs-title, 52 | .hljs-localvars, 53 | .hljs-chunk, 54 | .hljs-decorator, 55 | .hljs-built_in, 56 | .hljs-identifier, 57 | .vhdl .hljs-literal, 58 | .hljs-id, 59 | .css .hljs-function { 60 | color: #268bd2; 61 | } 62 | 63 | /* Solarized Yellow */ 64 | .hljs-attribute, 65 | .hljs-variable, 66 | .lisp .hljs-body, 67 | .smalltalk .hljs-number, 68 | .hljs-constant, 69 | .hljs-class .hljs-title, 70 | .hljs-parent, 71 | .haskell .hljs-type, 72 | .hljs-link_reference { 73 | color: #b58900; 74 | } 75 | 76 | /* Solarized Orange */ 77 | .hljs-preprocessor, 78 | .hljs-preprocessor .hljs-keyword, 79 | .hljs-pragma, 80 | .hljs-shebang, 81 | .hljs-symbol, 82 | .hljs-symbol .hljs-string, 83 | .diff .hljs-change, 84 | .hljs-special, 85 | .hljs-attr_selector, 86 | .hljs-subst, 87 | .hljs-cdata, 88 | .clojure .hljs-title, 89 | .css .hljs-pseudo, 90 | .hljs-header { 91 | color: #cb4b16; 92 | } 93 | 94 | /* Solarized Red */ 95 | .hljs-deletion, 96 | .hljs-important { 97 | color: #dc322f; 98 | } 99 | 100 | /* Solarized Violet */ 101 | .hljs-link_label { 102 | color: #6c71c4; 103 | } 104 | 105 | .tex .hljs-formula { 106 | background: #eee8d5; 107 | } -------------------------------------------------------------------------------- /_theme/stylesheets/vendors/bootstrap/pagination.less: -------------------------------------------------------------------------------- 1 | // 2 | // Pagination (multiple pages) 3 | // -------------------------------------------------- 4 | .pagination { 5 | display: inline-block; 6 | padding-left: 0; 7 | margin: @line-height-computed 0; 8 | border-radius: @border-radius-base; 9 | 10 | > li { 11 | display: inline; // Remove list-style and block-level defaults 12 | > a, 13 | > span { 14 | position: relative; 15 | float: left; // Collapse white-space 16 | padding: @padding-base-vertical @padding-base-horizontal; 17 | line-height: @line-height-base; 18 | text-decoration: none; 19 | background-color: @pagination-bg; 20 | border: 1px solid @pagination-border; 21 | margin-left: -1px; 22 | } 23 | &:first-child { 24 | > a, 25 | > span { 26 | margin-left: 0; 27 | .border-left-radius(@border-radius-base); 28 | } 29 | } 30 | &:last-child { 31 | > a, 32 | > span { 33 | .border-right-radius(@border-radius-base); 34 | } 35 | } 36 | } 37 | 38 | > li > a, 39 | > li > span { 40 | &:hover, 41 | &:focus { 42 | background-color: @pagination-hover-bg; 43 | } 44 | } 45 | 46 | > .active > a, 47 | > .active > span { 48 | &, 49 | &:hover, 50 | &:focus { 51 | z-index: 2; 52 | color: @pagination-active-color; 53 | background-color: @pagination-active-bg; 54 | border-color: @pagination-active-bg; 55 | cursor: default; 56 | } 57 | } 58 | 59 | > .disabled { 60 | > span, 61 | > a, 62 | > a:hover, 63 | > a:focus { 64 | color: @pagination-disabled-color; 65 | background-color: @pagination-bg; 66 | border-color: @pagination-border; 67 | cursor: not-allowed; 68 | } 69 | } 70 | } 71 | 72 | // Sizing 73 | // -------------------------------------------------- 74 | 75 | // Large 76 | .pagination-lg { 77 | .pagination-size(@padding-large-vertical; @padding-large-horizontal; @font-size-large; @border-radius-large); 78 | } 79 | 80 | // Small 81 | .pagination-sm { 82 | .pagination-size(@padding-small-vertical; @padding-small-horizontal; @font-size-small; @border-radius-small); 83 | } 84 | -------------------------------------------------------------------------------- /_theme/stylesheets/vendors/bootstrap/list-group.less: -------------------------------------------------------------------------------- 1 | // 2 | // List groups 3 | // -------------------------------------------------- 4 | 5 | // Base class 6 | // 7 | // Easily usable on