/* * 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 a(e,t){var a;if(null===e&&null!==t||null!==e&&null===t)return!1;if(a=e.length,a!==t.length)return!1;for(;a--;)if(e[a]!==t[a])return!1;return!0}function n(e){var t=e.firstChild;return t&&"none"===t.style.display&&(t=l(t,k)),t}function i(e){var t=e.lastChild;return t&&"none"===t.style.display&&(t=l(t,w)),t}function l(e,t){return e=e[t],e&&"none"===e.style.display&&(e=l(e,t)),e}var r=window.kendo,s=r.ui,o=s.List,u=r.keys,c=r._activeElement,d=r.data.ObservableArray,p=e.proxy,_="id",h="li",f="accept",g="filter",v="open",m="close",y="change",b="progress",T="select",k="nextSibling",w="previousSibling",C=' style="display:none"',S="aria-disabled",x="aria-readonly",I="k-state-focused",L="k-loading-hidden",D="k-state-hover",V="k-state-disabled",F="disabled",B="readonly",E=".kendoMultiSelect",A="click"+E,H="keydown"+E,O="mouseenter"+E,N="mouseleave"+E,W=O+" "+N,P=/"/g,M=e.isArray,R=["font-family","font-size","font-stretch","font-style","font-weight","letter-spacing","text-transform","line-height"],j=o.extend({init:function(t,a){var n,i,l=this;l.ns=E,o.fn.init.call(l,t,a),l._wrapper(),l._tagList(),l._input(),l._textContainer(),l._loader(),l._tabindex(l.input),t=l.element.attr("multiple","multiple").hide(),a=l.options,i=a.value,a.placeholder||(a.placeholder=t.data("placeholder")),n=t.attr(_),n&&(l._tagID=n+"_tag_active",n+="_taglist",l.tagList.attr(_,n)),l._aria(n),l._dataSource(),l._ignoreCase(),l._popup(),l._values=[],l._dataItems=[],l._reset(),l._enable(),l._placeholder(),a.autoBind?l.dataSource.fetch():i&&(M(i)||(i=[i]),(e.isPlainObject(i[0])||!a.dataValueField)&&(l._retrieveData=!0,l.dataSource.data(i),l.value(l._initialValues))),r.notify(l)},options:{name:"MultiSelect",enabled:!0,autoBind:!0,highlightFirst:!0,dataTextField:"",dataValueField:"",filter:"startswith",ignoreCase:!0,minLength:0,delay:100,value:null,maxSelectedItems:null,itemTemplate:"",tagTemplate:"",placeholder:"",height:200,animation:{}},events:[v,m,y,T,"dataBinding","dataBound"],setDataSource:function(e){this.options.dataSource=e,this._dataSource(),this.options.autoBind&&this.dataSource.fetch()},setOptions:function(e){o.fn.setOptions.call(this,e),this._template(),this._accessors(),this._aria(this.tagList.attr(_))},current:function(e){return this.currentTag(null),o.fn.current.call(this,e)},currentTag:function(e){var a=this;return e===t?a._currentTag:(a._currentTag&&(a._currentTag.removeClass(I).removeAttr(_),a.input.removeAttr("aria-activedescendant")),e&&(e.addClass(I).attr(_,a._tagID),a.input.attr("aria-activedescendant",a._tagID)),a._currentTag=e,t)},dataItems:function(){return this._dataItems},destroy:function(){var e=this,t=e.ns;e.wrapper.off(t),e.tagList.off(t),e.input.off(t),o.fn.destroy.call(e)},_editable:function(t){var a=this,n=t.disable,i=t.readonly,l=a.wrapper.off(E),r=a.tagList.off(E),s=a.element.add(a.input.off(E));i||n?(n?l.addClass(V):l.removeClass(V),s.attr(F,n).attr(B,i).attr(S,n).attr(x,i)):(l.removeClass(V).on(W,a._toggleHover).on("mousedown"+E,function(e){e.preventDefault(),a.input[0]!==c()&&a.input.focus(),-1==e.target.className.indexOf("k-delete")&&0===a.options.minLength&&a.open()}),a.input.on(H,p(a._keydown,a)).on("paste"+E,p(a._search,a)).on("focus"+E,function(){a._placeholder(!1)}).on("blur"+E,function(){clearTimeout(a._typing),a._placeholder(),a.close(),a._state===g&&(a._state=f),a.element.blur()}),s.removeAttr(F).removeAttr(B).attr(S,!1).attr(x,!1),r.on(O,h,function(){e(this).addClass(D)}).on(N,h,function(){e(this).removeClass(D)}).on(A,".k-delete",function(t){a._unselect(e(t.target).closest(h)),a._change(),a.close()}))},close:function(){this.popup.close(),this.current(null)},open:function(){var t=this;!t.ul[0].firstChild||t._state===f||t._retrieveData?(t._state="",t._open=!0,t._retrieveData=!1,t._filterSource()):t._visibleItems&&t._allowSelection()&&(t.popup.open(),t.current(t.options.highlightFirst?e(n(t.ul[0])):null))},toggle:function(e){this[e?v:m]()},refresh:function(){var t,a=this,i=null;a.trigger("dataBinding"),t=a._render(a.dataSource.view()),a._height(t),a._setInitialValues&&(a._setInitialValues=!1,a.value(a._initialValues)),a._open&&(a._open=!1,a.toggle(t)),a.popup.visible()&&(a.popup._position(),a.options.highlightFirst&&(i=e(n(a.ul[0])))),a.current(i),a._touchScroller&&a._touchScroller.reset(),a._makeUnselectable(),a._hideBusy(),a.trigger("dataBound")},search:function(e){var t=this,a=t.options,n=a.ignoreCase,i=a.filter,l=a.dataTextField;clearTimeout(t._typing),e="string"==typeof e?e:t.input.val(),e.length>=a.minLength&&(t._state=g,t._open=!0,t._filterSource({value:n?e.toLowerCase():e,field:l,operator:i,ignoreCase:n}))},value:function(a){var n,i=this,l=e(i.tagList[0].children),r=l.length,s=0;if(a===t)return i._values;if(!i._fetchItems(a)){for(;r>s;s++)i._unselect(l.eq(s));if(null!==a){for(a=M(a)||a instanceof d?a:[a],s=0,r=a.length;r>s;s++)n=i._index(a[s]),n>-1&&i._select(n);i._old=i._values.slice()}}},_dataSource:function(){var e=this,t=e.element,a=e.options,n=a.dataSource||{};n=M(n)?{data:n}:n,n.select=t,n.fields=[{field:a.dataTextField},{field:a.dataValueField}],e.dataSource&&e._refreshHandler?e._unbindDataSource():(e._refreshHandler=p(e.refresh,e),e._progressHandler=p(e._showBusy,e)),e.dataSource=r.data.DataSource.create(n).bind(y,e._refreshHandler).bind(b,e._progressHandler)},_fetchItems:function(e){var a=this;return a._fetch||a.ul[0].firstChild?t:(a.dataSource.one(y,function(){a.value(e),a._fetch=!1}),a._fetch=!0,a.dataSource.fetch(),!0)},_reset:function(){var t=this,a=t.element,n=a.attr("form"),i=n?e("#"+n):a.closest("form");i[0]&&(t._resetHandler=function(){setTimeout(function(){t.value(t._initialValues)})},t._form=i.on("reset",t._resetHandler))},_initValue:function(){var e=this,t=e.options.value||e.element.val();null===t?t=[]:(M(t)||(t=[t]),t=e._mapValues(t)),e._old=e._initialValues=t,e._setInitialValues=!!t[0]},_mapValues:function(t){var a=this;return t&&e.isPlainObject(t[0])&&(t=e.map(t,function(e){return a._value(e)})),t},_change:function(){var e=this,t=e.value();a(t,e._old)||(e._old=t.slice(),e.trigger(y),e.element.trigger(y))},_click:function(a){var n=this,i=e(a.currentTarget);if(!a.isDefaultPrevented()){if(n.trigger(T,{item:i}))return n.close(),t;n._select(i),n._change(),n.close()}},_item:function(e,t){return e=e[t](),e[0]&&!e.is(":visible")&&(e=this._item(e,t)),e},_keydown:function(a){var s=this,o=a.keyCode,c=s._currentTag,d=s._current,p=s.input.val(),_=r.support.isRtl(s.wrapper),h=s.popup.visible();if(o===u.DOWN){if(a.preventDefault(),!h)return s.open(),t;d=d?l(d[0],k):s.ul[0].firstChild,d&&s.current(e(d))}else if(o===u.UP)h&&(d=d?l(d[0],w):s.ul[0].lastChild,s.current(e(d)),s._current[0]||s.close()),a.preventDefault();else if(o===u.LEFT&&!_||o===u.RIGHT&&_)p||(c=c?c.prev():e(s.tagList[0].lastChild),c[0]&&s.currentTag(c));else if(o===u.RIGHT&&!_||o===u.LEFT&&_)!p&&c&&(c=c.next(),s.currentTag(c[0]?c:null));else if(o===u.ENTER&&h){if(d){if(s.trigger(T,{item:d}))return s.close(),t;s._select(d)}s._change(),s.close(),a.preventDefault()}else o===u.ESC?(h?a.preventDefault():s.currentTag(null),s.close()):o===u.HOME?h?s.current(e(n(s.ul[0]))):p||(c=s.tagList[0].firstChild,c&&s.currentTag(e(c))):o===u.END?h?s.current(e(i(s.ul[0]))):p||(c=s.tagList[0].lastChild,c&&s.currentTag(e(c))):o!==u.DELETE&&o!==u.BACKSPACE||p?(clearTimeout(s._typing),setTimeout(function(){s._scale()}),s._search()):(o!==u.BACKSPACE||c||(c=e(s.tagList[0].lastChild)),c&&c[0]&&(s._unselect(c),s._change(),s.close()))},_hideBusy:function(){var e=this;clearTimeout(e._busy),e.input.attr("aria-busy",!1),e._loading.addClass(L),e._busy=null},_showBusy:function(){var e=this;e._busy||(e._busy=setTimeout(function(){e.input.attr("aria-busy",!0),e._loading.removeClass(L)},100))},_placeholder:function(e){var a=this,n=a.input;e===t?(e=!1,n[0]!==c()&&(e=!a._dataItems[0]),a.wrapper.removeClass(I)):a.wrapper.addClass(I),a._prev="",n.toggleClass("k-readonly",e).val(e?a.options.placeholder:""),a._scale()},_scale:function(){var e,t=this,a=t.wrapper,n=a.width(),i=t._span.text(t.input.val());a.is(":visible")?e=i.width()+25:(i.appendTo(document.documentElement),n=e=i.width()+25,i.appendTo(a)),t.input.width(e>n?n:e)},_option:function(e,a){var n=""},_render:function(e){for(var t,a,n=this,i=e.length,l=n.itemTemplate,r=n._dataItems.slice(0),s=0,o=0,u="",c="";i>o;o++)t=e[o],a=n._selected(r,t),c+=l(t,o,a),u+=n._option(t,a),a||(s+=1);if(i=r.length)for(o=0;i>o;o++)u+=n._option(r[o],!0);return n.ul[0].innerHTML=c,n.element.html(u),n._visibleItems=s,s},_selected:function(e,a){var n,i=this,l=i._text,r=i._value,s=r(a),o=e.length,u=!1,c=0;for(s===t&&(s=l(a));o>c;c++)if(a=e[c],n=r(a),n===t&&(n=l(a)),n!==t&&n===s){u=!0;break}return u&&e.splice(c,1),u},_search:function(){var e=this;e._typing=setTimeout(function(){var t=e.input.val();e._prev!==t&&(e._prev=t,e.search(t))},e.options.delay)},_allowSelection:function(){var e=this.options.maxSelectedItems;return null===e||e>this._values.length},_select:function(e){var t,a,n=this,i=n._values;n._allowSelection()&&(isNaN(e)?a=e.hide().data("idx"):(a=e,n.ul[0].children[a].style.display="none"),n.element[0].children[a].selected=!0,t=n.dataSource.view()[a],n.tagList.append(n.tagTemplate(t)),n._dataItems.push(t),i.push(n._dataValue(t)),n._visibleItems-=1,n.currentTag(null),n._placeholder(),n._height(n._visibleItems),n._state===g&&(n._state=f))},_unselect:function(t){var a,n,i,l,r,s=this,o=t.index();if(t.remove(),s.currentTag(null),s._values.splice(o,1),a=s._dataItems.splice(o,1)[0],n=s._dataValue(a),o=s._index(n),-1!==o)e(s.ul[0].children[o]).show(),s.element[0].children[o].selected=!1,s._visibleItems+=1,s._height(s._visibleItems);else for(o=s.dataSource.view().length,i=s.element[0].children,r=i.length;r>o;o++)if(l=i[o],l.value==n){l.selected=!1;break}s._placeholder()},_template:function(){var e,t=this,a=t.options,n=a.itemTemplate,i=a.tagTemplate,l=a.dataSource;t.element[0].length&&!l&&(a.dataTextField=a.dataTextField||"text",a.dataValueField=a.dataValueField||"value"),e=r.template("#:"+r.expr(a.dataTextField,"data")+"#",{useWithBlock:!1}),n=n?r.template(n):e,i=i?r.template(i):e,t.itemTemplate=function(e,t,a){return'