hdw
2018-11-21 47baad903367aab2cc21475ee8b15bb25a90fc97
gx_tieta/WebRoot/js/whyc-jqueryui.js
@@ -490,6 +490,7 @@
   // 根据数据的正确性修改文本框的样式
   _proto.changeVal = function() {
      var testVal = this;
      this.ele.off('input propertychange blur focus');
      
      // 文本框内容改变
      this.ele.on('input propertychange', function() {
@@ -515,9 +516,17 @@
         ele.myTooltip('hide');
         ele.removeClass('error-data');
         
         testVal.opts.btn.removeClass('whyc-btn-disabled');
         // 遍历testVal.opts.btn的值
         testVal.opts.btn.each(function() {
            if(!$(this).hasClass('error-data')) {
               $(this).removeClass('whyc-btn-disabled');
            }
            $(this).removeClass('error-data');
         });
      }else {
         ele.next('i').addClass('error-data');
         //console.log(testVal.opts.msg);
         ele.myTooltip({
                position: testVal.opts.position,
                thing: 'show',
@@ -525,6 +534,15 @@
                content: '<span style="color:#FF0000">'+testVal.opts.msg+'</span>'
         });
         ele.addClass('error-data');
         // 遍历testVal.opts.btn的值
         testVal.opts.btn.each(function() {
            if(!$(this).hasClass('whyc-btn-disabled') && !$(this).hasClass('error-data')) {
               $(this).addClass('whyc-btn-disabled');
            }else {
               $(this).addClass('whyc-btn-disabled error-data');
            }
         });
         
         testVal.opts.btn.addClass('whyc-btn-disabled');
      }
@@ -548,10 +566,11 @@
      
      return flag;
   };
   _proto.error = function() {
      console.info(this.opts.msg);
   };
   $.fn.testVal = function(options) {
   $.fn.testVal = function(options, attr, val) {
      var defaults = {
         pattern: "",
         event: "changeVal",
@@ -563,13 +582,24 @@
         max: 0,
         position: 'bottom'
      };
      var opts = $.extend(true, {}, defaults, options||{});
      var opts = {};
      // 判断是否为更新配置项
      if(isString(options)) {
         var oldOpts = this.data('testVal');
         opts = $.extend({}, opts, oldOpts);
         opts[attr] = val;
      }else if(isObject(options)){
         opts = $.extend(true, {}, defaults, options||{});
      }
      // console.log(opts);
      if(opts.pattern.constructor.name != 'RegExp') {
         opts.event = "error";
         opts.msg = '请输入正确的正则表达式格式!!!'
      }
      
      var testVal = new TestVal(this, opts);
      this.data('testVal', testVal.opts);
      testVal[opts.event]();
      
      return this;