<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Dialog - Modal form</title>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
   
    <link rel="stylesheet" type="text/css" href="<?php echo CDN_URL;?>css/jquery-ui.css" />
    <link rel="stylesheet" type="text/css" href="<?php echo CDN_URL;?>css/ui.jqgrid.css" />
    <link rel="stylesheet" type="text/css" href="<?php echo CDN_URL;?>css/jquery.jqplot.min.css" />
     <link rel="stylesheet" type="text/css" href="<?php echo CDN_URL;?>css/style.css" />
    <link rel="stylesheet" href="<?php echo CDN_URL; ?>css/jquery-ui.css">
    <link rel="stylesheet" href="<?php echo CDN_URL; ?>css/ui.jqgrid.css">
    <link rel="stylesheet" href="<?php echo CDN_URL; ?>css/jquery.jqplot.min.css">

  
  
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
    <script src="<?php echo CDN_URL; ?>js/jquery-1.11.0.min.js"></script>
    <script src="<?php echo CDN_URL; ?>js/jquery-ui.js"></script>
    <script src="<?php echo CDN_URL; ?>js/i18n/grid.locale-en.js"></script>
    <script src="<?php echo CDN_URL; ?>js/jquery.jqGrid.min.js"></script>
    <script src="<?php echo CDN_URL; ?>js/jquery.jqplot.min.js"></script>
    <script src="<?php echo CDN_URL; ?>js/plugins/jqplot.barRenderer.min.js"></script>
    <script src="<?php echo CDN_URL; ?>js/plugins/jqplot.pieRenderer.min.js"></script>
    <script src="<?php echo CDN_URL; ?>js/plugins/jqplot.categoryAxisRenderer.min.js"></script>
    <script src="<?php echo CDN_URL; ?>js/plugins/jqplot.pointLabels.min.js"></script>

 
<style>
body { font-size: 62.5%; }
label, input { display:block; }
input.text { margin-bottom:12px; width:95%; padding: .4em; }
fieldset { padding:0; border:0; margin-top:25px; }
h1 { font-size: 1.2em; margin: .6em 0; }

 
</style>



<script>
$(function() {


	var dialog, form,
	// From http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#e-mail-state-%28type=email%29
	emailRegex = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,
	name = $( "#name" ),
	email = $( "#email" ),
	password = $( "#password" ),
	allFields = $( [] ).add( name ).add( email ).add( password ),
	tips = $( ".validateTips" );
	
	
	
	function updateTips( t ) {
		tips.text( t ).addClass( "ui-state-highlight" );
		setTimeout(function() {	tips.removeClass( "ui-state-highlight", 1500 );	}, 500 );
	}
	
	function checkLength( o, n, min, max ) {
		if ( o.val().length > max || o.val().length < min ) {
			o.addClass( "ui-state-error" );
			updateTips( "Length of " + n + " must be between " +
			min + " and " + max + "." );
			return false;
		} else {
			return true;
		}
	}
	function checkRegexp( o, regexp, n ) {
		if ( !( regexp.test( o.val() ) ) ) {
			o.addClass( "ui-state-error" );
			updateTips( n );
			return false;
		} else {
			return true;
		}
	}


	function addParticipant() {
		var valid = true;
		allFields.removeClass( "ui-state-error" );
		valid = valid && checkLength( name, "username", 1, 12 ); 
		valid = valid && checkRegexp( name, /^[a-z]([0-9a-z_\s])+$/i, "Username may consist of a-z, 0-9, underscores, spaces and must begin with a letter." );
	 
		if ( valid ) {
		//	alert("Name is"+name.val());
			dialog.dialog( "close" );
		}
		return valid;
	}


	dialog = $( "#dialog-form" ).dialog({
		autoOpen: false,
		height: 170,
		width: 300,
		modal: true,
		buttons: {
			"Save": addParticipant,
			Cancel: function() {
				dialog.dialog( "close" );
			}
		},
		close: function() {
			form[ 0 ].reset();
			allFields.removeClass( "ui-state-error" );
		}
	});



	form = dialog.find( "form" ).on( "submit", function( event ) {
		event.preventDefault();
		addParticipant();
	});


	$( "#create-participant" ).button().on( "click", function() {
		dialog.dialog( "open" );
	});
});
</script>




</head>
<body>
<div id="dialog-form" title="Create new Participant" style="display:none">
 
<form>
<fieldset>
<label for="name"><?php echo __("LBL_NAME"); ?></label>
<input type="text" name="name" id="name" value="" class="text ui-widget-content ui-corner-all">
 
 
<input type="submit" tabindex="-1" style="position:absolute; top:-1000px">
</fieldset>
</form>
</div>
<div id="users-contain" class="ui-widget">
 
</div>
<button id="create-participant"><?php echo __("LBL_CREATE_PARTICIPANT"); ?></button>
</body>
</html>