forked from guillaumepotier/Parsley.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 66e756c
Showing
14 changed files
with
6,805 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
language: node_js | ||
|
||
node_js: | ||
- 0.6 | ||
|
||
before_script: | ||
- npm install mocha-phantomjs | ||
|
||
script: ./bin/test-suite.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [[ -z "$1" ]] | ||
then | ||
echo "You must give a version number. eg: ./bin/build.sh 1.0.0" | ||
|
||
else | ||
echo "** building parsley.min.js version " $1 | ||
ruby ./bin/minify parsley.js dist/parsley.min.js $1 --force | ||
echo " done!" | ||
|
||
echo "** building parsley-standalone.min.js version " $1 | ||
ruby ./bin/minify resources/zepto-1.0rc1[zepto.event.data].min.js parsley.js dist/parsley-standalone.min.js $1 --force | ||
echo " done!" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env ruby | ||
|
||
# heavily inspired by https://gist.github.com/765432 :) | ||
|
||
dry_run = ARGV.delete('--dry-run') | ||
force = ARGV.delete('--force') | ||
|
||
input, output, garlic_version = ARGV.length == 1 ? | ||
[ARGV, ARGV.first.sub(/\.js$/, '.min.js'), 'x.x.x'] : | ||
[ARGV[0..-3], ARGV.at(-2), ARGV.last] | ||
|
||
if (missing = input.select { |path| !File.exists?(path) }).any? | ||
puts "Some input files do not exist:\n #{missing.join(" \n")}" | ||
exit 1 | ||
end | ||
|
||
if File.exists?(output) && !force | ||
puts "Output file #{output} already exists, use the --force to overwrite" | ||
exit 1 | ||
end | ||
|
||
if dry_run | ||
puts "#{input.inspect} => #{output}" | ||
else | ||
require 'rubygems' | ||
|
||
begin | ||
require 'closure-compiler' | ||
rescue LoadError | ||
puts "Error loading Closure Compiler gem:\n gem install closure-compiler" | ||
exit 1 | ||
end | ||
|
||
File.open(output, 'w') do |f| | ||
f.write "/* Garlicjs %s build version %s http://garlicjs.org */\n" % | ||
[output, garlic_version] | ||
f.write Closure::Compiler.new.compile(input.map { |file| | ||
File.read(file) | ||
}) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
mocha-phantomjs tests/index.html && mocha-phantomjs tests/index.html#jquery-min && mocha-phantomjs tests/index.html#zepto && mocha-phantomjs tests/index.html#zepto-min && mocha-phantomjs tests/index.html#standalone |
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* | ||
Parsley.js allows you to verify your form inputs frontend side, without writing a line of javascript. Or so.. | ||
author: Guillaume Potier - @guillaumepotier | ||
*/ | ||
|
||
!function ($) { | ||
|
||
"use strict"; | ||
|
||
/* PARSLEY PUBLIC CLASS DEFINITION | ||
* =============================== */ | ||
var Parsley = function ( element, options ) { | ||
this.init( 'parsley', element, options ); | ||
} | ||
|
||
Parsley.prototype = { | ||
|
||
constructor: Parsley | ||
|
||
/* init data, bind jQuery on() actions */ | ||
, init: function ( type, element, options ) { | ||
this.type = type; | ||
this.$element = $( element ); | ||
this.options = this.getOptions( options ); | ||
this.parentForm = this.$element.closest( 'form' ); | ||
this.$element.addClass( 'parsley-validated' ); | ||
|
||
// bind parsley verification events | ||
// this.$element.on( this.options.events.join( '.' + this.type + ' ') , false, $.proxy( this.persist, this ) ); | ||
} | ||
|
||
, getOptions: function ( options ) { | ||
options = $.extend( {}, $.fn[this.type].defaults, options, this.$element.data() ); | ||
|
||
return options; | ||
} | ||
} | ||
|
||
/* PARSLEY PLUGIN DEFINITION | ||
* ========================= */ | ||
|
||
$.fn.parsley = function ( option, fn ) { | ||
var options = $.extend(true, {}, $.fn.parsley.defaults, option, this.data() ) | ||
, returnValue = false; | ||
|
||
function bind ( self ) { | ||
var $this = $( self ) | ||
, data = $this.data( 'parsley' ) | ||
, fieldOptions = $.extend( {}, options, $this.data() ); | ||
|
||
// if data never binded, bind it right now! | ||
if ( !data ) { | ||
$this.data( 'parsley', ( data = new Parsley( self, fieldOptions ) ) ); | ||
} | ||
|
||
// here is our parsley public function accessor, currently does not support args | ||
if ( 'string' === typeof option && 'function' === typeof data[option] ) { | ||
return data[option](); | ||
} | ||
} | ||
|
||
// loop through every elemt we want to parsley | ||
this.each(function () { | ||
// if a form elem is given, bind all its input children | ||
if ( $( this ).is( 'form' ) ) { | ||
$( this ).find( options.inputs ).each( function () { | ||
returnValue = bind( $( this ) ); | ||
}); | ||
|
||
// if it is a Parsley supported single element, bind it too | ||
// add here a return instance, cuz' we could call public methods on single elems with data[option]() above | ||
} else if ( $( this ).is( options.inputs ) ) { | ||
returnValue = bind( $( this ) ); | ||
} | ||
}); | ||
|
||
return 'function' === typeof fn ? fn() : returnValue; | ||
} | ||
|
||
/* PARSLEY CONFIGS & OPTIONS | ||
* ========================= */ | ||
$.fn.parsley.Constructor = Parsley; | ||
|
||
$.fn.parsley.defaults = { | ||
inputs: 'input, textarea, select' // Default supported inputs. | ||
} | ||
|
||
/* PARSLEY DATA-API | ||
* =============== */ | ||
$( window ).on( 'load', function () { | ||
$( '[data-validate="parsley"]' ).each( function () { | ||
$(this).parsley(); | ||
}) | ||
}); | ||
|
||
// This plugin works with jQuery or Zepto (with data extension builded for Zepto.) | ||
}(window.jQuery || window.Zepto); |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.