Front End Development

Day 1
Pascal Rettig / CTO at Fundraise.com / @cykod
http://bitly.com/bss-frontend

2-Day schedule - Day 1

2-Day schedule - Day 2

What is the Web?

The world wide web is a system of interlinked hypertext documents accessed via the Internet. With a web browser, one can view web pages that may contain text, images, videos, and other multimedia and navigate between them via hyperlinks.

The Web is Content

What can you do
on the web?

Just about anything...It's no longer just sites of text. Bookcase

The web is....

Whatever you want to build.

The Good:

If you can dream it,
you can build it
...and deliver it to Billions of people instantly

The Bad:

There's a lot to learn

The Ages of the Web

What is
"Front end"?

A set of technologies, guided by standards used on the client.

Front-end technologies

What's the point of each?

  1. HTML - Semantics, Content, Information, Data

  2. CSS - Layout and Styling

  3. Javascript - Create Dynamism, interaction

  4. Data-transport - Transmit information, transform into HTML w/ JavaScript

What is
"The Client"?

Usually - the browser (Chrome, Firefox, Safari, IE)

What does the client do (simplified)?

Look-up a domain, get an IP address, make a HTTP request, make sub requests, download a page ...

nslookup reddit.com
...

telnet 204.245.162.17 80
Trying 204.245.162.17...
Connected to a204-245-162-17.deploy.akamaitechnologies.com.
Escape character is '^]'.
GET / HTTP/1.1
Host: www.reddit.com

...

.. what does the client do (cont.)?

HTML

Hypertext Markup Language

HTML is a markup language, which means you're annotating (marking up) plain text to give it structure and meaning, similar to the way you would underline or make notes in a book.

HTML "1.0"

The Browser War, Round 1

XHTML

HTML5 and The New Hope

Last numbered version of HTML
Browser makers driving features
Feature coming fast and furious
Browser Wars Round #2

New in "HTML5"

  1. New Semantic Tags

  2. Hardware Accelerated 2D + 3D Graphics

  3. CSS3 - visual goodies, transitions

  4. Audio, Video

  5. WebSockets

  6. Local Storage

  7. Offline Storage

  8. SVG

  9. New Events (touch, orientation, accel)

  10. Geolocation (via GPS)

  11. WebRTC

Tags

HTML tags usually come in pairs
<head>   </head>
In the industry we refer to these as start tag and end tag or open tag and close tag

Tags

In HTML you can write just the opening tag and it will often work like:
<h1> Headline
<p> Body text.

Don’t do this. Always use open and close or single tags.

Attributes

Tell the browser about your content

Attributes

Available on almost tags

HTML5 Semantic Structure

HTML5 Semantic Tags

Most Common Tags

how you might use these tags

Writing Good HTML

"A Semantic Chop"

The Goals

Reminder! your HTML is not your design CSS Zen Garden

CSS

Cascading Style Sheets

What is a style?

Available selectors

Selectors

Selector combinations

Selector Combination Exercise

Cascading - What Color?

Cascading Hierarchy: 999

Laying out a page w/ CSS

You're on your own...

CSS3 Stuff

CSS Transitions Example

More Examples

CSS3 Animations

CSS3 Animations Example

You'll need all your prefixes here! (-webkit, -moz, -ms) - only showing webkit for brevity

HTML / CSS Best practicies

1.Organizing Your CSS

  1. Start with your reset

  2. Set your body

  3. Set your base element styles (p, h1, h2, blockquote)

  4. Set your reusable class styles

  5. Set your layout styles

  6. Set your module styles (additional sub-themes like blogs,custom pages, etc )

2. Don't write CSS!

Use a pre-processor

Pre-processor will let you write reusable code with abstractions.

  1. LESS - Less CSS

  2. Sass - Syntactically Awesome Stylesheets

html5 boilerplate

understand and use! (what you need)

Twitter Bootstrap

Don't reinvent the wheel!

JavaScript

A Little Demo

The goal is to understand everything in here by the end of class today

Javascript Housekeeping

Hello World!

Call the built in 'alert' function and have it say "Hello World!" We don't use this all that often (it's ugly) - but it's really useful for debugging.

Our friend the console and console.log

Puts a result in the console - use Chrome or Firebug (must be open)

Variables

Let's do some math and some string manipulation and write out to the console.

Functions

Created with the "function" keyword, create reusable pieces of functionality.

Scope

You can only use variables that are defined in the scope you call them.

Returning from Functions

Use the return keyword to pass a value back to whatever called the function

Timeouts

we can use setTimeout to have something happen later, try it

Anonymous functions, callbacks

We don't have to give our callback function a name, we can do it anonymously

Why callbacks?

A lot of stuff on the web happens "Asynchronously" - AJAX, user actions, etc

Arrays

Playing with arrays

Objects

Objects

Conditionals

Conditional Exercise

Use a conditional to check if a user confirmed a ok/cancel question. Then use prompt and test against a return value.

jQuery Basics

Docs are your Friend

Get comfortable with docs.jquery.com

Loading jQuery

Include from a CDN or locally

<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>

Or

<script src='js/jquery.min.js'></script>

Need to make sure we have the file in the right location, can view in browser if there's a problem.

Using jQuery

Since we often include Javscript in the head of the document, we need to make sure we wait until the page is loaded before we use it. We can use the jQuery bind function to load stuff at the appropriate point.

<script>
$(document).on("ready",function() {
  // Dom Loaded
});
</script>

Why this is important..

Shorthand

Since this is so common, we can use a shorthand for this of $(function() { }) ...

<script>
$(function() {
  // Dom Loaded
});
</script>

Basic selection + manipulation

Let's try out $.text, $.html, $.hide, $.show, $.css, $.attr, $.addClass, $.hasClass, $.removeClass Selector Docs / Manipulation Docs

Some basic DOM insertion

Let's try out creating elements with $(), then using $.before, $.after, $.append, $.prepend, $.wrap, $.appendTo, both with text and elements.

Fun Stuff: Animation and transforms

$.fadeOut, $.fadeIn, $.slideDown, $.slideUp, $.toggle, $.stop, $.animate

Events

$.click, $.on, $.off, $.hover

Demo Revisited

The goal is to understand everything in here by the end of class today

Putting it all together

Let's use two buttons to increase and decrease a counter.

Plugins

Let's use the cycle plugin: http://jquery.malsup.com/cycle/ (images from http://lorempixel.com)

Ajax

$.ajax, $.get, $.post, $.getJSON

JSONp

Ajax is same-domain only. So there's a hack to pull data across domains called $.getScript

Project