public
Created

actionQueue in practice

  • Download Gist
actionQueue.html
HTML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
<!DOCTYPE html>
<html>
<head>
<title>Like Button</title>
<!-- just getting this stuff out of the way -->
<style type="text/css" media="screen">
body {width: 750px;margin: 0 auto;}
p { margin: 10px 0 5px 0;}
.like-button{padding:5px 10px 5px 5px;border-radius:3px;background-color:#eee;color:#000;text-decoration:none;}
.like-button .star{text-shadow:magenta 1px 1px,magenta 2px 2px,magenta 3px 3px;}
.un-liked .star,.liked:hover .star{color:#fff;}
.liked .star,.un-liked:hover .star{color:#000;}
</style>
<script type="text/javascript">
// build your global we can use to contain all our code
var A = {};
</script>
<!-- actionQueue -->
<script src="https://raw.github.com/gist/1398040/098b5d6388e0b05ca28bbf7e95849fa208b36f17/actionQueue.js" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8">
A.actionQueue.register(
'like-button',
{
interim: function(id){
var element = document.getElementById(id);
element.className = 'like-button liked';
},
cleanup: function(id){
var element = document.getElementById('like-button-text');
element.innerHTML = 'Done!';
}
},
'like-handler'
);
</script>
 
</head>
<body>
<h1>A Simple Like Button</h1>
<p>
<a href='#' id='like-button' class='like-button un-liked' onclick='A.actionQueue.queue_click(this.id);'>
<span class='star'>&#9733;</span>
<span id='like-button-text' class='text'>Like</span>
</a>
</p>
<br/><br/><br/><br/>
<p><a href='#' onclick='A.actionQueue.module_loaded("like-handler");'>Load the module</a>
<div class='qunit-output'>
<h1 id="qunit-header">QUnit example</h1>
<h2 id="qunit-banner"></h2>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
</div>
</body>
</html>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.