Smashing CoffeeScript [NOOK Book]

Overview

MASTER COFFEESCRIPT AND BREW UP COMPLEX JAVASCRIPT APPLICATIONS FASTER AND EASIER THAN EVER BEFORE

Highly descriptive and easy to read, the CoffeeScript language adds syntactic sugar to JavaScript, making it faster and easier than ever to create complex JavaScreipt apps. Besides requiring one-third less code than JavaScript, CoffeeScript lets you program with more sophisticated features, such as list comprehension and pattern matching.

Getting ...

See more details below
Smashing CoffeeScript

Available on NOOK devices and apps  
  • NOOK Devices
  • Samsung Galaxy Tab 4 NOOK
  • NOOK HD/HD+ Tablet
  • NOOK
  • NOOK Color
  • NOOK Tablet
  • Tablet/Phone
  • NOOK for Windows 8 Tablet
  • NOOK for iOS
  • NOOK for Android
  • NOOK Kids for iPad
  • PC/Mac
  • NOOK for Windows 8
  • NOOK for PC
  • NOOK for Mac

Want a NOOK? Explore Now

NOOK Book (eBook)
$25.99
BN.com price
(Save 42%)$44.99 List Price
Note: This NOOK Book can be purchased in bulk. Please email us for more information.

Overview

MASTER COFFEESCRIPT AND BREW UP COMPLEX JAVASCRIPT APPLICATIONS FASTER AND EASIER THAN EVER BEFORE

Highly descriptive and easy to read, the CoffeeScript language adds syntactic sugar to JavaScript, making it faster and easier than ever to create complex JavaScreipt apps. Besides requiring one-third less code than JavaScript, CoffeeScript lets you program with more sophisticated features, such as list comprehension and pattern matching.

Getting the hang of CoffeeScript can be a bit tricky at first, especially for programmers who cut their teeth on JavaScript parents, brackets, and often frustrating syntactic quirks. Written by expert Alex Hudson, this book gets you up and running with CoffeeScript right away. Featuring dozens of full-color illustrations and screen shots, this step-by-step guide delivers what you need to:

  • MASTER COFFEESCRIPT LANGUAGE, SYNTAX, AND PATTERNS-FAST
  • PRODUCE MORE CONCISE, BETTER QUALITY CODE IN ONE-THIRD THE TIME
  • DEVELOP BRILLIANT MOBILE APPS AND RICH INTERNET APPS IN COFFEESCRIPT
  • GET THE HANG OF ADVANCED HTML5 FEATURES AND REAL-TIME COMMUNICATION IN COFFEESCRIPT
  • USE COFFEESCRIPT WITHIN NODE.JS PROJECTS
  • BLEND JAVASCRIPT WITH COFFEESCRIPT FOR VASTLY BETTER OUTCOMES

With Smashing CoffeeScript to guide you, in no time you’ll be writing perfect code with CoffeeScript and streamlining your JavaScript development.

Read More Show Less

Product Details

  • ISBN-13: 9781118454947
  • Publisher: Wiley
  • Publication date: 3/29/2013
  • Series: Smashing Magazine Book Series
  • Sold by: Barnes & Noble
  • Format: eBook
  • Edition number: 1
  • Pages: 336
  • Sales rank: 1,207,774
  • File size: 3 MB

Meet the Author

Alex Hudson is a technology expert and programmer. A hacker by trade, he likes to keep on top of new technologies. He hacks in C, C#, JavaScript, Perl, PHP, Python, and Vala Primarily, and due to the day job has a keen interest in HTML5, CSS, SQL, and NoSQL.
Read More Show Less

Table of Contents

INTRODUCTION 1

PART I: COFFEESCRIPT BASICS 7

Chapter 1: Starting Up Your CoffeeScript Environment 9

CoffeeScript in the Browser 10

Starting CoffeeScript in Plain HTML 10

Understanding CoffeeScript 11

Compiling CoffeeScript Outside the Browser 12

What Is npm? 12

Installing Coffee Using npm 13

A Quick Tour of npm 13

Installing CoffeeScript 14

Compiling CoffeeScript Code 15

Putting It Together 16

Automatic Compilation 17

Avoiding Coff eeScript Errors 17

Coding in Good Style 18

Coffeelint Will Pick Up Errors 20

Summary 20

Chapter 2: Using jQuery: DOM Manipulation 21

jQuery’s Fluent API 22

Th e “DOM Ready” Handler 23

Selectors, Now Even More Usable 24

Comprehensions 25

Working with Functions 26

Functions for Encapsulation 28

Keeping Code DRY 31

Function Parameters and Existential Operators 32

Using Utility Functions 33

Cleaner Click Handlers 36

General Event Handling 37

Page Events 38

Feature Detection for Practical Polyfi ll 40

Detecting CSS Features 41

Summary 42

Chapter 3: Working with Forms 43

Basic HTML5 Forms 44

Collecting Form Data 44

Validating Form Data 45

Systematizing Validation 47

Common Form Techniques 49

Displaying Validation Results Inline 49

Continuous Validation 52

Controlling Submit Button Interaction 54

Prepopulating Form Elements 54

Multi-Step Forms 55

Selective Form Display 55

Validating Partial Form Data 59

Modal Form UI 59

Using Subforms as Data Helpers 61

Summary 62

Chapter 4: AJAX Requests 63

Getting Data to and from the Server 64

HTTP Requests 64

Easily Retrieving Information 66

Cross-origin Request Handling 68

Understanding Browser Request Security 68

JSONP Requests 69

Cross-Origin Resource Sharing 71

Example: User Registration Form 71

Error Handling 78

Generating Errors 79

