/**
* Copyright <%= year %> 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){for(var i,r=0,o=t.length-1;o>r;++r)i=t[r],i in e||(e[i]={}),e=e[i];e[t[o]]=n}var i=window.kendo,r=i.ui,o=r.Select,a=i.support.mobileOS,s=".kendoDropDownList",l="disabled",u="readonly",c="change",d="k-state-focused",f="k-state-default",h="k-state-disabled",p="aria-disabled",g="aria-readonly",m="k-state-selected",v="mouseenter"+s+" mouseleave"+s,_="tabindex",y=e.proxy,b=o.extend({init:function(n,r){var a,l,u,c=this,d=r&&r.index;c.ns=s,r=e.isArray(r)?{dataSource:r}:r,o.fn.init.call(c,n,r),c._focusHandler=function(){c.wrapper.focus()},r=c.options,n=c.element.on("focus"+s,c._focusHandler),this._inputTemplate(),c._reset(),c._word="",c._wrapper(),c._tabindex(),c.wrapper.data(_,c.wrapper.attr(_)),c._aria(),c._span(),c._popup(),c._mobile(),c._dataSource(),c._ignoreCase(),c._enable(),c._oldIndex=c.selectedIndex=-1,c._cascade(),d!==t&&(r.index=d),r.autoBind?c.dataSource.fetch():-1===c.selectedIndex&&(u=r.text||"",u||(a=r.optionLabel,l=a&&0===r.index,c._isSelect?u=l?a:n.children(":selected").text():!n[0].value&&l&&(u=a)),c._textAccessor(u)),i.notify(c)},options:{name:"DropDownList",enabled:!0,autoBind:!0,index:0,text:null,value:null,template:"",valueTemplate:"",delay:500,height:200,dataTextField:"",dataValueField:"",optionLabel:"",cascadeFrom:"",cascadeFromField:"",ignoreCase:!0,animation:{}},events:["open","close",c,"select","dataBinding","dataBound","cascade"],setOptions:function(e){o.fn.setOptions.call(this,e),this._template(),this._inputTemplate(),this._accessors(),this._aria()},destroy:function(){var e=this;e.wrapper.off(s),e.element.off(s),e._inputWrapper.off(s),o.fn.destroy.call(e)},open:function(){var e=this;e.ul[0].firstChild?(e.popup.open(),e._scroll(e._current)):(e._open=!0,e._request||e.dataSource.fetch())},toggle:function(e){this._toggle(e)},refresh:function(){var e,t=this,n=t._data(),r=n.length,o=t.options.optionLabel,a=t.element[0];t.trigger("dataBinding"),t._current&&t.current(null),t.ul[0].innerHTML=i.render(t.template,n),t._height(r),t.popup.visible()&&t.popup._position(),t._isSelect&&(e=a.selectedIndex,o&&r&&(o='"),t._options(n,o),a.selectedIndex=-1===e?0:e),t._open&&(t._open=!1,t.toggle(!!r)),t._hideBusy(),t._makeUnselectable(),t._fetch||(r?t._selectItem():t._textAccessor()!==o&&(t.element.val(""),t._textAccessor(""))),t._bound=!!r,t.trigger("dataBound")},search:function(e){if(e){var n=this,i=n.options.ignoreCase;i&&(e=e.toLowerCase()),n._select(function(r){var o=n._text(r);return o!==t?(o+="",i&&(o=o.toLowerCase()),0===o.indexOf(e)):t})}},text:function(e){var n,i,r=this,o=r.options.ignoreCase;return e=null===e?"":e,e===t?r._textAccessor():("string"==typeof e&&(i=o?e.toLowerCase():e,n=r._select(function(e){return e=r._text(e),o&&(e=(e+"").toLowerCase()),e===i}),n&&(e=n)),r._textAccessor(e),t)},value:function(e){var n,i,r=this;return e===t?r._accessor():(null!==e&&(e=""+e),r._selectedValue=e,i=e||r.options.optionLabel&&!r.element[0].disabled&&""===e,i&&r._fetchItems(e)||(n=r._index(e),r.select(n>-1?n:0)),t)},_editable:function(e){var t=this,n=t.element,r=e.disable,o=e.readonly,a=t.wrapper.off(s),c=t._inputWrapper.off(v),m=function(){c.addClass(d),t._blured=!1},b=function(){if(!t._blured){t._triggerCascade();var e=window.self!==window.top;i.support.mobileOS.ios&&e?t._change():t._blur(),c.removeClass(d),t._blured=!0,n.blur()}};o||r?(r?(a.removeAttr(_),c.addClass(h).removeClass(f)):(c.addClass(f).removeClass(h),a.on("focusin"+s,m).on("focusout"+s,b)),n.attr(l,r).attr(u,o),a.attr(p,r).attr(g,o)):(n.removeAttr(l).removeAttr(u),c.addClass(f).removeClass(h).on(v,t._toggleHover),a.attr(_,a.data(_)).attr(p,!1).attr(g,!1).on("click"+s,function(e){t._blured=!1,e.preventDefault(),t.toggle()}).on("keydown"+s,y(t._keydown,t)).on("keypress"+s,y(t._keypress,t)).on("focusin"+s,m).on("focusout"+s,b))},_accept:function(e){this._focus(e)},_optionLabelText:function(){var e=this.options,t=e.dataTextField,n=e.optionLabel;return n&&t&&"object"==typeof n?this._text(n):n},_data:function(){var e=this,t=e.options,r=t.optionLabel,o=t.dataTextField,a=t.dataValueField,s=e.dataSource.view(),l=s.length,u=r,c=0;if(r&&l){for("object"==typeof r?u=r:o&&(u={},o=o.split("."),a=a.split("."),n(u,a,""),n(u,o,r)),u=new i.data.ObservableArray([u]);l>c;c++)u.push(s[c]);s=u}return s},_selectItem:function(){o.fn._selectItem.call(this),this.current()||this.select(0)},_keydown:function(e){var t=this,n=e.keyCode,r=i.keys,o=t.ul[0];n===r.LEFT?n=r.UP:n===r.RIGHT&&(n=r.DOWN),e.keyCode=n,t._move(e),n===r.HOME?(e.preventDefault(),t._select(o.firstChild)):n===r.END&&(e.preventDefault(),t._select(o.lastChild))},_selectNext:function(e,n){for(var i,r=this,o=n,a=r._data(),s=a.length,l=r.options.ignoreCase,u=function(n,i){return n+="",l&&(n=n.toLowerCase()),0===n.indexOf(e)?(r._select(i),r._triggerEvents(),!0):t};s>n;n++)if(i=r._text(a[n]),i&&u(i,n))return!0;if(o>0)for(console.log(o),n=0;o>=n;n++)if(i=r._text(a[n]),i&&u(i,n))return!0;return!1},_keypress:function(e){if(0!==e.which&&e.keyCode!==i.keys.ENTER){var t=this,n=String.fromCharCode(e.charCode||e.keyCode),r=t.selectedIndex,o=t._word;t.options.ignoreCase&&(n=n.toLowerCase())," "===n&&e.preventDefault(),t._last===n&&1>=o.length&&r>-1&&(o||(o=n),t._selectNext(o,r+1))||(t._word=o+n,t._last=n,t._search())}},_popup:function(){o.fn._popup.call(this),this.popup.one("open",y(function(){var e=this.popup;e.wrapper=i.wrap(e.element),e.element.closest(".km-root")[0]&&(e.wrapper.addClass("km-popup km-widget"),this.wrapper.addClass("km-widget"))},this))},_search:function(){var e=this,n=e.dataSource,i=e.selectedIndex,r=e._word;return clearTimeout(e._typing),e._typing=setTimeout(function(){e._word=""},e.options.delay),-1===i&&(i=0),e.ul[0].firstChild?(e._selectNext(r,i),e._triggerEvents(),t):(n.one(c,function(){n.data()[0]&&i>-1&&e._selectNext(r,i)}).fetch(),t)},_select:function(e){var n,i,o=this,a=o._current,s=null;return e=o._get(e),e&&e[0]&&!e.hasClass(m)&&(a&&a.removeClass(m),i=r.List.inArray(e[0],o.ul[0]),i>-1&&(s=o._data()[i],n=o._value(s),o.selectedIndex=i,o._textAccessor(s),o._accessor(n!==t?n:o._text(s),i),o._selectedValue=o._accessor(),o.current(e.addClass(m)),o._optionID&&o._current.attr("aria-selected",!0))),s},_triggerEvents:function(){this.popup.visible()||(this._triggerCascade(),this._change())},_mobile:function(){var e=this,t=e.popup,n=t.element.parents(".km-root").eq(0);n.length&&a&&(t.options.animation.open.effects=a.android||a.meego?"fadeIn":a.ios||a.wp?"slideIn:up":t.options.animation.open.effects)},_span:function(){var t,n=this,i=n.wrapper,r="span.k-input";t=i.find(r),t[0]||(i.append('select').append(n.element),t=i.find(r)),n.span=t,n._inputWrapper=e(i[0].firstChild),n._arrow=i.find(".k-icon").mousedown(function(e){e.preventDefault()})},_wrapper:function(){var e,t=this,n=t.element,i=n[0];e=n.parent(),e.is("span.k-widget")||(e=n.wrap("").parent(),e[0].style.cssText=i.style.cssText),n.hide(),t._focused=t.wrapper=e.addClass("k-widget k-dropdown k-header").addClass(i.className).css("display","").attr({unselectable:"on",role:"listbox","aria-haspopup":!0,"aria-expanded":!1})},_clearSelection:function(){var e=this,n=e.options.optionLabel;return e.options.value="",e._selectedValue="",e.dataSource.view()[0]&&(n||e._userTriggered)?(e.select(0),t):(e.selectedIndex=-1,e.element.val(""),e._textAccessor(e.options.optionLabel),t)},_inputTemplate:function(){var t=this,n=t.options.valueTemplate;n=n?i.template(n):e.proxy(i.template("#:this._text(data)#",{useWithBlock:!1}),t),t.valueTemplate=n},_textAccessor:function(r){var o=this.dataItem(),a=this.options,s=this.span;return r===t?s.text():(e.isPlainObject(r)||r instanceof i.data.ObservableObject?o=r:o&&this._text(o)===r||(a.dataTextField?(o={},n(o,a.dataTextField.split("."),r),n(o,a.dataValueField.split("."),this._accessor())):o=r),s.html(this.valueTemplate(o)),t)}});r.plugin(b)}(window.kendo.jQuery),window.kendo},"function"==typeof define&&define.amd?define:function(e,t){t()});