',h=v.extend({init:function(t,l){var r,s,a,o,f=this,u="string";v.fn.init.call(f,t,l),r=f.operators=l.operators||{},t=f.element,l=f.options,l.appendToElement||(a=t.addClass("k-filterable").find(".k-grid-filter"),a[0]||(a=t.prepend('').find(".k-grid-filter")),a.attr("tabindex",-1).on("click"+d,n(f._click,f))),f.link=a||e(),f.dataSource=l.dataSource,f.field=l.field||t.attr(i.attr("field")),f.model=f.dataSource.reader.model,f._parse=function(e){return e+""},f.model&&f.model.fields&&(o=f.model.fields[f.field],o&&(u=o.type||"string",o.parse&&(f._parse=n(o.parse,o)))),l.values&&(u="enums"),f.type=u,r=r[u]||l.operators[u];for(s in r)break;f._defaultFilter=function(){return{field:f.field,operator:s||"eq",value:""}},f._refreshHandler=n(f.refresh,f),f.dataSource.bind("change",f._refreshHandler),l.appendToElement?f._init():f.refresh()},_init:function(){var t,r=this,s=r.options,f=r.operators||{},u=s.ui,v=p(u),h=r.type;f=f[h]||s.operators[h],v||(t=u||c[h]),r.form=e('').html(i.template("boolean"===h?m:g)({field:r.field,format:s.format,ns:i.ns,messages:s.messages,extra:s.extra,operators:f,type:h,role:t,values:l(s.values)})).on("keydown"+d,n(r._keydown,r)).on("submit"+d,n(r._submit,r)).on("reset"+d,n(r._reset,r)),s.appendToElement?(r.element.append(r.form),r.popup=r.element.closest(".k-popup").data(a)):r.popup=r.form[a]({anchor:r.link,open:n(r._open,r),activate:n(r._activate,r),close:r.options.closeCallback}).data(a),v&&r.form.find(".k-textbox").removeClass("k-textbox").each(function(){u(e(this))}),r.form.find("["+i.attr("role")+"=numerictextbox]").removeClass("k-textbox").end().find("["+i.attr("role")+"=datetimepicker]").removeClass("k-textbox").end().find("["+i.attr("role")+"=timepicker]").removeClass("k-textbox").end().find("["+i.attr("role")+"=datepicker]").removeClass("k-textbox"),r.refresh(),r.trigger(o,{field:r.field,container:r.form})},refresh:function(){var e=this,t=e.dataSource.filter()||{filters:[],logic:"and"};e.filterModel=i.observable({logic:"and",filters:[e._defaultFilter(),e._defaultFilter()]}),e.form&&i.bind(e.form.children().first(),e.filterModel),e._bind(t)?e.link.addClass("k-state-active"):e.link.removeClass("k-state-active")},destroy:function(){var e=this;v.fn.destroy.call(e),e.form&&(i.unbind(e.form),i.destroy(e.form),e.form.unbind(d),e.popup.destroy()),e.link.unbind(d),e._refreshHandler&&e.dataSource.unbind("change",e._refreshHandler)},_bind:function(e){var t,l,r,i,s=this,n=e.filters,a=!1,o=0,d=s.filterModel;for(t=0,l=n.length;l>t;t++)i=n[t],i.field==s.field?(d.set("logic",e.logic),r=d.filters[o],r||(d.filters.push({field:s.field}),r=d.filters[o]),r.set("value",s._parse(i.value)),r.set("operator",i.operator),o++,a=!0):i.filters&&(a=a||s._bind(i));return a},_merge:function(l){var r,i,s,n=this,a=l.logic||"and",o=l.filters,d=n.dataSource.filter()||{filters:[],logic:"and"};for(t(d,n.field),o=e.grep(o,function(e){return""!==e.value&&null!=e.value}),i=0,s=o.length;s>i;i++)r=o[i],r.value=n._parse(r.value);return o.length&&(d.filters.length?(l.filters=o,"and"!==d.logic&&(d.filters=[{logic:d.logic,filters:d.filters}],d.logic="and"),o.length>1?d.filters.push(l):d.filters.push(o[0])):(d.filters=o,d.logic=a)),d},filter:function(e){e=this._merge(e),e.filters.length&&this.dataSource.filter(e)},clear:function(){var t=this,l=t.dataSource.filter()||{filters:[]};l.filters=e.grep(l.filters,function(e){return e.filters?(e.filters=r(e.filters,t.field),e.filters.length):e.field!=t.field}),l.filters.length||(l=null),t.dataSource.filter(l)},_submit:function(e){var t=this;e.preventDefault(),t.filter(t.filterModel.toJSON()),t.popup.close()},_reset:function(){this.clear(),this.popup.close()},_click:function(e){e.preventDefault(),e.stopPropagation(),this.popup||this._init(),this.popup.toggle()},_open:function(){var t;e(".k-filter-menu").not(this.form).each(function(){t=e(this).data(a),t&&t.close()})},_activate:function(){this.form.find(":focusable:first").focus()},_keydown:function(e){e.keyCode==i.keys.ESC&&this.popup.close()},events:[o],options:{name:"FilterMenu",extra:!0,appendToElement:!1,type:"string",operators:{string:{eq:f,neq:u,startswith:"Starts with",contains:"Contains",doesnotcontain:"Does not contain",endswith:"Ends with"},number:{eq:f,neq:u,gte:"Is greater than or equal to",gt:"Is greater than",lte:"Is less than or equal to",lt:"Is less than"},date:{eq:f,neq:u,gte:"Is after or equal to",gt:"Is after",lte:"Is before or equal to",lt:"Is before"},enums:{eq:f,neq:u}},messages:{info:"Show items with value that:",isTrue:"is true",isFalse:"is false",filter:"Filter",clear:"Clear",and:"And",or:"Or",selectValue:"-Select value-"}}});s.plugin(h)}(window.kendo.jQuery)});