Jonathan Ouellette 580e90f6a2 initial add
2022-09-27 14:10:30 -07:00

10 lines
12 KiB
JavaScript

/*
* Kendo UI Complete v2013.3.1119 (http://kendoui.com)
* Copyright 2013 Telerik AD. All rights reserved.
*
* Kendo UI Complete commercial licenses may be obtained at
* https://www.kendoui.com/purchase/license-agreement/kendo-ui-complete-commercial.aspx
* If you do not own a commercial license, this file shall be governed by the trial license terms.
*/
!function(define){return define(["./kendo.data.min","./kendo.popup.min"],function(){!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,a=i.ui,r=a.Widget,o=i.keys,l=i.support,s=i.htmlEncode,u=i._activeElement,d="id",c="li",f="change",_="character",h="k-state-focused",p="k-state-hover",v="k-loading",m="open",g="close",b="select",x="selected",S="progress",y="requestEnd",w="width",C=e.extend,F=e.proxy,T=l.browser,k=T.msie&&T.version<9,I=/"/g,D={ComboBox:"DropDownList",DropDownList:"ComboBox"},H=r.extend({init:function(t,n){var i,a=this,o=a.ns;r.fn.init.call(a,t,n),t=a.element,a._isSelect=t.is(b),a._template(),a.ul=e('<ul unselectable="on" class="k-list k-reset"/>').css({overflow:l.kineticScrollNeeded?"":"auto"}).on("mouseenter"+o,c,function(){e(this).addClass(p)}).on("mouseleave"+o,c,function(){e(this).removeClass(p)}).on("click"+o,c,F(a._click,a)).attr({tabIndex:-1,role:"listbox","aria-hidden":!0}),a.list=e("<div class='k-list-container'/>").append(a.ul).on("mousedown"+o,function(e){e.preventDefault()}),i=t.attr(d),i&&(a.list.attr(d,i+"-list"),a.ul.attr(d,i+"_listbox"),a._optionID=i+"_option_selected"),a._header(),a._accessors(),a._initValue()},options:{valuePrimitive:!1,headerTemplate:""},setOptions:function(e){r.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,a=t.dataSource,r=a.filter()||{};n(r,i.dataTextField),e&&(r=r.filters||[],r.push(e)),a.filter(r)},_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._optionID;return e===t?n._current:(n._current&&(n._current.removeClass(h).removeAttr("aria-selected").removeAttr(d),n._focused.removeAttr("aria-activedescendant")),e&&(e.addClass(h),n._scroll(e),i&&(e.attr("id",i),n._focused.attr("aria-activedescendant",i))),n._current=e,t)},destroy:function(){var e=this,t=e.ns;r.fn.destroy.call(e),e._unbindDataSource(),e.ul.off(t),e.list.off(t),e.popup.destroy(),e._form&&e._form.off("reset",e._resetHandler)},dataItem:function(e){var n=this;return e===t&&(e=n.selectedIndex),n._data()[e]},_accessors:function(){var e=this,t=e.element,n=e.options,a=i.getter,r=t.attr(i.attr("text-field")),o=t.attr(i.attr("value-field"));r&&(n.dataTextField=r),o&&(n.dataValueField=o),e._text=a(n.dataTextField),e._value=a(n.dataValueField)},_aria:function(e){var n=this,i=n.options,a=n._focused;i.suggest!==t&&a.attr("aria-autocomplete",i.suggest?"both":"list"),e=e?e+" "+n.ul[0].id:n.ul[0].id,a.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,a=n.options.value,r=n.value();n._isSelect&&!n._bound&&a&&(r=a),r!==n._old?e=!0:i!==t&&i!==n._oldIndex&&(e=!0),e&&(n._old=r,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;return n.popup.visible()&&e&&n.trigger(b,{item:e})?(n.close(),t):(n._select(e),n._triggerCascade(),n._blur(),t)},_index:function(e){var t,n,i=this,a=i._data();for(t=0,n=a.length;n>t;t++)if(i._dataValue(a[t])==e)return t;return-1},_dataValue:function(e){var n=this._value(e);return n===t&&(n=this._text(e)),n},_height:function(e){if(e){var t=this,n=t.list,i=t.popup.visible(),a=t.options.height;n=n.add(n.parent(".k-animation-container")).show().height(t.ul[0].scrollHeight>a?a:"auto"),i||n.hide()}},_adjustListWidth:function(){var e,t,n=this.list,i=n[0].style.width,a=this.wrapper;if(n.data(w)||!i)return e=window.getComputedStyle?window.getComputedStyle(a[0],null):0,t=e?parseFloat(e.width):a.outerWidth(),e&&(T.mozilla||T.msie)&&(t+=parseFloat(e.paddingLeft)+parseFloat(e.paddingRight)+parseFloat(e.borderLeftWidth)+parseFloat(e.borderRightWidth)),i="border-box"!==n.css("box-sizing")?t-(n.outerWidth()-n.width()):t,n.css({fontFamily:a.css("font-family"),width:i}).data(w,i),!0},_popup:function(){var e=this,t=e.list,n=e._focused,r=e.options,o=e.wrapper;e.popup=new a.Popup(t,C({},r.popup,{anchor:o,open:function(t){e._adjustListWidth(),e.trigger(m)?t.preventDefault():(n.attr("aria-expanded",!0),e.ul.attr("aria-hidden",!1))},close:function(t){e.trigger(g)?t.preventDefault():(n.attr("aria-expanded",!1),e.ul.attr("aria-hidden",!0))},animation:r.animation,isRtl:l.isRtl(o)})),e.popup.one(m,function(){e._height(e._data().length)}),e._touchScroller=i.touchScroller(e.popup.element)},_makeUnselectable:function(){k&&this.list.find("*").attr("unselectable","on")},_toggleHover:function(t){e(t.currentTarget).toggleClass(p,"mouseenter"===t.type)},_toggle:function(e){var n=this;e=e!==t?e:!n.popup.visible(),l.touch||n._focused[0]===u()||n._focused.focus(),n[e?m:g]()},_scroll:function(e){if(e){e[0]&&(e=e[0]);var t,n,i=this.ul[0],a=e.offsetTop,r=e.offsetHeight,o=i.scrollTop,l=i.clientHeight,s=a+r,u=this._touchScroller;u?(t=u.dimensions.y,t.enabled&&a>t.size&&(a=a-t.size+r+4,u.scrollTo(0,-a))):(n=this.header?this.header.outerHeight():0,i.scrollTop=o>a?a-n:s>o+l?s-l-n:o)}},_template:function(){var e=this,t=e.options,n=t.template,a=t.dataSource;e._isSelect&&e.element[0].length&&(a||(t.dataTextField=t.dataTextField||"text",t.dataValueField=t.dataValueField||"value")),n?(n=i.template(n),e.template=function(e){return'<li tabindex="-1" role="option" unselectable="on" class="k-item">'+n(e)+"</li>"}):e.template=i.template('<li tabindex="-1" role="option" unselectable="on" class="k-item">${'+i.expr(t.dataTextField,"data")+"}</li>",{useWithBlock:!1})},_triggerCascade:function(){var e=this,t=e.value();(!e._bound&&t||e._old!==t)&&e.trigger("cascade")},_unbindDataSource:function(){var e=this;e.dataSource.unbind(f,e._refreshHandler).unbind(S,e._progressHandler).unbind(y,e._requestEndHandler).unbind("error",e._errorHandler)}});C(H,{caret:function(e){var t,n=e.ownerDocument.selection;return t=n?Math.abs(n.createRange().moveStart(_,-e.value.length)):e.selectionStart},selectText:function(e,t,n){try{if(e.createTextRange){e.focus();var i=e.createTextRange();i.collapse(!0),i.moveStart(_,t),i.moveEnd(_,n-t),i.select()}else e.setSelectionRange(t,n)}catch(a){}},inArray:function(e,t){var n,i,a=t.children;if(!e||e.parentNode!==t)return-1;for(n=0,i=a.length;i>n;n++)if(e===a[n])return n;return-1}}),i.ui.List=H,a.Select=H.extend({init:function(e,t){H.fn.init.call(this,e,t),this._initial=this.element.val()},setDataSource:function(e){this.options.dataSource=e,this._dataSource(),this._bound=!1,this.options.autoBind&&this.dataSource.fetch()},close:function(){this.popup.close()},select:function(e){var n=this;return e===t?n.selectedIndex:(n._select(e),n._triggerCascade(),n._old=n._accessor(),n._oldIndex=n.selectedIndex,t)},_accessor:function(e,n){var i,a=this.element[0],r=this._isSelect,o=a.selectedIndex;return e===t?(r?o>-1&&(i=a.options[o],i&&(e=i.value)):e=a.value,e):(r?(o>-1&&a.options[o].removeAttribute(x),a.selectedIndex=n,i=a.options[n],i&&i.setAttribute(x,x)):a.value=e,t)},_hideBusy:function(){var e=this;clearTimeout(e._busy),e._arrow.removeClass(v),e._focused.attr("aria-busy",!1),e._busy=null},_showBusy:function(){var e=this;e._request=!0,e._busy||(e._busy=setTimeout(function(){e._focused.attr("aria-busy",!0),e._arrow.addClass(v)},100))},_requestEnd:function(){this._request=!1},_dataSource:function(){var t,n=this,a=n.element,r=n.options,o=r.dataSource||{};o=e.isArray(o)?{data:o}:o,n._isSelect&&(t=a[0].selectedIndex,t>-1&&(r.index=t),o.select=a,o.fields=[{field:r.dataTextField},{field:r.dataValueField}]),n.dataSource&&n._refreshHandler?n._unbindDataSource():(n._refreshHandler=F(n.refresh,n),n._progressHandler=F(n._showBusy,n),n._requestEndHandler=F(n._requestEnd,n),n._errorHandler=F(n._hideBusy,n)),n.dataSource=i.data.DataSource.create(o).bind(f,n._refreshHandler).bind(S,n._progressHandler).bind(y,n._requestEndHandler).bind("error",n._errorHandler)},_get:function(t){var n,i,a=this,r=a._data();if("function"==typeof t)for(n=0,i=r.length;i>n;n++)if(t(r[n])){t=n;break}if("number"==typeof t){if(0>t)return e();t=e(a.ul[0].children[t])}return t&&t.nodeType&&(t=e(t)),t},_move:function(e){var t,n,i=this,a=e.keyCode,r=i.ul[0],l=i.popup.visible()?"_select":"_accept",s=i._current,u=a===o.DOWN;if(a===o.UP||u){if(e.altKey)i.toggle(u);else{if(t=r.firstChild,!t&&!i._accessor()&&"filter"!==i._state)return i._fetch||(i.dataSource.one(f,function(){i._move(e),i._fetch=!1}),i._fetch=!0,i._filterSource()),e.preventDefault(),!0;u?(!s||-1===i.selectedIndex&&!i.value()&&s[0]===t?s=t:(s=s[0].nextSibling,s||t!==r.lastChild||(s=t)),i[l](s)):(s=s?s[0].previousSibling:r.lastChild,s||t!==r.lastChild||(s=t),i[l](s))}e.preventDefault(),n=!0}else a===o.ENTER||a===o.TAB?(i.popup.visible()&&e.preventDefault(),i._accept(s),n=!0):a===o.ESC&&(i.popup.visible()&&e.preventDefault(),i.close(),n=!0);return n},_selectItem:function(){var e,t,n=this,i=n.options,a=n.selectedIndex;e=n._isSelect&&!n._initial&&!i.value&&i.index&&!n._bound,e||(t=n._selectedValue||i.value||n._accessor()),t?n.value(t):(!n._bound||a>-1)&&(n._bound||(a=i.index),n.select(a))},_fetchItems:function(e){var n=this,i=n.ul[0].firstChild;return n._request?!0:n._fetch||i?t:n.options.cascadeFrom?!i:(n.dataSource.one(f,function(){n.value(e),n._fetch=!1}),n._fetch=!0,n.dataSource.fetch(),!0)},_options:function(n,i){var a,r,o,l,u=this,d=u.element,c=d[0].selectedIndex,f=n.length,_="",h=0;for(i&&(h=1,_=i,-1===i.indexOf(e(d[0].firstChild).text())&&(c+=1));f>h;h++)a="<option",r=n[h],o=u._text(r),l=u._value(r),l!==t&&(l+="",-1!==l.indexOf('"')&&(l=l.replace(I,"&quot;")),a+=' value="'+l+'"'),a+=">",o!==t&&(a+=s(o)),a+="</option>",_+=a;d.html(_),d[0].selectedIndex=-1===c?0:c},_reset:function(){var t=this,n=t.element,i=n.attr("form"),a=i?e("#"+i):n.closest("form");a[0]&&(t._resetHandler=function(){setTimeout(function(){t.value(t._initial)})},t._form=a.on("reset",t._resetHandler))},_cascade:function(){var t,i,a,r,o,l=this,s=l.options,u=s.cascadeFrom;if(u){if(l._selectedValue=s.value||l._accessor(),i=e("#"+u),t=i.data("kendo"+s.name),t||(t=i.data("kendo"+D[s.name])),!t)return;s.autoBind=!1,r=s.cascadeFromField||t.options.dataValueField,o=function(){var e=l._selectedValue||l.value();e?(l.value(e),l.dataSource.view()[0]&&-1!==l.selectedIndex||l._clearSelection(t,!0)):l.select(s.index),l.enable(),l._triggerCascade()},a=function(){var e,i,a=t.dataItem(),s=a?t._value(a):null;s||0===s?(e=l.dataSource.filter()||{},n(e,r),i=e.filters||[],i.push({field:r,operator:"eq",value:s}),l.dataSource.one(f,o).filter(i)):(l.enable(!1),l._clearSelection(t),l._triggerCascade())},t.bind("cascade",function(){a()}),t._bound?a():t.value()||l.enable(!1)}}})}(window.kendo.jQuery)})}("function"==typeof define&&define.amd?define:function(e,t){return t()});
//@ sourceMappingURL=kendo.list.min.js.map