{"version":3,"sources":["kendo.data.js"],"names":["f","define","$","undefined","eventHandler","context","type","field","prefix","e","key","event","CHANGE","_notifyChange","trigger","equal","x","y","xtype","ytype","getTime","getFieldByName","obj","name","fieldName","isPlainObject","Query","data","this","normalizeSort","dir","descriptor","STRING","descriptors","isArray","grep","d","sortFields","sorts","i","sortObject","length","index","normalizeOperator","expression","idx","filter","operator","filters","operatorMap","toLowerCase","normalizeFilter","isEmptyObject","logic","compareDescriptor","f1","f2","value","normalizeDescriptor","fieldComparer","a","b","compareFilters","expr1","expr2","filters1","filters2","slice","sort","normalizeAggregate","expressions","normalizeGroup","compare","skipItemSorting","map","aggregates","normalizeGroupWithoutCompare","anyGroupDescriptorHasCompare","groupDescriptors","isFunction","groupValueComparer","calculateAggregate","accumulator","item","state","aggr","functionName","len","aggregate","functions","kendo","accessor","isNumber","val","isNaN","isDate","toJSON","array","result","Array","serializeRecords","getters","modelInstance","originalFieldNames","fieldNames","record","getter","originalName","setters","setter","convertRecords","_parse","convertGroup","items","hasSubgroups","wrapDataAccess","originalFunction","model","converter","wrapDataAccessBase","toString","call","ObservableArray","fillLastGroup","originalGroup","newGroup","currOriginal","currentNew","push","apply","mergeGroups","target","dest","skip","take","group","concat","splice","flatGroups","groups","indexFunction","groupIndex","itemIndex","groupsLength","indexFn","flattenGroups","at","wrapGroupItems","LazyObservableArray","_events","eachGroupItems","func","replaceInRanges","ranges","observable","replaceInRange","replaceWithObservable","view","serverGrouping","viewIndex","removeModel","dataItem","uid","indexOfPristineModel","indexOf","idField","id","_defaultId","indexOfModel","comparer","fieldNameFromModel","fields","from","convertFilterDescriptorsField","convertDescriptorsField","inferSelect","select","options","firstField","secondField","optgroup","option","parentNode","disabled","label","text","attributes","specified","inferTable","table","fieldIndex","cells","cell","empty","tbody","tBodies","rows","fieldCount","nodeName","innerHTML","dataMethod","_data","DataSource","fn","arguments","_attachBubbleHandlers","inferList","list","elements","collection","tagName","add","find","textChild","className","children","textField","urlField","spriteCssClassField","imageUrlField","_loaded","eq","firstChild","attr","nodeType","nodeValue","prop","trim","replace","hasChildren","ObservableObject","parsers","defaultValues","Model","Comparer","StableComparer","operators","LocalTransport","RemoteTransport","Cache","DataReader","Transport","Node","HierarchicalDataSource","Buffer","BatchBuffer","extend","proxy","ajax","each","noop","window","Observable","Class","FUNCTION","ASCENDING","CREATE","READ","UPDATE","DESTROY","SYNC","GET","ERROR","REQUESTSTART","PROGRESS","REQUESTEND","crud","identity","o","stringify","math","Math","join","pop","shift","unshift","stableSort","support","dateRegExp","init","that","wrapAll","serializeFunctions","json","parent","source","wrap","object","bind","node","action","omitChangeEvent","howMany","unbind","forEach","callback","thisArg","reduce","reduceRight","every","some","remove","Symbol","iterator","prototype","events","_parent","member","_handlers","charAt","guid","shouldSerialize","hasOwnProperty","get","_set","paths","path","composite","split","set","isSetPrevented","current","change","isObservableArray","isDataSource","number","parseFloat","date","parseDate","boolean","string","default","Date","defaults","_initializers","dirty","dirtyFields","parse","editable","accept","isNew","base","proto","functionFields","nullable","defaultValue","selector","localeCompare","create","combine","comparers","asc","valueA","valueB","__position","desc","quote","str","JSON","textOp","impl","ignore","accentFoldingFiltering","toLocaleLowerCase","op","exec","getMatchRegexp","pattern","rx","esc","ch","neq","gt","gte","lt","lte","startswith","doesnotstartwith","endswith","n","doesnotendwith","contains","doesnotcontain","matches","substring","doesnotmatch","isempty","isnotempty","isnull","isnotnull","isnullorempty","isnotnullorempty","filterExpr","expr","and","or","fieldFunctions","operatorFunctions","match","ignoreCase","==","equals","isequalto","equalto","!=","ne","notequals","isnotequalto","notequalto","notequal","<","islessthan","lessthan","less","<=","le","islessthanorequalto","lessthanequal",">","isgreaterthan","greaterthan","greater",">=","isgreaterthanorequalto","greaterthanequal","ge","notsubstringof","toArray","range","count","order","inPlace","orderBy","orderByDescending","compiled","predicate","Function","allData","groupPaging","groupAllData","itemCount","subgroupCount","groupBy","sorted","groupValue","currentValue","_sortForGrouping","_sortGroups","sum","average","max","min","process","customGroupSort","query","groupDescriptorsWithoutCompare","normalizedSort","groupDescriptorsWithoutSort","total","filterCallback","groupDescriptor","read","success","update","destroy","parameterMap","url","cache","submit","setup","error","parameters","operation","_store","clear","store","inmemory","schema","dataFunction","groupsFunction","serializeFunction","serializeGetters","modelBase","_dataAccessFunction","serialize","fromName","_wrapDataAccessBase","errors","_map","_prefetch","_pristineData","_ranges","_view","_pristineTotal","_destroyed","_pageSize","pageSize","_page","page","_sort","_sortFields","_filter","_group","_aggregate","_total","_groupPaging","_groupsState","_shouldDetachObservableParents","transport","pushCreate","_pushCreate","pushUpdate","_pushUpdate","pushDestroy","_pushDestroy","offlineStorage","_storage","getItem","localStorage","setItem","reader","readers","_detachObservableParents","_observe","_online","serverSorting","serverPaging","serverFiltering","serverAggregates","batch","inPlaceSort","clone","online","sync","Deferred","resolve","promise","offlineData","_isServerGrouped","_isServerGroupPaged","_isGroupPaged","_push","_readData","_flatData","useRanges","getByUid","_getByUid","dataItems","_storeData","_addRange","_process","_observeView","flatView","insert","_createNewModel","_wrapInEmptyGroup","_insertModelInRange","pushInsert","pushed","autoSync","pristine","rangeSpan","_getCurrentRangeSpan","last","pristineData","_updatePristineForModel","_removeItems","removePristine","shouldRemovePristine","destroyed","found","_eachItem","_removePristineForModel","hasGroups","_removeModelFromRanges","created","updated","promises","_sendSubmit","_send","when","then","_accept","_syncEnd","_change","cancelChanges","_cancelModel","_changesCanceled","_markOfflineUpdatesAsDirty","__state__","hasChanges","models","response","serverGroup","_handleCustomErrors","values","_executeOnPristineForModel","deepExtend","_eachPristineItem","_pristineForModel","_modelCanceled","_submit","status","reject","deferred","_promise","method","converted","params","_params","_queueRequest","isPrevented","_dequeueRequest","args","_readAggregates","replaceSubset","itemIds","j","_serverGroupsTotal","_aggregateResult","_skip","endless","_changeHandler","updatePristine","end","start","timestamp","_timeStamp","outerStart","outerEnd","_sortRanges","_groupsFlat","_appendToGroupsFlat","_updateOuterRangesLength","_getGroupByUid","xhr","errorThrown","_requestInProgress","_pending","_shouldWrap","arrayType","_updateTotalForAction","parseInt","handler","first","_calculateAggregates","_take","currentRangeStart","_clearEmptyGroups","_queryProcess","dataToAggregate","_setView","_setFilterTotal","_mergeState","_currentRangeStart","moreItemsCount","remote","_hasExpandedSubGroups","_findGroupedRange","parents","itemsLength","hasNotRequestedItems","groupCount","itemsToSkip","taken","getGroupSubGroupCount","_fetchingGroupItems","skipped","getGroupItems","includeParents","excludeHeader","currentItems","subgroups","_composeItemsFilter","floor","findSubgroups","clearTimeout","_timeout","setTimeout","_groupItemsSuccessHandler","g","includeSubGroupCount","_subGroupCountSuccessHandler","totalField","temp","_updateRangePristineData","_currentRequestTimeStamp","_skipRequestsInProgress","indexOfCurrentGroup","currentGroup","dataLength","indexes","rangesLength","_containsSubGroup","_cloneGroup","subgroup","currentSubGroup","filterTotal","setDefaultValue","fetch","_query","done","next","totalPages","prev","_pageableQueryOptions","round","getGroupsFlat","groupsTotal","includeExpanded","_calculateGroupsTotal","itemsField","ignoreState","_groupsTotal","countGroupRange","_emptyAggregates","ceil","inRange","_findRange","lastRange","firstItemUid","enableRequestsInProgress","pageSkip","size","_originalPageSkip","_originalSize","_adjustPageSkip","_groupRangeExists","_rangeExists","prefetch","_processRangeData","skipIdx","takeIdx","startIndex","endIndex","rangeData","rangeEnd","processed","flatData","prevRangeEnd","currentDataLength","groupMapOptions","isGroupPaged","startField","endField","_mergeGroups","_getRangesMismatch","mismatch","prevGroup","eventData","paging","sorting","filtering","_omitPrefetch","_prefetchSuccessHandler","force","_multiplePrefetch","prevRange","_getPrevRange","_getNextRange","availableItemsCount","_removeModelFromRange","_updateRangesLength","rangeLength","mismatchFound","mismatchLength","lengthDifference","abs","dataSource","transportOptions","transports","schemas","logToConsole","hasChildrenObject","childrenField","childrenOptions","_childrenOptions","_initChildren","_updateChildrenField","append","loaded","level","_childrenLoaded","load","one","_matchFilter","_hierarchicalFilter","_markHierarchicalQuery","_updateHierarchicalFilter","_find","_dataSource","viewSize","disablePrefetch","_prefetching","buffer","_reset","_syncWithDataSource","setViewSize","_recalculate","itemPresent","dataOffset","prefetchThreshold","midPageThreshold","nextMidRange","nextPageThreshold","nextFullRange","pullBackThreshold","offset","previousMidRange","previousFullRange","_goToRange","nextRange","syncDataSource","prefetchOffset","expanding","_expanding","_syncPending","_firstItemUid","batchSize","batchBuffer","endreached","prefetching","prefetched","reset","resize","jQuery","amd","a1","a2","a3"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;CAwBC,SAAUA,EAAGC,QACVA,OAAO,cACH,aACA,mBACA,kBACDD,IACL,WAy2JE,MA70JC,UAAUE,EAAGC,GAsRV,QAASC,GAAaC,EAASC,EAAMC,EAAOC,GACxC,MAAO,UAAUC,GACb,GAAgBC,GAAZC,IACJ,KAAKD,IAAOD,GACRE,EAAMD,GAAOD,EAAEC,EAGfC,GAAMJ,MADNC,EACcD,EAAQ,IAAME,EAAEF,MAEhBA,EAEdD,GAAQM,IAAUP,EAAQQ,eAC1BR,EAAQQ,cAAcF,GAE1BN,EAAQS,QAAQR,EAAMK,IAkI9B,QAASI,GAAMC,EAAGC,GACd,GAAID,IAAMC,EACN,OAAO,CAEX,IAA0CV,GAAtCW,EAAQhB,EAAEI,KAAKU,GAAIG,EAAQjB,EAAEI,KAAKW,EACtC,IAAIC,IAAUC,EACV,OAAO,CAEX,IAAc,SAAVD,EACA,MAAOF,GAAEI,YAAcH,EAAEG,SAE7B,IAAc,WAAVF,GAAgC,UAAVA,EACtB,OAAO,CAEX,KAAKX,IAASS,GACV,IAAKD,EAAMC,EAAET,GAAQU,EAAEV,IACnB,OAAO,CAGf,QAAO,EA0CX,QAASc,GAAeC,EAAKC,GACzB,GAAIhB,GAAOiB,CACX,KAAKA,IAAaF,GAAK,CAEnB,GADAf,EAAQe,EAAIE,GACRC,GAAclB,IAAUA,EAAMA,OAASA,EAAMA,QAAUgB,EACvD,MAAOhB,EACJ,IAAIA,IAAUgB,EACjB,MAAOhB,GAGf,MAAO,MAkYX,QAASmB,GAAMC,GACXC,KAAKD,K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OjK,MAAM+tB,QACR9jB,OAAOjK,OACE,kBAAVzF,SAAwBA,OAAOyzB,IAAMzzB,OAAS,SAAU0zB,EAAIC,EAAIC,IACrEA,GAAMD","file":"kendo.data.min.js","sourcesContent":["/*!\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n*/\n(function (f, define) {\n define('kendo.data', [\n 'kendo.core',\n 'kendo.data.odata',\n 'kendo.data.xml'\n ], f);\n}(function () {\n var __meta__ = {\n id: 'data',\n name: 'Data source',\n category: 'framework',\n description: 'Powerful component for using local and remote data.Fully supports CRUD, Sorting, Paging, Filtering, Grouping, and Aggregates.',\n depends: ['core'],\n features: [\n {\n id: 'data-odata',\n name: 'OData',\n description: 'Support for accessing Open Data Protocol (OData) services.',\n depends: ['data.odata']\n },\n {\n id: 'data-signalr',\n name: 'SignalR',\n description: 'Support for binding to SignalR hubs.',\n depends: ['data.signalr']\n },\n {\n id: 'data-XML',\n name: 'XML',\n description: 'Support for binding to XML.',\n depends: ['data.xml']\n }\n ]\n };\n (function ($, undefined) {\n var extend = $.extend, proxy = $.proxy, isPlainObject = $.isPlainObject, isEmptyObject = $.isEmptyObject, isArray = $.isArray, grep = $.grep, ajax = $.ajax, map, each = $.each, noop = $.noop, kendo = window.kendo, isFunction = kendo.isFunction, Observable = kendo.Observable, Class = kendo.Class, STRING = 'string', FUNCTION = 'function', ASCENDING = 'asc', CREATE = 'create', READ = 'read', UPDATE = 'update', DESTROY = 'destroy', CHANGE = 'change', SYNC = 'sync', GET = 'get', ERROR = 'error', REQUESTSTART = 'requestStart', PROGRESS = 'progress', REQUESTEND = 'requestEnd', crud = [\n CREATE,\n READ,\n UPDATE,\n DESTROY\n ], identity = function (o) {\n return o;\n }, getter = kendo.getter, stringify = kendo.stringify, math = Math, push = [].push, join = [].join, pop = [].pop, splice = [].splice, shift = [].shift, slice = [].slice, unshift = [].unshift, toString = {}.toString, stableSort = kendo.support.stableSort, dateRegExp = /^\\/Date\\((.*?)\\)\\/$/;\n var ObservableArray = Observable.extend({\n init: function (array, type) {\n var that = this;\n that.type = type || ObservableObject;\n Observable.fn.init.call(that);\n that.length = array.length;\n that.wrapAll(array, that);\n },\n at: function (index) {\n return this[index];\n },\n toJSON: function (serializeFunctions) {\n var idx, length = this.length, value, json = new Array(length);\n for (idx = 0; idx < length; idx++) {\n value = this[idx];\n if (value instanceof ObservableObject) {\n value = value.toJSON(serializeFunctions);\n }\n json[idx] = value;\n }\n return json;\n },\n parent: noop,\n wrapAll: function (source, target) {\n var that = this, idx, length, parent = function () {\n return that;\n };\n target = target || [];\n for (idx = 0, length = source.length; idx < length; idx++) {\n target[idx] = that.wrap(source[idx], parent);\n }\n return target;\n },\n wrap: function (object, parent) {\n var that = this, observable;\n if (object !== null && toString.call(object) === '[object Object]') {\n observable = object instanceof that.type || object instanceof Model;\n if (!observable) {\n object = object instanceof ObservableObject ? object.toJSON() : object;\n object = new that.type(object);\n }\n object.parent = parent;\n object.bind(CHANGE, function (e) {\n that.trigger(CHANGE, {\n field: e.field,\n node: e.node,\n index: e.index,\n items: e.items || [this],\n action: e.node ? e.action || 'itemloaded' : 'itemchange'\n });\n });\n }\n return object;\n },\n push: function () {\n var index = this.length, items = this.wrapAll(arguments), result;\n result = push.apply(this, items);\n if (!this.omitChangeEvent) {\n this.trigger(CHANGE, {\n action: 'add',\n index: index,\n items: items\n });\n }\n return result;\n },\n slice: slice,\n sort: [].sort,\n join: join,\n pop: function () {\n var length = this.length, result = pop.apply(this);\n if (length) {\n this.trigger(CHANGE, {\n action: 'remove',\n index: length - 1,\n items: [result]\n });\n }\n return result;\n },\n splice: function (index, howMany, item) {\n var items = this.wrapAll(slice.call(arguments, 2)), result, i, len;\n result = splice.apply(this, [\n index,\n howMany\n ].concat(items));\n if (result.length) {\n this.trigger(CHANGE, {\n action: 'remove',\n index: index,\n items: result\n });\n for (i = 0, len = result.length; i < len; i++) {\n if (result[i] && result[i].children) {\n result[i].unbind(CHANGE);\n }\n }\n }\n if (item) {\n this.trigger(CHANGE, {\n action: 'add',\n index: index,\n items: items\n });\n }\n return result;\n },\n shift: function () {\n var length = this.length, result = shift.apply(this);\n if (length) {\n this.trigger(CHANGE, {\n action: 'remove',\n index: 0,\n items: [result]\n });\n }\n return result;\n },\n unshift: function () {\n var items = this.wrapAll(arguments), result;\n result = unshift.apply(this, items);\n this.trigger(CHANGE, {\n action: 'add',\n index: 0,\n items: items\n });\n return result;\n },\n indexOf: function (item) {\n var that = this, idx, length;\n for (idx = 0, length = that.length; idx < length; idx++) {\n if (that[idx] === item) {\n return idx;\n }\n }\n return -1;\n },\n forEach: function (callback, thisArg) {\n var idx = 0;\n var length = this.length;\n var context = thisArg || window;\n for (; idx < length; idx++) {\n callback.call(context, this[idx], idx, this);\n }\n },\n map: function (callback, thisArg) {\n var idx = 0;\n var result = [];\n var length = this.length;\n var context = thisArg || window;\n for (; idx < length; idx++) {\n result[idx] = callback.call(context, this[idx], idx, this);\n }\n return result;\n },\n reduce: function (callback) {\n var idx = 0, result, length = this.length;\n if (arguments.length == 2) {\n result = arguments[1];\n } else if (idx < length) {\n result = this[idx++];\n }\n for (; idx < length; idx++) {\n result = callback(result, this[idx], idx, this);\n }\n return result;\n },\n reduceRight: function (callback) {\n var idx = this.length - 1, result;\n if (arguments.length == 2) {\n result = arguments[1];\n } else if (idx > 0) {\n result = this[idx--];\n }\n for (; idx >= 0; idx--) {\n result = callback(result, this[idx], idx, this);\n }\n return result;\n },\n filter: function (callback, thisArg) {\n var idx = 0;\n var result = [];\n var item;\n var length = this.length;\n var context = thisArg || window;\n for (; idx < length; idx++) {\n item = this[idx];\n if (callback.call(context, item, idx, this)) {\n result[result.length] = item;\n }\n }\n return result;\n },\n find: function (callback, thisArg) {\n var idx = 0;\n var item;\n var length = this.length;\n var context = thisArg || window;\n for (; idx < length; idx++) {\n item = this[idx];\n if (callback.call(context, item, idx, this)) {\n return item;\n }\n }\n },\n every: function (callback, thisArg) {\n var idx = 0;\n var item;\n var length = this.length;\n var context = thisArg || window;\n for (; idx < length; idx++) {\n item = this[idx];\n if (!callback.call(context, item, idx, this)) {\n return false;\n }\n }\n return true;\n },\n some: function (callback, thisArg) {\n var idx = 0;\n var item;\n var length = this.length;\n var context = thisArg || window;\n for (; idx < length; idx++) {\n item = this[idx];\n if (callback.call(context, item, idx, this)) {\n return true;\n }\n }\n return false;\n },\n remove: function (item) {\n var idx = this.indexOf(item);\n if (idx !== -1) {\n this.splice(idx, 1);\n }\n },\n empty: function () {\n this.splice(0, this.length);\n }\n });\n if (typeof Symbol !== 'undefined' && Symbol.iterator && !ObservableArray.prototype[Symbol.iterator]) {\n ObservableArray.prototype[Symbol.iterator] = [][Symbol.iterator];\n }\n var LazyObservableArray = ObservableArray.extend({\n init: function (data, type, events) {\n Observable.fn.init.call(this);\n this.type = type || ObservableObject;\n if (events) {\n this._events = events;\n }\n for (var idx = 0; idx < data.length; idx++) {\n this[idx] = data[idx];\n }\n this.length = idx;\n this._parent = proxy(function () {\n return this;\n }, this);\n },\n at: function (index) {\n var item = this[index];\n if (!(item instanceof this.type)) {\n item = this[index] = this.wrap(item, this._parent);\n } else {\n item.parent = this._parent;\n }\n return item;\n }\n });\n function eventHandler(context, type, field, prefix) {\n return function (e) {\n var event = {}, key;\n for (key in e) {\n event[key] = e[key];\n }\n if (prefix) {\n event.field = field + '.' + e.field;\n } else {\n event.field = field;\n }\n if (type == CHANGE && context._notifyChange) {\n context._notifyChange(event);\n }\n context.trigger(type, event);\n };\n }\n var ObservableObject = Observable.extend({\n init: function (value) {\n var that = this, member, field, parent = function () {\n return that;\n };\n Observable.fn.init.call(this);\n this._handlers = {};\n for (field in value) {\n member = value[field];\n if (typeof member === 'object' && member && !member.getTime && field.charAt(0) != '_') {\n member = that.wrap(member, field, parent);\n }\n that[field] = member;\n }\n that.uid = kendo.guid();\n },\n shouldSerialize: function (field, serializeFunctions) {\n return this.hasOwnProperty(field) && field !== '_handlers' && field !== '_events' && (serializeFunctions && serializeFunctions[field] || typeof this[field] !== FUNCTION) && field !== 'uid';\n },\n forEach: function (f) {\n for (var i in this) {\n if (this.shouldSerialize(i)) {\n f(this[i], i);\n }\n }\n },\n toJSON: function (serializeFunctions) {\n var result = {}, value, field;\n for (field in this) {\n if (this.shouldSerialize(field, serializeFunctions)) {\n value = this[field];\n if (value instanceof ObservableObject || value instanceof ObservableArray) {\n value = value.toJSON(serializeFunctions);\n }\n result[field] = value;\n }\n }\n return result;\n },\n get: function (field) {\n var that = this, result;\n that.trigger(GET, { field: field });\n if (field === 'this') {\n result = that;\n } else {\n result = kendo.getter(field, true)(that);\n }\n return result;\n },\n _set: function (field, value) {\n var that = this;\n var composite = field.indexOf('.') >= 0;\n if (composite) {\n var paths = field.split('.'), path = '';\n while (paths.length > 1) {\n path += paths.shift();\n var obj = kendo.getter(path, true)(that);\n if (obj instanceof ObservableObject) {\n obj.set(paths.join('.'), value);\n return composite;\n }\n path += '.';\n }\n }\n kendo.setter(field)(that, value);\n return composite;\n },\n set: function (field, value) {\n var that = this, isSetPrevented = false, composite = field.indexOf('.') >= 0, current = kendo.getter(field, true)(that);\n if (current !== value) {\n if (current instanceof Observable && this._handlers[field]) {\n if (this._handlers[field].get) {\n current.unbind(GET, this._handlers[field].get);\n }\n current.unbind(CHANGE, this._handlers[field].change);\n }\n isSetPrevented = that.trigger('set', {\n field: field,\n value: value\n });\n if (!isSetPrevented) {\n if (!composite) {\n value = that.wrap(value, field, function () {\n return that;\n });\n }\n if (!that._set(field, value) || field.indexOf('(') >= 0 || field.indexOf('[') >= 0) {\n that.trigger(CHANGE, { field: field });\n }\n }\n }\n return isSetPrevented;\n },\n parent: noop,\n wrap: function (object, field, parent) {\n var that = this;\n var get;\n var change;\n var type = toString.call(object);\n if (object != null && (type === '[object Object]' || type === '[object Array]')) {\n var isObservableArray = object instanceof ObservableArray;\n var isDataSource = object instanceof DataSource;\n if (type === '[object Object]' && !isDataSource && !isObservableArray) {\n if (!(object instanceof ObservableObject)) {\n object = new ObservableObject(object);\n }\n get = eventHandler(that, GET, field, true);\n object.bind(GET, get);\n change = eventHandler(that, CHANGE, field, true);\n object.bind(CHANGE, change);\n that._handlers[field] = {\n get: get,\n change: change\n };\n } else if (type === '[object Array]' || isObservableArray || isDataSource) {\n if (!isObservableArray && !isDataSource) {\n object = new ObservableArray(object);\n }\n change = eventHandler(that, CHANGE, field, false);\n object.bind(CHANGE, change);\n that._handlers[field] = { change: change };\n }\n object.parent = parent;\n }\n return object;\n }\n });\n function equal(x, y) {\n if (x === y) {\n return true;\n }\n var xtype = $.type(x), ytype = $.type(y), field;\n if (xtype !== ytype) {\n return false;\n }\n if (xtype === 'date') {\n return x.getTime() === y.getTime();\n }\n if (xtype !== 'object' && xtype !== 'array') {\n return false;\n }\n for (field in x) {\n if (!equal(x[field], y[field])) {\n return false;\n }\n }\n return true;\n }\n var parsers = {\n 'number': function (value) {\n if (typeof value === STRING && value.toLowerCase() === 'null') {\n return null;\n }\n return kendo.parseFloat(value);\n },\n 'date': function (value) {\n if (typeof value === STRING && value.toLowerCase() === 'null') {\n return null;\n }\n return kendo.parseDate(value);\n },\n 'boolean': function (value) {\n if (typeof value === STRING) {\n if (value.toLowerCase() === 'null') {\n return null;\n } else {\n return value.toLowerCase() === 'true';\n }\n }\n return value != null ? !!value : value;\n },\n 'string': function (value) {\n if (typeof value === STRING && value.toLowerCase() === 'null') {\n return null;\n }\n return value != null ? value + '' : value;\n },\n 'default': function (value) {\n return value;\n }\n };\n var defaultValues = {\n 'string': '',\n 'number': 0,\n 'date': new Date(),\n 'boolean': false,\n 'default': ''\n };\n function getFieldByName(obj, name) {\n var field, fieldName;\n for (fieldName in obj) {\n field = obj[fieldName];\n if (isPlainObject(field) && field.field && field.field === name) {\n return field;\n } else if (field === name) {\n return field;\n }\n }\n return null;\n }\n var Model = ObservableObject.extend({\n init: function (data) {\n var that = this;\n if (!data || $.isEmptyObject(data)) {\n data = $.extend({}, that.defaults, data);\n if (that._initializers) {\n for (var idx = 0; idx < that._initializers.length; idx++) {\n var name = that._initializers[idx];\n data[name] = that.defaults[name]();\n }\n }\n }\n ObservableObject.fn.init.call(that, data);\n that.dirty = false;\n that.dirtyFields = {};\n if (that.idField) {\n that.id = that.get(that.idField);\n if (that.id === undefined) {\n that.id = that._defaultId;\n }\n }\n },\n shouldSerialize: function (field) {\n return ObservableObject.fn.shouldSerialize.call(this, field) && field !== 'uid' && !(this.idField !== 'id' && field === 'id') && field !== 'dirty' && field !== 'dirtyFields' && field !== '_accessors';\n },\n _parse: function (field, value) {\n var that = this, fieldName = field, fields = that.fields || {}, parse;\n field = fields[field];\n if (!field) {\n field = getFieldByName(fields, fieldName);\n }\n if (field) {\n parse = field.parse;\n if (!parse && field.type) {\n parse = parsers[field.type.toLowerCase()];\n }\n }\n return parse ? parse(value) : value;\n },\n _notifyChange: function (e) {\n var action = e.action;\n if (action == 'add' || action == 'remove') {\n this.dirty = true;\n this.dirtyFields[e.field] = true;\n }\n },\n editable: function (field) {\n field = (this.fields || {})[field];\n return field ? field.editable !== false : true;\n },\n set: function (field, value) {\n var that = this;\n var dirty = that.dirty;\n if (that.editable(field)) {\n value = that._parse(field, value);\n if (!equal(value, that.get(field))) {\n that.dirty = true;\n that.dirtyFields[field] = true;\n if (ObservableObject.fn.set.call(that, field, value) && !dirty) {\n that.dirty = dirty;\n if (!that.dirty) {\n that.dirtyFields[field] = false;\n }\n }\n } else {\n that.trigger('equalSet', {\n field: field,\n value: value\n });\n }\n }\n },\n accept: function (data) {\n var that = this, parent = function () {\n return that;\n }, field;\n for (field in data) {\n var value = data[field];\n if (field.charAt(0) != '_') {\n value = that.wrap(data[field], field, parent);\n }\n that._set(field, value);\n }\n if (that.idField) {\n that.id = that.get(that.idField);\n }\n that.dirty = false;\n that.dirtyFields = {};\n },\n isNew: function () {\n return this.id === this._defaultId;\n }\n });\n Model.define = function (base, options) {\n if (options === undefined) {\n options = base;\n base = Model;\n }\n var model, proto = extend({ defaults: {} }, options), name, field, type, value, idx, length, fields = {}, originalName, id = proto.id, functionFields = [];\n if (id) {\n proto.idField = id;\n }\n if (proto.id) {\n delete proto.id;\n }\n if (id) {\n proto.defaults[id] = proto._defaultId = '';\n }\n if (toString.call(proto.fields) === '[object Array]') {\n for (idx = 0, length = proto.fields.length; idx < length; idx++) {\n field = proto.fields[idx];\n if (typeof field === STRING) {\n fields[field] = {};\n } else if (field.field) {\n fields[field.field] = field;\n }\n }\n proto.fields = fields;\n }\n for (name in proto.fields) {\n field = proto.fields[name];\n type = field.type || 'default';\n value = null;\n originalName = name;\n name = typeof field.field === STRING ? field.field : name;\n if (!field.nullable) {\n value = proto.defaults[originalName !== name ? originalName : name] = field.defaultValue !== undefined ? field.defaultValue : defaultValues[type.toLowerCase()];\n if (typeof value === 'function') {\n functionFields.push(name);\n }\n }\n if (options.id === name) {\n proto._defaultId = value;\n }\n proto.defaults[originalName !== name ? originalName : name] = value;\n field.parse = field.parse || parsers[type];\n }\n if (functionFields.length > 0) {\n proto._initializers = functionFields;\n }\n model = base.extend(proto);\n model.define = function (options) {\n return Model.define(model, options);\n };\n if (proto.fields) {\n model.fields = proto.fields;\n model.idField = proto.idField;\n }\n return model;\n };\n var Comparer = {\n selector: function (field) {\n return isFunction(field) ? field : getter(field);\n },\n compare: function (field) {\n var selector = this.selector(field);\n return function (a, b) {\n a = selector(a);\n b = selector(b);\n if (a == null && b == null) {\n return 0;\n }\n if (a == null) {\n return -1;\n }\n if (b == null) {\n return 1;\n }\n if (a.localeCompare) {\n return a.localeCompare(b);\n }\n return a > b ? 1 : a < b ? -1 : 0;\n };\n },\n create: function (sort) {\n var compare = sort.compare || this.compare(sort.field);\n if (sort.dir == 'desc') {\n return function (a, b) {\n return compare(b, a, true);\n };\n }\n return compare;\n },\n combine: function (comparers) {\n return function (a, b) {\n var result = comparers[0](a, b), idx, length;\n for (idx = 1, length = comparers.length; idx < length; idx++) {\n result = result || comparers[idx](a, b);\n }\n return result;\n };\n }\n };\n var StableComparer = extend({}, Comparer, {\n asc: function (field) {\n var selector = this.selector(field);\n return function (a, b) {\n var valueA = selector(a);\n var valueB = selector(b);\n if (valueA && valueA.getTime && valueB && valueB.getTime) {\n valueA = valueA.getTime();\n valueB = valueB.getTime();\n }\n if (valueA === valueB) {\n return a.__position - b.__position;\n }\n if (valueA == null) {\n return -1;\n }\n if (valueB == null) {\n return 1;\n }\n if (valueA.localeCompare) {\n return valueA.localeCompare(valueB);\n }\n return valueA > valueB ? 1 : -1;\n };\n },\n desc: function (field) {\n var selector = this.selector(field);\n return function (a, b) {\n var valueA = selector(a);\n var valueB = selector(b);\n if (valueA && valueA.getTime && valueB && valueB.getTime) {\n valueA = valueA.getTime();\n valueB = valueB.getTime();\n }\n if (valueA === valueB) {\n return a.__position - b.__position;\n }\n if (valueA == null) {\n return 1;\n }\n if (valueB == null) {\n return -1;\n }\n if (valueB.localeCompare) {\n return valueB.localeCompare(valueA);\n }\n return valueA < valueB ? 1 : -1;\n };\n },\n create: function (sort) {\n return this[sort.dir](sort.field);\n }\n });\n map = function (array, callback) {\n var idx, length = array.length, result = new Array(length);\n for (idx = 0; idx < length; idx++) {\n result[idx] = callback(array[idx], idx, array);\n }\n return result;\n };\n var operators = function () {\n function quote(str) {\n if (typeof str == 'string') {\n str = str.replace(/[\\r\\n]+/g, '');\n }\n return JSON.stringify(str);\n }\n function textOp(impl) {\n return function (a, b, ignore, accentFoldingFiltering) {\n b += '';\n if (ignore) {\n a = '(' + a + ' + \\'\\').toString()' + (accentFoldingFiltering ? '.toLocaleLowerCase(\\'' + accentFoldingFiltering + '\\')' : '.toLowerCase()');\n b = accentFoldingFiltering ? b.toLocaleLowerCase(accentFoldingFiltering) : b.toLowerCase();\n }\n return impl(a, quote(b), ignore);\n };\n }\n function operator(op, a, b, ignore, accentFoldingFiltering) {\n if (b != null) {\n if (typeof b === STRING) {\n var date = dateRegExp.exec(b);\n if (date) {\n b = new Date(+date[1]);\n } else if (ignore) {\n b = quote(accentFoldingFiltering ? b.toLocaleLowerCase(accentFoldingFiltering) : b.toLowerCase());\n a = '((' + a + ' || \\'\\')+\\'\\')' + (accentFoldingFiltering ? '.toLocaleLowerCase(\\'' + accentFoldingFiltering + '\\')' : '.toLowerCase()');\n } else {\n b = quote(b);\n }\n }\n if (b.getTime) {\n a = '(' + a + '&&' + a + '.getTime?' + a + '.getTime():' + a + ')';\n b = b.getTime();\n }\n }\n return a + ' ' + op + ' ' + b;\n }\n function getMatchRegexp(pattern) {\n for (var rx = '/^', esc = false, i = 0; i < pattern.length; ++i) {\n var ch = pattern.charAt(i);\n if (esc) {\n rx += '\\\\' + ch;\n } else if (ch == '~') {\n esc = true;\n continue;\n } else if (ch == '*') {\n rx += '.*';\n } else if (ch == '?') {\n rx += '.';\n } else if ('.+^$()[]{}|\\\\/\\n\\r\\u2028\\u2029\\xA0'.indexOf(ch) >= 0) {\n rx += '\\\\' + ch;\n } else {\n rx += ch;\n }\n esc = false;\n }\n return rx + '$/';\n }\n return {\n quote: function (value) {\n if (value && value.getTime) {\n return 'new Date(' + value.getTime() + ')';\n }\n return quote(value);\n },\n eq: function (a, b, ignore, accentFoldingFiltering) {\n return operator('==', a, b, ignore, accentFoldingFiltering);\n },\n neq: function (a, b, ignore, accentFoldingFiltering) {\n return operator('!=', a, b, ignore, accentFoldingFiltering);\n },\n gt: function (a, b, ignore) {\n return operator('>', a, b, ignore);\n },\n gte: function (a, b, ignore) {\n return operator('>=', a, b, ignore);\n },\n lt: function (a, b, ignore) {\n return operator('<', a, b, ignore);\n },\n lte: function (a, b, ignore) {\n return operator('<=', a, b, ignore);\n },\n startswith: textOp(function (a, b) {\n return a + '.lastIndexOf(' + b + ', 0) == 0';\n }),\n doesnotstartwith: textOp(function (a, b) {\n return a + '.lastIndexOf(' + b + ', 0) == -1';\n }),\n endswith: textOp(function (a, b) {\n var n = b ? b.length - 2 : 0;\n return a + '.indexOf(' + b + ', ' + a + '.length - ' + n + ') >= 0';\n }),\n doesnotendwith: textOp(function (a, b) {\n var n = b ? b.length - 2 : 0;\n return a + '.indexOf(' + b + ', ' + a + '.length - ' + n + ') < 0';\n }),\n contains: textOp(function (a, b) {\n return a + '.indexOf(' + b + ') >= 0';\n }),\n doesnotcontain: textOp(function (a, b) {\n return a + '.indexOf(' + b + ') == -1';\n }),\n matches: textOp(function (a, b) {\n b = b.substring(1, b.length - 1);\n return getMatchRegexp(b) + '.test(' + a + ')';\n }),\n doesnotmatch: textOp(function (a, b) {\n b = b.substring(1, b.length - 1);\n return '!' + getMatchRegexp(b) + '.test(' + a + ')';\n }),\n isempty: function (a) {\n return a + ' === \\'\\'';\n },\n isnotempty: function (a) {\n return a + ' !== \\'\\'';\n },\n isnull: function (a) {\n return '(' + a + ' == null)';\n },\n isnotnull: function (a) {\n return '(' + a + ' != null)';\n },\n isnullorempty: function (a) {\n return '(' + a + ' === null) || (' + a + ' === \\'\\')';\n },\n isnotnullorempty: function (a) {\n return '(' + a + ' !== null) && (' + a + ' !== \\'\\')';\n }\n };\n }();\n function Query(data) {\n this.data = data || [];\n }\n Query.filterExpr = function (expression) {\n var expressions = [], logic = {\n and: ' && ',\n or: ' || '\n }, idx, length, filter, expr, fieldFunctions = [], operatorFunctions = [], field, operator, filters = expression.filters;\n for (idx = 0, length = filters.length; idx < length; idx++) {\n filter = filters[idx];\n field = filter.field;\n operator = filter.operator;\n if (filter.filters) {\n expr = Query.filterExpr(filter);\n filter = expr.expression.replace(/__o\\[(\\d+)\\]/g, function (match, index) {\n index = +index;\n return '__o[' + (operatorFunctions.length + index) + ']';\n }).replace(/__f\\[(\\d+)\\]/g, function (match, index) {\n index = +index;\n return '__f[' + (fieldFunctions.length + index) + ']';\n });\n operatorFunctions.push.apply(operatorFunctions, expr.operators);\n fieldFunctions.push.apply(fieldFunctions, expr.fields);\n } else {\n if (typeof field === FUNCTION) {\n expr = '__f[' + fieldFunctions.length + '](d)';\n fieldFunctions.push(field);\n } else {\n expr = kendo.expr(field);\n }\n if (typeof operator === FUNCTION) {\n filter = '__o[' + operatorFunctions.length + '](' + expr + ', ' + operators.quote(filter.value) + ')';\n operatorFunctions.push(operator);\n } else {\n filter = operators[(operator || 'eq').toLowerCase()](expr, filter.value, filter.ignoreCase !== undefined ? filter.ignoreCase : true, expression.accentFoldingFiltering);\n }\n }\n expressions.push(filter);\n }\n return {\n expression: '(' + expressions.join(logic[expression.logic]) + ')',\n fields: fieldFunctions,\n operators: operatorFunctions\n };\n };\n function normalizeSort(field, dir) {\n if (field) {\n var descriptor = typeof field === STRING ? {\n field: field,\n dir: dir\n } : field, descriptors = isArray(descriptor) ? descriptor : descriptor !== undefined ? [descriptor] : [];\n return grep(descriptors, function (d) {\n return !!d.dir;\n });\n }\n }\n function sortFields(sorts, dir) {\n var sortObject = {};\n if (sorts) {\n var descriptor = typeof sorts === STRING ? {\n field: sorts,\n dir: dir\n } : sorts, descriptors = isArray(descriptor) ? descriptor : descriptor !== undefined ? [descriptor] : [];\n for (var i = 0; i < descriptors.length; i++) {\n sortObject[descriptors[i].field] = {\n dir: descriptors[i].dir,\n index: i + 1\n };\n }\n }\n return sortObject;\n }\n var operatorMap = {\n '==': 'eq',\n equals: 'eq',\n isequalto: 'eq',\n equalto: 'eq',\n equal: 'eq',\n '!=': 'neq',\n ne: 'neq',\n notequals: 'neq',\n isnotequalto: 'neq',\n notequalto: 'neq',\n notequal: 'neq',\n '<': 'lt',\n islessthan: 'lt',\n lessthan: 'lt',\n less: 'lt',\n '<=': 'lte',\n le: 'lte',\n islessthanorequalto: 'lte',\n lessthanequal: 'lte',\n '>': 'gt',\n isgreaterthan: 'gt',\n greaterthan: 'gt',\n greater: 'gt',\n '>=': 'gte',\n isgreaterthanorequalto: 'gte',\n greaterthanequal: 'gte',\n ge: 'gte',\n notsubstringof: 'doesnotcontain',\n isnull: 'isnull',\n isempty: 'isempty',\n isnotempty: 'isnotempty'\n };\n function normalizeOperator(expression) {\n var idx, length, filter, operator, filters = expression.filters;\n if (filters) {\n for (idx = 0, length = filters.length; idx < length; idx++) {\n filter = filters[idx];\n operator = filter.operator;\n if (operator && typeof operator === STRING) {\n filter.operator = operatorMap[operator.toLowerCase()] || operator;\n }\n normalizeOperator(filter);\n }\n }\n }\n function normalizeFilter(expression) {\n if (expression && !isEmptyObject(expression)) {\n if (isArray(expression) || !expression.filters) {\n expression = {\n logic: 'and',\n filters: isArray(expression) ? expression : [expression]\n };\n }\n normalizeOperator(expression);\n return expression;\n }\n }\n Query.normalizeFilter = normalizeFilter;\n function compareDescriptor(f1, f2) {\n if (f1.logic || f2.logic) {\n return false;\n }\n return f1.field === f2.field && f1.value === f2.value && f1.operator === f2.operator;\n }\n function normalizeDescriptor(filter) {\n filter = filter || {};\n if (isEmptyObject(filter)) {\n return {\n logic: 'and',\n filters: []\n };\n }\n return normalizeFilter(filter);\n }\n function fieldComparer(a, b) {\n if (b.logic || a.field > b.field) {\n return 1;\n } else if (a.field < b.field) {\n return -1;\n } else {\n return 0;\n }\n }\n function compareFilters(expr1, expr2) {\n expr1 = normalizeDescriptor(expr1);\n expr2 = normalizeDescriptor(expr2);\n if (expr1.logic !== expr2.logic) {\n return false;\n }\n var f1, f2;\n var filters1 = (expr1.filters || []).slice();\n var filters2 = (expr2.filters || []).slice();\n if (filters1.length !== filters2.length) {\n return false;\n }\n filters1 = filters1.sort(fieldComparer);\n filters2 = filters2.sort(fieldComparer);\n for (var idx = 0; idx < filters1.length; idx++) {\n f1 = filters1[idx];\n f2 = filters2[idx];\n if (f1.logic && f2.logic) {\n if (!compareFilters(f1, f2)) {\n return false;\n }\n } else if (!compareDescriptor(f1, f2)) {\n return false;\n }\n }\n return true;\n }\n Query.compareFilters = compareFilters;\n function normalizeAggregate(expressions) {\n return isArray(expressions) ? expressions : [expressions];\n }\n function normalizeGroup(field, dir, compare, skipItemSorting) {\n var descriptor = typeof field === STRING ? {\n field: field,\n dir: dir,\n compare: compare,\n skipItemSorting: skipItemSorting\n } : field, descriptors = isArray(descriptor) ? descriptor : descriptor !== undefined ? [descriptor] : [];\n return map(descriptors, function (d) {\n return {\n field: d.field,\n dir: d.dir || 'asc',\n aggregates: d.aggregates,\n compare: d.compare,\n skipItemSorting: d.skipItemSorting\n };\n });\n }\n function normalizeGroupWithoutCompare(field, dir, compare) {\n var descriptors = normalizeGroup(field, dir, compare);\n for (var i = 0; i < descriptors.length; i++) {\n delete descriptors[i].compare;\n }\n return descriptors;\n }\n function anyGroupDescriptorHasCompare(groupDescriptors) {\n var descriptors = isArray(groupDescriptors) ? groupDescriptors : [groupDescriptors];\n for (var i = 0; i < descriptors.length; i++) {\n if (descriptors[i] && isFunction(descriptors[i].compare)) {\n return true;\n }\n }\n return false;\n }\n Query.prototype = {\n toArray: function () {\n return this.data;\n },\n range: function (index, count) {\n return new Query(this.data.slice(index, index + count));\n },\n skip: function (count) {\n return new Query(this.data.slice(count));\n },\n take: function (count) {\n return new Query(this.data.slice(0, count));\n },\n select: function (selector) {\n return new Query(map(this.data, selector));\n },\n order: function (selector, dir, inPlace) {\n var sort = { dir: dir };\n if (selector) {\n if (selector.compare) {\n sort.compare = selector.compare;\n } else {\n sort.field = selector;\n }\n }\n if (inPlace) {\n return new Query(this.data.sort(Comparer.create(sort)));\n }\n return new Query(this.data.slice(0).sort(Comparer.create(sort)));\n },\n orderBy: function (selector, inPlace) {\n return this.order(selector, 'asc', inPlace);\n },\n orderByDescending: function (selector, inPlace) {\n return this.order(selector, 'desc', inPlace);\n },\n sort: function (field, dir, comparer, inPlace) {\n var idx, length, descriptors = normalizeSort(field, dir), comparers = [];\n comparer = comparer || Comparer;\n if (descriptors.length) {\n for (idx = 0, length = descriptors.length; idx < length; idx++) {\n comparers.push(comparer.create(descriptors[idx]));\n }\n return this.orderBy({ compare: comparer.combine(comparers) }, inPlace);\n }\n return this;\n },\n filter: function (expressions) {\n var idx, current, length, compiled, predicate, data = this.data, fields, operators, result = [], filter;\n expressions = normalizeFilter(expressions);\n if (!expressions || expressions.filters.length === 0) {\n return this;\n }\n compiled = Query.filterExpr(expressions);\n fields = compiled.fields;\n operators = compiled.operators;\n predicate = filter = new Function('d, __f, __o', 'return ' + compiled.expression);\n if (fields.length || operators.length) {\n filter = function (d) {\n return predicate(d, fields, operators);\n };\n }\n for (idx = 0, length = data.length; idx < length; idx++) {\n current = data[idx];\n if (filter(current)) {\n result.push(current);\n }\n }\n return new Query(result);\n },\n group: function (descriptors, allData, options) {\n descriptors = normalizeGroup(descriptors || []);\n allData = allData || this.data;\n var that = this, result = new Query(that.data), descriptor;\n if (descriptors.length > 0) {\n descriptor = descriptors[0];\n if (options && options.groupPaging) {\n result = new Query(allData).groupAllData(descriptor, allData).select(function (group) {\n var data = new Query(allData).filter([{\n field: group.field,\n operator: 'eq',\n value: group.value,\n ignoreCase: false\n }]);\n var items = descriptors.length > 1 ? new Query(group.items).group(descriptors.slice(1), data.toArray(), options).toArray() : group.items;\n return {\n field: group.field,\n value: group.value,\n hasSubgroups: descriptors.length > 1,\n items: items,\n aggregates: data.aggregate(descriptor.aggregates),\n uid: kendo.guid(),\n itemCount: items.length,\n subgroupCount: items.length\n };\n });\n } else {\n result = result.groupBy(descriptor).select(function (group) {\n var data = new Query(allData).filter([{\n field: group.field,\n operator: 'eq',\n value: group.value,\n ignoreCase: false\n }]);\n return {\n field: group.field,\n value: group.value,\n items: descriptors.length > 1 ? new Query(group.items).group(descriptors.slice(1), data.toArray()).toArray() : group.items,\n hasSubgroups: descriptors.length > 1,\n aggregates: data.aggregate(descriptor.aggregates)\n };\n });\n }\n }\n return result;\n },\n groupBy: function (descriptor) {\n var that = this;\n if (isEmptyObject(descriptor) || !this.data.length) {\n return new Query([]);\n }\n var field = descriptor.field, sorted = descriptor.skipItemSorting ? this.data : this._sortForGrouping(field, descriptor.dir || 'asc'), accessor = kendo.accessor(field), item, groupValue = accessor.get(sorted[0], field), group = {\n field: field,\n value: groupValue,\n items: []\n }, currentValue, idx, len, result = [group];\n for (idx = 0, len = sorted.length; idx < len; idx++) {\n item = sorted[idx];\n currentValue = accessor.get(item, field);\n if (!groupValueComparer(groupValue, currentValue)) {\n groupValue = currentValue;\n group = {\n field: field,\n value: groupValue,\n items: []\n };\n result.push(group);\n }\n group.items.push(item);\n }\n result = that._sortGroups(result, descriptor);\n return new Query(result);\n },\n groupAllData: function (descriptor, allData) {\n if (isEmptyObject(descriptor) || this.data && !this.data.length) {\n return new Query([]);\n }\n var field = descriptor.field, sorted = descriptor.skipItemSorting ? allData : new Query(allData).sort(field, descriptor.dir || 'asc', StableComparer).toArray(), accessor = kendo.accessor(field), item, groupValue = accessor.get(sorted[0], field), group = {\n field: field,\n value: groupValue,\n items: []\n }, currentValue, idx, len, result = [group];\n for (idx = 0, len = sorted.length; idx < len; idx++) {\n item = sorted[idx];\n currentValue = accessor.get(item, field);\n if (!groupValueComparer(groupValue, currentValue)) {\n groupValue = currentValue;\n group = {\n field: field,\n value: groupValue,\n items: []\n };\n result.push(group);\n }\n group.items.push(item);\n }\n result = this._sortGroups(result, descriptor);\n return new Query(result);\n },\n _sortForGrouping: function (field, dir) {\n var idx, length, data = this.data;\n if (!stableSort) {\n for (idx = 0, length = data.length; idx < length; idx++) {\n data[idx].__position = idx;\n }\n data = new Query(data).sort(field, dir, StableComparer).toArray();\n for (idx = 0, length = data.length; idx < length; idx++) {\n delete data[idx].__position;\n }\n return data;\n }\n return this.sort(field, dir).toArray();\n },\n _sortGroups: function (groups, descriptor) {\n var result = groups;\n if (descriptor && isFunction(descriptor.compare)) {\n result = new Query(result).order({ compare: descriptor.compare }, descriptor.dir || ASCENDING).toArray();\n }\n return result;\n },\n aggregate: function (aggregates) {\n var idx, len, result = {}, state = {};\n if (aggregates && aggregates.length) {\n for (idx = 0, len = this.data.length; idx < len; idx++) {\n calculateAggregate(result, aggregates, this.data[idx], idx, len, state);\n }\n }\n return result;\n }\n };\n function groupValueComparer(a, b) {\n if (a && a.getTime && b && b.getTime) {\n return a.getTime() === b.getTime();\n }\n return a === b;\n }\n function calculateAggregate(accumulator, aggregates, item, index, length, state) {\n aggregates = aggregates || [];\n var idx, aggr, functionName, len = aggregates.length;\n for (idx = 0; idx < len; idx++) {\n aggr = aggregates[idx];\n functionName = aggr.aggregate;\n var field = aggr.field;\n accumulator[field] = accumulator[field] || {};\n state[field] = state[field] || {};\n state[field][functionName] = state[field][functionName] || {};\n accumulator[field][functionName] = functions[functionName.toLowerCase()](accumulator[field][functionName], item, kendo.accessor(field), index, length, state[field][functionName]);\n }\n }\n var functions = {\n sum: function (accumulator, item, accessor) {\n var value = accessor.get(item);\n if (!isNumber(accumulator)) {\n accumulator = value;\n } else if (isNumber(value)) {\n accumulator += value;\n }\n return accumulator;\n },\n count: function (accumulator) {\n return (accumulator || 0) + 1;\n },\n average: function (accumulator, item, accessor, index, length, state) {\n var value = accessor.get(item);\n if (state.count === undefined) {\n state.count = 0;\n }\n if (!isNumber(accumulator)) {\n accumulator = value;\n } else if (isNumber(value)) {\n accumulator += value;\n }\n if (isNumber(value)) {\n state.count++;\n }\n if (index == length - 1 && isNumber(accumulator)) {\n accumulator = accumulator / state.count;\n }\n return accumulator;\n },\n max: function (accumulator, item, accessor) {\n var value = accessor.get(item);\n if (!isNumber(accumulator) && !isDate(accumulator)) {\n accumulator = value;\n }\n if (accumulator < value && (isNumber(value) || isDate(value))) {\n accumulator = value;\n }\n return accumulator;\n },\n min: function (accumulator, item, accessor) {\n var value = accessor.get(item);\n if (!isNumber(accumulator) && !isDate(accumulator)) {\n accumulator = value;\n }\n if (accumulator > value && (isNumber(value) || isDate(value))) {\n accumulator = value;\n }\n return accumulator;\n }\n };\n function isNumber(val) {\n return typeof val === 'number' && !isNaN(val);\n }\n function isDate(val) {\n return val && val.getTime;\n }\n function toJSON(array) {\n var idx, length = array.length, result = new Array(length);\n for (idx = 0; idx < length; idx++) {\n result[idx] = array[idx].toJSON();\n }\n return result;\n }\n Query.normalizeGroup = normalizeGroup;\n Query.normalizeSort = normalizeSort;\n Query.process = function (data, options, inPlace) {\n options = options || {};\n var group = options.group;\n var customGroupSort = anyGroupDescriptorHasCompare(normalizeGroup(group || []));\n var query = new Query(data), groupDescriptorsWithoutCompare = normalizeGroupWithoutCompare(group || []), normalizedSort = normalizeSort(options.sort || []), sort = customGroupSort ? normalizedSort : groupDescriptorsWithoutCompare.concat(normalizedSort), groupDescriptorsWithoutSort, total, filterCallback = options.filterCallback, filter = options.filter, skip = options.skip, take = options.take;\n if (sort && inPlace) {\n query = query.sort(sort, undefined, undefined, inPlace);\n }\n if (filter) {\n query = query.filter(filter);\n if (filterCallback) {\n query = filterCallback(query);\n }\n total = query.toArray().length;\n }\n if (sort) {\n if (!inPlace) {\n query = query.sort(sort);\n }\n if (group) {\n data = query.toArray();\n }\n }\n if (customGroupSort) {\n query = query.group(group, data);\n if (skip !== undefined && take !== undefined) {\n query = new Query(flatGroups(query.toArray())).range(skip, take);\n groupDescriptorsWithoutSort = map(groupDescriptorsWithoutCompare, function (groupDescriptor) {\n return extend({}, groupDescriptor, { skipItemSorting: true });\n });\n query = query.group(groupDescriptorsWithoutSort, data);\n }\n } else {\n if (skip !== undefined && take !== undefined) {\n query = query.range(skip, take);\n }\n if (group) {\n query = query.group(group, data, options);\n }\n }\n return {\n total: total,\n data: query.toArray()\n };\n };\n var LocalTransport = Class.extend({\n init: function (options) {\n this.data = options.data;\n },\n read: function (options) {\n options.success(this.data);\n },\n update: function (options) {\n options.success(options.data);\n },\n create: function (options) {\n options.success(options.data);\n },\n destroy: function (options) {\n options.success(options.data);\n }\n });\n var RemoteTransport = Class.extend({\n init: function (options) {\n var that = this, parameterMap;\n options = that.options = extend({}, that.options, options);\n each(crud, function (index, type) {\n if (typeof options[type] === STRING) {\n options[type] = { url: options[type] };\n }\n });\n that.cache = options.cache ? Cache.create(options.cache) : {\n find: noop,\n add: noop\n };\n parameterMap = options.parameterMap;\n if (options.submit) {\n that.submit = options.submit;\n }\n if (isFunction(options.push)) {\n that.push = options.push;\n }\n if (!that.push) {\n that.push = identity;\n }\n that.parameterMap = isFunction(parameterMap) ? parameterMap : function (options) {\n var result = {};\n each(options, function (option, value) {\n if (option in parameterMap) {\n option = parameterMap[option];\n if (isPlainObject(option)) {\n value = option.value(value);\n option = option.key;\n }\n }\n result[option] = value;\n });\n return result;\n };\n },\n options: { parameterMap: identity },\n create: function (options) {\n return ajax(this.setup(options, CREATE));\n },\n read: function (options) {\n var that = this, success, error, result, cache = that.cache;\n options = that.setup(options, READ);\n success = options.success || noop;\n error = options.error || noop;\n result = cache.find(options.data);\n if (result !== undefined) {\n success(result);\n } else {\n options.success = function (result) {\n cache.add(options.data, result);\n success(result);\n };\n $.ajax(options);\n }\n },\n update: function (options) {\n return ajax(this.setup(options, UPDATE));\n },\n destroy: function (options) {\n return ajax(this.setup(options, DESTROY));\n },\n setup: function (options, type) {\n options = options || {};\n var that = this, parameters, operation = that.options[type], data = isFunction(operation.data) ? operation.data(options.data) : operation.data;\n options = extend(true, {}, operation, options);\n parameters = extend(true, {}, data, options.data);\n options.data = that.parameterMap(parameters, type);\n if (isFunction(options.url)) {\n options.url = options.url(parameters);\n }\n return options;\n }\n });\n var Cache = Class.extend({\n init: function () {\n this._store = {};\n },\n add: function (key, data) {\n if (key !== undefined) {\n this._store[stringify(key)] = data;\n }\n },\n find: function (key) {\n return this._store[stringify(key)];\n },\n clear: function () {\n this._store = {};\n },\n remove: function (key) {\n delete this._store[stringify(key)];\n }\n });\n Cache.create = function (options) {\n var store = {\n 'inmemory': function () {\n return new Cache();\n }\n };\n if (isPlainObject(options) && isFunction(options.find)) {\n return options;\n }\n if (options === true) {\n return new Cache();\n }\n return store[options]();\n };\n function serializeRecords(data, getters, modelInstance, originalFieldNames, fieldNames) {\n var record, getter, originalName, idx, setters = {}, length;\n for (idx = 0, length = data.length; idx < length; idx++) {\n record = data[idx];\n for (getter in getters) {\n originalName = fieldNames[getter];\n if (originalName && originalName !== getter) {\n if (!setters[originalName]) {\n setters[originalName] = kendo.setter(originalName);\n }\n setters[originalName](record, getters[getter](record));\n delete record[getter];\n }\n }\n }\n }\n function convertRecords(data, getters, modelInstance, originalFieldNames, fieldNames) {\n var record, getter, originalName, idx, length;\n for (idx = 0, length = data.length; idx < length; idx++) {\n record = data[idx];\n for (getter in getters) {\n record[getter] = modelInstance._parse(getter, getters[getter](record));\n originalName = fieldNames[getter];\n if (originalName && originalName !== getter) {\n delete record[originalName];\n }\n }\n }\n }\n function convertGroup(data, getters, modelInstance, originalFieldNames, fieldNames) {\n var record, idx, fieldName, length;\n for (idx = 0, length = data.length; idx < length; idx++) {\n record = data[idx];\n fieldName = originalFieldNames[record.field];\n if (fieldName && fieldName != record.field) {\n record.field = fieldName;\n }\n record.value = modelInstance._parse(record.field, record.value);\n if (record.items) {\n if (record.hasSubgroups) {\n convertGroup(record.items, getters, modelInstance, originalFieldNames, fieldNames);\n } else {\n convertRecords(record.items, getters, modelInstance, originalFieldNames, fieldNames);\n }\n }\n }\n }\n function wrapDataAccess(originalFunction, model, converter, getters, originalFieldNames, fieldNames) {\n return function (data) {\n data = originalFunction(data);\n return wrapDataAccessBase(model, converter, getters, originalFieldNames, fieldNames)(data);\n };\n }\n function wrapDataAccessBase(model, converter, getters, originalFieldNames, fieldNames) {\n return function (data) {\n if (data && !isEmptyObject(getters)) {\n if (toString.call(data) !== '[object Array]' && !(data instanceof ObservableArray)) {\n data = [data];\n }\n converter(data, getters, new model(), originalFieldNames, fieldNames);\n }\n return data || [];\n };\n }\n var DataReader = Class.extend({\n init: function (schema) {\n var that = this, member, get, model, base;\n schema = schema || {};\n for (member in schema) {\n get = schema[member];\n that[member] = typeof get === STRING ? getter(get) : get;\n }\n base = schema.modelBase || Model;\n if (isPlainObject(that.model)) {\n that.model = model = base.define(that.model);\n }\n var dataFunction = proxy(that.data, that);\n that._dataAccessFunction = dataFunction;\n if (that.model) {\n var groupsFunction = proxy(that.groups, that), serializeFunction = proxy(that.serialize, that), originalFieldNames = {}, getters = {}, serializeGetters = {}, fieldNames = {}, shouldSerialize = false, fieldName, name;\n model = that.model;\n if (model.fields) {\n each(model.fields, function (field, value) {\n var fromName;\n fieldName = field;\n if (isPlainObject(value) && value.field) {\n fieldName = value.field;\n } else if (typeof value === STRING) {\n fieldName = value;\n }\n if (isPlainObject(value) && value.from) {\n fromName = value.from;\n }\n shouldSerialize = shouldSerialize || fromName && fromName !== field || fieldName !== field;\n name = fromName || fieldName;\n getters[field] = name.indexOf('.') !== -1 ? getter(name, true) : getter(name);\n serializeGetters[field] = getter(field);\n originalFieldNames[fromName || fieldName] = field;\n fieldNames[field] = fromName || fieldName;\n });\n if (!schema.serialize && shouldSerialize) {\n that.serialize = wrapDataAccess(serializeFunction, model, serializeRecords, serializeGetters, originalFieldNames, fieldNames);\n }\n }\n that._dataAccessFunction = dataFunction;\n that._wrapDataAccessBase = wrapDataAccessBase(model, convertRecords, getters, originalFieldNames, fieldNames);\n that.data = wrapDataAccess(dataFunction, model, convertRecords, getters, originalFieldNames, fieldNames);\n that.groups = wrapDataAccess(groupsFunction, model, convertGroup, getters, originalFieldNames, fieldNames);\n }\n },\n errors: function (data) {\n return data ? data.errors : null;\n },\n parse: identity,\n data: identity,\n total: function (data) {\n return data.length;\n },\n groups: identity,\n aggregates: function () {\n return {};\n },\n serialize: function (data) {\n return data;\n }\n });\n function fillLastGroup(originalGroup, newGroup) {\n var currOriginal;\n var currentNew;\n if (newGroup.items && newGroup.items.length) {\n for (var i = 0; i < newGroup.items.length; i++) {\n currOriginal = originalGroup.items[i];\n currentNew = newGroup.items[i];\n if (currOriginal && currentNew) {\n if (currOriginal.hasSubgroups) {\n fillLastGroup(currOriginal, currentNew);\n } else if (currOriginal.field && currOriginal.value == currentNew.value) {\n currOriginal.items.push.apply(currOriginal.items, currentNew.items);\n } else {\n originalGroup.items.push.apply(originalGroup.items, [currentNew]);\n }\n } else if (currentNew) {\n originalGroup.items.push.apply(originalGroup.items, [currentNew]);\n }\n }\n }\n }\n function mergeGroups(target, dest, skip, take) {\n var group, idx = 0, items;\n while (dest.length && take) {\n group = dest[idx];\n items = group.items;\n var length = items.length;\n if (target && target.field === group.field && target.value === group.value) {\n if (target.hasSubgroups && target.items.length) {\n mergeGroups(target.items[target.items.length - 1], group.items, skip, take);\n } else {\n items = items.slice(skip, skip + take);\n target.items = target.items.concat(items);\n }\n dest.splice(idx--, 1);\n } else if (group.hasSubgroups && items.length) {\n mergeGroups(group, items, skip, take);\n if (!group.items.length) {\n dest.splice(idx--, 1);\n }\n } else {\n items = items.slice(skip, skip + take);\n group.items = items;\n if (!group.items.length) {\n dest.splice(idx--, 1);\n }\n }\n if (items.length === 0) {\n skip -= length;\n } else {\n skip = 0;\n take -= items.length;\n }\n if (++idx >= dest.length) {\n break;\n }\n }\n if (idx < dest.length) {\n dest.splice(idx, dest.length - idx);\n }\n }\n function flatGroups(groups, indexFunction) {\n var result = [];\n var groupsLength = (groups || []).length;\n var group;\n var items;\n var indexFn = isFunction(indexFunction) ? indexFunction : function (array, index) {\n return array[index];\n };\n for (var groupIndex = 0; groupIndex < groupsLength; groupIndex++) {\n group = indexFn(groups, groupIndex);\n if (group.hasSubgroups) {\n result = result.concat(flatGroups(group.items));\n } else {\n items = group.items;\n for (var itemIndex = 0; itemIndex < items.length; itemIndex++) {\n result.push(indexFn(items, itemIndex));\n }\n }\n }\n return result;\n }\n function flattenGroups(data) {\n var idx, result = [], length, items, itemIndex;\n for (idx = 0, length = data.length; idx < length; idx++) {\n var group = data.at(idx);\n if (group.items) {\n if (group.hasSubgroups) {\n result = result.concat(flattenGroups(group.items));\n } else {\n items = group.items;\n for (itemIndex = 0; itemIndex < items.length; itemIndex++) {\n result.push(items.at(itemIndex));\n }\n }\n }\n }\n return result;\n }\n function wrapGroupItems(data, model) {\n var idx, length, group;\n if (model) {\n for (idx = 0, length = data.length; idx < length; idx++) {\n group = data.at(idx);\n if (group.items) {\n if (group.hasSubgroups) {\n wrapGroupItems(group.items, model);\n } else {\n group.items = new LazyObservableArray(group.items, model, group.items._events);\n }\n }\n }\n }\n }\n function eachGroupItems(data, func) {\n for (var idx = 0; idx < data.length; idx++) {\n if (data[idx].hasSubgroups) {\n if (eachGroupItems(data[idx].items, func)) {\n return true;\n }\n } else if (func(data[idx].items, data[idx])) {\n return true;\n }\n }\n }\n function replaceInRanges(ranges, data, item, observable) {\n for (var idx = 0; idx < ranges.length; idx++) {\n if (ranges[idx].data === data) {\n break;\n }\n if (replaceInRange(ranges[idx].data, item, observable)) {\n break;\n }\n }\n }\n function replaceInRange(items, item, observable) {\n for (var idx = 0, length = items.length; idx < length; idx++) {\n if (items[idx] && items[idx].hasSubgroups) {\n return replaceInRange(items[idx].items, item, observable);\n } else if (items[idx] === item || items[idx] === observable) {\n items[idx] = observable;\n return true;\n }\n }\n }\n function replaceWithObservable(view, data, ranges, type, serverGrouping) {\n for (var viewIndex = 0, length = view.length; viewIndex < length; viewIndex++) {\n var item = view[viewIndex];\n if (!item || item instanceof type) {\n continue;\n }\n if (item.hasSubgroups !== undefined && !serverGrouping) {\n replaceWithObservable(item.items, data, ranges, type, serverGrouping);\n } else {\n for (var idx = 0; idx < data.length; idx++) {\n if (data[idx] === item) {\n view[viewIndex] = data.at(idx);\n replaceInRanges(ranges, data, item, view[viewIndex]);\n break;\n }\n }\n }\n }\n }\n function removeModel(data, model) {\n if (!data) {\n return;\n }\n var length = data.length;\n var dataItem;\n var idx;\n for (idx = 0; idx < length; idx++) {\n dataItem = data[idx];\n if (dataItem.uid && dataItem.uid == model.uid) {\n data.splice(idx, 1);\n return dataItem;\n }\n }\n }\n function indexOfPristineModel(data, model) {\n if (model) {\n return indexOf(data, function (item) {\n return item.uid && item.uid == model.uid || item[model.idField] === model.id && model.id !== model._defaultId;\n });\n }\n return -1;\n }\n function indexOfModel(data, model) {\n if (model) {\n return indexOf(data, function (item) {\n return item.uid == model.uid;\n });\n }\n return -1;\n }\n function indexOf(data, comparer) {\n var idx, length;\n if (!data) {\n return;\n }\n for (idx = 0, length = data.length; idx < length; idx++) {\n if (comparer(data[idx])) {\n return idx;\n }\n }\n return -1;\n }\n function fieldNameFromModel(fields, name) {\n if (fields && !isEmptyObject(fields)) {\n var descriptor = fields[name];\n var fieldName;\n if (isPlainObject(descriptor)) {\n fieldName = descriptor.from || descriptor.field || name;\n } else {\n fieldName = fields[name] || name;\n }\n if (isFunction(fieldName)) {\n return name;\n }\n return fieldName;\n }\n return name;\n }\n function convertFilterDescriptorsField(descriptor, model) {\n var idx, length, target = {};\n for (var field in descriptor) {\n if (field !== 'filters') {\n target[field] = descriptor[field];\n }\n }\n if (descriptor.filters) {\n target.filters = [];\n for (idx = 0, length = descriptor.filters.length; idx < length; idx++) {\n target.filters[idx] = convertFilterDescriptorsField(descriptor.filters[idx], model);\n }\n } else {\n target.field = fieldNameFromModel(model.fields, target.field);\n }\n return target;\n }\n function convertDescriptorsField(descriptors, model) {\n var idx, length, result = [], target, descriptor;\n for (idx = 0, length = descriptors.length; idx < length; idx++) {\n target = {};\n descriptor = descriptors[idx];\n for (var field in descriptor) {\n target[field] = descriptor[field];\n }\n target.field = fieldNameFromModel(model.fields, target.field);\n if (target.aggregates && isArray(target.aggregates)) {\n target.aggregates = convertDescriptorsField(target.aggregates, model);\n }\n result.push(target);\n }\n return result;\n }\n var DataSource = Observable.extend({\n init: function (options) {\n var that = this, model, data;\n if (options) {\n data = options.data;\n }\n options = that.options = extend({}, that.options, options);\n that._map = {};\n that._prefetch = {};\n that._data = [];\n that._pristineData = [];\n that._ranges = [];\n that._view = [];\n that._pristineTotal = 0;\n that._destroyed = [];\n that._pageSize = options.pageSize;\n that._page = options.page || (options.pageSize ? 1 : undefined);\n that._sort = normalizeSort(options.sort);\n that._sortFields = sortFields(options.sort);\n that._filter = normalizeFilter(options.filter);\n that._group = normalizeGroup(options.group);\n that._aggregate = options.aggregate;\n that._total = options.total;\n that._groupPaging = options.groupPaging;\n if (that._groupPaging) {\n that._groupsState = {};\n }\n that._shouldDetachObservableParents = true;\n Observable.fn.init.call(that);\n that.transport = Transport.create(options, data, that);\n if (isFunction(that.transport.push)) {\n that.transport.push({\n pushCreate: proxy(that._pushCreate, that),\n pushUpdate: proxy(that._pushUpdate, that),\n pushDestroy: proxy(that._pushDestroy, that)\n });\n }\n if (options.offlineStorage != null) {\n if (typeof options.offlineStorage == 'string') {\n var key = options.offlineStorage;\n that._storage = {\n getItem: function () {\n return JSON.parse(localStorage.getItem(key));\n },\n setItem: function (item) {\n localStorage.setItem(key, stringify(that.reader.serialize(item)));\n }\n };\n } else {\n that._storage = options.offlineStorage;\n }\n }\n that.reader = new kendo.data.readers[options.schema.type || 'json'](options.schema);\n model = that.reader.model || {};\n that._detachObservableParents();\n that._data = that._observe(that._data);\n that._online = true;\n that.bind([\n 'push',\n ERROR,\n CHANGE,\n REQUESTSTART,\n SYNC,\n REQUESTEND,\n PROGRESS\n ], options);\n },\n options: {\n data: null,\n schema: { modelBase: Model },\n offlineStorage: null,\n serverSorting: false,\n serverPaging: false,\n serverFiltering: false,\n serverGrouping: false,\n serverAggregates: false,\n batch: false,\n inPlaceSort: false\n },\n clone: function () {\n return this;\n },\n online: function (value) {\n if (value !== undefined) {\n if (this._online != value) {\n this._online = value;\n if (value) {\n return this.sync();\n }\n }\n return $.Deferred().resolve().promise();\n } else {\n return this._online;\n }\n },\n offlineData: function (state) {\n if (this.options.offlineStorage == null) {\n return null;\n }\n if (state !== undefined) {\n return this._storage.setItem(state);\n }\n return this._storage.getItem() || [];\n },\n _isServerGrouped: function () {\n var group = this.group() || [];\n return this.options.serverGrouping && group.length;\n },\n _isServerGroupPaged: function () {\n return this._isServerGrouped() && this._groupPaging;\n },\n _isGroupPaged: function () {\n var group = this._group || [];\n return this._groupPaging && group.length;\n },\n _pushCreate: function (result) {\n this._push(result, 'pushCreate');\n },\n _pushUpdate: function (result) {\n this._push(result, 'pushUpdate');\n },\n _pushDestroy: function (result) {\n this._push(result, 'pushDestroy');\n },\n _push: function (result, operation) {\n var data = this._readData(result);\n if (!data) {\n data = result;\n }\n this[operation](data);\n },\n _flatData: function (data, skip) {\n if (data) {\n if (this._isServerGrouped()) {\n return flattenGroups(data);\n }\n if (!skip) {\n for (var idx = 0; idx < data.length; idx++) {\n data.at(idx);\n }\n }\n }\n return data;\n },\n parent: noop,\n get: function (id) {\n var idx, length, data = this._flatData(this._data, this.options.useRanges);\n for (idx = 0, length = data.length; idx < length; idx++) {\n if (data[idx].id == id) {\n return data[idx];\n }\n }\n },\n getByUid: function (id) {\n return this._getByUid(id, this._data);\n },\n _getByUid: function (id, dataItems) {\n var idx, length, data = this._flatData(dataItems, this.options.useRanges);\n if (!data) {\n return;\n }\n for (idx = 0, length = data.length; idx < length; idx++) {\n if (data[idx].uid == id) {\n return data[idx];\n }\n }\n },\n indexOf: function (model) {\n return indexOfModel(this._data, model);\n },\n at: function (index) {\n return this._data.at(index);\n },\n data: function (value) {\n var that = this;\n if (value !== undefined) {\n that._detachObservableParents();\n that._data = this._observe(value);\n that._pristineData = value.slice(0);\n that._storeData();\n that._ranges = [];\n that.trigger('reset');\n that._addRange(that._data);\n that._total = that._data.length;\n that._pristineTotal = that._total;\n that._process(that._data);\n } else {\n if (that._data) {\n for (var idx = 0; idx < that._data.length; idx++) {\n that._data.at(idx);\n }\n }\n return that._data;\n }\n },\n view: function (value) {\n if (value === undefined) {\n return this._view;\n } else {\n this._view = this._observeView(value);\n }\n },\n _observeView: function (data) {\n var that = this;\n replaceWithObservable(data, that._data, that._ranges, that.reader.model || ObservableObject, that._isServerGrouped());\n var view = new LazyObservableArray(data, that.reader.model);\n view.parent = function () {\n return that.parent();\n };\n return view;\n },\n flatView: function () {\n var groups = this.group() || [];\n if (groups.length) {\n return flattenGroups(this._view);\n } else {\n return this._view;\n }\n },\n add: function (model) {\n return this.insert(this._data.length, model);\n },\n _createNewModel: function (model) {\n if (this.reader.model) {\n return new this.reader.model(model);\n }\n if (model instanceof ObservableObject) {\n return model;\n }\n return new ObservableObject(model);\n },\n insert: function (index, model) {\n if (!model) {\n model = index;\n index = 0;\n }\n if (!(model instanceof Model)) {\n model = this._createNewModel(model);\n }\n if (this._isServerGrouped()) {\n this._data.splice(index, 0, this._wrapInEmptyGroup(model));\n } else {\n this._data.splice(index, 0, model);\n }\n this._insertModelInRange(index, model);\n return model;\n },\n pushInsert: function (index, items) {\n var that = this;\n var rangeSpan = that._getCurrentRangeSpan();\n if (!items) {\n items = index;\n index = 0;\n }\n if (!isArray(items)) {\n items = [items];\n }\n var pushed = [];\n var autoSync = this.options.autoSync;\n this.options.autoSync = false;\n try {\n for (var idx = 0; idx < items.length; idx++) {\n var item = items[idx];\n var result = this.insert(index, item);\n pushed.push(result);\n var pristine = result.toJSON();\n if (this._isServerGrouped()) {\n pristine = this._wrapInEmptyGroup(pristine);\n }\n this._pristineData.push(pristine);\n if (rangeSpan && rangeSpan.length) {\n $(rangeSpan).last()[0].pristineData.push(pristine);\n }\n index++;\n }\n } finally {\n this.options.autoSync = autoSync;\n }\n if (pushed.length) {\n this.trigger('push', {\n type: 'create',\n items: pushed\n });\n }\n },\n pushCreate: function (items) {\n this.pushInsert(this._data.length, items);\n },\n pushUpdate: function (items) {\n if (!isArray(items)) {\n items = [items];\n }\n var pushed = [];\n for (var idx = 0; idx < items.length; idx++) {\n var item = items[idx];\n var model = this._createNewModel(item);\n var target = this.get(model.id);\n if (target) {\n pushed.push(target);\n target.accept(item);\n target.trigger(CHANGE);\n this._updatePristineForModel(target, item);\n } else {\n this.pushCreate(item);\n }\n }\n if (pushed.length) {\n this.trigger('push', {\n type: 'update',\n items: pushed\n });\n }\n },\n pushDestroy: function (items) {\n var pushed = this._removeItems(items);\n if (pushed.length) {\n this.trigger('push', {\n type: 'destroy',\n items: pushed\n });\n }\n },\n _removeItems: function (items, removePristine) {\n if (!isArray(items)) {\n items = [items];\n }\n var shouldRemovePristine = typeof removePristine !== 'undefined' ? removePristine : true;\n var destroyed = [];\n var autoSync = this.options.autoSync;\n this.options.autoSync = false;\n try {\n for (var idx = 0; idx < items.length; idx++) {\n var item = items[idx];\n var model = this._createNewModel(item);\n var found = false;\n this._eachItem(this._data, function (items) {\n for (var idx = 0; idx < items.length; idx++) {\n var item = items.at(idx);\n if (item.id === model.id) {\n destroyed.push(item);\n items.splice(idx, 1);\n found = true;\n break;\n }\n }\n });\n if (found && shouldRemovePristine) {\n this._removePristineForModel(model);\n this._destroyed.pop();\n }\n }\n } finally {\n this.options.autoSync = autoSync;\n }\n return destroyed;\n },\n remove: function (model) {\n var result, that = this, hasGroups = that._isServerGrouped();\n this._eachItem(that._data, function (items) {\n result = removeModel(items, model);\n if (result && hasGroups) {\n if (!result.isNew || !result.isNew()) {\n that._destroyed.push(result);\n }\n return true;\n }\n });\n this._removeModelFromRanges(model);\n return model;\n },\n destroyed: function () {\n return this._destroyed;\n },\n created: function () {\n var idx, length, result = [], data = this._flatData(this._data, this.options.useRanges);\n for (idx = 0, length = data.length; idx < length; idx++) {\n if (data[idx].isNew && data[idx].isNew()) {\n result.push(data[idx]);\n }\n }\n return result;\n },\n updated: function () {\n var idx, length, result = [], data = this._flatData(this._data, this.options.useRanges);\n for (idx = 0, length = data.length; idx < length; idx++) {\n if (data[idx].isNew && !data[idx].isNew() && data[idx].dirty) {\n result.push(data[idx]);\n }\n }\n return result;\n },\n sync: function () {\n var that = this, created = [], updated = [], destroyed = that._destroyed;\n var promise = $.Deferred().resolve().promise();\n if (that.online()) {\n if (!that.reader.model) {\n return promise;\n }\n created = that.created();\n updated = that.updated();\n var promises = [];\n if (that.options.batch && that.transport.submit) {\n promises = that._sendSubmit(created, updated, destroyed);\n } else {\n promises.push.apply(promises, that._send('create', created));\n promises.push.apply(promises, that._send('update', updated));\n promises.push.apply(promises, that._send('destroy', destroyed));\n }\n promise = $.when.apply(null, promises).then(function () {\n var idx, length;\n for (idx = 0, length = arguments.length; idx < length; idx++) {\n if (arguments[idx]) {\n that._accept(arguments[idx]);\n }\n }\n that._storeData(true);\n that._syncEnd();\n that._change({ action: 'sync' });\n that.trigger(SYNC);\n if (that._isServerGroupPaged()) {\n that.read();\n }\n });\n } else {\n that._storeData(true);\n that._syncEnd();\n that._change({ action: 'sync' });\n }\n return promise;\n },\n _syncEnd: noop,\n cancelChanges: function (model) {\n var that = this;\n if (model instanceof kendo.data.Model) {\n that._cancelModel(model);\n } else {\n that._destroyed = [];\n that._detachObservableParents();\n that._data = that._observe(that._pristineData);\n if (that.options.serverPaging) {\n that._total = that._pristineTotal;\n }\n that._ranges = [];\n that._addRange(that._data, 0);\n that._changesCanceled();\n that._change();\n that._markOfflineUpdatesAsDirty();\n if (that._isServerGrouped()) {\n that.read();\n }\n }\n },\n _changesCanceled: noop,\n _markOfflineUpdatesAsDirty: function () {\n var that = this;\n if (that.options.offlineStorage != null) {\n that._eachItem(that._data, function (items) {\n for (var idx = 0; idx < items.length; idx++) {\n var item = items.at(idx);\n if (item.__state__ == 'update' || item.__state__ == 'create') {\n item.dirty = true;\n }\n }\n });\n }\n },\n hasChanges: function () {\n var idx, length, data = this._flatData(this._data, this.options.useRanges);\n if (this._destroyed.length) {\n return true;\n }\n for (idx = 0, length = data.length; idx < length; idx++) {\n if (data[idx].isNew && data[idx].isNew() || data[idx].dirty) {\n return true;\n }\n }\n return false;\n },\n _accept: function (result) {\n var that = this, models = result.models, response = result.response, idx = 0, serverGroup = that._isServerGrouped(), pristine = that._pristineData, type = result.type, length;\n that.trigger(REQUESTEND, {\n response: response,\n type: type\n });\n if (response && !isEmptyObject(response)) {\n response = that.reader.parse(response);\n if (that._handleCustomErrors(response)) {\n return;\n }\n response = that.reader.data(response);\n if (!isArray(response)) {\n response = [response];\n }\n } else {\n response = $.map(models, function (model) {\n return model.toJSON();\n });\n }\n if (type === 'destroy') {\n that._destroyed = [];\n }\n for (idx = 0, length = models.length; idx < length; idx++) {\n if (type !== 'destroy') {\n models[idx].accept(response[idx]);\n if (type === 'create') {\n pristine.push(serverGroup ? that._wrapInEmptyGroup(models[idx].toJSON()) : response[idx]);\n } else if (type === 'update') {\n that._updatePristineForModel(models[idx], response[idx]);\n }\n } else {\n that._removePristineForModel(models[idx]);\n }\n }\n },\n _updatePristineForModel: function (model, values) {\n this._executeOnPristineForModel(model, function (index, items) {\n kendo.deepExtend(items[index], values);\n });\n },\n _executeOnPristineForModel: function (model, callback) {\n this._eachPristineItem(function (items) {\n var index = indexOfPristineModel(items, model);\n if (index > -1) {\n callback(index, items);\n return true;\n }\n });\n },\n _removePristineForModel: function (model) {\n this._executeOnPristineForModel(model, function (index, items) {\n items.splice(index, 1);\n });\n },\n _readData: function (data) {\n var read = !this._isServerGrouped() ? this.reader.data : this.reader.groups;\n return read.call(this.reader, data);\n },\n _eachPristineItem: function (callback) {\n var that = this;\n var options = that.options;\n var rangeSpan = that._getCurrentRangeSpan();\n that._eachItem(that._pristineData, callback);\n if (options.serverPaging && options.useRanges) {\n each(rangeSpan, function (i, range) {\n that._eachItem(range.pristineData, callback);\n });\n }\n },\n _eachItem: function (data, callback) {\n if (data && data.length) {\n if (this._isServerGrouped()) {\n eachGroupItems(data, callback);\n } else {\n callback(data);\n }\n }\n },\n _pristineForModel: function (model) {\n var pristine, idx, callback = function (items) {\n idx = indexOfPristineModel(items, model);\n if (idx > -1) {\n pristine = items[idx];\n return true;\n }\n };\n this._eachPristineItem(callback);\n return pristine;\n },\n _cancelModel: function (model) {\n var that = this;\n var pristine = this._pristineForModel(model);\n this._eachItem(this._data, function (items) {\n var idx = indexOfModel(items, model);\n if (idx >= 0) {\n if (pristine && (!model.isNew() || pristine.__state__)) {\n items[idx].accept(pristine);\n if (pristine.__state__ == 'update') {\n items[idx].dirty = true;\n }\n } else {\n that._modelCanceled(model);\n items.splice(idx, 1);\n that._removeModelFromRanges(model);\n }\n }\n });\n },\n _modelCanceled: noop,\n _submit: function (promises, data) {\n var that = this;\n that.trigger(REQUESTSTART, { type: 'submit' });\n that.trigger(PROGRESS);\n that.transport.submit(extend({\n success: function (response, type) {\n var promise = $.grep(promises, function (x) {\n return x.type == type;\n })[0];\n if (promise) {\n promise.resolve({\n response: response,\n models: promise.models,\n type: type\n });\n }\n },\n error: function (response, status, error) {\n for (var idx = 0; idx < promises.length; idx++) {\n promises[idx].reject(response);\n }\n that.error(response, status, error);\n }\n }, data));\n },\n _sendSubmit: function (created, updated, destroyed) {\n var that = this, promises = [];\n if (that.options.batch) {\n if (created.length) {\n promises.push($.Deferred(function (deferred) {\n deferred.type = 'create';\n deferred.models = created;\n }));\n }\n if (updated.length) {\n promises.push($.Deferred(function (deferred) {\n deferred.type = 'update';\n deferred.models = updated;\n }));\n }\n if (destroyed.length) {\n promises.push($.Deferred(function (deferred) {\n deferred.type = 'destroy';\n deferred.models = destroyed;\n }));\n }\n that._submit(promises, {\n data: {\n created: that.reader.serialize(toJSON(created)),\n updated: that.reader.serialize(toJSON(updated)),\n destroyed: that.reader.serialize(toJSON(destroyed))\n }\n });\n }\n return promises;\n },\n _promise: function (data, models, type) {\n var that = this;\n return $.Deferred(function (deferred) {\n that.trigger(REQUESTSTART, { type: type });\n that.trigger(PROGRESS);\n that.transport[type].call(that.transport, extend({\n success: function (response) {\n deferred.resolve({\n response: response,\n models: models,\n type: type\n });\n },\n error: function (response, status, error) {\n deferred.reject(response);\n that.error(response, status, error);\n }\n }, data));\n }).promise();\n },\n _send: function (method, data) {\n var that = this, idx, length, promises = [], converted = that.reader.serialize(toJSON(data));\n if (that.options.batch) {\n if (data.length) {\n promises.push(that._promise({ data: { models: converted } }, data, method));\n }\n } else {\n for (idx = 0, length = data.length; idx < length; idx++) {\n promises.push(that._promise({ data: converted[idx] }, [data[idx]], method));\n }\n }\n return promises;\n },\n read: function (data) {\n var that = this, params = that._params(data);\n var deferred = $.Deferred();\n that._queueRequest(params, function () {\n var isPrevented = that.trigger(REQUESTSTART, { type: 'read' });\n if (!isPrevented) {\n that.trigger(PROGRESS);\n that._ranges = [];\n that.trigger('reset');\n if (that.online()) {\n that.transport.read({\n data: params,\n success: function (data) {\n that._ranges = [];\n that.success(data, params);\n deferred.resolve();\n },\n error: function () {\n var args = slice.call(arguments);\n that.error.apply(that, args);\n deferred.reject.apply(deferred, args);\n }\n });\n } else if (that.options.offlineStorage != null) {\n that.success(that.offlineData(), params);\n deferred.resolve();\n }\n } else {\n that._dequeueRequest();\n deferred.resolve(isPrevented);\n }\n });\n return deferred.promise();\n },\n _readAggregates: function (data) {\n return this.reader.aggregates(data);\n },\n success: function (data) {\n var that = this, options = that.options, items, replaceSubset;\n that.trigger(REQUESTEND, {\n response: data,\n type: 'read'\n });\n if (that.online()) {\n data = that.reader.parse(data);\n if (that._handleCustomErrors(data)) {\n that._dequeueRequest();\n return;\n }\n that._total = that.reader.total(data);\n if (that._isServerGroupPaged()) {\n that._serverGroupsTotal = that._total;\n }\n if (that._pageSize > that._total) {\n that._pageSize = that._total;\n if (that.options.pageSize && that.options.pageSize > that._pageSize) {\n that._pageSize = that.options.pageSize;\n }\n }\n if (that._aggregate && options.serverAggregates) {\n that._aggregateResult = that._readAggregates(data);\n }\n data = that._readData(data);\n that._destroyed = [];\n } else {\n data = that._readData(data);\n items = [];\n var itemIds = {};\n var model = that.reader.model;\n var idField = model ? model.idField : 'id';\n var idx;\n for (idx = 0; idx < this._destroyed.length; idx++) {\n var id = this._destroyed[idx][idField];\n itemIds[id] = id;\n }\n for (idx = 0; idx < data.length; idx++) {\n var item = data[idx];\n var state = item.__state__;\n if (state == 'destroy') {\n if (!itemIds[item[idField]]) {\n this._destroyed.push(this._createNewModel(item));\n }\n } else {\n items.push(item);\n }\n }\n data = items;\n that._total = data.length;\n }\n that._pristineTotal = that._total;\n replaceSubset = that._skip && that._data.length && that._skip < that._data.length;\n if (that.options.endless) {\n if (replaceSubset) {\n that._pristineData.splice(that._skip, that._pristineData.length);\n }\n items = data.slice(0);\n for (var j = 0; j < items.length; j++) {\n that._pristineData.push(items[j]);\n }\n } else {\n that._pristineData = data.slice(0);\n }\n that._detachObservableParents();\n if (that.options.endless) {\n that._data.unbind(CHANGE, that._changeHandler);\n if (that._isServerGrouped() && that._data[that._data.length - 1].value === data[0].value) {\n fillLastGroup(that._data[that._data.length - 1], data[0]);\n data.shift();\n }\n data = that._observe(data);\n if (replaceSubset) {\n that._data.splice(that._skip, that._data.length);\n }\n for (var i = 0; i < data.length; i++) {\n that._data.push(data[i]);\n }\n that._data.bind(CHANGE, that._changeHandler);\n } else {\n that._data = that._observe(data);\n }\n that._markOfflineUpdatesAsDirty();\n that._storeData();\n that._addRange(that._data);\n that._process(that._data);\n that._dequeueRequest();\n },\n _detachObservableParents: function () {\n if (this._data && this._shouldDetachObservableParents) {\n for (var idx = 0; idx < this._data.length; idx++) {\n if (this._data[idx].parent) {\n this._data[idx].parent = noop;\n }\n }\n }\n },\n _storeData: function (updatePristine) {\n var serverGrouping = this._isServerGrouped();\n var model = this.reader.model;\n function items(data) {\n var state = [];\n for (var idx = 0; idx < data.length; idx++) {\n var dataItem = data.at(idx);\n var item = dataItem.toJSON();\n if (serverGrouping && dataItem.items) {\n item.items = items(dataItem.items);\n } else {\n item.uid = dataItem.uid;\n if (model) {\n if (dataItem.isNew()) {\n item.__state__ = 'create';\n } else if (dataItem.dirty) {\n item.__state__ = 'update';\n }\n }\n }\n state.push(item);\n }\n return state;\n }\n if (this.options.offlineStorage != null) {\n var state = items(this._data);\n var destroyed = [];\n for (var idx = 0; idx < this._destroyed.length; idx++) {\n var item = this._destroyed[idx].toJSON();\n item.__state__ = 'destroy';\n destroyed.push(item);\n }\n this.offlineData(state.concat(destroyed));\n if (updatePristine) {\n this._pristineData = this.reader.reader ? this.reader.reader._wrapDataAccessBase(state) : this.reader._wrapDataAccessBase(state);\n }\n }\n },\n _addRange: function (data, skip) {\n var that = this, start = typeof skip !== 'undefined' ? skip : that._skip || 0, end, range = {\n data: data,\n pristineData: data.toJSON(),\n timestamp: that._timeStamp()\n };\n if (this._isGroupPaged()) {\n end = start + data.length;\n range.outerStart = start;\n range.outerEnd = end;\n } else {\n end = start + that._flatData(data, true).length;\n }\n range.start = start;\n range.end = end;\n that._ranges.push(range);\n that._sortRanges();\n if (that._isGroupPaged()) {\n if (!that._groupsFlat) {\n that._groupsFlat = [];\n }\n that._appendToGroupsFlat(range.data);\n that._updateOuterRangesLength();\n }\n },\n _appendToGroupsFlat: function (data) {\n var length = data.length;\n for (var i = 0; i < length; i++) {\n this._groupsFlat.push(data[i]);\n }\n },\n _getGroupByUid: function (uid) {\n var length = this._groupsFlat.length;\n var group;\n for (var i = 0; i < length; i++) {\n group = this._groupsFlat[i];\n if (group.uid === uid) {\n return group;\n }\n }\n },\n _sortRanges: function () {\n this._ranges.sort(function (x, y) {\n return x.start - y.start;\n });\n },\n error: function (xhr, status, errorThrown) {\n this._dequeueRequest();\n this.trigger(REQUESTEND, {});\n this.trigger(ERROR, {\n xhr: xhr,\n status: status,\n errorThrown: errorThrown\n });\n },\n _params: function (data) {\n var that = this, options = extend({\n take: that.take(),\n skip: that.skip(),\n page: that.page(),\n pageSize: that.pageSize(),\n sort: that._sort,\n filter: that._filter,\n group: that._group,\n aggregate: that._aggregate,\n groupPaging: !!that._groupPaging\n }, data);\n if (!that.options.serverPaging) {\n delete options.take;\n delete options.skip;\n delete options.page;\n delete options.pageSize;\n }\n if (!that.options.serverGrouping) {\n delete options.group;\n } else if (that.reader.model && options.group) {\n options.group = convertDescriptorsField(options.group, that.reader.model);\n }\n if (!that.options.serverFiltering) {\n delete options.filter;\n } else if (that.reader.model && options.filter) {\n options.filter = convertFilterDescriptorsField(options.filter, that.reader.model);\n }\n if (!that.options.serverSorting) {\n delete options.sort;\n } else if (that.reader.model && options.sort) {\n options.sort = convertDescriptorsField(options.sort, that.reader.model);\n }\n if (!that.options.serverAggregates) {\n delete options.aggregate;\n } else if (that.reader.model && options.aggregate) {\n options.aggregate = convertDescriptorsField(options.aggregate, that.reader.model);\n }\n if (!that.options.groupPaging) {\n delete options.groupPaging;\n }\n return options;\n },\n _queueRequest: function (options, callback) {\n var that = this;\n if (!that._requestInProgress) {\n that._requestInProgress = true;\n that._pending = undefined;\n callback();\n } else {\n that._pending = {\n callback: proxy(callback, that),\n options: options\n };\n }\n },\n _dequeueRequest: function () {\n var that = this;\n that._requestInProgress = false;\n if (that._pending) {\n that._queueRequest(that._pending.options, that._pending.callback);\n }\n },\n _handleCustomErrors: function (response) {\n if (this.reader.errors) {\n var errors = this.reader.errors(response);\n if (errors) {\n this.trigger(ERROR, {\n xhr: null,\n status: 'customerror',\n errorThrown: 'custom error',\n errors: errors\n });\n return true;\n }\n }\n return false;\n },\n _shouldWrap: function (data) {\n var model = this.reader.model;\n if (model && data.length) {\n return !(data[0] instanceof model);\n }\n return false;\n },\n _observe: function (data) {\n var that = this, model = that.reader.model;\n that._shouldDetachObservableParents = true;\n if (data instanceof ObservableArray) {\n that._shouldDetachObservableParents = false;\n if (that._shouldWrap(data)) {\n data.type = that.reader.model;\n data.wrapAll(data, data);\n }\n } else {\n var arrayType = that.pageSize() && !that.options.serverPaging ? LazyObservableArray : ObservableArray;\n data = new arrayType(data, that.reader.model);\n data.parent = function () {\n return that.parent();\n };\n }\n if (that._isServerGrouped()) {\n wrapGroupItems(data, model);\n }\n if (that._changeHandler && that._data && that._data instanceof ObservableArray && !(that.options.useRanges && that.options.serverPaging)) {\n that._data.unbind(CHANGE, that._changeHandler);\n } else {\n that._changeHandler = proxy(that._change, that);\n }\n return data.bind(CHANGE, that._changeHandler);\n },\n _updateTotalForAction: function (action, items) {\n var that = this;\n var total = parseInt(that._total, 10);\n if (!isNumber(that._total)) {\n total = parseInt(that._pristineTotal, 10);\n }\n if (action === 'add') {\n total += items.length;\n } else if (action === 'remove') {\n total -= items.length;\n } else if (action !== 'itemchange' && action !== 'sync' && !that.options.serverPaging) {\n total = that._pristineTotal;\n } else if (action === 'sync') {\n total = that._pristineTotal = parseInt(that._total, 10);\n }\n that._total = total;\n },\n _change: function (e) {\n var that = this, idx, length, action = e ? e.action : '';\n if (action === 'remove') {\n for (idx = 0, length = e.items.length; idx < length; idx++) {\n if (!e.items[idx].isNew || !e.items[idx].isNew()) {\n that._destroyed.push(e.items[idx]);\n }\n }\n }\n if (that.options.autoSync && (action === 'add' || action === 'remove' || action === 'itemchange')) {\n var handler = function (args) {\n if (args.action === 'sync') {\n that.unbind('change', handler);\n that._updateTotalForAction(action, e.items);\n }\n };\n that.first('change', handler);\n that.sync();\n } else {\n that._updateTotalForAction(action, e ? e.items : []);\n that._process(that._data, e);\n }\n },\n _calculateAggregates: function (data, options) {\n options = options || {};\n var query = new Query(data), aggregates = options.aggregate, filter = options.filter;\n if (filter) {\n query = query.filter(filter);\n }\n return query.aggregate(aggregates);\n },\n _process: function (data, e) {\n var that = this, options = {}, result;\n if (that.options.serverPaging !== true) {\n options.skip = that._skip;\n options.take = that._take || that._pageSize;\n if (options.skip === undefined && that._page !== undefined && that._pageSize !== undefined) {\n options.skip = (that._page - 1) * that._pageSize;\n }\n if (that.options.useRanges) {\n options.skip = that.currentRangeStart();\n }\n }\n if (that.options.serverSorting !== true) {\n options.sort = that._sort;\n }\n if (that.options.serverFiltering !== true) {\n options.filter = that._filter;\n }\n if (that.options.serverGrouping !== true) {\n options.group = that._group;\n }\n if (that.options.serverAggregates !== true) {\n options.aggregate = that._aggregate;\n }\n if (that.options.serverGrouping) {\n that._clearEmptyGroups(data);\n }\n options.groupPaging = that._groupPaging;\n if (that._isGroupPaged() && e && (e.action === 'page' || e.action === 'expandGroup' || e.action === 'collapseGroup')) {\n result = that._queryProcess(data, { aggregate: that._aggregate });\n } else {\n result = that._queryProcess(data, options);\n }\n if (that.options.serverAggregates !== true) {\n that._aggregateResult = that._calculateAggregates(result.dataToAggregate || data, options);\n }\n that._setView(result, options, e);\n that._setFilterTotal(result.total, false);\n e = e || {};\n e.items = e.items || that._view;\n that.trigger(CHANGE, e);\n },\n _setView: function (result, options, e) {\n var that = this;\n if (that._isGroupPaged() && !that._isServerGrouped()) {\n if (e && (e.action === 'page' || e.action === 'expandGroup' || e.action === 'collapseGroup')) {\n that.view(result.data);\n that._updateOuterRangesLength();\n } else {\n that._ranges = [];\n var query = new Query(result.data);\n that._addRange(that._observe(result.data));\n if (options.skip + options.take > result.data.length) {\n options.skip = result.data.length - options.take;\n }\n that.view(query.range(options.skip, options.take).toArray());\n }\n } else {\n that.view(result.data);\n }\n },\n _clearEmptyGroups: function (data) {\n for (var idx = data.length - 1; idx >= 0; idx--) {\n var group = data[idx];\n if (group.hasSubgroups) {\n this._clearEmptyGroups(group.items);\n } else {\n if (group.items && !group.items.length) {\n splice.apply(group.parent(), [\n idx,\n 1\n ]);\n }\n }\n }\n },\n _queryProcess: function (data, options) {\n if (this.options.inPlaceSort) {\n return Query.process(data, options, this.options.inPlaceSort);\n } else {\n return Query.process(data, options);\n }\n },\n _mergeState: function (options) {\n var that = this;\n if (options !== undefined) {\n that._pageSize = options.pageSize;\n that._page = options.page;\n that._sort = options.sort;\n that._filter = options.filter;\n that._group = options.group;\n that._aggregate = options.aggregate;\n that._skip = that._currentRangeStart = options.skip;\n that._take = options.take;\n if (that._skip === undefined) {\n that._skip = that._currentRangeStart = that.skip();\n options.skip = that.skip();\n }\n if (that._take === undefined && that._pageSize !== undefined) {\n that._take = that._pageSize;\n options.take = that._take;\n }\n if (options.sort) {\n that._sort = options.sort = normalizeSort(options.sort);\n that._sortFields = sortFields(options.sort);\n }\n if (options.filter) {\n that._filter = options.filter = that.options.accentFoldingFiltering && !$.isEmptyObject(options.filter) ? $.extend({}, normalizeFilter(options.filter), { accentFoldingFiltering: that.options.accentFoldingFiltering }) : normalizeFilter(options.filter);\n }\n if (options.group) {\n that._group = options.group = normalizeGroup(options.group);\n }\n if (options.aggregate) {\n that._aggregate = options.aggregate = normalizeAggregate(options.aggregate);\n }\n }\n return options;\n },\n query: function (options) {\n var result;\n var remote = this.options.serverSorting || this.options.serverPaging || this.options.serverFiltering || this.options.serverGrouping || this.options.serverAggregates;\n if (remote || (this._data === undefined || this._data.length === 0) && !this._destroyed.length) {\n if (this.options.endless) {\n var moreItemsCount = options.pageSize - this.pageSize();\n if (moreItemsCount > 0) {\n moreItemsCount = this.pageSize();\n options.page = options.pageSize / moreItemsCount;\n options.pageSize = moreItemsCount;\n } else {\n options.page = 1;\n this.options.endless = false;\n }\n }\n return this.read(this._mergeState(options));\n }\n var isPrevented = this.trigger(REQUESTSTART, { type: 'read' });\n if (!isPrevented) {\n this.trigger(PROGRESS);\n if (options) {\n options.groupPaging = this._groupPaging;\n }\n result = this._queryProcess(this._data, this._mergeState(options));\n this._setFilterTotal(result.total, true);\n this._aggregateResult = this._calculateAggregates(result.dataToAggregate || this._data, options);\n this._setView(result, options);\n this.trigger(REQUESTEND, { type: 'read' });\n this.trigger(CHANGE, {\n items: result.data,\n action: options ? options.action : ''\n });\n }\n return $.Deferred().resolve(isPrevented).promise();\n },\n _hasExpandedSubGroups: function (group) {\n var result = false;\n var length = group.items ? group.items.length : 0;\n if (!group.hasSubgroups) {\n return false;\n }\n for (var i = 0; i < length; i++) {\n if (this._groupsState[group.items[i].uid]) {\n result = true;\n break;\n }\n }\n return result;\n },\n _findGroupedRange: function (data, result, options, parents, callback) {\n var that = this;\n var length = data.length;\n var group;\n var current;\n var itemsLength;\n var hasNotRequestedItems;\n var groupCount;\n var itemsToSkip;\n for (var i = 0; i < length; i++) {\n group = data[i];\n if (options.taken >= options.take) {\n break;\n }\n if (!that._getGroupByUid(group.uid)) {\n that._groupsFlat.push(group);\n }\n if (that._groupsState[group.uid]) {\n if (that._isServerGroupPaged()) {\n if (group.hasSubgroups && !group.subgroupCount) {\n that.getGroupSubGroupCount(group, options, parents, callback);\n that._fetchingGroupItems = true;\n return;\n }\n groupCount = (group.subgroupCount || group.itemCount) + 1;\n itemsToSkip = options.skip - options.skipped;\n hasNotRequestedItems = !group.items || group.items.length - itemsToSkip < options.take - options.taken;\n if (!that._hasExpandedSubGroups(group) && itemsToSkip > groupCount) {\n options.skipped += groupCount;\n continue;\n }\n if (group.hasSubgroups && (!group.items || hasNotRequestedItems && group.items.length < group.subgroupCount) || !group.hasSubgroups && (!group.items || hasNotRequestedItems && group.items.length < group.itemCount)) {\n that.getGroupItems(group, options, parents, callback);\n that._fetchingGroupItems = true;\n return;\n }\n }\n if (options.includeParents && options.skipped < options.skip) {\n options.skipped++;\n group.excludeHeader = true;\n } else if (options.includeParents) {\n options.taken++;\n }\n if (group.hasSubgroups && group.items && group.items.length) {\n group.currentItems = [];\n if (!parents) {\n parents = [];\n }\n parents.push(group);\n that._findGroupedRange(group.items, group.currentItems, options, parents, callback);\n parents.pop();\n if (group.currentItems.length || options.taken > 0) {\n result.push(group);\n } else {\n group.excludeHeader = false;\n }\n } else {\n current = [];\n itemsLength = group.items.length;\n for (var j = 0; j < itemsLength; j++) {\n if (options.skipped < options.skip) {\n options.skipped++;\n continue;\n }\n if (options.taken >= options.take) {\n break;\n }\n current.push(group.items[j]);\n options.taken++;\n }\n if (current.length || options.taken > 0) {\n group.currentItems = current;\n result.push(group);\n } else {\n group.excludeHeader = false;\n }\n }\n } else {\n if (options.skipped < options.skip) {\n options.skipped++;\n continue;\n }\n result.push(group);\n options.taken++;\n }\n }\n },\n getGroupItems: function (group, options, parents, callback) {\n var that = this;\n var skip;\n var take;\n var filter;\n var data;\n var subgroups;\n if (!group.items) {\n group.items = [];\n }\n skip = group.items.length;\n take = that.take();\n filter = this._composeItemsFilter(group, parents);\n data = {\n page: math.floor((skip || 0) / (take || 1)) || 1,\n pageSize: take,\n skip: skip,\n take: take,\n filter: filter,\n aggregate: that._aggregate,\n sort: that._sort\n };\n subgroups = that.findSubgroups(group);\n if (subgroups && subgroups.length) {\n data.group = subgroups;\n data.groupPaging = true;\n }\n clearTimeout(that._timeout);\n that._timeout = setTimeout(function () {\n that._queueRequest(data, function () {\n if (!that.trigger(REQUESTSTART, { type: 'read' })) {\n that.transport.read({\n data: data,\n success: that._groupItemsSuccessHandler(group, options.skip, that.take(), callback),\n error: function () {\n var args = slice.call(arguments);\n that.error.apply(that, args);\n }\n });\n } else {\n that._dequeueRequest();\n }\n });\n }, 100);\n },\n getGroupSubGroupCount: function (group, options, parents, callback) {\n var that = this;\n var filter;\n var groupIndex;\n var data;\n if (!group.items) {\n group.items = [];\n }\n filter = this._composeItemsFilter(group, parents);\n groupIndex = this._group.map(function (g) {\n return g.field;\n }).indexOf(group.field);\n data = {\n filter: filter,\n group: [that._group[groupIndex + 1]],\n groupPaging: true,\n includeSubGroupCount: true\n };\n clearTimeout(that._timeout);\n that._timeout = setTimeout(function () {\n that._queueRequest(data, function () {\n if (!that.trigger(REQUESTSTART, { type: 'read' })) {\n that.transport.read({\n data: data,\n success: that._subGroupCountSuccessHandler(group, options.skip, that.take(), callback),\n error: function () {\n var args = slice.call(arguments);\n that.error.apply(that, args);\n }\n });\n } else {\n that._dequeueRequest();\n }\n });\n }, 100);\n },\n _subGroupCountSuccessHandler: function (group, skip, take, callback) {\n var that = this;\n callback = isFunction(callback) ? callback : noop;\n var totalField = that.options.schema && that.options.schema.total ? that.options.schema.total : 'Total';\n return function (data) {\n that._dequeueRequest();\n that.trigger(REQUESTEND, {\n response: data,\n type: 'read'\n });\n that._fetchingGroupItems = false;\n if (isFunction(totalField)) {\n group.subgroupCount = totalField(data);\n } else {\n group.subgroupCount = data[totalField];\n }\n that.range(skip, take, callback, 'expandGroup');\n };\n },\n _groupItemsSuccessHandler: function (group, skip, take, callback) {\n var that = this;\n var timestamp = that._timeStamp();\n callback = isFunction(callback) ? callback : noop;\n return function (data) {\n var temp;\n var model = Model.define(that.options.schema.model);\n that._dequeueRequest();\n that.trigger(REQUESTEND, {\n response: data,\n type: 'read'\n });\n data = that.reader.parse(data);\n if (group.hasSubgroups) {\n temp = that.reader.groups(data);\n } else {\n temp = that.reader.data(data);\n temp = temp.map(function (item) {\n return new model(item);\n });\n }\n group.items.omitChangeEvent = true;\n for (var i = 0; i < temp.length; i++) {\n group.items.push(temp[i]);\n }\n group.items.omitChangeEvent = false;\n that._updateRangePristineData(group);\n that._fetchingGroupItems = false;\n that._serverGroupsTotal += temp.length;\n that.range(skip, take, callback, 'expandGroup');\n if (timestamp >= that._currentRequestTimeStamp || !that._skipRequestsInProgress) {\n that.trigger(CHANGE, {});\n }\n };\n },\n findSubgroups: function (group) {\n var indexOfCurrentGroup = this._group.map(function (g) {\n return g.field;\n }).indexOf(group.field);\n return this._group.slice(indexOfCurrentGroup + 1, this._group.length);\n },\n _composeItemsFilter: function (group, parents) {\n var filter = this.filter() || {\n logic: 'and',\n filters: []\n };\n filter = extend(true, {}, filter);\n filter.filters.push({\n field: group.field,\n operator: 'eq',\n value: group.value\n });\n if (parents) {\n for (var i = 0; i < parents.length; i++) {\n filter.filters.push({\n field: parents[i].field,\n operator: 'eq',\n value: parents[i].value\n });\n }\n }\n return filter;\n },\n _updateRangePristineData: function (group) {\n var that = this;\n var ranges = that._ranges;\n var rangesLength = ranges.length;\n var temp;\n var currentGroup;\n var range;\n var dataLength;\n var indexes;\n for (var i = 0; i < rangesLength; i++) {\n range = ranges[i];\n dataLength = range.data.length;\n indexes = [];\n for (var j = 0; j < dataLength; j++) {\n currentGroup = range.data[j];\n indexes.push(j);\n if (currentGroup.uid === group.uid || currentGroup.hasSubgroups && currentGroup.items.length && that._containsSubGroup(currentGroup, group, indexes)) {\n break;\n }\n indexes.pop();\n }\n if (indexes.length) {\n temp = ranges[i].pristineData;\n while (indexes.length > 1) {\n temp = temp[indexes.splice(0, 1)[0]].items;\n }\n temp[indexes[0]] = that._cloneGroup(group);\n break;\n }\n }\n },\n _containsSubGroup: function (group, subgroup, indexes) {\n var that = this;\n var length = group.items.length;\n var currentSubGroup;\n if (group.hasSubgroups && length) {\n for (var i = 0; i < length; i++) {\n currentSubGroup = group.items[i];\n indexes.push(i);\n if (currentSubGroup.uid === subgroup.uid) {\n return true;\n } else if (currentSubGroup.hasSubgroups && currentSubGroup.items.length) {\n return that._containsSubGroup(currentSubGroup, subgroup, indexes);\n }\n indexes.pop();\n }\n }\n },\n _cloneGroup: function (group) {\n var that = this;\n group = typeof group.toJSON == 'function' ? group.toJSON() : group;\n if (group.items && group.items.length) {\n group.items = group.items.map(function (item) {\n return that._cloneGroup(item);\n });\n }\n return group;\n },\n _setFilterTotal: function (filterTotal, setDefaultValue) {\n var that = this;\n if (!that.options.serverFiltering) {\n if (filterTotal !== undefined) {\n that._total = filterTotal;\n } else if (setDefaultValue) {\n that._total = that._data.length;\n }\n }\n },\n fetch: function (callback) {\n var that = this;\n var fn = function (isPrevented) {\n if (isPrevented !== true && isFunction(callback)) {\n callback.call(that);\n }\n };\n return this._query().done(fn);\n },\n _query: function (options) {\n var that = this;\n return that.query(extend({}, {\n page: that.page(),\n pageSize: that.pageSize(),\n sort: that.sort(),\n filter: that.filter(),\n group: that.group(),\n aggregate: that.aggregate()\n }, options));\n },\n next: function (options) {\n var that = this, page = that.page(), total = that.total();\n options = options || {};\n if (!page || total && page + 1 > that.totalPages()) {\n return;\n }\n that._skip = that._currentRangeStart = page * that.take();\n page += 1;\n options.page = page;\n that._query(options);\n return page;\n },\n prev: function (options) {\n var that = this, page = that.page();\n options = options || {};\n if (!page || page === 1) {\n return;\n }\n that._skip = that._currentRangeStart = that._skip - that.take();\n page -= 1;\n options.page = page;\n that._query(options);\n return page;\n },\n page: function (val) {\n var that = this, skip;\n if (val !== undefined) {\n val = math.max(math.min(math.max(val, 1), that.totalPages()), 1);\n var take = that.take();\n if (that._isGroupPaged()) {\n val -= 1;\n that.range(val * take, take, null, 'page');\n return;\n }\n that._query(that._pageableQueryOptions({ page: val }));\n return;\n }\n skip = that.skip();\n return skip !== undefined ? math.round((skip || 0) / (that.take() || 1)) + 1 : undefined;\n },\n pageSize: function (val) {\n var that = this;\n if (val !== undefined) {\n that._query(that._pageableQueryOptions({\n pageSize: val,\n page: 1\n }));\n return;\n }\n return that.take();\n },\n sort: function (val) {\n var that = this;\n if (val !== undefined) {\n that.trigger('sort');\n that._query({ sort: val });\n return;\n }\n return that._sort;\n },\n filter: function (val) {\n var that = this;\n if (val === undefined) {\n return that._filter;\n }\n that.trigger('reset');\n that._query({\n filter: val,\n page: 1\n });\n },\n group: function (val) {\n var that = this;\n var options = { group: val };\n if (that._groupPaging) {\n options.page = 1;\n }\n if (val !== undefined) {\n that._query(options);\n return;\n }\n return that._group;\n },\n getGroupsFlat: function (data) {\n var idx, result = [], length;\n for (idx = 0, length = data.length; idx < length; idx++) {\n var group = data[idx];\n if (group.hasSubgroups) {\n result = result.concat(this.getGroupsFlat(group.items));\n }\n result.push(group);\n }\n return result;\n },\n total: function () {\n return parseInt(this._total || 0, 10);\n },\n groupsTotal: function (includeExpanded) {\n var that = this;\n if (!that._group.length) {\n return that.total();\n }\n if (that._isServerGrouped()) {\n if (that._serverGroupsTotal) {\n return that._serverGroupsTotal;\n }\n that._serverGroupsTotal = that.total();\n return that._serverGroupsTotal;\n }\n return that._calculateGroupsTotal(that._ranges.length ? that._ranges[0].data : [], includeExpanded);\n },\n _calculateGroupsTotal: function (groups, includeExpanded, itemsField, ignoreState) {\n var that = this;\n itemsField = itemsField || 'items';\n var total;\n var length;\n if (that._group.length && groups) {\n total = 0;\n length = groups.length;\n for (var i = 0; i < length; i++) {\n total += that.groupCount(groups[i], includeExpanded, itemsField, ignoreState);\n }\n that._groupsTotal = total;\n return total;\n }\n that._groupsTotal = that._data.length;\n return that._groupsTotal;\n },\n groupCount: function (group, includeExpanded, itemsField, ignoreState) {\n var that = this;\n var total = 0;\n if (group.hasSubgroups && that._groupsState[group.uid]) {\n if (includeExpanded && !group.excludeHeader || ignoreState) {\n total += 1;\n }\n group[itemsField].forEach(function (subgroup) {\n total += that.groupCount(subgroup, includeExpanded, itemsField, ignoreState);\n });\n } else {\n if (that._groupsState[group.uid]) {\n if (includeExpanded && !group.excludeHeader || ignoreState) {\n total++;\n }\n total += group[itemsField] ? group[itemsField].length : 0;\n } else {\n total++;\n }\n }\n return total;\n },\n countGroupRange: function (range) {\n var total = 0;\n var length = range.length;\n for (var i = 0; i < length; i++) {\n total += this.groupCount(range[i], true);\n }\n return total;\n },\n aggregate: function (val) {\n var that = this;\n if (val !== undefined) {\n that._query({ aggregate: val });\n return;\n }\n return that._aggregate;\n },\n aggregates: function () {\n var result = this._aggregateResult;\n if (isEmptyObject(result)) {\n result = this._emptyAggregates(this.aggregate());\n }\n return result;\n },\n _emptyAggregates: function (aggregates) {\n var result = {};\n if (!isEmptyObject(aggregates)) {\n var aggregate = {};\n if (!isArray(aggregates)) {\n aggregates = [aggregates];\n }\n for (var idx = 0; idx < aggregates.length; idx++) {\n aggregate[aggregates[idx].aggregate] = 0;\n result[aggregates[idx].field] = aggregate;\n }\n }\n return result;\n },\n _pageableQueryOptions: function (options) {\n return options;\n },\n _wrapInEmptyGroup: function (model) {\n var groups = this.group(), parent, group, idx, length;\n for (idx = groups.length - 1, length = 0; idx >= length; idx--) {\n group = groups[idx];\n parent = {\n value: model.get ? model.get(group.field) : model[group.field],\n field: group.field,\n items: parent ? [parent] : [model],\n hasSubgroups: !!parent,\n aggregates: this._emptyAggregates(group.aggregates)\n };\n }\n return parent;\n },\n totalPages: function () {\n var that = this, pageSize = that.pageSize() || that.total(), total = that._isGroupPaged() ? that.groupsTotal(true) : that.total();\n return math.ceil((total || 0) / pageSize);\n },\n inRange: function (skip, take) {\n var that = this, end = math.min(skip + take, that.total());\n if (!that.options.serverPaging && that._data.length > 0) {\n return true;\n }\n return that._findRange(skip, end).length > 0;\n },\n lastRange: function () {\n var ranges = this._ranges;\n return ranges[ranges.length - 1] || {\n start: 0,\n end: 0,\n data: []\n };\n },\n firstItemUid: function () {\n var ranges = this._ranges;\n return ranges.length && ranges[0].data.length && ranges[0].data[0].uid;\n },\n enableRequestsInProgress: function () {\n this._skipRequestsInProgress = false;\n },\n _timeStamp: function () {\n return new Date().getTime();\n },\n range: function (skip, take, callback, action) {\n this._currentRequestTimeStamp = this._timeStamp();\n this._skipRequestsInProgress = true;\n var total = this._isGroupPaged() ? this.groupsTotal(true) : this.total();\n if (action === 'expandGroup' || action === 'collapseGroup') {\n this._updateOuterRangesLength();\n }\n skip = math.min(skip || 0, total);\n callback = isFunction(callback) ? callback : noop;\n var that = this, pageSkip = math.max(math.floor(skip / take), 0) * take, size = math.min(pageSkip + take, total), data;\n data = that._findRange(skip, math.min(skip + take, total), callback);\n if ((data.length || total === 0) && !that._fetchingGroupItems) {\n that._processRangeData(data, skip, take, that._originalPageSkip || pageSkip, that._originalSize || size, { action: action });\n that._originalPageSkip = null;\n that._originalSize = null;\n callback();\n return;\n }\n if (that._isGroupPaged()) {\n that._originalPageSkip = pageSkip;\n that._originalSize = size;\n pageSkip = math.max(math.floor(that._adjustPageSkip(skip, take) / take), 0) * take;\n size = math.min(pageSkip + take, total);\n }\n if (take !== undefined && !that._fetchingGroupItems) {\n if (that._isGroupPaged() && !that._groupRangeExists(pageSkip, take) || !that._rangeExists(pageSkip, size)) {\n that.prefetch(pageSkip, take, function () {\n if (skip > pageSkip && size < that.total() && !that._rangeExists(size, math.min(size + take, that.total()))) {\n that.prefetch(size, take, function () {\n that.range(skip, take, callback);\n });\n } else {\n that.range(skip, take, callback);\n }\n });\n } else if (pageSkip < skip) {\n that.prefetch(size, take, function () {\n that.range(skip, take, callback);\n });\n }\n }\n },\n _findRange: function (start, end, callback) {\n var that = this, ranges = that._ranges, range, data = [], skipIdx, takeIdx, startIndex, endIndex, rangeData, rangeEnd, processed, options = that.options, remote = options.serverSorting || options.serverPaging || options.serverFiltering || options.serverGrouping || options.serverAggregates, flatData, count, length, groupMapOptions = {\n take: end - start,\n skip: start,\n skipped: 0,\n taken: 0,\n includeParents: true\n }, prevRangeEnd, isGroupPaged = that._isGroupPaged(), startField = isGroupPaged ? 'outerStart' : 'start', endField = isGroupPaged ? 'outerEnd' : 'end', currentDataLength;\n for (skipIdx = 0, length = ranges.length; skipIdx < length; skipIdx++) {\n range = ranges[skipIdx];\n if (isGroupPaged) {\n if (range.outerStart >= end) {\n return [];\n }\n if (start > range.outerEnd) {\n groupMapOptions.skipped += range.outerEnd - (prevRangeEnd || 0);\n prevRangeEnd = range.outerEnd;\n continue;\n }\n if (typeof prevRangeEnd !== 'undefined' && prevRangeEnd != range.outerStart) {\n groupMapOptions.skipped += range.outerStart - prevRangeEnd;\n }\n if (groupMapOptions.skipped > groupMapOptions.skip) {\n return [];\n }\n if (typeof prevRangeEnd === 'undefined' && start > 0 && range.start > 0) {\n groupMapOptions.skipped = range.outerStart;\n }\n takeIdx = skipIdx;\n while (true) {\n this._findGroupedRange(range.data, data, groupMapOptions, null, callback);\n currentDataLength = that._calculateGroupsTotal(data, true, 'currentItems');\n if (currentDataLength >= groupMapOptions.take) {\n return data;\n }\n if (that._fetchingGroupItems) {\n return [];\n }\n takeIdx++;\n if (ranges[takeIdx] && ranges[takeIdx].outerStart === range.outerEnd) {\n range = ranges[takeIdx];\n } else {\n break;\n }\n }\n } else if (start >= range[startField] && start <= range[endField]) {\n count = 0;\n for (takeIdx = skipIdx; takeIdx < length; takeIdx++) {\n range = ranges[takeIdx];\n flatData = that._flatData(range.data, true);\n if (flatData.length && start + count >= range.start) {\n rangeData = range.data;\n rangeEnd = range.end;\n if (!remote) {\n if (options.inPlaceSort) {\n processed = that._queryProcess(range.data, { filter: that.filter() });\n } else {\n var sort = normalizeGroupWithoutCompare(that.group() || []).concat(normalizeSort(that.sort() || []));\n processed = that._queryProcess(range.data, {\n sort: sort,\n filter: that.filter()\n });\n }\n flatData = rangeData = processed.data;\n if (processed.total !== undefined) {\n rangeEnd = processed.total;\n }\n }\n startIndex = 0;\n if (start + count > range.start) {\n startIndex = start + count - range.start;\n }\n endIndex = flatData.length;\n if (rangeEnd > end) {\n endIndex = endIndex - (rangeEnd - end);\n }\n count += endIndex - startIndex;\n data = that._mergeGroups(data, rangeData, startIndex, endIndex);\n if (end <= range.end && count == end - start) {\n return data;\n }\n }\n }\n break;\n }\n prevRangeEnd = range.outerEnd;\n }\n return [];\n },\n _getRangesMismatch: function (pageSkip) {\n var that = this;\n var ranges = that._ranges;\n var mismatch = 0;\n var i = 0;\n while (true) {\n var range = ranges[i];\n if (!range || range.outerStart > pageSkip) {\n break;\n }\n if (range.outerEnd != range.end) {\n mismatch = range.outerEnd - range.end;\n }\n i++;\n }\n return mismatch;\n },\n _mergeGroups: function (data, range, skip, take) {\n if (this._isServerGrouped()) {\n var temp = range.toJSON(), prevGroup;\n if (data.length) {\n prevGroup = data[data.length - 1];\n }\n mergeGroups(prevGroup, temp, skip, take);\n return data.concat(temp);\n }\n return data.concat(range.slice(skip, take));\n },\n _processRangeData: function (data, skip, take, pageSkip, size, eventData) {\n var that = this;\n that._pending = undefined;\n that._skip = skip > that.skip() && !that._omitPrefetch ? math.min(size, (that.totalPages() - 1) * that.take()) : pageSkip;\n that._currentRangeStart = skip;\n that._take = take;\n var paging = that.options.serverPaging;\n var sorting = that.options.serverSorting;\n var filtering = that.options.serverFiltering;\n var aggregates = that.options.serverAggregates;\n try {\n that.options.serverPaging = true;\n if (!that._isServerGrouped() && !(that.group() && that.group().length)) {\n that.options.serverSorting = true;\n }\n that.options.serverFiltering = true;\n that.options.serverPaging = true;\n that.options.serverAggregates = true;\n if (paging) {\n that._detachObservableParents();\n that._data = data = that._observe(data);\n }\n that._process(data, eventData);\n } finally {\n that.options.serverPaging = paging;\n that.options.serverSorting = sorting;\n that.options.serverFiltering = filtering;\n that.options.serverAggregates = aggregates;\n }\n },\n skip: function () {\n var that = this;\n if (that._skip === undefined) {\n return that._page !== undefined ? (that._page - 1) * (that.take() || 1) : undefined;\n }\n return that._skip;\n },\n currentRangeStart: function () {\n return this._currentRangeStart || 0;\n },\n take: function () {\n return this._take || this._pageSize;\n },\n _prefetchSuccessHandler: function (skip, size, callback, force) {\n var that = this;\n var timestamp = that._timeStamp();\n return function (data) {\n var found = false, range = {\n start: skip,\n end: size,\n data: [],\n timestamp: that._timeStamp()\n }, idx, length, temp;\n that._dequeueRequest();\n that.trigger(REQUESTEND, {\n response: data,\n type: 'read'\n });\n data = that.reader.parse(data);\n temp = that._readData(data);\n if (temp.length) {\n for (idx = 0, length = that._ranges.length; idx < length; idx++) {\n if (that._ranges[idx].start === skip) {\n found = true;\n range = that._ranges[idx];\n if (!that._isGroupPaged()) {\n range.pristineData = temp;\n range.data = that._observe(temp);\n range.end = range.start + that._flatData(range.data, true).length;\n that._sortRanges();\n }\n break;\n }\n }\n if (!found) {\n that._addRange(that._observe(temp), skip);\n }\n }\n that._total = that.reader.total(data);\n if (force || (timestamp >= that._currentRequestTimeStamp || !that._skipRequestsInProgress)) {\n if (callback && temp.length) {\n callback();\n } else {\n that.trigger(CHANGE, {});\n }\n }\n };\n },\n prefetch: function (skip, take, callback) {\n var that = this, size = math.min(skip + take, that.total()), options = {\n take: take,\n skip: skip,\n page: skip / take + 1,\n pageSize: take,\n sort: that._sort,\n filter: that._filter,\n group: that._group,\n aggregate: that._aggregate\n };\n if (that._isGroupPaged() && !that._isServerGrouped() && that._groupRangeExists(skip, size)) {\n if (callback) {\n callback();\n }\n return;\n }\n if (that._isServerGroupPaged() && !that._groupRangeExists(skip, size) || !that._rangeExists(skip, size)) {\n clearTimeout(that._timeout);\n that._timeout = setTimeout(function () {\n that._queueRequest(options, function () {\n if (!that.trigger(REQUESTSTART, { type: 'read' })) {\n if (that._omitPrefetch) {\n that.trigger(PROGRESS);\n }\n that.transport.read({\n data: that._params(options),\n success: that._prefetchSuccessHandler(skip, size, callback),\n error: function () {\n var args = slice.call(arguments);\n that.error.apply(that, args);\n }\n });\n } else {\n that._dequeueRequest();\n }\n });\n }, 100);\n } else if (callback) {\n callback();\n }\n },\n _multiplePrefetch: function (skip, take, callback) {\n var that = this, size = math.min(skip + take, that.total()), options = {\n take: take,\n skip: skip,\n page: skip / take + 1,\n pageSize: take,\n sort: that._sort,\n filter: that._filter,\n group: that._group,\n aggregate: that._aggregate\n };\n if (!that._rangeExists(skip, size)) {\n if (!that.trigger(REQUESTSTART, { type: 'read' })) {\n that.transport.read({\n data: that._params(options),\n success: that._prefetchSuccessHandler(skip, size, callback, true)\n });\n }\n } else if (callback) {\n callback();\n }\n },\n _adjustPageSkip: function (start, take) {\n var that = this;\n var prevRange = that._getPrevRange(start);\n var result;\n var total = that.total();\n var mismatch;\n if (prevRange) {\n mismatch = that._getRangesMismatch(start);\n if (!mismatch) {\n return start;\n }\n start -= mismatch;\n }\n result = math.max(math.floor(start / take), 0) * take;\n if (result > total) {\n while (true) {\n result -= take;\n if (result < total) {\n break;\n }\n }\n }\n return result;\n },\n _getNextRange: function (end) {\n var that = this, ranges = that._ranges, idx, length;\n for (idx = 0, length = ranges.length; idx < length; idx++) {\n if (ranges[idx].start <= end && ranges[idx].end >= end) {\n return ranges[idx];\n }\n }\n },\n _getPrevRange: function (start) {\n var that = this, ranges = that._ranges, idx, range, length = ranges.length;\n for (idx = length - 1; idx >= 0; idx--) {\n if (ranges[idx].outerStart <= start) {\n range = ranges[idx];\n break;\n }\n }\n return range;\n },\n _rangeExists: function (start, end) {\n var that = this, ranges = that._ranges, idx, length;\n for (idx = 0, length = ranges.length; idx < length; idx++) {\n if (ranges[idx].start <= start && ranges[idx].end >= end) {\n return true;\n }\n }\n return false;\n },\n _groupRangeExists: function (start, end) {\n var that = this, ranges = that._ranges, idx, length, availableItemsCount = 0, total = that.groupsTotal(true);\n if (end > total && !that._isServerGrouped()) {\n end = total;\n }\n for (idx = 0, length = ranges.length; idx < length; idx++) {\n var range = ranges[idx];\n if (range.outerStart <= start && range.outerEnd >= start) {\n availableItemsCount += range.outerEnd - start;\n } else if (range.outerStart <= end && range.outerEnd >= end) {\n availableItemsCount += end - range.outerStart;\n }\n }\n return availableItemsCount >= end - start;\n },\n _getCurrentRangeSpan: function () {\n var that = this;\n var ranges = that._ranges;\n var start = that.currentRangeStart();\n var end = start + (that.take() || 0);\n var rangeSpan = [];\n var range;\n var idx;\n var length = ranges.length;\n for (idx = 0; idx < length; idx++) {\n range = ranges[idx];\n if (range.start <= start && range.end >= start || range.start >= start && range.start <= end) {\n rangeSpan.push(range);\n }\n }\n return rangeSpan;\n },\n _removeModelFromRanges: function (model) {\n var that = this;\n var range;\n for (var idx = 0, length = this._ranges.length; idx < length; idx++) {\n range = this._ranges[idx];\n that._removeModelFromRange(range, model);\n }\n that._updateRangesLength();\n },\n _removeModelFromRange: function (range, model) {\n this._eachItem(range.data, function (data) {\n if (!data) {\n return;\n }\n for (var idx = 0; idx < data.length; idx++) {\n var dataItem = data[idx];\n if (dataItem.uid && dataItem.uid == model.uid) {\n [].splice.call(data, idx, 1);\n break;\n }\n }\n });\n },\n _insertModelInRange: function (index, model) {\n var that = this;\n var ranges = that._ranges || [];\n var rangesLength = ranges.length;\n var range;\n var i;\n for (i = 0; i < rangesLength; i++) {\n range = ranges[i];\n if (range.start <= index && range.end >= index) {\n if (!that._getByUid(model.uid, range.data)) {\n if (that._isServerGrouped()) {\n range.data.splice(index, 0, that._wrapInEmptyGroup(model));\n } else {\n range.data.splice(index, 0, model);\n }\n }\n break;\n }\n }\n that._updateRangesLength();\n },\n _updateRangesLength: function () {\n var that = this;\n var ranges = that._ranges || [];\n var rangesLength = ranges.length;\n var mismatchFound = false;\n var mismatchLength = 0;\n var lengthDifference = 0;\n var rangeLength;\n var range;\n var i;\n for (i = 0; i < rangesLength; i++) {\n range = ranges[i];\n rangeLength = that._isGroupPaged() ? range.data.length : that._flatData(range.data, true).length;\n lengthDifference = rangeLength - math.abs(range.end - range.start);\n if (!mismatchFound && lengthDifference !== 0) {\n mismatchFound = true;\n mismatchLength = lengthDifference;\n range.end += mismatchLength;\n continue;\n }\n if (mismatchFound) {\n range.start += mismatchLength;\n range.end += mismatchLength;\n }\n }\n },\n _updateOuterRangesLength: function () {\n var that = this;\n var ranges = that._ranges || [];\n var rangesLength = ranges.length;\n var mismatchLength = 0;\n var range;\n var i;\n var prevRange;\n var rangeLength;\n for (i = 0; i < rangesLength; i++) {\n range = ranges[i];\n rangeLength = that._isGroupPaged() ? that._calculateGroupsTotal(range.data, true, 'items', true) : that._flatData(range.data, true).length;\n if (prevRange) {\n if (prevRange.end != range.start) {\n mismatchLength = range.start - prevRange.end;\n }\n range.outerStart = prevRange.outerEnd + mismatchLength;\n mismatchLength = 0;\n } else {\n range.outerStart = range.start;\n }\n range.outerEnd = range.outerStart + rangeLength;\n prevRange = range;\n }\n }\n });\n var Transport = {};\n Transport.create = function (options, data, dataSource) {\n var transport, transportOptions = options.transport ? $.extend({}, options.transport) : null;\n if (transportOptions) {\n transportOptions.read = typeof transportOptions.read === STRING ? { url: transportOptions.read } : transportOptions.read;\n if (options.type === 'jsdo') {\n transportOptions.dataSource = dataSource;\n }\n if (options.type) {\n kendo.data.transports = kendo.data.transports || {};\n kendo.data.schemas = kendo.data.schemas || {};\n if (!kendo.data.transports[options.type]) {\n kendo.logToConsole('Unknown DataSource transport type \\'' + options.type + '\\'.\\nVerify that registration scripts for this type are included after Kendo UI on the page.', 'warn');\n } else if (!isPlainObject(kendo.data.transports[options.type])) {\n transport = new kendo.data.transports[options.type](extend(transportOptions, { data: data }));\n } else {\n transportOptions = extend(true, {}, kendo.data.transports[options.type], transportOptions);\n }\n options.schema = extend(true, {}, kendo.data.schemas[options.type], options.schema);\n }\n if (!transport) {\n transport = isFunction(transportOptions.read) ? transportOptions : new RemoteTransport(transportOptions);\n }\n } else {\n transport = new LocalTransport({ data: options.data || [] });\n }\n return transport;\n };\n DataSource.create = function (options) {\n if (isArray(options) || options instanceof ObservableArray) {\n options = { data: options };\n }\n var dataSource = options || {}, data = dataSource.data, fields = dataSource.fields, table = dataSource.table, select = dataSource.select, idx, length, model = {}, field;\n if (!data && fields && !dataSource.transport) {\n if (table) {\n data = inferTable(table, fields);\n } else if (select) {\n data = inferSelect(select, fields);\n if (dataSource.group === undefined && data[0] && data[0].optgroup !== undefined) {\n dataSource.group = 'optgroup';\n }\n }\n }\n if (kendo.data.Model && fields && (!dataSource.schema || !dataSource.schema.model)) {\n for (idx = 0, length = fields.length; idx < length; idx++) {\n field = fields[idx];\n if (field.type) {\n model[field.field] = field;\n }\n }\n if (!isEmptyObject(model)) {\n dataSource.schema = extend(true, dataSource.schema, { model: { fields: model } });\n }\n }\n dataSource.data = data;\n select = null;\n dataSource.select = null;\n table = null;\n dataSource.table = null;\n return dataSource instanceof DataSource ? dataSource : new DataSource(dataSource);\n };\n function inferSelect(select, fields) {\n select = $(select)[0];\n var options = select.options;\n var firstField = fields[0];\n var secondField = fields[1];\n var data = [];\n var idx, length;\n var optgroup;\n var option;\n var record;\n var value;\n for (idx = 0, length = options.length; idx < length; idx++) {\n record = {};\n option = options[idx];\n optgroup = option.parentNode;\n if (optgroup === select) {\n optgroup = null;\n }\n if (option.disabled || optgroup && optgroup.disabled) {\n continue;\n }\n if (optgroup) {\n record.optgroup = optgroup.label;\n }\n record[firstField.field] = option.text;\n value = option.attributes.value;\n if (value && value.specified) {\n value = option.value;\n } else {\n value = option.text;\n }\n record[secondField.field] = value;\n data.push(record);\n }\n return data;\n }\n function inferTable(table, fields) {\n var tbody = $(table)[0].tBodies[0], rows = tbody ? tbody.rows : [], idx, length, fieldIndex, fieldCount = fields.length, data = [], cells, record, cell, empty;\n for (idx = 0, length = rows.length; idx < length; idx++) {\n record = {};\n empty = true;\n cells = rows[idx].cells;\n for (fieldIndex = 0; fieldIndex < fieldCount; fieldIndex++) {\n cell = cells[fieldIndex];\n if (cell.nodeName.toLowerCase() !== 'th') {\n empty = false;\n record[fields[fieldIndex].field] = cell.innerHTML;\n }\n }\n if (!empty) {\n data.push(record);\n }\n }\n return data;\n }\n var Node = Model.define({\n idField: 'id',\n init: function (value) {\n var that = this, hasChildren = that.hasChildren || value && value.hasChildren, childrenField = 'items', childrenOptions = {};\n kendo.data.Model.fn.init.call(that, value);\n if (typeof that.children === STRING) {\n childrenField = that.children;\n }\n childrenOptions = {\n schema: {\n data: childrenField,\n model: {\n hasChildren: hasChildren,\n id: that.idField,\n fields: that.fields\n }\n }\n };\n if (typeof that.children !== STRING) {\n extend(childrenOptions, that.children);\n }\n childrenOptions.data = value;\n if (!hasChildren) {\n hasChildren = childrenOptions.schema.data;\n }\n if (typeof hasChildren === STRING) {\n hasChildren = kendo.getter(hasChildren);\n }\n if (isFunction(hasChildren)) {\n var hasChildrenObject = hasChildren.call(that, that);\n if (hasChildrenObject && hasChildrenObject.length === 0) {\n that.hasChildren = false;\n } else {\n that.hasChildren = !!hasChildrenObject;\n }\n }\n that._childrenOptions = childrenOptions;\n if (that.hasChildren) {\n that._initChildren();\n }\n that._loaded = !!(value && value._loaded);\n },\n _initChildren: function () {\n var that = this;\n var children, transport, parameterMap;\n if (!(that.children instanceof HierarchicalDataSource)) {\n children = that.children = new HierarchicalDataSource(that._childrenOptions);\n transport = children.transport;\n parameterMap = transport.parameterMap;\n transport.parameterMap = function (data, type) {\n data[that.idField || 'id'] = that.id;\n if (parameterMap) {\n data = parameterMap.call(that, data, type);\n }\n return data;\n };\n children.parent = function () {\n return that;\n };\n children.bind(CHANGE, function (e) {\n e.node = e.node || that;\n that.trigger(CHANGE, e);\n });\n children.bind(ERROR, function (e) {\n var collection = that.parent();\n if (collection) {\n e.node = e.node || that;\n collection.trigger(ERROR, e);\n }\n });\n that._updateChildrenField();\n }\n },\n append: function (model) {\n this._initChildren();\n this.loaded(true);\n this.children.add(model);\n },\n hasChildren: false,\n level: function () {\n var parentNode = this.parentNode(), level = 0;\n while (parentNode && parentNode.parentNode) {\n level++;\n parentNode = parentNode.parentNode ? parentNode.parentNode() : null;\n }\n return level;\n },\n _updateChildrenField: function () {\n var fieldName = this._childrenOptions.schema.data;\n this[fieldName || 'items'] = this.children.data();\n },\n _childrenLoaded: function () {\n this._loaded = true;\n this._updateChildrenField();\n },\n load: function () {\n var options = {};\n var method = '_query';\n var children, promise;\n if (this.hasChildren) {\n this._initChildren();\n children = this.children;\n options[this.idField || 'id'] = this.id;\n if (!this._loaded) {\n children._data = undefined;\n method = 'read';\n }\n children.one(CHANGE, proxy(this._childrenLoaded, this));\n if (this._matchFilter) {\n options.filter = {\n field: '_matchFilter',\n operator: 'eq',\n value: true\n };\n }\n promise = children[method](options);\n } else {\n this.loaded(true);\n }\n return promise || $.Deferred().resolve().promise();\n },\n parentNode: function () {\n var array = this.parent();\n return array.parent();\n },\n loaded: function (value) {\n if (value !== undefined) {\n this._loaded = value;\n } else {\n return this._loaded;\n }\n },\n shouldSerialize: function (field) {\n return Model.fn.shouldSerialize.call(this, field) && field !== 'children' && field !== '_loaded' && field !== 'hasChildren' && field !== '_childrenOptions';\n }\n });\n function dataMethod(name) {\n return function () {\n var data = this._data, result = DataSource.fn[name].apply(this, slice.call(arguments));\n if (this._data != data) {\n this._attachBubbleHandlers();\n }\n return result;\n };\n }\n var HierarchicalDataSource = DataSource.extend({\n init: function (options) {\n var node = Node.define({ children: options });\n if (options.filter && !options.serverFiltering) {\n this._hierarchicalFilter = options.filter;\n options.filter = null;\n }\n DataSource.fn.init.call(this, extend(true, {}, {\n schema: {\n modelBase: node,\n model: node\n }\n }, options));\n this._attachBubbleHandlers();\n },\n _attachBubbleHandlers: function () {\n var that = this;\n that._data.bind(ERROR, function (e) {\n that.trigger(ERROR, e);\n });\n },\n read: function (data) {\n var result = DataSource.fn.read.call(this, data);\n if (this._hierarchicalFilter) {\n if (this._data && this._data.length > 0) {\n this.filter(this._hierarchicalFilter);\n } else {\n this.options.filter = this._hierarchicalFilter;\n this._filter = normalizeFilter(this.options.filter);\n this._hierarchicalFilter = null;\n }\n }\n return result;\n },\n remove: function (node) {\n var parentNode = node.parentNode(), dataSource = this, result;\n if (parentNode && parentNode._initChildren) {\n dataSource = parentNode.children;\n }\n result = DataSource.fn.remove.call(dataSource, node);\n if (parentNode && !dataSource.data().length) {\n parentNode.hasChildren = false;\n }\n return result;\n },\n success: dataMethod('success'),\n data: dataMethod('data'),\n insert: function (index, model) {\n var parentNode = this.parent();\n if (parentNode && parentNode._initChildren) {\n parentNode.hasChildren = true;\n parentNode._initChildren();\n }\n return DataSource.fn.insert.call(this, index, model);\n },\n filter: function (val) {\n if (val === undefined) {\n return this._filter;\n }\n if (!this.options.serverFiltering && this._markHierarchicalQuery(val)) {\n val = {\n logic: 'or',\n filters: [\n val,\n {\n field: '_matchFilter',\n operator: 'equals',\n value: true\n }\n ]\n };\n }\n this.trigger('reset');\n this._query({\n filter: val,\n page: 1\n });\n },\n _markHierarchicalQuery: function (expressions) {\n var compiled;\n var predicate;\n var fields;\n var operators;\n var filter;\n var accentFoldingFiltering = this.options.accentFoldingFiltering;\n expressions = accentFoldingFiltering ? $.extend({}, normalizeFilter(expressions), { accentFoldingFiltering: accentFoldingFiltering }) : normalizeFilter(expressions);\n if (!expressions || expressions.filters.length === 0) {\n this._updateHierarchicalFilter(function () {\n return true;\n });\n return false;\n }\n compiled = Query.filterExpr(expressions);\n fields = compiled.fields;\n operators = compiled.operators;\n predicate = filter = new Function('d, __f, __o', 'return ' + compiled.expression);\n if (fields.length || operators.length) {\n filter = function (d) {\n return predicate(d, fields, operators);\n };\n }\n this._updateHierarchicalFilter(filter);\n return true;\n },\n _updateHierarchicalFilter: function (filter) {\n var current;\n var data = this._data;\n var result = false;\n for (var idx = 0; idx < data.length; idx++) {\n current = data[idx];\n if (current.hasChildren) {\n current._matchFilter = current.children._updateHierarchicalFilter(filter);\n if (!current._matchFilter) {\n current._matchFilter = filter(current);\n }\n } else {\n current._matchFilter = filter(current);\n }\n if (current._matchFilter) {\n result = true;\n }\n }\n return result;\n },\n _find: function (method, value) {\n var idx, length, node, children;\n var data = this._data;\n if (!data) {\n return;\n }\n node = DataSource.fn[method].call(this, value);\n if (node) {\n return node;\n }\n data = this._flatData(this._data);\n for (idx = 0, length = data.length; idx < length; idx++) {\n children = data[idx].children;\n if (!(children instanceof HierarchicalDataSource)) {\n continue;\n }\n node = children[method](value);\n if (node) {\n return node;\n }\n }\n },\n get: function (id) {\n return this._find('get', id);\n },\n getByUid: function (uid) {\n return this._find('getByUid', uid);\n }\n });\n function inferList(list, fields) {\n var items = $(list).children(), idx, length, data = [], record, textField = fields[0].field, urlField = fields[1] && fields[1].field, spriteCssClassField = fields[2] && fields[2].field, imageUrlField = fields[3] && fields[3].field, item, id, textChild, className, children;\n function elements(collection, tagName) {\n return collection.filter(tagName).add(collection.find(tagName));\n }\n for (idx = 0, length = items.length; idx < length; idx++) {\n record = { _loaded: true };\n item = items.eq(idx);\n textChild = item[0].firstChild;\n children = item.children();\n list = children.filter('ul');\n children = children.filter(':not(ul)');\n id = item.attr('data-id');\n if (id) {\n record.id = id;\n }\n if (textChild) {\n record[textField] = textChild.nodeType == 3 ? textChild.nodeValue : children.text();\n }\n if (urlField) {\n record[urlField] = elements(children, 'a').attr('href');\n }\n if (imageUrlField) {\n record[imageUrlField] = elements(children, 'img').attr('src');\n }\n if (spriteCssClassField) {\n className = elements(children, '.k-sprite').prop('className');\n record[spriteCssClassField] = className && kendo.trim(className.replace('k-sprite', ''));\n }\n if (list.length) {\n record.items = inferList(list.eq(0), fields);\n }\n if (item.attr('data-hasChildren') == 'true') {\n record.hasChildren = true;\n }\n data.push(record);\n }\n return data;\n }\n HierarchicalDataSource.create = function (options) {\n options = options && options.push ? { data: options } : options;\n var dataSource = options || {}, data = dataSource.data, fields = dataSource.fields, list = dataSource.list;\n if (data && data._dataSource) {\n return data._dataSource;\n }\n if (!data && fields && !dataSource.transport) {\n if (list) {\n data = inferList(list, fields);\n }\n }\n dataSource.data = data;\n return dataSource instanceof HierarchicalDataSource ? dataSource : new HierarchicalDataSource(dataSource);\n };\n var Buffer = kendo.Observable.extend({\n init: function (dataSource, viewSize, disablePrefetch) {\n kendo.Observable.fn.init.call(this);\n this._prefetching = false;\n this.dataSource = dataSource;\n this.prefetch = !disablePrefetch;\n var buffer = this;\n dataSource.bind('change', function () {\n buffer._change();\n });\n dataSource.bind('reset', function () {\n buffer._reset();\n });\n this._syncWithDataSource();\n this.setViewSize(viewSize);\n },\n setViewSize: function (viewSize) {\n this.viewSize = viewSize;\n this._recalculate();\n },\n at: function (index) {\n var pageSize = this.pageSize, itemPresent = true;\n if (index >= this.total()) {\n this.trigger('endreached', { index: index });\n return null;\n }\n if (!this.useRanges) {\n return this.dataSource.view()[index];\n }\n if (this.useRanges) {\n if (index < this.dataOffset || index >= this.skip + pageSize) {\n itemPresent = this.range(Math.floor(index / pageSize) * pageSize);\n }\n if (index === this.prefetchThreshold) {\n this._prefetch();\n }\n if (index === this.midPageThreshold) {\n this.range(this.nextMidRange, true);\n } else if (index === this.nextPageThreshold) {\n this.range(this.nextFullRange);\n } else if (index === this.pullBackThreshold) {\n if (this.offset === this.skip) {\n this.range(this.previousMidRange);\n } else {\n this.range(this.previousFullRange);\n }\n }\n if (itemPresent) {\n return this.dataSource.at(index - this.dataOffset);\n } else {\n this.trigger('endreached', { index: index });\n return null;\n }\n }\n },\n indexOf: function (item) {\n return this.dataSource.data().indexOf(item) + this.dataOffset;\n },\n total: function () {\n return parseInt(this.dataSource.total(), 10);\n },\n next: function () {\n var buffer = this, pageSize = buffer.pageSize, offset = buffer.skip - buffer.viewSize + pageSize, pageSkip = math.max(math.floor(offset / pageSize), 0) * pageSize;\n this.offset = offset;\n this.dataSource.prefetch(pageSkip, pageSize, function () {\n buffer._goToRange(offset, true);\n });\n },\n range: function (offset, nextRange) {\n if (this.offset === offset) {\n return true;\n }\n var buffer = this, pageSize = this.pageSize, pageSkip = math.max(math.floor(offset / pageSize), 0) * pageSize, dataSource = this.dataSource;\n if (nextRange) {\n pageSkip += pageSize;\n }\n if (dataSource.inRange(offset, pageSize)) {\n this.offset = offset;\n this._recalculate();\n this._goToRange(offset);\n return true;\n } else if (this.prefetch) {\n dataSource.prefetch(pageSkip, pageSize, function () {\n buffer.offset = offset;\n buffer._recalculate();\n buffer._goToRange(offset, true);\n });\n return false;\n }\n return true;\n },\n syncDataSource: function () {\n var offset = this.offset;\n this.offset = null;\n this.range(offset);\n },\n destroy: function () {\n this.unbind();\n },\n _prefetch: function () {\n var buffer = this, pageSize = this.pageSize, prefetchOffset = this.skip + pageSize, dataSource = this.dataSource;\n if (!dataSource.inRange(prefetchOffset, pageSize) && !this._prefetching && this.prefetch) {\n this._prefetching = true;\n this.trigger('prefetching', {\n skip: prefetchOffset,\n take: pageSize\n });\n dataSource.prefetch(prefetchOffset, pageSize, function () {\n buffer._prefetching = false;\n buffer.trigger('prefetched', {\n skip: prefetchOffset,\n take: pageSize\n });\n });\n }\n },\n _goToRange: function (offset, expanding) {\n if (this.offset !== offset) {\n return;\n }\n this.dataOffset = offset;\n this._expanding = expanding;\n this.dataSource.range(offset, this.pageSize);\n this.dataSource.enableRequestsInProgress();\n },\n _reset: function () {\n this._syncPending = true;\n },\n _change: function () {\n var dataSource = this.dataSource;\n this.length = this.useRanges ? dataSource.lastRange().end : dataSource.view().length;\n if (this._syncPending) {\n this._syncWithDataSource();\n this._recalculate();\n this._syncPending = false;\n this.trigger('reset', { offset: this.offset });\n }\n this.trigger('resize');\n if (this._expanding) {\n this.trigger('expand');\n }\n delete this._expanding;\n },\n _syncWithDataSource: function () {\n var dataSource = this.dataSource;\n this._firstItemUid = dataSource.firstItemUid();\n this.dataOffset = this.offset = dataSource.skip() || 0;\n this.pageSize = dataSource.pageSize();\n this.useRanges = dataSource.options.serverPaging;\n },\n _recalculate: function () {\n var pageSize = this.pageSize, offset = this.offset, viewSize = this.viewSize, skip = Math.ceil(offset / pageSize) * pageSize;\n this.skip = skip;\n this.midPageThreshold = skip + pageSize - 1;\n this.nextPageThreshold = skip + viewSize - 1;\n this.prefetchThreshold = skip + Math.floor(pageSize / 3 * 2);\n this.pullBackThreshold = this.offset - 1;\n this.nextMidRange = skip + pageSize - viewSize;\n this.nextFullRange = skip;\n this.previousMidRange = offset - viewSize;\n this.previousFullRange = skip - pageSize;\n }\n });\n var BatchBuffer = kendo.Observable.extend({\n init: function (dataSource, batchSize) {\n var batchBuffer = this;\n kendo.Observable.fn.init.call(batchBuffer);\n this.dataSource = dataSource;\n this.batchSize = batchSize;\n this._total = 0;\n this.buffer = new Buffer(dataSource, batchSize * 3);\n this.buffer.bind({\n 'endreached': function (e) {\n batchBuffer.trigger('endreached', { index: e.index });\n },\n 'prefetching': function (e) {\n batchBuffer.trigger('prefetching', {\n skip: e.skip,\n take: e.take\n });\n },\n 'prefetched': function (e) {\n batchBuffer.trigger('prefetched', {\n skip: e.skip,\n take: e.take\n });\n },\n 'reset': function () {\n batchBuffer._total = 0;\n batchBuffer.trigger('reset');\n },\n 'resize': function () {\n batchBuffer._total = Math.ceil(this.length / batchBuffer.batchSize);\n batchBuffer.trigger('resize', {\n total: batchBuffer.total(),\n offset: this.offset\n });\n }\n });\n },\n syncDataSource: function () {\n this.buffer.syncDataSource();\n },\n at: function (index) {\n var buffer = this.buffer, skip = index * this.batchSize, take = this.batchSize, view = [], item;\n if (buffer.offset > skip) {\n buffer.at(buffer.offset - 1);\n }\n for (var i = 0; i < take; i++) {\n item = buffer.at(skip + i);\n if (item === null) {\n break;\n }\n view.push(item);\n }\n return view;\n },\n total: function () {\n return this._total;\n },\n destroy: function () {\n this.buffer.destroy();\n this.unbind();\n }\n });\n extend(true, kendo.data, {\n readers: { json: DataReader },\n Query: Query,\n DataSource: DataSource,\n HierarchicalDataSource: HierarchicalDataSource,\n Node: Node,\n Comparer: Comparer,\n ObservableObject: ObservableObject,\n ObservableArray: ObservableArray,\n LazyObservableArray: LazyObservableArray,\n LocalTransport: LocalTransport,\n RemoteTransport: RemoteTransport,\n Cache: Cache,\n DataReader: DataReader,\n Model: Model,\n Buffer: Buffer,\n BatchBuffer: BatchBuffer\n });\n }(window.kendo.jQuery));\n return window.kendo;\n}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {\n (a3 || a2)();\n}));"]}