<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>arrived demo</title>
<link rel="stylesheet" href="//code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src="//code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="//code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<style>
td {
vertical-align: middle;
}
tr td:first-child {
width: 500px;
padding: 20px;
}
.box {
width: 200px;
height: 100%;
}
.arrivalIndicator{
position:relative;
background: #e1e1e1;
display:inline-block;
overflow:hidden;
cursor:pointer;
}
.arrivalIndicator:before{
content:'';
position:absolute;
top:0;left:50%;
width:0;
height:100%;
background:green;
z-index:-1;
transition: left 1.05s, width 1.05s, .6s transform .2s;
transition: left 1.05s, width 1.05s, .6s transform .2s;
transition: left 1.05s, width 1.05s, .6s transform .2s;
}
.fillGreen:before{
width:100%;
left: 0%;
background:green;
z-index:10;
}
.fillGray:before{
width:100%;
left: 0%;
background:#e1e1e1;
z-index:10;
}
.arrived {
background: green;
}
</style>
</head>
<body>
<div data-role="page" id="page1">
<div data-role="header">
<h1>My page</h1>
</div>
<div role="main" class="ui-content">
<table>
<tr>
<td>Person's name</td>
<td id="t1" class="box arrivalIndicator"></div></td>
</tr>
<tr>
<td>Someone elses name</td>
<td class="box arrivalIndicator"></td>
</tr>
</table>
</div>
</div>
<script>
var tapTime = 0;
$(document).on("pagecreate","#page1", function(){
$('.arrivalIndicator').on('vmousedown vmouseup', function (event) {
if (event.type == 'vmousedown') {
tapTime = new Date().getTime();
if($(this).hasClass('arrived')){
$(this).addClass('fillGray');
} else {
//if not arrived
$(this).addClass('fillGreen');
}
} else {
//event.type == 'vmouseup'
//here you can check how long the `tap` was to determine what do do
var duration = (new Date().getTime() - tapTime);
if (duration > 1000) {
//this is a tap-hold
if($(this).hasClass('arrived')){
//if already marked as arrived
$(this).removeClass('arrived');
} else {
$(this).addClass('arrived');
}
localStorage.setItem('t1','Y');
}
//this is a tap
$(this).removeClass('fillGray');
$(this).removeClass('fillGreen');
}
});
});
</script>
</body>
</html>
Output
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |