Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added common JS pattern examples

  • Loading branch information...
commit 1c4a81878ecd42e6344ba10daa56c6e49ffa85dc 1 parent f7fd841
Dan Mohl authored May 29, 2012

Showing 32 changed files with 382 additions and 104 deletions. Show diff stats Hide diff stats

  1. BIN  Examples/FsCoffeeScriptjQueryUI/FsCoffeeScriptjQueryUIExample.suo
  2. 37  ...ryUI/FsCoffeeScriptjQueryUIExample/FsCoffeeScriptjQueryUIExampleWeb/FsCoffeeScriptjQueryUIExampleWeb.csproj
  3. 7  ...ScriptjQueryUI/FsCoffeeScriptjQueryUIExample/FsCoffeeScriptjQueryUIExampleWeb/Scripts/Patterns/Class.coffee
  4. 17  ...ffeeScriptjQueryUI/FsCoffeeScriptjQueryUIExample/FsCoffeeScriptjQueryUIExampleWeb/Scripts/Patterns/Class.js
  5. 8  ...riptjQueryUI/FsCoffeeScriptjQueryUIExample/FsCoffeeScriptjQueryUIExampleWeb/Scripts/Patterns/Command.coffee
  6. 16  ...eeScriptjQueryUI/FsCoffeeScriptjQueryUIExample/FsCoffeeScriptjQueryUIExampleWeb/Scripts/Patterns/Command.js
  7. 11  ...iptjQueryUI/FsCoffeeScriptjQueryUIExample/FsCoffeeScriptjQueryUIExampleWeb/Scripts/Patterns/Strategy.coffee
  8. 10  ...eScriptjQueryUI/FsCoffeeScriptjQueryUIExample/FsCoffeeScriptjQueryUIExampleWeb/Scripts/Patterns/Strategy.js
  9. 14  ...tjQueryUI/FsCoffeeScriptjQueryUIExample/FsCoffeeScriptjQueryUIExampleWeb/Scripts/SlideDeck/SlideDeck.coffee
  10. 18  ...criptjQueryUI/FsCoffeeScriptjQueryUIExample/FsCoffeeScriptjQueryUIExampleWeb/Scripts/SlideDeck/SlideDeck.js
  11. BIN  ...ptjQueryUIExample/FsCoffeeScriptjQueryUIExampleWeb/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
  12. BIN  ...CoffeeScriptjQueryUIExample/FsCoffeeScriptjQueryUIExampleWeb/obj/Debug/TempPE/Scripts.Patterns.Class.js.dll
  13. BIN  ...feeScriptjQueryUIExample/FsCoffeeScriptjQueryUIExampleWeb/obj/Debug/TempPE/Scripts.Patterns.Strategy.js.dll
  14. 2  Examples/FsCoffeeScriptjQueryUI/_ReSharper.FsCoffeeScriptjQueryUIExample/BuildScriptCache/.crc
  15. BIN  Examples/FsCoffeeScriptjQueryUI/_ReSharper.FsCoffeeScriptjQueryUIExample/BuildScriptCache/1/56808d5a.dat
  16. 2  Examples/FsCoffeeScriptjQueryUI/_ReSharper.FsCoffeeScriptjQueryUIExample/NamedArguments/.crc
  17. BIN  Examples/FsCoffeeScriptjQueryUI/_ReSharper.FsCoffeeScriptjQueryUIExample/NamedArguments/7/7d94b125.dat
  18. BIN  ...feeScriptjQueryUI/_ReSharper.FsCoffeeScriptjQueryUIExample/PdbInfo/489b52b9da113729c5817f70a616e1f36609f619
  19. BIN  ...feeScriptjQueryUI/_ReSharper.FsCoffeeScriptjQueryUIExample/PdbInfo/b0c7019bddee13d39d50a04eca2409474689f5da
  20. BIN  Examples/FsCoffeeScriptjQueryUI/_ReSharper.FsCoffeeScriptjQueryUIExample/SymbolCache.bin
  21. 2  Examples/FsCoffeeScriptjQueryUI/_ReSharper.FsCoffeeScriptjQueryUIExample/TagPrefixes/.crc
  22. BIN  Examples/FsCoffeeScriptjQueryUI/_ReSharper.FsCoffeeScriptjQueryUIExample/TagPrefixes/6/63daa5f9.dat
  23. BIN  Examples/FsCoffeeScriptjQueryUI/_ReSharper.FsCoffeeScriptjQueryUIExample/TagPrefixes/9/56261ebb.dat
  24. 2  Examples/FsCoffeeScriptjQueryUI/_ReSharper.FsCoffeeScriptjQueryUIExample/TodoCache/.crc
  25. BIN  Examples/FsCoffeeScriptjQueryUI/_ReSharper.FsCoffeeScriptjQueryUIExample/TodoCache/5/3742fc83.dat
  26. 2  Examples/FsCoffeeScriptjQueryUI/_ReSharper.FsCoffeeScriptjQueryUIExample/WordIndex/.crc
  27. BIN  Examples/FsCoffeeScriptjQueryUI/_ReSharper.FsCoffeeScriptjQueryUIExample/WordIndex/9/20718d8.dat
  28. BIN  slides.zip
  29. 14  slides/Deck.js/CoffeeScript-Good Bold and with Sugar/SlideDeck.coffee
  30. 18  slides/Deck.js/CoffeeScript-Good Bold and with Sugar/SlideDeck.js
  31. 293  slides/Deck.js/CoffeeScript-Good Bold and with Sugar/index.html
  32. 13  slides/Deck.js/CoffeeScript-Good Bold and with Sugar/introduction.js
BIN  Examples/FsCoffeeScriptjQueryUI/FsCoffeeScriptjQueryUIExample.suo
Binary file not shown
37  ...I/FsCoffeeScriptjQueryUIExample/FsCoffeeScriptjQueryUIExampleWeb/FsCoffeeScriptjQueryUIExampleWeb.csproj
@@ -14,6 +14,7 @@
14 14
     <AssemblyName>FsCoffeeScriptjQueryUIExampleWeb</AssemblyName>
15 15
     <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
16 16
     <MvcBuildViews>false</MvcBuildViews>
  17
+    <UseIISExpress>false</UseIISExpress>
17 18
   </PropertyGroup>
18 19
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
19 20
     <DebugSymbols>true</DebugSymbols>
@@ -111,6 +112,21 @@
111 112
     <Content Include="Scripts\jquery.validate.min.js" />
112 113
     <Content Include="Scripts\modernizr-1.7.js" />
113 114
     <Content Include="Scripts\modernizr-1.7.min.js" />
  115
+    <Content Include="Scripts\Patterns\Class.js">
  116
+      <AutoGen>True</AutoGen>
  117
+      <DesignTime>True</DesignTime>
  118
+      <DependentUpon>Class.coffee</DependentUpon>
  119
+    </Content>
  120
+    <Content Include="Scripts\Patterns\Command.js">
  121
+      <AutoGen>True</AutoGen>
  122
+      <DesignTime>True</DesignTime>
  123
+      <DependentUpon>Command.coffee</DependentUpon>
  124
+    </Content>
  125
+    <Content Include="Scripts\Patterns\Strategy.js">
  126
+      <AutoGen>True</AutoGen>
  127
+      <DesignTime>True</DesignTime>
  128
+      <DependentUpon>Strategy.coffee</DependentUpon>
  129
+    </Content>
114 130
     <Content Include="Scripts\PictureManager\PictureManager.js">
115 131
       <AutoGen>True</AutoGen>
116 132
       <DesignTime>True</DesignTime>
@@ -121,6 +137,11 @@
121 137
       <DesignTime>True</DesignTime>
122 138
       <DependentUpon>Portlets.coffee</DependentUpon>
123 139
     </Content>
  140
+    <Content Include="Scripts\SlideDeck\SlideDeck.js">
  141
+      <AutoGen>True</AutoGen>
  142
+      <DesignTime>True</DesignTime>
  143
+      <DependentUpon>SlideDeck.coffee</DependentUpon>
  144
+    </Content>
124 145
     <Content Include="Scripts\UserManager\UserManager.js">
125 146
       <AutoGen>True</AutoGen>
126 147
       <DesignTime>True</DesignTime>
@@ -168,6 +189,18 @@
168 189
     <Content Include="Views\PictureManager\Index.cshtml" />
169 190
   </ItemGroup>
170 191
   <ItemGroup>
  192
+    <None Include="Scripts\Patterns\Class.coffee">
  193
+      <Generator>CoffeeScriptGenerator</Generator>
  194
+      <LastGenOutput>Class.js</LastGenOutput>
  195
+    </None>
  196
+    <None Include="Scripts\Patterns\Command.coffee">
  197
+      <Generator>CoffeeScriptGenerator</Generator>
  198
+      <LastGenOutput>Command.js</LastGenOutput>
  199
+    </None>
  200
+    <None Include="Scripts\Patterns\Strategy.coffee">
  201
+      <Generator>CoffeeScriptGenerator</Generator>
  202
