Team:Queens Canada/sandbox

From 2012.igem.org

(Difference between revisions)
(Replaced content with "{{Template:Queens_Canada/Header}} <html> <head> <script type="text/javascript" src="http://2012.igem.org/Team:Queens_Canada/Javascript/Mousehold?action=raw&ctype=text/js"></s...")
Line 1: Line 1:
-
{{Template:Queens_Canada/Header}}
 
<html>
<html>
<head>
<head>
-
<script type="text/javascript" src="http://2012.igem.org/Team:Queens_Canada/Javascript/Mousehold?action=raw&ctype=text/js"></script>
+
<script type="text/javascript">
 +
/**
 +
* jQuery mousehold plugin - fires an event while the mouse is clicked down.
 +
* Additionally, the function, when executed, is passed a single
 +
* argument representing the count of times the event has been fired during
 +
* this session of the mouse hold.
 +
*
 +
* @author Remy Sharp (leftlogic.com)
 +
* @date 2006-12-15
 +
* @example $("img").mousehold(200, function(i){  })
 +
* @desc Repeats firing the passed function while the mouse is clicked down
 +
*
 +
* @name mousehold
 +
* @type jQuery
 +
* @param Number timeout The frequency to repeat the event in milliseconds
 +
* @param Function fn A function to execute
 +
* @cat Plugin
 +
*/
 +
 
 +
jQuery.fn.mousehold = function(timeout, f) {
 +
if (timeout && typeof timeout == 'function') {
 +
f = timeout;
 +
timeout = 100;
 +
}
 +
if (f && typeof f == 'function') {
 +
var timer = 0;
 +
var fireStep = 0;
 +
return this.each(function() {
 +
jQuery(this).mousedown(function() {
 +
fireStep = 1;
 +
var ctr = 0;
 +
var t = this;
 +
timer = setInterval(function() {
 +
ctr++;
 +
f.call(t, ctr);
 +
fireStep = 2;
 +
}, timeout);
 +
})
 +
 
 +
clearMousehold = function() {
 +
clearInterval(timer);
 +
if (fireStep == 1) f.call(this, 1);
 +
fireStep = 0;
 +
}
 +
 +
jQuery(this).mouseout(clearMousehold);
 +
jQuery(this).mouseup(clearMousehold);
 +
})
 +
}
 +
}
 +
 
 +
</script>
<script type="text/javascript">
<script type="text/javascript">
Line 18: Line 68:
</head>
</head>
<Body>
<Body>
-
<div id="upbuttontwo">
+
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
 +
 
 +
 
 +
<div id="upbuttontwo" style="bottom:0px; position:fixed;">
up
up
</div>
</div>
 +
 +
<script>
 +
    $("#upbutton").mousehold(function(){
 +
   
 +
   
 +
window.scrollBy(0,-10);   
 +
 +
});
 +
 +
 +
 +
   
 +
</script>
</body>
</body>
</html>
</html>

Revision as of 13:44, 7 June 2012












































up