diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..a507933 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +# This file is for unifying the coding style for different editors and IDEs +# editorconfig.org + +root = true + +[*] +indent_size = 2 +indent_style = space +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/.gitignore b/.gitignore index e43b0f9..10d9d84 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ +node_modules .DS_Store +.idea/ diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..2d739bf --- /dev/null +++ b/.jshintrc @@ -0,0 +1,13 @@ +{ + "boss": true, + "curly": true, + "eqeqeq": true, + "eqnull": true, + "expr": true, + "immed": true, + "noarg": true, + "onevar": true, + "quotmark": "single", + "unused": true, + "node": true +} diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..1a01981 --- /dev/null +++ b/.npmignore @@ -0,0 +1,10 @@ +#Testing, not relevant to end user +test/ +.travis.yml +.jshintrc + +#Not relevant to npm users +bower.json + +#IDE +.idea/ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..9bf327d --- /dev/null +++ b/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - "4.2.4" +before_script: + - npm install -g grunt-cli diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..1eef85c --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,208 @@ +//TODO: During next major version bump change to /dist. Leaving at ./form-validator for backwards +//compatibility +const DIST_DIR = './form-validator'; +const MAIN_PLUGIN_FILE = 'jquery.form-validator'; +const SRC_DIR = './src'; +const MAIN_DIR = '/main/'; +const MODULE_DIR = '/modules'; +const LANG_DIR = '/lang'; +const CSS_FILE = 'theme-default.css'; +const CORE_VALIDATORS = 'core-validators.js'; //must come at end of concatted file +const coreValidatorsPath = SRC_DIR + MAIN_DIR + CORE_VALIDATORS; + +var fs = require('fs'), + readFile = function (file) { + return fs.readFileSync(file, 'utf-8'); + }, + replaceInFile = function (path, from, to) { + fs.writeFileSync(path, readFile(path).replace(from, to)); + }; + +function initializeGruntConfig(grunt) { + + grunt.initConfig({ + + // Import package manifest + pkg: grunt.file.readJSON("package.json"), + + // Banner definitions + meta: { + banner: "/** File generated by Grunt -- do not modify\n" + + " * <%= (pkg.title || pkg.name).toUpperCase() %>\n" + + " *\n" + + " * @version <%= pkg.version %>\n" + + " * @website <%= pkg.homepage %>\n" + + " * @author <%= pkg.author.name %>, <%= pkg.author.url %>\n" + + " * @license <%= pkg.license %>\n" + + " */\n" + }, + + concat: { + main:{ + files: [ + //This concatenates the core validators file after the other files + //Per: http://gruntjs.com/configuring-tasks + { + src: [SRC_DIR + MAIN_DIR+'*.js', '!' + coreValidatorsPath, coreValidatorsPath], + dest: DIST_DIR + '/' + MAIN_PLUGIN_FILE + '.js' + }, + { + src: [SRC_DIR + MAIN_DIR+'*.js', '!' + coreValidatorsPath, coreValidatorsPath], + dest: DIST_DIR + '/' + MAIN_PLUGIN_FILE + '.min.js' + }] + }, + options: { + banner: "<%= meta.banner %>" + } + }, + + cssmin: { + target: { + files: [ + { + dest: DIST_DIR, + src: CSS_FILE, + cwd: SRC_DIR, + expand: true, + ext: '.min.css' + } + ] + } + }, + // Lint definitions + jshint: { + files: [SRC_DIR + '/*'], + options: { + jshintrc: ".jshintrc", + ignores: [SRC_DIR + '/' + CSS_FILE] + } + }, + + // Minify definitions + uglify: { + options: { + banner: "<%= meta.banner %>" + }, + main: { + files: [ + { + expand: true, + cwd: DIST_DIR + '/', + src: ['**/*.js', '!' + MAIN_PLUGIN_FILE +'.js'], + dest: DIST_DIR + '/' + } + ] + } + }, + + watch: { + files: [SRC_DIR + '/**'], + tasks: ['test'], + options: { + nospawn: true, + livereload: true + } + }, + + // Unit tests + qunit: { + all: ['test/qunit.html'] + }, + + // Standalone servers + connect: { + server: { + options: { + port: 8000, + base: '.' + } + } + }, + + copy: { + main: { + files: [ + { + src: SRC_DIR + '/' + CSS_FILE, + dest: DIST_DIR + '/' + CSS_FILE + }, + { + cwd: SRC_DIR + '/' + MODULE_DIR, + src: '**', + dest: DIST_DIR + '/', + expand: true + }, + { + cwd: SRC_DIR + '/' + LANG_DIR, + src: '**', + dest: DIST_DIR + LANG_DIR +'/', + expand: true + }] + } + }, + + clean: [DIST_DIR + '/'], + + umd: { + main: { + options: { + src: DIST_DIR + '/**/*.js', + dest: './', + deps: { + default: ['jQuery'], + amd: [{'jquery': 'jQuery'}], + cjs: [{'jquery': 'jQuery'}] + } + } + } + } + }); +} + +module.exports = function (grunt) { + + initializeGruntConfig(grunt); + /* + * Change to new version or the next version number. The project must be built again after this task + * in order for the version change to take effect. + */ + grunt.registerTask('version', 'Bump up the version number, or change version name by adding --new-version=3.1.0', function () { + var pkg = grunt.config.get('pkg'), + currentVersion = pkg.version, + newVersion = grunt.option('new-version'); + + if (!newVersion) { + var versionParts = currentVersion.split('.'), + newSubVersion = parseInt(versionParts.splice(versionParts.length - 1, 1)[0]) + 1; + newSubVersion = newSubVersion < 10 && newSubVersion > 0 ? '0' + newSubVersion : newSubVersion.toString(); + newVersion = versionParts.join('.') + '.' + newSubVersion; + } + + grunt.log.writeln('* Moving from version ' + currentVersion + ' to ' + newVersion); + + replaceInFile('package.json', '"version": "' + currentVersion + '"', + '"version": "' + newVersion + '"'); + replaceInFile('formvalidator.jquery.json', '"version": "' + currentVersion + '"', '"version": "' + newVersion + '"'); + + // Set new version globally (can later on be used by concat/uglify) + pkg.version = newVersion; + grunt.config.set('pkg', pkg); + }); + + grunt.loadNpmTasks('grunt-contrib-clean'); + grunt.loadNpmTasks("grunt-contrib-concat"); + grunt.loadNpmTasks('grunt-contrib-copy'); + grunt.loadNpmTasks("grunt-contrib-jshint"); + grunt.loadNpmTasks("grunt-contrib-uglify"); + grunt.loadNpmTasks("grunt-contrib-watch"); + grunt.loadNpmTasks('grunt-contrib-connect'); + grunt.loadNpmTasks('grunt-contrib-qunit'); + grunt.loadNpmTasks('grunt-contrib-cssmin'); + grunt.loadNpmTasks('grunt-umd'); + + grunt.registerTask("build-production", ["version", "test", "uglify"]); + grunt.registerTask('build', ['concat', 'copy', 'umd', 'cssmin']); + grunt.registerTask('test', ['build','jshint', 'qunit']); + grunt.registerTask("default", ["test", "connect", "watch"]); + grunt.registerTask("prepublish", ["test", "uglify"]); +}; diff --git a/README.md b/README.md index 644117e..e1e957b 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,14 @@ -# jQuery Form Validator +# jQuery Form Validator [DISCONTINUED] -With this feature rich jQuery plugin it becomes easy to validate user input while keeping your - HTML markup clean from javascript code. Even though this plugin has **a wide range of validation functions** -it's designed to require as little bandwidth as possible. This is achieved by grouping together validation functions -in "modules", making it possible for the programmer to load **only those functions that's needed** to validate a -particular form. +*Validation framework that let's you configure, rather than code, your validation logic.* -**Form demos and full documentation is available at http://formvalidator.net/** +I started writing this plugin back in 2009 and it has given me much joy over the years. But all good things must come to an end and now it's time for this plugin to pull in its oars and go down with history. + +**This plugin is no longer being developed!** It supports jQuery v. 1.8 >= 2.2.4. No pull requests will become merged in but feel free to fork and do whatever you like! + +[](https://travis-ci.org/victorjonsson/jQuery-Form-Validator/builds/) + +[](https://www.npmjs.com/package/jquery-form-validator) *Usage example* @@ -31,7 +33,6 @@ particular form. - - -