@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
3 lines (2 loc) • 3.85 kB
JavaScript
!function(e){"function"==typeof define&&define.amd?define(["kendo.core.min","kendo.floatinglabel.min","kendo.icons.min"],e):e()}((function(){var e,n,t,l,a,i,o,s,r,d,u,p,c,f,b,h,g;e=window.kendo.jQuery,t=window.kendo,l=t.ui.Widget,a=t.ui,i=e.isPlainObject,o=".kendoTextBox",s="change",r="disabled",d="readonly",u="k-input-inner",p="input",c="k-focus",f="k-disabled",b="k-no-click",h="aria-disabled",g=l.extend({init:function(a,i){var o=this;l.fn.init.call(o,a,i),i=e.extend(!0,{},i),o.options.value=i.value||o.element.val(),o.options.readonly=i.readonly!==n?i.readonly:Boolean(o.element.attr("readonly")),o.options.enable=i.enable!==n?i.enable:!Boolean(o.element.attr("disabled")),o.options.placeholder=i.placeholder||o.element.attr("placeholder"),o.value(o.options.value),o._wrapper(),o._label(),o._editable({readonly:o.options.readonly,disable:!o.options.enable}),o.element.addClass(u).attr("placeholder",o.options.placeholder).attr("autocomplete","off"),i.icon&&o._icon(),t.notify(o),o._applyCssClasses()},events:[s,p],options:{name:"TextBox",value:"",readonly:!1,enable:!0,placeholder:"",label:null,rounded:"medium",size:"medium",fillMode:"solid",icon:null},value:function(e){var t=this;if(e===n)return t._value;t._value=e,t.element.val(e),t.floatingLabel&&t.floatingLabel.refresh()},readonly:function(e){this._editable({readonly:e===n||e,disable:!1}),this.floatingLabel&&this.floatingLabel.readonly(e===n||e)},enable:function(e){this._editable({readonly:!1,disable:!(e=e===n||e)}),this.floatingLabel&&this.floatingLabel.enable(e=e===n||e)},focus:function(){this.element[0].focus()},destroy:function(){var e=this;e.floatingLabel&&e.floatingLabel.destroy(),e.element.off(o),e.element[0].style.width="",e.element.removeClass(u),l.fn.destroy.call(e)},setOptions:function(e){this.destroy(),this._inputLabel&&(this._inputLabel.remove(),this._inputLabel=null),this._floatingLabelContainer?(this.floatingLabel.destroy(),this.floatingLabel=null,this.element.unwrap(),this.element.unwrap(),this._floatingLabelContainer=null):this.element.unwrap(),t.deepExtend(this.options,e),this.init(this.element,this.options)},_editable:function(e){var n=this,t=n.element,l=n.wrapper,a=e.disable,i=e.readonly;t.off(o),i||a?(t.attr(r,a).attr(d,i).attr(h,a),l.toggleClass(f,a).toggleClass(b,i)):(t.prop(r,!1).prop(d,!1).attr(h,!1),l.removeClass(f).removeClass(b),t.on("focusin"+o,n._focusin.bind(n)),t.on("focusout"+o,n._focusout.bind(n)),t.on("change"+o,n._change.bind(n)),t.on(p+o,n._input.bind(n)))},_icon:function(){this.wrapper.prepend(t.ui.icon({icon:this.options.icon,iconClass:"k-input-icon"}))},_input:function(e){var n=this.element.val();this.trigger(p,{value:n,originalEvent:e})},_label:function(){var n,l,a=this,o=a.element,s=a.options,r=o.attr("id");null!==s.label&&(n=!!i(s.label)&&s.label.floating,l=i(s.label)?s.label.content:s.label,n&&(a._floatingLabelContainer=a.wrapper.wrap("<span></span>").parent(),a.floatingLabel=new t.ui.FloatingLabel(a._floatingLabelContainer,{widget:a})),t.isFunction(l)&&(l=l.call(a)),l||(l=""),r||(r=s.name+"_"+t.guid(),o.attr("id",r)),a._inputLabel=e("<label class='k-label k-input-label' for='"+r+"'>"+l+"</label>'").insertBefore(a.wrapper))},_focusin:function(){this.wrapper.addClass(c)},_focusout:function(){this.wrapper.removeClass(c)},_change:function(e){var n=this,t=n.element.val();n._value=t,n.trigger(s,{value:t,originalEvent:e})},_wrapper:function(){var e,n=this.element,t=n[0];(e=n.wrap("<span class='k-input k-textbox'></span>").parent())[0].style.cssText=t.style.cssText,t.style.width="100%",this.wrapper=e.addClass(t.className).removeClass("input-validation-error")}}),t.cssProperties.registerPrefix("TextBox","k-input-"),t.cssProperties.registerValues("TextBox",[{prop:"rounded",values:t.cssProperties.roundedValues.concat([["full","full"]])}]),a.plugin(g)}));
//# sourceMappingURL=kendo.textbox.min.js.map