Created
June 17, 2011 18:28
-
-
Save sido/1031973 to your computer and use it in GitHub Desktop.
Flashcard UI: Part 1
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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>ui.Flashcard</title> | |
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/pepper-grinder/jquery-ui.css"> | |
<link rel="stylesheet" href="ui.flashcard.css"> | |
<style> | |
body { font-family: sans-serif; } | |
#myFlashcard { margin: 2em auto; } | |
</style> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/modernizr/2.0.4/modernizr.min.js"></script> | |
</head> | |
<body> | |
<dl id="myFlashcard"> | |
<dt>Who ya gonna call?</dt> | |
<dd>GHOSTBUSTERS!</dd> | |
</dl> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script> | |
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.js"></script> | |
<script src="ui.flashcard.js"></script> | |
<script> | |
$("#myFlashcard").flashcard(); | |
</script> | |
</body> | |
</html> |
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
.ui-flashcard { | |
font-size: 1.6em; | |
height: 150px; | |
position: relative; | |
width: 350px; | |
} | |
.ui-flashcard dt, | |
.ui-flashcard dd { | |
height: 100%; | |
left: 0; | |
line-height: 150px; /* vertical align text */ | |
margin: 0; | |
padding: 0; | |
position: absolute; | |
text-align: center; | |
top: 0; | |
width: 100%; | |
} | |
.ui-flashcard dt { | |
cursor: pointer; | |
font-style: italic; | |
} | |
.ui-flashcard dd { | |
z-index: -1; | |
} |
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
(function($, undefined) { | |
$.widget("ui.flashcard", { | |
_create: function() { | |
var widget = this; | |
this.element | |
.addClass("ui-flashcard ui-widget") | |
.find("dt, dd") | |
.addClass("ui-widget-content ui-corner-all") | |
.end() | |
.bind("show", function() { | |
widget.show(); | |
}) | |
.find("dt") | |
.click(function() { | |
widget.element.trigger("show"); | |
}) | |
; | |
}, | |
show: function() { | |
this.element.find("dt").fadeOut("slow"); | |
}, | |
_destroy: function() { | |
this.element | |
.removeClass("ui-flashcard ui-widget ui-corner-all") | |
.find("dt, dd") | |
.addClass("ui-widget-content") | |
; | |
} | |
}); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment