var _____WB$wombat$assign$function_____ = function(name) {return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name)) || self[name]; }; if (!self.__WB_pmw) { self.__WB_pmw = function(obj) { this.__WB_source = obj; return this; } } { let window = _____WB$wombat$assign$function_____("window"); let self = _____WB$wombat$assign$function_____("self"); let document = _____WB$wombat$assign$function_____("document"); let location = _____WB$wombat$assign$function_____("location"); let top = _____WB$wombat$assign$function_____("top"); let parent = _____WB$wombat$assign$function_____("parent"); let frames = _____WB$wombat$assign$function_____("frames"); let opener = _____WB$wombat$assign$function_____("opener"); $k.fn.maskInput = function (config) { var obj = function (selector, config) { this.selector = selector; this.config = $.extendEx({}, this.defConfig, config); } obj.prototype.defConfig = { color:'gray' }; obj.prototype.setPosition = function () { var _obj = this; var maskPanel = _obj.maskPanel; maskPanel.css('left', _obj.selector.offset().left); maskPanel.css('top', _obj.selector.offset().top); maskPanel.css('width', _obj.selector.width()); maskPanel.css('height', _obj.selector.outerHeight()); }; obj.prototype.maskInput = function () { var _obj = this; var maskPanel = $('
' + _obj.config.text + '
').appendTo($('body')); _obj.maskPanel = maskPanel; _obj.setPosition(); maskPanel.css('line-height', _obj.selector.outerHeight()+'px'); maskPanel.css('padding-left', _obj.selector.css('padding-left')); maskPanel.mousedown(function () { $(this).hide(); window.setTimeout(function () { _obj.selector[0].focus(); },100); }); _obj.selector.focus(function () { maskPanel.hide(); }); _obj.selector.blur(function () { if($(this).val()==''){ maskPanel.show(); } }); if (_obj.selector.val() != '') { maskPanel.hide(); } } var _obj = new obj($(this.jo), config || {}); $(window).resize(function () { //_obj.maskInput(); _obj.setPosition(); }); $(window).scroll(function () { //_obj.maskInput(); _obj.setPosition(); }); _obj.maskInput(); return _obj; } //实现自动调用. $(function () { $.each($('input'), function (i, o) { var maskText=$(o).attr('mask-text'); if (maskText) { $k(o).maskInput({ text: maskText }); } }); }); }