Created
November 7, 2008 16:06
-
-
Save trek/22893 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| require 'redshift' | |
| class PhotoBucket | |
| def initialize(element) | |
| @element = element | |
| @req = Request.new | |
| @req.upon(:request) { self.show_loader } | |
| @req.upon(:success) { self.hide_loader } | |
| @req.upon(:response) { self.load_photos } | |
| self.load_initial_photos | |
| end | |
| def load_initial_photos | |
| @req.execute({:url => '/photos/1.html'}) | |
| end | |
| def hide_loader | |
| @element['#loading'].styles[:display] = 'none' | |
| end | |
| def show_loader | |
| @element['#loading'].styles[:display] = 'block' | |
| end | |
| end | |
| Document.ready? do | |
| Document['.photo_wrapper'].each do |e| | |
| PhotoBucket.new(e) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment