Skip to content

Commit 4b34720

Browse files
committed
Initial commit
0 parents  commit 4b34720

15 files changed

+4641
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist
2+
node_modules
3+
config.json

LICENSE-MIT.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Copyright (c) 2013 Jörn Zaefferer, http://bassistance.de/
2+
3+
This software consists of voluntary contributions made by many
4+
individuals. For exact contribution history, see the revision history
5+
and logs, available at http://github.com/jzaefferer/jqueryvalidation-content
6+
7+
Permission is hereby granted, free of charge, to any person obtaining
8+
a copy of this software and associated documentation files (the
9+
"Software"), to deal in the Software without restriction, including
10+
without limitation the rights to use, copy, modify, merge, publish,
11+
distribute, sublicense, and/or sell copies of the Software, and to
12+
permit persons to whom the Software is furnished to do so, subject to
13+
the following conditions:
14+
15+
The above copyright notice and this permission notice shall be
16+
included in all copies or substantial portions of the Software.
17+
18+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
jqueryvalidation-content
2+
========================
3+
4+
## Building
5+
6+
### Requirements
7+
8+
* <a href="http://www.xmlsoft.org/">libxml2</a>
9+
* <a href="http://xmlsoft.org/XSLT/">libxslt</a>
10+
11+
The `xmllint` and `xsltproc` utilities need to be in your path. If you are on Windows, you can get libxml2 and libxslt from <a href="http://sourceforge.net/projects/gnuwin32/files/">GnuWin32</a>.
12+
13+
* Install [WordPress](http://wordpress.org/download/)
14+
* Install [jqueryvalidation-theme](https://github.com/jzaefferer/validation-theme) - clone that repo, then symlink it into your `wp-content/themes` folder
15+
* Install [grunt-wordpress plugin](https://github.com/jquery/jquery-wp-content/blob/master/mu-plugins/grunt-wordpress.php)
16+
* Install [jquery-static-index plugin](https://github.com/jquery/jquery-wp-content/blob/master/plugins/jquery-static-index.php)
17+
18+
### Installation
19+
20+
In this repo:
21+
* Make sure nodejs (with npm) is installed, otherwise install from nodejs.org
22+
* `cp config-sample.json config.json`, edit config.json to match login for local WordPress
23+
* run `npm install -g grunt-cli`
24+
* run `npm install`
25+
26+
### Deploy
27+
28+
`grunt deploy`

categories.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<categories>
2+
<category name="Uncategorized" slug="uncategorized"/>
3+
<category name="Methods" slug="methods"></category>
4+
<category name="Additional Methods" slug="additional-methods"></category>
5+
<category name="Plugin Methods" slug="plugin">
6+
<desc><![CDATA[
7+
All jQuery methods that the plugin adds, available on all jQuery objects.
8+
]]></desc>
9+
</category>
10+
<category name="Validator" slug="validator">
11+
<desc><![CDATA[
12+
Methods available on the Validator object returned by the validate method.
13+
]]></desc>
14+
</category>
15+
</categories>

config-sample.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"url": "validation.local",
3+
"username": "admin",
4+
"password": "secret",
5+
"dir": "dist/wordpress"
6+
}

entries/Validator.resetForm.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0"?>
2+
<?xml-stylesheet type="text/xsl" href="../entries2html.xsl" ?>
3+
<entry type="method" name="Validator.resetForm">
4+
<title>Validator.resetForm()</title>
5+
<signature>
6+
</signature>
7+
<desc>Resets the controlled form.</desc>
8+
<longdesc>Resets input fields to their original value (requires form plugin), removes classes indicating invalid elements and hides error messages.</longdesc>
9+
<example>
10+
<desc>Reset the form controlled by this validator.</desc>
11+
<code><![CDATA[
12+
var validator = $( "#myform" );
13+
validator.resetForm();
14+
]]></code>
15+
</example>
16+
<category slug="validator"/>
17+
</entry>

entries/validate.xml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<?xml version="1.0"?>
2+
<entry name="validate" type="method" return="Validator">
3+
<title>.validate()</title>
4+
<desc>Validate a single form.</desc>
5+
<longdesc>
6+
<p>The jQuery UI <code>.position()</code> method allows you to position an element relative to the window, document, another element, or the cursor/mouse, without worrying about offset parents.</p>
7+
<p><em>Note: jQuery UI does not support positioning hidden elements.</em></p>
8+
<p>This is a standalone jQuery plugin and has no dependencies on other jQuery UI components.</p>
9+
<xi:include href="../includes/core-extension-desc.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/>
10+
</longdesc>
11+
<added>1.8</added>
12+
<signature>
13+
<argument name="options" type="Object">
14+
<property name="my" default='"center"'>
15+
<desc>Defines which position <strong>on the element being positioned</strong> to align with the target element: "horizontal vertical" alignment. A single value such as <code>"right"</code> will be normalized to <code>"right center"</code>, <code>"top"</code> will be normalized to <code>"center top"</code> (following CSS convention). Acceptable horizontal values: <code>"left"</code>, <code>"center"</code>, <code>"right"</code>. Acceptable vertical values: <code>"top"</code>, <code>"center"</code>, <code>"bottom"</code>. Example: <code>"left top"</code> or <code>"center center"</code>. Each dimension can also contain offsets, in pixels or percent, e.g., <code>"right+10 top-25%"</code>. Percentage offsets are relative to the element being positioned.</desc>
16+
<type name="String"/>
17+
</property>
18+
<property name="at" default='"center"'>
19+
<desc>Defines which position <strong>on the target element</strong> to align the positioned element against: "horizontal vertical" alignment. See the <a href="#option-my"><code>my</code></a> option for full details on possible values. Percentage offsets are relative to the target element.</desc>
20+
<type name="String"/>
21+
</property>
22+
<property name="of" default="null">
23+
<desc>Which element to position against. If you provide a selector or jQuery object, the first matching element will be used. If you provide an event object, the <code>pageX</code> and <code>pageY</code> properties will be used. Example: <code>"#top-menu"</code></desc>
24+
<type name="Selector"/>
25+
<type name="Element"/>
26+
<type name="jQuery"/>
27+
<type name="Event"/>
28+
</property>
29+
<property name="collision" default='"flip"'>
30+
<desc>
31+
<p>When the positioned element overflows the window in some direction, move it to an alternative position. Similar to <a href="#option-my"><code>my</code></a> and <a href="#option-at"><code>at</code></a>, this accepts a single value or a pair for horizontal/vertical, e.g., <code>"flip"</code>, <code>"fit"</code>, <code>"fit flip"</code>, <code>"fit none"</code>.</p>
32+
<ul>
33+
<li><code>"flip"</code>: Flips the element to the opposite side of the target and the collision detection is run again to see if it will fit. Whichever side allows more of the element to be visible will be used.</li>
34+
<li><code>"fit"</code>: Shift the element away from the edge of the window.</li>
35+
<li><code>"flipfit"</code>: First applies the flip logic, placing the element on whichever side allows more of the element to be visible. Then the fit logic is applied to ensure as much of the element is visible as possible.</li>
36+
<li><code>"none"</code>: Does not apply any collision detection.</li>
37+
</ul>
38+
</desc>
39+
<type name="String"/>
40+
</property>
41+
<property name="using" default="null">
42+
<desc>
43+
When specified, the actual property setting is delegated to this callback. Receives two parameters: The first is a hash of <code>top</code> and <code>left</code> values for the position that should be set and can be forwarded to <code>.css()</code> or <code>.animate()</code>.
44+
<p>The second provides feedback about the position and dimensions of both elements, as well as calculations to their relative position. Both <code>target</code> and <code>element</code> have these properties: <code>element</code>, <code>left</code>, <code>top</code>, <code>width</code>, <code>height</code>. In addition, there's <code>horizontal</code>, <code>vertical</code> and <code>important</code>, giving you twelve potential directions like <code>{ horizontal: "center", vertical: "left", important: "horizontal" }</code>.</p>
45+
</desc>
46+
<type name="Function"/>
47+
</property>
48+
<property name="within" default="window">
49+
<desc>Element to position within, affecting collision detection. If you provide a selector or jQuery object, the first matching element will be used.</desc>
50+
<type name="Selector"/>
51+
<type name="Element"/>
52+
<type name="jQuery"/>
53+
</property>
54+
</argument>
55+
</signature>
56+
<example>
57+
<desc>A simple jQuery UI Position example.</desc>
58+
<css><![CDATA[
59+
.positionDiv {
60+
position: absolute;
61+
width: 75px;
62+
height: 75px;
63+
background: green;
64+
}
65+
]]></css>
66+
<code><![CDATA[
67+
$( "#position1" ).position({
68+
my: "center",
69+
at: "center",
70+
of: "#targetElement"
71+
});
72+
73+
$( "#position2" ).position({
74+
my: "left top",
75+
at: "left top",
76+
of: "#targetElement"
77+
});
78+
79+
$( "#position3" ).position({
80+
my: "right center",
81+
at: "right bottom",
82+
of: "#targetElement"
83+
});
84+
85+
$( document ).mousemove(function( event ) {
86+
$( "#position4" ).position({
87+
my: "left+3 bottom-3",
88+
of: event,
89+
collision: "fit"
90+
});
91+
});
92+
]]></code>
93+
<html><![CDATA[
94+
<div id="targetElement">
95+
<div class="positionDiv" id="position1"></div>
96+
<div class="positionDiv" id="position2"></div>
97+
<div class="positionDiv" id="position3"></div>
98+
<div class="positionDiv" id="position4"></div>
99+
</div>
100+
]]></html>
101+
</example>
102+
<category slug="plugin"/>
103+
</entry>

entries2html.xsl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
2+
3+
<xsl:import href="node_modules/grunt-jquery-content/tasks/jquery-xml/entries2html-base.xsl"/>
4+
<xsl:variable name="method-prefix-dot" select="false()"/>
5+
6+
<xsl:template name="example-code">
7+
&lt;!doctype html&gt;
8+
&lt;html&gt;
9+
&lt;head&gt;
10+
&lt;meta charset="utf-8"&gt;
11+
&lt;title&gt;<xsl:value-of select="desc"/>&lt;/title&gt;
12+
<xsl:if test="css">
13+
&lt;style&gt;<xsl:copy-of select="css/text()"/> &lt;/style&gt;</xsl:if>
14+
&lt;script src="jquery.validate.js"&gt;&lt;/script&gt;
15+
&lt;script&gt;<xsl:copy-of select="code/text()"/>&lt;/script&gt;
16+
&lt;/head&gt;
17+
&lt;body&gt;
18+
&lt;form&gt;
19+
<xsl:copy-of select="html/text()"/>
20+
&lt;/form&gt;
21+
&lt;/body&gt;
22+
&lt;/html&gt;
23+
</xsl:template>
24+
25+
</xsl:stylesheet>

grunt.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*jshint node:true */
2+
module.exports = function( grunt ) {
3+
"use strict";
4+
5+
var entryFiles = grunt.file.expandFiles( "entries/*.xml" );
6+
7+
grunt.loadNpmTasks( "grunt-clean" );
8+
grunt.loadNpmTasks( "grunt-wordpress" );
9+
grunt.loadNpmTasks( "grunt-jquery-content" );
10+
grunt.loadNpmTasks( "grunt-check-modules" );
11+
12+
grunt.initConfig({
13+
clean: {
14+
folder: "dist"
15+
},
16+
lint: {
17+
grunt: "grunt.js"
18+
},
19+
watch: {
20+
files: [ "entries/**", "pages/**", "categories.xml" ],
21+
tasks: "deploy"
22+
},
23+
xmllint: {
24+
all: [].concat( entryFiles, "categories.xml", "entries2html.xsl" )
25+
},
26+
xmltidy: {
27+
all: [].concat( entryFiles, "categories.xml" )
28+
},
29+
"build-pages": {
30+
all: grunt.file.expandFiles( "pages/**" )
31+
},
32+
"build-xml-entries": {
33+
all: entryFiles
34+
},
35+
"build-resources": {
36+
all: grunt.file.expandFiles( "resources/**" )
37+
},
38+
wordpress: grunt.utils._.extend({
39+
dir: "dist/wordpress"
40+
}, grunt.file.readJSON( "config.json" ) )
41+
});
42+
43+
// workaround until I figure out how to allow upload of xml files
44+
grunt.registerTask( "delete-apixml", function() {
45+
var fs = require( "fs" );
46+
fs.unlinkSync( "dist/wordpress/resources/api.xml" );
47+
});
48+
49+
grunt.registerTask( "default", "build-wordpress" );
50+
grunt.registerTask( "build", "build-pages build-xml-entries build-xml-categories build-xml-full build-resources delete-apixml" );
51+
grunt.registerTask( "build-wordpress", "check-modules clean lint xmllint build" );
52+
grunt.registerTask( "tidy", "xmllint xmltidy" );
53+
54+
};

0 commit comments

Comments
 (0)