UNPKG

@progress/kendo-ui

Version:

This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.

1 lines 9.26 kB
module.exports=function(e){function t(a){if(r[a])return r[a].exports;var o=r[a]={exports:{},id:a,loaded:!1};return e[a].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}({0:function(e,t,r){e.exports=r(1263)},3:function(e,t){e.exports=function(){throw Error("define cannot be used indirect")}},1061:function(e,t){e.exports=require("./kendo.combobox")},1062:function(e,t){e.exports=require("./kendo.dropdownlist")},1104:function(e,t){e.exports=require("./kendo.numerictextbox")},1189:function(e,t){e.exports=require("./kendo.datepicker")},1263:function(e,t,r){var a,o,n;!function(l,define){o=[r(1264),r(1189),r(1104),r(1061),r(1062)],a=l,n="function"==typeof a?a.apply(t,o):a,!(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 a(t,r){var o,n,l=[];if(e.isPlainObject(t))if(t.hasOwnProperty("filters"))l=t.filters;else if(t.field==r)return t;for(Array.isArray(t)&&(l=t),o=0;o<l.length;o++)if(n=a(l[o],r))return n}function o(t,r){t.filters&&(t.filters=e.grep(t.filters,function(e){return o(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 a,o,n=e(t),l=[],i=0,s={};i<n.length;)a=n[i++],o=r(a),s.hasOwnProperty(o)||(l.push(a),s[o]=!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(a,o){var n,i,s,g,h,v,w,y,b,_,x,S,I;if(a=e(a).addClass("k-filtercell"),n=this.wrapper=e("<span/>").appendTo(a),i=this,h=o,y=i.operators=o.operators||{},b=i.input=e("<input/>").attr(l.attr("bind"),"value: value").appendTo(n),_=o?o.suggestDataSource:null,_&&(o=e.extend({},o,{suggestDataSource:{}})),u.fn.init.call(i,a[0],o),_&&(i.options.suggestDataSource=_),o=i.options,s=i.dataSource=o.dataSource,i.model=s.reader.model,w=o.type=f,x=l.getter("reader.model.fields",!0)(s)||{},S=x[o.field],S&&S.type&&(w=o.type=S.type),o.values&&(o.type=w=c),y=y[w]||o.operators[w],!h.operator)for(v in y){o.operator=v;break}i._parse=function(e){return null!=e?e+"":e},i.model&&i.model.fields&&(I=i.model.fields[o.field],I&&I.parse&&(i._parse=m(I.parse,I))),i.defaultOperator=o.operator,i.viewModel=g=l.observable({operator:o.operator,value:null,operatorVisible:function(){var e=this.get("value");return null!==e&&e!==t&&"undefined"!=e||r(this.get("operator"))&&i.dataSource.filter()&&!i._clearInProgress}}),i._prevOperator=o.operator,g.bind(p,m(i.updateDsFilter,i)),w==f&&i.initSuggestDataSource(o),null!==o.inputWidth&&(b.addClass("k-sized-input"),b.width(o.inputWidth)),b.attr("aria-label",i._getColumnTitle()),b.attr("title",i._getColumnTitle()),i._setInputType(o,w),w!=d&&o.showOperators!==!1?i._createOperatorDropDown(y):(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&&(o.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 a,o,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").attr("id",l.guid()):r==d?(p.remove(),a=e("<input type='radio'/>"),o=u.wrapper,n=l.guid(),i=e("<label/>").text(t.messages.isTrue).append(a),a.attr(l.attr("bind"),"checked:value").attr("name",n).val("true"),s=i.clone().text(t.messages.isFalse),a.clone().val("false").appendTo(s),o.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,a,o=[],n=this.viewModel;for(r in t)o.push({text:t[r],value:r});a=e('<input class="k-dropdown-operator" '+l.attr("bind")+'="value: operator"/>').appendTo(this.wrapper),a.attr("aria-label",this._getColumnTitle()),this.operatorDropDown=a.kendoDropDownList({dataSource:o,dataTextField:"text",dataValueField:"value",open:function(){this.popup.element.width(150)},valuePrimitive:!0}).data("kendoDropDownList"),n.bind("change",function(){var e=t[n.operator];a.attr("aria-label",e)}),this.operatorDropDown.wrapper.attr("aria-label",this._getColumnTitle()).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&&!this.options.template&&r.setDataSource(t)},_refreshUI:function(){var t=this,r=a(t.dataSource.filter(),this.options.field)||{},o=t.viewModel;t.manuallyUpdatingVM=!0,r=e.extend(!0,{},r),t.options.type==d&&o.value!==r.value&&t.wrapper.find(":radio").prop("checked",!1),r.operator&&o.set("operator",r.operator),o.set("value",r.value),e.isEmptyObject(r)&&o.trigger(p,{field:"operatorVisible"}),t.manuallyUpdatingVM=!1},_applyFilter:function(e){this.dataSource.filter(e.filters.length?e:{})},updateDsFilter:function(a){var n,l,i,s,u,d=this,c=d.viewModel;return"operator"==a.field&&c.value===t&&!r(c)&&r(d._prevOperator)?(n=d.dataSource.filter()||{filters:[],logic:"and"},o(n,d.options.field),d._prevOperator=c.operator,d._applyFilter(n),t):(d.manuallyUpdatingVM||"operator"==a.field&&c.value===t&&!r(c)||"operator"==a.field&&d._clearInProgress&&null!==c.value||(l=e.extend({},d.viewModel.toJSON(),{field:d.options.field}),d._prevOperator=l.operator,i={logic:"and",filters:[]},s=!1,(l.value!==t&&null!==l.value||r(l)&&!this._clearInProgress)&&(i.filters.push(l),s=d.trigger(p,{filter:i,field:d.options.field})),(d._clearInProgress||null===l.value)&&(s=d.trigger(p,{filter:null,field:d.options.field})),s||(u=d._merge(i),d._applyFilter(u))),t)},_merge:function(t){var a,n,l,i=this,s=t.logic||"and",u=t.filters,p=i.dataSource.filter()||{filters:[],logic:"and"};for(o(p,i.options.field),n=0,l=u.length;n<l;n++)a=u[n],a.value=i._parse(a.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'></span>").on("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))},1264:function(e,t){e.exports=require("./kendo.autocomplete")}});