Created
April 3, 2011 23:30
-
-
Save cognominal/900921 to your computer and use it in GitHub Desktop.
Want to work both on node and in a browser. my problem was the scope of window and $
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 Cursor | |
constructor: (dadDiv) -> | |
dadDiv.append $ "<div class='cursor'></div>" | |
@visible = false | |
toggle : -> | |
cursor.style.visibility = | |
if @visible = !@visible then 'visible' else 'hidden' | |
setTimeout toggle, 500 | |
main = -> | |
$ "body" | |
c = new Cursor $ "body" | |
console.log ($ ".cursor").length | |
if window? | |
main() | |
else | |
{ jsdom } = require 'jsdom' | |
this.$ = require 'jquery' | |
this.window = jsdom().createWindow() | |
main.call(window) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment