Created
          November 18, 2009 21:31 
        
      - 
      
- 
        Save cowlby/238281 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
    
  
  
    
  | /** | |
| * Script: | |
| * Screensaver.js - Screensaver functionality written in MooTools. | |
| * | |
| * License: | |
| * MIT-style license. | |
| * | |
| * Author: | |
| * Jose Prado | |
| * | |
| * Copyright: | |
| * Copyright (©) 2009 [Jose Prado](http://pradador.com/). | |
| * | |
| */ | |
| var Screensaver = new Class({ | |
| Implements: [Options, Events], | |
| options: { time: 10000 }, | |
| initialize: function(show, hide, options) { | |
| this.setOptions(options); | |
| this.show = show; | |
| this.hide = hide; | |
| this.enabled = false; | |
| window.addEvents({ | |
| 'click': this.reset.bind(this), | |
| 'keypress': this.reset.bind(this), | |
| 'mousemove': this.reset.bind(this) | |
| }); | |
| this.start(); | |
| }, | |
| start: function() { this.clearID = this.display.delay(this.options.time, this); }, | |
| reset: function() { | |
| $clear(this.clearID); | |
| if (this.enabled) { | |
| this.hide(); | |
| this.enabled = false; | |
| this.fireEvent('hide'); | |
| } | |
| this.start(); | |
| this.fireEvent('reset'); | |
| }, | |
| display: function() { | |
| this.show(); | |
| this.enabled = true; | |
| this.fireEvent('show'); | |
| } | |
| }); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment