Browse Source

Listing 4.5: restore default size.

Frederic G. MARAND 8 years ago
parent
commit
d3b50a8f05
4 changed files with 74 additions and 7 deletions
  1. 1 3
      Chapter 2/complete.js
  2. 1 0
      Chapter 3/index.html
  3. 10 4
      Chapter 4/04.js
  4. 62 0
      Chapter 4/04.scss

+ 1 - 3
Chapter 2/complete.js

@@ -8,13 +8,11 @@ $(document).ready(function() {
   $('a[href$=".pdf"]').addClass('pdflink');
   $('a[href^="http"][href*="henry"]').addClass('henrylink');
 
-  $('tr:nth-child(odd)').addClass('alt');
   $('a').filter(function() {
     return this.hostname && this.hostname != location.hostname;
   }).addClass('external');
 
-
-
+  $('tr:nth-child(odd)').addClass('alt');
   $('td:contains(Henry)') // Find every cell containing "Henry"
     .parent() // Select its parent
     .find('td:eq(1)') // Find the 2nd descendant cell

+ 1 - 0
Chapter 3/index.html

@@ -6,6 +6,7 @@
     <title>A Christmas Carol</title>
 
     <link rel="stylesheet" href="03.css" type="text/css" />
+
     <script src="jquery.js"></script>
     <script src="03.js"></script>
   </head>

+ 10 - 4
Chapter 4/04.js

@@ -2,12 +2,18 @@ $(document).ready(function () {
   "use strict";
 
   var $speech = $('div.speech');
+  var defaultSize = parseFloat($speech.css('fontSize'));
   $('#switcher button').click(function () {
     var num = parseFloat($speech.css('fontSize'));
-    if (this.id == 'switcher-large') {
-      num *= 1.4;
-    } else if (this.id == 'switcher-small') {
-      num /= 1.4;
+    switch (this.id) {
+      case 'switcher-large':
+        num *= 1.4;
+        break;
+      case 'switcher-small':
+        num /= 1.4;
+        break;
+      default:
+        num = defaultSize;
     }
     $speech.css('fontSize', num + 'px');
   });

+ 62 - 0
Chapter 4/04.scss

@@ -0,0 +1,62 @@
+$black: #000;
+$white: #fff;
+$darkfg: #06581f;
+$medium: #777;
+
+/***************************************
+   Default Styles
+************************************** */
+
+html, body {
+  margin: 0;
+  padding: 0;
+}
+
+body {
+  font: 62.5% Verdana, Helvetica, Arial, sans-serif;
+  color: $black;
+  background: $white;
+}
+#container {
+  font-size: 1.2em;
+  margin: 10px 2em;
+}
+
+h1 {
+  font-size: 2.5em;
+  margin-bottom: 0;
+}
+
+h2 {
+  font-size: 1.3em;
+  margin-bottom: .5em;
+}
+h3 {
+  font-size: 1.1em;
+  margin-bottom: 0;
+}
+
+code {
+  font-size: 1.2em;
+}
+
+a {
+  color: $darkfg;
+}
+
+
+/***************************************
+   Chapter Styles
+************************************** */
+
+#switcher {
+  width: 300px;
+  padding: .5em;
+  border: 1px solid $medium;
+}
+.label {
+  width: 130px;
+  margin: .5em 0;
+  cursor: pointer;
+}
+