2 tickets please!

lab-logo

Welcome to your new lab, here's the instructions for each exercise :

You must try to find documentation and solution by yourself. The course contains links to references and a lot of other interesting websites. Don't forget : the web is your friend ;-)

Bon courage...

One month, two months, three months...

Learning goals

  1. Know how to manipulate dates.
  2. Know how to add elements to the DOM (directly and with jQuery).

Context

In this exercise, we'll try to display an empty calendar for the next 6 months. The result should look like 2-tickets-please-calendar.html.

We'll use both direct DOM manipulation and using jQuery. If you're still wondering which one is better, have look at this jsperf.

Steps

Months (no jQuery)

<div class="calendar">
  <div class="cal-month" data-month="9" data-year="2012">
    <h2 class="cal-month-name">October 2012</h2>
  </div>
  <div class="cal-month" data-month="10" data-year="2012">
    <h2 class="cal-month-name">November 2012</h2>
  </div>
  <div class="cal-month" data-month="11" data-year="2012">
    <h2 class="cal-month-name">December 2012</h2>
  </div>
  <div class="cal-month" data-month="0" data-year="2013">
    <h2 class="cal-month-name">January 2013</h2>
  </div>
  <div class="cal-month" data-month="1" data-year="2013">
    <h2 class="cal-month-name">February 2013</h2>
  </div>
  <div class="cal-month" data-month="2" data-year="2013">
    <h2 class="cal-month-name">March 2013</h2>
  </div>
</div>
<ul class="months">
  <li class="month-name">October 2012</li>
  <li class="month-name">November 2012</li>
  <li class="month-name">December 2012</li>
  <li class="month-name">January 2013</li>
  <li class="month-name">February 2013</li>
  <li class="month-name">March 2013</li>
</ul>

Day names (using jQuery)

<div class="cal-month" data-month="9" data-year="2012">
  <h2 class="cal-month-name">October 2012</h2>
  <div class="day-names">
    <div class="day-name">Monday</div>
    <div class="day-name">Tuesday</div>
    <div class="day-name">Wednesday</div>
    <div class="day-name">Thursday</div>
    <div class="day-name">Friday</div>
    <div class="day-name">Saturday</div>
    <div class="day-name">Sunday</div>
  </div>
</div>

Days (using jQuery)

<div class="cal-month" data-month="9" data-year="2012">
  <h2 class="cal-month-name">October 2012</h2>
  <div class="day-names"><!-- day names... --></div>
  <div class="days">
    <div class="day" data-day="1">
      <div class="day-number">1</div>
    </div>
    <div class="day" data-day="2">
      <div class="day-number">2</div>
    </div>
    <!-- and so on... -->
  </div>
</div>

Last details (no jQuery)

/* Thursday */
[data-day-start="2"] .day:first-child {
  margin-left: 14.47%;
}
/* Wednesday */
[data-day-start="3"] .day:first-child {
  margin-left: 28.74%;
}
/* Tuesday */
[data-day-start="4"] .day:first-child {
  margin-left: 43.01%;
}
/* Friday */
[data-day-start="5"] .day:first-child {
  margin-left: 57.28%;
}
/* Saturday */
[data-day-start="6"] .day:first-child {
  margin-left: 71.55%;
}
/* Sunday */
[data-day-start="0"] .day:first-child {
  margin-left: 85.82%;
}
<div class="cal-month" data-day-start="4" data-month="10" data-year="2012">
  <h2 class="cal-month-name">November 2012</h2>
</div>

Rules

Deliveries

And now we can begin the show.

Learning goals

  1. Know how retrieve elements from the DOM and modify them (directly and with jQuery).
  2. Know how to parse and read complex JSON.

Context

Now that we have our beautiful empty calendar, it's time to fill it with some events such as concerts, one-man-show, plays...

The result should look like 2-tickets-please-events.html.

In real life, these events would be retrieved from a server or something. We haven't covered that in the lessons, we'll see more about that next week.

The 2-tickets-please-events.js script provides a JSON strings that contains venues and events.

Steps

Venue list (jQuery)

<ul class="venues">
  <li class="venue-name zenith">Le Zénith</li>
  <li class="venue-name aeronef">L'Aéronef</li>
  <!-- and so on... -->
</ul>

Events (jQuery)

<div class="day" data-day="23">
  <div class="day-number">23</div>
  <div class="event" data-venue="zenith" title="CARAVAN PALACE">CARAVAN PALACE</div>
</div>

Rules

Deliveries

Crazy ideas!

This is a "be awesome" exercise!

Learning goals

  1. Learn new stuffs from another website.
  2. Try out and experiment stuffs.

Context

Our "2 Tickets Please!" application works fine, let's try to improve it. In the following steps, you'll find easy stuffs you can add, more complex ones and resources to learn new features...

It's your app, do what you want and be awesome.

Steps

Easy tasks

Ideas you can implement

The "checkbox hack"

There's a way to implement selector/filter without JavaScript. Using that, you could :

This "hack" crosses the line of what you "should" do with CSS and introduces some bad semantics. However, it's fun to play with it and you'll realize how much CSS is powerful. Don't use it on real websites unless you have a very good reason.

Go mobile

Try to add some responsivity with media queries. Have some different CSS for phone, tablet... resolutions.

Rules

Deliveries