Skip to content
This repository has been archived by the owner on Jun 24, 2018. It is now read-only.

Commit

Permalink
1. Beginning to add support for data attribute.
Browse files Browse the repository at this point in the history
2. Working on url and email INPUT types.
  • Loading branch information
westonruter committed May 29, 2007
1 parent c9e78a3 commit 24613b7
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 42 deletions.
2 changes: 1 addition & 1 deletion project.kpf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Komodo Project File - DO NOT EDIT -->
<project kpf_version="3" id="e3f37c79-18f1-478b-8898-d6b830b0a9f6" name="project.kpf">
<project id="e3f37c79-18f1-478b-8898-d6b830b0a9f6" name="project.kpf" kpf_version="4">
<preference-set idref="e3f37c79-18f1-478b-8898-d6b830b0a9f6">
<boolean id="import_live">1</boolean>
</preference-set>
Expand Down
31 changes: 30 additions & 1 deletion task-queue.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@








Expand All @@ -14,6 +16,9 @@









Expand All @@ -32,22 +37,27 @@




<ol>





<li>Repetition blocks that are not siblings of template are not included in repetitionBlocks list</li>





<li><font color="#c0c0c0"><strike>Flashing of invalid form controls is not working when there is more than one</strike>.</font></li>




<li>Unable to remove transparency when hovering over an error message.</li>

<li><strike>Unable to remove transparency when hovering over an error message.</strike></li>




Expand All @@ -58,59 +68,78 @@




<li><font color="#c0c0c0"><strike>how to determine that an element is
not focusable? We should only focus on a form control which
hasAttribute('autofocus') when it is focusable.</strike></font></li>




<li>Add DOMAttrModified handlers for repeatStart, et al</li>




<li>Can we use DOMNodeInserted and just see if it is the child of the document?</li>




<li>We need to test the implementation in XHTML: is DOMContentLoaded fired after onload in XHTML?</li>




<li>Make a greasemonkey script available.... webforms2.user.js......... can there be one for MSIE?</li>




<li>Upload test cases to weston.ruter.net and add redirects from repetition model test cases to these ones</li>




<li>Can we emulate :valid and :invalid with CSS classNames?</li>



<li>Note: using document.body as the test for when loaded is not good... XHTML documents will not work with this.</li>


<li>We should have a function that applies the WF2 (not just validation) behavior to a specific context</li>


<li>Execute repetition model before Data attributes are prefilled</li>


<li>What happens when the MAXLENGTH is changed dynamically?</li>


<li><font color="#c0c0c0"><strike>Positioning of error messages is incorrect in Firefox and MSIE (note offsetLeft)</strike></font>.</li>


<li><font color="#ff0000">Add onsubmit listener so that
form.checkValidity is called... if checkValidity is called by event
listener (explicitly passed THROW_NO_EXCEPTION argument) &nbsp;then no
exception is raised. If the submit() function is used, then raise an
exception... question: is there a submit event raised when manually
calling submit()??</font>?<br>

</li>

<li>Created initWF2Functionality to initialize the validation model,
autofocus, etc. Should the Repetition Model functions be called within
here?</li>
<li>Add support for form.data and select.data</li>
<li>Use Ruby's Racc to create RegExes for URL and Email</li>

</ol>





