/*
* Kendo UI Beta v2013.2.716 (http://kendoui.com)
* Copyright 2013 Telerik AD. All rights reserved.
*
* Kendo UI Beta license terms available at
* http://www.kendoui.com/purchase/license-agreement/kendo-ui-beta.aspx
*/
("function"==typeof define&&define.amd?define:function(e,t){return t()})(["./kendo.list.min"],function(){!function(e,t){var n=window.kendo,a=n.ui,s=a.List,o=a.Select,i=n.support,r=i.placeholder,l=n._activeElement,c=n.keys,u=".kendoComboBox",d="click"+u,p="mousedown"+u,_="disabled",h="readonly",f="change",g="k-state-default",v="k-state-focused",m="k-state-disabled",x="aria-disabled",C="aria-readonly",y="k-state-selected",w="filter",b="accept",k="rebind",L="mouseenter"+u+" mouseleave"+u,S=null,T=e.proxy,B=o.extend({init:function(t,a){var s,i=this;i.ns=u,a=e.isArray(a)?{dataSource:a}:a,o.fn.init.call(i,t,a),i._focusHandler=function(){i.input.focus()},a=i.options,t=i.element.on("focus"+u,i._focusHandler),a.placeholder=a.placeholder||t.attr("placeholder"),i._reset(),i._wrapper(),i._input(),i._tabindex(i.input),i._popup(),i._dataSource(),i._ignoreCase(),i._enable(),i._cascade(),i._aria(),i._oldIndex=i.selectedIndex=-1,a.autoBind?i._filterSource():(s=a.text,!s&&i._isSelect&&(s=t.children(":selected").text()),s&&(i.input.val(s),i._prev=s)),s||i._placeholder(),n.notify(i)},options:{name:"ComboBox",enabled:!0,index:-1,text:null,value:null,autoBind:!0,delay:200,dataTextField:"",dataValueField:"",minLength:0,height:200,highlightFirst:!0,template:"",filter:"none",placeholder:"",suggest:!1,ignoreCase:!0,animation:{}},events:["open","close",f,"select","dataBinding","dataBound","cascade"],setOptions:function(e){o.fn.setOptions.call(this,e),this._template(),this._accessors(),this._aria()},current:function(e){var n=this,a=n._current;return e===t?a:(a&&a.removeClass(y),o.fn.current.call(n,e),t)},destroy:function(){var e=this;e.input.off(u),e.element.off(u),e._inputWrapper.off(u),o.fn.destroy.call(e)},_editable:function(e){var t=this,n=e.disable,a=e.readonly,s=t._inputWrapper.off(u),o=t.element.add(t.input.off(u)),i=t._arrow.parent().off(d+" "+p);a||n?(s.addClass(n?m:g).removeClass(n?g:m),o.attr(_,n).attr(h,a).attr(x,n).attr(C,a)):(s.addClass(g).removeClass(m).on(L,t._toggleHover),o.removeAttr(_).removeAttr(h).attr(x,!1).attr(C,!1),i.on(d,function(){t.toggle()}).on(p,function(e){e.preventDefault()}),t.input.on("keydown"+u,T(t._keydown,t)).on("focus"+u,function(){s.addClass(v),t._placeholder(!1)}).on("blur"+u,function(){s.removeClass(v),clearTimeout(t._typing),t.options.text!==t.input.val()&&t.text(t.text()),t._placeholder(),t._blur(),t.element.blur()}))},open:function(){var e=this,t=e.dataSource.options.serverFiltering;e.popup.visible()||(!e.ul[0].firstChild||e._state===b&&!t?(e._open=!0,e._state=k,e._filterSource()):(e.popup.open(),e._scroll(e._current)))},refresh:function(){var a,s,o,i=this,r=i.ul[0],c=i.options,u=i._state,d=i._data(),p=d.length;i.trigger("dataBinding"),r.innerHTML=n.render(i.template,d),i._height(p),i.popup.visible()&&i.popup._position(),i._isSelect&&(u===k&&(i._state="",a=i.value()),o=i._option,i._option=t,i._options(d),o&&o[0].selected&&i._custom(o.val())),p&&(c.highlightFirst&&i.current(e(r.firstChild)),c.suggest&&i.input.val()&&i._request!==t&&i.suggest(e(r.firstChild))),u===w||i._fetch||i._selectItem(),i._open&&(i._open=!1,s=!!p,i._typing&&i.input[0]!==l()&&(s=!1),i.toggle(s),i._typing=t),i._touchScroller&&i._touchScroller.reset(),i._makeUnselectable(),i._hideBusy(),i._bound=!0,i.trigger("dataBound")},search:function(e){e="string"==typeof e?e:this.text();var t=this,n=e.length,a=t.options,s=a.ignoreCase,o=a.filter,i=a.dataTextField;clearTimeout(t._typing),n>=a.minLength&&(t._state=w,"none"===o?t._filter(e):(t._open=!0,t._filterSource({value:s?e.toLowerCase():e,field:i,operator:o,ignoreCase:s})))},suggest:function(e){var n,a=this,o=a.input[0],i=a.text(),r=s.caret(o),l=a._last;return l==c.BACKSPACE||l==c.DELETE?(a._last=t,t):(e=e||"","string"!=typeof e&&(n=s.inArray(e[0],a.ul[0]),e=n>-1?a._text(a.dataSource.view()[n]):""),0>=r&&(r=i.toLowerCase().indexOf(e.toLowerCase())+1),e?(n=e.toLowerCase().indexOf(i.toLowerCase()),n>-1&&(i+=e.substring(n+i.length))):i=i.substring(0,r),i.length===r&&e||(o.value=i,s.selectText(o,r,i.length)),t)},text:function(e){e=null===e?"":e;var n,a=this,s=a._text,o=a.input[0],i=a.options.ignoreCase,r=e;return e===t?o.value:(n=a.dataItem(),n&&s(n)===e?(a._triggerCascade(),t):(i&&(r=r.toLowerCase()),a._select(function(e){return e=s(e),i&&(e=(e+"").toLowerCase()),e===r}),a.selectedIndex<0&&(a._custom(e),o.value=e),a._prev=o.value,a._triggerCascade(),t))},toggle:function(e){var t=this;t._toggle(e)},value:function(e){var n,a=this;return e===t?a._accessor():(null!==e&&(e=""+e),a._selectedValue=e,!a._open&&e&&a._fetchItems(e)||(n=a._index(e),n>-1?a.select(n):(a.current(S),a._custom(e),a.text(e),a._placeholder()),a._old=a._accessor(),a._oldIndex=a.selectedIndex),t)},_accept:function(e){var t=this;e?t._focus(e):(t.text(t.text()),t._change())},_custom:function(t){var n=this,a=n.element,s=n._option;n._state===w&&(n._state=b),n._isSelect?(s||(s=n._option=e(""),a.append(s)),s.text(t),s[0].selected=!0):a.val(t),n._selectedValue=t},_filter:function(e){var n=this,a=n.options,s=n.dataSource,o=a.ignoreCase,i=function(a){var s=n._text(a);return s!==t?(s+="",""!==s&&""===e?!1:(o&&(s=s.toLowerCase()),0===s.indexOf(e))):t};return o&&(e=e.toLowerCase()),n.ul[0].firstChild?(-1!==n._highlight(i)&&(a.suggest&&n._current&&n.suggest(n._current),n.open()),n._hideBusy(),t):(s.one(f,function(){s.data()[0]&&n.search(e)}).fetch(),t)},_highlight:function(n){var a,o=this;return n===t||null===n?-1:(n=o._get(n),a=s.inArray(n[0],o.ul[0]),-1==a&&(n=o.options.highlightFirst&&!o.text()?e(o.ul[0].firstChild):S),o.current(n),a)},_input:function(){var t,n=this,a=n.element.removeClass("k-input")[0],s=a.accessKey,o=n.wrapper,i="input.k-input",l=a.name||"";l&&(l='name="'+l+'_input" '),t=o.find(i),t[0]||(o.append('select').append(n.element),t=o.find(i)),t[0].style.cssText=a.style.cssText,a.maxLength>-1&&(t[0].maxLength=a.maxLength),t.addClass(a.className).val(a.value).css({width:"100%",height:a.style.height}).attr({role:"combobox","aria-expanded":!1}).show(),r&&t.attr("placeholder",n.options.placeholder),s&&(a.accessKey="",t[0].accessKey=s),n._focused=n.input=t,n._inputWrapper=e(o[0].firstChild),n._arrow=o.find(".k-icon").attr({role:"button",tabIndex:-1}),a.id&&n._arrow.attr("aria-controls",n.ul[0].id)},_keydown:function(e){var t=this,n=e.keyCode;t._last=n,clearTimeout(t._typing),n==c.TAB||t._move(e)||t._search()},_placeholder:function(e){if(!r){var n,a=this,s=a.input,o=a.options.placeholder;if(o){if(n=a.value(),e===t&&(e=!n),s.toggleClass("k-readonly",e),!e){if(n)return;o=""}s.val(o)}}},_search:function(){var e=this;e._typing=setTimeout(function(){var t=e.text();e._prev!==t&&(e._prev=t,e.search(t))},e.options.delay)},_select:function(e){var n,a,s=this,o=s._data(),i=s._highlight(e);s.selectedIndex=i,-1!==i&&(s._state===w&&(s._state=b),s._current.addClass(y),o=o[i],n=s._text(o),a=s._value(o),s._prev=s.input[0].value=n,s._accessor(a!==t?a:n,i),s._selectedValue=s._accessor(),s._placeholder(),s._optionID&&s._current.attr("aria-selected",!0))},_wrapper:function(){var e=this,t=e.element,n=t.parent();n.is("span.k-widget")||(n=t.hide().wrap("").parent(),n[0].style.cssText=t[0].style.cssText),e.wrapper=n.addClass("k-widget k-combobox k-header").addClass(t[0].className).css("display","")},_clearSelection:function(e,t){var n=this,a=e._selectedValue||e.value(),s=a&&-1===e.selectedIndex;(t||!a||s)&&n.value("")}});a.plugin(B)}(window.kendo.jQuery)});