Last active
December 18, 2015 13:10
-
-
Save voising/5788363 to your computer and use it in GitHub Desktop.
COFFESCRIPT : Ergonomics on forms
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
.focus { | |
color: #DEDEDE; | |
} | |
.hidden { | |
visibility: hidden; | |
} |
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
refreshErgo = -> | |
$(".ergo input[type=\"text\"], .ergo textarea").each -> | |
label = $(this).parent().parent().find("label[for=\"" + @id + "\"]") | |
$(this).off("focus").on "focus", -> | |
label.addClass "focus" | |
$(this).off("keydown").on "keydown", -> | |
label.addClass "hidden" | |
$(this).off("blur").on "blur", -> | |
label.removeClass "focus" | |
if @value is "" | |
label.removeClass "hidden" | |
else | |
label.addClass "hidden" | |
label.addClass "hidden" if @value isnt "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment