16 lines
2.9 KiB
JavaScript
16 lines
2.9 KiB
JavaScript
/**
|
|
* Copyright 2014 Telerik AD
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
!function(e,define){define(["./kendo.core.min"],e)}(function(){return function(e,t){var n=window.kendo,r=e.isArray,i=e.isPlainObject,o=e.map,a=e.each,s=e.extend,u=n.getter,l=n.Class,c=l.extend({init:function(e){var t,u,l,c,d=this,f=e.total,p=e.model,h=e.parse,m=e.errors,g=e.serialize,y=e.data;p&&(i(p)&&(t=e.modelBase||n.data.Model,p.fields&&a(p.fields,function(e,t){t=i(t)&&t.field?s(t,{field:d.getter(t.field)}):{field:d.getter(t)},p.fields[e]=t}),u=p.id,u&&(l={},l[d.xpathToMember(u,!0)]={field:d.getter(u)},p.fields=s(l,p.fields),p.id=d.xpathToMember(u)),p=t.define(p)),d.model=p),f&&("string"==typeof f?(f=d.getter(f),d.total=function(e){return parseInt(f(e),10)}):"function"==typeof f&&(d.total=f)),m&&("string"==typeof m?(m=d.getter(m),d.errors=function(e){return m(e)||null}):"function"==typeof m&&(d.errors=m)),y&&("string"==typeof y?(y=d.xpathToMember(y),d.data=function(e){var t,n=d.evaluate(e,y);return n=r(n)?n:[n],d.model&&p.fields?(t=new d.model,o(n,function(e){if(e){var n,r={};for(n in p.fields)r[n]=t._parse(n,p.fields[n].field(e));return r}})):n}):"function"==typeof y&&(d.data=y)),"function"==typeof h&&(c=d.parse,d.parse=function(e){var t=h.call(d,e);return c.call(d,t)}),"function"==typeof g&&(d.serialize=g)},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 n,i,o,a,s,u,l,c={},d=e.attributes,f=d.length;for(l=0;f>l;l++)u=d[l],c["@"+u.nodeName]=u.nodeValue;for(i=e.firstChild;i;i=i.nextSibling)o=i.nodeType,3===o||4===o?c["#text"]=i.nodeValue:1===o&&(n=this.parseDOM(i),a=i.nodeName,s=c[a],r(s)?s.push(n):s=s!==t?[s,n]:n,c[a]=s);return c},evaluate:function(e,t){for(var n,i,o,a,s,u=t.split(".");n=u.shift();)if(e=e[n],r(e)){for(i=[],t=u.join("."),s=0,o=e.length;o>s;s++)a=this.evaluate(e[s],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,"."),e.indexOf("@")>=0?e.replace(/\.?(@.*)/,t?"$1":'["$1"]'):e.indexOf("text()")>=0?e.replace(/(\.?text\(\))/,t?"#text":'["#text"]'):e):""},getter:function(e){return u(this.xpathToMember(e),!0)}});e.extend(!0,n.data,{XmlDataReader:c,readers:{xml:c}})}(window.kendo.jQuery),window.kendo},"function"==typeof define&&define.amd?define:function(e,t){t()}); |