+      <LastGenOutput>Strategy.js</LastGenOutput>
  203
+    </None>
171 204
     <None Include="Scripts\PictureManager\PictureManager.coffee">
172 205
       <Generator>CoffeeScriptGenerator</Generator>
173 206
       <LastGenOutput>PictureManager.js</LastGenOutput>
@@ -176,6 +209,10 @@
176 209
       <Generator>CoffeeScriptGenerator</Generator>
177 210
       <LastGenOutput>Portlets.js</LastGenOutput>
178 211
     </None>
  212
+    <None Include="Scripts\SlideDeck\SlideDeck.coffee">
  213
+      <Generator>CoffeeScriptGenerator</Generator>
  214
+      <LastGenOutput>SlideDeck.js</LastGenOutput>
  215
+    </None>
179 216
     <None Include="Scripts\UserManager\UserManager.coffee">
180 217
       <Generator>CoffeeScriptGenerator</Generator>
181 218
       <LastGenOutput>UserManager.js</LastGenOutput>
7  ...iptjQueryUI/FsCoffeeScriptjQueryUIExample/FsCoffeeScriptjQueryUIExampleWeb/Scripts/Patterns/Class.coffee
... ...
@@ -0,0 +1,7 @@
  1
+class Dog
  2
+    offset = 7
  3
+    constructor: (@name, @age) ->
  4
+    toString: -> "#{@name} is #{@age*offset} years old."
  5
+
  6
+emma = new Dog "Emma", 9
  7
+console.log emma.toString()
17  ...eScriptjQueryUI/FsCoffeeScriptjQueryUIExample/FsCoffeeScriptjQueryUIExampleWeb/Scripts/Patterns/Class.js
... ...
@@ -0,0 +1,17 @@
  1
+(function() {
  2
+  var Dog, emma;
  3
+  Dog = (function() {
  4
+    var offset;
  5
+    offset = 7;
  6
+    function Dog(name, age) {
  7
+      this.name = name;
  8
+      this.age = age;
  9
+    }
  10
+    Dog.prototype.toString = function() {
  11
+      return "" + this.name + " is " + (this.age * offset) + " years old.";
  12
+    };
  13
+    return Dog;
  14
+  })();
  15
+  emma = new Dog("Emma", 9);
  16
+  console.log(emma.toString());
  17
+}).call(this);
8  ...tjQueryUI/FsCoffeeScriptjQueryUIExample/FsCoffeeScriptjQueryUIExampleWeb/Scripts/Patterns/Command.coffee
... ...
@@ -0,0 +1,8 @@
  1
+jqxhr = $.ajax
  2
+	url: "/"
  3
+
  4
+logMessages = ""
  5
+
  6
+jqxhr.success -> logMessages += "Success!\n"
  7
+jqxhr.error -> logMessages += "Error!\n"
  8
+jqxhr.complete -> logMessages += "Completed!\n"
16  ...criptjQueryUI/FsCoffeeScriptjQueryUIExample/FsCoffeeScriptjQueryUIExampleWeb/Scripts/Patterns/Command.js
... ...
@@ -0,0 +1,16 @@
  1
+(function() {
  2
+  var jqxhr, logMessages;
  3
+  jqxhr = $.ajax({
  4
+    url: "/"
  5
+  });
  6
+  logMessages = "";
  7
+  jqxhr.success(function() {
  8
+    return logMessages += "Success!\n";
  9
+  });
  10
+  jqxhr.error(function() {
  11
+    return logMessages += "Error!\n";
  12
+  });
  13
+  jqxhr.complete(function() {
  14
+    return logMessages += "Completed!\n";
  15
+  });
  16
+}).call(this);
11  ...jQueryUI/FsCoffeeScriptjQueryUIExample/FsCoffeeScriptjQueryUIExampleWeb/Scripts/Patterns/Strategy.coffee
... ...
@@ -0,0 +1,11 @@
  1
+standardAlgorithm = 2 * 2
  2
+customAlgorithm = 2 * 3   
  3
+
  4
+applyAlgorithm = (someNumber, algorithm) -> 
  5
+    someNumber * algorithm
  6
+
  7
+console.log """Standard algorithm result is 
  8
+    #{applyAlgorithm 2, standardAlgorithm}"""
  9
+
  10
+console.log """Custom algorithm result is
  11
+    #{applyAlgorithm 2, customAlgorithm}."""
10  ...riptjQueryUI/FsCoffeeScriptjQueryUIExample/FsCoffeeScriptjQueryUIExampleWeb/Scripts/Patterns/Strategy.js
... ...
@@ -0,0 +1,10 @@
  1
