Skip to content

Instantly share code, notes, and snippets.

@Killavus
Last active August 29, 2015 14:04
Show Gist options
  • Save Killavus/9c6a5cf4785a0b1db18d to your computer and use it in GitHub Desktop.
Save Killavus/9c6a5cf4785a0b1db18d to your computer and use it in GitHub Desktop.
Example of the Gui class
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