[ Mini Kiebo ]
Server: Windows NT DESKTOP-5B8S0D4 6.2 build 9200 (Windows 8 Professional Edition) i586
Path:
D:
/
xampp182
/
htdocs
/
simpeg
/
zapatec
/
zpgrid
/
zpgrid
/
jsdocs
/
[
Home
]
File: overview-summary-zpgrid-validate.js.html
<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd"> <html> <head> <title> Zapatec Grid Overview </title> <link rel ="stylesheet" type="text/css" href="stylesheet.css" title="Style"> <script> function asd() { parent.document.title="zpgrid-validate.js Overview"; } </script> </head> <body bgcolor="white" onload="asd();"> <!-- ========== START OF NAVBAR ========== --> <a name="navbar_top"><!-- --></a> <table border="0" width="100%" cellpadding="1" cellspacing="0"> <tr> <td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1"> <a name="navbar_top_firstrow"><!-- --></a> <table border="0" cellpadding="0" cellspacing="3"> <tr align="center" valign="top"> <td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a> </td> <td bgcolor="#FFFFFF" class="NavBarCell1Rev"> <font class="NavBarFont1Rev"><b>File</b></font> </td> <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font> </td> <td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a> </td> <td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a> </td> <td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a> </td> </tr> </table> </td> <td bgcolor="#EEEEFF" align="right" valign="top"> <em> <b>Zapatec Grid</b></em> </td> </tr> <tr> <td bgcolor="white" class="NavBarCell2"><font size="-2"> PREV NEXT</font></td> <td bgcolor="white" class="NavBarCell2"><font size="-2"> <a href="index.html" target="_top"><b>FRAMES</b></a> <a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a> <script> <!-- if(window==top) { document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>'); } //--> </script> <noscript> <a href="allclasses-noframe.html" target=""><b>All Classes</b></a> </noscript> </font></td> </tr> </table> <!-- =========== END OF NAVBAR =========== --> <hr> <center> <h2>zpgrid-validate.js</h2> </center> <h4>Summary</h4> <p> Plugin for Zapatec Grid to provide validation methods for cells depending on their data types. <pre> Copyright (c) 2004-2006 by Zapatec, Inc. http://www.zapatec.com 1700 MLK Way, Berkeley, California, 94709, U.S.A. All rights reserved. </pre><BR/><BR/> </p> <hr> <!-- ========== METHOD SUMMARY =========== --> <!-- ========== END METHOD SUMMARY =========== --> <pre class="sourceview"><span class="comment">/** * <span class="attrib">@fileoverview</span> Plugin for Zapatec Grid to provide validation methods for cells * depending on their data types. * * <pre> * Copyright (c) 2004-2006 by Zapatec, Inc. * http://www.zapatec.com * 1700 MLK Way, Berkeley, California, * 94709, U.S.A. * All rights reserved. * </pre> */</span> <span class="comment">/* $Id: zpgrid-validate.js 7323 2007-06-01 21:05:51Z alex $ */</span> <span class="comment">/** * Validates cell of integer data type. * * <span class="attrib">@param</span> {object} objCell Cell object * <span class="attrib">@return</span> True if valid * <span class="attrib">@type</span> boolean */</span> Zapatec.Grid.<span class="reserved">prototype</span>.validateInteger = <span class="reserved">function</span>(objCell) { <span class="comment">// Infinity is valid</span> <span class="reserved">if</span> (objCell && (objCell.v == Infinity || objCell.v == -Infinity)) { <span class="reserved">return</span> true; } <span class="comment">// Validate original value</span> <span class="reserved">return</span> /^\-?\d+$/.test(objCell.o); }; <span class="comment">/** * Validates cell of float data type. * * <span class="attrib">@param</span> {object} objCell Cell object * <span class="attrib">@return</span> True if valid * <span class="attrib">@type</span> boolean */</span> Zapatec.Grid.<span class="reserved">prototype</span>.validateFloat = <span class="reserved">function</span>(objCell) { <span class="comment">// Infinity is valid</span> <span class="reserved">if</span> (objCell && (objCell.v == Infinity || objCell.v == -Infinity)) { <span class="reserved">return</span> true; } <span class="comment">// Validate original value</span> <span class="reserved">return</span> /^\-?\d*\.?\d+$/.test(objCell.o); }; <span class="comment">/** * Validates cell of date data type. * * <span class="attrib">@param</span> {object} objCell Cell object * <span class="attrib">@return</span> True if valid * <span class="attrib">@type</span> boolean */</span> Zapatec.Grid.<span class="reserved">prototype</span>.validateDate = <span class="reserved">function</span>(objCell) { <span class="comment">// Validate original value</span> <span class="reserved">return</span> !isNaN(Date.parse(objCell.o)); }; <span class="comment">/** * Validates cell of time data type. * * <span class="attrib">@param</span> {object} objCell Cell object * <span class="attrib">@return</span> True if valid * <span class="attrib">@type</span> boolean */</span> Zapatec.Grid.<span class="reserved">prototype</span>.validateTime = <span class="reserved">function</span>(objCell) { <span class="comment">// Validate original value</span> var arrMatch = objCell.o.match(/(\d{1,2})\D+(\d{1,2})(\D+(\d{1,2}))?\W*(AM|PM)?/i); <span class="reserved">if</span> (!arrMatch) { <span class="comment">// Try without separator</span> arrMatch = objCell.o.match(/(\d{2})(\d{2})((\d{2}))?\W*(AM|PM)?/i); } <span class="reserved">if</span> (arrMatch && arrMatch[1] && arrMatch[2]) { <span class="reserved">return</span> true; } <span class="reserved">return</span> false; }; <span class="comment">/** * Validates cell of timestamp data type. * * <span class="attrib">@param</span> {object} objCell Cell object * <span class="attrib">@return</span> True if valid * <span class="attrib">@type</span> boolean */</span> Zapatec.Grid.<span class="reserved">prototype</span>.validateTimestamp = <span class="reserved">function</span>(objCell) { <span class="comment">// Validate original value</span> <span class="reserved">return</span> /^\d+$/.test(objCell.o); }; <span class="comment">/** * Validates cell of boolean data type. * * <span class="attrib">@param</span> {object} objCell Cell object * <span class="attrib">@return</span> True if valid * <span class="attrib">@type</span> boolean */</span> Zapatec.Grid.<span class="reserved">prototype</span>.validateBoolean = <span class="reserved">function</span>(objCell) { <span class="comment">// Validate original value</span> switch (objCell.o.toUpperCase()) { case <span class="literal">'0'</span>: case <span class="literal">'1'</span>: case <span class="literal">'F'</span>: case <span class="literal">'T'</span>: case <span class="literal">'FALSE'</span>: case <span class="literal">'TRUE'</span>: case <span class="literal">'N'</span>: case <span class="literal">'Y'</span>: case <span class="literal">'NO'</span>: case <span class="literal">'YES'</span>: <span class="reserved">return</span> true; } <span class="reserved">if</span> (Zapatec.Grid.booleanValues) { switch (objCell.o.toUpperCase()) { case Zapatec.Grid.booleanValues[0].toUpperCase(): case Zapatec.Grid.booleanValues[1].toUpperCase(): <span class="reserved">return</span> true; } } <span class="reserved">return</span> false; }; <span class="comment">/** * Validates cell of booleanTF data type. * * <span class="attrib">@param</span> {object} objCell Cell object * <span class="attrib">@return</span> True if valid * <span class="attrib">@type</span> boolean */</span> Zapatec.Grid.<span class="reserved">prototype</span>.validateBooleanTF = <span class="reserved">function</span>(objCell) { <span class="comment">// Validate original value</span> switch (objCell.o.toUpperCase()) { case <span class="literal">'0'</span>: case <span class="literal">'1'</span>: case <span class="literal">'F'</span>: case <span class="literal">'T'</span>: case <span class="literal">'FALSE'</span>: case <span class="literal">'TRUE'</span>: case <span class="literal">'N'</span>: case <span class="literal">'Y'</span>: case <span class="literal">'NO'</span>: case <span class="literal">'YES'</span>: <span class="reserved">return</span> true; } <span class="reserved">if</span> (Zapatec.Grid.booleanTFValues) { switch (objCell.o.toUpperCase()) { case Zapatec.Grid.booleanTFValues[0].toUpperCase(): case Zapatec.Grid.booleanTFValues[1].toUpperCase(): <span class="reserved">return</span> true; } } <span class="reserved">return</span> false; }; <span class="comment">/** * Associative array to access validation method by data type name. * <span class="attrib">@private</span> */</span> Zapatec.Grid.validateByType = { <span class="literal">'int'</span>: <span class="literal">'validateInteger'</span>, <span class="literal">'integer'</span>: <span class="literal">'validateInteger'</span>, <span class="literal">'float'</span>: <span class="literal">'validateFloat'</span>, <span class="literal">'date'</span>: <span class="literal">'validateDate'</span>, <span class="literal">'time'</span>: <span class="literal">'validateTime'</span>, <span class="literal">'timestamp'</span>: <span class="literal">'validateTimestamp'</span>, <span class="literal">'timestampMMDDYYYY'</span>: <span class="literal">'validateTimestamp'</span>, <span class="literal">'timestampDDMMYYYY'</span>: <span class="literal">'validateTimestamp'</span>, <span class="literal">'timestampYYYYMMDD'</span>: <span class="literal">'validateTimestamp'</span>, <span class="literal">'boolean'</span>: <span class="literal">'validateBoolean'</span>, <span class="literal">'booleanTF'</span>: <span class="literal">'validateBooleanTF'</span> }; <span class="comment">/** * Returns name of validation method corresponding to data type. * * <span class="attrib">@param</span> {string} strType Data type * <span class="attrib">@return</span> Validation method name or undefined if not found * <span class="attrib">@type</span> string */</span> Zapatec.Grid.<span class="reserved">prototype</span>.getValidateByType = <span class="reserved">function</span>(strType) { <span class="reserved">return</span> Zapatec.Grid.validateByType[strType]; }; <span class="comment">/** * Creates validation method for custom data type. * * <span class="attrib">@param</span> {function} funcConvert Function that validates cell value * <span class="attrib">@param</span> {string} strTypeName Type name */</span> Zapatec.Grid.createValidation = <span class="reserved">function</span>(funcValidate, strTypeName) { <span class="comment">// Check arguments</span> <span class="reserved">if</span> (typeof funcValidate != <span class="literal">'function'</span> || typeof strTypeName != <span class="literal">'string'</span> || !strTypeName.length) { <span class="reserved">return</span>; } <span class="comment">// Form method name</span> var strFuncName = <span class="literal">'validateCustom'</span> + strTypeName.charAt(0).toUpperCase() + strTypeName.substr(1); <span class="comment">// Add method</span> Zapatec.Grid.<span class="reserved">prototype</span>[strFuncName] = funcValidate; Zapatec.Grid.validateByType[strTypeName] = strFuncName; }; </pre> <hr> <!-- ========== START OF NAVBAR ========== --> <a name="navbar_top"><!-- --></a> <table border="0" width="100%" cellpadding="1" cellspacing="0"> <tr> <td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1"> <a name="navbar_top_firstrow"><!-- --></a> <table border="0" cellpadding="0" cellspacing="3"> <tr align="center" valign="top"> <td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a> </td> <td bgcolor="#FFFFFF" class="NavBarCell1Rev"> <font class="NavBarFont1Rev"><b>File</b></font> </td> <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font> </td> <td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a> </td> <td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a> </td> <td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a> </td> </tr> </table> </td> <td bgcolor="#EEEEFF" align="right" valign="top"><em> <b>Zapatec Grid</b></em> </td> </tr> <tr> <td bgcolor="white" class="NavBarCell2"><font size="-2"> PREV NEXT</font></td> <td bgcolor="white" class="NavBarCell2"><font size="-2"> <a href="index.html" target="_top"><b>FRAMES</b></a> <a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a> <script> <!-- if(window==top) { document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>'); } //--> </script> <noscript> <a href="allclasses-noframe.html" target=""><b>All Classes</b></a> </noscript> </font></td> </tr> </table> <!-- =========== END OF NAVBAR =========== --> <hr> <font size="-1"> </font> <div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Thu Aug 16 12:18:56 2007</div> </body> </html>