+(function() {
  2
+  var applyAlgorithm, customAlgorithm, standardAlgorithm;
  3
+  standardAlgorithm = 2 * 2;
  4
+  customAlgorithm = 2 * 3;
  5
+  applyAlgorithm = function(someNumber, algorithm) {
  6
+    return someNumber * algorithm;
  7
+  };
  8
+  console.log("Standard algorithm result is \n" + (applyAlgorithm(2, standardAlgorithm)));
  9
+  console.log("Custom algorithm result is\n" + (applyAlgorithm(2, customAlgorithm)) + ".");
  10
+}).call(this);
14  ...ueryUI/FsCoffeeScriptjQueryUIExample/FsCoffeeScriptjQueryUIExampleWeb/Scripts/SlideDeck/SlideDeck.coffee
... ...
@@ -0,0 +1,14 @@
  1
+$ = jQuery
  2
+$ -> 
  3
+	$(".code-example").fancybox
  4
+		'titlePosition'	: 'outside'
  5
+		'overlayColor' : '#000'
  6
+		'overlayOpacity'	: 0.4
  7
+
  8
+	$.deck '.slide'
  9
+	
  10
+	$('#style-themes').change ->
  11
+		$('#style-theme-link').attr 'href', $(@).val()
  12
+
  13
+	$('#transition-themes').change ->
  14
+		$('#transition-theme-link').attr 'href', $(@).val()
18  ...ptjQueryUI/FsCoffeeScriptjQueryUIExample/FsCoffeeScriptjQueryUIExampleWeb/Scripts/SlideDeck/SlideDeck.js
... ...
@@ -0,0 +1,18 @@
  1
+(function() {
  2
+  var $;
  3
+  $ = jQuery;
  4
+  $(function() {
  5
+    $(".code-example").fancybox({
  6
+      'titlePosition': 'outside',
  7
+      'overlayColor': '#000',
  8
+      'overlayOpacity': 0.4
  9
+    });
  10
+    $.deck('.slide');
  11
+    $('#style-themes').change(function() {
  12
+      return $('#style-theme-link').attr('href', $(this).val());
  13
+    });
  14
+    return $('#transition-themes').change(function() {
  15
+      return $('#transition-theme-link').attr('href', $(this).val());
  16
+    });
  17
+  });
  18
+}).call(this);
BIN  ...QueryUIExample/FsCoffeeScriptjQueryUIExampleWeb/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
Binary file not shown
BIN  ...feeScriptjQueryUIExample/FsCoffeeScriptjQueryUIExampleWeb/obj/Debug/TempPE/Scripts.Patterns.Class.js.dll
Binary file not shown
BIN  ...ScriptjQueryUIExample/FsCoffeeScriptjQueryUIExampleWeb/obj/Debug/TempPE/Scripts.Patterns.Strategy.js.dll
Binary file not shown
2  Examples/FsCoffeeScriptjQueryUI/_ReSharper.FsCoffeeScriptjQueryUIExample/BuildScriptCache/.crc
... ...
@@ -1 +1 @@
1  
-L4w
  1
