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