</body>
</html>
8 changes: 5 additions & 3 deletions testsuite/~testcases/017.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<html debug="true" xmlns="http://www.w3.org/1999/xhtml"><!-- debug -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 5//EN">
<html debug="true" xmlns="http://www.w3.org/1999/xhtml"><!-- debug -->
<head>
<title>Form validation</title>
<meta name="description" content="" />
Expand Down Expand Up @@ -185,19 +186,20 @@
<div style="text-align:center; ">
<input type="button" value="Check validity" style="font-size:13pt" onclick="if(document.forms[0].checkValidity()) alert('Form is valid!')">
</div>
<div>
<fieldset>
<legend>Text input</legend>
<ul>
<li>type=text <input type="text" name="text1" value="" required> (required)</li>
<li>type=text <input type="text" name="text2" pattern="\d\d\d-\d\d-\d\d\d\d"> (pattern="\d\d\d-\d\d-\d\d\d\d")</li>
<li>type=text <input type="text" name="text3" value="(222) 222-2222" required pattern="\(\d\d\d\) \d\d\d-\d\d\d\d"> (required pattern="\(\d\d\d\) \d\d\d-\d\d\d\d")</li>
<li>type=email <input type="email" name="text4" required value='invalid%email.com' oninvalid="insertErrorAfter(this, 'Incorrect email (note the default UI error message is not displayed)'); if(document.getElementById('oldEventModel').checked) handle_traditionalEvent(event); return false"> (required, overriding oninvalid)</li>
<li>type=text <input type="text" name="text5" required maxlength="5" value="0123456789"> (required)</li>
<li>type=url <input type="url" name="text6" required value="blob://www.google.com/"> (required)</li>
<li><textarea cols="40" rows="3" name="ta6" maxlength="10">1
2
3</textarea> (length should be 7) maxlength=10 (QUESTION: what about when maxlength &lt; len(defaultValue))</li>
</ul>
</div>
</fieldset>

<fieldset>
<legend>Radio buttons</legend>
Expand Down
4 changes: 4 additions & 0 deletions testsuite/~testcases/018-formdata.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0"?>
<formdata xmlns="http://n.whatwg.org/formdata">

