Create a new directory project6
with a subdirectory
p1
that will contain the solution for this problem.
Within that subdirectory, create a file Calendar.js
that implements a Javascript class named
Calendar
that can be used as in the following example:
var calendar = new Calendar("div1"); calendar.render(new Date("July 4, 1776"));
The constructor takes a single argument consisting of the id
attribute for a div, and the render
method takes one argument
consisting of a Date
object that selects a particular
month (the object can
refer to any time within the month). When render
is invoked it replaces the contents of the calendar's div with
HTML that displays a small one-month calendar such as those you might
see in an airline reservation Web site:
<a>
useful for these controls:
<a href="javascript: ...">
The calendar does not need to do anything if the user clicks on a particular date; all it needs to do is display one month and allow the month to be changed by clicking on the controls.
Once you have created the Javascript class, create an HTML
file calendar.html
that uses the Javascript
class to display two different calendar divs. One of the
calendars should initially display the current month and the
other should display the month of January, 2009. It should
be possible to change the month of each calendar independently,
using the controls on that calendar.
In this project you will extend your work on Project #5 by implementing a tagging mechanism that allows users to identify people in the photos of your photo-sharing Web site. Here is a rough sketch of the way this new feature should behave:
<select>
element) displaying the first and
last names of all the users currently registered.
To get started, copy the directory tree for Project #5 to a new
subdirectory p2
in the project6
directory.
Do all of your work for this problem in the new directory.
Is up to you to choose how to implement photo tagging in your application, based on the description above. You can decide whether to use existing pages or add new ones, how to structure any forms that are needed, and so on.
However, you must implement and use a
Javascript "class" named
Tagger
to select the photo region:
<div>
, which must
be a child of the first id's element; the Tagger class will
reposition this element during drags, and you can set CSS
for this element to control the appearance of the feedback.
The last four ids are for hidden form elements that will be
filled in by the Tagger class.<div>
in response to mouse
actions, and filling in the four hidden form elements with
the x and y coordinates, width, and height of the selected
region.The most important criteria for these points are whether or not your Calendar and Tagger implementations are reusable. In addition, your Javascript must be clean (appropriate use of classes, no global variables). We will also consider the usual issues of MVC decomposition, Rails conventions, validation, overall cleanliness of your code and templates, and the appearance and convenience of your Web pages.
x
and y
as
attribute names in your models: y
is a predefined
method in ActiveRecord and you will see weird errors if you use
it as an attribute name.
<div>
element at particular pixel coordinates inside another
<div>
, you must set the position
style attribute in the parent <div>
to
"relative", and you must set the position
style attribute in the child <div>
to
"absolute". Setting the position
of the
parent creates a new "positioning context" in the parent,
so that the child's coordinates are interpreted relative to
the parent. If you don't set the position
of
the parent than the coordinates of the child will be interpreted
relative to the page, not the parent <div>
;
this will probably be much less convenient.
For more information on positioning contexts and the
position
style attribute, see Online Section V of
the book Dynamic HTML, available at
http://cdn.oreilly.com/books/9780596527402/9780596527402_supp.pdf.false
from that handler.
Use the standard class submission mechanism
to submit the entire project6
directory. As always,
your HTML files should pass XHTML validation.