Created
June 5, 2012 06:43
-
-
Save yctay/2873139 to your computer and use it in GitHub Desktop.
Simple Timer Controls, with Bootstrap v2 CSS styles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- Le CSS | |
| ============================== --> | |
| <link href="https://raw.github.com/twitter/bootstrap/master/docs/assets/css/bootstrap.css" rel="stylesheet" type="text/css"> | |
| <!-- Le HTML | |
| ============================== --> | |
| <div class="btn-group" id="timer-controls"> | |
| <a class="btn btn-success" id="timer-start" style="padding-left:47px;padding-right:48px;"><i class="icon-play icon-white"></i> Start</a> | |
| </div> | |
| <!-- Le jQuery include, from Google CDN with local fallback | |
| ============================== --> | |
| <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> | |
| <script type="text/javascript"> | |
| if (typeof jQuery == 'undefined') | |
| { | |
| document.write(unescape("%3Cscript src='js/jquery-1.7.2.min.js' type='text/javascript'%3E%3C/script%3E")); | |
| } | |
| </script> | |
| <!-- Le Timer Button Controls | |
| ============================== --> | |
| <script> | |
| var secondaryButtonsHTML = '<a class="btn btn-warning" id="timer-pause"><i class="icon-pause icon-white"></i> Pause</a>' + '<a class="btn btn-danger" id="timer-stop"><i class="icon-stop icon-white"></i> Stop</a>'; | |
| var resumeButtonHTML = '<a class="btn btn-success" id="timer-resume" style="padding-left:37px;padding-right:37px;"><i class="icon-play icon-white"></i> Resume</a>' | |
| var restartButtonHTML = '<a class="btn btn-success" id="timer-restart" style="padding-left:40px;padding-right:40px;"><i class="icon-play icon-white"></i> Restart</a>' | |
| function showTimerSecondaryButtons() { | |
| $(this).replaceWith( $(secondaryButtonsHTML)); | |
| } | |
| function showTimerResumeButton() { | |
| $(this).replaceWith( $(resumeButtonHTML)); | |
| $('#timer-stop').remove(); | |
| } | |
| function showTimerRestartButton() { | |
| $(this).replaceWith( $(restartButtonHTML)); | |
| $('#timer-pause').remove(); | |
| } | |
| $('#timer-start').on('click', showTimerSecondaryButtons); | |
| $('#timer-controls').on('click', '#timer-pause', showTimerResumeButton); | |
| $('#timer-controls').on('click', '#timer-stop', showTimerRestartButton); | |
| $('#timer-controls').on('click', '#timer-resume', showTimerSecondaryButtons); | |
| $('#timer-controls').on('click', '#timer-restart', showTimerSecondaryButtons); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment