-
-
Save jtulach/7212206 to your computer and use it in GitHub Desktop.
Spinning Duke by Ivar
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title></title> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
<style type="text/css"> | |
@keyframes spin { | |
0% { transform: rotate(0deg); } | |
100% { transform: rotate(360deg); } | |
} | |
.rotate { | |
animation-name: spin; | |
animation-duration: 3s; | |
animation-iteration-count: infinite; | |
animation-direction: alternate; | |
} | |
#scene { | |
position: relative; | |
top: 60px; | |
text-align: center; | |
} | |
#words span { | |
border: 1px solid #ccc; | |
background: rgba(255,255,155,0.8); | |
text-align: center; | |
font-size: 30px; | |
-webkit-box-shadow: inset 0 0 40px rgba(0,0,0,0.4); | |
position: absolute; | |
} | |
#words span:nth-child(1) { left: 45%; top: 0px; } | |
#words span:nth-child(2) { left: 25%; top: 100px; } | |
#words span:nth-child(3) { left: 65%; top: 100px; } | |
#words span:nth-child(4) { left: 10%; top: 200px; } | |
#words span:nth-child(5) { left: 45%; top: 200px; } | |
#words span:nth-child(6) { left: 80%; top: 200px; } | |
</style> | |
</head> | |
<body> | |
<h1>Spinning Duke</h1> | |
<br> | |
<button data-bind="enable: !on(), click: $root.turnOn">Start</button> | |
<button data-bind="enable: on, click: $root.turnOff">Stop</button> | |
<button data-bind="enable: true, click: $root.switchDuke, text: $root.buttonText" ></button> | |
<div id="scene"> | |
<img data-bind="attr: {'src' : $root.image, 'alt': '', 'height':200, 'width': 200}, css: {'rotate' : $root.on }"/> | |
</div> | |
</body> | |
</html> |
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
package dew.demo.duke2brwsr; | |
import net.java.html.json.*; | |
@Model(className = "Data", properties = { | |
@Property(name = "image", type = String.class), | |
@Property(name = "buttonText", type =String.class), | |
@Property(name = "on", type = boolean.class) | |
}) | |
class Duke2Brwsr { | |
static { | |
Data model = new Data(); | |
model.setButtonText("Krakow Duke"); | |
model.setImage("http://www.agilejava.eu/duke2brwser/Juggler.gif"); | |
model.applyBindings(); | |
} | |
@Function | |
static void switchDuke(Data model) { | |
if(model.getImage().equals("http://www.agilejava.eu/duke2brwser/Juggler.gif")) { | |
model.setImage("http://www.agilejava.eu/duke2brwser/krakowduke.jpg"); | |
model.setButtonText("Normal Duke"); | |
} else { | |
model.setImage("http://www.agilejava.eu/duke2brwser/Juggler.gif"); | |
model.setButtonText("Krakow Duke"); | |
} | |
} | |
@Function | |
static void turnOn(Data model) { | |
model.setOn(true); | |
} | |
@Function | |
static void turnOff(Data model) { | |
model.setOn(false); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
First ever DEW written by somebody else than me. Originally written by Ivar Grimstad to win the http://practical.apidesign.org book at JDD Krakow conference (http://13.jdd.org.pl) and published here: http://www.agilejava.eu/duke2brwser/
On Oct 29, 2013 Ivar converted his sample into a gist (https://gist.github.com/ivargrimstad/7211752). I polished it a bit and you can play with it as following DEW: http://dew.apidesign.org/dew/#7212206