demo20230512/Scripts/kendo/2014.2.716/kendo.list.min.js

16 lines
12 KiB
JavaScript
Raw Permalink Normal View History

2023-05-12 10:20:28 +08:00
/**
* 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.data.min","./kendo.popup.min"],e)}(function(){return function(e,t){function n(t,i){t.filters&&(t.filters=e.grep(t.filters,function(e){return n(e,i),e.filters?e.filters.length:e.field!=i}))}var i=window.kendo,r=i.ui,o=r.Widget,a=i.keys,s=i.support,l=i.htmlEncode,u=i._activeElement,d="id",c="li",f="change",h="k-state-focused",p="k-state-hover",g="k-loading",m="open",v="close",_="select",y="selected",b="progress",w="requestEnd",x="width",k=e.extend,T=e.proxy,C=s.browser,S=C.msie&&9>C.version,F=/"/g,D={ComboBox:"DropDownList",DropDownList:"ComboBox"},M=i.ui.DataBoundWidget.extend({init:function(t,n){var i,r=this,a=r.ns;o.fn.init.call(r,t,n),t=r.element,r._isSelect=t.is(_),r._template(),r.ul=e('<ul unselectable="on" class="k-list k-reset"/>').css({overflow:s.kineticScrollNeeded?"":"auto"}).on("mouseenter"+a,c,function(){e(this).addClass(p)}).on("mouseleave"+a,c,function(){e(this).removeClass(p)}).on("click"+a,c,T(r._click,r)).attr({tabIndex:-1,role:"listbox","aria-hidden":!0}),r.list=e("<div class='k-list-container'/>").append(r.ul).on("mousedown"+a,function(e){r.filterInput&&r.filterInput[0]===e.target||e.preventDefault()}),i=t.attr(d),i&&(r.list.attr(d,i+"-list"),r.ul.attr(d,i+"_listbox"),r._optionID=i+"_option_selected"),r._header(),r._accessors(),r._initValue()},options:{valuePrimitive:!1,headerTemplate:""},setOptions:function(e){o.fn.setOptions.call(this,e),e&&e.enable!==t&&(e.enabled=e.enable)},focus:function(){this._focused.focus()},readonly:function(e){this._editable({readonly:e===t?!0:e,disable:!1})},enable:function(e){this._editable({readonly:!1,disable:!(e=e===t?!0:e)})},_filterSource:function(e){var t=this,i=t.options,r=t.dataSource,o=r.filter()||{};n(o,i.dataTextField),e&&(o=o.filters||[],o.push(e)),r.filter(o)},_header:function(){var t,n=this.options.headerTemplate;e.isFunction(n)&&(n=n({})),n&&(this.list.prepend(n),t=this.ul.prev(),this.header=t[0]?t:null)},_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,n=t.dataSource.reader.model;n&&n.fields&&(e=n.fields[t.options.dataTextField],e&&e.type&&"string"!==e.type&&(t.options.ignoreCase=!1))},items:function(){return this.ul[0].children},current:function(e){var n=this,i=n._focused.add(n.filterInput),r=n._optionID;return e===t?n._current:(n._current&&(n._current.removeClass(h).removeAttr("aria-selected").removeAttr(d),i.removeAttr("aria-activedescendant")),e&&(e.addClass(h),n._scroll(e),r&&(e.attr("id",r),i.attr("aria-activedescendant",r))),n._current=e,t)},destroy:function(){var e=this,t=e.ns;o.fn.destroy.call(e),e._unbindDataSource(),e.ul.off(t),e.list.off(t),e._touchScroller&&e._touchScroller.destroy(),e.popup.destroy(),e._form&&e._form.off("reset",e._resetHandler)},dataItem:function(n){var i=this;return n===t?n=i.selectedIndex:"number"!=typeof n&&(n=e(i.items()).index(n)),i._data()[n]},_accessors:function(){var e=this,t=e.element,n=e.options,r=i.getter,o=t.attr(i.attr("text-field")),a=t.attr(i.attr("value-field"));o&&(n.dataTextField=o),a&&(n.dataValueField=a),e._text=r(n.dataTextField),e._value=r(n.dataValueField)},_aria:function(e){var n=this,i=n.options,r=n._focused.add(n.filterInput);i.suggest!==t&&r.attr("aria-autocomplete",i.suggest?"both":"list"),e=e?e+" "+n.ul[0].id:n.ul[0].id,r.attr("aria-owns",e),n.ul.attr("aria-live",i.filter&&"none"!==i.filter?"polite":"off")},_blur:function(){var e=this;e._change(),e.close()},_change:function(){var e,n=this,i=n.selectedIndex,r=n.options.value,o=n.value();n._isSelect&&!n._bound&&r&&(o=r),o!==n._old?e=!0:i!==t&&i!==n._oldIndex&&(e=!0),e&&(n._old=o,n._oldIndex=i,n.trigger(f),n.element.trigger(f))},_click:function(t){t.isDefaultPrevented()||this._accept(e(t.currentTarget))},_data:function(){return this.dataSource.view()},_enable:function(){var e=this,n=e.options,i=e.element.is("[disabled]");n.enable!==t&&(n.enabled=n.enable),!n.enabled||i?e.enable(!1):e.readonly(e.element.is("[readonly]"))},_focus:function(e){var n=this,i=!0;return n.popup.visible()&&e&&n.trigger(_,{item:e})?