@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
1 lines • 8.7 kB
JavaScript
module.exports=function(e){function t(o){if(r[o])return r[o].exports;var a=r[o]={exports:{},id:o,loaded:!1};return e[o].call(a.exports,a,a.exports,t),a.loaded=!0,a.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}({0:function(e,t,r){e.exports=r(1185)},3:function(e,t){e.exports=function(){throw Error("define cannot be used indirect")}},1009:function(e,t){e.exports=require("./kendo.combobox")},1010:function(e,t){e.exports=require("./kendo.dropdownlist")},1122:function(e,t){e.exports=require("./kendo.datepicker")},1139:function(e,t){e.exports=require("./kendo.numerictextbox")},1185:function(e,t,r){var o,a,n;!function(l,define){a=[r(1186),r(1122),r(1139),r(1009),r(1010)],o=l,n="function"==typeof o?o.apply(t,a):o,!(void 0!==n&&(e.exports=n))}(function(){return function(e,t){function r(t){var r="string"==typeof t?t:t.operator;return e.inArray(r,v)>-1}function o(t,r){var a,n,l=[];if(e.isPlainObject(t))if(t.hasOwnProperty("filters"))l=t.filters;else if(t.field==r)return t;for(e.isArray(t)&&(l=t),a=0;a<l.length;a++)if(n=o(l[a],r))return n}function a(t,r){t.filters&&(t.filters=e.grep(t.filters,function(e){return a(e,r),e.filters?e.filters.length:e.field!=r}))}function n(e,t){var r=l.getter(t,!0);return function(t){for(var o,a,n=e(t),l=[],i=0,s={};i<n.length;)o=n[i++],a=r(o),s.hasOwnProperty(a)||(l.push(o),s[a]=!0);return l}}var l=window.kendo,i=l.ui,s=l.data.DataSource,u=i.Widget,p="change",d="boolean",c="enums",f="string",g="Is equal to",h="Is not equal to",m=e.proxy,v=["isnull","isnotnull","isempty","isnotempty","isnullorempty","isnotnullorempty"],w=u.extend({init:function(o,a){var n,i,s,g,h,v,w,b,y,x,I,S,D;if(o=e(o).addClass("k-filtercell"),n=this.wrapper=e("<span/>").appendTo(o),i=this,h=a,b=i.operators=a.operators||{},y=i.input=e("<input/>").attr(l.attr("bind"),"value: value").appendTo(n),x=a?a.suggestDataSource:null,x&&(a=e.extend({},a,{suggestDataSource:{}})),u.fn.init.call(i,o[0],a),x&&(i.options.suggestDataSource=x),a=i.options,s=i.dataSource=a.dataSource,i.model=s.reader.model,w=a.type=f,I=l.getter("reader.model.fields",!0)(s)||{},S=I[a.field],S&&S.type&&(w=a.type=S.type),a.values&&(a.type=w=c),b=b[w]||a.operators[w],!h.operator)for(v in b){a.operator=v;break}i._parse=function(e){return null!=e?e+"":e},i.model&&i.model.fields&&(D=i.model.fields[a.field],D&&D.parse&&(i._parse=m(D.parse,D))),i.defaultOperator=a.operator,i.viewModel=g=l.observable({operator:a.operator,value:null,operatorVisible:function(){var e=this.get("value");return null!==e&&e!==t&&"undefined"!=e||r(this.get("operator"))&&!i._clearInProgress}}),g.bind(p,m(i.updateDsFilter,i)),w==f&&i.initSuggestDataSource(a),null!==a.inputWidth&&(y.addClass("k-sized-input"),y.width(a.inputWidth)),y.attr("aria-label",i._getColumnTitle()),i._setInputType(a,w),w!=d&&a.showOperators!==!1?i._createOperatorDropDown(b):(e('<div unselectable="on" />').css("display","none").text("eq").appendTo(n),n.addClass("k-operator-hidden")),i._createClearIcon(),l.bind(this.wrapper,g),w==f&&(a.template||i.setAutoCompleteSource()),w==c&&i.setComboBoxSource(i.options.values),i._refreshUI(),i._refreshHandler=m(i._refreshUI,i),i.dataSource.bind(p,i._refreshHandler)},_setInputType:function(t,r){var o,a,n,i,s,u=this,p=u.input;"function"==typeof t.template?(t.template.call(u.viewModel,{element:u.input,dataSource:u.suggestDataSource}),u._angularItems("compile")):r==f?p.attr(l.attr("role"),"autocomplete").attr(l.attr("text-field"),t.dataTextField||t.field).attr(l.attr("filter"),t.suggestionOperator).attr(l.attr("delay"),t.delay).attr(l.attr("min-length"),t.minLength).attr(l.attr("value-primitive"),!0):"date"==r?p.attr(l.attr("role"),"datepicker"):r==d?(p.remove(),o=e("<input type='radio'/>"),a=u.wrapper,n=l.guid(),i=e("<label/>").text(t.messages.isTrue).append(o),o.attr(l.attr("bind"),"checked:value").attr("name",n).val("true"),s=i.clone().text(t.messages.isFalse),o.clone().val("false").appendTo(s),a.append([i,s])):"number"==r?p.attr(l.attr("role"),"numerictextbox").attr("title",u._getColumnTitle()):r==c&&p.attr(l.attr("role"),"combobox").attr(l.attr("text-field"),"text").attr(l.attr("suggest"),!0).attr(l.attr("filter"),"contains").attr(l.attr("value-field"),"value").attr(l.attr("value-primitive"),!0)},_getColumnTitle:function(){var e=this.options.column;return e?e.title||e.field:""},_createOperatorDropDown:function(t){var r,o,a=[],n=this.viewModel;for(r in t)a.push({text:t[r],value:r});o=e('<input class="k-dropdown-operator" '+l.attr("bind")+'="value: operator"/>').appendTo(this.wrapper),this.operatorDropDown=o.kendoDropDownList({dataSource:a,dataTextField:"text",dataValueField:"value",open:function(){this.popup.element.width(150)},valuePrimitive:!0}).data("kendoDropDownList"),n.bind("change",function(){var e=t[n.operator];o.attr("aria-label",e)}),this.operatorDropDown.wrapper.find(".k-i-arrow-60-down").removeClass("k-i-arrow-60-down").addClass("k-i-filter")},initSuggestDataSource:function(e){var r=e.suggestDataSource;r instanceof s||(!e.customDataSource&&r&&(r.group=t),r=this.suggestDataSource=s.create(r)),e.customDataSource||(r._pageSize=t,r.reader.data=n(r.reader.data,this.options.field)),this.suggestDataSource=r},setAutoCompleteSource:function(){var e=this.input.data("kendoAutoComplete");e&&e.setDataSource(this.suggestDataSource)},setComboBoxSource:function(e){var t=s.create({data:e}),r=this.input.data("kendoComboBox");r&&r.setDataSource(t)},_refreshUI:function(){var t=this,r=o(t.dataSource.filter(),this.options.field)||{},a=t.viewModel;t.manuallyUpdatingVM=!0,r=e.extend(!0,{},r),t.options.type==d&&a.value!==r.value&&t.wrapper.find(":radio").prop("checked",!1),r.operator&&a.set("operator",r.operator),a.set("value",r.value),t.manuallyUpdatingVM=!1},updateDsFilter:function(o){var a,n,l,i,s=this,u=s.viewModel;s.manuallyUpdatingVM||"operator"==o.field&&u.value===t&&!r(u)||"operator"==o.field&&s._clearInProgress&&null!==u.value||(a=e.extend({},s.viewModel.toJSON(),{field:s.options.field}),n={logic:"and",filters:[]},l=!1,(a.value!==t&&null!==a.value||r(a)&&!this._clearInProgress)&&(n.filters.push(a),l=s.trigger(p,{filter:n,field:s.options.field})),(s._clearInProgress||null===a.value)&&(l=s.trigger(p,{filter:null,field:s.options.field})),l||(i=s._merge(n),s.dataSource.filter(i.filters.length?i:{})))},_merge:function(t){var o,n,l,i=this,s=t.logic||"and",u=t.filters,p=i.dataSource.filter()||{filters:[],logic:"and"};for(a(p,i.options.field),n=0,l=u.length;n<l;n++)o=u[n],o.value=i._parse(o.value);return u=e.grep(u,function(e){return""!==e.value&&null!==e.value||r(e)}),u.length&&(p.filters.length?(t.filters=u,"and"!==p.logic&&(p.filters=[{logic:p.logic,filters:p.filters}],p.logic="and"),p.filters.push(u.length>1?t:u[0])):(p.filters=u,p.logic=s)),p},_createClearIcon:function(){var t=this;e("<button type='button' class='k-button k-button-icon' title = "+t.options.messages.clear+"/>").attr("aria-label",t.options.messages.clear).attr(l.attr("bind"),"visible:operatorVisible").html("<span class='k-icon k-i-filter-clear'/>").click(m(t.clearFilter,t)).appendTo(t.wrapper)},clearFilter:function(){this._clearInProgress=!0,r(this.viewModel.operator)&&this.viewModel.set("operator",this.defaultOperator),this.viewModel.set("value",null),this._clearInProgress=!1},_angularItems:function(e){var t=this.wrapper.closest("th").get(),r=this.options.column;this.angular(e,function(){return{elements:t,data:[{column:r}]}})},destroy:function(){var e=this;e.filterModel=null,e.operatorDropDown=null,e._angularItems("cleanup"),e._refreshHandler&&(e.dataSource.bind(p,e._refreshHandler),e._refreshHandler=null),l.unbind(e.element),u.fn.destroy.call(e),l.destroy(e.element)},events:[p],options:{name:"FilterCell",delay:200,minLength:1,inputWidth:null,values:t,customDataSource:!1,field:"",dataTextField:"",type:"string",suggestDataSource:null,suggestionOperator:"startswith",operator:"eq",showOperators:!0,template:null,messages:{isTrue:"is true",isFalse:"is false",filter:"Filter",clear:"Clear",operator:"Operator"},operators:{string:{eq:g,neq:h,startswith:"Starts with",contains:"Contains",doesnotcontain:"Does not contain",endswith:"Ends with",isnull:"Is null",isnotnull:"Is not null",isempty:"Is empty",isnotempty:"Is not empty",isnullorempty:"Has no value",isnotnullorempty:"Has value"},number:{eq:g,neq:h,gte:"Is greater than or equal to",gt:"Is greater than",lte:"Is less than or equal to",lt:"Is less than",isnull:"Is null",isnotnull:"Is not null"},date:{eq:g,neq:h,gte:"Is after or equal to",gt:"Is after",lte:"Is before or equal to",lt:"Is before",isnull:"Is null",isnotnull:"Is not null"},enums:{eq:g,neq:h,isnull:"Is null",isnotnull:"Is not null"}}}});i.plugin(w)}(window.kendo.jQuery),window.kendo},r(3))},1186:function(e,t){e.exports=require("./kendo.autocomplete")}});