Skip to content

Instantly share code, notes, and snippets.

Created May 9, 2013 11:11
Show Gist options
  • Save anonymous/5546895 to your computer and use it in GitHub Desktop.
Save anonymous/5546895 to your computer and use it in GitHub Desktop.
$ ->
class AjaxDateUpdater
constructor: (@id, @url) ->
$(@id).hover hover_in, hover_out
@old = ""
@has_focus = false
hover_in = () ->
unless @has_focus
@old = $(this).html()
width = $(this).width()
$(this).html ""
props = { "type": 'name'
"name": @id
"value": @old
"style": "width: " + width + "px"
}
input = $( "<input>", props)
input.appendTo this
input.focusin grab_focus
input.focusout leave_focus
hover_out = () ->
unless @has_focus
$(this).html @old
grab_focus = () =>
console.log "grabfocus"
@has_focus = true
leave_focus = () =>
@has_focus = false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment