/** * jQuery webUI 1.1.0 * * */ (function ($) { $.webDefaults = $.webDefaults || {}; $.webDefaults.TextBox = { onBeforeInput: null, onInputed: null, onChangeValue: null, width: null }; /// $.fn.webTextBox = function (options) { return this.each(function () { if (this.usedTextBox) return; var p = $.extend({}, options || {}); if ($(this).attr("webui")) { try { var attroptions = $(this).attr("webui"); if (attroptions.indexOf('{') < 0) attroptions = "{" + attroptions + "}"; eval("attroptions = " + attroptions + ";"); if (attroptions) p = $.extend({}, attroptions, p || {}); } catch (e) { } } p = $.extend({}, $.webDefaults.TextBox, p || {}); var g = {}; g.inputText = $(this); //外层 g.wrapper = g.inputText.wrap('
').parent(); g.wrapper.append('
'); if (!g.inputText.hasClass("n-text-field")) g.inputText.addClass("n-text-field"); if (!p.width) { p.width = 140; } g.wrapper.css({ width: p.width }); g.inputText.css({ width: p.width - 4 }); if (p.height) { g.wrapper.height(p.height); g.inputText.height(p.height - 2); } g.inputText .bind('blur.webTextBox', function () { g.wrapper.removeClass("n-text-focus"); }).bind('focus.webTextBox', function () { g.wrapper.addClass("n-text-focus"); }) .change(function () { if (p.onChangeValue) { p.onChangeValue(this.value); } }); g.wrapper.hover(function () { g.wrapper.addClass("n-text-over"); }, function () { g.wrapper.removeClass("n-text-over"); }); this.usedTextBox = true; }); }; })(jQuery);