+-²C«
BIN  Examples/FsCoffeeScriptjQueryUI/_ReSharper.FsCoffeeScriptjQueryUIExample/BuildScriptCache/1/56808d5a.dat
Binary file not shown
2  Examples/FsCoffeeScriptjQueryUI/_ReSharper.FsCoffeeScriptjQueryUIExample/NamedArguments/.crc
... ...
@@ -1 +1 @@
1  
-`ܐs
  1
+ô\“±
BIN  Examples/FsCoffeeScriptjQueryUI/_ReSharper.FsCoffeeScriptjQueryUIExample/NamedArguments/7/7d94b125.dat
Binary file not shown
BIN  ...ScriptjQueryUI/_ReSharper.FsCoffeeScriptjQueryUIExample/PdbInfo/489b52b9da113729c5817f70a616e1f36609f619
Binary file not shown
BIN  ...ScriptjQueryUI/_ReSharper.FsCoffeeScriptjQueryUIExample/PdbInfo/b0c7019bddee13d39d50a04eca2409474689f5da
Binary file not shown
BIN  Examples/FsCoffeeScriptjQueryUI/_ReSharper.FsCoffeeScriptjQueryUIExample/SymbolCache.bin
Binary file not shown
2  Examples/FsCoffeeScriptjQueryUI/_ReSharper.FsCoffeeScriptjQueryUIExample/TagPrefixes/.crc
... ...
@@ -1 +1 @@
1  
-d
  1
+P
BIN  Examples/FsCoffeeScriptjQueryUI/_ReSharper.FsCoffeeScriptjQueryUIExample/TagPrefixes/6/63daa5f9.dat
Binary file not shown
BIN  Examples/FsCoffeeScriptjQueryUI/_ReSharper.FsCoffeeScriptjQueryUIExample/TagPrefixes/9/56261ebb.dat
Binary file not shown
2  Examples/FsCoffeeScriptjQueryUI/_ReSharper.FsCoffeeScriptjQueryUIExample/TodoCache/.crc
... ...
@@ -1 +1 @@
1  
--V
  1
BIN  Examples/FsCoffeeScriptjQueryUI/_ReSharper.FsCoffeeScriptjQueryUIExample/TodoCache/5/3742fc83.dat
Binary file not shown
2  Examples/FsCoffeeScriptjQueryUI/_ReSharper.FsCoffeeScriptjQueryUIExample/WordIndex/.crc
... ...
@@ -1 +1 @@
1  
-DW
  1
+-k
BIN  Examples/FsCoffeeScriptjQueryUI/_ReSharper.FsCoffeeScriptjQueryUIExample/WordIndex/9/20718d8.dat
Binary file not shown
BIN  slides.zip
Binary file not shown
14  slides/Deck.js/CoffeeScript-Good Bold and with Sugar/SlideDeck.coffee
... ...
@@ -0,0 +1,14 @@
  1
+$ = jQuery
  2
+$ -> 
  3
+	$(".code-example").fancybox
  4
+		'titlePosition'	: 'outside'
  5
+		'overlayColor' : '#000'
  6
+		'overlayOpacity'	: 0.4
  7
+
  8
+	$.deck '.slide'
  9
+	
  10
+	$('#style-themes').change ->
  11
+		$('#style-theme-link').attr 'href', $(@).val()
  12
+
  13
+	$('#transition-themes').change ->
  14
+		$('#transition-theme-link').attr 'href', $(@).val()
18  slides/Deck.js/CoffeeScript-Good Bold and with Sugar/SlideDeck.js
... ...
@@ -0,0 +1,18 @@
  1
+(function() {
  2
+  var $;
  3
+  $ = jQuery;
  4
+  $(function() {
  5
+    $(".code-example").fancybox({
  6
+      'titlePosition': 'outside',
  7
+      'overlayColor': '#000',
  8
+      'overlayOpacity': 0.4
  9
+    });
  10
+    $.deck('.slide');
  11
+    $('#style-themes').change(function() {
  12
+      return $('#style-theme-link').attr('href', $(this).val());
  13
+    });
  14
+    return $('#transition-themes').change(function() {
  15
+      return $('#transition-theme-link').attr('href', $(this).val());
  16
+    });
  17
+  });
  18
+}).call(this);
293  slides/Deck.js/CoffeeScript-Good Bold and with Sugar/index.html
@@ -31,6 +31,9 @@
31 31
 	<!-- Prettify -->
32 32
 	<link rel="stylesheet" type="text/css" href="prettify/prettify.css" media="screen" />
33 33
 	
  34
+	<!-- Custom CSS just for this page -->
  35
+    <link rel="stylesheet" href="introduction.css">
  36
+
34 37
 	<script src="../../Deck.js/modernizr.custom.js"></script>
35 38
 </head>
36 39
 
@@ -146,22 +149,8 @@
146 149
 			    <a class="code-example view-code-button" href="#truthy-falsy-example-div" title="Truthy Example">
147 150
 				Code</a> 
148 151
 			</li>
149  
-		</ul>
150  
-	</div>
151  
-
152  
-	<div class="slide" id="cs-the-good-parts-2">
153  
-		<h2>CoffeeScript: The Good Parts</h2>
154  
-	    <p>
155  
-        More of the <a href="http://arcturo.github.com/library/coffeescript/07_the_bad_parts.html">bad parts fixed by CoffeeScript</a>:
156  
-		</p>
157  
-		<ul>
158  
-			<li>
159  
-    			Hoisting issues (only function expressions are allowed) 
160  
-			    <a class="code-example view-code-button" href="#hoisting-example-div" title="Hosting Issue/Resolution Example">
161  
-				Code</a> 
162  
-			</li>
163  
-			<li>
164  
-			Others not mentioned in Crockford's book (i.e. enforces SoC, etc.)  
  152
+			<li class="slide" id="bad-parts-3">
  153
+			Others d mentioned in Crockford's book (i.e. enforces SoC, etc.)  
165 154
 			</li>
166 155
 		</ul>
167 156
 	</div>
@@ -306,6 +295,16 @@
306 295
 	</div>
307 296
 
308 297
 	<div class="slide" id="jquery-ui-examples">
  298
+		<h2>More examples</h2>
  299
+		<ul>
  300
+			<li>Shows more complex scenarios</li>
  301
+			<li>jQuery UI Examples: <a href="http://jqueryui.com/demos/sortable/#portlets">Portlets</a>, <a href="http://jqueryui.com/demos/droppable/#photo-manager">Photo Manager</a>, and <a href="http://jqueryui.com/demos/dialog/#modal-form">Modal Form</a></li>
  302
+			<li>Mocha Example <a href="http://www.nuget.org/packages/ExpectThat.Mocha">on NuGet Gallery</a></li>
  303
+			<li>Example available on <a href="https://github.com/dmohl/FsCoffeeScriptjQueryUIExample">my GitHub</a></li>
  304
+		</ul>
  305
+	</div>
  306
+
  307
+	<div class="slide" id="jquery-ui-examples">
309 308
 		<h2>Example with ASP.NET MVC, F#, jQuery UI, and CoffeeScript</h2>
310 309
 		<ul>
311 310
 			<li>Shows more complex scenarios</li>
@@ -314,6 +313,21 @@
314 313
 		</ul>
315 314
 	</div>
316 315
 
  316
+	<div class="slide" id="jquery-ui-examples">
  317
+		<h2>More Common JS Patterns in CoffeeScript</h2>
  318
+		<ul>
  319
+			<li class="slide" id="more-patterns-1">Revealing Module Pattern 
  320
+			    <a class="code-example view-code-button" href="#revealing-module-div" title="Revealing Module Pattern">Code</a>
  321
+			</li>
  322
+			<li class="slide" id="more-patterns-2">Classes - Constructor function with prototype
  323
+			    <a class="code-example view-code-button" href="#classes-div" title="Construstor with Prototype">Code</a></li>
  324
+			<li class="slide" id="more-patterns-3">Command Pattern
  325
+			    <a class="code-example view-code-button" href="#command-div" title="Command Pattern">Code</a></li>
  326
+			<li class="slide" id="more-patterns-4">Strategy Pattern
  327
+			    <a class="code-example view-code-button" href="#strategy-div" title="Strategy Pattern">Code</a></li>
  328
+		</ul>
  329
+	</div>
  330
+
317 331
 	<div class="slide" id="where-to-get-this-presentation">
318 332
 		<h2>Where to Go for More Information?</h2>
319 333
 		<li><a href="http://coffeescript.org/">http://coffeescript.org/</a></li>
@@ -449,59 +463,6 @@
449 463
 		</div>
450 464
 	</div>
451 465
 
452  
-	<div style="display: none;">
453  
-		<div id="hoisting-example-div" class="source-code-light-box">			
454  
-			<div class="left-source-code">
455  
-			    <pre class="prettyprint">
456  
-// Example derived from 
457  
-//     <a href="http://bit.ly/wbdl7g">http://bit.ly/wbdl7g</a>
458  
-// Some browsers will return
459  
-//     different results here.
460  
-
461  
-addIt(2, 3);
462  
-
463  
-if (true) {
464  
-    function addIt(val1, val2) {
465  
-        return val1 + val2;
466  
-    }
467  
-} else {
468  
-    function addIt(val1, val2) {
469  
-        return val1 + val2 + 1000;
470  
-    }
471  
-}
472  
-
473  
-// This is due to hoisting, which also
474  
-//     affects defined variables
475  
-				</pre>
476  
-			</div>
477  
-			<div class="right-source-code">
478  
-			    <pre class="prettyprint">
479  
-# CoffeeScript
480  
-addIt 2, 3
481  
-if true
482  
-    addIt = (val1, val2) ->
483  
-        val1 + val2
484  
-else
485  
-    addIt = (val1, val2) ->
486  
-        val1 + val2 + 1000
487  
-	
488  
-// JavaScript after compilation
489  
-var addIt;
490  
-addIt(2, 3);
491  
-if (true) {
492  
-    addIt = function(val1, val2) {
493  
-        return val1 + val2;
494  
-    };
495  
-} else {
496  
-    addIt = function(val1, val2) {
497  
-        return val1 + val2 + 1000;
498  
-    };
499  
-}	
500  
-				</pre>
501  
-			</div>
502  
-		</div>
503  
-	</div>
504  
-
505 466
     <div style="display: none;">
506 467
    		<div id="at-sign-sugar-example-div" class="source-code-light-box">
507 468
    			<div class="left-source-code">
@@ -738,7 +699,7 @@
738 699
 		</div>
739 700
 	</div>
740 701
 
741  
-		<div style="display: none;">
  702
+	<div style="display: none;">
742 703
 		<div id="existential-operator-example-div" class="source-code-light-box">			
743 704
 			<div class="left-source-code">
744 705
 			    <pre class="prettyprint">
@@ -759,7 +720,7 @@
759 720
 		</div>
760 721
 	</div>
761 722
 
762  
-		<div style="display: none;">
  723
+	<div style="display: none;">
763 724
 		<div id="regular-expression-example-div" class="source-code-light-box">			
764 725
 			<div class="left-source-code">
765 726
 			    <pre class="prettyprint">
@@ -786,6 +747,178 @@
786 747
 		</div>
787 748
 	</div>
788 749
 	
  750
+	<div style="display: none;">
  751
+		<div id="revealing-module-div" class="source-code-light-box">			
  752
+			<div class="left-source-code">
  753
+			    <pre class="prettyprint">
  754
+// From Burke Holland's blog
  755
+// http://a.shinynew.me/post/16063066350/a-coffeescript-revealing-module
  756
+
  757
+var logger = function($) {
  758
+    var pub = {};
  759
+    var logContainer;
  760
+	
  761
+    // anything off pub is public    
  762
+    pub.init = function(el) {
  763
+        logContainer = el;
  764
+    }
  765
+        
  766
+    pub.log = function(msg) {
  767
+        write(msg);
  768
+    }
  769
+        
  770
+    // everything else is private
  771
+    var write = function(msg) {
  772
+        logContainer.append(msg);
  773
+    }
  774
+    return pub;
  775
+}(jQuery);
  776
+
  777
+logger.init($("#log"));
  778
+logger.log("Modules FTW!");
  779
+				</pre>
  780
+			</div>
  781
+			<div class="right-source-code">
  782
+			    <pre class="prettyprint">
  783
+root = this
  784
+$ = jQuery
  785
+root.logger = do ($) ->
  786
+    pub = logContainer = {}
  787
+    pub.init = (el) -> logContainer = el
  788
+    pub.log = (msg) -> write msg
  789
+    write = (msg) ->
  790
+        logContainer.append("#{msg}")
  791
+        
  792
+    pub				</pre>
  793
+			</div>
  794
+		</div>
  795
+	</div>	
  796
+	
  797
+	<div style="display: none;">
  798
+		<div id="classes-div" class="source-code-light-box">			
  799
+			<div class="left-source-code">
  800
+			    <pre class="prettyprint">
  801
+  var Dog, emma;
  802
+
  803
+  Dog = (function() {
  804
+    var offset = 7;
  805
+	
  806
+    function Dog(name, age) {
  807
+      this.name = name;
  808
+      this.age = age;
  809
+    }
  810
+	
  811
+    Dog.prototype.toString = function() {
  812
+      return "" + this.name + " is " + 
  813
+	      (this.age * offset) + 
  814
+		  " years old.";
  815
+    };
  816
+	
  817
+    return Dog;
  818
+  })();
  819
+  emma = new Dog("Emma", 9);
  820
+  console.log(emma.toString());
  821
+				</pre>
  822
+			</div>
  823
+			<div class="right-source-code">
  824
+			    <pre class="prettyprint">
  825
+class Dog
  826
+    offset = 7
  827
+    constructor: (@name, @age) ->
  828
+    toString: -> 
  829
+	    """#{@name} is #{@age*offset} 
  830
+	    years old."""
  831
+
  832
+emma = new Dog "Emma", 9
  833
+console.log emma.toString()
  834
+                </pre>
  835
+			</div>
  836
+		</div>
  837
+	</div>	
  838
+	
  839
+	<div style="display: none;">
  840
+		<div id="command-div" class="source-code-light-box">			
  841
+			<div class="left-source-code">
  842
+			    <pre class="prettyprint">
  843
+(function() {
  844
+  var jqxhr, logMessages;
  845
+  
  846
+  jqxhr = $.ajax({
  847
+    url: "/"
  848
+  });
  849
+  
  850
+  logMessages = "";
  851
+  
  852
+  jqxhr.success(function() {
  853
+    return logMessages += "Success!\n";
  854
+  });
  855
+  
  856
+  jqxhr.error(function() {
  857
+    return logMessages += "Error!\n";
  858
+  });
  859
+  
  860
+  jqxhr.complete(function() {
  861
+    return logMessages += "Completed!\n";
  862
+  });
  863
+}).call(this);
  864
+				</pre>
  865
+			</div>
  866
+			<div class="right-source-code">
  867
+			    <pre class="prettyprint">
  868
+# From http://coffeescriptcookbook.com/chapters/design_patterns/command				
  869
+				
  870
+jqxhr = $.ajax
  871
+	url: "/"
  872
+
  873
+logMessages = ""
  874
+
  875
+jqxhr.success -> logMessages += "Success!\n"
  876
+jqxhr.error -> logMessages += "Error!\n"
  877
+jqxhr.complete -> logMessages += "Completed!\n"                
  878
+				</pre>
  879
+			</div>
  880
+		</div>
  881
+	</div>	
  882
+
  883
+	<div style="display: none;">
  884
+		<div id="strategy-div" class="source-code-light-box">			
  885
+			<div class="left-source-code">
  886
+			    <pre class="prettyprint">
  887
+(function() {
  888
+  var applyAlgorithm, customAlgorithm, standardAlgorithm;
  889
+  standardAlgorithm = 2 * 2;
  890
+  customAlgorithm = 2 * 3;
  891
+  
  892
+  applyAlgorithm = function(someNumber, algorithm) {
  893
+    return someNumber * algorithm;
  894
+  };
  895
+  
  896
+  console.log("Standard algorithm result is \n" + 
  897
+      (applyAlgorithm(2, standardAlgorithm)));
  898
+	  
  899
+  console.log("Custom algorithm result is\n" + 
  900
+      (applyAlgorithm(2, customAlgorithm)) + ".");
  901
+}).call(this);
  902
+				</pre>
  903
+			</div>
  904
+			<div class="right-source-code">
  905
+			    <pre class="prettyprint">
  906
+standardAlgorithm = 2 * 2
  907
+customAlgorithm = 2 * 3   
  908
+
  909
+applyAlgorithm = (someNumber, algorithm) -> 
  910
+    someNumber * algorithm
  911
+
  912
+console.log """Standard algorithm result is 
  913
+    #{applyAlgorithm 2, standardAlgorithm}"""
  914
+
  915
+console.log """Custom algorithm result is
  916
+    #{applyAlgorithm 2, customAlgorithm}."""
  917
+				</pre>
  918
+			</div>
  919
+		</div>
  920
+	</div>	
  921
+
789 922
 
790 923
 	<a href="#" class="deck-prev-link" title="Previous">&#8592;</a>
791 924
 	<a href="#" class="deck-next-link" title="Next">&#8594;</a>
@@ -807,15 +940,9 @@
807 940
 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.js"></script>
808 941
 <script>window.jQuery || document.write('<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.1.min.js">\x3C/script>')</script>
809 942
 <script type="text/javascript" src="jquery.fancybox-1.3.4/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
810  
-<script type="text/javascript">
811  
-	$(document).ready(function() {
812  
-		$(".code-example").fancybox({
813  
-			'titlePosition'	: 'outside',
814  
-			'overlayColor' : '#000',
815  
-			'overlayOpacity'	: 0.4
816  
-		});
817  
-	});
818  
-</script>
  943
+
  944
+<script src="SlideDeck.js"></script>
  945
+
819 946
 <script type="text/javascript" src="prettify/prettify_mod.js"></script> 
820 947
 
821 948
 <!-- Deck Core and extensions -->
@@ -826,11 +953,5 @@
826 953
 <script src="../../Deck.js/extensions/navigation/deck.navigation.js"></script>
827 954
 <script src="../../Deck.js/extensions/hash/deck.hash.js"></script>
828 955
 
829  
-<!-- Specific to this page -->
830  
-<script src="introduction.js"></script>
831  
-
832  
-<!-- Custom CSS just for this page -->
833  
-<link rel="stylesheet" href="introduction.css">
834  
-
835 956
 </body>
836 957
 </html>
13  slides/Deck.js/CoffeeScript-Good Bold and with Sugar/introduction.js
... ...
@@ -1,13 +0,0 @@
1  
-$(function() {
2  
-	// Deck initialization
3  
-	$.deck('.slide');
4  
-	
5  
-	$('#style-themes').change(function() {
6  
-		$('#style-theme-link').attr('href', $(this).val());
7  
-	});
8  
-	
9  
-	$('#transition-themes').change(function() {
10  
-		$('#transition-theme-link').attr('href', $(this).val());
11  
-	});
12  
-});
13  
-

0 notes on commit 1c4a818

Please sign in to comment.
Something went wrong with that request. Please try again.