Permalink
Browse files

Add GruntJS tasks and new distribution files

* Update demos to use built files
* Update tests to use new spec format
* Add missing files that weren't part of previous commit
  • Loading branch information...
craig-davis committed Mar 31, 2013
1 parent b72b0a5 commit 5b6f49373dcac2fa042fd32de3b8c980f8d45abf
View
@@ -1,6 +1,3 @@
_public/*
_old
demos/dev.html
build.sh
js/min.header.js
/node_modules/
.DS_Store
View
@@ -0,0 +1,15 @@
{
"curly": true,
"eqeqeq": true,
"immed": true,
"latedef": true,
"newcap": true,
"noarg": true,
"sub": true,
"undef": true,
"unused": true,
"boss": true,
"eqnull": true,
"node": true,
"es5": true
}
View
@@ -0,0 +1,31 @@
# Contributing
## Important notes
Please don't edit files in the `dist` subdirectory as they are generated via Grunt. You'll find source code in the `src` subdirectory!
### Code style
Regarding code style like indentation and whitespace, **follow the conventions you see used in the source already.**
### PhantomJS
While Grunt can run the included unit tests via [PhantomJS](http://phantomjs.org/), this shouldn't be considered a substitute for the real thing. Please be sure to test the `test/*.html` unit test file(s) in _actual_ browsers.
## Modifying the code
First, ensure that you have the latest [Node.js](http://nodejs.org/) and [npm](http://npmjs.org/) installed.
Test that Grunt's CLI is installed by running `grunt --version`. If the command isn't found, run `npm install -g grunt-cli`. For more information about installing Grunt, see the [getting started guide](http://gruntjs.com/getting-started).
1. Fork and clone the repo.
1. Run `npm install` to install all dependencies (including Grunt).
1. Run `grunt` to grunt this project.
Assuming that you don't see any red, you're ready to go. Just be sure to run `grunt` after making any changes, to ensure that nothing is broken.
## Submitting pull requests
1. Create a new branch, please don't work in your `master` branch directly.
1. Add failing tests for the change you want to make. Run `grunt` to see the tests fail.
1. Fix stuff.
1. Run `grunt` to see if the tests pass. Repeat steps 2-4 until done.
1. Open `test/*.html` unit test file(s) in actual browser to ensure tests pass everywhere.
1. Update the documentation to reflect any changes.
1. Push to your fork and submit a pull request.
View
@@ -0,0 +1,109 @@
'use strict';
module.exports = function (grunt) {
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-cssmin');
// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'),
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
// Task configuration.
clean: {
files: ['dist']
},
cssmin: {
compress: {
options: {
banner: '<%= banner %>'
},
files: {
"dist/uni-form.css": ["css/uni-form.css", "css/style.uni-form.css"]
}
},
},
concat: {
options: {
banner: '<%= banner %>',
stripBanners: true
},
dist: {
src: ['src/uni-form.jquery.js'],
dest: 'dist/uni-form.jquery.js'
},
dist_validation: {
src: ['src/uni-form-validation.jquery.js', 'src/validators/*.js'],
dest: 'dist/uni-form-validation.jquery.js'
}
},
uglify: {
options: {
banner: '<%= banner %>'
},
dist: {
src: '<%= concat.dist.dest %>',
dest: 'dist/uni-form.jquery.min.js'
},
dist_validation: {
src: '<%= concat.dist_validation.dest %>',
dest: 'dist/uni-form-validation.jquery.min.js'
}
},
qunit: {
files: ['test/**/*.html']
},
jshint: {
gruntfile: {
options: {
jshintrc: '.jshintrc'
},
src: 'Gruntfile.js'
},
src: {
options: {
jshintrc: 'src/.jshintrc'
},
src: ['src/**/*.js']
},
test: {
options: {
jshintrc: 'test/.jshintrc'
},
src: ['test/**/*.js']
}
},
watch: {
css: {
files: 'css/*.css',
tasks: ['cssmin']
},
src: {
files: '<%= jshint.src.src %>',
tasks: ['jshint:src', 'concat', 'uglify'] //, 'qunit']
},
test: {
files: '<%= jshint.test.src %>',
tasks: ['jshint:test', 'qunit']
}
}
});
// Default task.
grunt.registerTask('default', ['jshint',/*'qunit', */ 'clean', 'concat', 'cssmin', 'uglify']);
// Alias this to make it standard across my repos. (Jasmine v. QUnit)
grunt.registerTask('test', ['qunit']);
};
View
@@ -0,0 +1,22 @@
Copyright (c) 2013 Dragan Babic
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
View
@@ -1,15 +1,14 @@
<!doctype html>
<html lang="en-us" dir="ltr">
<head>
<meta charset="utf-8">
<!--
<!--
Copyright (c) 2010, Dragan Babic
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
@@ -18,10 +17,10 @@
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -34,11 +33,11 @@
-->
<title>Uni&ndash;Form</title>
<link href="../css/uni-form.css" media="screen" rel="stylesheet"/>
<link href="../css/style.uni-form.css" media="screen" rel="stylesheet"/>
<link href="./css/demo.css" media="screen" rel="stylesheet"/>
<!--[if lte ie 7]>
<style type="text/css" media="screen">
/* Move these to your IE6/7 specific stylesheet if possible */
@@ -51,21 +50,21 @@
<body>
<h1><a href="http://sprawsm.com/uni-form/" title="visit Uni–Form online"><img src="../img/uni-form-logo.png" alt=""/></a></h1>
<div class="uni-form-wrap">
<form action="#" class="uni-form">
<fieldset>
<h2 class="uni-form-title">Client side form demonstration</h2>
<div class="ctrl-holder">
<label for=""><em>*</em> Custom callback item</label>
<input name="name" id="name" data-default-value="Placeholder text" size="35" maxlength="50" type="text" class="input-text required validateCallback my_code_callback"/>
<p class="form-hint">A two letter code of a number and a letter: A4, B8, C2</p>
</div>
<div class="ctrl-holder">
<label for=""><em>*</em> Your email</label>
<input name="email" id="email" data-default-value="Placeholder text" size="35" maxlength="50" type="email" class="input-text validateEmail"/>
@@ -79,7 +78,7 @@ <h2 class="uni-form-title">Client side form demonstration</h2>
</div>
</fieldset>
<div class="button-holder">
<button type="submit" class="action-secondary">← Cancel and go back</button>
<button type="submit" class="action-primary">Submit</button>
@@ -94,21 +93,21 @@ <h2 class="uni-form-title">Client side form demonstration</h2>
</div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="../js/uni-form-validation.jquery.js" charset="utf-8"></script>
<script type="text/javascript" src="../libs/jquery/jquery.js"></script>
<script type="text/javascript" src="../dist/uni-form-validation.jquery.js" charset="utf-8"></script>
<script>
$(function(){
$('form.uniForm').uniform();
});
/**
* A somewhat contrived example of a custom callback
*
*
* This will check for a letter + number code in the field
* of length 2
*
* Trigger this by giving the form element two classnames,
*
* Trigger this by giving the form element two classnames,
* validateCallback name_of_the_custom_function
*
* Make sure that the function is put into the window object.
Oops, something went wrong.

0 comments on commit 5b6f493

Please sign in to comment.