forked from saucelabs/the-internet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:tourdedave/the-internet into rele…
…ase/0.39.0
- Loading branch information
Showing
3 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'></script> | ||
<script> | ||
function onClick (){ | ||
disableButton(); | ||
clearMessage(); | ||
showDelay(); | ||
pauseThenToggleControls(); | ||
}; | ||
|
||
function disableButton() { | ||
$('#btn').attr("disabled",true); | ||
}; | ||
|
||
function clearMessage() { | ||
if ($('#message').length) { | ||
$('#message').first().remove(); | ||
} | ||
}; | ||
|
||
function showDelay() { | ||
$('#btn').after("<div id='loading'>Wait for it... <img src='/img/ajax-loader.gif'></div></br>"); | ||
}; | ||
|
||
function pauseThenToggleControls() { | ||
setTimeout(function() { | ||
toggleControls(); | ||
} , 3000 ); | ||
}; | ||
|
||
function toggleControls() { | ||
var btn = $('#btn').first(); | ||
var check = $('#checkbox').first(); | ||
var load = $('#loading'); | ||
if ( btn.text() == "Remove") { | ||
check.remove(); | ||
btn.text("Add"); | ||
btn.after("<p id='message'>It's gone!</p>"); | ||
btn.attr("disabled", false); | ||
load.hide(); | ||
}else{ | ||
btn.text("Remove"); | ||
btn.after("<div id='checkbox'><input type='checkbox' id='checkbox'> A checkbox </div>"); | ||
btn.after("<p id='message'>It's back!</p>"); | ||
btn.attr("disabled", false); | ||
load.hide(); | ||
} | ||
}; | ||
</script> | ||
<div class="example"> | ||
<h4>Dynamic Controls</h4> | ||
<p>This example demonstrates when controls (e.g., checkbox, option button, etc.) are added or removed asynchronously.</p> | ||
|
||
<form > | ||
<button autocomplete="off" type="button" id="btn" onclick="onClick()" >Remove</button> | ||
<div id="checkbox"> | ||
<input type="checkbox" id="checkbox" > A checkbox | ||
</div> | ||
|
||
</form> | ||
<div> |
This file contains 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