UNPKG

@progress/kendo-ui

Version:

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

1 lines 6.76 kB
module.exports=function(r){var n={};function a(e){if(n[e])return n[e].exports;var t=n[e]={exports:{},id:e,loaded:!1};return r[e].call(t.exports,t,t.exports,a),t.loaded=!0,t.exports}return a.m=r,a.c=n,a.p="",a(0)}({0:function(e,t,r){e.exports=r(1704)},3:function(e,t){e.exports=function(){throw Error("define cannot be used indirect")}},5:function(e,t){e.exports=require("../kendo.data")},20:function(e,t){e.exports=require("../kendo.core")},1704:function(e,t,r){var n;r(3),r=[r(20),r(5)],void 0===(t="function"==typeof(n=function(){var i=kendo,e=i.spreadsheet.Filter=i.Class.extend({prepare:function(){},value:function(e){return e.value},matches:function(){throw new Error("The 'matches' method is not implemented.")},toJSON:function(){throw new Error("The 'toJSON' method is not implemented.")}});function n(e){var t=e.getMonth()+1;if(t>=1&&t<=3)return 1;else if(t>=4&&t<=6)return 2;else if(t>=7&&t<=9)return 3;else return 4}function t(e,t){if(e instanceof Date){var r=i.date.today();r.setFullYear(r.getFullYear()+t);return r.getFullYear()===e.getFullYear()}return false}function r(e,t){if(e instanceof Date){var r=i.date.firstDayOfMonth(i.date.today());r.setMonth(r.getMonth()+t,1);return r.getTime()===i.date.firstDayOfMonth(e).getTime()}return false}function a(e,t){if(t instanceof Date){var r=i.date.dayOfWeek(i.date.getDate(e),1);var n=i.date.dayOfWeek(i.date.getDate(t),1);return r.getTime()===n.getTime()}return false}e.create=function(e){var t=e.filter;if(!t)throw new Error("Filter type not specified.");var r=i.spreadsheet[t.charAt(0).toUpperCase()+t.substring(1)+"Filter"];if(!r)throw new Error("Filter type not recognized.");return new r(e)},i.spreadsheet.ValueFilter=e.extend({_values:[],_dates:[],_blanks:false,init:function e(t){if(t.values!==undefined)this._values=t.values;if(t.blanks!==undefined)this._blanks=t.blanks;if(t.dates!==undefined)this._dates=t.dates},value:function(e){var t=e.value;if(this._dates.length>0&&e.format&&typeof t==="number"){var r=i.spreadsheet.formatting.type(t,e.format);if(r==="date")t=i.spreadsheet.numberToDate(t)}return t},matches:function(t){if(t===null||t===undefined)return this._blanks;if(t instanceof Date)return this._dates.some(function(e){return e.year===t.getFullYear()&&(e.month===undefined||e.month===t.getMonth())&&(e.day===undefined||e.day===t.getDate())&&(e.hours===undefined||e.hours===t.getHours())&&(e.minutes===undefined||e.minutes===t.getMinutes())&&(e.seconds===undefined||e.seconds===t.getSeconds())});return this._values.indexOf(t)>=0},toJSON:function(){return{filter:"value",blanks:this._blanks,values:this._values.slice(0)}}}),i.spreadsheet.CustomFilter=e.extend({_logic:"and",init:function e(t){if(t.logic!==undefined)this._logic=t.logic;if(t.criteria===undefined)throw new Error("Must specify criteria.");this._criteria=t.criteria;var r=i.data.Query.filterExpr({logic:this._logic,filters:this._criteria,accentFoldingFiltering:i.culture().name}).expression;this._matches=new Function("d","return "+r)},matches:function(e){if(e===null)return false;return this._matches(e)},value:function(e){var t=e.value;var r=this._criteria[0].value;var n=r instanceof Date?"date":typeof r;var a=typeof t;if(e.format)a=i.spreadsheet.formatting.type(t,e.format);if(a!=n){if(n=="string"){if(e.format)t=i.spreadsheet.formatting.text(t,e.format);t=t+""}}else if(a=="date")t=i.spreadsheet.numberToDate(t);return t},toJSON:function(){return{filter:"custom",logic:this._logic,criteria:this._criteria}}}),i.spreadsheet.TopFilter=e.extend({init:function e(t){this._type=t.type;this._value=t.value;this._values=[]},prepare:function(e){var t=e.map(this.value).sort().filter(function(e,t,r){return t===0||e!==r[t-1]});if(this._type==="topNumber"||this._type=="topPercent")t.sort(function(e,t){return t-e});else t.sort(function(e,t){return e-t});var r=this._value;if(this._type==="topPercent"||this._type==="bottomPercent")r=t.length*r/100>>0;this._values=t.slice(0,r)},matches:function(e){return this._values.indexOf(e)>=0},toJSON:function(){return{filter:"top",type:this._type,value:this._value}}}),i.spreadsheet.DynamicFilter=e.extend({init:function e(t){this._type=t.type;this._predicate=this[t.type];if(typeof this._predicate!=="function")throw new Error("DynamicFilter type '"+t.type+"' not recognized.")},value:function(e){var t=e.value;if(e.format){var r=i.spreadsheet.formatting.type(t,e.format);if(r==="date")t=i.spreadsheet.numberToDate(t)}return t},prepare:function(e){var t=0;var r=0;for(var n=0;n<e.length;n++){var a=this.value(e[n]);if(typeof a==="number"){t+=a;r++}}if(r>0)this._average=t/r;else this._average=0},matches:function(e){return this._predicate(e)},aboveAverage:function(e){if(e instanceof Date)e=i.spreadsheet.dateToNumber(e);if(typeof e!=="number")return false;return e>this._average},belowAverage:function(e){if(e instanceof Date)e=i.spreadsheet.dateToNumber(e);if(typeof e!=="number")return false;return e<this._average},tomorrow:function(e){if(e instanceof Date){var t=i.date.addDays(i.date.today(),1);return i.date.getDate(e).getTime()===t.getTime()}return false},today:function(e){if(e instanceof Date)return i.date.isToday(e);return false},yesterday:function(e){if(e instanceof Date){var t=i.date.addDays(i.date.today(),-1);return i.date.getDate(e).getTime()===t.getTime()}return false},nextWeek:function(e){return a(i.date.addDays(i.date.today(),7),e)},thisWeek:function(e){return a(i.date.today(),e)},lastWeek:function(e){return a(i.date.addDays(i.date.today(),-7),e)},nextMonth:function(e){return r(e,1)},thisMonth:function(e){return r(e,0)},lastMonth:function(e){return r(e,-1)},nextQuarter:function(e){if(e instanceof Date){var t=i.date.today();var r=n(e)-n(t);return r===1&&t.getFullYear()===e.getFullYear()||r==-3&&t.getFullYear()+1===e.getFullYear()}return false},thisQuarter:function(e){if(e instanceof Date){var t=i.date.today();var r=n(e)-n(t);return r===0&&t.getFullYear()===e.getFullYear()}return false},lastQuarter:function(e){if(e instanceof Date){var t=i.date.today();var r=n(t)-n(e);return r===1&&t.getFullYear()===e.getFullYear()||r==-3&&t.getFullYear()-1===e.getFullYear()}return false},nextYear:function(e){return t(e,1)},thisYear:function(e){return t(e,0)},lastYear:function(e){return t(e,-1)},yearToDate:function(e){if(e instanceof Date){var t=i.date.today();return e.getFullYear()===t.getFullYear()&&e<=t}return false},toJSON:function(){return{filter:"dynamic",type:this._type}}}),[1,2,3,4].forEach(function(t){i.spreadsheet.DynamicFilter.prototype["quarter"+t]=function(e){if(e instanceof Date)return n(e)===t;return false}}),i.cultures["en-US"].calendar.months.names.forEach(function(e,t){i.spreadsheet.DynamicFilter.prototype[e.toLowerCase()]=function(e){if(e instanceof Date)return e.getMonth()===t;return false}})})?n.apply(t,r):n)||(e.exports=t)}});