</formdata>
2 changes: 1 addition & 1 deletion testsuite/~testcases/testcase.template.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 5//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
Expand Down
44 changes: 16 additions & 28 deletions webforms2.css
Original file line number Diff line number Diff line change
@@ -1,53 +1,41 @@
input.wf2_invalid, textarea.wf2_invalid, select.wf2_invalid { background-color:#FFCCCC; }
input.wf2_invalid, textarea.wf2_invalid, select.wf2_invalid, div.wf2_errorMsg { background-color:#FFCCCC; }

.wf2_errorMsg
{
position:absolute; display:inline; border:dotted 1px red; background-color:white; padding:.25em;
div.wf2_errorMsg {
position:absolute;
border:dotted 1px red;
padding:.25em;
padding-left:.5em;
/*padding-right:3em;*/
cursor:default;
background-color:#FFCCCC;
font-size:smaller;
opacity:.5;
opacity:0.5;
filter: alpha(opacity=50);
}
.wf2_errorMsg:hover
{
/*background-color:Black;
color:White;
opacity:.4;*/
opacity:1 !important;
z-index:1000 !important;
}
.wf2_firstErrorMsg
{
opacity:1;

div.wf2_errorMsg:hover,
div.wf2_firstErrorMsg {
opacity:1.0;
filter: alpha(opacity=100);
}


.wf2_errorMsg ol
{
div.wf2_errorMsg ol {
list-style-position:inside;
margin:0;
padding:0;
}
.wf2_errorMsg ol.single
{
div.wf2_errorMsg ol.single {
list-style:none;
}
.wf2_errorMsg ol.single li
{
div.wf2_errorMsg ol.single li {
margin:0;
padding:0;
}


@namespace xh url(http://www.w3.org/1999/xhtml); /* For XHTML */
/*
@namespace xh url(http://www.w3.org/1999/xhtml);
:not(xh|*)[xh|repeat="template"],
xh|*[|repeat="template"] {
display: none;
}
}*/

*[repeat="template"] {
display:none;
Expand Down
52 changes: 44 additions & 8 deletions webforms2.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,19 @@ $wf2 = {
parent = document.getElementsByTagName('*')[0];
parent.insertBefore(style, parent.firstChild);

// Initialize Repetition Behaviors ****************************************
//Seeding a form with initial values*************************************
//Before load events are fired, but after the entire document has been parsed and after select elements
// have been filled from external data sources (if necessary), forms with data attributes are prefilled.
var forms = $wf2.getElementsByTagNameAndAttribute("form", "data");
for(var i = 0; i < forms.length; i++){
//[The data attribute] must be a URI or IRI that points to a well-formed XML file whose root element
// is a formdata element in the http://n.whatwg.org/formdata namespace. The MIME type must be an XML
// MIME type [RFC3023], preferably application/xml.

//TODO
}

//Initialize Repetition Behaviors ****************************************

//RepetitionElement interface must be implemented by all elements.
if(window.Element && Element.prototype){
Expand Down Expand Up @@ -85,7 +97,7 @@ $wf2 = {
$wf2.updateAddButtons();
$wf2.updateMoveButtons();

// Initialize Validation Behaviors ****************************************
// Initialize Non-Repetition Behaviors ****************************************
if(document.addEventListener){
document.addEventListener("mousedown", $wf2.clearInvalidIndicators, false);
document.addEventListener("keydown", $wf2.clearInvalidIndicators, false);
Expand All @@ -94,10 +106,10 @@ $wf2 = {
document.attachEvent("onmousedown", $wf2.clearInvalidIndicators);
document.attachEvent("onkeydown", $wf2.clearInvalidIndicators);
}
$wf2.initWF2Functionality();
$wf2.initNonRepetitionFunctionality();
},

initWF2Functionality : function(parent){
initNonRepetitionFunctionality : function(parent){
parent = (parent || document.documentElement);
var i,j, form, forms = parent.getElementsByTagName('form');
for(i = 0; form = forms[i]; i++){
Expand Down Expand Up @@ -702,8 +714,8 @@ $wf2 = {
$wf2.updateMoveButtons(this.parentNode);
}

//Setup block with the Web Forms 2.0 behavior
$wf2.initWF2Functionality(block);
//Setup block with the other WF2 behavior
$wf2.initNonRepetitionFunctionality(block);
//var els = $wf2.getElementsByTagNameAndAttribute.apply(block, ["*", "autofocus"]); //ISSUE: Any form control (except hidden and output controls) can have an autofocus attribute specified. //var elName = els[i].nodeName.toLowerCase(); if(elName == 'output' || (elName == 'input' && els[i].type == 'hidden'))
//for(var i = 0; i < els.length; i++)
// $wf2.initAutofocusElement(els[i]);
Expand Down Expand Up @@ -1221,10 +1233,33 @@ $wf2 = {
}
break;
case 'email':
//An e-mail address, following the format of the addr-spec token defined in RFC 2822 section
// 3.4.1 [RFC2822], but excluding the CFWS subtoken everywhere, and excluding the FWS
// subtoken everywhere except in the quoted-string subtoken. UAs could, for example, offer
// e-mail addresses from the user's address book. (See below for notes on IDN.)
//http://www.ietf.org/rfc/rfc2822
//addr-spec = local-part "@" domain
//local-part = dot-atom / quoted-string / obs-local-part
//domain = dot-atom / domain-literal / obs-domain
//domain-literal = [CFWS] "[" *([FWS] dcontent) [FWS] "]" [CFWS]
//dcontent = dtext / quoted-pair
//dtext = NO-WS-CTL / ; Non white space controls
// %d33-90 / ; The rest of the US-ASCII
// %d94-126 ; characters not including "[",
// ; "]", or "\"

node.validity.typeMismatch = !/^.+@.+$/.test(node.value);
break;
case 'url':
node.validity.typeMismatch = !/^(http|ftp):\/\/.+$/i.test(node.value);
//An IRI, as defined by [RFC3987] (the IRI token, defined in RFC 3987 section 2.2). UAs could,
// for example, offer the user URIs from his bookmarks. (See below for notes on IDN.) The value
// is called url (as opposed to iri or uri) for consistency with CSS syntax and because it is
// generally felt authors are more familiar with the term "URL" than the other, more technically
// correct terms.
//http://www.ietf.org/rfc/rfc3987

//TODO: use http://cvs.m17n.org/~akr/abnf/ to covert 2.2 of http://www.ietf.org/rfc/rfc3987
node.validity.typeMismatch = !/^(https?|ftp):\/\/.+$/i.test(node.value);
break;
}
}
Expand Down Expand Up @@ -1977,7 +2012,8 @@ if(document.addEventListener){

//## Execute the document initializers once the DOM has loaded ########################################

//The script has been included after the DOM has loaded (perhaps via Greasemonkey), so fire immediately
//The script has been included after the DOM has loaded (perhaps via Greasemonkey), so fire immediately
//NOTE: This does not work with XHTML documents in Gecko
if(document.body){
$wf2.init();
return;
Expand Down

0 comments on commit 24613b7

Please sign in to comment.