Skip to content

Commit

Permalink
Dialog demos: Coding standards.
Browse files Browse the repository at this point in the history
  • Loading branch information
scottgonzalez committed Sep 10, 2010
1 parent 6df7729 commit 98fb8c8
Show file tree
Hide file tree
Showing 7 changed files with 157 additions and 168 deletions.
48 changes: 24 additions & 24 deletions demos/dialog/animated.html
Original file line number Original file line Diff line number Diff line change
@@ -1,34 +1,34 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="utf-8">
<title>jQuery UI Dialog - Animation</title> <title>jQuery UI Dialog - Animation</title>
<link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" /> <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
<script type="text/javascript" src="../../jquery-1.4.2.js"></script> <script src="../../jquery-1.4.2.js"></script>
<script type="text/javascript" src="../../external/jquery.bgiframe-2.1.1.js"></script> <script src="../../external/jquery.bgiframe-2.1.1.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.core.js"></script> <script src="../../ui/jquery.ui.core.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script> <script src="../../ui/jquery.ui.widget.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.mouse.js"></script> <script src="../../ui/jquery.ui.mouse.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.draggable.js"></script> <script src="../../ui/jquery.ui.draggable.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.position.js"></script> <script src="../../ui/jquery.ui.position.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.resizable.js"></script> <script src="../../ui/jquery.ui.resizable.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.dialog.js"></script> <script src="../../ui/jquery.ui.dialog.js"></script>
<script type="text/javascript" src="../../ui/jquery.effects.core.js"></script> <script src="../../ui/jquery.effects.core.js"></script>
<script type="text/javascript" src="../../ui/jquery.effects.blind.js"></script> <script src="../../ui/jquery.effects.blind.js"></script>
<script type="text/javascript" src="../../ui/jquery.effects.explode.js"></script> <script src="../../ui/jquery.effects.explode.js"></script>
<link type="text/css" href="../demos.css" rel="stylesheet" /> <link rel="stylesheet" href="../demos.css">
<script type="text/javascript"> <script>
// increase the default animation speed to exaggerate the effect // increase the default animation speed to exaggerate the effect
$.fx.speeds._default = 1000; $.fx.speeds._default = 1000;
$(function() { $(function() {
$('#dialog').dialog({ $( "#dialog" ).dialog({
autoOpen: false, autoOpen: false,
show: 'blind', show: "blind",
hide: 'explode' hide: "explode"
}); });

$('#opener').click(function() { $( "#opener" ).click(function() {
$('#dialog').dialog('open'); $( "#dialog" ).dialog( "open" );
return false; return false;
}); });
}); });
Expand All @@ -46,10 +46,10 @@


</div><!-- End demo --> </div><!-- End demo -->


<div class="demo-description">


<p>Dialogs may be animated by specifying an effect for the show and/or hide properties. You must include the individual effects file for any effects you would like to use.</p>


<div class="demo-description">
<p>Dialogs may be animated by specifying an effect for the show and/or hide properties. You must include the individual effects file for any effects you would like to use.</p>
</div><!-- End demo-description --> </div><!-- End demo-description -->


</body> </body>
Expand Down
32 changes: 16 additions & 16 deletions demos/dialog/default.html
Original file line number Original file line Diff line number Diff line change
@@ -1,22 +1,22 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="utf-8">
<title>jQuery UI Dialog - Default functionality</title> <title>jQuery UI Dialog - Default functionality</title>
<link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" /> <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
<script type="text/javascript" src="../../jquery-1.4.2.js"></script> <script src="../../jquery-1.4.2.js"></script>
<script type="text/javascript" src="../../external/jquery.bgiframe-2.1.1.js"></script> <script src="../../external/jquery.bgiframe-2.1.1.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.core.js"></script> <script src="../../ui/jquery.ui.core.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script> <script src="../../ui/jquery.ui.widget.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.mouse.js"></script> <script src="../../ui/jquery.ui.mouse.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.draggable.js"></script> <script src="../../ui/jquery.ui.draggable.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.position.js"></script> <script src="../../ui/jquery.ui.position.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.resizable.js"></script> <script src="../../ui/jquery.ui.resizable.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.dialog.js"></script> <script src="../../ui/jquery.ui.dialog.js"></script>
<link type="text/css" href="../demos.css" rel="stylesheet" /> <link rel="stylesheet" href="../demos.css">
<script type="text/javascript"> <script>
$(function() { $(function() {
$("#dialog").dialog(); $( "#dialog" ).dialog();
}); });
</script> </script>
</head> </head>
Expand Down Expand Up @@ -44,10 +44,10 @@


