diff --git a/bower.json b/bower.json index 928dde9..ae5eaad 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "validetta", "description": "A tiny jquery plugin for validate your forms", - "version": "1.0.0", + "version": "1.0.1", "homepage": "http://lab.hasanaydogdu.com/validetta/", "author": { "name": "Hasan Aydoğdu", diff --git a/dist/validetta.css b/dist/validetta.css index 0c86760..f4352e6 100644 --- a/dist/validetta.css +++ b/dist/validetta.css @@ -1,42 +1,41 @@ -/*! - * Validetta (http://lab.hasanaydogdu.com/validetta/) - * Version 1.0.0 ( 04-02-2015 ) - * Licensed under MIT (https://github.com/hsnayd/validetta/blob/master/LICENCE) - * Copyright 2013-2015 Hasan Aydoğdu - http://www.hasanaydogdu.com - */ - -.validetta-bubble { - position: absolute; - background-color: #cd2e26; - max-width: 325px; - border-radius: 5px; - color: white; - padding: 5px 12px; - z-index: 9; } - .validetta-bubble--right:before { - top: 7px; - left: -10px; - border-color: transparent #cd2e26 transparent transparent; } - .validetta-bubble--bottom:before { - top: -10px; - left: 10px; - border-color: transparent transparent #cd2e26 transparent; } - -.validetta-bubble:before { - content: ''; - position: absolute; - display: block; - height: 0; - width: 0; - border-width: 5px; - border-style: solid; } - -.validetta-inline, -.validetta-bubble { - display: block; - font: 12px/14px Arial, Helvetica, sans-serif; } - -.validetta-inline { - color: #cd2e26; } - -/*# sourceMappingURL=validetta.css.map */ +/*! + * Validetta (http://lab.hasanaydogdu.com/validetta/) + * Version 1.0.1 ( 16-08-2015 ) + * Licensed under MIT (https://github.com/hsnayd/validetta/blob/master/LICENCE) + * Copyright 2013-2015 Hasan Aydoğdu - http://www.hasanaydogdu.com + */ + +.validetta-bubble { + position: absolute; + background-color: #cd2e26; + max-width: 325px; + border-radius: 5px; + color: white; + padding: 5px 12px; + z-index: 9; } + .validetta-bubble:before { + content: ''; + position: absolute; + display: block; + height: 0; + width: 0; + border-width: 5px; + border-style: solid; } + .validetta-bubble--right:before { + top: 7px; + left: -10px; + border-color: transparent #cd2e26 transparent transparent; } + .validetta-bubble--bottom:before { + top: -10px; + left: 10px; + border-color: transparent transparent #cd2e26 transparent; } + +.validetta-inline, +.validetta-bubble { + display: block; + font: 12px/14px Arial, Helvetica, sans-serif; } + +.validetta-inline { + color: #cd2e26; } + +/*# sourceMappingURL=validetta.css.map */ diff --git a/dist/validetta.js b/dist/validetta.js index c0b0df5..50c43a8 100644 --- a/dist/validetta.js +++ b/dist/validetta.js @@ -1,10 +1,10 @@ -/*! - * Validetta (http://lab.hasanaydogdu.com/validetta/) - * Version 1.0.0 ( 04-02-2015 ) - * Licensed under MIT (https://github.com/hsnayd/validetta/blob/master/LICENCE) - * Copyright 2013-2015 Hasan Aydoğdu - http://www.hasanaydogdu.com - */ - +/*! + * Validetta (http://lab.hasanaydogdu.com/validetta/) + * Version 1.0.1 ( 16-08-2015 ) + * Licensed under MIT (https://github.com/hsnayd/validetta/blob/master/LICENCE) + * Copyright 2013-2015 Hasan Aydoğdu - http://www.hasanaydogdu.com + */ + ;(function( $ ) { "use strict"; /** @@ -48,12 +48,13 @@ errorTemplateClass : 'validetta-bubble', // Class of the element that would receive error message errorClass : 'validetta-error', // Class that would be added on every failing validation field validClass : 'validetta-valid', // Same for valid validation - bubblePosition: 'right', + bubblePosition: 'right', // Bubble position // right / bottom + bubbleGapLeft: 15, // Right gap of bubble + bubbleGapTop: 0, // Top gap of bubble realTime : false, // To enable real-time form control, set this option true. onValid : function(){}, // This function to be called when the user submits the form and there is no error. onError : function(){}, // This function to be called when the user submits the form and there are some errors - custom : {}, // Costum reg method variable - remote : {} + validators: {} // Custom validators stored in this variable }, /** @@ -106,10 +107,10 @@ }, // equalTo check equalTo : function( tmp, self ) { - return $( self.form ).find('input[name="'+ tmp.arg +'"]').val() === tmp.val || messages.notEqual; + return self.form.querySelector('input[name="'+ tmp.arg +'"]').value === tmp.val || messages.notEqual; }, different: function( tmp, self ) { - return $( self.form ).find('input[name="'+ tmp.arg +'"]').val() !== tmp.val || messages.different; + return self.form.querySelector('input[name="'+ tmp.arg +'"]').value !== tmp.val || messages.different; }, /** * Credit Card Control @@ -163,7 +164,7 @@ }, // Radio radio : function( el ) { - var count = $( this.form.querySelectorAll('input[type=radio][name="'+ el.name +'"]') ).filter(':checked').length ; + var count = this.form.querySelectorAll('input[type=radio][name="'+ el.name +'"]:checked').length; return count === 1; }, // Custom reg check @@ -349,7 +350,7 @@ checkRemote : function( el, e ) { var ajaxOptions = {}, data = {}, - fieldName = el.name || el.getAttribute('id'); + fieldName = el.name || el.id; if ( typeof this.remoteCache === 'undefined' ) this.remoteCache = {}; @@ -462,34 +463,25 @@ // If the parent element undefined, that means el is an object. So we need to transform to the element if( typeof elParent === 'undefined' ) elParent = el[0].parentNode; // if there is an error window which previously opened for el, return - if( $( elParent ).find( '.'+ this.options.errorTemplateClass ).length ) return; + if ( elParent.querySelectorAll( '.'+ this.options.errorTemplateClass ).length ) return; // Create the error window object which will be appear var errorObject = document.createElement('span'); errorObject.className = this.options.errorTemplateClass + ' '+this.options.errorTemplateClass + '--' + this.options.bubblePosition; // if error display is bubble, calculate to positions if( this.options.display === 'bubble' ) { - var pos, W, H; + var pos, W = 0, H = 0; // !! Here, JQuery functions are using to support the IE8 pos = $( el ).position(); if ( this.options.bubblePosition === 'bottom' ){ - H = el.clientHeight; - if ( H === 0 ) { - pos = $(el.parentNode).position(); - H = el.parentNode.clientHeight; - } - pos.top += H +10; - pos.left -= 5; + H = el.offsetHeight; } else { - W = $( el ).outerWidth(true); - pos.left += W + 15; + W = el.offsetWidth; } - - $( errorObject ).empty().css({ - 'left' : pos.left +'px', - 'top' : pos.top +'px' - }); + errorObject.innerHTML = ''; + errorObject.style.top = pos.top + H + this.options.bubbleGapTop +'px'; + errorObject.style.left = pos.left + W + this.options.bubbleGapLeft +'px' } elParent.appendChild( errorObject ); errorObject.innerHTML = error ; @@ -519,7 +511,7 @@ // if el is undefined ( This is the process of resetting all