kendo-ui-core
Version:
3 lines (2 loc) • 2.72 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("kendo.core.js")):"function"==typeof define&&define.amd?define(["kendo.core.min"],t):((e="undefined"!=typeof globalThis?globalThis:e||self).kendodata=e.kendodata||{},e.kendodata.xml=e.kendodata.xml||{},e.kendodata.xml.js=t())}(this,(function(){return function(e,t){var n=window.kendo,r=Array.isArray,i=e.isPlainObject,o=e.map,a=e.each,d=e.extend,f=n.getter,l=n.Class.extend({init:function(e){var t=this,f=e.total,l=e.model,u=e.parse,s=e.errors,p=e.serialize,c=e.data;if(l){if(i(l)){var m=e.modelBase||n.data.Model;l.fields&&a(l.fields,(function(e,r){i(r)&&r.field?n.isFunction(r.field)||(r=d(r,{field:t.getter(r.field)})):r={field:t.getter(r)},l.fields[e]=r}));var h=l.id;if(h){var x={};x[t.xpathToMember(h,!0)]={field:t.getter(h)},l.fields=d(x,l.fields),l.id=t.xpathToMember(h)}l=m.define(l)}t.model=l}if(f&&("string"==typeof f?(f=t.getter(f),t.total=function(e){return parseInt(f(e),10)}):"function"==typeof f&&(t.total=f)),s&&("string"==typeof s?(s=t.getter(s),t.errors=function(e){return s(e)||null}):"function"==typeof s&&(t.errors=s)),c&&("string"==typeof c?(c=t.xpathToMember(c),t.data=function(e){var n,i=t.evaluate(e,c);return i=r(i)?i:[i],t.model&&l.fields?(n=new t.model,o(i,(function(e){if(e){var t,r={};for(t in l.fields)r[t]=n._parse(t,l.fields[t].field(e));return r}}))):i}):"function"==typeof c&&(t.data=c)),"function"==typeof u){var g=t.parse;t.parse=function(e){var n=u.call(t,e);return g.call(t,n)}}"function"==typeof p&&(t.serialize=p)},total:function(e){return this.data(e).length},errors:function(e){return e?e.errors:null},serialize:function(e){return e},parseDOM:function(e){var t,n,i,o,a,d,f,l={},u=e.attributes,s=u.length;for(f=0;f<s;f++)l["@"+(d=u[f]).nodeName]=d.nodeValue;for(n=e.firstChild;n;n=n.nextSibling)3===(i=n.nodeType)||4===i?l["#text"]=n.nodeValue:1===i&&(t=this.parseDOM(n),a=l[o=n.nodeName],r(a)?a.push(t):a=undefined!==a?[a,t]:t,l[o]=a);return l},evaluate:function(e,t){for(var n,i,o,a,d,f=t.split(".");n=f.shift();)if(e=e[n],r(e)){for(i=[],t=f.join("."),d=0,o=e.length;d<o;d++)a=this.evaluate(e[d],t),a=r(a)?a:[a],i.push.apply(i,a);return i}return e},parse:function(t){var n,r,i={};return n=t.documentElement||e.parseXML(t).documentElement,r=this.parseDOM(n),i[n.nodeName]=r,i},xpathToMember:function(e,t){return e?(e=e.replace(/^\//,"").replace(/\//g,".")).indexOf("@")>=0?e.replace(/\.?(@.*)/,t?"$1":'["$1"]'):e.indexOf("text()")>=0?e.replace(/(\.?text\(\))/,t?"#text":'["#text"]'):e:""},getter:function(e){return f(this.xpathToMember(e),!0)}});e.extend(!0,n.data,{XmlDataReader:l,readers:{xml:l}})}(window.kendo.jQuery),kendo}));
//# sourceMappingURL=kendo.data.xml.min.js.map