16 lines
7.0 KiB
JavaScript
16 lines
7.0 KiB
JavaScript
|
/**
|
||
|
* Copyright 2014 Telerik AD
|
||
|
*
|
||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
* you may not use this file except in compliance with the License.
|
||
|
* You may obtain a copy of the License at
|
||
|
*
|
||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||
|
*
|
||
|
* Unless required by applicable law or agreed to in writing, software
|
||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
* See the License for the specific language governing permissions and
|
||
|
* limitations under the License.
|
||
|
*/
|
||
|
!function(e,define){define(["./kendo.list.min","./kendo.mobile.scroller.min"],e)}(function(){return function(e,t){function n(e,t,n){return n?t.substring(0,e).split(n).length-1:0}function i(e,t,i){return t.split(i)[n(e,t,i)]}function r(e,t,i,r){var o=t.split(r);return o.splice(n(e,t,r),1,i),r&&""!==o[o.length-1]&&o.push(""),o.join(r)}var o=window.kendo,a=o.support,s=o.caret,l=o._activeElement,u=a.placeholder,c=o.ui,d=c.List,f=o.keys,h=o.data.DataSource,p="aria-disabled",g="aria-readonly",m="k-state-default",v="disabled",_="readonly",y="k-state-focused",b="k-state-selected",w="k-state-disabled",x="k-state-hover",k=".kendoAutoComplete",C="mouseenter"+k+" mouseleave"+k,T=e.proxy,S=d.extend({init:function(t,n){var i,r=this;r.ns=k,n=e.isArray(n)?{dataSource:n}:n,d.fn.init.call(r,t,n),t=r.element,n=r.options,n.placeholder=n.placeholder||t.attr("placeholder"),u&&t.attr("placeholder",n.placeholder),r._wrapper(),r._loader(),r._dataSource(),r._ignoreCase(),t[0].type="text",i=r.wrapper,r._popup(),t.addClass("k-input").on("keydown"+k,T(r._keydown,r)).on("paste"+k,T(r._search,r)).on("focus"+k,function(){r._prev=r._accessor(),r._placeholder(!1),i.addClass(y)}).on("focusout"+k,function(){r._change(),r._placeholder(),i.removeClass(y)}).attr({autocomplete:"off",role:"textbox","aria-haspopup":!0}),r._enable(),r._old=r._accessor(),t[0].id&&t.attr("aria-owns",r.ul[0].id),r._aria(),r._placeholder(),o.notify(r)},options:{name:"AutoComplete",enabled:!0,suggest:!1,template:"",dataTextField:"",minLength:1,delay:200,height:200,filter:"startswith",ignoreCase:!0,highlightFirst:!1,separator:null,placeholder:"",animation:{},value:null},_dataSource:function(){var e=this;e.dataSource&&e._refreshHandler?e._unbindDataSource():(e._refreshHandler=T(e.refresh,e),e._progressHandler=T(e._showBusy,e)),e.dataSource=h.create(e.options.dataSource).bind("change",e._refreshHandler).bind("progress",e._progressHandler)},setDataSource:function(e){this.options.dataSource=e,this._dataSource()},events:["open","close","change","select","dataBinding","dataBound"],setOptions:function(e){d.fn.setOptions.call(this,e),this._template(),this._accessors(),this._aria()},_editable:function(e){var t=this,n=t.element,i=t.wrapper.off(k),r=e.readonly,o=e.disable;r||o?(i.addClass(o?w:m).removeClass(o?m:w),n.attr(v,o).attr(_,r).attr(p,o).attr(g,r)):(i.addClass(m).removeClass(w).on(C,t._toggleHover),n.removeAttr(v).removeAttr(_).attr(p,!1).attr(g,!1))},close:function(){var e=this,t=e._current;t&&t.removeClass(b),e.current(null),e.popup.close()},destroy:function(){var e=this;e.element.off(k),e.wrapper.off(k),d.fn.destroy.call(e)},refresh:function(){var n,i=this,r=i.ul[0],a=i.popup,s=i.options,u=i._data(),c=u.length;i._angularItems("cleanup"),i.trigger("dataBinding"),r.innerHTML=o.render(i.template,u),i._height(c),a.visible()&&a._position(),c&&(s.highlightFirst&&i.current(e(r.firstChild)),s.suggest&&i.suggest(e(r.firstChild))),i._open&&(i._open=!1,n=c?"open":"close",i._typing&&i.element[0]!==l()&&(n="close"),a[n](),i._typing=t),i._touchScroller&&i._touchScroller.reset(),i._makeUnselectable(),i._hideBusy(),i._angularItems("compile"),i.trigger("dataBound")},select:function(e){this._select(e)},search:function(e){var t,n=this,r=n.options,o=r.ignoreCase,a=r.separator;e=e||n._accessor(),n._current=null,clearTimeout(n._typing),a&&(e=i(s(n.element)[0],e,a)),t=e.length,t?t>=n.options.minLength&&(n._open=!0,n._filterSource({value:o?e.toLowerCase():e,operator:r.filter,field:r.dataTextField,ignoreCase:o})):n.popup.close()},suggest:function(e){var i,r=this,o=r._last,a=r._accessor(),u=r.element[0],c=s(u)[0],h=r.options.separator,p=a.split(h),g=n(c,a,h),m=c;return o==f.BACKSPACE||o==f.DELETE?(r._last=t,t):(e=e||"","string"!=typeof e&&(i=d.inArray(e[0],r.ul[0]),e=i>-1?r._text(r._data()[i]):""),0>=c&&(c=a.toLowerCase().indexOf(e.toLowerCase())+1),i=a.substring(0,c).lastIndexOf(h),i=i>-1?c-(i+h.length):c,a=p[g].substring(0,i),e&&(i=e.toLowerCase().indexOf(a.toLowerCase()),i>-1&&(e=e.substring(i+a.length),m=c+e.length,a+=e),h&&""!==p[p.length-1]&&p.push("")),p[g]=a,r._accessor(p.join(h||"")),u===l()&&s(u,c,m)
|