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.63 kB
module.exports=function(n){var r={};function a(e){if(r[e])return r[e].exports;var t=r[e]={exports:{},id:e,loaded:!1};return n[e].call(t.exports,t,t.exports,a),t.loaded=!0,t.exports}return a.m=n,a.c=r,a.p="",a(0)}({0:function(e,t,n){e.exports=n(1129)},3:function(e,t){e.exports=function(){throw Error("define cannot be used indirect")}},1051:function(e,t){e.exports=require("./kendo.core")},1129:function(e,t,n){var r;n(3),n=[n(1051)],void 0===(t="function"==typeof(r=function(){var e={id:"data.odata",name:"OData",category:"framework",depends:["core"],hidden:true},r=window.kendo.jQuery,g=void 0,c=window.kendo,d=r.extend,u="\r\n",f="\r\n\r\n",p=c.isFunction,m={eq:"eq",neq:"ne",gt:"gt",gte:"ge",lt:"lt",lte:"le",contains:"substringof",doesnotcontain:"substringof",endswith:"endswith",startswith:"startswith",isnull:"eq",isnotnull:"ne",isnullorempty:"eq",isnotnullorempty:"ne",isempty:"eq",isnotempty:"ne"},v=d({},m,{contains:"contains"}),s={pageSize:r.noop,page:r.noop,filter:function(e,t,n){if(t){t=j(t,n);if(t)e.$filter=t}},sort:function(e,t){var n=r.map(t,function(e){var t=e.field.replace(/\./g,"/");if(e.dir==="desc")t+=" desc";return t}).join(",");if(n)e.$orderby=n},skip:function(e,t){if(t)e.$skip=t},take:function(e,t){if(t)e.$top=t}},T={read:{dataType:"jsonp"}};function j(e,t){var n=[],f=e.logic||"and",r,a,o,i,s,d,u,p,l=e.filters;for(r=0,a=l.length;r<a;r++){e=l[r];o=e.field;u=e.value;d=e.operator;if(e.filters)e=j(e,t);else{p=e.ignoreCase;o=o.replace(/\./g,"/");e=m[d];if(t)e=v[d];if(d==="isnullorempty")e=c.format("{0} {1} null or {0} {1} ''",o,e);else if(d==="isnotnullorempty")e=c.format("{0} {1} null and {0} {1} ''",o,e);else if(d==="isnull"||d==="isnotnull")e=c.format("{0} {1} null",o,e);else if(d==="isempty"||d==="isnotempty")e=c.format("{0} {1} ''",o,e);else if(e&&u!==g){i=c.type(u);if(i==="string"){s="'{1}'";u=u.replace(/'/g,"''");if(p===true)o="tolower("+o+")"}else if(i==="date")if(t){s="{1:yyyy-MM-ddTHH:mm:ss+00:00}";u=c.timezone.apply(u,"Etc/UTC")}else s="datetime'{1:yyyy-MM-ddTHH:mm:ss}'";else s="{1}";if(e.length>3)if(e!=="substringof")s="{0}({2},"+s+")";else{s="{0}("+s+",{2})";if(d==="doesnotcontain")if(t){s="{0}({2},'{1}') eq -1";e="indexof"}else s+=" eq false"}else s="{2} {0} "+s;e=c.format(s,e,u,o)}}n.push(e)}e=n.join(" "+f+" ");if(n.length>1)e="("+e+")";return e}function n(e){for(var t in e)if(t.indexOf("@odata")===0)delete e[t]}function t(){return Math.floor((1+Math.random())*65536).toString(16).substr(1)}function l(e){return e+t()+"-"+t()+"-"+t()}function y(e,t){var n=u+"--"+e;if(t)n+="--";return n}function b(e,t,n,r){var a=e.options[r].url;var o=c.format("{0} ",n);if(p(a))return o+a(t);else return o+a}function x(e,t){var n="";n+=y(e,false);n+=u+"Content-Type: application/http";n+=u+"Content-Transfer-Encoding: binary";n+=u+"Content-ID: "+t;return n}function E(e){var t="";t+=u+"Content-Type: application/json;odata=minimalmetadata";t+=u+"Prefer: return=representation";t+=f+c.stringify(e);return t}function w(e,t,n,r,a,o){var i="";for(var s=0;s<e.length;s++){i+=x(t,n);i+=f+b(a,e[s],a.options[r].type,r)+" HTTP/1.1";if(!o)i+=E(e[s]);i+=u;n++}return i}function h(e,t,n,r,a,o,i){var s="";s+=$(t,n);s+=w(e,n,r,o,a,i);s+=y(n,true);s+=u;return s}function $(e,t){var n="";n+="--"+e+u;n+="Content-Type: multipart/mixed; boundary="+t+u;return n}function i(e,t){var n=d({},e.options.batch);var r=l("sf_batch_");var a="";var o=0;var i=e.options.batch.url;var s=l("sf_changeset_");n.type=e.options.batch.type;n.url=p(i)?i():i;n.headers=d(n.headers||{},{"Content-Type":"multipart/mixed; boundary="+r});if(t.updated.length){a+=h(t.updated,r,s,o,e,"update",false);o+=t.updated.length;s=l("sf_changeset_")}if(t.destroyed.length){a+=h(t.destroyed,r,s,o,e,"destroy",true);o+=t.destroyed.length;s=l("sf_changeset_")}if(t.created.length)a+=h(t.created,r,s,o,e,"create",false);a+=y(r,true);n.data=a;return n}function O(e){var t=e.match(/--changesetresponse_[a-z0-9-]+$/gm);var n=0;var r=[];var a;var o;var i;var s;var d;r.push({models:[],passed:true});for(var u=0;u<t.length;u++){s=t[u];if(s.lastIndexOf("--",s.length-1)){if(u<t.length-1)r.push({models:[],passed:true});continue}if(!n)n=e.indexOf(s);else n=e.indexOf(s,n+s.length);a=e.substring(n,e.indexOf("--",n+1));o=a.match(/^HTTP\/1\.\d (\d{3}) (.*)$/gm).pop();i=c.parseFloat(o.match(/\d{3}/g).pop());if(i>=200&&i<=299){d=a.match(/\{.*\}/gm);if(d)r[r.length-1].models.push(JSON.parse(d[0]))}else r[r.length-1].passed=false}return r}return d(true,c.data,{schemas:{odata:{type:"json",data:function(e){return e.d.results||[e.d]},total:"d.__count"}},transports:{odata:{read:{cache:true,dataType:"jsonp",jsonp:"$callback"},update:{cache:true,dataType:"json",contentType:"application/json",type:"PUT"},create:{cache:true,dataType:"json",contentType:"application/json",type:"POST"},destroy:{cache:true,dataType:"json",type:"DELETE"},parameterMap:function(e,t,n){var r,a,o,i;e=e||{};t=t||"read";i=(this.options||T)[t];i=i?i.dataType:"json";if(t==="read"){r={$inlinecount:"allpages"};if(i!="json")r.$format="json";for(o in e)if(s[o])s[o](r,e[o],n);else r[o]=e[o]}else{if(i!=="json")throw new Error("Only json dataType can be used for "+t+" operation.");if(t!=="destroy"){for(o in e){a=e[o];if(typeof a==="number")e[o]=a+""}r=c.stringify(e)}}return r}}}}),d(true,c.data,{schemas:{"odata-v4":{type:"json",data:function(e){if(Array.isArray(e)){for(var t=0;t<e.length;t++)n(e[t]);return e}else{e=r.extend({},e);n(e);if(e.value)return e.value;return[e]}},total:function(e){return e["@odata.count"]}}},transports:{"odata-v4":{batch:{type:"POST"},read:{cache:true,dataType:"json"},update:{cache:true,dataType:"json",contentType:"application/json;IEEE754Compatible=true",type:"PUT"},create:{cache:true,dataType:"json",contentType:"application/json;IEEE754Compatible=true",type:"POST"},destroy:{cache:true,dataType:"json",type:"DELETE"},parameterMap:function(e,t){var n=c.data.transports.odata.parameterMap(e,t,true);if(t=="read"){n.$count=true;delete n.$inlinecount}if(n&&n.$filter)n.$filter=n.$filter.replace(/('[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}')/gi,function(e){return e.substring(1,e.length-1)});return n},submit:function(a){var e=this;var t=i(e,a.data);var o=a.data;if(!o.updated.length&&!o.destroyed.length&&!o.created.length)return;r.ajax(d(true,{},{success:function(e){var t=O(e);var n=0;var r;if(o.updated.length){r=t[n];if(r.passed)a.success(r.models.length?r.models:[],"update");n++}if(o.destroyed.length){r=t[n];if(r.passed)a.success([],"destroy");n++}if(o.created.length){r=t[n];if(r.passed)a.success(r.models,"create")}},error:function(e,t,n){a.error(e,t,n)}},t))}}}}),window.kendo})?r.apply(t,n):r)||(e.exports=t)}});