Last active
August 29, 2015 14:04
-
-
Save Killavus/9c6a5cf4785a0b1db18d to your computer and use it in GitHub Desktop.
Example of the Gui class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Photos.Gui | |
constructor: (@dom) -> | |
photoRow: (photo) => | |
$("<li><a id='photo_#{photo.id}' href='#{photo.url}'><img src='#{photo.url}' alt='#{photo.alt}' /></a></li>") | |
addPhoto: (photo) => | |
photoNode = @photoRow(photo).appendTo(@dom) | |
@linkClickHandlerToPhoto(photoNode, photo) | |
linkClickHandlerToPhoto: (photoNode, photo) => | |
photoNode.on('click', (e) => | |
e.preventDefault() | |
@switchPhotoToGrayscaled(photoNode, photo) | |
switchPhotoToGrayscaled: (photoNode, photo) => | |
photoNode.find('img').prop('src', photo.grayscaledURL()) | |
fetchPhotosFailed: => | |
$("<li>Failed to fetch photos.</li>").appendTo(@dom) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment