Skip to content

Commit

Permalink
Item10203: fixes for loading with ajax, css, wikiword validation
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk@10438 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
ArthurClemens authored and ArthurClemens committed Dec 29, 2010
1 parent a7f432b commit 8eafe6b
Showing 1 changed file with 81 additions and 63 deletions.
144 changes: 81 additions & 63 deletions TopicUserMappingContrib/data/System/DefaultUserRegistration.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ else=" %IF{"$REGISTRATION_DISABLED!='DISABLED'" then=" *%MAKETEXT{"Create your a
<!--
Show the form, if not REGISTRATION_DISABLED
-->
%INCLUDE{"%TOPIC%" section="form%REGISTRATION_DISABLED%" warn="on"}%<p>
%INCLUDE{"%TOPIC%" section="form%REGISTRATION_DISABLED%" warn="off"}%%INCLUDE{"%TOPIC%" section="resources%REGISTRATION_DISABLED%" warn="off"}%<p>
%MAKETEXT{"If you have any questions about registration, send an e-mail to [_1]." args="<a href='mailto:%WIKIWEBMASTER%?subject=%TOPIC%&#32;Question'>%WIKIWEBMASTER%</a>"}%
</p>
<verbatim class="foswikiHidden">
Expand All @@ -26,10 +26,14 @@ All the topic sections.
The main section is "form", INCLUDEd when REGISTRATION_DISABLED is not 'DISABLED'.
Other sections define the fields and extra info text.

%STARTSECTION{"form"}%<div class="registration"><form name="registration" id="foswikiRegistration" action="%SCRIPTURLPATH{"register"}%/%USERSWEB%/%HOMETOPIC%" method="post">

%STARTSECTION{"form"}%%INCLUDE{"%TOPIC%" section="htmlform%REGISTRATION_DISABLED%" warn="off"}%%INCLUDE{"%TOPIC%" section="resources%REGISTRATION_DISABLED%" warn="off"}%%ENDSECTION{"form"}%


%STARTSECTION{"htmlform"}%<div class="registration"><form name="registration" id="foswikiRegistration" action="%SCRIPTURLPATH{"register"}%/%USERSWEB%/%HOMETOPIC%" method="post">
<div class="foswikiFormSteps">
<div class="foswikiFormStep">
<p><em>%MAKETEXT{"Fields marked <span class='required'>*</span> are required"}%</em></p>
<p class="required"><em>%MAKETEXT{"Fields marked <span class='required'>*</span> are required"}%</em></p>
<ul>
<!-- REQUIRED FIELDS -->
%INCLUDE{"%TOPIC%" section="requiredField_firstName"}%
Expand All @@ -49,8 +53,9 @@ $REGISTRATIONGROUPTYPE = "automatic"' then='$percentINCLUDE{"%WEB%.%TOPIC%" sect
<input type="hidden" name="topic" value="%TOPIC%" />
<input type="hidden" name="action" value="register" />
</form>
</div>
%ADDTOZONE{
</div>%ENDSECTION{"htmlform"}%

%STARTSECTION{"resources"}%%ADDTOZONE{
"head"
id="UserRegistrationStyle"
text="<style type='text/css' media='all'>
Expand Down Expand Up @@ -84,13 +89,12 @@ text="<style type='text/css' media='all'>
}
.registration label.expl,
.registration label.error {
float:left;
width:40%;
padding:0 0 0 27px;
text-align:left;
display:block;
margin:0 0 0 43%;
padding:2px 0 2px 26px;
color:#666;
font-size:86%;
line-height:125%;
font-size:94%;
line-height:130%;
}
/* END horizontal layout */
.registration ul {
Expand Down Expand Up @@ -120,7 +124,7 @@ text="<style type='text/css' media='all'>
float:left;
margin-top:-2px;
}
.registration .required {
.registration span.required {
padding:0 .3em;
color:#f00;
}
Expand All @@ -137,71 +141,85 @@ text="<style type='text/css' media='all'>
</style>"
}%
%JQREQUIRE{"validate"}%
%TMPL:P{JavascriptFiles/foswikiString"}%
%ADDTOZONE{
"script"
id="UserRegistrationValidation"
text="<script type='text/javascript'>
$(document).ready(
function() {
$('#foswikiRegistration').validate({
rules: {
Twk1FirstName: 'required',
Twk1LastName: 'required',
Twk1WikiName: {
required: true,
remote: function() {
return '%SCRIPTURL{view}%/%WEB%/%TOPIC%?section=checkname;skin=text;name=' + $('#Twk1WikiName').val();
}
},
Twk1LoginName: 'required',
Twk1Email: {
required: true,
email: true
jQuery.validator.addMethod('wikiname', function(value, element) {
return foswiki.String.isWikiWord(value);
}, '%MAKETEXT{"This is not a valid Wiki name"}%');
$('#foswikiRegistration').livequery(function() {
$(this).validate({
submitHandler: function() {
alert('submitted!');
},
Twk1Password: {
required: true,
minlength: %QUERY{"{MinPasswordLength}"}%
},
Twk1Confirm: {
required: true,
minlength: %QUERY{"{MinPasswordLength}"}%,
equalTo: '#Twk1Password'
}
},
messages: {
Twk1FirstName: '%MAKETEXT{"Please enter your first name"}%',
Twk1LastName: '%MAKETEXT{"Please enter your last name"}%',
Twk1WikiName: {
required: '%MAKETEXT{"Please enter a valid Wiki name"}%',
remote: jQuery.format('{0} is already in use')
rules: {
Twk1FirstName: 'required',
Twk1LastName: 'required',
Twk1WikiName: {
required: true,
wikiname:true,
remote: {
url: '%SCRIPTURL{view}%/%WEB%/%TOPIC%',
type: 'post',
data: {
section: 'isWikiNameAvailable',
skin: 'text',
name: function() {
return $('#Twk1WikiName').val();
}
}
}
},
Twk1LoginName: 'required',
Twk1Email: {
required: true,
email: true
},
Twk1Password: {
required: true,
minlength: %QUERY{"{MinPasswordLength}"}%
},
Twk1Confirm: {
required: true,
minlength: %QUERY{"{MinPasswordLength}"}%,
equalTo: '#Twk1Password'
}
},
Twk1Email: '%MAKETEXT{"Please enter a valid email address"}%',
Twk1LoginName: '%MAKETEXT{"Please enter a login name"}%',
Twk1Password: {
required: '%MAKETEXT{"Please enter a password"}%',
minlength: '%MAKETEXT{"Your password must be at least [_1] characters long" args="%QUERY{"{MinPasswordLength}"}%"}%'
messages: {
Twk1FirstName: '%MAKETEXT{"Please enter your first name"}%',
Twk1LastName: '%MAKETEXT{"Please enter your last name"}%',
Twk1WikiName: {
required: '%MAKETEXT{"Please enter a Wiki name"}%',
remote: '%MAKETEXT{"This Wiki name is already in use"}%'
},
Twk1Email: '%MAKETEXT{"Please enter a valid email address"}%',
Twk1LoginName: '%MAKETEXT{"Please enter a login name"}%',
Twk1Password: {
required: '%MAKETEXT{"Please enter a password"}%',
minlength: '%MAKETEXT{"Your password must be at least [_1] characters long" args="%QUERY{"{MinPasswordLength}"}%"}%'
},
Twk1Confirm: {
required: '%MAKETEXT{"Please confirm your password"}%',
equalTo: '%MAKETEXT{"Please enter the same password as above"}%',
minlength: '%MAKETEXT{"Your password must be at least [_1] characters long" args="%QUERY{"{MinPasswordLength}"}%"}%'
}
},
Twk1Confirm: {
required: '%MAKETEXT{"Please confirm your password"}%',
equalTo: '%MAKETEXT{"Please enter the same password as above"}%',
minlength: '%MAKETEXT{"Your password must be at least [_1] characters long" args="%QUERY{"{MinPasswordLength}"}%"}%'
success: function(label) {
// remove generated label
label.remove();
}
},
success: function(label) {
// remove generated label
var generated = $(label).parent().attr('generated');
if (generated) {
generated.remove();
}
}
});
});
}
);
</script>"
requires="JQUERYPLUGIN::VALIDATE"
}%
%TMPL:P{JavascriptFiles/foswikiString"}%
%ENDSECTION{"form"}%
%ENDSECTION{"resources"}%



Expand All @@ -222,7 +240,7 @@ Required field last name
Required field wiki name

%STARTSECTION{"requiredField_wikiName"}%<li><label class="desc" for="Twk1WikiName"><span class="required">*</span>%MAKETEXT{"Wiki name"}%</label>
<div><input type="text" id="Twk1WikiName" name="Twk1WikiName" size="40" class="foswikiInputField" value="" tabindex="3" onblur="" /><label class="expl">%MAKETEXT{"Your name as displayed online. This must be a unique [[%SYSTEMWEB%.WikiName][Wiki name]]."}%</em></div></li>%ENDSECTION{"requiredField_wikiName"}%
<div><input type="text" id="Twk1WikiName" name="Twk1WikiName" size="40" class="foswikiInputField" value="" tabindex="3" onblur="" /><label class="expl">%MAKETEXT{"Your name as displayed online. This must be a unique [_1]" args="%POPUPWINDOW{"%SYSTEMWEB%.WikiName" label="%MAKETEXT{"Wiki name"}%"}%."}%</em></div></li>%ENDSECTION{"requiredField_wikiName"}%



Expand Down Expand Up @@ -354,7 +372,7 @@ Optional privacy information

Test if user topic exists. Used for form validation.

%STARTSECTION{"checkname"}%%IF{"istopic '%USERSWEB%.%URLPARAM{"name"}%'" then="false" else="true"}%%ENDSECTION{"checkname"}%
%STARTSECTION{"isWikiNameAvailable"}%%IF{"istopic '%USERSWEB%.%URLPARAM{"name"}%'" then="false" else="true"}%%ENDSECTION{"isWikiNameAvailable"}%

</verbatim>

Expand Down

0 comments on commit 8eafe6b

Please sign in to comment.