Detecting Errors 80

Retrying in Case of Temporary Errors 81

Deferring and Cancelling Requests Using Queues 83

Strategies to Defer Requests 84

Strategies to Cancel Requests 86

Local Storage and Offl ine Apps 87

A Short History of Local Storage 87

LocalStorage 88

IndexedDB 90

Comparing Local Storage Options 92

Summary 92

Chapter 5: Object-Oriented Design 93

Classes and Inheritance 94

What Does It Mean To Be Object-Oriented? 94

Functions Versus Objects to Encapsulate 95

Extending Classes 97

Making Classes Substitutable 100

Using this. in Coff eeScript 101

Private and Protected Members 102

Mixins and Interfaces 102

Summary 103

PART II: COFFEESCRIPT PROJECTS 105

Chapter 6: Using Javascript Libraries 107

Easy Calling Conventions: Don’t Th row Away that Existing Code! 108

Calling JavaScript from Coff eeScript 108

Calling Coff eeScript from JavaScript 110

Using CommonJS Modules 111

Using Extends on Existing Classes 113

Not All Objects Are Created Equal 113

Writing Javascript Libraries in Coff eeScript 114

Providing a Natural Interface 114

Documenting Code 115

Mixing Javascript—When Absolutely Required 117

Summary 119

Chapter 7: Testing with Jasmine 121

Introducing Jasmine 122

Setting Up a Spec Area to Run Jasmine Tests 122

Writing Jasmine Tests 123

Spying with Jasmine 124

Behavior-Driven Development: What Is a Good Test? 126

Testing Inside the Browser 127

Conventions for Testing the UI 131

Driving jQuery 132

Fixtures 133

Summary 134

Chapter 8: Debugging CoffeeScript 135

Writing Reliable Software 136

Reading and Debugging CoffeeScript and JavaScript 136

Using Firebug 139

Using AceBug 142

Building Source Maps 143

Introducing CoffeeScript Redux 144

Using CoffeeScript Redux 145

Using Source Maps 146

Summary 150

Chapter 9: Building Resources with cake and hem 151

Tasks and the Cakefile 152

Starting with cake 152

Thinking about Project Directory Layout 153

Tests from cake 154

Compile Source into Single Files for Production Deployment 155

hem for Further Minification 156

Using Standardized Locations 157

Summary 158

PART III: COFFEESCRIPT APPLICATION DEVELOPMENT 159

Chapter 10: Writing Applications with Spine 161

Introducing Spine 162

Creating a New Spine Application 163

Building the Application 169

Preparing the Ground 170

Removing jQueryify 171

Styling an Application with Stylus 172

Working with Stylus 172

Taking a Deeper Look at Stylus Features 174

Spine’s Default Styls 177

Starting with Controllers 180

Testing Controllers 181

Controlling the Page 182

Adding Controllers 185

Stacking Controllers 186

Viewing the Results 188

Using (j)Eco Templates 188

Data Binding 190

Modelling Client-Side Data 193

Creating a Spine Model 193

Working with Models 195

Triggering Model Events 196

Validating Models 198

Editing Model Data 199

Storing Data on the Server 202

Summary 204

Chapter 11: Writing jQuery Plug-ins 205

Anatomy of a jQuery Plug-in 206

Creating a Skeleton Plug-in 206

Writing a Classful Plug-in 209

Handling Events and Behavior 211

Attaching the Plug-in to jQuery 213

Inheriting from an Existing Plug-in 214

jQuery UI 215

Using Widgets Instead of Plug-ins 215

Writing a Tagging Component 218

Bridging the Divide 222

Summary 225

Chapter 12: Mobile Coff eeScript Applications 227

Understanding Mobile First Principles 228

jQuery and Mobile Applications 229

Spine.mobile 230

Creating an e-Commerce Shop 234

Providing a Product Listing 238

Bringing in jQuery Mobile 243

Jumping and History 250

Summary 254

PART IV: ADVANCED COFFEESCRIPT 255

Chapter 13: Data Bindings and Form Elements 257

One-Way Bindings onto Form Views 258

A Simple Binding Interface 258

Setting Form Data 260

Two-Way Bindings 261

The Infamous “Getter Setter” Pattern 262

Implicit Getter/Setter 264

Observing Changes 265

Dynamic Form Building 268

Form as Model, View, and Controller 270

Summary 270

Chapter 14: Server-Side CoffeeScript 271

Putting Coff ee in the Server 272

Node.js and Coff eeScript 272

Writing a Simple Server 273

Using MongoDB 273

Architecting with MVC 274

Introducing Express.js 275

Responding to Client Requests 279

Rendering Views 280

Controlling Responses 281

Securing the Application 287

Summary 290

Chapter 15: Real-Time Web with socket.io 291

Defi ning Real-Time Applications 292

Polling the Server for Data 292

Comet for Lightweight Polling 293

Server-Side Events and Web Sockets 293

Doing Micro-Blogging in Real Time 294

Integrating Static and Real-Time Data 296

Rendering on the Client Side 296

Reusing Server-Side Code on the Client 298

Sharing Templates 298

Sharing Models 299

Dealing with Callback Pyramids 299

Real-Time Collaboration within a Single App 301

Operational Transformation 302

Separating Input from Operation 302

Building a Meeting Whiteboard App 303

Modeling Information According to OT 306

Serving Simple socket.io Information 307

Handling Remote Updates 308

Summary 311

Index 313

Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star

(0)

4 Star

(0)

3 Star

(0)

2 Star

(0)

1 Star

(0)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously

    If you find inappropriate content, please report it to Barnes & Noble
    Why is this product inappropriate?
    Comments (optional)