@@ -926,6 +926,91 @@ function Foundation5ElementModifierFn() {
926926
927927angular . module ( 'jcs-autoValidate' ) . factory ( 'foundation5ElementModifier' , Foundation5ElementModifierFn ) ;
928928
929+ function foundation6ElementModifierFn ( ) {
930+ var reset = function ( el , inputEl ) {
931+ angular . forEach ( el . find ( 'small' ) , function ( smallEl ) {
932+ if ( angular . element ( smallEl ) . hasClass ( 'form-error is-visible' ) ) {
933+ angular . element ( smallEl ) . remove ( ) ;
934+ }
935+ } ) ;
936+
937+ inputEl . removeClass ( 'alert callout' ) ;
938+ } ,
939+ findParentColumn = function ( el ) {
940+ var parent = el ;
941+ for ( var i = 0 ; i <= 3 ; i += 1 ) {
942+ if ( parent !== undefined && ( parent . hasClass ( 'columns' ) || parent . hasClass ( 'column' ) ) ) {
943+ break ;
944+ } else if ( parent !== undefined ) {
945+ parent = parent . parent ( ) ;
946+ }
947+ }
948+
949+ return parent ;
950+ } ,
951+
952+ /**
953+ * @ngdoc function
954+ * @name foundation6ElementModifier#makeValid
955+ * @methodOf foundation6ElementModifier
956+ *
957+ * @description
958+ * Makes an element appear valid by apply Foundation 6 specific styles and child elements.
959+ * See: http://foundation.zurb.com/sites/docs/forms.html
960+ *
961+ * @param {Element } el - The input control element that is the target of the validation.
962+ */
963+ makeValid = function ( el ) {
964+ var parentColumn = findParentColumn ( el ) ;
965+ reset ( parentColumn && parentColumn . length > 0 ? parentColumn : el , el ) ;
966+ } ,
967+
968+ /**
969+ * @ngdoc function
970+ * @name foundation6ElementModifier#makeInvalid
971+ * @methodOf foundation6ElementModifier
972+ *
973+ * @description
974+ * Makes an element appear invalid by apply Foundation 6 specific styles and child elements.
975+ * See: http://foundation.zurb.com/sites/docs/forms.html
976+ *
977+ * @param {Element } el - The input control element that is the target of the validation.
978+ */
979+ makeInvalid = function ( el , errorMsg ) {
980+ var parentColumn = findParentColumn ( el ) ,
981+ helpTextEl ;
982+ reset ( parentColumn || el , el ) ;
983+ el . addClass ( 'alert callout' ) ;
984+ if ( parentColumn ) {
985+ helpTextEl = angular . element ( '<small class="form-error is-visible">' + errorMsg + '</small>' ) ;
986+ parentColumn . append ( helpTextEl ) ;
987+ }
988+ } ,
989+
990+ /**
991+ * @ngdoc function
992+ * @name foundation6ElementModifier#makeDefault
993+ * @methodOf foundation6ElementModifier
994+ *
995+ * @description
996+ * Makes an element appear in its default visual state by apply Foundation 6 specific styles and child elements.
997+ *
998+ * @param {Element } el - The input control element that is the target of the validation.
999+ */
1000+ makeDefault = function ( el ) {
1001+ makeValid ( el ) ;
1002+ } ;
1003+
1004+ return {
1005+ makeValid : makeValid ,
1006+ makeInvalid : makeInvalid ,
1007+ makeDefault : makeDefault ,
1008+ key : 'foundation6'
1009+ } ;
1010+ }
1011+
1012+ angular . module ( 'jcs-autoValidate' ) . factory ( 'foundation6ElementModifier' , foundation6ElementModifierFn ) ;
1013+
9291014function ElementUtilsFn ( ) {
9301015 var isElementVisible = function ( el ) {
9311016 return el [ 0 ] . offsetWidth > 0 && el [ 0 ] . offsetHeight > 0 ;
0 commit comments