</div><!-- End demo --> </div><!-- End demo -->


<div class="demo-description">


<p>The basic dialog window is an overlay positioned within the viewport and is protected from page content (like select elements) shining through with an iframe. It has a title bar and a content area, and can be moved, resized and closed with the 'x' icon by default.</p>


<div class="demo-description">
<p>The basic dialog window is an overlay positioned within the viewport and is protected from page content (like select elements) shining through with an iframe. It has a title bar and a content area, and can be moved, resized and closed with the 'x' icon by default.</p>
</div><!-- End demo-description --> </div><!-- End demo-description -->


</body> </body>
Expand Down
4 changes: 2 additions & 2 deletions demos/dialog/index.html
Original file line number Original file line Diff line number Diff line change
@@ -1,9 +1,9 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="utf-8">
<title>jQuery UI Dialog Demos</title> <title>jQuery UI Dialog Demos</title>
<link type="text/css" href="../demos.css" rel="stylesheet" /> <link rel="stylesheet" href="../demos.css">
</head> </head>
<body> <body>


Expand Down
40 changes: 20 additions & 20 deletions demos/dialog/modal-confirmation.html
Original file line number Original file line Diff line number Diff line change
@@ -1,34 +1,34 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="utf-8">
<title>jQuery UI Dialog - Modal confirmation</title> <title>jQuery UI Dialog - Modal confirmation</title>
<link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" /> <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
<script type="text/javascript" src="../../jquery-1.4.2.js"></script> <script src="../../jquery-1.4.2.js"></script>
<script type="text/javascript" src="../../external/jquery.bgiframe-2.1.1.js"></script> <script src="../../external/jquery.bgiframe-2.1.1.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.core.js"></script> <script src="../../ui/jquery.ui.core.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script> <script src="../../ui/jquery.ui.widget.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.mouse.js"></script> <script src="../../ui/jquery.ui.mouse.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.button.js"></script> <script src="../../ui/jquery.ui.button.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.draggable.js"></script> <script src="../../ui/jquery.ui.draggable.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.position.js"></script> <script src="../../ui/jquery.ui.position.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.dialog.js"></script> <script src="../../ui/jquery.ui.dialog.js"></script>
<link type="text/css" href="../demos.css" rel="stylesheet" /> <link rel="stylesheet" href="../demos.css">
<script type="text/javascript"> <script>
$(function() { $(function() {
// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore! // a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
$("#dialog").dialog("destroy"); $( "#dialog" ).dialog( "destroy" );


$("#dialog-confirm").dialog({ $( "#dialog-confirm" ).dialog({
resizable: false, resizable: false,
height:140, height:140,
modal: true, modal: true,
buttons: { buttons: {
'Delete all items': function() { "Delete all items": function() {
$(this).dialog('close'); $( this ).dialog( "close" );
}, },
Cancel: function() { Cancel: function() {
$(this).dialog('close'); $( this ).dialog( "close" );
} }
} }
}); });
Expand Down Expand Up @@ -59,10 +59,10 @@


</div><!-- End demo --> </div><!-- End demo -->


<div class="demo-description">


<p>Confirm an action that may be destructive or important. Set the <code>modal</code> option to true, and specify primary and secondary user actions with the <code>buttons</code> option.</p>


<div class="demo-description">
<p>Confirm an action that may be destructive or important. Set the <code>modal</code> option to true, and specify primary and secondary user actions with the <code>buttons</code> option.</p>
</div><!-- End demo-description --> </div><!-- End demo-description -->


</body> </body>
Expand Down
128 changes: 59 additions & 69 deletions demos/dialog/modal-form.html
Original file line number Original file line Diff line number Diff line change
@@ -1,22 +1,22 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="utf-8">
<title>jQuery UI Dialog - Modal form</title> <title>jQuery UI Dialog - Modal form</title>
<link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" /> <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
<script type="text/javascript" src="../../jquery-1.4.2.js"></script> <script src="../../jquery-1.4.2.js"></script>
<script type="text/javascript" src="../../external/jquery.bgiframe-2.1.1.js"></script> <script src="../../external/jquery.bgiframe-2.1.1.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.core.js"></script> <script src="../../ui/jquery.ui.core.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script> <script src="../../ui/jquery.ui.widget.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.mouse.js"></script> <script src="../../ui/jquery.ui.mouse.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.button.js"></script> <script src="../../ui/jquery.ui.button.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.draggable.js"></script> <script src="../../ui/jquery.ui.draggable.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.position.js"></script> <script src="../../ui/jquery.ui.position.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.resizable.js"></script> <script src="../../ui/jquery.ui.resizable.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.dialog.js"></script> <script src="../../ui/jquery.ui.dialog.js"></script>
<script type="text/javascript" src="../../ui/jquery.effects.core.js"></script> <script src="../../ui/jquery.effects.core.js"></script>
<link type="text/css" href="../demos.css" rel="stylesheet" /> <link rel="stylesheet" href="../demos.css">
<style type="text/css"> <style>
body { font-size: 62.5%; } body { font-size: 62.5%; }
label, input { display:block; } label, input { display:block; }
input.text { margin-bottom:12px; width:95%; padding: .4em; } input.text { margin-bottom:12px; width:95%; padding: .4em; }
Expand All @@ -27,97 +27,90 @@
div#users-contain table td, div#users-contain table th { border: 1px solid #eee; padding: .6em 10px; text-align: left; } div#users-contain table td, div#users-contain table th { border: 1px solid #eee; padding: .6em 10px; text-align: left; }
.ui-dialog .ui-state-error { padding: .3em; } .ui-dialog .ui-state-error { padding: .3em; }
.validateTips { border: 1px solid transparent; padding: 0.3em; } .validateTips { border: 1px solid transparent; padding: 0.3em; }

</style> </style>
<script type="text/javascript"> <script>
$(function() { $(function() {
// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore! // a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
$("#dialog").dialog("destroy"); $( "#dialog" ).dialog( "destroy" );


var name = $("#name"), var name = $( "#name" ),
email = $("#email"), email = $( "#email" ),
password = $("#password"), password = $( "#password" ),
allFields = $([]).add(name).add(email).add(password), allFields = $( [] ).add( name ).add( email ).add( password ),
tips = $(".validateTips"); tips = $( ".validateTips" );


function updateTips(t) { function updateTips( t ) {
tips tips
.text(t) .text( t )
.addClass('ui-state-highlight'); .addClass( "ui-state-highlight" );
setTimeout(function() { setTimeout(function() {
tips.removeClass('ui-state-highlight', 1500); tips.removeClass( "ui-state-highlight", 1500 );
}, 500); }, 500 );
} }


function checkLength(o,n,min,max) { function checkLength( o, n, min, max ) {

if ( o.val().length > max || o.val().length < min ) { if ( o.val().length > max || o.val().length < min ) {
o.addClass('ui-state-error'); o.addClass( "ui-state-error" );
updateTips("Length of " + n + " must be between "+min+" and "+max+"."); updateTips( "Length of " + n + " must be between " +
min + " and " + max + "." );
return false; return false;
} else { } else {
return true; return true;
} }

} }


function checkRegexp(o,regexp,n) { function checkRegexp( o, regexp, n ) {

if ( !( regexp.test( o.val() ) ) ) { if ( !( regexp.test( o.val() ) ) ) {
o.addClass('ui-state-error'); o.addClass( "ui-state-error" );
updateTips(n); updateTips( n );
return false; return false;
} else { } else {
return true; return true;
} }

} }


$("#dialog-form").dialog({ $( "#dialog-form" ).dialog({
autoOpen: false, autoOpen: false,
height: 300, height: 300,
width: 350, width: 350,
modal: true, modal: true,
buttons: { buttons: {
'Create an account': function() { "Create an account": function() {
var bValid = true; var bValid = true;
allFields.removeClass('ui-state-error'); allFields.removeClass( "ui-state-error' );
bValid = bValid && checkLength(name,"username",3,16); bValid = bValid && checkLength( name, "username", 3, 16 );
bValid = bValid && checkLength(email,"email",6,80); bValid = bValid && checkLength( email, "email", 6, 80 );
bValid = bValid && checkLength(password,"password",5,16); bValid = bValid && checkLength( password, "password", 5, 16 );


bValid = bValid && checkRegexp(name,/^[a-z]([0-9a-z_])+$/i,"Username may consist of a-z, 0-9, underscores, begin with a letter."); bValid = bValid && checkRegexp( name, /^[a-z]([0-9a-z_])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter." );
// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/ // From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
bValid = bValid && checkRegexp(email,/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i,"eg. ui@jquery.com"); bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "eg. ui@jquery.com" );
bValid = bValid && checkRegexp(password,/^([0-9a-zA-Z])+$/,"Password field only allow : a-z 0-9"); bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );

if (bValid) { if ( bValid ) {
$('#users tbody').append('<tr>' + $( "#users tbody" ).append( "<tr>" +
'<td>' + name.val() + '</td>' + "<td>" + name.val() + "</td>" +
'<td>' + email.val() + '</td>' + "<td>" + email.val() + "</td>" +
'<td>' + password.val() + '</td>' + "<td>" + password.val() + "</td>" +
'</tr>'); "</tr>" );
$(this).dialog('close'); $( this ).dialog( "close" );
} }
}, },
Cancel: function() { Cancel: function() {
$(this).dialog('close'); $( this ).dialog( "close" );
} }
}, },
close: function() { close: function() {
allFields.val('').removeClass('ui-state-error'); allFields.val( "" ).removeClass( "ui-state-error" );
} }
}); });



$( "#create-user" )

$('#create-user')
.button() .button()
.click(function() { .click(function() {
$('#dialog-form').dialog('open'); $( "#dialog-form" ).dialog( "open" );
}); });

}); });
</script> </script>
</head> </head>
Expand All @@ -142,10 +135,7 @@




<div id="users-contain" class="ui-widget"> <div id="users-contain" class="ui-widget">

<h1>Existing Users:</h1>
<h1>Existing Users:</h1>


<table id="users" class="ui-widget ui-widget-content"> <table id="users" class="ui-widget ui-widget-content">
<thead> <thead>
<tr class="ui-widget-header "> <tr class="ui-widget-header ">
Expand All @@ -167,10 +157,10 @@ <h1>Existing Users:</h1>


</div><!-- End demo --> </div><!-- End demo -->


<div class="demo-description">


<p>Use a modal dialog to require that the user enter data during a multi-step process. Embed form markup in the content area, set the <code>modal</code> option to true, and specify primary and secondary user actions with the <code>buttons</code> option.</p>


<div class="demo-description">
<p>Use a modal dialog to require that the user enter data during a multi-step process. Embed form markup in the content area, set the <code>modal</code> option to true, and specify primary and secondary user actions with the <code>buttons</code> option.</p>
</div><!-- End demo-description --> </div><!-- End demo-description -->


</body> </body>
Expand Down
Loading

0 comments on commit 98fb8c8

Please sign in to comment.