Browse Source

1.show message when get focus
2.keep error message populated from back end
3.feedback icon's position can't be adjusted by css file when there is no label or it's in input-group
4.for multiple validators, tooltip or popover is destroyed by last NOT_VALIDATED validator

Dorian 11 years ago
parent
commit
944f363495
1 changed files with 6 additions and 14 deletions
  1. 6 14
      src/js/bootstrapValidator.js

+ 6 - 14
src/js/bootstrapValidator.js

@@ -293,7 +293,7 @@
                 $field.off(events).on(events, function() {
                     that.updateStatus($(this), that.STATUS_NOT_VALIDATED);
                 });
-                //Dorian: show message when get focus
+                //show tooltip or popover message when get focus
                 $field.off("focus.showmsg.bv").on("focus.showmsg.bv", function() {
                     var $icon =$parent.find('.form-control-feedback[data-bv-icon-for="' + field + '"]');
                     if($icon.length>0 && container){
@@ -350,7 +350,7 @@
                     && (!updateAll || i === total - 1))
                 {
                     //$parent.removeClass('has-success').removeClass('has-error').addClass('has-feedback');
-                    //Dorian: keep error message populated from back end
+                    //keep error message populated from back end
                     $parent.addClass('has-feedback');
                     var $icon = $('<i/>')
                                     .css('display', 'none')
@@ -369,17 +369,9 @@
                         }
                     }
 
-                    // The feedback icon does not render correctly if there is no label
-                    // https://github.com/twbs/bootstrap/issues/12873
-                    if ($parent.find('label').length === 0) {
-                        //Dorian: feedback icon's position can't be adjusted when there is no label or it's in input-group
-                        //$icon.css('top', 0);
-                    }
                     // Fix feedback icons in input-group
                     if ($parent.find('.input-group').length !== 0) {
                         $icon.css({
-                            //Dorian: feedback icon's position can't be adjusted when there is no label or it's in input-group
-                            //'top': 0,
                             'z-index': 100
                         }).insertAfter($parent.find('.input-group').eq(0));
                     }
@@ -1021,7 +1013,8 @@
                                     placement: 'top',
                                     title: $allErrors.filter('[data-bv-result="' + that.STATUS_INVALID + '"]').eq(0).html()
                                 })
-                                : $icon.css('cursor', '').tooltip('destroy');
+                                /* multiple validator, tooltip is destroyed by last NOT_VALIDATED validator*/
+                                : $icon.tooltip('hide');
                         break;
                     // ... or popover
                     case ($icon && 'popover' === container):
@@ -1030,12 +1023,11 @@
                                     container: 'body',
                                     content: $allErrors.filter('[data-bv-result="' + that.STATUS_INVALID + '"]').eq(0).html(),
                                     html: true,
-                                    //Dorian:
-                                    container:'body',
                                     placement: 'top',
                                     trigger: 'hover click'
                                 })
-                                : $icon.css('cursor', '').popover('destroy');
+                                /* multiple validator, popover is destroyed by last NOT_VALIDATED validator*/
+                                : $icon.popover('hide');
                         break;
                     default:
                         (status === this.STATUS_INVALID) ? $errors.show() : $errors.hide();