Are you as tired as I am of "Are you sure?" dialog boxes to make sure users don't hurt themselves? Then maybe you are in the right place. This plugin makes the user hold a button down (or any container element) for a priod of time before acting. This is my first attempt at writing a jQuery plugin. I am VERY much open to suggestions.
Also, I totally stole this idea from someone else but I can't remember who it was or where I saw it or even when.
-
Include jQuery of course:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
-
Include plugin's code:
<script src="jquery.pressAndHold.js"></script>
-
Call the plugin:
$("#element").pressAndHold();
- holdTime:
The amount of time the user needs to hold the mouse button. - progressIndicatorRemoveDelay:
Sets a delay on removing the progress indicator. Might be a useful hint to help teach the user how to use the control. - progressIndicatorColor:
Color of the progress bar. - progressIndicatorOpacity:
Opacity of the progress bar.
- start.pressAndHold:
The control has started the holding timer. - complete.pressAndHold
The control has completed holding for the entirity of the hold time. - end.pressAndHold
The control has completed holding regarless of duration.