Skip to content

Instantly share code, notes, and snippets.

@jraines
Created January 14, 2010 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jraines/277338 to your computer and use it in GitHub Desktop.
Save jraines/277338 to your computer and use it in GitHub Desktop.
## Explanatory screencast: http://www.youtube.com/jraines002#p/u/0/Vj5LjE4kuLM
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="My Gadget" height="30">
<Require feature="wave" />
<Require feature="locked-domain" />
<Require feature="dynamic-height" />
</ModulePrefs>
<Content type="html">
<![CDATA[
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
function stateUpdated() {
if (wave.getState().get('approver')) {
$('#message').hide();
$('#approval').append(wave.getState().get('approver', 'None'));
$('#approval').show();
}
else {
$('#message').append("Click to Approve");
}
}
function approve() {
var approver = wave.getViewer().getDisplayName();
var state = wave.getState().submitDelta({'approver' : approver});
}
function init() {
if (wave && wave.isInWaveContainer()) {
$(function() {
$('#approval').hide();
$('#message').click(approve);
wave.setStateCallback(stateUpdated);
});
}
}
gadgets.util.registerOnLoadHandler(init);
</script>
<div id="main" style="background:#DEDEDE; height:20px; width:90px">
<div id="message" style="curson:pointer;background:red"> </div>
<div id="approval" style="background:green"> Approved By: </div>
</div>
]]>
</Content>
</Module>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment