UNPKG

@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) 38.1 kB
!function(e){"function"==typeof define&&define.amd?define(["kendo.data.min","kendo.popup.min","kendo.label.min","kendo.icons.min"],e):e()}((function(){!function(e,t){var i=window.kendo,a=i.ui,n=i._outerHeight,s=/^\d+(\.\d+)?%$/i,l=a.Widget,r=i.keys,o=i.support,u=i.htmlEncode,c=i._activeElement,d=i._outerWidth,h=i.data.ObservableArray,f="id",p="change",_="k-focus",g="k-hover",m="k-selected",v="k-i-loading k-input-loading-icon",b="k-list-ul",w=".k-list-group-sticky-header",x=".k-list-item",S="open",I="close",y="cascade",F="select",C="click",k="mouseenter",V="activate",T="deactivate",D="dataBinding",L="dataBound",H="selectedItemChange",B="selected",E="requestStart",P="requestEnd",A="focus",O=e.extend,G=Array.isArray,W=o.browser,q="k-hidden",N="width",z="text",M=W.msie,R=/"/g,U={ComboBox:["DropDownList","MultiColumnComboBox"],DropDownList:["ComboBox","MultiColumnComboBox"],MultiColumnComboBox:["ComboBox","DropDownList"]},j="aria-labelledby",$="aria-label",Q="aria-activedescendant",Y="aria-expanded",K="aria-hidden",X="aria-busy",J="aria-selected",Z=".k-table-group-row",ee=i.ui.DataBoundWidget.extend({init:function(t,a){var n,s=this;l.fn.init.call(s,t,a),t=s.element,a=s.options,s._isSelect=t.is(F),s._isSelect&&s.element[0].length&&(a.dataSource||(a.dataTextField=a.dataTextField||z,a.dataValueField=a.dataValueField||"value")),s._listSize=i.cssProperties.getValidClass({widget:"List",propName:"size",value:a.size}),s.ul=e('<ul unselectable="on"/>').attr({tabIndex:-1,"aria-hidden":!0}),s.list=e("<div class='k-list'/>").addClass(s._listSize).append(s.ul),(n=t.attr(f))||(n=i.guid()),s.list.attr(f,n+"-list"),s.ul.attr(f,n+"_listbox"),a.columns&&a.columns.length&&(s.list.removeClass("k-list").addClass("k-data-table"),s.list.removeClass(s._listSize).addClass("k-table-md"),s.ul.removeClass(b).addClass("k-table"),s._columnsHeader()),s._header(),s._noData(),s._footer(),s._accessors(),s._initValue()},options:{valuePrimitive:!1,footerTemplate:"",headerTemplate:"",noDataTemplate:!0,size:"medium",messages:{noData:"No data found.",clear:"clear"}},setOptions:function(e){l.fn.setOptions.call(this,e),e&&e.enable!==t&&(e.enabled=e.enable),e.columns&&e.columns.length&&this._columnsHeader(),this._header(),this._noData(),this._footer(),this._renderFooter(),this._renderNoData(),e.label&&this._inputLabel?this.label.setOptions(e.label):!1===e.label?(this.label._unwrapFloating(),this._inputLabel.remove(),delete this._inputLabel):e.label&&this._label()},focus:function(){this._focused.trigger(A)},readonly:function(e){this._editable({readonly:e===t||e,disable:!1}),this.label&&this.label.floatingLabel&&this.label.floatingLabel.readonly(e===t||e)},enable:function(e){this._editable({readonly:!1,disable:!(e=e===t||e)}),this.label&&this.label.floatingLabel&&this.label.floatingLabel.enable(e=e===t||e)},_label:function(){var t=this,a=t.options,n=e.isPlainObject(a.label)?a.label:{content:a.label};t.label=new i.ui.Label(null,e.extend({},n,{widget:t,floatCheck:t._floatCheck.bind(t)})),t._inputLabel=t.label.element},_floatCheck:function(){return!this.listView||!(this.value()||!!this.text&&this.text())&&!this.popup.visible()},_refreshFloatingLabel:function(){var e=this;e.label&&e.label.floatingLabel&&e.label.floatingLabel.refresh()},_header:function(){var t=this,a=e(t.header),n=t.options.headerTemplate;if(this._angularElement(a,"cleanup"),i.destroy(a),a.remove(),n){var s="function"!=typeof n?i.template(n):n;a=e(s({})),t.header=a[0]?a:null,t.list.parent.length>0&&t.list.before(a),this._angularElement(t.header,"compile")}else t.header=null},_columnsHeader:function(){var t=this,a=e(t.columnsHeader);this._angularElement(a,"cleanup"),i.destroy(a),a.remove();for(var n="<div class='k-table-header'><div class='k-table-header-wrap'><table class='k-table' role='presentation'>",l="<colgroup>",r="<tr class='k-table-row'>",o=0;o<this.options.columns.length;o++){var u=this.options.columns[o],c=u.title||u.field||"",d=u.headerTemplate||function(){return c},h="function"!=typeof d?i.template(d):d,f=u.width,p=parseInt(f,10),_="";f&&!isNaN(p)&&(_+="style='width:",_+=p,_+=s.test(f)?"%":"px",_+=";'"),l+="<col "+_+"/>",r+="<th class='k-table-th'>",r+=h(u),r+="</th>"}n+=l+="</colgroup>",n+="<thead class='k-table-thead'>",n+=r+="</tr>",n+="</thead></table></div></div>",t.columnsHeader=a=e(n),t.list.prepend(a),this._angularElement(t.columnsHeader,"compile")},_noData:function(){var t=this,a=e(t.noData),n=!0===t.options.noDataTemplate?function(){return t.options.messages.noData}:t.options.noDataTemplate;t.angular("cleanup",(function(){return{elements:a}})),i.destroy(a),a.remove(),n?(t.noData=e('<div class="k-no-data" style="display: none;"></div>').appendTo(t.list),t.noDataTemplate="function"!=typeof n?i.template(n):n):t.noData=null},_footer:function(){var t=this,a=e(t.footer),n=t.options.footerTemplate,s=this.options.columns&&this.options.columns.length?'<div class="k-table-footer"><span class="k-table-td"></span></div>':'<div class="k-list-footer"></div>';this._angularElement(a,"cleanup"),i.destroy(a),a.remove(),n?(t.footer=e(s).appendTo(t.list),t.footerTemplate="function"!=typeof n?i.template(n):n):t.footer=null},_listOptions:function(t){var a=this,n=a.options,s=n.virtual,l={change:a._listChange.bind(a)},r=a._listBound.bind(a),o=a._focused,c=a.element.attr("id"),d=e('label[for="'+a.element.attr("id")+'"]'),h=o.attr(j);return!h&&d.length&&(h=d.attr("id")||a._generateLabelId(d,c||i.guid())),s="object"==typeof s?s:{},(t=e.extend({autoBind:!1,selectable:!0,dataSource:a.dataSource,click:a._click.bind(a),activate:a._activateItem.bind(a),columns:n.columns,deactivate:a._deactivateItem.bind(a),dataBinding:function(){a.trigger(D)},dataBound:r,height:n.height,dataValueField:n.dataValueField,dataTextField:n.dataTextField,groupTemplate:n.groupTemplate,fixedGroupTemplate:n.fixedGroupTemplate,template:n.template,ariaLabel:o.attr($),ariaLabelledBy:h,listSize:a._listSize},t,s,l)).template||(t.template=function(e){return u(i.getter(t.dataTextField)(e))}),n.$angular&&(t.$angular=n.$angular),t},_initList:function(){var e=this,t=e._listOptions({selectedItemChange:e._listChange.bind(e)});e.options.virtual?(e.listView=new i.ui.VirtualList(e.ul,t),e.list.addClass("k-virtual-list")):e.listView=new i.ui.StaticList(e.ul,t),e.listView.bind("listBound",e._listBound.bind(e)),e._setListValue()},_setListValue:function(e){(e=e||this.options.value)!==t&&this.listView.value(e).done(this._updateSelectionState.bind(this))},_updateSelectionState:e.noop,_listMousedown:function(e){this.filterInput&&this.filterInput[0]===e.target||e.preventDefault()},_isFilterEnabled:function(){var e=this.options.filter;return e&&"none"!==e},_hideClear:function(){this._clear&&this._clear.addClass(q)},_showClear:function(){this._clear&&this._clear.removeClass(q)},_clearValue:function(){this._clearText(),this._accessor(""),this.listView.value([]),this._isSelect&&(this._customOption=t),this._isFilterEnabled()&&!this.options.enforceMinLength&&(this._filter({word:"",open:!1}),this.options.highlightFirst&&this.listView.focus(0)),this._change()},_clearText:function(){this.text("")},_clearFilter:function(){this.options.virtual||this.listView.bound(!1),this._filterSource()},_filterSource:function(t,i){var a=this,n=a.options,s=n.filterFields&&t&&t.logic&&t.filters&&t.filters.length,l=a.dataSource,r=O({},l.filter()||{}),o=t||r.filters&&r.filters.length&&!t,u=re(r,n.dataTextField);if(this._clearFilterExpressions(r),(t||u)&&a.trigger("filtering",{filter:t}))return e.Deferred().reject().promise();var c={filters:[],logic:"and"};s?c.filters.push(t):this._pushFilterExpression(c,t),le(r)&&(c.logic===r.logic?c.filters=c.filters.concat(r.filters):c.filters.push(r)),a._cascading&&this.listView.setDSFilter(c);var d=O({},{page:o?1:l.page(),pageSize:o?l.options.pageSize:l.pageSize(),sort:l.sort(),filter:l.filter(),group:l.group(),aggregate:l.aggregate()},{filter:c});return l[i?"read":"query"](l._mergeState(d))},_pushFilterExpression:function(e,t){le(t)&&""!==t.value&&e.filters.push(t)},_clearFilterExpressions:function(e){if(e.filters){for(var t,i=0;i<e.filters.length;i++)"fromFilter"in e.filters[i]&&(t=i);isNaN(t)||e.filters.splice(t,1)}},_angularElement:function(e,t){e&&this.angular(t,(function(){return{elements:e}}))},_renderNoData:function(){var e=this,t=e.noData;t&&(this._angularElement(t,"cleanup"),t.html(e.noDataTemplate({instance:e})),this._angularElement(t,"compile"))},_toggleNoData:function(t){e(this.noData).toggle(t)},_toggleHeader:function(e){this.listView.content.prev(w).toggle(e)},_renderFooter:function(){var e=this,t=e.footer?this.options.columns&&this.options.columns.length?e.footer.children().first():e.footer:null;t&&(this._angularElement(t,"cleanup"),t.html(e.footerTemplate({instance:e})),this._angularElement(t,"compile"))},_allowOpening:function(){return this.options.noDataTemplate||this.dataSource.flatView().length},_initValue:function(){var e=this,t=e.options.value;null!==t?e.element.val(t):(t=e._accessor(),e.options.value=t),e._old=t},_ignoreCase:function(){var e,t=this,i=t.dataSource.reader.model;i&&i.fields&&(e=i.fields[t.options.dataTextField])&&e.type&&"string"!==e.type&&(t.options.ignoreCase=!1)},_focus:function(e){return this.listView.focus(e)},_filter:function(e){var t,i=this,a=i.options,n=e.word,s=a.filterFields,l=a.dataTextField;if(s&&s.length){t={logic:"or",filters:[],fromFilter:!0};for(var r=0;r<s.length;r++)this._pushFilterExpression(t,i._buildExpression(n,s[r]))}else t=i._buildExpression(n,l);i._open=e.open,i._filterSource(t)},_buildExpression:function(e,t){var i=this.options,a=i.ignoreCase,n=this.dataSource.options.accentFoldingFiltering;return{value:a?n?e.toLocaleLowerCase(n):e.toLowerCase():e,field:t,operator:i.filter,ignoreCase:a}},_clearButton:function(){var t=this,a=t.options.messages.clear;t._clear||(t._clear=e('<span unselectable="on" class="k-clear-value" title="'+a+'">'+i.ui.icon("x")+"</span>").attr({role:"button",tabIndex:-1})),t.options.clearButton||t._clear.remove(),this._hideClear()},search:function(e){var t=this.options;e="string"==typeof e?e:this._inputValue(),clearTimeout(this._typingTimeout),(!t.enforceMinLength&&!e.length||e.length>=t.minLength)&&(this._state="filter",this.listView&&(this.listView._emptySearch=!i.trim(e).length),this._isFilterEnabled()?this._filter({word:e,open:!0}):this._searchByWord(e))},current:function(e){return this._focus(e)},items:function(){return this.ul[0].children},destroy:function(){var e=this,t=e.ns;l.fn.destroy.call(e),e._unbindDataSource(),e.listView.destroy(),e.list.off(t),e.popup.destroy(),e._form&&e._form.off("reset",e._resetHandler),e.label&&e.label.destroy()},dataItem:function(i){var a=this;if(i===t)return a.listView.selectedDataItems()[0];if("number"!=typeof i){if(a.options.virtual)return a.dataSource.getByUid(e(i).data("uid"));i=e(a.items()).index(i)}return a.dataSource.flatView()[i]},_activateItem:function(){var e=this.listView.focus();e&&this.popup.visible()&&this._focused.add(this.filterInput).attr(Q,e.attr("id"))},_deactivateItem:function(){this._focused.add(this.filterInput).removeAttr(Q)},_accessors:function(){var e=this,t=e.element,a=e.options,n=i.getter,s=t.attr(i.attr("text-field")),l=t.attr(i.attr("value-field"));!a.dataTextField&&s&&(a.dataTextField=s),!a.dataValueField&&l&&(a.dataValueField=l),e._text=n(a.dataTextField),e._value=n(a.dataValueField)},_aria:function(e){var i,a=this,n=a.options,s=a._focused;n.suggest!==t&&(i="none"===n.filter?!0===n.suggest?"inline":"none":!0===n.suggest?"both":"list",s.attr("aria-autocomplete",i)),e=e?e+" "+a.ul[0].id:a.ul[0].id,s.attr({"aria-controls":e}),a.filterInput&&a.filterInput.length>0&&a.filterInput.attr("aria-controls",e),a.ul.attr("aria-live",a._isFilterEnabled()?"polite":"off"),a._ariaLabel(a._focused)},_blur:function(){var e=this;e._change(),e.close(),e._userTriggered=!1},_isValueChanged:function(e){return e!==te(this._old,typeof e)},_change:function(){var e,i=this,a=i.selectedIndex,n=i.options.value,s=i.value();i._isSelect&&!i.listView.bound()&&n&&(s=n),i._isValueChanged(s)||i._valueBeforeCascade!==t&&i._valueBeforeCascade!==te(i._old,typeof i._valueBeforeCascade)&&i._userTriggered?e=!0:a===t||a===i._oldIndex||i.listView.isFiltered()||(e=!0),e&&(null===i._old||""===i._old||""===s?i._valueBeforeCascade=i._old=s:i.dataItem()?i._valueBeforeCascade=i._old=i.options.dataValueField?i.dataItem()[i.options.dataValueField]:i.dataItem():i._valueBeforeCascade=i._old=null,i._oldIndex=a,i._typing||i.element.trigger(p),i.trigger(p)),i.typing=!1},_data:function(){return this.dataSource.view()},_enable:function(){var e=this,i=e.options,a=e.element.is("[disabled]");i.enable!==t&&(i.enabled=i.enable),!i.enabled||a?e.enable(!1):e.readonly(e.element.is("[readonly]"))},_dataValue:function(e){var i=this._value(e);return i===t&&(i=this._text(e)),i},_offsetHeight:function(){var t=0;return this.listView.content.parent().prevAll(":visible").each((function(){var i=e(this);t+=n(i,!0)})),t},_height:function(t){var i,a=this,s=a.list,l=a.options.height,r=a.popup.visible(),o=this.options.columns&&this.options.columns.length;if(t||a.options.noDataTemplate){if(i=s.parent().add(s.closest(".k-animation-container")).show(),!s.parent().is(":visible"))return void i.hide();l=a.listView.content[0].scrollHeight>l?l:"auto",i.height(l),"auto"!==l&&(l-=a._offsetHeight(),o&&(l=l-(n(e(a.footer))||0)-(n(e(a.columnsHeader))||0))),o?a.listView.content.outerHeight(l):a.listView.content.parent().outerHeight(l),r||s.parent().hide()}return l},_openHandler:function(e){var t;this._adjustListWidth(),this.trigger(S)?e.preventDefault():(this._focused.attr(Y,!0),this.ul.attr(K,!1),(t=this.listView.focus())&&this._focused.add(this.filterInput).attr(Q,t.attr("id")))},_adjustListWidth:function(){var e,t,i=this,a=i.list.parent(),n=a[0].style.width,s=i.wrapper;if(a.data(N)||!n)return e=window.getComputedStyle?window.getComputedStyle(s[0],null):0,t=parseFloat(e&&e.width)||d(s),e&&W.msie&&(t+=parseFloat(e.paddingLeft)+parseFloat(e.paddingRight)+parseFloat(e.borderLeftWidth)+parseFloat(e.borderRightWidth)),n="border-box"!==a.css("box-sizing")?t-(d(a)-a.width()):t,a.css({fontFamily:s.css("font-family"),width:i.options.autoWidth?"auto":n,minWidth:n,whiteSpace:i.options.autoWidth?"nowrap":"normal"}).data(N,n),!0},_closeHandler:function(e){this.trigger(I)?e.preventDefault():(this._focused.attr(Y,!1),this.ul.attr(K,!0),this._focused.add(this.filterInput).removeAttr(Q))},_focusItem:function(){var e=this.listView,i=!e.focus(),a=ne(e.select());a===t&&this.options.highlightFirst&&i&&(a=0),a!==t?e.focus(a):i&&e.scrollToIndex(0)},_calculateGroupPadding:function(e){var t=this.ul.children(".k-first").first(),a=this.listView.content.prev(w),n=0,s="right";a[0]&&"none"!==a[0].style.display&&("auto"!==e&&(n=i.support.scrollbar()),this.element.parents(".k-rtl").length&&(s="left"),n+=parseFloat(t.css("border-"+s+"-width"),10)+parseFloat(t.children(".k-list-item-group-label").css("padding-"+s),10),a.css("padding-"+s,n))},_calculatePopupHeight:function(e){var t=this._height(this.dataSource.flatView().length||e);this._calculateGroupPadding(t),this._calculateColumnsHeaderPadding(t)},_calculateColumnsHeaderPadding:function(e){if(this.options.columns&&this.options.columns.length){var t=o.isRtl(this.wrapper),a=i.support.scrollbar();this.columnsHeader.css(t?"padding-left":"padding-right","auto"!==e?a:0)}},_refreshScroll:function(){var e=this.listView,t=e.element.height()>e.content.height();this.options.autoWidth&&e.content.css({overflowX:"hidden",overflowY:t?"scroll":"auto"})},_resizePopup:function(e){this.options.virtual||(this.popup.element.is(":visible")?this._calculatePopupHeight(e):(this.popup.one("open",function(e){return function(t){t.isDefaultPrevented()||this._calculatePopupHeight(e)}.bind(this)}.call(this,e)),this.popup.one(V,this._refreshScroll.bind(this))))},_popup:function(){var e=this,t=this;t.list.wrap("<div>"),t.popup=new a.Popup(t.list.parent(),O({},t.options.popup,{anchor:t.wrapper,open:t._openHandler.bind(t),close:t._closeHandler.bind(t),animation:t.options.animation,isRtl:o.isRtl(t.wrapper),autosize:t.options.autoWidth,activate:function(){e._refreshFloatingLabel()},deactivate:function(){e._refreshFloatingLabel()}})),t.popup.element.prepend(t.header).on("mousedown"+this.ns,this._listMousedown.bind(this))},_toggleHover:function(t){e(t.currentTarget).toggleClass(g,t.type===k)},_toggle:function(e,i){var a=this,n=o.mobileOS&&(o.touch||o.MSPointers||o.pointers);e=e!==t?e:!a.popup.visible(),i||n||a._focused[0]===c()||(a._prevent=!0,a._focused.trigger(A),a._prevent=!1),a[e?S:I]()},_triggerCascade:function(){var e=this;e._cascadeTriggered&&e.value()===te(e._cascadedValue,typeof e.value())||(e._cascadedValue=e.value(),e._cascadeTriggered=!0,e.trigger(y,{userTriggered:e._userTriggered}))},_triggerChange:function(){this._valueBeforeCascade!==this.value()&&this.trigger(p)},_unbindDataSource:function(){var e=this;e.dataSource.unbind(E,e._requestStartHandler).unbind(P,e._requestEndHandler).unbind("error",e._errorHandler)},requireValueMapper:function(e,t){if(((e.value instanceof Array?e.value.length:e.value)||(t instanceof Array?t.length:t))&&e.virtual&&"function"!=typeof e.virtual.valueMapper)throw new Error("ValueMapper is not provided while the value is being set. See http://docs.telerik.com/kendo-ui/controls/editors/combobox/virtualization#the-valuemapper-function")}});function te(e,i){return e!==t&&""!==e&&null!==e&&("boolean"===i?("boolean"!=typeof e&&(e="true"===e.toString().toLowerCase()),e=Boolean(e)):"number"===i?e=Number(e):"string"===i&&(e=e.toString())),e}O(ee,{inArray:function(e,t){var i,a,n=t.children;if(!e||e.parentNode!==t)return-1;for(i=0,a=n.length;i<a;i++)if(e===n[i])return i;return-1},unifyType:te}),i.ui.List=ee,a.Select=ee.extend({init:function(e,t){ee.fn.init.call(this,e,t),this._initial=this.element.val()},setDataSource:function(e){var t,i=this;i.options.dataSource=e,i._dataSource(),i.listView.bound()&&(i._initialIndex=null,i.listView._current=null),i.listView.setDataSource(i.dataSource),i.options.autoBind&&i.dataSource.fetch(),(t=i._parentWidget())&&i._cascadeSelect(t)},close:function(){this.popup.close()},select:function(e){var i=this;return e===t?i.selectedIndex:i._select(e).done((function(){i._cascadeValue=i._old=i._accessor(),i._oldIndex=i.selectedIndex,i._refreshFloatingLabel()}))},_accessor:function(e,t){return this[this._isSelect?"_accessorSelect":"_accessorInput"](e,t)},_accessorInput:function(e){var i=this.element[0];if(e===t)return i.value;null===e&&(e=""),i.value=e},_accessorSelect:function(e,i){var a=this.element[0];if(e===t)return se(a).value||"";se(a).selected=!1,i===t&&(i=-1),null!==e&&""!==e&&-1==i?this._custom(e):e?a.value=e:a.selectedIndex=i},_syncValueAndText:function(){return!0},_custom:function(t){var i=this,a=i.element,n=i._customOption;n||(n=e("<option/>"),i._customOption=n,a.append(n)),n.text(t),n[0].selected=!0},_hideBusy:function(){var e=this;clearTimeout(e._busy),e._arrowIcon.removeClass(v),e._focused.attr(X,!1),e._busy=null,e._showClear()},_showBusy:function(e){var t=this;e.isDefaultPrevented()||(t._request=!0,t._busy||(t._busy=setTimeout((function(){t._arrowIcon&&(t._focused.attr(X,!0),t._arrowIcon.addClass(v),t._hideClear())}),100)))},_requestEnd:function(){this._request=!1,this._hideBusy()},_dataSource:function(){var e,t=this,a=t.element,n=t.options,s=n.dataSource||{};s=Array.isArray(s)?{data:s}:s,t._isSelect&&((e=a[0].selectedIndex)>-1&&(n.index=e),s.select=a,s.fields=[{field:n.dataTextField},{field:n.dataValueField}]),t.dataSource?t._unbindDataSource():(t._requestStartHandler=t._showBusy.bind(t),t._requestEndHandler=t._requestEnd.bind(t),t._errorHandler=t._hideBusy.bind(t)),t.dataSource=i.data.DataSource.create(s).bind(E,t._requestStartHandler).bind(P,t._requestEndHandler).bind("error",t._errorHandler)},_firstItem:function(){this.listView.focusFirst()},_lastItem:function(){this.listView.focusLast()},_nextItem:function(){return this.listView.focusNext()},_prevItem:function(){return this.listView.focusPrev()},_getNormalizedDataItem:function(e){var t,i=this,a=i.listView,n="number"==typeof e,s=i.optionLabel&&i.optionLabel.length;return t=n?s?--e:e:a.getElementIndex(e),a.dataItemByIndex(t)},_getNormalizedSelectCandidate:function(e){var t=e;return this.optionLabel&&this.optionLabel.length&&"number"==typeof e&&t++,t},_move:function(e){var t,i,a,n,s,l=this,o=l.listView,u=e.keyCode,d=u===r.DOWN,h=l.options.virtual;if(u===r.UP||d){if(e.altKey)l.toggle(d);else{if(!o.bound()&&!l.ul[0].firstChild)return l._fetch||(l.dataSource.one(p,(function(){l._fetch=!1,l._move(e)})),l._fetch=!0,l._filterSource()),e.preventDefault(),!0;a=l._focus(),l._fetch||a&&!a.hasClass(m)||(d?(n=l._nextItem(),(h&&n<=0||!l._focus()&&!n)&&l._lastItem()):(n=l._prevItem(),(h&&n>=o.dataSource.total()-1||!l._focus()&&!n)&&l._firstItem())),s=l._getNormalizedSelectCandidate(l._get(l._focus())||n||0),l._select(s,!0).done((function(){var e=function(){l.popup.visible()||l._blur(),null===l._cascadedValue?l._cascadedValue=l.value():l._cascadedValue=l.dataItem()?l.dataItem()[l.options.dataValueField]||l.dataItem():null};l.trigger(F,{dataItem:l._getNormalizedDataItem(s),item:l._focus()})?l._select(a).done(e):e()}))}e.preventDefault(),i=!0}else if(u===r.ENTER||u===r.TAB){l.popup.visible()&&e.preventDefault(),a=l._focus(),t=l.dataItem(),l.popup.visible()||t&&l.text()===l._text(t)||(a=null);var f,_=l.filterInput&&l.filterInput[0]===c();if(a){var g=!0;if((t=o.dataItemByIndex(o.getElementIndex(a)))&&(g=l._value(t)!==ee.unifyType(l.value(),typeof l._value(t))),g&&l.trigger(F,{dataItem:t,item:a}))return;f=l._select(a)}else l.input&&((l._syncValueAndText()||l._isSelect)&&l._accessor(l.input.val()),l.listView.value(l.input.val()));l._focusElement&&l._focusElement(l.wrapper),_&&u===r.TAB?l.wrapper.focusout():f&&"function"==typeof f.done?f.done((function(){l._blur()})):l._blur(),l.close(),i=!0}else if(u===r.ESC)l.popup.visible()&&e.preventDefault(),l.close(),i=!0;else if(l.popup.visible()&&(u===r.PAGEDOWN||u===r.PAGEUP)){e.preventDefault();var v=u===r.PAGEDOWN?1:-1;o.scrollWith(v*o.screenHeight()),i=!0}return i},_fetchData:function(){var e=this,t=!!e.dataSource.view().length;e._request||e.options.cascadeFrom||e.listView.bound()||e._fetch||t||(e._fetch=!0,e.dataSource.fetch().done((function(){e._fetch=!1})))},_options:function(e,i,a){var n,s,l,r,o=this,c=o.element,d=c[0],h=e.length,f="",p=0;for(i&&(f=i);p<h;p++)n="<option",s=e[p],l=o._text(s),(r=o._value(s))!==t&&(-1!==(r+="").indexOf('"')&&(r=r.replace(R,"&quot;")),n+=' value="'+r+'"'),n+=">",l!==t&&(n+=u(l)),f+=n+="</option>";c.html(f),a!==t&&(d.value=a,d.value&&!a&&(d.selectedIndex=-1)),-1!==d.selectedIndex&&(n=se(d))&&n.setAttribute(B,B)},_reset:function(){var t=this,i=t.element,a=i.attr("form"),n=a?e("#"+a):i.closest("form");n[0]&&(t._resetHandler=function(){setTimeout((function(){t.value(t._initial)}))},t._form=n.on("reset",t._resetHandler))},_parentWidget:function(){var t=this.options.name;if(this.options.cascadeFrom){var i=e("#"+this.options.cascadeFrom),a=i.data("kendo"+t);if(!a)for(var n=0;n<U[t].length&&!(a=i.data("kendo"+U[t][n]));n+=1);return a}},_cascade:function(){var e,t=this,i=t.options;if(i.cascadeFrom){if(!(e=t._parentWidget()))return;t._cascadeHandlerProxy=t._cascadeHandler.bind(t),t._cascadeFilterRequests=[],i.autoBind=!1,e.bind("set",(function(){t.one("set",(function(e){t._selectedValue=e.value||t._accessor()}))})),e.first(y,t._cascadeHandlerProxy),e.listView.bound()?(t._toggleCascadeOnFocus(),t._cascadeSelect(e)):(e.one(L,(function(){t._toggleCascadeOnFocus(),e.popup.visible()&&e._focused.trigger(A)})),e.value()||t.enable(!1))}},_toggleCascadeOnFocus:function(){var e=this,t=e._parentWidget(),i=M&&t instanceof a.DropDownList?"blur":"focusout";t._focused.add(t.filterInput).on(A,(function(){t.unbind(y,e._cascadeHandlerProxy),t.unbind(p,e._cascadeHandlerProxy),t.first(p,e._cascadeHandlerProxy)})),t._focused.add(t.filterInput).on(i,(function(){t.unbind(p,e._cascadeHandlerProxy),t.unbind(y,e._cascadeHandlerProxy),t.first(y,e._cascadeHandlerProxy)}))},_cascadeHandler:function(e){var t=this._parentWidget(),i=this.value();this._userTriggered=e.userTriggered||t._userTriggered,this.listView.bound()&&this._clearSelection(t,!0),this._cascadeSelect(t,i)},_cascadeChange:function(e){var t=this,i=t._accessor()||t._selectedValue;t._cascadeFilterRequests.length||(t._selectedValue=null),t._userTriggered?t._clearSelection(e,!0):i?(i!==te(t.listView.value()[0],typeof i)&&t.value(i),t.dataSource.view()[0]&&-1!==t.selectedIndex||t._clearSelection(e,!0)):t.dataSource.flatView().length&&t.select(t.options.index),t.enable(),t._triggerCascade(),t._triggerChange(),t._userTriggered=!1},_cascadeSelect:function(e,i){var a=this,n=e.dataItem(),s=n?n[a.options.cascadeFromParentField]||e._value(n):null,l=a.options.cascadeFromField||e.options.dataValueField;if(!e.options.cascadeOnCustomValue||null!==s||a.options.cascadeFromParentField&&a.options.cascadeFromParentField!==e.options.dataValueField||(s=e.value()),a._valueBeforeCascade=i!==t?i:a.value(),s||0===s){re(a.dataSource.filter()||{},l);var r=function(){var t=a._cascadeFilterRequests.shift();t&&a.unbind("dataBound",t),(t=a._cascadeFilterRequests[0])&&a.first("dataBound",t),a._cascadeChange(e)};a._cascadeFilterRequests.push(r),1===a._cascadeFilterRequests.length&&a.first("dataBound",r),a._cascading=!0,a._filterSource({field:l,operator:"eq",value:s}),a._cascading=!1}else a.enable(!1),a._clearSelection(e),a._triggerCascade(),a._triggerChange(),a._userTriggered=!1;a._refreshFloatingLabel()}});var ie=".StaticList",ae=i.ui.DataBoundWidget.extend({init:function(t,a){if(l.fn.init.call(this,t,a),this.element.attr("role","listbox").on("click.StaticList","li",this._click.bind(this)).on("mouseenter.StaticList","li",(function(){e(this).addClass(g)})).on("mouseleave.StaticList","li",(function(){e(this).removeClass(g)})),a&&a.ariaLabel?this.element.attr($,a.ariaLabel):a&&a.ariaLabelledBy&&this.element.attr(j,a.ariaLabelledBy),o.touch&&this._touchHandlers(),"multiple"===this.options.selectable&&this.element.attr("aria-multiselectable",!0),this.options.columns&&this.options.columns.length){var n=this.element.parent().find(".k-table-thead"),s=e('<tr class="k-table-group-row"><th class="k-table-th" colspan="'+this.options.columns.length+'"></th></tr>');n.append(s),this.header=s.find(".k-table-th"),this.content=this.element.wrap("<div class='k-table-body k-table-scroller' unselectable='on'></div>").parent(),this.element.addClass("k-table-list")}else this.content=this.element.wrap("<div class='k-list-content k-list-scroller' unselectable='on'></div>").parent(),this.header=this.content.before('<div class="k-list-group-sticky-header" style="display:none"></div>').prev(),this.element.addClass(b);this.bound(!1),this._optionID=i.guid(),this._selectedIndices=[],this._view=[],this._dataItems=[],this._values=[];var r=this.options.value;r&&(this._values=Array.isArray(r)?r.slice(0):[r]),this._getter(),this._templates(),this.setDataSource(this.options.dataSource),this._createOnScrollProxy()},options:{name:"StaticList",dataValueField:null,valuePrimitive:!1,selectable:!0,template:null,groupTemplate:null,fixedGroupTemplate:null,ariaLabel:null,ariaLabelledBy:null},events:[C,p,V,T,D,L,H],setDataSource:function(e){var t,a=this,n=e||{};n=Array.isArray(n)?{data:n}:n,n=i.data.DataSource.create(n),a.dataSource?(a.dataSource.unbind(p,a._refreshHandler),t=a.value(),a.value([]),a.bound(!1),a.value(t)):a._refreshHandler=a.refresh.bind(a),a.setDSFilter(n.filter()),a.dataSource=n.bind(p,a._refreshHandler),a._fixedHeader()},_touchHandlers:function(){var t,i,a=this,n=this.options.columns&&this.options.columns.length?".k-table-row":x,s=function(e){return(e.originalEvent||e).changedTouches[0].pageY};a.element.on("touchstart.StaticList",(function(e){t=s(e)})),a.element.on("touchend.StaticList",(function(l){l.isDefaultPrevented()||(i=s(l),Math.abs(i-t)<10&&(a._touchTriggered=!0,a._triggerClick(e(l.target).closest(n).get(0))))}))},skip:function(){return this.dataSource.skip()},setOptions:function(e){l.fn.setOptions.call(this,e),this._getter(),this._templates(),this._render(),e.label?this.label.setOptions(e.label):!1===e.label&&(this.label._unwrapFloating(),this._inputLabel.remove(),delete this._inputLabel)},destroy:function(){this.element.off(ie),this._refreshHandler&&this.dataSource.unbind(p,this._refreshHandler),clearTimeout(this._scrollId),l.fn.destroy.call(this)},dataItemByIndex:function(e){return this.dataSource.flatView()[e]},screenHeight:function(){return this.content[0].clientHeight},scrollToIndex:function(e){var t=this.element[0].children[e];t&&this.scroll(t)},scrollWith:function(e){this.content.scrollTop(this.content.scrollTop()+e)},scroll:function(e){if(e){e[0]&&(e=e[0]);var t=this.content[0],i=e.offsetTop,a=e.offsetHeight,n=t.scrollTop,s=t.clientHeight,l=i+a;n>i?n=i:l>n+s&&(n=l-s),t.scrollTop=n}},selectedDataItems:function(e){if(e===t)return this._dataItems.slice();this._dataItems=e,this._values=this._getValues(e)},_getValues:function(t){var i=this._valueGetter;return e.map(t,(function(e){return i(e)}))},focusNext:function(){var e=this.focus();e=e?e.next():0,this.focus(e)},focusPrev:function(){var e=this.focus();e=e?e.prev():this.element[0].children.length-1,this.focus(e)},focusFirst:function(){this.focus(this.element[0].children[0])},focusLast:function(){this.focus(ne(this.element[0].children))},focus:function(i){var a,n=this,s=n._optionID;if(i===t)return n._current;i=ne(n._get(i)),i=e(this.element[0].children[i]),n._current&&(n._current.removeClass(_).removeAttr(f),n.trigger(T)),(a=!!i[0])&&(i.addClass(_),n.scroll(i),i.attr("id",s)),n._current=a?i:null,n.trigger(V)},focusIndex:function(){return this.focus()?this.focus().index():t},skipUpdate:function(e){this._skipUpdate=e},select:function(i){var a,n,s=this,l=s.options.selectable,r="multiple"!==l&&!1!==l,o=s._selectedIndices,u=[this.element.find(".k-selected").index()],c=[];if(i===t)return o.slice();1===(i=s._get(i)).length&&-1===i[0]&&(i=[]);var d=e.Deferred().resolve(),h=s.isFiltered();return h&&!r&&s._deselectFiltered(i)?d:r&&!h&&-1!==e.inArray(ne(i),o)&&-1!==e.inArray(ne(i),u)?(s._dataItems.length&&s._view.length&&(s._dataItems=[s._view[o[0]].item]),d):(a=(n=s._deselect(i)).removed,(i=n.indices).length&&(r&&(i=[ne(i)]),c=s._select(i)),(c.length||a.length)&&(s._valueComparer=null,s.trigger(p,{added:c,removed:a})),d)},removeAt:function(e){return this._selectedIndices.splice(e,1),this._values.splice(e,1),this._valueComparer=null,{position:e,dataItem:this._dataItems.splice(e,1)[0]}},setValue:function(e){e=Array.isArray(e)||e instanceof h?e.slice(0):[e],this._values=e,this._valueComparer=null},value:function(i){var a,n=this,s=n._valueDeferred;return i===t?n._values.slice():(n.setValue(i),s&&"resolved"!==s.state()||(n._valueDeferred=s=e.Deferred()),n.bound()&&(a=n._valueIndices(n._values),"multiple"===n.options.selectable&&n.select(-1),n.select(a),s.resolve()),n._skipUpdate=!1,s)},items:function(){return this.element.children(x)},_click:function(e){this._touchTriggered?this._touchTriggered=!1:e.isDefaultPrevented()||this._triggerClick(e.currentTarget)},_createOnScrollProxy:function(){this._onScroll=function(){var e=this;clearTimeout(e._scrollId),e._scrollId=setTimeout((function(){e._renderHeader()}),50)}.bind(this)},_triggerClick:function(t){this.trigger(C,{item:e(t)})||this.select(t)},_valueExpr:function(e,t){var i,a=this,n=0,s=[];if(!a._valueComparer||a._valueType!==e){for(a._valueType=e;n<t.length;n++)s.push(te(t[n],e));i=function(e,t){for(var i=0;i<s.length;i++)if(e===t[i])return i;return-1},a._valueComparer=function(e){return i(e,s)}}return a._valueComparer},_dataItemPosition:function(e,t){var i=this._valueGetter(e);return this._valueExpr(typeof i,t)(i)},_getter:function(){this._valueGetter=i.getter(this.options.dataValueField)},_deselect:function(t){var i,a,n,s=this,l=s.element[0].children,r=s.options.selectable,o=s._selectedIndices,u=s._dataItems,c=s._values,d=[],h=0;if(t=t.slice(),!0!==r&&t.length){if("multiple"===r)for(;h<t.length;h++)if(a=t[h],e(l[a]).hasClass(m))for(i=0;i<o.length;i++)if((n=o[i])===a){e(l[n]).removeClass(m).attr(J,!1);var f=this._view[a].item,p=this._dataItemPosition(f,this._values);d.push({position:p,dataItem:f}),u.splice(i,1),o.splice(i,1),t.splice(h,1),c.splice(i,1),1,h-=1,i-=1;break}}else{for(;h<o.length;h++)e(l[o[h]]).removeClass(m).attr(J,!1),d.push({position:h,dataItem:u[h]});s._values=[],s._dataItems=[],s._selectedIndices=[]}return{indices:t,removed:d}},_deselectFiltered:function(t){for(var i,a,n,s=this.element[0].children,l=[],r=0;r<t.length;r++)a=t[r],i=this._view[a].item,(n=this._dataItemPosition(i,this._values))>-1&&(l.push(this.removeAt(n)),e(s[a]).removeClass(m));return!!l.length&&(this.trigger(p,{added:[],removed:l}),!0)},_select:function(t){var i,a,n=this,s=n.element[0].children,l=n._view,r=[],o=0;for(-1!==ne(t)&&n.focus(t);o<t.length;o++)i=l[a=t[o]],-1!==a&&i&&(i=i.item,n._selectedIndices.push(a),n._dataItems.push(i),n._values.push(n._valueGetter(i)),e(s[a]).addClass(m).attr(J,!0),r.push({dataItem:i}));return r},getElementIndex:function(t){return e(t).data("offset-index")},_get:function(e){return"number"==typeof e?e=[e]:G(e)||(e=[(e=this.getElementIndex(e))!==t?e:-1]),e},_templates:function(){var e,t=this.options,a={template:t.template,groupTemplate:t.groupTemplate,fixedGroupTemplate:t.fixedGroupTemplate};for(var n in t.columns&&t.columns.forEach((function(e,t){var n=e.field?e.field.toString():z;a["column"+t]=e.template||function(e){return u(i.getter(n)(e))}})),a)(e=a[n])&&"function"!=typeof e&&(a[n]=i.template(e));this.templates=a},_normalizeIndices:function(e){for(var i=[],a=0;a<e.length;a++)e[a]!==t&&i.push(e[a]);return i},_valueIndices:function(e,t){var i,a=this._view,n=0;if(t=t?t.slice():[],!e.length)return[];for(;n<a.length;n++)-1!==(i=this._dataItemPosition(a[n].item,e))&&(t[i]=n);return this._normalizeIndices(t)},_firstVisibleItem:function(){for(var t=this.element[0],i=this.content[0].scrollTop,a=e(t.children[0]).height(),n=Math.floor(i/a)||0,s=t.children[n]||t.lastChild,l=s.offsetTop<i;s;)if(l){if(s.offsetTop+a>i||!s.nextSibling)break;s=s.nextSibling}else{if(s.offsetTop<=i||!s.previousSibling)break;s=s.previousSibling}return this._view[e(s).data("offset-index")]},_fixedHeader:function(){this.isGrouped()&&this.templates.fixedGroupTemplate?(this.header.closest(Z).length?this.header.closest(Z).show():this.header.show(),this.content.scroll(this._onScroll)):(this.header.closest(Z).length?this.header.closest(Z).hide():this.header.hide(),this.content.off("scroll",this._onScroll))},_renderHeader:function(){var e=this.templates.fixedGroupTemplate;if(e){var t=this._firstVisibleItem();t&&t.group.toString().length&&this.header.html(e(t.group))}},_renderItem:function(e){var t='<li tabindex="-1" role="option" unselectable="on" ',i=e.item,a=0!==e.index,n=e.selected,s=this.isGrouped(),l=this.options.columns&&this.options.columns.length,r=e.index%2==1?" k-table-alt-row":"";return t+=l?'class="k-table-row'+r:'class="k-list-item',a&&e.newGroup&&(t+=" k-first"),e.isLastGroupedItem&&l&&(t+=" k-last"),n&&(t+=" k-selected"),t+='" aria-selected="'+(n?"true":"false")+'" data-offset-index="'+e.index+'">',l?t+=this._renderColumns(i):(t+='<span class="k-list-item-text">',t+=this.templates.template(i),t+="</span>"),a&&e.newGroup?t+=l?'<span class="k-table-td k-table-group-td"><span>'+this.templates.groupTemplate(e.group)+"</span></span>":'<div class="k-list-item-group-label">'+this.templates.groupTemplate(e.group)+"</div>":s&&l&&(t+='<span class="k-table-td k-table-spacer-td"></span>'),t+"</li>"},_renderColumns:function(e){for(var t="",i=0;i<this.options.columns.length;i++){var a=this.options.columns[i].width,n=parseInt(a,10),l="";a&&!isNaN(n)&&(l+="style='width:",l+=n,l+=s.test(a)?"%":"px",l+=";'"),t+="<span class='k-table-td' "+l+">",t+=this.templates["column"+i](e),t+="</span>"}return t},_render:function(){var e,t,i,a,n="",s=0,l=0,r=[],o=this.dataSource.view(),u=this.value(),c=this.isGrouped();if(c)for(s=0;s<o.length;s++)for(t=o[s],i=!0,a=0;a<t.items.length;a++)e={selected:this._selected(t.items[a],u),item:t.items[a],group:t.value,newGroup:i,isLastGroupedItem:a===t.items.length-1,index:l},r[l]=e,l+=1,n+=this._renderItem(e),i=!1;else for(s=0;s<o.length;s++)e={selected:this._selected(o[s],u),item:o[s],index:s},r[s]=e,n+=this._renderItem(e);this._view=r,this.element[0].innerHTML=n,c&&r.length&&this._renderHeader()},_selected:function(e,t){return(!this.isFiltered()||"multiple"===this.options.selectable)&&-1!==this._dataItemPosition(e,t)},setDSFilter:function(e){this._lastDSFilter=O({},e)},isFiltered:function(){return this._lastDSFilter||this.setDSFilter(this.dataSource.filter()),!i.data.Query.compareFilters(this.dataSource.filter(),this._lastDSFilter)},refresh:function(e){var t,i=this,a=e&&e.action,n=i.options.skipUpdateOnBind,s="itemchange"===a;i.trigger(D),i._angularItems("cleanup"),i._fixedHeader(),i._render(),i.bound(!0),s||"remove"===a?(t=function(e,t){var i,a,n,s,l=t.length,r=e.length,o=[],u=[];if(r)for(n=0;n<r;n++){for(i=e[n],a=!1,s=0;s<l;s++)if(i===t[s]){a=!0,o.push({index:n,item:i});break}a||u.push(i)}return{changed:o,unchanged:u}}(i._dataItems,e.items)).changed.length&&(s?i.trigger(H,{items:t.changed}):i.value(i._getValues(t.unchanged))):i.isFiltered()||i._skipUpdate||i._emptySearch?(i.focus(0),i._skipUpdate&&(i._skipUpdate=!1,i._selectedIndices=i._valueIndices(i._values,i._selectedIndices))):n||a&&"add"!==a||i.value(i._values),i._valueDeferred&&i._valueDeferred.resolve(),i._angularItems("compile"),i.trigger(L)},bound:function(e){if(e===t)return this._bound;this._bound=e},isGrouped:function(){return(this.dataSource.group()||[]).length}});function ne(e){return e[e.length-1]}function se(e){var t=e.selectedIndex;return t>-1?e.options[t]:{}}function le(t){return!(!t||e.isEmptyObject(t))&&!(t.filters&&!t.filters.length)}function re(t,i){var a,n=!1;return t.filters&&(a=e.grep(t.filters,(function(e){return n=re(e,i),e.filters?e.filters.length:e.field!=i})),n||t.filters.length===a.length||(n=!0),t.filters=a),n}a.plugin(ae),i.cssProperties.registerPrefix("List","k-list-")}(window.kendo.jQuery)})); //# sourceMappingURL=kendo.list.min.js.map