{"version":3,"file":"kendo.all.min.js","sources":["kendo.all.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.core',['jquery'], f);\n})(function(){\n\nvar __meta__ = { // jshint ignore:line\n id: \"core\",\n name: \"Core\",\n category: \"framework\",\n description: \"The core of the Kendo framework.\"\n};\n\n/*jshint eqnull: true, loopfunc: true, evil: true, boss: true, freeze: false*/\n(function($, window, undefined) {\n var kendo = window.kendo = window.kendo || { cultures: {} },\n extend = $.extend,\n each = $.each,\n isArray = Array.isArray,\n proxy = $.proxy,\n noop = $.noop,\n math = Math,\n Template,\n JSON = window.JSON || {},\n support = {},\n percentRegExp = /%/,\n formatRegExp = /\\{(\\d+)(:[^\\}]+)?\\}/g,\n boxShadowRegExp = /(\\d+(?:\\.?)\\d*)px\\s*(\\d+(?:\\.?)\\d*)px\\s*(\\d+(?:\\.?)\\d*)px\\s*(\\d+)?/i,\n numberRegExp = /^(\\+|-?)\\d+(\\.?)\\d*$/,\n FUNCTION = \"function\",\n STRING = \"string\",\n NUMBER = \"number\",\n OBJECT = \"object\",\n NULL = \"null\",\n BOOLEAN = \"boolean\",\n UNDEFINED = \"undefined\",\n PREFIX = \"prefix\",\n getterCache = {},\n setterCache = {},\n slice = [].slice,\n cssPropertiesNames = [ \"themeColor\", \"fillMode\", \"shape\", \"size\", \"rounded\", \"positionMode\" ],\n // avoid extending the depricated properties in latest verions of jQuery\n noDepricateExtend = function() {\n var src, copyIsArray, copy, name, options, clone,\n target = arguments[ 0 ] || {},\n i = 1,\n length = arguments.length,\n deep = false;\n\n // Handle a deep copy situation\n if ( typeof target === \"boolean\" ) {\n deep = target;\n\n // skip the boolean and the target\n target = arguments[ i ] || {};\n i++;\n }\n\n // Handle case when target is a string or something (possible in deep copy)\n if ( typeof target !== \"object\" && typeof target !== \"function\") {\n target = {};\n }\n\n // extend jQuery itself if only one argument is passed\n if ( i === length ) {\n target = this;\n i--;\n }\n\n for ( ; i < length; i++ ) {\n\n // Only deal with non-null/undefined values\n if ( ( options = arguments[ i ] ) != null ) {\n\n // Extend the base object\n for ( name in options ) {\n // filters, concat and : properties are depricated in the jQuery 3.3.0\n // accessing these properties throw a warning when jQuery migrate is included\n if (name == \"filters\" || name == \"concat\" || name == \":\") {\n continue;\n }\n src = target[ name ];\n copy = options[ name ];\n\n // Prevent never-ending loop\n if ( target === copy ) {\n continue;\n }\n\n // Recurse if we're merging plain objects or arrays\n if ( deep && copy && ( jQuery.isPlainObject( copy ) ||\n ( copyIsArray = Array.isArray( copy ) ) ) ) {\n\n if ( copyIsArray ) {\n copyIsArray = false;\n clone = src && Array.isArray( src ) ? src : [];\n\n } else {\n clone = src && jQuery.isPlainObject( src ) ? src : {};\n }\n\n // Never move original objects, clone them\n target[ name ] = noDepricateExtend( deep, clone, copy );\n\n // Don't bring in undefined values\n } else if ( copy !== undefined ) {\n target[ name ] = copy;\n }\n }\n }\n }\n\n // Return the modified object\n return target;\n };\n\n kendo.version = \"2022.1.301\".replace(/^\\s+|\\s+$/g, '');\n\n function Class() {}\n\n Class.extend = function(proto) {\n var base = function() {},\n member,\n that = this,\n subclass = proto && proto.init ? proto.init : function () {\n that.apply(this, arguments);\n },\n fn;\n\n base.prototype = that.prototype;\n fn = subclass.fn = subclass.prototype = new base();\n\n for (member in proto) {\n if (proto[member] != null && proto[member].constructor === Object) {\n // Merge object members\n fn[member] = extend(true, {}, base.prototype[member], proto[member]);\n } else {\n fn[member] = proto[member];\n }\n }\n\n fn.constructor = subclass;\n subclass.extend = that.extend;\n\n return subclass;\n };\n\n Class.prototype._initOptions = function(options) {\n this.options = deepExtend({}, this.options, options);\n };\n\n var isFunction = kendo.isFunction = function(fn) {\n return typeof fn === \"function\";\n };\n\n var preventDefault = function() {\n this._defaultPrevented = true;\n };\n\n var isDefaultPrevented = function() {\n return this._defaultPrevented === true;\n };\n\n var Observable = Class.extend({\n init: function() {\n this._events = {};\n },\n\n bind: function(eventName, handlers, one) {\n var that = this,\n idx,\n eventNames = typeof eventName === STRING ? [eventName] : eventName,\n length,\n original,\n handler,\n handlersIsFunction = typeof handlers === FUNCTION,\n events;\n\n if (handlers === undefined) {\n for (idx in eventName) {\n that.bind(idx, eventName[idx]);\n }\n return that;\n }\n\n for (idx = 0, length = eventNames.length; idx < length; idx++) {\n eventName = eventNames[idx];\n\n handler = handlersIsFunction ? handlers : handlers[eventName];\n\n if (handler) {\n if (one) {\n original = handler;\n handler = function() {\n that.unbind(eventName, handler);\n original.apply(that, arguments);\n };\n handler.original = original;\n }\n events = that._events[eventName] = that._events[eventName] || [];\n events.push(handler);\n }\n }\n\n return that;\n },\n\n one: function(eventNames, handlers) {\n return this.bind(eventNames, handlers, true);\n },\n\n first: function(eventName, handlers) {\n var that = this,\n idx,\n eventNames = typeof eventName === STRING ? [eventName] : eventName,\n length,\n handler,\n handlersIsFunction = typeof handlers === FUNCTION,\n events;\n\n for (idx = 0, length = eventNames.length; idx < length; idx++) {\n eventName = eventNames[idx];\n\n handler = handlersIsFunction ? handlers : handlers[eventName];\n\n if (handler) {\n events = that._events[eventName] = that._events[eventName] || [];\n events.unshift(handler);\n }\n }\n\n return that;\n },\n\n trigger: function(eventName, e) {\n var that = this,\n events = that._events[eventName],\n idx,\n length;\n\n if (events) {\n e = e || {};\n\n e.sender = that;\n\n e._defaultPrevented = false;\n\n e.preventDefault = preventDefault;\n\n e.isDefaultPrevented = isDefaultPrevented;\n\n events = events.slice();\n\n for (idx = 0, length = events.length; idx < length; idx++) {\n events[idx].call(that, e);\n }\n\n return e._defaultPrevented === true;\n }\n\n return false;\n },\n\n unbind: function(eventName, handler) {\n var that = this,\n events = that._events[eventName],\n idx;\n\n if (eventName === undefined) {\n that._events = {};\n } else if (events) {\n if (handler) {\n for (idx = events.length - 1; idx >= 0; idx--) {\n if (events[idx] === handler || events[idx].original === handler) {\n events.splice(idx, 1);\n }\n }\n } else {\n that._events[eventName] = [];\n }\n }\n\n return that;\n }\n });\n\n\n function compilePart(part, stringPart) {\n if (stringPart) {\n return \"'\" +\n part.split(\"'\").join(\"\\\\'\")\n .split('\\\\\"').join('\\\\\\\\\\\\\"')\n .replace(/\\n/g, \"\\\\n\")\n .replace(/\\r/g, \"\\\\r\")\n .replace(/\\t/g, \"\\\\t\") + \"'\";\n } else {\n var first = part.charAt(0),\n rest = part.substring(1);\n\n if (first === \"=\") {\n return \"+(\" + rest + \")+\";\n } else if (first === \":\") {\n return \"+$kendoHtmlEncode(\" + rest + \")+\";\n } else {\n return \";\" + part + \";$kendoOutput+=\";\n }\n }\n }\n\n var argumentNameRegExp = /^\\w+/,\n encodeRegExp = /\\$\\{([^}]*)\\}/g,\n escapedCurlyRegExp = /\\\\\\}/g,\n curlyRegExp = /__CURLY__/g,\n escapedSharpRegExp = /\\\\#/g,\n sharpRegExp = /__SHARP__/g,\n zeros = [\"\", \"0\", \"00\", \"000\", \"0000\"];\n\n Template = {\n paramName: \"data\", // name of the parameter of the generated template\n useWithBlock: true, // whether to wrap the template in a with() block\n render: function(template, data) {\n var idx,\n length,\n html = \"\";\n\n for (idx = 0, length = data.length; idx < length; idx++) {\n html += template(data[idx]);\n }\n\n return html;\n },\n compile: function(template, options) {\n var settings = extend({}, this, options),\n paramName = settings.paramName,\n argumentName = paramName.match(argumentNameRegExp)[0],\n useWithBlock = settings.useWithBlock,\n functionBody = \"var $kendoOutput, $kendoHtmlEncode = kendo.htmlEncode;\",\n fn,\n parts,\n idx;\n\n if (isFunction(template)) {\n return template;\n }\n\n functionBody += useWithBlock ? \"with(\" + paramName + \"){\" : \"\";\n\n functionBody += \"$kendoOutput=\";\n\n parts = template\n .replace(escapedCurlyRegExp, \"__CURLY__\")\n .replace(encodeRegExp, \"#=$kendoHtmlEncode($1)#\")\n .replace(curlyRegExp, \"}\")\n .replace(escapedSharpRegExp, \"__SHARP__\")\n .split(\"#\");\n\n for (idx = 0; idx < parts.length; idx ++) {\n functionBody += compilePart(parts[idx], idx % 2 === 0);\n }\n\n functionBody += useWithBlock ? \";}\" : \";\";\n\n functionBody += \"return $kendoOutput;\";\n\n functionBody = functionBody.replace(sharpRegExp, \"#\");\n\n try {\n fn = new Function(argumentName, functionBody);\n fn._slotCount = Math.floor(parts.length / 2);\n return fn;\n } catch(e) {\n throw new Error(kendo.format(\"Invalid template:'{0}' Generated code:'{1}'\", template, functionBody));\n }\n }\n };\n\nfunction pad(number, digits, end) {\n number = number + \"\";\n digits = digits || 2;\n end = digits - number.length;\n\n if (end) {\n return zeros[digits].substring(0, end) + number;\n }\n\n return number;\n}\n\n //JSON stringify\n(function() {\n var escapable = /[\\\\\\\"\\x00-\\x1f\\x7f-\\x9f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,\n gap,\n indent,\n meta = {\n \"\\b\": \"\\\\b\",\n \"\\t\": \"\\\\t\",\n \"\\n\": \"\\\\n\",\n \"\\f\": \"\\\\f\",\n \"\\r\": \"\\\\r\",\n \"\\\"\" : '\\\\\"',\n \"\\\\\": \"\\\\\\\\\"\n },\n rep,\n toString = {}.toString;\n\n\n if (typeof Date.prototype.toJSON !== FUNCTION) {\n\n Date.prototype.toJSON = function () {\n var that = this;\n\n return isFinite(that.valueOf()) ?\n pad(that.getUTCFullYear(), 4) + \"-\" +\n pad(that.getUTCMonth() + 1) + \"-\" +\n pad(that.getUTCDate()) + \"T\" +\n pad(that.getUTCHours()) + \":\" +\n pad(that.getUTCMinutes()) + \":\" +\n pad(that.getUTCSeconds()) + \"Z\" : null;\n };\n\n String.prototype.toJSON = Number.prototype.toJSON = Boolean.prototype.toJSON = function () {\n return this.valueOf();\n };\n }\n\n function quote(string) {\n escapable.lastIndex = 0;\n return escapable.test(string) ? \"\\\"\" + string.replace(escapable, function (a) {\n var c = meta[a];\n return typeof c === STRING ? c :\n \"\\\\u\" + (\"0000\" + a.charCodeAt(0).toString(16)).slice(-4);\n }) + \"\\\"\" : \"\\\"\" + string + \"\\\"\";\n }\n\n function str(key, holder) {\n var i,\n k,\n v,\n length,\n mind = gap,\n partial,\n value = holder[key],\n type;\n\n if (value && typeof value === OBJECT && typeof value.toJSON === FUNCTION) {\n value = value.toJSON(key);\n }\n\n if (typeof rep === FUNCTION) {\n value = rep.call(holder, key, value);\n }\n\n type = typeof value;\n if (type === STRING) {\n return quote(value);\n } else if (type === NUMBER) {\n return isFinite(value) ? String(value) : NULL;\n } else if (type === BOOLEAN || type === NULL) {\n return String(value);\n } else if (type === OBJECT) {\n if (!value) {\n return NULL;\n }\n gap += indent;\n partial = [];\n if (toString.apply(value) === \"[object Array]\") {\n length = value.length;\n for (i = 0; i < length; i++) {\n partial[i] = str(i, value) || NULL;\n }\n v = partial.length === 0 ? \"[]\" : gap ?\n \"[\\n\" + gap + partial.join(\",\\n\" + gap) + \"\\n\" + mind + \"]\" :\n \"[\" + partial.join(\",\") + \"]\";\n gap = mind;\n return v;\n }\n if (rep && typeof rep === OBJECT) {\n length = rep.length;\n for (i = 0; i < length; i++) {\n if (typeof rep[i] === STRING) {\n k = rep[i];\n v = str(k, value);\n if (v) {\n partial.push(quote(k) + (gap ? \": \" : \":\") + v);\n }\n }\n }\n } else {\n for (k in value) {\n if (Object.hasOwnProperty.call(value, k)) {\n v = str(k, value);\n if (v) {\n partial.push(quote(k) + (gap ? \": \" : \":\") + v);\n }\n }\n }\n }\n\n v = partial.length === 0 ? \"{}\" : gap ?\n \"{\\n\" + gap + partial.join(\",\\n\" + gap) + \"\\n\" + mind + \"}\" :\n \"{\" + partial.join(\",\") + \"}\";\n gap = mind;\n return v;\n }\n }\n\n if (typeof JSON.stringify !== FUNCTION) {\n JSON.stringify = function (value, replacer, space) {\n var i;\n gap = \"\";\n indent = \"\";\n\n if (typeof space === NUMBER) {\n for (i = 0; i < space; i += 1) {\n indent += \" \";\n }\n\n } else if (typeof space === STRING) {\n indent = space;\n }\n\n rep = replacer;\n if (replacer && typeof replacer !== FUNCTION && (typeof replacer !== OBJECT || typeof replacer.length !== NUMBER)) {\n throw new Error(\"JSON.stringify\");\n }\n\n return str(\"\", {\"\": value});\n };\n }\n})();\n\n// Date and Number formatting\n(function() {\n var dateFormatRegExp = /dddd|ddd|dd|d|MMMM|MMM|MM|M|yyyy|yy|HH|H|hh|h|mm|m|fff|ff|f|tt|ss|s|zzz|zz|z|\"[^\"]*\"|'[^']*'/g,\n standardFormatRegExp = /^(n|c|p|e)(\\d*)$/i,\n literalRegExp = /(\\\\.)|(['][^']*[']?)|([\"][^\"]*[\"]?)/g,\n commaRegExp = /\\,/g,\n EMPTY = \"\",\n POINT = \".\",\n COMMA = \",\",\n SHARP = \"#\",\n ZERO = \"0\",\n PLACEHOLDER = \"??\",\n EN = \"en-US\",\n objectToString = {}.toString;\n\n //cultures\n kendo.cultures[\"en-US\"] = {\n name: EN,\n numberFormat: {\n pattern: [\"-n\"],\n decimals: 2,\n \",\": \",\",\n \".\": \".\",\n groupSize: [3],\n percent: {\n pattern: [\"-n %\", \"n %\"],\n decimals: 2,\n \",\": \",\",\n \".\": \".\",\n groupSize: [3],\n symbol: \"%\"\n },\n currency: {\n name: \"US Dollar\",\n abbr: \"USD\",\n pattern: [\"($n)\", \"$n\"],\n decimals: 2,\n \",\": \",\",\n \".\": \".\",\n groupSize: [3],\n symbol: \"$\"\n }\n },\n calendars: {\n standard: {\n days: {\n names: [\"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\"],\n namesAbbr: [\"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\"],\n namesShort: [ \"Su\", \"Mo\", \"Tu\", \"We\", \"Th\", \"Fr\", \"Sa\" ]\n },\n months: {\n names: [\"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"],\n namesAbbr: [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"]\n },\n AM: [ \"AM\", \"am\", \"AM\" ],\n PM: [ \"PM\", \"pm\", \"PM\" ],\n patterns: {\n d: \"M/d/yyyy\",\n D: \"dddd, MMMM dd, yyyy\",\n F: \"dddd, MMMM dd, yyyy h:mm:ss tt\",\n g: \"M/d/yyyy h:mm tt\",\n G: \"M/d/yyyy h:mm:ss tt\",\n m: \"MMMM dd\",\n M: \"MMMM dd\",\n s: \"yyyy'-'MM'-'ddTHH':'mm':'ss\",\n t: \"h:mm tt\",\n T: \"h:mm:ss tt\",\n u: \"yyyy'-'MM'-'dd HH':'mm':'ss'Z'\",\n y: \"MMMM, yyyy\",\n Y: \"MMMM, yyyy\"\n },\n \"/\": \"/\",\n \":\": \":\",\n firstDay: 0,\n twoDigitYearMax: 2029\n }\n }\n };\n\n\n function findCulture(culture) {\n if (culture) {\n if (culture.numberFormat) {\n return culture;\n }\n\n if (typeof culture === STRING) {\n var cultures = kendo.cultures;\n return cultures[culture] || cultures[culture.split(\"-\")[0]] || null;\n }\n\n return null;\n }\n\n return null;\n }\n\n function getCulture(culture) {\n if (culture) {\n culture = findCulture(culture);\n }\n\n return culture || kendo.cultures.current;\n }\n\n kendo.culture = function(cultureName) {\n var cultures = kendo.cultures, culture;\n\n if (cultureName !== undefined) {\n culture = findCulture(cultureName) || cultures[EN];\n culture.calendar = culture.calendars.standard;\n cultures.current = culture;\n } else {\n return cultures.current;\n }\n };\n\n kendo.findCulture = findCulture;\n kendo.getCulture = getCulture;\n\n //set current culture to en-US.\n kendo.culture(EN);\n\n function formatDate(date, format, culture) {\n culture = getCulture(culture);\n\n var calendar = culture.calendars.standard,\n days = calendar.days,\n months = calendar.months;\n\n format = calendar.patterns[format] || format;\n\n return format.replace(dateFormatRegExp, function (match) {\n var minutes;\n var result;\n var sign;\n\n if (match === \"d\") {\n result = date.getDate();\n } else if (match === \"dd\") {\n result = pad(date.getDate());\n } else if (match === \"ddd\") {\n result = days.namesAbbr[date.getDay()];\n } else if (match === \"dddd\") {\n result = days.names[date.getDay()];\n } else if (match === \"M\") {\n result = date.getMonth() + 1;\n } else if (match === \"MM\") {\n result = pad(date.getMonth() + 1);\n } else if (match === \"MMM\") {\n result = months.namesAbbr[date.getMonth()];\n } else if (match === \"MMMM\") {\n result = months.names[date.getMonth()];\n } else if (match === \"yy\") {\n result = pad(date.getFullYear() % 100);\n } else if (match === \"yyyy\") {\n result = pad(date.getFullYear(), 4);\n } else if (match === \"h\" ) {\n result = date.getHours() % 12 || 12;\n } else if (match === \"hh\") {\n result = pad(date.getHours() % 12 || 12);\n } else if (match === \"H\") {\n result = date.getHours();\n } else if (match === \"HH\") {\n result = pad(date.getHours());\n } else if (match === \"m\") {\n result = date.getMinutes();\n } else if (match === \"mm\") {\n result = pad(date.getMinutes());\n } else if (match === \"s\") {\n result = date.getSeconds();\n } else if (match === \"ss\") {\n result = pad(date.getSeconds());\n } else if (match === \"f\") {\n result = math.floor(date.getMilliseconds() / 100);\n } else if (match === \"ff\") {\n result = date.getMilliseconds();\n if (result > 99) {\n result = math.floor(result / 10);\n }\n result = pad(result);\n } else if (match === \"fff\") {\n result = pad(date.getMilliseconds(), 3);\n } else if (match === \"tt\") {\n result = date.getHours() < 12 ? calendar.AM[0] : calendar.PM[0];\n } else if (match === \"zzz\") {\n minutes = date.getTimezoneOffset();\n sign = minutes < 0;\n\n result = math.abs(minutes / 60).toString().split(\".\")[0];\n minutes = math.abs(minutes) - (result * 60);\n\n result = (sign ? \"+\" : \"-\") + pad(result);\n result += \":\" + pad(minutes);\n } else if (match === \"zz\" || match === \"z\") {\n result = date.getTimezoneOffset() / 60;\n sign = result < 0;\n\n result = math.abs(result).toString().split(\".\")[0];\n result = (sign ? \"+\" : \"-\") + (match === \"zz\" ? pad(result) : result);\n }\n\n return result !== undefined ? result : match.slice(1, match.length - 1);\n });\n }\n\n //number formatting\n function formatNumber(number, format, culture) {\n culture = getCulture(culture);\n\n var numberFormat = culture.numberFormat,\n decimal = numberFormat[POINT],\n precision = numberFormat.decimals,\n pattern = numberFormat.pattern[0],\n literals = [],\n symbol,\n isCurrency, isPercent,\n customPrecision,\n formatAndPrecision,\n negative = number < 0,\n integer,\n fraction,\n integerLength,\n fractionLength,\n replacement = EMPTY,\n value = EMPTY,\n idx,\n length,\n ch,\n hasGroup,\n hasNegativeFormat,\n decimalIndex,\n sharpIndex,\n zeroIndex,\n hasZero, hasSharp,\n percentIndex,\n currencyIndex,\n startZeroIndex,\n start = -1,\n end;\n\n //return empty string if no number\n if (number === undefined) {\n return EMPTY;\n }\n\n if (!isFinite(number)) {\n return number;\n }\n\n //if no format then return number.toString() or number.toLocaleString() if culture.name is not defined\n if (!format) {\n return culture.name.length ? number.toLocaleString() : number.toString();\n }\n\n formatAndPrecision = standardFormatRegExp.exec(format);\n\n // standard formatting\n if (formatAndPrecision) {\n format = formatAndPrecision[1].toLowerCase();\n\n isCurrency = format === \"c\";\n isPercent = format === \"p\";\n\n if (isCurrency || isPercent) {\n //get specific number format information if format is currency or percent\n numberFormat = isCurrency ? numberFormat.currency : numberFormat.percent;\n decimal = numberFormat[POINT];\n precision = numberFormat.decimals;\n symbol = numberFormat.symbol;\n pattern = numberFormat.pattern[negative ? 0 : 1];\n }\n\n customPrecision = formatAndPrecision[2];\n\n if (customPrecision) {\n precision = +customPrecision;\n }\n\n //return number in exponential format\n if (format === \"e\") {\n var exp = customPrecision ? number.toExponential(precision) : number.toExponential(); // toExponential() and toExponential(undefined) differ in FF #653438.\n\n return exp.replace(POINT, numberFormat[POINT]);\n }\n\n // multiply if format is percent\n if (isPercent) {\n number *= 100;\n }\n\n number = round(number, precision);\n negative = number < 0;\n number = number.split(POINT);\n\n integer = number[0];\n fraction = number[1];\n\n //exclude \"-\" if number is negative.\n if (negative) {\n integer = integer.substring(1);\n }\n\n value = groupInteger(integer, 0, integer.length, numberFormat);\n\n if (fraction) {\n value += decimal + fraction;\n }\n\n if (format === \"n\" && !negative) {\n return value;\n }\n\n number = EMPTY;\n\n for (idx = 0, length = pattern.length; idx < length; idx++) {\n ch = pattern.charAt(idx);\n\n if (ch === \"n\") {\n number += value;\n } else if (ch === \"$\" || ch === \"%\") {\n number += symbol;\n } else {\n number += ch;\n }\n }\n\n return number;\n }\n\n //custom formatting\n //\n //separate format by sections.\n\n if (format.indexOf(\"'\") > -1 || format.indexOf(\"\\\"\") > -1 || format.indexOf(\"\\\\\") > -1) {\n format = format.replace(literalRegExp, function (match) {\n var quoteChar = match.charAt(0).replace(\"\\\\\", \"\"),\n literal = match.slice(1).replace(quoteChar, \"\");\n\n literals.push(literal);\n\n return PLACEHOLDER;\n });\n }\n\n format = format.split(\";\");\n if (negative && format[1]) {\n //get negative format\n format = format[1];\n hasNegativeFormat = true;\n } else if (number === 0 && format[2]) {\n //format for zeros\n format = format[2];\n if (format.indexOf(SHARP) == -1 && format.indexOf(ZERO) == -1) {\n //return format if it is string constant.\n return format;\n }\n } else {\n format = format[0];\n }\n\n percentIndex = format.indexOf(\"%\");\n currencyIndex = format.indexOf(\"$\");\n\n isPercent = percentIndex != -1;\n isCurrency = currencyIndex != -1;\n\n //multiply number if the format has percent\n if (isPercent) {\n number *= 100;\n }\n\n if (isCurrency && format[currencyIndex - 1] === \"\\\\\") {\n format = format.split(\"\\\\\").join(\"\");\n isCurrency = false;\n }\n\n if (isCurrency || isPercent) {\n //get specific number format information if format is currency or percent\n numberFormat = isCurrency ? numberFormat.currency : numberFormat.percent;\n decimal = numberFormat[POINT];\n precision = numberFormat.decimals;\n symbol = numberFormat.symbol;\n }\n\n hasGroup = format.indexOf(COMMA) > -1;\n if (hasGroup) {\n format = format.replace(commaRegExp, EMPTY);\n }\n\n decimalIndex = format.indexOf(POINT);\n length = format.length;\n\n if (decimalIndex != -1) {\n fraction = number.toString().split(\"e\");\n if (fraction[1]) {\n fraction = round(number, Math.abs(fraction[1]));\n } else {\n fraction = fraction[0];\n }\n fraction = fraction.split(POINT)[1] || EMPTY;\n zeroIndex = format.lastIndexOf(ZERO) - decimalIndex;\n sharpIndex = format.lastIndexOf(SHARP) - decimalIndex;\n hasZero = zeroIndex > -1;\n hasSharp = sharpIndex > -1;\n idx = fraction.length;\n\n if (!hasZero && !hasSharp) {\n format = format.substring(0, decimalIndex) + format.substring(decimalIndex + 1);\n length = format.length;\n decimalIndex = -1;\n idx = 0;\n }\n\n if (hasZero && zeroIndex > sharpIndex) {\n idx = zeroIndex;\n } else if (sharpIndex > zeroIndex) {\n if (hasSharp && idx > sharpIndex) {\n var rounded = round(number, sharpIndex, negative);\n\n while (rounded.charAt(rounded.length - 1) === ZERO && sharpIndex > 0 && sharpIndex > zeroIndex) {\n sharpIndex--;\n\n rounded = round(number, sharpIndex, negative);\n }\n\n idx = sharpIndex;\n } else if (hasZero && idx < zeroIndex) {\n idx = zeroIndex;\n }\n }\n }\n\n number = round(number, idx, negative);\n\n sharpIndex = format.indexOf(SHARP);\n startZeroIndex = zeroIndex = format.indexOf(ZERO);\n\n //define the index of the first digit placeholder\n if (sharpIndex == -1 && zeroIndex != -1) {\n start = zeroIndex;\n } else if (sharpIndex != -1 && zeroIndex == -1) {\n start = sharpIndex;\n } else {\n start = sharpIndex > zeroIndex ? zeroIndex : sharpIndex;\n }\n\n sharpIndex = format.lastIndexOf(SHARP);\n zeroIndex = format.lastIndexOf(ZERO);\n\n //define the index of the last digit placeholder\n if (sharpIndex == -1 && zeroIndex != -1) {\n end = zeroIndex;\n } else if (sharpIndex != -1 && zeroIndex == -1) {\n end = sharpIndex;\n } else {\n end = sharpIndex > zeroIndex ? sharpIndex : zeroIndex;\n }\n\n if (start == length) {\n end = start;\n }\n\n if (start != -1) {\n value = number.toString().split(POINT);\n integer = value[0];\n fraction = value[1] || EMPTY;\n\n integerLength = integer.length;\n fractionLength = fraction.length;\n\n if (negative && (number * -1) >= 0) {\n negative = false;\n }\n\n number = format.substring(0, start);\n\n if (negative && !hasNegativeFormat) {\n number += \"-\";\n }\n\n for (idx = start; idx < length; idx++) {\n ch = format.charAt(idx);\n\n if (decimalIndex == -1) {\n if (end - idx < integerLength) {\n number += integer;\n break;\n }\n } else {\n if (zeroIndex != -1 && zeroIndex < idx) {\n replacement = EMPTY;\n }\n\n if ((decimalIndex - idx) <= integerLength && decimalIndex - idx > -1) {\n number += integer;\n idx = decimalIndex;\n }\n\n if (decimalIndex === idx) {\n number += (fraction ? decimal : EMPTY) + fraction;\n idx += end - decimalIndex + 1;\n continue;\n }\n }\n\n if (ch === ZERO) {\n number += ch;\n replacement = ch;\n } else if (ch === SHARP) {\n number += replacement;\n }\n }\n\n if (hasGroup) {\n number = groupInteger(number, start + (negative && !hasNegativeFormat ? 1 : 0), Math.max(end, (integerLength + start)), numberFormat);\n }\n\n if (end >= start) {\n number += format.substring(end + 1);\n }\n\n //replace symbol placeholders\n if (isCurrency || isPercent) {\n value = EMPTY;\n for (idx = 0, length = number.length; idx < length; idx++) {\n ch = number.charAt(idx);\n value += (ch === \"$\" || ch === \"%\") ? symbol : ch;\n }\n number = value;\n }\n\n length = literals.length;\n\n if (length) {\n for (idx = 0; idx < length; idx++) {\n number = number.replace(PLACEHOLDER, literals[idx]);\n }\n }\n }\n\n return number;\n }\n\n var groupInteger = function(number, start, end, numberFormat) {\n var decimalIndex = number.indexOf(numberFormat[POINT]);\n var groupSizes = numberFormat.groupSize.slice();\n var groupSize = groupSizes.shift();\n var integer, integerLength;\n var idx, parts, value;\n var newGroupSize;\n\n end = decimalIndex !== -1 ? decimalIndex : end + 1;\n\n integer = number.substring(start, end);\n integerLength = integer.length;\n\n if (integerLength >= groupSize) {\n idx = integerLength;\n parts = [];\n\n while (idx > -1) {\n value = integer.substring(idx - groupSize, idx);\n if (value) {\n parts.push(value);\n }\n idx -= groupSize;\n newGroupSize = groupSizes.shift();\n groupSize = newGroupSize !== undefined ? newGroupSize : groupSize;\n\n if (groupSize === 0) {\n if (idx > 0) {\n parts.push(integer.substring(0, idx));\n }\n break;\n }\n }\n\n integer = parts.reverse().join(numberFormat[COMMA]);\n number = number.substring(0, start) + integer + number.substring(end);\n }\n\n return number;\n };\n\n var round = function(value, precision, negative) {\n precision = precision || 0;\n\n value = value.toString().split('e');\n value = Math.round(+(value[0] + 'e' + (value[1] ? (+value[1] + precision) : precision)));\n\n if (negative) {\n value = -value;\n }\n\n value = value.toString().split('e');\n value = +(value[0] + 'e' + (value[1] ? (+value[1] - precision) : -precision));\n\n return value.toFixed(Math.min(precision, 20));\n };\n\n var toString = function(value, fmt, culture) {\n if (fmt) {\n if (objectToString.call(value) === \"[object Date]\") {\n return formatDate(value, fmt, culture);\n } else if (typeof value === NUMBER) {\n return formatNumber(value, fmt, culture);\n }\n }\n\n return value !== undefined ? value : \"\";\n };\n\n kendo.format = function(fmt) {\n var values = arguments;\n\n return fmt.replace(formatRegExp, function(match, index, placeholderFormat) {\n var value = values[parseInt(index, 10) + 1];\n\n return toString(value, placeholderFormat ? placeholderFormat.substring(1) : \"\");\n });\n };\n\n kendo._extractFormat = function (format) {\n if (format.slice(0,3) === \"{0:\") {\n format = format.slice(3, format.length - 1);\n }\n\n return format;\n };\n\n kendo._activeElement = function() {\n try {\n return document.activeElement;\n } catch(e) {\n return document.documentElement.activeElement;\n }\n };\n\n kendo._round = round;\n kendo._outerWidth = function (element, includeMargin) { return $(element).outerWidth(includeMargin || false) || 0; };\n kendo._outerHeight = function (element, includeMargin) { return $(element).outerHeight(includeMargin || false) || 0; };\n kendo.toString = toString;\n})();\n\n\n(function() {\n var nonBreakingSpaceRegExp = /\\u00A0/g,\n spaceRegExp = /\\s/g,\n exponentRegExp = /[eE][\\-+]?[0-9]+/,\n shortTimeZoneRegExp = /[+|\\-]\\d{1,2}/,\n longTimeZoneRegExp = /[+|\\-]\\d{1,2}:?\\d{2}/,\n dateRegExp = /^\\/Date\\((.*?)\\)\\/$/,\n offsetRegExp = /[+-]\\d*/,\n FORMATS_SEQUENCE = [ [], [ \"G\", \"g\", \"F\" ], [ \"D\", \"d\", \"y\", \"m\", \"T\", \"t\" ] ],\n STANDARD_FORMATS = [\n [\n \"yyyy-MM-ddTHH:mm:ss.fffffffzzz\",\n \"yyyy-MM-ddTHH:mm:ss.fffffff\",\n \"yyyy-MM-ddTHH:mm:ss.fffzzz\",\n \"yyyy-MM-ddTHH:mm:ss.fff\",\n \"ddd MMM dd yyyy HH:mm:ss\",\n \"yyyy-MM-ddTHH:mm:sszzz\",\n \"yyyy-MM-ddTHH:mmzzz\",\n \"yyyy-MM-ddTHH:mmzz\",\n \"yyyy-MM-ddTHH:mm:ss\",\n \"yyyy-MM-dd HH:mm:ss\",\n \"yyyy/MM/dd HH:mm:ss\"\n ], [\n \"yyyy-MM-ddTHH:mm\",\n \"yyyy-MM-dd HH:mm\",\n \"yyyy/MM/dd HH:mm\"\n ], [\n \"yyyy/MM/dd\",\n \"yyyy-MM-dd\",\n \"HH:mm:ss\",\n \"HH:mm\"\n ]\n ],\n numberRegExp = {\n 2: /^\\d{1,2}/,\n 3: /^\\d{1,3}/,\n 4: /^\\d{4}/\n },\n objectToString = {}.toString;\n\n function outOfRange(value, start, end) {\n return !(value >= start && value <= end);\n }\n\n function designatorPredicate(designator) {\n return designator.charAt(0);\n }\n\n function mapDesignators(designators) {\n return $.map(designators, designatorPredicate);\n }\n\n //if date's day is different than the typed one - adjust\n function adjustDST(date, hours) {\n if (!hours && date.getHours() === 23) {\n date.setHours(date.getHours() + 2);\n }\n }\n\n function lowerArray(data) {\n var idx = 0,\n length = data.length,\n array = [];\n\n for (; idx < length; idx++) {\n array[idx] = (data[idx] + \"\").toLowerCase();\n }\n\n return array;\n }\n\n function lowerLocalInfo(localInfo) {\n var newLocalInfo = {}, property;\n\n for (property in localInfo) {\n newLocalInfo[property] = lowerArray(localInfo[property]);\n }\n\n return newLocalInfo;\n }\n\n function parseExact(value, format, culture, strict) {\n if (!value) {\n return null;\n }\n\n var lookAhead = function (match) {\n var i = 0;\n while (format[idx] === match) {\n i++;\n idx++;\n }\n if (i > 0) {\n idx -= 1;\n }\n return i;\n },\n getNumber = function(size) {\n var rg = numberRegExp[size] || new RegExp('^\\\\d{1,' + size + '}'),\n match = value.substr(valueIdx, size).match(rg);\n\n if (match) {\n match = match[0];\n valueIdx += match.length;\n return parseInt(match, 10);\n }\n return null;\n },\n getIndexByName = function (names, lower) {\n var i = 0,\n length = names.length,\n name, nameLength,\n matchLength = 0,\n matchIdx = 0,\n subValue;\n\n for (; i < length; i++) {\n name = names[i];\n nameLength = name.length;\n subValue = value.substr(valueIdx, nameLength);\n\n if (lower) {\n subValue = subValue.toLowerCase();\n }\n\n if (subValue == name && nameLength > matchLength) {\n matchLength = nameLength;\n matchIdx = i;\n }\n }\n\n if (matchLength) {\n valueIdx += matchLength;\n return matchIdx + 1;\n }\n\n return null;\n },\n checkLiteral = function() {\n var result = false;\n if (value.charAt(valueIdx) === format[idx]) {\n valueIdx++;\n result = true;\n }\n return result;\n },\n calendar = culture.calendars.standard,\n year = null,\n month = null,\n day = null,\n hours = null,\n minutes = null,\n seconds = null,\n milliseconds = null,\n idx = 0,\n valueIdx = 0,\n literal = false,\n date = new Date(),\n twoDigitYearMax = calendar.twoDigitYearMax || 2029,\n defaultYear = date.getFullYear(),\n ch, count, length, pattern,\n pmHour, UTC, matches,\n amDesignators, pmDesignators,\n hoursOffset, minutesOffset,\n hasTime, match;\n\n if (!format) {\n format = \"d\"; //shord date format\n }\n\n //if format is part of the patterns get real format\n pattern = calendar.patterns[format];\n if (pattern) {\n format = pattern;\n }\n\n format = format.split(\"\");\n length = format.length;\n\n for (; idx < length; idx++) {\n ch = format[idx];\n\n if (literal) {\n if (ch === \"'\") {\n literal = false;\n } else {\n checkLiteral();\n }\n } else {\n if (ch === \"d\") {\n count = lookAhead(\"d\");\n if (!calendar._lowerDays) {\n calendar._lowerDays = lowerLocalInfo(calendar.days);\n }\n\n if (day !== null && count > 2) {\n continue;\n }\n\n day = count < 3 ? getNumber(2) : getIndexByName(calendar._lowerDays[count == 3 ? \"namesAbbr\" : \"names\"], true);\n\n if (day === null || outOfRange(day, 1, 31)) {\n return null;\n }\n } else if (ch === \"M\") {\n count = lookAhead(\"M\");\n if (!calendar._lowerMonths) {\n calendar._lowerMonths = lowerLocalInfo(calendar.months);\n }\n month = count < 3 ? getNumber(2) : getIndexByName(calendar._lowerMonths[count == 3 ? 'namesAbbr' : 'names'], true);\n\n if (month === null || outOfRange(month, 1, 12)) {\n return null;\n }\n month -= 1; //because month is zero based\n } else if (ch === \"y\") {\n count = lookAhead(\"y\");\n year = getNumber(count);\n\n if (year === null) {\n return null;\n }\n\n if (count == 2) {\n if (typeof twoDigitYearMax === \"string\") {\n twoDigitYearMax = defaultYear + parseInt(twoDigitYearMax, 10);\n }\n\n year = (defaultYear - defaultYear % 100) + year;\n if (year > twoDigitYearMax) {\n year -= 100;\n }\n }\n } else if (ch === \"h\" ) {\n lookAhead(\"h\");\n hours = getNumber(2);\n if (hours == 12) {\n hours = 0;\n }\n if (hours === null || outOfRange(hours, 0, 11)) {\n return null;\n }\n } else if (ch === \"H\") {\n lookAhead(\"H\");\n hours = getNumber(2);\n if (hours === null || outOfRange(hours, 0, 23)) {\n return null;\n }\n } else if (ch === \"m\") {\n lookAhead(\"m\");\n minutes = getNumber(2);\n if (minutes === null || outOfRange(minutes, 0, 59)) {\n return null;\n }\n } else if (ch === \"s\") {\n lookAhead(\"s\");\n seconds = getNumber(2);\n if (seconds === null || outOfRange(seconds, 0, 59)) {\n return null;\n }\n } else if (ch === \"f\") {\n count = lookAhead(\"f\");\n\n match = value.substr(valueIdx, count).match(numberRegExp[3]);\n milliseconds = getNumber(count); //move value index position\n\n if (milliseconds !== null) {\n milliseconds = parseFloat(\"0.\" + match[0], 10);\n milliseconds = kendo._round(milliseconds, 3);\n milliseconds *= 1000;\n }\n\n if (milliseconds === null || outOfRange(milliseconds, 0, 999)) {\n return null;\n }\n\n } else if (ch === \"t\") {\n count = lookAhead(\"t\");\n amDesignators = calendar.AM;\n pmDesignators = calendar.PM;\n\n if (count === 1) {\n amDesignators = mapDesignators(amDesignators);\n pmDesignators = mapDesignators(pmDesignators);\n }\n\n pmHour = getIndexByName(pmDesignators);\n if (!pmHour && !getIndexByName(amDesignators)) {\n return null;\n }\n }\n else if (ch === \"z\") {\n UTC = true;\n count = lookAhead(\"z\");\n\n if (value.substr(valueIdx, 1) === \"Z\") {\n checkLiteral();\n continue;\n }\n\n matches = value.substr(valueIdx, 6)\n .match(count > 2 ? longTimeZoneRegExp : shortTimeZoneRegExp);\n\n if (!matches) {\n return null;\n }\n\n matches = matches[0].split(\":\");\n\n hoursOffset = matches[0];\n minutesOffset = matches[1];\n\n if (!minutesOffset && hoursOffset.length > 3) { //(+|-)[hh][mm] format is used\n valueIdx = hoursOffset.length - 2;\n minutesOffset = hoursOffset.substring(valueIdx);\n hoursOffset = hoursOffset.substring(0, valueIdx);\n }\n\n hoursOffset = parseInt(hoursOffset, 10);\n if (outOfRange(hoursOffset, -12, 13)) {\n return null;\n }\n\n if (count > 2) {\n minutesOffset = matches[0][0] + minutesOffset;\n minutesOffset = parseInt(minutesOffset, 10);\n if (isNaN(minutesOffset) || outOfRange(minutesOffset, -59, 59)) {\n return null;\n }\n }\n } else if (ch === \"'\") {\n literal = true;\n checkLiteral();\n } else if (!checkLiteral()) {\n return null;\n }\n }\n }\n\n // if more characters follow, assume wrong format\n // https://github.com/telerik/kendo-ui-core/issues/3476\n if (strict && !/^\\s*$/.test(value.substr(valueIdx))) {\n return null;\n }\n\n hasTime = hours !== null || minutes !== null || seconds || null;\n\n if (year === null && month === null && day === null && hasTime) {\n year = defaultYear;\n month = date.getMonth();\n day = date.getDate();\n } else {\n if (year === null) {\n year = defaultYear;\n }\n\n if (day === null) {\n day = 1;\n }\n }\n\n if (pmHour && hours < 12) {\n hours += 12;\n }\n\n if (UTC) {\n if (hoursOffset) {\n hours += -hoursOffset;\n }\n\n if (minutesOffset) {\n minutes += -minutesOffset;\n }\n\n value = new Date(Date.UTC(year, month, day, hours, minutes, seconds, milliseconds));\n } else {\n value = new Date(year, month, day, hours, minutes, seconds, milliseconds);\n adjustDST(value, hours);\n }\n\n if (year < 100) {\n value.setFullYear(year);\n }\n\n if (value.getDate() !== day && UTC === undefined) {\n return null;\n }\n\n return value;\n }\n\n function parseMicrosoftFormatOffset(offset) {\n var sign = offset.substr(0, 1) === \"-\" ? -1 : 1;\n\n offset = offset.substring(1);\n offset = (parseInt(offset.substr(0, 2), 10) * 60) + parseInt(offset.substring(2), 10);\n\n return sign * offset;\n }\n\n function getDefaultFormats(culture) {\n var length = math.max(FORMATS_SEQUENCE.length, STANDARD_FORMATS.length);\n var calendar = culture.calendar || culture.calendars.standard;\n var patterns = calendar.patterns;\n var cultureFormats, formatIdx, idx;\n var formats = [];\n\n for (idx = 0; idx < length; idx++) {\n cultureFormats = FORMATS_SEQUENCE[idx];\n for (formatIdx = 0; formatIdx < cultureFormats.length; formatIdx++) {\n formats.push(patterns[cultureFormats[formatIdx]]);\n }\n formats = formats.concat(STANDARD_FORMATS[idx]);\n }\n\n return formats;\n }\n\n function internalParseDate(value, formats, culture, strict) {\n if (objectToString.call(value) === \"[object Date]\") {\n return value;\n }\n\n var idx = 0;\n var date = null;\n var length;\n var tzoffset;\n\n if (value && value.indexOf(\"/D\") === 0) {\n date = dateRegExp.exec(value);\n if (date) {\n date = date[1];\n tzoffset = offsetRegExp.exec(date.substring(1));\n\n date = new Date(parseInt(date, 10));\n\n if (tzoffset) {\n tzoffset = parseMicrosoftFormatOffset(tzoffset[0]);\n date = kendo.timezone.apply(date, 0);\n date = kendo.timezone.convert(date, 0, -1 * tzoffset);\n }\n\n return date;\n }\n }\n\n culture = kendo.getCulture(culture);\n\n if (!formats) {\n formats = getDefaultFormats(culture);\n }\n\n formats = isArray(formats) ? formats: [formats];\n length = formats.length;\n\n for (; idx < length; idx++) {\n date = parseExact(value, formats[idx], culture, strict);\n if (date) {\n return date;\n }\n }\n\n return date;\n }\n\n kendo.parseDate = function(value, formats, culture) {\n return internalParseDate(value, formats, culture, false);\n };\n\n kendo.parseExactDate = function(value, formats, culture) {\n return internalParseDate(value, formats, culture, true);\n };\n\n kendo.parseInt = function(value, culture) {\n var result = kendo.parseFloat(value, culture);\n if (result) {\n result = result | 0;\n }\n return result;\n };\n\n kendo.parseFloat = function(value, culture, format) {\n if (!value && value !== 0) {\n return null;\n }\n\n if (typeof value === NUMBER) {\n return value;\n }\n\n value = value.toString();\n culture = kendo.getCulture(culture);\n\n var number = culture.numberFormat,\n percent = number.percent,\n currency = number.currency,\n symbol = currency.symbol,\n percentSymbol = percent.symbol,\n negative = value.indexOf(\"-\"),\n parts, isPercent;\n\n //handle exponential number\n if (exponentRegExp.test(value)) {\n value = parseFloat(value.replace(number[\".\"], \".\"));\n if (isNaN(value)) {\n value = null;\n }\n return value;\n }\n\n if (negative > 0) {\n return null;\n } else {\n negative = negative > -1;\n }\n\n if (value.indexOf(symbol) > -1 || (format && format.toLowerCase().indexOf(\"c\") > -1)) {\n number = currency;\n parts = number.pattern[0].replace(\"$\", symbol).split(\"n\");\n if (value.indexOf(parts[0]) > -1 && value.indexOf(parts[1]) > -1) {\n value = value.replace(parts[0], \"\").replace(parts[1], \"\");\n negative = true;\n }\n } else if (value.indexOf(percentSymbol) > -1) {\n isPercent = true;\n number = percent;\n symbol = percentSymbol;\n }\n\n value = value.replace(\"-\", \"\")\n .replace(symbol, \"\")\n .replace(nonBreakingSpaceRegExp, \" \")\n .split(number[\",\"].replace(nonBreakingSpaceRegExp, \" \")).join(\"\")\n .replace(spaceRegExp, \"\")\n .replace(number[\".\"], \".\");\n\n value = parseFloat(value);\n\n if (isNaN(value)) {\n value = null;\n } else if (negative) {\n value *= -1;\n }\n\n if (value && isPercent) {\n value /= 100;\n }\n\n return value;\n };\n})();\n\n function getShadows(element) {\n var shadow = element.css(kendo.support.transitions.css + \"box-shadow\") || element.css(\"box-shadow\"),\n radius = shadow ? shadow.match(boxShadowRegExp) || [ 0, 0, 0, 0, 0 ] : [ 0, 0, 0, 0, 0 ],\n blur = math.max((+radius[3]), +(radius[4] || 0));\n\n return {\n left: (-radius[1]) + blur,\n right: (+radius[1]) + blur,\n bottom: (+radius[2]) + blur\n };\n }\n\n function wrap(element, autosize) {\n var percentage,\n outerWidth = kendo._outerWidth,\n outerHeight = kendo._outerHeight,\n parent = element.parent(),\n windowOuterWidth = outerWidth(window);\n\n parent.removeClass(\"k-animation-container-sm\");\n\n if (!parent.hasClass(\"k-animation-container\")) {\n var width = element[0].style.width,\n height = element[0].style.height,\n percentWidth = percentRegExp.test(width),\n percentHeight = percentRegExp.test(height),\n forceWidth = element.hasClass(\"k-tooltip\") || element.is(\".k-menu-horizontal.k-context-menu\");\n\n percentage = percentWidth || percentHeight;\n\n if (!percentWidth && (!autosize || (autosize && width) || forceWidth)) { width = autosize ? outerWidth(element) + 1 : outerWidth(element); }\n if (!percentHeight && (!autosize || (autosize && height)) || element.is(\".k-menu-horizontal.k-context-menu\")) { height = outerHeight(element); }\n\n element.wrap(\n $(\"
\")\n .addClass(\"k-animation-container\")\n .css({\n width: width,\n height: height\n }));\n parent = element.parent();\n\n if (percentage) {\n element.css({\n width: \"100%\",\n height: \"100%\",\n boxSizing: \"border-box\",\n mozBoxSizing: \"border-box\",\n webkitBoxSizing: \"border-box\"\n });\n }\n } else {\n wrapResize(element, autosize);\n }\n\n if(windowOuterWidth < outerWidth(parent)){\n parent.addClass(\"k-animation-container-sm\");\n\n wrapResize(element, autosize);\n }\n\n return parent;\n }\n\n function wrapResize(element, autosize) {\n var percentage,\n outerWidth = kendo._outerWidth,\n outerHeight = kendo._outerHeight,\n wrapper = element.parent(\".k-animation-container\"),\n wrapperStyle = wrapper[0].style;\n\n if (wrapper.is(\":hidden\")) {\n wrapper.css({\n display: \"\",\n position: \"\"\n });\n }\n\n percentage = percentRegExp.test(wrapperStyle.width) || percentRegExp.test(wrapperStyle.height);\n\n if (!percentage) {\n wrapper.css({\n width: autosize ? outerWidth(element) + 1 : outerWidth(element),\n height: outerHeight(element),\n boxSizing: \"content-box\",\n mozBoxSizing: \"content-box\",\n webkitBoxSizing: \"content-box\"\n });\n }\n }\n\n function deepExtend(destination) {\n var i = 1,\n length = arguments.length;\n\n for (i = 1; i < length; i++) {\n deepExtendOne(destination, arguments[i]);\n }\n\n return destination;\n }\n\n function deepExtendOne(destination, source) {\n var ObservableArray = kendo.data.ObservableArray,\n LazyObservableArray = kendo.data.LazyObservableArray,\n DataSource = kendo.data.DataSource,\n HierarchicalDataSource = kendo.data.HierarchicalDataSource,\n property,\n propValue,\n propType,\n propInit,\n destProp;\n\n for (property in source) {\n propValue = source[property];\n propType = typeof propValue;\n\n if (propType === OBJECT && propValue !== null) {\n propInit = propValue.constructor;\n } else {\n propInit = null;\n }\n\n if (propInit &&\n propInit !== Array && propInit !== ObservableArray && propInit !== LazyObservableArray &&\n propInit !== DataSource && propInit !== HierarchicalDataSource && propInit !== RegExp &&\n (!kendo.isFunction(window.ArrayBuffer) || propInit !== ArrayBuffer)) {\n\n if (propValue instanceof Date) {\n destination[property] = new Date(propValue.getTime());\n } else if (isFunction(propValue.clone)) {\n destination[property] = propValue.clone();\n } else {\n destProp = destination[property];\n if (typeof (destProp) === OBJECT) {\n destination[property] = destProp || {};\n } else {\n destination[property] = {};\n }\n deepExtendOne(destination[property], propValue);\n }\n } else if (propType !== UNDEFINED) {\n destination[property] = propValue;\n }\n }\n\n return destination;\n }\n\n function testRx(agent, rxs, dflt) {\n for (var rx in rxs) {\n if (rxs.hasOwnProperty(rx) && rxs[rx].test(agent)) {\n return rx;\n }\n }\n return dflt !== undefined ? dflt : agent;\n }\n\n function toHyphens(str) {\n return str.replace(/([a-z][A-Z])/g, function (g) {\n return g.charAt(0) + '-' + g.charAt(1).toLowerCase();\n });\n }\n\n function toCamelCase(str) {\n return str.replace(/\\-(\\w)/g, function (strMatch, g1) {\n return g1.toUpperCase();\n });\n }\n\n function getComputedStyles(element, properties) {\n var styles = {}, computedStyle;\n\n if (document.defaultView && document.defaultView.getComputedStyle) {\n computedStyle = document.defaultView.getComputedStyle(element, \"\");\n\n if (properties) {\n $.each(properties, function(idx, value) {\n styles[value] = computedStyle.getPropertyValue(value);\n });\n }\n } else {\n computedStyle = element.currentStyle;\n\n if (properties) {\n $.each(properties, function(idx, value) {\n styles[value] = computedStyle[toCamelCase(value)];\n });\n }\n }\n\n if (!kendo.size(styles)) {\n styles = computedStyle;\n }\n\n return styles;\n }\n\n function isScrollable(element) {\n if (element && element.className && typeof(element.className) === \"string\" && element.className.indexOf(\"k-auto-scrollable\") > -1) {\n return true;\n }\n\n var overflow = getComputedStyles(element, [\"overflow\"]).overflow;\n return overflow.indexOf(\"auto\") > -1 || overflow.indexOf(\"scroll\") > -1;\n }\n\n function scrollLeft(element, value) {\n var webkit = support.browser.webkit;\n var mozila = support.browser.mozilla;\n var browserVersion = support.browser.version;\n var el, isRtl;\n\n if(element instanceof $ && value !== undefined) {\n element.each(function(i, e) {\n scrollLeft(e, value);\n });\n\n return;\n } else {\n el = element instanceof $ ? element[0] : element;\n }\n\n if (!el) {\n return;\n }\n\n isRtl = support.isRtl(element);\n\n // After updating browser detection,\n // Test in which if should the Safari browsers go\n if (value !== undefined) {\n if (isRtl && webkit && (browserVersion < 85 || support.browser.safari)) {\n el.scrollLeft = el.scrollWidth - el.clientWidth - value;\n } else if (isRtl && (mozila || webkit) && value > 0) {\n el.scrollLeft = -value;\n } else {\n el.scrollLeft = value;\n }\n } else {\n if (isRtl && webkit && (browserVersion < 85 || support.browser.safari)) {\n return el.scrollWidth - el.clientWidth - el.scrollLeft;\n } else {\n return Math.abs(el.scrollLeft);\n }\n }\n }\n\n (function () {\n support._scrollbar = undefined;\n\n support.scrollbar = function (refresh) {\n if (!isNaN(support._scrollbar) && !refresh) {\n return support._scrollbar;\n } else {\n var div = document.createElement(\"div\"),\n result;\n\n div.style.cssText = \"overflow:scroll;overflow-x:hidden;zoom:1;clear:both;display:block\";\n div.innerHTML = \" \";\n document.body.appendChild(div);\n\n support._scrollbar = result = div.offsetWidth - div.scrollWidth;\n\n document.body.removeChild(div);\n\n return result;\n }\n };\n\n support.isRtl = function(element) {\n return $(element).closest(\".k-rtl\").length > 0;\n };\n\n var table = document.createElement(\"table\");\n\n // Internet Explorer does not support setting the innerHTML of TBODY and TABLE elements\n try {\n table.innerHTML = \"\";\n\n support.tbodyInnerHtml = true;\n } catch (e) {\n support.tbodyInnerHtml = false;\n }\n\n support.touch = \"ontouchstart\" in window;\n\n var docStyle = document.documentElement.style;\n var transitions = support.transitions = false,\n transforms = support.transforms = false,\n elementProto = \"HTMLElement\" in window ? HTMLElement.prototype : [];\n\n support.hasHW3D = (\"WebKitCSSMatrix\" in window && \"m11\" in new window.WebKitCSSMatrix()) || \"MozPerspective\" in docStyle || \"msPerspective\" in docStyle;\n support.cssFlexbox = (\"flexWrap\" in docStyle) || (\"WebkitFlexWrap\" in docStyle) || (\"msFlexWrap\" in docStyle);\n\n each([ \"Moz\", \"webkit\", \"O\", \"ms\" ], function () {\n var prefix = this.toString(),\n hasTransitions = typeof table.style[prefix + \"Transition\"] === STRING;\n\n if (hasTransitions || typeof table.style[prefix + \"Transform\"] === STRING) {\n var lowPrefix = prefix.toLowerCase();\n\n transforms = {\n css: (lowPrefix != \"ms\") ? \"-\" + lowPrefix + \"-\" : \"\",\n prefix: prefix,\n event: (lowPrefix === \"o\" || lowPrefix === \"webkit\") ? lowPrefix : \"\"\n };\n\n if (hasTransitions) {\n transitions = transforms;\n transitions.event = transitions.event ? transitions.event + \"TransitionEnd\" : \"transitionend\";\n }\n\n return false;\n }\n });\n\n table = null;\n\n support.transforms = transforms;\n support.transitions = transitions;\n\n support.devicePixelRatio = window.devicePixelRatio === undefined ? 1 : window.devicePixelRatio;\n\n try {\n support.screenWidth = window.outerWidth || window.screen ? window.screen.availWidth : window.innerWidth;\n support.screenHeight = window.outerHeight || window.screen ? window.screen.availHeight : window.innerHeight;\n } catch(e) {\n //window.outerWidth throws error when in IE showModalDialog.\n support.screenWidth = window.screen.availWidth;\n support.screenHeight = window.screen.availHeight;\n }\n\n support.detectOS = function (ua) {\n var os = false, minorVersion, match = [],\n notAndroidPhone = !/mobile safari/i.test(ua),\n agentRxs = {\n wp: /(Windows Phone(?: OS)?)\\s(\\d+)\\.(\\d+(\\.\\d+)?)/,\n fire: /(Silk)\\/(\\d+)\\.(\\d+(\\.\\d+)?)/,\n android: /(Android|Android.*(?:Opera|Firefox).*?\\/)\\s*(\\d+)\\.?(\\d+(\\.\\d+)?)?/,\n iphone: /(iPhone|iPod).*OS\\s+(\\d+)[\\._]([\\d\\._]+)/,\n ipad: /(iPad).*OS\\s+(\\d+)[\\._]([\\d_]+)/,\n meego: /(MeeGo).+NokiaBrowser\\/(\\d+)\\.([\\d\\._]+)/,\n webos: /(webOS)\\/(\\d+)\\.(\\d+(\\.\\d+)?)/,\n blackberry: /(BlackBerry|BB10).*?Version\\/(\\d+)\\.(\\d+(\\.\\d+)?)/,\n playbook: /(PlayBook).*?Tablet\\s*OS\\s*(\\d+)\\.(\\d+(\\.\\d+)?)/,\n windows: /(MSIE)\\s+(\\d+)\\.(\\d+(\\.\\d+)?)/,\n tizen: /(tizen).*?Version\\/(\\d+)\\.(\\d+(\\.\\d+)?)/i,\n sailfish: /(sailfish).*rv:(\\d+)\\.(\\d+(\\.\\d+)?).*firefox/i,\n ffos: /(Mobile).*rv:(\\d+)\\.(\\d+(\\.\\d+)?).*Firefox/\n },\n osRxs = {\n ios: /^i(phone|pad|pod)$/i,\n android: /^android|fire$/i,\n blackberry: /^blackberry|playbook/i,\n windows: /windows/,\n wp: /wp/,\n flat: /sailfish|ffos|tizen/i,\n meego: /meego/\n },\n formFactorRxs = {\n tablet: /playbook|ipad|fire/i\n },\n browserRxs = {\n omini: /Opera\\sMini/i,\n omobile: /Opera\\sMobi/i,\n firefox: /Firefox|Fennec/i,\n mobilesafari: /version\\/.*safari/i,\n ie: /MSIE|Windows\\sPhone/i,\n chrome: /chrome|crios/i,\n webkit: /webkit/i\n };\n\n for (var agent in agentRxs) {\n if (agentRxs.hasOwnProperty(agent)) {\n match = ua.match(agentRxs[agent]);\n if (match) {\n if (agent == \"windows\" && \"plugins\" in navigator) { return false; } // Break if not Metro/Mobile Windows\n\n os = {};\n os.device = agent;\n os.tablet = testRx(agent, formFactorRxs, false);\n os.browser = testRx(ua, browserRxs, \"default\");\n os.name = testRx(agent, osRxs);\n os[os.name] = true;\n os.majorVersion = match[2];\n os.minorVersion = (match[3] || \"0\").replace(\"_\", \".\");\n minorVersion = os.minorVersion.replace(\".\", \"\").substr(0, 2);\n os.flatVersion = os.majorVersion + minorVersion + (new Array(3 - (minorVersion.length < 3 ? minorVersion.length : 2)).join(\"0\"));\n os.cordova = typeof window.PhoneGap !== UNDEFINED || typeof window.cordova !== UNDEFINED; // Use file protocol to detect appModes.\n os.appMode = window.navigator.standalone || (/file|local|wmapp/).test(window.location.protocol) || os.cordova; // Use file protocol to detect appModes.\n\n if (os.android && (support.devicePixelRatio < 1.5 && os.flatVersion < 400 || notAndroidPhone) && (support.screenWidth > 800 || support.screenHeight > 800)) {\n os.tablet = agent;\n }\n\n break;\n }\n }\n }\n return os;\n };\n\n var mobileOS = support.mobileOS = support.detectOS(navigator.userAgent);\n\n support.wpDevicePixelRatio = mobileOS.wp ? screen.width / 320 : 0;\n\n support.hasNativeScrolling = false;\n\n if (mobileOS.ios || (mobileOS.android && mobileOS.majorVersion > 2) || mobileOS.wp) {\n support.hasNativeScrolling = mobileOS;\n }\n\n support.delayedClick = function() {\n\n // only the mobile devices with touch events do this.\n if (support.touch) {\n // All iOS devices so far (by the time I am writing this, iOS 9.0.2 is the latest),\n // delay their click events.\n if (mobileOS.ios) {\n return true;\n }\n\n if (mobileOS.android) {\n\n if (!support.browser.chrome) { // older webkits and webviews delay the click\n return true;\n }\n\n // from here on, we deal with Chrome on Android.\n if (support.browser.version < 32) {\n return false;\n }\n\n // Chrome 32+ does conditional fast clicks if the view port is not user scalable.\n return !($(\"meta[name=viewport]\").attr(\"content\") || \"\").match(/user-scalable=no/i);\n }\n }\n\n return false;\n };\n\n support.mouseAndTouchPresent = support.touch && !(support.mobileOS.ios || support.mobileOS.android);\n\n support.detectBrowser = function(ua) {\n var browser = false,\n match = [],\n chromiumEdgeMatch = [],\n browserRxs = {\n edge: /(edge)[ \\/]([\\w.]+)/i,\n webkit: /(chrome|crios)[ \\/]([\\w.]+)/i,\n safari: /(webkit)[ \\/]([\\w.]+)/i,\n opera: /(opera)(?:.*version|)[ \\/]([\\w.]+)/i,\n msie: /(msie\\s|trident.*? rv:)([\\w.]+)/i,\n mozilla: /(mozilla)(?:.*? rv:([\\w.]+)|)/i\n };\n\n for (var agent in browserRxs) {\n if (browserRxs.hasOwnProperty(agent)) {\n match = ua.match(browserRxs[agent]);\n if (match) {\n browser = {};\n browser[agent] = true;\n browser[match[1].toLowerCase().split(\" \")[0].split(\"/\")[0]] = true;\n browser.version = parseInt(document.documentMode || match[2], 10);\n\n if (browser.chrome) {\n chromiumEdgeMatch = ua.match(/(edg)[ \\/]([\\w.]+)/i);\n\n if(chromiumEdgeMatch) {\n browser.chromiumEdge = true;\n }\n }\n\n break;\n }\n }\n }\n\n return browser;\n };\n\n support.browser = support.detectBrowser(navigator.userAgent);\n\n if (!mobileOS && support.touch && support.browser.safari) {\n mobileOS = support.mobileOS = {\n ios: true,\n tablet: \"tablet\",\n device: \"ipad\"\n };\n }\n\n support.detectClipboardAccess = function() {\n var commands = {\n copy: document.queryCommandSupported ? document.queryCommandSupported(\"copy\") : false,\n cut: document.queryCommandSupported ? document.queryCommandSupported(\"cut\") : false,\n paste : document.queryCommandSupported ? document.queryCommandSupported(\"paste\") : false\n };\n\n if (support.browser.chrome) {\n //not using queryCommandSupported due to chromium issues 476508 and 542948\n commands.paste = false;\n if(support.browser.version >= 43) {\n commands.copy = true;\n commands.cut = true;\n }\n }\n\n return commands;\n };\n\n support.clipboard = support.detectClipboardAccess();\n\n support.zoomLevel = function() {\n try {\n var browser = support.browser;\n var ie11WidthCorrection = 0;\n var docEl = document.documentElement;\n\n if (browser.msie && browser.version == 11 && docEl.scrollHeight > docEl.clientHeight && !support.touch) {\n ie11WidthCorrection = support.scrollbar();\n }\n\n return support.touch ? (docEl.clientWidth / window.innerWidth) :\n browser.msie && browser.version >= 10 ? (((top || window).document.documentElement.offsetWidth + ie11WidthCorrection) / (top || window).innerWidth) : 1;\n } catch(e) {\n return 1;\n }\n };\n\n (function(browser) {\n // add browser-specific CSS class\n var cssClass = \"\",\n docElement = $(document.documentElement),\n majorVersion = parseInt(browser.version, 10);\n\n if (browser.msie) {\n cssClass = \"ie\";\n } else if (browser.mozilla) {\n cssClass = \"ff\";\n } else if (browser.safari) {\n cssClass = \"safari\";\n } else if (browser.webkit) {\n cssClass = \"webkit\";\n } else if (browser.opera) {\n cssClass = \"opera\";\n } else if (browser.edge) {\n cssClass = \"edge\";\n }\n\n if (cssClass) {\n cssClass = \"k-\" + cssClass + \" k-\" + cssClass + majorVersion;\n }\n if (support.mobileOS) {\n cssClass += \" k-mobile\";\n }\n\n if (!support.cssFlexbox) {\n cssClass += \" k-no-flexbox\";\n }\n\n docElement.addClass(cssClass);\n })(support.browser);\n\n support.eventCapture = document.documentElement.addEventListener;\n\n var input = document.createElement(\"input\");\n\n support.placeholder = \"placeholder\" in input;\n support.propertyChangeEvent = \"onpropertychange\" in input;\n\n support.input = (function() {\n var types = [\"number\", \"date\", \"time\", \"month\", \"week\", \"datetime\", \"datetime-local\"];\n var length = types.length;\n var value = \"test\";\n var result = {};\n var idx = 0;\n var type;\n\n for (;idx < length; idx++) {\n type = types[idx];\n input.setAttribute(\"type\", type);\n input.value = value;\n\n result[type.replace(\"-\", \"\")] = input.type !== \"text\" && input.value !== value;\n }\n\n return result;\n })();\n\n input.style.cssText = \"float:left;\";\n\n support.cssFloat = !!input.style.cssFloat;\n\n input = null;\n\n support.stableSort = (function() {\n // Chrome sort is not stable for more than *10* items\n // IE9+ sort is not stable for than *512* items\n var threshold = 513;\n\n var sorted = [{\n index: 0,\n field: \"b\"\n }];\n\n for (var i = 1; i < threshold; i++) {\n sorted.push({\n index: i,\n field: \"a\"\n });\n }\n\n sorted.sort(function(a, b) {\n return a.field > b.field ? 1 : (a.field < b.field ? -1 : 0);\n });\n\n return sorted[0].index === 1;\n })();\n\n support.matchesSelector = elementProto.webkitMatchesSelector || elementProto.mozMatchesSelector ||\n elementProto.msMatchesSelector || elementProto.oMatchesSelector ||\n elementProto.matchesSelector || elementProto.matches ||\n function( selector ) {\n var nodeList = document.querySelectorAll ? ( this.parentNode || document ).querySelectorAll( selector ) || [] : $(selector),\n i = nodeList.length;\n\n while (i--) {\n if (nodeList[i] == this) {\n return true;\n }\n }\n\n return false;\n };\n\n support.matchMedia = \"matchMedia\" in window;\n\n support.pushState = window.history && window.history.pushState;\n\n support.hashChange = \"onhashchange\" in window;\n\n support.customElements = \"registerElement\" in window.document;\n\n var chrome = support.browser.chrome,\n mobileChrome = support.browser.crios,\n mozilla = support.browser.mozilla,\n safari = support.browser.safari;\n support.msPointers = !chrome && window.MSPointerEvent;\n support.pointers = !chrome && !mobileChrome && !mozilla && !safari && window.PointerEvent;\n support.kineticScrollNeeded = mobileOS && (support.touch || support.msPointers || support.pointers);\n })();\n\n\n function size(obj) {\n var result = 0, key;\n for (key in obj) {\n if (obj.hasOwnProperty(key) && key != \"toJSON\") { // Ignore fake IE7 toJSON.\n result++;\n }\n }\n\n return result;\n }\n\n function getOffset(element, type, positioned) {\n if (!type) {\n type = \"offset\";\n }\n\n var offset = element[type]();\n // clone ClientRect object to JS object (jQuery3)\n var result = {\n top: offset.top,\n right: offset.right,\n bottom: offset.bottom,\n left: offset.left\n };\n\n // IE10 touch zoom is living in a separate viewport\n if (support.browser.msie && (support.pointers || support.msPointers) && !positioned) {\n var sign = support.isRtl(element) ? 1 : -1;\n\n result.top -= (window.pageYOffset - (document.documentElement.scrollTop));\n result.left -= (window.pageXOffset + (sign * document.documentElement.scrollLeft));\n }\n\n return result;\n }\n\n var directions = {\n left: { reverse: \"right\" },\n right: { reverse: \"left\" },\n down: { reverse: \"up\" },\n up: { reverse: \"down\" },\n top: { reverse: \"bottom\" },\n bottom: { reverse: \"top\" },\n \"in\": { reverse: \"out\" },\n out: { reverse: \"in\" }\n };\n\n function parseEffects(input) {\n var effects = {};\n\n each((typeof input === \"string\" ? input.split(\" \") : input), function(idx) {\n effects[idx] = this;\n });\n\n return effects;\n }\n\n function fx(element) {\n return new kendo.effects.Element(element);\n }\n\n var effects = {};\n\n $.extend(effects, {\n enabled: true,\n Element: function(element) {\n this.element = $(element);\n },\n\n promise: function(element, options) {\n if (!element.is(\":visible\")) {\n element.css({ display: element.data(\"olddisplay\") || \"block\" }).css(\"display\");\n }\n\n if (options.hide) {\n element.data(\"olddisplay\", element.css(\"display\")).hide();\n }\n\n if (options.init) {\n options.init();\n }\n\n if (options.completeCallback) {\n options.completeCallback(element); // call the external complete callback with the element\n }\n\n element.dequeue();\n },\n\n disable: function() {\n this.enabled = false;\n this.promise = this.promiseShim;\n },\n\n enable: function() {\n this.enabled = true;\n this.promise = this.animatedPromise;\n }\n });\n\n effects.promiseShim = effects.promise;\n\n function prepareAnimationOptions(options, duration, reverse, complete) {\n if (typeof options === STRING) {\n // options is the list of effect names separated by space e.g. animate(element, \"fadeIn slideDown\")\n\n // only callback is provided e.g. animate(element, options, function() {});\n if (isFunction(duration)) {\n complete = duration;\n duration = 400;\n reverse = false;\n }\n\n if (isFunction(reverse)) {\n complete = reverse;\n reverse = false;\n }\n\n if (typeof duration === BOOLEAN){\n reverse = duration;\n duration = 400;\n }\n\n options = {\n effects: options,\n duration: duration,\n reverse: reverse,\n complete: complete\n };\n }\n\n return extend({\n //default options\n effects: {},\n duration: 400, //jQuery default duration\n reverse: false,\n init: noop,\n teardown: noop,\n hide: false\n }, options, { completeCallback: options.complete, complete: noop }); // Move external complete callback, so deferred.resolve can be always executed.\n\n }\n\n function animate(element, options, duration, reverse, complete) {\n var idx = 0,\n length = element.length,\n instance;\n\n for (; idx < length; idx ++) {\n instance = $(element[idx]);\n instance.queue(function() {\n effects.promise(instance, prepareAnimationOptions(options, duration, reverse, complete));\n });\n }\n\n return element;\n }\n\n function toggleClass(element, classes, options, add) {\n if (classes) {\n classes = classes.split(\" \");\n\n each(classes, function(idx, value) {\n element.toggleClass(value, add);\n });\n }\n\n return element;\n }\n\n if (!(\"kendoAnimate\" in $.fn)) {\n extend($.fn, {\n kendoStop: function(clearQueue, gotoEnd) {\n return this.stop(clearQueue, gotoEnd);\n },\n\n kendoAnimate: function(options, duration, reverse, complete) {\n return animate(this, options, duration, reverse, complete);\n },\n\n kendoAddClass: function(classes, options){\n return kendo.toggleClass(this, classes, options, true);\n },\n\n kendoRemoveClass: function(classes, options){\n return kendo.toggleClass(this, classes, options, false);\n },\n kendoToggleClass: function(classes, options, toggle){\n return kendo.toggleClass(this, classes, options, toggle);\n }\n });\n }\n\n var ampRegExp = /&/g,\n ltRegExp = //g;\n function htmlEncode(value) {\n return (\"\" + value).replace(ampRegExp, \"&\").replace(ltRegExp, \"<\").replace(gtRegExp, \">\").replace(quoteRegExp, \""\").replace(aposRegExp, \"'\");\n }\n\n function unescape(value) {\n var template;\n\n try {\n template = window.decodeURIComponent(value);\n } catch(error) {\n // If the string contains Unicode characters\n // the decodeURIComponent() will throw an error.\n // Therefore: convert to UTF-8 character\n template = value.replace(/%u([\\dA-F]{4})|%([\\dA-F]{2})/gi, function(_, m1, m2) {\n return String.fromCharCode(parseInt(\"0x\" + (m1 || m2), 16));\n });\n }\n\n return template;\n }\n\n var eventTarget = function (e) {\n return e.target;\n };\n\n if (support.touch) {\n\n eventTarget = function(e) {\n var touches = \"originalEvent\" in e ? e.originalEvent.changedTouches : \"changedTouches\" in e ? e.changedTouches : null;\n\n return touches ? document.elementFromPoint(touches[0].clientX, touches[0].clientY) : e.target;\n };\n\n each([\"swipe\", \"swipeLeft\", \"swipeRight\", \"swipeUp\", \"swipeDown\", \"doubleTap\", \"tap\"], function(m, value) {\n $.fn[value] = function(callback) {\n return this.on(value, callback);\n };\n });\n }\n\n if (support.touch) {\n if (!support.mobileOS) {\n support.mousedown = \"mousedown touchstart\";\n support.mouseup = \"mouseup touchend\";\n support.mousemove = \"mousemove touchmove\";\n support.mousecancel = \"mouseleave touchcancel\";\n support.click = \"click\";\n support.resize = \"resize\";\n } else {\n support.mousedown = \"touchstart\";\n support.mouseup = \"touchend\";\n support.mousemove = \"touchmove\";\n support.mousecancel = \"touchcancel\";\n support.click = \"touchend\";\n support.resize = \"orientationchange\";\n }\n } else if (support.pointers) {\n support.mousemove = \"pointermove\";\n support.mousedown = \"pointerdown\";\n support.mouseup = \"pointerup\";\n support.mousecancel = \"pointercancel\";\n support.click = \"pointerup\";\n support.resize = \"orientationchange resize\";\n } else if (support.msPointers) {\n support.mousemove = \"MSPointerMove\";\n support.mousedown = \"MSPointerDown\";\n support.mouseup = \"MSPointerUp\";\n support.mousecancel = \"MSPointerCancel\";\n support.click = \"MSPointerUp\";\n support.resize = \"orientationchange resize\";\n } else {\n support.mousemove = \"mousemove\";\n support.mousedown = \"mousedown\";\n support.mouseup = \"mouseup\";\n support.mousecancel = \"mouseleave\";\n support.click = \"click\";\n support.resize = \"resize\";\n }\n\n var wrapExpression = function(members, paramName) {\n var result = paramName || \"d\",\n index,\n idx,\n length,\n member,\n count = 1;\n\n for (idx = 0, length = members.length; idx < length; idx++) {\n member = members[idx];\n if (member !== \"\") {\n index = member.indexOf(\"[\");\n\n if (index !== 0) {\n if (index == -1) {\n member = \".\" + member;\n } else {\n count++;\n member = \".\" + member.substring(0, index) + \" || {})\" + member.substring(index);\n }\n }\n\n count++;\n result += member + ((idx < length - 1) ? \" || {})\" : \")\");\n }\n }\n return new Array(count).join(\"(\") + result;\n },\n localUrlRe = /^([a-z]+:)?\\/\\//i;\n\n extend(kendo, {\n widgets: [],\n _widgetRegisteredCallbacks: [],\n ui: kendo.ui || {},\n fx: kendo.fx || fx,\n effects: kendo.effects || effects,\n mobile: kendo.mobile || { },\n data: kendo.data || {},\n dataviz: kendo.dataviz || {},\n drawing: kendo.drawing || {},\n spreadsheet: { messages: {} },\n keys: {\n INSERT: 45,\n DELETE: 46,\n BACKSPACE: 8,\n TAB: 9,\n ENTER: 13,\n ESC: 27,\n LEFT: 37,\n UP: 38,\n RIGHT: 39,\n DOWN: 40,\n END: 35,\n HOME: 36,\n SPACEBAR: 32,\n PAGEUP: 33,\n PAGEDOWN: 34,\n F2: 113,\n F10: 121,\n F12: 123,\n NUMPAD_PLUS: 107,\n NUMPAD_MINUS: 109,\n NUMPAD_DOT: 110\n },\n support: kendo.support || support,\n animate: kendo.animate || animate,\n ns: \"\",\n attr: function(value) {\n return \"data-\" + kendo.ns + value;\n },\n getShadows: getShadows,\n wrap: wrap,\n deepExtend: deepExtend,\n getComputedStyles: getComputedStyles,\n isScrollable: isScrollable,\n scrollLeft: scrollLeft,\n size: size,\n toCamelCase: toCamelCase,\n toHyphens: toHyphens,\n getOffset: kendo.getOffset || getOffset,\n parseEffects: kendo.parseEffects || parseEffects,\n toggleClass: kendo.toggleClass || toggleClass,\n directions: kendo.directions || directions,\n Observable: Observable,\n Class: Class,\n Template: Template,\n template: proxy(Template.compile, Template),\n render: proxy(Template.render, Template),\n stringify: proxy(JSON.stringify, JSON),\n eventTarget: eventTarget,\n htmlEncode: htmlEncode,\n unescape: unescape,\n isLocalUrl: function(url) {\n return url && !localUrlRe.test(url);\n },\n\n expr: function(expression, safe, paramName) {\n expression = expression || \"\";\n\n if (typeof safe == STRING) {\n paramName = safe;\n safe = false;\n }\n\n paramName = paramName || \"d\";\n\n if (expression && expression.charAt(0) !== \"[\") {\n expression = \".\" + expression;\n }\n\n if (safe) {\n expression = expression.replace(/\"([^.]*)\\.([^\"]*)\"/g,'\"$1_$DOT$_$2\"');\n expression = expression.replace(/'([^.]*)\\.([^']*)'/g,\"'$1_$DOT$_$2'\");\n expression = wrapExpression(expression.split(\".\"), paramName);\n expression = expression.replace(/_\\$DOT\\$_/g, \".\");\n } else {\n expression = paramName + expression;\n }\n\n return expression;\n },\n\n getter: function(expression, safe) {\n var key = expression + safe;\n return getterCache[key] = getterCache[key] || new Function(\"d\", \"return \" + kendo.expr(expression, safe));\n },\n\n setter: function(expression) {\n return setterCache[expression] = setterCache[expression] || new Function(\"d,value\", kendo.expr(expression) + \"=value\");\n },\n\n accessor: function(expression) {\n return {\n get: kendo.getter(expression),\n set: kendo.setter(expression)\n };\n },\n\n guid: function() {\n var id = \"\", i, random, chars = \"abcdef\";\n\n id += chars[Math.floor(Math.random() * Math.floor(chars.length))];\n\n for (i = 1; i < 32; i++) {\n random = math.random() * 16 | 0;\n\n if (i == 8 || i == 12 || i == 16 || i == 20) {\n id += \"-\";\n }\n id += (i == 12 ? 4 : (i == 16 ? (random & 3 | 8) : random)).toString(16);\n }\n\n return id;\n },\n\n roleSelector: function(role) {\n return role.replace(/(\\S+)/g, \"[\" + kendo.attr(\"role\") + \"=$1],\").slice(0, -1);\n },\n\n directiveSelector: function(directives) {\n var selectors = directives.split(\" \");\n\n if (selectors) {\n for (var i = 0; i < selectors.length; i++) {\n if (selectors[i] != \"view\") {\n selectors[i] = selectors[i].replace(/(\\w*)(view|bar|strip|over)$/, \"$1-$2\");\n }\n }\n }\n\n return selectors.join(\" \").replace(/(\\S+)/g, \"kendo-mobile-$1,\").slice(0, -1);\n },\n\n triggeredByInput: function(e) {\n return (/^(label|input|textarea|select)$/i).test(e.target.tagName);\n },\n\n onWidgetRegistered: function(callback) {\n for (var i = 0, len = kendo.widgets.length; i < len; i++) {\n callback(kendo.widgets[i]);\n }\n\n kendo._widgetRegisteredCallbacks.push(callback);\n },\n\n logToConsole: function(message, type) {\n var console = window.console;\n\n if (!kendo.suppressLog && typeof(console) != \"undefined\" && console.log) {\n console[type || \"log\"](message);\n }\n }\n });\n\n var Widget = Observable.extend( {\n init: function(element, options) {\n var that = this;\n\n that.element = kendo.jQuery(element).handler(that);\n\n that.angular(\"init\", options);\n\n Observable.fn.init.call(that);\n\n var dataSource = options ? options.dataSource : null;\n var props;\n\n if (options) {\n props = (that.componentTypes || {})[(options || {}).componentType];\n }\n\n if (dataSource) {\n // avoid deep cloning the data source\n options = extend({}, options, { dataSource: {} });\n }\n\n options = that.options = extend(true, {}, that.options, that.defaults, props || {}, options);\n\n if (dataSource) {\n options.dataSource = dataSource;\n }\n\n if (!that.element.attr(kendo.attr(\"role\"))) {\n that.element.attr(kendo.attr(\"role\"), (options.name || \"\").toLowerCase());\n }\n\n that.element.data(\"kendo\" + options.prefix + options.name, that);\n\n that.bind(that.events, options);\n },\n\n events: [],\n\n options: {\n prefix: \"\"\n },\n\n _hasBindingTarget: function() {\n return !!this.element[0].kendoBindingTarget;\n },\n\n _tabindex: function(target) {\n target = target || this.wrapper;\n\n var element = this.element,\n TABINDEX = \"tabindex\",\n tabindex = target.attr(TABINDEX) || element.attr(TABINDEX);\n\n element.removeAttr(TABINDEX);\n\n target.attr(TABINDEX, !isNaN(tabindex) ? tabindex : 0);\n },\n\n setOptions: function(options) {\n this._clearCssClasses(options);\n this._setEvents(options);\n $.extend(this.options, options);\n this._applyCssClasses();\n },\n\n _setEvents: function(options) {\n var that = this,\n idx = 0,\n length = that.events.length,\n e;\n\n for (; idx < length; idx ++) {\n e = that.events[idx];\n if (that.options[e] && options[e]) {\n that.unbind(e, that.options[e]);\n if (that._events && that._events[e]) {\n delete that._events[e];\n }\n }\n }\n\n that.bind(that.events, options);\n },\n\n resize: function(force) {\n var size = this.getSize(),\n currentSize = this._size;\n\n if (force || (size.width > 0 || size.height > 0) && (!currentSize || size.width !== currentSize.width || size.height !== currentSize.height)) {\n this._size = size;\n this._resize(size, force);\n this.trigger(\"resize\", size);\n }\n },\n\n getSize: function() {\n return kendo.dimensions(this.element);\n },\n\n size: function(size) {\n if (!size) {\n return this.getSize();\n } else {\n this.setSize(size);\n }\n },\n\n setSize: $.noop,\n _resize: $.noop,\n\n destroy: function() {\n var that = this;\n\n that.element.removeData(\"kendo\" + that.options.prefix + that.options.name);\n that.element.removeData(\"handler\");\n that.unbind();\n },\n _destroy: function() {\n this.destroy();\n },\n angular: function(){},\n\n _muteAngularRebind: function(callback) {\n this._muteRebind = true;\n\n callback.call(this);\n\n this._muteRebind = false;\n },\n\n _applyCssClasses: function(element) {\n var protoOptions = this.__proto__.options, // jshint ignore:line\n options = this.options,\n el = element || this.wrapper || this.element,\n classes = [],\n i, prop, validFill, widgetName;\n\n if (!kendo.cssProperties.propertyDictionary[protoOptions.name]) {\n return;\n }\n\n for (i = 0; i < cssPropertiesNames.length; i++) {\n prop = cssPropertiesNames[i];\n widgetName = this.options._altname || protoOptions.name;\n\n if (protoOptions.hasOwnProperty(prop)) {\n if (prop === \"themeColor\") {\n validFill = kendo.cssProperties.getValidClass({\n widget: widgetName,\n propName: \"fillMode\",\n value: options.fillMode\n });\n\n if (validFill && validFill.length) {\n classes.push(kendo.cssProperties.getValidClass({\n widget: widgetName,\n propName: prop,\n value: options[prop],\n fill: options.fillMode\n }));\n }\n } else {\n classes.push(kendo.cssProperties.getValidClass({\n widget: widgetName,\n propName: prop,\n value: options[prop]\n }));\n }\n }\n }\n\n el.addClass(classes.join(\" \"));\n },\n\n _clearCssClasses: function(newOptions, element) {\n var protoOptions = this.__proto__.options, // jshint ignore:line\n currentOptions = this.options,\n el = element || this.wrapper || this.element,\n i, prop, widgetName;\n\n if(!kendo.cssProperties.propertyDictionary[protoOptions.name]) {\n return;\n }\n\n for(i = 0; i < cssPropertiesNames.length; i++) {\n prop = cssPropertiesNames[i];\n widgetName = this.options._altname || protoOptions.name;\n\n if(protoOptions.hasOwnProperty(prop) && newOptions.hasOwnProperty(prop)) {\n if (prop === \"themeColor\") {\n el.removeClass(kendo.cssProperties.getValidClass({\n widget: widgetName,\n propName: prop,\n value: currentOptions[prop],\n fill: currentOptions.fillMode\n }));\n } else {\n if (prop === \"fillMode\") {\n el.removeClass(kendo.cssProperties.getValidClass({\n widget: widgetName,\n propName: \"themeColor\",\n value: currentOptions.themeColor,\n fill: currentOptions.fillMode\n }));\n }\n\n el.removeClass(kendo.cssProperties.getValidClass({\n widget: widgetName,\n propName: prop,\n value: currentOptions[prop]\n }));\n }\n }\n }\n }\n });\n\n var DataBoundWidget = Widget.extend({\n // Angular consumes these.\n dataItems: function() {\n return this.dataSource.flatView();\n },\n\n _angularItems: function(cmd) {\n var that = this;\n that.angular(cmd, function(){\n return {\n elements: that.items(),\n data: $.map(that.dataItems(), function(dataItem){\n return { dataItem: dataItem };\n })\n };\n });\n }\n });\n\n kendo.dimensions = function(element, dimensions) {\n var domElement = element[0];\n\n if (dimensions) {\n element.css(dimensions);\n }\n\n return { width: domElement.offsetWidth, height: domElement.offsetHeight };\n };\n\n kendo.notify = noop;\n\n var templateRegExp = /template$/i,\n jsonRegExp = /^\\s*(?:\\{(?:.|\\r\\n|\\n)*\\}|\\[(?:.|\\r\\n|\\n)*\\])\\s*$/,\n jsonFormatRegExp = /^\\{(\\d+)(:[^\\}]+)?\\}|^\\[[A-Za-z_]+\\]$/,\n dashRegExp = /([A-Z])/g;\n\n function parseOption(element, option) {\n var value;\n\n if (option.indexOf(\"data\") === 0) {\n option = option.substring(4);\n option = option.charAt(0).toLowerCase() + option.substring(1);\n }\n\n option = option.replace(dashRegExp, \"-$1\");\n value = element.getAttribute(\"data-\" + kendo.ns + option);\n\n if (value === null) {\n value = undefined;\n } else if (value === \"null\") {\n value = null;\n } else if (value === \"true\") {\n value = true;\n } else if (value === \"false\") {\n value = false;\n } else if (numberRegExp.test(value) && option != \"mask\" && option != \"format\") {\n value = parseFloat(value);\n } else if (jsonRegExp.test(value) && !jsonFormatRegExp.test(value)) {\n value = new Function(\"return (\" + value + \")\")();\n }\n\n return value;\n }\n\n function parseOptions(element, options, source) {\n var result = {},\n option,\n value,\n role = element.getAttribute(\"data-\" + kendo.ns + \"role\");\n\n for (option in options) {\n value = parseOption(element, option);\n\n if (value !== undefined) {\n\n if (templateRegExp.test(option) && role != \"drawer\") {\n if(typeof value === \"string\") {\n if($(\"#\" + value).length){\n value = kendo.template($(\"#\" + value).html());\n }else if (source){\n value = kendo.template(source[value]);\n }\n } else {\n value = element.getAttribute(option);\n }\n }\n\n result[option] = value;\n }\n }\n\n return result;\n }\n\n kendo.initWidget = function(element, options, roles) {\n var result,\n option,\n widget,\n idx,\n length,\n role,\n value,\n dataSource,\n fullPath,\n widgetKeyRegExp;\n\n // Preserve backwards compatibility with (element, options, namespace) signature, where namespace was kendo.ui\n if (!roles) {\n roles = kendo.ui.roles;\n } else if (roles.roles) {\n roles = roles.roles;\n }\n\n element = element.nodeType ? element : element[0];\n\n role = element.getAttribute(\"data-\" + kendo.ns + \"role\");\n\n if (!role) {\n return;\n }\n\n fullPath = role.indexOf(\".\") === -1;\n\n // look for any widget that may be already instantiated based on this role.\n // The prefix used is unknown, hence the regexp\n //\n\n if (fullPath) {\n widget = roles[role];\n } else { // full namespace path - like kendo.ui.Widget\n widget = kendo.getter(role)(window);\n }\n\n var data = $(element).data(),\n widgetKey = widget ? \"kendo\" + widget.fn.options.prefix + widget.fn.options.name : \"\";\n\n if (fullPath) {\n widgetKeyRegExp = new RegExp(\"^kendo.*\" + role + \"$\", \"i\");\n } else { // full namespace path - like kendo.ui.Widget\n widgetKeyRegExp = new RegExp(\"^\" + widgetKey + \"$\", \"i\");\n }\n\n for(var key in data) {\n if (key.match(widgetKeyRegExp)) {\n // we have detected a widget of the same kind - save its reference, we will set its options\n if (key === widgetKey) {\n result = data[key];\n } else {\n return data[key];\n }\n }\n }\n\n if (!widget) {\n return;\n }\n\n dataSource = parseOption(element, \"dataSource\");\n\n options = $.extend({}, parseOptions(element, $.extend({}, widget.fn.options, widget.fn.defaults) ), options);\n\n if (dataSource) {\n if (typeof dataSource === STRING) {\n options.dataSource = kendo.getter(dataSource)(window);\n } else {\n options.dataSource = dataSource;\n }\n }\n\n for (idx = 0, length = widget.fn.events.length; idx < length; idx++) {\n option = widget.fn.events[idx];\n\n value = parseOption(element, option);\n\n if (value !== undefined) {\n options[option] = kendo.getter(value)(window);\n }\n }\n\n if (!result) {\n result = new widget(element, options);\n } else if (!$.isEmptyObject(options)) {\n result.setOptions(options);\n }\n\n return result;\n };\n\n kendo.rolesFromNamespaces = function(namespaces) {\n var roles = [],\n idx,\n length;\n\n if (!namespaces[0]) {\n namespaces = [kendo.ui, kendo.dataviz.ui];\n }\n\n for (idx = 0, length = namespaces.length; idx < length; idx ++) {\n roles[idx] = namespaces[idx].roles;\n }\n\n return extend.apply(null, [{}].concat(roles.reverse()));\n };\n\n kendo.init = function(element) {\n var roles = kendo.rolesFromNamespaces(slice.call(arguments, 1));\n\n $(element).find(\"[data-\" + kendo.ns + \"role]\").addBack().each(function(){\n kendo.initWidget(this, {}, roles);\n });\n };\n\n kendo.destroy = function(element) {\n $(element).find(\"[data-\" + kendo.ns + \"role]\").addBack().each(function(){\n var data = $(this).data();\n\n for (var key in data) {\n if (key.indexOf(\"kendo\") === 0 && typeof data[key].destroy === FUNCTION) {\n data[key].destroy();\n }\n }\n });\n };\n\n function containmentComparer(a, b) {\n return $.contains(a, b) ? -1 : 1;\n }\n\n function resizableWidget() {\n var widget = $(this);\n return ($.inArray(widget.attr(\"data-\" + kendo.ns + \"role\"), [\"slider\", \"rangeslider\", \"breadcrumb\"]) > -1) || widget.is(\":visible\");\n }\n\n kendo.resize = function(element, force) {\n var widgets = $(element).find(\"[data-\" + kendo.ns + \"role]\").addBack().filter(resizableWidget);\n\n if (!widgets.length) {\n return;\n }\n\n // sort widgets based on their parent-child relation\n var widgetsArray = $.makeArray(widgets);\n widgetsArray.sort(containmentComparer);\n\n // resize widgets\n $.each(widgetsArray, function () {\n var widget = kendo.widgetInstance($(this));\n if (widget) {\n widget.resize(force);\n }\n });\n };\n\n kendo.parseOptions = parseOptions;\n\n extend(kendo.ui, {\n Widget: Widget,\n DataBoundWidget: DataBoundWidget,\n roles: {},\n progress: function(container, toggle, options) {\n var mask = container.find(\".k-loading-mask\"),\n support = kendo.support,\n browser = support.browser,\n isRtl, leftRight, webkitCorrection, containerScrollLeft, cssClass;\n\n options = $.extend({}, {\n width: \"100%\",\n height: \"100%\",\n top: container.scrollTop(),\n opacity: false\n }, options);\n\n cssClass = options.opacity ? 'k-loading-mask k-opaque' : 'k-loading-mask';\n\n if (toggle) {\n if (!mask.length) {\n isRtl = support.isRtl(container);\n leftRight = isRtl ? \"right\" : \"left\";\n containerScrollLeft = kendo.scrollLeft(container);\n webkitCorrection = browser.webkit ? (!isRtl ? 0 : container[0].scrollWidth - container.width() - 2 * containerScrollLeft) : 0;\n\n mask = $(kendo.format(\"
{1}
\", cssClass, kendo.ui.progress.messages.loading))\n .width(options.width).height(options.height)\n .css(\"top\", options.top)\n .css(leftRight, Math.abs(containerScrollLeft) + webkitCorrection)\n .prependTo(container);\n }\n } else if (mask) {\n mask.remove();\n }\n },\n plugin: function(widget, register, prefix) {\n var name = widget.fn.options.name,\n getter;\n\n register = register || kendo.ui;\n prefix = prefix || \"\";\n\n register[name] = widget;\n\n register.roles[name.toLowerCase()] = widget;\n\n getter = \"getKendo\" + prefix + name;\n name = \"kendo\" + prefix + name;\n\n var widgetEntry = { name: name, widget: widget, prefix: prefix || \"\" };\n kendo.widgets.push(widgetEntry);\n\n for (var i = 0, len = kendo._widgetRegisteredCallbacks.length; i < len; i++) {\n kendo._widgetRegisteredCallbacks[i](widgetEntry);\n }\n\n $.fn[name] = function(options) {\n var value = this,\n args;\n\n if (typeof options === STRING) {\n args = slice.call(arguments, 1);\n\n this.each(function(){\n var widget = $.data(this, name),\n method,\n result;\n\n if (!widget) {\n throw new Error(kendo.format(\"Cannot call method '{0}' of {1} before it is initialized\", options, name));\n }\n\n method = widget[options];\n\n if (typeof method !== FUNCTION) {\n throw new Error(kendo.format(\"Cannot find method '{0}' of {1}\", options, name));\n }\n\n result = method.apply(widget, args);\n\n if (result !== undefined) {\n value = result;\n return false;\n }\n });\n } else {\n this.each(function() {\n return new widget(this, options);\n });\n }\n\n return value;\n };\n\n $.fn[name].widget = widget;\n\n $.fn[getter] = function() {\n return this.data(name);\n };\n }\n });\n\n kendo.ui.progress.messages = {\n loading: \"Loading...\"\n };\n\n var ContainerNullObject = { bind: function () { return this; }, nullObject: true, options: {} };\n\n var MobileWidget = Widget.extend({\n init: function(element, options) {\n Widget.fn.init.call(this, element, options);\n this.element.autoApplyNS();\n this.wrapper = this.element;\n this.element.addClass(\"km-widget\");\n },\n\n destroy: function() {\n Widget.fn.destroy.call(this);\n this.element.kendoDestroy();\n },\n\n options: {\n prefix: \"Mobile\"\n },\n\n events: [],\n\n view: function() {\n var viewElement = this.element.closest(kendo.roleSelector(\"view splitview modalview drawer\"));\n return kendo.widgetInstance(viewElement, kendo.mobile.ui) || ContainerNullObject;\n },\n\n viewHasNativeScrolling: function() {\n var view = this.view();\n return view && view.options.useNativeScrolling;\n },\n\n container: function() {\n var element = this.element.closest(kendo.roleSelector(\"view layout modalview drawer splitview\"));\n return kendo.widgetInstance(element.eq(0), kendo.mobile.ui) || ContainerNullObject;\n }\n });\n\n extend(kendo.mobile, {\n init: function(element) {\n kendo.init(element, kendo.mobile.ui, kendo.ui, kendo.dataviz.ui);\n },\n\n appLevelNativeScrolling: function() {\n return kendo.mobile.application && kendo.mobile.application.options && kendo.mobile.application.options.useNativeScrolling;\n },\n\n roles: {},\n\n ui: {\n Widget: MobileWidget,\n DataBoundWidget: DataBoundWidget.extend(MobileWidget.prototype),\n roles: {},\n plugin: function(widget) {\n kendo.ui.plugin(widget, kendo.mobile.ui, \"Mobile\");\n }\n }\n });\n\n deepExtend(kendo.dataviz, {\n init: function(element) {\n kendo.init(element, kendo.dataviz.ui);\n },\n ui: {\n roles: {},\n themes: {},\n views: [],\n plugin: function(widget) {\n kendo.ui.plugin(widget, kendo.dataviz.ui);\n }\n },\n roles: {}\n });\n\n kendo.touchScroller = function(elements, options) {\n // return the first touch scroller\n if (!options){ options = {}; }\n\n options.useNative = true;\n\n return $(elements).map(function(idx, element) {\n element = $(element);\n if (support.kineticScrollNeeded && kendo.mobile.ui.Scroller && !element.data(\"kendoMobileScroller\")) {\n element.kendoMobileScroller(options);\n return element.data(\"kendoMobileScroller\");\n } else {\n return false;\n }\n })[0];\n };\n\n kendo.preventDefault = function(e) {\n e.preventDefault();\n };\n\n kendo.widgetInstance = function(element, suites) {\n var role = element.data(kendo.ns + \"role\"),\n widgets = [], i, length,\n elementData = element.data(\"kendoView\");\n\n if (role) {\n // HACK!!! mobile view scroller widgets are instantiated on data-role=\"content\" elements. We need to discover them when resizing.\n if (role === \"content\") {\n role = \"scroller\";\n }\n\n // kendoEditorToolbar is not a public plugin, thus it does not exist in kendo.ui.roles.\n // Therefore, this is needed in order to be resized when placed in Kendo Window.\n if (role === \"editortoolbar\") {\n var editorToolbar = element.data(\"kendoEditorToolbar\");\n if (editorToolbar) {\n return editorToolbar;\n }\n }\n\n // kendo.View is not a ui plugin\n\n if (role === \"view\" && elementData) {\n return elementData;\n }\n\n if (suites) {\n if (suites[0]) {\n for (i = 0, length = suites.length; i < length; i ++) {\n widgets.push(suites[i].roles[role]);\n }\n } else {\n widgets.push(suites.roles[role]);\n }\n }\n else {\n widgets = [ kendo.ui.roles[role], kendo.dataviz.ui.roles[role], kendo.mobile.ui.roles[role] ];\n }\n\n if (role.indexOf(\".\") >= 0) {\n widgets = [ kendo.getter(role)(window) ];\n }\n\n for (i = 0, length = widgets.length; i < length; i ++) {\n var widget = widgets[i];\n if (widget) {\n var instance = element.data(\"kendo\" + widget.fn.options.prefix + widget.fn.options.name);\n if (instance) {\n return instance;\n }\n }\n }\n }\n };\n\n kendo.onResize = function(callback) {\n var handler = callback;\n if (support.mobileOS.android) {\n handler = function() { setTimeout(callback, 600); };\n }\n\n $(window).on(support.resize, handler);\n return handler;\n };\n\n kendo.unbindResize = function(callback) {\n $(window).off(support.resize, callback);\n };\n\n kendo.attrValue = function(element, key) {\n return element.data(kendo.ns + key);\n };\n\n kendo.days = {\n Sunday: 0,\n Monday: 1,\n Tuesday: 2,\n Wednesday: 3,\n Thursday: 4,\n Friday: 5,\n Saturday: 6\n };\n\n function focusable(element, isTabIndexNotNaN) {\n var nodeName = element.nodeName.toLowerCase();\n\n return (/input|select|textarea|button|object/.test(nodeName) ?\n !element.disabled :\n \"a\" === nodeName ?\n element.href || isTabIndexNotNaN :\n isTabIndexNotNaN\n ) &&\n visible(element);\n }\n\n function visible(element) {\n return $.expr.pseudos.visible(element) &&\n !$(element).parents().addBack().filter(function() {\n return $.css(this,\"visibility\") === \"hidden\";\n }).length;\n }\n\n $.extend($.expr.pseudos, {\n kendoFocusable: function(element) {\n var idx = $.attr(element, \"tabindex\");\n return focusable(element, !isNaN(idx) && idx > -1);\n }\n });\n\n var MOUSE_EVENTS = [\"mousedown\", \"mousemove\", \"mouseenter\", \"mouseleave\", \"mouseover\", \"mouseout\", \"mouseup\", \"click\"];\n var EXCLUDE_BUST_CLICK_SELECTOR = \"label, input, [data-rel=external]\";\n\n var MouseEventNormalizer = {\n setupMouseMute: function() {\n var idx = 0,\n length = MOUSE_EVENTS.length,\n element = document.documentElement;\n\n if (MouseEventNormalizer.mouseTrap || !support.eventCapture) {\n return;\n }\n\n MouseEventNormalizer.mouseTrap = true;\n\n MouseEventNormalizer.bustClick = false;\n MouseEventNormalizer.captureMouse = false;\n\n var handler = function(e) {\n if (MouseEventNormalizer.captureMouse) {\n if (e.type === \"click\") {\n if (MouseEventNormalizer.bustClick && !$(e.target).is(EXCLUDE_BUST_CLICK_SELECTOR)) {\n e.preventDefault();\n e.stopPropagation();\n }\n } else {\n e.stopPropagation();\n }\n }\n };\n\n for (; idx < length; idx++) {\n element.addEventListener(MOUSE_EVENTS[idx], handler, true);\n }\n },\n\n muteMouse: function(e) {\n MouseEventNormalizer.captureMouse = true;\n if (e.data.bustClick) {\n MouseEventNormalizer.bustClick = true;\n }\n clearTimeout(MouseEventNormalizer.mouseTrapTimeoutID);\n },\n\n unMuteMouse: function() {\n clearTimeout(MouseEventNormalizer.mouseTrapTimeoutID);\n MouseEventNormalizer.mouseTrapTimeoutID = setTimeout(function() {\n MouseEventNormalizer.captureMouse = false;\n MouseEventNormalizer.bustClick = false;\n }, 400);\n }\n };\n\n var eventMap = {\n down: \"touchstart mousedown\",\n move: \"mousemove touchmove\",\n up: \"mouseup touchend touchcancel\",\n cancel: \"mouseleave touchcancel\"\n };\n\n if (support.touch && (support.mobileOS.ios || support.mobileOS.android)) {\n eventMap = {\n down: \"touchstart\",\n move: \"touchmove\",\n up: \"touchend touchcancel\",\n cancel: \"touchcancel\"\n };\n } else if (support.pointers) {\n eventMap = {\n down: \"pointerdown\",\n move: \"pointermove\",\n up: \"pointerup\",\n cancel: \"pointercancel pointerleave\"\n };\n } else if (support.msPointers) {\n eventMap = {\n down: \"MSPointerDown\",\n move: \"MSPointerMove\",\n up: \"MSPointerUp\",\n cancel: \"MSPointerCancel MSPointerLeave\"\n };\n }\n\n if (support.msPointers && !(\"onmspointerenter\" in window)) { // IE10\n // Create MSPointerEnter/MSPointerLeave events using mouseover/out and event-time checks\n $.each({\n MSPointerEnter: \"MSPointerOver\",\n MSPointerLeave: \"MSPointerOut\"\n }, function( orig, fix ) {\n $.event.special[ orig ] = {\n delegateType: fix,\n bindType: fix,\n\n handle: function( event ) {\n var ret,\n target = this,\n related = event.relatedTarget,\n handleObj = event.handleObj;\n\n // For mousenter/leave call the handler if related is outside the target.\n // NB: No relatedTarget if the mouse left/entered the browser window\n if ( !related || (related !== target && !$.contains( target, related )) ) {\n event.type = handleObj.origType;\n ret = handleObj.handler.apply( this, arguments );\n event.type = fix;\n }\n return ret;\n }\n };\n });\n }\n\n\n var getEventMap = function(e) { return (eventMap[e] || e); },\n eventRegEx = /([^ ]+)/g;\n\n kendo.applyEventMap = function(events, ns) {\n events = events.replace(eventRegEx, getEventMap);\n\n if (ns) {\n events = events.replace(eventRegEx, \"$1.\" + ns);\n }\n\n return events;\n };\n\n kendo.keyDownHandler = function(e, widget) {\n var events = widget._events.kendoKeydown;\n\n if(!events){\n return true;\n }\n\n events = events.slice();\n e.sender = widget;\n e.preventKendoKeydown = false;\n for (var idx = 0, length = events.length; idx < length; idx++) {\n events[idx].call(widget, e);\n }\n\n return !e.preventKendoKeydown;\n };\n\n var on = $.fn.on;\n\n function kendoJQuery(selector, context) {\n return new kendoJQuery.fn.init(selector, context);\n }\n\n noDepricateExtend(true, kendoJQuery, $);\n\n kendoJQuery.fn = kendoJQuery.prototype = new $();\n\n kendoJQuery.fn.constructor = kendoJQuery;\n\n kendoJQuery.fn.init = function(selector, context) {\n if (context && context instanceof $ && !(context instanceof kendoJQuery)) {\n context = kendoJQuery(context);\n }\n\n return $.fn.init.call(this, selector, context, rootjQuery);\n };\n\n kendoJQuery.fn.init.prototype = kendoJQuery.fn;\n\n var rootjQuery = kendoJQuery(document);\n\n extend(kendoJQuery.fn, {\n handler: function(handler) {\n this.data(\"handler\", handler);\n return this;\n },\n\n autoApplyNS: function(ns) {\n this.data(\"kendoNS\", ns || kendo.guid());\n return this;\n },\n\n on: function() {\n var that = this,\n ns = that.data(\"kendoNS\");\n\n // support for event map signature\n if (arguments.length === 1) {\n return on.call(that, arguments[0]);\n }\n\n var context = that,\n args = slice.call(arguments);\n\n if (typeof args[args.length -1] === UNDEFINED) {\n args.pop();\n }\n\n var callback = args[args.length - 1],\n events = kendo.applyEventMap(args[0], ns);\n\n // setup mouse trap\n if (support.mouseAndTouchPresent && events.search(/mouse|click/) > -1 && this[0] !== document.documentElement) {\n MouseEventNormalizer.setupMouseMute();\n\n var selector = args.length === 2 ? null : args[1],\n bustClick = events.indexOf(\"click\") > -1 && events.indexOf(\"touchend\") > -1;\n\n on.call(this,\n {\n touchstart: MouseEventNormalizer.muteMouse,\n touchend: MouseEventNormalizer.unMuteMouse\n },\n selector,\n {\n bustClick: bustClick\n });\n }\n\n if(arguments[0].indexOf(\"keydown\") !== -1 && args[1] && args[1].options){\n args[0] = events;\n var widget = args[1];\n var keyDownCallBack = args[args.length - 1];\n args[args.length - 1]= function(e){\n if(kendo.keyDownHandler(e, widget)){\n return keyDownCallBack.apply(this, [e]);\n }\n };\n on.apply(that, args);\n return that;\n }\n\n if (typeof callback === STRING) {\n context = that.data(\"handler\");\n callback = context[callback];\n\n args[args.length - 1] = function(e) {\n callback.call(context, e);\n };\n }\n\n args[0] = events;\n\n on.apply(that, args);\n\n return that;\n },\n\n kendoDestroy: function(ns) {\n ns = ns || this.data(\"kendoNS\");\n\n if (ns) {\n this.off(\".\" + ns);\n }\n\n return this;\n }\n });\n\n kendo.jQuery = kendoJQuery;\n kendo.eventMap = eventMap;\n\n kendo.timezone = (function(){\n var months = { Jan: 0, Feb: 1, Mar: 2, Apr: 3, May: 4, Jun: 5, Jul: 6, Aug: 7, Sep: 8, Oct: 9, Nov: 10, Dec: 11 };\n var days = { Sun: 0, Mon: 1, Tue: 2, Wed: 3, Thu: 4, Fri: 5, Sat: 6 };\n\n function ruleToDate(year, rule) {\n var date;\n var targetDay;\n var ourDay;\n var month = rule[3];\n var on = rule[4];\n var time = rule[5];\n var cache = rule[8];\n\n if (!cache) {\n rule[8] = cache = {};\n }\n\n if (cache[year]) {\n return cache[year];\n }\n\n if (!isNaN(on)) {\n date = new Date(Date.UTC(year, months[month], on, time[0], time[1], time[2], 0));\n } else if (on.indexOf(\"last\") === 0) {\n date = new Date(Date.UTC(year, months[month] + 1, 1, time[0] - 24, time[1], time[2], 0));\n\n targetDay = days[on.substr(4, 3)];\n ourDay = date.getUTCDay();\n\n date.setUTCDate(date.getUTCDate() + targetDay - ourDay - (targetDay > ourDay ? 7 : 0));\n } else if (on.indexOf(\">=\") >= 0) {\n date = new Date(Date.UTC(year, months[month], on.substr(5), time[0], time[1], time[2], 0));\n\n targetDay = days[on.substr(0, 3)];\n ourDay = date.getUTCDay();\n\n date.setUTCDate(date.getUTCDate() + targetDay - ourDay + (targetDay < ourDay ? 7 : 0));\n } else if (on.indexOf(\"<=\") >= 0) {\n date = new Date(Date.UTC(year, months[month], on.substr(5), time[0], time[1], time[2], 0));\n\n targetDay = days[on.substr(0, 3)];\n ourDay = date.getUTCDay();\n\n date.setUTCDate(date.getUTCDate() + targetDay - ourDay - (targetDay > ourDay ? 7 : 0));\n }\n\n return cache[year] = date;\n }\n\n function findRule(utcTime, rules, zone) {\n rules = rules[zone];\n\n if (!rules) {\n var time = zone.split(\":\");\n var offset = 0;\n\n if (time.length > 1) {\n offset = time[0] * 60 + Number(time[1]);\n }\n\n return [-1000000, 'max', '-', 'Jan', 1, [0, 0, 0], offset, '-'];\n }\n\n var year = new Date(utcTime).getUTCFullYear();\n\n rules = jQuery.grep(rules, function(rule) {\n var from = rule[0];\n var to = rule[1];\n\n return from <= year && (to >= year || (from == year && to == \"only\") || to == \"max\");\n });\n\n rules.push(utcTime);\n\n rules.sort(function(a, b) {\n if (typeof a != \"number\") {\n a = Number(ruleToDate(year, a));\n }\n\n if (typeof b != \"number\") {\n b = Number(ruleToDate(year, b));\n }\n\n return a - b;\n });\n\n var rule = rules[jQuery.inArray(utcTime, rules) - 1] || rules[rules.length - 1];\n\n return isNaN(rule) ? rule : null;\n }\n\n function findZone(utcTime, zones, timezone) {\n var zoneRules = zones[timezone];\n\n if (typeof zoneRules === \"string\") {\n zoneRules = zones[zoneRules];\n }\n\n if (!zoneRules) {\n throw new Error('Timezone \"' + timezone + '\" is either incorrect, or kendo.timezones.min.js is not included.');\n }\n\n for (var idx = zoneRules.length - 1; idx >= 0; idx--) {\n var until = zoneRules[idx][3];\n\n if (until && utcTime > until) {\n break;\n }\n }\n\n var zone = zoneRules[idx + 1];\n\n if (!zone) {\n throw new Error('Timezone \"' + timezone + '\" not found on ' + utcTime + \".\");\n }\n\n return zone;\n }\n\n function zoneAndRule(utcTime, zones, rules, timezone) {\n if (typeof utcTime != NUMBER) {\n utcTime = Date.UTC(utcTime.getFullYear(), utcTime.getMonth(),\n utcTime.getDate(), utcTime.getHours(), utcTime.getMinutes(),\n utcTime.getSeconds(), utcTime.getMilliseconds());\n }\n\n var zone = findZone(utcTime, zones, timezone);\n\n return {\n zone: zone,\n rule: findRule(utcTime, rules, zone[1])\n };\n }\n\n function offset(utcTime, timezone) {\n if (timezone == \"Etc/UTC\" || timezone == \"Etc/GMT\") {\n return 0;\n }\n\n var info = zoneAndRule(utcTime, this.zones, this.rules, timezone);\n var zone = info.zone;\n var rule = info.rule;\n\n return kendo.parseFloat(rule? zone[0] - rule[6] : zone[0]);\n }\n\n function abbr(utcTime, timezone) {\n var info = zoneAndRule(utcTime, this.zones, this.rules, timezone);\n var zone = info.zone;\n var rule = info.rule;\n\n var base = zone[2];\n\n if (base.indexOf(\"/\") >= 0) {\n return base.split(\"/\")[rule && +rule[6] ? 1 : 0];\n } else if (base.indexOf(\"%s\") >= 0) {\n return base.replace(\"%s\", (!rule || rule[7] == \"-\") ? '' : rule[7]);\n }\n\n return base;\n }\n\n function convert(date, fromOffset, toOffset) {\n var tempToOffset = toOffset;\n var diff;\n\n if (typeof fromOffset == STRING) {\n fromOffset = this.offset(date, fromOffset);\n }\n\n if (typeof toOffset == STRING) {\n toOffset = this.offset(date, toOffset);\n }\n\n var fromLocalOffset = date.getTimezoneOffset();\n\n date = new Date(date.getTime() + (fromOffset - toOffset) * 60000);\n\n var toLocalOffset = date.getTimezoneOffset();\n\n if (typeof tempToOffset == STRING) {\n tempToOffset = this.offset(date, tempToOffset);\n }\n\n diff = (toLocalOffset - fromLocalOffset) + (toOffset - tempToOffset);\n\n return new Date(date.getTime() + diff * 60000);\n }\n\n function apply(date, timezone) {\n return this.convert(date, date.getTimezoneOffset(), timezone);\n }\n\n function remove(date, timezone) {\n return this.convert(date, timezone, date.getTimezoneOffset());\n }\n\n function toLocalDate(time) {\n return this.apply(new Date(time), \"Etc/UTC\");\n }\n\n return {\n zones: {},\n rules: {},\n offset: offset,\n convert: convert,\n apply: apply,\n remove: remove,\n abbr: abbr,\n toLocalDate: toLocalDate\n };\n })();\n\n kendo.date = (function(){\n var MS_PER_MINUTE = 60000,\n MS_PER_DAY = 86400000;\n\n function adjustDST(date, hours) {\n if (hours === 0 && date.getHours() === 23) {\n date.setHours(date.getHours() + 2);\n return true;\n }\n\n return false;\n }\n\n function setDayOfWeek(date, day, dir) {\n var hours = date.getHours();\n\n dir = dir || 1;\n day = ((day - date.getDay()) + (7 * dir)) % 7;\n\n date.setDate(date.getDate() + day);\n adjustDST(date, hours);\n }\n\n function dayOfWeek(date, day, dir) {\n date = new Date(date);\n setDayOfWeek(date, day, dir);\n return date;\n }\n\n function firstDayOfMonth(date) {\n return new Date(\n date.getFullYear(),\n date.getMonth(),\n 1\n );\n }\n\n function lastDayOfMonth(date) {\n var last = new Date(date.getFullYear(), date.getMonth() + 1, 0),\n first = firstDayOfMonth(date),\n timeOffset = Math.abs(last.getTimezoneOffset() - first.getTimezoneOffset());\n\n if (timeOffset) {\n last.setHours(first.getHours() + (timeOffset / 60));\n }\n\n return last;\n }\n\n function firstDayOfYear(date) {\n return new Date(date.getFullYear(), 0, 1);\n }\n\n function lastDayOfYear(date) {\n return new Date(date.getFullYear(), 11, 31);\n }\n\n function moveDateToWeekStart(date, weekStartDay) {\n if (weekStartDay !== 1) {\n return addDays(dayOfWeek(date, weekStartDay, -1), 4);\n }\n\n return addDays(date, (4 - (date.getDay() || 7)));\n }\n\n function calcWeekInYear(date, weekStartDay) {\n var firstWeekInYear = new Date(date.getFullYear(), 0, 1, -6);\n\n var newDate = moveDateToWeekStart(date, weekStartDay);\n\n var diffInMS = newDate.getTime() - firstWeekInYear.getTime();\n\n var days = Math.floor(diffInMS / MS_PER_DAY);\n\n return 1 + Math.floor(days / 7);\n }\n\n function weekInYear(date, weekStartDay) {\n if(weekStartDay === undefined) {\n weekStartDay = kendo.culture().calendar.firstDay;\n }\n\n var prevWeekDate = addDays(date, -7);\n var nextWeekDate = addDays(date, 7);\n\n var weekNumber = calcWeekInYear(date, weekStartDay);\n\n if (weekNumber === 0) {\n return calcWeekInYear(prevWeekDate, weekStartDay) + 1;\n }\n\n if (weekNumber === 53 && calcWeekInYear(nextWeekDate, weekStartDay) > 1) {\n return 1;\n }\n\n return weekNumber;\n }\n\n function getDate(date) {\n date = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);\n adjustDST(date, 0);\n return date;\n }\n\n function toUtcTime(date) {\n return Date.UTC(date.getFullYear(), date.getMonth(),\n date.getDate(), date.getHours(), date.getMinutes(),\n date.getSeconds(), date.getMilliseconds());\n }\n\n function getMilliseconds(date) {\n return toInvariantTime(date).getTime() - getDate(toInvariantTime(date));\n }\n\n function isInTimeRange(value, min, max) {\n var msMin = getMilliseconds(min),\n msMax = getMilliseconds(max),\n msValue;\n\n if (!value || msMin == msMax) {\n return true;\n }\n\n if (min >= max) {\n max += MS_PER_DAY;\n }\n\n msValue = getMilliseconds(value);\n\n if (msMin > msValue) {\n msValue += MS_PER_DAY;\n }\n\n if (msMax < msMin) {\n msMax += MS_PER_DAY;\n }\n\n return msValue >= msMin && msValue <= msMax;\n }\n\n function isInDateRange(value, min, max) {\n var msMin = min.getTime(),\n msMax = max.getTime(),\n msValue;\n\n if (msMin >= msMax) {\n msMax += MS_PER_DAY;\n }\n\n msValue = value.getTime();\n\n return msValue >= msMin && msValue <= msMax;\n }\n\n function addDays(date, offset) {\n var hours = date.getHours();\n date = new Date(date);\n\n setTime(date, offset * MS_PER_DAY);\n adjustDST(date, hours);\n return date;\n }\n\n function setTime(date, milliseconds, ignoreDST) {\n var offset = date.getTimezoneOffset();\n var difference;\n\n date.setTime(date.getTime() + milliseconds);\n\n if (!ignoreDST) {\n difference = date.getTimezoneOffset() - offset;\n date.setTime(date.getTime() + difference * MS_PER_MINUTE);\n }\n }\n\n function setHours(date, time) {\n date = new Date(date.getFullYear(), date.getMonth(), date.getDate(), time.getHours(), time.getMinutes(), time.getSeconds(), time.getMilliseconds());\n adjustDST(date, time.getHours());\n return date;\n }\n\n function today() {\n return getDate(new Date());\n }\n\n function isToday(date) {\n return getDate(date).getTime() == today().getTime();\n }\n\n function toInvariantTime(date) {\n var staticDate = new Date(1980, 1, 1, 0, 0, 0);\n\n if (date) {\n staticDate.setHours(date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());\n }\n\n return staticDate;\n }\n\n function addYear(date, offset) {\n var currentDate = new Date(date);\n\n return new Date(currentDate.setFullYear(currentDate.getFullYear() + offset));\n }\n\n return {\n adjustDST: adjustDST,\n dayOfWeek: dayOfWeek,\n setDayOfWeek: setDayOfWeek,\n getDate: getDate,\n isInDateRange: isInDateRange,\n isInTimeRange: isInTimeRange,\n isToday: isToday,\n nextDay: function(date) {\n return addDays(date, 1);\n },\n previousDay: function(date) {\n return addDays(date, -1);\n },\n toUtcTime: toUtcTime,\n MS_PER_DAY: MS_PER_DAY,\n MS_PER_HOUR: 60 * MS_PER_MINUTE,\n MS_PER_MINUTE: MS_PER_MINUTE,\n setTime: setTime,\n setHours: setHours,\n addDays: addDays,\n today: today,\n toInvariantTime: toInvariantTime,\n firstDayOfMonth: firstDayOfMonth,\n lastDayOfMonth: lastDayOfMonth,\n weekInYear: weekInYear,\n getMilliseconds: getMilliseconds,\n firstDayOfYear: firstDayOfYear,\n lastDayOfYear: lastDayOfYear,\n nextYear: function(date) {\n return addYear(date, 1);\n },\n previousYear: function(date) {\n return addYear(date, -1);\n }\n };\n })();\n\n\n kendo.stripWhitespace = function(element) {\n if (document.createNodeIterator) {\n var iterator = document.createNodeIterator(element, NodeFilter.SHOW_TEXT, function(node) {\n return node.parentNode == element ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;\n }, false);\n\n while (iterator.nextNode()) {\n if (iterator.referenceNode && !iterator.referenceNode.textContent.trim()) {\n iterator.referenceNode.parentNode.removeChild(iterator.referenceNode);\n }\n }\n } else { // IE7/8 support\n for (var i = 0; i < element.childNodes.length; i++) {\n var child = element.childNodes[i];\n\n if (child.nodeType == 3 && !/\\S/.test(child.nodeValue)) {\n element.removeChild(child);\n i--;\n }\n\n if (child.nodeType == 1) {\n kendo.stripWhitespace(child);\n }\n }\n }\n };\n\n var animationFrame = window.requestAnimationFrame ||\n window.webkitRequestAnimationFrame ||\n window.mozRequestAnimationFrame ||\n window.oRequestAnimationFrame ||\n window.msRequestAnimationFrame ||\n function(callback){ setTimeout(callback, 1000 / 60); };\n\n kendo.animationFrame = function(callback) {\n animationFrame.call(window, callback);\n };\n\n var animationQueue = [];\n\n kendo.queueAnimation = function(callback) {\n animationQueue[animationQueue.length] = callback;\n if (animationQueue.length === 1) {\n kendo.runNextAnimation();\n }\n };\n\n kendo.runNextAnimation = function() {\n kendo.animationFrame(function() {\n if (animationQueue[0]) {\n animationQueue.shift()();\n if (animationQueue[0]) {\n kendo.runNextAnimation();\n }\n }\n });\n };\n\n kendo.parseQueryStringParams = function(url) {\n var queryString = url.split('?')[1] || \"\",\n params = {},\n paramParts = queryString.split(/&|=/),\n length = paramParts.length,\n idx = 0;\n\n for (; idx < length; idx += 2) {\n if(paramParts[idx] !== \"\") {\n params[decodeURIComponent(paramParts[idx])] = decodeURIComponent(paramParts[idx + 1]);\n }\n }\n\n return params;\n };\n\n kendo.elementUnderCursor = function(e) {\n if (typeof e.x.client != \"undefined\") {\n return document.elementFromPoint(e.x.client, e.y.client);\n }\n };\n\n kendo.wheelDeltaY = function(jQueryEvent) {\n var e = jQueryEvent.originalEvent,\n deltaY = e.wheelDeltaY,\n delta;\n\n if (e.wheelDelta) { // Webkit and IE\n if (deltaY === undefined || deltaY) { // IE does not have deltaY, thus always scroll (horizontal scrolling is treated as vertical)\n delta = e.wheelDelta;\n }\n } else if (e.detail && e.axis === e.VERTICAL_AXIS) { // Firefox and Opera\n delta = (-e.detail) * 10;\n }\n\n return delta;\n };\n\n kendo.throttle = function(fn, delay) {\n var timeout;\n var lastExecTime = 0;\n\n if (!delay || delay <= 0) {\n return fn;\n }\n\n var throttled = function() {\n var that = this;\n var elapsed = +new Date() - lastExecTime;\n var args = arguments;\n\n function exec() {\n fn.apply(that, args);\n lastExecTime = +new Date();\n }\n\n // first execution\n if (!lastExecTime) {\n return exec();\n }\n\n if (timeout) {\n clearTimeout(timeout);\n }\n\n if (elapsed > delay) {\n exec();\n } else {\n timeout = setTimeout(exec, delay - elapsed);\n }\n };\n\n throttled.cancel = function() {\n clearTimeout(timeout);\n };\n\n return throttled;\n };\n\n\n kendo.caret = function (element, start, end) {\n var rangeElement;\n var isPosition = start !== undefined;\n\n if (end === undefined) {\n end = start;\n }\n\n if (element[0]) {\n element = element[0];\n }\n\n if (isPosition && element.disabled) {\n return;\n }\n\n try {\n if (element.selectionStart !== undefined) {\n if (isPosition) {\n element.focus();\n var mobile = support.mobileOS;\n if(mobile.wp || mobile.android) {// without the timeout the caret is at the end of the input\n setTimeout(function() { element.setSelectionRange(start, end); }, 0);\n }\n else {\n element.setSelectionRange(start, end);\n }\n } else {\n start = [element.selectionStart, element.selectionEnd];\n }\n } else if (document.selection) {\n if ($(element).is(\":visible\")) {\n element.focus();\n }\n\n rangeElement = element.createTextRange();\n\n if (isPosition) {\n rangeElement.collapse(true);\n rangeElement.moveStart(\"character\", start);\n rangeElement.moveEnd(\"character\", end - start);\n rangeElement.select();\n } else {\n var rangeDuplicated = rangeElement.duplicate(),\n selectionStart, selectionEnd;\n\n rangeElement.moveToBookmark(document.selection.createRange().getBookmark());\n rangeDuplicated.setEndPoint('EndToStart', rangeElement);\n selectionStart = rangeDuplicated.text.length;\n selectionEnd = selectionStart + rangeElement.text.length;\n\n start = [selectionStart, selectionEnd];\n }\n }\n } catch(e) {\n /* element is not focused or it is not in the DOM */\n start = [];\n }\n\n return start;\n };\n\n kendo.compileMobileDirective = function(element, scope) {\n var angular = window.angular;\n\n element.attr(\"data-\" + kendo.ns + \"role\", element[0].tagName.toLowerCase().replace('kendo-mobile-', '').replace('-', ''));\n\n angular.element(element).injector().invoke([\"$compile\", function($compile) {\n $compile(element)(scope);\n\n if (!/^\\$(digest|apply)$/.test(scope.$$phase)) {\n scope.$digest();\n }\n }]);\n\n return kendo.widgetInstance(element, kendo.mobile.ui);\n };\n\n kendo.antiForgeryTokens = function() {\n var tokens = { },\n csrf_token = $(\"meta[name=csrf-token],meta[name=_csrf]\").attr(\"content\"),\n csrf_param = $(\"meta[name=csrf-param],meta[name=_csrf_header]\").attr(\"content\");\n\n $(\"input[name^='__RequestVerificationToken']\").each(function() {\n tokens[this.name] = this.value;\n });\n\n if (csrf_param !== undefined && csrf_token !== undefined) {\n tokens[csrf_param] = csrf_token;\n }\n\n return tokens;\n };\n\n kendo.cycleForm = function(form) {\n var firstElement = form.find(\"input, .k-widget\").first();\n var lastElement = form.find(\"button, .k-button\").last();\n\n function focus(el) {\n var widget = kendo.widgetInstance(el);\n\n if (widget && widget.focus) {\n widget.focus();\n } else {\n el.trigger(\"focus\");\n }\n }\n\n lastElement.on(\"keydown\", function(e) {\n if (e.keyCode == kendo.keys.TAB && !e.shiftKey) {\n e.preventDefault();\n focus(firstElement);\n }\n });\n\n firstElement.on(\"keydown\", function(e) {\n if (e.keyCode == kendo.keys.TAB && e.shiftKey) {\n e.preventDefault();\n focus(lastElement);\n }\n });\n };\n\n kendo.focusElement = function(element) {\n var scrollTopPositions = [];\n var scrollableParents = element.parentsUntil(\"body\")\n .filter(function(index, element) {\n var computedStyle = kendo.getComputedStyles(element, [\"overflow\"]);\n return computedStyle.overflow !== \"visible\";\n })\n .add(window);\n\n scrollableParents.each(function(index, parent) {\n scrollTopPositions[index] = $(parent).scrollTop();\n });\n\n try {\n //The setActive method does not cause the document to scroll to the active object in the current page\n element[0].setActive();\n } catch (e) {\n element[0].focus();\n }\n\n scrollableParents.each(function(index, parent) {\n $(parent).scrollTop(scrollTopPositions[index]);\n });\n };\n\n kendo.focusNextElement = function () {\n if (document.activeElement) {\n var focussable = $(\":kendoFocusable\");\n var index = focussable.index(document.activeElement);\n\n if(index > -1) {\n var nextElement = focussable[index + 1] || focussable[0];\n nextElement.focus();\n }\n }\n };\n\n kendo.trim = function(value) {\n if(!!value) {\n return value.toString().trim();\n } else {\n return \"\";\n }\n };\n\n kendo.getWidgetFocusableElement = function(element) {\n var nextFocusable = element.closest(\":kendoFocusable\"),\n widgetInstance = kendo.widgetInstance(element),\n target;\n\n if (nextFocusable.length) {\n target = nextFocusable;\n } else if (widgetInstance) {\n target = widgetInstance.options.name === 'Editor' ?\n $(widgetInstance.body) :\n widgetInstance.wrapper.find(\":kendoFocusable\").first();\n } else {\n target = element;\n }\n\n return target;\n };\n\n kendo.addAttribute = function(element, attribute, value) {\n var current = element.attr(attribute) || \"\";\n\n if (current.indexOf(value) < 0) {\n element.attr(attribute, (current + \" \" + value).trim());\n }\n };\n\n kendo.removeAttribute = function(element, attribute, value) {\n var current = element.attr(attribute) || \"\";\n\n element.attr(attribute, current.replace(value, \"\").trim());\n };\n\n kendo.toggleAttribute = function(element, attribute, value) {\n var current = element.attr(attribute) || \"\";\n\n if (current.indexOf(value) < 0) {\n kendo.addAttribute(element, attribute, value);\n } else {\n kendo.removeAttribute(element, attribute, value);\n }\n };\n\n kendo.matchesMedia = function(mediaQuery) {\n var media = kendo._bootstrapToMedia(mediaQuery) || mediaQuery;\n return support.matchMedia && window.matchMedia(media).matches;\n };\n\n kendo._bootstrapToMedia = function(bootstrapMedia) {\n return {\n \"xs\": \"(max-width: 576px)\",\n \"sm\": \"(min-width: 576px)\",\n \"md\": \"(min-width: 768px)\",\n \"lg\": \"(min-width: 992px)\",\n \"xl\": \"(min-width: 1200px)\"\n }[bootstrapMedia];\n };\n\n kendo.fileGroupMap = {\n audio: [\".aif\", \".iff\", \".m3u\", \".m4a\", \".mid\", \".mp3\", \".mpa\", \".wav\", \".wma\", \".ogg\", \".wav\", \".wma\", \".wpl\"],\n video: [\".3g2\", \".3gp\", \".avi\", \".asf\", \".flv\", \".m4u\", \".rm\", \".h264\", \".m4v\", \".mkv\", \".mov\", \".mp4\", \".mpg\",\n \".rm\", \".swf\", \".vob\", \".wmv\"],\n image: [\".ai\", \".dds\", \".heic\", \".jpe\", \"jfif\", \".jif\", \".jp2\", \".jps\", \".eps\", \".bmp\", \".gif\", \".jpeg\",\n \".jpg\", \".png\", \".ps\", \".psd\", \".svg\", \".svgz\", \".tif\", \".tiff\"],\n txt: [\".doc\", \".docx\", \".log\", \".pages\", \".tex\", \".wpd\", \".wps\", \".odt\", \".rtf\", \".text\", \".txt\", \".wks\"],\n presentation: [\".key\", \".odp\", \".pps\", \".ppt\", \".pptx\"],\n data: [\".xlr\", \".xls\", \".xlsx\"],\n programming: [\".tmp\", \".bak\", \".msi\", \".cab\", \".cpl\", \".cur\", \".dll\", \".dmp\", \".drv\", \".icns\", \".ico\", \".link\",\n \".sys\", \".cfg\", \".ini\", \".asp\", \".aspx\", \".cer\", \".csr\", \".css\", \".dcr\", \".htm\", \".html\", \".js\",\n \".php\", \".rss\", \".xhtml\"],\n pdf: [\".pdf\"],\n config: [\".apk\", \".app\", \".bat\", \".cgi\", \".com\", \".exe\", \".gadget\", \".jar\", \".wsf\"],\n zip: [\".7z\", \".cbr\", \".gz\", \".sitx\", \".arj\", \".deb\", \".pkg\", \".rar\", \".rpm\", \".tar.gz\", \".z\", \".zip\", \".zipx\"],\n \"disc-image\": [\".dmg\", \".iso\", \".toast\", \".vcd\", \".bin\", \".cue\", \".mdf\"]\n };\n\n kendo.getFileGroup = function(extension, withPrefix) {\n var fileTypeMap = kendo.fileGroupMap;\n var groups = Object.keys(fileTypeMap);\n var type = \"file\";\n\n if (extension === undefined || !extension.length) {\n return type;\n }\n\n for (var i = 0; i < groups.length; i += 1) {\n var extensions = fileTypeMap[groups[i]];\n\n if (extensions.indexOf(extension.toLowerCase()) > -1) {\n return withPrefix ? \"file-\" + groups[i] : groups[i];\n }\n }\n\n return type;\n };\n\n kendo.getFileSizeMessage = function(size) {\n var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];\n\n if (size === 0) {\n return '0 Byte';\n }\n\n var i = parseInt(Math.floor(Math.log(size) / Math.log(1024)), 10);\n return Math.round(size / Math.pow(1024, i), 2) + ' ' + sizes[i];\n };\n\n kendo.selectorFromClasses = function(classes) {\n return \".\"+classes.split(\" \").join(\".\");\n };\n\n // Standardized Properties and CSS classes\n\n var themeColorValues = ['base', 'primary', 'secondary', 'tertiary', 'inherit', 'info', 'success', 'warning', 'error', 'dark', 'light', 'inverse'];\n var fillValues = ['solid', 'outline', 'flat'];\n //var postitionValues = ['edge', 'outside', 'inside'];\n var shapeValues = ['rectangle', 'square'];\n var sizeValues = [ ['small', 'sm'], ['medium', 'md'], ['large', 'lg'] ];\n var roundedValues = [ ['small', 'sm'], ['medium', 'md'], ['large', 'lg'] ];\n //var alignValues = [ ['top start', 'top-start'], ['top end', 'top-end'], ['bottom start', 'bottom-start'], ['bottom end', 'bottom-end'] ];\n var positionModeValues = [ 'fixed', 'static', 'sticky', 'absolute' ];\n var resizeValues = [ 'both', 'horizontal', 'vertical' ];\n var overflowValues = [ 'auto', 'hidden', 'visible', 'scroll', 'clip' ];\n\n kendo.cssProperties = (function() {\n var defaultValues = {},\n propertyDictionary = {};\n\n function registerPrefix(widget, prefix) {\n var dict = kendo.cssProperties.propertyDictionary;\n\n if (!dict[widget]) {\n dict[widget] = {};\n }\n\n dict[widget][PREFIX] = prefix;\n }\n\n function registerValues(widget, args) {\n var dict = kendo.cssProperties.propertyDictionary,\n i, j, prop, values, newValues, currentValue;\n\n for (i = 0; i < args.length; i++) {\n prop = args[i].prop;\n newValues = args[i].values;\n\n if(!dict[widget][prop]) {\n dict[widget][prop] = {};\n }\n\n values = dict[widget][prop];\n\n for (j = 0; j < newValues.length; j++) {\n currentValue = newValues[j];\n\n if (isArray(newValues[j])) {\n values[currentValue[0]] = currentValue[1];\n } else {\n values[currentValue] = currentValue;\n }\n }\n }\n }\n\n function registerCssClass(propName, value, shorthand) {\n if (!defaultValues[propName]) {\n defaultValues[propName] = {};\n }\n\n defaultValues[propName][value] = shorthand || value;\n }\n\n function registerCssClasses(propName, arr) {\n for (var i = 0; i < arr.length; i++) {\n if (isArray(arr[i])) {\n registerCssClass(propName, arr[i][0], arr[i][1]);\n } else {\n registerCssClass(propName, arr[i]);\n }\n }\n }\n\n function getValidClass(args) {\n var widget = args.widget,\n propName = args.propName,\n value = args.value,\n fill = args.fill,\n cssProperties = kendo.cssProperties,\n defaultValues = cssProperties.defaultValues[propName],\n widgetProperties = cssProperties.propertyDictionary[widget],\n widgetValues, validValue, prefix;\n\n if(!widgetProperties) {\n return \"\";\n }\n\n widgetValues = widgetProperties[propName];\n validValue = widgetValues ? widgetValues[value] || defaultValues[value] : defaultValues[value];\n\n if (validValue) {\n if (propName === \"themeColor\") {\n prefix = widgetProperties[PREFIX] + fill + \"-\";\n } else if (propName === \"positionMode\") {\n prefix = \"k-pos-\";\n } else if (propName === \"rounded\") {\n prefix = \"k-rounded-\";\n } else if (propName === \"resize\") {\n prefix = \"k-resize-\";\n } else if (propName === \"overflow\") {\n prefix = \"k-overflow-\";\n } else {\n prefix = widgetProperties[PREFIX];\n }\n\n return prefix + validValue;\n } else {\n return \"\";\n }\n }\n\n registerCssClasses(\"themeColor\", themeColorValues);\n registerCssClasses(\"fillMode\", fillValues);\n registerCssClasses(\"shape\", shapeValues);\n registerCssClasses(\"size\", sizeValues);\n registerCssClasses(\"positionMode\", positionModeValues);\n registerCssClasses(\"rounded\", roundedValues);\n registerCssClasses(\"resize\", resizeValues);\n registerCssClasses(\"overflow\", overflowValues);\n\n return {\n positionModeValues: positionModeValues,\n roundedValues: roundedValues,\n sizeValues: sizeValues,\n shapeValues: shapeValues,\n fillModeValues: fillValues,\n themeColorValues: themeColorValues,\n\n defaultValues: defaultValues,\n propertyDictionary: propertyDictionary,\n\n registerValues: registerValues,\n getValidClass: getValidClass,\n registerPrefix: registerPrefix\n };\n }());\n\n //To do: delete below after implementing new styles and classes for BottomNavigation\n kendo.registerCssClass = function (propName, value, shorthand) {\n if (!kendo.propertyToCssClassMap[propName]) {\n kendo.propertyToCssClassMap[propName] = {};\n }\n\n kendo.propertyToCssClassMap[propName][value] = shorthand || value;\n };\n\n kendo.registerCssClasses = function (propName, arr) {\n for (var i = 0; i < arr.length; i++) {\n if (isArray(arr[i])) {\n kendo.registerCssClass(propName, arr[i][0], arr[i][1]);\n } else {\n kendo.registerCssClass(propName, arr[i]);\n }\n }\n };\n\n kendo.getValidCssClass = function (prefix, propName, value) {\n var validValue = kendo.propertyToCssClassMap[propName][value];\n\n if (validValue) {\n return prefix + validValue;\n }\n };\n\n kendo.propertyToCssClassMap = {};\n\n kendo.registerCssClasses(\"themeColor\", themeColorValues);\n kendo.registerCssClasses(\"fill\", fillValues);\n //kendo.registerCssClasses(\"postition\", postitionValues);\n kendo.registerCssClasses(\"shape\", shapeValues);\n kendo.registerCssClasses(\"size\", sizeValues);\n //kendo.registerCssClasses(\"align\", alignValues);\n kendo.registerCssClasses(\"positionMode\", positionModeValues);\n\n // jQuery deferred helpers\n\n // influenced from: https://gist.github.com/fearphage/4341799\n kendo.whenAll = function(array) {\n var resolveValues = arguments.length == 1 && Array.isArray(array) ? array : Array.prototype.slice.call(arguments),\n length = resolveValues.length,\n remaining = length,\n deferred = $.Deferred(),\n i = 0,\n failed = 0,\n rejectContexts = Array(length),\n rejectValues = Array(length),\n resolveContexts = Array(length),\n value;\n\n function updateFunc (index, contexts, values) {\n return function() {\n if(values != resolveValues) {\n failed++;\n }\n\n deferred.notifyWith(\n contexts[index] = this,\n values[index] = Array.prototype.slice.call(arguments)\n );\n\n if (!(--remaining)) {\n deferred[(!failed ? 'resolve' : 'reject') + 'With'](contexts, values);\n }\n };\n }\n\n for (; i < length; i++) {\n if ((value = resolveValues[i]) && kendo.isFunction(value.promise)) {\n value.promise()\n .done(updateFunc(i, resolveContexts, resolveValues))\n .fail(updateFunc(i, rejectContexts, rejectValues));\n }\n\n else {\n deferred.notifyWith(this, value);\n --remaining;\n }\n }\n\n if (!remaining) {\n deferred.resolveWith(resolveContexts, resolveValues);\n }\n\n return deferred.promise();\n };\n\n // kendo.saveAs -----------------------------------------------\n (function() {\n function postToProxy(dataURI, fileName, proxyURL, proxyTarget) {\n var form = $(\"
\").attr({\n action: proxyURL,\n method: \"POST\",\n target: proxyTarget\n });\n\n var data = kendo.antiForgeryTokens();\n data.fileName = fileName;\n\n var parts = dataURI.split(\";base64,\");\n data.contentType = parts[0].replace(\"data:\", \"\");\n data.base64 = parts[1];\n\n for (var name in data) {\n if (data.hasOwnProperty(name)) {\n $('').attr({\n value: data[name],\n name: name,\n type: \"hidden\"\n }).appendTo(form);\n }\n }\n\n form.appendTo(\"body\").submit().remove();\n }\n\n var fileSaver = document.createElement(\"a\");\n var downloadAttribute = \"download\" in fileSaver && !kendo.support.browser.edge;\n\n function saveAsBlob(dataURI, fileName) {\n var blob = dataURI; // could be a Blob object\n\n if (typeof dataURI == \"string\") {\n var parts = dataURI.split(\";base64,\");\n var contentType = parts[0];\n var base64 = atob(parts[1]);\n var array = new Uint8Array(base64.length);\n\n for (var idx = 0; idx < base64.length; idx++) {\n array[idx] = base64.charCodeAt(idx);\n }\n blob = new Blob([array.buffer], { type: contentType });\n }\n\n navigator.msSaveBlob(blob, fileName);\n }\n\n function saveAsDataURI(dataURI, fileName) {\n if (window.Blob && dataURI instanceof Blob) {\n dataURI = URL.createObjectURL(dataURI);\n }\n\n fileSaver.download = fileName;\n fileSaver.href = dataURI;\n\n var e = document.createEvent(\"MouseEvents\");\n e.initMouseEvent(\"click\", true, false, window,\n 0, 0, 0, 0, 0, false, false, false, false, 0, null);\n\n fileSaver.dispatchEvent(e);\n setTimeout(function(){\n URL.revokeObjectURL(dataURI);\n });\n }\n\n kendo.saveAs = function(options) {\n var save = postToProxy;\n\n if (!options.forceProxy) {\n if (downloadAttribute) {\n save = saveAsDataURI;\n } else if (navigator.msSaveBlob) {\n save = saveAsBlob;\n }\n }\n\n save(options.dataURI, options.fileName, options.proxyURL, options.proxyTarget);\n };\n })();\n\n // kendo proxySetters\n kendo.proxyModelSetters = function proxyModelSetters(data) {\n var observable = {};\n\n Object.keys(data || {}).forEach(function(property) {\n Object.defineProperty(observable, property, {\n get: function() {\n return data[property];\n },\n set: function(value) {\n data[property] = value;\n data.dirty = true;\n }\n });\n });\n\n return observable;\n };\n\n kendo.getSeriesColors = function() {\n var seriesColorsTemplate = '
' +\n '
' +\n '
' +\n '
' +\n '
' +\n '
',\n series = $(seriesColorsTemplate),\n colors = [];\n\n series.appendTo($('body'));\n\n series.each(function(i, item) {\n colors.push($(item).css(\"background-color\"));\n });\n\n series.remove();\n\n return colors;\n };\n\n kendo.isElement = function(element) {\n return element instanceof Element || element instanceof HTMLDocument; // jshint ignore:line\n };\n\n // Kendo defaults\n (function() {\n\n kendo.defaults = kendo.defaults || {};\n kendo.setDefaults = function(key, value) {\n var path = key.split(\".\");\n var curr = kendo.defaults;\n\n key = path.pop();\n\n path.forEach(function(part) {\n if (curr[part] === undefined) {\n curr[part] = {};\n }\n\n curr = curr[part];\n });\n\n if (value.constructor === Object) {\n curr[key] = deepExtend({}, curr[key], value);\n } else {\n curr[key] = value;\n }\n };\n\n })();\n\n // Implement type() as it has been depricated in jQuery\n (function() {\n kendo.class2type = {};\n\n jQuery.each( \"Boolean Number String Function Array Date RegExp Object Error Symbol\".split( \" \" ),\n function( _i, name ) {\n kendo.class2type[ \"[object \" + name + \"]\" ] = name.toLowerCase();\n } );\n\n kendo.type = function(obj) {\n if ( obj == null ) {\n return obj + \"\";\n }\n\n // Support: Android <=2.3 only (functionish RegExp)\n return typeof obj === \"object\" || typeof obj === \"function\" ?\n kendo.class2type[Object.prototype.toString.call(obj)] || \"object\" :\n typeof obj;\n };\n }());\n\n})(jQuery, window);\n\nreturn window.kendo;\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n\n(function(f, define){\n define('kendo.router',[ \"./kendo.core\" ], f);\n})(function(){\n\nvar __meta__ = { // jshint ignore:line\n id: \"router\",\n name: \"Router\",\n category: \"framework\",\n description: \"The Router class is responsible for tracking the application state and navigating between the application states.\",\n depends: [ \"core\" ],\n hidden: false\n};\n\n(function($, undefined) {\n var kendo = window.kendo,\n CHANGE = \"change\",\n BACK = \"back\",\n SAME = \"same\",\n support = kendo.support,\n location = window.location,\n history = window.history,\n CHECK_URL_INTERVAL = 50,\n BROKEN_BACK_NAV = kendo.support.browser.msie,\n hashStrip = /^#*/,\n document = window.document;\n\n function absoluteURL(path, pathPrefix) {\n if (!pathPrefix) {\n return path;\n }\n\n if (path + \"/\" === pathPrefix) {\n path = pathPrefix;\n }\n\n var regEx = new RegExp(\"^\" + pathPrefix, \"i\");\n\n if (!regEx.test(path)) {\n path = pathPrefix + \"/\" + path;\n }\n\n return location.protocol + '//' + (location.host + \"/\" + path).replace(/\\/\\/+/g, '/');\n }\n\n function hashDelimiter(bang) {\n return bang ? \"#!\" : \"#\";\n }\n\n function locationHash(hashDelimiter) {\n var href = location.href;\n\n // ignore normal anchors if in hashbang mode - however, still return \"\" if no hash present\n if (hashDelimiter === \"#!\" && href.indexOf(\"#\") > -1 && href.indexOf(\"#!\") < 0) {\n return null;\n }\n\n return href.split(hashDelimiter)[1] || \"\";\n }\n\n function stripRoot(root, url) {\n if (url.indexOf(root) === 0) {\n return (url.substr(root.length)).replace(/\\/\\//g, '/');\n } else {\n return url;\n }\n }\n\n var HistoryAdapter = kendo.Class.extend({\n back: function() {\n if (BROKEN_BACK_NAV) {\n setTimeout(function() { history.back(); });\n } else {\n history.back();\n }\n },\n\n forward: function() {\n if (BROKEN_BACK_NAV) {\n setTimeout(function() { history.forward(); });\n } else {\n history.forward();\n }\n },\n\n length: function() {\n return history.length;\n },\n\n replaceLocation: function(url) {\n location.replace(url);\n }\n });\n\n var PushStateAdapter = HistoryAdapter.extend({\n init: function(root) {\n this.root = root;\n },\n\n navigate: function(to) {\n history.pushState({}, document.title, absoluteURL(to, this.root));\n },\n\n replace: function(to) {\n history.replaceState({}, document.title, absoluteURL(to, this.root));\n },\n\n normalize: function(url) {\n return stripRoot(this.root, url);\n },\n\n current: function() {\n var current = location.pathname;\n\n if (location.search) {\n current += location.search;\n }\n\n return stripRoot(this.root, current);\n },\n\n change: function(callback) {\n $(window).bind(\"popstate.kendo\", callback);\n },\n\n stop: function() {\n $(window).unbind(\"popstate.kendo\");\n },\n\n normalizeCurrent: function(options) {\n var fixedUrl,\n root = options.root,\n pathname = location.pathname,\n hash = locationHash(hashDelimiter(options.hashBang));\n\n if (root === pathname + \"/\") {\n fixedUrl = root;\n }\n\n if (root === pathname && hash) {\n fixedUrl = absoluteURL(hash.replace(hashStrip, ''), root);\n }\n\n if (fixedUrl) {\n history.pushState({}, document.title, fixedUrl);\n }\n }\n });\n\n function fixHash(url) {\n return url.replace(/^(#)?/, \"#\");\n }\n\n function fixBang(url) {\n return url.replace(/^(#(!)?)?/, \"#!\");\n }\n\n var HashAdapter = HistoryAdapter.extend({\n init: function(bang) {\n this._id = kendo.guid();\n this.prefix = hashDelimiter(bang);\n this.fix = bang ? fixBang : fixHash;\n },\n\n navigate: function(to) {\n location.hash = this.fix(to);\n },\n\n replace: function(to) {\n this.replaceLocation(this.fix(to));\n },\n\n normalize: function(url) {\n if (url.indexOf(this.prefix) < 0) {\n return url;\n } else {\n return url.split(this.prefix)[1];\n }\n },\n\n change: function(callback) {\n if (support.hashChange) {\n $(window).on(\"hashchange.\" + this._id, callback);\n } else {\n this._interval = setInterval(callback, CHECK_URL_INTERVAL);\n }\n },\n\n stop: function() {\n $(window).off(\"hashchange.\" + this._id);\n clearInterval(this._interval);\n },\n\n current: function() {\n return locationHash(this.prefix);\n },\n\n normalizeCurrent: function(options) {\n var pathname = location.pathname,\n root = options.root;\n\n if (options.pushState && root !== pathname) {\n this.replaceLocation(root + this.prefix + stripRoot(root, pathname));\n return true; // browser will reload at this point.\n }\n\n return false;\n }\n });\n\n var History = kendo.Observable.extend({\n start: function(options) {\n options = options || {};\n\n this.bind([CHANGE, BACK, SAME], options);\n\n if (this._started) {\n return;\n }\n\n this._started = true;\n\n options.root = options.root || \"/\";\n\n var adapter = this.createAdapter(options),\n current;\n\n // adapter may reload the document\n if (adapter.normalizeCurrent(options)) {\n return;\n }\n\n current = adapter.current();\n\n $.extend(this, {\n adapter: adapter,\n root: options.root,\n historyLength: adapter.length(),\n current: current,\n locations: [current]\n });\n\n adapter.change($.proxy(this, \"_checkUrl\"));\n },\n\n createAdapter:function(options) {\n return support.pushState && options.pushState ? new PushStateAdapter(options.root) : new HashAdapter(options.hashBang);\n },\n\n stop: function() {\n if (!this._started) {\n return;\n }\n this.adapter.stop();\n this.unbind(CHANGE);\n this._started = false;\n },\n\n change: function(callback) {\n this.bind(CHANGE, callback);\n },\n\n replace: function(to, silent) {\n\n this._navigate(to, silent, function(adapter) {\n adapter.replace(to);\n this.locations[this.locations.length - 1] = this.current;\n });\n },\n\n navigate: function(to, silent) {\n if (to === \"#:back\") {\n this.backCalled = true;\n this.adapter.back();\n return;\n }\n\n this._navigate(to, silent, function(adapter) {\n adapter.navigate(to);\n this.locations.push(this.current);\n });\n },\n\n _navigate: function(to, silent, callback) {\n var adapter = this.adapter;\n\n to = adapter.normalize(to);\n\n if (this.current === to || this.current === decodeURIComponent(to)) {\n this.trigger(SAME);\n return;\n }\n\n if (!silent) {\n if (this.trigger(CHANGE, { url: to, decode: false })) {\n return;\n }\n }\n\n this.current = to;\n\n callback.call(this, adapter);\n\n this.historyLength = adapter.length();\n },\n\n _checkUrl: function() {\n var adapter = this.adapter,\n current = adapter.current(),\n newLength = adapter.length(),\n navigatingInExisting = this.historyLength === newLength,\n back = current === this.locations[this.locations.length - 2] && navigatingInExisting,\n backCalled = this.backCalled,\n prev = this.current;\n\n if (current === null || this.current === current || this.current === decodeURIComponent(current)) {\n return true;\n }\n\n this.historyLength = newLength;\n this.backCalled = false;\n\n this.current = current;\n\n if (back && this.trigger(\"back\", { url: prev, to: current })) {\n adapter.forward();\n this.current = prev;\n return;\n }\n\n if (this.trigger(CHANGE, { url: current, backButtonPressed: !backCalled })) {\n if (back) {\n adapter.forward();\n } else {\n adapter.back();\n this.historyLength --;\n }\n this.current = prev;\n return;\n }\n\n if (back) {\n this.locations.pop();\n } else {\n this.locations.push(current);\n }\n }\n });\n\n kendo.History = History;\n kendo.History.HistoryAdapter = HistoryAdapter;\n kendo.History.HashAdapter = HashAdapter;\n kendo.History.PushStateAdapter = PushStateAdapter;\n kendo.absoluteURL = absoluteURL;\n kendo.history = new History();\n})(window.kendo.jQuery);\n\n(function() {\n var kendo = window.kendo,\n history = kendo.history,\n Observable = kendo.Observable,\n INIT = \"init\",\n ROUTE_MISSING = \"routeMissing\",\n CHANGE = \"change\",\n BACK = \"back\",\n SAME = \"same\",\n optionalParam = /\\((.*?)\\)/g,\n namedParam = /(\\(\\?)?:\\w+/g,\n splatParam = /\\*\\w+/g,\n escapeRegExp = /[\\-{}\\[\\]+?.,\\\\\\^$|#\\s]/g;\n\n function namedParamReplace(match, optional) {\n return optional ? match : '([^\\/]+)';\n }\n\n function routeToRegExp(route, ignoreCase) {\n return new RegExp('^' + route\n .replace(escapeRegExp, '\\\\$&')\n .replace(optionalParam, '(?:$1)?')\n .replace(namedParam, namedParamReplace)\n .replace(splatParam, '(.*?)') + '$', ignoreCase ? \"i\" : \"\");\n }\n\n function stripUrl(url) {\n return url.replace(/(\\?.*)|(#.*)/g, \"\");\n }\n\n var Route = kendo.Class.extend({\n init: function(route, callback, ignoreCase) {\n if (!(route instanceof RegExp)) {\n route = routeToRegExp(route, ignoreCase);\n }\n\n this.route = route;\n this._callback = callback;\n },\n\n callback: function(url, back, decode) {\n var params,\n idx = 0,\n length,\n queryStringParams = kendo.parseQueryStringParams(url);\n queryStringParams._back = back;\n\n url = stripUrl(url);\n params = this.route.exec(url).slice(1);\n length = params.length;\n\n if (decode) {\n for (; idx < length; idx ++) {\n if (typeof params[idx] !== 'undefined') {\n params[idx] = decodeURIComponent(params[idx]);\n }\n }\n }\n\n params.push(queryStringParams);\n\n this._callback.apply(null, params);\n },\n\n worksWith: function(url, back, decode) {\n if (this.route.test(stripUrl(url))) {\n this.callback(url, back, decode);\n return true;\n } else {\n return false;\n }\n }\n });\n\n var Router = Observable.extend({\n init: function(options) {\n if (!options) {\n options = {};\n }\n\n Observable.fn.init.call(this);\n\n this.routes = [];\n this.pushState = options.pushState;\n this.hashBang = options.hashBang;\n this.root = options.root;\n this.ignoreCase = options.ignoreCase !== false;\n\n this.bind([INIT, ROUTE_MISSING, CHANGE, SAME, BACK], options);\n },\n\n destroy: function() {\n history.unbind(CHANGE, this._urlChangedProxy);\n history.unbind(SAME, this._sameProxy);\n history.unbind(BACK, this._backProxy);\n this.unbind();\n },\n\n start: function() {\n var that = this,\n sameProxy = function() { that._same(); },\n backProxy = function(e) { that._back(e); },\n urlChangedProxy = function(e) { that._urlChanged(e); };\n\n history.start({\n same: sameProxy,\n change: urlChangedProxy,\n back: backProxy,\n pushState: that.pushState,\n hashBang: that.hashBang,\n root: that.root\n });\n\n var initEventObject = { url: history.current || \"/\", preventDefault: $.noop };\n\n if (!that.trigger(INIT, initEventObject)) {\n that._urlChanged(initEventObject);\n }\n\n this._urlChangedProxy = urlChangedProxy;\n this._backProxy = backProxy;\n },\n\n route: function(route, callback) {\n this.routes.push(new Route(route, callback, this.ignoreCase));\n },\n\n navigate: function(url, silent) {\n kendo.history.navigate(url, silent);\n },\n\n replace: function(url, silent) {\n kendo.history.replace(url, silent);\n },\n\n _back: function(e) {\n if (this.trigger(BACK, { url: e.url, to: e.to })) {\n e.preventDefault();\n }\n },\n\n _same: function() {\n this.trigger(SAME);\n },\n\n _urlChanged: function(e) {\n var url = e.url;\n var decode = !!e.decode;\n var back = e.backButtonPressed;\n\n if (!url) {\n url = \"/\";\n }\n\n if (this.trigger(CHANGE, { url: e.url, params: kendo.parseQueryStringParams(e.url), backButtonPressed: back })) {\n e.preventDefault();\n return;\n }\n\n var idx = 0,\n routes = this.routes,\n route,\n length = routes.length;\n\n for (; idx < length; idx ++) {\n route = routes[idx];\n\n if (route.worksWith(url, back, decode)) {\n return;\n }\n }\n\n if (this.trigger(ROUTE_MISSING, { url: url, params: kendo.parseQueryStringParams(url), backButtonPressed: back })) {\n e.preventDefault();\n }\n }\n });\n\n kendo.Router = Router;\n})();\n\nreturn window.kendo;\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n\n(function(f, define){\n define('kendo.data.odata',[ \"./kendo.core\" ], f);\n})(function(){\n\nvar __meta__ = { // jshint ignore:line\n id: \"data.odata\",\n name: \"OData\",\n category: \"framework\",\n depends: [ \"core\" ],\n hidden: true\n};\n\n(function($, undefined) {\n var kendo = window.kendo,\n extend = $.extend,\n NEWLINE = \"\\r\\n\",\n DOUBLELINE = \"\\r\\n\\r\\n\",\n isFunction = kendo.isFunction,\n odataFilters = {\n eq: \"eq\",\n neq: \"ne\",\n gt: \"gt\",\n gte: \"ge\",\n lt: \"lt\",\n lte: \"le\",\n contains : \"substringof\",\n doesnotcontain: \"substringof\",\n endswith: \"endswith\",\n startswith: \"startswith\",\n isnull: \"eq\",\n isnotnull: \"ne\",\n isnullorempty: \"eq\",\n isnotnullorempty: \"ne\",\n isempty: \"eq\",\n isnotempty: \"ne\"\n },\n odataFiltersVersionFour = extend({}, odataFilters, {\n contains: \"contains\"\n }),\n mappers = {\n pageSize: $.noop,\n page: $.noop,\n filter: function(params, filter, useVersionFour) {\n if (filter) {\n filter = toOdataFilter(filter, useVersionFour);\n if (filter) {\n params.$filter = filter;\n }\n }\n },\n sort: function(params, orderby) {\n var expr = $.map(orderby, function(value) {\n var order = value.field.replace(/\\./g, \"/\");\n\n if (value.dir === \"desc\") {\n order += \" desc\";\n }\n\n return order;\n }).join(\",\");\n\n if (expr) {\n params.$orderby = expr;\n }\n },\n skip: function(params, skip) {\n if (skip) {\n params.$skip = skip;\n }\n },\n take: function(params, take) {\n if (take) {\n params.$top = take;\n }\n }\n },\n defaultDataType = {\n read: {\n dataType: \"jsonp\"\n }\n };\n\n function toOdataFilter(filter, useOdataFour) {\n var result = [],\n logic = filter.logic || \"and\",\n idx,\n length,\n field,\n type,\n format,\n operator,\n value,\n ignoreCase,\n filters = filter.filters;\n\n for (idx = 0, length = filters.length; idx < length; idx++) {\n filter = filters[idx];\n field = filter.field;\n value = filter.value;\n operator = filter.operator;\n\n if (filter.filters) {\n filter = toOdataFilter(filter, useOdataFour);\n } else {\n ignoreCase = filter.ignoreCase;\n field = field.replace(/\\./g, \"/\");\n filter = odataFilters[operator];\n if (useOdataFour) {\n filter = odataFiltersVersionFour[operator];\n }\n\n if (operator === \"isnullorempty\") {\n filter = kendo.format(\"{0} {1} null or {0} {1} ''\", field, filter);\n } else if(operator === \"isnotnullorempty\") {\n filter = kendo.format(\"{0} {1} null and {0} {1} ''\", field, filter);\n } else if (operator === \"isnull\" || operator === \"isnotnull\") {\n filter = kendo.format(\"{0} {1} null\", field, filter);\n } else if (operator === \"isempty\" || operator === \"isnotempty\") {\n filter = kendo.format(\"{0} {1} ''\", field, filter);\n } else if (filter && value !== undefined) {\n type = kendo.type(value);\n if (type === \"string\") {\n format = \"'{1}'\";\n value = value.replace(/'/g, \"''\");\n\n if (ignoreCase === true) {\n field = \"tolower(\" + field + \")\";\n }\n\n } else if (type === \"date\") {\n if (useOdataFour) {\n format = \"{1:yyyy-MM-ddTHH:mm:ss+00:00}\";\n value = kendo.timezone.apply(value, 'Etc/UTC');\n } else {\n format = \"datetime'{1:yyyy-MM-ddTHH:mm:ss}'\";\n }\n } else {\n format = \"{1}\";\n }\n\n if (filter.length > 3) {\n if (filter !== \"substringof\") {\n format = \"{0}({2},\" + format + \")\";\n } else {\n format = \"{0}(\" + format + \",{2})\";\n if (operator === \"doesnotcontain\") {\n if (useOdataFour) {\n format = \"{0}({2},'{1}') eq -1\";\n filter = \"indexof\";\n } else {\n format += \" eq false\";\n }\n }\n }\n } else {\n format = \"{2} {0} \" + format;\n }\n\n filter = kendo.format(format, filter, value, field);\n }\n }\n\n result.push(filter);\n }\n\n filter = result.join(\" \" + logic + \" \");\n\n if (result.length > 1) {\n filter = \"(\" + filter + \")\";\n }\n\n return filter;\n }\n\n function stripMetadata(obj) {\n for (var name in obj) {\n if(name.indexOf(\"@odata\") === 0) {\n delete obj[name];\n }\n }\n }\n\n function hex16() {\n return Math.floor((1 + Math.random()) * 0x10000).toString(16).substr(1);\n }\n\n function createBoundary(prefix) {\n return prefix + hex16() + '-' + hex16() + '-' + hex16();\n }\n\n function createDelimeter(boundary, close) {\n var result = NEWLINE + \"--\" + boundary;\n\n if (close) {\n result += \"--\";\n }\n\n return result;\n }\n\n function createCommand(transport, item, httpVerb, command) {\n var transportUrl = transport.options[command].url;\n var commandPrefix = kendo.format(\"{0} \", httpVerb);\n\n if (isFunction(transportUrl)) {\n return commandPrefix + transportUrl(item);\n } else {\n return commandPrefix + transportUrl;\n }\n }\n\n function getOperationHeader(changeset, changeId) {\n var header = \"\";\n\n header += createDelimeter(changeset, false);\n header += NEWLINE + 'Content-Type: application/http';\n header += NEWLINE + 'Content-Transfer-Encoding: binary';\n header += NEWLINE + 'Content-ID: ' + changeId;\n\n return header;\n }\n\n function getOperationContent(item) {\n var content = \"\";\n\n content += NEWLINE + \"Content-Type: application/json;odata=minimalmetadata\";\n content += NEWLINE + \"Prefer: return=representation\";\n content += DOUBLELINE + kendo.stringify(item);\n\n return content;\n }\n\n function getOperations(collection, changeset, changeId, command, transport, skipContent) {\n var requestBody = \"\";\n\n for (var i = 0; i < collection.length; i++) {\n requestBody += getOperationHeader(changeset, changeId);\n requestBody += DOUBLELINE + createCommand(transport, collection[i], transport.options[command].type, command) + ' HTTP/1.1';\n if (!skipContent) {\n requestBody += getOperationContent(collection[i]);\n }\n requestBody += NEWLINE;\n changeId++;\n }\n\n return requestBody;\n }\n\n function processCollection(colection, boundary, changeset, changeId, transport, command, skipContent) {\n var requestBody = \"\";\n\n requestBody += getBoundary(boundary, changeset);\n requestBody += getOperations(colection, changeset, changeId, command, transport, skipContent);\n requestBody += createDelimeter(changeset, true);\n requestBody += NEWLINE;\n\n return requestBody;\n }\n\n function getBoundary(boundary,changeset) {\n var requestBody = \"\";\n\n requestBody += \"--\" + boundary + NEWLINE;\n requestBody += \"Content-Type: multipart/mixed; boundary=\" + changeset + NEWLINE;\n\n return requestBody;\n }\n\n function createBatchRequest(transport, colections) {\n\t\tvar options = extend({}, transport.options.batch);\n var boundary = createBoundary(\"sf_batch_\");\n var requestBody = \"\";\n var changeId = 0;\n var batchURL = transport.options.batch.url;\n var changeset = createBoundary(\"sf_changeset_\");\n\n options.type = transport.options.batch.type;\n options.url = isFunction(batchURL) ? batchURL() : batchURL;\n\t\toptions.headers = extend(options.headers || {}, {\n\t\t\t\"Content-Type\": \"multipart/mixed; boundary=\" + boundary\n\t\t});\n\n if (colections.updated.length) {\n requestBody += processCollection(colections.updated, boundary, changeset, changeId, transport, \"update\", false);\n changeId += colections.updated.length;\n changeset = createBoundary(\"sf_changeset_\");\n }\n\n if (colections.destroyed.length) {\n requestBody += processCollection(colections.destroyed, boundary, changeset, changeId, transport, \"destroy\", true);\n changeId += colections.destroyed.length;\n changeset = createBoundary(\"sf_changeset_\");\n }\n\n if (colections.created.length) {\n requestBody += processCollection(colections.created, boundary, changeset, changeId, transport, \"create\", false);\n }\n\n requestBody += createDelimeter(boundary, true);\n\n options.data = requestBody;\n\n return options;\n }\n\n function parseBatchResponse(responseText) {\n var responseMarkers = responseText.match(/--changesetresponse_[a-z0-9-]+$/gm);\n var markerIndex = 0;\n var collections = [];\n var changeBody;\n var status;\n var code;\n var marker;\n var jsonModel;\n\n collections.push({ models: [], passed: true });\n\n for (var i = 0; i < responseMarkers.length; i++) {\n marker = responseMarkers[i];\n if (marker.lastIndexOf('--', marker.length - 1)) {\n if (i < responseMarkers.length - 1) {\n collections.push({ models: [], passed: true });\n }\n continue;\n }\n\n if (!markerIndex) {\n markerIndex = responseText.indexOf(marker);\n } else {\n markerIndex = responseText.indexOf(marker, markerIndex + marker.length);\n }\n\n changeBody = responseText.substring(markerIndex, responseText.indexOf(\"--\", markerIndex + 1));\n status = changeBody.match(/^HTTP\\/1\\.\\d (\\d{3}) (.*)$/gm).pop();\n code = kendo.parseFloat(status.match(/\\d{3}/g).pop());\n\n if (code >= 200 && code <= 299) {\n jsonModel = changeBody.match(/\\{.*\\}/gm);\n if (jsonModel) {\n collections[collections.length - 1].models.push(JSON.parse(jsonModel[0]));\n }\n } else {\n collections[collections.length - 1].passed = false;\n }\n\n }\n\n return collections;\n }\n\n extend(true, kendo.data, {\n schemas: {\n odata: {\n type: \"json\",\n data: function(data) {\n return data.d.results || [data.d];\n },\n total: \"d.__count\"\n }\n },\n transports: {\n odata: {\n read: {\n cache: true, // to prevent jQuery from adding cache buster\n dataType: \"jsonp\",\n jsonp: \"$callback\"\n },\n update: {\n cache: true,\n dataType: \"json\",\n contentType: \"application/json\", // to inform the server the the request body is JSON encoded\n type: \"PUT\" // can be PUT or MERGE\n },\n create: {\n cache: true,\n dataType: \"json\",\n contentType: \"application/json\",\n type: \"POST\" // must be POST to create new entity\n },\n destroy: {\n cache: true,\n dataType: \"json\",\n type: \"DELETE\"\n },\n parameterMap: function(options, type, useVersionFour) {\n var params,\n value,\n option,\n dataType;\n\n options = options || {};\n type = type || \"read\";\n dataType = (this.options || defaultDataType)[type];\n dataType = dataType ? dataType.dataType : \"json\";\n\n if (type === \"read\") {\n params = {\n $inlinecount: \"allpages\"\n };\n\n if (dataType != \"json\") {\n params.$format = \"json\";\n }\n\n for (option in options) {\n if (mappers[option]) {\n mappers[option](params, options[option], useVersionFour);\n } else {\n params[option] = options[option];\n }\n }\n } else {\n if (dataType !== \"json\") {\n throw new Error(\"Only json dataType can be used for \" + type + \" operation.\");\n }\n\n if (type !== \"destroy\") {\n for (option in options) {\n value = options[option];\n if (typeof value === \"number\") {\n options[option] = value + \"\";\n }\n }\n\n params = kendo.stringify(options);\n }\n }\n\n return params;\n }\n }\n }\n });\n\n extend(true, kendo.data, {\n schemas: {\n \"odata-v4\": {\n type: \"json\",\n data: function(data) {\n if (Array.isArray(data)) {\n for (var i = 0; i < data.length; i++) {\n stripMetadata(data[i]);\n }\n return data;\n } else {\n data = $.extend({}, data);\n stripMetadata(data);\n\n if (data.value) {\n return data.value;\n }\n return [data];\n }\n },\n total: function(data) {\n return data[\"@odata.count\"];\n }\n }\n },\n transports: {\n \"odata-v4\": {\n batch: {\n type: \"POST\"\n },\n read: {\n cache: true, // to prevent jQuery from adding cache buster\n dataType: \"json\"\n },\n update: {\n cache: true,\n dataType: \"json\",\n contentType: \"application/json;IEEE754Compatible=true\", // to inform the server the the request body is JSON encoded\n type: \"PUT\" // can be PUT or MERGE\n },\n create: {\n cache: true,\n dataType: \"json\",\n contentType: \"application/json;IEEE754Compatible=true\",\n type: \"POST\" // must be POST to create new entity\n },\n destroy: {\n cache: true,\n dataType: \"json\",\n type: \"DELETE\"\n },\n parameterMap: function(options, type) {\n var result = kendo.data.transports.odata.parameterMap(options, type, true);\n if (type == \"read\") {\n result.$count = true;\n delete result.$inlinecount;\n }\n\n\t\t\t\t\tif (result && result.$filter) {\n\t\t\t\t\t\t// Remove the single quotation marks around the GUID (OData v4).\n\t\t\t\t\t\tresult.$filter = result.$filter.replace(/('[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}')/ig, function (x) {\n\t\t\t\t\t\t\treturn x.substring(1, x.length - 1);\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n return result;\n },\n submit: function(e) {\n var that = this;\n var options = createBatchRequest(that, e.data);\n var collections = e.data;\n\n if (!collections.updated.length && !collections.destroyed.length && !collections.created.length) {\n return;\n }\n\n $.ajax(extend(true, {}, {\n success: function (response) {\n var responses = parseBatchResponse(response);\n var index = 0;\n var current;\n\n if (collections.updated.length) {\n current = responses[index];\n if (current.passed) {\n // Pass either the obtained models or an empty array if only status codes are returned.\n e.success(current.models.length ? current.models : [], \"update\");\n }\n index++;\n }\n if (collections.destroyed.length) {\n current = responses[index];\n if (current.passed) {\n // For delete operations OData returns only status codes.\n // Passing empty array to datasource will force it to correctly remove the deleted items from the pristine collection.\n e.success([], \"destroy\");\n }\n index++;\n }\n if (collections.created.length) {\n current = responses[index];\n if (current.passed) {\n e.success(current.models, \"create\");\n }\n }\n },\n error: function (response, status, error) {\n e.error(response, status, error);\n }\n }, options));\n }\n }\n }\n });\n\n})(window.kendo.jQuery);\n\nreturn window.kendo;\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n\n(function(f, define){\n define('kendo.data.xml',[ \"./kendo.core\" ], f);\n})(function(){\n\nvar __meta__ = { // jshint ignore:line\n id: \"data.xml\",\n name: \"XML\",\n category: \"framework\",\n depends: [ \"core\" ],\n hidden: true\n};\n\n/*jshint eqnull: true, boss: true */\n(function($, undefined) {\n var kendo = window.kendo,\n isArray = Array.isArray,\n isPlainObject = $.isPlainObject,\n map = $.map,\n each = $.each,\n extend = $.extend,\n getter = kendo.getter,\n Class = kendo.Class;\n\n var XmlDataReader = Class.extend({\n init: function(options) {\n var that = this,\n total = options.total,\n model = options.model,\n parse = options.parse,\n errors = options.errors,\n serialize = options.serialize,\n data = options.data;\n\n if (model) {\n if (isPlainObject(model)) {\n var base = options.modelBase || kendo.data.Model;\n\n if (model.fields) {\n each(model.fields, function(field, value) {\n if (isPlainObject(value) && value.field) {\n if (!kendo.isFunction(value.field)) {\n value = extend(value, { field: that.getter(value.field) });\n }\n } else {\n value = { field: that.getter(value) };\n }\n model.fields[field] = value;\n });\n }\n\n var id = model.id;\n if (id) {\n var idField = {};\n\n idField[that.xpathToMember(id, true)] = { field : that.getter(id) };\n model.fields = extend(idField, model.fields);\n model.id = that.xpathToMember(id);\n }\n model = base.define(model);\n }\n\n that.model = model;\n }\n\n if (total) {\n if (typeof total == \"string\") {\n total = that.getter(total);\n that.total = function(data) {\n return parseInt(total(data), 10);\n };\n } else if (typeof total == \"function\"){\n that.total = total;\n }\n }\n\n if (errors) {\n if (typeof errors == \"string\") {\n errors = that.getter(errors);\n that.errors = function(data) {\n return errors(data) || null;\n };\n } else if (typeof errors == \"function\"){\n that.errors = errors;\n }\n }\n\n if (data) {\n if (typeof data == \"string\") {\n data = that.xpathToMember(data);\n that.data = function(value) {\n var result = that.evaluate(value, data),\n modelInstance;\n\n result = isArray(result) ? result : [result];\n\n if (that.model && model.fields) {\n modelInstance = new that.model();\n\n return map(result, function(value) {\n if (value) {\n var record = {}, field;\n\n for (field in model.fields) {\n record[field] = modelInstance._parse(field, model.fields[field].field(value));\n }\n\n return record;\n }\n });\n }\n\n return result;\n };\n } else if (typeof data == \"function\") {\n that.data = data;\n }\n }\n\n if (typeof parse == \"function\") {\n var xmlParse = that.parse;\n\n that.parse = function(data) {\n var xml = parse.call(that, data);\n return xmlParse.call(that, xml);\n };\n }\n\n if (typeof serialize == \"function\") {\n that.serialize = serialize;\n }\n },\n total: function(result) {\n return this.data(result).length;\n },\n errors: function(data) {\n return data ? data.errors : null;\n },\n serialize: function(data) {\n return data;\n },\n parseDOM: function(element) {\n var result = {},\n parsedNode,\n node,\n nodeType,\n nodeName,\n member,\n attribute,\n attributes = element.attributes,\n attributeCount = attributes.length,\n idx;\n\n for (idx = 0; idx < attributeCount; idx++) {\n attribute = attributes[idx];\n result[\"@\" + attribute.nodeName] = attribute.nodeValue;\n }\n\n for (node = element.firstChild; node; node = node.nextSibling) {\n nodeType = node.nodeType;\n\n if (nodeType === 3 || nodeType === 4) {\n // text nodes or CDATA are stored as #text field\n result[\"#text\"] = node.nodeValue;\n } else if (nodeType === 1) {\n // elements are stored as fields\n parsedNode = this.parseDOM(node);\n\n nodeName = node.nodeName;\n\n member = result[nodeName];\n\n if (isArray(member)) {\n // elements of same nodeName are stored as array\n member.push(parsedNode);\n } else if (member !== undefined) {\n member = [member, parsedNode];\n } else {\n member = parsedNode;\n }\n\n result[nodeName] = member;\n }\n }\n return result;\n },\n\n evaluate: function(value, expression) {\n var members = expression.split(\".\"),\n member,\n result,\n length,\n intermediateResult,\n idx;\n\n while (member = members.shift()) {\n value = value[member];\n\n if (isArray(value)) {\n result = [];\n expression = members.join(\".\");\n\n for (idx = 0, length = value.length; idx < length; idx++) {\n intermediateResult = this.evaluate(value[idx], expression);\n\n intermediateResult = isArray(intermediateResult) ? intermediateResult : [intermediateResult];\n\n result.push.apply(result, intermediateResult);\n }\n\n return result;\n }\n }\n\n return value;\n },\n\n parse: function(xml) {\n var documentElement,\n tree,\n result = {};\n\n documentElement = xml.documentElement || $.parseXML(xml).documentElement;\n\n tree = this.parseDOM(documentElement);\n\n result[documentElement.nodeName] = tree;\n\n return result;\n },\n\n xpathToMember: function(member, raw) {\n if (!member) {\n return \"\";\n }\n\n member = member.replace(/^\\//, \"\") // remove the first \"/\"\n .replace(/\\//g, \".\"); // replace all \"/\" with \".\"\n\n if (member.indexOf(\"@\") >= 0) {\n // replace @attribute with '[\"@attribute\"]'\n return member.replace(/\\.?(@.*)/, raw? '$1':'[\"$1\"]');\n }\n\n if (member.indexOf(\"text()\") >= 0) {\n // replace \".text()\" with '[\"#text\"]'\n return member.replace(/(\\.?text\\(\\))/, raw? '#text':'[\"#text\"]');\n }\n\n return member;\n },\n getter: function(member) {\n return getter(this.xpathToMember(member), true);\n }\n });\n\n $.extend(true, kendo.data, {\n XmlDataReader: XmlDataReader,\n readers: {\n xml: XmlDataReader\n }\n });\n})(window.kendo.jQuery);\n\nreturn window.kendo;\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n\n(function(f, define){\n define('kendo.data',[ \"./kendo.core\", \"./kendo.data.odata\", \"./kendo.data.xml\" ], f);\n})(function(){\n\nvar __meta__ = { // jshint ignore:line\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 id: \"data-odata\",\n name: \"OData\",\n description: \"Support for accessing Open Data Protocol (OData) services.\",\n depends: [ \"data.odata\" ]\n }, {\n id: \"data-signalr\",\n name: \"SignalR\",\n description: \"Support for binding to SignalR hubs.\",\n depends: [ \"data.signalr\" ]\n }, {\n id: \"data-XML\",\n name: \"XML\",\n description: \"Support for binding to XML.\",\n depends: [ \"data.xml\" ]\n }]\n};\n\n/*jshint eqnull: true, loopfunc: true, evil: true */\n(function($, undefined) {\n var extend = $.extend,\n proxy = $.proxy,\n isPlainObject = $.isPlainObject,\n isEmptyObject = $.isEmptyObject,\n isArray = $.isArray,\n grep = $.grep,\n ajax = $.ajax,\n map,\n each = $.each,\n noop = $.noop,\n kendo = window.kendo,\n isFunction = kendo.isFunction,\n Observable = kendo.Observable,\n Class = kendo.Class,\n STRING = \"string\",\n FUNCTION = \"function\",\n ASCENDING = \"asc\",\n CREATE = \"create\",\n READ = \"read\",\n UPDATE = \"update\",\n DESTROY = \"destroy\",\n CHANGE = \"change\",\n SYNC = \"sync\",\n GET = \"get\",\n ERROR = \"error\",\n REQUESTSTART = \"requestStart\",\n PROGRESS = \"progress\",\n REQUESTEND = \"requestEnd\",\n crud = [CREATE, READ, UPDATE, DESTROY],\n identity = function(o) { return o; },\n getter = kendo.getter,\n stringify = kendo.stringify,\n math = Math,\n push = [].push,\n join = [].join,\n pop = [].pop,\n splice = [].splice,\n shift = [].shift,\n slice = [].slice,\n unshift = [].unshift,\n toString = {}.toString,\n stableSort = kendo.support.stableSort,\n dateRegExp = /^\\/Date\\((.*?)\\)\\/$/,\n objectKeys = [];\n\n var ObservableArray = Observable.extend({\n init: function(array, type) {\n var that = this;\n\n that.type = type || ObservableObject;\n\n Observable.fn.init.call(that);\n\n that.length = array.length;\n\n that.wrapAll(array, that);\n },\n\n at: function(index) {\n return this[index];\n },\n\n toJSON: function(serializeFunctions) {\n var idx, length = this.length, value, json = new Array(length);\n\n for (idx = 0; idx < length; idx++){\n value = this[idx];\n\n if (value instanceof ObservableObject) {\n value = value.toJSON(serializeFunctions);\n }\n\n json[idx] = value;\n }\n\n return json;\n },\n\n parent: noop,\n\n wrapAll: function(source, target) {\n var that = this,\n idx,\n length,\n parent = function() {\n return that;\n };\n\n target = target || [];\n\n for (idx = 0, length = source.length; idx < length; idx++) {\n target[idx] = that.wrap(source[idx], parent);\n }\n\n return target;\n },\n\n wrap: function(object, parent) {\n var that = this,\n observable;\n\n if (object !== null && toString.call(object) === \"[object Object]\") {\n observable = object instanceof that.type || object instanceof Model;\n\n if (!observable) {\n object = object instanceof ObservableObject ? object.toJSON() : object;\n object = new that.type(object);\n }\n\n object.parent = parent;\n\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\n return object;\n },\n\n push: function() {\n var index = this.length,\n items = this.wrapAll(arguments),\n result;\n\n result = push.apply(this, items);\n\n if (!this.omitChangeEvent) {\n this.trigger(CHANGE, {\n action: \"add\",\n index: index,\n items: items\n });\n }\n\n return result;\n },\n\n slice: slice,\n\n sort: [].sort,\n\n join: join,\n\n pop: function() {\n var length = this.length, result = pop.apply(this);\n\n if (length) {\n this.trigger(CHANGE, {\n action: \"remove\",\n index: length - 1,\n items:[result]\n });\n }\n\n return result;\n },\n\n splice: function(index, howMany, item) {\n var items = this.wrapAll(slice.call(arguments, 2)),\n result, i, len;\n\n result = splice.apply(this, [index, howMany].concat(items));\n\n if (result.length) {\n if (!this.omitChangeEvent) {\n this.trigger(CHANGE, {\n action: \"remove\",\n index: index,\n items: result\n });\n }\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\n if (item) {\n if (!this.omitChangeEvent) {\n this.trigger(CHANGE, {\n action: \"add\",\n index: index,\n items: items\n });\n }\n }\n return result;\n },\n\n shift: function() {\n var length = this.length, result = shift.apply(this);\n\n if (length) {\n this.trigger(CHANGE, {\n action: \"remove\",\n index: 0,\n items:[result]\n });\n }\n\n return result;\n },\n\n unshift: function() {\n var items = this.wrapAll(arguments),\n result;\n\n result = unshift.apply(this, items);\n\n this.trigger(CHANGE, {\n action: \"add\",\n index: 0,\n items: items\n });\n\n return result;\n },\n\n indexOf: function(item) {\n var that = this,\n idx,\n length;\n\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\n forEach: function(callback, thisArg) {\n var idx = 0;\n var length = this.length;\n var context = thisArg || window;\n\n for (; idx < length; idx++) {\n callback.call(context, this[idx], idx, this);\n }\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\n for (; idx < length; idx++) {\n result[idx] = callback.call(context, this[idx], idx, this);\n }\n\n return result;\n },\n\n reduce: function(callback) {\n var idx = 0,\n result,\n length = this.length;\n\n if (arguments.length == 2) {\n result = arguments[1];\n } else if (idx < length) {\n result = this[idx++];\n }\n\n for (; idx < length; idx++) {\n result = callback(result, this[idx], idx, this);\n }\n\n return result;\n },\n\n reduceRight: function(callback) {\n var idx = this.length - 1,\n result;\n\n if (arguments.length == 2) {\n result = arguments[1];\n } else if (idx > 0) {\n result = this[idx--];\n }\n\n for (; idx >= 0; idx--) {\n result = callback(result, this[idx], idx, this);\n }\n\n return result;\n },\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\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\n return result;\n },\n\n find: function(callback, thisArg) {\n var idx = 0;\n var item;\n var length = this.length;\n var context = thisArg || window;\n\n for (; idx < length; idx++) {\n item = this[idx];\n if (callback.call(context, item, idx, this)) {\n return item;\n }\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\n for (; idx < length; idx++) {\n item = this[idx];\n if (!callback.call(context, item, idx, this)) {\n return false;\n }\n }\n\n return true;\n },\n\n some: function(callback, thisArg) {\n var idx = 0;\n var item;\n var length = this.length;\n var context = thisArg || window;\n\n for (; idx < length; idx++) {\n item = this[idx];\n if (callback.call(context, item, idx, this)) {\n return true;\n }\n }\n\n return false;\n },\n\n // non-standard collection methods\n remove: function(item) {\n var idx = this.indexOf(item);\n\n if (idx !== -1) {\n this.splice(idx, 1);\n }\n },\n\n empty: function() {\n this.splice(0, this.length);\n }\n });\n\n // Polyfill for Symbol.iterator\n if (typeof Symbol !== \"undefined\" && Symbol.iterator && !ObservableArray.prototype[Symbol.iterator]) {\n ObservableArray.prototype[Symbol.iterator] = [][Symbol.iterator];\n }\n\n var LazyObservableArray = ObservableArray.extend({\n init: function (data, type, events) {\n Observable.fn.init.call(this);\n\n this.type = type || ObservableObject;\n\n if (events) {\n this._events = events;\n }\n\n for (var idx = 0; idx < data.length; idx++) {\n this[idx] = data[idx];\n }\n\n this.length = idx;\n this._parent = proxy(function() { return this; }, this);\n },\n at: function(index) {\n var item = this[index];\n\n if (!(item instanceof this.type)) {\n item = this[index] = this.wrap(item, this._parent);\n } else {\n item.parent = this._parent;\n }\n\n return item;\n }\n });\n\n function eventHandler(context, type, field, prefix) {\n return function(e) {\n var event = {}, key;\n\n for (key in e) {\n event[key] = e[key];\n }\n\n if (prefix) {\n event.field = field + \".\" + e.field;\n } else {\n event.field = field;\n }\n\n if (type == CHANGE && context._notifyChange) {\n context._notifyChange(event);\n }\n\n context.trigger(type, event);\n };\n }\n\n function ownKeys (value, ignoreObjectKeys) {\n var props = [];\n var keys, filteredObjectKeys;\n\n value = value || {};\n\n keys = Object.getOwnPropertyNames(value);\n filteredObjectKeys = objectKeys.filter(function(key){\n return keys.indexOf(key) < 0;\n });\n\n while (value) {\n Object.getOwnPropertyNames(value).forEach(function (prop) {\n if (props.indexOf(prop) === -1 && (!ignoreObjectKeys || filteredObjectKeys.indexOf(prop) < 0)) {\n props.push(prop);\n }\n });\n value = Object.getPrototypeOf(value);\n }\n\n return props;\n }\n\n objectKeys = ownKeys({}, false);\n\n var ObservableObject = Observable.extend({\n init: function(value) {\n var that = this,\n member,\n keys = ownKeys(value, true),\n parent = function() {\n return that;\n };\n\n Observable.fn.init.call(this);\n\n this._handlers = {};\n\n keys.forEach(function(field){\n member = value[field];\n\n if (typeof member === \"object\" && member && !member.getTime && field.charAt(0) != \"_\") {\n member = that.wrap(member, field, parent);\n }\n\n that[field] = member;\n });\n\n that.uid = kendo.guid();\n },\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\n forEach: function(f) {\n for (var i in this) {\n if (this.shouldSerialize(i)) {\n f(this[i], i);\n }\n }\n },\n\n toJSON: function (serializeFunctions) {\n var result = {}, value, field;\n\n for (field in this) {\n if (this.shouldSerialize(field, serializeFunctions)) {\n value = this[field];\n\n if (value instanceof ObservableObject || value instanceof ObservableArray) {\n value = value.toJSON(serializeFunctions);\n }\n\n result[field] = value;\n }\n }\n\n return result;\n },\n\n get: function(field) {\n var that = this, result;\n\n that.trigger(GET, { field: field });\n\n if (field === \"this\") {\n result = that;\n } else {\n result = kendo.getter(field, true)(that);\n }\n\n return result;\n },\n\n _set: function(field, value) {\n var that = this;\n var composite = field.indexOf(\".\") >= 0;\n\n if (composite) {\n var paths = field.split(\".\"),\n path = \"\";\n\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\n kendo.setter(field)(that, value);\n\n return composite;\n },\n\n set: function(field, value) {\n var that = this,\n isSetPrevented = false,\n composite = field.indexOf(\".\") >= 0,\n current = kendo.getter(field, true)(that);\n\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\n isSetPrevented = that.trigger(\"set\", { field: field, value: value });\n\n if (!isSetPrevented) {\n if (!composite) {\n value = that.wrap(value, field, function() { return that; });\n }\n if (!that._set(field, value) || field.indexOf(\"(\") >= 0 || field.indexOf(\"[\") >= 0) {\n that.trigger(CHANGE, { field: field });\n }\n }\n }\n\n return isSetPrevented;\n },\n\n parent: noop,\n\n wrap: function(object, field, parent) {\n var that = this;\n var get;\n var change;\n var type = toString.call(object);\n\n if (object != null && (type === \"[object Object]\" || type === \"[object Array]\")) {\n var isObservableArray = object instanceof ObservableArray;\n var isDataSource = object instanceof DataSource;\n\n if (type === \"[object Object]\" && !isDataSource && !isObservableArray) {\n if (!(object instanceof ObservableObject)) {\n object = new ObservableObject(object);\n }\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\n that._handlers[field] = { get: get, change: change };\n } else if (type === \"[object Array]\" || isObservableArray || isDataSource) {\n if (!isObservableArray && !isDataSource) {\n object = new ObservableArray(object);\n }\n\n change = eventHandler(that, CHANGE, field, false);\n\n object.bind(CHANGE, change);\n\n that._handlers[field] = { change: change };\n }\n\n object.parent = parent;\n }\n\n return object;\n }\n });\n\n function equal(x, y) {\n if (x === y) {\n return true;\n }\n\n var xtype = kendo.type(x), ytype = kendo.type(y), field;\n\n if (xtype !== ytype) {\n return false;\n }\n\n if (xtype === \"date\") {\n return x.getTime() === y.getTime();\n }\n\n if (xtype !== \"object\" && xtype !== \"array\") {\n return false;\n }\n\n for (field in x) {\n if (!equal(x[field], y[field])) {\n return false;\n }\n }\n\n return true;\n }\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\n \"date\": function(value) {\n if (typeof value === STRING && value.toLowerCase() === \"null\") {\n return null;\n }\n return kendo.parseDate(value);\n },\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\n \"string\": function(value) {\n if (typeof value === STRING && value.toLowerCase() === \"null\") {\n return null;\n }\n return value != null ? (value + \"\") : value;\n },\n\n \"default\": function(value) {\n return value;\n }\n };\n\n var defaultValues = {\n \"string\": \"\",\n \"number\": 0,\n \"date\": new Date(),\n \"boolean\": false,\n \"default\": \"\"\n };\n\n function getFieldByName(obj, name) {\n var field,\n fieldName;\n\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\n var Model = ObservableObject.extend({\n init: function(data) {\n var that = this;\n\n if (!data || $.isEmptyObject(data)) {\n data = $.extend({}, that.defaults, data);\n\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\n ObservableObject.fn.init.call(that, data);\n\n that.dirty = false;\n that.dirtyFields = {};\n\n if (that.idField) {\n that.id = that.get(that.idField);\n\n if (that.id === undefined) {\n that.id = that._defaultId;\n }\n }\n },\n\n shouldSerialize: function(field) {\n return ObservableObject.fn.shouldSerialize.call(this, field) &&\n field !== \"uid\" && !(this.idField !== \"id\" && field === \"id\") &&\n field !== \"dirty\" && field !== \"dirtyFields\" && field !== \"_accessors\";\n },\n\n _parse: function(field, value) {\n var that = this,\n fieldName = field,\n fields = (that.fields || {}),\n parse;\n\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\n return parse ? parse(value) : value;\n },\n\n _notifyChange: function(e) {\n var action = e.action;\n\n if (action == \"add\" || action == \"remove\") {\n this.dirty = true;\n this.dirtyFields[e.field] = true;\n }\n },\n\n editable: function(field) {\n field = (this.fields || {})[field];\n return field ? field.editable !== false : true;\n },\n\n set: function(field, value) {\n var that = this;\n var dirty = that.dirty;\n\n if (that.editable(field)) {\n value = that._parse(field, value);\n\n if (!equal(value, that.get(field))) {\n that.dirty = true;\n that.dirtyFields[field] = true;\n\n if (ObservableObject.fn.set.call(that, field, value) && !dirty) {\n that.dirty = dirty;\n\n if (!that.dirty) {\n that.dirtyFields[field] = false;\n }\n }\n } else {\n that.trigger(\"equalSet\", { field: field, value: value });\n }\n }\n },\n\n accept: function(data) {\n var that = this,\n parent = function() { return that; },\n field;\n\n for (field in data) {\n var value = data[field];\n\n if (field.charAt(0) != \"_\") {\n value = that.wrap(data[field], field, parent);\n }\n\n that._set(field, value);\n }\n\n if (that.idField) {\n that.id = that.get(that.idField);\n }\n\n that.dirty = false;\n that.dirtyFields = {};\n },\n\n isNew: function() {\n return this.id === this._defaultId;\n }\n });\n\n Model.define = function(base, options) {\n if (options === undefined) {\n options = base;\n base = Model;\n }\n\n var model,\n proto = extend({ defaults: {} }, options),\n name,\n field,\n type,\n value,\n idx,\n length,\n fields = {},\n originalName,\n id = proto.id,\n functionFields = [];\n\n if (id) {\n proto.idField = id;\n }\n\n if (proto.id) {\n delete proto.id;\n }\n\n if (id) {\n proto.defaults[id] = proto._defaultId = \"\";\n }\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\n for (name in proto.fields) {\n field = proto.fields[name];\n type = field.type || \"default\";\n value = null;\n originalName = name;\n\n name = typeof (field.field) === STRING ? field.field : name;\n\n if (!field.nullable) {\n value = proto.defaults[originalName !== name ? originalName : name] = field.defaultValue !== undefined ? field.defaultValue : defaultValues[type.toLowerCase()];\n\n if (typeof value === \"function\") {\n functionFields.push(name);\n }\n }\n\n if (options.id === name) {\n proto._defaultId = value;\n }\n\n proto.defaults[originalName !== name ? originalName : name] = value;\n\n field.parse = field.parse || parsers[type];\n }\n\n if (functionFields.length > 0) {\n proto._initializers = functionFields;\n }\n\n model = base.extend(proto);\n model.define = function(options) {\n return Model.define(model, options);\n };\n\n if (proto.fields) {\n model.fields = proto.fields;\n model.idField = proto.idField;\n }\n\n return model;\n };\n\n var Comparer = {\n selector: function(field) {\n return isFunction(field) ? field : getter(field);\n },\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\n if (a == null && b == null) {\n return 0;\n }\n\n if (a == null) {\n return -1;\n }\n\n if (b == null) {\n return 1;\n }\n\n if (a.localeCompare) {\n return a.localeCompare(b);\n }\n\n return a > b ? 1 : (a < b ? -1 : 0);\n };\n },\n\n create: function(sort) {\n var compare = sort.compare || this.compare(sort.field);\n\n if (sort.dir == \"desc\") {\n return function(a, b) {\n return compare(b, a, true);\n };\n }\n\n return compare;\n },\n\n combine: function(comparers) {\n return function(a, b) {\n var result = comparers[0](a, b),\n idx,\n length;\n\n for (idx = 1, length = comparers.length; idx < length; idx ++) {\n result = result || comparers[idx](a, b);\n }\n\n return result;\n };\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\n if (valueA && valueA.getTime && valueB && valueB.getTime) {\n valueA = valueA.getTime();\n valueB = valueB.getTime();\n }\n\n if (valueA === valueB) {\n return a.__position - b.__position;\n }\n\n if (valueA == null) {\n return -1;\n }\n\n if (valueB == null) {\n return 1;\n }\n\n if (valueA.localeCompare) {\n return valueA.localeCompare(valueB);\n }\n\n return valueA > valueB ? 1 : -1;\n };\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\n if (valueA && valueA.getTime && valueB && valueB.getTime) {\n valueA = valueA.getTime();\n valueB = valueB.getTime();\n }\n\n if (valueA === valueB) {\n return a.__position - b.__position;\n }\n\n if (valueA == null) {\n return 1;\n }\n\n if (valueB == null) {\n return -1;\n }\n\n if (valueB.localeCompare) {\n return valueB.localeCompare(valueA);\n }\n\n return valueA < valueB ? 1 : -1;\n };\n },\n create: function(sort) {\n return this[sort.dir](sort.field);\n }\n });\n\n map = function (array, callback) {\n var idx, length = array.length, result = new Array(length);\n\n for (idx = 0; idx < length; idx++) {\n result[idx] = callback(array[idx], idx, array);\n }\n\n return result;\n };\n\n var operators = (function(){\n\n function quote(str) {\n if (typeof str == \"string\") {\n str = str.replace(/[\\r\\n]+/g, \"\");\n }\n return JSON.stringify(str);\n }\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\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\n if (b.getTime) {\n //b looks like a Date\n a = \"(\" + a + \"&&\" + a + \".getTime?\" + a + \".getTime():\" + a + \")\";\n b = b.getTime();\n }\n }\n\n return a + \" \" + op + \" \" + b;\n }\n\n function getMatchRegexp(pattern) {\n // take a pattern, as supported by Excel match filter, and\n // convert it to the equivalent JS regular expression.\n // Excel patterns support:\n //\n // * - match any sequence of characters\n // ? - match a single character\n //\n // to match a literal * or ?, they must be prefixed by a tilde (~)\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\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\n function Query(data) {\n this.data = data || [];\n }\n\n Query.filterExpr = function(expression) {\n var expressions = [],\n logic = { and: \" && \", or: \" || \" },\n idx,\n length,\n filter,\n expr,\n fieldFunctions = [],\n operatorFunctions = [],\n field,\n operator,\n filters = expression.filters;\n\n for (idx = 0, length = filters.length; idx < length; idx++) {\n filter = filters[idx];\n field = filter.field;\n operator = filter.operator;\n\n if (filter.filters) {\n expr = Query.filterExpr(filter);\n //Nested function fields or operators - update their index e.g. __o[0] -> __o[1]\n filter = expr.expression\n .replace(/__o\\[(\\d+)\\]/g, function(match, index) {\n index = +index;\n return \"__o[\" + (operatorFunctions.length + index) + \"]\";\n })\n .replace(/__f\\[(\\d+)\\]/g, function(match, index) {\n index = +index;\n return \"__f[\" + (fieldFunctions.length + index) + \"]\";\n });\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\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\n expressions.push(filter);\n }\n\n return { expression: \"(\" + expressions.join(logic[expression.logic]) + \")\", fields: fieldFunctions, operators: operatorFunctions };\n };\n\n function normalizeSort(field, dir) {\n if (field) {\n var descriptor = typeof field === STRING ? { field: field, dir: dir } : field,\n descriptors = isArray(descriptor) ? descriptor : (descriptor !== undefined ? [descriptor] : []);\n\n return grep(descriptors, function(d) { return !!d.dir; });\n }\n }\n\n function sortFields(sorts, dir) {\n var sortObject = {};\n\n if (sorts) {\n var descriptor = typeof sorts === STRING ? { field: sorts, dir: dir } : sorts,\n descriptors = isArray(descriptor) ? descriptor : (descriptor !== undefined ? [descriptor] : []);\n\n for (var i = 0; i < descriptors.length; i++) {\n sortObject[descriptors[i].field] = { dir: descriptors[i].dir, index: i + 1 };\n }\n }\n\n return sortObject;\n }\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\n function normalizeOperator(expression) {\n var idx,\n length,\n filter,\n operator,\n filters = expression.filters;\n\n if (filters) {\n for (idx = 0, length = filters.length; idx < length; idx++) {\n filter = filters[idx];\n operator = filter.operator;\n\n if (operator && typeof operator === STRING) {\n filter.operator = operatorMap[operator.toLowerCase()] || operator;\n }\n\n normalizeOperator(filter);\n }\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\n normalizeOperator(expression);\n\n return expression;\n }\n }\n\n Query.normalizeFilter = normalizeFilter;\n\n function compareDescriptor(f1, f2) {\n if (f1.logic || f2.logic) {\n return false;\n }\n\n return f1.field === f2.field && f1.value === f2.value && f1.operator === f2.operator;\n }\n\n function normalizeDescriptor(filter) {\n filter = filter || {};\n\n if (isEmptyObject(filter)) {\n return { logic: \"and\", filters: [] };\n }\n\n return normalizeFilter(filter);\n }\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\n function compareFilters(expr1, expr2) {\n expr1 = normalizeDescriptor(expr1);\n expr2 = normalizeDescriptor(expr2);\n\n if (expr1.logic !== expr2.logic) {\n return false;\n }\n\n var f1, f2;\n var filters1 = (expr1.filters || []).slice();\n var filters2 = (expr2.filters || []).slice();\n\n if (filters1.length !== filters2.length) {\n return false;\n }\n\n filters1 = filters1.sort(fieldComparer);\n filters2 = filters2.sort(fieldComparer);\n\n for (var idx = 0; idx < filters1.length; idx++) {\n f1 = filters1[idx];\n f2 = filters2[idx];\n\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\n return true;\n }\n\n Query.compareFilters = compareFilters;\n\n function normalizeAggregate(expressions) {\n return isArray(expressions) ? expressions : [expressions];\n }\n\n function normalizeGroup(field, dir, compare, skipItemSorting) {\n var descriptor = typeof field === STRING ? { field: field, dir: dir, compare: compare, skipItemSorting : skipItemSorting } : field,\n descriptors = isArray(descriptor) ? descriptor : (descriptor !== undefined ? [descriptor] : []);\n\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\n function normalizeGroupWithoutCompare(field, dir, compare) {\n var descriptors = normalizeGroup(field, dir, compare);\n\n for (var i = 0; i < descriptors.length; i++) {\n delete descriptors[i].compare;\n }\n\n return descriptors;\n }\n\n function anyGroupDescriptorHasCompare(groupDescriptors) {\n var descriptors = isArray(groupDescriptors) ? groupDescriptors : [groupDescriptors];\n\n for (var i = 0; i < descriptors.length; i++) {\n if (descriptors[i] && isFunction(descriptors[i].compare)) {\n return true;\n }\n }\n\n return false;\n }\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\n if (selector) {\n if (selector.compare) {\n sort.compare = selector.compare;\n } else {\n sort.field = selector;\n }\n }\n\n if (inPlace) {\n return new Query(this.data.sort(Comparer.create(sort)));\n }\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,\n length,\n descriptors = normalizeSort(field, dir),\n comparers = [];\n\n comparer = comparer || Comparer;\n\n if (descriptors.length) {\n for (idx = 0, length = descriptors.length; idx < length; idx++) {\n comparers.push(comparer.create(descriptors[idx]));\n }\n\n return this.orderBy({ compare: comparer.combine(comparers) }, inPlace);\n }\n\n return this;\n },\n\n filter: function(expressions) {\n var idx,\n current,\n length,\n compiled,\n predicate,\n data = this.data,\n fields,\n operators,\n result = [],\n filter;\n\n expressions = normalizeFilter(expressions);\n\n if (!expressions || expressions.filters.length === 0) {\n return this;\n }\n\n compiled = Query.filterExpr(expressions);\n fields = compiled.fields;\n operators = compiled.operators;\n\n predicate = filter = new Function(\"d, __f, __o\", \"return \" + compiled.expression);\n\n if (fields.length || operators.length) {\n filter = function(d) {\n return predicate(d, fields, operators);\n };\n }\n\n\n for (idx = 0, length = data.length; idx < length; idx++) {\n current = data[idx];\n\n if (filter(current)) {\n result.push(current);\n }\n }\n\n return new Query(result);\n },\n\n group: function(descriptors, allData, options) {\n descriptors = normalizeGroup(descriptors || []);\n allData = allData || this.data;\n\n var that = this,\n result = new Query(that.data),\n descriptor;\n\n if (descriptors.length > 0) {\n descriptor = descriptors[0];\n\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\n } else {\n result = result.groupBy(descriptor).select(function(group) {\n var data = new Query(allData).filter([ { field: group.field, operator: \"eq\", value: group.value, ignoreCase: false } ]);\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\n groupBy: function(descriptor) {\n var that = this;\n\n if (isEmptyObject(descriptor) || !this.data.length) {\n return new Query([]);\n }\n\n var field = descriptor.field,\n sorted = descriptor.skipItemSorting ? this.data : this._sortForGrouping(field, descriptor.dir || \"asc\"),\n accessor = kendo.accessor(field),\n item,\n groupValue = accessor.get(sorted[0], field),\n group = {\n field: field,\n value: groupValue,\n items: []\n },\n currentValue,\n idx,\n len,\n result = [group];\n\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\n result = that._sortGroups(result, descriptor);\n\n return new Query(result);\n },\n\n groupAllData: function (descriptor, allData) {\n if (isEmptyObject(descriptor) || this.data && !this.data.length) {\n return new Query([]);\n }\n\n var field = descriptor.field,\n sorted = descriptor.skipItemSorting ? allData : new Query(allData).sort(field, descriptor.dir || \"asc\", StableComparer).toArray(),\n accessor = kendo.accessor(field),\n item,\n groupValue = accessor.get(sorted[0], field),\n group = {\n field: field,\n value: groupValue,\n items: []\n },\n currentValue,\n idx,\n len,\n result = [group];\n\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\n result = this._sortGroups(result, descriptor);\n\n return new Query(result);\n },\n\n _sortForGrouping: function(field, dir) {\n var idx, length,\n data = this.data;\n\n if (!stableSort) {\n for (idx = 0, length = data.length; idx < length; idx++) {\n data[idx].__position = idx;\n }\n\n data = new Query(data).sort(field, dir, StableComparer).toArray();\n\n for (idx = 0, length = data.length; idx < length; idx++) {\n delete data[idx].__position;\n }\n return data;\n }\n\n return this.sort(field, dir).toArray();\n },\n\n _sortGroups: function(groups, descriptor) {\n var result = groups;\n\n if (descriptor && isFunction(descriptor.compare)) {\n result = new Query(result).order({ compare: descriptor.compare }, descriptor.dir || ASCENDING).toArray();\n }\n\n return result;\n },\n\n aggregate: function (aggregates) {\n var idx,\n len,\n result = {},\n state = {};\n\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\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\n function calculateAggregate(accumulator, aggregates, item, index, length, state) {\n aggregates = aggregates || [];\n var idx,\n aggr,\n functionName,\n len = aggregates.length;\n\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\n var functions = {\n sum: function(accumulator, item, accessor) {\n var value = accessor.get(item);\n\n if (!isNumber(accumulator)) {\n accumulator = value;\n } else if (isNumber(value)) {\n accumulator += value;\n }\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\n if (state.count === undefined) {\n state.count = 0;\n }\n\n if (!isNumber(accumulator)) {\n accumulator = value;\n } else if (isNumber(value)) {\n accumulator += value;\n }\n\n if (isNumber(value)) {\n state.count++;\n }\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\n if (!isNumber(accumulator) && !isDate(accumulator)) {\n accumulator = value;\n }\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\n if (!isNumber(accumulator) && !isDate(accumulator)) {\n accumulator = value;\n }\n\n if(accumulator > value && (isNumber(value) || isDate(value))) {\n accumulator = value;\n }\n return accumulator;\n }\n };\n\n function isNumber(val) {\n return typeof val === \"number\" && !isNaN(val);\n }\n\n function isDate(val) {\n return val && val.getTime;\n }\n\n function toJSON(array) {\n var idx, length = array.length, result = new Array(length);\n\n for (idx = 0; idx < length; idx++) {\n result[idx] = array[idx].toJSON();\n }\n\n return result;\n }\n\n Query.normalizeGroup = normalizeGroup;\n Query.normalizeSort = normalizeSort;\n\n Query.process = function(data, options, inPlace) {\n options = options || {};\n\n var group = options.group;\n var customGroupSort = anyGroupDescriptorHasCompare(normalizeGroup(group || []));\n var query = new Query(data),\n groupDescriptorsWithoutCompare = normalizeGroupWithoutCompare(group || []),\n normalizedSort = normalizeSort(options.sort || []),\n sort = customGroupSort ? normalizedSort : groupDescriptorsWithoutCompare.concat(normalizedSort),\n groupDescriptorsWithoutSort,\n total,\n filterCallback = options.filterCallback,\n filter = options.filter,\n skip = options.skip,\n take = options.take;\n\n if (sort && inPlace) {\n query = query.sort(sort, undefined, undefined, inPlace);\n }\n\n if (filter) {\n query = query.filter(filter);\n\n if (filterCallback) {\n query = filterCallback(query);\n }\n\n total = query.toArray().length;\n }\n\n if (sort) {\n if (!inPlace) {\n query = query.sort(sort);\n }\n\n if (group) {\n data = query.toArray();\n }\n }\n\n if (customGroupSort) {\n query = query.group(group, data, options);\n\n if (skip !== undefined && take !== undefined && !options.groupPaging) {\n query = new Query(flatGroups(query.toArray())).range(skip, take);\n\n groupDescriptorsWithoutSort = map(groupDescriptorsWithoutCompare, function(groupDescriptor) {\n return extend({}, groupDescriptor, {\n skipItemSorting: true\n });\n });\n\n query = query.group(groupDescriptorsWithoutSort, data, options);\n }\n } else {\n if (skip !== undefined && take !== undefined) {\n query = query.range(skip, take);\n }\n\n if (group && (!isEmptyObject(group) || group.length !== 0)) {\n query = query.group(group, data, options);\n }\n }\n\n return {\n total: total,\n data: query.toArray()\n };\n };\n\n var LocalTransport = Class.extend({\n init: function(options) {\n this.data = options.data;\n },\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\n var RemoteTransport = Class.extend( {\n init: function(options) {\n var that = this, parameterMap;\n\n options = that.options = extend({}, that.options, options);\n\n each(crud, function(index, type) {\n if (typeof options[type] === STRING) {\n options[type] = {\n url: options[type]\n };\n }\n });\n\n that.cache = options.cache? Cache.create(options.cache) : {\n find: noop,\n add: noop\n };\n\n parameterMap = options.parameterMap;\n\n if (options.submit) {\n that.submit = options.submit;\n }\n\n if (isFunction(options.push)) {\n that.push = options.push;\n }\n\n if (!that.push) {\n that.push = identity;\n }\n\n that.parameterMap = isFunction(parameterMap) ? parameterMap : function(options) {\n var result = {};\n\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\n result[option] = value;\n });\n\n return result;\n };\n },\n\n options: {\n parameterMap: identity\n },\n\n create: function(options) {\n return ajax(this.setup(options, CREATE));\n },\n\n read: function(options) {\n var that = this,\n success,\n error,\n result,\n cache = that.cache;\n\n options = that.setup(options, READ);\n\n success = options.success || noop;\n error = options.error || noop;\n\n result = cache.find(options.data);\n\n if(result !== undefined) {\n success(result);\n } else {\n options.success = function(result) {\n cache.add(options.data, result);\n\n success(result);\n };\n\n $.ajax(options);\n }\n },\n\n update: function(options) {\n return ajax(this.setup(options, UPDATE));\n },\n\n destroy: function(options) {\n return ajax(this.setup(options, DESTROY));\n },\n\n setup: function(options, type) {\n options = options || {};\n\n var that = this,\n parameters,\n operation = that.options[type],\n data = isFunction(operation.data) ? operation.data(options.data) : operation.data;\n\n options = extend(true, {}, operation, options);\n parameters = extend(true, {}, data, options.data);\n\n options.data = that.parameterMap(parameters, type);\n\n if (isFunction(options.url)) {\n options.url = options.url(parameters);\n }\n\n return options;\n }\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\n Cache.create = function(options) {\n var store = {\n \"inmemory\": function() { return new Cache(); }\n };\n\n if (isPlainObject(options) && isFunction(options.find)) {\n return options;\n }\n\n if (options === true) {\n return new Cache();\n }\n\n return store[options]();\n };\n\n function serializeRecords(data, getters, modelInstance, originalFieldNames, fieldNames) {\n var record,\n getter,\n originalName,\n idx,\n setters = {},\n length;\n\n for (idx = 0, length = data.length; idx < length; idx++) {\n record = data[idx];\n for (getter in getters) {\n originalName = fieldNames[getter];\n\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\n function convertRecords(data, getters, modelInstance, originalFieldNames, fieldNames) {\n var record,\n getter,\n originalName,\n idx,\n length;\n\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\n originalName = fieldNames[getter];\n if (originalName && originalName !== getter) {\n delete record[originalName];\n }\n }\n }\n }\n\n function convertGroup(data, getters, modelInstance, originalFieldNames, fieldNames) {\n var record,\n idx,\n fieldName,\n length;\n\n for (idx = 0, length = data.length; idx < length; idx++) {\n record = data[idx];\n\n fieldName = originalFieldNames[record.field];\n if (fieldName && fieldName != record.field) {\n record.field = fieldName;\n }\n\n record.value = modelInstance._parse(record.field, record.value);\n\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\n function wrapDataAccess(originalFunction, model, converter, getters, originalFieldNames, fieldNames) {\n return function(data) {\n data = originalFunction(data);\n\n return wrapDataAccessBase(model, converter, getters, originalFieldNames, fieldNames)(data);\n };\n }\n\n function wrapDataAccessBase(model, converter, getters, originalFieldNames, fieldNames) {\n return function(data) {\n\n if (data && !isEmptyObject(getters)) {\n if (toString.call(data) !== \"[object Array]\" && !(data instanceof ObservableArray)) {\n data = [data];\n }\n\n converter(data, getters, new model(), originalFieldNames, fieldNames);\n }\n\n return data || [];\n };\n }\n\n var DataReader = Class.extend({\n init: function(schema) {\n var that = this, member, get, model, base;\n\n schema = schema || {};\n\n for (member in schema) {\n get = schema[member];\n\n that[member] = typeof get === STRING ? getter(get) : get;\n }\n\n base = schema.modelBase || Model;\n\n if (isPlainObject(that.model)) {\n that.model = model = base.define(that.model);\n }\n\n var dataFunction = proxy(that.data, that);\n\n that._dataAccessFunction = dataFunction;\n\n if (that.model) {\n var groupsFunction = proxy(that.groups, that),\n serializeFunction = proxy(that.serialize, that),\n originalFieldNames = {},\n getters = {},\n serializeGetters = {},\n fieldNames = {},\n shouldSerialize = false,\n fieldName,\n name;\n\n model = that.model;\n\n if (model.fields) {\n each(model.fields, function(field, value) {\n var fromName;\n\n fieldName = field;\n\n if (isPlainObject(value) && value.field) {\n fieldName = value.field;\n } else if (typeof value === STRING) {\n fieldName = value;\n }\n\n if (isPlainObject(value) && value.from) {\n fromName = value.from;\n }\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\n if (!schema.serialize && shouldSerialize) {\n that.serialize = wrapDataAccess(serializeFunction, model, serializeRecords, serializeGetters, originalFieldNames, fieldNames);\n }\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\n function fillLastGroup(originalGroup, newGroup) {\n var currOriginal;\n var currentNew;\n\n if (newGroup.items && newGroup.items.length) {\n for (var i = 0; i < newGroup.items.length; i++) {\n currOriginal = originalGroup.items[originalGroup.items.length - 1];\n currentNew = newGroup.items[i];\n if (currOriginal && currentNew) {\n if (currOriginal.hasSubgroups && currOriginal.value == currentNew.value) {\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,\n idx = 0,\n items;\n\n while (dest.length && take) {\n group = dest[idx];\n items = group.items;\n\n var length = items.length;\n\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\n if (!group.items.length) {\n dest.splice(idx--, 1);\n }\n }\n\n if (items.length === 0) {\n skip -= length;\n } else {\n skip = 0;\n take -= items.length;\n }\n\n if (++idx >= dest.length) {\n break;\n }\n }\n\n if (idx < dest.length) {\n dest.splice(idx, dest.length - idx);\n }\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\n for (var groupIndex = 0; groupIndex < groupsLength; groupIndex++) {\n group = indexFn(groups, groupIndex);\n\n if (group.hasSubgroups) {\n result = result.concat(flatGroups(group.items));\n } else {\n items = group.items;\n\n for (var itemIndex = 0; itemIndex < items.length; itemIndex++) {\n result.push(indexFn(items, itemIndex));\n }\n }\n }\n return result;\n }\n\n function flattenGroups(data) {\n var idx,\n result = [],\n length,\n items,\n itemIndex;\n\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\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\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\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\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\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\n if (!item || item instanceof type) {\n continue;\n }\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\n function removeModel(data, model) {\n if (!data) {\n return;\n }\n var length = data.length;\n var dataItem;\n var idx;\n\n for (idx = 0; idx < length; idx++) {\n dataItem = data[idx];\n\n if (dataItem.uid && dataItem.uid == model.uid) {\n data.splice(idx, 1);\n return dataItem;\n }\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\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\n function indexOf(data, comparer) {\n var idx, length;\n if (!data) {\n return;\n }\n\n for (idx = 0, length = data.length; idx < length; idx++) {\n if (comparer(data[idx])) {\n return idx;\n }\n }\n\n return -1;\n }\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\n if (isFunction(fieldName)) {\n return name;\n }\n\n return fieldName;\n }\n return name;\n }\n\n function convertFilterDescriptorsField(descriptor, model) {\n var idx,\n length,\n target = {};\n\n for (var field in descriptor) {\n if (field !== \"filters\") {\n target[field] = descriptor[field];\n }\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\n function convertDescriptorsField(descriptors, model) {\n var idx,\n length,\n result = [],\n target,\n descriptor;\n\n for (idx = 0, length = descriptors.length; idx < length; idx ++) {\n target = {};\n\n descriptor = descriptors[idx];\n\n for (var field in descriptor) {\n target[field] = descriptor[field];\n }\n\n target.field = fieldNameFromModel(model.fields, target.field);\n\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\n var DataSource = Observable.extend({\n init: function(options) {\n var that = this, model, data;\n\n if (options) {\n data = options.data;\n }\n\n options = that.options = extend({}, that.options, options);\n\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\n if (that._groupPaging) {\n that._groupsState = {};\n }\n that._shouldDetachObservableParents = true;\n\n Observable.fn.init.call(that);\n\n that.transport = Transport.create(options, data, that);\n\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\n if (options.offlineStorage != null) {\n if (typeof options.offlineStorage == \"string\") {\n var key = options.offlineStorage;\n\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\n that.reader = new kendo.data.readers[options.schema.type || \"json\" ](options.schema);\n\n model = that.reader.model || {};\n\n that._detachObservableParents();\n\n that._data = that._observe(that._data);\n that._online = true;\n\n that.bind([\"push\", ERROR, CHANGE, REQUESTSTART, SYNC, REQUESTEND, PROGRESS], options);\n },\n\n options: {\n data: null,\n schema: {\n modelBase: Model\n },\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\n clone: function() {\n return this;\n },\n\n online: function(value) {\n if (value !== undefined) {\n if (this._online != value) {\n this._online = value;\n\n if (value) {\n return this.sync();\n }\n }\n\n return $.Deferred().resolve().promise();\n } else {\n return this._online;\n }\n },\n\n offlineData: function(state) {\n if (this.options.offlineStorage == null) {\n return null;\n }\n\n if (state !== undefined) {\n return this._storage.setItem(state);\n }\n\n return this._storage.getItem() || [];\n },\n\n _isServerGrouped: function() {\n var group = this.group() || [];\n\n return this.options.serverGrouping && group.length;\n },\n\n _isServerGroupPaged: function(){\n return this._isServerGrouped() && this._groupPaging;\n },\n\n _isGroupPaged: function(){\n var group = this._group || [];\n\n return this._groupPaging && group.length;\n },\n\n _pushCreate: function(result) {\n this._push(result, \"pushCreate\");\n },\n\n _pushUpdate: function(result) {\n this._push(result, \"pushUpdate\");\n },\n\n _pushDestroy: function(result) {\n this._push(result, \"pushDestroy\");\n },\n\n _push: function(result, operation) {\n var data = this._readData(result);\n\n if (!data) {\n data = result;\n }\n\n this[operation](data);\n },\n\n _flatData: function(data, skip) {\n if (data) {\n if (this._isServerGrouped()) {\n return flattenGroups(data);\n }\n\n if (!skip) {\n for (var idx = 0; idx < data.length; idx++) {\n data.at(idx);\n }\n }\n }\n\n return data;\n },\n\n parent: noop,\n\n get: function(id) {\n var idx, length, data = this._flatData(this._data, this.options.useRanges);\n\n for (idx = 0, length = data.length; idx < length; idx++) {\n if (data[idx].id == id) {\n return data[idx];\n }\n }\n },\n\n getByUid: function(id) {\n return this._getByUid(id, this._data);\n },\n\n _getByUid: function(id, dataItems) {\n var idx, length, data = this._flatData(dataItems, this.options.useRanges);\n\n if (!data) {\n return;\n }\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\n indexOf: function(model) {\n return indexOfModel(this._data, model);\n },\n\n at: function(index) {\n return this._data.at(index);\n },\n\n data: function(value) {\n var that = this;\n if (value !== undefined) {\n that._detachObservableParents();\n that._data = this._observe(value);\n\n that._pristineData = value.slice(0);\n\n that._storeData();\n\n that._ranges = [];\n that.trigger(\"reset\");\n that._addRange(that._data);\n\n that._total = that._data.length;\n that._pristineTotal = that._total;\n\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\n return that._data;\n }\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\n _observeView: function(data) {\n var that = this;\n replaceWithObservable(data, that._data, that._ranges, that.reader.model || ObservableObject, that._isServerGrouped());\n\n var view = new LazyObservableArray(data, that.reader.model);\n view.parent = function() { return that.parent(); };\n return view;\n },\n\n flatView: function() {\n var groups = this.group() || [];\n\n if (groups.length) {\n return flattenGroups(this._view);\n } else {\n return this._view;\n }\n },\n\n add: function(model) {\n return this.insert(this._data.length, model);\n },\n\n _createNewModel: function(model) {\n if (this.reader.model) {\n return new this.reader.model(model);\n }\n\n if (model instanceof ObservableObject) {\n return model;\n }\n\n return new ObservableObject(model);\n },\n\n insert: function(index, model) {\n if (!model) {\n model = index;\n index = 0;\n }\n\n if (!(model instanceof Model)) {\n model = this._createNewModel(model);\n }\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\n this._insertModelInRange(index, model);\n\n return model;\n },\n\n pushInsert: function(index, items) {\n var that = this;\n var rangeSpan = that._getCurrentRangeSpan();\n\n if (!items) {\n items = index;\n index = 0;\n }\n\n if (!isArray(items)) {\n items = [items];\n }\n\n var pushed = [];\n var autoSync = this.options.autoSync;\n this.options.autoSync = false;\n\n try {\n for (var idx = 0; idx < items.length; idx ++) {\n var item = items[idx];\n\n var result = this.insert(index, item);\n\n pushed.push(result);\n\n var pristine = result.toJSON();\n\n if (this._isServerGrouped()) {\n pristine = this._wrapInEmptyGroup(pristine);\n }\n\n this._pristineData.push(pristine);\n\n if (rangeSpan && rangeSpan.length) {\n $(rangeSpan).last()[0].pristineData.push(pristine);\n }\n\n index++;\n }\n } finally {\n this.options.autoSync = autoSync;\n }\n\n if (pushed.length) {\n this.trigger(\"push\", {\n type: \"create\",\n items: pushed\n });\n }\n },\n\n pushCreate: function(items) {\n this.pushInsert(this._data.length, items);\n },\n\n pushUpdate: function(items) {\n if (!isArray(items)) {\n items = [items];\n }\n\n var pushed = [];\n\n for (var idx = 0; idx < items.length; idx ++) {\n var item = items[idx];\n var model = this._createNewModel(item);\n\n var target = this.get(model.id);\n\n if (target) {\n pushed.push(target);\n\n target.accept(item);\n\n target.trigger(CHANGE);\n\n this._updatePristineForModel(target, item);\n } else {\n this.pushCreate(item);\n }\n }\n\n if (pushed.length) {\n this.trigger(\"push\", {\n type: \"update\",\n items: pushed\n });\n }\n },\n\n pushDestroy: function(items) {\n var pushed = this._removeItems(items);\n\n if (pushed.length) {\n this.trigger(\"push\", {\n type: \"destroy\",\n items: pushed\n });\n }\n },\n\n _removeItems: function(items, removePristine) {\n if (!isArray(items)) {\n items = [items];\n }\n\n var shouldRemovePristine = typeof removePristine !== \"undefined\" ? removePristine : true;\n\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\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\n if (found && shouldRemovePristine) {\n this._removePristineForModel(model);\n this._destroyed.pop();\n }\n }\n } finally {\n this.options.autoSync = autoSync;\n }\n\n return destroyed;\n },\n\n pushMove: function(index, items) {\n var pushed = this._moveItems(index, items);\n\n if (pushed.length) {\n this.trigger(\"push\", {\n type: \"update\",\n items: pushed\n });\n }\n },\n\n _moveItems: function (index, items) {\n if (!isArray(items)) {\n items = [items];\n }\n\n var moved = [];\n var autoSync = this.options.autoSync;\n this.options.autoSync = false;\n\n try {\n for (var i = 0; i < items.length; i ++) {\n var item = items[i];\n var model = this._createNewModel(item);\n\n this._eachItem(this._data, function(dataItems){\n for (var idx = 0; idx < dataItems.length; idx++) {\n var dataItem = dataItems.at(idx);\n if (dataItem.id === model.id) {\n moved.push(dataItem);\n dataItems.splice(index >= idx ? --index : index, 0, dataItems.splice(idx, 1)[0]);\n index++;\n break;\n }\n }\n });\n }\n } finally {\n this.options.autoSync = autoSync;\n }\n\n return moved;\n },\n\n remove: function(model) {\n var result,\n that = this,\n hasGroups = that._isServerGrouped();\n\n if (hasGroups && model.uid && (!model.isNew || !model.isNew())) {\n that._destroyed.push(model);\n }\n\n this._eachItem(that._data, function(items) {\n result = removeModel(items, model);\n\n if (result && hasGroups) {\n return true;\n }\n });\n\n this._removeModelFromRanges(model);\n\n return model;\n },\n\n destroyed: function() {\n return this._destroyed;\n },\n\n created: function() {\n var idx,\n length,\n result = [],\n data = this._flatData(this._data, this.options.useRanges);\n\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\n updated: function() {\n var idx,\n length,\n result = [],\n data = this._flatData(this._data, this.options.useRanges);\n\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\n sync: function() {\n var that = this,\n created = [],\n updated = [],\n destroyed = that._destroyed;\n\n var promise = $.Deferred().resolve().promise();\n\n if (that.online()) {\n\n if (!that.reader.model) {\n return promise;\n }\n\n created = that.created();\n updated = that.updated();\n\n var promises = [];\n\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\n promise = $.when\n .apply(null, promises)\n .then(function() {\n var idx, length;\n\n for (idx = 0, length = arguments.length; idx < length; idx++){\n if (arguments[idx]) {\n that._accept(arguments[idx]);\n }\n }\n\n that._storeData(true);\n\n that._syncEnd();\n\n that._change({ action: \"sync\" });\n\n that.trigger(SYNC);\n\n if (that._isServerGroupPaged()) {\n that.read();\n }\n });\n } else {\n that._storeData(true);\n\n that._syncEnd();\n\n that._change({ action: \"sync\" });\n }\n\n return promise;\n },\n\n _syncEnd: noop,\n\n cancelChanges: function(model) {\n var that = this;\n\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\n that._ranges = [];\n that._addRange(that._data, 0);\n\n that._changesCanceled();\n\n that._change();\n\n that._markOfflineUpdatesAsDirty();\n\n if (that._isServerGrouped()) {\n that.read();\n }\n }\n },\n\n _changesCanceled: noop,\n\n _markOfflineUpdatesAsDirty: function() {\n var that = this;\n\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\n hasChanges: function() {\n var idx,\n length,\n data = this._flatData(this._data, this.options.useRanges);\n\n if (this._destroyed.length) {\n return true;\n }\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\n return false;\n },\n\n _accept: function(result) {\n var that = this,\n models = result.models,\n response = result.response,\n idx = 0,\n serverGroup = that._isServerGrouped(),\n pristine = that._pristineData,\n type = result.type,\n length;\n\n that.trigger(REQUESTEND, { response: response, type: type });\n\n if (response && !isEmptyObject(response)) {\n response = that.reader.parse(response);\n\n if (that._handleCustomErrors(response)) {\n return;\n }\n\n response = that.reader.data(response);\n\n if (!isArray(response)) {\n response = [response];\n }\n } else {\n response = $.map(models, function(model) { return model.toJSON(); } );\n }\n\n if (type === \"destroy\") {\n that._destroyed = [];\n }\n\n for (idx = 0, length = models.length; idx < length; idx++) {\n if (type !== \"destroy\") {\n models[idx].accept(response[idx]);\n\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\n _updatePristineForModel: function(model, values) {\n this._executeOnPristineForModel(model, function(index, items) {\n kendo.deepExtend(items[index], values);\n });\n },\n\n _executeOnPristineForModel: function(model, callback) {\n this._eachPristineItem(\n function(items) {\n var index = indexOfPristineModel(items, model);\n if (index > -1) {\n callback(index, items);\n return true;\n }\n });\n },\n\n _removePristineForModel: function(model) {\n this._executeOnPristineForModel(model, function(index, items) {\n items.splice(index, 1);\n });\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\n _eachPristineItem: function(callback) {\n var that = this;\n var options = that.options;\n var rangeSpan = that._getCurrentRangeSpan();\n\n that._eachItem(that._pristineData, callback);\n\n if (options.serverPaging && options.useRanges) {\n each(rangeSpan, function(i, range) {\n that._eachItem(range.pristineData, callback);\n });\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\n _pristineForModel: function(model) {\n var pristine,\n idx,\n callback = function(items) {\n idx = indexOfPristineModel(items, model);\n if (idx > -1) {\n pristine = items[idx];\n return true;\n }\n };\n\n this._eachPristineItem(callback);\n\n return pristine;\n },\n\n _cancelModel: function(model) {\n var that = this;\n var pristine = this._pristineForModel(model);\n\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\n if (pristine.__state__ == \"update\") {\n items[idx].dirty = true;\n }\n\n } else {\n that._modelCanceled(model);\n\n items.splice(idx, 1);\n\n that._removeModelFromRanges(model);\n }\n }\n });\n },\n\n _modelCanceled: noop,\n\n _submit: function(promises, data) {\n var that = this;\n\n that.trigger(REQUESTSTART, { type: \"submit\" });\n\n that.trigger(PROGRESS);\n\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\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\n that.error(response, status, error);\n }\n }, data));\n },\n\n _sendSubmit: function(created, updated, destroyed) {\n var that = this,\n promises = [];\n\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\n if (updated.length) {\n promises.push($.Deferred(function(deferred) {\n deferred.type = \"update\";\n deferred.models = updated;\n }));\n }\n\n if (destroyed.length) {\n promises.push($.Deferred(function(deferred) {\n deferred.type = \"destroy\";\n deferred.models = destroyed;\n }));\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\n return promises;\n },\n\n _promise: function(data, models, type) {\n var that = this;\n\n return $.Deferred(function(deferred) {\n that.trigger(REQUESTSTART, { type: type });\n\n that.trigger(PROGRESS);\n\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\n _send: function(method, data) {\n var that = this,\n idx,\n length,\n promises = [],\n converted = that.reader.serialize(toJSON(data));\n\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\n return promises;\n },\n\n read: function(data) {\n var that = this, params = that._params(data);\n var deferred = $.Deferred();\n\n that._queueRequest(params, function() {\n var isPrevented = that.trigger(REQUESTSTART, { type: \"read\" });\n if (!isPrevented) {\n that.trigger(PROGRESS);\n\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\n deferred.resolve();\n },\n error: function() {\n var args = slice.call(arguments);\n\n that.error.apply(that, args);\n\n deferred.reject.apply(deferred, args);\n }\n });\n } else if (that.options.offlineStorage != null){\n that.success(that.offlineData(), params);\n\n deferred.resolve();\n }\n } else {\n that._dequeueRequest();\n\n deferred.resolve(isPrevented);\n }\n });\n\n return deferred.promise();\n },\n\n _readAggregates: function(data) {\n return this.reader.aggregates(data);\n },\n\n success: function(data) {\n var that = this,\n options = that.options,\n items,\n replaceSubset;\n\n that.trigger(REQUESTEND, { response: data, type: \"read\" });\n\n if (that.online()) {\n data = that.reader.parse(data);\n\n if (that._handleCustomErrors(data)) {\n that._dequeueRequest();\n return;\n }\n\n that._total = that.reader.total(data);\n\n if (that._isServerGroupPaged()) {\n that._serverGroupsTotal = that._total;\n }\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\n if (that._aggregate && options.serverAggregates) {\n that._aggregateResult = that._readAggregates(data);\n }\n\n data = that._readData(data);\n\n that._destroyed = [];\n } else {\n data = that._readData(data);\n\n items = [];\n var itemIds = {};\n var model = that.reader.model;\n var idField = model ? model.idField : \"id\";\n var idx;\n\n for (idx = 0; idx < this._destroyed.length; idx++) {\n var id = this._destroyed[idx][idField];\n itemIds[id] = id;\n }\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\n data = items;\n\n that._total = data.length;\n }\n\n that._pristineTotal = that._total;\n replaceSubset = that._skip && that._data.length && that._skip < that._data.length;\n\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\n that._detachObservableParents();\n\n if (that.options.endless) {\n that._data.unbind(CHANGE, that._changeHandler);\n\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\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\n that._markOfflineUpdatesAsDirty();\n\n that._storeData();\n\n that._addRange(that._data);\n\n that._process(that._data);\n\n that._dequeueRequest();\n },\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\n _storeData: function(updatePristine) {\n var serverGrouping = this._isServerGrouped();\n var model = this.reader.model;\n\n function items(data) {\n var state = [];\n\n for (var idx = 0; idx < data.length; idx++) {\n var dataItem = data.at(idx);\n var item = dataItem.toJSON();\n\n if (serverGrouping && dataItem.items) {\n item.items = items(dataItem.items);\n } else {\n item.uid = dataItem.uid;\n\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\n return state;\n }\n\n if (this.options.offlineStorage != null) {\n var state = items(this._data);\n\n var destroyed = [];\n\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\n this.offlineData(state.concat(destroyed));\n\n if (updatePristine) {\n this._pristineData = this.reader.reader ? this.reader.reader._wrapDataAccessBase(state) : this.reader._wrapDataAccessBase(state);\n }\n }\n },\n\n _addRange: function (data, skip) {\n var that = this,\n start = typeof (skip) !== \"undefined\" ? skip : (that._skip || 0),\n end,\n range = {\n data: data,\n pristineData: data.toJSON(),\n timestamp: that._timeStamp()\n };\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\n range.start = start;\n range.end = end;\n that._ranges.push(range);\n that._sortRanges();\n\n if (that._isGroupPaged()) {\n if (!that._groupsFlat) {\n that._groupsFlat = [];\n }\n that._appendToGroupsFlat(range.data);\n that._updateOuterRangesLength();\n }\n },\n\n _appendToGroupsFlat: function (data) {\n var length = data.length;\n\n for (var i = 0; i < length; i++) {\n this._groupsFlat.push(data[i]);\n }\n },\n\n _getGroupByUid: function(uid){\n var length = this._groupsFlat.length;\n var group;\n\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\n _sortRanges: function() {\n this._ranges.sort(function(x, y) {\n return x.start - y.start;\n });\n },\n\n error: function(xhr, status, errorThrown) {\n this._dequeueRequest();\n this.trigger(REQUESTEND, { });\n this.trigger(ERROR, { xhr: xhr, status: status, errorThrown: errorThrown });\n },\n\n _params: function(data) {\n var that = this,\n 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\n if (!that.options.serverPaging) {\n delete options.take;\n delete options.skip;\n delete options.page;\n delete options.pageSize;\n }\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\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\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\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\n if (!that.options.groupPaging) {\n delete options.groupPaging;\n }\n\n return options;\n },\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 = { callback: proxy(callback, that), 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\n _handleCustomErrors: function(response) {\n if (this.reader.errors) {\n var errors = this.reader.errors(response);\n if (errors) {\n this.trigger(ERROR, { xhr: null, status: \"customerror\", errorThrown: \"custom error\", errors: errors });\n return true;\n }\n }\n return false;\n },\n\n _shouldWrap: function(data) {\n var model = this.reader.model;\n\n if (model && data.length) {\n return !(data[0] instanceof model);\n }\n\n return false;\n },\n\n _observe: function(data) {\n var that = this,\n model = that.reader.model;\n\n that._shouldDetachObservableParents = true;\n\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() { return that.parent(); };\n }\n\n if (that._isServerGrouped()) {\n wrapGroupItems(data, model);\n }\n\n if (that._changeHandler && that._data && that._data instanceof ObservableArray &&\n !(that.options.useRanges && that.options.serverPaging)) {\n that._data.unbind(CHANGE, that._changeHandler);\n } else {\n that._changeHandler = proxy(that._change, that);\n }\n\n return data.bind(CHANGE, that._changeHandler);\n },\n\n _updateTotalForAction: function(action, items) {\n var that = this;\n\n var total = parseInt(that._total, 10);\n\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\n that._total = total;\n },\n\n _change: function(e) {\n var that = this, idx, length, action = e ? e.action : \"\";\n\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\n if (that.options.autoSync && (action === \"add\" || action === \"remove\" || action === \"itemchange\")) {\n\n var handler = function(args) {\n if (args.action === \"sync\") {\n that.unbind(\"change\", handler);\n that._updateTotalForAction(action, e.items);\n }\n };\n\n that.first(\"change\", handler);\n\n that.sync();\n\n } else {\n that._updateTotalForAction(action, e ? e.items : []);\n\n that._process(that._data, e);\n }\n },\n\n _calculateAggregates: function (data, options) {\n options = options || {};\n\n var query = new Query(data),\n aggregates = options.aggregate,\n filter = options.filter;\n\n if (filter) {\n query = query.filter(filter);\n }\n\n return query.aggregate(aggregates);\n },\n\n _process: function (data, e) {\n var that = this,\n options = {},\n result;\n\n if (that.options.serverPaging !== true) {\n options.skip = that._skip;\n options.take = that._take || that._pageSize;\n\n if(options.skip === undefined && that._page !== undefined && that._pageSize !== undefined) {\n options.skip = (that._page - 1) * that._pageSize;\n }\n\n if (that.options.useRanges) {\n options.skip = that.currentRangeStart();\n }\n }\n\n if (that.options.serverSorting !== true) {\n options.sort = that._sort;\n }\n\n if (that.options.serverFiltering !== true) {\n options.filter = that._filter;\n }\n\n if (that.options.serverGrouping !== true) {\n options.group = that._group;\n }\n\n if (that.options.serverAggregates !== true) {\n options.aggregate = that._aggregate;\n }\n\n if (that.options.serverGrouping) {\n that._clearEmptyGroups(data);\n }\n\n options.groupPaging = that._groupPaging;\n\n if (that._isGroupPaged() && e && (e.action === \"page\" || e.action === \"expandGroup\" || e.action === \"collapseGroup\")) {\n result = that._queryProcess(data, {\n aggregate: that._aggregate\n });\n } else {\n result = that._queryProcess(data, options);\n }\n\n if (that.options.serverAggregates !== true) {\n // for performance reasons, calculate aggregates for part of the data only after query process\n // this is necessary in the TreeList when paging\n that._aggregateResult = that._calculateAggregates(result.dataToAggregate || data, options);\n }\n\n that._setView(result, options, e);\n\n that._setFilterTotal(result.total, false);\n\n e = e || {};\n\n e.items = e.items || that._view;\n\n that.trigger(CHANGE, e);\n },\n\n _setView: function (result, options, e) {\n var that = this;\n\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\n if (options.skip + options.take > result.data.length) {\n options.skip = result.data.length - options.take;\n }\n\n that.view(query.range(options.skip, options.take).toArray());\n }\n\n } else {\n that.view(result.data);\n }\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(), [idx, 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 }\n else {\n return Query.process(data, options);\n }\n },\n\n _mergeState: function(options) {\n var that = this;\n\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\n if(that._skip === undefined) {\n that._skip = that._currentRangeStart = that.skip();\n options.skip = that.skip();\n }\n\n if(that._take === undefined && that._pageSize !== undefined) {\n that._take = that._pageSize;\n options.take = that._take;\n }\n\n if (options.sort) {\n that._sort = options.sort = normalizeSort(options.sort);\n that._sortFields = sortFields(options.sort);\n }\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\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\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\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\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\n this._setFilterTotal(result.total, true);\n\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, { items: result.data, action: options ? options.action : \"\" });\n }\n\n return $.Deferred().resolve(isPrevented).promise();\n },\n\n _hasExpandedSubGroups: function (group) {\n var result = false;\n var length = group.items ? group.items.length : 0;\n\n if (!group.hasSubgroups) {\n return false;\n }\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\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 groupCount;\n var itemsToSkip;\n\n for (var i = 0; i < length; i++) {\n group = data[i];\n\n if (options.taken >= options.take) {\n break;\n }\n\n if (!that._getGroupByUid(group.uid)) {\n that._groupsFlat.push(group);\n }\n\n if (that._groupsState[group.uid]) {\n if (that._isServerGroupPaged()) {\n if (that._fetchGroupItems(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 if (!that._hasExpandedSubGroups(group) && itemsToSkip > groupCount) {\n options.skipped += groupCount;\n continue;\n }\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 group.excludeHeader = false;\n }\n\n if (group.hasSubgroups && group.items && group.items.length) {\n group.currentItems = [];\n\n if (!parents) {\n parents = [];\n }\n parents.push(group);\n\n that._findGroupedRange(group.items, group.currentItems, options, parents, callback);\n parents.pop();\n\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\n for (var j = 0; j < itemsLength; j++) {\n if (options.skipped < options.skip) {\n options.skipped++;\n continue;\n }\n\n if (options.taken >= options.take) {\n break;\n }\n current.push(group.items[j]);\n options.taken++;\n }\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\n _expandedSubGroupItemsCount: function (group, end, includeCurrentItems) {\n var that = this;\n var result = 0;\n var subGroup;\n var endSpecified = typeof end === \"number\";\n var length = endSpecified ? end : group.subgroupCount;\n var temp;\n\n if (!group.hasSubgroups) {\n return result;\n }\n\n for (var i = 0; i < length; i++) {\n subGroup = group.items[i];\n\n if (!subGroup) {\n break;\n }\n\n if (subGroup.hasSubgroups && that._groupsState[group.uid]) {\n temp = that._expandedSubGroupItemsCount(subGroup, length, true);\n result += temp;\n\n if (endSpecified) {\n length -= temp;\n }\n } else if (!subGroup.hasSubgroups && that._groupsState[subGroup.uid]) {\n temp = subGroup.items ? subGroup.items.length : 0;\n result += temp;\n if (endSpecified) {\n length -= temp;\n }\n }\n\n if (includeCurrentItems) {\n result += 1;\n if (endSpecified) {\n length -= 1;\n }\n }\n\n if (endSpecified && result > length) {\n return result;\n }\n }\n\n return result;\n },\n\n _fetchGroupItems: function(group, options, parents, callback) {\n var that = this;\n var groupItemsSkip;\n var firstItem;\n var lastItem;\n var groupItemCount = group.hasSubgroups ? group.subgroupCount : group.itemCount;\n var take = options.take;\n var skipped = options.skipped;\n var pageSize = that.take();\n var expandedSubGroupItemsCount;\n\n if (options.includeParents) {\n if (skipped < options.skip) {\n skipped += 1;\n } else {\n take -= 1;\n }\n }\n\n if (!group.items || (group.items && !group.items.length)) {\n that.getGroupItems(group, options, parents, callback, 0);\n return true;\n } else {\n expandedSubGroupItemsCount = this._expandedSubGroupItemsCount(group, options.skip - skipped);\n groupItemsSkip = Math.max(options.skip - (skipped + expandedSubGroupItemsCount), 0);\n\n if (groupItemsSkip >= groupItemCount) {\n return false;\n }\n\n firstItem = group.items[groupItemsSkip];\n lastItem = group.items[Math.min(groupItemsSkip + take, groupItemCount - 1)];\n\n if (firstItem.notFetched) {\n that.getGroupItems(group, options, parents, callback, math.max(math.floor(groupItemsSkip / pageSize), 0) * pageSize, math.round((groupItemsSkip + pageSize) / pageSize));\n return true;\n }\n\n if (lastItem.notFetched) {\n that.getGroupItems(group, options, parents, callback, math.max(math.floor((groupItemsSkip + pageSize) / pageSize), 0) * pageSize, math.round((groupItemsSkip + pageSize) / pageSize));\n return true;\n }\n }\n },\n\n getGroupItems: function(group, options, parents, callback, groupItemsSkip, page) {\n var that = this;\n var take;\n var filter;\n var data;\n var subgroups;\n\n if (!group.items) {\n group.items = [];\n }\n\n take = that.take();\n filter = this._composeItemsFilter(group, parents);\n data = {\n page: page || 1,\n pageSize: take,\n skip: groupItemsSkip,\n take: take,\n filter: filter,\n aggregate: that._aggregate,\n sort: that._sort\n };\n subgroups = that.findSubgroups(group);\n\n if (subgroups && subgroups.length) {\n data.group = subgroups;\n data.groupPaging = true;\n }\n\n clearTimeout(that._timeout);\n that._timeout = setTimeout(function () {\n that._queueRequest(data, function () {\n if (!that.trigger(REQUESTSTART, {\n type: \"read\"\n })) {\n that.transport.read({\n data: data,\n success: that._groupItemsSuccessHandler(group, options.skip, that.take(), callback, groupItemsSkip),\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\n _groupItemsSuccessHandler: function(group, skip, take, callback, groupItemsSkip) {\n var that = this;\n var timestamp = that._timeStamp();\n callback = isFunction(callback) ? callback : noop;\n var totalField = that.options.schema && that.options.schema.total ? that.options.schema.total : \"Total\";\n\n return function (data) {\n var temp;\n var model = Model.define(that.options.schema.model);\n var totalCount;\n\n that._dequeueRequest();\n\n that.trigger(REQUESTEND, {\n response: data,\n type: \"read\"\n });\n\n if (isFunction(totalField)) {\n totalCount = totalField(data);\n } else {\n totalCount = data[totalField];\n }\n\n data = that.reader.parse(data);\n\n if (group.hasSubgroups) {\n temp = that.reader.groups(data);\n group.subgroupCount = totalCount;\n } else {\n temp = that.reader.data(data);\n temp = temp.map(function (item) {\n return new model(item);\n });\n }\n\n group.items.omitChangeEvent = true;\n for (var i = 0; i < totalCount; i++) {\n if (i >= groupItemsSkip && i < (groupItemsSkip + take) ) {\n group.items.splice(i, 1, temp[i - groupItemsSkip]);\n } else {\n if (!group.items[i]) {\n group.items.splice(i, 0, { notFetched: true });\n }\n }\n }\n group.items.omitChangeEvent = false;\n\n that._updateRangePristineData(group);\n that._fetchingGroupItems = false;\n\n if (!group.countAdded) {\n that._serverGroupsTotal += totalCount;\n group.countAdded = true;\n }\n\n that.range(skip, take, callback, \"expandGroup\");\n\n if (timestamp >= that._currentRequestTimeStamp || !that._skipRequestsInProgress) {\n that.trigger(CHANGE, {});\n }\n };\n },\n\n findSubgroups: function(group) {\n var indexOfCurrentGroup = this._group.map(function (g) {\n return g.field;\n }).indexOf(group.field);\n\n return this._group.slice(indexOfCurrentGroup + 1, this._group.length);\n },\n\n _composeItemsFilter: function(group, parents) {\n var filter = this.filter() || {\n logic: \"and\",\n filters: []\n };\n\n filter = extend(true, {}, filter);\n filter.filters.push({\n field: group.field,\n operator: \"eq\",\n value: group.value\n });\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\n return filter;\n },\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 var currIdx;\n\n for (var i = 0; i < rangesLength; i++) {\n range = ranges[i];\n dataLength = range.data.length;\n indexes = [];\n temp = null;\n\n for (var j = 0; j < dataLength; j++) {\n currentGroup = range.data[j];\n indexes.push(j);\n\n if ((currentGroup.uid === group.uid) || (currentGroup.hasSubgroups && currentGroup.items.length && that._containsSubGroup(currentGroup, group, indexes))) {\n break;\n }\n indexes.pop();\n }\n\n if (indexes.length) {\n temp = ranges[i].pristineData;\n\n while (indexes.length > 1) {\n currIdx = indexes.splice(0, 1)[0];\n temp = temp[currIdx].items;\n }\n temp[indexes[0]] = that._cloneGroup(group);\n break;\n }\n }\n },\n\n _containsSubGroup: function(group, subgroup, indexes) {\n var that = this;\n var length = group.items.length;\n var currentSubGroup;\n\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 },\n\n _cloneGroup: function(group) {\n var that = this;\n group = typeof group.toJSON == \"function\" ? group.toJSON() : group;\n\n if (group.items && group.items.length) {\n group.items = group.items.map(function (item) {\n return that._cloneGroup(item);\n });\n }\n\n return group;\n },\n\n _setFilterTotal: function(filterTotal, setDefaultValue) {\n var that = this;\n\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\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\n return this._query().done(fn);\n },\n\n _query: function(options) {\n var that = this;\n\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\n next: function(options) {\n var that = this,\n page = that.page(),\n total = that.total();\n\n options = options || {};\n\n if (!page || (total && page + 1 > that.totalPages())) {\n return;\n }\n\n that._skip = that._currentRangeStart = page * that.take();\n\n page += 1;\n options.page = page;\n\n that._query(options);\n\n return page;\n },\n\n prev: function(options) {\n var that = this,\n page = that.page();\n\n options = options || {};\n\n if (!page || page === 1) {\n return;\n }\n\n that._skip = that._currentRangeStart = that._skip - that.take();\n\n page -= 1;\n options.page = page;\n\n that._query(options);\n\n return page;\n },\n\n page: function(val) {\n var that = this,\n skip;\n\n if(val !== undefined) {\n val = math.max(math.min(math.max(val, 1), that.totalPages()), 1);\n var take = that.take();\n\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\n return skip !== undefined ? math.round((skip || 0) / (that.take() || 1)) + 1 : undefined;\n },\n\n pageSize: function(val) {\n var that = this;\n\n if (val !== undefined) {\n that._query(that._pageableQueryOptions({ pageSize: val, page: 1 }));\n return;\n }\n\n return that.take();\n },\n\n sort: function(val) {\n var that = this;\n\n if(val !== undefined) {\n that.trigger(\"sort\");\n that._query({ sort: val });\n return;\n }\n\n return that._sort;\n },\n\n filter: function(val) {\n var that = this;\n\n if (val === undefined) {\n return that._filter;\n }\n\n that.trigger(\"reset\");\n that._query({ filter: val, page: 1 });\n },\n\n group: function(val) {\n var that = this;\n var options = { group: val };\n\n if (that._groupPaging) {\n // clear ranges if ungrouping is performed\n if (val!== undefined && (!val || !val.length) ) {\n that._ranges = [];\n }\n options.page = 1;\n }\n\n if(val !== undefined) {\n that._query(options);\n return;\n }\n\n return that._group;\n },\n\n getGroupsFlat: function (data) {\n var idx,\n result = [],\n length;\n\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\n result.push(group);\n }\n\n return result;\n },\n\n total: function() {\n return parseInt(this._total || 0, 10);\n },\n\n groupsTotal: function (includeExpanded) {\n var that = this;\n\n if (!that._group.length) {\n return that.total();\n }\n\n if (that._isServerGrouped()) {\n if (that._serverGroupsTotal) {\n return that._serverGroupsTotal;\n }\n that._serverGroupsTotal = that.total();\n\n return that._serverGroupsTotal;\n }\n\n return that._calculateGroupsTotal(that._ranges.length ? that._ranges[0].data : [], includeExpanded);\n },\n\n _calculateGroupsTotal: function (groups, includeExpanded, itemsField, ignoreState) {\n var that = this;\n itemsField = itemsField || \"items\";\n var total;\n var length;\n\n if (that._group.length && groups) {\n total = 0;\n length = groups.length;\n\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\n that._groupsTotal = that._data.length;\n return that._groupsTotal;\n },\n\n groupCount: function (group, includeExpanded, itemsField, ignoreState) {\n var that = this;\n var total = 0;\n\n if (group.hasSubgroups && that._groupsState[group.uid]) {\n if (includeExpanded && !group.excludeHeader || ignoreState) {\n total += 1;\n }\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\n countGroupRange: function (range) {\n var total = 0;\n var length = range.length;\n\n for (var i = 0; i < length; i++) {\n total += this.groupCount(range[i], true);\n }\n\n return total;\n },\n\n aggregate: function(val) {\n var that = this;\n\n if(val !== undefined) {\n that._query({ aggregate: val });\n return;\n }\n\n return that._aggregate;\n },\n\n aggregates: function() {\n var result = this._aggregateResult;\n\n if (isEmptyObject(result)) {\n result = this._emptyAggregates(this.aggregate());\n }\n\n return result;\n },\n\n _emptyAggregates: function(aggregates) {\n var result = {};\n\n if (!isEmptyObject(aggregates)) {\n var aggregate = {};\n\n if (!isArray(aggregates)){\n aggregates = [aggregates];\n }\n\n for (var idx = 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\n return parent;\n },\n\n totalPages: function() {\n var that = this,\n pageSize = that.pageSize() || that.total(),\n total = that._isGroupPaged() ? that.groupsTotal(true) : that.total();\n\n return math.ceil((total || 0) / pageSize);\n },\n\n inRange: function(skip, take) {\n var that = this,\n end = math.min(skip + take, that.total());\n\n if (!that.options.serverPaging && that._data.length > 0) {\n return true;\n }\n\n return that._findRange(skip, end).length > 0;\n },\n\n lastRange: function() {\n var ranges = this._ranges;\n return ranges[ranges.length - 1] || { start: 0, end: 0, 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\n enableRequestsInProgress: function() {\n this._skipRequestsInProgress = false;\n },\n\n _timeStamp: function() {\n return new Date().getTime();\n },\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\n if (action === \"expandGroup\" || action === \"collapseGroup\") {\n this._updateOuterRangesLength();\n }\n\n skip = math.min(skip || 0, total);\n callback = isFunction(callback) ? callback : noop;\n\n var that = this,\n pageSkip = math.max(math.floor(skip / take), 0) * take,\n size = math.min(pageSkip + take, total),\n data;\n\n data = that._findRange(skip, math.min(skip + take, total), callback);\n\n if ((data.length || total === 0) && !that._fetchingGroupItems) {\n that._processRangeData(data, skip, take, that._originalPageSkip || pageSkip, that._originalSize || size, {\n action: action\n });\n that._originalPageSkip = null;\n that._originalSize = null;\n callback();\n return;\n }\n\n if (that._isGroupPaged()) {\n that._originalPageSkip = pageSkip;\n that._originalSize = size;\n\n pageSkip = math.max(math.floor(that._adjustPageSkip(skip, take) / take), 0) * take;\n size = math.min(pageSkip + take, total);\n }\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\n _findRange: function(start, end, callback) {\n var that = this,\n ranges = that._ranges,\n range,\n data = [],\n skipIdx,\n takeIdx,\n startIndex,\n endIndex,\n rangeData,\n rangeEnd,\n processed,\n options = that.options,\n remote = options.serverSorting || options.serverPaging || options.serverFiltering || options.serverGrouping || options.serverAggregates,\n flatData,\n count,\n length,\n groupMapOptions = {\n take: end - start,\n skip: start,\n skipped: 0,\n taken: 0,\n includeParents: true\n },\n prevRangeEnd,\n isGroupPaged = that._isGroupPaged(),\n startField = isGroupPaged ? \"outerStart\" : \"start\",\n endField = isGroupPaged ? \"outerEnd\" : \"end\",\n currentDataLength;\n\n for (skipIdx = 0, length = ranges.length; skipIdx < length; skipIdx++) {\n range = ranges[skipIdx];\n\n if (isGroupPaged) {\n if (range.outerStart >= end) {\n return [];\n }\n\n if (start > range.outerEnd) {\n groupMapOptions.skipped += range.outerEnd - (prevRangeEnd || 0);\n prevRangeEnd = range.outerEnd;\n continue;\n }\n\n if (typeof prevRangeEnd !== \"undefined\" && prevRangeEnd != range.outerStart) {\n groupMapOptions.skipped += range.outerStart - prevRangeEnd;\n }\n\n if (groupMapOptions.skipped > groupMapOptions.skip) {\n return [];\n }\n\n if (typeof prevRangeEnd === \"undefined\" && start > 0 && range.start > 0) {\n groupMapOptions.skipped = range.outerStart;\n }\n\n takeIdx = skipIdx;\n while (true) {\n this._findGroupedRange(range.data, data, groupMapOptions, null, callback);\n currentDataLength = that._calculateGroupsTotal(data, true, \"currentItems\");\n\n if (currentDataLength >= groupMapOptions.take) {\n return data;\n }\n\n if (that._fetchingGroupItems) {\n return [];\n }\n takeIdx++;\n\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\n for (takeIdx = skipIdx; takeIdx < length; takeIdx++) {\n range = ranges[takeIdx];\n flatData = that._flatData(range.data, true);\n\n if (flatData.length && start + count >= range.start) {\n rangeData = range.data;\n rangeEnd = range.end;\n\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, { sort: sort, filter: that.filter() });\n }\n flatData = rangeData = processed.data;\n\n if (processed.total !== undefined) {\n rangeEnd = processed.total;\n }\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\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\n _getRangesMismatch: function (pageSkip) {\n var that = this;\n var ranges = that._ranges;\n var mismatch = 0;\n var i = 0;\n\n while (true) {\n var range = ranges[i];\n if (!range || range.outerStart > pageSkip) {\n break;\n }\n\n if (range.outerEnd != range.end) {\n mismatch = range.outerEnd - range.end;\n }\n i++;\n }\n\n return mismatch;\n },\n\n _mergeGroups: function(data, range, skip, take) {\n if (this._isServerGrouped()) {\n var temp = range.toJSON(),\n prevGroup;\n\n if (data.length) {\n prevGroup = data[data.length - 1];\n }\n\n mergeGroups(prevGroup, temp, skip, take);\n\n return data.concat(temp);\n }\n return data.concat(range.slice(skip, take));\n },\n\n _processRangeData: function(data, skip, take, pageSkip, size, eventData) {\n var that = this;\n\n that._pending = undefined;\n\n that._skip = skip > that.skip() && !that._omitPrefetch ? math.min(size, (that.totalPages() - 1) * that.take()) : pageSkip;\n\n that._currentRangeStart = skip;\n\n that._take = take;\n\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\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\n skip: function() {\n var that = this;\n\n if (that._skip === undefined) {\n return (that._page !== undefined ? (that._page - 1) * (that.take() || 1) : undefined);\n }\n return that._skip;\n },\n\n currentRangeStart: function() {\n return this._currentRangeStart || 0;\n },\n\n take: function() {\n return this._take || this._pageSize;\n },\n\n _prefetchSuccessHandler: function (skip, size, callback, force) {\n var that = this;\n var timestamp = that._timeStamp();\n\n return function(data) {\n var found = false,\n range = { start: skip, end: size, data: [], timestamp: that._timeStamp() },\n idx,\n length,\n temp;\n\n that._dequeueRequest();\n\n that.trigger(REQUESTEND, { response: data, type: \"read\" });\n\n data = that.reader.parse(data);\n\n temp = that._readData(data);\n\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\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\n break;\n }\n }\n\n if (!found) {\n that._addRange(that._observe(temp), skip);\n }\n }\n\n that._total = that.reader.total(data);\n\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\n prefetch: function(skip, take, callback) {\n var that = this,\n size = math.min(skip + take, that.total()),\n 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\n\n if ((that._isGroupPaged() && !that._isServerGrouped() && that._groupRangeExists(skip, size))) {\n if (callback) {\n callback();\n }\n return;\n }\n\n if ((that._isServerGroupPaged() && !that._groupRangeExists(skip, size)) || !that._rangeExists(skip, size)) {\n clearTimeout(that._timeout);\n\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\n _multiplePrefetch: function(skip, take, callback) {\n var that = this,\n size = math.min(skip + take, that.total()),\n 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\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\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\n if (prevRange) {\n mismatch = that._getRangesMismatch(start);\n\n if (!mismatch) {\n return start;\n }\n start -= mismatch;\n }\n result = math.max(math.floor(start / take), 0) * take;\n\n if (result > total) {\n while (true) {\n result -= take;\n if (result < total) {\n break;\n }\n }\n }\n return result;\n },\n\n _getNextRange: function (end) {\n var that = this,\n ranges = that._ranges,\n idx,\n length;\n\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\n _getPrevRange: function (start) {\n var that = this,\n ranges = that._ranges,\n idx,\n range,\n length = ranges.length;\n\n for (idx = length - 1; idx >= 0; idx--) {\n if (ranges[idx].outerStart <= start) {\n range = ranges[idx];\n break;\n }\n\n }\n\n return range;\n },\n\n _rangeExists: function(start, end) {\n var that = this,\n ranges = that._ranges,\n idx,\n length;\n\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\n return false;\n },\n\n _groupRangeExists: function (start, end) {\n var that = this,\n ranges = that._ranges,\n idx,\n length,\n availableItemsCount = 0,\n total = that.groupsTotal(true);\n\n if (end > total && !that._isServerGrouped()) {\n end = total;\n }\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\n return availableItemsCount >= end - start;\n },\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\n for (idx = 0; idx < length; idx++) {\n range = ranges[idx];\n\n if ((range.start <= start && range.end >= start) || (range.start >= start && range.start <= end)) {\n rangeSpan.push(range);\n }\n }\n\n return rangeSpan;\n },\n\n _removeModelFromRanges: function(model) {\n var that = this;\n var range;\n\n for (var idx = 0, length = this._ranges.length; idx < length; idx++) {\n range = this._ranges[idx];\n\n that._removeModelFromRange(range, model);\n }\n\n that._updateRangesLength();\n },\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\n if (dataItem.uid && dataItem.uid == model.uid) {\n [].splice.call(data, idx, 1);\n break;\n }\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\n for (i = 0; i < rangesLength; i++) {\n range = ranges[i];\n\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\n break;\n }\n }\n\n that._updateRangesLength();\n },\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\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\n if (!mismatchFound && lengthDifference !== 0) {\n mismatchFound = true;\n mismatchLength = lengthDifference;\n range.end += mismatchLength;\n continue;\n }\n\n if (mismatchFound) {\n range.start += mismatchLength;\n range.end += mismatchLength;\n }\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\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\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\n range.outerEnd = range.outerStart + rangeLength;\n prevRange = range;\n }\n }\n });\n\n var Transport = {};\n\n Transport.create = function(options, data, dataSource) {\n var transport,\n transportOptions = options.transport ? $.extend({}, options.transport) : null;\n\n if (transportOptions) {\n transportOptions.read = typeof transportOptions.read === STRING ? { url: transportOptions.read } : transportOptions.read;\n\n if (options.type === \"jsdo\") {\n transportOptions.dataSource = dataSource;\n }\n\n if (options.type) {\n kendo.data.transports = kendo.data.transports || {};\n kendo.data.schemas = kendo.data.schemas || {};\n\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\n options.schema = extend(true, {}, kendo.data.schemas[options.type], options.schema);\n }\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\n DataSource.create = function(options) {\n if (isArray(options) || options instanceof ObservableArray) {\n options = { data: options };\n }\n\n var dataSource = options || {},\n data = dataSource.data,\n fields = dataSource.fields,\n table = dataSource.table,\n select = dataSource.select,\n idx,\n length,\n model = {},\n field;\n\n if (!data && fields && !dataSource.transport) {\n if (table) {\n data = inferTable(table, fields);\n } else if (select) {\n data = inferSelect(select, fields);\n\n if (dataSource.group === undefined && data[0] && data[0].optgroup !== undefined) {\n dataSource.group = \"optgroup\";\n }\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\n if (!isEmptyObject(model)) {\n dataSource.schema = extend(true, dataSource.schema, { model: { fields: model } });\n }\n }\n\n dataSource.data = data;\n\n select = null;\n dataSource.select = null;\n table = null;\n dataSource.table = null;\n\n return dataSource instanceof DataSource ? dataSource : new DataSource(dataSource);\n };\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\n var data = [];\n var idx, length;\n var optgroup;\n var option;\n var record;\n var value;\n\n for (idx = 0, length = options.length; idx < length; idx++) {\n record = {};\n option = options[idx];\n optgroup = option.parentNode;\n\n if (optgroup === select) {\n optgroup = null;\n }\n\n if (option.disabled || (optgroup && optgroup.disabled)) {\n continue;\n }\n\n if (optgroup) {\n record.optgroup = optgroup.label;\n }\n\n record[firstField.field] = option.text;\n\n value = option.attributes.value;\n\n if (value && value.specified) {\n value = option.value;\n } else {\n value = option.text;\n }\n\n record[secondField.field] = value;\n\n data.push(record);\n }\n\n return data;\n }\n\n function inferTable(table, fields) {\n var tbody = $(table)[0].tBodies[0],\n rows = tbody ? tbody.rows : [],\n idx,\n length,\n fieldIndex,\n fieldCount = fields.length,\n data = [],\n cells,\n record,\n cell,\n empty;\n\n for (idx = 0, length = rows.length; idx < length; idx++) {\n record = {};\n empty = true;\n cells = rows[idx].cells;\n\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\n return data;\n }\n\n var Node = Model.define({\n idField: \"id\",\n\n init: function(value) {\n var that = this,\n hasChildren = that.hasChildren || value && value.hasChildren,\n childrenField = \"items\",\n childrenOptions = {};\n\n kendo.data.Model.fn.init.call(that, value);\n\n if (typeof that.children === STRING) {\n childrenField = that.children;\n }\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\n if (typeof that.children !== STRING) {\n extend(childrenOptions, that.children);\n }\n\n childrenOptions.data = value;\n\n if (!hasChildren) {\n hasChildren = childrenOptions.schema.data;\n }\n\n if (typeof hasChildren === STRING) {\n hasChildren = kendo.getter(hasChildren);\n }\n\n if (isFunction(hasChildren)) {\n var hasChildrenObject = hasChildren.call(that, that);\n\n if(hasChildrenObject && hasChildrenObject.length === 0){\n that.hasChildren = false;\n } else{\n that.hasChildren = !!hasChildrenObject;\n }\n }\n\n that._childrenOptions = childrenOptions;\n\n if (that.hasChildren) {\n that._initChildren();\n }\n\n that._loaded = !!(value && value._loaded);\n },\n\n _initChildren: function() {\n var that = this;\n var children, transport, parameterMap;\n\n if (!(that.children instanceof HierarchicalDataSource)) {\n children = that.children = new HierarchicalDataSource(that._childrenOptions);\n\n transport = children.transport;\n parameterMap = transport.parameterMap;\n\n transport.parameterMap = function(data, type) {\n data[that.idField || \"id\"] = that.id;\n\n if (parameterMap) {\n data = parameterMap.call(that, data, type);\n }\n\n return data;\n };\n\n children.parent = function(){\n return that;\n };\n\n children.bind(CHANGE, function(e){\n e.node = e.node || that;\n that.trigger(CHANGE, e);\n });\n\n children.bind(ERROR, function(e){\n var collection = that.parent();\n\n if (collection) {\n e.node = e.node || that;\n collection.trigger(ERROR, e);\n }\n });\n\n that._updateChildrenField();\n }\n },\n\n append: function(model) {\n this._initChildren();\n this.loaded(true);\n this.children.add(model);\n },\n\n hasChildren: false,\n\n level: function() {\n var parentNode = this.parentNode(),\n level = 0;\n\n while (parentNode && parentNode.parentNode) {\n level++;\n parentNode = parentNode.parentNode ? parentNode.parentNode() : null;\n }\n\n return level;\n },\n\n _updateChildrenField: function() {\n var fieldName = this._childrenOptions.schema.data;\n\n this[fieldName || \"items\"] = this.children.data();\n },\n\n _childrenLoaded: function() {\n this._loaded = true;\n\n this._updateChildrenField();\n },\n\n load: function() {\n var options = {};\n var method = \"_query\";\n var children, promise;\n\n if (this.hasChildren) {\n this._initChildren();\n\n children = this.children;\n\n options[this.idField || \"id\"] = this.id;\n\n if (!this._loaded) {\n children._data = undefined;\n method = \"read\";\n }\n\n children.one(CHANGE, proxy(this._childrenLoaded, this));\n\n if(this._matchFilter){\n options.filter = { field: '_matchFilter', operator: 'eq', value: true };\n }\n\n promise = children[method](options);\n } else {\n this.loaded(true);\n }\n\n return promise || $.Deferred().resolve().promise();\n },\n\n parentNode: function() {\n var array = this.parent();\n\n return array.parent();\n },\n\n loaded: function(value) {\n if (value !== undefined) {\n this._loaded = value;\n } else {\n return this._loaded;\n }\n },\n\n shouldSerialize: function(field) {\n return Model.fn.shouldSerialize.call(this, field) &&\n field !== \"children\" &&\n field !== \"_loaded\" &&\n field !== \"hasChildren\" &&\n field !== \"_childrenOptions\";\n }\n });\n\n function dataMethod(name) {\n return function() {\n var data = this._data,\n result = DataSource.fn[name].apply(this, slice.call(arguments));\n\n if (this._data != data) {\n this._attachBubbleHandlers();\n }\n\n return result;\n };\n }\n\n var HierarchicalDataSource = DataSource.extend({\n init: function(options) {\n var node = Node.define({\n children: options\n });\n\n if(options.filter && !options.serverFiltering){\n this._hierarchicalFilter = options.filter;\n options.filter = null;\n }\n\n DataSource.fn.init.call(this, extend(true, {}, { schema: { modelBase: node, model: node } }, options));\n\n this._attachBubbleHandlers();\n },\n\n _attachBubbleHandlers: function() {\n var that = this;\n\n that._data.bind(ERROR, function(e) {\n that.trigger(ERROR, e);\n });\n },\n\n read: function(data) {\n var result = DataSource.fn.read.call(this, data);\n\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\n return result;\n },\n\n remove: function(node){\n var parentNode = node.parentNode(),\n dataSource = this,\n result;\n\n if (parentNode && parentNode._initChildren) {\n dataSource = parentNode.children;\n }\n\n result = DataSource.fn.remove.call(dataSource, node);\n\n if (parentNode && !dataSource.data().length) {\n parentNode.hasChildren = false;\n }\n\n return result;\n },\n\n success: dataMethod(\"success\"),\n\n data: dataMethod(\"data\"),\n\n insert: function(index, model) {\n var parentNode = this.parent();\n\n if (parentNode && parentNode._initChildren) {\n parentNode.hasChildren = true;\n parentNode._initChildren();\n }\n\n return DataSource.fn.insert.call(this, index, model);\n },\n\n filter: function(val) {\n if (val === undefined) {\n return this._filter;\n }\n\n if(!this.options.serverFiltering && this._markHierarchicalQuery(val)){\n val = { logic: \"or\", filters: [val, {field:'_matchFilter', operator: 'equals', value: true }]};\n }\n\n this.trigger(\"reset\");\n this._query({ filter: val, 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\n expressions = accentFoldingFiltering ? $.extend({}, normalizeFilter(expressions), { accentFoldingFiltering: accentFoldingFiltering}) : normalizeFilter(expressions);\n\n if (!expressions || expressions.filters.length === 0) {\n this._updateHierarchicalFilter(function(){return true;});\n return false;\n }\n\n compiled = Query.filterExpr(expressions);\n fields = compiled.fields;\n operators = compiled.operators;\n\n predicate = filter = new Function(\"d, __f, __o\", \"return \" + compiled.expression);\n\n if (fields.length || operators.length) {\n filter = function(d) {\n return predicate(d, fields, operators);\n };\n }\n\n this._updateHierarchicalFilter(filter);\n return true;\n },\n\n _updateHierarchicalFilter: function(filter){\n var current;\n var data = this._data;\n var result = false;\n\n for (var idx = 0; idx < data.length; idx++) {\n current = data[idx];\n\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\n if(current._matchFilter){\n result = true;\n }\n }\n return result;\n },\n\n _find: function(method, value) {\n var idx, length, node, children;\n var data = this._data;\n\n if (!data) {\n return;\n }\n\n node = DataSource.fn[method].call(this, value);\n\n if (node) {\n return node;\n }\n\n data = this._flatData(this._data);\n\n for (idx = 0, length = data.length; idx < length; idx++) {\n children = data[idx].children;\n\n if (!(children instanceof HierarchicalDataSource)) {\n continue;\n }\n\n node = children[method](value);\n\n if (node) {\n return node;\n }\n }\n },\n\n get: function(id) {\n return this._find(\"get\", id);\n },\n\n getByUid: function(uid) {\n return this._find(\"getByUid\", uid);\n }\n });\n\n function inferList(list, fields) {\n var items = $(list).children(),\n idx,\n length,\n data = [],\n record,\n textField = fields[0].field,\n urlField = fields[1] && fields[1].field,\n spriteCssClassField = fields[2] && fields[2].field,\n imageUrlField = fields[3] && fields[3].field,\n item,\n id,\n textChild,\n className,\n children;\n\n function elements(collection, tagName) {\n return collection.filter(tagName).add(collection.find(tagName));\n }\n\n for (idx = 0, length = items.length; idx < length; idx++) {\n record = { _loaded: true };\n item = items.eq(idx);\n\n textChild = item[0].firstChild;\n children = item.children();\n list = children.filter(\"ul\");\n children = children.filter(\":not(ul)\");\n\n id = item.attr(\"data-id\");\n\n if (id) {\n record.id = id;\n }\n\n if (textChild) {\n record[textField] = textChild.nodeType == 3 ? textChild.nodeValue : children.text();\n }\n\n if (urlField) {\n record[urlField] = elements(children, \"a\").attr(\"href\");\n }\n\n if (imageUrlField) {\n record[imageUrlField] = elements(children, \"img\").attr(\"src\");\n }\n\n if (spriteCssClassField) {\n className = elements(children, \".k-sprite\").prop(\"className\");\n record[spriteCssClassField] = className && kendo.trim(className.replace(\"k-sprite\", \"\"));\n }\n\n if (list.length) {\n record.items = inferList(list.eq(0), fields);\n }\n\n if (item.attr(\"data-hasChildren\") == \"true\") {\n record.hasChildren = true;\n }\n\n data.push(record);\n }\n\n return data;\n }\n\n HierarchicalDataSource.create = function(options) {\n options = options && options.push ? { data: options } : options;\n\n var dataSource = options || {},\n data = dataSource.data,\n fields = dataSource.fields,\n list = dataSource.list;\n\n if (data && data._dataSource) {\n return data._dataSource;\n }\n\n if (!data && fields && !dataSource.transport) {\n if (list) {\n data = inferList(list, fields);\n }\n }\n\n dataSource.data = data;\n\n return dataSource instanceof HierarchicalDataSource ? dataSource : new HierarchicalDataSource(dataSource);\n };\n\n var Buffer = kendo.Observable.extend({\n init: function(dataSource, viewSize, disablePrefetch) {\n kendo.Observable.fn.init.call(this);\n\n this._prefetching = false;\n this.dataSource = dataSource;\n this.prefetch = !disablePrefetch;\n\n var buffer = this;\n\n dataSource.bind(\"change\", function() {\n buffer._change();\n });\n\n dataSource.bind(\"reset\", function() {\n buffer._reset();\n });\n\n this._syncWithDataSource();\n\n this.setViewSize(viewSize);\n },\n\n setViewSize: function(viewSize) {\n this.viewSize = viewSize;\n this._recalculate();\n },\n\n at: function(index) {\n var pageSize = this.pageSize,\n itemPresent = true;\n\n if (index >= this.total()) {\n this.trigger(\"endreached\", {index: index });\n return null;\n }\n\n if (!this.useRanges) {\n return this.dataSource.view()[index];\n }\n if (this.useRanges) {\n // out of range request\n if (index < this.dataOffset || index >= this.skip + pageSize) {\n itemPresent = this.range(Math.floor(index / pageSize) * pageSize);\n }\n\n // prefetch\n if (index === this.prefetchThreshold) {\n this._prefetch();\n }\n\n // mid-range jump - prefetchThreshold and nextPageThreshold may be equal, do not change to else if\n if (index === this.midPageThreshold) {\n this.range(this.nextMidRange, true);\n }\n // next range jump\n else if (index === this.nextPageThreshold) {\n this.range(this.nextFullRange);\n }\n // pull-back\n else if (index === this.pullBackThreshold) {\n if (this.offset === this.skip) { // from full range to mid range\n this.range(this.previousMidRange);\n } else { // from mid range to full range\n this.range(this.previousFullRange);\n }\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\n indexOf: function(item) {\n return this.dataSource.data().indexOf(item) + this.dataOffset;\n },\n\n total: function() {\n return parseInt(this.dataSource.total(), 10);\n },\n\n next: function() {\n var buffer = this,\n pageSize = buffer.pageSize,\n offset = buffer.skip - buffer.viewSize + pageSize,\n pageSkip = math.max(math.floor(offset / pageSize), 0) * pageSize;\n\n this.offset = offset;\n this.dataSource.prefetch(pageSkip, pageSize, function() {\n buffer._goToRange(offset, true);\n });\n },\n\n range: function(offset, nextRange) {\n if (this.offset === offset) {\n return true;\n }\n\n var buffer = this,\n pageSize = this.pageSize,\n pageSkip = math.max(math.floor(offset / pageSize), 0) * pageSize,\n dataSource = this.dataSource;\n\n if (nextRange) {\n pageSkip += pageSize;\n }\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\n return true;\n },\n\n syncDataSource: function() {\n var offset = this.offset;\n this.offset = null;\n this.range(offset);\n },\n\n destroy: function() {\n this.unbind();\n },\n\n _prefetch: function() {\n var buffer = this,\n pageSize = this.pageSize,\n prefetchOffset = this.skip + pageSize,\n dataSource = this.dataSource;\n\n if (!dataSource.inRange(prefetchOffset, pageSize) && !this._prefetching && this.prefetch) {\n this._prefetching = true;\n this.trigger(\"prefetching\", { skip: prefetchOffset, take: pageSize });\n\n dataSource.prefetch(prefetchOffset, pageSize, function() {\n buffer._prefetching = false;\n buffer.trigger(\"prefetched\", { skip: prefetchOffset, take: pageSize });\n });\n }\n },\n\n _goToRange: function(offset, expanding) {\n if (this.offset !== offset) {\n return;\n }\n\n this.dataOffset = offset;\n this._expanding = expanding;\n this.dataSource.range(offset, this.pageSize);\n this.dataSource.enableRequestsInProgress();\n },\n\n _reset: function() {\n this._syncPending = true;\n },\n\n _change: function() {\n var dataSource = this.dataSource;\n\n this.length = this.useRanges ? dataSource.lastRange().end : dataSource.view().length;\n\n if (this._syncPending) {\n this._syncWithDataSource();\n this._recalculate();\n this._syncPending = false;\n this.trigger(\"reset\", { offset: this.offset });\n }\n\n this.trigger(\"resize\");\n\n if (this._expanding) {\n this.trigger(\"expand\");\n }\n\n delete this._expanding;\n },\n\n _syncWithDataSource: function() {\n var dataSource = this.dataSource;\n\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\n _recalculate: function() {\n var pageSize = this.pageSize,\n offset = this.offset,\n viewSize = this.viewSize,\n skip = Math.ceil(offset / pageSize) * pageSize;\n\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\n this.nextMidRange = skip + pageSize - viewSize;\n this.nextFullRange = skip;\n this.previousMidRange = offset - viewSize;\n this.previousFullRange = skip - pageSize;\n }\n });\n\n var BatchBuffer = kendo.Observable.extend({\n init: function(dataSource, batchSize) {\n var batchBuffer = this;\n\n kendo.Observable.fn.init.call(batchBuffer);\n\n this.dataSource = dataSource;\n this.batchSize = batchSize;\n this._total = 0;\n\n this.buffer = new Buffer(dataSource, batchSize * 3);\n\n this.buffer.bind({\n \"endreached\": function (e) {\n batchBuffer.trigger(\"endreached\", { index: e.index });\n },\n \"prefetching\": function (e) {\n batchBuffer.trigger(\"prefetching\", { skip: e.skip, take: e.take });\n },\n \"prefetched\": function (e) {\n batchBuffer.trigger(\"prefetched\", { skip: e.skip, take: e.take });\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\", { total: batchBuffer.total(), offset: this.offset });\n }\n });\n },\n\n syncDataSource: function() {\n this.buffer.syncDataSource();\n },\n\n at: function(index) {\n var buffer = this.buffer,\n skip = index * this.batchSize,\n take = this.batchSize,\n view = [],\n item;\n\n if (buffer.offset > skip) {\n buffer.at(buffer.offset - 1);\n }\n\n for (var i = 0; i < take; i++) {\n item = buffer.at(skip + i);\n\n if (item === null) {\n break;\n }\n\n view.push(item);\n }\n\n return view;\n },\n\n total: function() {\n return this._total;\n },\n\n destroy: function() {\n this.buffer.destroy();\n this.unbind();\n }\n });\n\n extend(true, kendo.data, {\n readers: {\n json: DataReader\n },\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\nreturn window.kendo;\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n\n(function(f, define){\n define('kendo.binder',[ \"./kendo.core\", \"./kendo.data\" ], f);\n})(function(){\n\nvar __meta__ = { // jshint ignore:line\n id: \"binder\",\n name: \"MVVM\",\n category: \"framework\",\n description: \"Model View ViewModel (MVVM) is a design pattern which helps developers separate the Model (the data) from the View (the UI).\",\n depends: [ \"core\", \"data\" ]\n};\n\n/*jshint eqnull: true */\n(function ($, undefined) {\n var kendo = window.kendo,\n Observable = kendo.Observable,\n ObservableObject = kendo.data.ObservableObject,\n ObservableArray = kendo.data.ObservableArray,\n toString = {}.toString,\n binders = {},\n Class = kendo.Class,\n proxy = $.proxy,\n VALUE = \"value\",\n SOURCE = \"source\",\n EVENTS = \"events\",\n CHECKED = \"checked\",\n CSS = \"css\",\n deleteExpando = true,\n FUNCTION = \"function\",\n CHANGE = \"change\";\n\n (function() {\n var a = document.createElement(\"a\");\n\n try {\n delete a.test;\n } catch(e) {\n deleteExpando = false;\n }\n })();\n\n var Binding = Observable.extend( {\n init: function(parents, path) {\n var that = this;\n\n Observable.fn.init.call(that);\n\n that.source = parents[0];\n that.parents = parents;\n that.path = path;\n that.dependencies = {};\n that.dependencies[path] = true;\n that.observable = that.source instanceof Observable;\n\n that._access = function(e) {\n that.dependencies[e.field] = true;\n };\n\n if (that.observable) {\n that._change = function(e) {\n that.change(e);\n };\n\n that.source.bind(CHANGE, that._change);\n }\n },\n\n _parents: function() {\n var parents = this.parents;\n var value = this.get();\n\n if (value && typeof value.parent == \"function\") {\n var parent = value.parent();\n\n if ($.inArray(parent, parents) < 0) {\n parents = [parent].concat(parents);\n }\n }\n\n return parents;\n },\n\n change: function(e) {\n var dependency,\n ch,\n field = e.field,\n that = this;\n\n if (that.path === \"this\") {\n that.trigger(CHANGE, e);\n } else {\n for (dependency in that.dependencies) {\n if (dependency.indexOf(field) === 0) {\n ch = dependency.charAt(field.length);\n\n if (!ch || ch === \".\" || ch === \"[\") {\n that.trigger(CHANGE, e);\n break;\n }\n }\n }\n }\n },\n\n start: function(source) {\n source.bind(\"get\", this._access);\n },\n\n stop: function(source) {\n source.unbind(\"get\", this._access);\n },\n\n get: function() {\n\n var that = this,\n source = that.source,\n index = 0,\n path = that.path,\n result = source;\n\n if (!that.observable) {\n return result;\n }\n\n that.start(that.source);\n\n result = source.get(path);\n\n // Traverse the observable hierarchy if the binding is not resolved at the current level.\n while (result === undefined && source) {\n\n source = that.parents[++index];\n\n if (source instanceof ObservableObject) {\n result = source.get(path);\n }\n }\n\n // second pass try to get the parent from the object hierarchy\n if (result === undefined) {\n source = that.source; //get the initial source\n\n while (result === undefined && source) {\n source = source.parent();\n\n if (source instanceof ObservableObject) {\n result = source.get(path);\n }\n }\n }\n\n // If the result is a function - invoke it\n if (typeof result === \"function\") {\n index = path.lastIndexOf(\".\");\n\n // If the function is a member of a nested observable object make that nested observable the context (this) of the function\n if (index > 0) {\n source = source.get(path.substring(0, index));\n }\n\n // Invoke the function\n that.start(source);\n\n if (source !== that.source) {\n result = result.call(source, that.source);\n } else {\n result = result.call(source);\n }\n\n that.stop(source);\n }\n\n // If the binding is resolved by a parent object\n if (source && source !== that.source) {\n\n that.currentSource = source; // save parent object\n\n // Listen for changes in the parent object\n source.unbind(CHANGE, that._change)\n .bind(CHANGE, that._change);\n }\n\n that.stop(that.source);\n\n return result;\n },\n\n set: function(value) {\n var source = this.currentSource || this.source;\n\n var field = kendo.getter(this.path)(source);\n\n if (typeof field === \"function\") {\n if (source !== this.source) {\n field.call(source, this.source, value);\n } else {\n field.call(source, value);\n }\n } else {\n source.set(this.path, value);\n }\n },\n\n destroy: function() {\n if (this.observable) {\n this.source.unbind(CHANGE, this._change);\n if(this.currentSource) {\n this.currentSource.unbind(CHANGE, this._change);\n }\n }\n\n this.unbind();\n }\n });\n\n var EventBinding = Binding.extend( {\n get: function() {\n var source = this.source,\n path = this.path,\n index = 0,\n handler;\n\n handler = source.get(path);\n\n while (!handler && source) {\n source = this.parents[++index];\n\n if (source instanceof ObservableObject) {\n handler = source.get(path);\n }\n }\n\n return proxy(handler, source);\n }\n });\n\n var TemplateBinding = Binding.extend( {\n init: function(source, path, template) {\n var that = this;\n\n Binding.fn.init.call(that, source, path);\n\n that.template = template;\n },\n\n render: function(value) {\n var html;\n\n this.start(this.source);\n\n html = kendo.render(this.template, value);\n\n this.stop(this.source);\n\n return html;\n }\n });\n\n var Binder = Class.extend({\n init: function(element, bindings, options) {\n this.element = element;\n this.bindings = bindings;\n this.options = options;\n },\n\n bind: function(binding, attribute) {\n var that = this;\n\n binding = attribute ? binding[attribute] : binding;\n\n binding.bind(CHANGE, function(e) {\n that.refresh(attribute || e);\n });\n\n that.refresh(attribute);\n },\n\n destroy: function() {\n }\n });\n\n var TypedBinder = Binder.extend({\n dataType: function() {\n var dataType = this.element.getAttribute(\"data-\" + kendo.ns + \"type\") || this.element.type || \"text\";\n return dataType.toLowerCase();\n },\n\n parsedValue: function() {\n return this._parseValue(this.element.value, this.dataType());\n },\n\n _parseValue: function (value, dataType){\n if (dataType == \"date\") {\n value = kendo.parseDate(value, \"yyyy-MM-dd\");\n } else if (dataType == \"datetime-local\") {\n value = kendo.parseDate(value, [\"yyyy-MM-ddTHH:mm:ss\", \"yyyy-MM-ddTHH:mm\"] );\n } else if (dataType == \"number\") {\n value = kendo.parseFloat(value);\n } else if (dataType == \"boolean\"){\n value = value.toLowerCase();\n if(kendo.parseFloat(value) !== null){\n value = Boolean(kendo.parseFloat(value));\n }else{\n value = (value.toLowerCase() === \"true\");\n }\n }\n return value;\n }\n });\n\n binders.attr = Binder.extend({\n refresh: function(key) {\n this.element.setAttribute(key, this.bindings.attr[key].get());\n }\n });\n\n binders.css = Binder.extend({\n init: function(element, bindings, options) {\n Binder.fn.init.call(this, element, bindings, options);\n this.classes = {};\n },\n refresh: function(className) {\n var element = $(this.element),\n binding = this.bindings.css[className],\n hasClass = this.classes[className] = binding.get();\n if(hasClass){\n element.addClass(className);\n }else{\n element.removeClass(className);\n }\n }\n });\n\n binders.style = Binder.extend({\n refresh: function(key) {\n this.element.style[key] = this.bindings.style[key].get() || \"\";\n }\n });\n\n binders.enabled = Binder.extend({\n refresh: function() {\n if (this.bindings.enabled.get()) {\n this.element.removeAttribute(\"disabled\");\n } else {\n this.element.setAttribute(\"disabled\", \"disabled\");\n }\n }\n });\n\n binders.readonly = Binder.extend({\n refresh: function() {\n if (this.bindings.readonly.get()) {\n this.element.setAttribute(\"readonly\", \"readonly\");\n } else {\n this.element.removeAttribute(\"readonly\");\n }\n }\n });\n\n binders.disabled = Binder.extend({\n refresh: function() {\n if (this.bindings.disabled.get()) {\n this.element.setAttribute(\"disabled\", \"disabled\");\n } else {\n this.element.removeAttribute(\"disabled\");\n }\n }\n });\n\n binders.events = Binder.extend({\n init: function(element, bindings, options) {\n Binder.fn.init.call(this, element, bindings, options);\n this.handlers = {};\n },\n\n refresh: function(key) {\n var element = $(this.element),\n binding = this.bindings.events[key],\n handler = this.handlers[key];\n\n if (handler) {\n element.off(key, handler);\n }\n\n handler = this.handlers[key] = binding.get();\n\n element.on(key, binding.source, handler);\n },\n\n destroy: function() {\n var element = $(this.element),\n handler;\n\n for (handler in this.handlers) {\n element.off(handler, this.handlers[handler]);\n }\n }\n });\n\n binders.text = Binder.extend({\n refresh: function() {\n var text = this.bindings.text.get();\n var dataFormat = this.element.getAttribute(\"data-\" + kendo.ns + \"format\") || \"\";\n if (text == null) {\n text = \"\";\n }\n\n $(this.element).text(kendo.toString(text, dataFormat));\n }\n });\n\n binders.visible = Binder.extend({\n refresh: function() {\n if (this.bindings.visible.get()) {\n this.element.style.display = \"\";\n } else {\n this.element.style.display = \"none\";\n }\n }\n });\n\n binders.invisible = Binder.extend({\n refresh: function() {\n if (!this.bindings.invisible.get()) {\n this.element.style.display = \"\";\n } else {\n this.element.style.display = \"none\";\n }\n }\n });\n\n binders.html = Binder.extend({\n refresh: function() {\n this.element.innerHTML = this.bindings.html.get();\n }\n });\n\n binders.value = TypedBinder.extend({\n init: function(element, bindings, options) {\n TypedBinder.fn.init.call(this, element, bindings, options);\n\n this._change = proxy(this.change, this);\n this.eventName = options.valueUpdate || CHANGE;\n\n $(this.element).on(this.eventName, this._change);\n\n this._initChange = false;\n },\n\n change: function() {\n this._initChange = this.eventName != CHANGE;\n\n this.bindings[VALUE].set(this.parsedValue());\n\n this._initChange = false;\n },\n\n refresh: function() {\n if (!this._initChange) {\n var value = this.bindings[VALUE].get();\n\n if (value == null) {\n value = \"\";\n }\n\n var type = this.dataType();\n\n if (type == \"date\") {\n value = kendo.toString(value, \"yyyy-MM-dd\");\n } else if (type == \"datetime-local\") {\n value = kendo.toString(value, \"yyyy-MM-ddTHH:mm:ss\");\n }\n\n this.element.value = value;\n }\n\n this._initChange = false;\n },\n\n destroy: function() {\n $(this.element).off(this.eventName, this._change);\n }\n });\n\n binders.source = Binder.extend({\n init: function(element, bindings, options) {\n Binder.fn.init.call(this, element, bindings, options);\n\n var source = this.bindings.source.get();\n\n if (source instanceof kendo.data.DataSource && options.autoBind !== false) {\n source.fetch();\n }\n },\n\n refresh: function(e) {\n var that = this,\n source = that.bindings.source.get();\n\n if (source instanceof ObservableArray || source instanceof kendo.data.DataSource) {\n e = e || {};\n\n if (e.action == \"add\") {\n that.add(e.index, e.items);\n } else if (e.action == \"remove\") {\n that.remove(e.index, e.items);\n } else if (e.action != \"itemchange\") {\n that.render();\n }\n } else {\n that.render();\n }\n },\n\n container: function() {\n var element = this.element;\n\n if (element.nodeName.toLowerCase() == \"table\") {\n if (!element.tBodies[0]) {\n element.appendChild(document.createElement(\"tbody\"));\n }\n element = element.tBodies[0];\n }\n\n return element;\n },\n\n template: function() {\n var options = this.options,\n template = options.template,\n nodeName = this.container().nodeName.toLowerCase();\n\n if (!template) {\n if (nodeName == \"select\") {\n if (options.valueField || options.textField) {\n template = kendo.format('',\n options.valueField || options.textField, options.textField || options.valueField);\n } else {\n template = \"\";\n }\n } else if (nodeName == \"tbody\") {\n template = \"#:data#\";\n } else if (nodeName == \"ul\" || nodeName == \"ol\") {\n template = \"
  • #:data#
  • \";\n } else {\n template = \"#:data#\";\n }\n template = kendo.template(template);\n }\n\n return template;\n },\n\n add: function(index, items) {\n var element = this.container(),\n parents,\n idx,\n length,\n child,\n clone = element.cloneNode(false),\n reference = element.children[index];\n\n $(clone).html(kendo.render(this.template(), items));\n\n if (clone.children.length) {\n parents = this.bindings.source._parents();\n\n for (idx = 0, length = items.length; idx < length; idx++) {\n child = clone.children[0];\n element.insertBefore(child, reference || null);\n bindElement(child, items[idx], this.options.roles, [items[idx]].concat(parents));\n }\n }\n },\n\n remove: function(index, items) {\n var idx, element = this.container();\n\n for (idx = 0; idx < items.length; idx++) {\n var child = element.children[index];\n unbindElementTree(child, true);\n if (child.parentNode == element) {\n element.removeChild(child);\n }\n }\n },\n\n render: function() {\n var source = this.bindings.source.get(),\n parents,\n idx,\n length,\n element = this.container(),\n template = this.template();\n\n if (source == null) {\n return;\n }\n\n if (source instanceof kendo.data.DataSource) {\n source = source.view();\n }\n\n if (!(source instanceof ObservableArray) && toString.call(source) !== \"[object Array]\") {\n source = [source];\n }\n\n if (this.bindings.template) {\n unbindElementChildren(element, true);\n\n $(element).html(this.bindings.template.render(source));\n\n if (element.children.length) {\n parents = this.bindings.source._parents();\n\n for (idx = 0, length = source.length; idx < length; idx++) {\n bindElement(element.children[idx], source[idx], this.options.roles, [source[idx]].concat(parents));\n }\n }\n } else {\n $(element).html(kendo.render(template, source));\n }\n }\n });\n\n binders.input = {\n checked: TypedBinder.extend({\n init: function(element, bindings, options) {\n TypedBinder.fn.init.call(this, element, bindings, options);\n this._change = proxy(this.change, this);\n\n $(this.element).change(this._change);\n },\n\n change: function() {\n var element = this.element;\n var value = this.value();\n\n if (element.type == \"radio\") {\n value = this.parsedValue();\n this.bindings[CHECKED].set(value);\n } else if (element.type == \"checkbox\") {\n var source = this.bindings[CHECKED].get();\n var index;\n\n if (source instanceof ObservableArray) {\n value = this.parsedValue();\n if (value instanceof Date) {\n for(var i = 0; i < source.length; i++){\n if(source[i] instanceof Date && +source[i] === +value){\n index = i;\n break;\n }\n }\n }else{\n index = source.indexOf(value);\n }\n if (index > -1) {\n source.splice(index, 1);\n } else {\n source.push(value);\n }\n } else {\n this.bindings[CHECKED].set(value);\n }\n }\n },\n\n refresh: function() {\n var value = this.bindings[CHECKED].get(),\n source = value,\n type = this.dataType(),\n element = this.element;\n\n if (element.type == \"checkbox\") {\n if (source instanceof ObservableArray) {\n var index = -1;\n value = this.parsedValue();\n if(value instanceof Date){\n for(var i = 0; i < source.length; i++){\n if(source[i] instanceof Date && +source[i] === +value){\n index = i;\n break;\n }\n }\n }else{\n index = source.indexOf(value);\n }\n element.checked = (index >= 0);\n }else{\n element.checked = source;\n }\n } else if (element.type == \"radio\") {\n if (type == \"date\") {\n value = kendo.toString(value, \"yyyy-MM-dd\");\n } else if (type == \"datetime-local\") {\n value = kendo.toString(value, \"yyyy-MM-ddTHH:mm:ss\");\n }\n\n if (value !== null && typeof(value) !== \"undefined\" && element.value === value.toString()) {\n element.checked = true;\n } else {\n element.checked = false;\n }\n }\n },\n\n value: function() {\n var element = this.element,\n value = element.value;\n\n if (element.type == \"checkbox\") {\n value = element.checked;\n }\n\n return value;\n },\n destroy: function() {\n $(this.element).off(CHANGE, this._change);\n }\n })\n };\n\n binders.select = {\n source: binders.source.extend({\n refresh: function(e) {\n var that = this,\n source = that.bindings.source.get();\n\n if (source instanceof ObservableArray || source instanceof kendo.data.DataSource) {\n e = e || {};\n if (e.action == \"add\") {\n that.add(e.index, e.items);\n } else if (e.action == \"remove\") {\n that.remove(e.index, e.items);\n } else if (e.action == \"itemchange\" || e.action === undefined) {\n that.render();\n if(that.bindings.value){\n if (that.bindings.value) {\n var val = retrievePrimitiveValues(that.bindings.value.get(), $(that.element).data(\"valueField\"));\n if(val === null) {\n that.element.selectedIndex = -1;\n } else {\n that.element.value = val;\n }\n }\n }\n }\n } else {\n that.render();\n }\n }\n }),\n value: TypedBinder.extend({\n init: function(target, bindings, options) {\n TypedBinder.fn.init.call(this, target, bindings, options);\n\n this._change = proxy(this.change, this);\n $(this.element).change(this._change);\n },\n\n parsedValue : function() {\n var dataType = this.dataType();\n var values = [];\n var value, option, idx, length;\n for (idx = 0, length = this.element.options.length; idx < length; idx++) {\n option = this.element.options[idx];\n\n if (option.selected) {\n value = option.attributes.value;\n\n if (value && value.specified) {\n value = option.value;\n } else {\n value = option.text;\n }\n\n values.push(this._parseValue(value, dataType));\n }\n }\n return values;\n },\n\n change: function() {\n var values = [],\n element = this.element,\n source,\n field = this.options.valueField || this.options.textField,\n valuePrimitive = this.options.valuePrimitive,\n option,\n valueIndex,\n value,\n idx,\n length;\n\n for (idx = 0, length = element.options.length; idx < length; idx++) {\n option = element.options[idx];\n\n if (option.selected) {\n value = option.attributes.value;\n\n if (value && value.specified) {\n value = option.value;\n } else {\n value = option.text;\n }\n\n if (field) {\n values.push(value);\n } else {\n values.push(this._parseValue(value, this.dataType()));\n }\n\n }\n }\n\n if (field) {\n source = this.bindings.source.get();\n if (source instanceof kendo.data.DataSource) {\n source = source.view();\n }\n\n for (valueIndex = 0; valueIndex < values.length; valueIndex++) {\n for (idx = 0, length = source.length; idx < length; idx++) {\n var sourceValue = source[idx].get(field);\n var match = (String(sourceValue) === values[valueIndex]);\n if (match) {\n values[valueIndex] = source[idx];\n break;\n }\n }\n }\n }\n\n value = this.bindings[VALUE].get();\n if (value instanceof ObservableArray) {\n value.splice.apply(value, [0, value.length].concat(values));\n } else if (!valuePrimitive && (value instanceof ObservableObject || value === null || value === undefined || !field)) {\n this.bindings[VALUE].set(values[0]);\n } else {\n this.bindings[VALUE].set(values[0].get(field));\n }\n },\n refresh: function() {\n var optionIndex,\n element = this.element,\n options = element.options,\n value = this.bindings[VALUE].get(),\n values = value,\n field = this.options.valueField || this.options.textField,\n found = false,\n type = this.dataType(),\n optionValue;\n\n if (!(values instanceof ObservableArray)) {\n values = new ObservableArray([value]);\n }\n\n element.selectedIndex = -1;\n\n for (var valueIndex = 0; valueIndex < values.length; valueIndex++) {\n value = values[valueIndex];\n\n\n if (field && value instanceof ObservableObject) {\n value = value.get(field);\n }\n\n if (type == \"date\") {\n value = kendo.toString(values[valueIndex], \"yyyy-MM-dd\");\n } else if (type == \"datetime-local\") {\n value = kendo.toString(values[valueIndex], \"yyyy-MM-ddTHH:mm:ss\");\n }\n\n for (optionIndex = 0; optionIndex < options.length; optionIndex++) {\n optionValue = options[optionIndex].value;\n\n if (optionValue === \"\" && value !== \"\") {\n optionValue = options[optionIndex].text;\n }\n\n if (value != null && optionValue == value.toString()) {\n options[optionIndex].selected = true;\n found = true;\n }\n }\n }\n },\n destroy: function() {\n $(this.element).off(CHANGE, this._change);\n }\n })\n };\n\n function dataSourceBinding(bindingName, fieldName, setter) {\n return Binder.extend({\n init: function(widget, bindings, options) {\n var that = this;\n\n Binder.fn.init.call(that, widget.element[0], bindings, options);\n\n that.widget = widget;\n that._dataBinding = proxy(that.dataBinding, that);\n that._dataBound = proxy(that.dataBound, that);\n that._itemChange = proxy(that.itemChange, that);\n },\n\n itemChange: function(e) {\n bindElement(e.item[0], e.data, this._ns(e.ns), [e.data].concat(this.bindings[bindingName]._parents()));\n },\n\n dataBinding: function(e) {\n var idx,\n length,\n widget = this.widget,\n items = e.removedItems || widget.items();\n\n for (idx = 0, length = items.length; idx < length; idx++) {\n unbindElementTree(items[idx], false);\n }\n },\n\n _ns: function(ns) {\n ns = ns || kendo.ui;\n var all = [ kendo.ui, kendo.dataviz.ui, kendo.mobile.ui ];\n all.splice($.inArray(ns, all), 1);\n all.unshift(ns);\n\n return kendo.rolesFromNamespaces(all);\n },\n\n dataBound: function(e) {\n var idx,\n length,\n widget = this.widget,\n items = e.addedItems || widget.items(),\n dataSource = widget[fieldName],\n view,\n parents,\n hds = kendo.data.HierarchicalDataSource;\n\n if (hds && dataSource instanceof hds) {\n // suppress binding of HDS items, because calling view() on root\n // will return only root items, and widget.items() returns all items\n return;\n }\n\n if (items.length) {\n view = e.addedDataItems || dataSource.flatView();\n parents = this.bindings[bindingName]._parents();\n\n for (idx = 0, length = view.length; idx < length; idx++) {\n if (items[idx]) {\n bindElement(items[idx], view[idx], this._ns(e.ns), [view[idx]].concat(parents));\n }\n }\n }\n },\n\n refresh: function(e) {\n var that = this,\n source,\n widget = that.widget,\n select, multiselect, dropdowntree;\n\n e = e || {};\n\n if (!e.action) {\n that.destroy();\n\n widget.bind(\"dataBinding\", that._dataBinding);\n widget.bind(\"dataBound\", that._dataBound);\n widget.bind(\"itemChange\", that._itemChange);\n\n source = that.bindings[bindingName].get();\n\n if (widget[fieldName] instanceof kendo.data.DataSource && widget[fieldName] != source) {\n if (source instanceof kendo.data.DataSource) {\n widget[setter](source);\n } else if (source && source._dataSource) {\n widget[setter](source._dataSource);\n } else {\n select = kendo.ui.Select && widget instanceof kendo.ui.Select;\n multiselect = kendo.ui.MultiSelect && widget instanceof kendo.ui.MultiSelect;\n dropdowntree = kendo.ui.DropDownTree && widget instanceof kendo.ui.DropDownTree;\n\n if(!dropdowntree){\n widget[fieldName].data(source);\n }else{\n widget.treeview[fieldName].data(source);\n }\n\n if (that.bindings.value && (select || multiselect)) {\n widget.value(retrievePrimitiveValues(that.bindings.value.get(), widget.options.dataValueField));\n }\n }\n }\n }\n },\n\n destroy: function() {\n var widget = this.widget;\n\n widget.unbind(\"dataBinding\", this._dataBinding);\n widget.unbind(\"dataBound\", this._dataBound);\n widget.unbind(\"itemChange\", this._itemChange);\n }\n });\n }\n\n binders.widget = {\n events : Binder.extend({\n init: function(widget, bindings, options) {\n Binder.fn.init.call(this, widget.element[0], bindings, options);\n this.widget = widget;\n this.handlers = {};\n },\n\n refresh: function(key) {\n var binding = this.bindings.events[key],\n handler = this.handlers[key];\n\n if (handler) {\n this.widget.unbind(key, handler);\n }\n\n handler = binding.get();\n\n this.handlers[key] = function(e) {\n e.data = binding.source;\n\n handler(e);\n\n if (e.data === binding.source) {\n delete e.data;\n }\n };\n\n this.widget.bind(key, this.handlers[key]);\n },\n\n destroy: function() {\n var handler;\n\n for (handler in this.handlers) {\n this.widget.unbind(handler, this.handlers[handler]);\n }\n }\n }),\n\n checked: Binder.extend({\n init: function(widget, bindings, options) {\n Binder.fn.init.call(this, widget.element[0], bindings, options);\n\n this.widget = widget;\n this._change = proxy(this.change, this);\n this.widget.bind(CHANGE, this._change);\n },\n change: function() {\n this.bindings[CHECKED].set(this.value());\n },\n\n refresh: function() {\n if (this.element.type === \"radio\") {\n this.widget.check(this.bindings[CHECKED].get().toString() === this.value());\n } else {\n this.widget.check(this.bindings[CHECKED].get() === true);\n }\n },\n\n value: function() {\n var element = this.element,\n value = element.value;\n\n if (value == \"on\" || value == \"off\" || this.element.type == \"checkbox\") {\n value = element.checked;\n }\n\n return value;\n },\n\n destroy: function() {\n this.widget.unbind(CHANGE, this._change);\n }\n }),\n\n start: Binder.extend({\n init: function(widget, bindings, options) {\n Binder.fn.init.call(this, widget.element[0], bindings, options);\n this._change = proxy(this.change, this);\n this.widget = widget;\n this.widget.bind(CHANGE, this._change);\n },\n\n change: function() {\n this.bindings.start.set(this.widget.range().start);\n },\n\n refresh: function() {\n var that = this;\n var start = this.bindings.start.get();\n var end = that.widget._range ? that.widget._range.end: null;\n this.widget.range({start: start, end: end});\n },\n\n destroy: function() {\n this.widget.unbind(CHANGE, this._change);\n }\n }),\n\n end: Binder.extend({\n init: function(widget, bindings, options) {\n Binder.fn.init.call(this, widget.element[0], bindings, options);\n this._change = proxy(this.change, this);\n this.widget = widget;\n this.widget.bind(CHANGE, this._change);\n },\n\n change: function() {\n this.bindings.end.set(this.widget.range().end);\n },\n\n refresh: function() {\n var that = this;\n var end = this.bindings.end.get();\n var start = that.widget._range ? that.widget._range.start: null;\n this.widget.range({start: start, end: end});\n },\n\n destroy: function() {\n this.widget.unbind(CHANGE, this._change);\n }\n }),\n\n visible: Binder.extend({\n init: function(widget, bindings, options) {\n Binder.fn.init.call(this, widget.element[0], bindings, options);\n\n this.widget = widget;\n },\n\n refresh: function() {\n var visible = this.bindings.visible.get();\n this.widget.wrapper[0].style.display = visible ? \"\" : \"none\";\n }\n }),\n\n invisible: Binder.extend({\n init: function(widget, bindings, options) {\n Binder.fn.init.call(this, widget.element[0], bindings, options);\n\n this.widget = widget;\n },\n\n refresh: function() {\n var invisible = this.bindings.invisible.get();\n this.widget.wrapper[0].style.display = invisible ? \"none\" : \"\";\n }\n }),\n\n floatingLabel: Binder.extend({\n init: function(widget, bindings, options) {\n Binder.fn.init.call(this, widget.element[0], bindings, options);\n\n if (!widget.floatingLabel) {\n return;\n }\n\n widget.floatingLabel.refresh();\n }\n }),\n\n enabled: Binder.extend({\n init: function(widget, bindings, options) {\n Binder.fn.init.call(this, widget.element[0], bindings, options);\n\n this.widget = widget;\n },\n\n refresh: function() {\n if (this.widget.enable) {\n this.widget.enable(this.bindings.enabled.get());\n }\n }\n }),\n\n disabled: Binder.extend({\n init: function(widget, bindings, options) {\n Binder.fn.init.call(this, widget.element[0], bindings, options);\n\n this.widget = widget;\n },\n\n refresh: function() {\n if (this.widget.enable) {\n this.widget.enable(!this.bindings.disabled.get());\n }\n }\n }),\n\n source: dataSourceBinding(\"source\", \"dataSource\", \"setDataSource\"),\n\n value: Binder.extend({\n init: function(widget, bindings, options) {\n Binder.fn.init.call(this, widget.element[0], bindings, options);\n\n this.widget = widget;\n this._change = $.proxy(this.change, this);\n this.widget.first(CHANGE, this._change);\n\n var value = this.bindings.value.get();\n\n this._valueIsObservableObject = !options.valuePrimitive && (value == null || value instanceof ObservableObject);\n this._valueIsObservableArray = value instanceof ObservableArray;\n this._initChange = false;\n },\n\n _source: function() {\n var source;\n\n if (this.widget.dataItem) {\n source = this.widget.dataItem();\n if (source && source instanceof ObservableObject) {\n return [source];\n }\n }\n\n if (this.bindings.source) {\n source = this.bindings.source.get();\n }\n\n if (!source || source instanceof kendo.data.DataSource) {\n source = this.widget.dataSource.flatView();\n }\n\n return source;\n },\n\n change: function() {\n var value = this.widget.value(),\n field = this.options.dataValueField || this.options.dataTextField,\n isArray = toString.call(value) === \"[object Array]\",\n isObservableObject = this._valueIsObservableObject,\n valueIndex, valueLength, values = [],\n sourceItem, sourceValue,\n idx, length, source;\n\n this._initChange = true;\n\n if (field) {\n\n if (value === \"\" && (isObservableObject || this.options.valuePrimitive)) {\n value = null;\n } else {\n source = this._source();\n\n if (isArray) {\n valueLength = value.length;\n values = value.slice(0);\n }\n\n for (idx = 0, length = source.length; idx < length; idx++) {\n sourceItem = source[idx];\n sourceValue = sourceItem.get(field);\n\n if (isArray) {\n for (valueIndex = 0; valueIndex < valueLength; valueIndex++) {\n if (sourceValue == values[valueIndex]) {\n values[valueIndex] = sourceItem;\n break;\n }\n }\n } else if (sourceValue == value) {\n value = isObservableObject ? sourceItem : sourceValue;\n break;\n }\n }\n\n if (values[0]) {\n if (this._valueIsObservableArray) {\n value = values;\n } else if (isObservableObject || !field) {\n value = values[0];\n } else {\n value = values[0].get(field);\n }\n }\n }\n }\n\n this.bindings.value.set(value);\n this._initChange = false;\n },\n\n refresh: function() {\n if (!this._initChange) {\n var widget = this.widget;\n var options = widget.options;\n var textField = options.dataTextField;\n var valueField = options.dataValueField || textField;\n var value = this.bindings.value.get();\n var text = options.text || \"\";\n var idx = 0, length;\n var values = [];\n\n if (value === undefined) {\n value = null;\n }\n\n if (valueField) {\n if (value instanceof ObservableArray) {\n for (length = value.length; idx < length; idx++) {\n values[idx] = value[idx].get(valueField);\n }\n value = values;\n } else if (value instanceof ObservableObject) {\n text = value.get(textField);\n value = value.get(valueField);\n }\n }\n\n if (options.autoBind === false && !options.cascadeFrom && widget.listView && !widget.listView.bound()) {\n if (textField === valueField && !text) {\n text = value;\n }\n\n if (!text && (value || value === 0) && options.valuePrimitive) {\n widget.value(value);\n } else {\n widget._preselect(value, text);\n }\n } else {\n widget.value(value);\n }\n }\n\n this._initChange = false;\n },\n\n destroy: function() {\n this.widget.unbind(CHANGE, this._change);\n }\n }),\n dropdowntree: {\n value: Binder.extend({\n init: function(widget, bindings, options) {\n Binder.fn.init.call(this, widget.element[0], bindings, options);\n\n this.widget = widget;\n this._change = $.proxy(this.change, this);\n this.widget.first(CHANGE, this._change);\n this._initChange = false;\n },\n\n change: function() {\n var that = this,\n oldValues = that.bindings[VALUE].get(),\n valuePrimitive = that.options.valuePrimitive,\n selectedNode = that.widget.treeview.select(),\n nonPrimitiveValues = that.widget._isMultipleSelection() ? that.widget._getAllChecked(): (that.widget.treeview.dataItem(selectedNode) || that.widget.value()),\n newValues = (valuePrimitive || that.widget.options.autoBind === false) ? that.widget.value() : nonPrimitiveValues;\n\n var field = this.options.dataValueField || this.options.dataTextField;\n\n newValues = newValues.slice ? newValues.slice(0): newValues;\n\n that._initChange = true;\n\n if (oldValues instanceof ObservableArray) {\n var remove = [];\n var newLength = newValues.length;\n var i = 0, j = 0;\n var old = oldValues[i];\n var same = false;\n var removeIndex;\n var newValue;\n var found;\n\n while (old !== undefined) {\n found = false;\n for (j = 0; j < newLength; j++) {\n if (valuePrimitive) {\n same = newValues[j] == old;\n } else {\n newValue = newValues[j];\n\n newValue = newValue.get ? newValue.get(field) : newValue;\n same = newValue == (old.get ? old.get(field) : old);\n }\n\n if (same) {\n newValues.splice(j, 1);\n newLength -= 1;\n found = true;\n break;\n }\n }\n\n if (!found) {\n remove.push(old);\n arraySplice(oldValues, i, 1);\n removeIndex = i;\n } else {\n i += 1;\n }\n\n old = oldValues[i];\n }\n\n arraySplice(oldValues, oldValues.length, 0, newValues);\n\n if (remove.length) {\n oldValues.trigger(\"change\", {\n action: \"remove\",\n items: remove,\n index: removeIndex\n });\n }\n\n if (newValues.length) {\n oldValues.trigger(\"change\", {\n action: \"add\",\n items: newValues,\n index: oldValues.length - 1\n });\n }\n } else {\n that.bindings[VALUE].set(newValues);\n }\n\n that._initChange = false;\n },\n\n refresh: function() {\n if (!this._initChange) {\n var options = this.options,\n widget = this.widget,\n field = options.dataValueField || options.dataTextField,\n value = this.bindings.value.get(),\n data = value,\n idx = 0, length,\n values = [],\n selectedValue;\n\n if (field) {\n if (value instanceof ObservableArray) {\n for (length = value.length; idx < length; idx++) {\n selectedValue = value[idx];\n values[idx] = selectedValue.get ? selectedValue.get(field) : selectedValue;\n }\n value = values;\n } else if (value instanceof ObservableObject) {\n value = value.get(field);\n }\n }\n if (options.autoBind === false && options.valuePrimitive !== true) {\n widget._preselect(data, value);\n } else {\n widget.value(value);\n }\n }\n },\n\n destroy: function() {\n this.widget.unbind(CHANGE, this._change);\n }\n })\n },\n gantt: {\n dependencies: dataSourceBinding(\"dependencies\", \"dependencies\", \"setDependenciesDataSource\")\n },\n\n multiselect: {\n value: Binder.extend({\n init: function(widget, bindings, options) {\n Binder.fn.init.call(this, widget.element[0], bindings, options);\n\n this.widget = widget;\n this._change = $.proxy(this.change, this);\n this.widget.first(CHANGE, this._change);\n this._initChange = false;\n },\n\n change: function() {\n var that = this,\n oldValues = that.bindings[VALUE].get(),\n valuePrimitive = that.options.valuePrimitive,\n newValues = valuePrimitive ? that.widget.value() : that.widget.dataItems();\n\n var field = this.options.dataValueField || this.options.dataTextField;\n\n newValues = newValues.slice(0);\n\n that._initChange = true;\n\n if (oldValues instanceof ObservableArray) {\n var remove = [];\n\n var newLength = newValues.length;\n\n var i = 0, j = 0;\n var old = oldValues[i];\n var same = false;\n var removeIndex;\n var newValue;\n var found;\n\n while (old !== undefined) {\n found = false;\n for (j = 0; j < newLength; j++) {\n if (valuePrimitive) {\n same = newValues[j] == old;\n } else {\n newValue = newValues[j];\n\n newValue = newValue.get ? newValue.get(field) : newValue;\n same = newValue == (old.get ? old.get(field) : old);\n }\n\n if (same) {\n newValues.splice(j, 1);\n newLength -= 1;\n found = true;\n break;\n }\n }\n\n if (!found) {\n remove.push(old);\n arraySplice(oldValues, i, 1);\n removeIndex = i;\n } else {\n i += 1;\n }\n\n old = oldValues[i];\n }\n\n arraySplice(oldValues, oldValues.length, 0, newValues);\n\n if (remove.length) {\n oldValues.trigger(\"change\", {\n action: \"remove\",\n items: remove,\n index: removeIndex\n });\n }\n\n if (newValues.length) {\n oldValues.trigger(\"change\", {\n action: \"add\",\n items: newValues,\n index: oldValues.length - 1\n });\n }\n } else {\n that.bindings[VALUE].set(newValues);\n }\n\n that._initChange = false;\n },\n\n refresh: function() {\n if (!this._initChange) {\n var options = this.options,\n widget = this.widget,\n field = options.dataValueField || options.dataTextField,\n value = this.bindings.value.get(),\n data = value,\n idx = 0, length,\n values = [],\n selectedValue;\n\n if (value === undefined) {\n value = null;\n }\n\n if (field) {\n if (value instanceof ObservableArray) {\n for (length = value.length; idx < length; idx++) {\n selectedValue = value[idx];\n values[idx] = selectedValue.get ? selectedValue.get(field) : selectedValue;\n }\n value = values;\n } else if (value instanceof ObservableObject) {\n value = value.get(field);\n }\n }\n\n if (options.autoBind === false && options.valuePrimitive !== true && !widget._isBound()) {\n widget._preselect(data, value);\n } else {\n widget.value(value);\n }\n }\n },\n\n destroy: function() {\n this.widget.unbind(CHANGE, this._change);\n }\n\n })\n },\n scheduler: {\n source: dataSourceBinding(\"source\", \"dataSource\", \"setDataSource\").extend({\n dataBound: function(e) {\n var idx;\n var length;\n var widget = this.widget;\n var elements = e.addedItems || widget.items();\n var data, parents;\n\n if (elements.length) {\n data = e.addedDataItems || widget.dataItems();\n parents = this.bindings.source._parents();\n\n for (idx = 0, length = data.length; idx < length; idx++) {\n bindElement(elements[idx], data[idx], this._ns(e.ns), [data[idx]].concat(parents));\n }\n }\n }\n })\n },\n\n grid: {\n source: dataSourceBinding(\"source\", \"dataSource\", \"setDataSource\").extend({\n dataBound: function(e) {\n var idx,\n length,\n widget = this.widget,\n elements = e.addedItems || widget.items(),\n parents,\n data;\n\n if (elements.length) {\n data = e.addedDataItems || widget.dataItems();\n parents = this.bindings.source._parents();\n\n for (idx = 0, length = data.length; idx < length; idx++) {\n bindElement(elements[idx], data[idx], this._ns(e.ns), [data[idx]].concat(parents));\n }\n }\n }\n })\n },\n\n badge: {\n text: Binder.extend({\n init: function(widget, bindings, options) {\n Binder.fn.init.call(this, widget.element[0], bindings, options);\n\n this.widget = widget;\n },\n refresh: function() {\n var text = this.bindings.text.get();\n\n if (text == null) {\n text = \"\";\n }\n this.widget.text(text);\n }\n })\n }\n };\n\n var arraySplice = function(arr, idx, remove, add) {\n add = add || [];\n remove = remove || 0;\n\n var addLength = add.length;\n var oldLength = arr.length;\n\n var shifted = [].slice.call(arr, idx + remove);\n var shiftedLength = shifted.length;\n var index;\n\n if (addLength) {\n addLength = idx + addLength;\n index = 0;\n\n for (; idx < addLength; idx++) {\n arr[idx] = add[index];\n index++;\n }\n\n arr.length = addLength;\n } else if (remove) {\n arr.length = idx;\n\n remove += idx;\n while (idx < remove) {\n delete arr[--remove];\n }\n }\n\n if (shiftedLength) {\n shiftedLength = idx + shiftedLength;\n index = 0;\n\n for (; idx < shiftedLength; idx++) {\n arr[idx] = shifted[index];\n index++;\n }\n\n arr.length = shiftedLength;\n }\n\n idx = arr.length;\n\n while (idx < oldLength) {\n delete arr[idx];\n idx++;\n }\n };\n\n var BindingTarget = Class.extend( {\n init: function(target, options) {\n this.target = target;\n this.options = options;\n this.toDestroy = [];\n },\n\n bind: function(bindings) {\n var key,\n hasValue,\n hasSource,\n hasEvents,\n hasChecked,\n hasCss,\n widgetBinding = this instanceof WidgetBindingTarget,\n specificBinders = this.binders();\n\n for (key in bindings) {\n if (key == VALUE) {\n hasValue = true;\n } else if (key == SOURCE) {\n hasSource = true;\n } else if (key == EVENTS && !widgetBinding) {\n hasEvents = true;\n } else if (key == CHECKED) {\n hasChecked = true;\n } else if (key == CSS) {\n hasCss = true;\n } else {\n this.applyBinding(key, bindings, specificBinders);\n }\n }\n if (hasSource) {\n this.applyBinding(SOURCE, bindings, specificBinders);\n }\n\n if (hasValue) {\n this.applyBinding(VALUE, bindings, specificBinders);\n }\n\n if (hasChecked) {\n this.applyBinding(CHECKED, bindings, specificBinders);\n }\n\n if (hasEvents && !widgetBinding) {\n this.applyBinding(EVENTS, bindings, specificBinders);\n }\n\n if (hasCss && !widgetBinding) {\n this.applyBinding(CSS, bindings, specificBinders);\n }\n\n if (widgetBinding && this.target && this.target.floatingLabel) {\n this.applyBinding(\"floatingLabel\", bindings, specificBinders);\n }\n },\n\n binders: function() {\n return binders[this.target.nodeName.toLowerCase()] || {};\n },\n\n applyBinding: function(name, bindings, specificBinders) {\n var binder = specificBinders[name] || binders[name],\n toDestroy = this.toDestroy,\n attribute,\n binding = bindings[name];\n\n if (binder) {\n binder = new binder(this.target, bindings, this.options);\n\n toDestroy.push(binder);\n\n if (binding instanceof Binding) {\n binder.bind(binding);\n toDestroy.push(binding);\n } else {\n for (attribute in binding) {\n binder.bind(binding, attribute);\n toDestroy.push(binding[attribute]);\n }\n }\n } else if (name !== \"template\") {\n throw new Error(\"The \" + name + \" binding is not supported by the \" + this.target.nodeName.toLowerCase() + \" element\");\n }\n },\n\n destroy: function() {\n var idx,\n length,\n toDestroy = this.toDestroy;\n\n for (idx = 0, length = toDestroy.length; idx < length; idx++) {\n toDestroy[idx].destroy();\n }\n }\n });\n\n var WidgetBindingTarget = BindingTarget.extend( {\n binders: function() {\n return binders.widget[this.target.options.name.toLowerCase()] || {};\n },\n\n applyBinding: function(name, bindings, specificBinders) {\n var binder = specificBinders[name] || binders.widget[name],\n toDestroy = this.toDestroy,\n attribute,\n binding = bindings[name];\n\n if (binder) {\n binder = new binder(this.target, bindings, this.target.options);\n\n toDestroy.push(binder);\n\n\n if (binding instanceof Binding) {\n binder.bind(binding);\n toDestroy.push(binding);\n } else {\n for (attribute in binding) {\n binder.bind(binding, attribute);\n toDestroy.push(binding[attribute]);\n }\n }\n } else {\n throw new Error(\"The \" + name + \" binding is not supported by the \" + this.target.options.name + \" widget\");\n }\n }\n });\n\n function bindingTargetForRole(element, roles) {\n var widget = kendo.initWidget(element, {}, roles);\n\n if (widget) {\n return new WidgetBindingTarget(widget);\n }\n }\n\n var keyValueRegExp = /[A-Za-z0-9_\\-]+:(\\{([^}]*)\\}|[^,}]+)/g,\n whiteSpaceRegExp = /\\s/g;\n\n function parseBindings(bind) {\n var result = {},\n idx,\n length,\n token,\n colonIndex,\n key,\n value,\n tokens;\n\n tokens = bind.match(keyValueRegExp);\n\n for (idx = 0, length = tokens.length; idx < length; idx++) {\n token = tokens[idx];\n colonIndex = token.indexOf(\":\");\n\n key = token.substring(0, colonIndex);\n value = token.substring(colonIndex + 1);\n\n if (value.charAt(0) == \"{\") {\n value = parseBindings(value);\n }\n\n result[key] = value;\n }\n\n return result;\n }\n\n function createBindings(bindings, source, type) {\n var binding,\n result = {};\n\n for (binding in bindings) {\n result[binding] = new type(source, bindings[binding]);\n }\n\n return result;\n }\n\n function bindElement(element, source, roles, parents) {\n\n if(!element || element.getAttribute(\"data-\" + kendo.ns + \"stop\")){\n return;\n }\n\n var role = element.getAttribute(\"data-\" + kendo.ns + \"role\"),\n idx,\n bind = element.getAttribute(\"data-\" + kendo.ns + \"bind\"),\n childrenCopy = [],\n deep = true,\n bindings,\n options = {},\n target;\n\n parents = parents || [source];\n\n if (role || bind) {\n unbindElement(element, false);\n }\n\n if (role) {\n target = bindingTargetForRole(element, roles);\n }\n\n if (bind) {\n bind = parseBindings(bind.replace(whiteSpaceRegExp, \"\"));\n\n if (!target) {\n options = kendo.parseOptions(element, {textField: \"\", valueField: \"\", template: \"\", valueUpdate: CHANGE, valuePrimitive: false, autoBind: true}, source);\n options.roles = roles;\n target = new BindingTarget(element, options);\n }\n\n target.source = source;\n\n bindings = createBindings(bind, parents, Binding);\n\n if (options.template) {\n bindings.template = new TemplateBinding(parents, \"\", options.template);\n }\n\n if (bindings.click) {\n bind.events = bind.events || {};\n bind.events.click = bind.click;\n bindings.click.destroy();\n delete bindings.click;\n }\n\n if (bindings.source) {\n deep = false;\n }\n\n if (bind.attr) {\n bindings.attr = createBindings(bind.attr, parents, Binding);\n }\n\n if (bind.style) {\n bindings.style = createBindings(bind.style, parents, Binding);\n }\n\n if (bind.events) {\n bindings.events = createBindings(bind.events, parents, EventBinding);\n }\n\n if (bind.css) {\n bindings.css = createBindings(bind.css, parents, Binding);\n }\n\n target.bind(bindings);\n }\n\n if (target) {\n element.kendoBindingTarget = target;\n }\n\n var children = element.children;\n if (deep && children && !element.getAttribute(\"data-\" + kendo.ns + \"stop\")) {\n // https://github.com/telerik/kendo/issues/1240 for the weirdness.\n for (idx = 0; idx < children.length; idx++) {\n childrenCopy[idx] = children[idx];\n }\n\n for (idx = 0; idx < childrenCopy.length; idx++) {\n bindElement(childrenCopy[idx], source, roles, parents);\n }\n }\n }\n\n function bind(dom, object) {\n var idx,\n length,\n node,\n roles = kendo.rolesFromNamespaces([].slice.call(arguments, 2));\n\n object = kendo.observable(object);\n dom = $(dom);\n\n for (idx = 0, length = dom.length; idx < length; idx++) {\n node = dom[idx];\n if (node.nodeType === 1) {\n bindElement(node, object, roles);\n }\n }\n }\n\n function unbindElement(element, destroyWidget) {\n var bindingTarget = element.kendoBindingTarget;\n\n if (bindingTarget) {\n bindingTarget.destroy();\n\n if (deleteExpando) {\n delete element.kendoBindingTarget;\n } else if (element.removeAttribute) {\n element.removeAttribute(\"kendoBindingTarget\");\n } else {\n element.kendoBindingTarget = null;\n }\n }\n\n if(destroyWidget) {\n var widget = kendo.widgetInstance($(element));\n if (widget && typeof widget.destroy === FUNCTION) {\n widget.destroy();\n }\n }\n }\n\n function unbindElementTree(element, destroyWidgets) {\n unbindElement(element, destroyWidgets);\n\n unbindElementChildren(element, destroyWidgets);\n }\n\n function unbindElementChildren(element, destroyWidgets) {\n var children = element.children;\n\n if (children) {\n for (var idx = 0, length = children.length; idx < length; idx++) {\n unbindElementTree(children[idx], destroyWidgets);\n }\n }\n }\n\n function unbind(dom) {\n var idx, length;\n\n dom = $(dom);\n\n for (idx = 0, length = dom.length; idx < length; idx++ ) {\n unbindElementTree(dom[idx], false);\n }\n }\n\n function notify(widget, namespace) {\n var element = widget.element,\n bindingTarget = element[0].kendoBindingTarget;\n\n if (bindingTarget) {\n bind(element, bindingTarget.source, namespace);\n }\n }\n\n function retrievePrimitiveValues(value, valueField) {\n var values = [];\n var idx = 0;\n var length;\n var item;\n\n if (!valueField) {\n return value;\n }\n\n if (value instanceof ObservableArray) {\n for (length = value.length; idx < length; idx++) {\n item = value[idx];\n values[idx] = item.get ? item.get(valueField) : item[valueField];\n }\n value = values;\n } else if (value instanceof ObservableObject) {\n value = value.get(valueField);\n }\n\n return value;\n }\n\n kendo.unbind = unbind;\n kendo.bind = bind;\n kendo.data.binders = binders;\n kendo.data.Binder = Binder;\n kendo.notify = notify;\n\n kendo.observable = function(object) {\n if (!(object instanceof ObservableObject)) {\n object = new ObservableObject(object);\n }\n\n return object;\n };\n\n kendo.observableHierarchy = function(array) {\n var dataSource = kendo.data.HierarchicalDataSource.create(array);\n\n function recursiveRead(data) {\n var i, children;\n\n for (i = 0; i < data.length; i++) {\n data[i]._initChildren();\n\n children = data[i].children;\n\n children.fetch();\n\n data[i].items = children.data();\n\n recursiveRead(data[i].items);\n }\n }\n\n dataSource.fetch();\n\n recursiveRead(dataSource.data());\n\n dataSource._data._dataSource = dataSource;\n\n return dataSource._data;\n };\n\n})(window.kendo.jQuery);\n\nreturn window.kendo;\n\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n\n(function(f, define){\n define('kendo.fx',[ \"./kendo.core\" ], f);\n})(function(){\n\nvar __meta__ = { // jshint ignore:line\n id: \"fx\",\n name: \"Effects\",\n category: \"framework\",\n description: \"Required for animation effects in all Kendo UI widgets.\",\n depends: [ \"core\" ]\n};\n\n(function($, undefined) {\n var kendo = window.kendo,\n fx = kendo.effects,\n each = $.each,\n extend = $.extend,\n proxy = $.proxy,\n support = kendo.support,\n browser = support.browser,\n transforms = support.transforms,\n transitions = support.transitions,\n scaleProperties = { scale: 0, scalex: 0, scaley: 0, scale3d: 0 },\n translateProperties = { translate: 0, translatex: 0, translatey: 0, translate3d: 0 },\n hasZoom = (typeof document.documentElement.style.zoom !== \"undefined\") && !transforms,\n matrix3dRegExp = /matrix3?d?\\s*\\(.*,\\s*([\\d\\.\\-]+)\\w*?,\\s*([\\d\\.\\-]+)\\w*?,\\s*([\\d\\.\\-]+)\\w*?,\\s*([\\d\\.\\-]+)\\w*?/i,\n cssParamsRegExp = /^(-?[\\d\\.\\-]+)?[\\w\\s]*,?\\s*(-?[\\d\\.\\-]+)?[\\w\\s]*/i,\n translateXRegExp = /translatex?$/i,\n oldEffectsRegExp = /(zoom|fade|expand)(\\w+)/,\n singleEffectRegExp = /(zoom|fade|expand)/,\n unitRegExp = /[xy]$/i,\n transformProps = [\"perspective\", \"rotate\", \"rotatex\", \"rotatey\", \"rotatez\", \"rotate3d\", \"scale\", \"scalex\", \"scaley\", \"scalez\", \"scale3d\", \"skew\", \"skewx\", \"skewy\", \"translate\", \"translatex\", \"translatey\", \"translatez\", \"translate3d\", \"matrix\", \"matrix3d\"],\n transform2d = [\"rotate\", \"scale\", \"scalex\", \"scaley\", \"skew\", \"skewx\", \"skewy\", \"translate\", \"translatex\", \"translatey\", \"matrix\"],\n transform2units = { \"rotate\": \"deg\", scale: \"\", skew: \"px\", translate: \"px\" },\n cssPrefix = transforms.css,\n round = Math.round,\n BLANK = \"\",\n PX = \"px\",\n NONE = \"none\",\n AUTO = \"auto\",\n WIDTH = \"width\",\n HEIGHT = \"height\",\n HIDDEN = \"hidden\",\n ORIGIN = \"origin\",\n ABORT_ID = \"abortId\",\n OVERFLOW = \"overflow\",\n TRANSLATE = \"translate\",\n POSITION = \"position\",\n COMPLETE_CALLBACK = \"completeCallback\",\n TRANSITION = cssPrefix + \"transition\",\n TRANSFORM = cssPrefix + \"transform\",\n BACKFACE = cssPrefix + \"backface-visibility\",\n PERSPECTIVE = cssPrefix + \"perspective\",\n DEFAULT_PERSPECTIVE = \"1500px\",\n TRANSFORM_PERSPECTIVE = \"perspective(\" + DEFAULT_PERSPECTIVE + \")\",\n directions = {\n left: {\n reverse: \"right\",\n property: \"left\",\n transition: \"translatex\",\n vertical: false,\n modifier: -1\n },\n right: {\n reverse: \"left\",\n property: \"left\",\n transition: \"translatex\",\n vertical: false,\n modifier: 1\n },\n down: {\n reverse: \"up\",\n property: \"top\",\n transition: \"translatey\",\n vertical: true,\n modifier: 1\n },\n up: {\n reverse: \"down\",\n property: \"top\",\n transition: \"translatey\",\n vertical: true,\n modifier: -1\n },\n top: {\n reverse: \"bottom\"\n },\n bottom: {\n reverse: \"top\"\n },\n \"in\": {\n reverse: \"out\",\n modifier: -1\n },\n out: {\n reverse: \"in\",\n modifier: 1\n },\n\n vertical: {\n reverse: \"vertical\"\n },\n\n horizontal: {\n reverse: \"horizontal\"\n }\n };\n\n kendo.directions = directions;\n\n extend($.fn, {\n kendoStop: function(clearQueue, gotoEnd) {\n if (transitions) {\n return fx.stopQueue(this, clearQueue || false, gotoEnd || false);\n } else {\n return this.stop(clearQueue, gotoEnd);\n }\n }\n });\n\n /* jQuery support for all transform animations (FF 3.5/3.6, Opera 10.x, IE9 */\n\n if (transforms && !transitions) {\n each(transform2d, function(idx, value) {\n $.fn[value] = function(val) {\n if (typeof val == \"undefined\") {\n return animationProperty(this, value);\n } else {\n var that = $(this)[0],\n transformValue = value + \"(\" + val + transform2units[value.replace(unitRegExp, \"\")] + \")\";\n\n if (that.style.cssText.indexOf(TRANSFORM) == -1) {\n $(this).css(TRANSFORM, transformValue);\n } else {\n that.style.cssText = that.style.cssText.replace(new RegExp(value + \"\\\\(.*?\\\\)\", \"i\"), transformValue);\n }\n }\n return this;\n };\n\n $.fx.step[value] = function (fx) {\n $(fx.elem)[value](fx.now);\n };\n });\n\n var curProxy = $.fx.prototype.cur;\n $.fx.prototype.cur = function () {\n if (transform2d.indexOf(this.prop) != -1) {\n return parseFloat($(this.elem)[this.prop]());\n }\n\n return curProxy.apply(this, arguments);\n };\n }\n\n kendo.toggleClass = function(element, classes, options, add) {\n if (classes) {\n classes = classes.split(\" \");\n\n if (transitions) {\n options = extend({\n exclusive: \"all\",\n duration: 400,\n ease: \"ease-out\"\n }, options);\n\n element.css(TRANSITION, options.exclusive + \" \" + options.duration + \"ms \" + options.ease);\n setTimeout(function() {\n element.css(TRANSITION, \"\").css(HEIGHT);\n }, options.duration); // TODO: this should fire a kendoAnimate session instead.\n }\n\n each(classes, function(idx, value) {\n element.toggleClass(value, add);\n });\n }\n\n return element;\n };\n\n kendo.parseEffects = function(input, mirror) {\n var effects = {};\n\n if (typeof input === \"string\") {\n each(input.split(\" \"), function(idx, value) {\n var redirectedEffect = !singleEffectRegExp.test(value),\n resolved = value.replace(oldEffectsRegExp, function(match, $1, $2) {\n return $1 + \":\" + $2.toLowerCase();\n }), // Support for old zoomIn/fadeOut style, now deprecated.\n effect = resolved.split(\":\"),\n direction = effect[1],\n effectBody = {};\n\n if (effect.length > 1) {\n effectBody.direction = (mirror && redirectedEffect ? directions[direction].reverse : direction);\n }\n\n effects[effect[0]] = effectBody;\n });\n } else {\n each(input, function(idx) {\n var direction = this.direction;\n\n if (direction && mirror && !singleEffectRegExp.test(idx)) {\n this.direction = directions[direction].reverse;\n }\n\n effects[idx] = this;\n });\n }\n\n return effects;\n };\n\n function parseInteger(value) {\n return parseInt(value, 10);\n }\n\n function parseCSS(element, property) {\n return parseInteger(element.css(property));\n }\n\n function keys(obj) {\n var acc = [];\n for (var propertyName in obj) {\n acc.push(propertyName);\n }\n return acc;\n }\n\n function strip3DTransforms(properties) {\n for (var key in properties) {\n if (transformProps.indexOf(key) != -1 && transform2d.indexOf(key) == -1) {\n delete properties[key];\n }\n }\n\n return properties;\n }\n\n function normalizeCSS(element, properties) {\n var transformation = [], cssValues = {}, lowerKey, key, value, isTransformed;\n\n for (key in properties) {\n lowerKey = key.toLowerCase();\n isTransformed = transforms && transformProps.indexOf(lowerKey) != -1;\n\n if (!support.hasHW3D && isTransformed && transform2d.indexOf(lowerKey) == -1) {\n delete properties[key];\n } else {\n value = properties[key];\n\n if (isTransformed) {\n transformation.push(key + \"(\" + value + \")\");\n } else {\n cssValues[key] = value;\n }\n }\n }\n\n if (transformation.length) {\n cssValues[TRANSFORM] = transformation.join(\" \");\n }\n\n return cssValues;\n }\n\n if (transitions) {\n extend(fx, {\n transition: function(element, properties, options) {\n var css,\n delay = 0,\n oldKeys = element.data(\"keys\") || [],\n timeoutID;\n\n options = extend({\n duration: 200,\n ease: \"ease-out\",\n complete: null,\n exclusive: \"all\"\n },\n options\n );\n\n var stopTransitionCalled = false;\n\n var stopTransition = function() {\n if (!stopTransitionCalled) {\n stopTransitionCalled = true;\n\n if (timeoutID) {\n clearTimeout(timeoutID);\n timeoutID = null;\n }\n\n element\n .removeData(ABORT_ID)\n .dequeue()\n .css(TRANSITION, \"\")\n .css(TRANSITION);\n\n options.complete.call(element);\n }\n };\n\n options.duration = $.fx ? $.fx.speeds[options.duration] || options.duration : options.duration;\n\n css = normalizeCSS(element, properties);\n\n $.merge(oldKeys, keys(css));\n\n if ($.hasOwnProperty(\"uniqueSort\")) {\n element\n .data(\"keys\", $.uniqueSort(oldKeys))\n .height();\n } else {\n element\n .data(\"keys\", $.unique(oldKeys))\n .height();\n }\n\n element.css(TRANSITION, options.exclusive + \" \" + options.duration + \"ms \" + options.ease).css(TRANSITION);\n element.css(css).css(TRANSFORM);\n\n /**\n * Use transitionEnd event for browsers who support it - but duplicate it with setTimeout, as the transitionEnd event will not be triggered if no CSS properties change.\n * This should be cleaned up at some point (widget by widget), and refactored to widgets not relying on the complete callback if no transition occurs.\n *\n * For IE9 and below, resort to setTimeout.\n */\n if (transitions.event) {\n element.one(transitions.event, stopTransition);\n if (options.duration !== 0) {\n delay = 500;\n }\n }\n\n timeoutID = setTimeout(stopTransition, options.duration + delay);\n element.data(ABORT_ID, timeoutID);\n element.data(COMPLETE_CALLBACK, stopTransition);\n },\n\n stopQueue: function(element, clearQueue, gotoEnd) {\n var cssValues,\n taskKeys = element.data(\"keys\"),\n retainPosition = (!gotoEnd && taskKeys),\n completeCallback = element.data(COMPLETE_CALLBACK);\n\n if (retainPosition) {\n cssValues = kendo.getComputedStyles(element[0], taskKeys);\n }\n\n if (completeCallback) {\n completeCallback();\n }\n\n if (retainPosition) {\n element.css(cssValues);\n }\n\n return element\n .removeData(\"keys\")\n .stop(clearQueue);\n }\n });\n }\n\n function animationProperty(element, property) {\n if (transforms) {\n var transform = element.css(TRANSFORM);\n if (transform == NONE) {\n return property == \"scale\" ? 1 : 0;\n }\n\n var match = transform.match(new RegExp(property + \"\\\\s*\\\\(([\\\\d\\\\w\\\\.]+)\")),\n computed = 0;\n\n if (match) {\n computed = parseInteger(match[1]);\n } else {\n match = transform.match(matrix3dRegExp) || [0, 0, 0, 0, 0];\n property = property.toLowerCase();\n\n if (translateXRegExp.test(property)) {\n computed = parseFloat(match[3] / match[2]);\n } else if (property == \"translatey\") {\n computed = parseFloat(match[4] / match[2]);\n } else if (property == \"scale\") {\n computed = parseFloat(match[2]);\n } else if (property == \"rotate\") {\n computed = parseFloat(Math.atan2(match[2], match[1]));\n }\n }\n\n return computed;\n } else {\n return parseFloat(element.css(property));\n }\n }\n\n var EffectSet = kendo.Class.extend({\n init: function(element, options) {\n var that = this;\n\n that.element = element;\n that.effects = [];\n that.options = options;\n that.restore = [];\n },\n\n run: function(effects) {\n var that = this,\n effect,\n idx, jdx,\n length = effects.length,\n element = that.element,\n options = that.options,\n deferred = $.Deferred(),\n start = {},\n end = {},\n target,\n children,\n childrenLength;\n\n that.effects = effects;\n\n deferred.done($.proxy(that, \"complete\"));\n\n element.data(\"animating\", true);\n\n for (idx = 0; idx < length; idx ++) {\n effect = effects[idx];\n\n effect.setReverse(options.reverse);\n effect.setOptions(options);\n\n that.addRestoreProperties(effect.restore);\n\n effect.prepare(start, end);\n\n children = effect.children();\n\n for (jdx = 0, childrenLength = children.length; jdx < childrenLength; jdx ++) {\n children[jdx].duration(options.duration).run();\n }\n }\n\n // legacy support for options.properties\n for (var effectName in options.effects) {\n extend(end, options.effects[effectName].properties);\n }\n\n // Show the element initially\n if (!element.is(\":visible\")) {\n extend(start, { display: element.data(\"olddisplay\") || \"block\" });\n }\n\n if (transforms && !options.reset) {\n target = element.data(\"targetTransform\");\n\n if (target) {\n start = extend(target, start);\n }\n }\n\n start = normalizeCSS(element, start);\n\n if (transforms && !transitions) {\n start = strip3DTransforms(start);\n }\n\n element.css(start)\n .css(TRANSFORM); // Nudge\n\n for (idx = 0; idx < length; idx ++) {\n effects[idx].setup();\n }\n\n if (options.init) {\n options.init();\n }\n\n element.data(\"targetTransform\", end);\n fx.animate(element, end, extend({}, options, { complete: deferred.resolve }));\n\n return deferred.promise();\n },\n\n stop: function() {\n $(this.element).kendoStop(true, true);\n },\n\n addRestoreProperties: function(restore) {\n var element = this.element,\n value,\n i = 0,\n length = restore.length;\n\n for (; i < length; i ++) {\n value = restore[i];\n\n this.restore.push(value);\n\n if (!element.data(value)) {\n element.data(value, element.css(value));\n }\n }\n },\n\n restoreCallback: function() {\n var element = this.element;\n\n for (var i = 0, length = this.restore.length; i < length; i ++) {\n var value = this.restore[i];\n element.css(value, element.data(value));\n }\n },\n\n complete: function() {\n var that = this,\n idx = 0,\n element = that.element,\n options = that.options,\n effects = that.effects,\n length = effects.length;\n\n element\n .removeData(\"animating\")\n .dequeue(); // call next animation from the queue\n\n if (options.hide) {\n element.data(\"olddisplay\", element.css(\"display\")).hide();\n }\n\n this.restoreCallback();\n\n if (hasZoom && !transforms) {\n setTimeout($.proxy(this, \"restoreCallback\"), 0); // Again jQuery callback in IE8-\n }\n\n for (; idx < length; idx ++) {\n effects[idx].teardown();\n }\n\n if (options.completeCallback) {\n options.completeCallback(element);\n }\n }\n });\n\n fx.promise = function(element, options) {\n var effects = [],\n effectClass,\n effectSet = new EffectSet(element, options),\n parsedEffects = kendo.parseEffects(options.effects),\n effect;\n\n options.effects = parsedEffects;\n\n for (var effectName in parsedEffects) {\n effectClass = fx[capitalize(effectName)];\n\n if (effectClass) {\n effect = new effectClass(element, parsedEffects[effectName].direction);\n effects.push(effect);\n }\n }\n\n if (effects[0]) {\n effectSet.run(effects);\n } else { // Not sure how would an fx promise reach this state - means that you call kendoAnimate with no valid effects? Why?\n if (!element.is(\":visible\")) {\n element.css({ display: element.data(\"olddisplay\") || \"block\" }).css(\"display\");\n }\n\n if (options.init) {\n options.init();\n }\n\n element.dequeue();\n effectSet.complete();\n }\n };\n\n extend(fx, {\n animate: function(elements, properties, options) {\n var useTransition = options.transition !== false;\n delete options.transition;\n\n if (transitions && \"transition\" in fx && useTransition) {\n fx.transition(elements, properties, options);\n } else {\n if (transforms) {\n elements.animate(strip3DTransforms(properties), { queue: false, show: false, hide: false, duration: options.duration, complete: options.complete }); // Stop animate from showing/hiding the element to be able to hide it later on.\n } else {\n elements.each(function() {\n var element = $(this),\n multiple = {};\n\n each(transformProps, function(idx, value) { // remove transforms to avoid IE and older browsers confusion\n var params,\n currentValue = properties ? properties[value]+ \" \" : null; // We need to match\n\n if (currentValue) {\n var single = properties;\n\n if (value in scaleProperties && properties[value] !== undefined) {\n params = currentValue.match(cssParamsRegExp);\n if (transforms) {\n extend(single, { scale: +params[0] });\n }\n } else {\n if (value in translateProperties && properties[value] !== undefined) {\n var position = element.css(POSITION),\n isFixed = (position == \"absolute\" || position == \"fixed\");\n\n if (!element.data(TRANSLATE)) {\n if (isFixed) {\n element.data(TRANSLATE, {\n top: parseCSS(element, \"top\") || 0,\n left: parseCSS(element, \"left\") || 0,\n bottom: parseCSS(element, \"bottom\"),\n right: parseCSS(element, \"right\")\n });\n } else {\n element.data(TRANSLATE, {\n top: parseCSS(element, \"marginTop\") || 0,\n left: parseCSS(element, \"marginLeft\") || 0\n });\n }\n }\n\n var originalPosition = element.data(TRANSLATE);\n\n params = currentValue.match(cssParamsRegExp);\n if (params) {\n\n var dX = value == TRANSLATE + \"y\" ? +null : +params[1],\n dY = value == TRANSLATE + \"y\" ? +params[1] : +params[2];\n\n if (isFixed) {\n if (!isNaN(originalPosition.right)) {\n if (!isNaN(dX)) { extend(single, { right: originalPosition.right - dX }); }\n } else {\n if (!isNaN(dX)) { extend(single, { left: originalPosition.left + dX }); }\n }\n\n if (!isNaN(originalPosition.bottom)) {\n if (!isNaN(dY)) { extend(single, { bottom: originalPosition.bottom - dY }); }\n } else {\n if (!isNaN(dY)) { extend(single, { top: originalPosition.top + dY }); }\n }\n } else {\n if (!isNaN(dX)) { extend(single, { marginLeft: originalPosition.left + dX }); }\n if (!isNaN(dY)) { extend(single, { marginTop: originalPosition.top + dY }); }\n }\n }\n }\n }\n\n if (!transforms && value != \"scale\" && value in single) {\n delete single[value];\n }\n\n if (single) {\n extend(multiple, single);\n }\n }\n });\n\n if (browser.msie) {\n delete multiple.scale;\n }\n\n element.animate(multiple, { queue: false, show: false, hide: false, duration: options.duration, complete: options.complete }); // Stop animate from showing/hiding the element to be able to hide it later on.\n });\n }\n }\n }\n });\n\n fx.animatedPromise = fx.promise;\n\n var Effect = kendo.Class.extend({\n init: function(element, direction) {\n var that = this;\n that.element = element;\n that._direction = direction;\n that.options = {};\n that._additionalEffects = [];\n\n if (!that.restore) {\n that.restore = [];\n }\n },\n\n// Public API\n reverse: function() {\n this._reverse = true;\n return this.run();\n },\n\n play: function() {\n this._reverse = false;\n return this.run();\n },\n\n add: function(additional) {\n this._additionalEffects.push(additional);\n return this;\n },\n\n direction: function(value) {\n this._direction = value;\n return this;\n },\n\n duration: function(duration) {\n this._duration = duration;\n return this;\n },\n\n compositeRun: function() {\n var that = this,\n effectSet = new EffectSet(that.element, { reverse: that._reverse, duration: that._duration }),\n effects = that._additionalEffects.concat([ that ]);\n\n return effectSet.run(effects);\n },\n\n run: function() {\n if (this._additionalEffects && this._additionalEffects[0]) {\n return this.compositeRun();\n }\n\n var that = this,\n element = that.element,\n idx = 0,\n restore = that.restore,\n length = restore.length,\n value,\n deferred = $.Deferred(),\n start = {},\n end = {},\n target,\n children = that.children(),\n childrenLength = children.length;\n\n deferred.done($.proxy(that, \"_complete\"));\n\n element.data(\"animating\", true);\n\n for (idx = 0; idx < length; idx ++) {\n value = restore[idx];\n\n if (!element.data(value)) {\n element.data(value, element.css(value));\n }\n }\n\n for (idx = 0; idx < childrenLength; idx ++) {\n children[idx].duration(that._duration).run();\n }\n\n that.prepare(start, end);\n\n if (!element.is(\":visible\")) {\n extend(start, { display: element.data(\"olddisplay\") || \"block\" });\n }\n\n if (transforms) {\n target = element.data(\"targetTransform\");\n\n if (target) {\n start = extend(target, start);\n }\n }\n\n start = normalizeCSS(element, start);\n\n if (transforms && !transitions) {\n start = strip3DTransforms(start);\n }\n\n element.css(start).css(TRANSFORM); // Trick webkit into re-rendering\n\n that.setup();\n\n element.data(\"targetTransform\", end);\n fx.animate(element, end, { duration: that._duration, complete: deferred.resolve });\n\n return deferred.promise();\n },\n\n stop: function() {\n var idx = 0,\n children = this.children(),\n childrenLength = children.length;\n\n for (idx = 0; idx < childrenLength; idx ++) {\n children[idx].stop();\n }\n\n $(this.element).kendoStop(true, true);\n return this;\n },\n\n restoreCallback: function() {\n var element = this.element;\n\n for (var i = 0, length = this.restore.length; i < length; i ++) {\n var value = this.restore[i];\n element.css(value, element.data(value));\n }\n },\n\n _complete: function() {\n var that = this,\n element = that.element;\n\n element\n .removeData(\"animating\")\n .dequeue(); // call next animation from the queue\n\n that.restoreCallback();\n\n if (that.shouldHide()) {\n element.data(\"olddisplay\", element.css(\"display\")).hide();\n }\n\n if (hasZoom && !transforms) {\n setTimeout($.proxy(that, \"restoreCallback\"), 0); // Again jQuery callback in IE8-\n }\n\n that.teardown();\n },\n\n /////////////////////////// Support for kendo.animate;\n setOptions: function(options) {\n extend(true, this.options, options);\n },\n\n children: function() {\n return [];\n },\n\n shouldHide: $.noop,\n\n setup: $.noop,\n prepare: $.noop,\n teardown: $.noop,\n directions: [],\n\n setReverse: function(reverse) {\n this._reverse = reverse;\n return this;\n }\n });\n\n function capitalize(word) {\n return word.charAt(0).toUpperCase() + word.substring(1);\n }\n\n function createEffect(name, definition) {\n var effectClass = Effect.extend(definition),\n directions = effectClass.prototype.directions;\n\n fx[capitalize(name)] = effectClass;\n\n fx.Element.prototype[name] = function(direction, opt1, opt2, opt3) {\n return new effectClass(this.element, direction, opt1, opt2, opt3);\n };\n\n each(directions, function(idx, theDirection) {\n fx.Element.prototype[name + capitalize(theDirection)] = function(opt1, opt2, opt3) {\n return new effectClass(this.element, theDirection, opt1, opt2, opt3);\n };\n });\n }\n\n var FOUR_DIRECTIONS = [\"left\", \"right\", \"up\", \"down\"],\n IN_OUT = [\"in\", \"out\"];\n\n createEffect(\"slideIn\", {\n directions: FOUR_DIRECTIONS,\n\n divisor: function(value) {\n this.options.divisor = value;\n return this;\n },\n\n prepare: function(start, end) {\n var that = this,\n tmp,\n element = that.element,\n outerWidth = kendo._outerWidth,\n outerHeight = kendo._outerHeight,\n direction = directions[that._direction],\n offset = -direction.modifier * (direction.vertical ? outerHeight(element) : outerWidth(element)),\n startValue = offset / (that.options && that.options.divisor || 1) + PX,\n endValue = \"0px\";\n\n if (that._reverse) {\n tmp = start;\n start = end;\n end = tmp;\n }\n\n if (transforms) {\n start[direction.transition] = startValue;\n end[direction.transition] = endValue;\n } else {\n start[direction.property] = startValue;\n end[direction.property] = endValue;\n }\n }\n });\n\n createEffect(\"tile\", {\n directions: FOUR_DIRECTIONS,\n\n init: function(element, direction, previous) {\n Effect.prototype.init.call(this, element, direction);\n this.options = { previous: previous };\n },\n\n previousDivisor: function(value) {\n this.options.previousDivisor = value;\n return this;\n },\n\n children: function() {\n var that = this,\n reverse = that._reverse,\n previous = that.options.previous,\n divisor = that.options.previousDivisor || 1,\n dir = that._direction;\n\n var children = [ kendo.fx(that.element).slideIn(dir).setReverse(reverse) ];\n\n if (previous) {\n children.push( kendo.fx(previous).slideIn(directions[dir].reverse).divisor(divisor).setReverse(!reverse) );\n }\n\n return children;\n }\n });\n\n function createToggleEffect(name, property, defaultStart, defaultEnd) {\n createEffect(name, {\n directions: IN_OUT,\n\n startValue: function(value) {\n this._startValue = value;\n return this;\n },\n\n endValue: function(value) {\n this._endValue = value;\n return this;\n },\n\n shouldHide: function() {\n return this._shouldHide;\n },\n\n prepare: function(start, end) {\n var that = this,\n startValue,\n endValue,\n out = this._direction === \"out\",\n startDataValue = that.element.data(property),\n startDataValueIsSet = !(isNaN(startDataValue) || startDataValue == defaultStart);\n\n if (startDataValueIsSet) {\n startValue = startDataValue;\n } else if (typeof this._startValue !== \"undefined\") {\n startValue = this._startValue;\n } else {\n startValue = out ? defaultStart : defaultEnd;\n }\n\n if (typeof this._endValue !== \"undefined\") {\n endValue = this._endValue;\n } else {\n endValue = out ? defaultEnd : defaultStart;\n }\n\n if (this._reverse) {\n start[property] = endValue;\n end[property] = startValue;\n } else {\n start[property] = startValue;\n end[property] = endValue;\n }\n\n that._shouldHide = end[property] === defaultEnd;\n }\n });\n }\n\n createToggleEffect(\"fade\", \"opacity\", 1, 0);\n createToggleEffect(\"zoom\", \"scale\", 1, 0.01);\n\n createEffect(\"slideMargin\", {\n prepare: function(start, end) {\n var that = this,\n element = that.element,\n options = that.options,\n origin = element.data(ORIGIN),\n offset = options.offset,\n margin,\n reverse = that._reverse;\n\n if (!reverse && origin === null) {\n element.data(ORIGIN, parseFloat(element.css(\"margin-\" + options.axis)));\n }\n\n margin = (element.data(ORIGIN) || 0);\n end[\"margin-\" + options.axis] = !reverse ? margin + offset : margin;\n }\n });\n\n createEffect(\"slideTo\", {\n prepare: function(start, end) {\n var that = this,\n element = that.element,\n options = that.options,\n offset = options.offset.split(\",\"),\n reverse = that._reverse;\n\n if (transforms) {\n end.translatex = !reverse ? offset[0] : 0;\n end.translatey = !reverse ? offset[1] : 0;\n } else {\n end.left = !reverse ? offset[0] : 0;\n end.top = !reverse ? offset[1] : 0;\n }\n element.css(\"left\");\n }\n });\n\n createEffect(\"expand\", {\n directions: [\"horizontal\", \"vertical\"],\n\n restore: [ OVERFLOW ],\n\n prepare: function(start, end) {\n var that = this,\n element = that.element,\n options = that.options,\n reverse = that._reverse,\n property = that._direction === \"vertical\" ? HEIGHT : WIDTH,\n setLength = element[0].style[property],\n oldLength = element.data(property),\n length = parseFloat(oldLength || setLength),\n realLength = round(element.css(property, AUTO)[property]());\n\n start.overflow = HIDDEN;\n\n length = (options && options.reset) ? realLength || length : length || realLength;\n\n end[property] = (reverse ? 0 : length) + PX;\n start[property] = (reverse ? length : 0) + PX;\n\n if (oldLength === undefined) {\n element.data(property, setLength);\n }\n },\n\n shouldHide: function() {\n return this._reverse;\n },\n\n teardown: function() {\n var that = this,\n element = that.element,\n property = that._direction === \"vertical\" ? HEIGHT : WIDTH,\n length = element.data(property);\n\n if (length == AUTO || length === BLANK) {\n setTimeout(function() { element.css(property, AUTO).css(property); }, 0); // jQuery animate complete callback in IE is called before the last animation step!\n }\n }\n });\n\n var TRANSFER_START_STATE = { position: \"absolute\", marginLeft: 0, marginTop: 0, scale: 1 };\n /**\n * Intersection point formulas are taken from here - http://zonalandeducation.com/mmts/intersections/intersectionOfTwoLines1/intersectionOfTwoLines1.html\n * Formula for a linear function from two points from here - http://demo.activemath.org/ActiveMath2/search/show.cmd?id=mbase://AC_UK_calculus/functions/ex_linear_equation_two_points\n * The transform origin point is the intersection point of the two lines from the top left corners/top right corners of the element and target.\n * The math and variables below MAY BE SIMPLIFIED (zeroes removed), but this would make the formula too cryptic.\n */\n createEffect(\"transfer\", {\n init: function(element, target) {\n this.element = element;\n this.options = { target: target };\n this.restore = [];\n },\n\n setup: function() {\n this.element.appendTo(document.body);\n },\n\n prepare: function(start, end) {\n var that = this,\n element = that.element,\n outerBox = fx.box(element),\n innerBox = fx.box(that.options.target),\n currentScale = animationProperty(element, \"scale\"),\n scale = fx.fillScale(innerBox, outerBox),\n transformOrigin = fx.transformOrigin(innerBox, outerBox);\n\n extend(start, TRANSFER_START_STATE);\n end.scale = 1;\n\n element.css(TRANSFORM, \"scale(1)\").css(TRANSFORM);\n element.css(TRANSFORM, \"scale(\" + currentScale + \")\");\n\n start.top = outerBox.top;\n start.left = outerBox.left;\n start.transformOrigin = transformOrigin.x + PX + \" \" + transformOrigin.y + PX;\n\n if (that._reverse) {\n start.scale = scale;\n } else {\n end.scale = scale;\n }\n }\n });\n\n\n var CLIPS = {\n top: \"rect(auto auto $size auto)\",\n bottom: \"rect($size auto auto auto)\",\n left: \"rect(auto $size auto auto)\",\n right: \"rect(auto auto auto $size)\"\n };\n\n var ROTATIONS = {\n top: { start: \"rotatex(0deg)\", end: \"rotatex(180deg)\" },\n bottom: { start: \"rotatex(-180deg)\", end: \"rotatex(0deg)\" },\n left: { start: \"rotatey(0deg)\", end: \"rotatey(-180deg)\" },\n right: { start: \"rotatey(180deg)\", end: \"rotatey(0deg)\" }\n };\n\n function clipInHalf(container, direction) {\n var vertical = kendo.directions[direction].vertical,\n size = (container[vertical ? HEIGHT : WIDTH]() / 2) + \"px\";\n\n return CLIPS[direction].replace(\"$size\", size);\n }\n\n createEffect(\"turningPage\", {\n directions: FOUR_DIRECTIONS,\n\n init: function(element, direction, container) {\n Effect.prototype.init.call(this, element, direction);\n this._container = container;\n },\n\n prepare: function(start, end) {\n var that = this,\n reverse = that._reverse,\n direction = reverse ? directions[that._direction].reverse : that._direction,\n rotation = ROTATIONS[direction];\n\n start.zIndex = 1;\n\n if (that._clipInHalf) {\n start.clip = clipInHalf(that._container, kendo.directions[direction].reverse);\n }\n\n start[BACKFACE] = HIDDEN;\n\n end[TRANSFORM] = TRANSFORM_PERSPECTIVE + (reverse ? rotation.start : rotation.end);\n start[TRANSFORM] = TRANSFORM_PERSPECTIVE + (reverse ? rotation.end : rotation.start);\n },\n\n setup: function() {\n this._container.append(this.element);\n },\n\n face: function(value) {\n this._face = value;\n return this;\n },\n\n shouldHide: function() {\n var that = this,\n reverse = that._reverse,\n face = that._face;\n\n return (reverse && !face) || (!reverse && face);\n },\n\n clipInHalf: function(value) {\n this._clipInHalf = value;\n return this;\n },\n\n temporary: function() {\n this.element.addClass('temp-page');\n return this;\n }\n });\n\n createEffect(\"staticPage\", {\n directions: FOUR_DIRECTIONS,\n\n init: function(element, direction, container) {\n Effect.prototype.init.call(this, element, direction);\n this._container = container;\n },\n\n restore: [\"clip\"],\n\n prepare: function(start, end) {\n var that = this,\n direction = that._reverse ? directions[that._direction].reverse : that._direction;\n\n start.clip = clipInHalf(that._container, direction);\n start.opacity = 0.999;\n end.opacity = 1;\n },\n\n shouldHide: function() {\n var that = this,\n reverse = that._reverse,\n face = that._face;\n\n return (reverse && !face) || (!reverse && face);\n },\n\n face: function(value) {\n this._face = value;\n return this;\n }\n });\n\n createEffect(\"pageturn\", {\n directions: [\"horizontal\", \"vertical\"],\n\n init: function(element, direction, face, back) {\n Effect.prototype.init.call(this, element, direction);\n this.options = {};\n this.options.face = face;\n this.options.back = back;\n },\n\n children: function() {\n var that = this,\n options = that.options,\n direction = that._direction === \"horizontal\" ? \"left\" : \"top\",\n reverseDirection = kendo.directions[direction].reverse,\n reverse = that._reverse,\n temp,\n faceClone = options.face.clone(true).removeAttr(\"id\"),\n backClone = options.back.clone(true).removeAttr(\"id\"),\n element = that.element;\n\n if (reverse) {\n temp = direction;\n direction = reverseDirection;\n reverseDirection = temp;\n }\n\n return [\n kendo.fx(options.face).staticPage(direction, element).face(true).setReverse(reverse),\n kendo.fx(options.back).staticPage(reverseDirection, element).setReverse(reverse),\n kendo.fx(faceClone).turningPage(direction, element).face(true).clipInHalf(true).temporary().setReverse(reverse),\n kendo.fx(backClone).turningPage(reverseDirection, element).clipInHalf(true).temporary().setReverse(reverse)\n ];\n },\n\n prepare: function(start, end) {\n start[PERSPECTIVE] = DEFAULT_PERSPECTIVE;\n start.transformStyle = \"preserve-3d\";\n // hack to trigger transition end.\n start.opacity = 0.999;\n end.opacity = 1;\n },\n\n teardown: function() {\n this.element.find(\".temp-page\").remove();\n }\n });\n\n createEffect(\"flip\", {\n directions: [\"horizontal\", \"vertical\"],\n\n init: function(element, direction, face, back) {\n Effect.prototype.init.call(this, element, direction);\n this.options = {};\n this.options.face = face;\n this.options.back = back;\n },\n\n children: function() {\n var that = this,\n options = that.options,\n direction = that._direction === \"horizontal\" ? \"left\" : \"top\",\n reverseDirection = kendo.directions[direction].reverse,\n reverse = that._reverse,\n temp,\n element = that.element;\n\n if (reverse) {\n temp = direction;\n direction = reverseDirection;\n reverseDirection = temp;\n }\n\n return [\n kendo.fx(options.face).turningPage(direction, element).face(true).setReverse(reverse),\n kendo.fx(options.back).turningPage(reverseDirection, element).setReverse(reverse)\n ];\n },\n\n prepare: function(start) {\n start[PERSPECTIVE] = DEFAULT_PERSPECTIVE;\n start.transformStyle = \"preserve-3d\";\n }\n });\n\n var RESTORE_OVERFLOW = !support.mobileOS.android;\n var IGNORE_TRANSITION_EVENT_SELECTOR = \".km-touch-scrollbar, .km-actionsheet-wrapper\";\n\n createEffect(\"replace\", {\n _before: $.noop,\n _after: $.noop,\n init: function(element, previous, transitionClass) {\n Effect.prototype.init.call(this, element);\n this._previous = $(previous);\n this._transitionClass = transitionClass;\n },\n\n duration: function() {\n throw new Error(\"The replace effect does not support duration setting; the effect duration may be customized through the transition class rule\");\n },\n\n beforeTransition: function(callback) {\n this._before = callback;\n return this;\n },\n\n afterTransition: function(callback) {\n this._after = callback;\n return this;\n },\n\n _both: function() {\n return $().add(this._element).add(this._previous);\n },\n\n _containerClass: function() {\n var direction = this._direction,\n containerClass = \"k-fx k-fx-start k-fx-\" + this._transitionClass;\n\n if (direction) {\n containerClass += \" k-fx-\" + direction;\n }\n\n if (this._reverse) {\n containerClass += \" k-fx-reverse\";\n }\n\n return containerClass;\n },\n\n complete: function(e) {\n if (!this.deferred || (e && $(e.target).is(IGNORE_TRANSITION_EVENT_SELECTOR))) {\n return;\n }\n\n var container = this.container;\n\n container\n .removeClass(\"k-fx-end\")\n .removeClass(this._containerClass())\n .off(transitions.event, this.completeProxy);\n\n this._previous.hide().removeClass(\"k-fx-current\");\n this.element.removeClass(\"k-fx-next\");\n\n if (RESTORE_OVERFLOW) {\n container.css(OVERFLOW, \"\");\n }\n\n if (!this.isAbsolute) {\n this._both().css(POSITION, \"\");\n }\n\n this.deferred.resolve();\n delete this.deferred;\n },\n\n run: function() {\n if (this._additionalEffects && this._additionalEffects[0]) {\n return this.compositeRun();\n }\n\n var that = this,\n element = that.element,\n previous = that._previous,\n container = element.parents().filter(previous.parents()).first(),\n both = that._both(),\n deferred = $.Deferred(),\n originalPosition = element.css(POSITION),\n originalOverflow;\n\n // edge case for grid/scheduler, where the previous is already destroyed.\n if (!container.length) {\n container = element.parent();\n }\n\n this.container = container;\n this.deferred = deferred;\n this.isAbsolute = originalPosition == \"absolute\";\n\n if (!this.isAbsolute) {\n both.css(POSITION, \"absolute\");\n }\n\n if (RESTORE_OVERFLOW) {\n originalOverflow = container.css(OVERFLOW);\n container.css(OVERFLOW, \"hidden\");\n }\n\n if (!transitions) {\n this.complete();\n } else {\n element.addClass(\"k-fx-hidden\");\n\n container.addClass(this._containerClass());\n\n this.completeProxy = $.proxy(this, \"complete\");\n container.on(transitions.event, this.completeProxy);\n\n kendo.animationFrame(function() {\n element.removeClass(\"k-fx-hidden\").addClass(\"k-fx-next\");\n previous.css(\"display\", \"\").addClass(\"k-fx-current\");\n that._before(previous, element);\n kendo.animationFrame(function() {\n container.removeClass(\"k-fx-start\").addClass(\"k-fx-end\");\n that._after(previous, element);\n });\n });\n }\n\n return deferred.promise();\n },\n\n stop: function() {\n this.complete();\n }\n });\n\n var Animation = kendo.Class.extend({\n init: function() {\n var that = this;\n that._tickProxy = proxy(that._tick, that);\n that._started = false;\n },\n\n tick: $.noop,\n done: $.noop,\n onEnd: $.noop,\n onCancel: $.noop,\n\n start: function() {\n if (!this.enabled()) {\n return;\n }\n\n if (!this.done()) {\n this._started = true;\n kendo.animationFrame(this._tickProxy);\n } else {\n this.onEnd();\n }\n },\n\n enabled: function() {\n return true;\n },\n\n cancel: function() {\n this._started = false;\n this.onCancel();\n },\n\n _tick: function() {\n var that = this;\n if (!that._started) { return; }\n\n that.tick();\n\n if (!that.done()) {\n kendo.animationFrame(that._tickProxy);\n } else {\n that._started = false;\n that.onEnd();\n }\n }\n });\n\n var Transition = Animation.extend({\n init: function(options) {\n var that = this;\n extend(that, options);\n Animation.fn.init.call(that);\n },\n\n done: function() {\n return this.timePassed() >= this.duration;\n },\n\n timePassed: function() {\n return Math.min(this.duration, (new Date()) - this.startDate);\n },\n\n moveTo: function(options) {\n var that = this,\n movable = that.movable;\n\n that.initial = movable[that.axis];\n that.delta = options.location - that.initial;\n\n that.duration = typeof options.duration == \"number\" ? options.duration : 300;\n\n that.tick = that._easeProxy(options.ease);\n\n that.startDate = new Date();\n that.start();\n },\n\n _easeProxy: function(ease) {\n var that = this;\n\n return function() {\n that.movable.moveAxis(that.axis, ease(that.timePassed(), that.initial, that.delta, that.duration));\n };\n }\n });\n\n extend(Transition, {\n easeOutExpo: function (t, b, c, d) {\n return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;\n },\n\n easeOutBack: function (t, b, c, d, s) {\n s = 1.70158;\n return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;\n }\n });\n\n fx.Animation = Animation;\n fx.Transition = Transition;\n fx.createEffect = createEffect;\n\n fx.box = function(element) {\n element = $(element);\n var result = element.offset();\n result.width = kendo._outerWidth(element);\n result.height = kendo._outerHeight(element);\n return result;\n };\n\n fx.transformOrigin = function(inner, outer) {\n var x = (inner.left - outer.left) * outer.width / (outer.width - inner.width),\n y = (inner.top - outer.top) * outer.height / (outer.height - inner.height);\n\n return {\n x: isNaN(x) ? 0 : x,\n y: isNaN(y) ? 0 : y\n };\n };\n\n fx.fillScale = function(inner, outer) {\n return Math.min(inner.width / outer.width, inner.height / outer.height);\n };\n\n fx.fitScale = function(inner, outer) {\n return Math.max(inner.width / outer.width, inner.height / outer.height);\n };\n})(window.kendo.jQuery);\n\nreturn window.kendo;\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n\n(function(f, define){\n define('kendo.view',[\n \"./kendo.core\",\n \"./kendo.binder\",\n \"./kendo.fx\"\n ], f);\n})(function(){\n\nvar __meta__ = { // jshint ignore:line\n id: \"view\",\n name: \"View\",\n category: \"framework\",\n description: \"The View class instantiates and handles the events of a certain screen from the application.\",\n depends: [ \"core\", \"binder\", \"fx\" ],\n hidden: false\n};\n\n(function($, undefined) {\n var kendo = window.kendo,\n attr = kendo.attr,\n ui = kendo.ui,\n attrValue = kendo.attrValue,\n directiveSelector = kendo.directiveSelector,\n Observable = kendo.Observable,\n Widget = kendo.ui.Widget,\n roleSelector = kendo.roleSelector,\n\n SCRIPT = \"SCRIPT\",\n INIT = \"init\",\n TRANSITION_START = \"transitionStart\",\n TRANSITION_END = \"transitionEnd\",\n SHOW = \"show\",\n HIDE = \"hide\",\n ATTACH = \"attach\",\n DETACH = \"detach\",\n sizzleErrorRegExp = /unrecognized expression/;\n\n var bodyRegExp = /]*>(([\\u000a\\u000d\\u2028\\u2029]|.)*)<\\/body>/i;\n var LOAD_START = \"loadStart\";\n var LOAD_COMPLETE = \"loadComplete\";\n var SHOW_START = \"showStart\";\n var SAME_VIEW_REQUESTED = \"sameViewRequested\";\n var VIEW_SHOW = \"viewShow\";\n var VIEW_TYPE_DETERMINED = \"viewTypeDetermined\";\n var AFTER = \"after\";\n var classNames = {\n content: \"k-content\",\n view: \"k-view\",\n stretchedView: \"k-stretched-view\",\n widget: \"k-widget\",\n header: \"k-header\",\n footer: \"k-footer\"\n };\n\n var View = kendo.ui.Widget.extend({\n init: function(content, options) {\n var that = this;\n options = options || {};\n that.id = kendo.guid();\n\n Observable.fn.init.call(that);\n this.options = $.extend({}, this.options, options);\n\n that.content = content;\n\n if (that.options.renderOnInit) {\n Widget.fn.init.call(that, that._createElement(), options);\n }\n\n if (that.options.wrapInSections) {\n that._renderSections();\n }\n\n that.tagName = options.tagName || \"div\";\n that.model = options.model;\n that._wrap = options.wrap !== false;\n this._evalTemplate = options.evalTemplate || false;\n this._useWithBlock = options.useWithBlock;\n that._fragments = {};\n\n that.bind([ INIT, SHOW, HIDE, TRANSITION_START, TRANSITION_END ], options);\n },\n\n options: {\n name: \"View\",\n renderOnInit: false,\n wrapInSections: false,\n detachOnHide: true,\n detachOnDestroy: true\n },\n\n render: function(container) {\n var that = this,\n notInitialized = !that.element;\n\n // The order below matters - kendo.bind should happen when the element is in the DOM, and show should be triggered after init.\n\n if (notInitialized) {\n that.element = that._createElement();\n }\n\n if (container) {\n $(container).append(that.element);\n }\n\n if (notInitialized) {\n kendo.bind(that.element, that.model);\n that.trigger(INIT);\n }\n\n if (container) {\n that._eachFragment(ATTACH);\n that.trigger(SHOW);\n }\n\n return that.element;\n },\n\n clone: function() {\n return new ViewClone(this);\n },\n\n triggerBeforeShow: function() {\n return true;\n },\n\n triggerBeforeHide: function() {\n return true;\n },\n\n showStart: function() {\n var that = this;\n var element = that.render();\n\n if (element) {\n element.css(\"display\", \"\");\n }\n\n this.trigger(SHOW_START, { view: this });\n },\n\n showEnd: function() {\n },\n\n hideEnd: function() {\n this.hide();\n },\n\n beforeTransition: function(type){\n this.trigger(TRANSITION_START, { type: type });\n },\n\n afterTransition: function(type){\n this.trigger(TRANSITION_END, { type: type });\n },\n\n hide: function() {\n if (this.options.detachOnHide) {\n this._eachFragment(DETACH);\n $(this.element).detach();\n }\n\n this.trigger(HIDE);\n },\n\n destroy: function() {\n var that = this;\n var element = that.element;\n\n if (element) {\n Widget.fn.destroy.call(that);\n\n kendo.unbind(element);\n kendo.destroy(element);\n\n if (that.options.detachOnDestroy) {\n element.remove();\n }\n }\n },\n\n // ported from mobile view\n purge: function() {\n var that = this;\n\n that.destroy();\n $(that.element).add(that.content).add(that.wrapper).off().remove();\n },\n\n fragments: function(fragments) {\n $.extend(this._fragments, fragments);\n },\n\n _eachFragment: function(methodName) {\n for (var placeholder in this._fragments) {\n this._fragments[placeholder][methodName](this, placeholder);\n }\n },\n\n _createElement: function() {\n var that = this,\n wrapper = \"<\" + that.tagName + \">\",\n element,\n content;\n\n try {\n content = $(document.getElementById(that.content) || that.content); // support passing id without #\n\n if (content[0].tagName === SCRIPT) {\n content = content.html();\n }\n } catch(e) {\n if (sizzleErrorRegExp.test(e.message)) {\n content = that.content;\n }\n }\n \n if (typeof content === \"string\") {\n content = content.replace(/^\\s+|\\s+$/g, '');\n if (that._evalTemplate) {\n content = kendo.template(content, { useWithBlock: that._useWithBlock })(that.model || {});\n }\n\n element = $(wrapper).append(content);\n // drop the wrapper if asked - this seems like the easiest (although not very intuitive) way to avoid messing up templates with questionable content, like this one for instance:\n // \n if (!that._wrap) {\n element = element.contents();\n }\n } else {\n element = content;\n if (that._evalTemplate) {\n var result = $(kendo.template($(\"
    \").append(element.clone(true)).html(), { useWithBlock: that._useWithBlock })(that.model || {}));\n\n // template uses DOM\n if ($.contains(document, element[0])) {\n element.replaceWith(result);\n }\n\n element = result;\n }\n if (that._wrap) {\n element = element.wrapAll(wrapper).parent();\n }\n }\n\n return element;\n },\n\n _renderSections: function() {\n var that = this;\n\n if (that.options.wrapInSections) {\n that._wrapper();\n that._createContent();\n that._createHeader();\n that._createFooter();\n }\n },\n\n _wrapper: function() {\n var that = this;\n var content = that.content;\n\n if (content.is(roleSelector(\"view\"))) {\n that.wrapper = that.content;\n } else {\n that.wrapper = content\n .wrap('
    ')\n .parent();\n }\n\n var wrapper = that.wrapper;\n\n wrapper.attr(\"id\", that.id);\n\n wrapper.addClass(classNames.view);\n wrapper.addClass(classNames.widget);\n wrapper.attr(\"role\", \"view\");\n },\n\n _createContent: function() {\n var that = this;\n var wrapper = $(that.wrapper);\n var contentSelector = roleSelector(\"content\");\n\n if (!wrapper.children(contentSelector)[0]) {\n var ccontentElements = wrapper.children().filter(function() {\n var child = $(this);\n if (!child.is(roleSelector(\"header\")) && !child.is(roleSelector(\"footer\"))) {\n return child;\n }\n });\n\n ccontentElements.wrap(\"
    ');\n }\n\n // use contentElement instead of content as view.content can be a string\n this.contentElement = wrapper.children(roleSelector(\"content\"));\n\n this.contentElement\n .addClass(classNames.stretchedView)\n .addClass(classNames.content);\n },\n\n _createHeader: function() {\n var that = this;\n var wrapper = that.wrapper;\n\n this.header = wrapper.children(roleSelector(\"header\")).addClass(classNames.header);\n },\n\n _createFooter: function() {\n var that = this;\n var wrapper = that.wrapper;\n\n this.footer = wrapper.children(roleSelector(\"footer\")).addClass(classNames.footer);\n }\n });\n\n var ViewClone = kendo.Class.extend({\n init: function(view) {\n $.extend(this, {\n element: view.element.clone(true),\n transition: view.transition,\n id: view.id\n });\n\n view.element.parent().append(this.element);\n },\n\n hideEnd: function() {\n this.element.remove();\n },\n\n beforeTransition: $.noop,\n afterTransition: $.noop\n });\n\n var Layout = View.extend({\n init: function(content, options) {\n View.fn.init.call(this, content, options);\n this.containers = {};\n },\n\n container: function(selector) {\n var container = this.containers[selector];\n\n if (!container) {\n container = this._createContainer(selector);\n this.containers[selector] = container;\n }\n\n return container;\n },\n\n showIn: function(selector, view, transition) {\n this.container(selector).show(view, transition);\n },\n\n _createContainer: function(selector) {\n var root = this.render(),\n element = root.find(selector),\n container;\n\n if (!element.length && root.is(selector)) {\n if (root.is(selector)) {\n element = root;\n } else {\n\n throw new Error(\"can't find a container with the specified \" + selector + \" selector\");\n }\n }\n\n container = new ViewContainer(element);\n\n container.bind(\"accepted\", function(e) {\n e.view.render(element);\n });\n\n return container;\n }\n });\n\n var Fragment = View.extend({\n attach: function(view, placeholder) {\n view.element.find(placeholder).replaceWith(this.render());\n },\n\n detach: function() {\n }\n });\n\n var transitionRegExp = /^(\\w+)(:(\\w+))?( (\\w+))?$/;\n\n function parseTransition(transition) {\n if (!transition){\n return {};\n }\n\n var matches = transition.match(transitionRegExp) || [];\n\n return {\n type: matches[1],\n direction: matches[3],\n reverse: matches[5] === \"reverse\"\n };\n }\n\n var ViewContainer = Observable.extend({\n init: function(container) {\n Observable.fn.init.call(this);\n this.container = container;\n this.history = [];\n this.view = null;\n this.running = false;\n },\n\n after: function() {\n this.running = false;\n this.trigger(\"complete\", {view: this.view});\n this.trigger(\"after\");\n },\n\n end: function() {\n this.view.showEnd();\n this.previous.hideEnd();\n this.after();\n },\n\n show: function(view, transition, locationID) {\n if (!view.triggerBeforeShow() || (this.view && !this.view.triggerBeforeHide())) {\n this.trigger(\"after\");\n return false;\n }\n\n locationID = locationID || view.id;\n\n var that = this,\n current = (view === that.view) ? view.clone() : that.view,\n history = that.history,\n previousEntry = history[history.length - 2] || {},\n back = previousEntry.id === locationID,\n // If explicit transition is set, it will be with highest priority\n // Next we will try using the history record transition or the view transition configuration\n theTransition = transition || ( back ? history[history.length - 1].transition : view.transition ),\n transitionData = parseTransition(theTransition);\n\n if (that.running) {\n that.effect.stop();\n }\n\n if (theTransition === \"none\") {\n theTransition = null;\n }\n\n that.trigger(\"accepted\", { view: view });\n that.view = view;\n that.previous = current;\n that.running = true;\n\n if (!back) {\n history.push({ id: locationID, transition: theTransition });\n } else {\n history.pop();\n }\n\n if (!current) {\n view.showStart();\n view.showEnd();\n that.after();\n return true;\n }\n\n if (!theTransition || !kendo.effects.enabled) {\n view.showStart();\n that.end();\n } else {\n // hide the view element before init/show - prevents blinks on iPad\n // the replace effect will remove this class\n view.element.addClass(\"k-fx-hidden\");\n view.showStart();\n // do not reverse the explicit transition\n if (back && !transition) {\n transitionData.reverse = !transitionData.reverse;\n }\n\n that.effect = kendo.fx(view.element).replace(current.element, transitionData.type)\n .beforeTransition(function() {\n view.beforeTransition(\"show\");\n current.beforeTransition(\"hide\");\n })\n .afterTransition(function() {\n view.afterTransition(\"show\");\n current.afterTransition(\"hide\");\n })\n .direction(transitionData.direction)\n .setReverse(transitionData.reverse);\n\n that.effect.run().then(function() { that.end(); });\n }\n\n return true;\n },\n\n destroy: function() {\n var that = this;\n var view = that.view;\n\n if (view && view.destroy) {\n view.destroy();\n }\n }\n });\n\n var ViewEngine = Observable.extend({\n init: function(options) {\n var that = this,\n views,\n container;\n\n Observable.fn.init.call(that);\n that.options = options;\n\n $.extend(that, options);\n that.sandbox = $(\"
    \");\n container = that.container;\n\n views = that._hideViews(container);\n that.rootView = views.first();\n that.layouts = {};\n\n that.viewContainer = new kendo.ViewContainer(that.container);\n\n that.viewContainer.bind(\"accepted\", function(e) {\n e.view.params = that.params;\n });\n\n that.viewContainer.bind(\"complete\", function(e) {\n that.trigger(VIEW_SHOW, { view: e.view });\n });\n\n that.viewContainer.bind(AFTER, function() {\n that.trigger(AFTER);\n });\n\n this.bind(this.events, options);\n },\n\n events: [\n SHOW_START,\n AFTER,\n VIEW_SHOW,\n LOAD_START,\n LOAD_COMPLETE,\n SAME_VIEW_REQUESTED,\n VIEW_TYPE_DETERMINED\n ],\n\n destroy: function() {\n var that = this;\n var viewContainer = that.viewContainer;\n\n kendo.destroy(that.container);\n\n for (var id in that.layouts) {\n this.layouts[id].destroy();\n }\n\n if (viewContainer) {\n viewContainer.destroy();\n }\n },\n\n view: function() {\n return this.viewContainer.view;\n },\n\n showView: function(url, transition, params) {\n url = url.replace(new RegExp(\"^\" + this.remoteViewURLPrefix), \"\");\n if (url === \"\" && this.remoteViewURLPrefix) {\n url = \"/\";\n }\n\n if (url.replace(/^#/, \"\") === this.url) {\n this.trigger(SAME_VIEW_REQUESTED);\n return false;\n }\n\n this.trigger(SHOW_START);\n\n var that = this,\n element = that._findViewElement(url),\n view = kendo.widgetInstance(element);\n\n that.url = url.replace(/^#/, \"\");\n\n that.params = params;\n\n if (view && view.reload) {\n view.purge();\n element = [];\n }\n\n this.trigger(VIEW_TYPE_DETERMINED, { remote: element.length === 0, url: url });\n\n if (element[0]) {\n if (!view) {\n view = that._createView(element);\n }\n\n return that.viewContainer.show(view, transition, url);\n } else {\n return true;\n }\n },\n\n append: function(html, url) {\n var sandbox = this.sandbox,\n urlPath = (url || \"\").split(\"?\")[0],\n container = this.container,\n views,\n view;\n\n if (bodyRegExp.test(html)) {\n html = RegExp.$1;\n }\n\n sandbox[0].innerHTML = html;\n\n container.append(sandbox.children(\"script, style\"));\n\n views = this._hideViews(sandbox);\n view = views.first();\n\n // Generic HTML content found as remote view - no remote view markers\n if (!view.length) {\n views = view = sandbox.wrapInner(\"
    \").children(); // one element\n }\n\n if (urlPath) {\n view.hide().attr(attr(\"url\"), urlPath);\n }\n\n container.append(views);\n\n return this._createView(view);\n },\n\n _locate: function(selectors) {\n return this.$angular ? directiveSelector(selectors) : roleSelector(selectors);\n },\n\n _findViewElement: function(url) {\n var element,\n urlPath = url.split(\"?\")[0];\n\n if (!urlPath) {\n return this.rootView;\n }\n\n element = this.container.children(\"[\" + attr(\"url\") + \"='\" + urlPath + \"']\");\n\n // do not try to search for \"#/foo/bar\" id, jQuery throws error\n if (!element[0] && urlPath.indexOf(\"/\") === -1) {\n element = this.container.children(urlPath.charAt(0) === \"#\" ? urlPath : \"#\" + urlPath);\n }\n\n if (!element[0]) {\n element = this._findViewElementById(url);\n }\n\n return element;\n },\n\n _findViewElementById: function(id) {\n var element = this.container.children(\"[id='\" + id + \"']\");\n return element;\n },\n\n _createView: function(element) {\n //return this._createMobileView(element);\n return this._createSpaView(element);\n },\n\n _createMobileView: function(element) {\n return kendo.initWidget(element, {\n defaultTransition: this.transition,\n loader: this.loader,\n container: this.container,\n getLayout: this.getLayoutProxy,\n modelScope: this.modelScope,\n reload: attrValue(element, \"reload\")\n }, ui.roles);\n },\n\n _createSpaView: function(element) {\n var viewOptions = (this.options || {}).viewOptions || {};\n return new kendo.View(element, {\n renderOnInit: viewOptions.renderOnInit,\n wrap: viewOptions.wrap || false,\n wrapInSections: viewOptions.wrapInSections,\n detachOnHide: viewOptions.detachOnHide,\n detachOnDestroy: viewOptions.detachOnDestroy\n });\n },\n\n _hideViews: function(container) {\n return container.children(this._locate(\"view\")).hide();\n }\n });\n\n kendo.ViewEngine = ViewEngine;\n\n kendo.ViewContainer = ViewContainer;\n kendo.Fragment = Fragment;\n kendo.Layout = Layout;\n kendo.View = View;\n kendo.ViewClone = ViewClone;\n\n})(window.kendo.jQuery);\n\nreturn window.kendo;\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n\n(function(f, define){\r\n define('kendo.dom',[ \"./kendo.core\" ], f);\r\n})(function(){\r\n\r\nvar __meta__ = { // jshint ignore:line\r\n id: \"dom\",\r\n name: \"Virtual DOM\",\r\n category: \"framework\",\r\n depends: [ \"core\" ],\r\n advanced: true\r\n};\r\n\r\n(function(kendo) {\r\n function Node() {\r\n this.node = null;\r\n }\r\n\r\n Node.prototype = {\r\n remove: function() {\r\n if (this.node.parentNode) {\r\n this.node.parentNode.removeChild(this.node);\r\n }\r\n this.attr = {};\r\n },\r\n attr: {},\r\n text: function() {\r\n return \"\";\r\n }\r\n };\r\n\r\n function NullNode() {\r\n }\r\n\r\n NullNode.prototype = {\r\n nodeName: \"#null\",\r\n attr: { style: {} },\r\n children: [],\r\n remove: function() {\r\n }\r\n };\r\n\r\n var NULL_NODE = new NullNode();\r\n\r\n function Element(nodeName, attr, children) {\r\n this.nodeName = nodeName;\r\n\r\n this.attr = attr || {};\r\n\r\n this.children = children || [];\r\n }\r\n\r\n Element.prototype = new Node();\r\n\r\n Element.prototype.appendTo = function(parent) {\r\n var node = document.createElement(this.nodeName);\r\n\r\n var children = this.children;\r\n\r\n for (var index = 0; index < children.length; index++) {\r\n children[index].render(node, NULL_NODE);\r\n }\r\n\r\n parent.appendChild(node);\r\n\r\n return node;\r\n };\r\n\r\n Element.prototype.render = function(parent, cached) {\r\n var node;\r\n\r\n if (cached.nodeName !== this.nodeName) {\r\n cached.remove();\r\n\r\n node = this.appendTo(parent);\r\n } else {\r\n node = cached.node;\r\n\r\n var index;\r\n\r\n var children = this.children;\r\n\r\n var length = children.length;\r\n\r\n var cachedChildren = cached.children;\r\n\r\n var cachedLength = cachedChildren.length;\r\n\r\n if (Math.abs(cachedLength - length) > 2) {\r\n this.render({\r\n appendChild: function(node) {\r\n parent.replaceChild(node, cached.node);\r\n }\r\n }, NULL_NODE);\r\n\r\n return;\r\n }\r\n\r\n for (index = 0; index < length; index++) {\r\n children[index].render(node, cachedChildren[index] || NULL_NODE);\r\n }\r\n\r\n for (index = length; index < cachedLength; index++) {\r\n cachedChildren[index].remove();\r\n }\r\n }\r\n\r\n this.node = node;\r\n\r\n this.syncAttributes(cached.attr);\r\n\r\n this.removeAttributes(cached.attr);\r\n };\r\n\r\n Element.prototype.syncAttributes = function(cachedAttr) {\r\n var attr = this.attr;\r\n\r\n for (var name in attr) {\r\n var value = attr[name];\r\n\r\n var cachedValue = cachedAttr[name];\r\n\r\n if (name === \"style\") {\r\n this.setStyle(value, cachedValue);\r\n } else if (value !== cachedValue) {\r\n this.setAttribute(name, value, cachedValue);\r\n }\r\n }\r\n };\r\n\r\n Element.prototype.setStyle = function(style, cachedValue) {\r\n var node = this.node;\r\n var key;\r\n\r\n if (cachedValue) {\r\n for (key in style) {\r\n if (style[key] !== cachedValue[key]) {\r\n node.style[key] = style[key];\r\n }\r\n }\r\n } else {\r\n for (key in style) {\r\n node.style[key] = style[key];\r\n }\r\n }\r\n };\r\n\r\n Element.prototype.removeStyle = function(cachedStyle) {\r\n var style = this.attr.style || {};\r\n var node = this.node;\r\n\r\n for (var key in cachedStyle) {\r\n if (style[key] === undefined) {\r\n node.style[key] = \"\";\r\n }\r\n }\r\n };\r\n\r\n Element.prototype.removeAttributes = function(cachedAttr) {\r\n var attr = this.attr;\r\n\r\n for (var name in cachedAttr) {\r\n if (name === \"style\") {\r\n this.removeStyle(cachedAttr.style);\r\n } else if (attr[name] === undefined) {\r\n this.removeAttribute(name);\r\n }\r\n }\r\n };\r\n\r\n Element.prototype.removeAttribute = function(name) {\r\n var node = this.node;\r\n\r\n if (name === \"style\") {\r\n node.style.cssText = \"\";\r\n } else if (name === \"className\") {\r\n node.className = \"\";\r\n } else {\r\n node.removeAttribute(name);\r\n }\r\n };\r\n\r\n Element.prototype.setAttribute = function(name, value) {\r\n var node = this.node;\r\n\r\n if (node[name] !== undefined) {\r\n node[name] = value;\r\n } else {\r\n node.setAttribute(name, value);\r\n }\r\n };\r\n\r\n Element.prototype.text = function() {\r\n var str = \"\";\r\n for (var i = 0; i < this.children.length; ++i) {\r\n str += this.children[i].text();\r\n }\r\n return str;\r\n };\r\n\r\n function TextNode(nodeValue) {\r\n this.nodeValue = String(nodeValue);\r\n }\r\n\r\n TextNode.prototype = new Node();\r\n\r\n TextNode.prototype.nodeName = \"#text\";\r\n\r\n TextNode.prototype.render = function(parent, cached) {\r\n var node;\r\n\r\n if (cached.nodeName !== this.nodeName) {\r\n cached.remove();\r\n\r\n node = document.createTextNode(this.nodeValue);\r\n\r\n parent.appendChild(node);\r\n } else {\r\n node = cached.node;\r\n\r\n if (this.nodeValue !== cached.nodeValue) {\r\n if (node.parentNode) {\r\n // sometimes in IE parentNode is null (reason unknown),\r\n // and IE throws an error when you try to set a\r\n // parentless' nodeValue, because why not.\r\n node.nodeValue = this.nodeValue;\r\n }\r\n }\r\n }\r\n\r\n this.node = node;\r\n };\r\n\r\n TextNode.prototype.text = function() {\r\n return this.nodeValue;\r\n };\r\n\r\n function HtmlNode(html) {\r\n this.html = html;\r\n }\r\n\r\n HtmlNode.prototype = {\r\n nodeName: \"#html\",\r\n attr: {},\r\n remove: function() {\r\n for (var index = 0; index < this.nodes.length; index++) {\r\n var el = this.nodes[index];\r\n if (el.parentNode) {\r\n el.parentNode.removeChild(el);\r\n }\r\n }\r\n },\r\n render: function(parent, cached) {\r\n if (cached.nodeName !== this.nodeName || cached.html !== this.html) {\r\n cached.remove();\r\n\r\n var lastChild = parent.lastChild;\r\n\r\n insertHtml(parent, this.html);\r\n\r\n this.nodes = [];\r\n\r\n for (var child = lastChild ? lastChild.nextSibling : parent.firstChild; child; child = child.nextSibling) {\r\n this.nodes.push(child);\r\n }\r\n } else {\r\n this.nodes = cached.nodes.slice(0);\r\n }\r\n }\r\n };\r\n\r\n var HTML_CONTAINER = document.createElement(\"div\");\r\n\r\n function insertHtml(node, html) {\r\n HTML_CONTAINER.innerHTML = html;\r\n\r\n while (HTML_CONTAINER.firstChild) {\r\n node.appendChild(HTML_CONTAINER.firstChild);\r\n }\r\n }\r\n\r\n function html(value) {\r\n return new HtmlNode(value);\r\n }\r\n\r\n function element(nodeName, attrs, children) {\r\n return new Element(nodeName, attrs, children);\r\n }\r\n\r\n function text(value) {\r\n return new TextNode(value);\r\n }\r\n\r\n function Tree(root) {\r\n this.root = root;\r\n this.children = [];\r\n }\r\n\r\n Tree.prototype = {\r\n html: html,\r\n element: element,\r\n text: text,\r\n render: function(children) {\r\n var cachedChildren = this.children;\r\n\r\n var index;\r\n\r\n var length;\r\n\r\n for (index = 0, length = children.length; index < length; index++) {\r\n var cached = cachedChildren[index];\r\n if (!cached) {\r\n cached = NULL_NODE;\r\n } else if (!cached.node || !cached.node.parentNode) {\r\n cached.remove();\r\n cached = NULL_NODE;\r\n }\r\n children[index].render(this.root, cached);\r\n }\r\n\r\n for (index = length; index < cachedChildren.length; index++) {\r\n cachedChildren[index].remove();\r\n }\r\n\r\n this.children = children;\r\n }\r\n };\r\n\r\n kendo.dom = {\r\n html: html,\r\n text: text,\r\n element: element,\r\n Tree: Tree,\r\n Node: Node\r\n };\r\n})(window.kendo);\r\n\r\nreturn window.kendo;\r\n\r\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\r\n\n(function(f, define){\n define('ooxml/utils',[\n \"../kendo.core\"\n ], f);\n})(function(){\n\n(function () {\n\n/* global JSZip */\n\nkendo.ooxml = kendo.ooxml || {};\n\nkendo.ooxml.createZip = function() {\n if (typeof JSZip === \"undefined\") {\n throw new Error(\"JSZip not found. Check http://docs.telerik.com/kendo-ui/framework/excel/introduction#requirements for more details.\");\n }\n\n return new JSZip();\n};\n\n})();\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n\n/***********************************************************************\n * WARNING: this file is auto-generated. If you change it directly,\n * your modifications will eventually be lost. The source code is in\n * `kendo-ooxml` repository, you should make your changes there and\n * run `src-modules/sync.sh` in this repository.\n */\n(function(f, define){\n define('ooxml/kendo-ooxml',[\n \"../kendo.core\",\n \"./utils\"\n ], f);\n})(function(){\n\n(function ($) {\n/* jshint eqnull:true */\n/* jshint laxbreak:true */\n\nwindow.kendo.ooxml = window.kendo.ooxml || {};\nvar ooxml = kendo.ooxml;\n\nvar map = $.map;\nvar createZip = ooxml.createZip;\n\nvar current = {\n toString: function (value) { return value; }\n};\n\nvar IntlService = kendo.Class.extend({\n\n});\n\nIntlService.register = function(userImplementation) {\n current = userImplementation;\n};\n\nIntlService.toString = function(value, format) {\n return current.toString(value, format);\n};\n\n// date packing utilities from Kendo Spreadsheet\n\n// Julian days algorithms from http://www.hermetic.ch/cal_stud/jdn.htm#comp\nfunction dateToJulianDays(y, m, d) {\n return ((1461 * (y + 4800 + ((m - 13) / 12 | 0))) / 4 | 0) +\n ((367 * (m - 1 - 12 * ((m - 13) / 12 | 0))) / 12 | 0) -\n ((3 * (((y + 4900 + ((m - 13) / 12 | 0)) / 100 | 0))) / 4 | 0) +\n d - 32075;\n}\n\n// This uses the Google Spreadsheet approach: treat 1899-12-31 as day 1, allowing to avoid\n// implementing the \"Leap Year Bug\" yet still be Excel compatible for dates starting 1900-03-01.\nvar BASE_DATE = dateToJulianDays(1900, 0, -1);\n\nfunction packDate(year, month, date) {\n return dateToJulianDays(year, month, date) - BASE_DATE;\n}\n\nfunction packTime(hh, mm, ss, ms) {\n return (hh + (mm + (ss + ms / 1000) / 60) / 60) / 24;\n}\n\nfunction dateToSerial(date) {\n var time = packTime(date.getHours(),\n date.getMinutes(),\n date.getSeconds(),\n date.getMilliseconds());\n var serial = packDate(date.getFullYear(),\n date.getMonth(),\n date.getDate());\n return serial < 0 ? serial - 1 + time : serial + time;\n}\n\nvar MIME_TYPE = \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\";\nvar DATA_URL_PREFIX = \"data:\" + MIME_TYPE + \";base64,\";\nvar DATA_URL_OPTIONS = { compression: \"DEFLATE\", type: \"base64\" };\nvar BLOB_OPTIONS = { compression: \"DEFLATE\", type: \"blob\" };\nvar ARRAYBUFFER_OPTIONS = { compression: \"DEFLATE\", type: \"arraybuffer\" };\n\n/* eslint-disable key-spacing, no-arrow-condition, indent, no-nested-ternary, consistent-return */\n\nfunction toDataURI(content) {\n return DATA_URL_PREFIX + content;\n}\n\nfunction indexOf(thing, array) {\n return array.indexOf(thing);\n}\n\nvar parseJSON = JSON.parse.bind(JSON);\n\nfunction ESC(val) {\n return String(val)\n .replace(/&/g, \"&\")\n .replace(//g, \">\")\n .replace(/\\\"/g, \""\")\n .replace(/\\'/g, \"'\");\n}\n\nfunction repeat(count, func) {\n var str = \"\";\n for (var i = 0; i < count; ++i) {\n str += func(i);\n }\n return str;\n}\n\nfunction foreach(arr, func) {\n var str = \"\";\n if (arr != null) {\n if (Array.isArray(arr)) {\n for (var i = 0; i < arr.length; ++i) {\n str += func(arr[i], i);\n }\n } else if (typeof arr == \"object\") {\n Object.keys(arr).forEach(function (key, i) {\n str += func(arr[key], key, i);\n });\n }\n }\n return str;\n}\n\nvar XMLHEAD = '\\r';\n\nvar RELS = XMLHEAD + \"\\n \\n \\n \\n \\n \";\n\nvar CORE = function (ref) {\n var creator = ref.creator;\n var lastModifiedBy = ref.lastModifiedBy;\n var created = ref.created;\n var modified = ref.modified;\n\n return (XMLHEAD + \"\\n \\n \" + (ESC(creator)) + \"\\n \" + (ESC(lastModifiedBy)) + \"\\n \" + (ESC(created)) + \"\\n \" + (ESC(modified)) + \"\\n\");\n};\n\nvar APP = function (ref) {\n var sheets = ref.sheets;\n\n return (XMLHEAD + \"\\n\\n Microsoft Excel\\n 0\\n false\\n \\n \\n \\n Worksheets\\n \\n \\n \" + (sheets.length) + \"\\n \\n \\n \\n \\n \" + (foreach(sheets, function (sheet, i) { return sheet.options.title\n ? (\"\" + (ESC(sheet.options.title)) + \"\")\n : (\"Sheet\" + (i + 1) + \"\"); }\n )) + \"\\n \\n false\\n false\\n false\\n 14.0300\\n\");\n};\n\nvar CONTENT_TYPES = function (ref) {\n var sheetCount = ref.sheetCount;\n var commentFiles = ref.commentFiles;\n var drawingFiles = ref.drawingFiles;\n\n return (XMLHEAD + \"\\n\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \" + (repeat(sheetCount, function (idx) { return (\"\"); })) + \"\\n \" + (foreach(commentFiles, function (filename) { return (\"\"); })) + \"\\n \" + (foreach(drawingFiles, function (filename) { return (\"\"); })) + \"\\n \\n \\n\");\n};\n\nvar WORKBOOK = function (ref) {\n var sheets = ref.sheets;\n var filterNames = ref.filterNames;\n var userNames = ref.userNames;\n\n return (XMLHEAD + \"\\n\\n \\n \\n \\n \\n \\n \\n \" + (foreach(sheets, function (ref, i) {\n var options = ref.options;\n\n var name = options.name || options.title || (\"Sheet\" + (i + 1));\n return (\"\");\n })) + \"\\n \\n \" + (filterNames.length || userNames.length ? (\"\\n \\n \" + (foreach(filterNames, function (f) { return (\"\\n \"); })) + \"\\n \" + (foreach(userNames, function (f) { return (\"\\n \"); })) + \"\\n \") : '') + \"\\n \\n\");\n};\n\nvar WORKSHEET = function (ref$1) {\n var frozenColumns = ref$1.frozenColumns;\n var frozenRows = ref$1.frozenRows;\n var columns = ref$1.columns;\n var defaults = ref$1.defaults;\n var data = ref$1.data;\n var index = ref$1.index;\n var mergeCells = ref$1.mergeCells;\n var autoFilter = ref$1.autoFilter;\n var filter = ref$1.filter;\n var showGridLines = ref$1.showGridLines;\n var hyperlinks = ref$1.hyperlinks;\n var validations = ref$1.validations;\n var defaultCellStyleId = ref$1.defaultCellStyleId;\n var rtl = ref$1.rtl;\n var legacyDrawing = ref$1.legacyDrawing;\n var drawing = ref$1.drawing;\n var lastRow = ref$1.lastRow;\n var lastCol = ref$1.lastCol;\n\n return (XMLHEAD + \"\\n\\n \" + (lastRow && lastCol ? (\"\") : \"\") + \"\\n\\n \\n \\n \" + (frozenRows || frozenColumns ? (\"\\n \") : '') + \"\\n \\n \\n\\n \\n\\n \" + (defaultCellStyleId != null || (columns && columns.length > 0) ? (\"\\n \\n \" + (!columns || !columns.length ? (\"\\n \") : '') + \"\\n \" + (foreach(columns, function (column, ci) {\n var columnIndex = typeof column.index === \"number\" ? column.index + 1 : (ci + 1);\n if (column.width === 0) {\n return (\"\");\n }\n return (\"\");\n })) + \"\\n \") : '') + \"\\n\\n \\n \" + (foreach(data, function (row, ri) {\n var rowIndex = typeof row.index === \"number\" ? row.index + 1 : (ri + 1);\n return (\"\\n \\n \" + (foreach(row.data, function (cell) { return (\"\\n \\n \" + (cell.formula != null ? writeFormula(cell.formula) : '') + \"\\n \" + (cell.value != null ? (\"\" + (ESC(cell.value)) + \"\") : '') + \"\\n \"); })) + \"\\n \\n \");})) + \"\\n \\n\\n \" + (autoFilter ? (\"\")\n : filter ? spreadsheetFilters(filter) : '') + \"\\n\\n \" + (mergeCells.length ? (\"\\n \\n \" + (foreach(mergeCells, function (ref) { return (\"\"); })) + \"\\n \") : '') + \"\\n\\n \" + (validations.length ? (\"\\n \\n \" + (foreach(validations, function (val) { return (\"\\n \\n \" + (val.formula1 ? (\"\" + (ESC(val.formula1)) + \"\") : '') + \"\\n \" + (val.formula2 ? (\"\" + (ESC(val.formula2)) + \"\") : '') + \"\\n \"); })) + \"\\n \") : '') + \"\\n\\n \" + (hyperlinks.length ? (\"\\n \\n \" + (foreach(hyperlinks, function (link) { return (\"\\n \"); })) + \"\\n \") : '') + \"\\n\\n \\n \" + (drawing ? (\"\") : '') + \"\\n \" + (legacyDrawing ? (\"\") : '') + \"\\n\");\n};\n\nvar WORKBOOK_RELS = function (ref) {\n var count = ref.count;\n\n return (XMLHEAD + \"\\n\\n \" + (repeat(count, function (idx) { return (\"\\n \"); })) + \"\\n \\n \\n\");\n};\n\nvar WORKSHEET_RELS = function (ref) {\n var hyperlinks = ref.hyperlinks;\n var comments = ref.comments;\n var sheetIndex = ref.sheetIndex;\n var drawings = ref.drawings;\n\n return (XMLHEAD + \"\\n\\n \" + (foreach(hyperlinks, function (link) { return (\"\\n \"); })) + \"\\n \" + (!comments.length ? '' : (\"\\n \\n \")) + \"\\n \" + (!drawings.length ? '' : (\"\\n \")) + \"\\n\");\n};\n\nvar COMMENTS_XML = function (ref) {\n var comments = ref.comments;\n\n return (XMLHEAD + \"\\n\\n \\n \\n \\n \\n \" + (foreach(comments, function (comment) { return (\"\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \" + (ESC(comment.text)) + \"\\n \\n \\n \"); })) + \"\\n \\n\");\n};\n\nvar LEGACY_DRAWING = function (ref) {\n var comments = ref.comments;\n\n return (\"\\n \\n \\n \\n \\n \" + (foreach(comments, function (comment) { return (\"\\n \\n \\n \\n \\n \\n \" + (comment.anchor) + \"\\n False\\n \" + (comment.row) + \"\\n \" + (comment.col) + \"\\n \\n \"); })) + \"\\n\");\n};\n\nvar DRAWINGS_XML = function (drawings) { return (XMLHEAD + \"\\n\\n \" + (foreach(drawings, function (drawing, index) { return (\"\\n \\n \\n \" + (drawing.col) + \"\\n \" + (drawing.colOffset) + \"\\n \" + (drawing.row) + \"\\n \" + (drawing.rowOffset) + \"\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \"); })) + \"\\n\"); };\n\nvar DRAWINGS_RELS_XML = function (rels) { return (XMLHEAD + \"\\n\\n \" + (foreach(rels, function (rel) { return (\"\\n \"); })) + \"\\n\"); };\n\nvar SHARED_STRINGS = function (ref) {\n var count = ref.count;\n var uniqueCount = ref.uniqueCount;\n var indexes = ref.indexes;\n\n return (XMLHEAD + \"\\n\\n \" + (foreach(Object.keys(indexes), function (index) { return (\"\\n \" + (ESC(index.substring(1))) + \"\"); })) + \"\\n\");\n};\n\nvar STYLES = function (ref) {\n var formats = ref.formats;\n var fonts = ref.fonts;\n var fills = ref.fills;\n var borders = ref.borders;\n var styles = ref.styles;\n\n return (XMLHEAD + \"\\n\\n \\n \" + (foreach(formats, function (format, fi) { return (\"\\n \"); })) + \"\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \" + (foreach(fonts, function (font) { return (\"\\n \\n \" + (font.bold ? '' : '') + \"\\n \" + (font.italic ? '' : '') + \"\\n \" + (font.underline ? '' : '') + \"\\n \\n \" + (font.color ? (\"\") : '') + \"\\n \" + (font.fontFamily ? (\"\\n \\n \\n \") : \"\\n \\n \\n \\n \") + \"\\n \"); })) + \"\\n \\n \\n \\n \\n \" + (foreach(fills, function (fill) { return (\"\\n \" + (fill.background ? (\"\\n \\n \\n \\n \\n \\n \") : '')); })) + \"\\n \\n \\n \\n \" + (foreach(borders, borderTemplate)) + \"\\n \\n \\n \\n \\n \\n \\n \" + (foreach(styles, function (style) { return (\"\\n \\n \" + (style.textAlign || style.verticalAlign || style.wrap ? (\"\\n \\n \") : '') + \"\\n \\n \"); })) + \"\\n \\n \\n \\n \\n \\n \\n\");\n};\n\nfunction writeFormula(formula) {\n if (typeof formula == \"string\") {\n return (\"\" + (ESC(formula)) + \"\");\n }\n // array formulas\n return (\"\" + (ESC(formula.src)) + \"\");\n}\n\nfunction numChar(colIndex) {\n var letter = Math.floor(colIndex / 26) - 1;\n\n return (letter >= 0 ? numChar(letter) : \"\") + String.fromCharCode(65 + (colIndex % 26));\n}\n\nfunction ref(rowIndex, colIndex) {\n return numChar(colIndex) + (rowIndex + 1);\n}\n\nfunction $ref(rowIndex, colIndex) {\n return \"$\" + numChar(colIndex) + \"$\" + (rowIndex + 1);\n}\n\nfunction filterRowIndex(options) {\n var frozenRows = options.frozenRows || (options.freezePane || {}).rowSplit || 1;\n return frozenRows - 1;\n}\n\nfunction toWidth(px) {\n var maximumDigitWidth = 7;\n return (px / maximumDigitWidth) - (Math.floor(128 / maximumDigitWidth) / 256);\n}\n\nfunction toHeight(px) {\n return px * 0.75;\n}\n\nfunction stripFunnyChars(value) {\n return String(value)\n .replace(/[\\x00-\\x09\\x0B\\x0C\\x0E-\\x1F]/g, \"\") // leave CRLF in\n .replace(/\\r?\\n/g, \"\\r\\n\"); // make sure LF is preceded by CR\n}\n\nvar Worksheet = kendo.Class.extend({\n init: function(options, sharedStrings, styles, borders) {\n this.options = options;\n this._strings = sharedStrings;\n this._styles = styles;\n this._borders = borders;\n this._validations = {};\n this._comments = [];\n this._drawings = options.drawings || [];\n this._hyperlinks = (this.options.hyperlinks || []).map(\n function (link, i) { return $.extend({}, link, { rId: (\"link\" + i) }); });\n },\n\n relsToXML: function() {\n var hyperlinks = this._hyperlinks;\n var comments = this._comments;\n var drawings = this._drawings;\n\n if (hyperlinks.length || comments.length || drawings.length) {\n return WORKSHEET_RELS({\n hyperlinks : hyperlinks,\n comments : comments,\n sheetIndex : this.options.sheetIndex,\n drawings : drawings\n });\n }\n },\n\n toXML: function(index) {\n var this$1 = this;\n\n var mergeCells = this.options.mergedCells || [];\n var rows = this.options.rows || [];\n var data = inflate(rows, mergeCells);\n\n this._readCells(data);\n\n var autoFilter = this.options.filter;\n var filter;\n if (autoFilter && (typeof autoFilter.from === \"number\") && (typeof autoFilter.to === \"number\")) {\n // Grid enables auto filter\n autoFilter = {\n from: ref(filterRowIndex(this.options), autoFilter.from),\n to: ref(filterRowIndex(this.options), autoFilter.to)\n };\n } else if (autoFilter && autoFilter.ref && autoFilter.columns) {\n // this is probably from the Spreadsheet\n filter = autoFilter;\n autoFilter = null;\n }\n\n var validations = [];\n for (var i in this._validations) {\n if (Object.prototype.hasOwnProperty.call(this$1._validations, i)) {\n validations.push(this$1._validations[i]);\n }\n }\n\n var defaultCellStyleId = null;\n if (this.options.defaultCellStyle) {\n defaultCellStyleId = this._lookupStyle(this.options.defaultCellStyle);\n }\n\n var freezePane = this.options.freezePane || {};\n var defaults = this.options.defaults || {};\n var lastRow = this.options.rows ? this._getLastRow() : 1;\n var lastCol = this.options.rows ? this._getLastCol() : 1;\n\n return WORKSHEET({\n frozenColumns: this.options.frozenColumns || freezePane.colSplit,\n frozenRows: this.options.frozenRows || freezePane.rowSplit,\n columns: this.options.columns,\n defaults: defaults,\n data: data,\n index: index,\n mergeCells: mergeCells,\n autoFilter: autoFilter,\n filter: filter,\n showGridLines: this.options.showGridLines,\n hyperlinks: this._hyperlinks,\n validations: validations,\n defaultCellStyleId: defaultCellStyleId,\n rtl: this.options.rtl !== undefined ? this.options.rtl : defaults.rtl,\n legacyDrawing: this._comments.length ? (\"vml\" + (this.options.sheetIndex)) : null,\n drawing: this._drawings.length ? (\"drw\" + (this.options.sheetIndex)) : null,\n lastRow: lastRow,\n lastCol: lastCol\n });\n },\n\n commentsXML: function() {\n if (this._comments.length) {\n return COMMENTS_XML({ comments: this._comments });\n }\n },\n\n drawingsXML: function(images) {\n if (this._drawings.length) {\n var rels = {};\n var main = this._drawings.map(function (drw) {\n var ref = parseRef(drw.topLeftCell);\n var img = rels[drw.image];\n if (!img) {\n img = rels[drw.image] = {\n rId: (\"img\" + (drw.image)),\n target: images[drw.image].target\n };\n }\n return {\n col : ref.col,\n colOffset : pixelsToExcel(drw.offsetX),\n row : ref.row,\n rowOffset : pixelsToExcel(drw.offsetY),\n width : pixelsToExcel(drw.width),\n height : pixelsToExcel(drw.height),\n imageId : img.rId\n };\n });\n return {\n main: DRAWINGS_XML(main),\n rels: DRAWINGS_RELS_XML(rels)\n };\n }\n },\n\n legacyDrawing: function() {\n if (this._comments.length) {\n return LEGACY_DRAWING({ comments: this._comments });\n }\n },\n\n _lookupString: function(value) {\n var key = \"$\" + value;\n var index = this._strings.indexes[key];\n var result;\n\n if (index !== undefined) {\n result = index;\n } else {\n result = this._strings.indexes[key] = this._strings.uniqueCount;\n this._strings.uniqueCount ++;\n }\n\n this._strings.count ++;\n\n return result;\n },\n\n _lookupStyle: function(style) {\n var json = JSON.stringify(style);\n\n if (json === \"{}\") {\n return 0;\n }\n\n var index = indexOf(json, this._styles);\n\n if (index < 0) {\n index = this._styles.push(json) - 1;\n }\n\n // There is one default style\n return index + 1;\n },\n\n _lookupBorder: function(border) {\n var json = JSON.stringify(border);\n if (json === \"{}\") {\n return;\n }\n\n var index = indexOf(json, this._borders);\n if (index < 0) {\n index = this._borders.push(json) - 1;\n }\n\n // There is one default border\n return index + 1;\n },\n\n _readCells: function(rowData) {\n var this$1 = this;\n\n for (var i = 0; i < rowData.length; i++) {\n var row = rowData[i];\n var cells = row.cells;\n\n row.data = [];\n\n for (var j = 0; j < cells.length; j++) {\n var cellData = this$1._cell(cells[j], row.index, j);\n if (cellData) {\n row.data.push(cellData);\n }\n }\n }\n },\n\n _cell: function(data, rowIndex, cellIndex) {\n if (!data || data === EMPTY_CELL) {\n return null;\n }\n\n var value = data.value;\n\n var border = {};\n\n if (data.borderLeft) {\n border.left = data.borderLeft;\n }\n\n if (data.borderRight) {\n border.right = data.borderRight;\n }\n\n if (data.borderTop) {\n border.top = data.borderTop;\n }\n\n if (data.borderBottom) {\n border.bottom = data.borderBottom;\n }\n\n border = this._lookupBorder(border);\n\n var defStyle = this.options.defaultCellStyle || {};\n var style = { borderId: border };\n\n (function(add) {\n add(\"color\");\n add(\"background\");\n add(\"bold\");\n add(\"italic\");\n add(\"underline\");\n if (!add(\"fontFamily\")) { add(\"fontName\", \"fontFamily\"); }\n add(\"fontSize\");\n add(\"format\");\n if (!add(\"textAlign\")) { add(\"hAlign\", \"textAlign\"); }\n if (!add(\"verticalAlign\")) { add(\"vAlign\", \"verticalAlign\"); }\n add(\"wrap\");\n add(\"indent\");\n })(\n function(prop, target) {\n var val = data[prop];\n if (val === undefined) {\n val = defStyle[prop];\n }\n if (val !== undefined) {\n style[target || prop] = val;\n return true;\n }\n }\n );\n\n var columns = this.options.columns || [];\n\n var column = columns[cellIndex];\n var type = typeof value;\n\n if (column && column.autoWidth && (!data.colSpan || data.colSpan === 1)) {\n var displayValue = value;\n\n // XXX: let's not bring kendo.toString in only for this.\n // better wait until the spreadsheet engine is available as a separate\n // component, then we can use a real Excel-like formatter.\n //\n if (type === \"number\") {\n // kendo.toString will not behave exactly like the Excel format\n // Still, it's the best we have available for estimating the character count.\n displayValue = IntlService.toString(value, data.format);\n }\n\n column.width = Math.max(column.width || 0, String(displayValue).length);\n }\n\n if (type === \"string\") {\n value = stripFunnyChars(value);\n value = this._lookupString(value);\n type = \"s\";\n } else if (type === \"number\") {\n type = \"n\";\n } else if (type === \"boolean\") {\n type = \"b\";\n value = Number(value);\n } else if (value && value.getTime) {\n type = null;\n value = dateToSerial(value);\n if (!style.format) {\n style.format = \"mm-dd-yy\";\n }\n } else {\n type = null;\n value = null;\n }\n\n style = this._lookupStyle(style);\n\n var cellName = ref(rowIndex, cellIndex);\n\n if (data.validation) {\n this._addValidation(data.validation, cellName);\n }\n\n if (data.comment) {\n var anchor = [\n cellIndex + 1, // start column\n 15, // start column offset\n rowIndex, // start row\n 10, // start row offset\n cellIndex + 3, // end column\n 15, // end column offset\n rowIndex + 3, // end row\n 4 // end row offset\n ];\n this._comments.push({\n ref : cellName,\n text : data.comment,\n row : rowIndex,\n col : cellIndex,\n anchor : anchor.join(\", \")\n });\n }\n\n return {\n value: value,\n formula: data.formula,\n type: type,\n style: style,\n ref: cellName\n };\n },\n\n _addValidation: function(v, ref) {\n var tmp = {\n showErrorMessage : v.type === \"reject\" ? 1 : 0,\n formula1 : v.from,\n formula2 : v.to,\n type : MAP_EXCEL_TYPE[v.dataType] || v.dataType,\n operator : MAP_EXCEL_OPERATOR[v.comparerType] || v.comparerType,\n allowBlank : v.allowNulls ? 1 : 0,\n showDropDown : v.showButton ? 0 : 1, // LOL, Excel!\n error : v.messageTemplate,\n errorTitle : v.titleTemplate\n };\n var json = JSON.stringify(tmp);\n if (!this._validations[json]) {\n this._validations[json] = tmp;\n tmp.sqref = [];\n }\n this._validations[json].sqref.push(ref);\n },\n\n _getLastRow: function() {\n return countData(this.options.rows);\n },\n\n _getLastCol: function() {\n var last = 0;\n this.options.rows.forEach(function(row) {\n if (row.cells) {\n last = Math.max(last, countData(row.cells));\n }\n });\n return last;\n }\n});\n\nfunction countData(data) {\n var last = data.length;\n data.forEach(function(el) {\n if (el.index && el.index >= last) {\n last = el.index + 1;\n }\n });\n return last;\n}\n\nvar MAP_EXCEL_OPERATOR = {\n // includes only what differs; key is our operator, value is Excel\n // operator.\n greaterThanOrEqualTo : \"greaterThanOrEqual\",\n lessThanOrEqualTo : \"lessThanOrEqual\"\n};\n\nvar MAP_EXCEL_TYPE = {\n number: \"decimal\"\n};\n\nvar defaultFormats = {\n \"General\": 0,\n \"0\": 1,\n \"0.00\": 2,\n \"#,##0\": 3,\n \"#,##0.00\": 4,\n \"0%\": 9,\n \"0.00%\": 10,\n \"0.00E+00\": 11,\n \"# ?/?\": 12,\n \"# ??/??\": 13,\n \"mm-dd-yy\": 14,\n \"d-mmm-yy\": 15,\n \"d-mmm\": 16,\n \"mmm-yy\": 17,\n \"h:mm AM/PM\": 18,\n \"h:mm:ss AM/PM\": 19,\n \"h:mm\": 20,\n \"h:mm:ss\": 21,\n \"m/d/yy h:mm\": 22,\n \"#,##0 ;(#,##0)\": 37,\n \"#,##0 ;[Red](#,##0)\": 38,\n \"#,##0.00;(#,##0.00)\": 39,\n \"#,##0.00;[Red](#,##0.00)\": 40,\n \"mm:ss\": 45,\n \"[h]:mm:ss\": 46,\n \"mmss.0\": 47,\n \"##0.0E+0\": 48,\n \"@\": 49,\n \"[$-404]e/m/d\": 27,\n \"m/d/yy\": 30,\n \"t0\": 59,\n \"t0.00\": 60,\n \"t#,##0\": 61,\n \"t#,##0.00\": 62,\n \"t0%\": 67,\n \"t0.00%\": 68,\n \"t# ?/?\": 69,\n \"t# ??/??\": 70\n};\n\nfunction convertColor(value) {\n var color = value;\n if (color.length < 6) {\n color = color.replace(/(\\w)/g, function($0, $1) {\n return $1 + $1;\n });\n }\n\n color = color.substring(1).toUpperCase();\n\n if (color.length < 8) {\n color = \"FF\" + color;\n }\n\n return color;\n}\n\nvar Workbook = kendo.Class.extend({\n init: function(options) {\n var this$1 = this;\n\n this.options = options || {};\n this._strings = {\n indexes: {},\n count: 0,\n uniqueCount: 0\n };\n this._styles = [];\n this._borders = [];\n this._images = this.options.images;\n this._imgId = 0;\n\n this._sheets = map(this.options.sheets || [], function (options, i) {\n options.defaults = this$1.options;\n options.sheetIndex = i + 1;\n return new Worksheet(options, this$1._strings, this$1._styles, this$1._borders);\n });\n },\n\n imageFilename: function(mimeType) {\n var id = ++this._imgId;\n switch (mimeType) {\n case \"image/jpg\":\n case \"image/jpeg\":\n return (\"image\" + id + \".jpg\");\n case \"image/png\":\n return (\"image\" + id + \".png\");\n case \"image/gif\":\n return (\"image\" + id + \".gif\");\n default:\n return (\"image\" + id + \".bin\"); // XXX: anything better to do here?\n }\n },\n\n toZIP: function() {\n var this$1 = this;\n\n var zip = createZip();\n\n var docProps = zip.folder(\"docProps\");\n\n docProps.file(\"core.xml\", CORE({\n creator: this.options.creator || \"Kendo UI\",\n lastModifiedBy: this.options.creator || \"Kendo UI\",\n created: this.options.date || new Date().toJSON(),\n modified: this.options.date || new Date().toJSON()\n }));\n\n var sheetCount = this._sheets.length;\n\n docProps.file(\"app.xml\", APP({ sheets: this._sheets }));\n\n var rels = zip.folder(\"_rels\");\n rels.file(\".rels\", RELS);\n\n var xl = zip.folder(\"xl\");\n\n var xlRels = xl.folder(\"_rels\");\n xlRels.file(\"workbook.xml.rels\", WORKBOOK_RELS({ count: sheetCount }));\n\n if (this._images) {\n var media = xl.folder(\"media\");\n Object.keys(this._images).forEach(function (id) {\n var img = this$1._images[id];\n var filename = this$1.imageFilename(img.type);\n media.file(filename, img.data);\n img.target = \"../media/\" + filename;\n });\n }\n\n var sheetIds = {};\n xl.file(\"workbook.xml\", WORKBOOK({\n sheets: this._sheets,\n filterNames: map(this._sheets, function(sheet, index) {\n var options = sheet.options;\n var sheetName = (options.name || options.title || \"Sheet\" + (index + 1));\n sheetIds[sheetName.toLowerCase()] = index;\n var filter = options.filter;\n if (filter) {\n if (filter.ref) {\n // spreadsheet provides `ref`\n var a = filter.ref.split(\":\");\n var from = parseRef(a[0]);\n var to = parseRef(a[1]);\n return {\n localSheetId: index,\n name: sheetName,\n from: $ref(from.row, from.col),\n to: $ref(to.row, to.col)\n };\n } else if (typeof filter.from !== \"undefined\" && typeof filter.to !== \"undefined\") {\n // grid does this\n return {\n localSheetId: index,\n name: sheetName,\n from: $ref(filterRowIndex(options), filter.from),\n to: $ref(filterRowIndex(options), filter.to)\n };\n }\n }\n }),\n userNames: map(this.options.names || [], function(def) {\n return {\n name: def.localName,\n localSheetId: def.sheet ? sheetIds[def.sheet.toLowerCase()] : null,\n value: def.value,\n hidden: def.hidden\n };\n })\n }));\n\n var worksheets = xl.folder(\"worksheets\");\n var drawings = xl.folder(\"drawings\");\n var drawingsRels = drawings.folder(\"_rels\");\n var sheetRels = worksheets.folder(\"_rels\");\n var commentFiles = [];\n var drawingFiles = [];\n\n for (var idx = 0; idx < sheetCount; idx++) {\n var sheet = this$1._sheets[idx];\n var sheetName = \"sheet\" + (idx + 1) + \".xml\";\n var sheetXML = sheet.toXML(idx); // must be called before relsToXML\n var relsXML = sheet.relsToXML();\n var commentsXML = sheet.commentsXML();\n var legacyDrawing = sheet.legacyDrawing();\n var drawingsXML = sheet.drawingsXML(this$1._images);\n\n if (relsXML) {\n sheetRels.file(sheetName + \".rels\", relsXML);\n }\n if (commentsXML) {\n var name = \"comments\" + (sheet.options.sheetIndex) + \".xml\";\n xl.file(name, commentsXML);\n commentFiles.push(name);\n }\n if (legacyDrawing) {\n drawings.file((\"vmlDrawing\" + (sheet.options.sheetIndex) + \".vml\"), legacyDrawing);\n }\n if (drawingsXML) {\n var name$1 = \"drawing\" + (sheet.options.sheetIndex) + \".xml\";\n drawings.file(name$1, drawingsXML.main);\n drawingsRels.file((name$1 + \".rels\"), drawingsXML.rels);\n drawingFiles.push(name$1);\n }\n\n worksheets.file(sheetName, sheetXML);\n }\n\n var borders = map(this._borders, parseJSON);\n\n var styles = map(this._styles, parseJSON);\n\n var hasFont = function(style) {\n return style.underline || style.bold || style.italic || style.color || style.fontFamily || style.fontSize;\n };\n\n var convertFontSize = function(value) {\n var fontInPx = Number(value);\n var fontInPt;\n\n if (fontInPx) {\n fontInPt = fontInPx * 3 / 4;\n }\n\n return fontInPt;\n };\n\n var fonts = map(styles, function(style) {\n if (style.fontSize) {\n style.fontSize = convertFontSize(style.fontSize);\n }\n\n if (style.color) {\n style.color = convertColor(style.color);\n }\n\n if (hasFont(style)) {\n return style;\n }\n });\n\n var formats = map(styles, function(style) {\n if (style.format && defaultFormats[style.format] === undefined) {\n return style;\n }\n });\n\n var fills = map(styles, function(style) {\n if (style.background) {\n style.background = convertColor(style.background);\n return style;\n }\n });\n\n xl.file(\"styles.xml\", STYLES({\n fonts: fonts,\n fills: fills,\n formats: formats,\n borders: borders,\n styles: map(styles, function(style) {\n var result = {};\n\n if (hasFont(style)) {\n result.fontId = indexOf(style, fonts) + 1;\n }\n\n if (style.background) {\n result.fillId = indexOf(style, fills) + 2;\n }\n\n result.textAlign = style.textAlign;\n result.indent = style.indent;\n result.verticalAlign = style.verticalAlign;\n result.wrap = style.wrap;\n result.borderId = style.borderId;\n\n if (style.format) {\n if (defaultFormats[style.format] !== undefined) {\n result.numFmtId = defaultFormats[style.format];\n } else {\n result.numFmtId = 165 + indexOf(style, formats);\n }\n }\n\n return result;\n })\n }));\n\n xl.file(\"sharedStrings.xml\", SHARED_STRINGS(this._strings));\n\n zip.file(\"[Content_Types].xml\", CONTENT_TYPES({\n sheetCount: sheetCount,\n commentFiles: commentFiles,\n drawingFiles: drawingFiles\n }));\n\n return zip;\n },\n\n toDataURL: function() {\n var zip = this.toZIP();\n\n return zip.generateAsync ? zip.generateAsync(DATA_URL_OPTIONS).then(toDataURI) : toDataURI(zip.generate(DATA_URL_OPTIONS));\n },\n\n toBlob: function() {\n var zip = this.toZIP();\n if (zip.generateAsync) {\n return zip.generateAsync(BLOB_OPTIONS);\n }\n return new Blob([ zip.generate(ARRAYBUFFER_OPTIONS) ], { type: MIME_TYPE });\n }\n});\n\nfunction borderStyle(width) {\n var alias = \"thin\";\n\n if (width === 2) {\n alias = \"medium\";\n } else if (width === 3) {\n alias = \"thick\";\n }\n\n return alias;\n}\n\nfunction borderSideTemplate(name, style) {\n var result = \"\";\n\n if (style) {\n result += \"<\" + name + \" style=\\\"\" + borderStyle(style.size) + \"\\\">\";\n if (style.color) {\n result += \"\";\n }\n result += \"\";\n }\n\n return result;\n}\n\nfunction borderTemplate(border) {\n return \"\" +\n borderSideTemplate(\"left\", border.left) +\n borderSideTemplate(\"right\", border.right) +\n borderSideTemplate(\"top\", border.top) +\n borderSideTemplate(\"bottom\", border.bottom) +\n \"\";\n}\n\nvar EMPTY_CELL = {};\nfunction inflate(rows, mergedCells) {\n var rowData = [];\n var rowsByIndex = [];\n\n indexRows(rows, function(row, index) {\n var data = {\n _source: row,\n index: index,\n height: row.height,\n level: row.level,\n cells: []\n };\n\n rowData.push(data);\n rowsByIndex[index] = data;\n });\n\n var sorted = sortByIndex(rowData).slice(0);\n var ctx = {\n rowData: rowData,\n rowsByIndex: rowsByIndex,\n mergedCells: mergedCells\n };\n\n for (var i = 0; i < sorted.length; i++) {\n fillCells(sorted[i], ctx);\n delete sorted[i]._source;\n }\n\n return sortByIndex(rowData);\n}\n\nfunction indexRows(rows, callback) {\n for (var i = 0; i < rows.length; i++) {\n var row = rows[i];\n if (!row) {\n continue;\n }\n\n var index = row.index;\n if (typeof index !== \"number\") {\n index = i;\n }\n\n callback(row, index);\n }\n}\n\nfunction sortByIndex(items) {\n return items.sort(function(a, b) {\n return a.index - b.index;\n });\n}\n\nfunction pushUnique(array, el) {\n if (array.indexOf(el) < 0) {\n array.push(el);\n }\n}\n\nfunction getSpan(mergedCells, ref) {\n for (var i = 0; i < mergedCells.length; ++i) {\n var range = mergedCells[i];\n var a = range.split(\":\");\n var topLeft = a[0];\n if (topLeft === ref) {\n var bottomRight = a[1];\n topLeft = parseRef(topLeft);\n bottomRight = parseRef(bottomRight);\n return {\n rowSpan: bottomRight.row - topLeft.row + 1,\n colSpan: bottomRight.col - topLeft.col + 1\n };\n }\n }\n}\n\nfunction parseRef(ref) {\n function getcol(str) {\n var upperStr = str.toUpperCase();\n var col = 0;\n for (var i = 0; i < upperStr.length; ++i) {\n col = col * 26 + upperStr.charCodeAt(i) - 64;\n }\n return col - 1;\n }\n\n function getrow(str) {\n return parseInt(str, 10) - 1;\n }\n\n var m = /^([a-z]+)(\\d+)$/i.exec(ref);\n return {\n row: getrow(m[2]),\n col: getcol(m[1])\n };\n}\n\nfunction pixelsToExcel(px) {\n return Math.round(px * 9525);\n}\n\nfunction fillCells(data, ctx) {\n var row = data._source;\n var rowIndex = data.index;\n var cells = row.cells;\n var cellData = data.cells;\n\n if (!cells) {\n return;\n }\n\n for (var i = 0; i < cells.length; i++) {\n var cell = cells[i] || EMPTY_CELL;\n\n var rowSpan = cell.rowSpan || 1;\n var colSpan = cell.colSpan || 1;\n\n var cellIndex = insertCell(cellData, cell);\n var topLeftRef = ref(rowIndex, cellIndex);\n\n if (rowSpan === 1 && colSpan === 1) {\n // could still be merged: the spreadsheet does not send\n // rowSpan/colSpan, but mergedCells is already populated.\n // https://github.com/telerik/kendo-ui-core/issues/2401\n var tmp = getSpan(ctx.mergedCells, topLeftRef);\n if (tmp) {\n colSpan = tmp.colSpan;\n rowSpan = tmp.rowSpan;\n }\n }\n\n spanCell(cell, cellData, cellIndex, colSpan);\n\n if (rowSpan > 1 || colSpan > 1) {\n pushUnique(ctx.mergedCells,\n topLeftRef + \":\" + ref(rowIndex + rowSpan - 1,\n cellIndex + colSpan - 1));\n }\n\n if (rowSpan > 1) {\n for (var ri = rowIndex + 1; ri < rowIndex + rowSpan; ri++) {\n var nextRow = ctx.rowsByIndex[ri];\n if (!nextRow) {\n nextRow = ctx.rowsByIndex[ri] = { index: ri, cells: [] };\n ctx.rowData.push(nextRow);\n }\n\n spanCell(cell, nextRow.cells, cellIndex - 1, colSpan + 1);\n }\n }\n }\n}\n\nfunction insertCell(data, cell) {\n var index;\n\n if (typeof cell.index === \"number\") {\n index = cell.index;\n insertCellAt(data, cell, cell.index);\n } else {\n index = appendCell(data, cell);\n }\n\n return index;\n}\n\nfunction insertCellAt(data, cell, index) {\n data[index] = cell;\n}\n\nfunction appendCell(data, cell) {\n var index = data.length;\n\n for (var i = 0; i < data.length + 1; i++) {\n if (!data[i]) {\n data[i] = cell;\n index = i;\n break;\n }\n }\n\n return index;\n}\n\nfunction spanCell(cell, row, startIndex, colSpan) {\n for (var i = 1; i < colSpan; i++) {\n var tmp = {\n borderTop : cell.borderTop,\n borderRight : cell.borderRight,\n borderBottom : cell.borderBottom,\n borderLeft : cell.borderLeft\n };\n insertCellAt(row, tmp, startIndex + i);\n }\n}\n\nvar SPREADSHEET_FILTERS = function (ref$1) {\n var ref = ref$1.ref;\n var columns = ref$1.columns;\n var generators = ref$1.generators;\n\n return (\"\\n\\n \" + (foreach(columns, function (col) { return (\"\\n \\n \" + (generators[col.filter](col)) + \"\\n \\n \"); })) + \"\\n\");\n};\n\nvar SPREADSHEET_CUSTOM_FILTER = function (ref) {\n var logic = ref.logic;\n var criteria = ref.criteria;\n\n return (\"\\n\\n\" + (foreach(criteria, function (f) {\n var op = spreadsheetFilters.customOperator(f);\n var val = spreadsheetFilters.customValue(f);\n return (\"\");\n})) + \"\\n\");\n};\n\nvar SPREADSHEET_DYNAMIC_FILTER = function (ref) {\n var type = ref.type;\n\n return (\"\");\n};\n\nvar SPREADSHEET_TOP_FILTER = function (ref) {\n var type = ref.type;\n var value = ref.value;\n\n return (\"\");\n};\n\nvar SPREADSHEET_VALUE_FILTER = function (ref) {\n var blanks = ref.blanks;\n var values = ref.values;\n\n return (\"\\n \" + (foreach(values, function (value) { return (\"\\n \"); })) + \"\\n \");\n};\n\nfunction spreadsheetFilters(filter) {\n return SPREADSHEET_FILTERS({\n ref: filter.ref,\n columns: filter.columns,\n generators: {\n custom : SPREADSHEET_CUSTOM_FILTER,\n dynamic : SPREADSHEET_DYNAMIC_FILTER,\n top : SPREADSHEET_TOP_FILTER,\n value : SPREADSHEET_VALUE_FILTER\n }\n });\n}\n\nspreadsheetFilters.customOperator = function(f) {\n return {\n eq : \"equal\",\n gt : \"greaterThan\",\n gte : \"greaterThanOrEqual\",\n lt : \"lessThan\",\n lte : \"lessThanOrEqual\",\n ne : \"notEqual\",\n\n // These are not in the spec, but seems to be how Excel does\n // it (see customValue below). For the non-negated versions,\n // the operator attribute is missing completely.\n doesnotstartwith: \"notEqual\",\n doesnotendwith: \"notEqual\",\n doesnotcontain: \"notEqual\",\n doesnotmatch: \"notEqual\"\n }[f.operator.toLowerCase()];\n};\n\nfunction quoteSheet(name) {\n if (/^\\'/.test(name)) { // assume already quoted, the Spreadsheet does it.\n return name;\n }\n if (/^[a-z_][a-z0-9_]*$/i.test(name)) {\n return name; // no need to quote it\n }\n return \"'\" + name.replace(/\\x27/g, \"\\\\'\") + \"'\";\n}\n\nspreadsheetFilters.customValue = function(f) {\n function esc(str) {\n return str.replace(/([*?])/g, \"~$1\");\n }\n\n switch (f.operator.toLowerCase()) {\n case \"startswith\":\n case \"doesnotstartwith\":\n return esc(f.value) + \"*\";\n\n case \"endswith\":\n case \"doesnotendwith\":\n return \"*\" + esc(f.value);\n\n case \"contains\":\n case \"doesnotcontain\":\n return \"*\" + esc(f.value) + \"*\";\n\n default:\n return f.value;\n }\n};\n\nspreadsheetFilters.dynamicFilterType = function(type) {\n return {\n quarter1 : \"Q1\",\n quarter2 : \"Q2\",\n quarter3 : \"Q3\",\n quarter4 : \"Q4\",\n january : \"M1\",\n february : \"M2\",\n march : \"M3\",\n april : \"M4\",\n may : \"M5\",\n june : \"M6\",\n july : \"M7\",\n august : \"M8\",\n september : \"M9\",\n october : \"M10\",\n november : \"M11\",\n december : \"M12\"\n }[type.toLowerCase()] || type;\n};\n\nkendo.deepExtend(kendo.ooxml, {\n IntlService: IntlService,\n Workbook: Workbook,\n Worksheet: Worksheet\n});\n\n})(window.kendo.jQuery);\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n(function(f, define){\n define('ooxml/main',[\n \"../kendo.core\",\n \"./kendo-ooxml\"\n ], f);\n})(function(){\n\n(function ($) {\n\nvar Workbook = kendo.ooxml.Workbook;\n\nkendo.ooxml.IntlService.register({\n toString: kendo.toString\n});\n\nkendo.ooxml.Workbook = Workbook.extend({\n toDataURL: function() {\n var result = Workbook.fn.toDataURL.call(this);\n if (typeof result !== 'string') {\n throw new Error('The toDataURL method can be used only with jsZip 2. Either include jsZip 2 or use the toDataURLAsync method.');\n }\n\n return result;\n },\n\n toDataURLAsync: function() {\n var deferred = $.Deferred();\n var result = Workbook.fn.toDataURL.call(this);\n if (typeof result === 'string') {\n result = deferred.resolve(result);\n } else if (result && result.then){\n result.then(function(dataURI) {\n deferred.resolve(dataURI);\n }, function() {\n deferred.reject();\n });\n }\n\n return deferred.promise();\n }\n});\n\n})(window.kendo.jQuery);\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n\n(function(f, define){\r\n define('kendo.ooxml',[ \"./ooxml/main\" ], f);\r\n})(function(){\r\n\r\nvar __meta__ = { // jshint ignore:line\r\n id: \"ooxml\",\r\n name: \"XLSX generation\",\r\n category: \"framework\",\r\n advanced: true,\r\n depends: [ \"core\" ]\r\n};\r\n\r\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\r\n\n/***********************************************************************\n * WARNING: this file is auto-generated. If you change it directly,\n * your modifications will eventually be lost. The source code is in\n * `kendo-ooxml` repository, you should make your changes there and\n * run `src-modules/sync.sh` in this repository.\n */\n(function(f, define){\n define('excel/kendo-excel',[\n \"../kendo.core\"\n ], f);\n})(function(){\n\n(function ($) {\n\nwindow.kendo.excel = window.kendo.excel || {};\n\nvar getter = kendo.getter;\nvar map = $.map;\n\nvar current = {\n compile: function(template) {\n return template;\n }\n};\n\nvar TemplateService = kendo.Class.extend({\n\n});\n\nTemplateService.register = function(userImplementation) {\n current = userImplementation;\n};\n\nTemplateService.compile = function(template) {\n return current.compile(template);\n};\n\nfunction defaultGroupHeaderTemplate(data) {\n return ((data.title) + \": \" + (data.value));\n}\n\nfunction createArray(length, callback) {\n var result = [];\n\n for (var idx = 0; idx < length; idx++) {\n result.push(callback(idx));\n }\n\n return result;\n}\n\nfunction defaultItemId(item) {\n return item.id;\n}\n\nvar ExcelExporter = kendo.Class.extend({\n init: function(options) {\n options.columns = this._trimColumns(options.columns || []);\n\n this.allColumns = map(this._leafColumns(options.columns || []), this._prepareColumn);\n\n this.columns = this._visibleColumns(this.allColumns);\n\n this.options = options;\n this.data = options.data || [];\n this.aggregates = options.aggregates || {};\n this.groups = [].concat(options.groups || []);\n this.hasGroups = this.groups.length > 0;\n this.hierarchy = options.hierarchy;\n this.hasGroupHeaderColumn = this.columns.some(function (column) { return column.groupHeaderColumnTemplate; });\n this.collapsible = this.options.collapsible;\n },\n\n workbook: function() {\n var workbook = {\n sheets: [ {\n columns: this._columns(),\n rows: this.hierarchy ? this._hierarchyRows() : this._rows(),\n freezePane: this._freezePane(),\n filter: this._filter()\n } ]\n };\n\n return workbook;\n },\n\n _trimColumns: function(columns) {\n var this$1 = this;\n\n return columns.filter(function (column) {\n var result = Boolean(column.field);\n\n if (!result && column.columns) {\n result = this$1._trimColumns(column.columns).length > 0;\n }\n\n return result;\n });\n },\n\n _leafColumns: function(columns) {\n var this$1 = this;\n\n var result = [];\n\n for (var idx = 0; idx < columns.length; idx++) {\n if (!columns[idx].columns) {\n result.push(columns[idx]);\n } else {\n result = result.concat(this$1._leafColumns(columns[idx].columns));\n }\n }\n\n return result;\n },\n\n _prepareColumn: function(column) {\n if (!column.field) {\n return null;\n }\n\n var value = function(dataItem) {\n return getter(column.field, true)(dataItem);\n };\n\n var values = null;\n\n if (column.values) {\n values = {};\n\n column.values.forEach(function(item) {\n values[item.value] = item.text;\n });\n\n value = function(dataItem) {\n return values[getter(column.field, true)(dataItem)];\n };\n }\n\n return $.extend({}, column, {\n value: value,\n values: values,\n groupHeaderTemplate: column.groupHeaderTemplate ? TemplateService.compile(column.groupHeaderTemplate) : defaultGroupHeaderTemplate,\n groupHeaderColumnTemplate: column.groupHeaderColumnTemplate ? TemplateService.compile(column.groupHeaderColumnTemplate) : null,\n groupFooterTemplate: column.groupFooterTemplate ? TemplateService.compile(column.groupFooterTemplate) : null,\n footerTemplate: column.footerTemplate ? TemplateService.compile(column.footerTemplate) : null\n });\n },\n\n _filter: function() {\n if (!this.options.filterable) {\n return null;\n }\n\n var depth = this._depth();\n\n return {\n from: depth,\n to: depth + this.columns.length - 1\n };\n },\n\n _createPaddingCells: function(length) {\n var this$1 = this;\n\n return createArray(length, function () { return $.extend({\n background: \"#dfdfdf\",\n color: \"#333\"\n }, this$1.options.paddingCellOptions); });\n },\n\n _dataRow: function(dataItem, level, depth) {\n var this$1 = this;\n\n var cells = this._createPaddingCells(level);\n\n // grouped\n if (this.hasGroups && depth && dataItem.items) {\n cells = cells.concat(this._groupHeaderCells(dataItem, level, depth));\n var rows = this._dataRows(dataItem.items, level + 1);\n\n rows.unshift({\n type: \"group-header\",\n cells: cells,\n level: this.collapsible ? level : null\n });\n\n return rows.concat(this._footer(dataItem, level));\n }\n\n var dataCells = [];\n\n for (var cellIdx = 0; cellIdx < this.columns.length; cellIdx++) {\n dataCells[cellIdx] = this$1._cell(dataItem, this$1.columns[cellIdx]);\n }\n\n if (this.hierarchy) {\n dataCells[0].colSpan = depth - level + 1;\n }\n\n return [ {\n type: \"data\",\n cells: cells.concat(dataCells),\n level: this.collapsible ? level : null\n } ];\n },\n\n _groupHeaderCells: function(dataItem, level, depth) {\n var cells = [];\n\n var column = this.allColumns.filter(function(column) {\n return column.field === dataItem.field;\n })[0] || {};\n\n var title = column && column.title ? column.title : dataItem.field;\n var template = column ? column.groupHeaderTemplate || column.groupHeaderColumnTemplate : null;\n var group = $.extend({\n title: title,\n field: dataItem.field,\n value: column && column.values ? column.values[dataItem.value] : dataItem.value,\n aggregates: dataItem.aggregates,\n items: dataItem.items\n }, dataItem.aggregates[dataItem.field]);\n\n var value = template ? template(group) : (title + \": \" + (dataItem.value));\n\n cells.push($.extend({\n value: value,\n background: \"#dfdfdf\",\n color: \"#333\",\n colSpan: (this.hasGroupHeaderColumn ? 1 : this.columns.length) + depth - level\n }, column.groupHeaderCellOptions));\n\n if (this.hasGroupHeaderColumn) {\n this.columns.forEach(function(column, index) {\n if (index > 0) {\n cells.push($.extend({\n background: \"#dfdfdf\",\n color: \"#333\",\n value: column.groupHeaderColumnTemplate ?\n column.groupHeaderColumnTemplate($.extend({ group: group }, group, dataItem.aggregates[column.field])) :\n undefined\n }, column.groupHeaderCellOptions));\n }\n });\n }\n\n return cells;\n },\n\n _dataRows: function(dataItems, level) {\n var this$1 = this;\n\n var depth = this._depth();\n var rows = [];\n\n for (var idx = 0; idx < dataItems.length; idx++) {\n rows.push.apply(rows, this$1._dataRow(dataItems[idx], level, depth));\n }\n\n return rows;\n },\n\n _hierarchyRows: function() {\n var this$1 = this;\n\n var depth = this._depth();\n var data = this.data;\n var itemLevel = this.hierarchy.itemLevel;\n var itemId = this.hierarchy.itemId || defaultItemId;\n var hasFooter = this._hasFooterTemplate();\n var rows = [];\n var parents = [];\n var previousLevel = 0;\n var previousItemId;\n\n if (!hasFooter) {\n this.collapsible = false;\n }\n\n for (var idx = 0; idx < data.length; idx++) {\n var item = data[idx];\n var level = itemLevel(item, idx);\n\n if (hasFooter) {\n if (level > previousLevel) {\n parents.push({ id: previousItemId, level: previousLevel });\n } else if (level < previousLevel) {\n rows.push.apply(rows, this$1._hierarchyFooterRows(parents, level, depth));\n }\n\n previousLevel = level;\n previousItemId = itemId(item, idx);\n }\n\n rows.push.apply(rows, this$1._dataRow(item, level + 1, depth));\n }\n\n if (hasFooter) {\n rows.push.apply(rows, this._hierarchyFooterRows(parents, 0, depth));\n\n var rootAggregate = data.length ? this.aggregates[data[0].parentId] : {};\n rows.push(this._hierarchyFooter(rootAggregate, 0, depth));\n }\n\n this._prependHeaderRows(rows);\n\n return rows;\n },\n\n _hierarchyFooterRows: function(parents, currentLevel, depth) {\n var this$1 = this;\n\n var rows = [];\n while (parents.length && parents[parents.length - 1].level >= currentLevel) {\n var parent = parents.pop();\n rows.push(this$1._hierarchyFooter(this$1.aggregates[parent.id], parent.level + 1, depth));\n }\n\n return rows;\n },\n\n _hasFooterTemplate: function() {\n var columns = this.columns;\n for (var idx = 0; idx < columns.length; idx++) {\n if (columns[idx].footerTemplate) {\n return true;\n }\n }\n },\n\n _hierarchyFooter: function(aggregates, level, depth) {\n var cells = this.columns.map(function(column, index) {\n var colSpan = index ? 1 : depth - level + 1;\n if (column.footerTemplate) {\n var fieldAggregates = (aggregates || {})[column.field];\n return $.extend({\n background: \"#dfdfdf\",\n color: \"#333\",\n colSpan: colSpan,\n value: column.footerTemplate($.extend({ aggregates: aggregates }, fieldAggregates))\n }, column.footerCellOptions);\n }\n\n return $.extend({\n background: \"#dfdfdf\",\n color: \"#333\",\n colSpan: colSpan\n }, column.footerCellOptions);\n });\n\n return {\n type: \"footer\",\n cells: this._createPaddingCells(level).concat(cells),\n level: this.collapsible ? level : null\n };\n },\n\n _footer: function(dataItem, level) {\n var rows = [];\n var footer = this.columns.some(function (column) { return column.groupFooterTemplate; });\n\n var templateData, group;\n if (footer) {\n group = {\n group: { items: dataItem.items,\n field: dataItem.field,\n value: dataItem.value }\n };\n templateData = {};\n Object.keys(dataItem.aggregates).forEach(function (key) {\n templateData[key] = $.extend({}, dataItem.aggregates[key], group);\n });\n }\n\n var cells = this.columns.map(function (column) {\n if (column.groupFooterTemplate) {\n var data = $.extend({}, templateData, dataItem.aggregates[column.field], group);\n return $.extend({\n background: \"#dfdfdf\",\n color: \"#333\",\n value: column.groupFooterTemplate(data)\n }, column.groupFooterCellOptions);\n }\n\n return $.extend({\n background: \"#dfdfdf\",\n color: \"#333\"\n }, column.groupFooterCellOptions);\n });\n\n if (footer) {\n rows.push({\n type: \"group-footer\",\n cells: this._createPaddingCells(this.groups.length).concat(cells),\n level: this.collapsible ? level : null\n });\n }\n\n return rows;\n },\n\n _isColumnVisible: function(column) {\n return this._visibleColumns([ column ]).length > 0 && (column.field || column.columns);\n },\n\n _visibleColumns: function(columns) {\n var this$1 = this;\n\n return columns.filter(function (column) {\n var exportable = column.exportable;\n if (typeof exportable === 'object') {\n exportable = column.exportable.excel;\n }\n\n var visibleInExport = !column.hidden && exportable !== false;\n var visibleInExportOnly = column.hidden && exportable === true;\n var visible = visibleInExport || visibleInExportOnly;\n if (visible && column.columns) {\n visible = this$1._visibleColumns(column.columns).length > 0;\n }\n return visible;\n });\n },\n\n _headerRow: function(row, groups) {\n var this$1 = this;\n\n var headers = row.cells.map(function(cell) {\n return $.extend(cell, {\n colSpan: cell.colSpan > 1 ? cell.colSpan : 1,\n rowSpan: row.rowSpan > 1 && !cell.colSpan ? row.rowSpan : 1\n });\n });\n\n if (this.hierarchy && headers[0].firstCell) {\n headers[0].colSpan += this._depth();\n }\n\n return {\n type: \"header\",\n cells: createArray(groups.length, function () { return $.extend({\n background: \"#7a7a7a\",\n color: \"#fff\"\n }, this$1.options.headerPaddingCellOptions); }).concat(headers)\n };\n },\n\n _prependHeaderRows: function(rows) {\n var this$1 = this;\n\n var groups = this.groups;\n\n var headerRows = [ { rowSpan: 1, cells: [], index: 0 } ];\n\n this._prepareHeaderRows(headerRows, this.options.columns);\n\n for (var idx = headerRows.length - 1; idx >= 0; idx--) {\n rows.unshift(this$1._headerRow(headerRows[idx], groups));\n }\n },\n\n _prepareHeaderRows: function(rows, columns, parentCell, parentRow) {\n var this$1 = this;\n\n var row = parentRow || rows[rows.length - 1];\n var childRow = rows[row.index + 1];\n var totalColSpan = 0;\n\n for (var idx = 0; idx < columns.length; idx++) {\n var column = columns[idx];\n if (this$1._isColumnVisible(column)) {\n\n var cell = $.extend({\n background: \"#7a7a7a\",\n color: \"#fff\",\n value: column.title || column.field,\n colSpan: 0,\n firstCell: idx === 0 && (!parentCell || parentCell.firstCell)\n }, column.headerCellOptions);\n row.cells.push(cell);\n\n if (column.columns && column.columns.length) {\n if (!childRow) {\n childRow = { rowSpan: 0, cells: [], index: rows.length };\n rows.push(childRow);\n }\n cell.colSpan = this$1._trimColumns(this$1._visibleColumns(column.columns)).length;\n this$1._prepareHeaderRows(rows, column.columns, cell, childRow);\n totalColSpan += cell.colSpan - 1;\n row.rowSpan = rows.length - row.index;\n }\n }\n }\n\n if (parentCell) {\n parentCell.colSpan += totalColSpan;\n }\n },\n\n _rows: function() {\n var this$1 = this;\n\n var rows = this._dataRows(this.data, 0);\n\n if (this.columns.length) {\n this._prependHeaderRows(rows);\n var footer = false;\n\n var cells = this.columns.map(function (column) {\n if (column.footerTemplate) {\n footer = true;\n\n return $.extend({\n background: \"#dfdfdf\",\n color: \"#333\",\n value: column.footerTemplate($.extend({}, this$1.aggregates, this$1.aggregates[column.field]))\n }, column.footerCellOptions);\n }\n\n return $.extend({\n background: \"#dfdfdf\",\n color: \"#333\"\n }, column.footerCellOptions);\n });\n\n if (footer) {\n rows.push({\n type: \"footer\",\n cells: this._createPaddingCells(this.groups.length).concat(cells)\n });\n }\n }\n\n return rows;\n },\n\n _headerDepth: function(columns) {\n var this$1 = this;\n\n var result = 1;\n var max = 0;\n\n for (var idx = 0; idx < columns.length; idx++) {\n if (columns[idx].columns) {\n var temp = this$1._headerDepth(columns[idx].columns);\n if (temp > max) {\n max = temp;\n }\n }\n }\n return result + max;\n },\n\n _freezePane: function() {\n var columns = this._visibleColumns(this.options.columns || []);\n\n var colSplit = this._visibleColumns(this._trimColumns(this._leafColumns(columns.filter(function(column) {\n return column.locked;\n })))).length;\n\n return {\n rowSplit: this._headerDepth(columns),\n colSplit: colSplit ? colSplit + this.groups.length : 0\n };\n },\n\n _cell: function(dataItem, column) {\n return $.extend({\n value: column.value(dataItem)\n }, column.cellOptions);\n },\n\n _depth: function() {\n var depth = 0;\n\n if (this.hierarchy) {\n depth = this.hierarchy.depth;\n } else {\n depth = this.groups.length;\n }\n\n return depth;\n },\n\n _columns: function() {\n var depth = this._depth();\n var columns = createArray(depth, function () { return ({ width: 20 }); });\n\n return columns.concat(this.columns.map(function(column) {\n return {\n width: parseInt(column.width, 10),\n autoWidth: column.width ? false : true\n };\n }));\n }\n});\n\nkendo.deepExtend(kendo.excel, {\n ExcelExporter: ExcelExporter,\n TemplateService: TemplateService\n});\n\n})(window.kendo.jQuery);\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n(function(f, define){\n define('excel/main',[ \"../kendo.core\", \"../kendo.data\", \"./kendo-excel\" ], f);\n})(function(){\n\n(function($, kendo){\n\n var ExcelExporter = kendo.excel.ExcelExporter;\n\n var extend = $.extend;\n\n kendo.excel.TemplateService.register({\n compile: kendo.template\n });\n\n kendo.ExcelExporter = kendo.Class.extend({\n init: function(options) {\n this.options = options;\n var dataSource = options.dataSource;\n\n if (dataSource instanceof kendo.data.DataSource) {\n\n if (!dataSource.filter()) {\n dataSource.options.filter = undefined;\n }\n\n this.dataSource = new dataSource.constructor(extend(\n {},\n dataSource.options,\n {\n page: options.allPages ? 0 : dataSource.page(),\n filter: dataSource.filter(),\n pageSize: options.allPages ? dataSource.total() : dataSource.pageSize() || dataSource.total(),\n sort: dataSource.sort(),\n group: dataSource.group(),\n aggregate: dataSource.aggregate()\n }));\n\n var data = dataSource.data();\n\n if (data.length > 0) {\n if (options.hierarchy) {\n for (var i = 0; i < data.length; i++) {\n if (data[i].expanded === false || data[i].expanded === undefined) {\n data[i].expanded = true;\n }\n }\n }\n // Avoid toJSON() for perf and avoid data() to prevent reparenting.\n this.dataSource._data = data;\n\n var transport = this.dataSource.transport;\n if (dataSource._isServerGrouped() && transport.options && transport.options.data) { // clear the transport data when using aspnet-mvc transport\n transport.options.data = null;\n }\n }\n\n } else {\n this.dataSource = kendo.data.DataSource.create(dataSource);\n }\n },\n\n _hierarchy: function() {\n var hierarchy = this.options.hierarchy;\n var dataSource = this.dataSource;\n\n if (hierarchy && dataSource.level) {\n hierarchy = {\n itemLevel: function(item) {\n return dataSource.level(item);\n }\n };\n\n var view = dataSource.view();\n var depth = 0;\n var level;\n\n for (var idx = 0; idx < view.length; idx++) {\n level = dataSource.level(view[idx]);\n\n if (level > depth) {\n depth = level;\n }\n }\n\n hierarchy.depth = depth + 1;\n } else {\n hierarchy = false;\n }\n\n return {\n hierarchy: hierarchy\n };\n },\n\n workbook: function() {\n return $.Deferred($.proxy(function(d) {\n this.dataSource.fetch()\n .then($.proxy(function() {\n\n var workbook = new ExcelExporter(extend({}, this.options, this._hierarchy(), {\n data: this.dataSource.view(),\n groups: this.dataSource.group(),\n aggregates: this.dataSource.aggregates()\n })).workbook();\n\n d.resolve(workbook, this.dataSource.view());\n }, this));\n }, this)).promise();\n }\n });\n\n\n})(kendo.jQuery, kendo);\n\nreturn kendo;\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n\n(function(f, define){\n define('excel/mixins',[ \"./main\", \"../kendo.ooxml\" ], f);\n})(function(){\n\n(function($, kendo){\n\n\nkendo.ExcelMixin = {\n extend: function(proto) {\n proto.events.push(\"excelExport\");\n proto.options.excel = $.extend(proto.options.excel, this.options);\n proto.saveAsExcel = this.saveAsExcel;\n },\n options: {\n proxyURL: \"\",\n allPages: false,\n filterable: false,\n fileName: \"Export.xlsx\",\n collapsible: false\n },\n saveAsExcel: function() {\n var excel = this.options.excel || {};\n\n var exporter = new kendo.ExcelExporter({\n columns: this.columns,\n dataSource: this.dataSource,\n allPages: excel.allPages,\n filterable: excel.filterable,\n hierarchy: excel.hierarchy,\n collapsible: excel.collapsible\n });\n\n exporter.workbook().then($.proxy(function(book, data) {\n if (!this.trigger(\"excelExport\", { workbook: book, data: data })) {\n var workbook = new kendo.ooxml.Workbook(book);\n\n if(!workbook.options) {\n workbook.options = {};\n }\n workbook.options.skipCustomHeight = true;\n\n workbook.toDataURLAsync().then(function(dataURI) {\n kendo.saveAs({\n dataURI: dataURI,\n fileName: book.fileName || excel.fileName,\n proxyURL: excel.proxyURL,\n forceProxy: excel.forceProxy\n });\n });\n\n }\n }, this));\n }\n};\n\n})(kendo.jQuery, kendo);\n\nreturn kendo;\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n\n(function(f, define){\r\n define('kendo.excel',[ \"./excel/main\", \"./excel/mixins\" ], f);\r\n})(function(){\r\n\r\nvar __meta__ = { // jshint ignore:line\r\n id: \"excel\",\r\n name: \"Excel export\",\r\n category: \"framework\",\r\n advanced: true,\r\n mixin: true,\r\n depends: [ \"data\", \"ooxml\" ]\r\n};\r\n\r\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\r\n\n(function(f, define){\r\n define('kendo.data.signalr',[ \"./kendo.data\" ], f);\r\n})(function(){\r\n\r\nvar __meta__ = { // jshint ignore:line\r\n id: \"data.signalr\",\r\n name: \"SignalR\",\r\n category: \"framework\",\r\n depends: [ \"data\" ],\r\n hidden: true\r\n};\r\n\r\n(function($) {\r\n var kendo = window.kendo;\r\n var isFunction = kendo.isFunction;\r\n\r\n function isJQueryPromise(promise) {\r\n return promise && isFunction(promise.done) && isFunction(promise.fail);\r\n }\r\n\r\n function isNativePromise(promise) {\r\n return promise && isFunction(promise.then) && isFunction(promise.catch); // jshint ignore:line\r\n }\r\n\r\n var transport = kendo.data.RemoteTransport.extend({\r\n init: function (options) {\r\n var signalr = options && options.signalr ? options.signalr : {};\r\n\r\n var promise = signalr.promise;\r\n\r\n if (!promise) {\r\n throw new Error('The \"promise\" option must be set.');\r\n }\r\n\r\n if (!isJQueryPromise(promise) && !isNativePromise(promise)) {\r\n throw new Error('The \"promise\" option must be a Promise.');\r\n }\r\n\r\n this.promise = promise;\r\n\r\n var hub = signalr.hub;\r\n\r\n if (!hub) {\r\n throw new Error('The \"hub\" option must be set.');\r\n }\r\n\r\n if (typeof hub.on != \"function\" || typeof hub.invoke != \"function\") {\r\n throw new Error('The \"hub\" option is not a valid SignalR hub proxy.');\r\n }\r\n\r\n this.hub = hub;\r\n\r\n kendo.data.RemoteTransport.fn.init.call(this, options);\r\n },\r\n\r\n push: function(callbacks) {\r\n var client = this.options.signalr.client || {};\r\n\r\n if (client.create) {\r\n this.hub.on(client.create, callbacks.pushCreate);\r\n }\r\n\r\n if (client.update) {\r\n this.hub.on(client.update, callbacks.pushUpdate);\r\n }\r\n\r\n if (client.destroy) {\r\n this.hub.on(client.destroy, callbacks.pushDestroy);\r\n }\r\n },\r\n\r\n _crud: function(options, type) {\r\n var hub = this.hub;\r\n var promise = this.promise;\r\n var server = this.options.signalr.server;\r\n\r\n if (!server || !server[type]) {\r\n throw new Error(kendo.format('The \"server.{0}\" option must be set.', type));\r\n }\r\n\r\n var args = [server[type]];\r\n\r\n var data = this.parameterMap(options.data, type);\r\n\r\n if (!$.isEmptyObject(data)) {\r\n args.push(data);\r\n }\r\n\r\n if (isJQueryPromise(promise)) {\r\n promise.done(function() {\r\n hub.invoke.apply(hub, args)\r\n .done(options.success)\r\n .fail(options.error);\r\n });\r\n } else if (isNativePromise(promise)) {\r\n promise.then(function() {\r\n hub.invoke.apply(hub, args)\r\n .then(options.success)\r\n .catch(options.error); // jshint ignore:line\r\n });\r\n }\r\n },\r\n\r\n read: function(options) {\r\n this._crud(options, \"read\");\r\n },\r\n\r\n create: function(options) {\r\n this._crud(options, \"create\");\r\n },\r\n\r\n update: function(options) {\r\n this._crud(options, \"update\");\r\n },\r\n\r\n destroy: function(options) {\r\n this._crud(options, \"destroy\");\r\n }\r\n });\r\n\r\n $.extend(true, kendo.data, {\r\n transports: {\r\n signalr: transport\r\n }\r\n });\r\n\r\n})(window.kendo.jQuery);\r\n\r\nreturn window.kendo;\r\n\r\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\r\n\n(function(f, define){\n define('drawing/util',['../kendo.core'], f);\n})(function(){\n\n(function($) {\n\n /* jshint proto: true */\n\n function createPromise() {\n return $.Deferred();\n }\n\n function promiseAll(promises) {\n return $.when.apply($, promises);\n }\n\n function extendStatic(dest, src) {\n if (!src) {\n return;\n }\n\n if (typeof src.__proto__ === 'function') {\n dest.__proto__ = src;\n } else {\n for (var member in src) {\n if (src.hasOwnProperty(member)) {\n dest[member] = src[member];\n }\n }\n }\n }\n\n kendo.drawing.util = kendo.drawing.util || {};\n kendo.deepExtend(kendo.drawing.util, {\n createPromise: createPromise,\n promiseAll: promiseAll,\n extendStatic: extendStatic\n });\n\n})(window.kendo.jQuery);\n\nreturn window.kendo;\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n/***********************************************************************\n * WARNING: this file is auto-generated. If you change it directly,\n * your modifications will eventually be lost. The source code is in\n * `kendo-drawing` repository, you should make your changes there and\n * run `src-modules/sync.sh` in this repository.\n */\n(function(f, define){\n define('kendo.color',[ \"./kendo.core\" ], f);\n})(function(){\n\n var __meta__ = { // jshint ignore:line\n id: \"color\",\n name: \"Color utils\",\n category: \"framework\",\n advanced: true,\n description: \"Color utilities used across components\",\n depends: [ \"core\" ]\n };\n\n/*jshint eqnull:true */\n\nwindow.kendo = window.kendo || {};\n\nvar Class = kendo.Class;\nvar support = kendo.support;\n\nvar namedColors = {\n aliceblue: \"f0f8ff\", antiquewhite: \"faebd7\", aqua: \"00ffff\",\n aquamarine: \"7fffd4\", azure: \"f0ffff\", beige: \"f5f5dc\",\n bisque: \"ffe4c4\", black: \"000000\", blanchedalmond: \"ffebcd\",\n blue: \"0000ff\", blueviolet: \"8a2be2\", brown: \"a52a2a\",\n burlywood: \"deb887\", cadetblue: \"5f9ea0\", chartreuse: \"7fff00\",\n chocolate: \"d2691e\", coral: \"ff7f50\", cornflowerblue: \"6495ed\",\n cornsilk: \"fff8dc\", crimson: \"dc143c\", cyan: \"00ffff\",\n darkblue: \"00008b\", darkcyan: \"008b8b\", darkgoldenrod: \"b8860b\",\n darkgray: \"a9a9a9\", darkgrey: \"a9a9a9\", darkgreen: \"006400\",\n darkkhaki: \"bdb76b\", darkmagenta: \"8b008b\", darkolivegreen: \"556b2f\",\n darkorange: \"ff8c00\", darkorchid: \"9932cc\", darkred: \"8b0000\",\n darksalmon: \"e9967a\", darkseagreen: \"8fbc8f\", darkslateblue: \"483d8b\",\n darkslategray: \"2f4f4f\", darkslategrey: \"2f4f4f\", darkturquoise: \"00ced1\",\n darkviolet: \"9400d3\", deeppink: \"ff1493\", deepskyblue: \"00bfff\",\n dimgray: \"696969\", dimgrey: \"696969\", dodgerblue: \"1e90ff\",\n firebrick: \"b22222\", floralwhite: \"fffaf0\", forestgreen: \"228b22\",\n fuchsia: \"ff00ff\", gainsboro: \"dcdcdc\", ghostwhite: \"f8f8ff\",\n gold: \"ffd700\", goldenrod: \"daa520\", gray: \"808080\",\n grey: \"808080\", green: \"008000\", greenyellow: \"adff2f\",\n honeydew: \"f0fff0\", hotpink: \"ff69b4\", indianred: \"cd5c5c\",\n indigo: \"4b0082\", ivory: \"fffff0\", khaki: \"f0e68c\",\n lavender: \"e6e6fa\", lavenderblush: \"fff0f5\", lawngreen: \"7cfc00\",\n lemonchiffon: \"fffacd\", lightblue: \"add8e6\", lightcoral: \"f08080\",\n lightcyan: \"e0ffff\", lightgoldenrodyellow: \"fafad2\", lightgray: \"d3d3d3\",\n lightgrey: \"d3d3d3\", lightgreen: \"90ee90\", lightpink: \"ffb6c1\",\n lightsalmon: \"ffa07a\", lightseagreen: \"20b2aa\", lightskyblue: \"87cefa\",\n lightslategray: \"778899\", lightslategrey: \"778899\", lightsteelblue: \"b0c4de\",\n lightyellow: \"ffffe0\", lime: \"00ff00\", limegreen: \"32cd32\",\n linen: \"faf0e6\", magenta: \"ff00ff\", maroon: \"800000\",\n mediumaquamarine: \"66cdaa\", mediumblue: \"0000cd\", mediumorchid: \"ba55d3\",\n mediumpurple: \"9370d8\", mediumseagreen: \"3cb371\", mediumslateblue: \"7b68ee\",\n mediumspringgreen: \"00fa9a\", mediumturquoise: \"48d1cc\", mediumvioletred: \"c71585\",\n midnightblue: \"191970\", mintcream: \"f5fffa\", mistyrose: \"ffe4e1\",\n moccasin: \"ffe4b5\", navajowhite: \"ffdead\", navy: \"000080\",\n oldlace: \"fdf5e6\", olive: \"808000\", olivedrab: \"6b8e23\",\n orange: \"ffa500\", orangered: \"ff4500\", orchid: \"da70d6\",\n palegoldenrod: \"eee8aa\", palegreen: \"98fb98\", paleturquoise: \"afeeee\",\n palevioletred: \"d87093\", papayawhip: \"ffefd5\", peachpuff: \"ffdab9\",\n peru: \"cd853f\", pink: \"ffc0cb\", plum: \"dda0dd\",\n powderblue: \"b0e0e6\", purple: \"800080\", red: \"ff0000\",\n rosybrown: \"bc8f8f\", royalblue: \"4169e1\", saddlebrown: \"8b4513\",\n salmon: \"fa8072\", sandybrown: \"f4a460\", seagreen: \"2e8b57\",\n seashell: \"fff5ee\", sienna: \"a0522d\", silver: \"c0c0c0\",\n skyblue: \"87ceeb\", slateblue: \"6a5acd\", slategray: \"708090\",\n slategrey: \"708090\", snow: \"fffafa\", springgreen: \"00ff7f\",\n steelblue: \"4682b4\", tan: \"d2b48c\", teal: \"008080\",\n thistle: \"d8bfd8\", tomato: \"ff6347\", turquoise: \"40e0d0\",\n violet: \"ee82ee\", wheat: \"f5deb3\", white: \"ffffff\",\n whitesmoke: \"f5f5f5\", yellow: \"ffff00\", yellowgreen: \"9acd32\"\n};\n\nvar browser = support.browser;\n\nvar matchNamedColor = function (color) {\n var colorNames = Object.keys(namedColors);\n colorNames.push(\"transparent\");\n\n var regexp = new RegExp(\"^(\" + colorNames.join(\"|\") + \")(\\\\W|$)\", \"i\");\n matchNamedColor = function (color) { return regexp.exec(color); };\n\n return regexp.exec(color);\n};\n\nvar BaseColor = Class.extend({\n init: function() { },\n\n toHSV: function() { return this; },\n\n toRGB: function() { return this; },\n\n toHex: function(options) { return this.toBytes().toHex(options); },\n\n toBytes: function() { return this; },\n\n toCss: function(options) { return \"#\" + this.toHex(options); },\n\n toCssRgba: function() {\n var rgb = this.toBytes();\n return (\"rgba(\" + (rgb.r) + \", \" + (rgb.g) + \", \" + (rgb.b) + \", \" + (parseFloat((Number(this.a)).toFixed(3))) + \")\");\n },\n\n toDisplay: function() {\n if (browser.msie && browser.version < 9) {\n return this.toCss(); // no RGBA support; does it support any opacity in colors?\n }\n return this.toCssRgba();\n },\n\n equals: function(c) {\n return c === this || c !== null && this.toCssRgba() === parseColor(c).toCssRgba();\n },\n\n diff: function(other) {\n if (other === null) {\n return NaN;\n }\n\n var c1 = this.toBytes();\n var c2 = other.toBytes();\n\n return Math.sqrt(Math.pow((c1.r - c2.r) * 0.30, 2) +\n Math.pow((c1.g - c2.g) * 0.59, 2) +\n Math.pow((c1.b - c2.b) * 0.11, 2));\n },\n\n clone: function() {\n var c = this.toBytes();\n if (c === this) {\n c = new Bytes(c.r, c.g, c.b, c.a);\n }\n\n return c;\n }\n});\n\nvar RGB = BaseColor.extend({\n init: function(r, g, b, a) {\n BaseColor.fn.init.call(this);\n\n this.r = r;\n this.g = g;\n this.b = b;\n this.a = a;\n },\n\n toHSV: function() {\n var ref = this;\n var r = ref.r;\n var g = ref.g;\n var b = ref.b;\n var min = Math.min(r, g, b);\n var max = Math.max(r, g, b);\n var delta = max - min;\n var v = max;\n var h, s;\n\n if (delta === 0) {\n return new HSV(0, 0, v, this.a);\n }\n\n if (max !== 0) {\n s = delta / max;\n if (r === max) {\n h = (g - b) / delta;\n } else if (g === max) {\n h = 2 + (b - r) / delta;\n } else {\n h = 4 + (r - g) / delta;\n }\n\n h *= 60;\n if (h < 0) {\n h += 360;\n }\n } else {\n s = 0;\n h = -1;\n }\n\n return new HSV(h, s, v, this.a);\n },\n\n toHSL: function() {\n var ref = this;\n var r = ref.r;\n var g = ref.g;\n var b = ref.b;\n var max = Math.max(r, g, b);\n var min = Math.min(r, g, b);\n var h, s, l = (max + min) / 2;\n\n if (max === min) {\n h = s = 0;\n } else {\n var d = max - min;\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n switch (max) {\n case r: h = (g - b) / d + (g < b ? 6 : 0); break;\n case g: h = (b - r) / d + 2; break;\n case b: h = (r - g) / d + 4; break;\n default: break;\n }\n }\n\n return new HSL(h * 60, s * 100, l * 100, this.a);\n },\n\n toBytes: function() {\n return new Bytes(this.r * 255, this.g * 255, this.b * 255, this.a);\n }\n});\n\nvar Bytes = RGB.extend({\n init: function(r, g, b, a) {\n RGB.fn.init.call(this, Math.round(r), Math.round(g), Math.round(b), a);\n },\n\n toRGB: function() {\n return new RGB(this.r / 255, this.g / 255, this.b / 255, this.a);\n },\n\n toHSV: function() {\n return this.toRGB().toHSV();\n },\n\n toHSL: function() {\n return this.toRGB().toHSL();\n },\n\n toHex: function(options) {\n var value = hex(this.r, 2) + hex(this.g, 2) + hex(this.b, 2);\n\n if (options && options.alpha) {\n value += hex(Math.round(this.a * 255), 2);\n }\n\n return value;\n },\n\n toBytes: function() {\n return this;\n }\n});\n\nfunction hex(n, width, pad) {\n if (pad === void 0) { pad = \"0\"; }\n\n var result = n.toString(16);\n while (width > result.length) {\n result = pad + result;\n }\n\n return result;\n}\n\nvar HSV = BaseColor.extend({\n init: function(h, s, v, a) {\n BaseColor.fn.init.call(this);\n\n this.h = h;\n this.s = s;\n this.v = v;\n this.a = a;\n },\n\n toRGB: function() {\n var ref = this;\n var h = ref.h;\n var s = ref.s;\n var v = ref.v;\n var r, g, b;\n\n if (s === 0) {\n r = g = b = v;\n } else {\n h /= 60;\n\n var i = Math.floor(h);\n var f = h - i;\n var p = v * (1 - s);\n var q = v * (1 - s * f);\n var t = v * (1 - s * (1 - f));\n\n switch (i) {\n case 0: r = v; g = t; b = p; break;\n case 1: r = q; g = v; b = p; break;\n case 2: r = p; g = v; b = t; break;\n case 3: r = p; g = q; b = v; break;\n case 4: r = t; g = p; b = v; break;\n default: r = v; g = p; b = q; break;\n }\n }\n\n return new RGB(r, g, b, this.a);\n },\n\n toHSL: function() {\n return this.toRGB().toHSL();\n },\n\n toBytes: function() {\n return this.toRGB().toBytes();\n }\n});\n\nvar HSL = BaseColor.extend({\n init: function(h, s, l, a) {\n BaseColor.fn.init.call(this);\n\n this.h = h;\n this.s = s;\n this.l = l;\n this.a = a;\n },\n\n toRGB: function() {\n var h = this.h / 360;\n var s = this.s / 100;\n var l = this.l / 100;\n var r, g, b;\n\n if (s === 0) {\n r = g = b = l; // achromatic\n } else {\n var q = l < 0.5 ? l * (1 + s) : l + s - l * s;\n var p = 2 * l - q;\n r = hue2rgb(p, q, h + 1 / 3);\n g = hue2rgb(p, q, h);\n b = hue2rgb(p, q, h - 1 / 3);\n }\n\n return new RGB(r, g, b, this.a);\n },\n\n toHSV: function() {\n return this.toRGB().toHSV();\n },\n\n toBytes: function() {\n return this.toRGB().toBytes();\n }\n});\n\nfunction hue2rgb(p, q, s) {\n var t = s;\n\n if (t < 0) {\n t += 1;\n }\n\n if (t > 1) {\n t -= 1;\n }\n\n if (t < 1 / 6) {\n return p + (q - p) * 6 * t;\n }\n\n if (t < 1 / 2) {\n return q;\n }\n\n if (t < 2 / 3) {\n return p + (q - p) * (2 / 3 - t) * 6;\n }\n\n return p;\n}\n\nfunction alphaFromHex(a) {\n return parseFloat(parseFloat(parseInt(a, 16) / 255 ).toFixed(3));\n}\n\nfunction parseColor(value, safe) {\n var m, ret;\n\n if (value == null || value === \"none\") {\n return null;\n }\n\n if (value instanceof BaseColor) {\n return value;\n }\n\n var color = value.toLowerCase();\n if ((m = matchNamedColor(color))) {\n if (m[1] === \"transparent\") {\n color = new RGB(1, 1, 1, 0);\n } else {\n color = parseColor(namedColors[m[1]], safe);\n }\n color.match = [ m[1] ];\n return color;\n }\n if ((m = /^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})\\b/i.exec(color))) {\n ret = new Bytes(parseInt(m[1], 16),\n parseInt(m[2], 16),\n parseInt(m[3], 16), 1);\n } else if ((m = /^#?([0-9a-f])([0-9a-f])([0-9a-f])\\b/i.exec(color))) {\n ret = new Bytes(parseInt(m[1] + m[1], 16),\n parseInt(m[2] + m[2], 16),\n parseInt(m[3] + m[3], 16), 1);\n } else if ((m = /^#?([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])\\b/i.exec(color))) { // Parse 4 digit hex color\n ret = new Bytes(parseInt(m[1] + m[1], 16),\n parseInt(m[2] + m[2], 16),\n parseInt(m[3] + m[3], 16),\n alphaFromHex(m[4] + m[4]));\n } else if ((m = /^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})\\b/i.exec(color))) { // Parse 8 digit hex color\n ret = new Bytes(parseInt(m[1], 16),\n parseInt(m[2], 16),\n parseInt(m[3], 16),\n alphaFromHex(m[4]));\n } else if ((m = /^rgb\\(\\s*([0-9]+)\\s*,\\s*([0-9]+)\\s*,\\s*([0-9]+)\\s*\\)/.exec(color))) {\n ret = new Bytes(parseInt(m[1], 10),\n parseInt(m[2], 10),\n parseInt(m[3], 10), 1);\n } else if ((m = /^rgba\\(\\s*([0-9]+)\\s*,\\s*([0-9]+)\\s*,\\s*([0-9]+)\\s*,\\s*([0-9.]+)\\s*\\)/.exec(color))) {\n ret = new Bytes(parseInt(m[1], 10),\n parseInt(m[2], 10),\n parseInt(m[3], 10), parseFloat(m[4]));\n } else if ((m = /^rgb\\(\\s*([0-9]*\\.?[0-9]+)%\\s*,\\s*([0-9]*\\.?[0-9]+)%\\s*,\\s*([0-9]*\\.?[0-9]+)%\\s*\\)/.exec(color))) {\n ret = new RGB(parseFloat(m[1]) / 100,\n parseFloat(m[2]) / 100,\n parseFloat(m[3]) / 100, 1);\n } else if ((m = /^rgba\\(\\s*([0-9]*\\.?[0-9]+)%\\s*,\\s*([0-9]*\\.?[0-9]+)%\\s*,\\s*([0-9]*\\.?[0-9]+)%\\s*,\\s*([0-9.]+)\\s*\\)/.exec(color))) {\n ret = new RGB(parseFloat(m[1]) / 100,\n parseFloat(m[2]) / 100,\n parseFloat(m[3]) / 100, parseFloat(m[4]));\n }\n\n if (ret) {\n ret.match = m;\n } else if (!safe) {\n throw new Error(\"Cannot parse color: \" + color);\n }\n\n return ret;\n}\n\nvar DARK_TRESHOLD = 180;\n\nvar Color = Class.extend({\n init: function(value) {\n var this$1 = this;\n\n if (arguments.length === 1) {\n var formats = Color.formats;\n var resolvedColor = this.resolveColor(value);\n\n for (var idx = 0; idx < formats.length; idx++) {\n var formatRegex = formats[idx].re;\n var processor = formats[idx].process;\n var parts = formatRegex.exec(resolvedColor);\n\n if (parts) {\n var channels = processor(parts);\n this$1.r = channels[0];\n this$1.g = channels[1];\n this$1.b = channels[2];\n }\n }\n } else {\n this.r = arguments[0];\n this.g = arguments[1];\n this.b = arguments[2];\n }\n\n this.r = this.normalizeByte(this.r);\n this.g = this.normalizeByte(this.g);\n this.b = this.normalizeByte(this.b);\n },\n\n toHex: function() {\n var pad = this.padDigit;\n var r = this.r.toString(16);\n var g = this.g.toString(16);\n var b = this.b.toString(16);\n\n return \"#\" + pad(r) + pad(g) + pad(b);\n },\n\n resolveColor: function(value) {\n var color = value || \"black\";\n\n if (color.charAt(0) === \"#\") {\n color = color.substr(1, 6);\n }\n\n color = color.replace(/ /g, \"\");\n color = color.toLowerCase();\n color = Color.namedColors[color] || color;\n\n return color;\n },\n\n normalizeByte: function(value) {\n if (value < 0 || isNaN(value)) {\n return 0;\n }\n\n return value > 255 ? 255 : value;\n },\n\n padDigit: function(value) {\n return (value.length === 1) ? \"0\" + value : value;\n },\n\n brightness: function(value) {\n var round = Math.round;\n\n this.r = round(this.normalizeByte(this.r * value));\n this.g = round(this.normalizeByte(this.g * value));\n this.b = round(this.normalizeByte(this.b * value));\n\n return this;\n },\n\n percBrightness: function() {\n return Math.sqrt(0.241 * this.r * this.r + 0.691 * this.g * this.g + 0.068 * this.b * this.b);\n },\n\n isDark: function() {\n return this.percBrightness() < DARK_TRESHOLD;\n }\n});\n\nColor.fromBytes = function(r, g, b, a) {\n return new Bytes(r, g, b, a != null ? a : 1);\n};\n\nColor.fromRGB = function(r, g, b, a) {\n return new RGB(r, g, b, a != null ? a : 1);\n};\n\nColor.fromHSV = function(h, s, v, a) {\n return new HSV(h, s, v, a != null ? a : 1);\n};\n\nColor.fromHSL = function(h, s, l, a) {\n return new HSL(h, s, l, a != null ? a : 1);\n};\n\nColor.formats = [ {\n re: /^rgb\\((\\d{1,3}),\\s*(\\d{1,3}),\\s*(\\d{1,3})\\)$/,\n process: function(parts) {\n return [\n parseInt(parts[1], 10), parseInt(parts[2], 10), parseInt(parts[3], 10)\n ];\n }\n}, {\n re: /^(\\w{2})(\\w{2})(\\w{2})$/,\n process: function(parts) {\n return [\n parseInt(parts[1], 16), parseInt(parts[2], 16), parseInt(parts[3], 16)\n ];\n }\n}, {\n re: /^(\\w{1})(\\w{1})(\\w{1})$/,\n process: function(parts) {\n return [\n parseInt(parts[1] + parts[1], 16),\n parseInt(parts[2] + parts[2], 16),\n parseInt(parts[3] + parts[3], 16)\n ];\n }\n} ];\n\nColor.namedColors = namedColors;\n\nkendo.deepExtend(kendo, {\n parseColor: parseColor,\n namedColors: namedColors,\n Color: Color\n});\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n/***********************************************************************\n * WARNING: this file is auto-generated. If you change it directly,\n * your modifications will eventually be lost. The source code is in\n * `kendo-drawing` repository, you should make your changes there and\n * run `src-modules/sync.sh` in this repository.\n */\n(function(f, define){\n define('util/text-metrics',[\n \"../kendo.core\"\n ], f);\n})(function(){\n\n(function ($) {\n\nwindow.kendo.util = window.kendo.util || {};\n\nvar LRUCache = kendo.Class.extend({\n init: function(size) {\n\n this._size = size;\n this._length = 0;\n this._map = {};\n },\n\n put: function(key, value) {\n var map = this._map;\n var entry = { key: key, value: value };\n\n map[key] = entry;\n\n if (!this._head) {\n this._head = this._tail = entry;\n } else {\n this._tail.newer = entry;\n entry.older = this._tail;\n this._tail = entry;\n }\n\n if (this._length >= this._size) {\n map[this._head.key] = null;\n this._head = this._head.newer;\n this._head.older = null;\n } else {\n this._length++;\n }\n },\n\n get: function(key) {\n var entry = this._map[key];\n\n if (entry) {\n if (entry === this._head && entry !== this._tail) {\n this._head = entry.newer;\n this._head.older = null;\n }\n\n if (entry !== this._tail) {\n if (entry.older) {\n entry.older.newer = entry.newer;\n entry.newer.older = entry.older;\n }\n\n entry.older = this._tail;\n entry.newer = null;\n\n this._tail.newer = entry;\n this._tail = entry;\n }\n\n return entry.value;\n }\n }\n});\n\nvar REPLACE_REGEX = /\\r?\\n|\\r|\\t/g;\nvar SPACE = ' ';\n\nfunction normalizeText(text) {\n return String(text).replace(REPLACE_REGEX, SPACE);\n}\n\nfunction objectKey(object) {\n var parts = [];\n for (var key in object) {\n parts.push(key + object[key]);\n }\n\n return parts.sort().join(\"\");\n}\n\n// Computes FNV-1 hash\n// See http://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function\nfunction hashKey(str) {\n // 32-bit FNV-1 offset basis\n // See http://isthe.com/chongo/tech/comp/fnv/#FNV-param\n var hash = 0x811C9DC5;\n\n for (var i = 0; i < str.length; ++i) {\n hash += (hash << 1) + (hash << 4) + (hash << 7) + (hash << 8) + (hash << 24);\n hash ^= str.charCodeAt(i);\n }\n\n return hash >>> 0;\n}\n\nfunction zeroSize() {\n return { width: 0, height: 0, baseline: 0 };\n}\n\nvar DEFAULT_OPTIONS = {\n baselineMarkerSize: 1\n};\n\nvar defaultMeasureBox;\n\nif (typeof document !== \"undefined\") {\n defaultMeasureBox = document.createElement(\"div\");\n defaultMeasureBox.style.cssText = \"position: absolute !important; top: -4000px !important; width: auto !important; height: auto !important;\" +\n \"padding: 0 !important; margin: 0 !important; border: 0 !important;\" +\n \"line-height: normal !important; visibility: hidden !important; white-space: pre!important;\";\n}\n\nvar TextMetrics = kendo.Class.extend({\n init: function(options) {\n\n this._cache = new LRUCache(1000);\n this.options = $.extend({}, DEFAULT_OPTIONS, options);\n },\n\n measure: function(text, style, options) {\n if (options === void 0) { options = {}; }\n\n if (typeof text === 'undefined' || text === null) {\n return zeroSize();\n }\n\n var styleKey = objectKey(style);\n var cacheKey = hashKey(text + styleKey);\n var cachedResult = this._cache.get(cacheKey);\n\n if (cachedResult) {\n return cachedResult;\n }\n\n var size = zeroSize();\n var measureBox = options.box || defaultMeasureBox;\n var baselineMarker = this._baselineMarker().cloneNode(false);\n\n for (var key in style) {\n var value = style[key];\n if (typeof value !== \"undefined\") {\n measureBox.style[key] = value;\n }\n }\n\n var textStr = options.normalizeText !== false ? normalizeText(text) : String(text);\n\n measureBox.textContent = textStr;\n measureBox.appendChild(baselineMarker);\n document.body.appendChild(measureBox);\n\n if (textStr.length) {\n size.width = measureBox.offsetWidth - this.options.baselineMarkerSize;\n size.height = measureBox.offsetHeight;\n size.baseline = baselineMarker.offsetTop + this.options.baselineMarkerSize;\n }\n\n if (size.width > 0 && size.height > 0) {\n this._cache.put(cacheKey, size);\n }\n\n measureBox.parentNode.removeChild(measureBox);\n\n return size;\n },\n\n _baselineMarker: function() {\n var marker = document.createElement(\"div\");\n marker.style.cssText = \"display: inline-block; vertical-align: baseline;width: \" +\n this.options.baselineMarkerSize + \"px; height: \" + this.options.baselineMarkerSize + \"px;overflow: hidden;\";\n\n return marker;\n }\n});\n\nTextMetrics.current = new TextMetrics();\n\nfunction measureText(text, style, measureBox) {\n return TextMetrics.current.measure(text, style, measureBox);\n}\n\nkendo.deepExtend(kendo.util, {\n LRUCache: LRUCache,\n TextMetrics: TextMetrics,\n measureText: measureText,\n objectKey: objectKey,\n hashKey: hashKey,\n normalizeText: normalizeText\n});\n\n})(window.kendo.jQuery);\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n/***********************************************************************\n * WARNING: this file is auto-generated. If you change it directly,\n * your modifications will eventually be lost. The source code is in\n * `kendo-drawing` repository, you should make your changes there and\n * run `src-modules/sync.sh` in this repository.\n */\n(function(f, define){\n define('drawing/kendo-drawing',[ \"./util\", \"../kendo.color\", '../util/text-metrics' ], f);\n})(function(){\n\n(function ($) {\n\n/* jshint eqnull:true */\n/* jshint -W058 */\n/* jshint -W069 */\n/* jshint latedef: nofunc */\n/* jshint shadow: true */\n/* jshint unused: false */\n\nwindow.kendo = window.kendo || {};\nvar kendoDrawing = kendo.drawing;\nvar kendoDrawingUtil = kendoDrawing.util;\nvar extendStatic = kendoDrawingUtil.extendStatic;\nvar Class = kendo.Class;\nvar kendoUtil = kendo.util;\nvar support = kendo.support;\nvar supportBrowser = support.browser;\n\nvar createPromise = kendoDrawingUtil.createPromise;\nvar promiseAll = kendoDrawingUtil.promiseAll;\n\nvar HasObservers = (function (Class$$1) {\n function HasObservers () {\n Class$$1.apply(this, arguments);\n }\n\n extendStatic(HasObservers, Class$$1);\n HasObservers.prototype = Object.create( Class$$1 && Class$$1.prototype );\n HasObservers.prototype.constructor = HasObservers;\n HasObservers.fn = HasObservers.prototype;\n HasObservers.fn.init = HasObservers.fn.constructor;\n\n HasObservers.prototype.observers = function observers () {\n this._observers = this._observers || [];\n return this._observers;\n };\n\n HasObservers.prototype.addObserver = function addObserver (element) {\n if (!this._observers) {\n this._observers = [ element ];\n } else {\n this._observers.push(element);\n }\n return this;\n };\n\n HasObservers.prototype.removeObserver = function removeObserver (element) {\n var observers = this.observers();\n var index = observers.indexOf(element);\n if (index !== -1) {\n observers.splice(index, 1);\n }\n return this;\n };\n\n HasObservers.prototype.trigger = function trigger (methodName, event) {\n var observers = this._observers;\n\n if (observers && !this._suspended) {\n for (var idx = 0; idx < observers.length; idx++) {\n var observer = observers[idx];\n if (observer[methodName]) {\n observer[methodName](event);\n }\n }\n }\n return this;\n };\n\n HasObservers.prototype.optionsChange = function optionsChange (e) {\n if (e === void 0) { e = {}; }\n\n e.element = this;\n this.trigger(\"optionsChange\", e);\n };\n\n HasObservers.prototype.geometryChange = function geometryChange () {\n this.trigger(\"geometryChange\", {\n element: this\n });\n };\n\n HasObservers.prototype.suspend = function suspend () {\n this._suspended = (this._suspended || 0) + 1;\n return this;\n };\n\n HasObservers.prototype.resume = function resume () {\n this._suspended = Math.max((this._suspended || 0) - 1, 0);\n return this;\n };\n\n HasObservers.prototype._observerField = function _observerField (field, value) {\n if (this[field]) {\n this[field].removeObserver(this);\n }\n this[field] = value;\n value.addObserver(this);\n };\n\n return HasObservers;\n}(Class));\n\nfunction append$1$1(first, second) {\n first.push.apply(first, second);\n return first;\n}\n\n/* eslint-disable key-spacing,no-multi-spaces,no-param-reassign */\n\nvar literals = {\n 1 : \"i\", 10 : \"x\", 100 : \"c\",\n 2 : \"ii\", 20 : \"xx\", 200 : \"cc\",\n 3 : \"iii\", 30 : \"xxx\", 300 : \"ccc\",\n 4 : \"iv\", 40 : \"xl\", 400 : \"cd\",\n 5 : \"v\", 50 : \"l\", 500 : \"d\",\n 6 : \"vi\", 60 : \"lx\", 600 : \"dc\",\n 7 : \"vii\", 70 : \"lxx\", 700 : \"dcc\",\n 8 : \"viii\", 80 : \"lxxx\", 800 : \"dccc\",\n 9 : \"ix\", 90 : \"xc\", 900 : \"cm\",\n 1000 : \"m\"\n};\n\nfunction arabicToRoman(n) {\n var values = [ 1000,\n 900 , 800, 700, 600, 500, 400, 300, 200, 100,\n 90 , 80 , 70 , 60 , 50 , 40 , 30 , 20 , 10 ,\n 9 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 ];\n\n var roman = \"\";\n while (n > 0) {\n if (n < values[0]) {\n values.shift();\n } else {\n roman += literals[values[0]];\n n -= values[0];\n }\n }\n return roman;\n}\n\nvar UNDEFINED = \"undefined\";\n\nfunction defined(value) {\n return typeof value !== UNDEFINED;\n}\n\nvar defId = 1;\n\nfunction definitionId() {\n return \"kdef\" + defId++;\n}\n\nvar DEG_TO_RAD = Math.PI / 180;\nvar MAX_NUM = Number.MAX_VALUE;\nvar MIN_NUM = -Number.MAX_VALUE;\n\nfunction deg(radians) {\n return radians / DEG_TO_RAD;\n}\n\nvar fromCharCode = String.fromCharCode;\n\n// Encodes a string as UTF-8\nfunction encodeUTF8(input) {\n var output = \"\";\n\n for (var i = 0; i < input.length; i++) {\n var code = input.charCodeAt(i);\n\n if (0xD800 <= code && code <= 0xDBFF) {\n var hi = code;\n var low = input.charCodeAt(++i);\n\n if (!isNaN(low)) {\n // Combine high and low surrogate\n // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt\n code = (hi - 0xD800) * 0x400 +\n (low - 0xDC00) + 0x10000;\n }\n }\n\n if (code < 0x80) {\n // One byte\n output += fromCharCode(code);\n } else if (code < 0x800) {\n // Two bytes\n output += fromCharCode(0xC0 | (code >>> 6));\n output += fromCharCode(0x80 | (code & 0x3f));\n } else if (code < 0x10000) {\n // Three bytes\n output += fromCharCode(0xE0 | (code >>> 12));\n output += fromCharCode(0x80 | (code >>> 6 & 0x3f));\n output += fromCharCode(0x80 | (code & 0x3f));\n } else if (code < 0x10FFFF) {\n // Four bytes\n output += fromCharCode(0xF0 | (code >>> 18));\n output += fromCharCode(0x80 | (code >>> 12 & 0x3f));\n output += fromCharCode(0x80 | (code >>> 6 & 0x3f));\n output += fromCharCode(0x80 | (code & 0x3f));\n }\n }\n\n return output;\n}\n\n// Encodes a string as UTF-16 big-endian\n\nvar KEY_STR = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\";\n\nfunction encodeBase64(input) {\n var output = \"\";\n var i = 0;\n\n var utfInput = encodeUTF8(input);\n\n while (i < utfInput.length) {\n var chr1 = utfInput.charCodeAt(i++);\n var chr2 = utfInput.charCodeAt(i++);\n var chr3 = utfInput.charCodeAt(i++);\n\n var enc1 = chr1 >> 2;\n var enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);\n var enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);\n var enc4 = chr3 & 63;\n\n if (isNaN(chr2)) {\n enc3 = enc4 = 64;\n } else if (isNaN(chr3)) {\n enc4 = 64;\n }\n\n output = output +\n KEY_STR.charAt(enc1) + KEY_STR.charAt(enc2) +\n KEY_STR.charAt(enc3) + KEY_STR.charAt(enc4);\n }\n\n return output;\n}\n\nfunction eventCoordinates(e) {\n if (defined((e.x || {}).location)) {\n return {\n x: e.x.location,\n y: e.y.location\n };\n }\n\n return {\n x: e.pageX || e.clientX || 0,\n y: e.pageY || e.clientY || 0\n };\n}\n\nfunction eventElement(e) {\n if (e === void 0) { e = {}; }\n\n return e.touch ? e.touch.initialTouch : e.target;\n}\n\nfunction isTransparent(color) {\n return color === \"\" || color === null || color === \"none\" || color === \"transparent\" || !defined(color);\n}\n\nfunction last(array) {\n if (array) {\n return array[array.length - 1];\n }\n}\n\nfunction limitValue(value, min, max) {\n return Math.max(Math.min(value, max), min);\n}\n\n/* eslint-disable no-multi-spaces, key-spacing, indent, camelcase, space-before-blocks, eqeqeq, brace-style */\n/* eslint-disable space-infix-ops, space-before-function-paren, array-bracket-spacing, object-curly-spacing */\n/* eslint-disable no-nested-ternary, max-params, default-case, no-else-return, no-empty */\n/* eslint-disable no-param-reassign, no-var, block-scoped-var */\n\n// mergeSort is stable.\nfunction mergeSort(a, cmp) {\n if (a.length < 2) {\n return a.slice();\n }\n function merge(a, b) {\n var r = [], ai = 0, bi = 0, i = 0;\n while (ai < a.length && bi < b.length) {\n if (cmp(a[ai], b[bi]) <= 0) {\n r[i++] = a[ai++];\n } else {\n r[i++] = b[bi++];\n }\n }\n if (ai < a.length) {\n r.push.apply(r, a.slice(ai));\n }\n if (bi < b.length) {\n r.push.apply(r, b.slice(bi));\n }\n return r;\n }\n return (function sort(a) {\n if (a.length <= 1) {\n return a;\n }\n var m = Math.floor(a.length / 2);\n var left = a.slice(0, m);\n var right = a.slice(m);\n left = sort(left);\n right = sort(right);\n return merge(left, right);\n })(a);\n}\n\nvar now = Date.now || function() {\n return new Date().getTime();\n};\n\nfunction rad(degrees) {\n return degrees * DEG_TO_RAD;\n}\n\nfunction pow(p) {\n if (p) {\n return Math.pow(10, p);\n }\n\n return 1;\n}\n\nfunction round(value, precision) {\n var power = pow(precision);\n return Math.round(value * power) / power;\n}\n\nfunction valueOrDefault(value, defaultValue) {\n return defined(value) ? value : defaultValue;\n}\n\nfunction bindEvents(element, events) {\n for (var eventName in events) {\n var eventNames = eventName.trim().split(\" \");\n for (var idx = 0; idx < eventNames.length; idx++) {\n element.addEventListener(eventNames[idx], events[eventName], false);\n }\n }\n}\n\nfunction elementOffset(element) {\n var box = element.getBoundingClientRect();\n\n var documentElement = document.documentElement;\n\n return {\n top: box.top + (window.pageYOffset || documentElement.scrollTop) - (documentElement.clientTop || 0),\n left: box.left + (window.pageXOffset || documentElement.scrollLeft) - (documentElement.clientLeft || 0)\n };\n}\n\nfunction elementStyles(element, styles) {\n var result = {};\n var style = window.getComputedStyle(element) || {};\n var stylesArray = Array.isArray(styles) ? styles : [ styles ];\n\n for (var idx = 0; idx < stylesArray.length; idx++) {\n var field = stylesArray[idx];\n result[field] = style[field];\n }\n\n return result;\n}\n\nfunction getPixels(value) {\n if (isNaN(value)) {\n return value;\n }\n return value + \"px\";\n}\n\nfunction elementSize(element, size) {\n if (size) {\n var width = size.width;\n var height = size.height;\n\n if (defined(width)) {\n element.style.width = getPixels(width);\n }\n\n if (defined(height)) {\n element.style.height = getPixels(height);\n }\n\n } else {\n var size$1 = elementStyles(element, [ 'width', 'height' ]);\n\n return {\n width: parseInt(size$1.width, 10),\n height: parseInt(size$1.height, 10)\n };\n }\n}\n\nfunction unbindEvents(element, events) {\n if (events === void 0) { events = {}; }\n\n for (var name in events) {\n var eventNames = name.trim().split(\" \");\n for (var idx = 0; idx < eventNames.length; idx++) {\n element.removeEventListener(eventNames[idx], events[name], false);\n }\n }\n}\n\nfunction elementPadding(element) {\n var ref = elementStyles(element, [ \"paddingLeft\", \"paddingTop\" ]);\n var paddingLeft = ref.paddingLeft;\n var paddingTop = ref.paddingTop;\n return {\n top: parseFloat(paddingTop),\n left: parseFloat(paddingLeft)\n };\n}\n\nvar Matrix = (function (Class$$1) {\n function Matrix(a, b, c, d, e, f) {\n if (a === void 0) { a = 0; }\n if (b === void 0) { b = 0; }\n if (c === void 0) { c = 0; }\n if (d === void 0) { d = 0; }\n if (e === void 0) { e = 0; }\n if (f === void 0) { f = 0; }\n\n Class$$1.call(this);\n\n this.a = a;\n this.b = b;\n this.c = c;\n this.d = d;\n this.e = e;\n this.f = f;\n }\n\n extendStatic(Matrix, Class$$1);\n Matrix.prototype = Object.create( Class$$1 && Class$$1.prototype );\n Matrix.prototype.constructor = Matrix;\n Matrix.fn = Matrix.prototype;\n Matrix.fn.init = Matrix.fn.constructor;\n\n Matrix.prototype.multiplyCopy = function multiplyCopy (matrix) {\n return new Matrix(\n this.a * matrix.a + this.c * matrix.b,\n this.b * matrix.a + this.d * matrix.b,\n this.a * matrix.c + this.c * matrix.d,\n this.b * matrix.c + this.d * matrix.d,\n this.a * matrix.e + this.c * matrix.f + this.e,\n this.b * matrix.e + this.d * matrix.f + this.f\n );\n };\n\n Matrix.prototype.invert = function invert () {\n var ref = this;\n var a = ref.a;\n var b = ref.b;\n var d = ref.c;\n var e = ref.d;\n var g = ref.e;\n var h = ref.f;\n var det = a * e - b * d;\n\n if (det === 0) {\n return null;\n }\n\n return new Matrix(e / det, -b / det, -d / det, a / det,\n (d * h - e * g) / det, (b * g - a * h) / det);\n };\n\n Matrix.prototype.clone = function clone () {\n return new Matrix(this.a, this.b, this.c, this.d, this.e, this.f);\n };\n\n Matrix.prototype.equals = function equals (other) {\n if (!other) {\n return false;\n }\n\n return this.a === other.a && this.b === other.b &&\n this.c === other.c && this.d === other.d &&\n this.e === other.e && this.f === other.f;\n };\n\n Matrix.prototype.round = function round$1 (precision) {\n this.a = round(this.a, precision);\n this.b = round(this.b, precision);\n this.c = round(this.c, precision);\n this.d = round(this.d, precision);\n this.e = round(this.e, precision);\n this.f = round(this.f, precision);\n\n return this;\n };\n\n Matrix.prototype.toArray = function toArray (precision) {\n var result = [ this.a, this.b, this.c, this.d, this.e, this.f ];\n\n if (defined(precision)) {\n for (var i = 0; i < result.length; i++) {\n result[i] = round(result[i], precision);\n }\n }\n\n return result;\n };\n\n Matrix.prototype.toString = function toString (precision, separator) {\n if (separator === void 0) { separator = \",\"; }\n\n return this.toArray(precision).join(separator);\n };\n\n Matrix.translate = function translate (x, y) {\n return new Matrix(1, 0, 0, 1, x, y);\n };\n\n Matrix.unit = function unit () {\n return new Matrix(1, 0, 0, 1, 0, 0);\n };\n\n Matrix.rotate = function rotate (angle, x, y) {\n var matrix = new Matrix();\n matrix.a = Math.cos(rad(angle));\n matrix.b = Math.sin(rad(angle));\n matrix.c = -matrix.b;\n matrix.d = matrix.a;\n matrix.e = (x - x * matrix.a + y * matrix.b) || 0;\n matrix.f = (y - y * matrix.a - x * matrix.b) || 0;\n\n return matrix;\n };\n\n Matrix.scale = function scale (scaleX, scaleY) {\n return new Matrix(scaleX, 0, 0, scaleY, 0, 0);\n };\n\n return Matrix;\n}(Class));\n\nMatrix.IDENTITY = Matrix.unit();\n\nvar matrixRegexp = /matrix\\((.*)\\)/;\n\nfunction parseMatrix(matrixString) {\n var match = matrixString.match(matrixRegexp);\n if (match === null || match.length !== 2) {\n return Matrix.unit();\n }\n\n var members = match[1].split(',').map(function (x) { return parseFloat(x); });\n return new (Function.prototype.bind.apply( Matrix, [ null ].concat( members) ));\n}\n\nfunction transformMatrix(element) {\n var transform = getComputedStyle(element).transform;\n\n if (transform === 'none') {\n return Matrix.unit();\n }\n\n return parseMatrix(transform);\n}\n\nfunction elementScale(element) {\n if (!element) {\n return Matrix.unit();\n }\n\n var matrix = transformMatrix(element);\n var parent = element.parentElement;\n while (parent) {\n var parentMatrix = transformMatrix(parent);\n matrix = matrix.multiplyCopy(parentMatrix);\n parent = parent.parentElement;\n }\n\n matrix.b = matrix.c = matrix.e = matrix.f = 0;\n return matrix;\n}\n\nvar util = {\n\tappend: append$1$1,\n\tarabicToRoman: arabicToRoman,\n\tcreatePromise: createPromise,\n\tdefined: defined,\n\tdefinitionId: definitionId,\n\tdeg: deg,\n\tencodeBase64: encodeBase64,\n\teventCoordinates: eventCoordinates,\n\teventElement: eventElement,\n\tisTransparent: isTransparent,\n\tlast: last,\n\tlimitValue: limitValue,\n\tmergeSort: mergeSort,\n\tnow: now,\n\tpromiseAll: promiseAll,\n\trad: rad,\n\tround: round,\n\tvalueOrDefault: valueOrDefault,\n\tbindEvents: bindEvents,\n\telementOffset: elementOffset,\n\telementSize: elementSize,\n\telementStyles: elementStyles,\n\tunbindEvents: unbindEvents,\n\telementPadding: elementPadding,\n\telementScale: elementScale,\n\tDEG_TO_RAD: DEG_TO_RAD,\n\tMAX_NUM: MAX_NUM,\n\tMIN_NUM: MIN_NUM\n};\n\nvar toString$1 = {}.toString;\n\nvar OptionsStore = (function (HasObservers$$1) {\n function OptionsStore(options, prefix) {\n var this$1 = this;\n if (prefix === void 0) { prefix = \"\"; }\n\n HasObservers$$1.call(this);\n\n this.prefix = prefix;\n\n for (var field in options) {\n var member = options[field];\n member = this$1._wrap(member, field);\n this$1[field] = member;\n }\n }\n\n extendStatic(OptionsStore, HasObservers$$1);\n OptionsStore.prototype = Object.create( HasObservers$$1 && HasObservers$$1.prototype );\n OptionsStore.prototype.constructor = OptionsStore;\n OptionsStore.fn = OptionsStore.prototype;\n OptionsStore.fn.init = OptionsStore.fn.constructor;\n\n OptionsStore.prototype.get = function get (field) {\n var parts = field.split(\".\");\n var result = this;\n\n while (parts.length && result) {\n var part = parts.shift();\n result = result[part];\n }\n\n return result;\n };\n\n OptionsStore.prototype.set = function set (field, value) {\n var current = this.get(field);\n\n if (current !== value) {\n this._set(field, this._wrap(value, field));\n this.optionsChange({\n field: this.prefix + field,\n value: value\n });\n }\n };\n\n OptionsStore.prototype._set = function _set (field, value) {\n var this$1 = this;\n\n var composite = field.indexOf(\".\") >= 0;\n var parentObj = this;\n var fieldName = field;\n\n if (composite) {\n var parts = fieldName.split(\".\");\n var prefix = this.prefix;\n\n while (parts.length > 1) {\n fieldName = parts.shift();\n prefix += fieldName + \".\";\n\n var obj = parentObj[fieldName];\n\n if (!obj) {\n obj = new OptionsStore({}, prefix);\n obj.addObserver(this$1);\n parentObj[fieldName] = obj;\n }\n parentObj = obj;\n }\n fieldName = parts[0];\n }\n\n parentObj._clear(fieldName);\n parentObj[fieldName] = value;\n };\n\n OptionsStore.prototype._clear = function _clear (field) {\n var current = this[field];\n if (current && current.removeObserver) {\n current.removeObserver(this);\n }\n };\n\n OptionsStore.prototype._wrap = function _wrap (object, field) {\n var type = toString$1.call(object);\n var wrapped = object;\n\n if (wrapped !== null && defined(wrapped) && type === \"[object Object]\") {\n if (!(object instanceof OptionsStore) && !(object instanceof Class)) {\n wrapped = new OptionsStore(wrapped, this.prefix + field + \".\");\n }\n\n wrapped.addObserver(this);\n }\n\n return wrapped;\n };\n\n return OptionsStore;\n}(HasObservers));\n\nfunction setAccessor(field) {\n return function(value) {\n if (this[field] !== value) {\n this[field] = value;\n this.geometryChange();\n }\n\n return this;\n };\n}\n\nfunction getAccessor(field) {\n return function() {\n return this[field];\n };\n}\n\nfunction defineAccessors(fn, fields) {\n for (var i = 0; i < fields.length; i++) {\n var name = fields[i];\n var capitalized = name.charAt(0).toUpperCase() +\n name.substring(1, name.length);\n\n fn[\"set\" + capitalized] = setAccessor(name);\n fn[\"get\" + capitalized] = getAccessor(name);\n }\n}\n\nvar withAccessors = function (TBase, names) {\n var result = (function (TBase) {\n function result () {\n TBase.apply(this, arguments);\n }extendStatic(result, TBase);\n result.prototype = Object.create( TBase && TBase.prototype );\n result.prototype.constructor = result;\n result.fn = result.prototype;\n result.fn.init = result.fn.constructor;\n\n return result;\n }(TBase));\n defineAccessors(result.prototype, names);\n\n return result;\n};\n\nfunction toMatrix(transformation) {\n if (transformation && typeof transformation.matrix === \"function\") {\n return transformation.matrix();\n }\n\n return transformation;\n}\n\nvar Point = (function (superclass) {\n function Point(x, y) {\n superclass.call(this);\n\n this.x = x || 0;\n this.y = y || 0;\n }\n\n extendStatic(Point, superclass);\n Point.prototype = Object.create( superclass && superclass.prototype );\n Point.prototype.constructor = Point;\n Point.fn = Point.prototype;\n Point.fn.init = Point.fn.constructor;\n\n var staticAccessors = { ZERO: {} };\n\n Point.prototype.equals = function equals (other) {\n return other && other.x === this.x && other.y === this.y;\n };\n\n Point.prototype.clone = function clone () {\n return new Point(this.x, this.y);\n };\n\n Point.prototype.rotate = function rotate (angle, origin) {\n var originPoint = Point.create(origin) || Point.ZERO;\n\n return this.transform(Matrix.rotate(angle, originPoint.x, originPoint.y));\n };\n\n Point.prototype.translate = function translate (x, y) {\n this.x += x;\n this.y += y;\n\n this.geometryChange();\n\n return this;\n };\n\n Point.prototype.translateWith = function translateWith (point) {\n return this.translate(point.x, point.y);\n };\n\n Point.prototype.move = function move (x, y) {\n this.x = this.y = 0;\n return this.translate(x, y);\n };\n\n Point.prototype.scale = function scale (scaleX, scaleY) {\n if (scaleY === void 0) { scaleY = scaleX; }\n\n this.x *= scaleX;\n this.y *= scaleY;\n\n this.geometryChange();\n\n return this;\n };\n\n Point.prototype.scaleCopy = function scaleCopy (scaleX, scaleY) {\n return this.clone().scale(scaleX, scaleY);\n };\n\n Point.prototype.transform = function transform (transformation) {\n var matrix = toMatrix(transformation);\n var ref = this;\n var x = ref.x;\n var y = ref.y;\n\n this.x = matrix.a * x + matrix.c * y + matrix.e;\n this.y = matrix.b * x + matrix.d * y + matrix.f;\n\n this.geometryChange();\n\n return this;\n };\n\n Point.prototype.transformCopy = function transformCopy (transformation) {\n var point = this.clone();\n\n if (transformation) {\n point.transform(transformation);\n }\n\n return point;\n };\n\n Point.prototype.distanceTo = function distanceTo (point) {\n var dx = this.x - point.x;\n var dy = this.y - point.y;\n\n return Math.sqrt(dx * dx + dy * dy);\n };\n\n Point.prototype.round = function round$1 (digits) {\n this.x = round(this.x, digits);\n this.y = round(this.y, digits);\n\n this.geometryChange();\n\n return this;\n };\n\n Point.prototype.toArray = function toArray (digits) {\n var doRound = defined(digits);\n var x = doRound ? round(this.x, digits) : this.x;\n var y = doRound ? round(this.y, digits) : this.y;\n\n return [ x, y ];\n };\n\n Point.prototype.toString = function toString (digits, separator) {\n if (separator === void 0) { separator = \" \"; }\n\n var ref = this;\n var x = ref.x;\n var y = ref.y;\n\n if (defined(digits)) {\n x = round(x, digits);\n y = round(y, digits);\n }\n\n return x + separator + y;\n };\n\n Point.create = function create (arg0, arg1) {\n if (defined(arg0)) {\n if (arg0 instanceof Point) {\n return arg0;\n } else if (arguments.length === 1 && arg0.length === 2) {\n return new Point(arg0[0], arg0[1]);\n }\n\n return new Point(arg0, arg1);\n }\n };\n\n Point.min = function min () {\n var arguments$1 = arguments;\n\n var minX = MAX_NUM;\n var minY = MAX_NUM;\n\n for (var i = 0; i < arguments.length; i++) {\n var point = arguments$1[i];\n minX = Math.min(point.x, minX);\n minY = Math.min(point.y, minY);\n }\n\n return new Point(minX, minY);\n };\n\n Point.max = function max () {\n var arguments$1 = arguments;\n\n var maxX = MIN_NUM;\n var maxY = MIN_NUM;\n\n for (var i = 0; i < arguments.length; i++) {\n var point = arguments$1[i];\n maxX = Math.max(point.x, maxX);\n maxY = Math.max(point.y, maxY);\n }\n\n return new Point(maxX, maxY);\n };\n\n Point.minPoint = function minPoint () {\n return new Point(MIN_NUM, MIN_NUM);\n };\n\n Point.maxPoint = function maxPoint () {\n return new Point(MAX_NUM, MAX_NUM);\n };\n\n staticAccessors.ZERO.get = function () {\n return new Point(0, 0);\n };\n\n Object.defineProperties( Point, staticAccessors );\n\n return Point;\n}(withAccessors(HasObservers, [ \"x\", \"y\" ])));\n\nvar Size = (function (superclass) {\n function Size(width, height) {\n superclass.call(this);\n\n this.width = width || 0;\n this.height = height || 0;\n }\n\n extendStatic(Size, superclass);\n Size.prototype = Object.create( superclass && superclass.prototype );\n Size.prototype.constructor = Size;\n Size.fn = Size.prototype;\n Size.fn.init = Size.fn.constructor;\n\n var staticAccessors = { ZERO: {} };\n\n Size.prototype.equals = function equals (other) {\n return other && other.width === this.width && other.height === this.height;\n };\n\n Size.prototype.clone = function clone () {\n return new Size(this.width, this.height);\n };\n\n Size.prototype.toArray = function toArray (digits) {\n var doRound = defined(digits);\n var width = doRound ? round(this.width, digits) : this.width;\n var height = doRound ? round(this.height, digits) : this.height;\n\n return [ width, height ];\n };\n\n Size.create = function create (arg0, arg1) {\n if (defined(arg0)) {\n if (arg0 instanceof Size) {\n return arg0;\n } else if (arguments.length === 1 && arg0.length === 2) {\n return new Size(arg0[0], arg0[1]);\n }\n\n return new Size(arg0, arg1);\n }\n };\n\n staticAccessors.ZERO.get = function () {\n return new Size(0, 0);\n };\n\n Object.defineProperties( Size, staticAccessors );\n\n return Size;\n}(withAccessors(HasObservers, [ \"width\", \"height\" ])));\n\nvar Rect = (function (HasObservers$$1) {\n function Rect(origin, size, cornerRadius) {\n if (origin === void 0) { origin = new Point(); }\n if (size === void 0) { size = new Size(); }\n if (cornerRadius === void 0) { cornerRadius = 0; }\n\n HasObservers$$1.call(this);\n\n this.setOrigin(origin);\n this.setSize(size);\n this.setCornerRadius(cornerRadius);\n }\n\n extendStatic(Rect, HasObservers$$1);\n Rect.prototype = Object.create( HasObservers$$1 && HasObservers$$1.prototype );\n Rect.prototype.constructor = Rect;\n Rect.fn = Rect.prototype;\n Rect.fn.init = Rect.fn.constructor;\n\n Rect.prototype.clone = function clone () {\n return new Rect(\n this.origin.clone(),\n this.size.clone()\n );\n };\n\n Rect.prototype.equals = function equals (other) {\n return other &&\n other.origin.equals(this.origin) &&\n other.size.equals(this.size);\n };\n\n Rect.prototype.setOrigin = function setOrigin (value) {\n this._observerField(\"origin\", Point.create(value));\n this.geometryChange();\n return this;\n };\n\n Rect.prototype.getOrigin = function getOrigin () {\n return this.origin;\n };\n\n Rect.prototype.setCornerRadius = function setCornerRadius (radius) {\n this.cornerRadius = Array.isArray(radius) ? radius : [ radius, radius ];\n\n this.geometryChange();\n return this;\n };\n\n Rect.prototype.getCornerRadius = function getCornerRadius () {\n return this.cornerRadius;\n };\n\n Rect.prototype.setSize = function setSize (value) {\n this._observerField(\"size\", Size.create(value));\n this.geometryChange();\n return this;\n };\n\n Rect.prototype.getSize = function getSize () {\n return this.size;\n };\n\n Rect.prototype.width = function width () {\n return this.size.width;\n };\n\n Rect.prototype.height = function height () {\n return this.size.height;\n };\n\n Rect.prototype.topLeft = function topLeft () {\n return this.origin.clone();\n };\n\n Rect.prototype.bottomRight = function bottomRight () {\n return this.origin.clone().translate(this.width(), this.height());\n };\n\n Rect.prototype.topRight = function topRight () {\n return this.origin.clone().translate(this.width(), 0);\n };\n\n Rect.prototype.bottomLeft = function bottomLeft () {\n return this.origin.clone().translate(0, this.height());\n };\n\n Rect.prototype.center = function center () {\n return this.origin.clone().translate(this.width() / 2, this.height() / 2);\n };\n\n Rect.prototype.bbox = function bbox (matrix) {\n var tl = this.topLeft().transformCopy(matrix);\n var tr = this.topRight().transformCopy(matrix);\n var br = this.bottomRight().transformCopy(matrix);\n var bl = this.bottomLeft().transformCopy(matrix);\n\n return Rect.fromPoints(tl, tr, br, bl);\n };\n\n Rect.prototype.transformCopy = function transformCopy (m) {\n return Rect.fromPoints(\n this.topLeft().transform(m),\n this.bottomRight().transform(m)\n );\n };\n\n Rect.prototype.expand = function expand (x, y) {\n if (y === void 0) { y = x; }\n\n this.size.width += 2 * x;\n this.size.height += 2 * y;\n\n this.origin.translate(-x, -y);\n\n return this;\n };\n\n Rect.prototype.expandCopy = function expandCopy (x, y) {\n return this.clone().expand(x, y);\n };\n\n Rect.prototype.containsPoint = function containsPoint (point) {\n var origin = this.origin;\n var bottomRight = this.bottomRight();\n return !(point.x < origin.x || point.y < origin.y || bottomRight.x < point.x || bottomRight.y < point.y);\n };\n\n Rect.prototype._isOnPath = function _isOnPath (point, width) {\n var rectOuter = this.expandCopy(width, width);\n var rectInner = this.expandCopy(-width, -width);\n\n return rectOuter.containsPoint(point) && !rectInner.containsPoint(point);\n };\n\n Rect.fromPoints = function fromPoints () {\n var topLeft = Point.min.apply(null, arguments);\n var bottomRight = Point.max.apply(null, arguments);\n var size = new Size(\n bottomRight.x - topLeft.x,\n bottomRight.y - topLeft.y\n );\n\n return new Rect(topLeft, size);\n };\n\n Rect.union = function union (a, b) {\n return Rect.fromPoints(\n Point.min(a.topLeft(), b.topLeft()),\n Point.max(a.bottomRight(), b.bottomRight())\n );\n };\n\n Rect.intersect = function intersect (a, b) {\n var rect1 = {\n left: a.topLeft().x,\n top: a.topLeft().y,\n right: a.bottomRight().x,\n bottom: a.bottomRight().y\n };\n\n var rect2 = {\n left: b.topLeft().x,\n top: b.topLeft().y,\n right: b.bottomRight().x,\n bottom: b.bottomRight().y\n };\n\n if (rect1.left <= rect2.right &&\n rect2.left <= rect1.right &&\n rect1.top <= rect2.bottom &&\n rect2.top <= rect1.bottom) {\n return Rect.fromPoints(\n new Point(Math.max(rect1.left, rect2.left), Math.max(rect1.top, rect2.top)),\n new Point(Math.min(rect1.right, rect2.right), Math.min(rect1.bottom, rect2.bottom))\n );\n }\n };\n\n return Rect;\n}(HasObservers));\n\nvar Transformation = (function (HasObservers$$1) {\n function Transformation(matrix) {\n if (matrix === void 0) { matrix = Matrix.unit(); }\n\n HasObservers$$1.call(this);\n\n this._matrix = matrix;\n }\n\n extendStatic(Transformation, HasObservers$$1);\n Transformation.prototype = Object.create( HasObservers$$1 && HasObservers$$1.prototype );\n Transformation.prototype.constructor = Transformation;\n Transformation.fn = Transformation.prototype;\n Transformation.fn.init = Transformation.fn.constructor;\n\n Transformation.prototype.clone = function clone () {\n return new Transformation(\n this._matrix.clone()\n );\n };\n\n Transformation.prototype.equals = function equals (other) {\n return other &&\n other._matrix.equals(this._matrix);\n };\n\n Transformation.prototype.translate = function translate (x, y) {\n this._matrix = this._matrix.multiplyCopy(Matrix.translate(x, y));\n\n this._optionsChange();\n return this;\n };\n\n Transformation.prototype.scale = function scale (scaleX, scaleY, origin) {\n if (scaleY === void 0) { scaleY = scaleX; }\n if (origin === void 0) { origin = null; }\n\n var originPoint = origin;\n\n if (originPoint) {\n originPoint = Point.create(originPoint);\n this._matrix = this._matrix.multiplyCopy(Matrix.translate(originPoint.x, originPoint.y));\n }\n\n this._matrix = this._matrix.multiplyCopy(Matrix.scale(scaleX, scaleY));\n\n if (originPoint) {\n this._matrix = this._matrix.multiplyCopy(Matrix.translate(-originPoint.x, -originPoint.y));\n }\n\n this._optionsChange();\n return this;\n };\n\n Transformation.prototype.rotate = function rotate (angle, origin) {\n var originPoint = Point.create(origin) || Point.ZERO;\n\n this._matrix = this._matrix.multiplyCopy(Matrix.rotate(angle, originPoint.x, originPoint.y));\n\n this._optionsChange();\n return this;\n };\n\n Transformation.prototype.multiply = function multiply (transformation) {\n var matrix = toMatrix(transformation);\n\n this._matrix = this._matrix.multiplyCopy(matrix);\n\n this._optionsChange();\n return this;\n };\n\n Transformation.prototype.matrix = function matrix (value) {\n if (value) {\n this._matrix = value;\n this._optionsChange();\n return this;\n }\n\n return this._matrix;\n };\n\n Transformation.prototype._optionsChange = function _optionsChange () {\n this.optionsChange({\n field: \"transform\",\n value: this\n });\n };\n\n return Transformation;\n}(HasObservers));\n\nfunction transform$1(matrix) {\n if (matrix === null) {\n return null;\n }\n\n if (matrix instanceof Transformation) {\n return matrix;\n }\n\n return new Transformation(matrix);\n}\n\nvar Element$1 = (function (HasObservers$$1) {\n function Element(options) {\n HasObservers$$1.call(this);\n\n this._initOptions(options);\n }\n\n extendStatic(Element, HasObservers$$1);\n Element.prototype = Object.create( HasObservers$$1 && HasObservers$$1.prototype );\n Element.prototype.constructor = Element;\n Element.fn = Element.prototype;\n Element.fn.init = Element.fn.constructor;\n\n var prototypeAccessors = { nodeType: {} };\n\n prototypeAccessors.nodeType.get = function () {\n return \"Rect\";\n };\n\n Element.prototype._initOptions = function _initOptions (options) {\n if (options === void 0) { options = {}; }\n\n var clip = options.clip;\n var transform = options.transform;\n\n if (transform) {\n options.transform = transform$1(transform);\n }\n\n if (clip && !clip.id) {\n clip.id = definitionId();\n }\n\n this.options = new OptionsStore(options);\n this.options.addObserver(this);\n };\n\n Element.prototype.transform = function transform (value) {\n if (defined(value)) {\n this.options.set(\"transform\", transform$1(value));\n } else {\n return this.options.get(\"transform\");\n }\n };\n\n Element.prototype.parentTransform = function parentTransform () {\n var element = this;\n var parentMatrix;\n\n while (element.parent) {\n element = element.parent;\n var transformation = element.transform();\n if (transformation) {\n parentMatrix = transformation.matrix().multiplyCopy(parentMatrix || Matrix.unit());\n }\n }\n\n if (parentMatrix) {\n return transform$1(parentMatrix);\n }\n };\n\n Element.prototype.currentTransform = function currentTransform (parentTransform) {\n if (parentTransform === void 0) { parentTransform = this.parentTransform(); }\n\n var elementTransform = this.transform();\n var elementMatrix = toMatrix(elementTransform);\n\n var parentMatrix = toMatrix(parentTransform);\n var combinedMatrix;\n\n if (elementMatrix && parentMatrix) {\n combinedMatrix = parentMatrix.multiplyCopy(elementMatrix);\n } else {\n combinedMatrix = elementMatrix || parentMatrix;\n }\n\n if (combinedMatrix) {\n return transform$1(combinedMatrix);\n }\n };\n\n Element.prototype.visible = function visible (value) {\n if (defined(value)) {\n this.options.set(\"visible\", value);\n return this;\n }\n\n return this.options.get(\"visible\") !== false;\n };\n\n Element.prototype.clip = function clip (value) {\n var options = this.options;\n if (defined(value)) {\n if (value && !value.id) {\n value.id = definitionId();\n }\n options.set(\"clip\", value);\n return this;\n }\n\n return options.get(\"clip\");\n };\n\n Element.prototype.opacity = function opacity (value) {\n if (defined(value)) {\n this.options.set(\"opacity\", value);\n return this;\n }\n\n return valueOrDefault(this.options.get(\"opacity\"), 1);\n };\n\n Element.prototype.clippedBBox = function clippedBBox (transformation) {\n var bbox = this._clippedBBox(transformation);\n if (bbox) {\n var clip = this.clip();\n return clip ? Rect.intersect(bbox, clip.bbox(transformation)) : bbox;\n }\n };\n\n Element.prototype.containsPoint = function containsPoint (point, parentTransform) {\n if (this.visible()) {\n var transform = this.currentTransform(parentTransform);\n var transformedPoint = point;\n if (transform) {\n transformedPoint = point.transformCopy(transform.matrix().invert());\n }\n return (this._hasFill() && this._containsPoint(transformedPoint)) || (this._isOnPath && this._hasStroke() && this._isOnPath(transformedPoint));\n }\n return false;\n };\n\n Element.prototype._hasFill = function _hasFill () {\n var fill = this.options.fill;\n return fill && !isTransparent(fill.color);\n };\n\n Element.prototype._hasStroke = function _hasStroke () {\n var stroke = this.options.stroke;\n return stroke && stroke.width > 0 && !isTransparent(stroke.color);\n };\n\n Element.prototype._clippedBBox = function _clippedBBox (transformation) {\n return this.bbox(transformation);\n };\n\n Object.defineProperties( Element.prototype, prototypeAccessors );\n\n return Element;\n}(HasObservers));\n\nfunction ellipseExtremeAngles(center, rx, ry, matrix) {\n var extremeX = 0;\n var extremeY = 0;\n\n if (matrix) {\n extremeX = Math.atan2(matrix.c * ry, matrix.a * rx);\n if (matrix.b !== 0) {\n extremeY = Math.atan2(matrix.d * ry, matrix.b * rx);\n }\n }\n\n return {\n x: extremeX,\n y: extremeY\n };\n}\n\nvar PI_DIV_2 = Math.PI / 2;\n\nvar Circle$2 = (function (superclass) {\n function Circle(center, radius) {\n if (center === void 0) { center = new Point(); }\n if (radius === void 0) { radius = 0; }\n\n superclass.call(this);\n\n this.setCenter(center);\n this.setRadius(radius);\n }\n\n extendStatic(Circle, superclass);\n Circle.prototype = Object.create( superclass && superclass.prototype );\n Circle.prototype.constructor = Circle;\n Circle.fn = Circle.prototype;\n Circle.fn.init = Circle.fn.constructor;\n\n Circle.prototype.setCenter = function setCenter (value) {\n this._observerField(\"center\", Point.create(value));\n this.geometryChange();\n return this;\n };\n\n Circle.prototype.getCenter = function getCenter () {\n return this.center;\n };\n\n Circle.prototype.equals = function equals (other) {\n return other &&\n other.center.equals(this.center) &&\n other.radius === this.radius;\n };\n\n Circle.prototype.clone = function clone () {\n return new Circle(this.center.clone(), this.radius);\n };\n\n Circle.prototype.pointAt = function pointAt (angle) {\n return this._pointAt(rad(angle));\n };\n\n Circle.prototype.bbox = function bbox (matrix) {\n var this$1 = this;\n\n var extremeAngles = ellipseExtremeAngles(this.center, this.radius, this.radius, matrix);\n var minPoint = Point.maxPoint();\n var maxPoint = Point.minPoint();\n\n for (var i = 0; i < 4; i++) {\n var currentPointX = this$1._pointAt(extremeAngles.x + i * PI_DIV_2).transformCopy(matrix);\n var currentPointY = this$1._pointAt(extremeAngles.y + i * PI_DIV_2).transformCopy(matrix);\n var currentPoint = new Point(currentPointX.x, currentPointY.y);\n\n minPoint = Point.min(minPoint, currentPoint);\n maxPoint = Point.max(maxPoint, currentPoint);\n }\n\n return Rect.fromPoints(minPoint, maxPoint);\n };\n\n Circle.prototype._pointAt = function _pointAt (angle) {\n var ref = this;\n var center = ref.center;\n var radius = ref.radius;\n\n return new Point(\n center.x + radius * Math.cos(angle),\n center.y + radius * Math.sin(angle)\n );\n };\n\n Circle.prototype.containsPoint = function containsPoint (point) {\n var ref = this;\n var center = ref.center;\n var radius = ref.radius;\n var inCircle = Math.pow(point.x - center.x, 2) +\n Math.pow(point.y - center.y, 2) <= Math.pow(radius, 2);\n return inCircle;\n };\n\n Circle.prototype._isOnPath = function _isOnPath (point, width) {\n var ref = this;\n var center = ref.center;\n var radius = ref.radius;\n var pointDistance = center.distanceTo(point);\n\n return radius - width <= pointDistance && pointDistance <= radius + width;\n };\n\n return Circle;\n}(withAccessors(HasObservers, [ \"radius\" ])));\n\nvar GRADIENT = \"Gradient\";\n\nvar paintable = function (TBase) { return (\n (function (TBase) {\n function anonymous () {\n TBase.apply(this, arguments);\n }\n\n extendStatic(anonymous, TBase);\n anonymous.prototype = Object.create( TBase && TBase.prototype );\n anonymous.prototype.constructor = anonymous;\n anonymous.fn = anonymous.prototype;\n anonymous.fn.init = anonymous.fn.constructor;\n\n anonymous.prototype.fill = function fill (color, opacity) {\n var options = this.options;\n\n if (defined(color)) {\n if (color && color.nodeType !== GRADIENT) {\n var newFill = {\n color: color\n };\n if (defined(opacity)) {\n newFill.opacity = opacity;\n }\n options.set(\"fill\", newFill);\n } else {\n options.set(\"fill\", color);\n }\n\n return this;\n }\n\n return options.get(\"fill\");\n };\n\n anonymous.prototype.stroke = function stroke (color, width, opacity) {\n if (defined(color)) {\n this.options.set(\"stroke.color\", color);\n\n if (defined(width)) {\n this.options.set(\"stroke.width\", width);\n }\n\n if (defined(opacity)) {\n this.options.set(\"stroke.opacity\", opacity);\n }\n\n return this;\n }\n\n return this.options.get(\"stroke\");\n };\n\n return anonymous;\n }(TBase))\n); };\n\nvar IDENTITY_MATRIX_HASH = Matrix.IDENTITY.toString();\n\nvar measurable = function (TBase) { return (\n (function (TBase) {\n function anonymous () {\n TBase.apply(this, arguments);\n }\n\n extendStatic(anonymous, TBase);\n anonymous.prototype = Object.create( TBase && TBase.prototype );\n anonymous.prototype.constructor = anonymous;\n anonymous.fn = anonymous.prototype;\n anonymous.fn.init = anonymous.fn.constructor;\n\n anonymous.prototype.bbox = function bbox (transformation) {\n var combinedMatrix = toMatrix(this.currentTransform(transformation));\n var matrixHash = combinedMatrix ? combinedMatrix.toString() : IDENTITY_MATRIX_HASH;\n var bbox;\n\n if (this._bboxCache && this._matrixHash === matrixHash) {\n bbox = this._bboxCache.clone();\n } else {\n bbox = this._bbox(combinedMatrix);\n this._bboxCache = bbox ? bbox.clone() : null;\n this._matrixHash = matrixHash;\n }\n\n var strokeWidth = this.options.get(\"stroke.width\");\n if (strokeWidth && bbox) {\n bbox.expand(strokeWidth / 2);\n }\n\n return bbox;\n };\n\n anonymous.prototype.geometryChange = function geometryChange () {\n delete this._bboxCache;\n this.trigger(\"geometryChange\", {\n element: this\n });\n };\n\n return anonymous;\n }(TBase))\n); };\n\nfunction geometryAccessor(name) {\n var fieldName = \"_\" + name;\n return function(value) {\n if (defined(value)) {\n this._observerField(fieldName, value);\n this.geometryChange();\n return this;\n }\n\n return this[fieldName];\n };\n}\n\nfunction defineGeometryAccessors(fn, names) {\n for (var i = 0; i < names.length; i++) {\n fn[names[i]] = geometryAccessor(names[i]);\n }\n}\n\nvar withGeometry = function (TBase, names) {\n if (names === void 0) { names = [ \"geometry\" ]; }\n\n var result = (function (TBase) {\n function result () {\n TBase.apply(this, arguments);\n }extendStatic(result, TBase);\n result.prototype = Object.create( TBase && TBase.prototype );\n result.prototype.constructor = result;\n result.fn = result.prototype;\n result.fn.init = result.fn.constructor;\n\n return result;\n }(TBase));\n defineGeometryAccessors(result.prototype, names);\n\n return result;\n};\n\nvar DEFAULT_STROKE = \"#000\";\n\nvar Circle = (function (superclass) {\n function Circle(geometry, options) {\n if (geometry === void 0) { geometry = new Circle$2(); }\n if (options === void 0) { options = {}; }\n\n superclass.call(this, options);\n\n this.geometry(geometry);\n\n if (!defined(this.options.stroke)) {\n this.stroke(DEFAULT_STROKE);\n }\n }\n\n extendStatic(Circle, superclass);\n Circle.prototype = Object.create( superclass && superclass.prototype );\n Circle.prototype.constructor = Circle;\n Circle.fn = Circle.prototype;\n Circle.fn.init = Circle.fn.constructor;\n\n var prototypeAccessors = { nodeType: {} };\n\n prototypeAccessors.nodeType.get = function () {\n return \"Circle\";\n };\n\n Circle.prototype.rawBBox = function rawBBox () {\n return this._geometry.bbox();\n };\n\n Circle.prototype._bbox = function _bbox (matrix) {\n return this._geometry.bbox(matrix);\n };\n\n Circle.prototype._containsPoint = function _containsPoint (point) {\n return this.geometry().containsPoint(point);\n };\n\n Circle.prototype._isOnPath = function _isOnPath (point) {\n return this.geometry()._isOnPath(point, this.options.stroke.width / 2);\n };\n\n Object.defineProperties( Circle.prototype, prototypeAccessors );\n\n return Circle;\n}(paintable(measurable(withGeometry(Element$1)))));\n\nvar PRECISION = 10;\n\nfunction close$1(a, b, tolerance) {\n if (tolerance === void 0) { tolerance = PRECISION; }\n\n return round(Math.abs(a - b), tolerance) === 0;\n}\n\nfunction closeOrLess(a, b, tolerance) {\n return a < b || close$1(a, b, tolerance);\n}\n\nfunction lineIntersection(p0, p1, p2, p3) {\n var s1x = p1.x - p0.x;\n var s2x = p3.x - p2.x;\n var s1y = p1.y - p0.y;\n var s2y = p3.y - p2.y;\n var nx = p0.x - p2.x;\n var ny = p0.y - p2.y;\n var d = s1x * s2y - s2x * s1y;\n var s = (s1x * ny - s1y * nx) / d;\n var t = (s2x * ny - s2y * nx) / d;\n\n if (s >= 0 && s <= 1 && t >= 0 && t <= 1) {\n return new Point(p0.x + t * s1x, p0.y + t * s1y);\n }\n}\n\nvar MAX_INTERVAL = 45;\nvar pow$1 = Math.pow;\nvar accessors = [ \"radiusX\", \"radiusY\", \"startAngle\", \"endAngle\", \"anticlockwise\" ];\n\nvar Arc$2 = (function (superclass) {\n function Arc(center, options) {\n if (center === void 0) { center = new Point(); }\n if (options === void 0) { options = {}; }\n\n superclass.call(this);\n\n this.setCenter(center);\n\n this.radiusX = options.radiusX;\n this.radiusY = options.radiusY || options.radiusX;\n this.startAngle = options.startAngle;\n this.endAngle = options.endAngle;\n this.anticlockwise = options.anticlockwise || false;\n this.xRotation = options.xRotation;\n }\n\n extendStatic(Arc, superclass);\n Arc.prototype = Object.create( superclass && superclass.prototype );\n Arc.prototype.constructor = Arc;\n Arc.fn = Arc.prototype;\n Arc.fn.init = Arc.fn.constructor;\n\n Arc.prototype.clone = function clone () {\n return new Arc(this.center, {\n radiusX: this.radiusX,\n radiusY: this.radiusY,\n startAngle: this.startAngle,\n endAngle: this.endAngle,\n anticlockwise: this.anticlockwise\n });\n };\n\n Arc.prototype.setCenter = function setCenter (value) {\n this._observerField(\"center\", Point.create(value));\n this.geometryChange();\n return this;\n };\n\n Arc.prototype.getCenter = function getCenter () {\n return this.center;\n };\n\n Arc.prototype.pointAt = function pointAt (angle) {\n var center = this.center;\n var radian = rad(angle);\n\n return new Point(\n center.x + this.radiusX * Math.cos(radian),\n center.y + this.radiusY * Math.sin(radian)\n );\n };\n\n Arc.prototype.curvePoints = function curvePoints () {\n var this$1 = this;\n\n var startAngle = this.startAngle;\n var dir = this.anticlockwise ? -1 : 1;\n var curvePoints = [ this.pointAt(startAngle) ];\n var interval = this._arcInterval();\n var intervalAngle = interval.endAngle - interval.startAngle;\n var subIntervalsCount = Math.ceil(intervalAngle / MAX_INTERVAL);\n var subIntervalAngle = intervalAngle / subIntervalsCount;\n var currentAngle = startAngle;\n var transformation;\n if (this.xRotation) {\n transformation = transform$1().rotate(this.xRotation, this.center);\n }\n\n for (var i = 1; i <= subIntervalsCount; i++) {\n var nextAngle = currentAngle + dir * subIntervalAngle;\n var points = this$1._intervalCurvePoints(currentAngle, nextAngle, transformation);\n\n curvePoints.push(points.cp1, points.cp2, points.p2);\n currentAngle = nextAngle;\n }\n\n return curvePoints;\n };\n\n Arc.prototype.bbox = function bbox (matrix) {\n var this$1 = this;\n\n var interval = this._arcInterval();\n var startAngle = interval.startAngle;\n var endAngle = interval.endAngle;\n var extremeAngles = ellipseExtremeAngles(this.center, this.radiusX, this.radiusY, matrix);\n var extremeX = deg(extremeAngles.x);\n var extremeY = deg(extremeAngles.y);\n var endPoint = this.pointAt(endAngle).transformCopy(matrix);\n var currentAngleX = bboxStartAngle(extremeX, startAngle);\n var currentAngleY = bboxStartAngle(extremeY, startAngle);\n var currentPoint = this.pointAt(startAngle).transformCopy(matrix);\n var minPoint = Point.min(currentPoint, endPoint);\n var maxPoint = Point.max(currentPoint, endPoint);\n\n while (currentAngleX < endAngle || currentAngleY < endAngle) {\n var currentPointX = (void 0);\n if (currentAngleX < endAngle) {\n currentPointX = this$1.pointAt(currentAngleX).transformCopy(matrix);\n currentAngleX += 90;\n }\n\n var currentPointY = (void 0);\n if (currentAngleY < endAngle) {\n currentPointY = this$1.pointAt(currentAngleY).transformCopy(matrix);\n currentAngleY += 90;\n }\n\n currentPoint = new Point(currentPointX.x, currentPointY.y);\n minPoint = Point.min(minPoint, currentPoint);\n maxPoint = Point.max(maxPoint, currentPoint);\n }\n\n return Rect.fromPoints(minPoint, maxPoint);\n };\n\n Arc.prototype._arcInterval = function _arcInterval () {\n var ref = this;\n var startAngle = ref.startAngle;\n var endAngle = ref.endAngle;\n var anticlockwise = ref.anticlockwise;\n\n if (anticlockwise) {\n var oldStart = startAngle;\n startAngle = endAngle;\n endAngle = oldStart;\n }\n\n if (startAngle > endAngle || (anticlockwise && startAngle === endAngle)) {\n endAngle += 360;\n }\n\n return {\n startAngle: startAngle,\n endAngle: endAngle\n };\n };\n\n Arc.prototype._intervalCurvePoints = function _intervalCurvePoints (startAngle, endAngle, transformation) {\n var p1 = this.pointAt(startAngle);\n var p2 = this.pointAt(endAngle);\n var p1Derivative = this._derivativeAt(startAngle);\n var p2Derivative = this._derivativeAt(endAngle);\n var t = (rad(endAngle) - rad(startAngle)) / 3;\n var cp1 = new Point(p1.x + t * p1Derivative.x, p1.y + t * p1Derivative.y);\n var cp2 = new Point(p2.x - t * p2Derivative.x, p2.y - t * p2Derivative.y);\n if (transformation) {\n p1.transform(transformation);\n p2.transform(transformation);\n cp1.transform(transformation);\n cp2.transform(transformation);\n }\n\n return {\n p1: p1,\n cp1: cp1,\n cp2: cp2,\n p2: p2\n };\n };\n\n Arc.prototype._derivativeAt = function _derivativeAt (angle) {\n var radian = rad(angle);\n\n return new Point(-this.radiusX * Math.sin(radian), this.radiusY * Math.cos(radian));\n };\n\n Arc.prototype.containsPoint = function containsPoint (point) {\n var interval = this._arcInterval();\n var intervalAngle = interval.endAngle - interval.startAngle;\n var ref = this;\n var center = ref.center;\n var radiusX = ref.radiusX;\n var radiusY = ref.radiusY;\n var distance = center.distanceTo(point);\n var angleRad = Math.atan2(point.y - center.y, point.x - center.x);\n var pointRadius = (radiusX * radiusY) /\n Math.sqrt(pow$1(radiusX, 2) * pow$1(Math.sin(angleRad), 2) + pow$1(radiusY, 2) * pow$1(Math.cos(angleRad), 2));\n var startPoint = this.pointAt(this.startAngle).round(PRECISION);\n var endPoint = this.pointAt(this.endAngle).round(PRECISION);\n var intersection = lineIntersection(center, point.round(PRECISION), startPoint, endPoint);\n var containsPoint;\n\n if (intervalAngle < 180) {\n containsPoint = intersection && closeOrLess(center.distanceTo(intersection), distance) && closeOrLess(distance, pointRadius);\n } else {\n var angle = calculateAngle(center.x, center.y, radiusX, radiusY, point.x, point.y);\n if (angle !== 360) {\n angle = (360 + angle) % 360;\n }\n\n var inAngleRange = interval.startAngle <= angle && angle <= interval.endAngle;\n containsPoint = (inAngleRange && closeOrLess(distance, pointRadius)) || (!inAngleRange && (!intersection || intersection.equals(point)));\n }\n return containsPoint;\n };\n\n Arc.prototype._isOnPath = function _isOnPath (point, width) {\n var interval = this._arcInterval();\n var center = this.center;\n var angle = calculateAngle(center.x, center.y, this.radiusX, this.radiusY, point.x, point.y);\n if (angle !== 360) {\n angle = (360 + angle) % 360;\n }\n\n var inAngleRange = interval.startAngle <= angle && angle <= interval.endAngle;\n\n return inAngleRange && this.pointAt(angle).distanceTo(point) <= width;\n };\n\n Arc.fromPoints = function fromPoints (start, end, rx, ry, largeArc, swipe, rotation) {// eslint-disable-line max-params\n var arcParameters = normalizeArcParameters({\n x1: start.x,\n y1: start.y,\n x2: end.x,\n y2: end.y,\n rx: rx,\n ry: ry,\n largeArc: largeArc,\n swipe: swipe,\n rotation: rotation\n });\n\n return new Arc(arcParameters.center, {\n startAngle: arcParameters.startAngle,\n endAngle: arcParameters.endAngle,\n radiusX: arcParameters.radiusX,\n radiusY: arcParameters.radiusY,\n xRotation: arcParameters.xRotation,\n anticlockwise: swipe === 0\n });\n };\n\n return Arc;\n}(withAccessors(HasObservers, accessors)));\n\nfunction calculateAngle(cx, cy, rx, ry, x, y) {\n var cos = round((x - cx) / rx, 3);\n var sin = round((y - cy) / ry, 3);\n\n return round(deg(Math.atan2(sin, cos)));\n}\n\nfunction normalizeArcParameters(parameters) {\n var x1 = parameters.x1;\n var y1 = parameters.y1;\n var x2 = parameters.x2;\n var y2 = parameters.y2;\n var rx = parameters.rx;\n var ry = parameters.ry;\n var largeArc = parameters.largeArc;\n var swipe = parameters.swipe;\n var rotation = parameters.rotation; if (rotation === void 0) { rotation = 0; }\n\n var radians = rad(rotation);\n var cosine = Math.cos(radians);\n var sine = Math.sin(radians);\n\n var xT = cosine * (x1 - x2) / 2 + sine * (y1 - y2) / 2;\n var yT = -sine * (x1 - x2) / 2 + cosine * (y1 - y2) / 2;\n\n var sign = largeArc !== swipe ? 1 : -1;\n\n var xt2 = Math.pow(xT, 2);\n var yt2 = Math.pow(yT, 2);\n var rx2 = Math.pow(rx, 2);\n var ry2 = Math.pow(ry, 2);\n\n var delta = xt2 / rx2 + yt2 / ry2;\n\n if (delta > 1) {\n delta = Math.sqrt(xt2 / rx2 + yt2 / ry2);\n rx = delta * rx;\n rx2 = Math.pow(rx, 2);\n\n ry = delta * ry;\n ry2 = Math.pow(ry, 2);\n }\n\n var constT = sign * Math.sqrt((rx2 * ry2 - rx2 * yt2 - ry2 * xt2) / (rx2 * yt2 + ry2 * xt2));\n // due to rounding errors the value could become NaN even after radii correction\n if (isNaN(constT)) {\n constT = 0;\n }\n\n var cxT = constT * (rx * yT) / ry;\n var cyT = - constT * (ry * xT) / rx;\n\n var cx = cosine * cxT - sine * cyT + (x1 + x2) / 2;\n var cy = sine * cxT + cosine * cyT + (y1 + y2) / 2;\n\n var uX = (xT - cxT) / rx;\n var uY = (yT - cyT) / ry;\n var vX = -(xT + cxT) / rx;\n var vY = -(yT + cyT) / ry;\n\n var startAngle = (uY >= 0 ? 1 : -1) * deg(Math.acos(uX / Math.sqrt(uX * uX + uY * uY)));\n\n var angleCosine = round((uX * vX + uY * vY) / (Math.sqrt(uX * uX + uY * uY) * Math.sqrt(vX * vX + vY * vY)), 10);\n var angle = (uX * vY - uY * vX >= 0 ? 1 : -1) * deg(Math.acos(angleCosine));\n\n if (!swipe && angle > 0) {\n angle -= 360;\n }\n\n if (swipe && angle < 0) {\n angle += 360;\n }\n var endAngle = startAngle + angle;\n var signEndAngle = endAngle >= 0 ? 1 : -1;\n endAngle = (Math.abs(endAngle) % 360) * signEndAngle;\n\n return {\n center: new Point(cx, cy),\n startAngle: startAngle,\n endAngle: endAngle,\n radiusX: rx,\n radiusY: ry,\n xRotation: rotation\n };\n}\n\nfunction bboxStartAngle(angle, start) {\n var startAngle = angle;\n\n while (startAngle < start) {\n startAngle += 90;\n }\n\n return startAngle;\n}\n\nvar push = [].push;\nvar pop = [].pop;\nvar splice = [].splice;\nvar shift = [].shift;\nvar slice = [].slice;\nvar unshift = [].unshift;\n\nvar ElementsArray = (function (HasObservers$$1) {\n function ElementsArray(array) {\n if (array === void 0) { array = []; }\n\n HasObservers$$1.call(this);\n\n this.length = 0;\n this._splice(0, array.length, array);\n }\n\n extendStatic(ElementsArray, HasObservers$$1);\n ElementsArray.prototype = Object.create( HasObservers$$1 && HasObservers$$1.prototype );\n ElementsArray.prototype.constructor = ElementsArray;\n ElementsArray.fn = ElementsArray.prototype;\n ElementsArray.fn.init = ElementsArray.fn.constructor;\n\n ElementsArray.prototype.elements = function elements (value) {\n if (value) {\n this._splice(0, this.length, value);\n\n this._change();\n return this;\n }\n\n return this.slice(0);\n };\n\n ElementsArray.prototype.push = function push$1 () {\n var elements = arguments;\n var result = push.apply(this, elements);\n\n this._add(elements);\n\n return result;\n };\n\n ElementsArray.prototype.slice = function slice$1 () {\n return slice.call(this);\n };\n\n ElementsArray.prototype.pop = function pop$1 () {\n var length = this.length;\n var result = pop.apply(this);\n\n if (length) {\n this._remove([ result ]);\n }\n\n return result;\n };\n\n ElementsArray.prototype.splice = function splice$1 (index, howMany) {\n var elements = slice.call(arguments, 2);\n var result = this._splice(index, howMany, elements);\n\n this._change();\n\n return result;\n };\n\n ElementsArray.prototype.shift = function shift$1 () {\n var length = this.length;\n var result = shift.apply(this);\n\n if (length) {\n this._remove([ result ]);\n }\n\n return result;\n };\n\n ElementsArray.prototype.unshift = function unshift$1 () {\n var elements = arguments;\n var result = unshift.apply(this, elements);\n\n this._add(elements);\n\n return result;\n };\n\n ElementsArray.prototype.indexOf = function indexOf (element) {\n var this$1 = this;\n\n var length = this.length;\n\n for (var idx = 0; idx < length; idx++) {\n if (this$1[idx] === element) {\n return idx;\n }\n }\n return -1;\n };\n\n ElementsArray.prototype._splice = function _splice (index, howMany, elements) {\n var result = splice.apply(this, [ index, howMany ].concat(elements));\n\n this._clearObserver(result);\n this._setObserver(elements);\n\n return result;\n };\n\n ElementsArray.prototype._add = function _add (elements) {\n this._setObserver(elements);\n this._change();\n };\n\n ElementsArray.prototype._remove = function _remove (elements) {\n this._clearObserver(elements);\n this._change();\n };\n\n ElementsArray.prototype._setObserver = function _setObserver (elements) {\n var this$1 = this;\n\n for (var idx = 0; idx < elements.length; idx++) {\n elements[idx].addObserver(this$1);\n }\n };\n\n ElementsArray.prototype._clearObserver = function _clearObserver (elements) {\n var this$1 = this;\n\n for (var idx = 0; idx < elements.length; idx++) {\n elements[idx].removeObserver(this$1);\n }\n };\n\n ElementsArray.prototype._change = function _change () {};\n\n return ElementsArray;\n}(HasObservers));\n\nvar GeometryElementsArray = (function (ElementsArray$$1) {\n function GeometryElementsArray () {\n ElementsArray$$1.apply(this, arguments);\n }\n\n extendStatic(GeometryElementsArray, ElementsArray$$1);\n GeometryElementsArray.prototype = Object.create( ElementsArray$$1 && ElementsArray$$1.prototype );\n GeometryElementsArray.prototype.constructor = GeometryElementsArray;\n GeometryElementsArray.fn = GeometryElementsArray.prototype;\n GeometryElementsArray.fn.init = GeometryElementsArray.fn.constructor;\n\n GeometryElementsArray.prototype._change = function _change () {\n this.geometryChange();\n };\n\n return GeometryElementsArray;\n}(ElementsArray));\n\nfunction isOutOfEndPoint(endPoint, controlPoint, point) {\n var angle = deg(Math.atan2(controlPoint.y - endPoint.y, controlPoint.x - endPoint.x));\n var rotatedPoint = point.transformCopy(transform$1().rotate(-angle, endPoint));\n\n return rotatedPoint.x < endPoint.x;\n}\n\nfunction calculateCurveAt(t, field, points) {\n var t1 = 1 - t;\n return Math.pow(t1, 3) * points[0][field] +\n 3 * Math.pow(t1, 2) * t * points[1][field] +\n 3 * Math.pow(t, 2) * t1 * points[2][field] +\n Math.pow(t, 3) * points[3][field];\n}\n\nfunction toCubicPolynomial(points, field) {\n return [ -points[0][field] + 3 * points[1][field] - 3 * points[2][field] + points[3][field],\n 3 * (points[0][field] - 2 * points[1][field] + points[2][field]),\n 3 * (-points[0][field] + points[1][field]),\n points[0][field]\n ];\n}\n\nvar ComplexNumber = (function (Class$$1) {\n function ComplexNumber(real, img) {\n if (real === void 0) { real = 0; }\n if (img === void 0) { img = 0; }\n\n Class$$1.call(this);\n\n this.real = real;\n this.img = img;\n }\n\n extendStatic(ComplexNumber, Class$$1);\n ComplexNumber.prototype = Object.create( Class$$1 && Class$$1.prototype );\n ComplexNumber.prototype.constructor = ComplexNumber;\n ComplexNumber.fn = ComplexNumber.prototype;\n ComplexNumber.fn.init = ComplexNumber.fn.constructor;\n\n ComplexNumber.prototype.add = function add (cNumber) {\n return new ComplexNumber(round(this.real + cNumber.real, PRECISION), round(this.img + cNumber.img, PRECISION));\n };\n\n ComplexNumber.prototype.addConstant = function addConstant (value) {\n return new ComplexNumber(this.real + value, this.img);\n };\n\n ComplexNumber.prototype.negate = function negate () {\n return new ComplexNumber(-this.real, -this.img);\n };\n\n ComplexNumber.prototype.multiply = function multiply (cNumber) {\n return new ComplexNumber(this.real * cNumber.real - this.img * cNumber.img,\n this.real * cNumber.img + this.img * cNumber.real);\n };\n\n ComplexNumber.prototype.multiplyConstant = function multiplyConstant (value) {\n return new ComplexNumber(this.real * value, this.img * value);\n };\n\n ComplexNumber.prototype.nthRoot = function nthRoot (n) {\n var rad$$1 = Math.atan2(this.img, this.real);\n var r = Math.sqrt(Math.pow(this.img, 2) + Math.pow(this.real, 2));\n var nthR = Math.pow(r, 1 / n);\n\n return new ComplexNumber(nthR * Math.cos(rad$$1 / n), nthR * Math.sin(rad$$1 / n)); //Moivre's formula\n };\n\n ComplexNumber.prototype.equals = function equals (cNumber) {\n return this.real === cNumber.real && this.img === cNumber.img;\n };\n\n ComplexNumber.prototype.isReal = function isReal () {\n return this.img === 0;\n };\n\n return ComplexNumber;\n}(Class));\n\nfunction numberSign(x) {\n return x < 0 ? -1 : 1;\n}\n\nfunction solveQuadraticEquation(a, b, c) {\n var squareRoot = Math.sqrt(Math.pow(b, 2) - 4 * a * c);\n return [\n (-b + squareRoot) / (2 * a),\n (-b - squareRoot) / (2 * a)\n ];\n}\n\n//Cardano's formula\nfunction solveCubicEquation(a, b, c, d) {\n if (a === 0) {\n return solveQuadraticEquation(b, c, d);\n }\n\n var p = (3 * a * c - Math.pow(b, 2)) / (3 * Math.pow(a, 2));\n var q = (2 * Math.pow(b, 3) - 9 * a * b * c + 27 * Math.pow(a, 2) * d) / (27 * Math.pow(a, 3));\n var Q = Math.pow(p / 3, 3) + Math.pow(q / 2, 2);\n var i = new ComplexNumber(0,1);\n var b3a = -b / (3 * a);\n var x1, x2, y1, y2, y3, z1, z2;\n\n if (Q < 0) {\n x1 = new ComplexNumber(-q / 2, Math.sqrt(-Q)).nthRoot(3);\n x2 = new ComplexNumber(-q / 2, - Math.sqrt(-Q)).nthRoot(3);\n } else {\n x1 = -q / 2 + Math.sqrt(Q);\n x1 = new ComplexNumber(numberSign(x1) * Math.pow(Math.abs(x1), 1 / 3));\n x2 = -q / 2 - Math.sqrt(Q);\n x2 = new ComplexNumber(numberSign(x2) * Math.pow(Math.abs(x2), 1 / 3));\n }\n\n y1 = x1.add(x2);\n\n z1 = x1.add(x2).multiplyConstant(-1 / 2);\n z2 = x1.add(x2.negate()).multiplyConstant(Math.sqrt(3) / 2);\n\n y2 = z1.add(i.multiply(z2));\n y3 = z1.add(i.negate().multiply(z2));\n\n var result = [];\n\n if (y1.isReal()) {\n result.push(round(y1.real + b3a, PRECISION));\n }\n if (y2.isReal()) {\n result.push(round(y2.real + b3a, PRECISION));\n }\n if (y3.isReal()) {\n result.push(round(y3.real + b3a, PRECISION));\n }\n\n return result;\n}\n\nfunction hasRootsInRange(points, point, field, rootField, range) {\n var polynomial = toCubicPolynomial(points, rootField);\n var roots = solveCubicEquation(polynomial[0], polynomial[1], polynomial[2], polynomial[3] - point[rootField]);\n var intersection;\n\n for (var idx = 0; idx < roots.length; idx++) {\n if (0 <= roots[idx] && roots[idx] <= 1) {\n intersection = calculateCurveAt(roots[idx], field, points);\n if (Math.abs(intersection - point[field]) <= range) {\n return true;\n }\n }\n }\n}\n\nfunction curveIntersectionsCount(points, point, bbox) {\n var polynomial = toCubicPolynomial(points, \"x\");\n var roots = solveCubicEquation(polynomial[0], polynomial[1], polynomial[2], polynomial[3] - point.x);\n var rayIntersection, intersectsRay;\n var count = 0;\n for (var i = 0; i < roots.length; i++) {\n rayIntersection = calculateCurveAt(roots[i], \"y\", points);\n intersectsRay = close$1(rayIntersection, point.y) || rayIntersection > point.y;\n if (intersectsRay && (((roots[i] === 0 || roots[i] === 1) && bbox.bottomRight().x > point.x) || (0 < roots[i] && roots[i] < 1))) {\n count++;\n }\n }\n\n return count;\n}\n\nfunction lineIntersectionsCount(a, b, point) {\n var intersects;\n if (a.x !== b.x) {\n var minX = Math.min(a.x, b.x);\n var maxX = Math.max(a.x, b.x);\n var minY = Math.min(a.y, b.y);\n var maxY = Math.max(a.y, b.y);\n var inRange = minX <= point.x && point.x < maxX;\n\n if (minY === maxY) {\n intersects = point.y <= minY && inRange;\n } else {\n intersects = inRange && (((maxY - minY) * ((a.x - b.x) * (a.y - b.y) > 0 ? point.x - minX : maxX - point.x)) / (maxX - minX) + minY - point.y) >= 0;\n }\n }\n\n return intersects ? 1 : 0;\n}\n\nfunction pointAccessor(name) {\n var fieldName = \"_\" + name;\n return function(value) {\n if (defined(value)) {\n this._observerField(fieldName, Point.create(value));\n this.geometryChange();\n return this;\n }\n\n return this[fieldName];\n };\n}\n\nfunction definePointAccessors(fn, names) {\n for (var i = 0; i < names.length; i++) {\n fn[names[i]] = pointAccessor(names[i]);\n }\n}\n\nvar withPoints = function (TBase, names) {\n var result = (function (TBase) {\n function result () {\n TBase.apply(this, arguments);\n }extendStatic(result, TBase);\n result.prototype = Object.create( TBase && TBase.prototype );\n result.prototype.constructor = result;\n result.fn = result.prototype;\n result.fn.init = result.fn.constructor;\n\n return result;\n }(TBase));\n definePointAccessors(result.prototype, names);\n\n return result;\n};\n\nvar points = [ \"anchor\", \"controlIn\", \"controlOut\" ];\n\nvar Segment = (function (superclass) {\n function Segment(anchor, controlIn, controlOut) {\n superclass.call(this);\n\n this.anchor(anchor || new Point());\n this.controlIn(controlIn);\n this.controlOut(controlOut);\n }\n\n extendStatic(Segment, superclass);\n Segment.prototype = Object.create( superclass && superclass.prototype );\n Segment.prototype.constructor = Segment;\n Segment.fn = Segment.prototype;\n Segment.fn.init = Segment.fn.constructor;\n\n Segment.prototype.bboxTo = function bboxTo (toSegment, matrix) {\n var segmentAnchor = this.anchor().transformCopy(matrix);\n var toSegmentAnchor = toSegment.anchor().transformCopy(matrix);\n var rect;\n\n if (this.controlOut() && toSegment.controlIn()) {\n rect = this._curveBoundingBox(\n segmentAnchor, this.controlOut().transformCopy(matrix),\n toSegment.controlIn().transformCopy(matrix), toSegmentAnchor\n );\n } else {\n rect = this._lineBoundingBox(segmentAnchor, toSegmentAnchor);\n }\n\n return rect;\n };\n\n Segment.prototype._lineBoundingBox = function _lineBoundingBox (p1, p2) {\n return Rect.fromPoints(p1, p2);\n };\n\n Segment.prototype._curveBoundingBox = function _curveBoundingBox (p1, cp1, cp2, p2) {\n var points = [ p1, cp1, cp2, p2 ];\n var extremesX = this._curveExtremesFor(points, \"x\");\n var extremesY = this._curveExtremesFor(points, \"y\");\n var xLimits = arrayLimits([ extremesX.min, extremesX.max, p1.x, p2.x ]);\n var yLimits = arrayLimits([ extremesY.min, extremesY.max, p1.y, p2.y ]);\n\n return Rect.fromPoints(new Point(xLimits.min, yLimits.min), new Point(xLimits.max, yLimits.max));\n };\n\n Segment.prototype._curveExtremesFor = function _curveExtremesFor (points, field) {\n var extremes = this._curveExtremes(\n points[0][field], points[1][field],\n points[2][field], points[3][field]\n );\n\n return {\n min: calculateCurveAt(extremes.min, field, points),\n max: calculateCurveAt(extremes.max, field, points)\n };\n };\n\n Segment.prototype._curveExtremes = function _curveExtremes (x1, x2, x3, x4) {\n var a = x1 - 3 * x2 + 3 * x3 - x4;\n var b = - 2 * (x1 - 2 * x2 + x3);\n var c = x1 - x2;\n var sqrt = Math.sqrt(b * b - 4 * a * c);\n var t1 = 0;\n var t2 = 1;\n\n if (a === 0) {\n if (b !== 0) {\n t1 = t2 = -c / b;\n }\n } else if (!isNaN(sqrt)) {\n t1 = (- b + sqrt) / (2 * a);\n t2 = (- b - sqrt) / (2 * a);\n }\n\n var min = Math.max(Math.min(t1, t2), 0);\n if (min < 0 || min > 1) {\n min = 0;\n }\n\n var max = Math.min(Math.max(t1, t2), 1);\n if (max > 1 || max < 0) {\n max = 1;\n }\n\n return {\n min: min,\n max: max\n };\n };\n\n Segment.prototype._intersectionsTo = function _intersectionsTo (segment, point) {\n var intersectionsCount;\n if (this.controlOut() && segment.controlIn()) {\n intersectionsCount = curveIntersectionsCount([ this.anchor(), this.controlOut(), segment.controlIn(), segment.anchor() ], point, this.bboxTo(segment));\n } else {\n intersectionsCount = lineIntersectionsCount(this.anchor(), segment.anchor(), point);\n }\n return intersectionsCount;\n };\n\n Segment.prototype._isOnCurveTo = function _isOnCurveTo (segment, point, width, endSegment) {\n var bbox = this.bboxTo(segment).expand(width, width);\n if (bbox.containsPoint(point)) {\n var p1 = this.anchor();\n var p2 = this.controlOut();\n var p3 = segment.controlIn();\n var p4 = segment.anchor();\n\n if (endSegment === \"start\" && p1.distanceTo(point) <= width) {\n return !isOutOfEndPoint(p1, p2, point);\n } else if (endSegment === \"end\" && p4.distanceTo(point) <= width) {\n return !isOutOfEndPoint(p4, p3, point);\n }\n\n //the approach is not entirely correct but is close and the alternatives are solving a 6th degree polynomial or testing the segment points\n var points = [ p1, p2, p3, p4 ];\n if (hasRootsInRange(points, point, \"x\", \"y\", width) || hasRootsInRange(points, point, \"y\", \"x\", width)) {\n return true;\n }\n var rotation = transform$1().rotate(45, point);\n var rotatedPoints = [ p1.transformCopy(rotation), p2.transformCopy(rotation), p3.transformCopy(rotation), p4.transformCopy(rotation) ];\n return hasRootsInRange(rotatedPoints, point, \"x\", \"y\", width) || hasRootsInRange(rotatedPoints, point, \"y\", \"x\", width);\n }\n };\n\n Segment.prototype._isOnLineTo = function _isOnLineTo (segment, point, width) {\n var p1 = this.anchor();\n var p2 = segment.anchor();\n var angle = deg(Math.atan2(p2.y - p1.y, p2.x - p1.x));\n var rect = new Rect([ p1.x, p1.y - width / 2 ], [ p1.distanceTo(p2), width ]);\n return rect.containsPoint(point.transformCopy(transform$1().rotate(-angle, p1)));\n };\n\n Segment.prototype._isOnPathTo = function _isOnPathTo (segment, point, width, endSegment) {\n var isOnPath;\n if (this.controlOut() && segment.controlIn()) {\n isOnPath = this._isOnCurveTo(segment, point, width / 2, endSegment);\n } else {\n isOnPath = this._isOnLineTo(segment, point, width);\n }\n return isOnPath;\n };\n\n return Segment;\n}(withPoints(HasObservers, points)));\n\nfunction arrayLimits(arr) {\n var length = arr.length;\n var min = MAX_NUM;\n var max = MIN_NUM;\n\n for (var i = 0; i < length; i ++) {\n max = Math.max(max, arr[i]);\n min = Math.min(min, arr[i]);\n }\n\n return {\n min: min,\n max: max\n };\n}\n\nvar ShapeMap = {\n l: function(path, options) {\n var parameters = options.parameters;\n var position = options.position;\n\n for (var i = 0; i < parameters.length; i += 2) {\n var point = new Point(parameters[i], parameters[i + 1]);\n\n if (options.isRelative) {\n point.translateWith(position);\n }\n\n path.lineTo(point.x, point.y);\n\n position.x = point.x;\n position.y = point.y;\n }\n },\n\n c: function(path, options) {\n var parameters = options.parameters;\n var position = options.position;\n\n for (var i = 0; i < parameters.length; i += 6) {\n var controlOut = new Point(parameters[i], parameters[i + 1]);\n var controlIn = new Point(parameters[i + 2], parameters[i + 3]);\n var point = new Point(parameters[i + 4], parameters[i + 5]);\n if (options.isRelative) {\n controlIn.translateWith(position);\n controlOut.translateWith(position);\n point.translateWith(position);\n }\n\n path.curveTo(controlOut, controlIn, point);\n\n position.x = point.x;\n position.y = point.y;\n }\n },\n\n v: function(path, options) {\n var value = options.isRelative ? 0 : options.position.x;\n\n toLineParamaters(options.parameters, true, value);\n this.l(path, options);\n },\n\n h: function(path, options) {\n var value = options.isRelative ? 0 : options.position.y;\n\n toLineParamaters(options.parameters, false, value);\n this.l(path, options);\n },\n\n a: function(path, options) {\n var parameters = options.parameters;\n var position = options.position;\n\n for (var i = 0; i < parameters.length; i += 7) {\n var radiusX = parameters[i];\n var radiusY = parameters[i + 1];\n var rotation = parameters[i + 2];\n var largeArc = parameters[i + 3];\n var swipe = parameters[i + 4];\n var endPoint = new Point(parameters[i + 5], parameters[i + 6]);\n\n if (options.isRelative) {\n endPoint.translateWith(position);\n }\n if (position.x !== endPoint.x || position.y !== endPoint.y) {\n path.arcTo(endPoint, radiusX, radiusY, largeArc, swipe, rotation);\n\n position.x = endPoint.x;\n position.y = endPoint.y;\n }\n }\n },\n\n s: function(path, options) {\n var parameters = options.parameters;\n var position = options.position;\n var previousCommand = options.previousCommand;\n var lastControlIn;\n\n if (previousCommand === \"s\" || previousCommand === \"c\") {\n lastControlIn = last(last(path.paths).segments).controlIn();\n }\n\n for (var i = 0; i < parameters.length; i += 4) {\n var controlIn = new Point(parameters[i], parameters[i + 1]);\n var endPoint = new Point(parameters[i + 2], parameters[i + 3]);\n var controlOut = (void 0);\n\n if (options.isRelative) {\n controlIn.translateWith(position);\n endPoint.translateWith(position);\n }\n\n if (lastControlIn) {\n controlOut = reflectionPoint(lastControlIn, position);\n } else {\n controlOut = position.clone();\n }\n\n lastControlIn = controlIn;\n\n path.curveTo(controlOut, controlIn, endPoint);\n\n position.x = endPoint.x;\n position.y = endPoint.y;\n }\n },\n\n q: function(path, options) {\n var parameters = options.parameters;\n var position = options.position;\n\n for (var i = 0; i < parameters.length; i += 4) {\n var controlPoint = new Point(parameters[i], parameters[i + 1]);\n var endPoint = new Point(parameters[i + 2], parameters[i + 3]);\n\n if (options.isRelative) {\n controlPoint.translateWith(position);\n endPoint.translateWith(position);\n }\n\n var cubicControlPoints = quadraticToCubicControlPoints(position, controlPoint, endPoint);\n\n path.curveTo(cubicControlPoints.controlOut, cubicControlPoints.controlIn, endPoint);\n\n position.x = endPoint.x;\n position.y = endPoint.y;\n }\n },\n\n t: function(path, options) {\n var parameters = options.parameters;\n var position = options.position;\n var previousCommand = options.previousCommand;\n var controlPoint;\n\n if (previousCommand === \"q\" || previousCommand === \"t\") {\n var lastSegment = last(last(path.paths).segments);\n controlPoint = lastSegment.controlIn().clone()\n .translateWith(position.scaleCopy(-1 / 3))\n .scale(3 / 2);\n }\n\n for (var i = 0; i < parameters.length; i += 2) {\n var endPoint = new Point(parameters[i], parameters[i + 1]);\n if (options.isRelative) {\n endPoint.translateWith(position);\n }\n\n if (controlPoint) {\n controlPoint = reflectionPoint(controlPoint, position);\n } else {\n controlPoint = position.clone();\n }\n\n var cubicControlPoints = quadraticToCubicControlPoints(position, controlPoint, endPoint);\n\n path.curveTo(cubicControlPoints.controlOut, cubicControlPoints.controlIn, endPoint);\n\n position.x = endPoint.x;\n position.y = endPoint.y;\n }\n }\n};\n\nfunction toLineParamaters(parameters, isVertical, value) {\n var insertPosition = isVertical ? 0 : 1;\n\n for (var i = 0; i < parameters.length; i += 2) {\n parameters.splice(i + insertPosition, 0, value);\n }\n}\n\nfunction reflectionPoint(point, center) {\n if (point && center) {\n return center.scaleCopy(2).translate(-point.x, -point.y);\n }\n}\n\nvar third = 1 / 3;\n\nfunction quadraticToCubicControlPoints(position, controlPoint, endPoint) {\n var scaledPoint = controlPoint.clone().scale(2 / 3);\n return {\n controlOut: scaledPoint.clone().translateWith(position.scaleCopy(third)),\n controlIn: scaledPoint.translateWith(endPoint.scaleCopy(third))\n };\n}\n\nvar SEGMENT_REGEX = /([a-df-z]{1})([^a-df-z]*)(z)?/gi;\nvar SPLIT_REGEX = /[,\\s]?([+\\-]?(?:\\d*\\.\\d+|\\d+)(?:[eE][+\\-]?\\d+)?)/g;\nvar MOVE = \"m\";\nvar CLOSE = \"z\";\n\nfunction parseParameters(str) {\n var parameters = [];\n str.replace(SPLIT_REGEX, function(match, number) {\n parameters.push(parseFloat(number));\n });\n return parameters;\n}\n\nfunction parsePath(pathInstance, str) {\n var position = new Point();\n var previousCommand;\n\n str.replace(SEGMENT_REGEX, function (match, element, params, closePath) {\n var command = element.toLowerCase();\n var isRelative = command === element;\n var parameters = parseParameters(params.trim());\n\n if (command === MOVE) {\n if (isRelative) {\n position.x += parameters[0];\n position.y += parameters[1];\n } else {\n position.x = parameters[0];\n position.y = parameters[1];\n }\n\n pathInstance.moveTo(position.x, position.y);\n\n if (parameters.length > 2) {\n command = \"l\";\n parameters.splice(0, 2);\n }\n }\n\n if (ShapeMap[command]) {\n ShapeMap[command](\n pathInstance, {\n parameters: parameters,\n position: position,\n isRelative: isRelative,\n previousCommand: previousCommand\n }\n );\n\n if (closePath && closePath.toLowerCase() === CLOSE) {\n pathInstance.close();\n }\n } else if (command !== MOVE) {\n throw new Error(\"Error while parsing SVG path. Unsupported command: \" + command);\n }\n\n previousCommand = command;\n });\n\n return pathInstance;\n}\n\nfunction elementsBoundingBox(elements, applyTransform, transformation) {\n var boundingBox;\n\n for (var i = 0; i < elements.length; i++) {\n var element = elements[i];\n if (element.visible()) {\n var elementBoundingBox = applyTransform ? element.bbox(transformation) : element.rawBBox();\n if (elementBoundingBox) {\n if (boundingBox) {\n boundingBox = Rect.union(boundingBox, elementBoundingBox);\n } else {\n boundingBox = elementBoundingBox;\n }\n }\n }\n }\n\n return boundingBox;\n}\n\nfunction elementsClippedBoundingBox(elements, transformation) {\n var boundingBox;\n\n for (var i = 0; i < elements.length; i++) {\n var element = elements[i];\n if (element.visible()) {\n var elementBoundingBox = element.clippedBBox(transformation);\n if (elementBoundingBox) {\n if (boundingBox) {\n boundingBox = Rect.union(boundingBox, elementBoundingBox);\n } else {\n boundingBox = elementBoundingBox;\n }\n }\n }\n }\n\n return boundingBox;\n}\n\nvar Path = (function (superclass) {\n function Path(options) {\n superclass.call(this, options);\n this.segments = new GeometryElementsArray();\n this.segments.addObserver(this);\n\n if (!defined(this.options.stroke)) {\n this.stroke(\"#000\");\n\n if (!defined(this.options.stroke.lineJoin)) {\n this.options.set(\"stroke.lineJoin\", \"miter\");\n }\n }\n }\n\n extendStatic(Path, superclass);\n Path.prototype = Object.create( superclass && superclass.prototype );\n Path.prototype.constructor = Path;\n Path.fn = Path.prototype;\n Path.fn.init = Path.fn.constructor;\n\n var prototypeAccessors = { nodeType: {} };\n\n Path.parse = function parse (str, options) {\n return MultiPath.parse(str, options);\n };\n\n prototypeAccessors.nodeType.get = function () {\n return \"Path\";\n };\n\n Path.prototype.moveTo = function moveTo (x, y) {\n this.suspend();\n this.segments.elements([]);\n this.resume();\n\n this.lineTo(x, y);\n\n return this;\n };\n\n Path.prototype.lineTo = function lineTo (x, y) {\n var point = defined(y) ? new Point(x, y) : x;\n var segment = new Segment(point);\n\n this.segments.push(segment);\n\n return this;\n };\n\n Path.prototype.curveTo = function curveTo (controlOut, controlIn, point) {\n if (this.segments.length > 0) {\n var lastSegment = last(this.segments);\n var segment = new Segment(point, controlIn);\n this.suspend();\n lastSegment.controlOut(controlOut);\n this.resume();\n\n this.segments.push(segment);\n }\n\n return this;\n };\n\n Path.prototype.arc = function arc (startAngle, endAngle, radiusX, radiusY, anticlockwise) {\n if (this.segments.length > 0) {\n var lastSegment = last(this.segments);\n var anchor = lastSegment.anchor();\n var start = rad(startAngle);\n var center = new Point(anchor.x - radiusX * Math.cos(start),\n anchor.y - radiusY * Math.sin(start));\n var arc = new Arc$2(center, {\n startAngle: startAngle,\n endAngle: endAngle,\n radiusX: radiusX,\n radiusY: radiusY,\n anticlockwise: anticlockwise\n });\n\n this._addArcSegments(arc);\n }\n\n return this;\n };\n\n Path.prototype.arcTo = function arcTo (end, rx, ry, largeArc, swipe, rotation) {\n if (this.segments.length > 0) {\n var lastSegment = last(this.segments);\n var anchor = lastSegment.anchor();\n var arc = Arc$2.fromPoints(anchor, Point.create(end), rx, ry, largeArc, swipe, rotation);\n\n this._addArcSegments(arc);\n }\n return this;\n };\n\n Path.prototype._addArcSegments = function _addArcSegments (arc) {\n var this$1 = this;\n\n this.suspend();\n\n var curvePoints = arc.curvePoints();\n\n for (var i = 1; i < curvePoints.length; i += 3) {\n this$1.curveTo(curvePoints[i], curvePoints[i + 1], curvePoints[i + 2]);\n }\n\n this.resume();\n this.geometryChange();\n };\n\n Path.prototype.close = function close () {\n this.options.closed = true;\n this.geometryChange();\n\n return this;\n };\n\n Path.prototype.rawBBox = function rawBBox () {\n return this._bbox();\n };\n\n Path.prototype._containsPoint = function _containsPoint (point) {\n var segments = this.segments;\n var length = segments.length;\n var intersectionsCount = 0;\n var previous, current;\n\n for (var idx = 1; idx < length; idx++) {\n previous = segments[idx - 1];\n current = segments[idx];\n intersectionsCount += previous._intersectionsTo(current, point);\n }\n\n if (this.options.closed || !segments[0].anchor().equals(segments[length - 1].anchor())) {\n intersectionsCount += lineIntersectionsCount(segments[0].anchor(), segments[length - 1].anchor(), point);\n }\n\n return intersectionsCount % 2 !== 0;\n };\n\n Path.prototype._isOnPath = function _isOnPath (point, width) {\n var segments = this.segments;\n var length = segments.length;\n var pathWidth = width || this.options.stroke.width;\n\n if (length > 1) {\n if (segments[0]._isOnPathTo(segments[1], point, pathWidth, \"start\")) {\n return true;\n }\n\n for (var idx = 2; idx <= length - 2; idx++) {\n if (segments[idx - 1]._isOnPathTo(segments[idx], point, pathWidth)) {\n return true;\n }\n }\n\n if (segments[length - 2]._isOnPathTo(segments[length - 1], point, pathWidth, \"end\")) {\n return true;\n }\n }\n return false;\n };\n\n Path.prototype._bbox = function _bbox (matrix) {\n var segments = this.segments;\n var length = segments.length;\n var boundingBox;\n\n if (length === 1) {\n var anchor = segments[0].anchor().transformCopy(matrix);\n boundingBox = new Rect(anchor, Size.ZERO);\n } else if (length > 0) {\n for (var i = 1; i < length; i++) {\n var segmentBox = segments[i - 1].bboxTo(segments[i], matrix);\n if (boundingBox) {\n boundingBox = Rect.union(boundingBox, segmentBox);\n } else {\n boundingBox = segmentBox;\n }\n }\n }\n\n return boundingBox;\n };\n\n Path.fromRect = function fromRect (rect, options) {\n var path = new Path(options);\n var ref = rect.cornerRadius;\n var rx = ref[0];\n var ry = ref[1];\n\n if (rx === 0 && ry === 0) {\n path.moveTo(rect.topLeft())\n .lineTo(rect.topRight())\n .lineTo(rect.bottomRight())\n .lineTo(rect.bottomLeft())\n .close();\n } else {\n var origin = rect.origin;\n var x = origin.x;\n var y = origin.y;\n var width = rect.width();\n var height = rect.height();\n rx = limitValue(rx, 0, width / 2);\n ry = limitValue(ry, 0, height / 2);\n\n path.moveTo(x + rx, y)\n .lineTo(x + width - rx, y)\n .arcTo([ x + width, y + ry ], rx, ry, false)\n .lineTo(x + width, y + height - ry)\n .arcTo([ x + width - rx, y + height ], rx, ry, false)\n .lineTo(x + rx, y + height)\n .arcTo([ x, y + height - ry ], rx, ry, false)\n .lineTo(x, y + ry)\n .arcTo([ x + rx, y ], rx, ry, false);\n }\n\n return path;\n };\n\n Path.fromPoints = function fromPoints (points, options) {\n if (points) {\n var path = new Path(options);\n\n for (var i = 0; i < points.length; i++) {\n var point = Point.create(points[i]);\n if (point) {\n if (i === 0) {\n path.moveTo(point);\n } else {\n path.lineTo(point);\n }\n }\n }\n\n return path;\n }\n };\n\n Path.fromArc = function fromArc (arc, options) {\n var path = new Path(options);\n var startAngle = arc.startAngle;\n var start = arc.pointAt(startAngle);\n path.moveTo(start.x, start.y);\n path.arc(startAngle, arc.endAngle, arc.radiusX, arc.radiusY, arc.anticlockwise);\n return path;\n };\n\n Object.defineProperties( Path.prototype, prototypeAccessors );\n\n return Path;\n}(paintable(measurable(Element$1))));\n\nvar MultiPath = (function (superclass) {\n function MultiPath(options) {\n superclass.call(this, options);\n this.paths = new GeometryElementsArray();\n this.paths.addObserver(this);\n\n if (!defined(this.options.stroke)) {\n this.stroke(\"#000\");\n }\n }\n\n extendStatic(MultiPath, superclass);\n MultiPath.prototype = Object.create( superclass && superclass.prototype );\n MultiPath.prototype.constructor = MultiPath;\n MultiPath.fn = MultiPath.prototype;\n MultiPath.fn.init = MultiPath.fn.constructor;\n\n var prototypeAccessors$1 = { nodeType: {} };\n\n MultiPath.parse = function parse (str, options) {\n var instance = new MultiPath(options);\n return parsePath(instance, str);\n };\n\n prototypeAccessors$1.nodeType.get = function () {\n return \"MultiPath\";\n };\n\n MultiPath.prototype.moveTo = function moveTo (x, y) {\n var path = new Path();\n path.moveTo(x, y);\n\n this.paths.push(path);\n\n return this;\n };\n\n MultiPath.prototype.lineTo = function lineTo (x, y) {\n if (this.paths.length > 0) {\n last(this.paths).lineTo(x, y);\n }\n\n return this;\n };\n\n MultiPath.prototype.curveTo = function curveTo (controlOut, controlIn, point) {\n if (this.paths.length > 0) {\n last(this.paths).curveTo(controlOut, controlIn, point);\n }\n\n return this;\n };\n\n MultiPath.prototype.arc = function arc (startAngle, endAngle, radiusX, radiusY, anticlockwise) {\n if (this.paths.length > 0) {\n last(this.paths).arc(startAngle, endAngle, radiusX, radiusY, anticlockwise);\n }\n\n return this;\n };\n\n MultiPath.prototype.arcTo = function arcTo (end, rx, ry, largeArc, swipe, rotation) {\n if (this.paths.length > 0) {\n last(this.paths).arcTo(end, rx, ry, largeArc, swipe, rotation);\n }\n\n return this;\n };\n\n MultiPath.prototype.close = function close () {\n if (this.paths.length > 0) {\n last(this.paths).close();\n }\n\n return this;\n };\n\n MultiPath.prototype._bbox = function _bbox (matrix) {\n return elementsBoundingBox(this.paths, true, matrix);\n };\n\n MultiPath.prototype.rawBBox = function rawBBox () {\n return elementsBoundingBox(this.paths, false);\n };\n\n MultiPath.prototype._containsPoint = function _containsPoint (point) {\n var paths = this.paths;\n\n for (var idx = 0; idx < paths.length; idx++) {\n if (paths[idx]._containsPoint(point)) {\n return true;\n }\n }\n return false;\n };\n\n MultiPath.prototype._isOnPath = function _isOnPath (point) {\n var paths = this.paths;\n var width = this.options.stroke.width;\n\n for (var idx = 0; idx < paths.length; idx++) {\n if (paths[idx]._isOnPath(point, width)) {\n return true;\n }\n }\n return false;\n };\n\n MultiPath.prototype._clippedBBox = function _clippedBBox (transformation) {\n return elementsClippedBoundingBox(this.paths, this.currentTransform(transformation));\n };\n\n Object.defineProperties( MultiPath.prototype, prototypeAccessors$1 );\n\n return MultiPath;\n}(paintable(measurable(Element$1))));\n\nvar DEFAULT_STROKE$1 = \"#000\";\n\nvar Arc = (function (superclass) {\n function Arc(geometry, options) {\n if (geometry === void 0) { geometry = new Arc$2(); }\n if (options === void 0) { options = {}; }\n\n superclass.call(this, options);\n\n this.geometry(geometry);\n\n if (!defined(this.options.stroke)) {\n this.stroke(DEFAULT_STROKE$1);\n }\n }\n\n extendStatic(Arc, superclass);\n Arc.prototype = Object.create( superclass && superclass.prototype );\n Arc.prototype.constructor = Arc;\n Arc.fn = Arc.prototype;\n Arc.fn.init = Arc.fn.constructor;\n\n var prototypeAccessors = { nodeType: {} };\n\n prototypeAccessors.nodeType.get = function () {\n return \"Arc\";\n };\n\n Arc.prototype._bbox = function _bbox (matrix) {\n return this._geometry.bbox(matrix);\n };\n\n Arc.prototype.rawBBox = function rawBBox () {\n return this.geometry().bbox();\n };\n\n Arc.prototype.toPath = function toPath () {\n var path = new Path();\n var curvePoints = this.geometry().curvePoints();\n\n if (curvePoints.length > 0) {\n path.moveTo(curvePoints[0].x, curvePoints[0].y);\n\n for (var i = 1; i < curvePoints.length; i += 3) {\n path.curveTo(curvePoints[i], curvePoints[i + 1], curvePoints[i + 2]);\n }\n }\n\n return path;\n };\n\n Arc.prototype._containsPoint = function _containsPoint (point) {\n return this.geometry().containsPoint(point);\n };\n\n Arc.prototype._isOnPath = function _isOnPath (point) {\n return this.geometry()._isOnPath(point, this.options.stroke.width / 2);\n };\n\n Object.defineProperties( Arc.prototype, prototypeAccessors );\n\n return Arc;\n}(paintable(measurable(withGeometry(Element$1)))));\n\nvar DEFAULT_FONT = \"12px sans-serif\";\nvar DEFAULT_FILL = \"#000\";\n\nvar Text = (function (superclass) {\n function Text(content, position, options) {\n if (position === void 0) { position = new Point(); }\n if (options === void 0) { options = {}; }\n\n superclass.call(this, options);\n\n this.content(content);\n this.position(position);\n\n if (!this.options.font) {\n this.options.font = DEFAULT_FONT;\n }\n\n if (!defined(this.options.fill)) {\n this.fill(DEFAULT_FILL);\n }\n }\n\n extendStatic(Text, superclass);\n Text.prototype = Object.create( superclass && superclass.prototype );\n Text.prototype.constructor = Text;\n Text.fn = Text.prototype;\n Text.fn.init = Text.fn.constructor;\n\n var prototypeAccessors = { nodeType: {} };\n\n prototypeAccessors.nodeType.get = function () {\n return \"Text\";\n };\n\n Text.prototype.content = function content (value) {\n if (defined(value)) {\n this.options.set(\"content\", value);\n return this;\n }\n\n return this.options.get(\"content\");\n };\n\n Text.prototype.measure = function measure () {\n var metrics = kendoUtil.measureText(this.content(), {\n font: this.options.get(\"font\")\n });\n\n return metrics;\n };\n\n Text.prototype.rect = function rect () {\n var size = this.measure();\n var pos = this.position().clone();\n return new Rect(pos, [ size.width, size.height ]);\n };\n\n Text.prototype.bbox = function bbox (transformation) {\n var combinedMatrix = toMatrix(this.currentTransform(transformation));\n return this.rect().bbox(combinedMatrix);\n };\n\n Text.prototype.rawBBox = function rawBBox () {\n return this.rect().bbox();\n };\n\n Text.prototype._containsPoint = function _containsPoint (point) {\n return this.rect().containsPoint(point);\n };\n\n Object.defineProperties( Text.prototype, prototypeAccessors );\n\n return Text;\n}(paintable(withPoints(Element$1, [ \"position\" ]))));\n\nvar Image$1 = (function (superclass) {\n function Image(src, rect, options) {\n if (rect === void 0) { rect = new Rect(); }\n if (options === void 0) { options = {}; }\n\n superclass.call(this, options);\n\n this.src(src);\n this.rect(rect);\n }\n\n extendStatic(Image, superclass);\n Image.prototype = Object.create( superclass && superclass.prototype );\n Image.prototype.constructor = Image;\n Image.fn = Image.prototype;\n Image.fn.init = Image.fn.constructor;\n\n var prototypeAccessors = { nodeType: {} };\n\n prototypeAccessors.nodeType.get = function () {\n return \"Image\";\n };\n\n Image.prototype.src = function src (value) {\n if (defined(value)) {\n this.options.set(\"src\", value);\n return this;\n }\n\n return this.options.get(\"src\");\n };\n\n Image.prototype.bbox = function bbox (transformation) {\n var combinedMatrix = toMatrix(this.currentTransform(transformation));\n return this._rect.bbox(combinedMatrix);\n };\n\n Image.prototype.rawBBox = function rawBBox () {\n return this._rect.bbox();\n };\n\n Image.prototype._containsPoint = function _containsPoint (point) {\n return this._rect.containsPoint(point);\n };\n\n Image.prototype._hasFill = function _hasFill () {\n return this.src();\n };\n\n Object.defineProperties( Image.prototype, prototypeAccessors );\n\n return Image;\n}(withGeometry(Element$1, [ \"rect\" ])));\n\nvar traversable = function (TBase, childrenField) { return (\n (function (TBase) {\n function anonymous () {\n TBase.apply(this, arguments);\n }\n\n extendStatic(anonymous, TBase);\n anonymous.prototype = Object.create( TBase && TBase.prototype );\n anonymous.prototype.constructor = anonymous;\n anonymous.fn = anonymous.prototype;\n anonymous.fn.init = anonymous.fn.constructor;\n\n anonymous.prototype.traverse = function traverse (callback) {\n var children = this[childrenField];\n\n for (var i = 0; i < children.length; i++) {\n var child = children[i];\n\n if (child.traverse) {\n child.traverse(callback);\n } else {\n callback(child);\n }\n }\n\n return this;\n };\n\n return anonymous;\n }(TBase))\n); };\n\nvar Group = (function (superclass) {\n function Group(options) {\n superclass.call(this, options);\n this.children = [];\n }\n\n extendStatic(Group, superclass);\n Group.prototype = Object.create( superclass && superclass.prototype );\n Group.prototype.constructor = Group;\n Group.fn = Group.prototype;\n Group.fn.init = Group.fn.constructor;\n\n var prototypeAccessors = { nodeType: {} };\n\n prototypeAccessors.nodeType.get = function () {\n return \"Group\";\n };\n\n Group.prototype.childrenChange = function childrenChange (action, items, index) {\n this.trigger(\"childrenChange\",{\n action: action,\n items: items,\n index: index\n });\n };\n\n Group.prototype.append = function append$1 () {\n append$1$1(this.children, arguments);\n this._reparent(arguments, this);\n\n this.childrenChange(\"add\", arguments);\n\n return this;\n };\n\n Group.prototype.insert = function insert (index, element) {\n this.children.splice(index, 0, element);\n element.parent = this;\n\n this.childrenChange(\"add\", [ element ], index);\n\n return this;\n };\n\n Group.prototype.insertAt = function insertAt (element, index) {\n return this.insert(index, element);\n };\n\n Group.prototype.remove = function remove (element) {\n var index = this.children.indexOf(element);\n if (index >= 0) {\n this.children.splice(index, 1);\n element.parent = null;\n this.childrenChange(\"remove\", [ element ], index);\n }\n\n return this;\n };\n\n Group.prototype.removeAt = function removeAt (index) {\n if (0 <= index && index < this.children.length) {\n var element = this.children[index];\n this.children.splice(index, 1);\n element.parent = null;\n this.childrenChange(\"remove\", [ element ], index);\n }\n\n return this;\n };\n\n Group.prototype.clear = function clear () {\n var items = this.children;\n this.children = [];\n this._reparent(items, null);\n\n this.childrenChange(\"remove\", items, 0);\n\n return this;\n };\n\n Group.prototype.bbox = function bbox (transformation) {\n return elementsBoundingBox(this.children, true, this.currentTransform(transformation));\n };\n\n Group.prototype.rawBBox = function rawBBox () {\n return elementsBoundingBox(this.children, false);\n };\n\n Group.prototype._clippedBBox = function _clippedBBox (transformation) {\n return elementsClippedBoundingBox(this.children, this.currentTransform(transformation));\n };\n\n Group.prototype.currentTransform = function currentTransform (transformation) {\n return Element$1.prototype.currentTransform.call(this, transformation) || null;\n };\n\n Group.prototype.containsPoint = function containsPoint (point, parentTransform) {\n if (this.visible()) {\n var children = this.children;\n var transform = this.currentTransform(parentTransform);\n for (var idx = 0; idx < children.length; idx++) {\n if (children[idx].containsPoint(point, transform)) {\n return true;\n }\n }\n }\n return false;\n };\n\n Group.prototype._reparent = function _reparent (elements, newParent) {\n var this$1 = this;\n\n for (var i = 0; i < elements.length; i++) {\n var child = elements[i];\n var parent = child.parent;\n if (parent && parent !== this$1 && parent.remove) {\n parent.remove(child);\n }\n\n child.parent = newParent;\n }\n };\n\n Object.defineProperties( Group.prototype, prototypeAccessors );\n\n return Group;\n}(traversable(Element$1, \"children\")));\n\nfunction translateToPoint(point, bbox, element) {\n var transofrm = element.transform() || transform$1();\n var matrix = transofrm.matrix();\n matrix.e += point.x - bbox.origin.x;\n matrix.f += point.y - bbox.origin.y;\n\n transofrm.matrix(matrix);\n element.transform(transofrm);\n}\n\nfunction alignStart(size, rect, align, axis, sizeField) {\n var start;\n if (align === \"start\") {\n start = rect.origin[axis];\n } else if (align === \"end\") {\n start = rect.origin[axis] + rect.size[sizeField] - size;\n } else {\n start = rect.origin[axis] + (rect.size[sizeField] - size) / 2;\n }\n\n return start;\n}\n\nfunction alignStartReverse(size, rect, align, axis, sizeField) {\n var start;\n if (align === \"start\") {\n start = rect.origin[axis] + rect.size[sizeField] - size;\n } else if (align === \"end\") {\n start = rect.origin[axis];\n } else {\n start = rect.origin[axis] + (rect.size[sizeField] - size) / 2;\n }\n\n return start;\n}\n\nvar DEFAULT_OPTIONS = {\n alignContent: \"start\",\n justifyContent: \"start\",\n alignItems: \"start\",\n spacing: 0,\n orientation: \"horizontal\",\n lineSpacing: 0,\n wrap: true,\n revers: false\n};\n\nvar forEach = function (elements, callback) {\n elements.forEach(callback);\n};\n\nvar forEachReverse = function (elements, callback) {\n var length = elements.length;\n\n for (var idx = length - 1; idx >= 0; idx--) {\n callback(elements[idx], idx);\n }\n};\n\nvar Layout = (function (Group$$1) {\n function Layout(rect, options) {\n Group$$1.call(this, $.extend({}, DEFAULT_OPTIONS, options));\n this._rect = rect;\n this._fieldMap = {};\n }\n\n extendStatic(Layout, Group$$1);\n Layout.prototype = Object.create( Group$$1 && Group$$1.prototype );\n Layout.prototype.constructor = Layout;\n Layout.fn = Layout.prototype;\n Layout.fn.init = Layout.fn.constructor;\n\n Layout.prototype.rect = function rect (value) {\n if (value) {\n this._rect = value;\n return this;\n }\n\n return this._rect;\n };\n\n Layout.prototype._initMap = function _initMap () {\n var options = this.options;\n var fieldMap = this._fieldMap;\n if (options.orientation === \"horizontal\") {\n fieldMap.sizeField = \"width\";\n fieldMap.groupsSizeField = \"height\";\n fieldMap.groupAxis = \"x\";\n fieldMap.groupsAxis = \"y\";\n } else {\n fieldMap.sizeField = \"height\";\n fieldMap.groupsSizeField = \"width\";\n fieldMap.groupAxis = \"y\";\n fieldMap.groupsAxis = \"x\";\n }\n\n if (options.reverse) {\n this.forEach = forEachReverse;\n this.justifyAlign = alignStartReverse;\n } else {\n this.forEach = forEach;\n this.justifyAlign = alignStart;\n }\n };\n\n Layout.prototype.reflow = function reflow () {\n var this$1 = this;\n\n if (!this._rect || this.children.length === 0) {\n return;\n }\n this._initMap();\n\n if (this.options.transform) {\n this.transform(null);\n }\n\n var options = this.options;\n var rect = this._rect;\n var ref = this._initGroups();\n var groups = ref.groups;\n var groupsSize = ref.groupsSize;\n var ref$1 = this._fieldMap;\n var sizeField = ref$1.sizeField;\n var groupsSizeField = ref$1.groupsSizeField;\n var groupAxis = ref$1.groupAxis;\n var groupsAxis = ref$1.groupsAxis;\n var groupOrigin = new Point();\n var elementOrigin = new Point();\n var size = new Size();\n var groupStart = alignStart(groupsSize, rect, options.alignContent, groupsAxis, groupsSizeField);\n var elementStart, group, groupBox;\n\n var arrangeElements = function (bbox, idx) {\n var element = group.elements[idx];\n\n elementOrigin[groupAxis] = elementStart;\n elementOrigin[groupsAxis] = alignStart(bbox.size[groupsSizeField], groupBox, options.alignItems, groupsAxis, groupsSizeField);\n translateToPoint(elementOrigin, bbox, element);\n elementStart += bbox.size[sizeField] + options.spacing;\n };\n\n for (var groupIdx = 0; groupIdx < groups.length; groupIdx++) {\n group = groups[groupIdx];\n groupOrigin[groupAxis] = elementStart = this$1.justifyAlign(group.size, rect, options.justifyContent, groupAxis, sizeField);\n groupOrigin[groupsAxis] = groupStart;\n size[sizeField] = group.size;\n size[groupsSizeField] = group.lineSize;\n groupBox = new Rect(groupOrigin, size);\n this$1.forEach(group.bboxes, arrangeElements);\n\n groupStart += group.lineSize + options.lineSpacing;\n }\n\n if (!options.wrap && group.size > rect.size[sizeField]) {\n var scale = rect.size[sizeField] / groupBox.size[sizeField];\n var scaledStart = groupBox.topLeft().scale(scale, scale);\n var scaledSize = groupBox.size[groupsSizeField] * scale;\n var newStart = alignStart(scaledSize, rect, options.alignContent, groupsAxis, groupsSizeField);\n var transform = transform$1();\n if (groupAxis === \"x\") {\n transform.translate(rect.origin.x - scaledStart.x, newStart - scaledStart.y);\n } else {\n transform.translate(newStart - scaledStart.x, rect.origin.y - scaledStart.y);\n }\n transform.scale(scale, scale);\n\n this.transform(transform);\n }\n };\n\n Layout.prototype._initGroups = function _initGroups () {\n var this$1 = this;\n\n var ref = this;\n var options = ref.options;\n var children = ref.children;\n var lineSpacing = options.lineSpacing;\n var wrap = options.wrap;\n var spacing = options.spacing;\n var sizeField = this._fieldMap.sizeField;\n var group = this._newGroup();\n var groups = [];\n var addGroup = function() {\n groups.push(group);\n groupsSize += group.lineSize + lineSpacing;\n };\n var groupsSize = -lineSpacing;\n\n for (var idx = 0; idx < children.length; idx++) {\n var element = children[idx];\n var bbox = children[idx].clippedBBox();\n if (element.visible() && bbox) {\n if (wrap && group.size + bbox.size[sizeField] + spacing > this$1._rect.size[sizeField]) {\n if (group.bboxes.length === 0) {\n this$1._addToGroup(group, bbox, element);\n addGroup();\n group = this$1._newGroup();\n } else {\n addGroup();\n group = this$1._newGroup();\n this$1._addToGroup(group, bbox, element);\n }\n } else {\n this$1._addToGroup(group, bbox, element);\n }\n }\n }\n\n if (group.bboxes.length) {\n addGroup();\n }\n\n return {\n groups: groups,\n groupsSize: groupsSize\n };\n };\n\n Layout.prototype._addToGroup = function _addToGroup (group, bbox, element) {\n group.size += bbox.size[this._fieldMap.sizeField] + this.options.spacing;\n group.lineSize = Math.max(bbox.size[this._fieldMap.groupsSizeField], group.lineSize);\n group.bboxes.push(bbox);\n group.elements.push(element);\n };\n\n Layout.prototype._newGroup = function _newGroup () {\n return {\n lineSize: 0,\n size: -this.options.spacing,\n bboxes: [],\n elements: []\n };\n };\n\n return Layout;\n}(Group));\n\nvar Rect$2 = (function (superclass) {\n function Rect$$1(geometry, options) {\n if (geometry === void 0) { geometry = new Rect(); }\n if (options === void 0) { options = {}; }\n\n superclass.call(this, options);\n\n this.geometry(geometry);\n\n if (!defined(this.options.stroke)) {\n this.stroke(\"#000\");\n }\n }\n\n extendStatic(Rect$$1, superclass);\n Rect$$1.prototype = Object.create( superclass && superclass.prototype );\n Rect$$1.prototype.constructor = Rect$$1;\n Rect$$1.fn = Rect$$1.prototype;\n Rect$$1.fn.init = Rect$$1.fn.constructor;\n\n var prototypeAccessors = { nodeType: {} };\n\n prototypeAccessors.nodeType.get = function () {\n return \"Rect\";\n };\n\n Rect$$1.prototype._bbox = function _bbox (matrix) {\n return this._geometry.bbox(matrix);\n };\n\n Rect$$1.prototype.rawBBox = function rawBBox () {\n return this._geometry.bbox();\n };\n\n Rect$$1.prototype._containsPoint = function _containsPoint (point) {\n return this._geometry.containsPoint(point);\n };\n\n Rect$$1.prototype._isOnPath = function _isOnPath (point) {\n return this.geometry()._isOnPath(point, this.options.stroke.width / 2);\n };\n\n Object.defineProperties( Rect$$1.prototype, prototypeAccessors );\n\n return Rect$$1;\n}(paintable(measurable(withGeometry(Element$1)))));\n\nfunction alignElements(elements, rect, alignment, axis, sizeField) {\n for (var idx = 0; idx < elements.length; idx++) {\n var bbox = elements[idx].clippedBBox();\n if (bbox) {\n var point = bbox.origin.clone();\n point[axis] = alignStart(bbox.size[sizeField], rect, alignment || \"start\", axis, sizeField);\n translateToPoint(point, bbox, elements[idx]);\n }\n }\n}\n\nfunction align(elements, rect, alignment) {\n alignElements(elements, rect, alignment, \"x\", \"width\");\n}\n\nfunction vAlign(elements, rect, alignment) {\n alignElements(elements, rect, alignment, \"y\", \"height\");\n}\n\nfunction stackElements(elements, stackAxis, otherAxis, sizeField) {\n if (elements.length > 1) {\n var origin = new Point();\n var previousBBox = elements[0].bbox;\n\n for (var idx = 1; idx < elements.length; idx++) {\n var element = elements[idx].element;\n var bbox = elements[idx].bbox;\n origin[stackAxis] = previousBBox.origin[stackAxis] + previousBBox.size[sizeField];\n origin[otherAxis] = bbox.origin[otherAxis];\n translateToPoint(origin, bbox, element);\n bbox.origin[stackAxis] = origin[stackAxis];\n previousBBox = bbox;\n }\n }\n}\n\nfunction createStackElements(elements) {\n var stackElements = [];\n\n for (var idx = 0; idx < elements.length; idx++) {\n var element = elements[idx];\n var bbox = element.clippedBBox();\n if (bbox) {\n stackElements.push({\n element: element,\n bbox: bbox\n });\n }\n }\n\n return stackElements;\n}\n\nfunction stack(elements) {\n stackElements(createStackElements(elements), \"x\", \"y\", \"width\");\n}\n\nfunction vStack(elements) {\n stackElements(createStackElements(elements), \"y\", \"x\", \"height\");\n}\n\nfunction getStacks(elements, rect, sizeField) {\n var maxSize = rect.size[sizeField];\n var stacks = [];\n var stack = [];\n var stackSize = 0;\n var element, bbox;\n\n var addElementToStack = function() {\n stack.push({\n element: element,\n bbox: bbox\n });\n };\n\n for (var idx = 0; idx < elements.length; idx++) {\n element = elements[idx];\n\n bbox = element.clippedBBox();\n if (bbox) {\n var size = bbox.size[sizeField];\n if (stackSize + size > maxSize) {\n if (stack.length) {\n stacks.push(stack);\n stack = [];\n addElementToStack();\n stackSize = size;\n } else {\n addElementToStack();\n stacks.push(stack);\n stack = [];\n stackSize = 0;\n }\n } else {\n addElementToStack();\n stackSize += size;\n }\n }\n }\n\n if (stack.length) {\n stacks.push(stack);\n }\n\n return stacks;\n}\n\nfunction wrapElements(elements, rect, axis, otherAxis, sizeField) {\n var stacks = getStacks(elements, rect, sizeField);\n var origin = rect.origin.clone();\n var result = [];\n\n for (var idx = 0; idx < stacks.length; idx++) {\n var stack = stacks[idx];\n var startElement = stack[0];\n origin[otherAxis] = startElement.bbox.origin[otherAxis];\n translateToPoint(origin, startElement.bbox, startElement.element);\n startElement.bbox.origin[axis] = origin[axis];\n stackElements(stack, axis, otherAxis, sizeField);\n result.push([]);\n for (var elementIdx = 0; elementIdx < stack.length; elementIdx++) {\n result[idx].push(stack[elementIdx].element);\n }\n }\n return result;\n}\n\nfunction wrap(elements, rect) {\n return wrapElements(elements, rect, \"x\", \"y\", \"width\");\n}\n\nfunction vWrap(elements, rect) {\n return wrapElements(elements, rect, \"y\", \"x\", \"height\");\n}\n\nfunction fit(element, rect) {\n var bbox = element.clippedBBox();\n if (bbox) {\n var elementSize = bbox.size;\n var rectSize = rect.size;\n if (rectSize.width < elementSize.width || rectSize.height < elementSize.height) {\n var scale = Math.min(rectSize.width / elementSize.width, rectSize.height / elementSize.height);\n var transform = element.transform() || transform$1();\n transform.scale(scale, scale);\n element.transform(transform);\n }\n }\n}\n\nvar StopsArray = (function (ElementsArray$$1) {\n function StopsArray () {\n ElementsArray$$1.apply(this, arguments);\n }\n\n extendStatic(StopsArray, ElementsArray$$1);\n StopsArray.prototype = Object.create( ElementsArray$$1 && ElementsArray$$1.prototype );\n StopsArray.prototype.constructor = StopsArray;\n StopsArray.fn = StopsArray.prototype;\n StopsArray.fn.init = StopsArray.fn.constructor;\n\n StopsArray.prototype._change = function _change () {\n this.optionsChange({\n field: \"stops\"\n });\n };\n\n return StopsArray;\n}(ElementsArray));\n\nfunction optionsAccessor(name) {\n return function(value) {\n if (defined(value)) {\n this.options.set(name, value);\n return this;\n }\n\n return this.options.get(name);\n };\n}\n\nfunction defineOptionsAccessors(fn, names) {\n for (var i = 0; i < names.length; i++) {\n fn[names[i]] = optionsAccessor(names[i]);\n }\n}\n\nvar withOptions = function (TBase, names) {\n var result = (function (TBase) {\n function result () {\n TBase.apply(this, arguments);\n }extendStatic(result, TBase);\n result.prototype = Object.create( TBase && TBase.prototype );\n result.prototype.constructor = result;\n result.fn = result.prototype;\n result.fn.init = result.fn.constructor;\n\n return result;\n }(TBase));\n defineOptionsAccessors(result.prototype, names);\n\n return result;\n};\n\nvar options = [ \"offset\", \"color\", \"opacity\" ];\n\nvar GradientStop = (function (superclass) {\n function GradientStop(offset, color, opacity) {\n superclass.call(this);\n\n this.options = new OptionsStore({\n offset: offset,\n color: color,\n opacity: defined(opacity) ? opacity : 1\n });\n\n this.options.addObserver(this);\n }\n\n extendStatic(GradientStop, superclass);\n GradientStop.prototype = Object.create( superclass && superclass.prototype );\n GradientStop.prototype.constructor = GradientStop;\n GradientStop.fn = GradientStop.prototype;\n GradientStop.fn.init = GradientStop.fn.constructor;\n\n GradientStop.create = function create (arg) {\n if (defined(arg)) {\n var stop;\n if (arg instanceof GradientStop) {\n stop = arg;\n } else if (arg.length > 1) {\n stop = new GradientStop(arg[0], arg[1], arg[2]);\n } else {\n stop = new GradientStop(arg.offset, arg.color, arg.opacity);\n }\n\n return stop;\n }\n };\n\n return GradientStop;\n}(withOptions(HasObservers, options)));\n\nvar Gradient = (function (HasObservers$$1) {\n function Gradient(options) {\n if (options === void 0) { options = {}; }\n\n HasObservers$$1.call(this);\n\n this.stops = new StopsArray(this._createStops(options.stops));\n this.stops.addObserver(this);\n this._userSpace = options.userSpace;\n this.id = definitionId();\n }\n\n extendStatic(Gradient, HasObservers$$1);\n Gradient.prototype = Object.create( HasObservers$$1 && HasObservers$$1.prototype );\n Gradient.prototype.constructor = Gradient;\n Gradient.fn = Gradient.prototype;\n Gradient.fn.init = Gradient.fn.constructor;\n\n var prototypeAccessors = { nodeType: {} };\n\n prototypeAccessors.nodeType.get = function () {\n return \"Gradient\";\n };\n\n Gradient.prototype.userSpace = function userSpace (value) {\n if (defined(value)) {\n this._userSpace = value;\n this.optionsChange();\n return this;\n }\n\n return this._userSpace;\n };\n\n Gradient.prototype._createStops = function _createStops (stops) {\n if (stops === void 0) { stops = []; }\n\n var result = [];\n for (var idx = 0; idx < stops.length; idx++) {\n result.push(GradientStop.create(stops[idx]));\n }\n\n return result;\n };\n\n Gradient.prototype.addStop = function addStop (offset, color, opacity) {\n this.stops.push(new GradientStop(offset, color, opacity));\n };\n\n Gradient.prototype.removeStop = function removeStop (stop) {\n var index = this.stops.indexOf(stop);\n if (index >= 0) {\n this.stops.splice(index, 1);\n }\n };\n\n Gradient.prototype.optionsChange = function optionsChange (e) {\n this.trigger(\"optionsChange\", {\n field: \"gradient\" + (e ? \".\" + e.field : \"\"),\n value: this\n });\n };\n\n Gradient.prototype.geometryChange = function geometryChange () {\n this.optionsChange();\n };\n\n Object.defineProperties( Gradient.prototype, prototypeAccessors );\n\n return Gradient;\n}(HasObservers));\n\nvar points$1 = [ \"start\", \"end\" ];\n\nvar LinearGradient = (function (superclass) {\n function LinearGradient(options) {\n if (options === void 0) { options = {}; }\n\n superclass.call(this, options);\n\n this.start(options.start || new Point());\n this.end(options.end || new Point(1, 0));\n }\n\n extendStatic(LinearGradient, superclass);\n LinearGradient.prototype = Object.create( superclass && superclass.prototype );\n LinearGradient.prototype.constructor = LinearGradient;\n LinearGradient.fn = LinearGradient.prototype;\n LinearGradient.fn.init = LinearGradient.fn.constructor;\n\n return LinearGradient;\n}(withPoints(Gradient, points$1)));\n\nvar RadialGradient = (function (superclass) {\n function RadialGradient(options) {\n if (options === void 0) { options = {}; }\n\n superclass.call(this, options);\n\n this.center(options.center || new Point());\n this._radius = defined(options.radius) ? options.radius : 1;\n this._fallbackFill = options.fallbackFill;\n }\n\n extendStatic(RadialGradient, superclass);\n RadialGradient.prototype = Object.create( superclass && superclass.prototype );\n RadialGradient.prototype.constructor = RadialGradient;\n RadialGradient.fn = RadialGradient.prototype;\n RadialGradient.fn.init = RadialGradient.fn.constructor;\n\n RadialGradient.prototype.radius = function radius (value) {\n if (defined(value)) {\n this._radius = value;\n this.geometryChange();\n return this;\n }\n\n return this._radius;\n };\n\n RadialGradient.prototype.fallbackFill = function fallbackFill (value) {\n if (defined(value)) {\n this._fallbackFill = value;\n this.optionsChange();\n return this;\n }\n\n return this._fallbackFill;\n };\n\n return RadialGradient;\n}(withPoints(Gradient, [ \"center\" ])));\n\nfunction swing(position) {\n return 0.5 - Math.cos(position * Math.PI) / 2;\n}\n\nfunction linear(position) {\n return position;\n}\n\nfunction easeOutElastic(position, time, start, diff) {\n var s = 1.70158,\n p = 0,\n a = diff;\n\n if (position === 0) {\n return start;\n }\n\n if (position === 1) {\n return start + diff;\n }\n\n if (!p) {\n p = 0.5;\n }\n\n if (a < Math.abs(diff)) {\n a = diff;\n s = p / 4;\n } else {\n s = p / (2 * Math.PI) * Math.asin(diff / a);\n }\n\n return a * Math.pow(2, -10 * position) *\n Math.sin((Number(position) - s) * (1.1 * Math.PI) / p) + diff + start;\n}\n\nvar easingFunctions = {\n\tswing: swing,\n\tlinear: linear,\n\teaseOutElastic: easeOutElastic\n};\n\nvar instance;\n\nvar AnimationFactory = (function (Class$$1) {\n function AnimationFactory() {\n Class$$1.call(this);\n\n this._items = [];\n }\n\n extendStatic(AnimationFactory, Class$$1);\n AnimationFactory.prototype = Object.create( Class$$1 && Class$$1.prototype );\n AnimationFactory.prototype.constructor = AnimationFactory;\n AnimationFactory.fn = AnimationFactory.prototype;\n AnimationFactory.fn.init = AnimationFactory.fn.constructor;\n\n var staticAccessors = { current: {} };\n\n staticAccessors.current.get = function () {\n if (!instance) {\n instance = new AnimationFactory();\n }\n\n return instance;\n };\n\n AnimationFactory.prototype.register = function register (name, type) {\n this._items.push({\n name: name,\n type: type\n });\n };\n\n AnimationFactory.prototype.create = function create (element, options) {\n var items = this._items;\n var match;\n\n if (options && options.type) {\n var type = options.type.toLowerCase();\n for (var i = 0; i < items.length; i++) {\n if (items[i].name.toLowerCase() === type) {\n match = items[i];\n break;\n }\n }\n }\n\n if (match) {\n return new match.type(element, options);\n }\n };\n\n Object.defineProperties( AnimationFactory, staticAccessors );\n\n return AnimationFactory;\n}(Class));\n\nvar Animation = (function (Class$$1) {\n function Animation(element, options) {\n Class$$1.call(this);\n\n this.options = $.extend({}, this.options, options);\n this.element = element;\n }\n\n extendStatic(Animation, Class$$1);\n Animation.prototype = Object.create( Class$$1 && Class$$1.prototype );\n Animation.prototype.constructor = Animation;\n Animation.fn = Animation.prototype;\n Animation.fn.init = Animation.fn.constructor;\n\n var prototypeAccessors = { options: {} };\n\n Animation.create = function create (type, element, options) {\n return AnimationFactory.current.create(type, element, options);\n };\n\n prototypeAccessors.options.get = function () {\n return this._options || {\n duration: 500,\n easing: \"swing\"\n };\n };\n\n prototypeAccessors.options.set = function (value) {\n this._options = value;\n };\n\n Animation.prototype.setup = function setup () {};\n Animation.prototype.step = function step () {};\n\n Animation.prototype.play = function play () {\n var this$1 = this;\n\n var options = this.options;\n var duration = options.duration;\n var delay = options.delay; if (delay === void 0) { delay = 0; }\n var easing = easingFunctions[options.easing];\n var start = now() + delay;\n var finish = start + duration;\n\n if (duration === 0) {\n this.step(1);\n this.abort();\n } else {\n setTimeout(function () {\n var loop = function () {\n if (this$1._stopped) {\n return;\n }\n\n var wallTime = now();\n\n var time = limitValue(wallTime - start, 0, duration);\n var position = time / duration;\n var easingPosition = easing(position, time, 0, 1, duration);\n\n this$1.step(easingPosition);\n\n if (wallTime < finish) {\n kendo.animationFrame(loop);\n } else {\n this$1.abort();\n }\n };\n\n loop();\n }, delay);\n }\n };\n\n Animation.prototype.abort = function abort () {\n this._stopped = true;\n };\n\n Animation.prototype.destroy = function destroy () {\n this.abort();\n };\n\n Object.defineProperties( Animation.prototype, prototypeAccessors );\n\n return Animation;\n}(Class));\n\nvar instance$1;\n\nvar PathParser = (function (Class$$1) {\n function PathParser () {\n Class$$1.apply(this, arguments);\n }\n\n extendStatic(PathParser, Class$$1);\n PathParser.prototype = Object.create( Class$$1 && Class$$1.prototype );\n PathParser.prototype.constructor = PathParser;\n PathParser.fn = PathParser.prototype;\n PathParser.fn.init = PathParser.fn.constructor;\n\n var staticAccessors = { current: {} };\n\n staticAccessors.current.get = function () {\n if (!instance$1) {\n instance$1 = new PathParser();\n }\n\n return instance$1;\n };\n\n PathParser.prototype.parse = function parse (str, options) {\n var multiPath = new MultiPath(options);\n return parsePath(multiPath, str);\n };\n\n Object.defineProperties( PathParser, staticAccessors );\n\n return PathParser;\n}(Class));\n\nvar BaseNode = (function (Class$$1) {\n function BaseNode(srcElement) {\n Class$$1.call(this);\n\n this.childNodes = [];\n this.parent = null;\n\n if (srcElement) {\n this.srcElement = srcElement;\n this.observe();\n }\n }\n\n extendStatic(BaseNode, Class$$1);\n BaseNode.prototype = Object.create( Class$$1 && Class$$1.prototype );\n BaseNode.prototype.constructor = BaseNode;\n BaseNode.fn = BaseNode.prototype;\n BaseNode.fn.init = BaseNode.fn.constructor;\n\n BaseNode.prototype.destroy = function destroy () {\n var this$1 = this;\n\n if (this.srcElement) {\n this.srcElement.removeObserver(this);\n }\n\n var children = this.childNodes;\n for (var i = 0; i < children.length; i++) {\n this$1.childNodes[i].destroy();\n }\n\n this.parent = null;\n };\n\n BaseNode.prototype.load = function load () {};\n\n BaseNode.prototype.observe = function observe () {\n if (this.srcElement) {\n this.srcElement.addObserver(this);\n }\n };\n\n BaseNode.prototype.append = function append (node) {\n this.childNodes.push(node);\n node.parent = this;\n };\n\n BaseNode.prototype.insertAt = function insertAt (node, pos) {\n this.childNodes.splice(pos, 0, node);\n node.parent = this;\n };\n\n BaseNode.prototype.remove = function remove (index, count) {\n var this$1 = this;\n\n var end = index + count;\n for (var i = index; i < end; i++) {\n this$1.childNodes[i].removeSelf();\n }\n this.childNodes.splice(index, count);\n };\n\n BaseNode.prototype.removeSelf = function removeSelf () {\n this.clear();\n this.destroy();\n };\n\n BaseNode.prototype.clear = function clear () {\n this.remove(0, this.childNodes.length);\n };\n\n BaseNode.prototype.invalidate = function invalidate () {\n if (this.parent) {\n this.parent.invalidate();\n }\n };\n\n BaseNode.prototype.geometryChange = function geometryChange () {\n this.invalidate();\n };\n\n BaseNode.prototype.optionsChange = function optionsChange () {\n this.invalidate();\n };\n\n BaseNode.prototype.childrenChange = function childrenChange (e) {\n if (e.action === \"add\") {\n this.load(e.items, e.index);\n } else if (e.action === \"remove\") {\n this.remove(e.index, e.items.length);\n }\n\n this.invalidate();\n };\n\n return BaseNode;\n}(Class));\n\nvar events = [\n \"click\",\n \"mouseenter\",\n \"mouseleave\",\n \"mousemove\",\n \"resize\"\n];\n\nvar Surface$2 = (function (Observable$$1) {\n function Surface(element, options) {\n Observable$$1.call(this);\n\n this.options = $.extend({}, options);\n this.element = element;\n this.element._kendoExportVisual = this.exportVisual.bind(this);\n\n this._click = this._handler(\"click\");\n this._mouseenter = this._handler(\"mouseenter\");\n this._mouseleave = this._handler(\"mouseleave\");\n this._mousemove = this._handler(\"mousemove\");\n\n this._visual = new Group();\n\n elementSize(element, this.options);\n\n this.bind(events, this.options);\n\n this._enableTracking();\n }\n\n extendStatic(Surface, Observable$$1);\n Surface.prototype = Object.create( Observable$$1 && Observable$$1.prototype );\n Surface.prototype.constructor = Surface;\n Surface.fn = Surface.prototype;\n Surface.fn.init = Surface.fn.constructor;\n\n Surface.prototype.draw = function draw (element) {\n this._visual.children.push(element);\n };\n\n Surface.prototype.clear = function clear () {\n this._visual.children = [];\n };\n\n Surface.prototype.destroy = function destroy () {\n this._visual = null;\n this.element._kendoExportVisual = null;\n this.unbind();\n };\n\n Surface.prototype.eventTarget = function eventTarget (e) {\n var this$1 = this;\n\n var domNode = eventElement(e);\n var node;\n\n while (!node && domNode) {\n node = domNode._kendoNode;\n if (domNode === this$1.element) {\n break;\n }\n\n domNode = domNode.parentElement;\n }\n\n if (node) {\n return node.srcElement;\n }\n };\n\n Surface.prototype.exportVisual = function exportVisual () {\n return this._visual;\n };\n\n Surface.prototype.getSize = function getSize () {\n return elementSize(this.element);\n };\n\n Surface.prototype.currentSize = function currentSize (size) {\n if (size) {\n this._size = size;\n } else {\n return this._size;\n }\n };\n\n Surface.prototype.setSize = function setSize (size) {\n elementSize(this.element, size);\n\n this.currentSize(size);\n this._resize();\n };\n\n Surface.prototype.resize = function resize (force) {\n var size = this.getSize();\n var currentSize = this.currentSize();\n\n if (force || (size.width > 0 || size.height > 0) && (!currentSize || size.width !== currentSize.width || size.height !== currentSize.height)) {\n this.currentSize(size);\n this._resize(size, force);\n this.trigger(\"resize\", size);\n }\n };\n\n Surface.prototype.size = function size (value) {\n if (!value) {\n return this.getSize();\n }\n\n this.setSize(value);\n };\n\n Surface.prototype.suspendTracking = function suspendTracking () {\n this._suspendedTracking = true;\n };\n\n Surface.prototype.resumeTracking = function resumeTracking () {\n this._suspendedTracking = false;\n };\n\n Surface.prototype._enableTracking = function _enableTracking () {};\n\n Surface.prototype._resize = function _resize () {};\n\n Surface.prototype._handler = function _handler (eventName) {\n var this$1 = this;\n\n return function (e) {\n var node = this$1.eventTarget(e);\n if (node && !this$1._suspendedTracking) {\n this$1.trigger(eventName, {\n element: node,\n originalEvent: e,\n type: eventName\n });\n }\n };\n };\n\n Surface.prototype._elementOffset = function _elementOffset () {\n var element = this.element;\n var padding = elementPadding(element);\n var ref = elementOffset(element);\n var left = ref.left;\n var top = ref.top;\n\n return {\n left: left + padding.left,\n top: top + padding.top\n };\n };\n\n Surface.prototype._surfacePoint = function _surfacePoint (e) {\n var offset = this._elementOffset();\n var coord = eventCoordinates(e);\n var x = coord.x - offset.left;\n var y = coord.y - offset.top;\n\n var inverseTransform = elementScale(this.element).invert();\n var point = new Point(\n x,\n y\n ).transform(inverseTransform);\n\n return point;\n };\n\n return Surface;\n}(kendo.Observable));\n\nfunction renderAttr(name, value) {\n return (defined(value) && value !== null) ? (\" \" + name + \"=\\\"\" + value + \"\\\" \") : \"\";\n}\n\nfunction renderAllAttr(attrs) {\n var output = \"\";\n for (var i = 0; i < attrs.length; i++) {\n output += renderAttr(attrs[i][0], attrs[i][1]);\n }\n\n return output;\n}\n\nfunction renderStyle(attrs) {\n var output = \"\";\n for (var i = 0; i < attrs.length; i++) {\n var value = attrs[i][1];\n if (defined(value)) {\n output += attrs[i][0] + \":\" + value + \";\";\n }\n }\n\n if (output !== \"\") {\n return output;\n }\n}\n\nvar NODE_MAP = {};\n\nvar SVG_NS = \"http://www.w3.org/2000/svg\";\nvar NONE = \"none\";\n\nvar renderSVG = function(container, svg) {\n container.innerHTML = svg;\n};\n\nif (typeof document !== \"undefined\") {\n var testFragment = \"\";\n var testContainer = document.createElement(\"div\");\n var hasParser = typeof DOMParser !== \"undefined\";\n\n testContainer.innerHTML = testFragment;\n\n if (hasParser && testContainer.firstChild.namespaceURI !== SVG_NS) {\n renderSVG = function(container, svg) {\n var parser = new DOMParser();\n var chartDoc = parser.parseFromString(svg, \"text/xml\");\n var importedDoc = document.adoptNode(chartDoc.documentElement);\n\n container.innerHTML = \"\";\n container.appendChild(importedDoc);\n };\n }\n}\n\nvar renderSVG$1 = renderSVG;\n\nvar TRANSFORM = \"transform\";\nvar DefinitionMap = {\n clip: \"clip-path\",\n fill: \"fill\"\n};\n\nfunction isDefinition(type, value) {\n return type === \"clip\" || (type === \"fill\" && (!value || value.nodeType === \"Gradient\"));\n}\n\nfunction baseUrl() {\n var base = document.getElementsByTagName(\"base\")[0];\n var href = document.location.href;\n var url = \"\";\n\n if (base && !(supportBrowser || {}).msie) {\n var hashIndex = href.indexOf(\"#\");\n if (hashIndex !== -1) {\n href = href.substring(0, hashIndex);\n }\n\n url = href;\n }\n\n return url;\n}\n\nvar Node = (function (BaseNode$$1) {\n function Node(srcElement, options) {\n BaseNode$$1.call(this, srcElement);\n this.definitions = {};\n\n this.options = options;\n }\n\n extendStatic(Node, BaseNode$$1);\n Node.prototype = Object.create( BaseNode$$1 && BaseNode$$1.prototype );\n Node.prototype.constructor = Node;\n Node.fn = Node.prototype;\n Node.fn.init = Node.fn.constructor;\n\n Node.prototype.destroy = function destroy () {\n if (this.element) {\n this.element._kendoNode = null;\n this.element = null;\n }\n\n this.clearDefinitions();\n BaseNode$$1.prototype.destroy.call(this);\n };\n\n Node.prototype.load = function load (elements, pos) {\n var this$1 = this;\n\n for (var i = 0; i < elements.length; i++) {\n var srcElement = elements[i];\n var children = srcElement.children;\n\n var childNode = new NODE_MAP[srcElement.nodeType](srcElement, this$1.options);\n\n if (defined(pos)) {\n this$1.insertAt(childNode, pos);\n } else {\n this$1.append(childNode);\n }\n\n childNode.createDefinitions();\n\n if (children && children.length > 0) {\n childNode.load(children);\n }\n\n var element = this$1.element;\n if (element) {\n childNode.attachTo(element, pos);\n }\n }\n };\n\n Node.prototype.root = function root () {\n var root = this;\n\n while (root.parent) {\n root = root.parent;\n }\n\n return root;\n };\n\n Node.prototype.attachTo = function attachTo (domElement, pos) {\n var container = document.createElement(\"div\");\n renderSVG$1(container,\n \"\" +\n this.render() +\n \"\"\n );\n\n var element = container.firstChild.firstChild;\n if (element) {\n if (defined(pos)) {\n domElement.insertBefore(element, domElement.childNodes[pos] || null);\n } else {\n domElement.appendChild(element);\n }\n this.setElement(element);\n }\n };\n\n Node.prototype.setElement = function setElement (element) {\n if (this.element) {\n this.element._kendoNode = null;\n }\n\n this.element = element;\n this.element._kendoNode = this;\n\n var nodes = this.childNodes;\n for (var i = 0; i < nodes.length; i++) {\n var childElement = element.childNodes[i];\n nodes[i].setElement(childElement);\n }\n };\n\n Node.prototype.clear = function clear () {\n this.clearDefinitions();\n\n if (this.element) {\n this.element.innerHTML = \"\";\n }\n\n var children = this.childNodes;\n for (var i = 0; i < children.length; i++) {\n children[i].destroy();\n }\n\n this.childNodes = [];\n };\n\n Node.prototype.removeSelf = function removeSelf () {\n if (this.element) {\n var parentNode = this.element.parentNode;\n if (parentNode) {\n parentNode.removeChild(this.element);\n }\n this.element = null;\n }\n\n BaseNode$$1.prototype.removeSelf.call(this);\n };\n\n Node.prototype.template = function template () {\n return this.renderChildren();\n };\n\n Node.prototype.render = function render () {\n return this.template();\n };\n\n Node.prototype.renderChildren = function renderChildren () {\n var nodes = this.childNodes;\n var output = \"\";\n\n for (var i = 0; i < nodes.length; i++) {\n output += nodes[i].render();\n }\n\n return output;\n };\n\n Node.prototype.optionsChange = function optionsChange (e) {\n var field = e.field;\n var value = e.value;\n\n if (field === \"visible\") {\n this.css(\"display\", value ? \"\" : NONE);\n } else if (DefinitionMap[field] && isDefinition(field, value)) {\n this.updateDefinition(field, value);\n } else if (field === \"opacity\") {\n this.attr(\"opacity\", value);\n } else if (field === \"cursor\") {\n this.css(\"cursor\", value);\n } else if (field === \"id\") {\n if (value) {\n this.attr(\"id\", value);\n } else {\n this.removeAttr(\"id\");\n }\n }\n\n BaseNode$$1.prototype.optionsChange.call(this, e);\n };\n\n Node.prototype.attr = function attr (name, value) {\n if (this.element) {\n this.element.setAttribute(name, value);\n }\n };\n\n Node.prototype.allAttr = function allAttr (attrs) {\n var this$1 = this;\n\n for (var i = 0; i < attrs.length; i++) {\n this$1.attr(attrs[i][0], attrs[i][1]);\n }\n };\n\n Node.prototype.css = function css (name, value) {\n if (this.element) {\n this.element.style[name] = value;\n }\n };\n\n Node.prototype.allCss = function allCss (styles) {\n var this$1 = this;\n\n for (var i = 0; i < styles.length; i++) {\n this$1.css(styles[i][0], styles[i][1]);\n }\n };\n\n Node.prototype.removeAttr = function removeAttr (name) {\n if (this.element) {\n this.element.removeAttribute(name);\n }\n };\n\n Node.prototype.mapTransform = function mapTransform (transform) {\n var attrs = [];\n if (transform) {\n attrs.push([\n TRANSFORM,\n \"matrix(\" + transform.matrix().toString(6) + \")\"\n ]);\n }\n\n return attrs;\n };\n\n Node.prototype.renderTransform = function renderTransform () {\n return renderAllAttr(\n this.mapTransform(this.srcElement.transform())\n );\n };\n\n Node.prototype.transformChange = function transformChange (value) {\n if (value) {\n this.allAttr(this.mapTransform(value));\n } else {\n this.removeAttr(TRANSFORM);\n }\n };\n\n Node.prototype.mapStyle = function mapStyle () {\n var options = this.srcElement.options;\n var style = [ [ \"cursor\", options.cursor ] ];\n\n if (options.visible === false) {\n style.push([ \"display\", NONE ]);\n }\n\n return style;\n };\n\n Node.prototype.renderStyle = function renderStyle$1 () {\n return renderAttr(\"style\", renderStyle(this.mapStyle(true)));\n };\n\n Node.prototype.renderOpacity = function renderOpacity () {\n return renderAttr(\"opacity\", this.srcElement.options.opacity);\n };\n\n Node.prototype.renderId = function renderId () {\n return renderAttr(\"id\", this.srcElement.options.id);\n };\n\n Node.prototype.createDefinitions = function createDefinitions () {\n var srcElement = this.srcElement;\n var definitions = this.definitions;\n if (srcElement) {\n var options = srcElement.options;\n var hasDefinitions;\n\n for (var field in DefinitionMap) {\n var definition = options.get(field);\n if (definition && isDefinition(field, definition)) {\n definitions[field] = definition;\n hasDefinitions = true;\n }\n }\n if (hasDefinitions) {\n this.definitionChange({\n action: \"add\",\n definitions: definitions\n });\n }\n }\n };\n\n Node.prototype.definitionChange = function definitionChange (e) {\n if (this.parent) {\n this.parent.definitionChange(e);\n }\n };\n\n Node.prototype.updateDefinition = function updateDefinition (type, value) {\n var definitions = this.definitions;\n var current = definitions[type];\n var attr = DefinitionMap[type];\n var definition = {};\n if (current) {\n definition[type] = current;\n this.definitionChange({\n action: \"remove\",\n definitions: definition\n });\n delete definitions[type];\n }\n\n if (!value) {\n if (current) {\n this.removeAttr(attr);\n }\n } else {\n definition[type] = value;\n this.definitionChange({\n action: \"add\",\n definitions: definition\n });\n definitions[type] = value;\n this.attr(attr, this.refUrl(value.id));\n }\n };\n\n Node.prototype.clearDefinitions = function clearDefinitions () {\n var definitions = this.definitions;\n\n this.definitionChange({\n action: \"remove\",\n definitions: definitions\n });\n this.definitions = {};\n };\n\n Node.prototype.renderDefinitions = function renderDefinitions () {\n return renderAllAttr(this.mapDefinitions());\n };\n\n Node.prototype.mapDefinitions = function mapDefinitions () {\n var this$1 = this;\n\n var definitions = this.definitions;\n var attrs = [];\n\n for (var field in definitions) {\n attrs.push([ DefinitionMap[field], this$1.refUrl(definitions[field].id) ]);\n }\n\n return attrs;\n };\n\n Node.prototype.refUrl = function refUrl (id) {\n var skipBaseHref = (this.options || {}).skipBaseHref;\n var baseHref = this.baseUrl().replace(/'/g, \"\\\\'\");\n var base = skipBaseHref ? '' : baseHref;\n return (\"url(\" + base + \"#\" + id + \")\");\n };\n\n Node.prototype.baseUrl = function baseUrl$1 () {\n return baseUrl();\n };\n\n return Node;\n}(BaseNode));\n\nvar GradientStopNode = (function (Node$$1) {\n function GradientStopNode () {\n Node$$1.apply(this, arguments);\n }\n\n extendStatic(GradientStopNode, Node$$1);\n GradientStopNode.prototype = Object.create( Node$$1 && Node$$1.prototype );\n GradientStopNode.prototype.constructor = GradientStopNode;\n GradientStopNode.fn = GradientStopNode.prototype;\n GradientStopNode.fn.init = GradientStopNode.fn.constructor;\n\n GradientStopNode.prototype.template = function template () {\n return (\"\");\n };\n\n GradientStopNode.prototype.renderOffset = function renderOffset () {\n return renderAttr(\"offset\", this.srcElement.offset());\n };\n\n GradientStopNode.prototype.mapStyle = function mapStyle () {\n var srcElement = this.srcElement;\n return [\n [ \"stop-color\", srcElement.color() ],\n [ \"stop-opacity\", srcElement.opacity() ]\n ];\n };\n\n GradientStopNode.prototype.optionsChange = function optionsChange (e) {\n if (e.field === \"offset\") {\n this.attr(e.field, e.value);\n } else if (e.field === \"color\" || e.field === \"opacity\") {\n this.css(\"stop-\" + e.field, e.value);\n }\n };\n\n return GradientStopNode;\n}(Node));\n\nvar GradientNode = (function (Node$$1) {\n function GradientNode(srcElement) {\n Node$$1.call(this, srcElement);\n\n this.id = srcElement.id;\n\n this.loadStops();\n }\n\n extendStatic(GradientNode, Node$$1);\n GradientNode.prototype = Object.create( Node$$1 && Node$$1.prototype );\n GradientNode.prototype.constructor = GradientNode;\n GradientNode.fn = GradientNode.prototype;\n GradientNode.fn.init = GradientNode.fn.constructor;\n\n GradientNode.prototype.loadStops = function loadStops () {\n var this$1 = this;\n\n var stops = this.srcElement.stops;\n var element = this.element;\n\n for (var idx = 0; idx < stops.length; idx++) {\n var stopNode = new GradientStopNode(stops[idx]);\n this$1.append(stopNode);\n if (element) {\n stopNode.attachTo(element);\n }\n }\n };\n\n GradientNode.prototype.optionsChange = function optionsChange (e) {\n if (e.field === \"gradient.stops\") {\n BaseNode.prototype.clear.call(this);\n this.loadStops();\n } else if (e.field === \"gradient\") {\n this.allAttr(this.mapCoordinates());\n }\n };\n\n GradientNode.prototype.renderCoordinates = function renderCoordinates () {\n return renderAllAttr(this.mapCoordinates());\n };\n\n GradientNode.prototype.mapSpace = function mapSpace () {\n return [ \"gradientUnits\", this.srcElement.userSpace() ? \"userSpaceOnUse\" : \"objectBoundingBox\" ];\n };\n\n return GradientNode;\n}(Node));\n\nvar LinearGradientNode = (function (GradientNode$$1) {\n function LinearGradientNode () {\n GradientNode$$1.apply(this, arguments);\n }\n\n extendStatic(LinearGradientNode, GradientNode$$1);\n LinearGradientNode.prototype = Object.create( GradientNode$$1 && GradientNode$$1.prototype );\n LinearGradientNode.prototype.constructor = LinearGradientNode;\n LinearGradientNode.fn = LinearGradientNode.prototype;\n LinearGradientNode.fn.init = LinearGradientNode.fn.constructor;\n\n LinearGradientNode.prototype.template = function template () {\n return (\"\" + (this.renderChildren()) + \"\");\n };\n\n LinearGradientNode.prototype.mapCoordinates = function mapCoordinates () {\n var srcElement = this.srcElement;\n var start = srcElement.start();\n var end = srcElement.end();\n var attrs = [\n [ \"x1\", start.x ],\n [ \"y1\", start.y ],\n [ \"x2\", end.x ],\n [ \"y2\", end.y ],\n this.mapSpace()\n ];\n\n return attrs;\n };\n\n return LinearGradientNode;\n}(GradientNode));\n\nvar RadialGradientNode = (function (GradientNode$$1) {\n function RadialGradientNode () {\n GradientNode$$1.apply(this, arguments);\n }\n\n extendStatic(RadialGradientNode, GradientNode$$1);\n RadialGradientNode.prototype = Object.create( GradientNode$$1 && GradientNode$$1.prototype );\n RadialGradientNode.prototype.constructor = RadialGradientNode;\n RadialGradientNode.fn = RadialGradientNode.prototype;\n RadialGradientNode.fn.init = RadialGradientNode.fn.constructor;\n\n RadialGradientNode.prototype.template = function template () {\n return (\"\" + (this.renderChildren()) + \"\");\n };\n\n RadialGradientNode.prototype.mapCoordinates = function mapCoordinates () {\n var srcElement = this.srcElement;\n var center = srcElement.center();\n var radius = srcElement.radius();\n var attrs = [\n [ \"cx\", center.x ],\n [ \"cy\", center.y ],\n [ \"r\", radius ],\n this.mapSpace()\n ];\n return attrs;\n };\n\n return RadialGradientNode;\n}(GradientNode));\n\nvar ClipNode = (function (Node$$1) {\n function ClipNode(srcElement) {\n Node$$1.call(this);\n\n this.srcElement = srcElement;\n this.id = srcElement.id;\n\n this.load([ srcElement ]);\n }\n\n extendStatic(ClipNode, Node$$1);\n ClipNode.prototype = Object.create( Node$$1 && Node$$1.prototype );\n ClipNode.prototype.constructor = ClipNode;\n ClipNode.fn = ClipNode.prototype;\n ClipNode.fn.init = ClipNode.fn.constructor;\n\n ClipNode.prototype.template = function template () {\n return (\"\" + (this.renderChildren()) + \"\");\n };\n\n return ClipNode;\n}(Node));\n\nvar DefinitionNode = (function (Node$$1) {\n function DefinitionNode() {\n Node$$1.call(this);\n this.definitionMap = {};\n }\n\n extendStatic(DefinitionNode, Node$$1);\n DefinitionNode.prototype = Object.create( Node$$1 && Node$$1.prototype );\n DefinitionNode.prototype.constructor = DefinitionNode;\n DefinitionNode.fn = DefinitionNode.prototype;\n DefinitionNode.fn.init = DefinitionNode.fn.constructor;\n\n DefinitionNode.prototype.attachTo = function attachTo (domElement) {\n this.element = domElement;\n };\n\n DefinitionNode.prototype.template = function template () {\n return (\"\" + (this.renderChildren()) + \"\");\n };\n\n DefinitionNode.prototype.definitionChange = function definitionChange (e) {\n var definitions = e.definitions;\n var action = e.action;\n\n if (action === \"add\") {\n this.addDefinitions(definitions);\n } else if (action === \"remove\") {\n this.removeDefinitions(definitions);\n }\n };\n\n DefinitionNode.prototype.createDefinition = function createDefinition (type, item) {\n var nodeType;\n if (type === \"clip\") {\n nodeType = ClipNode;\n } else if (type === \"fill\") {\n if (item instanceof LinearGradient) {\n nodeType = LinearGradientNode;\n } else if (item instanceof RadialGradient) {\n nodeType = RadialGradientNode;\n }\n }\n return new nodeType(item);\n };\n\n DefinitionNode.prototype.addDefinitions = function addDefinitions (definitions) {\n var this$1 = this;\n\n for (var field in definitions) {\n this$1.addDefinition(field, definitions[field]);\n }\n };\n\n DefinitionNode.prototype.addDefinition = function addDefinition (type, srcElement) {\n var ref = this;\n var element = ref.element;\n var definitionMap = ref.definitionMap;\n var id = srcElement.id;\n var mapItem = definitionMap[id];\n if (!mapItem) {\n var node = this.createDefinition(type, srcElement);\n definitionMap[id] = {\n element: node,\n count: 1\n };\n this.append(node);\n if (element) {\n node.attachTo(this.element);\n }\n } else {\n mapItem.count++;\n }\n };\n\n DefinitionNode.prototype.removeDefinitions = function removeDefinitions (definitions) {\n var this$1 = this;\n\n for (var field in definitions) {\n this$1.removeDefinition(definitions[field]);\n }\n };\n\n DefinitionNode.prototype.removeDefinition = function removeDefinition (srcElement) {\n var definitionMap = this.definitionMap;\n var id = srcElement.id;\n var mapItem = definitionMap[id];\n\n if (mapItem) {\n mapItem.count--;\n if (mapItem.count === 0) {\n this.remove(this.childNodes.indexOf(mapItem.element), 1);\n delete definitionMap[id];\n }\n }\n };\n\n return DefinitionNode;\n}(Node));\n\nvar RootNode = (function (Node$$1) {\n function RootNode(options) {\n Node$$1.call(this);\n this.options = options;\n this.defs = new DefinitionNode();\n }\n\n extendStatic(RootNode, Node$$1);\n RootNode.prototype = Object.create( Node$$1 && Node$$1.prototype );\n RootNode.prototype.constructor = RootNode;\n RootNode.fn = RootNode.prototype;\n RootNode.fn.init = RootNode.fn.constructor;\n\n RootNode.prototype.attachTo = function attachTo (domElement) {\n this.element = domElement;\n this.defs.attachTo(domElement.firstElementChild);\n };\n\n RootNode.prototype.clear = function clear () {\n BaseNode.prototype.clear.call(this);\n };\n\n RootNode.prototype.template = function template () {\n return this.defs.render() + this.renderChildren();\n };\n\n RootNode.prototype.definitionChange = function definitionChange (e) {\n this.defs.definitionChange(e);\n };\n\n return RootNode;\n}(Node));\n\nvar DASH_ARRAYS = {\n dot: [ 1.5, 3.5 ],\n dash: [ 4, 3.5 ],\n longdash: [ 8, 3.5 ],\n dashdot: [ 3.5, 3.5, 1.5, 3.5 ],\n longdashdot: [ 8, 3.5, 1.5, 3.5 ],\n longdashdotdot: [ 8, 3.5, 1.5, 3.5, 1.5, 3.5 ]\n};\n\nvar SOLID = \"solid\";\nvar BUTT = \"butt\";\n\nvar ATTRIBUTE_MAP = {\n \"fill.opacity\": \"fill-opacity\",\n \"stroke.color\": \"stroke\",\n \"stroke.width\": \"stroke-width\",\n \"stroke.opacity\": \"stroke-opacity\"\n};\nvar SPACE = \" \";\n\nvar PathNode = (function (Node$$1) {\n function PathNode () {\n Node$$1.apply(this, arguments);\n }\n\n extendStatic(PathNode, Node$$1);\n PathNode.prototype = Object.create( Node$$1 && Node$$1.prototype );\n PathNode.prototype.constructor = PathNode;\n PathNode.fn = PathNode.prototype;\n PathNode.fn.init = PathNode.fn.constructor;\n\n PathNode.prototype.geometryChange = function geometryChange () {\n this.attr(\"d\", this.renderData());\n this.invalidate();\n };\n\n PathNode.prototype.optionsChange = function optionsChange (e) {\n switch (e.field) {\n case \"fill\":\n if (e.value) {\n this.allAttr(this.mapFill(e.value));\n } else {\n this.removeAttr(\"fill\");\n }\n break;\n\n case \"fill.color\":\n this.allAttr(this.mapFill({ color: e.value }));\n break;\n\n case \"stroke\":\n if (e.value) {\n this.allAttr(this.mapStroke(e.value));\n } else {\n this.removeAttr(\"stroke\");\n }\n break;\n\n case \"transform\":\n this.transformChange(e.value);\n break;\n\n default:\n var name = ATTRIBUTE_MAP[e.field];\n if (name) {\n this.attr(name, e.value);\n }\n break;\n }\n\n Node$$1.prototype.optionsChange.call(this, e);\n };\n\n PathNode.prototype.content = function content () {\n if (this.element) {\n this.element.textContent = this.srcElement.content();\n }\n };\n\n PathNode.prototype.renderData = function renderData () {\n return this.printPath(this.srcElement);\n };\n\n PathNode.prototype.printPath = function printPath (path) {\n var this$1 = this;\n\n var segments = path.segments;\n var length = segments.length;\n if (length > 0) {\n var parts = [];\n var output, currentType;\n\n for (var i = 1; i < length; i++) {\n var segmentType = this$1.segmentType(segments[i - 1], segments[i]);\n if (segmentType !== currentType) {\n currentType = segmentType;\n parts.push(segmentType);\n }\n\n if (segmentType === \"L\") {\n parts.push(this$1.printPoints(segments[i].anchor()));\n } else {\n parts.push(this$1.printPoints(segments[i - 1].controlOut(), segments[i].controlIn(), segments[i].anchor()));\n }\n }\n\n output = \"M\" + this.printPoints(segments[0].anchor()) + SPACE + parts.join(SPACE);\n if (path.options.closed) {\n output += \"Z\";\n }\n\n return output;\n }\n };\n\n PathNode.prototype.printPoints = function printPoints () {\n var points = arguments;\n var length = points.length;\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(points[i].toString(3));\n }\n\n return result.join(\" \");\n };\n\n PathNode.prototype.segmentType = function segmentType (segmentStart, segmentEnd) {\n return segmentStart.controlOut() && segmentEnd.controlIn() ? \"C\" : \"L\";\n };\n\n PathNode.prototype.mapStroke = function mapStroke (stroke) {\n var attrs = [];\n\n if (stroke && !isTransparent(stroke.color)) {\n attrs.push([ \"stroke\", stroke.color ]);\n attrs.push([ \"stroke-width\", stroke.width ]);\n attrs.push([ \"stroke-linecap\", this.renderLinecap(stroke) ]);\n attrs.push([ \"stroke-linejoin\", stroke.lineJoin ]);\n\n if (defined(stroke.opacity)) {\n attrs.push([ \"stroke-opacity\", stroke.opacity ]);\n }\n\n if (defined(stroke.dashType)) {\n attrs.push([ \"stroke-dasharray\", this.renderDashType(stroke) ]);\n }\n } else {\n attrs.push([ \"stroke\", NONE ]);\n }\n\n return attrs;\n };\n\n PathNode.prototype.renderStroke = function renderStroke () {\n return renderAllAttr(\n this.mapStroke(this.srcElement.options.stroke)\n );\n };\n\n PathNode.prototype.renderDashType = function renderDashType (stroke) {\n var dashType = stroke.dashType;\n var width = stroke.width; if (width === void 0) { width = 1; }\n\n if (dashType && dashType !== SOLID) {\n var dashArray = DASH_ARRAYS[dashType.toLowerCase()];\n var result = [];\n\n for (var i = 0; i < dashArray.length; i++) {\n result.push(dashArray[i] * width);\n }\n\n return result.join(\" \");\n }\n };\n\n PathNode.prototype.renderLinecap = function renderLinecap (stroke) {\n var dashType = stroke.dashType;\n var lineCap = stroke.lineCap;\n\n return (dashType && dashType !== \"solid\") ? BUTT : lineCap;\n };\n\n PathNode.prototype.mapFill = function mapFill (fill) {\n var attrs = [];\n if (!(fill && fill.nodeType === \"Gradient\")) {\n if (fill && !isTransparent(fill.color)) {\n attrs.push([ \"fill\", fill.color ]);\n\n if (defined(fill.opacity)) {\n attrs.push([ \"fill-opacity\", fill.opacity ]);\n }\n } else {\n attrs.push([ \"fill\", NONE ]);\n }\n }\n\n return attrs;\n };\n\n PathNode.prototype.renderFill = function renderFill () {\n return renderAllAttr(\n this.mapFill(this.srcElement.options.fill)\n );\n };\n\n PathNode.prototype.template = function template () {\n return \"\";\n };\n\n return PathNode;\n}(Node));\n\nvar ArcNode = (function (PathNode$$1) {\n function ArcNode () {\n PathNode$$1.apply(this, arguments);\n }\n\n extendStatic(ArcNode, PathNode$$1);\n ArcNode.prototype = Object.create( PathNode$$1 && PathNode$$1.prototype );\n ArcNode.prototype.constructor = ArcNode;\n ArcNode.fn = ArcNode.prototype;\n ArcNode.fn.init = ArcNode.fn.constructor;\n\n ArcNode.prototype.renderData = function renderData () {\n return this.printPath(this.srcElement.toPath());\n };\n\n return ArcNode;\n}(PathNode));\n\nvar CircleNode = (function (PathNode$$1) {\n function CircleNode () {\n PathNode$$1.apply(this, arguments);\n }\n\n extendStatic(CircleNode, PathNode$$1);\n CircleNode.prototype = Object.create( PathNode$$1 && PathNode$$1.prototype );\n CircleNode.prototype.constructor = CircleNode;\n CircleNode.fn = CircleNode.prototype;\n CircleNode.fn.init = CircleNode.fn.constructor;\n\n CircleNode.prototype.geometryChange = function geometryChange () {\n var center = this.center();\n this.attr(\"cx\", center.x);\n this.attr(\"cy\", center.y);\n this.attr(\"r\", this.radius());\n this.invalidate();\n };\n\n CircleNode.prototype.center = function center () {\n return this.srcElement.geometry().center;\n };\n\n CircleNode.prototype.radius = function radius () {\n return this.srcElement.geometry().radius;\n };\n\n CircleNode.prototype.template = function template () {\n return \"\";\n };\n\n return CircleNode;\n}(PathNode));\n\nvar GroupNode = (function (Node$$1) {\n function GroupNode () {\n Node$$1.apply(this, arguments);\n }\n\n extendStatic(GroupNode, Node$$1);\n GroupNode.prototype = Object.create( Node$$1 && Node$$1.prototype );\n GroupNode.prototype.constructor = GroupNode;\n GroupNode.fn = GroupNode.prototype;\n GroupNode.fn.init = GroupNode.fn.constructor;\n\n GroupNode.prototype.template = function template () {\n return (\"\" + (this.renderChildren()) + \"\");\n };\n\n GroupNode.prototype.optionsChange = function optionsChange (e) {\n if (e.field === \"transform\") {\n this.transformChange(e.value);\n }\n\n Node$$1.prototype.optionsChange.call(this, e);\n };\n\n return GroupNode;\n}(Node));\n\nvar ImageNode = (function (PathNode$$1) {\n function ImageNode () {\n PathNode$$1.apply(this, arguments);\n }\n\n extendStatic(ImageNode, PathNode$$1);\n ImageNode.prototype = Object.create( PathNode$$1 && PathNode$$1.prototype );\n ImageNode.prototype.constructor = ImageNode;\n ImageNode.fn = ImageNode.prototype;\n ImageNode.fn.init = ImageNode.fn.constructor;\n\n ImageNode.prototype.geometryChange = function geometryChange () {\n this.allAttr(this.mapPosition());\n this.invalidate();\n };\n\n ImageNode.prototype.optionsChange = function optionsChange (e) {\n if (e.field === \"src\") {\n this.allAttr(this.mapSource());\n }\n\n PathNode$$1.prototype.optionsChange.call(this, e);\n };\n\n ImageNode.prototype.mapPosition = function mapPosition () {\n var rect = this.srcElement.rect();\n var tl = rect.topLeft();\n\n return [\n [ \"x\", tl.x ],\n [ \"y\", tl.y ],\n [ \"width\", rect.width() + \"px\" ],\n [ \"height\", rect.height() + \"px\" ]\n ];\n };\n\n ImageNode.prototype.renderPosition = function renderPosition () {\n return renderAllAttr(this.mapPosition());\n };\n\n ImageNode.prototype.mapSource = function mapSource (encode) {\n var src = this.srcElement.src();\n\n if (encode) {\n src = kendo.htmlEncode(src);\n }\n\n return [ [ \"xlink:href\", src ] ];\n };\n\n ImageNode.prototype.renderSource = function renderSource () {\n return renderAllAttr(this.mapSource(true));\n };\n\n ImageNode.prototype.template = function template () {\n return \"\" +\n \"\";\n };\n\n return ImageNode;\n}(PathNode));\n\nvar MultiPathNode = (function (PathNode$$1) {\n function MultiPathNode () {\n PathNode$$1.apply(this, arguments);\n }\n\n extendStatic(MultiPathNode, PathNode$$1);\n MultiPathNode.prototype = Object.create( PathNode$$1 && PathNode$$1.prototype );\n MultiPathNode.prototype.constructor = MultiPathNode;\n MultiPathNode.fn = MultiPathNode.prototype;\n MultiPathNode.fn.init = MultiPathNode.fn.constructor;\n\n MultiPathNode.prototype.renderData = function renderData () {\n var this$1 = this;\n\n var paths = this.srcElement.paths;\n\n if (paths.length > 0) {\n var result = [];\n\n for (var i = 0; i < paths.length; i++) {\n result.push(this$1.printPath(paths[i]));\n }\n\n return result.join(\" \");\n }\n };\n\n return MultiPathNode;\n}(PathNode));\n\nvar RectNode = (function (PathNode$$1) {\n function RectNode () {\n PathNode$$1.apply(this, arguments);\n }\n\n extendStatic(RectNode, PathNode$$1);\n RectNode.prototype = Object.create( PathNode$$1 && PathNode$$1.prototype );\n RectNode.prototype.constructor = RectNode;\n RectNode.fn = RectNode.prototype;\n RectNode.fn.init = RectNode.fn.constructor;\n\n RectNode.prototype.geometryChange = function geometryChange () {\n var geometry = this.srcElement.geometry();\n this.attr(\"x\", geometry.origin.x);\n this.attr(\"y\", geometry.origin.y);\n this.attr(\"width\", geometry.size.width);\n this.attr(\"height\", geometry.size.height);\n this.attr(\"rx\", geometry.cornerRadius[0]);\n this.attr(\"ry\", geometry.cornerRadius[1]);\n this.invalidate();\n };\n\n RectNode.prototype.size = function size () {\n return this.srcElement.geometry().size;\n };\n\n RectNode.prototype.origin = function origin () {\n return this.srcElement.geometry().origin;\n };\n\n RectNode.prototype.rx = function rx () {\n return this.srcElement.geometry().cornerRadius[0];\n };\n\n RectNode.prototype.ry = function ry () {\n return this.srcElement.geometry().cornerRadius[1];\n };\n\n RectNode.prototype.template = function template () {\n return \"\";\n };\n\n return RectNode;\n}(PathNode));\n\nvar ENTITY_REGEX = /&(?:[a-zA-Z]+|#\\d+);/g;\n\nfunction decodeEntities(text) {\n if (!text || typeof text !== \"string\" || !ENTITY_REGEX.test(text)) {\n return text;\n }\n\n var element = decodeEntities._element;\n ENTITY_REGEX.lastIndex = 0;\n\n return text.replace(ENTITY_REGEX, function (match) {\n element.innerHTML = match;\n\n return element.textContent || element.innerText;\n });\n}\n\nif (typeof document !== \"undefined\") {\n decodeEntities._element = document.createElement(\"span\");\n}\n\nvar TextNode = (function (PathNode$$1) {\n function TextNode () {\n PathNode$$1.apply(this, arguments);\n }\n\n extendStatic(TextNode, PathNode$$1);\n TextNode.prototype = Object.create( PathNode$$1 && PathNode$$1.prototype );\n TextNode.prototype.constructor = TextNode;\n TextNode.fn = TextNode.prototype;\n TextNode.fn.init = TextNode.fn.constructor;\n\n TextNode.prototype.geometryChange = function geometryChange () {\n var pos = this.pos();\n this.attr(\"x\", pos.x);\n this.attr(\"y\", pos.y);\n this.invalidate();\n };\n\n TextNode.prototype.optionsChange = function optionsChange (e) {\n if (e.field === \"font\") {\n this.attr(\"style\", renderStyle(this.mapStyle()));\n this.geometryChange();\n } else if (e.field === \"content\") {\n PathNode$$1.prototype.content.call(this, this.srcElement.content());\n }\n\n PathNode$$1.prototype.optionsChange.call(this, e);\n };\n\n TextNode.prototype.mapStyle = function mapStyle (encode) {\n var style = PathNode$$1.prototype.mapStyle.call(this, encode);\n var font = this.srcElement.options.font;\n\n if (encode) {\n font = kendo.htmlEncode(font);\n }\n\n style.push([ \"font\", font ], [ \"white-space\", \"pre\" ]);\n\n return style;\n };\n\n TextNode.prototype.pos = function pos () {\n var pos = this.srcElement.position();\n var size = this.srcElement.measure();\n return pos.clone().setY(pos.y + size.baseline);\n };\n\n TextNode.prototype.renderContent = function renderContent () {\n var content = this.srcElement.content();\n content = decodeEntities(content);\n content = kendo.htmlEncode(content);\n\n return kendoUtil.normalizeText(content);\n };\n\n TextNode.prototype.renderTextAnchor = function renderTextAnchor () {\n var anchor;\n\n if ((this.options || {}).rtl && !(supportBrowser.msie || supportBrowser.edge)) {\n anchor = 'end';\n }\n\n return renderAttr(\"text-anchor\", anchor);\n };\n\n TextNode.prototype.template = function template () {\n return \"\" + (this.renderContent()) + \"\";\n };\n\n return TextNode;\n}(PathNode));\n\nNODE_MAP.Arc = ArcNode;\nNODE_MAP.Circle = CircleNode;\nNODE_MAP.Group = GroupNode;\nNODE_MAP.Image = ImageNode;\nNODE_MAP.MultiPath = MultiPathNode;\nNODE_MAP.Path = PathNode;\nNODE_MAP.Rect = RectNode;\nNODE_MAP.Text = TextNode;\n\nvar RTL = 'rtl';\n\nfunction alignToScreen(element) {\n var ctm;\n\n try {\n ctm = element.getScreenCTM ? element.getScreenCTM() : null;\n } catch (e) { } // eslint-disable-line no-empty\n\n if (ctm) {\n var left = - ctm.e % 1;\n var top = - ctm.f % 1;\n var style = element.style;\n\n if (left !== 0 || top !== 0) {\n style.left = left + \"px\";\n style.top = top + \"px\";\n }\n }\n}\n\nvar Surface$3 = (function (BaseSurface) {\n function Surface(element, options) {\n BaseSurface.call(this, element, options);\n\n this._root = new RootNode($.extend({\n rtl: elementStyles(element, 'direction').direction === RTL\n }, this.options));\n\n renderSVG$1(this.element, this._template());\n\n this._rootElement = this.element.firstElementChild;\n\n alignToScreen(this._rootElement);\n\n this._root.attachTo(this._rootElement);\n\n bindEvents(this.element, {\n click: this._click,\n mouseover: this._mouseenter,\n mouseout: this._mouseleave,\n mousemove: this._mousemove\n });\n\n this.resize();\n }\n\n extendStatic(Surface, BaseSurface);\n Surface.prototype = Object.create( BaseSurface && BaseSurface.prototype );\n Surface.prototype.constructor = Surface;\n Surface.fn = Surface.prototype;\n Surface.fn.init = Surface.fn.constructor;\n\n var prototypeAccessors = { type: {} };\n\n prototypeAccessors.type.get = function () {\n return \"svg\";\n };\n\n Surface.prototype.destroy = function destroy () {\n if (this._root) {\n this._root.destroy();\n this._root = null;\n this._rootElement = null;\n unbindEvents(this.element, {\n click: this._click,\n mouseover: this._mouseenter,\n mouseout: this._mouseleave,\n mousemove: this._mousemove\n });\n }\n\n BaseSurface.prototype.destroy.call(this);\n };\n\n Surface.prototype.translate = function translate (offset) {\n var viewBox = (Math.round(offset.x)) + \" \" + (Math.round(offset.y)) + \" \" + (this._size.width) + \" \" + (this._size.height);\n\n this._offset = offset;\n this._rootElement.setAttribute(\"viewBox\", viewBox);\n };\n\n Surface.prototype.draw = function draw (element) {\n BaseSurface.prototype.draw.call(this, element);\n this._root.load([ element ]);\n };\n\n Surface.prototype.clear = function clear () {\n BaseSurface.prototype.clear.call(this);\n this._root.clear();\n };\n\n Surface.prototype.svg = function svg () {\n return \"\" + this._template();\n };\n\n Surface.prototype.exportVisual = function exportVisual () {\n var ref = this;\n var visual = ref._visual;\n var offset = ref._offset;\n\n if (offset) {\n var wrap = new Group();\n wrap.children.push(visual);\n\n wrap.transform(\n transform$1().translate(-offset.x, -offset.y)\n );\n\n visual = wrap;\n }\n\n return visual;\n };\n\n Surface.prototype._resize = function _resize () {\n if (this._offset) {\n this.translate(this._offset);\n }\n };\n\n Surface.prototype._template = function _template () {\n return (\"\" + (this._root.render()) + \"\");\n };\n\n Object.defineProperties( Surface.prototype, prototypeAccessors );\n\n return Surface;\n}(Surface$2));\n\nvar NODE_MAP$2 = {};\n\nfunction renderPath(ctx, path) {\n var segments = path.segments;\n\n if (segments.length === 0) {\n return;\n }\n\n var segment = segments[0];\n var anchor = segment.anchor();\n ctx.moveTo(anchor.x, anchor.y);\n\n for (var i = 1; i < segments.length; i++) {\n segment = segments[i];\n anchor = segment.anchor();\n\n var prevSeg = segments[i - 1];\n var prevOut = prevSeg.controlOut();\n var controlIn = segment.controlIn();\n\n if (prevOut && controlIn) {\n ctx.bezierCurveTo(prevOut.x, prevOut.y,\n controlIn.x, controlIn.y,\n anchor.x, anchor.y);\n } else {\n ctx.lineTo(anchor.x, anchor.y);\n }\n }\n\n if (path.options.closed) {\n ctx.closePath();\n }\n}\n\nvar Node$2 = (function (BaseNode$$1) {\n function Node(srcElement) {\n BaseNode$$1.call(this, srcElement);\n if (srcElement) {\n this.initClip();\n }\n }\n\n extendStatic(Node, BaseNode$$1);\n Node.prototype = Object.create( BaseNode$$1 && BaseNode$$1.prototype );\n Node.prototype.constructor = Node;\n Node.fn = Node.prototype;\n Node.fn.init = Node.fn.constructor;\n\n Node.prototype.initClip = function initClip () {\n var clip = this.srcElement.clip();\n if (clip) {\n this.clip = clip;\n clip.addObserver(this);\n }\n };\n\n Node.prototype.clear = function clear () {\n if (this.srcElement) {\n this.srcElement.removeObserver(this);\n }\n\n this.clearClip();\n\n BaseNode$$1.prototype.clear.call(this);\n };\n\n Node.prototype.clearClip = function clearClip () {\n if (this.clip) {\n this.clip.removeObserver(this);\n delete this.clip;\n }\n };\n\n Node.prototype.setClip = function setClip (ctx) {\n if (this.clip) {\n ctx.beginPath();\n renderPath(ctx, this.clip);\n ctx.clip();\n }\n };\n\n Node.prototype.optionsChange = function optionsChange (e) {\n if (e.field === \"clip\") {\n this.clearClip();\n this.initClip();\n }\n\n BaseNode$$1.prototype.optionsChange.call(this, e);\n };\n\n Node.prototype.setTransform = function setTransform (ctx) {\n if (this.srcElement) {\n var transform = this.srcElement.transform();\n if (transform) {\n ctx.transform.apply(ctx, transform.matrix().toArray(6));\n }\n }\n };\n\n Node.prototype.loadElements = function loadElements (elements, pos, cors) {\n var this$1 = this;\n\n for (var i = 0; i < elements.length; i++) {\n var srcElement = elements[i];\n var children = srcElement.children;\n\n var childNode = new NODE_MAP$2[srcElement.nodeType](srcElement, cors);\n\n if (children && children.length > 0) {\n childNode.load(children, pos, cors);\n }\n\n if (defined(pos)) {\n this$1.insertAt(childNode, pos);\n } else {\n this$1.append(childNode);\n }\n }\n };\n\n Node.prototype.load = function load (elements, pos, cors) {\n this.loadElements(elements, pos, cors);\n\n this.invalidate();\n };\n\n Node.prototype.setOpacity = function setOpacity (ctx) {\n if (this.srcElement) {\n var opacity = this.srcElement.opacity();\n if (defined(opacity)) {\n this.globalAlpha(ctx, opacity);\n }\n }\n };\n\n Node.prototype.globalAlpha = function globalAlpha (ctx, value) {\n var opactity = value;\n if (opactity && ctx.globalAlpha) {\n opactity *= ctx.globalAlpha;\n }\n ctx.globalAlpha = opactity;\n };\n\n Node.prototype.visible = function visible () {\n var src = this.srcElement;\n return !src || (src && src.options.visible !== false);\n };\n\n return Node;\n}(BaseNode));\n\nvar GroupNode$2 = (function (superclass) {\n function GroupNode () {\n superclass.apply(this, arguments);\n }\n\n extendStatic(GroupNode, superclass);\n GroupNode.prototype = Object.create( superclass && superclass.prototype );\n GroupNode.prototype.constructor = GroupNode;\n GroupNode.fn = GroupNode.prototype;\n GroupNode.fn.init = GroupNode.fn.constructor;\n\n GroupNode.prototype.renderTo = function renderTo (ctx) {\n if (!this.visible()) {\n return;\n }\n\n ctx.save();\n\n this.setTransform(ctx);\n this.setClip(ctx);\n this.setOpacity(ctx);\n\n var childNodes = this.childNodes;\n for (var i = 0; i < childNodes.length; i++) {\n var child = childNodes[i];\n if (child.visible()) {\n child.renderTo(ctx);\n }\n }\n\n ctx.restore();\n };\n\n return GroupNode;\n}(traversable(Node$2, \"childNodes\")));\n\nvar FRAME_DELAY = 1000 / 60;\n\nvar RootNode$2 = (function (superclass) {\n function RootNode(canvas, size) {\n superclass.call(this);\n\n this.canvas = canvas;\n this.size = size;\n this.ctx = canvas.getContext(\"2d\");\n\n var invalidateHandler = this._invalidate.bind(this);\n this.invalidate = kendo.throttle(function () {\n kendo.animationFrame(invalidateHandler);\n }, FRAME_DELAY);\n }\n\n extendStatic(RootNode, superclass);\n RootNode.prototype = Object.create( superclass && superclass.prototype );\n RootNode.prototype.constructor = RootNode;\n RootNode.fn = RootNode.prototype;\n RootNode.fn.init = RootNode.fn.constructor;\n\n RootNode.prototype.destroy = function destroy () {\n superclass.prototype.destroy.call(this);\n this.canvas = null;\n this.ctx = null;\n };\n\n RootNode.prototype.load = function load (elements, pos, cors) {\n this.loadElements(elements, pos, cors);\n this._invalidate();\n };\n\n RootNode.prototype._rescale = function _rescale (scale) {\n var ref = this;\n var canvas = ref.canvas;\n var size = ref.size;\n canvas.width = size.width * scale;\n canvas.height = size.height * scale;\n this.ctx.scale(scale, scale);\n };\n\n RootNode.prototype._devicePixelRatio = function _devicePixelRatio () {\n if (typeof window.devicePixelRatio === 'number') {\n return window.devicePixelRatio;\n }\n\n return 1;\n };\n\n RootNode.prototype._invalidate = function _invalidate (options) {\n if (!this.ctx) {\n return;\n }\n\n var fixedScale = options && options.fixedScale;\n var scale = fixedScale ? 1 : this._devicePixelRatio();\n this._rescale(scale);\n\n this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);\n this.renderTo(this.ctx);\n };\n\n return RootNode;\n}(traversable(GroupNode$2, \"childNodes\")));\n\nvar QuadRoot = (function (Class$$1) {\n function QuadRoot() {\n Class$$1.call(this);\n\n this.shapes = [];\n }\n\n extendStatic(QuadRoot, Class$$1);\n QuadRoot.prototype = Object.create( Class$$1 && Class$$1.prototype );\n QuadRoot.prototype.constructor = QuadRoot;\n QuadRoot.fn = QuadRoot.prototype;\n QuadRoot.fn.init = QuadRoot.fn.constructor;\n\n QuadRoot.prototype._add = function _add (shape, bbox) {\n this.shapes.push({\n bbox: bbox,\n shape: shape\n });\n shape._quadNode = this;\n };\n\n QuadRoot.prototype.pointShapes = function pointShapes (point) {\n var shapes = this.shapes;\n var length = shapes.length;\n var result = [];\n for (var idx = 0; idx < length; idx++) {\n if (shapes[idx].bbox.containsPoint(point)) {\n result.push(shapes[idx].shape);\n }\n }\n return result;\n };\n\n QuadRoot.prototype.insert = function insert (shape, bbox) {\n this._add(shape, bbox);\n };\n\n QuadRoot.prototype.remove = function remove (shape) {\n var shapes = this.shapes;\n var length = shapes.length;\n\n for (var idx = 0; idx < length; idx++) {\n if (shapes[idx].shape === shape) {\n shapes.splice(idx, 1);\n break;\n }\n }\n };\n\n return QuadRoot;\n}(Class));\n\nvar geometry = {\n\tCircle: Circle$2,\n\tArc: Arc$2,\n\tRect: Rect,\n\tPoint: Point,\n\tSegment: Segment,\n\tMatrix: Matrix,\n\tSize: Size,\n\ttoMatrix: toMatrix,\n\tTransformation: Transformation,\n\ttransform: transform$1\n};\n\nvar QuadNode = (function (QuadRoot$$1) {\n function QuadNode(rect) {\n QuadRoot$$1.call(this);\n this.children = [];\n this.rect = rect;\n }\n\n extendStatic(QuadNode, QuadRoot$$1);\n QuadNode.prototype = Object.create( QuadRoot$$1 && QuadRoot$$1.prototype );\n QuadNode.prototype.constructor = QuadNode;\n QuadNode.fn = QuadNode.prototype;\n QuadNode.fn.init = QuadNode.fn.constructor;\n\n QuadNode.prototype.inBounds = function inBounds (rect) {\n var nodeRect = this.rect;\n var nodeBottomRight = nodeRect.bottomRight();\n var bottomRight = rect.bottomRight();\n var inBounds = nodeRect.origin.x <= rect.origin.x && nodeRect.origin.y <= rect.origin.y && bottomRight.x <= nodeBottomRight.x &&\n bottomRight.y <= nodeBottomRight.y;\n return inBounds;\n };\n\n QuadNode.prototype.pointShapes = function pointShapes (point) {\n var children = this.children;\n var length = children.length;\n var result = QuadRoot$$1.prototype.pointShapes.call(this, point);\n for (var idx = 0; idx < length; idx++) {\n append$1$1(result, children[idx].pointShapes(point));\n }\n return result;\n };\n\n QuadNode.prototype.insert = function insert (shape, bbox) {\n var children = this.children;\n var inserted = false;\n\n if (this.inBounds(bbox)) {\n if (this.shapes.length < 4) {\n this._add(shape, bbox);\n } else {\n if (!children.length) {\n this._initChildren();\n }\n\n for (var idx = 0; idx < children.length; idx++) {\n if (children[idx].insert(shape, bbox)) {\n inserted = true;\n break;\n }\n }\n\n if (!inserted) {\n this._add(shape, bbox);\n }\n }\n inserted = true;\n }\n\n return inserted;\n };\n\n QuadNode.prototype._initChildren = function _initChildren () {\n var ref = this;\n var rect = ref.rect;\n var children = ref.children;\n var center = rect.center();\n var halfWidth = rect.width() / 2;\n var halfHeight = rect.height() / 2;\n\n children.push(\n new QuadNode(new Rect([ rect.origin.x, rect.origin.y ], [ halfWidth, halfHeight ])),\n new QuadNode(new Rect([ center.x, rect.origin.y ], [ halfWidth, halfHeight ])),\n new QuadNode(new Rect([ rect.origin.x, center.y ], [ halfWidth, halfHeight ])),\n new QuadNode(new Rect([ center.x, center.y ], [ halfWidth, halfHeight ]))\n );\n };\n\n return QuadNode;\n}(QuadRoot));\n\nvar ROOT_SIZE = 3000;\nvar LEVEL_STEP = 10000;\nvar MAX_LEVEL = 75;\n\nvar ShapesQuadTree = (function (Class$$1) {\n function ShapesQuadTree() {\n Class$$1.call(this);\n\n this.initRoots();\n }\n\n extendStatic(ShapesQuadTree, Class$$1);\n ShapesQuadTree.prototype = Object.create( Class$$1 && Class$$1.prototype );\n ShapesQuadTree.prototype.constructor = ShapesQuadTree;\n ShapesQuadTree.fn = ShapesQuadTree.prototype;\n ShapesQuadTree.fn.init = ShapesQuadTree.fn.constructor;\n\n ShapesQuadTree.prototype.initRoots = function initRoots () {\n this.rootMap = {};\n this.root = new QuadRoot();\n this.rootElements = [];\n };\n\n ShapesQuadTree.prototype.clear = function clear () {\n var this$1 = this;\n\n var rootElements = this.rootElements;\n for (var idx = 0; idx < rootElements.length; idx++) {\n this$1.remove(rootElements[idx]);\n }\n this.initRoots();\n };\n\n ShapesQuadTree.prototype.pointShape = function pointShape (point) {\n var sectorRoot = ( this.rootMap[ Math.floor( point.x / ROOT_SIZE ) ] || {} )[ Math.floor( point.y / ROOT_SIZE ) ];\n var result = this.root.pointShapes(point);\n\n if (sectorRoot) {\n result = result.concat(sectorRoot.pointShapes(point));\n }\n\n this.assignZindex(result);\n\n result.sort(zIndexComparer);\n for (var idx = 0; idx < result.length; idx++) {\n if (result[idx].containsPoint(point)) {\n return result[idx];\n }\n }\n };\n\n ShapesQuadTree.prototype.assignZindex = function assignZindex (elements) {\n var this$1 = this;\n\n for (var idx = 0; idx < elements.length; idx++) {\n var element = elements[idx];\n var zIndex = 0;\n var levelWeight = Math.pow(LEVEL_STEP, MAX_LEVEL);\n var parents = [];\n\n while (element) {\n parents.push(element);\n element = element.parent;\n }\n\n while (parents.length) {\n element = parents.pop();\n zIndex += ((element.parent ? element.parent.children : this$1.rootElements).indexOf(element) + 1) * levelWeight;\n levelWeight /= LEVEL_STEP;\n }\n\n elements[idx]._zIndex = zIndex;\n }\n };\n\n ShapesQuadTree.prototype.optionsChange = function optionsChange (e) {\n if (e.field === \"transform\" || e.field === \"stroke.width\") {\n this.bboxChange(e.element);\n }\n };\n\n ShapesQuadTree.prototype.geometryChange = function geometryChange (e) {\n this.bboxChange(e.element);\n };\n\n ShapesQuadTree.prototype.bboxChange = function bboxChange (element) {\n var this$1 = this;\n\n if (element.nodeType === \"Group\") {\n for (var idx = 0; idx < element.children.length; idx++) {\n this$1.bboxChange(element.children[idx]);\n }\n } else {\n if (element._quadNode) {\n element._quadNode.remove(element);\n }\n this._insertShape(element);\n }\n };\n\n ShapesQuadTree.prototype.add = function add (elements) {\n var elementsArray = Array.isArray(elements) ? elements.slice(0) : [ elements ];\n\n append$1$1(this.rootElements, elementsArray);\n this._insert(elementsArray);\n };\n\n ShapesQuadTree.prototype.childrenChange = function childrenChange (e) {\n var this$1 = this;\n\n if (e.action === \"remove\") {\n for (var idx = 0; idx < e.items.length; idx++) {\n this$1.remove(e.items[idx]);\n }\n } else {\n this._insert(Array.prototype.slice.call(e.items, 0));\n }\n };\n\n ShapesQuadTree.prototype._insert = function _insert (elements) {\n var this$1 = this;\n\n var element;\n\n while (elements.length > 0) {\n element = elements.pop();\n element.addObserver(this$1);\n if (element.nodeType === \"Group\") {\n append$1$1(elements, element.children);\n } else {\n this$1._insertShape(element);\n }\n }\n };\n\n ShapesQuadTree.prototype._insertShape = function _insertShape (shape) {\n var bbox = shape.bbox();\n if (bbox) {\n var sectors = this.getSectors(bbox);\n var x = sectors[0][0];\n var y = sectors[1][0];\n\n if (this.inRoot(sectors)) {\n this.root.insert(shape, bbox);\n } else {\n var rootMap = this.rootMap;\n if (!rootMap[x]) {\n rootMap[x] = {};\n }\n\n if (!rootMap[x][y]) {\n rootMap[x][y] = new QuadNode(\n new Rect([ x * ROOT_SIZE, y * ROOT_SIZE ], [ ROOT_SIZE, ROOT_SIZE ])\n );\n }\n\n rootMap[x][y].insert(shape, bbox);\n }\n }\n };\n\n ShapesQuadTree.prototype.remove = function remove (element) {\n var this$1 = this;\n\n element.removeObserver(this);\n\n if (element.nodeType === \"Group\") {\n var children = element.children;\n for (var idx = 0; idx < children.length; idx++) {\n this$1.remove(children[idx]);\n }\n } else if (element._quadNode) {\n element._quadNode.remove(element);\n delete element._quadNode;\n }\n };\n\n ShapesQuadTree.prototype.inRoot = function inRoot (sectors) {\n return sectors[0].length > 1 || sectors[1].length > 1;\n };\n\n ShapesQuadTree.prototype.getSectors = function getSectors (rect) {\n var bottomRight = rect.bottomRight();\n var bottomX = Math.floor(bottomRight.x / ROOT_SIZE);\n var bottomY = Math.floor(bottomRight.y / ROOT_SIZE);\n var sectors = [ [], [] ];\n for (var x = Math.floor(rect.origin.x / ROOT_SIZE); x <= bottomX; x++) {\n sectors[0].push(x);\n }\n for (var y = Math.floor(rect.origin.y / ROOT_SIZE); y <= bottomY; y++) {\n sectors[1].push(y);\n }\n return sectors;\n };\n\n return ShapesQuadTree;\n}(Class));\n\nfunction zIndexComparer(x1, x2) {\n if (x1._zIndex < x2._zIndex) {\n return 1;\n }\n if (x1._zIndex > x2._zIndex) {\n return -1;\n }\n\n return 0;\n}\n\nvar SurfaceCursor = function SurfaceCursor(surface) {\n surface.bind(\"mouseenter\", this._mouseenter.bind(this));\n surface.bind(\"mouseleave\", this._mouseleave.bind(this));\n\n this.element = surface.element;\n};\n\nSurfaceCursor.prototype.clear = function clear () {\n this._resetCursor();\n};\n\nSurfaceCursor.prototype.destroy = function destroy () {\n this._resetCursor();\n delete this.element;\n};\n\nSurfaceCursor.prototype._mouseenter = function _mouseenter (e) {\n var cursor = this._shapeCursor(e);\n\n if (!cursor) {\n this._resetCursor();\n } else {\n if (!this._current) {\n this._defaultCursor = this._getCursor();\n }\n\n this._setCursor(cursor);\n }\n};\n\nSurfaceCursor.prototype._mouseleave = function _mouseleave () {\n this._resetCursor();\n};\n\nSurfaceCursor.prototype._shapeCursor = function _shapeCursor (e) {\n var shape = e.element;\n\n while (shape && !defined(shape.options.cursor)) {\n shape = shape.parent;\n }\n\n if (shape) {\n return shape.options.cursor;\n }\n};\n\nSurfaceCursor.prototype._getCursor = function _getCursor () {\n if (this.element) {\n return this.element.style.cursor;\n }\n};\n\nSurfaceCursor.prototype._setCursor = function _setCursor (cursor) {\n if (this.element) {\n this.element.style.cursor = cursor;\n this._current = cursor;\n }\n};\n\nSurfaceCursor.prototype._resetCursor = function _resetCursor () {\n if (this._current) {\n this._setCursor(this._defaultCursor || \"\");\n delete this._current;\n }\n};\n\nfunction addGradientStops(gradient, stops) {\n for (var idx = 0; idx < stops.length; idx++) {\n var stop = stops[idx];\n var color = kendo.parseColor(stop.color());\n\n color.a *= stop.opacity();\n\n gradient.addColorStop(stop.offset(), color.toCssRgba());\n }\n}\n\nvar PathNode$2 = (function (Node) {\n function PathNode () {\n Node.apply(this, arguments);\n }\n\n extendStatic(PathNode, Node);\n PathNode.prototype = Object.create( Node && Node.prototype );\n PathNode.prototype.constructor = PathNode;\n PathNode.fn = PathNode.prototype;\n PathNode.fn.init = PathNode.fn.constructor;\n\n PathNode.prototype.renderTo = function renderTo (ctx) {\n ctx.save();\n\n this.setTransform(ctx);\n this.setClip(ctx);\n this.setOpacity(ctx);\n\n ctx.beginPath();\n\n this.renderPoints(ctx, this.srcElement);\n\n this.setLineDash(ctx);\n this.setLineCap(ctx);\n this.setLineJoin(ctx);\n\n this.setFill(ctx);\n this.setStroke(ctx);\n\n ctx.restore();\n };\n\n PathNode.prototype.setFill = function setFill (ctx) {\n var fill = this.srcElement.options.fill;\n var hasFill = false;\n\n if (fill) {\n if (fill.nodeType === \"Gradient\") {\n this.setGradientFill(ctx, fill);\n hasFill = true;\n } else if (!isTransparent(fill.color)) {\n ctx.fillStyle = fill.color;\n\n ctx.save();\n this.globalAlpha(ctx, fill.opacity);\n ctx.fill();\n ctx.restore();\n\n hasFill = true;\n }\n }\n\n return hasFill;\n };\n\n PathNode.prototype.setGradientFill = function setGradientFill (ctx, fill) {\n var bbox = this.srcElement.rawBBox();\n var gradient;\n\n if (fill instanceof LinearGradient) {\n var start = fill.start();\n var end = fill.end();\n gradient = ctx.createLinearGradient(start.x, start.y, end.x, end.y);\n } else if (fill instanceof RadialGradient) {\n var center = fill.center();\n gradient = ctx.createRadialGradient(center.x, center.y, 0, center.x, center.y, fill.radius());\n }\n\n addGradientStops(gradient, fill.stops);\n\n ctx.save();\n\n if (!fill.userSpace()) {\n ctx.transform(bbox.width(), 0, 0, bbox.height(), bbox.origin.x, bbox.origin.y);\n }\n ctx.fillStyle = gradient;\n ctx.fill();\n\n ctx.restore();\n };\n\n PathNode.prototype.setStroke = function setStroke (ctx) {\n var stroke = this.srcElement.options.stroke;\n if (stroke && !isTransparent(stroke.color) && stroke.width > 0) {\n ctx.strokeStyle = stroke.color;\n ctx.lineWidth = valueOrDefault(stroke.width, 1);\n\n ctx.save();\n this.globalAlpha(ctx, stroke.opacity);\n ctx.stroke();\n ctx.restore();\n\n return true;\n }\n };\n\n PathNode.prototype.dashType = function dashType () {\n var stroke = this.srcElement.options.stroke;\n if (stroke && stroke.dashType) {\n return stroke.dashType.toLowerCase();\n }\n };\n\n PathNode.prototype.setLineDash = function setLineDash (ctx) {\n var dashType = this.dashType();\n if (dashType && dashType !== SOLID) {\n var dashArray = DASH_ARRAYS[dashType];\n if (ctx.setLineDash) {\n ctx.setLineDash(dashArray);\n } else {\n ctx.mozDash = dashArray;\n ctx.webkitLineDash = dashArray;\n }\n }\n };\n\n PathNode.prototype.setLineCap = function setLineCap (ctx) {\n var dashType = this.dashType();\n var stroke = this.srcElement.options.stroke;\n if (dashType && dashType !== SOLID) {\n ctx.lineCap = BUTT;\n } else if (stroke && stroke.lineCap) {\n ctx.lineCap = stroke.lineCap;\n }\n };\n\n PathNode.prototype.setLineJoin = function setLineJoin (ctx) {\n var stroke = this.srcElement.options.stroke;\n if (stroke && stroke.lineJoin) {\n ctx.lineJoin = stroke.lineJoin;\n }\n };\n\n PathNode.prototype.renderPoints = function renderPoints (ctx, path) {\n renderPath(ctx, path);\n };\n\n return PathNode;\n}(Node$2));\n\nvar ArcNode$2 = (function (PathNode) {\n function ArcNode () {\n PathNode.apply(this, arguments);\n }\n\n extendStatic(ArcNode, PathNode);\n ArcNode.prototype = Object.create( PathNode && PathNode.prototype );\n ArcNode.prototype.constructor = ArcNode;\n ArcNode.fn = ArcNode.prototype;\n ArcNode.fn.init = ArcNode.fn.constructor;\n\n ArcNode.prototype.renderPoints = function renderPoints (ctx) {\n var path = this.srcElement.toPath();\n renderPath(ctx, path);\n };\n\n return ArcNode;\n}(PathNode$2));\n\nvar CircleNode$2 = (function (PathNode) {\n function CircleNode () {\n PathNode.apply(this, arguments);\n }\n\n extendStatic(CircleNode, PathNode);\n CircleNode.prototype = Object.create( PathNode && PathNode.prototype );\n CircleNode.prototype.constructor = CircleNode;\n CircleNode.fn = CircleNode.prototype;\n CircleNode.fn.init = CircleNode.fn.constructor;\n\n CircleNode.prototype.renderPoints = function renderPoints (ctx) {\n var ref = this.srcElement.geometry();\n var center = ref.center;\n var radius = ref.radius;\n\n ctx.arc(center.x, center.y, radius, 0, Math.PI * 2);\n };\n\n return CircleNode;\n}(PathNode$2));\n\nvar ImageNode$2 = (function (PathNode) {\n function ImageNode(srcElement, cors) {\n PathNode.call(this, srcElement);\n\n this.onLoad = this.onLoad.bind(this);\n this.onError = this.onError.bind(this);\n\n this.loading = createPromise();\n\n var img = this.img = new Image();\n\n if (cors && !(/^data:/i.test(srcElement.src()))) {\n img.crossOrigin = cors;\n }\n\n img.src = srcElement.src();\n\n if (img.complete) {\n this.onLoad();\n } else {\n img.onload = this.onLoad;\n img.onerror = this.onError;\n }\n }\n\n extendStatic(ImageNode, PathNode);\n ImageNode.prototype = Object.create( PathNode && PathNode.prototype );\n ImageNode.prototype.constructor = ImageNode;\n ImageNode.fn = ImageNode.prototype;\n ImageNode.fn.init = ImageNode.fn.constructor;\n\n ImageNode.prototype.renderTo = function renderTo (ctx) {\n if (this.loading.state() === \"resolved\") {\n ctx.save();\n\n this.setTransform(ctx);\n this.setClip(ctx);\n\n this.drawImage(ctx);\n\n ctx.restore();\n }\n };\n\n ImageNode.prototype.optionsChange = function optionsChange (e) {\n if (e.field === \"src\") {\n this.loading = createPromise();\n this.img.src = this.srcElement.src();\n } else {\n PathNode.prototype.optionsChange.call(this, e);\n }\n };\n\n ImageNode.prototype.onLoad = function onLoad () {\n this.loading.resolve();\n this.invalidate();\n };\n\n ImageNode.prototype.onError = function onError () {\n this.loading.reject(new Error(\n \"Unable to load image '\" + this.img.src +\n \"'. Check for connectivity and verify CORS headers.\"\n ));\n };\n\n ImageNode.prototype.drawImage = function drawImage (ctx) {\n var rect = this.srcElement.rect();\n var topLeft = rect.topLeft();\n\n ctx.drawImage(\n this.img, topLeft.x, topLeft.y, rect.width(), rect.height()\n );\n };\n\n return ImageNode;\n}(PathNode$2));\n\nvar MultiPathNode$2 = (function (PathNode) {\n function MultiPathNode () {\n PathNode.apply(this, arguments);\n }\n\n extendStatic(MultiPathNode, PathNode);\n MultiPathNode.prototype = Object.create( PathNode && PathNode.prototype );\n MultiPathNode.prototype.constructor = MultiPathNode;\n MultiPathNode.fn = MultiPathNode.prototype;\n MultiPathNode.fn.init = MultiPathNode.fn.constructor;\n\n MultiPathNode.prototype.renderPoints = function renderPoints (ctx) {\n var paths = this.srcElement.paths;\n for (var i = 0; i < paths.length; i++) {\n renderPath(ctx, paths[i]);\n }\n };\n\n return MultiPathNode;\n}(PathNode$2));\n\nvar RectNode$2 = (function (PathNode) {\n function RectNode () {\n PathNode.apply(this, arguments);\n }\n\n extendStatic(RectNode, PathNode);\n RectNode.prototype = Object.create( PathNode && PathNode.prototype );\n RectNode.prototype.constructor = RectNode;\n RectNode.fn = RectNode.prototype;\n RectNode.fn.init = RectNode.fn.constructor;\n\n RectNode.prototype.renderPoints = function renderPoints (ctx) {\n var geometry = this.srcElement.geometry();\n var ref = geometry.cornerRadius;\n var rx = ref[0];\n var ry = ref[1];\n\n if (rx === 0 && ry === 0) {\n var origin = geometry.origin;\n var size = geometry.size;\n ctx.rect(origin.x, origin.y, size.width, size.height);\n } else {\n PathNode.prototype.renderPoints.call(this, ctx, Path.fromRect(geometry));\n }\n };\n\n return RectNode;\n}(PathNode$2));\n\nvar TextNode$2 = (function (PathNode) {\n function TextNode () {\n PathNode.apply(this, arguments);\n }\n\n extendStatic(TextNode, PathNode);\n TextNode.prototype = Object.create( PathNode && PathNode.prototype );\n TextNode.prototype.constructor = TextNode;\n TextNode.fn = TextNode.prototype;\n TextNode.fn.init = TextNode.fn.constructor;\n\n TextNode.prototype.renderTo = function renderTo (ctx) {\n var text = this.srcElement;\n var pos = text.position();\n var size = text.measure();\n\n ctx.save();\n\n this.setTransform(ctx);\n this.setClip(ctx);\n this.setOpacity(ctx);\n\n ctx.beginPath();\n\n ctx.font = text.options.font;\n ctx.textAlign = 'left';\n\n if (this.setFill(ctx)) {\n ctx.fillText(text.content(), pos.x, pos.y + size.baseline);\n }\n\n if (this.setStroke(ctx)) {\n this.setLineDash(ctx);\n ctx.strokeText(text.content(), pos.x, pos.y + size.baseline);\n }\n\n ctx.restore();\n };\n\n return TextNode;\n}(PathNode$2));\n\nNODE_MAP$2.Arc = ArcNode$2;\nNODE_MAP$2.Circle = CircleNode$2;\nNODE_MAP$2.Group = GroupNode$2;\nNODE_MAP$2.Image = ImageNode$2;\nNODE_MAP$2.MultiPath = MultiPathNode$2;\nNODE_MAP$2.Path = PathNode$2;\nNODE_MAP$2.Rect = RectNode$2;\nNODE_MAP$2.Text = TextNode$2;\n\nvar Surface$4 = (function (BaseSurface) {\n function Surface(element, options) {\n BaseSurface.call(this, element, options);\n\n this.element.innerHTML = this._template(this);\n\n var canvas = this.element.firstElementChild;\n var size = elementSize(element);\n\n canvas.width = size.width;\n canvas.height = size.height;\n\n this._rootElement = canvas;\n\n this._root = new RootNode$2(canvas, size);\n\n this._mouseTrackHandler = this._trackMouse.bind(this);\n\n bindEvents(this.element, {\n click: this._mouseTrackHandler,\n mousemove: this._mouseTrackHandler\n });\n }\n\n extendStatic(Surface, BaseSurface);\n Surface.prototype = Object.create( BaseSurface && BaseSurface.prototype );\n Surface.prototype.constructor = Surface;\n Surface.fn = Surface.prototype;\n Surface.fn.init = Surface.fn.constructor;\n\n var prototypeAccessors = { type: {} };\n\n prototypeAccessors.type.get = function () {\n return \"canvas\";\n };\n\n Surface.prototype.destroy = function destroy () {\n BaseSurface.prototype.destroy.call(this);\n\n if (this._root) {\n this._root.destroy();\n this._root = null;\n }\n\n if (this._searchTree) {\n this._searchTree.clear();\n delete this._searchTree;\n }\n\n if (this._cursor) {\n this._cursor.destroy();\n delete this._cursor;\n }\n\n unbindEvents(this.element, {\n click: this._mouseTrackHandler,\n mousemove: this._mouseTrackHandler\n });\n };\n\n Surface.prototype.draw = function draw (element) {\n BaseSurface.prototype.draw.call(this, element);\n this._root.load([ element ], undefined, this.options.cors);\n\n if (this._searchTree) {\n this._searchTree.add([ element ]);\n }\n };\n\n Surface.prototype.clear = function clear () {\n BaseSurface.prototype.clear.call(this);\n this._root.clear();\n\n if (this._searchTree) {\n this._searchTree.clear();\n }\n\n if (this._cursor) {\n this._cursor.clear();\n }\n };\n\n Surface.prototype.eventTarget = function eventTarget (e) {\n if (this._searchTree) {\n var point = this._surfacePoint(e);\n var shape = this._searchTree.pointShape(point);\n return shape;\n }\n };\n\n Surface.prototype.image = function image () {\n var ref = this;\n var root = ref._root;\n var rootElement = ref._rootElement;\n var loadingStates = [];\n\n root.traverse(function (childNode) {\n if (childNode.loading) {\n loadingStates.push(childNode.loading);\n }\n });\n\n var promise = createPromise();\n var resolveDataURL = function () {\n root._invalidate({ fixedScale: true });\n\n try {\n var data = rootElement.toDataURL();\n promise.resolve(data);\n } catch (e) {\n promise.reject(e);\n }\n };\n\n promiseAll(loadingStates).then(resolveDataURL, resolveDataURL);\n\n return promise;\n };\n\n Surface.prototype.suspendTracking = function suspendTracking () {\n BaseSurface.prototype.suspendTracking.call(this);\n if (this._searchTree) {\n this._searchTree.clear();\n delete this._searchTree;\n }\n };\n\n Surface.prototype.resumeTracking = function resumeTracking () {\n BaseSurface.prototype.resumeTracking.call(this);\n if (!this._searchTree) {\n this._searchTree = new ShapesQuadTree();\n\n var childNodes = this._root.childNodes;\n var rootElements = [];\n for (var idx = 0; idx < childNodes.length; idx++) {\n rootElements.push(childNodes[idx].srcElement);\n }\n this._searchTree.add(rootElements);\n }\n };\n\n Surface.prototype._resize = function _resize () {\n this._rootElement.width = this._size.width;\n this._rootElement.height = this._size.height;\n\n this._root.size = this._size;\n this._root.invalidate();\n };\n\n Surface.prototype._template = function _template () {\n return \"\";\n };\n\n Surface.prototype._enableTracking = function _enableTracking () {\n this._searchTree = new ShapesQuadTree();\n this._cursor = new SurfaceCursor(this);\n\n BaseSurface.prototype._enableTracking.call(this);\n };\n\n Surface.prototype._trackMouse = function _trackMouse (e) {\n if (this._suspendedTracking) {\n return;\n }\n\n var shape = this.eventTarget(e);\n\n if (e.type !== \"click\") {\n var currentShape = this._currentShape;\n if (currentShape && currentShape !== shape) {\n this.trigger(\"mouseleave\", {\n element: currentShape,\n originalEvent: e,\n type: \"mouseleave\"\n });\n }\n\n if (shape && currentShape !== shape) {\n this.trigger(\"mouseenter\", {\n element: shape,\n originalEvent: e,\n type: \"mouseenter\"\n });\n }\n\n this.trigger(\"mousemove\", {\n element: shape,\n originalEvent: e,\n type: \"mousemove\"\n });\n\n this._currentShape = shape;\n } else if (shape) {\n this.trigger(\"click\", {\n element: shape,\n originalEvent: e,\n type: \"click\"\n });\n }\n };\n\n Object.defineProperties( Surface.prototype, prototypeAccessors );\n\n return Surface;\n}(Surface$2));\n\nvar instance$2;\nvar support$1;\n\nvar hasDocument = function () { return typeof document !== \"undefined\"; };\n\nvar supportsCanvas = function () { return hasDocument() &&\n document.createElement(\"canvas\").getContext; };\n\nvar supportsSVG = function () { return hasDocument() &&\n document.implementation.hasFeature(\"http://www.w3.org/TR/SVG11/feature#BasicStructure\", \"1.1\"); };\n\nvar SurfaceFactory = (function (Class$$1) {\n function SurfaceFactory() {\n Class$$1.call(this);\n\n this._items = [ {\n name: \"svg\",\n type: Surface$3\n }, {\n name: \"canvas\",\n type: Surface$4\n } ];\n }\n\n extendStatic(SurfaceFactory, Class$$1);\n SurfaceFactory.prototype = Object.create( Class$$1 && Class$$1.prototype );\n SurfaceFactory.prototype.constructor = SurfaceFactory;\n SurfaceFactory.fn = SurfaceFactory.prototype;\n SurfaceFactory.fn.init = SurfaceFactory.fn.constructor;\n\n var staticAccessors = { support: {},current: {} };\n\n staticAccessors.support.get = function () {\n if (!support$1) {\n support$1 = {\n canvas: supportsCanvas(),\n svg: supportsSVG()\n };\n }\n\n return support$1;\n };\n\n staticAccessors.current.get = function () {\n if (!instance$2) {\n instance$2 = new SurfaceFactory();\n }\n\n return instance$2;\n };\n\n SurfaceFactory.prototype.create = function create (element, options) {\n var items = this._items;\n var match = items[0];\n\n if (options && options.type) {\n var preferred = options.type.toLowerCase();\n for (var i = 0; i < items.length; i++) {\n if (items[i].name === preferred) {\n match = items[i];\n break;\n }\n }\n }\n\n if (match) {\n return new match.type(element, options);\n }\n\n kendo.logToConsole(\n \"Warning: Unable to create Kendo UI Drawing Surface. Possible causes:\\n\" +\n \"- The browser does not support SVG and Canvas. User agent: \" + (navigator.userAgent));\n };\n\n Object.defineProperties( SurfaceFactory, staticAccessors );\n\n return SurfaceFactory;\n}(Class));\n\nvar Surface = (function (BaseSurface) {\n function Surface () {\n BaseSurface.apply(this, arguments);\n }\n\n extendStatic(Surface, BaseSurface);\n Surface.prototype = Object.create( BaseSurface && BaseSurface.prototype );\n Surface.prototype.constructor = Surface;\n Surface.fn = Surface.prototype;\n Surface.fn.init = Surface.fn.constructor;\n\n var staticAccessors = { support: {} };\n\n staticAccessors.support.get = function () {\n return SurfaceFactory.support;\n };\n\n Surface.create = function create (element, options) {\n return SurfaceFactory.current.create(element, options);\n };\n\n Object.defineProperties( Surface, staticAccessors );\n\n return Surface;\n}(Surface$2));\n\nfunction exportGroup(group) {\n var root = new RootNode({\n skipBaseHref: true\n });\n var bbox = group.clippedBBox();\n var rootGroup = group;\n\n if (bbox) {\n var origin = bbox.getOrigin();\n var exportRoot = new Group();\n exportRoot.transform(transform$1().translate(-origin.x, -origin.y));\n exportRoot.children.push(group);\n rootGroup = exportRoot;\n }\n\n root.load([ rootGroup ]);\n\n var svg = \"\" + (root.render()) + \"\";\n\n root.destroy();\n\n return svg;\n}\n\nvar svg$1 = {\n\tSurface: Surface$3,\n\tRootNode: RootNode,\n\tNode: Node,\n\tGroupNode: GroupNode,\n\tArcNode: ArcNode,\n\tCircleNode: CircleNode,\n\tRectNode: RectNode,\n\tImageNode: ImageNode,\n\tTextNode: TextNode,\n\tPathNode: PathNode,\n\tMultiPathNode: MultiPathNode,\n\tDefinitionNode: DefinitionNode,\n\tClipNode: ClipNode,\n\tGradientStopNode: GradientStopNode,\n\tLinearGradientNode: LinearGradientNode,\n\tRadialGradientNode: RadialGradientNode,\n\texportGroup: exportGroup\n};\n\nvar canvas = {\n\tSurface: Surface$4,\n\tRootNode: RootNode$2,\n\tNode: Node$2,\n\tGroupNode: GroupNode$2,\n\tArcNode: ArcNode$2,\n\tCircleNode: CircleNode$2,\n\tRectNode: RectNode$2,\n\tImageNode: ImageNode$2,\n\tTextNode: TextNode$2,\n\tPathNode: PathNode$2,\n\tMultiPathNode: MultiPathNode$2\n};\n\nfunction exportImage(group, options) {\n var defaults = {\n width: \"800px\", height: \"600px\",\n cors: \"Anonymous\"\n };\n\n var exportRoot = group;\n var bbox = group.clippedBBox();\n\n if (bbox) {\n var origin = bbox.getOrigin();\n exportRoot = new Group();\n exportRoot.transform(transform$1().translate(-origin.x, -origin.y));\n exportRoot.children.push(group);\n\n var size = bbox.getSize();\n defaults.width = size.width + \"px\";\n defaults.height = size.height + \"px\";\n }\n\n var surfaceOptions = $.extend(defaults, options);\n\n var container = document.createElement(\"div\");\n var style = container.style;\n\n style.display = \"none\";\n style.width = surfaceOptions.width;\n style.height = surfaceOptions.height;\n document.body.appendChild(container);\n\n var surface = new Surface$4(container, surfaceOptions);\n surface.suspendTracking();\n surface.draw(exportRoot);\n\n var promise = surface.image();\n var destroy = function () {\n surface.destroy();\n document.body.removeChild(container);\n };\n promise.then(destroy, destroy);\n\n return promise;\n}\n\nfunction exportSVG(group, options) {\n var svg = exportGroup(group);\n\n if (!options || !options.raw) {\n svg = \"data:image/svg+xml;base64,\" + encodeBase64(svg);\n }\n\n return createPromise().resolve(svg);\n}\n\n/* eslint-disable no-multi-spaces, key-spacing, indent, camelcase, space-before-blocks, eqeqeq, brace-style */\n/* eslint-disable space-infix-ops, space-before-function-paren, array-bracket-spacing, object-curly-spacing */\n/* eslint-disable no-nested-ternary, max-params, default-case, no-else-return, no-empty, yoda */\n/* eslint-disable no-param-reassign, no-var, block-scoped-var */\n\nvar browser = supportBrowser || {};\n/*\n\n XXX: to test:\n\n - cloneNodes function:\n - drawing document containing canvas with page breaking\n - drawing document with named radio -s (should not clear selection)\n - IE9/IE10 don't support el.dataset; do they copy user data?\n\n - repeating table headers/footers on page breaking\n\n - forceBreak, keepTogether\n\n - avoidLinks\n\n */\n\n/* -----[ local vars ]----- */\n\nfunction slice$1$1(thing) {\n return Array.prototype.slice.call(thing);\n}\n\nvar KENDO_PSEUDO_ELEMENT = \"KENDO-PSEUDO-ELEMENT\";\n\nvar IMAGE_CACHE = {};\n\nvar nodeInfo = {};\nnodeInfo._root = nodeInfo;\n\n/* -----[ Custom Text node to speed up rendering in kendo.pdf ]----- */\n\nvar inBrowser = typeof window !== 'undefined';\nvar microsoft = inBrowser ? browser.msie || browser.edge : false;\n\nvar TextRect = (function (Text$$1) {\n function TextRect(str, rect, options) {\n Text$$1.call(this, str, rect.getOrigin(), options);\n this._pdfRect = rect;\n }\n\n extendStatic(TextRect, Text$$1);\n TextRect.prototype = Object.create( Text$$1 && Text$$1.prototype );\n TextRect.prototype.constructor = TextRect;\n TextRect.fn = TextRect.prototype;\n TextRect.fn.init = TextRect.fn.constructor;\n TextRect.prototype.rect = function rect () {\n // this is the crux of it: we can avoid a call to\n // measure(), which is what the base class does, since we\n // already know the rect. measure() is s-l-o-w.\n return this._pdfRect;\n };\n TextRect.prototype.rawBBox = function rawBBox () {\n // also let's avoid creating a new rectangle.\n return this._pdfRect;\n };\n\n return TextRect;\n}(Text));\n\nfunction addClass(el, cls) {\n if (el.classList) {\n el.classList.add(cls);\n } else {\n el.className += \" \" + cls;\n }\n}\n\nfunction removeClass(el, cls) {\n if (el.classList) {\n el.classList.remove(cls);\n } else {\n el.className = el.className.split(/\\s+/).reduce(function(a, word){\n if (word != cls) {\n a.push(word);\n }\n return a;\n }, []).join(\" \");\n }\n}\n\nfunction setCSS(el, styles) {\n Object.keys(styles).forEach(function(key){\n el.style[key] = styles[key];\n });\n}\n\nvar matches = typeof Element !== \"undefined\" && Element.prototype && (function(p){\n if (p.matches) {\n return function(el, selector) { return el.matches(selector); };\n }\n if (p.webkitMatchesSelector) {\n return function(el, selector) { return el.webkitMatchesSelector(selector); };\n }\n if (p.mozMatchesSelector) {\n return function(el, selector) { return el.mozMatchesSelector(selector); };\n }\n if (p.msMatchesSelector) {\n return function(el, selector) { return el.msMatchesSelector(selector); };\n }\n return function(s) {\n\treturn [].indexOf.call(document.querySelectorAll(s), this) !== -1;\n };\n})(Element.prototype);\n\nfunction closest(el, selector) {\n if (el.closest) {\n return el.closest(selector);\n }\n // IE: stringifying rather than simply comparing with `document`,\n // which is not iframe-proof and fails in editor export —\n // https://github.com/telerik/kendo/issues/6721\n while (el && !/^\\[object (?:HTML)?Document\\]$/.test(String(el))) {\n if (el.nodeType == 1 /* Element */ && matches(el, selector)) {\n return el;\n }\n el = el.parentNode;\n }\n}\n\n// clone nodes ourselves, so that we redraw (DOM or\n// jQuery clone will not)\nvar cloneNodes = (function($){\n if ($) {\n // if we have Kendo and jQuery, use this version as it will\n // maintain proper links between cloned element and Kendo\n // widgets (i.e. it clones jQuery data(), which isn't the same\n // as element's data attributes).\n // https://github.com/telerik/kendo-ui-core/issues/2750\n return function cloneNodes(el) {\n var clone = el.cloneNode(false);\n if (el.nodeType == 1 /* Element */) {\n var $el = $(el), $clone = $(clone), i;\n var data = $el.data();\n for (i in data) {\n $clone.data(i, data[i]);\n }\n if (/^canvas$/i.test(el.tagName)) {\n clone.getContext(\"2d\").drawImage(el, 0, 0);\n } else if (/^(?:input|select|textarea|option)$/i.test(el.tagName)) {\n // drop the name attributes so that we don't affect the selection of the\n // original nodes (i.e. checked status of radio buttons) when we insert our copy\n // into the DOM. https://github.com/telerik/kendo/issues/5409\n clone.removeAttribute(\"id\");\n clone.removeAttribute(\"name\");\n if (!/^textarea$/i.test(el.tagName)) {\n clone.value = el.value;\n }\n clone.checked = el.checked;\n clone.selected = el.selected;\n }\n for (i = el.firstChild; i; i = i.nextSibling) {\n clone.appendChild(cloneNodes(i));\n }\n }\n return clone;\n };\n } else {\n // the no-jQuery version\n return function cloneNodes(el) {\n var clone = (function dive(node){\n var clone = node.cloneNode(false);\n if (node._kendoExportVisual) {\n clone._kendoExportVisual = node._kendoExportVisual;\n }\n for (var i = node.firstChild; i; i = i.nextSibling) {\n clone.appendChild(dive(i));\n }\n return clone;\n })(el);\n\n // re-draw canvases - https://github.com/telerik/kendo/issues/4872\n var canvases = el.querySelectorAll(\"canvas\");\n if (canvases.length) {\n slice$1$1(clone.querySelectorAll(\"canvas\")).forEach(function (canvas$$1, i) {\n canvas$$1.getContext(\"2d\").drawImage(canvases[i], 0, 0);\n });\n }\n\n // remove \"name\" attributes from elements -\n // https://github.com/telerik/kendo/issues/5409\n var orig = el.querySelectorAll(\"input, select, textarea, option\");\n slice$1$1(clone.querySelectorAll(\"input, select, textarea, option\")).forEach(function (el, i) {\n el.removeAttribute(\"id\");\n el.removeAttribute(\"name\");\n if (!/^textarea$/i.test(el.tagName)) {\n el.value = orig[i].value;\n }\n el.checked = orig[i].checked;\n el.selected = orig[i].selected;\n });\n\n return clone;\n };\n }\n})(typeof window !== \"undefined\" && window.kendo && window.kendo.jQuery);\n\nfunction getXY(thing) {\n if (typeof thing == \"number\") {\n return { x: thing, y: thing };\n }\n if (Array.isArray(thing)) {\n return { x: thing[0], y: thing[1] };\n }\n return { x: thing.x, y: thing.y };\n}\n\nfunction drawDOM(element, options) {\n if (!options) {\n options = {};\n }\n var promise = createPromise();\n\n if (!element) {\n return promise.reject(\"No element to export\");\n }\n\n if (typeof window.getComputedStyle != \"function\") {\n throw new Error(\"window.getComputedStyle is missing. You are using an unsupported browser, or running in IE8 compatibility mode. Drawing HTML is supported in Chrome, Firefox, Safari and IE9+.\");\n }\n\n kendo.pdf.defineFont(getFontFaces(element.ownerDocument));\n\n var scale = getXY(options.scale || 1);\n\n function doOne(element) {\n var group = new Group();\n\n // translate to start of page\n var pos = element.getBoundingClientRect();\n setTransform$1(group, [\n scale.x,\n 0,\n 0,\n scale.y,\n (-pos.left * scale.x),\n (-pos.top * scale.y)\n ]);\n\n nodeInfo._clipbox = false;\n nodeInfo._matrix = Matrix.unit();\n nodeInfo._stackingContext = {\n element: element,\n group: group\n };\n\n if (options.avoidLinks === true) {\n nodeInfo._avoidLinks = \"a\";\n } else {\n nodeInfo._avoidLinks = options.avoidLinks;\n }\n\n addClass(element, \"k-pdf-export\");\n renderElement(element, group);\n removeClass(element, \"k-pdf-export\");\n\n return group;\n }\n\n cacheImages([ element ], function(){\n var forceBreak = options && options.forcePageBreak;\n var hasPaperSize = options && options.paperSize && options.paperSize != \"auto\";\n var paperOptions = kendo.pdf.getPaperOptions(function(key, def){\n if (key == \"paperSize\") {\n // PDF.getPaperOptions croaks on \"auto\", just pass dummy A4 as we might\n // still be interested in margins.\n return hasPaperSize ? options[key] : \"A4\";\n }\n return key in options ? options[key] : def;\n });\n var pageWidth = hasPaperSize && paperOptions.paperSize[0];\n var pageHeight = hasPaperSize && paperOptions.paperSize[1];\n var margin = options.margin && paperOptions.margin;\n var hasMargin = Boolean(margin);\n if (forceBreak || pageHeight) {\n if (!margin) {\n margin = { left: 0, top: 0, right: 0, bottom: 0 };\n }\n\n // we want paper size and margin to be unaffected by\n // scaling in the output, so we have to reverse-scale\n // before our calculations begin.\n if (pageWidth) { pageWidth /= scale.x; }\n if (pageHeight) { pageHeight /= scale.y; }\n margin.left /= scale.x;\n margin.right /= scale.x;\n margin.top /= scale.y;\n margin.bottom /= scale.y;\n\n var group = new Group({\n pdf: {\n multiPage : true,\n paperSize : hasPaperSize ? paperOptions.paperSize : \"auto\",\n _ignoreMargin : hasMargin // HACK! see exportPDF in pdf/drawing.js\n }\n });\n handlePageBreaks(\n function(x) {\n if (options.progress) {\n var canceled = false, pageNum = 0;\n (function next(){\n if (pageNum < x.pages.length) {\n var page = doOne(x.pages[pageNum]);\n group.append(page);\n options.progress({\n page: page,\n pageNum: ++pageNum,\n totalPages: x.pages.length,\n cancel: function() {\n canceled = true;\n }\n });\n if (!canceled) {\n setTimeout(next);\n } else {\n // XXX: should we also fail() the deferred object?\n x.container.parentNode.removeChild(x.container);\n }\n } else {\n x.container.parentNode.removeChild(x.container);\n promise.resolve(group);\n }\n })();\n } else {\n x.pages.forEach(function(page){\n group.append(doOne(page));\n });\n x.container.parentNode.removeChild(x.container);\n promise.resolve(group);\n }\n },\n element,\n forceBreak,\n pageWidth ? pageWidth - margin.left - margin.right : null,\n pageHeight ? pageHeight - margin.top - margin.bottom : null,\n margin,\n options\n );\n } else {\n promise.resolve(doOne(element));\n }\n });\n\n function makeTemplate(template) {\n if (template != null) {\n if (typeof template == \"string\") {\n template = kendo.template(template.replace(/^\\s+|\\s+$/g, \"\"));\n }\n if (typeof template == \"function\") {\n return function(data) {\n var el = template(data);\n if (el && typeof el == \"string\") {\n var div = document.createElement(\"div\");\n div.innerHTML = el;\n el = div.firstElementChild;\n }\n return el;\n };\n }\n // assumed DOM element\n return function() {\n return template.cloneNode(true);\n };\n }\n }\n\n function handlePageBreaks(callback, element, forceBreak, pageWidth, pageHeight, margin, options) {\n var template = makeTemplate(options.template);\n var doc = element.ownerDocument;\n var pages = [];\n var copy = options._destructive ? element : cloneNodes(element);\n var container = doc.createElement(\"KENDO-PDF-DOCUMENT\");\n var adjust = 0;\n\n // make sure elements are at the end (Grid widget\n // places TFOOT before TBODY, tricking our algorithm to\n // insert a page break right after the header).\n // https://github.com/telerik/kendo/issues/4699\n slice$1$1(copy.querySelectorAll(\"tfoot\")).forEach(function(tfoot){\n tfoot.parentNode.appendChild(tfoot);\n });\n\n // remember the index of each LI from an ordered list.\n // we'll use it to reconstruct the proper numbering.\n slice$1$1(copy.querySelectorAll(\"ol\")).forEach(function(ol){\n slice$1$1(ol.children).forEach(function(li, index){\n li.setAttribute(\"kendo-split-index\", index);\n });\n });\n\n setCSS(container, {\n display : \"block\",\n position : \"absolute\",\n boxSizing : \"content-box\",\n left : \"-10000px\",\n top : \"-10000px\"\n });\n\n if (pageWidth) {\n // subtle: if we don't set the width *and* margins here, the layout in this\n // container will be different from the one in our final page elements, and we'll\n // split at the wrong places.\n setCSS(container, {\n width : pageWidth + \"px\",\n paddingLeft : margin.left + \"px\",\n paddingRight : margin.right + \"px\"\n });\n\n // when the first element has a margin-top (i.e. a

    ) the page will be\n // inadvertently enlarged by that number (the browser will report the container's\n // bounding box top to start at the element's top, rather than including its\n // margin). Adding overflow: hidden seems to fix it.\n //\n // to understand the difference, try the following snippets in your browser:\n //\n // 1.
    \n //

    Foo

    \n //
    \n //\n // 2.
    \n //

    Foo

    \n //
    \n //\n // this detail is not important when automatic page breaking is not requested, hence\n // doing it only if pageWidth is defined.\n setCSS(copy, { overflow: \"hidden\" });\n }\n\n element.parentNode.insertBefore(container, element);\n container.appendChild(copy);\n\n // With cache disabled, images will still have height zero until their `complete` attribute\n // is true. `whenImagesAreActuallyLoaded` will wait for it.\n if (options.beforePageBreak) {\n whenImagesAreActuallyLoaded([ container ], function() {\n options.beforePageBreak(container, doPageBreak);\n });\n } else {\n whenImagesAreActuallyLoaded([ container ], doPageBreak);\n }\n\n function doPageBreak() {\n if (forceBreak != \"-\" || pageHeight) {\n splitElement(copy);\n }\n\n {\n var page = makePage();\n copy.parentNode.insertBefore(page, copy);\n page.appendChild(copy);\n }\n\n if (template) {\n pages.forEach(function(page, i){\n var el = template({\n element : page,\n pageNum : i + 1,\n totalPages : pages.length\n });\n if (el) {\n page.appendChild(el);\n }\n });\n }\n\n cacheImages(pages, callback.bind(null, { pages: pages, container: container }));\n }\n\n function keepTogether(el) {\n if (options.keepTogether && matches(el, options.keepTogether) && el.offsetHeight <= pageHeight - adjust) {\n return true;\n }\n\n var tag = el.tagName;\n if (/^h[1-6]$/i.test(tag) && el.offsetHeight >= pageHeight - adjust) {\n return false;\n }\n\n return (el.getAttribute(\"data-kendo-chart\") ||\n /^(?:img|tr|thead|th|tfoot|iframe|svg|object|canvas|input|textarea|select|video|h[1-6])/i.test(el.tagName));\n }\n\n function splitElement(element) {\n if (element.tagName == \"TABLE\") {\n setCSS(element, { tableLayout: \"fixed\" });\n }\n if (keepTogether(element)) {\n return;\n }\n var style = getComputedStyle$1(element);\n var bottomPadding = parseFloat(getPropertyValue(style, \"padding-bottom\"));\n var bottomBorder = parseFloat(getPropertyValue(style, \"border-bottom-width\"));\n var saveAdjust = adjust;\n adjust += bottomPadding + bottomBorder;\n var isFirst = true;\n for (var el = element.firstChild; el; el = el.nextSibling) {\n if (el.nodeType == 1 /* Element */) {\n isFirst = false;\n if (matches(el, forceBreak)) {\n breakAtElement(el);\n continue;\n }\n if (!pageHeight) {\n // we're in \"manual breaks mode\"\n splitElement(el);\n continue;\n }\n if (!/^(?:static|relative)$/.test(getPropertyValue(getComputedStyle$1(el), \"position\"))) {\n continue;\n }\n var fall = fallsOnMargin(el);\n if (fall == 1) {\n // element starts on next page, break before anyway.\n breakAtElement(el);\n }\n else if (fall) {\n // elements ends up on next page, or possibly doesn't fit on a page at\n // all. break before it anyway if it's an or , otherwise\n // attempt to split.\n if (keepTogether(el)) {\n breakAtElement(el);\n } else {\n splitElement(el);\n }\n }\n else {\n splitElement(el);\n }\n }\n else if (el.nodeType == 3 /* Text */ && pageHeight) {\n splitText(el, isFirst);\n isFirst = false;\n }\n }\n adjust = saveAdjust;\n }\n\n function firstInParent(el) {\n var p = el.parentNode, first = p.firstChild;\n if (el === first) {\n return true;\n }\n if (el === p.children[0]) {\n if (first.nodeType == 7 /* comment */ ||\n first.nodeType == 8 /* processing instruction */) {\n return true;\n }\n if (first.nodeType == 3 /* text */) {\n // if whitespace only we can probably consider it's first\n return !/\\S/.test(first.data);\n }\n }\n return false;\n }\n\n function breakAtElement(el) {\n if (el.nodeType == 1 && el !== copy && firstInParent(el)) {\n return breakAtElement(el.parentNode);\n }\n var table, colgroup, thead, grid, gridHead;\n table = closest(el, \"table\");\n colgroup = table && table.querySelector(\"colgroup\");\n if (options.repeatHeaders) {\n thead = table && table.querySelector(\"thead\");\n\n // If we break page in a Kendo Grid, repeat its header. This ugly hack is\n // necessary because a scrollable grid will keep the header in a separate\n // element from its content.\n //\n // XXX: This is likely to break as soon as the widget HTML is modified.\n grid = closest(el, \".k-grid.k-widget\");\n if (grid && grid.querySelector(\".k-auto-scrollable\")) {\n gridHead = grid.querySelector(\".k-grid-header\");\n }\n }\n var page = makePage();\n var range = doc.createRange();\n range.setStartBefore(copy);\n range.setEndBefore(el);\n page.appendChild(range.extractContents());\n copy.parentNode.insertBefore(page, copy);\n preventBulletOnListItem(el.parentNode);\n if (table) {\n table = closest(el, \"table\"); // that's the
    on next page!\n if (options.repeatHeaders && thead) {\n table.insertBefore(thead.cloneNode(true), table.firstChild);\n }\n if (colgroup) {\n table.insertBefore(colgroup.cloneNode(true), table.firstChild);\n }\n }\n if (options.repeatHeaders && gridHead) {\n grid = closest(el, \".k-grid.k-widget\");\n grid.insertBefore(gridHead.cloneNode(true), grid.firstChild);\n }\n }\n\n function makePage() {\n var page = doc.createElement(\"KENDO-PDF-PAGE\");\n setCSS(page, {\n display : \"block\",\n boxSizing: \"content-box\",\n width : pageWidth ? (pageWidth + \"px\") : \"auto\",\n padding : (margin.top + \"px \" +\n margin.right + \"px \" +\n margin.bottom + \"px \" +\n margin.left + \"px\"),\n\n // allow absolutely positioned elements to be relative to current page\n position : \"relative\",\n\n // without the following we might affect layout of subsequent pages\n height : pageHeight ? (pageHeight + \"px\") : \"auto\",\n overflow : pageHeight || pageWidth ? \"hidden\" : \"visible\",\n clear : \"both\"\n });\n\n // debug\n // $(\"
    \").css({\n // position : \"absolute\",\n // left : margin.left,\n // top : margin.top,\n // width : pageWidth,\n // height : pageHeight,\n // boxSizing : \"border-box\",\n // background: \"rgba(255, 255, 0, 0.5)\"\n // //border : \"1px solid red\"\n // }).appendTo(page);\n\n if (options && options.pageClassName) {\n page.className = options.pageClassName;\n }\n pages.push(page);\n return page;\n }\n\n function fallsOnMargin(thing) {\n var box = thing.getBoundingClientRect();\n if (box.width === 0 || box.height === 0) {\n // I'd say an element with dimensions zero fits on current page.\n return 0;\n }\n var top = copy.getBoundingClientRect().top;\n var available = pageHeight - adjust;\n return (box.height > available) ? 3\n : (box.top - top > available) ? 1\n : (box.bottom - top > available) ? 2\n : 0;\n }\n\n function splitText(node, isFirst) {\n if (!/\\S/.test(node.data)) {\n return;\n }\n\n var len = node.data.length;\n var range = doc.createRange();\n range.selectNodeContents(node);\n var fall = fallsOnMargin(range);\n if (!fall) {\n return; // the whole text fits on current page\n }\n\n var nextnode = node;\n if (fall == 1) {\n // starts on next page, break before anyway.\n if (isFirst) {\n // avoid leaving an empty

    ,

  • , etc. on previous page.\n breakAtElement(node.parentNode);\n } else {\n breakAtElement(node);\n }\n }\n else {\n (function findEOP(min, pos, max) {\n range.setEnd(node, pos);\n if (min == pos || pos == max) {\n return pos;\n }\n if (fallsOnMargin(range)) {\n return findEOP(min, (min + pos) >> 1, pos);\n } else {\n return findEOP(pos, (pos + max) >> 1, max);\n }\n })(0, len >> 1, len);\n\n if (!/\\S/.test(range.toString()) && isFirst) {\n // avoid leaving an empty

    ,

  • , etc. on previous page.\n breakAtElement(node.parentNode);\n } else {\n // This is only needed for IE, but it feels cleaner to do it anyway. Without\n // it, IE will truncate a very long text (playground/pdf-long-text-2.html).\n nextnode = node.splitText(range.endOffset);\n\n var page = makePage();\n range.setStartBefore(copy);\n page.appendChild(range.extractContents());\n copy.parentNode.insertBefore(page, copy);\n preventBulletOnListItem(nextnode.parentNode);\n }\n }\n\n splitText(nextnode);\n }\n\n function preventBulletOnListItem(el) {\n // set a hint on continued LI elements, to tell the\n // renderer not to draw the bullet again.\n // https://github.com/telerik/kendo-ui-core/issues/2732\n var li = closest(el, \"li\");\n if (li) {\n li.setAttribute(\"kendo-no-bullet\", \"1\");\n preventBulletOnListItem(li.parentNode);\n }\n }\n }\n\n return promise;\n}\n\n// This is needed for the Spreadsheet print functionality. Since\n// there we only need to draw text, this cuts through the ceremony\n// of drawDOM/renderElement and renders the text node directly.\nfunction drawText(element) {\n var group = new Group();\n nodeInfo._clipbox = false;\n nodeInfo._matrix = Matrix.unit();\n nodeInfo._stackingContext = {\n element: element,\n group: group\n };\n pushNodeInfo(element, getComputedStyle$1(element), group);\n if (element.firstChild.nodeType == 3 /* Text */) {\n // avoid the penalty of renderElement\n renderText(element, element.firstChild, group);\n } else {\n _renderElement(element, group);\n }\n popNodeInfo();\n return group;\n}\n\nvar parseBackgroundImage = (function(){\n var tok_linear_gradient = /^((-webkit-|-moz-|-o-|-ms-)?linear-gradient\\s*)\\(/;\n //var tok_radial_gradient = /^((-webkit-|-moz-|-o-|-ms-)?radial-gradient\\s*)\\(/;\n var tok_percent = /^([-0-9.]+%)/;\n var tok_length = /^([-0-9.]+px)/;\n var tok_keyword = /^(left|right|top|bottom|to|center)\\W/;\n var tok_angle = /^([-0-9.]+(deg|grad|rad|turn)|0)/;\n var tok_whitespace = /^(\\s+)/;\n var tok_popen = /^(\\()/;\n var tok_pclose = /^(\\))/;\n var tok_comma = /^(,)/;\n var tok_url = /^(url)\\(/;\n var tok_content = /^(.*?)\\)/;\n\n var cache1 = {}, cache2 = {};\n\n function parse(input) {\n var orig = input;\n if (hasOwnProperty(cache1, orig)) {\n return cache1[orig];\n }\n function skip_ws() {\n var m = tok_whitespace.exec(input);\n if (m) {\n input = input.substr(m[1].length);\n }\n }\n function read(token) {\n skip_ws();\n var m = token.exec(input);\n if (m) {\n input = input.substr(m[1].length);\n return m[1];\n }\n }\n\n function read_stop() {\n var color = kendo.parseColor(input, true);\n var length, percent;\n if (color) {\n var match =\n /^#[0-9a-f]+/i.exec(input) ||\n /^rgba?\\(.*?\\)/i.exec(input) ||\n /^..*?\\b/.exec(input); // maybe named color\n input = input.substr(match[0].length);\n color = color.toRGB();\n if (!(length = read(tok_length))) {\n percent = read(tok_percent);\n }\n return { color: color, length: length, percent: percent };\n }\n }\n\n function read_linear_gradient(propName) {\n var angle;\n var to1, to2;\n var stops = [];\n var reverse = false;\n\n if (read(tok_popen)) {\n // 1. [ || to , ]?\n angle = read(tok_angle);\n if (angle == \"0\") {\n angle = \"0deg\"; // Edge\n }\n if (angle) {\n angle = parseAngle(angle);\n read(tok_comma);\n }\n else {\n to1 = read(tok_keyword);\n if (to1 == \"to\") {\n to1 = read(tok_keyword);\n } else if (to1 && /^-/.test(propName)) {\n reverse = true;\n }\n to2 = read(tok_keyword);\n read(tok_comma);\n }\n\n if (/-moz-/.test(propName) && angle == null && to1 == null) {\n var x = read(tok_percent), y = read(tok_percent);\n reverse = true;\n if (x == \"0%\") {\n to1 = \"left\";\n } else if (x == \"100%\") {\n to1 = \"right\";\n }\n if (y == \"0%\") {\n to2 = \"top\";\n } else if (y == \"100%\") {\n to2 = \"bottom\";\n }\n read(tok_comma);\n }\n\n // 2. color stops\n while (input && !read(tok_pclose)) {\n var stop = read_stop();\n if (!stop) {\n break;\n }\n stops.push(stop);\n read(tok_comma);\n }\n\n return {\n type : \"linear\",\n angle : angle,\n to : to1 && to2 ? to1 + \" \" + to2 : to1 ? to1 : to2 ? to2 : null,\n stops : stops,\n reverse : reverse\n };\n }\n }\n\n function read_url() {\n if (read(tok_popen)) {\n var url = read(tok_content);\n url = url.replace(/^['\"]+|[\"']+$/g, \"\");\n read(tok_pclose);\n return { type: \"url\", url: url };\n }\n }\n\n var tok;\n\n if ((tok = read(tok_linear_gradient))) {\n tok = read_linear_gradient(tok);\n }\n else if ((tok = read(tok_url))) {\n tok = read_url();\n }\n\n return (cache1[orig] = tok || { type: \"none\" });\n }\n\n return function(input) {\n if (hasOwnProperty(cache2, input)) {\n return cache2[input];\n }\n return (cache2[input] = splitProperty(input).map(parse));\n };\n})();\n\nvar splitProperty = (function(){\n var cache = {};\n return function(input, separator) {\n if (!separator) {\n separator = /^\\s*,\\s*/;\n }\n\n var cacheKey = input + separator;\n\n if (hasOwnProperty(cache, cacheKey)) {\n return cache[cacheKey];\n }\n\n var ret = [];\n var last$$1 = 0, pos = 0;\n var in_paren = 0;\n var in_string = false;\n var m;\n\n function looking_at(rx) {\n return (m = rx.exec(input.substr(pos)));\n }\n\n function trim(str) {\n return str.replace(/^\\s+|\\s+$/g, \"\");\n }\n\n while (pos < input.length) {\n if (!in_string && looking_at(/^[\\(\\[\\{]/)) {\n in_paren++;\n pos++;\n }\n else if (!in_string && looking_at(/^[\\)\\]\\}]/)) {\n in_paren--;\n pos++;\n }\n else if (!in_string && looking_at(/^[\\\"\\']/)) {\n in_string = m[0];\n pos++;\n }\n else if (in_string == \"'\" && looking_at(/^\\\\\\'/)) {\n pos += 2;\n }\n else if (in_string == '\"' && looking_at(/^\\\\\\\"/)) {\n pos += 2;\n }\n else if (in_string == \"'\" && looking_at(/^\\'/)) {\n in_string = false;\n pos++;\n }\n else if (in_string == '\"' && looking_at(/^\\\"/)) {\n in_string = false;\n pos++;\n }\n else if (looking_at(separator)) {\n if (!in_string && !in_paren && pos > last$$1) {\n ret.push(trim(input.substring(last$$1, pos)));\n last$$1 = pos + m[0].length;\n }\n pos += m[0].length;\n }\n else {\n pos++;\n }\n }\n if (last$$1 < pos) {\n ret.push(trim(input.substring(last$$1, pos)));\n }\n return (cache[cacheKey] = ret);\n };\n})();\n\nvar getFontURL = (function(cache){\n return function(el){\n // XXX: for IE we get here the whole cssText of the rule,\n // because the computedStyle.src is empty. Next time we need\n // to fix these regexps we better write a CSS parser. :-\\\n var url = cache[el];\n if (!url) {\n var m;\n if ((m = /url\\((['\"]?)([^'\")]*?)\\1\\)\\s+format\\((['\"]?)truetype\\3\\)/.exec(el))) {\n url = cache[el] = m[2];\n } else if ((m = /url\\((['\"]?)([^'\")]*?\\.ttf)\\1\\)/.exec(el))) {\n url = cache[el] = m[2];\n }\n }\n return url;\n };\n})(Object.create ? Object.create(null) : {});\n\nvar getFontHeight = (function(cache){\n return function(font) {\n var height = cache[font];\n if (height == null) {\n height = cache[font] = kendoUtil.measureText(\"Mapq\", { font: font }).height;\n }\n return height;\n };\n})(Object.create ? Object.create(null) : {});\n\nfunction getFontFaces(doc) {\n if (doc == null) {\n doc = document;\n }\n var result = {};\n for (var i = 0; i < doc.styleSheets.length; ++i) {\n doStylesheet(doc.styleSheets[i]);\n }\n return result;\n function doStylesheet(ss) {\n if (ss) {\n var rules = null;\n try {\n rules = ss.cssRules;\n } catch (ex) {}\n if (rules) {\n addRules(ss, rules);\n }\n }\n }\n function findFonts(rule) {\n var src = getPropertyValue(rule.style, \"src\");\n if (src) {\n return splitProperty(src).reduce(function(a, el){\n var font = getFontURL(el);\n if (font) {\n a.push(font);\n }\n return a;\n }, []);\n } else {\n // Internet Explorer\n // XXX: this is gross. should work though for valid CSS.\n var font = getFontURL(rule.cssText);\n return font ? [ font ] : [];\n }\n }\n function addRules(styleSheet, rules) {\n for (var i = 0; i < rules.length; ++i) {\n var r = rules[i];\n switch (r.type) {\n case 3: // CSSImportRule\n doStylesheet(r.styleSheet);\n break;\n case 5: // CSSFontFaceRule\n var style = r.style;\n var family = splitProperty(getPropertyValue(style, \"font-family\"));\n var bold = /^([56789]00|bold)$/i.test(getPropertyValue(style, \"font-weight\"));\n var italic = \"italic\" == getPropertyValue(style, \"font-style\");\n var src = findFonts(r);\n if (src.length > 0) {\n addRule(styleSheet, family, bold, italic, src[0]);\n }\n }\n }\n }\n function addRule(styleSheet, names, bold, italic, url) {\n // We get full resolved absolute URLs in Chrome, but sadly\n // not in Firefox.\n if (!(/^data:/i.test(url))) {\n if (!(/^[^\\/:]+:\\/\\//.test(url) || /^\\//.test(url))) {\n url = String(styleSheet.href).replace(/[^\\/]*$/, \"\") + url;\n }\n }\n names.forEach(function(name){\n name = name.replace(/^(['\"]?)(.*?)\\1$/, \"$2\"); // it's quoted\n if (bold) {\n name += \"|bold\";\n }\n if (italic) {\n name += \"|italic\";\n }\n result[name] = url;\n });\n }\n}\n\nfunction hasOwnProperty(obj, key) {\n return Object.prototype.hasOwnProperty.call(obj, key);\n}\n\nfunction getCounter(name) {\n name = \"_counter_\" + name;\n return nodeInfo[name];\n}\n\nfunction getAllCounters(name) {\n var values = [], p = nodeInfo;\n name = \"_counter_\" + name;\n while (p) {\n if (hasOwnProperty(p, name)) {\n values.push(p[name]);\n }\n p = Object.getPrototypeOf(p);\n }\n return values.reverse();\n}\n\nfunction incCounter(name, inc) {\n var p = nodeInfo;\n name = \"_counter_\" + name;\n while (p && !hasOwnProperty(p, name)) {\n p = Object.getPrototypeOf(p);\n }\n if (!p) {\n p = nodeInfo._root;\n }\n p[name] = (p[name] || 0) + (inc == null ? 1 : inc);\n}\n\nfunction resetCounter(name, val) {\n name = \"_counter_\" + name;\n nodeInfo[name] = val == null ? 0 : val;\n}\n\nfunction doCounters(a, f, def) {\n for (var i = 0; i < a.length;) {\n var name = a[i++];\n var val = parseFloat(a[i]);\n if (isNaN(val)) {\n f(name, def);\n } else {\n f(name, val);\n ++i;\n }\n }\n}\n\nfunction updateCounters(style) {\n var counterReset = getPropertyValue(style, \"counter-reset\");\n if (counterReset) {\n doCounters(splitProperty(counterReset, /^\\s+/), resetCounter, 0);\n }\n var counterIncrement = getPropertyValue(style, \"counter-increment\");\n if (counterIncrement) {\n doCounters(splitProperty(counterIncrement, /^\\s+/), incCounter, 1);\n }\n}\n\nfunction parseColor$1(str, css) {\n var color = kendo.parseColor(str, true);\n if (color) {\n color = color.toRGB();\n if (css) {\n color = color.toCssRgba();\n } else if (color.a === 0) {\n color = null;\n }\n }\n return color;\n}\n\nfunction whenImagesAreActuallyLoaded(elements, callback) {\n var pending = 0;\n elements.forEach(function(el){\n var images = el.querySelectorAll(\"img\");\n for (var i = 0; i < images.length; ++i) {\n var img = images[i];\n if (!img.complete) {\n pending++;\n img.onload = img.onerror = next;\n }\n }\n });\n if (!pending) {\n next();\n }\n function next() {\n if (--pending <= 0) {\n callback();\n }\n }\n}\n\nfunction cacheImages(elements, callback) {\n var urls = [];\n function add(url) {\n if (!IMAGE_CACHE[url]) {\n IMAGE_CACHE[url] = true;\n urls.push(url);\n }\n }\n\n elements.forEach(function dive(element){\n if (/^img$/i.test(element.tagName)) {\n add(element.src);\n }\n parseBackgroundImage(\n getPropertyValue(\n getComputedStyle$1(element), \"background-image\"\n )\n ).forEach(function(bg){\n if (bg.type == \"url\") {\n add(bg.url);\n }\n });\n\n if (element.children) {\n slice$1$1(element.children).forEach(dive);\n }\n });\n\n var count = urls.length;\n function next() {\n if (--count <= 0) {\n // Even though we cached them, they simply won't be available immediately in the newly\n // created DOM. Previously we'd allow a 10ms timeout, but that's arbitrary and clearly\n // not working in all cases (https://github.com/telerik/kendo/issues/5399), so this\n // function will wait for their .complete attribute.\n whenImagesAreActuallyLoaded(elements, callback);\n }\n }\n if (count === 0) {\n next();\n }\n urls.forEach(function(url){\n var img = IMAGE_CACHE[url] = new window.Image();\n if (!(/^data:/i.test(url))) {\n img.crossOrigin = \"Anonymous\";\n }\n img.src = url;\n if (img.complete) {\n next();\n } else {\n img.onload = next;\n img.onerror = function() {\n IMAGE_CACHE[url] = null;\n next();\n };\n }\n });\n}\n\nfunction alphaNumeral(n) {\n var result = \"\";\n do {\n var r = n % 26;\n result = String.fromCharCode(97 + r) + result;\n n = Math.floor(n / 26);\n } while (n > 0);\n return result;\n}\n\nfunction pushNodeInfo(element, style, group) {\n nodeInfo = Object.create(nodeInfo);\n nodeInfo[element.tagName.toLowerCase()] = {\n element: element,\n style: style\n };\n var decoration = getPropertyValue(style, \"text-decoration\");\n if (decoration && decoration != \"none\") {\n var color = getPropertyValue(style, \"color\");\n decoration.split(/\\s+/g).forEach(function(name){\n if (!nodeInfo[name]) {\n nodeInfo[name] = color;\n }\n });\n }\n\n if (createsStackingContext(style)) {\n nodeInfo._stackingContext = {\n element: element,\n group: group\n };\n }\n}\n\nfunction popNodeInfo() {\n nodeInfo = Object.getPrototypeOf(nodeInfo);\n}\n\nfunction updateClipbox(path) {\n if (nodeInfo._clipbox != null) {\n var box = path.bbox(nodeInfo._matrix);\n if (nodeInfo._clipbox) {\n nodeInfo._clipbox = Rect.intersect(nodeInfo._clipbox, box);\n } else {\n nodeInfo._clipbox = box;\n }\n }\n}\n\nfunction emptyClipbox() {\n var cb = nodeInfo._clipbox;\n if (cb == null) {\n return true;\n }\n if (cb) {\n return cb.width() === 0 || cb.height() === 0;\n }\n}\n\nfunction createsStackingContext(style) {\n function prop(name) { return getPropertyValue(style, name); }\n if (prop(\"transform\") != \"none\" ||\n prop(\"position\") != \"static\" ||\n prop(\"z-index\") != \"auto\" ||\n prop(\"opacity\") < 1) {\n return true;\n }\n}\n\nfunction getComputedStyle$1(element, pseudoElt) {\n return window.getComputedStyle(element, pseudoElt || null);\n}\n\nfunction getPropertyValue(style, prop, defa) {\n var val = style.getPropertyValue(prop);\n if (val == null || val === \"\") {\n if (browser.webkit) {\n val = style.getPropertyValue(\"-webkit-\" + prop );\n } else if (browser.mozilla) {\n val = style.getPropertyValue(\"-moz-\" + prop );\n } else if (browser.opera) {\n val = style.getPropertyValue(\"-o-\" + prop);\n } else if (microsoft) {\n val = style.getPropertyValue(\"-ms-\" + prop);\n }\n }\n if (arguments.length > 2 && (val == null || val === \"\")) {\n return defa;\n } else {\n return val;\n }\n}\n\nfunction pleaseSetPropertyValue(style, prop, value, important) {\n style.setProperty(prop, value, important);\n if (browser.webkit) {\n style.setProperty(\"-webkit-\" + prop, value, important);\n } else if (browser.mozilla) {\n style.setProperty(\"-moz-\" + prop, value, important);\n } else if (browser.opera) {\n style.setProperty(\"-o-\" + prop, value, important);\n } else if (microsoft) {\n style.setProperty(\"-ms-\" + prop, value, important);\n prop = \"ms\" + prop.replace(/(^|-)([a-z])/g, function(s, p1, p2){\n return p1 + p2.toUpperCase();\n });\n style[prop] = value;\n }\n}\n\nfunction getBorder(style, side) {\n side = \"border-\" + side;\n return {\n width: parseFloat(getPropertyValue(style, side + \"-width\")),\n style: getPropertyValue(style, side + \"-style\"),\n color: parseColor$1(getPropertyValue(style, side + \"-color\"), true)\n };\n}\n\nfunction saveStyle(element, func) {\n var prev = element.style.cssText;\n var result = func();\n element.style.cssText = prev;\n return result;\n}\n\nfunction getBorderRadius(style, side) {\n var r = getPropertyValue(style, \"border-\" + side + \"-radius\").split(/\\s+/g).map(parseFloat);\n if (r.length == 1) {\n r.push(r[0]);\n }\n return sanitizeRadius({ x: r[0], y: r[1] });\n}\n\nfunction getContentBox(element) {\n var box = element.getBoundingClientRect();\n box = innerBox(box, \"border-*-width\", element);\n box = innerBox(box, \"padding-*\", element);\n return box;\n}\n\nfunction innerBox(box, prop, element) {\n var style, wt, wr, wb, wl;\n if (typeof prop == \"string\") {\n style = getComputedStyle$1(element);\n wt = parseFloat(getPropertyValue(style, prop.replace(\"*\", \"top\")));\n wr = parseFloat(getPropertyValue(style, prop.replace(\"*\", \"right\")));\n wb = parseFloat(getPropertyValue(style, prop.replace(\"*\", \"bottom\")));\n wl = parseFloat(getPropertyValue(style, prop.replace(\"*\", \"left\")));\n }\n else if (typeof prop == \"number\") {\n wt = wr = wb = wl = prop;\n }\n return {\n top : box.top + wt,\n right : box.right - wr,\n bottom : box.bottom - wb,\n left : box.left + wl,\n width : box.right - box.left - wr - wl,\n height : box.bottom - box.top - wb - wt\n };\n}\n\nfunction getTransform(style) {\n var transform$$1 = getPropertyValue(style, \"transform\");\n if (transform$$1 == \"none\") {\n return null;\n }\n var matrix = /^\\s*matrix\\(\\s*(.*?)\\s*\\)\\s*$/.exec(transform$$1);\n if (matrix) {\n var origin = getPropertyValue(style, \"transform-origin\");\n matrix = matrix[1].split(/\\s*,\\s*/g).map(parseFloat);\n origin = origin.split(/\\s+/g).map(parseFloat);\n return {\n matrix: matrix,\n origin: origin\n };\n }\n}\n\nfunction radiansToDegrees(radians) {\n return ((180 * radians) / Math.PI) % 360;\n}\n\nfunction parseAngle(angle) {\n var num = parseFloat(angle);\n if (/grad$/.test(angle)) {\n return Math.PI * num / 200;\n }\n else if (/rad$/.test(angle)) {\n return num;\n }\n else if (/turn$/.test(angle)) {\n return Math.PI * num * 2;\n }\n else if (/deg$/.test(angle)) {\n return Math.PI * num / 180;\n }\n}\n\nfunction setTransform$1(shape, m) {\n m = new Matrix(m[0], m[1], m[2], m[3], m[4], m[5]);\n shape.transform(m);\n return m;\n}\n\nfunction setClipping(shape, clipPath) {\n shape.clip(clipPath);\n}\n\nfunction addArcToPath(path, x, y, options) {\n var points = new Arc$2([ x, y ], options).curvePoints(), i = 1;\n while (i < points.length) {\n path.curveTo(points[i++], points[i++], points[i++]);\n }\n}\n\nfunction sanitizeRadius(r) {\n if (r.x <= 0 || r.y <= 0) {\n r.x = r.y = 0;\n }\n return r;\n}\n\nfunction adjustBorderRadiusForBox(box, rTL, rTR, rBR, rBL) {\n // adjust border radiuses such that the sum of adjacent\n // radiuses is not bigger than the length of the side.\n // seems the correct algorithm is variant (3) from here:\n // http://www.w3.org/Style/CSS/Tracker/issues/29?changelog\n var tl_x = Math.max(0, rTL.x), tl_y = Math.max(0, rTL.y);\n var tr_x = Math.max(0, rTR.x), tr_y = Math.max(0, rTR.y);\n var br_x = Math.max(0, rBR.x), br_y = Math.max(0, rBR.y);\n var bl_x = Math.max(0, rBL.x), bl_y = Math.max(0, rBL.y);\n\n var f = Math.min(\n box.width / (tl_x + tr_x),\n box.height / (tr_y + br_y),\n box.width / (br_x + bl_x),\n box.height / (bl_y + tl_y)\n );\n\n if (f < 1) {\n tl_x *= f; tl_y *= f;\n tr_x *= f; tr_y *= f;\n br_x *= f; br_y *= f;\n bl_x *= f; bl_y *= f;\n }\n\n return {\n tl: { x: tl_x, y: tl_y },\n tr: { x: tr_x, y: tr_y },\n br: { x: br_x, y: br_y },\n bl: { x: bl_x, y: bl_y }\n };\n}\n\nfunction elementRoundBox(element, box, type) {\n var style = getComputedStyle$1(element);\n\n var rTL = getBorderRadius(style, \"top-left\");\n var rTR = getBorderRadius(style, \"top-right\");\n var rBL = getBorderRadius(style, \"bottom-left\");\n var rBR = getBorderRadius(style, \"bottom-right\");\n\n if (type == \"padding\" || type == \"content\") {\n var bt = getBorder(style, \"top\");\n var br = getBorder(style, \"right\");\n var bb = getBorder(style, \"bottom\");\n var bl = getBorder(style, \"left\");\n rTL.x -= bl.width; rTL.y -= bt.width;\n rTR.x -= br.width; rTR.y -= bt.width;\n rBR.x -= br.width; rBR.y -= bb.width;\n rBL.x -= bl.width; rBL.y -= bb.width;\n if (type == \"content\") {\n var pt = parseFloat(getPropertyValue(style, \"padding-top\"));\n var pr = parseFloat(getPropertyValue(style, \"padding-right\"));\n var pb = parseFloat(getPropertyValue(style, \"padding-bottom\"));\n var pl = parseFloat(getPropertyValue(style, \"padding-left\"));\n rTL.x -= pl; rTL.y -= pt;\n rTR.x -= pr; rTR.y -= pt;\n rBR.x -= pr; rBR.y -= pb;\n rBL.x -= pl; rBL.y -= pb;\n }\n }\n\n if (typeof type == \"number\") {\n rTL.x -= type; rTL.y -= type;\n rTR.x -= type; rTR.y -= type;\n rBR.x -= type; rBR.y -= type;\n rBL.x -= type; rBL.y -= type;\n }\n\n return roundBox(box, rTL, rTR, rBR, rBL);\n}\n\n// Create a drawing.Path for a rounded rectangle. Receives the\n// bounding box and the border-radiuses in CSS order (top-left,\n// top-right, bottom-right, bottom-left). The radiuses must be\n// objects containing x (horiz. radius) and y (vertical radius).\nfunction roundBox(box, rTL0, rTR0, rBR0, rBL0) {\n var tmp = adjustBorderRadiusForBox(box, rTL0, rTR0, rBR0, rBL0);\n var rTL = tmp.tl;\n var rTR = tmp.tr;\n var rBR = tmp.br;\n var rBL = tmp.bl;\n var path = new Path({ fill: null, stroke: null });\n path.moveTo(box.left, box.top + rTL.y);\n if (rTL.x) {\n addArcToPath(path, box.left + rTL.x, box.top + rTL.y, {\n startAngle: -180,\n endAngle: -90,\n radiusX: rTL.x,\n radiusY: rTL.y\n });\n }\n path.lineTo(box.right - rTR.x, box.top);\n if (rTR.x) {\n addArcToPath(path, box.right - rTR.x, box.top + rTR.y, {\n startAngle: -90,\n endAngle: 0,\n radiusX: rTR.x,\n radiusY: rTR.y\n });\n }\n path.lineTo(box.right, box.bottom - rBR.y);\n if (rBR.x) {\n addArcToPath(path, box.right - rBR.x, box.bottom - rBR.y, {\n startAngle: 0,\n endAngle: 90,\n radiusX: rBR.x,\n radiusY: rBR.y\n });\n }\n path.lineTo(box.left + rBL.x, box.bottom);\n if (rBL.x) {\n addArcToPath(path, box.left + rBL.x, box.bottom - rBL.y, {\n startAngle: 90,\n endAngle: 180,\n radiusX: rBL.x,\n radiusY: rBL.y\n });\n }\n return path.close();\n}\n\nfunction formatCounter(val, style) {\n var str = String(parseFloat(val));\n switch (style) {\n case \"decimal-leading-zero\":\n if (str.length < 2) {\n str = \"0\" + str;\n }\n return str;\n case \"lower-roman\":\n return arabicToRoman(val).toLowerCase();\n case \"upper-roman\":\n return arabicToRoman(val).toUpperCase();\n case \"lower-latin\":\n case \"lower-alpha\":\n return alphaNumeral(val - 1);\n case \"upper-latin\":\n case \"upper-alpha\":\n return alphaNumeral(val - 1).toUpperCase();\n default:\n return str;\n }\n}\n\nfunction evalPseudoElementContent(element, content) {\n function displayCounter(name, style, separator) {\n if (!separator) {\n return formatCounter(getCounter(name) || 0, style);\n }\n separator = separator.replace(/^\\s*([\"'])(.*)\\1\\s*$/, \"$2\");\n return getAllCounters(name).map(function(val){\n return formatCounter(val, style);\n }).join(separator);\n }\n var a = splitProperty(content, /^\\s+/);\n var result = [], m;\n a.forEach(function(el){\n var tmp;\n if ((m = /^\\s*([\"'])(.*)\\1\\s*$/.exec(el))) {\n result.push(m[2].replace(/\\\\([0-9a-f]{4})/gi, function(s, p){\n return String.fromCharCode(parseInt(p, 16));\n }));\n }\n else if ((m = /^\\s*counter\\((.*?)\\)\\s*$/.exec(el))) {\n tmp = splitProperty(m[1]);\n result.push(displayCounter(tmp[0], tmp[1]));\n }\n else if ((m = /^\\s*counters\\((.*?)\\)\\s*$/.exec(el))) {\n tmp = splitProperty(m[1]);\n result.push(displayCounter(tmp[0], tmp[2], tmp[1]));\n }\n else if ((m = /^\\s*attr\\((.*?)\\)\\s*$/.exec(el))) {\n result.push(element.getAttribute(m[1]) || \"\");\n }\n else {\n result.push(el);\n }\n });\n return result.join(\"\");\n}\n\nfunction getCssText(style) {\n if (style.cssText) {\n return style.cssText;\n }\n // Status: NEW. Report year: 2002. Current year: 2014.\n // Nice played, Mozillians.\n // https://bugzilla.mozilla.org/show_bug.cgi?id=137687\n var result = [];\n for (var i = 0; i < style.length; ++i) {\n result.push(style[i] + \": \" + getPropertyValue(style, style[i]));\n }\n return result.join(\";\\n\");\n}\n\nfunction _renderWithPseudoElements(element, group) {\n if (element.tagName == KENDO_PSEUDO_ELEMENT) {\n _renderElement(element, group);\n return;\n }\n var fake = [];\n function pseudo(kind, place) {\n var style = getComputedStyle$1(element, kind), content = style.content;\n updateCounters(style);\n if (content && content != \"normal\" && content != \"none\" && style.width != \"0px\") {\n var psel = element.ownerDocument.createElement(KENDO_PSEUDO_ELEMENT);\n psel.style.cssText = getCssText(style);\n psel.textContent = evalPseudoElementContent(element, content);\n element.insertBefore(psel, place);\n fake.push(psel);\n }\n }\n pseudo(\":before\", element.firstChild);\n pseudo(\":after\", null);\n if (fake.length > 0) {\n var saveClass = element.className;\n element.className += \" kendo-pdf-hide-pseudo-elements\";\n _renderElement(element, group);\n element.className = saveClass;\n fake.forEach(function(el){ element.removeChild(el); });\n } else {\n _renderElement(element, group);\n }\n}\n\nfunction _renderElement(element, group) {\n var style = getComputedStyle$1(element);\n\n var top = getBorder(style, \"top\");\n var right = getBorder(style, \"right\");\n var bottom = getBorder(style, \"bottom\");\n var left = getBorder(style, \"left\");\n\n var rTL0 = getBorderRadius(style, \"top-left\");\n var rTR0 = getBorderRadius(style, \"top-right\");\n var rBL0 = getBorderRadius(style, \"bottom-left\");\n var rBR0 = getBorderRadius(style, \"bottom-right\");\n\n var dir = getPropertyValue(style, \"direction\");\n\n var backgroundColor = getPropertyValue(style, \"background-color\");\n backgroundColor = parseColor$1(backgroundColor);\n\n var backgroundImage = parseBackgroundImage( getPropertyValue(style, \"background-image\") );\n var backgroundRepeat = splitProperty( getPropertyValue(style, \"background-repeat\") );\n var backgroundPosition = splitProperty( getPropertyValue(style, \"background-position\") );\n var backgroundOrigin = splitProperty( getPropertyValue(style, \"background-origin\") );\n var backgroundSize = splitProperty( getPropertyValue(style, \"background-size\") );\n\n // IE shrinks the text with text-overflow: ellipsis,\n // apparently because the returned bounding box for the range\n // is limited to the visible area minus space for the dots,\n // instead of being the full width of the text.\n //\n // https://github.com/telerik/kendo/issues/5232\n // https://github.com/telerik/kendo-ui-core/issues/1868\n //\n // We have to test it here rather than in renderText because\n // text-overflow: ellipsis could be set on a parent element (not\n // necessarily the one containing the text); in this case,\n // getComputedStyle(elementWithTheText) will return \"clip\", not\n // \"ellipsis\" (which is probably a bug, but oh well...)\n var textOverflow, saveTextOverflow;\n if (microsoft) {\n textOverflow = style.textOverflow; // computed style\n if (textOverflow == \"ellipsis\") {\n saveTextOverflow = element.style.textOverflow; // own style.\n element.style.textOverflow = \"clip\";\n }\n }\n\n if (browser.msie && browser.version < 10) {\n // IE9 hacks. getPropertyValue won't return the correct\n // value. Sucks that we have to do it here, I'd prefer to\n // move it in getPropertyValue, but we don't have the\n // element.\n backgroundPosition = splitProperty(element.currentStyle.backgroundPosition);\n }\n\n var innerbox = innerBox(element.getBoundingClientRect(), \"border-*-width\", element);\n\n // CSS \"clip\" property - if present, replace the group with a\n // new one which is clipped. This must happen before drawing\n // the borders and background.\n (function(){\n var clip = getPropertyValue(style, \"clip\");\n var m = /^\\s*rect\\((.*)\\)\\s*$/.exec(clip);\n if (m) {\n var a = m[1].split(/[ ,]+/g);\n var top = a[0] == \"auto\" ? innerbox.top : parseFloat(a[0]) + innerbox.top;\n var right = a[1] == \"auto\" ? innerbox.right : parseFloat(a[1]) + innerbox.left;\n var bottom = a[2] == \"auto\" ? innerbox.bottom : parseFloat(a[2]) + innerbox.top;\n var left = a[3] == \"auto\" ? innerbox.left : parseFloat(a[3]) + innerbox.left;\n var tmp = new Group();\n var clipPath = new Path()\n .moveTo(left, top)\n .lineTo(right, top)\n .lineTo(right, bottom)\n .lineTo(left, bottom)\n .close();\n setClipping(tmp, clipPath);\n group.append(tmp);\n group = tmp;\n updateClipbox(clipPath);\n }\n })();\n\n var boxes, i, cells;\n var display = getPropertyValue(style, \"display\");\n\n if (display == \"table-row\") {\n // because of rowspan/colspan, we shouldn't draw background of table row elements on the\n // box given by its getBoundingClientRect, because if we do we risk overwritting a\n // previously rendered cell. https://github.com/telerik/kendo/issues/4881\n boxes = [];\n for (i = 0, cells = element.children; i < cells.length; ++i) {\n boxes.push(cells[i].getBoundingClientRect());\n }\n } else {\n boxes = element.getClientRects();\n if (boxes.length == 1) {\n // Workaround the missing borders in Chrome! getClientRects() boxes contains values\n // rounded to integer. getBoundingClientRect() appears to work fine. We still need\n // getClientRects() to support cases where there are more boxes (continued inline\n // elements that might have border/background).\n boxes = [ element.getBoundingClientRect() ];\n }\n }\n\n // This function workarounds another Chrome bug, where boxes returned for a table with\n // border-collapse: collapse will overlap the table border. Our rendering is not perfect in\n // such case anyway, but with this is better than without it.\n boxes = adjustBoxes(boxes);\n\n for (i = 0; i < boxes.length; ++i) {\n drawOneBox(boxes[i], i === 0, i == boxes.length - 1);\n }\n\n // Render links as separate groups. We can't use boxes returned by element's getClientRects\n // because if display type is \"inline\" (default for ), boxes will not include the height of\n // images inside. https://github.com/telerik/kendo-ui-core/issues/3359\n if (element.tagName == \"A\" && element.href && !/^#?$/.test(element.getAttribute(\"href\"))) {\n if (!nodeInfo._avoidLinks || !matches(element, nodeInfo._avoidLinks)) {\n var r = document.createRange();\n r.selectNodeContents(element);\n slice$1$1(r.getClientRects()).forEach(function(box){\n var g = new Group();\n g._pdfLink = {\n url : element.href,\n top : box.top,\n right : box.right,\n bottom : box.bottom,\n left : box.left\n };\n group.append(g);\n });\n }\n }\n\n if (boxes.length > 0 && display == \"list-item\" && !element.getAttribute(\"kendo-no-bullet\")) {\n drawBullet(boxes[0]);\n }\n\n // overflow: hidden/auto - if present, replace the group with\n // a new one clipped by the inner box.\n (function(){\n function clipit() {\n var clipPath = elementRoundBox(element, innerbox, \"padding\");\n var tmp = new Group();\n setClipping(tmp, clipPath);\n group.append(tmp);\n group = tmp;\n updateClipbox(clipPath);\n }\n if (isFormField(element)) {\n clipit();\n } else if (/^(hidden|auto|scroll)/.test(getPropertyValue(style, \"overflow\"))) {\n clipit();\n } else if (/^(hidden|auto|scroll)/.test(getPropertyValue(style, \"overflow-x\"))) {\n clipit();\n } else if (/^(hidden|auto|scroll)/.test(getPropertyValue(style, \"overflow-y\"))) {\n clipit();\n }\n })();\n\n if (!maybeRenderWidget(element, group)) {\n renderContents(element, group);\n }\n\n if (microsoft && textOverflow == \"ellipsis\") {\n element.style.textOverflow = saveTextOverflow;\n }\n\n return group; // only utility functions after this line.\n\n function adjustBoxes(boxes) {\n if (/^td$/i.test(element.tagName)) {\n var table = nodeInfo.table;\n if (table && getPropertyValue(table.style, \"border-collapse\") == \"collapse\") {\n var tableBorderLeft = getBorder(table.style, \"left\").width;\n var tableBorderTop = getBorder(table.style, \"top\").width;\n // check if we need to adjust\n if (tableBorderLeft === 0 && tableBorderTop === 0) {\n return boxes; // nope\n }\n var tableBox = table.element.getBoundingClientRect();\n var firstCell = table.element.rows[0].cells[0];\n var firstCellBox = firstCell.getBoundingClientRect();\n if (firstCellBox.top == tableBox.top || firstCellBox.left == tableBox.left) {\n return slice$1$1(boxes).map(function(box){\n return {\n left : box.left + tableBorderLeft,\n top : box.top + tableBorderTop,\n right : box.right + tableBorderLeft,\n bottom : box.bottom + tableBorderTop,\n height : box.height,\n width : box.width\n };\n });\n }\n }\n }\n return boxes;\n }\n\n // this function will be called to draw each border. it\n // draws starting at origin and the resulted path must be\n // translated/rotated to be placed in the proper position.\n //\n // arguments are named as if it draws the top border:\n //\n // - `len` the length of the edge\n // - `Wtop` the width of the edge (i.e. border-top-width)\n // - `Wleft` the width of the left edge (border-left-width)\n // - `Wright` the width of the right edge\n // - `rl` and `rl` -- the border radius on the left and right\n // (objects containing x and y, for horiz/vertical radius)\n // - `transform` -- transformation to apply\n //\n function drawEdge(color, len, Wtop, Wleft, Wright, rl, rr, transform$$1) {\n if (Wtop <= 0) {\n return;\n }\n\n var path, edge = new Group();\n setTransform$1(edge, transform$$1);\n group.append(edge);\n\n sanitizeRadius(rl);\n sanitizeRadius(rr);\n\n // draw main border. this is the area without the rounded corners\n path = new Path({\n fill: { color: color },\n stroke: null\n });\n edge.append(path);\n path.moveTo(rl.x ? Math.max(rl.x, Wleft) : 0, 0)\n .lineTo(len - (rr.x ? Math.max(rr.x, Wright) : 0), 0)\n .lineTo(len - Math.max(rr.x, Wright), Wtop)\n .lineTo(Math.max(rl.x, Wleft), Wtop)\n .close();\n\n if (rl.x) {\n drawRoundCorner(Wleft, rl, [ -1, 0, 0, 1, rl.x, 0 ]);\n }\n\n if (rr.x) {\n drawRoundCorner(Wright, rr, [ 1, 0, 0, 1, len - rr.x, 0 ]);\n }\n\n // draws one round corner, starting at origin (needs to be\n // translated/rotated to be placed properly).\n function drawRoundCorner(Wright, r, transform$$1) {\n var angle = Math.PI/2 * Wright / (Wright + Wtop);\n\n // not sanitizing this one, because negative values\n // are useful to fill the box correctly.\n var ri = {\n x: r.x - Wright,\n y: r.y - Wtop\n };\n\n var path = new Path({\n fill: { color: color },\n stroke: null\n }).moveTo(0, 0);\n\n setTransform$1(path, transform$$1);\n\n addArcToPath(path, 0, r.y, {\n startAngle: -90,\n endAngle: -radiansToDegrees(angle),\n radiusX: r.x,\n radiusY: r.y\n });\n\n if (ri.x > 0 && ri.y > 0) {\n path.lineTo(ri.x * Math.cos(angle), r.y - ri.y * Math.sin(angle));\n addArcToPath(path, 0, r.y, {\n startAngle: -radiansToDegrees(angle),\n endAngle: -90,\n radiusX: ri.x,\n radiusY: ri.y,\n anticlockwise: true\n });\n }\n else if (ri.x > 0) {\n path.lineTo(ri.x, Wtop)\n .lineTo(0, Wtop);\n }\n else {\n path.lineTo(ri.x, Wtop)\n .lineTo(ri.x, 0);\n }\n\n edge.append(path.close());\n }\n }\n\n function drawBackground(box) {\n var background = new Group();\n setClipping(background, roundBox(box, rTL0, rTR0, rBR0, rBL0));\n group.append(background);\n\n if (backgroundColor) {\n var path = new Path({\n fill: { color: backgroundColor.toCssRgba() },\n stroke: null\n });\n path.moveTo(box.left, box.top)\n .lineTo(box.right, box.top)\n .lineTo(box.right, box.bottom)\n .lineTo(box.left, box.bottom)\n .close();\n background.append(path);\n }\n\n for (var i = backgroundImage.length; --i >= 0;) {\n drawOneBackground(\n background, box,\n backgroundImage[i],\n backgroundRepeat[i % backgroundRepeat.length],\n backgroundPosition[i % backgroundPosition.length],\n backgroundOrigin[i % backgroundOrigin.length],\n backgroundSize[i % backgroundSize.length]\n );\n }\n }\n\n function drawOneBackground(group, box, background, backgroundRepeat, backgroundPosition, backgroundOrigin, backgroundSize) {\n if (!background || (background == \"none\")) {\n return;\n }\n\n if (background.type == \"url\") {\n var img = IMAGE_CACHE[background.url];\n if (img && img.width > 0 && img.height > 0) {\n drawBackgroundImage(group, box, img.width, img.height, function(group, rect){\n group.append(new Image$1(background.url, rect));\n });\n }\n } else if (background.type == \"linear\") {\n drawBackgroundImage(group, box, box.width, box.height, gradientRenderer(background));\n } else {\n return;\n }\n\n function drawBackgroundImage(group, box, img_width, img_height, renderBG) {\n var aspect_ratio = img_width / img_height, f;\n\n // for background-origin: border-box the box is already appropriate\n var orgBox = box;\n if (backgroundOrigin == \"content-box\") {\n orgBox = innerBox(orgBox, \"border-*-width\", element);\n orgBox = innerBox(orgBox, \"padding-*\", element);\n } else if (backgroundOrigin == \"padding-box\") {\n orgBox = innerBox(orgBox, \"border-*-width\", element);\n }\n\n if (!/^\\s*auto(\\s+auto)?\\s*$/.test(backgroundSize)) {\n if (backgroundSize == \"contain\") {\n f = Math.min(orgBox.width / img_width,\n orgBox.height / img_height);\n img_width *= f;\n img_height *= f;\n }\n else if (backgroundSize == \"cover\") {\n f = Math.max(orgBox.width / img_width,\n orgBox.height / img_height);\n img_width *= f;\n img_height *= f;\n }\n else {\n var size = backgroundSize.split(/\\s+/g);\n // compute width\n if (/%$/.test(size[0])) {\n img_width = orgBox.width * parseFloat(size[0]) / 100;\n } else {\n img_width = parseFloat(size[0]);\n }\n // compute height\n if (size.length == 1 || size[1] == \"auto\") {\n img_height = img_width / aspect_ratio;\n } else if (/%$/.test(size[1])) {\n img_height = orgBox.height * parseFloat(size[1]) / 100;\n } else {\n img_height = parseFloat(size[1]);\n }\n }\n }\n\n var pos = String(backgroundPosition);\n\n // IE sometimes reports single-word positions\n // https://github.com/telerik/kendo-ui-core/issues/2786\n //\n // it seems to switch to percentages when the horizontal\n // position is not \"center\", therefore we don't handle\n // multi-word cases here. All other browsers return\n // percentages or pixels instead of keywords. At least\n // for now...\n switch (pos) {\n case \"bottom\" : pos = \"50% 100%\"; break;\n case \"top\" : pos = \"50% 0\"; break;\n case \"left\" : pos = \"0 50%\"; break;\n case \"right\" : pos = \"100% 50%\"; break;\n case \"center\" : pos = \"50% 50%\"; break;\n }\n\n pos = pos.split(/\\s+/);\n if (pos.length == 1) {\n pos[1] = \"50%\";\n }\n\n if (/%$/.test(pos[0])) {\n pos[0] = parseFloat(pos[0]) / 100 * (orgBox.width - img_width);\n } else {\n pos[0] = parseFloat(pos[0]);\n }\n if (/%$/.test(pos[1])) {\n pos[1] = parseFloat(pos[1]) / 100 * (orgBox.height - img_height);\n } else {\n pos[1] = parseFloat(pos[1]);\n }\n\n var rect = new Rect([ orgBox.left + pos[0], orgBox.top + pos[1] ], [ img_width, img_height ]);\n\n // XXX: background-repeat could be implemented more\n // efficiently as a fill pattern (at least for PDF\n // output, probably SVG too).\n\n function rewX() {\n while (rect.origin.x > box.left) {\n rect.origin.x -= img_width;\n }\n }\n\n function rewY() {\n while (rect.origin.y > box.top) {\n rect.origin.y -= img_height;\n }\n }\n\n function repeatX() {\n while (rect.origin.x < box.right) {\n renderBG(group, rect.clone());\n rect.origin.x += img_width;\n }\n }\n\n if (backgroundRepeat == \"no-repeat\") {\n renderBG(group, rect);\n }\n else if (backgroundRepeat == \"repeat-x\") {\n rewX();\n repeatX();\n }\n else if (backgroundRepeat == \"repeat-y\") {\n rewY();\n while (rect.origin.y < box.bottom) {\n renderBG(group, rect.clone());\n rect.origin.y += img_height;\n }\n }\n else if (backgroundRepeat == \"repeat\") {\n rewX();\n rewY();\n var origin = rect.origin.clone();\n while (rect.origin.y < box.bottom) {\n rect.origin.x = origin.x;\n repeatX();\n rect.origin.y += img_height;\n }\n }\n }\n }\n\n function drawBullet() {\n var listStyleType = getPropertyValue(style, \"list-style-type\");\n if (listStyleType == \"none\") {\n return;\n }\n var listStylePosition = getPropertyValue(style, \"list-style-position\");\n\n function _drawBullet(f) {\n saveStyle(element, function(){\n element.style.position = \"relative\";\n var bullet = element.ownerDocument.createElement(KENDO_PSEUDO_ELEMENT);\n bullet.style.position = \"absolute\";\n bullet.style.boxSizing = \"border-box\";\n if (listStylePosition == \"outside\") {\n bullet.style.width = \"6em\";\n bullet.style.left = \"-6.8em\";\n bullet.style.textAlign = \"right\";\n } else {\n bullet.style.left = \"0px\";\n }\n f(bullet);\n element.insertBefore(bullet, element.firstChild);\n renderElement(bullet, group);\n element.removeChild(bullet);\n });\n }\n\n function elementIndex(f) {\n var a = element.parentNode.children;\n var k = element.getAttribute(\"kendo-split-index\");\n if (k != null) {\n return f(k|0, a.length);\n }\n for (var i = 0; i < a.length; ++i) {\n if (a[i] === element) {\n return f(i, a.length);\n }\n }\n }\n\n switch (listStyleType) {\n case \"circle\":\n case \"disc\":\n case \"square\":\n _drawBullet(function(bullet){\n // XXX: the science behind these values is called \"trial and error\".\n bullet.style.fontSize = \"60%\";\n bullet.style.lineHeight = \"200%\";\n bullet.style.paddingRight = \"0.5em\";\n bullet.style.fontFamily = \"DejaVu Serif\";\n bullet.innerHTML = {\n \"disc\" : \"\\u25cf\",\n \"circle\" : \"\\u25ef\",\n \"square\" : \"\\u25a0\"\n }[listStyleType];\n });\n break;\n\n case \"decimal\":\n case \"decimal-leading-zero\":\n _drawBullet(function(bullet){\n elementIndex(function(idx){\n ++idx;\n if (listStyleType == \"decimal-leading-zero\" && idx < 10) {\n idx = \"0\" + idx;\n }\n bullet.innerHTML = idx + \".\";\n });\n });\n break;\n\n case \"lower-roman\":\n case \"upper-roman\":\n _drawBullet(function(bullet){\n elementIndex(function(idx){\n idx = arabicToRoman(idx + 1);\n if (listStyleType == \"upper-roman\") {\n idx = idx.toUpperCase();\n }\n bullet.innerHTML = idx + \".\";\n });\n });\n break;\n\n case \"lower-latin\":\n case \"lower-alpha\":\n case \"upper-latin\":\n case \"upper-alpha\":\n _drawBullet(function(bullet){\n elementIndex(function(idx){\n idx = alphaNumeral(idx);\n if (/^upper/i.test(listStyleType)) {\n idx = idx.toUpperCase();\n }\n bullet.innerHTML = idx + \".\";\n });\n });\n break;\n }\n }\n\n // draws a single border box\n function drawOneBox(box, isFirst, isLast) {\n if (box.width === 0 || box.height === 0) {\n return;\n }\n\n drawBackground(box);\n\n var shouldDrawLeft = (left.width > 0 && ((isFirst && dir == \"ltr\") || (isLast && dir == \"rtl\")));\n var shouldDrawRight = (right.width > 0 && ((isLast && dir == \"ltr\") || (isFirst && dir == \"rtl\")));\n\n // The most general case is that the 4 borders have different widths and border\n // radiuses. The way that is handled is by drawing 3 Paths for each border: the\n // straight line, and two round corners which represent half of the entire rounded\n // corner. To simplify code those shapes are drawed at origin (by the drawEdge\n // function), then translated/rotated into the right position.\n //\n // However, this leads to poor results due to rounding in the simpler cases where\n // borders are straight lines. Therefore we handle a few such cases separately with\n // straight lines. C^wC^wC^w -- nope, scratch that. poor rendering was because of a bug\n // in Chrome (getClientRects() returns rounded integer values rather than exact floats.\n // web dev is still a ghetto.)\n\n // first, just in case there is no border...\n if (top.width === 0 && left.width === 0 && right.width === 0 && bottom.width === 0) {\n return;\n }\n\n // START paint borders\n // if all borders have equal colors...\n if (top.color == right.color && top.color == bottom.color && top.color == left.color) {\n\n // if same widths too, we can draw the whole border by stroking a single path.\n if (top.width == right.width && top.width == bottom.width && top.width == left.width)\n {\n if (shouldDrawLeft && shouldDrawRight) {\n // reduce box by half the border width, so we can draw it by stroking.\n box = innerBox(box, top.width/2);\n\n // adjust the border radiuses, again by top.width/2, and make the path element.\n var path = elementRoundBox(element, box, top.width/2);\n path.options.stroke = {\n color: top.color,\n width: top.width\n };\n group.append(path);\n return;\n }\n }\n }\n\n // if border radiuses are zero and widths are at most one pixel, we can again use simple\n // paths.\n if (rTL0.x === 0 && rTR0.x === 0 && rBR0.x === 0 && rBL0.x === 0) {\n // alright, 1.9px will do as well. the difference in color blending should not be\n // noticeable.\n if (top.width < 2 && left.width < 2 && right.width < 2 && bottom.width < 2) {\n // top border\n if (top.width > 0) {\n group.append(\n new Path({\n stroke: { width: top.width, color: top.color }\n })\n .moveTo(box.left, box.top + top.width/2)\n .lineTo(box.right, box.top + top.width/2)\n );\n }\n\n // bottom border\n if (bottom.width > 0) {\n group.append(\n new Path({\n stroke: { width: bottom.width, color: bottom.color }\n })\n .moveTo(box.left, box.bottom - bottom.width/2)\n .lineTo(box.right, box.bottom - bottom.width/2)\n );\n }\n\n // left border\n if (shouldDrawLeft) {\n group.append(\n new Path({\n stroke: { width: left.width, color: left.color }\n })\n .moveTo(box.left + left.width/2, box.top)\n .lineTo(box.left + left.width/2, box.bottom)\n );\n }\n\n // right border\n if (shouldDrawRight) {\n group.append(\n new Path({\n stroke: { width: right.width, color: right.color }\n })\n .moveTo(box.right - right.width/2, box.top)\n .lineTo(box.right - right.width/2, box.bottom)\n );\n }\n\n return;\n }\n }\n // END paint borders\n\n var tmp = adjustBorderRadiusForBox(box, rTL0, rTR0, rBR0, rBL0);\n var rTL = tmp.tl;\n var rTR = tmp.tr;\n var rBR = tmp.br;\n var rBL = tmp.bl;\n\n // top border\n drawEdge(top.color,\n box.width, top.width, left.width, right.width,\n rTL, rTR,\n [ 1, 0, 0, 1, box.left, box.top ]);\n\n // bottom border\n drawEdge(bottom.color,\n box.width, bottom.width, right.width, left.width,\n rBR, rBL,\n [ -1, 0, 0, -1, box.right, box.bottom ]);\n\n // for left/right borders we need to invert the border-radiuses\n function inv(p) {\n return { x: p.y, y: p.x };\n }\n\n // left border\n drawEdge(left.color,\n box.height, left.width, bottom.width, top.width,\n inv(rBL), inv(rTL),\n [ 0, -1, 1, 0, box.left, box.bottom ]);\n\n // right border\n drawEdge(right.color,\n box.height, right.width, top.width, bottom.width,\n inv(rTR), inv(rBR),\n [ 0, 1, -1, 0, box.right, box.top ]);\n }\n}\n\nfunction gradientRenderer(gradient) {\n return function(group, rect) {\n var width = rect.width(), height = rect.height();\n\n switch (gradient.type) {\n case \"linear\":\n\n // figure out the angle.\n var angle = gradient.angle != null ? gradient.angle : Math.PI;\n switch (gradient.to) {\n case \"top\":\n angle = 0;\n break;\n case \"left\":\n angle = -Math.PI / 2;\n break;\n case \"bottom\":\n angle = Math.PI;\n break;\n case \"right\":\n angle = Math.PI / 2;\n break;\n case \"top left\": case \"left top\":\n angle = -Math.atan2(height, width);\n break;\n case \"top right\": case \"right top\":\n angle = Math.atan2(height, width);\n break;\n case \"bottom left\": case \"left bottom\":\n angle = Math.PI + Math.atan2(height, width);\n break;\n case \"bottom right\": case \"right bottom\":\n angle = Math.PI - Math.atan2(height, width);\n break;\n }\n\n if (gradient.reverse) {\n angle -= Math.PI;\n }\n\n // limit the angle between 0..2PI\n angle %= 2 * Math.PI;\n if (angle < 0) {\n angle += 2 * Math.PI;\n }\n\n // compute gradient's start/end points. here len is the length of the gradient line\n // and x,y is the end point relative to the center of the rectangle in conventional\n // (math) axis direction.\n\n // this is the original (unscaled) length of the gradient line. needed to deal with\n // absolutely positioned color stops. formula from the CSS spec:\n // http://dev.w3.org/csswg/css-images-3/#linear-gradient-syntax\n var pxlen = Math.abs(width * Math.sin(angle)) + Math.abs(height * Math.cos(angle));\n\n // The math below is pretty simple, but it took a while to figure out. We compute x\n // and y, the *end* of the gradient line. However, we want to transform them into\n // element-based coordinates (SVG's gradientUnits=\"objectBoundingBox\"). That means,\n // x=0 is the left edge, x=1 is the right edge, y=0 is the top edge and y=1 is the\n // bottom edge.\n //\n // A naive approach would use the original angle for these calculations. Say we'd\n // like to draw a gradient angled at 45deg in a 100x400 box. When we use\n // objectBoundingBox, the renderer will draw it in a 1x1 *square* box, and then\n // scale that to the desired dimensions. The 45deg angle will look more like 70deg\n // after scaling. SVG (http://www.w3.org/TR/SVG/pservers.html#LinearGradients) says\n // the following:\n //\n // When gradientUnits=\"objectBoundingBox\" and 'gradientTransform' is the\n // identity matrix, the normal of the linear gradient is perpendicular to the\n // gradient vector in object bounding box space (i.e., the abstract coordinate\n // system where (0,0) is at the top/left of the object bounding box and (1,1) is\n // at the bottom/right of the object bounding box). When the object's bounding\n // box is not square, the gradient normal which is initially perpendicular to\n // the gradient vector within object bounding box space may render\n // non-perpendicular relative to the gradient vector in user space. If the\n // gradient vector is parallel to one of the axes of the bounding box, the\n // gradient normal will remain perpendicular. This transformation is due to\n // application of the non-uniform scaling transformation from bounding box space\n // to user space.\n //\n // which is an extremely long and confusing way to tell what I just said above.\n //\n // For this reason we need to apply the reverse scaling to the original angle, so\n // that when it'll finally be rendered it'll actually be at the desired slope. Now\n // I'll let you figure out the math yourself.\n\n var scaledAngle = Math.atan(width * Math.tan(angle) / height);\n var sin = Math.sin(scaledAngle), cos = Math.cos(scaledAngle);\n var len = Math.abs(sin) + Math.abs(cos);\n var x = len/2 * sin;\n var y = len/2 * cos;\n\n // Because of the arctangent, our scaledAngle ends up between -PI/2..PI/2, possibly\n // losing the intended direction of the gradient. The following fixes it.\n if (angle > Math.PI/2 && angle <= 3*Math.PI/2) {\n x = -x;\n y = -y;\n }\n\n // compute the color stops.\n var implicit = [], right = 0;\n var stops = gradient.stops.map(function(s, i){\n var offset = s.percent;\n if (offset) {\n offset = parseFloat(offset) / 100;\n } else if (s.length) {\n offset = parseFloat(s.length) / pxlen;\n } else if (i === 0) {\n offset = 0;\n } else if (i == gradient.stops.length - 1) {\n offset = 1;\n }\n var stop = {\n color: s.color.toCssRgba(),\n offset: offset\n };\n if (offset != null) {\n right = offset;\n // fix implicit offsets\n implicit.forEach(function(s, i){\n var stop = s.stop;\n stop.offset = s.left + (right - s.left) * (i + 1) / (implicit.length + 1);\n });\n implicit = [];\n } else {\n implicit.push({ left: right, stop: stop });\n }\n return stop;\n });\n\n var start = [ 0.5 - x, 0.5 + y ];\n var end = [ 0.5 + x, 0.5 - y ];\n\n // finally, draw it.\n group.append(\n Path.fromRect(rect)\n .stroke(null)\n .fill(new LinearGradient({\n start : start,\n end : end,\n stops : stops,\n userSpace : false\n }))\n );\n break;\n case \"radial\":\n // XXX:\n if (window.console && window.console.log) {\n window.console.log(\"Radial gradients are not yet supported in HTML renderer\");\n }\n break;\n }\n };\n}\n\nfunction maybeRenderWidget(element, group) {\n var visual;\n\n if (element._kendoExportVisual) {\n visual = element._kendoExportVisual();\n } else if (window.kendo && window.kendo.jQuery && element.getAttribute(window.kendo.attr(\"role\"))) {\n var widget = window.kendo.widgetInstance(window.kendo.jQuery(element));\n if (widget && (widget.exportDOMVisual || widget.exportVisual)) {\n if (widget.exportDOMVisual) {\n visual = widget.exportDOMVisual();\n } else {\n visual = widget.exportVisual();\n }\n }\n }\n\n if (!visual) {\n return false;\n }\n\n var wrap$$1 = new Group();\n wrap$$1.children.push(visual);\n\n var bbox = element.getBoundingClientRect();\n wrap$$1.transform(transform$1().translate(bbox.left, bbox.top));\n\n group.append(wrap$$1);\n\n return true;\n}\n\nfunction renderImage(element, url, group) {\n var box = getContentBox(element);\n var rect = new Rect([ box.left, box.top ], [ box.width, box.height ]);\n var image = new Image$1(url, rect);\n setClipping(image, elementRoundBox(element, box, \"content\"));\n group.append(image);\n}\n\nfunction zIndexSort(a, b) {\n var sa = getComputedStyle$1(a);\n var sb = getComputedStyle$1(b);\n var za = parseFloat(getPropertyValue(sa, \"z-index\"));\n var zb = parseFloat(getPropertyValue(sb, \"z-index\"));\n var pa = getPropertyValue(sa, \"position\");\n var pb = getPropertyValue(sb, \"position\");\n if (isNaN(za) && isNaN(zb)) {\n if ((/static|absolute/.test(pa)) && (/static|absolute/.test(pb))) {\n return 0;\n }\n if (pa == \"static\") {\n return -1;\n }\n if (pb == \"static\") {\n return 1;\n }\n return 0;\n }\n if (isNaN(za)) {\n return zb === 0 ? 0 : zb > 0 ? -1 : 1;\n }\n if (isNaN(zb)) {\n return za === 0 ? 0 : za > 0 ? 1 : -1;\n }\n return parseFloat(za) - parseFloat(zb);\n}\n\nfunction isFormField(element) {\n return /^(?:textarea|select|input)$/i.test(element.tagName);\n}\n\nfunction getSelectedOption(element) {\n if (element.selectedOptions && element.selectedOptions.length > 0) {\n return element.selectedOptions[0];\n }\n return element.options[element.selectedIndex];\n}\n\nfunction renderCheckbox(element, group) {\n var style = getComputedStyle$1(element);\n var color = getPropertyValue(style, \"color\");\n var box = element.getBoundingClientRect();\n if (element.type == \"checkbox\") {\n group.append(\n Path.fromRect(\n new Rect([ box.left+1, box.top+1 ],\n [ box.width-2, box.height-2 ])\n ).stroke(color, 1)\n );\n if (element.checked) {\n // fill a rectangle inside? looks kinda ugly.\n // group.append(\n // Path.fromRect(\n // new geo.Rect([ box.left+4, box.top+4 ],\n // [ box.width-8, box.height-8])\n // ).fill(color).stroke(null)\n // );\n\n // let's draw a checkmark instead. artistic, eh?\n group.append(\n new Path()\n .stroke(color, 1.2)\n .moveTo(box.left + 0.22 * box.width,\n box.top + 0.55 * box.height)\n .lineTo(box.left + 0.45 * box.width,\n box.top + 0.75 * box.height)\n .lineTo(box.left + 0.78 * box.width,\n box.top + 0.22 * box.width)\n );\n }\n } else {\n group.append(\n new Circle(\n new Circle$2([\n (box.left + box.right) / 2,\n (box.top + box.bottom) / 2\n ], Math.min(box.width-2, box.height-2) / 2)\n ).stroke(color, 1)\n );\n if (element.checked) {\n group.append(\n new Circle(\n new Circle$2([\n (box.left + box.right) / 2,\n (box.top + box.bottom) / 2\n ], Math.min(box.width-8, box.height-8) / 2)\n ).fill(color).stroke(null)\n );\n }\n }\n}\n\nfunction renderFormField(element, group) {\n var tag = element.tagName.toLowerCase();\n if (tag == \"input\" && (element.type == \"checkbox\" || element.type == \"radio\")) {\n return renderCheckbox(element, group);\n }\n var p = element.parentNode;\n var doc = element.ownerDocument;\n var el = doc.createElement(KENDO_PSEUDO_ELEMENT);\n var option;\n el.style.cssText = getCssText(getComputedStyle$1(element));\n if (tag == \"input\") {\n el.style.whiteSpace = \"pre\";\n }\n if (tag == \"select\" || tag == \"textarea\") {\n el.style.overflow = \"auto\";\n }\n if (tag == \"select\") {\n if (element.multiple) {\n for (var i = 0; i < element.options.length; ++i) {\n option = doc.createElement(KENDO_PSEUDO_ELEMENT);\n option.style.cssText = getCssText(getComputedStyle$1(element.options[i]));\n option.style.display = \"block\"; // IE9 messes up without this\n option.textContent = element.options[i].textContent;\n el.appendChild(option);\n }\n } else {\n option = getSelectedOption(element);\n if (option) {\n el.textContent = option.textContent;\n }\n }\n } else {\n el.textContent = element.value;\n }\n p.insertBefore(el, element);\n el.scrollLeft = element.scrollLeft;\n el.scrollTop = element.scrollTop;\n\n // must temporarily hide the original element, otherwise it\n // may affect layout of the fake element we want to render.\n element.style.display = \"none\";\n\n renderContents(el, group);\n element.style.display = \"\";\n p.removeChild(el);\n}\n\nfunction serializeSVG(element) {\n var serializer = new window.XMLSerializer();\n var xml = serializer.serializeToString(element);\n\n if (browser.mozilla && !(element.getAttribute(\"width\") && element.getAttribute(\"height\"))) {\n var doc = new window.DOMParser().parseFromString(xml, \"image/svg+xml\");\n var svg$$1 = doc.documentElement;\n var box = getContentBox(element);\n svg$$1.setAttribute(\"width\", box.width);\n svg$$1.setAttribute(\"height\", box.height);\n xml = serializer.serializeToString(svg$$1);\n }\n\n return xml;\n}\n\nfunction renderContents(element, group) {\n if (nodeInfo._stackingContext.element === element) {\n // the group that was set in pushNodeInfo might have\n // changed due to clipping/transforms, update it here.\n nodeInfo._stackingContext.group = group;\n }\n switch (element.tagName.toLowerCase()) {\n case \"img\":\n renderImage(element, element.src, group);\n break;\n\n case \"svg\":\n var xml = serializeSVG(element);\n var dataURL = \"data:image/svg+xml;base64,\" + (encodeBase64(xml));\n renderImage(element, dataURL, group);\n break;\n\n case \"canvas\":\n try {\n renderImage(element, element.toDataURL(\"image/png\"), group);\n } catch (ex) {\n // tainted; can't draw it, ignore.\n }\n break;\n\n case \"textarea\":\n case \"input\":\n case \"select\":\n renderFormField(element, group);\n break;\n\n default:\n var children = [], floats = [], positioned = [];\n for (var i = element.firstChild; i; i = i.nextSibling) {\n switch (i.nodeType) {\n case 3: // Text\n if (/\\S/.test(i.data)) {\n renderText(element, i, group);\n }\n break;\n case 1: // Element\n var style = getComputedStyle$1(i);\n var floating = getPropertyValue(style, \"float\");\n var position = getPropertyValue(style, \"position\");\n if (position != \"static\") {\n positioned.push(i);\n }\n else if (floating != \"none\") {\n floats.push(i);\n } else {\n children.push(i);\n }\n break;\n }\n }\n\n mergeSort(children, zIndexSort).forEach(function(el){ renderElement(el, group); });\n mergeSort(floats, zIndexSort).forEach(function(el){ renderElement(el, group); });\n mergeSort(positioned, zIndexSort).forEach(function(el){ renderElement(el, group); });\n }\n}\n\nfunction renderText(element, node, group) {\n if (emptyClipbox()) {\n return;\n }\n var style = getComputedStyle$1(element);\n\n if (parseFloat(getPropertyValue(style, \"text-indent\")) < -500) {\n // assume it should not be displayed. the slider's\n // draggable handle displays a Drag text for some reason,\n // having text-indent: -3333px.\n return;\n }\n\n var text = node.data;\n var start = 0;\n var end = text.search(/\\S\\s*$/) + 1;\n\n if (!end) {\n return; // whitespace-only node\n }\n\n var fontSize = getPropertyValue(style, \"font-size\");\n var lineHeight = getPropertyValue(style, \"line-height\");\n\n // simply getPropertyValue(\"font\") doesn't work in Firefox :-\\\n var font = [\n getPropertyValue(style, \"font-style\"),\n getPropertyValue(style, \"font-variant\"),\n getPropertyValue(style, \"font-weight\"),\n fontSize, // no need for line height here; it breaks layout in FF\n getPropertyValue(style, \"font-family\")\n ].join(\" \");\n\n fontSize = parseFloat(fontSize);\n lineHeight = parseFloat(lineHeight);\n\n if (fontSize === 0) {\n return;\n }\n\n var color = getPropertyValue(style, \"color\");\n var range = element.ownerDocument.createRange();\n var align$$1 = getPropertyValue(style, \"text-align\");\n var isJustified = align$$1 == \"justify\";\n var columnCount = getPropertyValue(style, \"column-count\", 1);\n var whiteSpace = getPropertyValue(style, \"white-space\");\n var textTransform = getPropertyValue(style, \"text-transform\");\n\n // A line of 500px, with a font of 12px, contains an average of 80 characters, but since we\n // err, we'd like to guess a bigger number rather than a smaller one. Multiplying by 5\n // seems to be a good option.\n var estimateLineLength = element.getBoundingClientRect().width / fontSize * 5;\n if (estimateLineLength === 0) {\n estimateLineLength = 500;\n }\n\n // we'll maintain this so we can workaround bugs in Chrome's Range.getClientRects\n // https://github.com/telerik/kendo/issues/5740\n var prevLineBottom = null;\n\n var underline = nodeInfo[\"underline\"];\n var lineThrough = nodeInfo[\"line-through\"];\n var overline = nodeInfo[\"overline\"];\n var hasDecoration = underline || lineThrough || overline;\n\n // doChunk returns true when all text has been rendered\n while (!doChunk()) {}\n\n if (hasDecoration) {\n range.selectNode(node);\n slice$1$1(range.getClientRects()).forEach(decorate);\n }\n\n return; // only function declarations after this line\n\n function actuallyGetRangeBoundingRect(range) {\n // XXX: to be revised when this Chrome bug is fixed:\n // https://bugs.chromium.org/p/chromium/issues/detail?id=612459\n if (microsoft || browser.chrome || browser.safari) {\n // Workaround browser bugs: IE and Chrome would sometimes\n // return 0 or 1-width rectangles before or after the main\n // one. https://github.com/telerik/kendo/issues/4674\n\n // Actually Chrome 50 got worse, since the rectangles can now have the width of a\n // full character, making it hard to tell whether it's a bogus rectangle or valid\n // selection location. The workaround is to ignore rectangles that fall on the\n // previous line. https://github.com/telerik/kendo/issues/5740\n var rectangles = range.getClientRects(), box = {\n top : Infinity,\n right : -Infinity,\n bottom : -Infinity,\n left : Infinity\n }, done = false;\n for (var i = 0; i < rectangles.length; ++i) {\n var b = rectangles[i];\n if (b.width <= 1 || b.bottom === prevLineBottom) {\n continue; // bogus rectangle\n }\n box.left = Math.min(b.left , box.left);\n box.top = Math.min(b.top , box.top);\n box.right = Math.max(b.right , box.right);\n box.bottom = Math.max(b.bottom , box.bottom);\n done = true;\n }\n if (!done) {\n return range.getBoundingClientRect();\n }\n box.width = box.right - box.left;\n box.height = box.bottom - box.top;\n return box;\n }\n return range.getBoundingClientRect();\n }\n\n // Render a chunk of text, typically one line (but for justified text we render each word as\n // a separate Text object, because spacing is variable). Returns true when it finished the\n // current node. After each chunk it updates `start` to just after the last rendered\n // character.\n function doChunk() {\n var origStart = start;\n var box, pos = text.substr(start).search(/\\S/);\n start += pos;\n if (pos < 0 || start >= end) {\n return true;\n }\n\n // Select a single character to determine the height of a line of text. The box.bottom\n // will be essential for us to figure out where the next line begins.\n range.setStart(node, start);\n range.setEnd(node, start + 1);\n box = actuallyGetRangeBoundingRect(range);\n\n // for justified text we must split at each space, because space has variable width.\n var found = false;\n if (isJustified || columnCount > 1) {\n pos = text.substr(start).search(/\\s/);\n if (pos >= 0) {\n // we can only split there if it's on the same line, otherwise we'll fall back\n // to the default mechanism (see findEOL below).\n range.setEnd(node, start + pos);\n var r = actuallyGetRangeBoundingRect(range);\n if (r.bottom == box.bottom) {\n box = r;\n found = true;\n start += pos;\n }\n }\n }\n\n if (!found) {\n // This code does three things: (1) it selects one line of text in `range`, (2) it\n // leaves the bounding rect of that line in `box` and (3) it returns the position\n // just after the EOL. We know where the line starts (`start`) but we don't know\n // where it ends. To figure this out, we select a piece of text and look at the\n // bottom of the bounding box. If it changes, we have more than one line selected\n // and should retry with a smaller selection.\n //\n // To speed things up, we first try to select all text in the node (`start` ->\n // `end`). If there's more than one line there, then select only half of it. And\n // so on. When we find a value for `end` that fits in one line, we try increasing\n // it (also in halves) until we get to the next line. The algorithm stops when the\n // right side of the bounding box does not change.\n //\n // One more thing to note is that everything happens in a single Text DOM node.\n // There's no other tags inside it, therefore the left/top coordinates of the\n // bounding box will not change.\n pos = (function findEOL(min, eol, max){\n range.setEnd(node, eol);\n var r = actuallyGetRangeBoundingRect(range);\n if (r.bottom != box.bottom && min < eol) {\n return findEOL(min, (min + eol) >> 1, eol);\n } else if (r.right != box.right) {\n box = r;\n if (eol < max) {\n return findEOL(eol, (eol + max) >> 1, max);\n } else {\n return eol;\n }\n } else {\n return eol;\n }\n })(start, Math.min(end, start + estimateLineLength), end);\n\n if (pos == start) {\n // if EOL is at the start, then no more text fits on this line. Skip the\n // remainder of this node entirely to avoid a stack overflow.\n return true;\n }\n start = pos;\n\n pos = range.toString().search(/\\s+$/);\n if (pos === 0) {\n return false; // whitespace only; we should not get here.\n }\n if (pos > 0) {\n // eliminate trailing whitespace\n range.setEnd(node, range.startOffset + pos);\n box = actuallyGetRangeBoundingRect(range);\n }\n }\n\n // another workaround for IE: if we rely on getBoundingClientRect() we'll overlap with the bullet for LI\n // elements. Calling getClientRects() and using the *first* rect appears to give us the correct location.\n // Note: not to be used in Chrome as it randomly returns a zero-width rectangle from the previous line.\n if (microsoft) {\n box = range.getClientRects()[0];\n }\n\n var str = range.toString();\n if (!/^(?:pre|pre-wrap)$/i.test(whiteSpace)) {\n // node with non-significant space -- collapse whitespace.\n str = str.replace(/\\s+/g, \" \");\n }\n else if (/\\t/.test(str)) {\n // with significant whitespace we need to do something about literal TAB characters.\n // There's no TAB glyph in a font so they would be rendered in PDF as an empty box,\n // and the whole text will stretch to fill the original width. The core PDF lib\n // does not have sufficient context to deal with it.\n\n // calculate the starting column here, since we initially discarded any whitespace.\n var cc = 0;\n for (pos = origStart; pos < range.startOffset; ++pos) {\n var code = text.charCodeAt(pos);\n if (code == 9) {\n // when we meet a TAB we must round up to the next tab stop.\n // in all browsers TABs seem to be 8 characters.\n cc += 8 - cc % 8;\n } else if (code == 10 || code == 13) {\n // just in case we meet a newline we must restart.\n cc = 0;\n } else {\n // ordinary character --> advance one column\n cc++;\n }\n }\n\n // based on starting column, replace any TAB characters in the string we actually\n // have to display with spaces so that they align to columns multiple of 8.\n while ((pos = str.search(\"\\t\")) >= 0) {\n var indent = \" \".substr(0, 8 - (cc + pos) % 8);\n str = str.substr(0, pos) + indent + str.substr(pos + 1);\n }\n }\n\n if (!found) {\n prevLineBottom = box.bottom;\n }\n drawText(str, box);\n }\n\n function drawText(str, box) {\n // In IE the box height will be approximately lineHeight, while in\n // other browsers it'll (correctly) be the height of the bounding\n // box for the current text/font. Which is to say, IE sucks again.\n // The only good solution I can think of is to measure the text\n // ourselves and center the bounding box.\n if (microsoft && !isNaN(lineHeight)) {\n var height = getFontHeight(font);\n var top = (box.top + box.bottom - height) / 2;\n box = {\n top : top,\n right : box.right,\n bottom : top + height,\n left : box.left,\n height : height,\n width : box.right - box.left\n };\n }\n\n // var path = new Path({ stroke: { color: \"red\" }});\n // path.moveTo(box.left, box.top)\n // .lineTo(box.right, box.top)\n // .lineTo(box.right, box.bottom)\n // .lineTo(box.left, box.bottom)\n // .close();\n // group.append(path);\n\n switch (textTransform) {\n case \"uppercase\":\n str = str.toUpperCase();\n break;\n case \"lowercase\":\n str = str.toLowerCase();\n break;\n case \"capitalize\":\n str = str.replace(/(?:^|\\s)\\S/g, function (l) { return l.toUpperCase(); });\n break;\n }\n\n var text = new TextRect(\n str, new Rect([ box.left, box.top ],\n [ box.width, box.height ]),\n {\n font: font,\n fill: { color: color }\n }\n );\n group.append(text);\n }\n\n function decorate(box) {\n line(underline, box.bottom);\n line(lineThrough, box.bottom - box.height / 2.7);\n line(overline, box.top);\n function line(color, ypos) {\n if (color) {\n var width = fontSize / 12;\n var path = new Path({ stroke: {\n width: width,\n color: color\n }});\n\n ypos -= width;\n path.moveTo(box.left, ypos)\n .lineTo(box.right, ypos);\n group.append(path);\n }\n }\n }\n}\n\nfunction groupInStackingContext(element, group, zIndex) {\n var main;\n if (zIndex != \"auto\") {\n // use the current stacking context\n main = nodeInfo._stackingContext.group;\n zIndex = parseFloat(zIndex);\n } else {\n // normal flow — use given container. we still have to\n // figure out where should we insert this element with the\n // assumption that its z-index is zero, as the group might\n // already contain elements with higher z-index.\n main = group;\n zIndex = 0;\n }\n var a = main.children;\n for (var i = 0; i < a.length; ++i) {\n if (a[i]._dom_zIndex != null && a[i]._dom_zIndex > zIndex) {\n break;\n }\n }\n\n var tmp = new Group();\n main.insert(i, tmp);\n tmp._dom_zIndex = zIndex;\n\n if (main !== group) {\n // console.log(\"Placing\", element, \"in\", nodeInfo._stackingContext.element, \"at position\", i, \" / \", a.length);\n // console.log(a.slice(i+1));\n\n // if (nodeInfo._matrix) {\n // tmp.transform(nodeInfo._matrix);\n // }\n if (nodeInfo._clipbox) {\n var m = nodeInfo._matrix.invert();\n var r = nodeInfo._clipbox.transformCopy(m);\n setClipping(tmp, Path.fromRect(r));\n // console.log(r);\n // tmp.append(Path.fromRect(r));\n // tmp.append(new Text(element.className || element.id, r.topLeft()));\n }\n }\n\n return tmp;\n}\n\nfunction renderElement(element, container) {\n var style = getComputedStyle$1(element);\n\n updateCounters(style);\n\n if (/^(style|script|link|meta|iframe|col|colgroup)$/i.test(element.tagName)) {\n return;\n }\n\n if (nodeInfo._clipbox == null) {\n return;\n }\n\n var opacity = parseFloat(getPropertyValue(style, \"opacity\"));\n var visibility = getPropertyValue(style, \"visibility\");\n var display = getPropertyValue(style, \"display\");\n\n if (opacity === 0 || visibility == \"hidden\" || display == \"none\") {\n return;\n }\n\n var tr = getTransform(style);\n var group;\n\n var zIndex = getPropertyValue(style, \"z-index\");\n if ((tr || opacity < 1) && zIndex == \"auto\") {\n zIndex = 0;\n }\n group = groupInStackingContext(element, container, zIndex);\n\n // XXX: remove at some point\n // group._pdfElement = element;\n // group.options._pdfDebug = \"\";\n // if (element.id) {\n // group.options._pdfDebug = \"#\" + element.id;\n // }\n // if (element.className) {\n // group.options._pdfDebug += \".\" + element.className.split(\" \").join(\".\");\n // }\n\n if (opacity < 1) {\n group.opacity(opacity * group.opacity());\n }\n\n pushNodeInfo(element, style, group);\n\n if (!tr) {\n _renderWithPseudoElements(element, group);\n }\n else {\n saveStyle(element, function(){\n // must clear transform, so getBoundingClientRect returns correct values.\n pleaseSetPropertyValue(element.style, \"transform\", \"none\", \"important\");\n\n // must also clear transitions, so correct values are returned *immediately*\n pleaseSetPropertyValue(element.style, \"transition\", \"none\", \"important\");\n\n // the presence of any transform makes it behave like it had position: relative,\n // because why not.\n // http://meyerweb.com/eric/thoughts/2011/09/12/un-fixing-fixed-elements-with-css-transforms/\n if (getPropertyValue(style, \"position\") == \"static\") {\n // but only if it's not already positioned. :-/\n pleaseSetPropertyValue(element.style, \"position\", \"relative\", \"important\");\n }\n\n // must translate to origin before applying the CSS\n // transformation, then translate back.\n var bbox = element.getBoundingClientRect();\n var x = bbox.left + tr.origin[0];\n var y = bbox.top + tr.origin[1];\n var m = [ 1, 0, 0, 1, -x, -y ];\n m = mmul(m, tr.matrix);\n m = mmul(m, [ 1, 0, 0, 1, x, y ]);\n m = setTransform$1(group, m);\n\n nodeInfo._matrix = nodeInfo._matrix.multiplyCopy(m);\n\n _renderWithPseudoElements(element, group);\n });\n }\n\n popNodeInfo();\n\n //drawDebugBox(element.getBoundingClientRect(), container);\n}\n\n// function drawDebugBox(box, group, color) {\n// var path = Path.fromRect(new geo.Rect([ box.left, box.top ], [ box.width, box.height ]));\n// if (color) {\n// path.stroke(color);\n// }\n// group.append(path);\n// }\n\n// function dumpTextNode(node) {\n// var txt = node.data.replace(/^\\s+/, \"\");\n// if (txt.length < 100) {\n// console.log(node.data.length + \": |\" + txt);\n// } else {\n// console.log(node.data.length + \": |\" + txt.substr(0, 50) + \"|...|\" + txt.substr(-50));\n// }\n// }\n\nfunction mmul(a, b) {\n var a1 = a[0], b1 = a[1], c1 = a[2], d1 = a[3], e1 = a[4], f1 = a[5];\n var a2 = b[0], b2 = b[1], c2 = b[2], d2 = b[3], e2 = b[4], f2 = b[5];\n return [\n a1*a2 + b1*c2, a1*b2 + b1*d2,\n c1*a2 + d1*c2, c1*b2 + d1*d2,\n e1*a2 + f1*c2 + e2, e1*b2 + f1*d2 + f2\n ];\n}\n\nvar drawing = {\n\tsvg: svg$1,\n\tcanvas: canvas,\n\tutil: util,\n\tHasObservers: HasObservers,\n\tPathParser: PathParser,\n\tparsePath: parsePath,\n\tBaseNode: BaseNode,\n\tOptionsStore: OptionsStore,\n\tSurface: Surface,\n\tSurfaceFactory: SurfaceFactory,\n\texportImage: exportImage,\n\texportSVG: exportSVG,\n\tQuadNode: QuadNode,\n\tShapesQuadTree: ShapesQuadTree,\n\tElement: Element$1,\n\tCircle: Circle,\n\tArc: Arc,\n\tPath: Path,\n\tMultiPath: MultiPath,\n\tText: Text,\n\tImage: Image$1,\n\tGroup: Group,\n\tLayout: Layout,\n\tRect: Rect$2,\n\talign: align,\n\tvAlign: vAlign,\n\tstack: stack,\n\tvStack: vStack,\n\twrap: wrap,\n\tvWrap: vWrap,\n\tfit: fit,\n\tLinearGradient: LinearGradient,\n\tRadialGradient: RadialGradient,\n\tGradientStop: GradientStop,\n\tGradient: Gradient,\n\tAnimation: Animation,\n\tAnimationFactory: AnimationFactory,\n\tdrawDOM: drawDOM,\n\tdrawText: drawText,\n\tgetFontFaces: getFontFaces\n};\n\nkendo.deepExtend(kendo, {\n drawing: drawing,\n geometry: geometry\n});\n\nkendo.drawing.Segment = kendo.geometry.Segment;\nkendo.dataviz.drawing = kendo.drawing;\nkendo.dataviz.geometry = kendo.geometry;\nkendo.drawing.util.measureText = kendo.util.measureText;\nkendo.drawing.util.objectKey = kendo.util.objectKey;\nkendo.drawing.Color = kendo.Color;\nkendo.util.encodeBase64 = kendo.drawing.util.encodeBase64;\n\n})(window.kendo.jQuery);\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n(function(f, define){\n define('kendo.popup',[ \"./kendo.core\" ], f);\n})(function(){\n\nvar __meta__ = { // jshint ignore:line\n id: \"popup\",\n name: \"Pop-up\",\n category: \"framework\",\n depends: [ \"core\" ],\n advanced: true\n};\n\n(function($, undefined) {\n var kendo = window.kendo,\n ui = kendo.ui,\n Widget = ui.Widget,\n Class = kendo.Class,\n support = kendo.support,\n getOffset = kendo.getOffset,\n outerWidth = kendo._outerWidth,\n outerHeight = kendo._outerHeight,\n OPEN = \"open\",\n CLOSE = \"close\",\n DEACTIVATE = \"deactivate\",\n ACTIVATE = \"activate\",\n CENTER = \"center\",\n LEFT = \"left\",\n RIGHT = \"right\",\n TOP = \"top\",\n BOTTOM = \"bottom\",\n ABSOLUTE = \"absolute\",\n HIDDEN = \"hidden\",\n BODY = \"body\",\n LOCATION = \"location\",\n POSITION = \"position\",\n VISIBLE = \"visible\",\n EFFECTS = \"effects\",\n ACTIVE = \"k-state-active\",\n ACTIVEBORDER = \"k-state-border\",\n ACTIVEBORDERREGEXP = /k-state-border-(\\w+)/,\n ACTIVECHILDREN = \".k-picker-wrap, .k-dropdown-wrap, .k-link\",\n MOUSEDOWN = \"down\",\n DOCUMENT_ELEMENT = $(document.documentElement),\n proxy = $.proxy,\n WINDOW = $(window),\n SCROLL = \"scroll\",\n cssPrefix = support.transitions.css,\n TRANSFORM = cssPrefix + \"transform\",\n extend = $.extend,\n NS = \".kendoPopup\",\n styles = [\"font-size\",\n \"font-family\",\n \"font-stretch\",\n \"font-style\",\n \"font-weight\",\n \"line-height\"];\n\n function contains(container, target) {\n if (!container || !target) {\n return false;\n }\n return container === target || $.contains(container, target);\n }\n\n var Popup = Widget.extend({\n init: function(element, options) {\n var that = this, parentPopup;\n\n options = options || {};\n\n if (options.isRtl) {\n options.origin = options.origin || BOTTOM + \" \" + RIGHT;\n options.position = options.position || TOP + \" \" + RIGHT;\n }\n\n Widget.fn.init.call(that, element, options);\n\n element = that.element;\n options = that.options;\n\n that.collisions = options.collision ? options.collision.split(\" \") : [];\n that.downEvent = kendo.applyEventMap(MOUSEDOWN, kendo.guid());\n\n if (that.collisions.length === 1) {\n that.collisions.push(that.collisions[0]);\n }\n\n parentPopup = $(that.options.anchor).closest(\".k-popup,.k-group\").filter(\":not([class^=km-])\"); // When popup is in another popup, make it relative.\n\n options.appendTo = $($(options.appendTo)[0] || parentPopup[0] || document.body);\n\n that.element.hide()\n .addClass(\"k-popup k-group k-reset\")\n .toggleClass(\"k-rtl\", !!options.isRtl)\n .css({ position : ABSOLUTE })\n .appendTo(options.appendTo)\n .attr(\"aria-hidden\", true)\n .on(\"mouseenter\" + NS, function() {\n that._hovered = true;\n })\n .on(\"wheel\" + NS, function(e) {\n var list = $(e.target).find(\".k-list\");\n var scrollArea = list.parent();\n if (list.length && list.is(\":visible\") && ((scrollArea.scrollTop() === 0 && e.originalEvent.deltaY < 0) ||\n (scrollArea.scrollTop() === scrollArea.prop('scrollHeight') - scrollArea.prop('offsetHeight') && e.originalEvent.deltaY > 0))) {\n e.preventDefault();\n }\n })\n .on(\"mouseleave\" + NS, function() {\n that._hovered = false;\n });\n\n that.wrapper = $();\n\n if (options.animation === false) {\n options.animation = { open: { effects: {} }, close: { hide: true, effects: {} } };\n }\n\n extend(options.animation.open, {\n complete: function() {\n that.wrapper.css({ overflow: VISIBLE }); // Forcing refresh causes flickering in mobile.\n that._activated = true;\n that._trigger(ACTIVATE);\n }\n });\n\n extend(options.animation.close, {\n complete: function() {\n that._animationClose();\n }\n });\n\n that._mousedownProxy = function(e) {\n that._mousedown(e);\n };\n\n if (support.mobileOS.android) {\n that._resizeProxy = function(e) {\n setTimeout(function() {\n that._resize(e);\n }, 600); //Logic from kendo.onResize\n };\n } else {\n that._resizeProxy = function(e) {\n that._resize(e);\n };\n }\n\n if (options.toggleTarget) {\n $(options.toggleTarget).on(options.toggleEvent + NS, $.proxy(that.toggle, that));\n }\n },\n\n events: [\n OPEN,\n ACTIVATE,\n CLOSE,\n DEACTIVATE\n ],\n\n options: {\n name: \"Popup\",\n toggleEvent: \"click\",\n origin: BOTTOM + \" \" + LEFT,\n position: TOP + \" \" + LEFT,\n anchor: BODY,\n appendTo: null,\n collision: \"flip fit\",\n viewport: window,\n copyAnchorStyles: true,\n autosize: false,\n modal: false,\n adjustSize: {\n width: 0,\n height: 0\n },\n animation: {\n open: {\n effects: \"slideIn:down\",\n transition: true,\n duration: 200\n },\n close: { // if close animation effects are defined, they will be used instead of open.reverse\n duration: 100,\n hide: true\n }\n },\n omitOriginOffsets: false\n },\n\n _animationClose: function() {\n var that = this;\n var location = that.wrapper.data(LOCATION);\n\n that.wrapper.hide();\n\n if (location) {\n that.wrapper.css(location);\n }\n\n if (that.options.anchor != BODY) {\n that._hideDirClass();\n }\n\n that._closing = false;\n that._trigger(DEACTIVATE);\n },\n\n destroy: function() {\n var that = this,\n options = that.options,\n element = that.element.off(NS),\n parent;\n\n Widget.fn.destroy.call(that);\n\n if (options.toggleTarget) {\n $(options.toggleTarget).off(NS);\n }\n\n if (!options.modal) {\n DOCUMENT_ELEMENT.off(that.downEvent, that._mousedownProxy);\n that._toggleResize(false);\n }\n\n kendo.destroy(that.element.children());\n element.removeData();\n\n if (options.appendTo[0] === document.body) {\n parent = element.parent(\".k-animation-container\");\n\n if (parent[0]) {\n parent.remove();\n } else {\n element.remove();\n }\n }\n },\n\n open: function(x, y) {\n var that = this,\n fixed = { isFixed: !isNaN(parseInt(y,10)), x: x, y: y },\n element = that.element,\n options = that.options,\n animation, wrapper,\n anchor = $(options.anchor),\n mobile = element[0] && element.hasClass(\"km-widget\");\n\n if (!that.visible()) {\n if (options.copyAnchorStyles) {\n if (mobile && styles[0] == \"font-size\") {\n styles.shift();\n }\n element.css(kendo.getComputedStyles(anchor[0], styles));\n }\n\n if (element.data(\"animating\") || that._trigger(OPEN)) {\n return;\n }\n\n that._activated = false;\n\n if (!options.modal) {\n DOCUMENT_ELEMENT.off(that.downEvent, that._mousedownProxy)\n .on(that.downEvent, that._mousedownProxy);\n\n // this binding hangs iOS in editor\n // all elements in IE7/8 fire resize event, causing mayhem\n that._toggleResize(false);\n that._toggleResize(true);\n }\n\n that.wrapper = wrapper = kendo.wrap(element, options.autosize)\n .css({\n overflow: HIDDEN,\n display: \"block\",\n position: ABSOLUTE\n })\n .attr(\"aria-hidden\", false);\n\n if (support.mobileOS.android) {\n wrapper.css(TRANSFORM, \"translatez(0)\"); // Android is VERY slow otherwise. Should be tested in other droids as well since it may cause blur.\n }\n\n wrapper.css(POSITION);\n\n if ($(options.appendTo)[0] == document.body) {\n wrapper.css(TOP, \"-10000px\");\n }\n\n that.flipped = that._position(fixed);\n animation = that._openAnimation();\n\n if (options.anchor != BODY) {\n that._showDirClass(animation);\n }\n\n if (!element.is(\":visible\") && element.data(\"olddisplay\") === undefined) {\n element.show();\n element.data(\"olddisplay\", element.css(\"display\"));\n element.hide();\n }\n\n element.data(EFFECTS, animation.effects)\n .kendoStop(true)\n .kendoAnimate(animation)\n .attr(\"aria-hidden\", false);\n }\n },\n\n _location: function(isFixed) {\n var that = this,\n element = that.element,\n options = that.options,\n wrapper,\n anchor = $(options.anchor),\n mobile = element[0] && element.hasClass(\"km-widget\");\n\n if (options.copyAnchorStyles) {\n if (mobile && styles[0] == \"font-size\") {\n styles.shift();\n }\n element.css(kendo.getComputedStyles(anchor[0], styles));\n }\n\n that.wrapper = wrapper = kendo.wrap(element, options.autosize)\n .css({\n overflow: HIDDEN,\n display: \"block\",\n position: ABSOLUTE\n });\n\n if (support.mobileOS.android) {\n wrapper.css(TRANSFORM, \"translatez(0)\"); // Android is VERY slow otherwise. Should be tested in other droids as well since it may cause blur.\n }\n\n wrapper.css(POSITION);\n\n if ($(options.appendTo)[0] == document.body) {\n wrapper.css(TOP, \"-10000px\");\n }\n\n that._position(isFixed || {});\n\n var offset = wrapper.offset();\n return {\n width: kendo._outerWidth(wrapper),\n height: kendo._outerHeight(wrapper),\n left: offset.left,\n top: offset.top\n };\n },\n\n _openAnimation: function() {\n var animation = extend(true, {}, this.options.animation.open);\n animation.effects = kendo.parseEffects(animation.effects, this.flipped);\n\n return animation;\n },\n\n _hideDirClass: function() {\n var anchor = $(this.options.anchor);\n var direction = ((anchor.attr(\"class\") || \"\").match(ACTIVEBORDERREGEXP) || [\"\", \"down\"])[1];\n var dirClass = ACTIVEBORDER + \"-\" + direction;\n\n anchor\n .removeClass(dirClass)\n .children(ACTIVECHILDREN)\n .removeClass(ACTIVE)\n .removeClass(dirClass);\n\n this.element.removeClass(ACTIVEBORDER + \"-\" + kendo.directions[direction].reverse);\n },\n\n _showDirClass: function(animation) {\n var direction = animation.effects.slideIn ? animation.effects.slideIn.direction : \"down\";\n var dirClass = ACTIVEBORDER + \"-\" + direction;\n\n $(this.options.anchor)\n .addClass(dirClass)\n .children(ACTIVECHILDREN)\n .addClass(ACTIVE)\n .addClass(dirClass);\n\n this.element.addClass(ACTIVEBORDER + \"-\" + kendo.directions[direction].reverse);\n },\n\n position: function() {\n if (this.visible()) {\n this.flipped = this._position();\n //this._hideDirClass();\n //this._showDirClass(this._openAnimation());\n }\n },\n\n toggle: function() {\n var that = this;\n\n that[that.visible() ? CLOSE : OPEN]();\n },\n\n visible: function() {\n return this.element.is(\":\" + VISIBLE);\n },\n\n close: function(skipEffects) {\n var that = this,\n options = that.options, wrap,\n animation, openEffects, closeEffects;\n\n if (that.visible()) {\n wrap = (that.wrapper[0] ? that.wrapper : kendo.wrap(that.element).hide());\n\n that._toggleResize(false);\n\n if (that._closing || that._trigger(CLOSE)) {\n that._toggleResize(true);\n return;\n }\n\n // Close all inclusive popups.\n that.element.find(\".k-popup\").each(function () {\n var that = $(this),\n popup = that.data(\"kendoPopup\");\n\n if (popup) {\n popup.close(skipEffects);\n }\n });\n\n DOCUMENT_ELEMENT.off(that.downEvent, that._mousedownProxy);\n\n if (skipEffects) {\n animation = { hide: true, effects: {} };\n } else {\n animation = extend(true, {}, options.animation.close);\n openEffects = that.element.data(EFFECTS);\n closeEffects = animation.effects;\n\n if (!closeEffects && !kendo.size(closeEffects) && openEffects && kendo.size(openEffects)) {\n animation.effects = openEffects;\n animation.reverse = true;\n }\n\n that._closing = true;\n }\n\n that.element\n .kendoStop(true)\n .attr(\"aria-hidden\", true);\n wrap\n .css({ overflow: HIDDEN }) // stop callback will remove hidden overflow\n .attr(\"aria-hidden\", true);\n that.element.kendoAnimate(animation);\n\n if (skipEffects) {\n that._animationClose();\n }\n }\n },\n\n _trigger: function(ev) {\n return this.trigger(ev, { type: ev });\n },\n\n _resize: function(e) {\n var that = this;\n\n if (support.resize.indexOf(e.type) !== -1) {\n clearTimeout(that._resizeTimeout);\n that._resizeTimeout = setTimeout(function() {\n that._position();\n that._resizeTimeout = null;\n }, 50);\n } else {\n if (!that._hovered || (that._activated && that.element.find(\".k-list\").length > 0)) {\n that.close();\n }\n }\n },\n\n _toggleResize: function(toggle) {\n var method = toggle ? \"on\" : \"off\";\n var eventNames = support.resize;\n\n if (!(support.mobileOS.ios || support.mobileOS.android || support.browser.safari)) {\n eventNames += \" \" + SCROLL;\n }\n\n if (toggle && !this.scrollableParents) {\n this.scrollableParents = this._scrollableParents();\n }\n\n if (this.scrollableParents && this.scrollableParents.length) {\n this.scrollableParents[method](SCROLL, this._resizeProxy);\n }\n\n WINDOW[method](eventNames, this._resizeProxy);\n },\n\n _mousedown: function(e) {\n var that = this,\n container = that.element[0],\n options = that.options,\n anchor = $(options.anchor)[0],\n toggleTarget = options.toggleTarget,\n target = kendo.eventTarget(e),\n popup = $(target).closest(\".k-popup\"),\n mobile = popup.parent().parent(\".km-shim\").length;\n\n popup = popup[0];\n if (!mobile && popup && popup !== that.element[0]){\n return;\n }\n\n // This MAY result in popup not closing in certain cases.\n if ($(e.target).closest(\"a\").data(\"rel\") === \"popover\") {\n return;\n }\n\n if (!contains(container, target) && !contains(anchor, target) && !(toggleTarget && contains($(toggleTarget)[0], target))) {\n that.close();\n }\n },\n\n _fit: function(position, size, viewPortSize) {\n var output = 0;\n\n if (position + size > viewPortSize) {\n output = viewPortSize - (position + size);\n }\n\n if (position < 0) {\n output = -position;\n }\n\n return output;\n },\n\n _flip: function(offset, size, anchorSize, viewPortSize, origin, position, boxSize) {\n var output = 0;\n boxSize = boxSize || size;\n\n if (position !== origin && position !== CENTER && origin !== CENTER) {\n if (offset + boxSize > viewPortSize) {\n output += -(anchorSize + size);\n }\n\n if (offset + output < 0) {\n output += anchorSize + size;\n }\n }\n return output;\n },\n\n _scrollableParents: function() {\n return $(this.options.anchor)\n .parentsUntil(\"body\")\n .filter(function(index, element) {\n return kendo.isScrollable(element);\n });\n },\n\n _position: function(fixed) {\n var that = this,\n //element = that.element.css(POSITION, \"\"), /* fixes telerik/kendo-ui-core#790, comes from telerik/kendo#615 */\n element = that.element,\n wrapper = that.wrapper,\n options = that.options,\n viewport = $(options.viewport),\n zoomLevel = support.zoomLevel(),\n isWindow = !!((viewport[0] == window) && window.innerWidth && (zoomLevel <= 1.02)),\n anchor = $(options.anchor),\n origins = options.origin.toLowerCase().split(\" \"),\n positions = options.position.toLowerCase().split(\" \"),\n collisions = that.collisions,\n siblingContainer, parents,\n parentZIndex, zIndex = 10002,\n idx = 0,\n docEl = document.documentElement,\n length, viewportOffset, viewportWidth, viewportHeight;\n\n if (options.viewport === window) {\n viewportOffset = {\n top: (window.pageYOffset || document.documentElement.scrollTop || 0),\n left: (window.pageXOffset || document.documentElement.scrollLeft || 0)\n };\n } else {\n viewportOffset = viewport.offset();\n }\n\n if (isWindow) {\n viewportWidth = window.innerWidth;\n viewportHeight = window.innerHeight;\n } else {\n viewportWidth = viewport.width();\n viewportHeight = viewport.height();\n }\n\n if (isWindow && docEl.scrollHeight - docEl.clientHeight > 0) {\n var sign = options.isRtl ? -1 : 1;\n\n viewportWidth -= sign * kendo.support.scrollbar();\n }\n\n siblingContainer = anchor.parents().filter(wrapper.siblings());\n\n if (siblingContainer[0]) {\n parentZIndex = Math.max(Number(siblingContainer.css(\"zIndex\")), 0);\n\n // set z-index to be more than that of the container/sibling\n // compensate with more units for window z-stack\n if (parentZIndex) {\n zIndex = parentZIndex + 10;\n } else {\n parents = anchor.parentsUntil(siblingContainer);\n for (length = parents.length; idx < length; idx++) {\n parentZIndex = Number($(parents[idx]).css(\"zIndex\"));\n if (parentZIndex && zIndex < parentZIndex) {\n zIndex = parentZIndex + 10;\n }\n }\n }\n }\n\n wrapper.css(\"zIndex\", zIndex);\n\n if (fixed && fixed.isFixed) {\n wrapper.css({ left: fixed.x, top: fixed.y });\n } else {\n wrapper.css(that._align(origins, positions));\n }\n\n var pos = getOffset(wrapper, POSITION, anchor[0] === wrapper.offsetParent()[0]),\n offset = getOffset(wrapper),\n anchorParent = anchor.offsetParent().parent(\".k-animation-container,.k-popup,.k-group\"); // If the parent is positioned, get the current positions\n\n if (anchorParent.length) {\n pos = getOffset(wrapper, POSITION, true);\n offset = getOffset(wrapper);\n }\n\n offset.top -= viewportOffset.top;\n offset.left -= viewportOffset.left;\n\n if (!that.wrapper.data(LOCATION)) { // Needed to reset the popup location after every closure - fixes the resize bugs.\n wrapper.data(LOCATION, extend({}, pos));\n }\n\n var offsets = extend({}, offset),\n location = extend({}, pos),\n adjustSize = options.adjustSize;\n\n if (collisions[0] === \"fit\") {\n location.top += that._fit(offsets.top, outerHeight(wrapper) + adjustSize.height, viewportHeight / zoomLevel);\n }\n\n if (collisions[1] === \"fit\") {\n location.left += that._fit(offsets.left, outerWidth(wrapper) + adjustSize.width, viewportWidth / zoomLevel);\n }\n\n var flipPos = extend({}, location);\n var elementHeight = outerHeight(element);\n var wrapperHeight = outerHeight(wrapper);\n\n if (!wrapper.height() && elementHeight) {\n wrapperHeight = wrapperHeight + elementHeight;\n }\n\n if (collisions[0] === \"flip\") {\n location.top += that._flip(offsets.top, elementHeight, outerHeight(anchor), viewportHeight / zoomLevel, origins[0], positions[0], wrapperHeight);\n }\n\n if (collisions[1] === \"flip\") {\n location.left += that._flip(offsets.left, outerWidth(element), outerWidth(anchor), viewportWidth / zoomLevel, origins[1], positions[1], outerWidth(wrapper));\n }\n\n element.css(POSITION, ABSOLUTE);\n wrapper.css(location);\n\n return (location.left != flipPos.left || location.top != flipPos.top);\n },\n\n _align: function(origin, position) {\n var that = this,\n element = that.wrapper,\n anchor = $(that.options.anchor),\n verticalOrigin = origin[0],\n horizontalOrigin = origin[1],\n verticalPosition = position[0],\n horizontalPosition = position[1],\n anchorOffset = getOffset(anchor),\n appendTo = $(that.options.appendTo),\n appendToOffset,\n width = outerWidth(element),\n height = outerHeight(element) || outerHeight(element.children().first()),\n anchorWidth = outerWidth(anchor),\n anchorHeight = outerHeight(anchor),\n top = that.options.omitOriginOffsets ? 0 : anchorOffset.top,\n left = that.options.omitOriginOffsets ? 0 : anchorOffset.left,\n round = Math.round;\n\n if (appendTo[0] != document.body) {\n appendToOffset = getOffset(appendTo);\n top -= appendToOffset.top;\n left -= appendToOffset.left;\n }\n\n\n if (verticalOrigin === BOTTOM) {\n top += anchorHeight;\n }\n\n if (verticalOrigin === CENTER) {\n top += round(anchorHeight / 2);\n }\n\n if (verticalPosition === BOTTOM) {\n top -= height;\n }\n\n if (verticalPosition === CENTER) {\n top -= round(height / 2);\n }\n\n if (horizontalOrigin === RIGHT) {\n left += anchorWidth;\n }\n\n if (horizontalOrigin === CENTER) {\n left += round(anchorWidth / 2);\n }\n\n if (horizontalPosition === RIGHT) {\n left -= width;\n }\n\n if (horizontalPosition === CENTER) {\n left -= round(width / 2);\n }\n\n return {\n top: top,\n left: left\n };\n }\n });\n\n ui.plugin(Popup);\n\n var stableSort = kendo.support.stableSort;\n var tabKeyTrapNS = \"kendoTabKeyTrap\";\n var focusableNodesSelector = \"a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, [tabindex], *[contenteditable]\";\n var TabKeyTrap = Class.extend({\n init: function(element) {\n this.element = $(element);\n this.element.autoApplyNS(tabKeyTrapNS);\n },\n\n trap: function() {\n this.element.on(\"keydown\", proxy(this._keepInTrap, this));\n },\n\n removeTrap: function() {\n this.element.kendoDestroy(tabKeyTrapNS);\n },\n\n destroy: function() {\n this.element.kendoDestroy(tabKeyTrapNS);\n this.element = undefined;\n },\n\n shouldTrap: function () {\n return true;\n },\n\n _keepInTrap: function(e) {\n if (e.which !== 9 || !this.shouldTrap() || e.isDefaultPrevented()) {\n return;\n }\n\n var elements = this._focusableElements();\n var sortedElements = this._sortFocusableElements(elements);\n var next = this._nextFocusable(e, sortedElements);\n\n this._focus(next);\n\n e.preventDefault();\n },\n _focusableElements: function(){\n var elements = this.element.find(focusableNodesSelector).filter(function(i, item){\n return item.tabIndex >= 0 && $(item).is(':visible') && !$(item).is('[disabled]');\n });\n\n if (this.element.is(\"[tabindex]\")) {\n elements.push(this.element[0]);\n }\n\n return elements;\n },\n _sortFocusableElements: function(elements){\n var sortedElements;\n\n if (stableSort) {\n sortedElements = elements.sort(function(prev, next) {\n return prev.tabIndex - next.tabIndex;\n });\n } else {\n var attrName = \"__k_index\";\n elements.each(function(i, item){\n item.setAttribute(attrName, i);\n });\n\n sortedElements = elements.sort(function(prev, next) {\n return prev.tabIndex === next.tabIndex ?\n parseInt(prev.getAttribute(attrName), 10) - parseInt(next.getAttribute(attrName), 10) :\n prev.tabIndex - next.tabIndex;\n });\n\n elements.removeAttr(attrName);\n }\n\n return sortedElements;\n },\n _nextFocusable: function(e, elements){\n var count = elements.length;\n var current = elements.index(e.target);\n\n return elements.get((current + (e.shiftKey ? -1 : 1)) % count);\n },\n _focus: function(element){\n if (element.nodeName == \"IFRAME\") {\n element.contentWindow.document.body.focus();\n return;\n }\n\n element.focus();\n\n if (element.nodeName == \"INPUT\" && element.setSelectionRange && this._haveSelectionRange(element)) {\n element.setSelectionRange(0, element.value.length);\n }\n },\n _haveSelectionRange: function(element){\n var elementType = element.type.toLowerCase();\n\n return elementType === \"text\" || elementType === \"search\" ||\n elementType === \"url\" || elementType === \"tel\" ||\n elementType === \"password\";\n }\n });\n ui.Popup.TabKeyTrap = TabKeyTrap;\n})(window.kendo.jQuery);\n\n\n\nreturn window.kendo;\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n\n(function(f, define){\n define('drawing/surface-tooltip',[ \"../kendo.popup\", \"./kendo-drawing\" ], f);\n})(function(){\n\n(function ($) {\n\n var NS = \".kendo\";\n var kendo = window.kendo;\n var deepExtend = kendo.deepExtend;\n var utils = kendo.drawing.util;\n var defined = utils.defined;\n var limitValue = utils.limitValue;\n var eventCoordinates = utils.eventCoordinates;\n var outerWidth = kendo._outerWidth;\n var outerHeight = kendo._outerHeight;\n var proxy = $.proxy;\n\n var TOOLTIP_TEMPLATE = '
    ' +\n '
    ' +\n '
    ';\n var TOOLTIP_CLOSE_TEMPLATE = '
    ';\n\n var SurfaceTooltip = kendo.Class.extend({\n init: function(surface, options) {\n this.element = $(TOOLTIP_TEMPLATE);\n this.content = this.element.children(\".k-tooltip-content\");\n\n options = options || {};\n\n this.options = deepExtend({}, this.options, this._tooltipOptions(options));\n this.popupOptions = {\n appendTo: options.appendTo,\n animation: options.animation,\n copyAnchorStyles: false,\n collision: \"fit fit\"\n };\n\n this._openPopupHandler = $.proxy(this._openPopup, this);\n\n this.surface = surface;\n this._bindEvents();\n },\n\n options: {\n position: \"top\",\n showOn: \"mouseenter\",\n offset: 7,\n autoHide: true,\n hideDelay: 0,\n showAfter: 100\n },\n\n _bindEvents: function() {\n this._showHandler = proxy(this._showEvent, this);\n this._surfaceLeaveHandler = proxy(this._surfaceLeave, this);\n this._mouseleaveHandler = proxy(this._mouseleave, this);\n this._mousemoveHandler = proxy(this._mousemove, this);\n\n this.surface.bind(\"click\", this._showHandler);\n this.surface.bind(\"mouseenter\", this._showHandler);\n this.surface.bind(\"mouseleave\", this._mouseleaveHandler);\n this.surface.bind(\"mousemove\", this._mousemoveHandler);\n\n this.surface.element.on(\"mouseleave\" + NS, this._surfaceLeaveHandler);\n\n this.element.on(\"click\" + NS, \".k-tooltip-button\", proxy(this._hideClick, this));\n this.element.on(\"mouseleave\" + NS, proxy(this._tooltipLeave, this));\n },\n\n getPopup: function() {\n if (!this.popup) {\n this.popup = new kendo.ui.Popup(this.element, this.popupOptions);\n }\n\n return this.popup;\n },\n\n destroy: function() {\n var popup = this.popup;\n\n this.surface.unbind(\"click\", this._showHandler);\n this.surface.unbind(\"mouseenter\", this._showHandler);\n this.surface.unbind(\"mouseleave\", this._mouseleaveHandler);\n this.surface.unbind(\"mousemove\", this._mousemoveHandler);\n\n this.surface.element.off(\"mouseleave\" + NS, this._surfaceLeaveHandler);\n this.element.off(\"click\" + NS);\n this.element.off(\"mouseleave\" + NS);\n\n if (popup) {\n popup.destroy();\n delete this.popup;\n }\n delete this.popupOptions;\n\n clearTimeout(this._timeout);\n\n delete this.element;\n delete this.content;\n delete this.surface;\n },\n\n _tooltipOptions: function(options) {\n options = options || {};\n return {\n position: options.position,\n showOn: options.showOn,\n offset: options.offset,\n autoHide: options.autoHide,\n width: options.width,\n height: options.height,\n content: options.content,\n shared: options.shared,\n hideDelay: options.hideDelay,\n showAfter: options.showAfter\n };\n },\n\n _tooltipShape: function(shape) {\n while(shape && !shape.options.tooltip) {\n shape = shape.parent;\n }\n return shape;\n },\n\n _updateContent: function(target, shape, options) {\n var content = options.content;\n if (kendo.isFunction(content)) {\n content = content({\n element: shape,\n target: target\n });\n }\n\n if (content) {\n this.content.html(content);\n return true;\n }\n },\n\n _position: function(shape, options, elementSize, event) {\n var position = options.position;\n var tooltipOffset = options.offset || 0;\n var surface = this.surface;\n var offset = surface._instance._elementOffset();\n var size = surface.getSize();\n var surfaceOffset = surface._instance._offset;\n var bbox = shape.bbox();\n var width = elementSize.width;\n var height = elementSize.height;\n var left = 0, top = 0;\n\n bbox.origin.translate(offset.left, offset.top);\n if (surfaceOffset) {\n bbox.origin.translate(-surfaceOffset.x, -surfaceOffset.y);\n }\n\n if (position == \"cursor\" && event) {\n var coord = eventCoordinates(event);\n left = coord.x - width / 2;\n top = coord.y - height - tooltipOffset;\n } else if (position == \"left\") {\n left = bbox.origin.x - width - tooltipOffset;\n top = bbox.center().y - height / 2;\n } else if (position == \"right\") {\n left = bbox.bottomRight().x + tooltipOffset;\n top = bbox.center().y - height / 2;\n } else if (position == \"bottom\") {\n left = bbox.center().x - width / 2;\n top = bbox.bottomRight().y + tooltipOffset;\n } else {\n left = bbox.center().x - width / 2;\n top = bbox.origin.y - height - tooltipOffset;\n }\n\n return {\n left: limitValue(left, offset.left, offset.left + size.width),\n top: limitValue(top, offset.top, offset.top + size.height)\n };\n },\n\n show: function(shape, options) {\n this._show(shape, shape, deepExtend({}, this.options, this._tooltipOptions(shape.options.tooltip), options));\n },\n\n hide: function() {\n var popup = this.popup;\n var current = this._current;\n\n delete this._current;\n clearTimeout(this._showTimeout);\n if (popup && popup.visible() && current &&\n !this.surface.trigger(\"tooltipClose\", { element: current.shape, target: current.target, popup: popup})) {\n popup.close();\n }\n },\n\n _hideClick: function(e) {\n e.preventDefault();\n this.hide();\n },\n\n _show: function(target, shape, options, event, delay) {\n var current = this._current;\n\n clearTimeout(this._timeout);\n\n if (current && ((current.shape === shape && options.shared) || current.target === target)) {\n return;\n }\n\n clearTimeout(this._showTimeout);\n\n var popup = this.getPopup();\n\n if (!this.surface.trigger(\"tooltipOpen\", { element: shape, target: target, popup: popup }) &&\n this._updateContent(target, shape, options)) {\n\n this._autoHide(options);\n var elementSize = this._measure(options);\n\n if (popup.visible()) {\n popup.close(true);\n }\n\n this._current = {\n options: options,\n elementSize: elementSize,\n shape: shape,\n target: target,\n position: this._position(options.shared ? shape: target, options, elementSize, event)\n };\n\n if (delay) {\n this._showTimeout = setTimeout(this._openPopupHandler, options.showAfter || 0);\n } else {\n this._openPopup();\n }\n }\n },\n\n _openPopup: function() {\n var current = this._current;\n var position = current.position;\n\n this.getPopup().open(position.left, position.top);\n },\n\n _autoHide: function(options) {\n if (options.autoHide && this._closeButton) {\n this.element.removeClass(\"k-tooltip-closable\");\n this._closeButton.remove();\n delete this._closeButton;\n }\n\n if (!options.autoHide && !this._closeButton) {\n this.element.addClass(\"k-tooltip-closable\");\n this._closeButton = $(TOOLTIP_CLOSE_TEMPLATE).appendTo(this.element);\n }\n },\n\n _showEvent: function(e) {\n var shape = this._tooltipShape(e.element);\n\n if (shape) {\n var options = deepExtend({}, this.options, this._tooltipOptions(shape.options.tooltip));\n\n if (options && options.showOn == e.type) {\n this._show(e.element, shape, options, e.originalEvent, true);\n }\n }\n },\n\n _measure: function(options) {\n var popup = this.getPopup();\n var width, height;\n this.element.css({\n width: \"auto\",\n height: \"auto\"\n });\n var visible = popup.visible();\n if (!visible) {\n popup.wrapper.show();\n }\n\n this.element.css({\n width: defined(options.width) ? options.width : \"auto\",\n height: defined(options.height) ? options.height : \"auto\"\n });\n\n width = outerWidth(this.element);\n height = outerHeight(this.element);\n\n if (!visible) {\n popup.wrapper.hide();\n }\n\n return {\n width: width,\n height: height\n };\n },\n\n _mouseleave: function(e) {\n if (this.popup && !this._popupRelatedTarget(e.originalEvent)) {\n var tooltip = this;\n var current = tooltip._current;\n\n if (current && current.options.autoHide) {\n tooltip._timeout = setTimeout(function() {\n clearTimeout(tooltip._showTimeout);\n tooltip.hide();\n }, current.options.hideDelay || 0);\n }\n }\n },\n\n _mousemove: function(e) {\n var current = this._current;\n if (current && e.element) {\n var options = current.options;\n if (options.position == \"cursor\") {\n var position = this._position(e.element, options, current.elementSize, e.originalEvent);\n current.position = position;\n this.getPopup().wrapper.css({left: position.left, top: position.top});\n }\n }\n },\n\n _surfaceLeave: function(e) {\n if (this.popup && !this._popupRelatedTarget(e)) {\n clearTimeout(this._showTimeout);\n this.hide();\n }\n },\n\n _popupRelatedTarget: function(e) {\n return e.relatedTarget && $(e.relatedTarget).closest(this.popup.wrapper).length;\n },\n\n _tooltipLeave: function() {\n var tooltip = this;\n var current = tooltip._current;\n if (current && current.options.autoHide) {\n tooltip._timeout = setTimeout(function() {\n tooltip.hide();\n }, current.options.hideDelay || 0);\n }\n }\n });\n\n kendo.drawing.SurfaceTooltip = SurfaceTooltip;\n\n})(window.kendo.jQuery);\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n(function(f, define){\n define('drawing/surface',[ \"./kendo-drawing\", \"./surface-tooltip\" ], f);\n})(function(){\n\n(function ($) {\n\n var kendo = window.kendo;\n var draw = kendo.drawing;\n var DrawingSurface = draw.Surface;\n var Widget = kendo.ui.Widget;\n var deepExtend = kendo.deepExtend;\n var proxy = $.proxy;\n\n kendo.support.svg = DrawingSurface.support.svg;\n kendo.support.canvas = DrawingSurface.support.canvas;\n\n var Surface = Widget.extend({\n init: function(element, options) {\n Widget.fn.init.call(this, element, {});\n\n this.options = deepExtend({}, this.options, options);\n\n this._instance = DrawingSurface.create(this.element[0], options);\n if (this._instance.translate) {\n this.translate = translate;\n }\n\n this._triggerInstanceHandler = proxy(this._triggerInstanceEvent, this);\n this._bindHandler(\"click\");\n this._bindHandler(\"mouseenter\");\n this._bindHandler(\"mouseleave\");\n this._bindHandler(\"mousemove\");\n\n this._enableTracking();\n },\n\n options: {\n name: \"Surface\",\n tooltip: {}\n },\n\n events: [\n \"click\",\n \"mouseenter\",\n \"mouseleave\",\n \"mousemove\",\n \"resize\",\n \"tooltipOpen\",\n \"tooltipClose\"\n ],\n\n _triggerInstanceEvent: function(e) {\n this.trigger(e.type, e);\n },\n\n _bindHandler: function(event) {\n this._instance.bind(event, this._triggerInstanceHandler);\n },\n\n draw: function(element) {\n this._instance.draw(element);\n },\n\n clear: function() {\n if (this._instance) {\n this._instance.clear();\n }\n this.hideTooltip();\n },\n\n destroy: function() {\n if (this._instance) {\n this._instance.destroy();\n delete this._instance;\n }\n\n if (this._tooltip) {\n this._tooltip.destroy();\n delete this._tooltip;\n }\n\n Widget.fn.destroy.call(this);\n },\n\n exportVisual: function() {\n return this._instance.exportVisual();\n },\n\n eventTarget: function(e) {\n return this._instance.eventTarget(e);\n },\n\n showTooltip: function(shape, options) {\n if (this._tooltip) {\n this._tooltip.show(shape, options);\n }\n },\n\n hideTooltip: function() {\n if (this._tooltip) {\n this._tooltip.hide();\n }\n },\n\n suspendTracking: function() {\n this._instance.suspendTracking();\n this.hideTooltip();\n },\n\n resumeTracking: function() {\n this._instance.resumeTracking();\n },\n\n getSize: function() {\n return {\n width: this.element.width(),\n height: this.element.height()\n };\n },\n\n setSize: function(size) {\n this.element.css({\n width: size.width,\n height: size.height\n });\n\n this._size = size;\n this._instance.currentSize(size);\n this._resize();\n },\n\n _resize: function() {\n this._instance.currentSize(this._size);\n this._instance._resize();\n },\n\n _enableTracking: function() {\n if (kendo.ui.Popup) {\n this._tooltip = new draw.SurfaceTooltip(this, this.options.tooltip || {});\n }\n }\n });\n\n kendo.ui.plugin(Surface);\n\n Surface.create = function(element, options) {\n return new Surface(element, options);\n };\n\n kendo.drawing.Surface = Surface;\n\n function translate(offset) {\n this._instance.translate(offset);\n }\n\n})(window.kendo.jQuery);\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n(function(f, define){\n define('drawing/html',[ \"./kendo-drawing\" ], f);\n})(function(){\n\n(function ($) {\n\n var kendo = window.kendo;\n var drawing = kendo.drawing;\n var drawDOM = drawing.drawDOM;\n\n drawing.drawDOM = function(element, options) {\n return drawDOM($(element)[0], options);\n };\n\n // Aliases used by spreadsheet/print.js\n drawing.drawDOM.drawText = drawing.drawText;\n drawing.drawDOM.getFontFaces = drawing.getFontFaces;\n\n})(window.kendo.jQuery);\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n\n(function(f, define){\n define('kendo.drawing',[\n \"./drawing/util\",\n \"./drawing/kendo-drawing\",\n \"./drawing/surface-tooltip\",\n \"./drawing/surface\",\n \"./drawing/html\"\n ], f);\n})(function(){\n\n var __meta__ = { // jshint ignore:line\n id: \"drawing\",\n name: \"Drawing API\",\n category: \"framework\",\n description: \"The Kendo UI low-level drawing API\",\n depends: [ \"core\", \"color\", \"popup\" ]\n };\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n(function(f, define){\n define('kendo.validator',[ \"./kendo.core\" ], f);\n})(function(){\n\nvar __meta__ = { // jshint ignore:line\n id: \"validator\",\n name: \"Validator\",\n category: \"web\",\n description: \"The Validator offers an easy way to do a client-side form validation.\",\n depends: [ \"core\" ]\n};\n\n/* jshint eqnull: true */\n(function($, undefined) {\n var kendo = window.kendo,\n Widget = kendo.ui.Widget,\n NS = \".kendoValidator\",\n INVALIDMSG = \"k-invalid-msg\",\n invalidMsgRegExp = new RegExp(INVALIDMSG,'i'),\n INVALIDINPUT = \"k-invalid\",\n VALIDINPUT = \"k-valid\",\n VALIDATIONSUMMARY = \"k-validation-summary\",\n INVALIDLABEL = \"k-text-error\",\n MESSAGEBOX = \"k-messagebox k-messagebox-error\",\n INPUTINNER = \".k-input-inner\",\n INPUTWRAPPER = \".k-input\",\n ARIAINVALID = \"aria-invalid\",\n ARIADESCRIBEDBY = \"aria-describedby\",\n emailRegExp = /^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/i,\n urlRegExp = /^(https?|ftp):\\/\\/(((([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(%[\\da-f]{2})|[!\\$&'\\(\\)\\*\\+,;=]|:)*@)?(((\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5]))|((([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.)+(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.?)(:\\d*)?)(\\/((([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(%[\\da-f]{2})|[!\\$&'\\(\\)\\*\\+,;=]|:|@)+(\\/(([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(%[\\da-f]{2})|[!\\$&'\\(\\)\\*\\+,;=]|:|@)*)*)?)?(\\?((([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(%[\\da-f]{2})|[!\\$&'\\(\\)\\*\\+,;=]|:|@)|[\\uE000-\\uF8FF]|\\/|\\?)*)?(\\#((([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(%[\\da-f]{2})|[!\\$&'\\(\\)\\*\\+,;=]|:|@)|\\/|\\?)*)?$/i,\n INPUTSELECTOR = \":input:not(:button,[type=submit],[type=reset],[disabled],[readonly])\",\n CHECKBOXSELECTOR = \":checkbox:not([disabled],[readonly])\",\n NUMBERINPUTSELECTOR = \"[type=number],[type=range]\",\n BLUR = \"blur\",\n NAME = \"name\",\n FORM = \"form\",\n NOVALIDATE = \"novalidate\",\n //events\n VALIDATE = \"validate\",\n CHANGE = \"change\",\n VALIDATE_INPUT = \"validateInput\",\n proxy = $.proxy,\n patternMatcher = function(value, pattern) {\n if (typeof pattern === \"string\") {\n pattern = new RegExp('^(?:' + pattern + ')$');\n }\n return pattern.test(value);\n },\n matcher = function(input, selector, pattern) {\n var value = input.val();\n\n if (input.filter(selector).length && value !== \"\") {\n return patternMatcher(value, pattern);\n }\n return true;\n },\n hasAttribute = function(input, name) {\n if (input.length) {\n return input[0].attributes[name] != null;\n }\n return false;\n };\n\n if (!kendo.ui.validator) {\n kendo.ui.validator = { rules: {}, messages: {}, allowSubmit: $.noop, validateOnInit: $.noop };\n }\n\n function resolveRules(element) {\n var resolvers = kendo.ui.validator.ruleResolvers || {},\n rules = {},\n name;\n\n for (name in resolvers) {\n $.extend(true, rules, resolvers[name].resolve(element));\n }\n return rules;\n }\n\n function decode(value) {\n return value.replace(/&/g, '&')\n .replace(/"/g, '\"')\n .replace(/'/g, \"'\")\n .replace(/</g, '<')\n .replace(/>/g, '>');\n }\n\n function numberOfDecimalDigits(value) {\n value = (value + \"\").split('.');\n if (value.length > 1) {\n return value[1].length;\n }\n return 0;\n }\n\n function parseHtml(text) {\n if ($.parseHTML) {\n return $($.parseHTML(text));\n }\n return $(text);\n }\n\n function searchForMessageContainer(elements, fieldName) {\n var containers = $(),\n element,\n attr;\n\n for (var idx = 0, length = elements.length; idx < length; idx++) {\n element = elements[idx];\n if (invalidMsgRegExp.test(element.className)) {\n attr = element.getAttribute(kendo.attr(\"for\"));\n if (attr === fieldName) {\n containers = containers.add(element);\n }\n }\n }\n return containers;\n }\n\n function isLabelFor(label, element) {\n if (!label) {\n return false;\n }\n if (typeof label.nodeName !== 'string' || label.nodeName !== 'LABEL') {\n return false;\n }\n if (typeof label.getAttribute('for') !== 'string' || typeof element.getAttribute('id') !== 'string') {\n return false;\n }\n if (label.getAttribute('for') !== element.getAttribute('id')) {\n return false;\n }\n\n return true;\n }\n\n var SUMMARYTEMPLATE = '';\n\n var Validator = Widget.extend({\n init: function(element, options) {\n var that = this,\n resolved = resolveRules(element),\n validateAttributeSelector = \"[\" + kendo.attr(\"validate\") + \"!=false]\";\n\n options = options || {};\n\n options.rules = $.extend({}, kendo.ui.validator.rules, resolved.rules, options.rules);\n options.messages = $.extend({}, kendo.ui.validator.messages, resolved.messages, options.messages);\n\n Widget.fn.init.call(that, element, options);\n\n that._errorTemplate = kendo.template(that.options.errorTemplate);\n that._summaryTemplate = kendo.template(that.options.validationSummary.template || SUMMARYTEMPLATE);\n\n if (that.element.is(FORM)) {\n that.element.attr(NOVALIDATE, NOVALIDATE);\n }\n\n that._inputSelector = INPUTSELECTOR + validateAttributeSelector;\n that._checkboxSelector = CHECKBOXSELECTOR + validateAttributeSelector;\n\n that._errors = {};\n that._attachEvents();\n that._isValidated = false;\n\n if (that._validateOnInit()) {\n that.validate();\n }\n },\n\n events: [ VALIDATE, CHANGE, VALIDATE_INPUT ],\n\n options: {\n name: \"Validator\",\n errorTemplate: '#= message #',\n messages: {\n required: \"{0} is required\",\n pattern: \"{0} is not valid\",\n min: \"{0} should be greater than or equal to {1}\",\n max: \"{0} should be smaller than or equal to {1}\",\n step: \"{0} is not valid\",\n email: \"{0} is not valid email\",\n url: \"{0} is not valid URL\",\n date: \"{0} is not valid date\",\n dateCompare: \"End date should be greater than or equal to the start date\",\n captcha: \"The text you entered doesn't match the image.\"\n },\n rules: {\n required: function(input) {\n var noNameCheckbox = !input.attr(\"name\") && !input.is(\":checked\"),\n name = input.attr(\"name\"),\n quote = !!name && name.indexOf(\"'\") > -1 ? '\\\"' : \"'\",\n namedCheckbox = input.attr(\"name\") && !this.element.find(\"input[name=\" + quote + input.attr(\"name\") + quote + \"]:checked\").length,\n checkbox = input.filter(\"[type=checkbox]\").length && (noNameCheckbox || namedCheckbox),\n radio = input.filter(\"[type=radio]\").length && !this.element.find(\"input[name=\" + quote + input.attr(\"name\") + quote + \"]:checked\").length,\n value = input.val();\n\n return !(hasAttribute(input, \"required\") && (!value || value === \"\" || value.length === 0 || checkbox || radio));\n },\n pattern: function(input) {\n if (input.filter(\"[type=text],[type=email],[type=url],[type=tel],[type=search],[type=password]\").filter(\"[pattern]\").length && input.val() !== \"\") {\n return patternMatcher(input.val(), input.attr(\"pattern\"));\n }\n return true;\n },\n min: function(input) {\n if (input.filter(NUMBERINPUTSELECTOR + \",[\" + kendo.attr(\"type\") + \"=number]\").filter(\"[min]\").length && input.val() !== \"\") {\n var min = parseFloat(input.attr(\"min\")) || 0,\n val = kendo.parseFloat(input.val());\n\n return min <= val;\n }\n return true;\n },\n max: function(input) {\n if (input.filter(NUMBERINPUTSELECTOR + \",[\" + kendo.attr(\"type\") + \"=number]\").filter(\"[max]\").length && input.val() !== \"\") {\n var max = parseFloat(input.attr(\"max\")) || 0,\n val = kendo.parseFloat(input.val());\n\n return max >= val;\n }\n return true;\n },\n step: function(input) {\n if (input.filter(NUMBERINPUTSELECTOR + \",[\" + kendo.attr(\"type\") + \"=number]\").filter(\"[step]\").length && input.val() !== \"\") {\n var min = parseFloat(input.attr(\"min\")) || 0,\n step = parseFloat(input.attr(\"step\")) || 1,\n val = parseFloat(input.val()),\n decimals = numberOfDecimalDigits(step),\n raise;\n\n if (decimals) {\n raise = Math.pow(10, decimals);\n return ((Math.floor((val-min)*raise))%(step*raise)) / Math.pow(100, decimals) === 0;\n }\n return ((val-min)%step) === 0;\n }\n return true;\n },\n email: function(input) {\n return matcher(input, \"[type=email],[\" + kendo.attr(\"type\") + \"=email]\", emailRegExp);\n },\n url: function(input) {\n return matcher(input, \"[type=url],[\" + kendo.attr(\"type\") + \"=url]\", urlRegExp);\n },\n date: function(input) {\n if (input.filter(\"[type^=date],[\" + kendo.attr(\"type\") + \"=date]\").length && input.val() !== \"\") {\n return kendo.parseDate(input.val(), input.attr(kendo.attr(\"format\"))) !== null;\n }\n return true;\n },\n captcha: function (input) {\n if (input.filter(\"[\" + kendo.attr(\"role\") + \"=captcha]\").length) {\n var that = this,\n captcha = kendo.widgetInstance(input),\n isValidated = function(isValid){\n return typeof(isValid) !== 'undefined' && isValid !== null;\n };\n\n if (!input.data(\"captcha_validating\") && !isValidated(captcha.isValid()) && !!captcha.getCaptchaId()) {\n input.data(\"captcha_validating\", true);\n that._validating = true;\n captcha.validate().done(function(){\n that._validating = false;\n that._checkElement(input);\n }).fail(function(data){\n that._validating = false;\n if(data.error && data.error === \"handler_not_defined\") {\n window.console.warn(\"Captcha's validationHandler is not defined! You should either define a proper validation endpoint or declare a callback function to ensure the required behavior.\");\n }\n });\n }\n\n if (isValidated(captcha.isValid())){\n input.removeData(\"captcha_validating\");\n return captcha.isValid();\n }\n }\n return true;\n }\n },\n validateOnBlur: true,\n validationSummary: false\n },\n\n _allowSubmit: function() {\n return kendo.ui.validator.allowSubmit(this.element, this.errors());\n },\n\n _validateOnInit: function() {\n return kendo.ui.validator.validateOnInit(this.element);\n },\n\n destroy: function() {\n Widget.fn.destroy.call(this);\n\n this.element.off(NS);\n\n if (this.validationSummary) {\n this.validationSummary.off(NS);\n this.validationSummary = null;\n }\n },\n\n value: function() {\n if (!this._isValidated) {\n return false;\n }\n\n return this.errors().length === 0;\n },\n\n _submit: function(e) {\n if ((!this.validate() && !this._allowSubmit()) || this._validating) {\n e.stopPropagation();\n e.stopImmediatePropagation();\n e.preventDefault();\n return false;\n }\n return true;\n },\n\n _checkElement: function(element) {\n var state = this.value();\n\n this.validateInput(element);\n\n if (this.value() !== state) {\n this.trigger(CHANGE);\n }\n },\n\n _attachEvents: function() {\n var that = this;\n\n if (that.element.is(FORM)) {\n that.element.on(\"submit\" + NS, proxy(that._submit, that));\n }\n\n if (that.options.validateOnBlur) {\n if (!that.element.is(INPUTSELECTOR)) {\n that.element.on(BLUR + NS, that._inputSelector, function() {\n that._checkElement($(this));\n });\n\n that.element.on(\"click\" + NS, that._checkboxSelector, function() {\n that._checkElement($(this));\n });\n } else {\n that.element.on(BLUR + NS, function() {\n that._checkElement(that.element);\n });\n\n if (that.element.is(CHECKBOXSELECTOR)) {\n that.element.on(\"click\" + NS, function() {\n that._checkElement(that.element);\n });\n }\n }\n }\n },\n\n validate: function() {\n var inputs;\n var idx;\n var result = false;\n var length;\n\n var isValid = this.value();\n\n this._errors = {};\n\n if (!this.element.is(INPUTSELECTOR)) {\n var invalid = false;\n\n inputs = this.element.find(this._inputSelector);\n\n for (idx = 0, length = inputs.length; idx < length; idx++) {\n if (!this.validateInput(inputs.eq(idx))) {\n invalid = true;\n }\n }\n\n result = !invalid;\n } else {\n result = this.validateInput(this.element);\n }\n\n if (this.options.validationSummary && !isValid) {\n this.showValidationSummary();\n }\n\n this.trigger(VALIDATE, { valid: result, errors: this.errors() });\n\n if (isValid !== result) {\n this.trigger(CHANGE);\n }\n\n return result;\n },\n\n validateInput: function(input) {\n input = $(input);\n\n\n this._isValidated = true;\n\n var that = this,\n template = that._errorTemplate,\n result = that._checkValidity(input),\n valid = result.valid,\n className = \".\" + INVALIDMSG,\n fieldName = (input.attr(NAME) || \"\"),\n lbl = that._findMessageContainer(fieldName).add(input.next(className).filter(function() {\n var element = $(this);\n if (element.filter(\"[\" + kendo.attr(\"for\") + \"]\").length) {\n return element.attr(kendo.attr(\"for\")) === fieldName;\n }\n\n return true;\n\n })).addClass(\"k-hidden\"),\n messageText = !valid ? that._extractMessage(input, result.key) : \"\",\n messageLabel = !valid ? parseHtml(template({ message: decode(messageText), field: fieldName })) : \"\",\n wasValid = !input.attr(ARIAINVALID),\n isInputInner = input.is(INPUTINNER),\n inputWrapper = input.parent(INPUTWRAPPER);\n\n input.removeAttr(ARIAINVALID);\n\n if (!valid && !input.data(\"captcha_validating\")) {\n that._errors[fieldName] = messageText;\n var lblId = lbl.attr('id');\n\n that._decorateMessageContainer(messageLabel, fieldName);\n\n\n if (lblId) {\n messageLabel.attr('id', lblId);\n }\n\n if (lbl.length !== 0) {\n lbl.replaceWith(messageLabel);\n } else {\n var widgetInstance = kendo.widgetInstance(input);\n var parentElement = input.parent().get(0);\n var nextElement = input.next().get(0);\n var prevElement = input.prev().get(0);\n\n // Get the instance of the RadioGroup which is not initialized on the input element\n if(!widgetInstance && input.is(\"[type=radio]\")) {\n widgetInstance = kendo.widgetInstance(input.closest(\".k-radio-list\"));\n }\n\n // Get the instance of the CheckBoxGroup which is not initialized on the input element\n if(!widgetInstance && input.is(\"[type=checkbox]\")) {\n widgetInstance = kendo.widgetInstance(input.closest(\".k-checkbox-list\"));\n }\n\n if (widgetInstance && widgetInstance.wrapper) {\n messageLabel.insertAfter(widgetInstance.wrapper);\n } else if (parentElement && parentElement.nodeName === \"LABEL\") {\n // Input inside label\n messageLabel.insertAfter(parentElement);\n } else if (nextElement && isLabelFor(nextElement, input[0])) {\n // Input before label\n messageLabel.insertAfter(nextElement);\n } else if (prevElement && isLabelFor(prevElement, input[0])) {\n // Input after label\n messageLabel.insertAfter(input);\n } else if (isInputInner && inputWrapper.length) {\n // Input after input wrapper\n messageLabel.insertAfter(inputWrapper);\n } else {\n messageLabel.insertAfter(input);\n }\n }\n\n messageLabel.removeClass(\"k-hidden\");\n\n input.attr(ARIAINVALID, true);\n } else {\n delete that._errors[fieldName];\n }\n\n if (wasValid !== valid) {\n this.trigger(VALIDATE_INPUT, { valid: valid, input: input, error: messageText, field: fieldName });\n }\n\n if (isInputInner && inputWrapper.length) {\n inputWrapper.toggleClass(INVALIDINPUT, !valid);\n inputWrapper.toggleClass(VALIDINPUT, valid);\n }\n\n input.toggleClass(INVALIDINPUT, !valid);\n input.toggleClass(VALIDINPUT, valid);\n\n\n if (kendo.widgetInstance(input)) {\n var widget = kendo.widgetInstance(input);\n var inputWrap = widget._inputWrapper || widget.wrapper;\n var inputLabel = widget._inputLabel;\n\n if (inputWrap) {\n inputWrap.toggleClass(INVALIDINPUT, !valid);\n inputWrap.toggleClass(VALIDINPUT, valid);\n }\n if (inputLabel) {\n inputLabel.toggleClass(INVALIDLABEL, !valid);\n }\n }\n\n if (wasValid !== valid) {\n var errorId = messageLabel ? messageLabel.attr(\"id\") : lbl.attr(\"id\");\n\n that._associateMessageContainer(input, errorId);\n\n if (this.options.validationSummary && this.options.validateOnBlur) {\n this.showValidationSummary();\n }\n }\n\n return valid;\n },\n\n hideMessages: function() {\n var that = this,\n className = \".\" + INVALIDMSG,\n element = that.element;\n\n that._disassociateMessageContainers();\n\n if (!element.is(INPUTSELECTOR)) {\n element.find(className).addClass(\"k-hidden\");\n } else {\n element.next(className).addClass(\"k-hidden\");\n }\n },\n\n reset: function() {\n var that = this,\n inputs = that.element.find(\".\" + INVALIDINPUT),\n labels = that.element.find(\".\" + INVALIDLABEL);\n\n that._errors = [];\n\n that.hideMessages();\n\n that.hideValidationSummary();\n\n inputs.removeAttr(ARIAINVALID);\n inputs.removeClass(INVALIDINPUT);\n labels.removeClass(INVALIDLABEL);\n },\n\n _findMessageContainer: function(fieldName) {\n var locators = kendo.ui.validator.messageLocators,\n name,\n containers = $();\n\n for (var idx = 0, length = this.element.length; idx < length; idx++) {\n containers = containers.add(searchForMessageContainer(this.element[idx].getElementsByTagName(\"*\"), fieldName));\n }\n\n for (name in locators) {\n containers = containers.add(locators[name].locate(this.element, fieldName));\n }\n\n return containers;\n },\n\n _decorateMessageContainer: function(container, fieldName) {\n var locators = kendo.ui.validator.messageLocators,\n name;\n\n container.addClass(INVALIDMSG)\n .attr(kendo.attr(\"for\"), fieldName || \"\");\n\n if (!container.attr(\"id\")) {\n container.attr(\"id\", fieldName + \"-error\");\n }\n\n for (name in locators) {\n locators[name].decorate(container, fieldName);\n }\n },\n\n _extractMessage: function(input, ruleKey) {\n var that = this,\n customMessage = that.options.messages[ruleKey],\n fieldName = input.attr(NAME),\n nonDefaultMessage;\n\n if (!kendo.ui.Validator.prototype.options.messages[ruleKey]) {\n nonDefaultMessage = kendo.isFunction(customMessage) ? customMessage(input) : customMessage;\n }\n\n customMessage = kendo.isFunction(customMessage) ? customMessage(input) : customMessage;\n\n return kendo.format(input.attr(kendo.attr(ruleKey + \"-msg\")) || input.attr(\"validationMessage\") || nonDefaultMessage || customMessage || input.attr(\"title\") || \"\",\n fieldName,\n input.attr(ruleKey) || input.attr(kendo.attr(ruleKey)));\n },\n\n _checkValidity: function(input) {\n var rules = this.options.rules,\n rule;\n\n for (rule in rules) {\n if (!rules[rule].call(this, input)) {\n return { valid: false, key: rule };\n }\n }\n\n return { valid: true };\n },\n\n errors: function() {\n var results = [],\n errors = this._errors,\n error;\n\n for (error in errors) {\n results.push(errors[error]);\n }\n return results;\n },\n\n setOptions: function(options) {\n if (options.validationSummary) {\n this.hideValidationSummary();\n }\n\n kendo.deepExtend(this.options, options);\n\n this.destroy();\n\n this.init(this.element, this.options);\n\n this._setEvents(this.options);\n },\n\n _getInputNames: function() {\n var that = this,\n inputs = that.element.find(that._inputSelector),\n sorted = [];\n\n for (var idx = 0, length = inputs.length; idx < length; idx++) {\n var input = $(inputs[idx]);\n\n if (hasAttribute(input, NAME)) {\n // Add current name if:\n // - not present so far;\n // - present but not part of CheckBoxGroup or RadioGroup.\n if(sorted.indexOf(input.attr(NAME)) === -1 ||\n (input.closest(\".k-checkbox-list\").length === 0 &&\n input.closest(\".k-radio-list\").length === 0)) {\n sorted.push(input.attr(NAME));\n }\n }\n }\n\n return sorted;\n },\n\n _associateMessageContainer: function(input, errorId) {\n var nextFocusable = kendo.getWidgetFocusableElement(input);\n\n if (!nextFocusable || !errorId) {\n return;\n }\n\n kendo.toggleAttribute(nextFocusable, ARIADESCRIBEDBY, errorId);\n },\n\n _disassociateMessageContainers: function() {\n var that = this,\n inputs = that.element.find(\".\" + INVALIDINPUT).addBack(),\n input, errorId;\n\n for (var i = 0; i < inputs.length; i += 1) {\n input = $(inputs[i]);\n\n if (input.is(\"input\")) {\n errorId = that._findMessageContainer(input.attr(NAME))\n .add(input.next(\".\" + INVALIDMSG))\n .attr(\"id\");\n\n that._associateMessageContainer(input, errorId);\n }\n }\n },\n\n _errorsByName: function() {\n var that = this,\n inputNames = that._getInputNames(),\n sorted = [];\n\n for (var i = 0; i < inputNames.length; i += 1) {\n var name = inputNames[i];\n\n if (that._errors[name]) {\n sorted.push({\n field: name,\n message: that._errors[name]\n });\n }\n }\n\n return sorted;\n },\n\n _renderSummary: function() {\n var that = this,\n options = this.options.validationSummary,\n element = this.element,\n prevElement = element.prev(),\n container;\n\n if (options.container) {\n container = $(options.container);\n } else if (prevElement && prevElement.hasClass(VALIDATIONSUMMARY)) {\n container = prevElement;\n } else {\n container = $(\"
    \").insertBefore(that.element);\n }\n\n container.addClass([VALIDATIONSUMMARY, MESSAGEBOX].join(\" \"));\n container.attr(\"role\", \"alert\");\n\n container.on(\"click\" + NS, proxy(that._summaryClick, that));\n\n return container;\n },\n\n _summaryClick: function(e) {\n e.preventDefault();\n\n var that = this,\n link = $(e.target),\n target = that.element.find(\"[name='\" + link.data(\"field\") + \"']\"),\n nextFocusable;\n\n if (!target.length) {\n return;\n }\n\n nextFocusable = kendo.getWidgetFocusableElement(target);\n\n if (nextFocusable) {\n nextFocusable.trigger(\"focus\");\n }\n },\n\n showValidationSummary: function() {\n var that = this,\n summary = that.validationSummary,\n errors = that._errorsByName(),\n errorsList;\n\n if (!summary) {\n summary = that.validationSummary = that._renderSummary();\n }\n\n errorsList = parseHtml(that._summaryTemplate({\n errors: errors\n }));\n\n summary.html(errorsList);\n\n summary.toggleClass(\"k-hidden\", !errors.length);\n },\n\n hideValidationSummary: function() {\n var that = this,\n summary = that.validationSummary;\n\n if (!summary) {\n return;\n }\n\n summary.addClass(\"k-hidden\");\n }\n });\n\n kendo.ui.plugin(Validator);\n})(window.kendo.jQuery);\n\nreturn window.kendo;\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n\n(function(f, define){\n define('kendo.userevents',[ \"./kendo.core\" ], f);\n})(function(){\n\nvar __meta__ = { // jshint ignore:line\n id: \"userevents\",\n name: \"User Events\",\n category: \"framework\",\n depends: [ \"core\" ],\n hidden: true\n};\n\n(function ($, undefined) {\n var kendo = window.kendo,\n support = kendo.support,\n Class = kendo.Class,\n Observable = kendo.Observable,\n now = Date.now,\n extend = $.extend,\n OS = support.mobileOS,\n invalidZeroEvents = OS && OS.android,\n DEFAULT_MIN_HOLD = 800,\n CLICK_DELAY = 300,\n DEFAULT_THRESHOLD = support.browser.msie ? 5 : 0, // WP8 and W8 are very sensitive and always report move.\n\n // UserEvents events\n PRESS = \"press\",\n HOLD = \"hold\",\n SELECT = \"select\",\n START = \"start\",\n MOVE = \"move\",\n END = \"end\",\n CANCEL = \"cancel\",\n TAP = \"tap\",\n DOUBLETAP = \"doubleTap\",\n RELEASE = \"release\",\n GESTURESTART = \"gesturestart\",\n GESTURECHANGE = \"gesturechange\",\n GESTUREEND = \"gestureend\",\n GESTURETAP = \"gesturetap\";\n\n var THRESHOLD = {\n \"api\": 0,\n \"touch\": 0,\n \"mouse\": 9,\n \"pointer\": 9\n };\n\n var ENABLE_GLOBAL_SURFACE = (!support.touch || support.mouseAndTouchPresent);\n\n function touchDelta(touch1, touch2) {\n var x1 = touch1.x.location,\n y1 = touch1.y.location,\n x2 = touch2.x.location,\n y2 = touch2.y.location,\n dx = x1 - x2,\n dy = y1 - y2;\n\n return {\n center: {\n x: (x1 + x2) / 2,\n y: (y1 + y2) / 2\n },\n\n distance: Math.sqrt(dx*dx + dy*dy)\n };\n }\n\n function getTouches(e) {\n var touches = [],\n originalEvent = e.originalEvent,\n currentTarget = e.currentTarget,\n idx = 0, length,\n changedTouches,\n touch;\n\n if (e.api) {\n touches.push({\n id: 2, // hardcoded ID for API call;\n event: e,\n target: e.target,\n currentTarget: e.target,\n location: e,\n type: \"api\"\n });\n }\n else if (e.type.match(/touch/)) {\n changedTouches = originalEvent ? originalEvent.changedTouches : [];\n for (length = changedTouches.length; idx < length; idx ++) {\n touch = changedTouches[idx];\n touches.push({\n location: touch,\n event: e,\n target: touch.target,\n currentTarget: currentTarget,\n id: touch.identifier,\n type: \"touch\"\n });\n }\n }\n else if (support.pointers || support.msPointers) {\n touches.push({\n location: originalEvent,\n event: e,\n target: e.target,\n currentTarget: currentTarget,\n id: originalEvent.pointerId,\n type: \"pointer\"\n });\n } else {\n touches.push({\n id: 1, // hardcoded ID for mouse event;\n event: e,\n target: e.target,\n currentTarget: currentTarget,\n location: e,\n type: \"mouse\"\n });\n }\n\n return touches;\n }\n\n var TouchAxis = Class.extend({\n init: function(axis, location) {\n var that = this;\n\n that.axis = axis;\n\n that._updateLocationData(location);\n\n that.startLocation = that.location;\n that.velocity = that.delta = 0;\n that.timeStamp = now();\n },\n\n move: function(location) {\n var that = this,\n offset = location[\"page\" + that.axis],\n timeStamp = now(),\n timeDelta = (timeStamp - that.timeStamp) || 1; // Firing manually events in tests can make this 0;\n\n if (!offset && invalidZeroEvents) {\n return;\n }\n\n that.delta = offset - that.location;\n\n that._updateLocationData(location);\n\n that.initialDelta = offset - that.startLocation;\n that.velocity = that.delta / timeDelta;\n that.timeStamp = timeStamp;\n },\n\n _updateLocationData: function(location) {\n var that = this, axis = that.axis;\n\n that.location = location[\"page\" + axis];\n that.client = location[\"client\" + axis];\n that.screen = location[\"screen\" + axis];\n }\n });\n\n var Touch = Class.extend({\n init: function(userEvents, target, touchInfo) {\n extend(this, {\n x: new TouchAxis(\"X\", touchInfo.location),\n y: new TouchAxis(\"Y\", touchInfo.location),\n type: touchInfo.type,\n useClickAsTap: userEvents.useClickAsTap,\n threshold: userEvents.threshold || THRESHOLD[touchInfo.type],\n userEvents: userEvents,\n target: target,\n currentTarget: touchInfo.currentTarget,\n initialTouch: touchInfo.target,\n id: touchInfo.id,\n pressEvent: touchInfo,\n _clicks: userEvents._clicks,\n supportDoubleTap: userEvents.supportDoubleTap,\n _moved: false,\n _finished: false\n });\n },\n\n press: function() {\n this._holdTimeout = setTimeout($.proxy(this, \"_hold\"), this.userEvents.minHold);\n this._trigger(PRESS, this.pressEvent);\n },\n\n _tap: function(touchInfo) {\n var that = this;\n that.userEvents._clicks++;\n if (that.userEvents._clicks == 1) {\n that._clickTimeout = setTimeout(function() {\n if (that.userEvents._clicks == 1) {\n that._trigger(TAP, touchInfo);\n }\n else {\n that._trigger(DOUBLETAP, touchInfo);\n }\n that.userEvents._clicks = 0;\n }, CLICK_DELAY);\n }\n },\n\n _hold: function() {\n this._trigger(HOLD, this.pressEvent);\n },\n\n move: function(touchInfo) {\n var that = this;\n var preventMove = touchInfo.type !== \"api\" && that.userEvents._shouldNotMove;\n\n if (that._finished || preventMove) { return; }\n\n that.x.move(touchInfo.location);\n that.y.move(touchInfo.location);\n\n if (!that._moved) {\n if (that._withinIgnoreThreshold()) {\n return;\n }\n\n if (!UserEvents.current || UserEvents.current === that.userEvents) {\n that._start(touchInfo);\n } else {\n return that.dispose();\n }\n }\n\n // Event handlers may cancel the drag in the START event handler, hence the double check for pressed.\n if (!that._finished) {\n that._trigger(MOVE, touchInfo);\n }\n },\n\n end: function(touchInfo) {\n this.endTime = now();\n\n if (this._finished) { return; }\n\n // Mark the object as finished if there are blocking operations in the event handlers (alert/confirm)\n this._finished = true;\n\n this._trigger(RELEASE, touchInfo); // Release should be fired before TAP (as click is after mouseup/touchend)\n\n if (this._moved) {\n this._trigger(END, touchInfo);\n } else {\n if (!this.useClickAsTap) {\n if (this.supportDoubleTap) {\n this._tap(touchInfo);\n }\n else {\n this._trigger(TAP, touchInfo);\n }\n }\n }\n\n clearTimeout(this._holdTimeout);\n\n this.dispose();\n },\n\n dispose: function() {\n var userEvents = this.userEvents,\n activeTouches = userEvents.touches;\n\n this._finished = true;\n this.pressEvent = null;\n clearTimeout(this._holdTimeout);\n\n activeTouches.splice($.inArray(this, activeTouches), 1);\n },\n\n skip: function() {\n this.dispose();\n },\n\n cancel: function() {\n this.dispose();\n },\n\n isMoved: function() {\n return this._moved;\n },\n\n _start: function(touchInfo) {\n clearTimeout(this._holdTimeout);\n\n this.startTime = now();\n this._moved = true;\n this._trigger(START, touchInfo);\n },\n\n _trigger: function(name, touchInfo) {\n var that = this,\n jQueryEvent = touchInfo.event,\n data = {\n touch: that,\n x: that.x,\n y: that.y,\n target: that.target,\n event: jQueryEvent\n };\n\n if(that.userEvents.notify(name, data)) {\n jQueryEvent.preventDefault();\n }\n },\n\n _withinIgnoreThreshold: function() {\n var xDelta = this.x.initialDelta,\n yDelta = this.y.initialDelta;\n\n return Math.sqrt(xDelta * xDelta + yDelta * yDelta) <= this.threshold;\n }\n });\n\n function withEachUpEvent(callback) {\n var downEvents = kendo.eventMap.up.split(\" \"),\n idx = 0,\n length = downEvents.length;\n\n for(; idx < length; idx ++) {\n callback(downEvents[idx]);\n }\n }\n\n var UserEvents = Observable.extend({\n init: function(element, options) {\n var that = this,\n filter,\n ns = kendo.guid();\n\n options = options || {};\n filter = that.filter = options.filter;\n that.threshold = options.threshold || DEFAULT_THRESHOLD;\n that.minHold = options.minHold || DEFAULT_MIN_HOLD;\n that.touches = [];\n that._maxTouches = options.multiTouch ? 2 : 1;\n that.allowSelection = options.allowSelection;\n that.captureUpIfMoved = options.captureUpIfMoved;\n that.useClickAsTap = !options.fastTap && !support.delayedClick();\n that.eventNS = ns;\n that._clicks = 0;\n that.supportDoubleTap = options.supportDoubleTap;\n\n element = $(element).handler(that);\n Observable.fn.init.call(that);\n\n extend(that, {\n element: element,\n // the touch events lock to the element anyway, so no need for the global setting\n surface: options.global && ENABLE_GLOBAL_SURFACE ? $(element[0].ownerDocument.documentElement) : $(options.surface || element),\n stopPropagation: options.stopPropagation,\n pressed: false\n });\n\n that.surface.handler(that)\n .on(kendo.applyEventMap(\"move\", ns), \"_move\")\n .on(kendo.applyEventMap(\"up cancel\", ns), \"_end\");\n\n element.on(kendo.applyEventMap(\"down\", ns), filter, \"_start\");\n\n if (that.useClickAsTap) {\n element.on(kendo.applyEventMap(\"click\", ns), filter, \"_click\");\n }\n\n if (support.pointers || support.msPointers) {\n //touch-action:none will not work for IE10\n if (support.browser.version < 11) {\n var defaultAction = \"pinch-zoom double-tap-zoom\";\n element.css(\"-ms-touch-action\", options.touchAction && options.touchAction != \"none\" ? defaultAction + \" \" + options.touchAction : defaultAction);\n } else {\n element.css(\"touch-action\", options.touchAction || \"none\");\n }\n }\n\n if (options.preventDragEvent) {\n element.on(kendo.applyEventMap(\"dragstart\", ns), kendo.preventDefault);\n }\n\n element.on(kendo.applyEventMap(\"mousedown\", ns), filter, { root: element }, \"_select\");\n\n if (that.captureUpIfMoved && support.eventCapture) {\n var surfaceElement = that.surface[0],\n preventIfMovingProxy = $.proxy(that.preventIfMoving, that);\n\n withEachUpEvent(function(eventName) {\n surfaceElement.addEventListener(eventName, preventIfMovingProxy, true);\n });\n }\n\n that.bind([\n PRESS,\n HOLD,\n TAP,\n DOUBLETAP,\n START,\n MOVE,\n END,\n RELEASE,\n CANCEL,\n GESTURESTART,\n GESTURECHANGE,\n GESTUREEND,\n GESTURETAP,\n SELECT\n ], options);\n },\n\n preventIfMoving: function(e) {\n if (this._isMoved()) {\n e.preventDefault();\n }\n },\n\n destroy: function() {\n var that = this;\n\n if (that._destroyed) {\n return;\n }\n\n that._destroyed = true;\n\n if (that.captureUpIfMoved && support.eventCapture) {\n var surfaceElement = that.surface[0];\n withEachUpEvent(function(eventName) {\n surfaceElement.removeEventListener(eventName, that.preventIfMoving);\n });\n }\n\n that.element.kendoDestroy(that.eventNS);\n that.surface.kendoDestroy(that.eventNS);\n that.element.removeData(\"handler\");\n that.surface.removeData(\"handler\");\n that._disposeAll();\n\n that.unbind();\n delete that.surface;\n delete that.element;\n delete that.currentTarget;\n },\n\n capture: function() {\n UserEvents.current = this;\n },\n\n cancel: function() {\n this._disposeAll();\n this.trigger(CANCEL);\n },\n\n notify: function(eventName, data) {\n var that = this,\n touches = that.touches;\n\n if (this._isMultiTouch()) {\n switch(eventName) {\n case MOVE:\n eventName = GESTURECHANGE;\n break;\n case END:\n eventName = GESTUREEND;\n break;\n case TAP:\n eventName = GESTURETAP;\n break;\n }\n\n extend(data, {touches: touches}, touchDelta(touches[0], touches[1]));\n }\n\n return this.trigger(eventName, extend(data, {type: eventName}));\n },\n\n // API\n press: function(x, y, target) {\n this._apiCall(\"_start\", x, y, target);\n },\n\n move: function(x, y) {\n this._apiCall(\"_move\", x, y);\n },\n\n end: function(x, y) {\n this._apiCall(\"_end\", x, y);\n },\n\n _isMultiTouch: function() {\n return this.touches.length > 1;\n },\n\n _maxTouchesReached: function() {\n return this.touches.length >= this._maxTouches;\n },\n\n _disposeAll: function() {\n var touches = this.touches;\n while (touches.length > 0) {\n touches.pop().dispose();\n }\n },\n\n _isMoved: function() {\n return $.grep(this.touches, function(touch) {\n return touch.isMoved();\n }).length;\n },\n\n _select: function(e) {\n if (!this.allowSelection || this.trigger(SELECT, { event: e })) {\n e.preventDefault();\n }\n },\n\n _start: function(e) {\n var that = this,\n idx = 0,\n filter = that.filter,\n target,\n touches = getTouches(e),\n length = touches.length,\n touch,\n which = e.which;\n\n if ((which && which > 1) || (that._maxTouchesReached())){\n return;\n }\n\n UserEvents.current = null;\n\n that.currentTarget = e.currentTarget;\n\n if (that.stopPropagation) {\n e.stopPropagation();\n }\n\n for (; idx < length; idx ++) {\n if (that._maxTouchesReached()) {\n break;\n }\n\n touch = touches[idx];\n\n if (filter) {\n target = $(touch.currentTarget); // target.is(filter) ? target : target.closest(filter, that.element);\n } else {\n target = that.element;\n }\n\n if (!target.length) {\n continue;\n }\n\n touch = new Touch(that, target, touch);\n that.touches.push(touch);\n touch.press();\n\n if (that._isMultiTouch()) {\n that.notify(\"gesturestart\", {});\n }\n }\n },\n\n _move: function(e) {\n this._eachTouch(\"move\", e);\n },\n\n _end: function(e) {\n this._eachTouch(\"end\", e);\n },\n\n _click: function(e) {\n var data = {\n touch: {\n initialTouch: e.target,\n target: $(e.currentTarget),\n endTime: now(),\n x: {\n location: e.pageX,\n client: e.clientX\n },\n y: {\n location: e.pageY,\n client: e.clientY\n }\n },\n x: e.pageX,\n y: e.pageY,\n target: $(e.currentTarget),\n event: e,\n type: \"tap\"\n };\n\n if (this.trigger(\"tap\", data)) {\n e.preventDefault();\n }\n },\n\n _eachTouch: function(methodName, e) {\n var that = this,\n dict = {},\n touches = getTouches(e),\n activeTouches = that.touches,\n idx,\n touch,\n touchInfo,\n matchingTouch;\n\n for (idx = 0; idx < activeTouches.length; idx ++) {\n touch = activeTouches[idx];\n dict[touch.id] = touch;\n }\n\n for (idx = 0; idx < touches.length; idx ++) {\n touchInfo = touches[idx];\n matchingTouch = dict[touchInfo.id];\n\n if (matchingTouch) {\n matchingTouch[methodName](touchInfo);\n }\n }\n },\n\n _apiCall: function(type, x, y, target) {\n this[type]({\n api: true,\n pageX: x,\n pageY: y,\n clientX: x,\n clientY: y,\n target: $(target || this.element)[0],\n stopPropagation: $.noop,\n preventDefault: $.noop\n });\n }\n });\n\n UserEvents.defaultThreshold = function(value) {\n DEFAULT_THRESHOLD = value;\n };\n\n UserEvents.minHold = function(value) {\n DEFAULT_MIN_HOLD = value;\n };\n\n kendo.getTouches = getTouches;\n kendo.touchDelta = touchDelta;\n kendo.UserEvents = UserEvents;\n })(window.kendo.jQuery);\n\nreturn window.kendo;\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n\n(function(f, define){\n define('kendo.draganddrop',[ \"./kendo.core\", \"./kendo.userevents\" ], f);\n})(function(){\n\nvar __meta__ = { // jshint ignore:line\n id: \"draganddrop\",\n name: \"Drag & drop\",\n category: \"framework\",\n description: \"Drag & drop functionality for any DOM element.\",\n depends: [ \"core\", \"userevents\" ]\n};\n\n(function ($, undefined) {\n var kendo = window.kendo,\n support = kendo.support,\n document = window.document,\n $window = $(window),\n Class = kendo.Class,\n Widget = kendo.ui.Widget,\n Observable = kendo.Observable,\n UserEvents = kendo.UserEvents,\n proxy = $.proxy,\n extend = $.extend,\n getOffset = kendo.getOffset,\n draggables = {},\n dropTargets = {},\n dropAreas = {},\n lastDropTarget,\n elementUnderCursor = kendo.elementUnderCursor,\n KEYUP = \"keyup\",\n CHANGE = \"change\",\n\n // Draggable events\n DRAGSTART = \"dragstart\",\n HOLD = \"hold\",\n DRAG = \"drag\",\n DRAGEND = \"dragend\",\n DRAGCANCEL = \"dragcancel\",\n HINTDESTROYED = \"hintDestroyed\",\n\n // DropTarget events\n DRAGENTER = \"dragenter\",\n DRAGLEAVE = \"dragleave\",\n DROP = \"drop\";\n\n function contains(parent, child) {\n try {\n return $.contains(parent, child) || parent == child;\n } catch (e) {\n return false;\n }\n }\n\n function numericCssPropery(element, property) {\n return parseInt(element.css(property), 10) || 0;\n }\n\n function within(value, range) {\n return Math.min(Math.max(value, range.min), range.max);\n }\n\n function containerBoundaries(container, element) {\n var offset = getOffset(container),\n outerWidth = kendo._outerWidth,\n outerHeight = kendo._outerHeight,\n minX = offset.left + numericCssPropery(container, \"borderLeftWidth\") + numericCssPropery(container, \"paddingLeft\"),\n minY = offset.top + numericCssPropery(container, \"borderTopWidth\") + numericCssPropery(container, \"paddingTop\"),\n maxX = minX + container.width() - outerWidth(element, true),\n maxY = minY + container.height() - outerHeight(element, true);\n\n return {\n x: { min: minX, max: maxX },\n y: { min: minY, max: maxY }\n };\n }\n\n function checkTarget(target, targets, areas) {\n var theTarget, theFilter, i = 0,\n targetLen = targets && targets.length,\n areaLen = areas && areas.length;\n\n while (target && target.parentNode) {\n for (i = 0; i < targetLen; i ++) {\n theTarget = targets[i];\n if (theTarget.element[0] === target) {\n return { target: theTarget, targetElement: target };\n }\n }\n\n for (i = 0; i < areaLen; i ++) {\n theFilter = areas[i];\n if ($.contains(theFilter.element[0], target) && support.matchesSelector.call(target, theFilter.options.filter)) {\n return { target: theFilter, targetElement: target };\n }\n }\n\n target = target.parentNode;\n }\n\n return undefined;\n }\n\n var TapCapture = Observable.extend({\n init: function(element, options) {\n var that = this,\n domElement = element[0];\n\n that.capture = false;\n\n if (domElement.addEventListener) {\n $.each(kendo.eventMap.down.split(\" \"), function() {\n domElement.addEventListener(this, proxy(that._press, that), true);\n });\n $.each(kendo.eventMap.up.split(\" \"), function() {\n domElement.addEventListener(this, proxy(that._release, that), true);\n });\n } else {\n $.each(kendo.eventMap.down.split(\" \"), function() {\n domElement.attachEvent(this, proxy(that._press, that));\n });\n $.each(kendo.eventMap.up.split(\" \"), function() {\n domElement.attachEvent(this, proxy(that._release, that));\n });\n }\n\n Observable.fn.init.call(that);\n\n that.bind([\"press\", \"release\"], options || {});\n },\n\n captureNext: function() {\n this.capture = true;\n },\n\n cancelCapture: function() {\n this.capture = false;\n },\n\n _press: function(e) {\n var that = this;\n that.trigger(\"press\");\n if (that.capture) {\n e.preventDefault();\n }\n },\n\n _release: function(e) {\n var that = this;\n that.trigger(\"release\");\n\n if (that.capture) {\n e.preventDefault();\n that.cancelCapture();\n }\n }\n });\n\n var PaneDimension = Observable.extend({\n init: function(options) {\n var that = this;\n Observable.fn.init.call(that);\n\n that.forcedEnabled = false;\n\n $.extend(that, options);\n\n that.scale = 1;\n\n if (that.horizontal) {\n that.measure = \"offsetWidth\";\n that.scrollSize = \"scrollWidth\";\n that.axis = \"x\";\n } else {\n that.measure = \"offsetHeight\";\n that.scrollSize = \"scrollHeight\";\n that.axis = \"y\";\n }\n },\n\n makeVirtual: function() {\n $.extend(this, {\n virtual: true,\n forcedEnabled: true,\n _virtualMin: 0,\n _virtualMax: 0\n });\n },\n\n virtualSize: function(min, max) {\n if (this._virtualMin !== min || this._virtualMax !== max) {\n this._virtualMin = min;\n this._virtualMax = max;\n this.update();\n }\n },\n\n outOfBounds: function(offset) {\n return offset > this.max || offset < this.min;\n },\n\n forceEnabled: function() {\n this.forcedEnabled = true;\n },\n\n getSize: function() {\n return this.container[0][this.measure];\n },\n\n getTotal: function() {\n return this.element[0][this.scrollSize];\n },\n\n rescale: function(scale) {\n this.scale = scale;\n },\n\n update: function(silent) {\n var that = this,\n total = that.virtual ? that._virtualMax : that.getTotal(),\n scaledTotal = total * that.scale,\n size = that.getSize();\n\n if (total === 0 && !that.forcedEnabled) {\n return; // we are not visible.\n }\n\n that.max = that.virtual ? -that._virtualMin : 0;\n that.size = size;\n that.total = scaledTotal;\n that.min = Math.min(that.max, size - scaledTotal);\n that.minScale = size / total;\n that.centerOffset = (scaledTotal - size) / 2;\n\n that.enabled = that.forcedEnabled || (scaledTotal > size);\n\n if (!silent) {\n that.trigger(CHANGE, that);\n }\n }\n });\n\n var PaneDimensions = Observable.extend({\n init: function(options) {\n var that = this;\n\n Observable.fn.init.call(that);\n\n that.x = new PaneDimension(extend({horizontal: true}, options));\n that.y = new PaneDimension(extend({horizontal: false}, options));\n that.container = options.container;\n that.forcedMinScale = options.minScale;\n that.maxScale = options.maxScale || 100;\n\n that.bind(CHANGE, options);\n },\n\n rescale: function(newScale) {\n this.x.rescale(newScale);\n this.y.rescale(newScale);\n this.refresh();\n },\n\n centerCoordinates: function() {\n return { x: Math.min(0, -this.x.centerOffset), y: Math.min(0, -this.y.centerOffset) };\n },\n\n refresh: function() {\n var that = this;\n that.x.update();\n that.y.update();\n that.enabled = that.x.enabled || that.y.enabled;\n that.minScale = that.forcedMinScale || Math.min(that.x.minScale, that.y.minScale);\n that.fitScale = Math.max(that.x.minScale, that.y.minScale);\n that.trigger(CHANGE);\n }\n });\n\n var PaneAxis = Observable.extend({\n init: function(options) {\n var that = this;\n extend(that, options);\n Observable.fn.init.call(that);\n },\n\n outOfBounds: function() {\n return this.dimension.outOfBounds(this.movable[this.axis]);\n },\n\n dragMove: function(delta) {\n var that = this,\n dimension = that.dimension,\n axis = that.axis,\n movable = that.movable,\n position = movable[axis] + delta;\n\n if (!dimension.enabled) {\n return;\n }\n\n if ((position < dimension.min && delta < 0) || (position > dimension.max && delta > 0)) {\n delta *= that.resistance;\n }\n\n movable.translateAxis(axis, delta);\n that.trigger(CHANGE, that);\n }\n });\n\n var Pane = Class.extend({\n\n init: function(options) {\n var that = this,\n x,\n y,\n resistance,\n movable;\n\n extend(that, {elastic: true}, options);\n\n resistance = that.elastic ? 0.5 : 0;\n movable = that.movable;\n\n that.x = x = new PaneAxis({\n axis: \"x\",\n dimension: that.dimensions.x,\n resistance: resistance,\n movable: movable\n });\n\n that.y = y = new PaneAxis({\n axis: \"y\",\n dimension: that.dimensions.y,\n resistance: resistance,\n movable: movable\n });\n\n that.userEvents.bind([\"press\", \"move\", \"end\", \"gesturestart\", \"gesturechange\"], {\n gesturestart: function(e) {\n that.gesture = e;\n that.offset = that.dimensions.container.offset();\n },\n\n press: function(e) {\n if ($(e.event.target).closest(\"a\").is(\"[data-navigate-on-press=true]\")) {\n e.sender.cancel();\n }\n },\n\n gesturechange: function(e) {\n var previousGesture = that.gesture,\n previousCenter = previousGesture.center,\n\n center = e.center,\n\n scaleDelta = e.distance / previousGesture.distance,\n\n minScale = that.dimensions.minScale,\n maxScale = that.dimensions.maxScale,\n coordinates;\n\n if (movable.scale <= minScale && scaleDelta < 1) {\n // Resist shrinking. Instead of shrinking from 1 to 0.5, it will shrink to 0.5 + (1 /* minScale */ - 0.5) * 0.8 = 0.9;\n scaleDelta += (1 - scaleDelta) * 0.8;\n }\n\n if (movable.scale * scaleDelta >= maxScale) {\n scaleDelta = maxScale / movable.scale;\n }\n\n var offsetX = movable.x + that.offset.left,\n offsetY = movable.y + that.offset.top;\n\n coordinates = {\n x: (offsetX - previousCenter.x) * scaleDelta + center.x - offsetX,\n y: (offsetY - previousCenter.y) * scaleDelta + center.y - offsetY\n };\n\n movable.scaleWith(scaleDelta);\n\n x.dragMove(coordinates.x);\n y.dragMove(coordinates.y);\n\n that.dimensions.rescale(movable.scale);\n that.gesture = e;\n e.preventDefault();\n },\n\n move: function(e) {\n if (e.event.target.tagName.match(/textarea|input/i)) {\n return;\n }\n\n if (x.dimension.enabled || y.dimension.enabled) {\n x.dragMove(e.x.delta);\n y.dragMove(e.y.delta);\n e.preventDefault();\n } else {\n e.touch.skip();\n }\n },\n\n end: function(e) {\n e.preventDefault();\n }\n });\n }\n });\n\n var TRANSFORM_STYLE = support.transitions.prefix + \"Transform\",\n translate;\n\n\n if (support.hasHW3D) {\n translate = function(x, y, scale) {\n return \"translate3d(\" + x + \"px,\" + y +\"px,0) scale(\" + scale + \")\";\n };\n } else {\n translate = function(x, y, scale) {\n return \"translate(\" + x + \"px,\" + y +\"px) scale(\" + scale + \")\";\n };\n }\n\n var Movable = Observable.extend({\n init: function(element) {\n var that = this;\n\n Observable.fn.init.call(that);\n\n that.element = $(element);\n that.element[0].style.webkitTransformOrigin = \"left top\";\n that.x = 0;\n that.y = 0;\n that.scale = 1;\n that._saveCoordinates(translate(that.x, that.y, that.scale));\n },\n\n translateAxis: function(axis, by) {\n this[axis] += by;\n this.refresh();\n },\n\n scaleTo: function(scale) {\n this.scale = scale;\n this.refresh();\n },\n\n scaleWith: function(scaleDelta) {\n this.scale *= scaleDelta;\n this.refresh();\n },\n\n translate: function(coordinates) {\n this.x += coordinates.x;\n this.y += coordinates.y;\n this.refresh();\n },\n\n moveAxis: function(axis, value) {\n this[axis] = value;\n this.refresh();\n },\n\n moveTo: function(coordinates) {\n extend(this, coordinates);\n this.refresh();\n },\n\n refresh: function() {\n var that = this,\n x = that.x,\n y = that.y,\n newCoordinates;\n\n if (that.round) {\n x = Math.round(x);\n y = Math.round(y);\n }\n\n newCoordinates = translate(x, y, that.scale);\n\n if (newCoordinates != that.coordinates) {\n if (kendo.support.browser.msie && kendo.support.browser.version < 10) {\n that.element[0].style.position = \"absolute\";\n that.element[0].style.left = that.x + \"px\";\n that.element[0].style.top = that.y + \"px\";\n\n } else {\n that.element[0].style[TRANSFORM_STYLE] = newCoordinates;\n }\n that._saveCoordinates(newCoordinates);\n that.trigger(CHANGE);\n }\n },\n\n _saveCoordinates: function(coordinates) {\n this.coordinates = coordinates;\n }\n });\n\n function destroyDroppable(collection, widget) {\n var groupName = widget.options.group,\n droppables = collection[groupName],\n i;\n\n Widget.fn.destroy.call(widget);\n\n if (droppables.length > 1) {\n for (i = 0; i < droppables.length; i++) {\n if (droppables[i] == widget) {\n droppables.splice(i, 1);\n break;\n }\n }\n } else {\n droppables.length = 0; // WTF, porting this from the previous destroyGroup\n delete collection[groupName];\n }\n }\n\n var DropTarget = Widget.extend({\n init: function(element, options) {\n var that = this;\n\n Widget.fn.init.call(that, element, options);\n\n var group = that.options.group;\n\n if (!(group in dropTargets)) {\n dropTargets[group] = [ that ];\n } else {\n dropTargets[group].push( that );\n }\n },\n\n events: [\n DRAGENTER,\n DRAGLEAVE,\n DROP\n ],\n\n options: {\n name: \"DropTarget\",\n group: \"default\"\n },\n\n destroy: function() {\n destroyDroppable(dropTargets, this);\n },\n\n _trigger: function(eventName, e) {\n var that = this,\n draggable = draggables[that.options.group];\n\n if (draggable) {\n return that.trigger(eventName, extend({}, e.event, {\n draggable: draggable,\n dropTarget: e.dropTarget\n }));\n }\n },\n\n _over: function(e) {\n this._trigger(DRAGENTER, e);\n },\n\n _out: function(e) {\n this._trigger(DRAGLEAVE, e);\n },\n\n _drop: function(e) {\n var that = this,\n draggable = draggables[that.options.group];\n\n if (draggable) {\n draggable.dropped = !that._trigger(DROP, e);\n }\n }\n });\n\n DropTarget.destroyGroup = function(groupName) {\n var group = dropTargets[groupName] || dropAreas[groupName],\n i;\n\n if (group) {\n for (i = 0; i < group.length; i++) {\n Widget.fn.destroy.call(group[i]);\n }\n\n group.length = 0;\n delete dropTargets[groupName];\n delete dropAreas[groupName];\n }\n };\n\n DropTarget._cache = dropTargets;\n\n var DropTargetArea = DropTarget.extend({\n init: function(element, options) {\n var that = this;\n\n Widget.fn.init.call(that, element, options);\n\n var group = that.options.group;\n\n if (!(group in dropAreas)) {\n dropAreas[group] = [ that ];\n } else {\n dropAreas[group].push( that );\n }\n },\n\n destroy: function() {\n destroyDroppable(dropAreas, this);\n },\n\n options: {\n name: \"DropTargetArea\",\n group: \"default\",\n filter: null\n }\n });\n\n var Draggable = Widget.extend({\n init: function (element, options) {\n var that = this;\n\n Widget.fn.init.call(that, element, options);\n\n that._activated = false;\n\n that.userEvents = new UserEvents(that.element, {\n global: true,\n allowSelection: true,\n filter: that.options.filter,\n threshold: that.options.distance,\n start: proxy(that._start, that),\n hold: proxy(that._hold, that),\n move: proxy(that._drag, that),\n end: proxy(that._end, that),\n cancel: proxy(that._cancel, that),\n select: proxy(that._select, that)\n });\n\n if (kendo.support.touch) {\n that.element.find(that.options.filter).css('touch-action', 'none');\n }\n\n that._afterEndHandler = proxy(that._afterEnd, that);\n that._captureEscape = proxy(that._captureEscape, that);\n },\n\n events: [\n HOLD,\n DRAGSTART,\n DRAG,\n DRAGEND,\n DRAGCANCEL,\n HINTDESTROYED\n ],\n\n options: {\n name: \"Draggable\",\n distance: ( kendo.support.touch ? 0 : 5),\n group: \"default\",\n cursorOffset: null,\n axis: null,\n container: null,\n filter: null,\n ignore: null,\n holdToDrag: false,\n autoScroll: false,\n dropped: false\n },\n\n cancelHold: function() {\n this._activated = false;\n },\n\n _captureEscape: function(e) {\n var that = this;\n\n if (e.keyCode === kendo.keys.ESC) {\n that._trigger(DRAGCANCEL, { event: e });\n that.userEvents.cancel();\n }\n },\n\n _updateHint: function(e) {\n var that = this,\n coordinates,\n options = that.options,\n boundaries = that.boundaries,\n axis = options.axis,\n cursorOffset = that.options.cursorOffset;\n\n if (cursorOffset) {\n coordinates = { left: e.x.location + cursorOffset.left, top: e.y.location + cursorOffset.top };\n } else {\n that.hintOffset.left += e.x.delta;\n that.hintOffset.top += e.y.delta;\n coordinates = $.extend({}, that.hintOffset);\n }\n\n if (boundaries) {\n coordinates.top = within(coordinates.top, boundaries.y);\n coordinates.left = within(coordinates.left, boundaries.x);\n }\n\n if (axis === \"x\") {\n delete coordinates.top;\n } else if (axis === \"y\") {\n delete coordinates.left;\n }\n\n that.hint.css(coordinates);\n },\n\n _shouldIgnoreTarget: function(target) {\n var ignoreSelector = this.options.ignore;\n return ignoreSelector && $(target).is(ignoreSelector);\n },\n\n _select: function(e) {\n if (!this._shouldIgnoreTarget(e.event.target)) {\n e.preventDefault();\n }\n },\n\n _start: function(e) {\n var that = this,\n options = that.options,\n container = options.container ? $(options.container): null,\n hint = options.hint;\n\n if (this._shouldIgnoreTarget(e.touch.initialTouch) || (options.holdToDrag && !that._activated)) {\n that.userEvents.cancel();\n return;\n }\n\n that.currentTarget = e.target;\n that.currentTargetOffset = getOffset(that.currentTarget);\n\n if (hint) {\n if (that.hint) {\n that.hint.stop(true, true).remove();\n }\n\n that.hint = kendo.isFunction(hint) ? $(hint.call(that, that.currentTarget)) : hint;\n\n var offset = getOffset(that.currentTarget);\n that.hintOffset = offset;\n\n that.hint.css( {\n position: \"absolute\",\n zIndex: 20000, // the Window's z-index is 10000 and can be raised because of z-stacking\n left: offset.left,\n top: offset.top\n })\n .appendTo(document.body);\n\n that.angular(\"compile\", function(){\n that.hint.removeAttr(\"ng-repeat\");\n var scopeTarget = $(e.target);\n\n while (!scopeTarget.data(\"$$kendoScope\") && scopeTarget.length) {\n scopeTarget = scopeTarget.parent();\n }\n\n return {\n elements: that.hint.get(),\n scopeFrom: scopeTarget.data(\"$$kendoScope\")\n };\n });\n }\n\n draggables[options.group] = that;\n\n that.dropped = false;\n\n if (container) {\n that.boundaries = containerBoundaries(container, that.hint);\n }\n\n $(document).on(KEYUP, that._captureEscape);\n\n if (that._trigger(DRAGSTART, e)) {\n that.userEvents.cancel();\n that._afterEnd();\n }\n\n that.userEvents.capture();\n },\n\n _hold: function(e) {\n this.currentTarget = e.target;\n\n if (this._trigger(HOLD, e)) {\n this.userEvents.cancel();\n } else {\n this._activated = true;\n }\n },\n\n _drag: function(e) {\n e.preventDefault();\n\n var cursorElement = this._elementUnderCursor(e);\n\n if (this.options.autoScroll && this._cursorElement !== cursorElement) {\n this._scrollableParent = findScrollableParent(cursorElement);\n this._cursorElement = cursorElement;\n }\n\n this._lastEvent = e;\n this._processMovement(e, cursorElement);\n\n if (this.options.autoScroll) {\n // chrome seems to trigger mousemove when mouse is moved outside of the window (over the Chrome), too.\n if (this._scrollableParent[0]) {\n var velocity = autoScrollVelocity(e.x.location, e.y.location, scrollableViewPort(this._scrollableParent));\n\n\n this._scrollCompenstation = $.extend({}, this.hintOffset);\n this._scrollVelocity = velocity;\n\n if (velocity.y === 0 && velocity.x === 0) {\n clearInterval(this._scrollInterval);\n this._scrollInterval = null;\n } else if(!this._scrollInterval) {\n this._scrollInterval = setInterval($.proxy(this, \"_autoScroll\"), 50);\n }\n }\n }\n\n if (this.hint) {\n this._updateHint(e);\n }\n },\n\n _processMovement: function(e, cursorElement) {\n this._withDropTarget(cursorElement, function(target, targetElement) {\n if (!target) {\n if (lastDropTarget) {\n lastDropTarget._trigger(DRAGLEAVE, extend(e, { dropTarget: $(lastDropTarget.targetElement) }));\n lastDropTarget = null;\n }\n return;\n }\n\n if (lastDropTarget) {\n if (targetElement === lastDropTarget.targetElement) {\n return;\n }\n\n lastDropTarget._trigger(DRAGLEAVE, extend(e, { dropTarget: $(lastDropTarget.targetElement) }));\n }\n\n target._trigger(DRAGENTER, extend(e, { dropTarget: $(targetElement) }));\n lastDropTarget = extend(target, { targetElement: targetElement });\n });\n\n this._trigger(DRAG, extend(e, { dropTarget: lastDropTarget, elementUnderCursor: cursorElement }));\n },\n\n _autoScroll: function() {\n var parent = this._scrollableParent[0],\n velocity = this._scrollVelocity,\n compensation = this._scrollCompenstation;\n\n if (!parent) {\n return;\n }\n\n var cursorElement = this._elementUnderCursor(this._lastEvent);\n this._processMovement(this._lastEvent, cursorElement);\n\n var yIsScrollable, xIsScrollable;\n\n var isRootNode = parent === scrollableRoot()[0];\n\n if (isRootNode) {\n yIsScrollable = document.body.scrollHeight > $window.height();\n xIsScrollable = document.body.scrollWidth > $window.width();\n } else {\n yIsScrollable = parent.offsetHeight <= parent.scrollHeight;\n xIsScrollable = parent.offsetWidth <= parent.scrollWidth;\n }\n\n var yDelta = parent.scrollTop + velocity.y;\n var yInBounds = yIsScrollable && yDelta > 0 && yDelta < parent.scrollHeight;\n\n var xDelta = parent.scrollLeft + velocity.x;\n var xInBounds = xIsScrollable && xDelta > 0 && xDelta < parent.scrollWidth;\n\n if (yInBounds) {\n parent.scrollTop += velocity.y;\n } else if (yIsScrollable && yDelta < 0) {\n parent.scrollTop = 0;\n }\n\n if (xInBounds) {\n parent.scrollLeft += velocity.x;\n } else if (xIsScrollable && xDelta < 0) {\n parent.scrollLeft = 0;\n }\n\n if (this.hint && isRootNode && (xInBounds || yInBounds)) {\n if (yInBounds) {\n compensation.top += velocity.y;\n }\n\n if (xInBounds) {\n compensation.left += velocity.x;\n }\n\n this.hint.css(compensation);\n }\n },\n\n _end: function(e) {\n this._withDropTarget(this._elementUnderCursor(e), function(target, targetElement) {\n if (target) {\n target._drop(extend({}, e, { dropTarget: $(targetElement) }));\n lastDropTarget = null;\n }\n });\n\n clearInterval(this._scrollInterval);\n this._scrollInterval = null;\n this._cancel(this._trigger(DRAGEND, e));\n },\n\n _cancel: function(isDefaultPrevented) {\n var that = this;\n\n that._scrollableParent = null;\n this._cursorElement = null;\n clearInterval(this._scrollInterval);\n that._activated = false;\n\n if (that.hint && !that.dropped) {\n setTimeout(function() {\n that.hint.stop(true, true);\n\n if (isDefaultPrevented) {\n that._afterEndHandler();\n } else {\n that.hint.animate(that.currentTargetOffset, \"fast\", that._afterEndHandler);\n }\n }, 0);\n\n } else {\n that._afterEnd();\n }\n },\n\n _trigger: function(eventName, e) {\n var that = this;\n\n return that.trigger(\n eventName, extend(\n {},\n e.event,\n {\n x: e.x,\n y: e.y,\n currentTarget: that.currentTarget,\n initialTarget: e.touch ? e.touch.initialTouch : null,\n dropTarget: e.dropTarget,\n elementUnderCursor: e.elementUnderCursor\n }\n ));\n },\n\n _elementUnderCursor: function(e) {\n var target = elementUnderCursor(e),\n hint = this.hint;\n\n if (hint && contains(hint[0], target)) {\n hint.hide();\n target = elementUnderCursor(e);\n // IE8 does not return the element in iframe from first attempt\n if (!target) {\n target = elementUnderCursor(e);\n }\n hint.show();\n }\n\n return target;\n },\n\n _withDropTarget: function(element, callback) {\n var result,\n group = this.options.group,\n targets = dropTargets[group],\n areas = dropAreas[group];\n\n if (targets && targets.length || areas && areas.length) {\n result = checkTarget(element, targets, areas);\n\n if (result) {\n callback(result.target, result.targetElement);\n } else {\n callback();\n }\n }\n },\n\n destroy: function() {\n var that = this;\n\n Widget.fn.destroy.call(that);\n\n that._afterEnd();\n\n that.userEvents.destroy();\n\n this._scrollableParent = null;\n this._cursorElement = null;\n clearInterval(this._scrollInterval);\n\n that.currentTarget = null;\n },\n\n _afterEnd: function() {\n var that = this;\n\n if (that.hint) {\n that.hint.remove();\n }\n\n delete draggables[that.options.group];\n\n that.trigger(\"destroy\");\n that.trigger(HINTDESTROYED);\n $(document).off(KEYUP, that._captureEscape);\n }\n });\n\n kendo.ui.plugin(DropTarget);\n kendo.ui.plugin(DropTargetArea);\n kendo.ui.plugin(Draggable);\n kendo.TapCapture = TapCapture;\n kendo.containerBoundaries = containerBoundaries;\n\n extend(kendo.ui, {\n Pane: Pane,\n PaneDimensions: PaneDimensions,\n Movable: Movable\n });\n\n function scrollableViewPort(element) {\n var root = scrollableRoot()[0],\n offset,\n top,\n left;\n\n if (element[0] === root) {\n top = root.scrollTop;\n left = root.scrollLeft;\n\n return {\n top: top,\n left: left,\n bottom: top + $window.height(),\n right: left + $window.width()\n };\n } else {\n offset = element.offset();\n offset.bottom = offset.top + element.height();\n offset.right = offset.left + element.width();\n return offset;\n }\n }\n\n function scrollableRoot() {\n return $(kendo.support.browser.edge || kendo.support.browser.safari ? document.body : document.documentElement);\n }\n\n function findScrollableParent(element) {\n var root = scrollableRoot();\n\n if (!element || element === document.body || element === document.documentElement) {\n return root;\n }\n\n var parent = $(element)[0];\n\n while (parent && !kendo.isScrollable(parent) && parent !== document.body) {\n parent = parent.parentNode;\n }\n\n if (parent === document.body) {\n return root;\n }\n\n return $(parent);\n }\n\n function autoScrollVelocity(mouseX, mouseY, rect) {\n var velocity = { x: 0, y: 0 };\n\n var AUTO_SCROLL_AREA = 50;\n\n if (mouseX - rect.left < AUTO_SCROLL_AREA) {\n velocity.x = -(AUTO_SCROLL_AREA - (mouseX - rect.left));\n } else if (rect.right - mouseX < AUTO_SCROLL_AREA) {\n velocity.x = AUTO_SCROLL_AREA - (rect.right - mouseX);\n }\n\n if (mouseY - rect.top < AUTO_SCROLL_AREA) {\n velocity.y = -(AUTO_SCROLL_AREA - (mouseY - rect.top));\n } else if (rect.bottom - mouseY < AUTO_SCROLL_AREA) {\n velocity.y = AUTO_SCROLL_AREA - (rect.bottom - mouseY);\n }\n\n return velocity;\n }\n\n // export for testing\n kendo.ui.Draggable.utils = {\n autoScrollVelocity: autoScrollVelocity,\n scrollableViewPort: scrollableViewPort,\n findScrollableParent: findScrollableParent\n };\n\n })(window.kendo.jQuery);\n\nreturn window.kendo;\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n\n(function(f, define){\n define('kendo.mobile.scroller',[ \"./kendo.fx\", \"./kendo.draganddrop\" ], f);\n})(function(){\n\nvar __meta__ = { // jshint ignore:line\n id: \"mobile.scroller\",\n name: \"Scroller\",\n category: \"mobile\",\n description: \"The Kendo Mobile Scroller widget enables touch friendly kinetic scrolling for the contents of a given DOM element.\",\n depends: [ \"fx\", \"draganddrop\" ]\n};\n\n(function($, undefined) {\n var kendo = window.kendo,\n mobile = kendo.mobile,\n fx = kendo.effects,\n ui = mobile.ui,\n proxy = $.proxy,\n extend = $.extend,\n Widget = ui.Widget,\n Class = kendo.Class,\n Movable = kendo.ui.Movable,\n Pane = kendo.ui.Pane,\n PaneDimensions = kendo.ui.PaneDimensions,\n Transition = fx.Transition,\n Animation = fx.Animation,\n abs = Math.abs,\n SNAPBACK_DURATION = 500,\n SCROLLBAR_OPACITY = 0.7,\n FRICTION = 0.96,\n VELOCITY_MULTIPLIER = 10,\n MAX_VELOCITY = 55,\n OUT_OF_BOUNDS_FRICTION = 0.5,\n ANIMATED_SCROLLER_PRECISION = 5,\n RELEASECLASS = \"km-scroller-release\",\n REFRESHCLASS = \"km-scroller-refresh\",\n PULL = \"pull\",\n CHANGE = \"change\",\n RESIZE = \"resize\",\n SCROLL = \"scroll\",\n MOUSE_WHEEL_ID = 2;\n\n var ZoomSnapBack = Animation.extend({\n init: function(options) {\n var that = this;\n Animation.fn.init.call(that);\n extend(that, options);\n\n that.userEvents.bind(\"gestureend\", proxy(that.start, that));\n that.tapCapture.bind(\"press\", proxy(that.cancel, that));\n },\n\n enabled: function() {\n return this.movable.scale < this.dimensions.minScale;\n },\n\n done: function() {\n return this.dimensions.minScale - this.movable.scale < 0.01;\n },\n\n tick: function() {\n var movable = this.movable;\n movable.scaleWith(1.1);\n this.dimensions.rescale(movable.scale);\n },\n\n onEnd: function() {\n var movable = this.movable;\n movable.scaleTo(this.dimensions.minScale);\n this.dimensions.rescale(movable.scale);\n }\n });\n\n var DragInertia = Animation.extend({\n init: function(options) {\n var that = this;\n\n Animation.fn.init.call(that);\n\n extend(that, options, {\n transition: new Transition({\n axis: options.axis,\n movable: options.movable,\n onEnd: function() { that._end(); }\n })\n });\n\n that.tapCapture.bind(\"press\", function() { that.cancel(); });\n that.userEvents.bind(\"end\", proxy(that.start, that));\n that.userEvents.bind(\"gestureend\", proxy(that.start, that));\n that.userEvents.bind(\"tap\", proxy(that.onEnd, that));\n },\n\n onCancel: function() {\n this.transition.cancel();\n },\n\n freeze: function(location) {\n var that = this;\n that.cancel();\n that._moveTo(location);\n },\n\n onEnd: function() {\n var that = this;\n if (that.paneAxis.outOfBounds()) {\n that._snapBack();\n } else {\n that._end();\n }\n },\n\n done: function() {\n return abs(this.velocity) < 1;\n },\n\n start: function(e) {\n var that = this,\n velocity;\n\n if (!that.dimension.enabled) { return; }\n\n if (that.paneAxis.outOfBounds()) {\n if(that.transition._started){\n that.transition.cancel();\n that.velocity = Math.min(e.touch[that.axis].velocity * that.velocityMultiplier, MAX_VELOCITY);\n\n Animation.fn.start.call(that);\n }else{\n that._snapBack();\n }\n } else {\n velocity = e.touch.id === MOUSE_WHEEL_ID ? 0 : e.touch[that.axis].velocity;\n that.velocity = Math.max(Math.min(velocity * that.velocityMultiplier, MAX_VELOCITY), -MAX_VELOCITY);\n\n that.tapCapture.captureNext();\n Animation.fn.start.call(that);\n }\n },\n\n tick: function() {\n var that = this,\n dimension = that.dimension,\n friction = that.paneAxis.outOfBounds() ? OUT_OF_BOUNDS_FRICTION : that.friction,\n delta = (that.velocity *= friction),\n location = that.movable[that.axis] + delta;\n\n if (!that.elastic && dimension.outOfBounds(location)) {\n location = Math.max(Math.min(location, dimension.max), dimension.min);\n that.velocity = 0;\n }\n\n that.movable.moveAxis(that.axis, location);\n },\n\n _end: function() {\n this.tapCapture.cancelCapture();\n this.end();\n },\n\n _snapBack: function() {\n var that = this,\n dimension = that.dimension,\n snapBack = that.movable[that.axis] > dimension.max ? dimension.max : dimension.min;\n that._moveTo(snapBack);\n },\n\n _moveTo: function(location) {\n this.transition.moveTo({ location: location, duration: SNAPBACK_DURATION, ease: Transition.easeOutExpo });\n }\n });\n\n var AnimatedScroller = Animation.extend({\n init: function(options) {\n var that = this;\n\n kendo.effects.Animation.fn.init.call(this);\n\n extend(that, options, {\n origin: {},\n destination: {},\n offset: {}\n });\n },\n\n tick: function() {\n this._updateCoordinates();\n this.moveTo(this.origin);\n },\n\n done: function() {\n return abs(this.offset.y) < ANIMATED_SCROLLER_PRECISION && abs(this.offset.x) < ANIMATED_SCROLLER_PRECISION;\n },\n\n onEnd: function() {\n this.moveTo(this.destination);\n if (this.callback) {\n this.callback.call();\n }\n },\n\n setCoordinates: function(from, to) {\n this.offset = {};\n this.origin = from;\n this.destination = to;\n },\n\n setCallback: function(callback) {\n if (callback && kendo.isFunction(callback)) {\n this.callback = callback;\n } else {\n callback = undefined;\n }\n },\n\n _updateCoordinates: function() {\n this.offset = {\n x: (this.destination.x - this.origin.x) / 4,\n y: (this.destination.y - this.origin.y) / 4\n };\n\n this.origin = {\n y: this.origin.y + this.offset.y,\n x: this.origin.x + this.offset.x\n };\n }\n });\n\n var ScrollBar = Class.extend({\n init: function(options) {\n var that = this,\n horizontal = options.axis === \"x\",\n element = $('
    ');\n\n if(horizontal) {\n element.attr(\"aria-orientation\", \"horizontal\");\n }\n\n extend(that, options, {\n element: element,\n elementSize: 0,\n movable: new Movable(element),\n scrollMovable: options.movable,\n alwaysVisible: options.alwaysVisible,\n size: horizontal ? \"width\" : \"height\"\n });\n\n that.scrollMovable.bind(CHANGE, proxy(that.refresh, that));\n that.container.append(element);\n if (options.alwaysVisible) {\n that.show();\n }\n },\n\n refresh: function() {\n var that = this,\n axis = that.axis,\n dimension = that.dimension,\n paneSize = dimension.size,\n scrollMovable = that.scrollMovable,\n sizeRatio = paneSize / dimension.total,\n position = Math.round(-scrollMovable[axis] * sizeRatio),\n size = Math.round(paneSize * sizeRatio);\n\n if (sizeRatio >= 1) {\n this.element.css(\"display\", \"none\");\n } else {\n this.element.css(\"display\", \"\");\n }\n\n if (position + size > paneSize) {\n size = paneSize - position;\n } else if (position < 0) {\n size += position;\n position = 0;\n }\n\n if (that.elementSize != size) {\n that.element.css(that.size, size + \"px\");\n that.elementSize = size;\n }\n\n that._ariaValue(position, dimension.size - that.elementSize);\n\n that.movable.moveAxis(axis, position);\n },\n\n show: function() {\n this.element.css({opacity: SCROLLBAR_OPACITY, visibility: \"visible\"});\n },\n\n hide: function() {\n if (!this.alwaysVisible) {\n this.element.css({opacity: 0});\n }\n },\n\n _ariaValue: function(current, total) {\n var element = this.element;\n\n if(current > total) {\n current = total;\n }\n\n element.attr(\"aria-valuemax\", total);\n element.attr(\"aria-valuenow\", current);\n }\n });\n\n var Scroller = Widget.extend({\n init: function(element, options) {\n var that = this;\n Widget.fn.init.call(that, element, options);\n\n element = that.element;\n\n that._native = that.options.useNative && kendo.support.hasNativeScrolling;\n if (that._native) {\n element.addClass(\"km-native-scroller\")\n .prepend('
    ');\n\n extend(that, {\n scrollElement: element,\n fixedContainer: element.children().first()\n });\n\n return;\n }\n\n element\n .css(\"overflow\", \"hidden\")\n .addClass(\"km-scroll-wrapper\")\n .wrapInner('
    ')\n .prepend('
    ');\n\n var inner = element.children().eq(1),\n\n tapCapture = new kendo.TapCapture(element),\n\n movable = new Movable(inner),\n\n dimensions = new PaneDimensions({\n element: inner,\n container: element,\n forcedEnabled: that.options.zoom\n }),\n\n avoidScrolling = this.options.avoidScrolling,\n\n userEvents = new kendo.UserEvents(element, {\n touchAction: \"pan-y\",\n fastTap: true,\n allowSelection: true,\n preventDragEvent: true,\n captureUpIfMoved: true,\n multiTouch: that.options.zoom,\n supportDoubleTap: that.options.supportDoubleTap,\n start: function(e) {\n dimensions.refresh();\n\n var velocityX = abs(e.x.velocity),\n velocityY = abs(e.y.velocity),\n horizontalSwipe = velocityX * 2 >= velocityY,\n originatedFromFixedContainer = $.contains(that.fixedContainer[0], e.event.target),\n verticalSwipe = velocityY * 2 >= velocityX;\n\n\n if (!originatedFromFixedContainer && !avoidScrolling(e) && that.enabled && (dimensions.x.enabled && horizontalSwipe || dimensions.y.enabled && verticalSwipe)) {\n userEvents.capture();\n } else {\n userEvents.cancel();\n }\n }\n }),\n\n pane = new Pane({\n movable: movable,\n dimensions: dimensions,\n userEvents: userEvents,\n elastic: that.options.elastic\n }),\n\n zoomSnapBack = new ZoomSnapBack({\n movable: movable,\n dimensions: dimensions,\n userEvents: userEvents,\n tapCapture: tapCapture\n }),\n\n animatedScroller = new AnimatedScroller({\n moveTo: function(coordinates) {\n that.scrollTo(coordinates.x, coordinates.y);\n }\n });\n\n movable.bind(CHANGE, function() {\n that.scrollTop = - movable.y;\n that.scrollLeft = - movable.x;\n\n that.trigger(SCROLL, {\n scrollTop: that.scrollTop,\n scrollLeft: that.scrollLeft\n });\n });\n\n if (that.options.mousewheelScrolling) {\n element.on(\"DOMMouseScroll mousewheel\", proxy(this, \"_wheelScroll\"));\n }\n\n extend(that, {\n movable: movable,\n dimensions: dimensions,\n zoomSnapBack: zoomSnapBack,\n animatedScroller: animatedScroller,\n userEvents: userEvents,\n pane: pane,\n tapCapture: tapCapture,\n pulled: false,\n enabled: true,\n scrollElement: inner,\n scrollTop: 0,\n scrollLeft: 0,\n fixedContainer: element.children().first()\n });\n\n that._initAxis(\"x\");\n that._initAxis(\"y\");\n\n // build closure\n that._wheelEnd = function() {\n that._wheel = false;\n that.userEvents.end(0, that._wheelY);\n };\n\n dimensions.refresh();\n\n if (that.options.pullToRefresh) {\n that._initPullToRefresh();\n }\n },\n\n _wheelScroll: function(e) {\n if (e.ctrlKey) {\n return;\n }\n\n if (!this._wheel) {\n this._wheel = true;\n this._wheelY = 0;\n this.userEvents.press(0, this._wheelY);\n }\n\n clearTimeout(this._wheelTimeout);\n this._wheelTimeout = setTimeout(this._wheelEnd, 50);\n\n var delta = kendo.wheelDeltaY(e);\n\n if (delta) {\n this._wheelY += delta;\n this.userEvents.move(0, this._wheelY);\n }\n\n e.preventDefault();\n },\n\n makeVirtual: function() {\n this.dimensions.y.makeVirtual();\n },\n\n virtualSize: function(min, max) {\n this.dimensions.y.virtualSize(min, max);\n },\n\n height: function() {\n return this.dimensions.y.size;\n },\n\n scrollHeight: function() {\n return this.scrollElement[0].scrollHeight;\n },\n\n scrollWidth: function() {\n return this.scrollElement[0].scrollWidth;\n },\n\n options: {\n name: \"Scroller\",\n zoom: false,\n pullOffset: 140,\n visibleScrollHints: false,\n elastic: true,\n useNative: false,\n mousewheelScrolling: true,\n avoidScrolling: function() { return false; },\n pullToRefresh: false,\n messages: {\n pullTemplate: \"Pull to refresh\",\n releaseTemplate: \"Release to refresh\",\n refreshTemplate: \"Refreshing\"\n }\n },\n\n events: [\n PULL,\n SCROLL,\n RESIZE\n ],\n\n _resize: function() {\n if (!this._native) {\n this.contentResized();\n }\n },\n\n setOptions: function(options) {\n var that = this;\n Widget.fn.setOptions.call(that, options);\n if (options.pullToRefresh) {\n that._initPullToRefresh();\n }\n },\n\n reset: function() {\n if (this._native) {\n this.scrollElement.scrollTop(0);\n } else {\n this.movable.moveTo({x: 0, y: 0});\n this._scale(1);\n }\n },\n\n contentResized: function() {\n this.dimensions.refresh();\n if (this.pane.x.outOfBounds()) {\n this.movable.moveAxis(\"x\", this.dimensions.x.min);\n }\n\n if (this.pane.y.outOfBounds()) {\n this.movable.moveAxis(\"y\", this.dimensions.y.min);\n }\n },\n\n zoomOut: function() {\n var dimensions = this.dimensions;\n dimensions.refresh();\n this._scale(dimensions.fitScale);\n this.movable.moveTo(dimensions.centerCoordinates());\n },\n\n enable: function() {\n this.enabled = true;\n },\n\n disable: function() {\n this.enabled = false;\n },\n\n scrollTo: function(x, y) {\n if (this._native) {\n kendo.scrollLeft(this.scrollElement, abs(x));\n this.scrollElement.scrollTop(abs(y));\n } else {\n this.dimensions.refresh();\n this.movable.moveTo({x: x, y: y});\n }\n },\n\n animatedScrollTo: function(x, y, callback) {\n var from,\n to;\n\n if(this._native) {\n this.scrollTo(x, y);\n } else {\n from = { x: this.movable.x, y: this.movable.y };\n to = { x: x, y: y };\n\n this.animatedScroller.setCoordinates(from, to);\n this.animatedScroller.setCallback(callback);\n this.animatedScroller.start();\n }\n },\n\n pullHandled: function() {\n var that = this;\n that.refreshHint.removeClass(REFRESHCLASS);\n that.hintContainer.html(that.pullTemplate({}));\n that.yinertia.onEnd();\n that.xinertia.onEnd();\n that.userEvents.cancel();\n },\n\n destroy: function() {\n Widget.fn.destroy.call(this);\n if (this.userEvents) {\n this.userEvents.destroy();\n }\n },\n\n _scale: function(scale) {\n this.dimensions.rescale(scale);\n this.movable.scaleTo(scale);\n },\n\n _initPullToRefresh: function() {\n var that = this;\n\n that.dimensions.y.forceEnabled();\n that.pullTemplate = kendo.template(that.options.messages.pullTemplate);\n that.releaseTemplate = kendo.template(that.options.messages.releaseTemplate);\n that.refreshTemplate = kendo.template(that.options.messages.refreshTemplate);\n\n that.scrollElement.prepend('' + that.pullTemplate({}) + '');\n that.refreshHint = that.scrollElement.children().first();\n that.hintContainer = that.refreshHint.children(\".km-template\");\n\n that.pane.y.bind(\"change\", proxy(that._paneChange, that));\n that.userEvents.bind(\"end\", proxy(that._dragEnd, that));\n },\n\n _dragEnd: function() {\n var that = this;\n\n if(!that.pulled) {\n return;\n }\n\n that.pulled = false;\n that.refreshHint.removeClass(RELEASECLASS).addClass(REFRESHCLASS);\n that.hintContainer.html(that.refreshTemplate({}));\n that.yinertia.freeze(that.options.pullOffset / 2);\n that.trigger(\"pull\");\n },\n\n _paneChange: function() {\n var that = this;\n\n if (that.movable.y / OUT_OF_BOUNDS_FRICTION > that.options.pullOffset) {\n if (!that.pulled) {\n that.pulled = true;\n that.refreshHint.removeClass(REFRESHCLASS).addClass(RELEASECLASS);\n that.hintContainer.html(that.releaseTemplate({}));\n }\n } else if (that.pulled) {\n that.pulled = false;\n that.refreshHint.removeClass(RELEASECLASS);\n that.hintContainer.html(that.pullTemplate({}));\n }\n },\n\n _initAxis: function(axis) {\n var that = this,\n elementId = that.element.attr(\"id\"),\n movable = that.movable,\n dimension = that.dimensions[axis],\n tapCapture = that.tapCapture,\n paneAxis = that.pane[axis],\n scrollBar;\n\n if(!elementId) {\n elementId = kendo.guid();\n that.element.attr(\"id\", elementId);\n }\n\n scrollBar = new ScrollBar({\n axis: axis,\n movable: movable,\n dimension: dimension,\n container: that.element,\n alwaysVisible: that.options.visibleScrollHints,\n controlsId: elementId\n });\n\n dimension.bind(CHANGE, function() {\n scrollBar.refresh();\n });\n\n paneAxis.bind(CHANGE, function() {\n scrollBar.show();\n });\n\n that[axis + \"inertia\"] = new DragInertia({\n axis: axis,\n paneAxis: paneAxis,\n movable: movable,\n tapCapture: tapCapture,\n userEvents: that.userEvents,\n dimension: dimension,\n elastic: that.options.elastic,\n friction: that.options.friction || FRICTION,\n velocityMultiplier: that.options.velocityMultiplier || VELOCITY_MULTIPLIER,\n end: function() {\n scrollBar.hide();\n that.trigger(\"scrollEnd\", {\n axis: axis,\n scrollTop: that.scrollTop,\n scrollLeft: that.scrollLeft\n });\n }\n });\n }\n });\n\n ui.plugin(Scroller);\n})(window.kendo.jQuery);\n\nreturn window.kendo;\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n\n(function(f, define){\n define('kendo.groupable',[ \"./kendo.core\", \"./kendo.draganddrop\" ], f);\n})(function(){\n\nvar __meta__ = { // jshint ignore:line\n id: \"groupable\",\n name: \"Groupable\",\n category: \"framework\",\n depends: [ \"core\", \"draganddrop\" ],\n advanced: true\n};\n\n(function ($, undefined) {\n var kendo = window.kendo,\n Widget = kendo.ui.Widget,\n outerWidth = kendo._outerWidth,\n kendoAttr = kendo.attr,\n extend = $.extend,\n each = $.each,\n proxy = $.proxy,\n isRtl = false,\n\n DIR = \"dir\",\n FIELD = \"field\",\n TITLE = \"title\",\n ASCENDING = \"asc\",\n DESCENDING = \"desc\",\n GROUP_SORT = \"group-sort\",\n NS = \".kendoGroupable\",\n CHANGE = \"change\",\n indicatorTmpl = kendo.template('', { useWithBlock:false }),\n hint = function(target) {\n var title = target.attr(kendo.attr(\"title\"));\n if (title) {\n title = kendo.htmlEncode(title);\n }\n\n return $('
    ')\n .html(title || target.attr(kendo.attr(\"field\")))\n .prepend('');\n },\n dropCue = $('
    ');\n\n var Groupable = Widget.extend({\n init: function(element, options) {\n var that = this,\n group = kendo.guid(),\n intializePositions = proxy(that._intializePositions, that),\n draggable,\n horizontalCuePosition,\n dropCuePositions = that._dropCuePositions = [];\n\n Widget.fn.init.call(that, element, options);\n\n isRtl = kendo.support.isRtl(element);\n horizontalCuePosition = isRtl ? \"right\" : \"left\";\n\n that.draggable = draggable = that.options.draggable || new kendo.ui.Draggable(that.element, {\n filter: that.options.draggableElements,\n hint: hint,\n group: group\n });\n\n that.groupContainer = $(that.options.groupContainer, that.element)\n .kendoDropTarget({\n group: draggable.options.group,\n dragenter: function(e) {\n if (that._canDrag(e.draggable.currentTarget)) {\n e.draggable.hint.find(\".k-drag-status\").removeClass(\"k-i-cancel\").addClass(\"k-i-plus\");\n dropCue.css(horizontalCuePosition, 0).appendTo(that.groupContainer);\n }\n },\n dragleave: function(e) {\n e.draggable.hint.find(\".k-drag-status\").removeClass(\"k-i-plus\").addClass(\"k-i-cancel\");\n dropCue.remove();\n },\n drop: function(e) {\n var targetElement = e.draggable.currentTarget,\n field = targetElement.attr(kendo.attr(\"field\")),\n title = targetElement.attr(kendo.attr(\"title\")),\n sourceIndicator = that.indicator(field),\n dropCuePositions = that._dropCuePositions,\n lastCuePosition = dropCuePositions[dropCuePositions.length - 1],\n position;\n var sortOptions = extend({}, that.options.sort, targetElement.data(GROUP_SORT));\n var dir = sortOptions.dir;\n\n if (!targetElement.hasClass(\"k-group-indicator\") && !that._canDrag(targetElement)) {\n return;\n }\n if(lastCuePosition) {\n position = that._dropCuePosition(kendo.getOffset(dropCue).left + parseInt(lastCuePosition.element.css(\"marginLeft\"), 10) * (isRtl ? -1 : 1) + parseInt(lastCuePosition.element.css(\"marginRight\"), 10));\n if(position && that._canDrop($(sourceIndicator), position.element, position.left)) {\n if(position.before) {\n position.element.before(sourceIndicator || that.buildIndicator(field, title, dir));\n } else {\n position.element.after(sourceIndicator || that.buildIndicator(field, title, dir));\n }\n\n that._setIndicatorSortOptions(field, sortOptions);\n that._change();\n }\n } else {\n that.groupContainer.empty();\n that.groupContainer.append(that.buildIndicator(field, title, dir));\n that._setIndicatorSortOptions(field, sortOptions);\n that._change();\n }\n }\n })\n .kendoDraggable({\n filter: \"div.k-group-indicator\",\n hint: hint,\n group: draggable.options.group,\n dragcancel: proxy(that._dragCancel, that),\n dragstart: function(e) {\n var element = e.currentTarget,\n marginLeft = parseInt(element.css(\"marginLeft\"), 10),\n elementPosition = element.position(),\n left = isRtl ? elementPosition.left - marginLeft : elementPosition.left + outerWidth(element);\n\n intializePositions();\n dropCue.css(\"left\", left).appendTo(that.groupContainer);\n this.hint.find(\".k-drag-status\").removeClass(\"k-i-cancel\").addClass(\"k-i-plus\");\n },\n dragend: function() {\n that._dragEnd(this);\n },\n drag: proxy(that._drag, that)\n })\n .on(\"click\" + NS, \".k-button\", function(e) {\n e.preventDefault();\n that._removeIndicator($(this).parent());\n })\n .on(\"click\" + NS,\".k-link\", function(e) {\n var indicator = $(this).parent();\n var newDir = indicator.attr(kendoAttr(DIR)) === ASCENDING ? DESCENDING : ASCENDING;\n\n indicator.attr(kendoAttr(DIR), newDir);\n that._change();\n e.preventDefault();\n });\n\n draggable.bind([ \"dragend\", \"dragcancel\", \"dragstart\", \"drag\" ],\n {\n dragend: function() {\n that._dragEnd(this);\n },\n dragcancel: proxy(that._dragCancel, that),\n dragstart: function(e) {\n var element, marginRight, left;\n\n if (!that.options.allowDrag && !that._canDrag(e.currentTarget)) {\n e.preventDefault();\n return;\n }\n\n intializePositions();\n if(dropCuePositions.length) {\n element = dropCuePositions[dropCuePositions.length - 1].element;\n marginRight = parseInt(element.css(\"marginRight\"), 10);\n left = element.position().left + outerWidth(element) + marginRight;\n } else {\n left = 0;\n }\n },\n drag: proxy(that._drag, that)\n });\n\n that.dataSource = that.options.dataSource;\n\n if (that.dataSource && that._refreshHandler) {\n that.dataSource.unbind(CHANGE, that._refreshHandler);\n } else {\n that._refreshHandler = proxy(that.refresh, that);\n }\n\n if(that.dataSource) {\n that.dataSource.bind(\"change\", that._refreshHandler);\n that.refresh();\n }\n },\n\n refresh: function() {\n var that = this,\n dataSource = that.dataSource;\n var groups = dataSource.group() || [];\n var fieldAttr = kendoAttr(FIELD);\n var titleAttr = kendoAttr(TITLE);\n var indicatorHtml;\n\n if (that.groupContainer) {\n that.groupContainer.empty();\n\n each(groups, function(index, group) {\n var field = group.field;\n var dir =group.dir;\n var element = that.element\n .find(that.options.filter)\n .filter(function() {\n return $(this).attr(fieldAttr) === field;\n });\n\n indicatorHtml = that.buildIndicator(field, element.attr(titleAttr), dir);\n that.groupContainer.append(indicatorHtml);\n that._setIndicatorSortOptions(field, extend({}, that.options.sort, { dir: dir, compare: group.compare }));\n });\n }\n\n that._invalidateGroupContainer();\n },\n\n destroy: function() {\n var that = this;\n\n Widget.fn.destroy.call(that);\n\n that.groupContainer.off(NS);\n\n if (that.groupContainer.data(\"kendoDropTarget\")) {\n that.groupContainer.data(\"kendoDropTarget\").destroy();\n }\n\n if (that.groupContainer.data(\"kendoDraggable\")) {\n that.groupContainer.data(\"kendoDraggable\").destroy();\n }\n\n if (!that.options.draggable) {\n that.draggable.destroy();\n }\n\n if (that.dataSource && that._refreshHandler) {\n that.dataSource.unbind(\"change\", that._refreshHandler);\n that._refreshHandler = null;\n }\n\n that.groupContainer = that.element = that.draggable = null;\n },\n\n events: [\"change\"],\n\n options: {\n name: \"Groupable\",\n filter: \"th\",\n draggableElements: \"th\",\n messages: {\n empty: \"Drag a column header and drop it here to group by that column\"\n },\n sort: {\n dir: ASCENDING,\n compare: null\n }\n },\n\n indicator: function(field) {\n var indicators = $(\".k-group-indicator\", this.groupContainer);\n return $.grep(indicators, function (item)\n {\n return $(item).attr(kendo.attr(\"field\")) === field;\n })[0];\n },\n\n buildIndicator: function(field, title, dir) {\n var that = this;\n var indicator = indicatorTmpl({\n ns: kendo.ns,\n field: field.replace(/\"/g, \"'\"),\n title: title,\n dir: dir || (that.options.sort || {}).dir || ASCENDING\n });\n\n return indicator;\n },\n\n _setIndicatorSortOptions: function(field, options) {\n var indicator = $(this.indicator(field));\n indicator.data(GROUP_SORT, options);\n },\n\n aggregates: function() {\n var that = this;\n var names;\n var idx;\n var length;\n\n return that.element.find(that.options.filter).map(function() {\n var cell = $(this),\n aggregate = cell.attr(kendo.attr(\"aggregates\")),\n member = cell.attr(kendo.attr(\"field\"));\n\n if (aggregate && aggregate !== \"\") {\n names = aggregate.split(\",\");\n aggregate = [];\n for (idx = 0, length = names.length; idx < length; idx++) {\n aggregate.push({ field: member, aggregate: names[idx] });\n }\n }\n return aggregate;\n }).toArray();\n },\n\n descriptors: function() {\n var that = this,\n indicators = $(\".k-group-indicator\", that.groupContainer),\n field,\n aggregates = that.aggregates();\n\n return $.map(indicators, function(item) {\n item = $(item);\n field = item.attr(kendo.attr(\"field\"));\n var sortOptions = that.options.sort || {};\n var indicatorSortOptions = item.data(GROUP_SORT) || {};\n\n return {\n field: field,\n dir: item.attr(kendo.attr(\"dir\")),\n aggregates: aggregates || [],\n compare: indicatorSortOptions.compare || sortOptions.compare\n };\n });\n },\n\n _removeIndicator: function(indicator) {\n var that = this;\n indicator.off();\n indicator.removeData();\n indicator.remove();\n that._invalidateGroupContainer();\n that._change();\n },\n\n _change: function() {\n var that = this;\n if(that.dataSource) {\n var descriptors = that.descriptors();\n if (that.trigger(\"change\", { groups: descriptors })) {\n that.refresh();\n return;\n }\n that.dataSource.group(descriptors);\n }\n },\n\n _dropCuePosition: function(position) {\n var dropCuePositions = this._dropCuePositions;\n if(!dropCue.is(\":visible\") || dropCuePositions.length === 0) {\n return;\n }\n\n position = Math.ceil(position);\n\n var lastCuePosition = dropCuePositions[dropCuePositions.length - 1],\n left = lastCuePosition.left,\n right = lastCuePosition.right,\n marginLeft = parseInt(lastCuePosition.element.css(\"marginLeft\"), 10),\n marginRight = parseInt(lastCuePosition.element.css(\"marginRight\"), 10);\n\n if(position >= right && !isRtl || position < left && isRtl) {\n position = {\n left: lastCuePosition.element.position().left + (!isRtl ? outerWidth(lastCuePosition.element) + marginRight : - marginLeft),\n element: lastCuePosition.element,\n before: false\n };\n } else {\n position = $.grep(dropCuePositions, function(item) {\n return (item.left <= position && position <= item.right) || (isRtl && position > item.right);\n })[0];\n\n if(position) {\n position = {\n left: isRtl ? position.element.position().left + outerWidth(position.element) + marginRight : position.element.position().left - marginLeft,\n element: position.element,\n before: true\n };\n }\n }\n\n return position;\n },\n _drag: function(event) {\n var position = this._dropCuePosition(event.x.location);\n\n if (position) {\n dropCue.css({ left: position.left, right: \"auto\" });\n }\n },\n _canDrag: function(element) {\n var field = element.attr(kendo.attr(\"field\"));\n\n return element.attr(kendo.attr(\"groupable\")) != \"false\" &&\n field &&\n (element.hasClass(\"k-group-indicator\") ||\n !this.indicator(field));\n },\n _canDrop: function(source, target, position) {\n var next = source.next(),\n result = source[0] !== target[0] && (!next[0] || target[0] !== next[0] || (!isRtl && position > next.position().left || isRtl && position < next.position().left));\n return result;\n },\n _dragEnd: function(draggable) {\n var that = this,\n field = draggable.currentTarget.attr(kendo.attr(\"field\")),\n sourceIndicator = that.indicator(field);\n\n if (draggable !== that.options.draggable && !draggable.dropped && sourceIndicator) {\n that._removeIndicator($(sourceIndicator));\n }\n\n that._dragCancel();\n },\n _dragCancel: function() {\n dropCue.remove();\n this._dropCuePositions = [];\n },\n _intializePositions: function() {\n var that = this,\n indicators = $(\".k-group-indicator\", that.groupContainer),\n left;\n\n that._dropCuePositions = $.map(indicators, function(item) {\n item = $(item);\n left = kendo.getOffset(item).left;\n return {\n left: parseInt(left, 10),\n right: parseInt(left + outerWidth(item), 10),\n element: item\n };\n });\n },\n _invalidateGroupContainer: function() {\n var groupContainer = this.groupContainer;\n if(groupContainer && groupContainer.is(\":empty\")) {\n groupContainer.html(this.options.messages.empty);\n }\n }\n });\n\n kendo.ui.plugin(Groupable);\n\n})(window.kendo.jQuery);\n\nreturn window.kendo;\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n\n(function(f, define){\n define('kendo.reorderable',[ \"./kendo.core\", \"./kendo.draganddrop\" ], f);\n})(function(){\n\nvar __meta__ = { // jshint ignore:line\n id: \"reorderable\",\n name: \"Reorderable\",\n category: \"framework\",\n depends: [ \"core\", \"draganddrop\" ],\n advanced: true\n};\n\n(function ($, undefined) {\n var kendo = window.kendo,\n outerWidth = kendo._outerWidth,\n outerHeight = kendo._outerHeight,\n getOffset = kendo.getOffset,\n Widget = kendo.ui.Widget,\n CHANGE = \"change\",\n KREORDERABLE = \"k-reorderable\";\n\n var Reorderable = Widget.extend({\n init: function(element, options) {\n var that = this,\n draggable,\n group = kendo.guid() + \"-reorderable\";\n\n Widget.fn.init.call(that, element, options);\n\n element = that.element.addClass(KREORDERABLE);\n options = that.options;\n\n that.draggable = draggable = options.draggable || new kendo.ui.Draggable(element, {\n group: group,\n autoScroll: true,\n filter: options.filter,\n hint: options.hint\n });\n\n if(!that.options.dropFilter) {\n that.options.dropFilter = draggable.options.filter;\n }\n\n that.reorderDropCue = that.options.reorderDropCue;\n\n element.find(options.dropFilter).kendoDropTarget({\n group: draggable.options.group,\n dragenter: function(e) {\n var externalDraggableInstance = that._externalDraggable(e);\n\n if (!that._draggable && !externalDraggableInstance) {\n return;\n }\n\n if (externalDraggableInstance) {\n that._handleExternalDraggable(externalDraggableInstance);\n }\n\n var dropTarget = this.element, offset;\n\n var denied = that._isPartOfSortable(that._draggable) ? (!that._dropTargetAllowed(dropTarget) || that._isLastDraggable()) : false;\n\n that.toggleHintClass(e.draggable.hint, denied);\n\n if (!denied) {\n offset = getOffset(dropTarget);\n var cueOffset = { top: offset.top, left: offset.left};\n var isHorizontal = options.orientation === \"horizontal\";\n\n if (!options.smartPosition || (options.inSameContainer && !options.inSameContainer({\n source: dropTarget,\n target: that._draggable,\n sourceIndex: that._index(dropTarget),\n targetIndex: that._index(that._draggable)\n }))) {\n that._dropTarget = dropTarget;\n } else {\n if (that._index(dropTarget) > that._index(that._draggable) && options.smartPosition) {\n cueOffset[isHorizontal ? \"left\" : \"top\"] += isHorizontal ? outerWidth(dropTarget) : outerHeight(dropTarget);\n }\n }\n\n that.reorderDropCue.css({\n height: outerHeight(dropTarget),\n top: cueOffset.top,\n left: cueOffset.left,\n zIndex: 19000\n })\n .appendTo(document.body);\n\n if (options.positionDropCue) {\n options.positionDropCue(that.reorderDropCue, dropTarget);\n }\n }\n },\n dragleave: function(e) {\n that.toggleHintClass(e.draggable.hint, true);\n that.reorderDropCue.remove();\n that._dropTarget = null;\n },\n drop: function() {\n that._dropTarget = null;\n\n if (!that._draggable) {\n return;\n }\n var dropTarget = this.element;\n var draggable = that._draggable;\n var dropIndex = that._index(dropTarget);\n\n var isAfter = that.options.orientation === \"horizontal\" ?\n getOffset(that.reorderDropCue).left > getOffset(dropTarget).left :\n getOffset(that.reorderDropCue).top > getOffset(dropTarget).top;\n\n dropIndex = isAfter ? dropIndex + 1 : dropIndex;\n\n if (that._dropTargetAllowed(dropTarget) && !that._isLastDraggable() && that._index(draggable) !== dropIndex) {\n that.trigger(CHANGE, {\n element: that._draggable,\n target: dropTarget,\n oldIndex: that._index(draggable),\n newIndex: that._index(dropTarget),\n position: isAfter ? \"after\" : \"before\"\n });\n }\n\n if(that.reorderDropCue) {\n that.reorderDropCue.remove();\n }\n }\n });\n\n draggable.bind([ \"dragcancel\", \"dragend\", \"dragstart\", \"drag\" ], {\n dragcancel: $.proxy(that._dragcancel, that),\n dragend: $.proxy(that._dragend, that),\n dragstart: $.proxy(that._dragstart, that),\n drag: $.proxy(that._drag, that)\n });\n },\n\n options: {\n name: \"Reorderable\",\n filter: \"*\",\n orientation: \"horizontal\",\n deniedIcon: \"k-i-cancel\",\n allowIcon: \"k-i-plus\",\n reorderDropCue: $('
    '),\n smartPosition: true\n },\n\n events: [\n CHANGE\n ],\n\n toggleHintClass: function (hint, denied) {\n var that = this,\n options = that.options;\n\n hint = $(hint);\n\n if (denied) {\n hint.find(\".k-drag-status\").removeClass(options.allowIcon).addClass(options.deniedIcon);\n } else {\n hint.find(\".k-drag-status\").removeClass(options.deniedIcon).addClass(options.allowIcon);\n }\n },\n\n _handleExternalDraggable: function (draggable) {\n var that = this;\n\n that._dragcancelHandler = $.proxy(that._dragcancel, that);\n that._dragendHandler = $.proxy(that._dragend, that);\n that._dragstartHandler = $.proxy(that._dragstart, that);\n that._dragHandler = $.proxy(that._drag, that);\n\n that._draggable = draggable.currentTarget.closest(that.options.dropFilter);\n that._draggableInstance = draggable;\n that._elements = that.element.find(that.options.dropFilter);\n\n draggable.bind([ \"dragcancel\", \"dragend\", \"dragstart\", \"drag\" ], {\n dragcancel: that._dragcancelHandler,\n dragend: that._dragendHandler,\n dragstart: that._dragstartHandler,\n drag: that._dragHandler\n });\n },\n\n _dragcancel: function() {\n var that = this;\n\n if(that._draggableInstance && (that._dragcancelHandler || that._dragendHandler ||\n that._dragstartHandler || that._dragHandler)) {\n\n that._draggableInstance.unbind({\n dragcancel: that._dragcancelHandler,\n dragend: that._dragendHandler,\n dragstart: that._dragstartHandler,\n drag: that._dragHandler\n });\n }\n\n if(that.reorderDropCue) {\n that.reorderDropCue.remove();\n }\n\n that._draggable = null;\n that._elements = null;\n\n },\n _dragend: function() {\n var that = this;\n\n if(that._draggableInstance && (that._dragcancelHandler || that._dragendHandler ||\n that._dragstartHandler || that._dragHandler)) {\n\n that._draggableInstance.unbind({\n dragcancel: that._dragcancelHandler,\n dragend: that._dragendHandler,\n dragstart: that._dragstartHandler,\n drag: that._dragHandler\n });\n }\n\n if(that.reorderDropCue) {\n that.reorderDropCue.remove();\n }\n\n that._draggable = null;\n that._elements = null;\n },\n _dragstart: function(e) {\n var that = this;\n var target = $(e.currentTarget);\n\n that._draggable = target.is(that.options.dropFilter) ? target : target.closest(that.options.dropFilter);\n that._elements = that.element.find(that.options.dropFilter);\n },\n _drag: function(e) {\n var that = this,\n dropIndex, sourceIndex, denied,\n offset = {},\n target = $(e.currentTarget).closest(that.options.dropFilter);\n\n if (!that._dropTarget || (that.options.smartPosition && e.sender.hint.find(\".k-drag-status\").hasClass(\"k-i-cancel\"))) {\n return;\n }\n\n dropIndex = that._index(that._dropTarget);\n sourceIndex = that._index(target);\n sourceIndex = dropIndex > sourceIndex ? sourceIndex + 1 : sourceIndex;\n\n if(that.options.orientation === \"horizontal\") {\n var dropStartOffset = getOffset(that._dropTarget).left;\n var width = outerWidth(that._dropTarget);\n\n if (e.pageX > dropStartOffset + width / 2) {\n offset.left = dropStartOffset + width;\n dropIndex += 1;\n } else {\n offset.left = dropStartOffset;\n }\n } else {\n var dropStartTop = getOffset(that._dropTarget).top;\n var height = outerHeight(that._dropTarget);\n\n if (e.pageY > dropStartTop + height / 2) {\n offset.top = dropStartTop + height;\n dropIndex += 1;\n } else {\n offset.top = dropStartTop;\n }\n }\n\n that.reorderDropCue.css(offset);\n\n if (that.options.positionDropCue) {\n that.options.positionDropCue(that.reorderDropCue, that._dropTarget);\n }\n\n if (that._isPartOfSortable(target)) {\n\n denied = sourceIndex === dropIndex || (that.options.dragOverContainers && !that.options.dragOverContainers(sourceIndex, dropIndex));\n\n that.toggleHintClass(e.sender.hint, denied);\n }\n },\n\n _isPartOfSortable: function (draggable) {\n var that = this;\n\n return that._elements.index(draggable) >= 0;\n },\n\n _externalDraggable: function(e) {\n var that = this,\n options = that.options;\n\n if(!that._draggable && options.externalDraggable) {\n return options.externalDraggable(e);\n }\n\n return null;\n },\n\n _isLastDraggable: function() {\n var inSameContainer = this.options.inSameContainer,\n draggable = this._draggable[0],\n elements = this._elements.get(),\n found = false,\n item;\n\n if (!inSameContainer) {\n return false;\n }\n\n while (!found && elements.length > 0) {\n item = elements.pop();\n found = draggable !== item && inSameContainer({\n source: draggable,\n target: item,\n sourceIndex: this._index(draggable),\n targetIndex: this._index(item)\n });\n }\n\n return !found;\n },\n\n _dropTargetAllowed: function(dropTarget) {\n var inSameContainer = this.options.inSameContainer,\n dragOverContainers = this.options.dragOverContainers,\n draggable = this._draggable;\n\n if (draggable[0] === dropTarget[0]) {\n return false;\n }\n\n if (!inSameContainer || !dragOverContainers) {\n return true;\n }\n\n if (inSameContainer({ source: draggable,\n target: dropTarget,\n sourceIndex: this._index(draggable),\n targetIndex: this._index(dropTarget)\n })) {\n return true;\n }\n\n return dragOverContainers(this._index(draggable), this._index(dropTarget));\n },\n\n _index: function(element) {\n return this._elements.index(element);\n },\n\n destroy: function() {\n var that = this;\n\n\n Widget.fn.destroy.call(that);\n\n that.element.find(that.options.dropFilter).each(function() {\n var item = $(this);\n if (item.data(\"kendoDropTarget\")) {\n item.data(\"kendoDropTarget\").destroy();\n }\n });\n\n if (that.draggable) {\n that.draggable.destroy();\n\n that.draggable.element = that.draggable = null;\n }\n\n that.reorderDropCue.remove();\n that.elements = that.reorderDropCue = that._elements = that._draggable = null;\n }\n });\n\n kendo.ui.plugin(Reorderable);\n\n})(window.kendo.jQuery);\n\nreturn window.kendo;\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n\n\n(function(f, define){\r\n define('kendo.resizable',[ \"./kendo.core\", \"./kendo.draganddrop\" ], f);\r\n})(function(){\r\n\r\nvar __meta__ = { // jshint ignore:line\r\n id: \"resizable\",\r\n name: \"Resizable\",\r\n category: \"framework\",\r\n depends: [ \"core\", \"draganddrop\" ],\r\n advanced: true\r\n};\r\n\r\n(function($, undefined) {\r\n var kendo = window.kendo,\r\n ui = kendo.ui,\r\n Widget = ui.Widget,\r\n proxy = $.proxy,\r\n isFunction = kendo.isFunction,\r\n extend = $.extend,\r\n HORIZONTAL = \"horizontal\",\r\n VERTICAL = \"vertical\",\r\n START = \"start\",\r\n RESIZE = \"resize\",\r\n RESIZEEND = \"resizeend\";\r\n\r\n var Resizable = Widget.extend({\r\n init: function(element, options) {\r\n var that = this;\r\n\r\n Widget.fn.init.call(that, element, options);\r\n\r\n that.orientation = that.options.orientation.toLowerCase() != VERTICAL ? HORIZONTAL : VERTICAL;\r\n that._positionMouse = that.orientation == HORIZONTAL ? \"x\" : \"y\";\r\n that._position = that.orientation == HORIZONTAL ? \"left\" : \"top\";\r\n that._sizingDom = that.orientation == HORIZONTAL ? \"outerWidth\" : \"outerHeight\";\r\n\r\n that.draggable = new ui.Draggable(options.draggableElement || element, {\r\n distance: 1,\r\n filter: options.handle,\r\n drag: proxy(that._resize, that),\r\n dragcancel: proxy(that._cancel, that),\r\n dragstart: proxy(that._start, that),\r\n dragend: proxy(that._stop, that)\r\n });\r\n\r\n that.userEvents = that.draggable.userEvents;\r\n },\r\n\r\n events: [\r\n RESIZE,\r\n RESIZEEND,\r\n START\r\n ],\r\n\r\n options: {\r\n name: \"Resizable\",\r\n orientation: HORIZONTAL\r\n },\r\n\r\n resize: function() {\r\n // Overrides base widget resize\r\n },\r\n\r\n _max: function(e) {\r\n var that = this,\r\n hintSize = that.hint ? that.hint[that._sizingDom]() : 0,\r\n size = that.options.max;\r\n\r\n return isFunction(size) ? size(e) : size !== undefined ? (that._initialElementPosition + size) - hintSize : size;\r\n },\r\n\r\n _min: function(e) {\r\n var that = this,\r\n size = that.options.min;\r\n\r\n return isFunction(size) ? size(e) : size !== undefined ? that._initialElementPosition + size : size;\r\n },\r\n\r\n _start: function(e) {\r\n var that = this,\r\n hint = that.options.hint,\r\n el = $(e.currentTarget);\r\n\r\n that._initialElementPosition = el.position()[that._position];\r\n that._initialMousePosition = e[that._positionMouse].startLocation;\r\n\r\n if (hint) {\r\n that.hint = isFunction(hint) ? $(hint(el)) : hint;\r\n\r\n that.hint.css({\r\n position: \"absolute\"\r\n })\r\n .css(that._position, that._initialElementPosition)\r\n .appendTo(that.element);\r\n }\r\n\r\n that.trigger(START, e);\r\n\r\n that._maxPosition = that._max(e);\r\n that._minPosition = that._min(e);\r\n\r\n $(document.body).css(\"cursor\", el.css(\"cursor\"));\r\n },\r\n\r\n _resize: function(e) {\r\n var that = this,\r\n maxPosition = that._maxPosition,\r\n minPosition = that._minPosition,\r\n currentPosition = that._initialElementPosition + (e[that._positionMouse].location - that._initialMousePosition),\r\n position;\r\n\r\n position = minPosition !== undefined ? Math.max(minPosition, currentPosition) : currentPosition;\r\n that.position = position = maxPosition !== undefined ? Math.min(maxPosition, position) : position;\r\n\r\n if(that.hint) {\r\n that.hint.toggleClass(that.options.invalidClass || \"\", position == maxPosition || position == minPosition)\r\n .css(that._position, position);\r\n }\r\n\r\n that.resizing = true;\r\n that.trigger(RESIZE, extend(e, { position: position }));\r\n },\r\n\r\n _stop: function(e) {\r\n var that = this;\r\n\r\n if(that.hint) {\r\n that.hint.remove();\r\n }\r\n\r\n that.resizing = false;\r\n that.trigger(RESIZEEND, extend(e, { position: that.position }));\r\n $(document.body).css(\"cursor\", \"\");\r\n },\r\n\r\n _cancel: function(e) {\r\n var that = this;\r\n\r\n if (that.hint) {\r\n that.position = undefined;\r\n that.hint.css(that._position, that._initialElementPosition);\r\n that._stop(e);\r\n }\r\n },\r\n\r\n destroy: function() {\r\n var that = this;\r\n\r\n Widget.fn.destroy.call(that);\r\n\r\n if (that.draggable) {\r\n that.draggable.destroy();\r\n }\r\n },\r\n\r\n press: function(target) {\r\n if (!target) {\r\n return;\r\n }\r\n\r\n var position = target.position(),\r\n that = this;\r\n\r\n that.userEvents.press(position.left, position.top, target[0]);\r\n that.targetPosition = position;\r\n that.target = target;\r\n },\r\n\r\n move: function(delta) {\r\n var that = this,\r\n orientation = that._position,\r\n position = that.targetPosition,\r\n current = that.position;\r\n\r\n if (current === undefined) {\r\n current = position[orientation];\r\n }\r\n\r\n position[orientation] = current + delta;\r\n\r\n that.userEvents.move(position.left, position.top);\r\n },\r\n\r\n end: function() {\r\n this.userEvents.end();\r\n this.target = this.position = undefined;\r\n }\r\n });\r\n\r\n kendo.ui.plugin(Resizable);\r\n\r\n})(window.kendo.jQuery);\r\n\r\nreturn window.kendo;\r\n\r\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\r\n\n/* jshint eqnull: true */\n(function(f, define){\n define('kendo.sortable',[ \"./kendo.draganddrop\" ], f);\n})(function(){\n\nvar __meta__ = { // jshint ignore:line\n id: \"sortable\",\n name: \"Sortable\",\n category: \"framework\",\n depends: [ \"draganddrop\" ]\n};\n\n(function($, undefined) {\n var kendo = window.kendo,\n Widget = kendo.ui.Widget,\n outerWidth = kendo._outerWidth,\n outerHeight = kendo._outerHeight,\n\n START = \"start\",\n BEFORE_MOVE = \"beforeMove\",\n MOVE = \"move\",\n END = \"end\",\n CHANGE = \"change\",\n CANCEL = \"cancel\",\n\n ACTION_SORT = \"sort\",\n ACTION_REMOVE = \"remove\",\n ACTION_RECEIVE = \"receive\",\n\n DEFAULT_FILTER = \">*\",\n MISSING_INDEX = -1;\n\n function containsOrEqualTo(parent, child) {\n try {\n return $.contains(parent, child) || parent == child;\n } catch (e) {\n return false;\n }\n }\n\n function defaultHint(element) {\n return element.clone();\n }\n\n function defaultPlaceholder(element) {\n return element.clone().removeAttr(\"id\").css(\"visibility\", \"hidden\");\n }\n\n var Sortable = Widget.extend({\n init: function(element, options) {\n var that = this;\n\n Widget.fn.init.call(that, element, options);\n\n if(!that.options.placeholder) {\n that.options.placeholder = defaultPlaceholder;\n }\n\n if(!that.options.hint) {\n that.options.hint = defaultHint;\n }\n\n that.draggable = that._createDraggable();\n },\n\n events: [\n START,\n BEFORE_MOVE,\n MOVE,\n END,\n CHANGE,\n CANCEL\n ],\n\n options: {\n name: \"Sortable\",\n hint: null,\n placeholder: null,\n filter: DEFAULT_FILTER,\n holdToDrag: false,\n disabled: null,\n container: null,\n connectWith: null,\n handler: null,\n cursorOffset: null,\n axis: null,\n ignore: null,\n autoScroll: false,\n cursor: \"auto\",\n moveOnDragEnter: false\n },\n\n destroy: function() {\n this.draggable.destroy();\n Widget.fn.destroy.call(this);\n },\n\n _createDraggable: function() {\n var that = this,\n element = that.element,\n options = that.options;\n\n return new kendo.ui.Draggable(element, {\n filter: options.filter,\n hint: kendo.isFunction(options.hint) ? options.hint : $(options.hint),\n holdToDrag: options.holdToDrag,\n container: options.container ? $(options.container) : null,\n cursorOffset: options.cursorOffset,\n axis: options.axis,\n ignore: options.ignore,\n autoScroll: options.autoScroll,\n dragstart: $.proxy(that._dragstart, that),\n dragcancel: $.proxy(that._dragcancel, that),\n drag: $.proxy(that._drag, that),\n dragend: $.proxy(that._dragend, that)\n });\n },\n\n _dragstart: function(e) {\n var draggedElement = this.draggedElement = e.currentTarget,\n disabled = this.options.disabled,\n handler = this.options.handler,\n _placeholder = this.options.placeholder,\n placeholder = this.placeholder = kendo.isFunction(_placeholder) ? $(_placeholder.call(this, draggedElement)) : $(_placeholder);\n\n if(disabled && draggedElement.is(disabled)) {\n e.preventDefault();\n } else if(handler && !$(e.initialTarget).is(handler)) {\n e.preventDefault();\n } else {\n\n if(this.trigger(START, { item: draggedElement, draggableEvent: e })) {\n e.preventDefault();\n } else {\n draggedElement.css(\"display\", \"none\");\n draggedElement.before(placeholder);\n\n this._setCursor();\n }\n\n }\n },\n\n _dragcancel: function() {\n this._cancel();\n this.trigger(CANCEL, { item: this.draggedElement });\n\n this._resetCursor();\n },\n\n _drag: function(e) {\n var draggedElement = this.draggedElement,\n target = this._findTarget(e),\n targetCenter,\n cursorOffset = { left: e.x.location, top: e.y.location },\n offsetDelta,\n axisDelta = { x: e.x.delta, y: e.y.delta },\n direction,\n sibling,\n getSibling,\n axis = this.options.axis,\n moveOnDragEnter= this.options.moveOnDragEnter,\n eventData = { item: draggedElement, list: this, draggableEvent: e };\n\n if(axis === \"x\" || axis === \"y\") {\n this._movementByAxis(axis, cursorOffset, axisDelta[axis], eventData);\n return;\n }\n\n if(target) {\n targetCenter = this._getElementCenter(target.element);\n\n offsetDelta = {\n left: Math.round(cursorOffset.left - targetCenter.left),\n top: Math.round(cursorOffset.top - targetCenter.top)\n };\n\n $.extend(eventData, { target: target.element });\n\n if(target.appendToBottom) {\n this._movePlaceholder(target, null, eventData);\n return;\n }\n\n if(target.appendAfterHidden) {\n this._movePlaceholder(target, \"next\", eventData);\n }\n\n if(this._isFloating(target.element)) { //horizontal\n if((axisDelta.x < 0 && moveOnDragEnter) || (!moveOnDragEnter && offsetDelta.left < 0)) {\n direction = \"prev\";\n } else if((axisDelta.x > 0 && moveOnDragEnter) || (!moveOnDragEnter && offsetDelta.left > 0)) {\n direction = \"next\";\n }\n } else { //vertical\n if((axisDelta.y < 0 && moveOnDragEnter) || (!moveOnDragEnter && offsetDelta.top < 0)) {\n direction = \"prev\";\n } else if((axisDelta.y > 0 && moveOnDragEnter) || (!moveOnDragEnter && offsetDelta.top > 0)) {\n direction = \"next\";\n }\n }\n\n if(direction) {\n getSibling = (direction === \"prev\") ? jQuery.fn.prev : jQuery.fn.next;\n\n sibling = getSibling.call(target.element);\n\n //find the prev/next visible sibling\n while(sibling.length && !sibling.is(\":visible\")) {\n sibling = getSibling.call(sibling);\n }\n\n if(sibling[0] != this.placeholder[0]) {\n this._movePlaceholder(target, direction, eventData);\n }\n }\n }\n },\n\n _dragend: function(e) {\n var placeholder = this.placeholder,\n draggedElement = this.draggedElement,\n draggedIndex = this.indexOf(draggedElement),\n placeholderIndex = this.indexOf(placeholder),\n connectWith = this.options.connectWith,\n connectedList,\n isDefaultPrevented,\n eventData,\n connectedListEventData;\n\n this._resetCursor();\n\n eventData = {\n action: ACTION_SORT,\n item: draggedElement,\n oldIndex: draggedIndex,\n newIndex: placeholderIndex,\n draggableEvent: e\n };\n\n if(placeholderIndex >= 0) {\n isDefaultPrevented = this.trigger(END, eventData);\n } else {\n connectedList = placeholder.parents(connectWith).getKendoSortable();\n\n eventData.action = ACTION_REMOVE;\n connectedListEventData = $.extend({}, eventData, {\n action: ACTION_RECEIVE,\n oldIndex: MISSING_INDEX,\n newIndex: connectedList.indexOf(placeholder)\n });\n\n isDefaultPrevented = !(!this.trigger(END, eventData) && !connectedList.trigger(END, connectedListEventData));\n }\n\n if(isDefaultPrevented || placeholderIndex === draggedIndex) {\n this._cancel();\n return;\n }\n\n placeholder.replaceWith(draggedElement);\n\n draggedElement.show();\n this.draggable.dropped = true;\n\n eventData = {\n action: this.indexOf(draggedElement) != MISSING_INDEX ? ACTION_SORT : ACTION_REMOVE,\n item: draggedElement,\n oldIndex: draggedIndex,\n newIndex: this.indexOf(draggedElement),\n draggableEvent: e\n };\n\n this.trigger(CHANGE, eventData);\n\n if(connectedList) {\n connectedListEventData = $.extend({}, eventData, {\n action: ACTION_RECEIVE,\n oldIndex: MISSING_INDEX,\n newIndex: connectedList.indexOf(draggedElement)\n });\n\n connectedList.trigger(CHANGE, connectedListEventData);\n }\n\n },\n\n _findTarget: function(e) {\n var element = this._findElementUnderCursor(e),\n items,\n connectWith = this.options.connectWith,\n node;\n\n if($.contains(this.element[0], element)) { //the element is part of the sortable container\n items = this.items();\n node = items.filter(element)[0] || items.has(element)[0];\n\n return node ? { element: $(node), sortable: this } : null;\n } else if (this.element[0] == element && this._isEmpty()) {\n return { element: this.element, sortable: this, appendToBottom: true };\n } else if (this.element[0] == element && this._isLastHidden()) {\n node = this.items().eq(0);\n return { element: node , sortable: this, appendAfterHidden: true };\n } else if (connectWith) { //connected lists are present\n return this._searchConnectedTargets(element, e);\n }\n },\n\n _findElementUnderCursor: function(e) {\n var elementUnderCursor = kendo.elementUnderCursor(e),\n draggable = e.sender;\n\n if(containsOrEqualTo(draggable.hint[0], elementUnderCursor)) {\n draggable.hint.hide();\n elementUnderCursor = kendo.elementUnderCursor(e);\n // IE8 does not return the element in iframe from first attempt\n if (!elementUnderCursor) {\n elementUnderCursor = kendo.elementUnderCursor(e);\n }\n draggable.hint.show();\n }\n\n return elementUnderCursor;\n },\n\n _searchConnectedTargets: function(element, e) {\n var connected = $(this.options.connectWith),\n sortableInstance,\n items,\n node;\n\n for (var i = 0; i < connected.length; i++) {\n sortableInstance = connected.eq(i).getKendoSortable();\n\n if($.contains(connected[i], element)) {\n if(sortableInstance) {\n items = sortableInstance.items();\n node = items.filter(element)[0] || items.has(element)[0];\n\n if(node) {\n sortableInstance.placeholder = this.placeholder;\n return { element: $(node), sortable: sortableInstance };\n } else {\n return null;\n }\n }\n } else if(connected[i] == element) {\n if(sortableInstance && sortableInstance._isEmpty()) {\n return { element: connected.eq(i), sortable: sortableInstance, appendToBottom: true };\n } else if (this._isCursorAfterLast(sortableInstance, e)) {\n node = sortableInstance.items().last();\n return { element: node, sortable: sortableInstance };\n }\n }\n }\n\n },\n\n _isCursorAfterLast: function(sortable, e) {\n var lastItem = sortable.items().last(),\n cursorOffset = { left: e.x.location, top: e.y.location },\n lastItemOffset,\n delta;\n\n lastItemOffset = kendo.getOffset(lastItem);\n lastItemOffset.top += outerHeight(lastItem);\n lastItemOffset.left += outerWidth(lastItem);\n\n if(this._isFloating(lastItem)) { //horizontal\n delta = lastItemOffset.left - cursorOffset.left;\n } else { //vertical\n delta = lastItemOffset.top - cursorOffset.top;\n }\n\n return delta < 0 ? true : false;\n },\n\n _movementByAxis: function(axis, cursorOffset, delta, eventData) {\n var cursorPosition = (axis === \"x\") ? cursorOffset.left : cursorOffset.top,\n target = (delta < 0) ? this.placeholder.prev() : this.placeholder.next(),\n items = this.items(),\n targetCenter;\n\n if (target.length && !target.is(\":visible\")) {\n target = (delta <0) ? target.prev() : target.next();\n }\n\n if (!items.filter(target).length) {\n return;\n }\n\n $.extend(eventData, { target: target });\n targetCenter = this._getElementCenter(target);\n\n if (targetCenter) {\n targetCenter = (axis === \"x\") ? targetCenter.left : targetCenter.top;\n }\n\n if (target.length && delta < 0 && cursorPosition - targetCenter < 0) { //prev\n this._movePlaceholder({ element: target, sortable: this }, \"prev\", eventData);\n } else if (target.length && delta > 0 && cursorPosition - targetCenter > 0) { //next\n this._movePlaceholder({ element: target, sortable: this }, \"next\", eventData);\n }\n },\n\n _movePlaceholder: function(target, direction, eventData) {\n var placeholder = this.placeholder;\n\n if (!target.sortable.trigger(BEFORE_MOVE, eventData)) {\n\n if (!direction) {\n target.element.append(placeholder);\n } else if (direction === \"prev\") {\n target.element.before(placeholder);\n } else if (direction === \"next\") {\n target.element.after(placeholder);\n }\n\n target.sortable.trigger(MOVE, eventData);\n }\n },\n\n _setCursor: function() {\n var cursor = this.options.cursor,\n body;\n\n if(cursor && cursor !== \"auto\") {\n body = $(document.body);\n\n this._originalCursorType = body.css(\"cursor\");\n body.css({ \"cursor\": cursor });\n\n if(!this._cursorStylesheet) {\n this._cursorStylesheet = $(\"\");\n }\n\n this._cursorStylesheet.appendTo(body);\n }\n },\n\n _resetCursor: function() {\n if(this._originalCursorType) {\n $(document.body).css(\"cursor\", this._originalCursorType);\n this._originalCursorType = null;\n\n this._cursorStylesheet.remove();\n }\n },\n\n _getElementCenter: function(element) {\n var center = element.length ? kendo.getOffset(element) : null;\n if(center) {\n center.top += outerHeight(element) / 2;\n center.left += outerWidth(element) / 2;\n }\n\n return center;\n },\n\n _isFloating: function (item) {\n var isFloating = /left|right/.test(item.css('float'));\n var isTable = /inline|table-cell/.test(item.css('display'));\n var isHorizontalFlex = /flex/.test(item.parent().css('display')) && (/row|row-reverse/.test(item.parent().css('flex-direction')) || !item.parent().css('flex-direction'));\n return isFloating || isTable || isHorizontalFlex;\n },\n\n _cancel: function() {\n this.draggedElement.show();\n this.placeholder.remove();\n this.draggable.dropped = true;\n },\n\n _items: function() {\n var filter = this.options.filter,\n items;\n\n if(filter) {\n items = this.element.find(filter);\n } else {\n items = this.element.children();\n }\n\n return items;\n },\n\n indexOf: function(element) {\n var items = this._items(),\n placeholder = this.placeholder,\n draggedElement = this.draggedElement;\n\n if(placeholder && element[0] == placeholder[0]) {\n return items.not(draggedElement).index(element);\n } else {\n return items.not(placeholder).index(element);\n }\n },\n\n items: function() {\n var placeholder = this.placeholder,\n items = this._items();\n\n if(placeholder) {\n items = items.not(placeholder);\n }\n\n return items;\n },\n\n _isEmpty: function() {\n return !this.items().length;\n },\n\n _isLastHidden: function() {\n return this.items().length === 1 && this.items().is(\":hidden\");\n }\n\n });\n\n kendo.ui.plugin(Sortable);\n})(window.kendo.jQuery);\n\nreturn window.kendo;\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n\n(function(f, define){\n define('kendo.selectable',[ \"./kendo.core\", \"./kendo.userevents\" ], f);\n})(function(){\n\nvar __meta__ = { // jshint ignore:line\n id: \"selectable\",\n name: \"Selectable\",\n category: \"framework\",\n depends: [ \"core\", \"userevents\" ],\n advanced: true\n};\n\n(function ($, undefined) {\n var kendo = window.kendo,\n Widget = kendo.ui.Widget,\n proxy = $.proxy,\n abs = Math.abs,\n ARIASELECTED = \"aria-selected\",\n SELECTED = \"k-state-selected\",\n ACTIVE = \"k-state-selecting\",\n SELECTABLE = \"k-selectable\",\n CHANGE = \"change\",\n NS = \".kendoSelectable\",\n UNSELECT = \"unselect\",\n UNSELECTING = \"k-state-unselecting\",\n INPUTSELECTOR = \"input,a,textarea,.k-multiselect-wrap,select,button,.k-button>span,.k-button>img,span.k-icon.k-i-arrow-60-down,span.k-icon.k-i-arrow-60-up,label.k-checkbox-label.k-no-text,.k-icon.k-i-collapse,.k-icon.k-i-expand,span.k-numeric-wrap,.k-focusable\",\n msie = kendo.support.browser.msie,\n supportEventDelegation = false,\n extend = $.extend;\n\n (function($) {\n (function() {\n $('
    ')\n .on(\"click\", \">*\", function() {\n supportEventDelegation = true;\n })\n .find(\"span\")\n .trigger(\"click\")\n .end()\n .off();\n })();\n })($);\n\n var Selectable = Widget.extend({\n init: function(element, options) {\n var that = this,\n multiple;\n\n Widget.fn.init.call(that, element, options);\n\n that._marquee = $(\"
    \");\n that._lastActive = null;\n that.element.addClass(SELECTABLE);\n\n that.relatedTarget = that.options.relatedTarget;\n\n multiple = that.options.multiple;\n\n that.userEvents = new kendo.UserEvents(that.element, {\n global: true,\n allowSelection: true,\n filter: (!supportEventDelegation ? \".\" + SELECTABLE + \" \" : \"\") + that.options.filter,\n tap: proxy(that._tap, that),\n touchAction: multiple ? \"none\" : \"pan-x pan-y\"\n });\n\n if (multiple) {\n that.userEvents\n .bind(\"start\", proxy(that._start, that))\n .bind(\"move\", proxy(that._move, that))\n .bind(\"end\", proxy(that._end, that))\n .bind(\"select\", proxy(that._select, that));\n }\n },\n\n events: [CHANGE, UNSELECT],\n\n options: {\n name: \"Selectable\",\n filter: \">*\",\n inputSelectors: INPUTSELECTOR,\n multiple: false,\n relatedTarget: $.noop,\n ignoreOverlapped: false,\n addIdToRanges: false\n },\n\n _isElement: function(target) {\n var elements = this.element;\n var idx, length = elements.length, result = false;\n\n target = target[0];\n\n for (idx = 0; idx < length; idx ++) {\n if (elements[idx] === target) {\n result = true;\n break;\n }\n }\n\n return result;\n },\n\n _tap: function(e) {\n var target = $(e.target),\n that = this,\n ctrlKey = e.event.ctrlKey || e.event.metaKey,\n multiple = that.options.multiple,\n shiftKey = multiple && e.event.shiftKey,\n selectedClass = that.options.selectedClass || SELECTED,\n selected,\n whichCode = e.event.which,\n buttonCode = e.event.button;\n\n //in case of hierarchy or right-click\n if (!that._isElement(target.closest(\".\" + SELECTABLE)) || whichCode && whichCode == 3 || buttonCode && buttonCode == 2) {\n return;\n }\n\n if (!this._allowSelection(e.event.target)) {\n return;\n }\n\n selected = target.hasClass(selectedClass);\n if (!multiple || !ctrlKey) {\n that.clear();\n }\n\n target = target.add(that.relatedTarget(target));\n\n if (shiftKey) {\n that.selectRange(that._firstSelectee(), target, e);\n } else {\n if (selected && ctrlKey) {\n that._unselect(target);\n that._notify(CHANGE, e);\n } else {\n that.value(target, e);\n }\n\n that._lastActive = that._downTarget = target;\n }\n },\n\n _start: function(e) {\n var that = this,\n target = $(e.target),\n selectedClass = that.options.selectedClass || SELECTED,\n selected = target.hasClass(selectedClass),\n currentElement,\n ctrlKey = e.event.ctrlKey || e.event.metaKey;\n\n if (!this._allowSelection(e.event.target)) {\n return;\n }\n\n that._downTarget = target;\n\n //in case of hierarchy\n if (!that._isElement(target.closest(\".\" + SELECTABLE))) {\n that.userEvents.cancel();\n return;\n }\n\n if (that.options.useAllItems) {\n that._items = that.element.find(that.options.filter);\n } else {\n currentElement = target.closest(that.element);\n that._items = currentElement.find(that.options.filter);\n }\n\n e.sender.capture();\n\n that._marquee\n .appendTo(document.body)\n .css({\n left: e.x.client + 1,\n top: e.y.client + 1,\n width: 0,\n height: 0\n });\n\n if (!ctrlKey) {\n that.clear();\n }\n\n target = target.add(that.relatedTarget(target));\n if (selected) {\n that._selectElement(target, true);\n if (ctrlKey) {\n target.addClass(UNSELECTING);\n }\n }\n },\n\n _move: function(e) {\n var that = this,\n position = {\n left: e.x.startLocation > e.x.location ? e.x.location : e.x.startLocation,\n top: e.y.startLocation > e.y.location ? e.y.location : e.y.startLocation,\n width: abs(e.x.initialDelta),\n height: abs(e.y.initialDelta)\n };\n\n that._marquee.css(position);\n\n that._invalidateSelectables(position, (e.event.ctrlKey || e.event.metaKey));\n\n e.preventDefault();\n },\n\n _end: function(e) {\n var that = this,\n rangeSelectedAttr = kendo.attr(\"range-selected\"),\n uid = kendo.guid();\n\n that._marquee.remove();\n\n that._unselect(that.element\n .find(that.options.filter + \".\" + UNSELECTING))\n .removeClass(UNSELECTING);\n\n\n var target = that.element.find(that.options.filter + \".\" + ACTIVE);\n target = target.add(that.relatedTarget(target));\n\n if (that.options.addIdToRanges) {\n for (var i = 0; i < that._currentlyActive.length; i++) {\n $(that._currentlyActive[i]).attr(rangeSelectedAttr, uid);\n }\n }\n\n that.value(target, e);\n that._lastActive = that._downTarget;\n that._items = null;\n },\n\n _invalidateSelectables: function(position, ctrlKey) {\n var idx,\n length,\n target = this._downTarget[0],\n items = this._items,\n selectedClass = this.options.selectedClass || SELECTED,\n related,\n toSelect;\n\n this._currentlyActive = [];\n\n for (idx = 0, length = items.length; idx < length; idx ++) {\n toSelect = items.eq(idx);\n related = toSelect.add(this.relatedTarget(toSelect));\n\n if (collision(toSelect, position)) {\n if(toSelect.hasClass(selectedClass)) {\n if(ctrlKey && target !== toSelect[0]) {\n related.removeClass(selectedClass).addClass(UNSELECTING);\n }\n } else if (!toSelect.hasClass(ACTIVE) && !toSelect.hasClass(UNSELECTING) && !this._collidesWithActiveElement(related, position)) {\n related.addClass(ACTIVE);\n }\n this._currentlyActive.push(related[0]);\n } else {\n if (toSelect.hasClass(ACTIVE)) {\n related.removeClass(ACTIVE);\n } else if(ctrlKey && toSelect.hasClass(UNSELECTING)) {\n related.removeClass(UNSELECTING).addClass(selectedClass);\n }\n }\n }\n },\n\n _collidesWithActiveElement: function (element, marqueeRect) {\n if (!this.options.ignoreOverlapped) {\n return false;\n }\n\n var activeElements = this._currentlyActive;\n var elemRect = element[0].getBoundingClientRect();\n var activeElementRect;\n var collision = false;\n var isRtl = kendo.support.isRtl(element);\n var leftRight = isRtl ? \"right\" : \"left\";\n var tempRect = {};\n\n marqueeRect.right = marqueeRect.left + marqueeRect.width;\n marqueeRect.bottom = marqueeRect.top + marqueeRect.height;\n\n for (var i = 0; i < activeElements.length; i++) {\n activeElementRect = activeElements[i].getBoundingClientRect();\n if (overlaps(elemRect, activeElementRect)) {\n tempRect[leftRight] = leftRight === \"left\" ? activeElementRect.right : activeElementRect.left;\n elemRect = extend({}, elemRect, tempRect);\n if (elemRect.left > elemRect.right) {\n return true;\n }\n collision = !overlaps(elemRect, marqueeRect);\n }\n }\n return collision;\n },\n\n value: function(val, e) {\n var that = this,\n selectElement = proxy(that._selectElement, that);\n\n if(val) {\n val.each(function() {\n selectElement(this);\n });\n\n that._notify(CHANGE, e);\n return;\n }\n\n return that.element.find(that.options.filter + \".\" + (that.options.selectedClass || SELECTED));\n },\n\n selectedRanges: function () {\n var that = this;\n var rangeSelectedAttr = kendo.attr(\"range-selected\");\n var map = {};\n\n that.element.find(\"[\" + rangeSelectedAttr + \"]\").each(function (_, elem) {\n var rangeId = $(elem).attr(rangeSelectedAttr);\n var mapLocation = map[rangeId];\n\n if (!mapLocation) {\n mapLocation = map[rangeId] = [];\n }\n\n mapLocation.push($(elem));\n });\n\n return map;\n },\n\n selectedSingleItems: function () {\n var that = this;\n var rangeSelectedAttr = kendo.attr(\"range-selected\");\n\n return that.element.find(that.options.filter + \".\" + (that.options.selectedClass || SELECTED) + \":not([\" + rangeSelectedAttr + \"])\").toArray().map(function (elem) {\n return $(elem);\n });\n },\n\n _firstSelectee: function() {\n var that = this,\n selected;\n\n if(that._lastActive !== null) {\n return that._lastActive;\n }\n\n selected = that.value();\n return selected.length > 0 ?\n selected[0] :\n that.element.find(that.options.filter)[0];\n },\n\n _selectElement: function(element, preventNotify) {\n var toSelect = $(element),\n selectedClass = this.options.selectedClass || SELECTED,\n isPrevented = !preventNotify && this._notify(\"select\", { element: element });\n\n toSelect.removeClass(ACTIVE);\n if(!isPrevented) {\n toSelect.addClass(selectedClass);\n\n if (this.options.aria) {\n toSelect.attr(ARIASELECTED, true);\n }\n }\n },\n\n _notify: function(name, args) {\n args = args || { };\n return this.trigger(name, args);\n },\n\n _unselect: function(element) {\n if (this.trigger(UNSELECT, { element: element})) {\n return;\n }\n\n var rangeSelectedAttr = kendo.attr(\"range-selected\");\n\n element.removeClass(this.options.selectedClass || SELECTED).removeAttr(rangeSelectedAttr);\n\n if (this.options.aria) {\n element.attr(ARIASELECTED, false);\n }\n\n return element;\n },\n\n _select: function(e) {\n if (this._allowSelection(e.event.target)) {\n if (!msie || (msie && !$(kendo._activeElement()).is(this.options.inputSelectors))) {\n e.preventDefault();\n }\n }\n },\n\n _allowSelection: function(target) {\n if ($(target).is(this.options.inputSelectors)) {\n this.userEvents.cancel();\n this._downTarget = null;\n return false;\n }\n\n return true;\n },\n\n resetTouchEvents: function() {\n this.userEvents.cancel();\n },\n\n clear: function() {\n var items = this.element.find(this.options.filter + \".\" + (this.options.selectedClass || SELECTED));\n this._unselect(items);\n },\n\n selectRange: function(start, end, e) {\n var that = this,\n idx,\n tmp,\n items;\n\n that.clear();\n\n if (that.element.length > 1) {\n items = that.options.continuousItems();\n }\n\n if (!items || !items.length) {\n items = that.element.find(that.options.filter);\n }\n\n start = $.inArray($(start)[0], items);\n end = $.inArray($(end)[0], items);\n\n if (start > end) {\n tmp = start;\n start = end;\n end = tmp;\n }\n\n if (!that.options.useAllItems) {\n end += that.element.length - 1;\n }\n\n for (idx = start; idx <= end; idx ++ ) {\n that._selectElement(items[idx]);\n }\n\n that._notify(CHANGE, e);\n },\n\n destroy: function() {\n var that = this;\n\n Widget.fn.destroy.call(that);\n\n that.element.off(NS);\n\n that.userEvents.destroy();\n\n that._marquee = that._lastActive = that.element = that.userEvents = null;\n }\n });\n\n Selectable.parseOptions = function(selectable) {\n var selectableMode = selectable.mode || selectable;\n var asLowerString = typeof selectableMode === \"string\" && selectableMode.toLowerCase();\n\n return {\n multiple: asLowerString && asLowerString.indexOf(\"multiple\") > -1,\n cell: asLowerString && asLowerString.indexOf(\"cell\") > -1\n };\n };\n\n function collision(element, position) {\n if (!element.is(\":visible\")) {\n return false;\n }\n\n var elementPosition = kendo.getOffset(element),\n right = position.left + position.width,\n bottom = position.top + position.height;\n\n elementPosition.right = elementPosition.left + kendo._outerWidth(element);\n elementPosition.bottom = elementPosition.top + kendo._outerHeight(element);\n\n return !(elementPosition.left > right||\n elementPosition.right < position.left ||\n elementPosition.top > bottom ||\n elementPosition.bottom < position.top);\n }\n\n function overlaps(firstRect, secondRect) {\n return !(firstRect.right <= secondRect.left ||\n firstRect.left >= secondRect.right ||\n firstRect.bottom <= secondRect.top ||\n firstRect.top >= secondRect.bottom);\n }\n\n kendo.ui.plugin(Selectable);\n\n})(window.kendo.jQuery);\n\nreturn window.kendo;\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n\n(function(f, define){\n define('chat/messageBox',[ \"../kendo.core\" ], f);\n})(function(){\n\n(function($, undefined) {\n\n var kendo = window.kendo;\n var Widget = kendo.ui.Widget;\n var extend = $.extend;\n var proxy = $.proxy;\n var DOT = \".\";\n var NS = \".kendoChat\";\n var keys = kendo.keys;\n var SEND_ICON = '';\n var TOGGLE_ICON = ' ';\n\n var messageBoxStyles = {\n input: \"k-input-inner\",\n inputWrapper: \"k-textbox k-input k-input-lg k-input-solid\",\n button: \"k-button\",\n buttonFlat: \"k-button-lg k-button-flat k-button-flat-base\",\n iconButton: \"k-icon-button\",\n buttonIcon: \"k-button-icon\",\n buttonSend: \"k-button-send\",\n buttonToggle: \"k-button-toggle\",\n iconAdd: \"k-icon k-i-add\",\n hidden: \"k-hidden\",\n inputSuffix: \"k-input-suffix\"\n };\n\n var ChatMessageBox = Widget.extend({\n init: function(element, options) {\n Widget.fn.init.call(this, element, options);\n\n this._wrapper();\n\n this._attachEvents();\n\n this._typing = false;\n },\n\n events: [\n ],\n\n options: {\n messages: {\n placeholder: \"Type a message...\",\n toggleButton: \"Toggle toolbar\",\n sendButton: \"Send message\"\n }\n },\n\n destroy: function() {\n Widget.fn.destroy.call(this);\n\n if (this.input) {\n this.input.off(NS);\n this.input.remove();\n this.input = null;\n }\n\n this.element.off(NS);\n this.element.empty();\n },\n\n _wrapper: function() {\n var styles = ChatMessageBox.styles;\n var options = this.options;\n var messages = options.messages;\n var inputId = \"inputId_\" + kendo.guid();\n\n $(\"
  • \";\n var colGroup = \"\";\n var row = \"\";\n\n for (var idx = 0; idx < this.options.columns.length; idx++) {\n var currentColumn = this.options.columns[idx];\n var title = currentColumn.title || currentColumn.field || \"\";\n var template = currentColumn.headerTemplate || title;\n var columnsHeaderTemplate = typeof template !== \"function\" ? kendo.template(template) : template;\n var currentWidth = currentColumn.width;\n var currentWidthInt = parseInt(currentWidth, 10);\n var widthStyle = '';\n\n if (currentWidth && !isNaN(currentWidthInt)) {\n widthStyle += \"style='width:\";\n widthStyle += currentWidthInt;\n widthStyle += percentageUnitsRegex.test(currentWidth) ? \"%\" : \"px\";\n widthStyle += \";'\";\n }\n\n colGroup += \"\";\n\n row += \"\";\n }\n colGroup += \"\";\n row += \"\";\n header += colGroup;\n header += \"\";\n header += row;\n header += \"

    \";\n\n list.columnsHeader = columnsHeader = $(header);\n list.list.prepend(columnsHeader);\n\n this._angularElement(list.columnsHeader, \"compile\");\n },\n\n _noData: function() {\n var list = this;\n var noData = $(list.noData);\n var template = list.options.noDataTemplate === true ? list.options.messages.noData : list.options.noDataTemplate;\n\n list.angular(\"cleanup\", function() { return { elements: noData }; });\n kendo.destroy(noData);\n noData.remove();\n\n if (!template) {\n list.noData = null;\n return;\n }\n\n list.noData = $(NO_DATA_EL).appendTo(list.list);\n list.noDataTemplate = typeof template !== \"function\" ? kendo.template(template) : template;\n },\n\n _footer: function() {\n var list = this;\n var footer = $(list.footer);\n var template = list.options.footerTemplate;\n var footerEl = this.options.columns && this.options.columns.length ? TABLE_FOOTER_EL : LIST_FOOTER_EL;\n\n this._angularElement(footer, \"cleanup\");\n kendo.destroy(footer);\n footer.remove();\n\n if (!template) {\n list.footer = null;\n return;\n }\n\n list.footer = $(footerEl).appendTo(list.list);\n list.footerTemplate = typeof template !== \"function\" ? kendo.template(template) : template;\n },\n\n _listOptions: function(options) {\n var that = this;\n var currentOptions = that.options;\n var virtual = currentOptions.virtual;\n var changeEventOption = { change: proxy(that._listChange, that) };\n var listBoundHandler = proxy(that._listBound, that);\n var focusedElm = that._focused;\n var inputId = that.element.attr(\"id\");\n var labelElm = $(\"label[for=\\\"\" + that.element.attr(\"id\") + \"\\\"]\");\n var labelledBy = focusedElm.attr(ARIA_LABELLEDBY);\n\n if (!labelledBy && labelElm.length) {\n labelledBy = labelElm.attr(\"id\") || that._generateLabelId(labelElm, inputId || kendo.guid());\n }\n\n virtual = typeof virtual === \"object\" ? virtual : {};\n\n options = $.extend({\n autoBind: false,\n selectable: true,\n dataSource: that.dataSource,\n click: proxy(that._click, that),\n activate: proxy(that._activateItem, that),\n columns: currentOptions.columns,\n deactivate: proxy(that._deactivateItem, that),\n dataBinding: function() {\n that.trigger(DATA_BINDING);\n },\n dataBound: listBoundHandler,\n height: currentOptions.height,\n dataValueField: currentOptions.dataValueField,\n dataTextField: currentOptions.dataTextField,\n groupTemplate: currentOptions.groupTemplate,\n fixedGroupTemplate: currentOptions.fixedGroupTemplate,\n template: currentOptions.template,\n ariaLabel: focusedElm.attr(ARIA_LABEL),\n ariaLabelledBy: labelledBy,\n listSize: that._listSize\n }, options, virtual, changeEventOption);\n\n if (!options.template) {\n options.template = \"#:\" + kendo.expr(options.dataTextField, \"data\") + \"#\";\n }\n\n if (currentOptions.$angular) {\n options.$angular = currentOptions.$angular;\n }\n\n return options;\n },\n\n _initList: function() {\n var that = this;\n var listOptions = that._listOptions({\n selectedItemChange: proxy(that._listChange, that)\n });\n\n if (!that.options.virtual) {\n that.listView = new kendo.ui.StaticList(that.ul, listOptions);\n } else {\n that.listView = new kendo.ui.VirtualList(that.ul, listOptions);\n that.list.addClass(\"k-virtual-list\");\n }\n\n that.listView.bind(\"listBound\", proxy(that._listBound, that));\n that._setListValue();\n },\n\n _setListValue: function(value) {\n value = value || this.options.value;\n\n if (value !== undefined) {\n this.listView.value(value)\n .done(proxy(this._updateSelectionState, this));\n }\n },\n\n _updateSelectionState: $.noop,\n\n _listMousedown: function(e) {\n if (!this.filterInput || this.filterInput[0] !== e.target) {\n e.preventDefault();\n }\n },\n\n _isFilterEnabled: function() {\n var filter = this.options.filter;\n return filter && filter !== \"none\";\n },\n\n _hideClear: function() {\n var list = this;\n\n if (list._clear) {\n list._clear.addClass(HIDDENCLASS);\n }\n },\n\n _showClear: function() {\n if (this._clear) {\n this._clear.removeClass(HIDDENCLASS);\n }\n },\n\n _clearValue: function() {\n this._clearText();\n this._accessor(\"\");\n this.listView.value([]);\n\n if (this._isSelect) {\n this._customOption = undefined;\n }\n\n if (this._isFilterEnabled() && !this.options.enforceMinLength) {\n this._filter({ word: \"\", open: false });\n\n if (this.options.highlightFirst) {\n this.listView.focus(0);\n }\n }\n this._change();\n },\n\n _clearText: function() {\n this.text(\"\");\n },\n\n _clearFilter: function() {\n if (!this.options.virtual) {\n this.listView.bound(false);\n }\n\n this._filterSource();\n },\n\n _filterSource: function(filter, force) {\n var that = this;\n var options = that.options;\n var isMultiColumnFiltering = options.filterFields && filter && filter.logic && filter.filters && filter.filters.length;\n var dataSource = that.dataSource;\n var expression = extend({}, dataSource.filter() || {});\n var resetPageSettings = filter || (expression.filters && expression.filters.length && !filter);\n\n var removed = removeFiltersForField(expression, options.dataTextField);\n\n this._clearFilterExpressions(expression);\n\n if ((filter || removed) && that.trigger(\"filtering\", { filter: filter })) {\n return $.Deferred().reject().promise();\n }\n\n var newExpression = {\n filters: [],\n logic: \"and\"\n };\n\n if (isMultiColumnFiltering) {\n newExpression.filters.push(filter);\n } else {\n this._pushFilterExpression(newExpression, filter);\n }\n\n if (isValidFilterExpr(expression)) {\n if (newExpression.logic === expression.logic) {\n newExpression.filters = newExpression.filters.concat(expression.filters);\n } else {\n newExpression.filters.push(expression);\n }\n }\n\n if (that._cascading) {\n this.listView.setDSFilter(newExpression);\n }\n\n var dataSourceState = extend({}, {\n page: resetPageSettings ? 1 : dataSource.page(),\n pageSize: resetPageSettings ? dataSource.options.pageSize : dataSource.pageSize(),\n sort: dataSource.sort(),\n filter: dataSource.filter(),\n group: dataSource.group(),\n aggregate: dataSource.aggregate()\n }, { filter: newExpression });\n\n return dataSource[force ? \"read\" : \"query\"](dataSource._mergeState(dataSourceState));\n },\n\n _pushFilterExpression: function(newExpression, filter) {\n if (isValidFilterExpr(filter) && filter.value !== \"\") {\n newExpression.filters.push(filter);\n }\n },\n\n _clearFilterExpressions: function(expression) {\n if (!expression.filters) {\n return;\n }\n\n var filtersToRemove;\n\n for (var i = 0; i < expression.filters.length; i++) {\n if (\"fromFilter\" in expression.filters[i]) {\n filtersToRemove = i;\n }\n }\n\n if (!isNaN(filtersToRemove)) {\n expression.filters.splice(filtersToRemove, 1);\n }\n },\n\n _angularElement: function(element, action) {\n if (!element) {\n return;\n }\n\n this.angular(action, function() {\n return { elements: element };\n });\n },\n\n _renderNoData: function() {\n var list = this;\n var noData = list.noData;\n\n if (!noData) {\n return;\n }\n\n this._angularElement(noData, \"cleanup\");\n noData.html(list.noDataTemplate({ instance: list }));\n this._angularElement(noData, \"compile\");\n },\n\n _toggleNoData: function(show) {\n $(this.noData).toggle(show);\n },\n\n _toggleHeader: function(show) {\n var groupHeader = this.listView.content.prev(FIXED_GROUP_HEADER);\n groupHeader.toggle(show);\n },\n\n _renderFooter: function() {\n var list = this,\n footer = list.footer ? this.options.columns && this.options.columns.length ? list.footer.children().first() : list.footer : null;\n\n if (!footer) {\n return;\n }\n\n this._angularElement(footer, \"cleanup\");\n footer.html(list.footerTemplate({ instance: list }));\n this._angularElement(footer, \"compile\");\n },\n\n _allowOpening: function() {\n return this.options.noDataTemplate || this.dataSource.flatView().length;\n },\n\n _initValue: function() {\n var that = this,\n value = that.options.value;\n\n if (value !== null) {\n that.element.val(value);\n } else {\n value = that._accessor();\n that.options.value = value;\n }\n\n that._old = value;\n },\n\n _ignoreCase: function() {\n var that = this,\n model = that.dataSource.reader.model,\n field;\n\n if (model && model.fields) {\n field = model.fields[that.options.dataTextField];\n\n if (field && field.type && field.type !== \"string\") {\n that.options.ignoreCase = false;\n }\n }\n },\n\n _focus: function(candidate) {\n return this.listView.focus(candidate);\n },\n\n _filter: function(options) {\n var that = this;\n var widgetOptions = that.options;\n var word = options.word;\n var filterFields = widgetOptions.filterFields;\n var field = widgetOptions.dataTextField;\n var expression;\n\n if (filterFields && filterFields.length) {\n expression = {\n logic: \"or\",\n filters: [],\n fromFilter: true\n };\n for (var i = 0; i < filterFields.length; i++) {\n this._pushFilterExpression(expression, that._buildExpression(word, filterFields[i]));\n }\n } else {\n expression = that._buildExpression(word, field);\n }\n\n that._open = options.open;\n that._filterSource(expression);\n },\n\n _buildExpression: function(value, field) {\n var that = this;\n var widgetOptions = that.options;\n var ignoreCase = widgetOptions.ignoreCase;\n var accentFoldingFiltering = that.dataSource.options.accentFoldingFiltering;\n\n return {\n value: ignoreCase ? (accentFoldingFiltering ? value.toLocaleLowerCase(accentFoldingFiltering) : value.toLowerCase()) : value,\n field: field,\n operator: widgetOptions.filter,\n ignoreCase: ignoreCase\n };\n },\n\n _clearButton: function() {\n var list = this;\n var clearTitle = list.options.messages.clear;\n\n if (!list._clear) {\n list._clear = $('').attr({\n \"role\": \"button\",\n \"tabIndex\": -1\n });\n }\n\n if (!list.options.clearButton) {\n list._clear.remove();\n }\n this._hideClear();\n },\n\n search: function(word) {\n var options = this.options;\n\n word = typeof word === \"string\" ? word : this._inputValue();\n\n clearTimeout(this._typingTimeout);\n\n if ((!options.enforceMinLength && !word.length) || word.length >= options.minLength) {\n this._state = \"filter\";\n if (this.listView) {\n this.listView._emptySearch = !kendo.trim(word).length;\n }\n\n if (!this._isFilterEnabled()) {\n this._searchByWord(word);\n } else {\n this._filter({ word: word, open: true });\n }\n }\n },\n\n current: function(candidate) {\n return this._focus(candidate);\n },\n\n items: function() {\n return this.ul[0].children;\n },\n\n destroy: function() {\n var that = this;\n var ns = that.ns;\n\n Widget.fn.destroy.call(that);\n\n that._unbindDataSource();\n\n that.listView.destroy();\n that.list.off(ns);\n\n that.popup.destroy();\n\n if (that._form) {\n that._form.off(\"reset\", that._resetHandler);\n }\n },\n\n dataItem: function(index) {\n var that = this;\n\n if (index === undefined) {\n return that.listView.selectedDataItems()[0];\n }\n\n if (typeof index !== \"number\") {\n if (that.options.virtual) {\n return that.dataSource.getByUid($(index).data(\"uid\"));\n }\n\n index = $(that.items()).index(index);\n }\n\n return that.dataSource.flatView()[index];\n },\n\n _activateItem: function() {\n var current = this.listView.focus();\n if (current) {\n this._focused.add(this.filterInput).attr(ARIA_ACTIVEDESCENDANT, current.attr(\"id\"));\n }\n },\n\n _deactivateItem: function() {\n this._focused.add(this.filterInput).removeAttr(ARIA_ACTIVEDESCENDANT);\n },\n\n _accessors: function() {\n var that = this;\n var element = that.element;\n var options = that.options;\n var getter = kendo.getter;\n var textField = element.attr(kendo.attr(\"text-field\"));\n var valueField = element.attr(kendo.attr(\"value-field\"));\n\n if (!options.dataTextField && textField) {\n options.dataTextField = textField;\n }\n\n if (!options.dataValueField && valueField) {\n options.dataValueField = valueField;\n }\n\n that._text = getter(options.dataTextField);\n that._value = getter(options.dataValueField);\n },\n\n _aria: function(id) {\n var that = this,\n options = that.options,\n element = that._focused,\n autocomplete;\n\n if (options.suggest !== undefined) {\n if (options.filter === \"none\") {\n if (options.suggest === true) {\n autocomplete = \"inline\";\n } else {\n autocomplete = \"none\";\n }\n } else {\n if (options.suggest === true) {\n autocomplete = \"both\";\n } else {\n autocomplete = \"list\";\n }\n }\n\n element.attr(ARIA_AUTOCOMPLETE, autocomplete);\n }\n\n id = id ? id + \" \" + that.ul[0].id : that.ul[0].id;\n\n element.attr({\n \"aria-owns\": id,\n \"aria-controls\": id\n });\n\n if (that.filterInput && that.filterInput.length > 0) {\n that.filterInput.attr(ARIA_CONTROLS, id);\n }\n\n that.ul.attr(ARIA_LIVE, !that._isFilterEnabled() ? \"off\" : \"polite\");\n\n that._ariaLabel();\n },\n\n _ariaLabel: function() {\n var that = this;\n var focusedElm = that._focused;\n var inputElm = that.element;\n var inputId = inputElm.attr(\"id\");\n var labelElm = $(\"label[for=\\\"\" + inputId + \"\\\"]\");\n var ariaLabel = inputElm.attr(ARIA_LABEL);\n var ariaLabelledBy = inputElm.attr(ARIA_LABELLEDBY);\n\n if (focusedElm === inputElm) {\n return;\n }\n\n if (ariaLabel) {\n focusedElm.attr(ARIA_LABEL, ariaLabel);\n } else if (ariaLabelledBy) {\n focusedElm.attr(ARIA_LABELLEDBY, ariaLabelledBy);\n } else if (labelElm.length) {\n var labelId = labelElm.attr(\"id\") || that._generateLabelId(labelElm, inputId || kendo.guid());\n focusedElm.attr(ARIA_LABELLEDBY, labelId);\n }\n },\n\n _generateLabelId: function(label, inputId) {\n var labelId = inputId + LABELIDPART;\n label.attr(\"id\", labelId);\n\n return labelId;\n },\n\n _blur: function() {\n var that = this;\n\n that._change();\n that.close();\n that._userTriggered = false;\n },\n\n _isValueChanged: function(value) {\n return value !== unifyType(this._old, typeof value);\n },\n\n _change: function() {\n var that = this;\n var index = that.selectedIndex;\n var optionValue = that.options.value;\n var value = that.value();\n var trigger;\n\n if (that._isSelect && !that.listView.bound() && optionValue) {\n value = optionValue;\n }\n\n if (that._isValueChanged(value)) {\n trigger = true;\n } else if (that._valueBeforeCascade !== undefined && that._valueBeforeCascade !== unifyType(that._old, typeof that._valueBeforeCascade) && that._userTriggered) {\n trigger = true;\n } else if (index !== undefined && index !== that._oldIndex && !that.listView.isFiltered()) {\n trigger = true;\n }\n\n if (trigger) {\n\n if (that._old === null || that._old === \"\" || value === \"\") {\n that._valueBeforeCascade = that._old = value;\n } else {\n if (that.dataItem()) {\n that._valueBeforeCascade = that._old = that.options.dataValueField ? that.dataItem()[that.options.dataValueField] : that.dataItem();\n } else {\n that._valueBeforeCascade = that._old = null;\n }\n }\n that._oldIndex = index;\n\n if (!that._typing) {\n // trigger the DOM change event so any subscriber gets notified\n that.element.trigger(CHANGE);\n }\n\n that.trigger(CHANGE);\n }\n\n that.typing = false;\n },\n\n _data: function() {\n return this.dataSource.view();\n },\n\n _enable: function() {\n var that = this,\n options = that.options,\n disabled = that.element.is(\"[disabled]\");\n\n if (options.enable !== undefined) {\n options.enabled = options.enable;\n }\n\n if (!options.enabled || disabled) {\n that.enable(false);\n } else {\n that.readonly(that.element.is(\"[readonly]\"));\n }\n },\n\n _dataValue: function(dataItem) {\n var value = this._value(dataItem);\n\n if (value === undefined) {\n value = this._text(dataItem);\n }\n\n return value;\n },\n\n _offsetHeight: function() {\n var offsetHeight = 0;\n var siblings = this.listView.content.parent().prevAll(\":visible\");\n\n siblings.each(function() {\n var element = $(this);\n\n offsetHeight += outerHeight(element, true);\n });\n\n return offsetHeight;\n },\n\n _height: function(length) {\n var that = this;\n var list = that.list;\n var height = that.options.height;\n var visible = that.popup.visible();\n var isMccb = this.options.columns && this.options.columns.length;\n var offsetTop, popups;\n\n if (length || that.options.noDataTemplate) {\n // Check where animation container stays\n popups = list.parent().add(list.closest(\".k-animation-container\")).show();\n\n if (!list.parent().is(\":visible\")) {\n popups.hide();\n return;\n }\n\n height = that.listView.content[0].scrollHeight > height ? height : \"auto\";\n\n popups.height(height);\n\n if (height !== \"auto\") {\n offsetTop = that._offsetHeight();\n\n height = height - offsetTop;\n\n if (isMccb) {\n height = height - (outerHeight($(that.footer)) || 0) - (outerHeight($(that.columnsHeader)) || 0);\n }\n }\n\n if (isMccb) {\n that.listView.content.outerHeight(height);\n } else {\n that.listView.content.parent().outerHeight(height);\n }\n\n if (!visible) {\n popups.hide();\n }\n }\n\n return height;\n },\n\n _openHandler: function(e) {\n this._adjustListWidth();\n\n if (this.trigger(OPEN)) {\n e.preventDefault();\n } else {\n this._focused.attr(ARIA_EXPANDED, true);\n this.ul.attr(ARIA_HIDDEN, false);\n }\n },\n\n _adjustListWidth: function() {\n var that = this,\n list = that.list.parent(),\n width = list[0].style.width,\n wrapper = that.wrapper,\n computedStyle, computedWidth;\n\n if (!list.data(WIDTH) && width) {\n return;\n }\n\n computedStyle = window.getComputedStyle ? window.getComputedStyle(wrapper[0], null) : 0;\n computedWidth = parseFloat(computedStyle && computedStyle.width) || outerWidth(wrapper);\n\n if (computedStyle && browser.msie) { // getComputedStyle returns different box in IE.\n computedWidth += parseFloat(computedStyle.paddingLeft) + parseFloat(computedStyle.paddingRight) + parseFloat(computedStyle.borderLeftWidth) + parseFloat(computedStyle.borderRightWidth);\n }\n\n if (list.css(\"box-sizing\") !== \"border-box\") {\n width = computedWidth - (outerWidth(list) - list.width());\n } else {\n width = computedWidth;\n }\n\n list.css({\n fontFamily: wrapper.css(\"font-family\"),\n width: that.options.autoWidth ? \"auto\" : width,\n minWidth: width,\n whiteSpace: that.options.autoWidth ? \"nowrap\" : \"normal\"\n })\n .data(WIDTH, width);\n\n return true;\n },\n\n _closeHandler: function(e) {\n if (this.trigger(CLOSE)) {\n e.preventDefault();\n } else {\n this._focused.attr(ARIA_EXPANDED, false);\n this.ul.attr(ARIA_HIDDEN, true);\n }\n },\n\n _focusItem: function() {\n var listView = this.listView;\n var noFocusedItem = !listView.focus();\n var index = last(listView.select());\n\n if (index === undefined && this.options.highlightFirst && noFocusedItem) {\n index = 0;\n }\n\n if (index !== undefined) {\n listView.focus(index);\n } else if (noFocusedItem) {\n listView.scrollToIndex(0);\n }\n },\n\n _calculateGroupPadding: function(height) {\n var li = this.ul.children(\".k-first\").first();\n var groupHeader = this.listView.content.prev(FIXED_GROUP_HEADER);\n var padding = 0;\n var direction = 'right';\n\n if (groupHeader[0] && groupHeader[0].style.display !== \"none\") {\n if (height !== \"auto\") {\n padding = kendo.support.scrollbar();\n }\n\n if (this.element.parents('.k-rtl').length) {\n direction = 'left';\n }\n\n padding += parseFloat(li.css(\"border-\" + direction + \"-width\"), 10) + parseFloat(li.children(GROUP_LABEL).css(\"padding-\" + direction), 10);\n groupHeader.css(\"padding-\" + direction, padding);\n }\n },\n\n _calculatePopupHeight: function(force) {\n var height = this._height(this.dataSource.flatView().length || force);\n this._calculateGroupPadding(height);\n this._calculateColumnsHeaderPadding(height);\n },\n\n _calculateColumnsHeaderPadding: function(height) {\n if (this.options.columns && this.options.columns.length) {\n var list = this;\n var isRtl = support.isRtl(list.wrapper);\n var scrollbar = kendo.support.scrollbar();\n\n list.columnsHeader.css((isRtl ? \"padding-left\" : \"padding-right\"), height !== \"auto\" ? scrollbar : 0);\n }\n },\n\n _refreshScroll: function() {\n var listView = this.listView;\n var enableYScroll = listView.element.height() > listView.content.height();\n\n if (this.options.autoWidth) {\n listView.content.css({\n overflowX: \"hidden\",\n overflowY: enableYScroll ? \"scroll\" : \"auto\"\n });\n }\n },\n\n _resizePopup: function(force) {\n if (this.options.virtual) {\n return;\n }\n\n if (!this.popup.element.is(\":visible\")) {\n this.popup.one(\"open\", (function(force) {\n return proxy(function() {\n this._calculatePopupHeight(force);\n }, this);\n }).call(this, force));\n\n this.popup.one(ACTIVATE, proxy(this._refreshScroll, this));\n } else {\n this._calculatePopupHeight(force);\n }\n },\n\n _popup: function() {\n var list = this;\n\n list.list.wrap(\"
    \");\n\n list.popup = new ui.Popup(list.list.parent(), extend({}, list.options.popup, {\n anchor: list.wrapper,\n open: proxy(list._openHandler, list),\n close: proxy(list._closeHandler, list),\n animation: list.options.animation,\n isRtl: support.isRtl(list.wrapper),\n autosize: list.options.autoWidth\n }));\n\n list.popup.element.prepend(list.header)\n .on(MOUSEDOWN + this.ns, proxy(this._listMousedown, this));\n },\n\n _toggleHover: function(e) {\n $(e.currentTarget).toggleClass(HOVER, e.type === MOUSEENTER);\n },\n\n _toggle: function(open, preventFocus) {\n var that = this;\n var touchEnabled = support.mobileOS && (support.touch || support.MSPointers || support.pointers);\n\n open = open !== undefined ? open : !that.popup.visible();\n\n if (!preventFocus && !touchEnabled && that._focused[0] !== activeElement()) {\n that._prevent = true;\n that._focused.trigger(FOCUS);\n that._prevent = false;\n }\n\n that[open ? OPEN : CLOSE]();\n },\n\n _triggerCascade: function() {\n var that = this;\n\n if (!that._cascadeTriggered || that.value() !== unifyType(that._cascadedValue, typeof that.value())) {\n that._cascadedValue = that.value();\n that._cascadeTriggered = true;\n that.trigger(CASCADE, { userTriggered: that._userTriggered });\n }\n },\n\n _triggerChange: function() {\n if (this._valueBeforeCascade !== this.value()) {\n this.trigger(CHANGE);\n }\n },\n\n _unbindDataSource: function() {\n var that = this;\n\n that.dataSource.unbind(REQUESTSTART, that._requestStartHandler)\n .unbind(REQUESTEND, that._requestEndHandler)\n .unbind(\"error\", that._errorHandler);\n },\n\n requireValueMapper: function(options, value) {\n var hasValue = (options.value instanceof Array ? options.value.length : options.value) || (value instanceof Array ? value.length : value);\n if (hasValue && options.virtual && typeof options.virtual.valueMapper !== \"function\") {\n throw new Error(\"ValueMapper is not provided while the value is being set. See http://docs.telerik.com/kendo-ui/controls/editors/combobox/virtualization#the-valuemapper-function\");\n }\n }\n });\n\n function unifyType(value, type) {\n if (value !== undefined && value !== \"\" && value !== null) {\n if (type === \"boolean\") {\n if (typeof value !== \"boolean\") {\n value = value.toString().toLowerCase() === \"true\";\n }\n value = Boolean(value);\n } else if (type === \"number\") {\n value = Number(value);\n } else if (type === \"string\") {\n value = value.toString();\n }\n }\n\n return value;\n }\n\n extend(List, {\n inArray: function(node, parentNode) {\n var idx, length, siblings = parentNode.children;\n\n if (!node || node.parentNode !== parentNode) {\n return -1;\n }\n\n for (idx = 0, length = siblings.length; idx < length; idx++) {\n if (node === siblings[idx]) {\n return idx;\n }\n }\n\n return -1;\n },\n unifyType: unifyType\n });\n\n kendo.ui.List = List;\n\n ui.Select = List.extend({\n init: function(element, options) {\n List.fn.init.call(this, element, options);\n this._initial = this.element.val();\n },\n\n setDataSource: function(dataSource) {\n var that = this;\n var parent;\n\n that.options.dataSource = dataSource;\n\n that._dataSource();\n\n if (that.listView.bound()) {\n that._initialIndex = null;\n that.listView._current = null;\n }\n\n that.listView.setDataSource(that.dataSource);\n\n if (that.options.autoBind) {\n that.dataSource.fetch();\n }\n\n parent = that._parentWidget();\n\n if (parent) {\n that._cascadeSelect(parent);\n }\n },\n\n close: function() {\n this.popup.close();\n },\n\n select: function(candidate) {\n var that = this;\n\n if (candidate === undefined) {\n return that.selectedIndex;\n } else {\n return that._select(candidate).done(function() {\n that._cascadeValue = that._old = that._accessor();\n that._oldIndex = that.selectedIndex;\n });\n }\n },\n\n _accessor: function(value, idx) {\n return this[this._isSelect ? \"_accessorSelect\" : \"_accessorInput\"](value, idx);\n },\n\n _accessorInput: function(value) {\n var element = this.element[0];\n\n if (value === undefined) {\n return element.value;\n } else {\n if (value === null) {\n value = \"\";\n }\n element.value = value;\n }\n },\n\n _accessorSelect: function(value, idx) {\n var element = this.element[0];\n var hasValue;\n\n if (value === undefined) {\n return getSelectedOption(element).value || \"\";\n }\n\n getSelectedOption(element).selected = false;\n\n if (idx === undefined) {\n idx = -1;\n }\n\n hasValue = (value !== null && value !== \"\");\n\n if (hasValue && idx == -1) {\n this._custom(value);\n } else {\n if (value) {\n element.value = value;\n } else {\n element.selectedIndex = idx;\n }\n }\n },\n\n _syncValueAndText: function() {\n return true;\n },\n\n _custom: function(value) {\n var that = this;\n var element = that.element;\n var custom = that._customOption;\n\n if (!custom) {\n custom = $(\"\";\n options += option;\n }\n\n element.html(options);\n\n if (value !== undefined) {\n htmlElement.value = value;\n if (htmlElement.value && !value) {\n htmlElement.selectedIndex = -1;\n }\n }\n\n if (htmlElement.selectedIndex !== -1) {\n option = getSelectedOption(htmlElement);\n\n if (option) {\n option.setAttribute(SELECTED, SELECTED);\n }\n }\n },\n\n _reset: function() {\n var that = this,\n element = that.element,\n formId = element.attr(\"form\"),\n form = formId ? $(\"#\" + formId) : element.closest(\"form\");\n\n if (form[0]) {\n that._resetHandler = function() {\n setTimeout(function() {\n that.value(that._initial);\n });\n };\n\n that._form = form.on(\"reset\", that._resetHandler);\n }\n },\n\n _parentWidget: function() {\n var name = this.options.name;\n\n if (!this.options.cascadeFrom) {\n return;\n }\n\n var parentElement = $(\"#\" + this.options.cascadeFrom);\n var parent = parentElement.data(\"kendo\" + name);\n\n if (!parent) {\n for (var i = 0; i < alternativeNames[name].length; i += 1) {\n parent = parentElement.data(\"kendo\" + alternativeNames[name][i]);\n\n if (!!parent) {\n break;\n }\n }\n }\n\n return parent;\n },\n\n _cascade: function() {\n var that = this;\n var options = that.options;\n var cascade = options.cascadeFrom;\n var parent;\n\n if (cascade) {\n parent = that._parentWidget();\n\n if (!parent) {\n return;\n }\n\n that._cascadeHandlerProxy = proxy(that._cascadeHandler, that);\n that._cascadeFilterRequests = [];\n\n options.autoBind = false;\n\n parent.bind(\"set\", function() { //will cascade\n that.one(\"set\", function(e) { //get your value\n that._selectedValue = e.value || that._accessor();\n });\n });\n\n parent.first(CASCADE, that._cascadeHandlerProxy);\n\n //refresh was called\n if (parent.listView.bound()) {\n that._toggleCascadeOnFocus();\n that._cascadeSelect(parent);\n } else {\n parent.one(DATA_BOUND, function() {\n that._toggleCascadeOnFocus();\n if (parent.popup.visible()) {\n parent._focused.trigger(FOCUS);\n }\n });\n\n if (!parent.value()) {\n that.enable(false);\n }\n }\n }\n },\n\n _toggleCascadeOnFocus: function() {\n var that = this;\n var parent = that._parentWidget();\n var focusout = isIE && parent instanceof ui.DropDownList ? BLUR : FOCUSOUT;\n\n parent._focused.add(parent.filterInput).on(FOCUS, function() {\n parent.unbind(CASCADE, that._cascadeHandlerProxy);\n parent.unbind(CHANGE, that._cascadeHandlerProxy);\n parent.first(CHANGE, that._cascadeHandlerProxy);\n });\n\n parent._focused.add(parent.filterInput).on(focusout, function() {\n parent.unbind(CHANGE, that._cascadeHandlerProxy);\n parent.unbind(CASCADE, that._cascadeHandlerProxy);\n parent.first(CASCADE, that._cascadeHandlerProxy);\n });\n },\n\n _cascadeHandler: function(e) {\n var parent = this._parentWidget();\n var valueBeforeCascade = this.value();\n\n this._userTriggered = e.userTriggered || parent._userTriggered;\n\n if (this.listView.bound()) {\n this._clearSelection(parent, true);\n }\n\n this._cascadeSelect(parent, valueBeforeCascade);\n },\n\n _cascadeChange: function(parent) {\n var that = this;\n var value = that._accessor() || that._selectedValue;\n\n if (!that._cascadeFilterRequests.length) {\n that._selectedValue = null;\n }\n\n if (that._userTriggered) {\n that._clearSelection(parent, true);\n } else if (value) {\n if (value !== unifyType(that.listView.value()[0], typeof value)) {\n that.value(value);\n }\n\n if (!that.dataSource.view()[0] || that.selectedIndex === -1) {\n that._clearSelection(parent, true);\n }\n } else if (that.dataSource.flatView().length) {\n that.select(that.options.index);\n }\n\n that.enable();\n that._triggerCascade();\n that._triggerChange();\n that._userTriggered = false;\n },\n\n _cascadeSelect: function(parent, valueBeforeCascade) {\n var that = this;\n var dataItem = parent.dataItem();\n var filterValue = dataItem ? dataItem[that.options.cascadeFromParentField] || parent._value(dataItem) : null;\n var valueField = that.options.cascadeFromField || parent.options.dataValueField;\n var expressions;\n\n that._valueBeforeCascade = valueBeforeCascade !== undefined ? valueBeforeCascade : that.value();\n\n if (filterValue || filterValue === 0) {\n expressions = that.dataSource.filter() || {};\n removeFiltersForField(expressions, valueField);\n\n var handler = function() {\n var currentHandler = that._cascadeFilterRequests.shift();\n if (currentHandler) {\n that.unbind('dataBound', currentHandler);\n }\n\n currentHandler = that._cascadeFilterRequests[0];\n if (currentHandler) {\n that.first('dataBound', currentHandler);\n }\n\n that._cascadeChange(parent);\n };\n\n that._cascadeFilterRequests.push(handler);\n\n if (that._cascadeFilterRequests.length === 1) {\n that.first('dataBound', handler);\n }\n\n that._cascading = true;\n that._filterSource({\n field: valueField,\n operator: \"eq\",\n value: filterValue\n });\n that._cascading = false;\n } else {\n that.enable(false);\n that._clearSelection(parent);\n that._triggerCascade();\n that._triggerChange();\n that._userTriggered = false;\n }\n }\n });\n\n var STATIC_LIST_NS = \".StaticList\";\n\n var StaticList = kendo.ui.DataBoundWidget.extend({\n init: function(element, options) {\n Widget.fn.init.call(this, element, options);\n\n this.element.attr(\"role\", \"listbox\")\n .on(CLICK + STATIC_LIST_NS, \"li\", proxy(this._click, this))\n .on(MOUSEENTER + STATIC_LIST_NS, \"li\", function() { $(this).addClass(HOVER); })\n .on(MOUSELEAVE + STATIC_LIST_NS, \"li\", function() { $(this).removeClass(HOVER); });\n\n if (options && options.ariaLabel) {\n this.element.attr(ARIA_LABEL, options.ariaLabel);\n } else if (options && options.ariaLabelledBy) {\n this.element.attr(ARIA_LABELLEDBY, options.ariaLabelledBy);\n }\n\n if (support.touch) {\n this._touchHandlers();\n }\n\n if (this.options.selectable === \"multiple\") {\n this.element.attr(ARIA_MULTISELECTABLE, true);\n }\n\n if (this.options.columns && this.options.columns.length) {\n var thead = this.element.parent().find('.k-table-thead');\n var row = $('' +\n '' +\n '');\n\n thead.append(row);\n\n this.header = row.find(\".k-table-th\");\n\n this.content = this.element.wrap(\"
    \").parent();\n\n this.element.addClass(TABLE_LIST);\n } else {\n this.content = this.element.wrap(\"
    \").parent();\n this.header = this.content.before('
    ').prev();\n this.element.addClass(LIST_UL);\n }\n\n this.bound(false);\n\n this._optionID = kendo.guid();\n\n this._selectedIndices = [];\n\n this._view = [];\n this._dataItems = [];\n this._values = [];\n\n var value = this.options.value;\n\n if (value) {\n this._values = Array.isArray(value) ? value.slice(0) : [value];\n }\n\n this._getter();\n this._templates();\n\n this.setDataSource(this.options.dataSource);\n\n this._onScroll = proxy(function() {\n var that = this;\n clearTimeout(that._scrollId);\n\n that._scrollId = setTimeout(function() {\n that._renderHeader();\n }, 50);\n }, this);\n },\n\n options: {\n name: \"StaticList\",\n dataValueField: null,\n valuePrimitive: false,\n selectable: true,\n template: null,\n groupTemplate: null,\n fixedGroupTemplate: null,\n ariaLabel: null,\n ariaLabelledBy: null\n },\n\n events: [\n CLICK,\n CHANGE,\n ACTIVATE,\n DEACTIVATE,\n DATA_BINDING,\n DATA_BOUND,\n SELECTED_ITEM_CHANGE\n ],\n\n setDataSource: function(source) {\n var that = this;\n var dataSource = source || {};\n var value;\n\n dataSource = Array.isArray(dataSource) ? { data: dataSource } : dataSource;\n dataSource = kendo.data.DataSource.create(dataSource);\n\n if (that.dataSource) {\n that.dataSource.unbind(CHANGE, that._refreshHandler);\n\n value = that.value();\n\n that.value([]);\n that.bound(false);\n\n that.value(value);\n } else {\n that._refreshHandler = proxy(that.refresh, that);\n }\n\n that.setDSFilter(dataSource.filter());\n\n that.dataSource = dataSource.bind(CHANGE, that._refreshHandler);\n that._fixedHeader();\n },\n\n _touchHandlers: function() {\n var that = this;\n var startY;\n var endY;\n var tapPosition = function(event) {\n return (event.originalEvent || event).changedTouches[0].pageY;\n };\n\n that.element.on(\"touchstart\" + STATIC_LIST_NS, function(e) {\n startY = tapPosition(e);\n });\n\n that.element.on(\"touchend\" + STATIC_LIST_NS, function(e) {\n if (e.isDefaultPrevented()) {\n return;\n }\n\n endY = tapPosition(e);\n\n if (Math.abs(endY - startY) < 10) {\n that._touchTriggered = true;\n that._triggerClick($(e.target).closest(ITEMSELECTOR).get(0));\n }\n });\n },\n\n skip: function() {\n return this.dataSource.skip();\n },\n\n setOptions: function(options) {\n Widget.fn.setOptions.call(this, options);\n\n this._getter();\n this._templates();\n this._render();\n },\n\n destroy: function() {\n this.element.off(STATIC_LIST_NS);\n\n if (this._refreshHandler) {\n this.dataSource.unbind(CHANGE, this._refreshHandler);\n }\n\n clearTimeout(this._scrollId);\n\n Widget.fn.destroy.call(this);\n },\n\n dataItemByIndex: function(index) {\n return this.dataSource.flatView()[index];\n },\n\n screenHeight: function() {\n return this.content[0].clientHeight;\n },\n\n scrollToIndex: function(index) {\n var item = this.element[0].children[index];\n\n if (item) {\n this.scroll(item);\n }\n },\n\n scrollWith: function(value) {\n this.content.scrollTop(this.content.scrollTop() + value);\n },\n\n scroll: function(item) {\n if (!item) {\n return;\n }\n\n if (item[0]) {\n item = item[0];\n }\n\n var content = this.content[0],\n itemOffsetTop = item.offsetTop,\n itemOffsetHeight = item.offsetHeight,\n contentScrollTop = content.scrollTop,\n contentOffsetHeight = content.clientHeight,\n bottomDistance = itemOffsetTop + itemOffsetHeight;\n\n if (contentScrollTop > itemOffsetTop) {\n contentScrollTop = itemOffsetTop;\n } else if (bottomDistance > (contentScrollTop + contentOffsetHeight)) {\n contentScrollTop = (bottomDistance - contentOffsetHeight);\n }\n\n content.scrollTop = contentScrollTop;\n },\n\n selectedDataItems: function(dataItems) {\n if (dataItems === undefined) {\n return this._dataItems.slice();\n }\n\n this._dataItems = dataItems;\n this._values = this._getValues(dataItems);\n },\n\n _getValues: function(dataItems) {\n var getter = this._valueGetter;\n\n return $.map(dataItems, function(dataItem) {\n return getter(dataItem);\n });\n },\n\n focusNext: function() {\n var current = this.focus();\n\n if (!current) {\n current = 0;\n } else {\n current = current.next();\n }\n\n this.focus(current);\n },\n\n focusPrev: function() {\n var current = this.focus();\n\n if (!current) {\n current = this.element[0].children.length - 1;\n } else {\n current = current.prev();\n }\n\n this.focus(current);\n },\n\n focusFirst: function() {\n this.focus(this.element[0].children[0]);\n },\n\n focusLast: function() {\n this.focus(last(this.element[0].children));\n },\n\n focus: function(candidate) {\n var that = this;\n var id = that._optionID;\n var hasCandidate;\n\n if (candidate === undefined) {\n return that._current;\n }\n\n candidate = last(that._get(candidate));\n candidate = $(this.element[0].children[candidate]);\n\n if (that._current) {\n that._current\n .removeClass(FOCUSED)\n .removeAttr(ID);\n\n that.trigger(DEACTIVATE);\n }\n\n hasCandidate = !!candidate[0];\n\n if (hasCandidate) {\n candidate.addClass(FOCUSED);\n that.scroll(candidate);\n\n candidate.attr(\"id\", id);\n }\n\n that._current = hasCandidate ? candidate : null;\n that.trigger(ACTIVATE);\n },\n\n focusIndex: function() {\n return this.focus() ? this.focus().index() : undefined;\n },\n\n skipUpdate: function(skipUpdate) {\n this._skipUpdate = skipUpdate;\n },\n\n select: function(indices) {\n var that = this;\n var selectable = that.options.selectable;\n var singleSelection = selectable !== \"multiple\" && selectable !== false;\n var selectedIndices = that._selectedIndices;\n var uiSelectedIndices = [this.element.find(\".k-selected\").index()];\n\n var added = [];\n var removed = [];\n var result;\n\n if (indices === undefined) {\n return selectedIndices.slice();\n }\n\n indices = that._get(indices);\n\n if (indices.length === 1 && indices[0] === -1) {\n indices = [];\n }\n\n var deferred = $.Deferred().resolve();\n var filtered = that.isFiltered();\n\n if (filtered && !singleSelection && that._deselectFiltered(indices)) {\n return deferred;\n }\n\n if (singleSelection && !filtered &&\n $.inArray(last(indices), selectedIndices) !== -1 && $.inArray(last(indices), uiSelectedIndices) !== -1) {\n\n if (that._dataItems.length && that._view.length) {\n that._dataItems = [that._view[selectedIndices[0]].item];\n }\n\n return deferred;\n }\n\n result = that._deselect(indices);\n\n removed = result.removed;\n indices = result.indices;\n\n if (indices.length) {\n if (singleSelection) {\n indices = [last(indices)];\n }\n\n added = that._select(indices);\n }\n\n if (added.length || removed.length) {\n that._valueComparer = null;\n that.trigger(CHANGE, {\n added: added,\n removed: removed\n });\n }\n\n return deferred;\n },\n\n removeAt: function(position) {\n this._selectedIndices.splice(position, 1);\n this._values.splice(position, 1);\n this._valueComparer = null;\n\n return {\n position: position,\n dataItem: this._dataItems.splice(position, 1)[0]\n };\n },\n\n setValue: function(value) {\n value = Array.isArray(value) || value instanceof ObservableArray ? value.slice(0) : [value];\n\n this._values = value;\n\n this._valueComparer = null;\n },\n\n value: function(value) {\n var that = this;\n var deferred = that._valueDeferred;\n var indices;\n\n if (value === undefined) {\n return that._values.slice();\n }\n\n that.setValue(value);\n\n if (!deferred || deferred.state() === \"resolved\") {\n that._valueDeferred = deferred = $.Deferred();\n }\n\n if (that.bound()) {\n indices = that._valueIndices(that._values);\n\n if (that.options.selectable === \"multiple\") {\n that.select(-1);\n }\n\n that.select(indices);\n\n deferred.resolve();\n }\n\n that._skipUpdate = false;\n\n return deferred;\n },\n\n items: function() {\n return this.element.children(ITEMSELECTOR);\n },\n\n _click: function(e) {\n if (this._touchTriggered)\n {\n this._touchTriggered = false;\n return;\n }\n\n if (!e.isDefaultPrevented()) {\n this._triggerClick(e.currentTarget);\n }\n },\n\n _triggerClick: function(item) {\n if (!this.trigger(CLICK, { item: $(item) })) {\n this.select(item);\n }\n },\n\n _valueExpr: function(type, values) {\n var that = this;\n var idx = 0;\n\n var body;\n var comparer;\n var normalized = [];\n\n if (!that._valueComparer || that._valueType !== type) {\n that._valueType = type;\n\n for (; idx < values.length; idx++) {\n normalized.push(unifyType(values[idx], type));\n }\n\n body = \"for (var idx = 0; idx < \" + normalized.length + \"; idx++) {\" +\n \" if (current === values[idx]) {\" +\n \" return idx;\" +\n \" }\" +\n \"} \" +\n \"return -1;\";\n\n comparer = new Function(\"current\", \"values\", body);\n\n that._valueComparer = function(current) {\n return comparer(current, normalized);\n };\n }\n\n return that._valueComparer;\n },\n\n _dataItemPosition: function(dataItem, values) {\n var value = this._valueGetter(dataItem);\n\n var valueExpr = this._valueExpr(typeof value, values);\n\n return valueExpr(value);\n },\n\n _getter: function() {\n this._valueGetter = kendo.getter(this.options.dataValueField);\n },\n\n _deselect: function(indices) {\n var that = this;\n var children = that.element[0].children;\n var selectable = that.options.selectable;\n var selectedIndices = that._selectedIndices;\n var dataItems = that._dataItems;\n var values = that._values;\n var removed = [];\n var i = 0;\n var j;\n\n var index, selectedIndex;\n var removedIndices = 0;\n\n indices = indices.slice();\n\n if (selectable === true || !indices.length) {\n for (; i < selectedIndices.length; i++) {\n $(children[selectedIndices[i]]).removeClass(KSELECTED).attr(ARIA_SELECTED, false);\n\n removed.push({\n position: i,\n dataItem: dataItems[i]\n });\n }\n\n that._values = [];\n that._dataItems = [];\n that._selectedIndices = [];\n } else if (selectable === \"multiple\") {\n for (; i < indices.length; i++) {\n index = indices[i];\n\n if (!$(children[index]).hasClass(KSELECTED)) {\n continue;\n }\n\n for (j = 0; j < selectedIndices.length; j++) {\n selectedIndex = selectedIndices[j];\n\n if (selectedIndex === index) {\n $(children[selectedIndex]).removeClass(KSELECTED).attr(ARIA_SELECTED, false);\n var dataItem = this._view[index].item;\n var position = this._dataItemPosition(dataItem, this._values);\n\n removed.push({\n position: position,\n dataItem: dataItem\n });\n\n dataItems.splice(j, 1);\n selectedIndices.splice(j, 1);\n indices.splice(i, 1);\n values.splice(j, 1);\n\n removedIndices += 1;\n i -= 1;\n j -= 1;\n break;\n }\n }\n }\n }\n\n return {\n indices: indices,\n removed: removed\n };\n },\n\n _deselectFiltered: function(indices) {\n var children = this.element[0].children;\n var dataItem, index, position;\n var removed = [];\n var idx = 0;\n\n for (; idx < indices.length; idx++) {\n index = indices[idx];\n\n dataItem = this._view[index].item;\n position = this._dataItemPosition(dataItem, this._values);\n\n if (position > -1) {\n removed.push(this.removeAt(position));\n $(children[index]).removeClass(KSELECTED);\n }\n }\n\n if (removed.length) {\n this.trigger(CHANGE, {\n added: [],\n removed: removed\n });\n\n return true;\n }\n\n return false;\n },\n\n _select: function(indices) {\n var that = this;\n var children = that.element[0].children;\n var data = that._view;\n var dataItem, index;\n var added = [];\n var idx = 0;\n\n if (last(indices) !== -1) {\n that.focus(indices);\n }\n\n for (; idx < indices.length; idx++) {\n index = indices[idx];\n dataItem = data[index];\n\n if (index === -1 || !dataItem) {\n continue;\n }\n\n dataItem = dataItem.item;\n\n that._selectedIndices.push(index);\n that._dataItems.push(dataItem);\n that._values.push(that._valueGetter(dataItem));\n\n $(children[index]).addClass(KSELECTED).attr(ARIA_SELECTED, true);\n\n added.push({\n dataItem: dataItem\n });\n }\n\n return added;\n },\n\n getElementIndex: function(element) {\n return $(element).data(\"offset-index\");\n },\n\n _get: function(candidate) {\n if (typeof candidate === \"number\") {\n candidate = [candidate];\n } else if (!isArray(candidate)) {\n candidate = this.getElementIndex(candidate);\n candidate = [candidate !== undefined ? candidate : -1];\n }\n\n return candidate;\n },\n\n _template: function() {\n var that = this;\n var options = that.options;\n var template = options.template;\n\n if (!template) {\n template = kendo.template('
  • ${' + kendo.expr(options.dataTextField, \"data\") + \"}
  • \", { useWithBlock: false });\n } else {\n template = kendo.template(template);\n template = function(data) {\n return '
  • ' + template(data) + \"
  • \";\n };\n }\n\n return template;\n },\n\n _templates: function() {\n var template;\n var options = this.options;\n var templates = {\n template: options.template,\n groupTemplate: options.groupTemplate,\n fixedGroupTemplate: options.fixedGroupTemplate\n };\n\n if (options.columns) {\n for (var i = 0; i < options.columns.length; i++) {\n var currentColumn = options.columns[i];\n var templateText = currentColumn.field ? currentColumn.field.toString() : TEXT;\n\n templates[\"column\" + i] = currentColumn.template || \"#: \" + templateText + \"#\";\n }\n }\n\n for (var key in templates) {\n template = templates[key];\n if (template && typeof template !== \"function\") {\n templates[key] = kendo.template(template);\n }\n }\n\n this.templates = templates;\n },\n\n _normalizeIndices: function(indices) {\n var newIndices = [];\n var idx = 0;\n\n for (; idx < indices.length; idx++) {\n if (indices[idx] !== undefined) {\n newIndices.push(indices[idx]);\n }\n }\n\n return newIndices;\n },\n\n _valueIndices: function(values, indices) {\n var data = this._view;\n var idx = 0;\n var index;\n\n indices = indices ? indices.slice() : [];\n\n if (!values.length) {\n return [];\n }\n\n for (; idx < data.length; idx++) {\n index = this._dataItemPosition(data[idx].item, values);\n\n if (index !== -1) {\n indices[index] = idx;\n }\n }\n\n return this._normalizeIndices(indices);\n },\n\n _firstVisibleItem: function() {\n var element = this.element[0];\n var content = this.content[0];\n var scrollTop = content.scrollTop;\n var itemHeight = $(element.children[0]).height();\n var itemIndex = Math.floor(scrollTop / itemHeight) || 0;\n var item = element.children[itemIndex] || element.lastChild;\n var forward = item.offsetTop < scrollTop;\n\n while (item) {\n if (forward) {\n if ((item.offsetTop + itemHeight) > scrollTop || !item.nextSibling) {\n break;\n }\n\n item = item.nextSibling;\n } else {\n if (item.offsetTop <= scrollTop || !item.previousSibling) {\n break;\n }\n\n item = item.previousSibling;\n }\n }\n\n return this._view[$(item).data(\"offset-index\")];\n },\n\n _fixedHeader: function() {\n if (this.isGrouped() && this.templates.fixedGroupTemplate) {\n if (this.header.closest(GROUP_ROW_SEL).length) {\n this.header.closest(GROUP_ROW_SEL).show();\n } else {\n this.header.show();\n }\n\n this.content.scroll(this._onScroll);\n } else {\n if (this.header.closest(GROUP_ROW_SEL).length) {\n this.header.closest(GROUP_ROW_SEL).hide();\n } else {\n this.header.hide();\n }\n\n this.content.off(\"scroll\", this._onScroll);\n }\n },\n\n _renderHeader: function() {\n var template = this.templates.fixedGroupTemplate;\n if (!template) {\n return;\n }\n\n var visibleItem = this._firstVisibleItem();\n\n if (visibleItem && visibleItem.group.toString().length) {\n this.header.html(template(visibleItem.group));\n }\n },\n\n _renderItem: function(context) {\n var item = '
  • ';\n if (hasColumns) {\n item += this._renderColumns(dataItem);\n } else {\n item += '';\n item += this.templates.template(dataItem);\n item += '';\n }\n\n if (notFirstItem && context.newGroup) {\n if (hasColumns) {\n item += '' + this.templates.groupTemplate(context.group) + '';\n } else {\n item += '
    ' + this.templates.groupTemplate(context.group) + '
    ';\n }\n } else if (isGrouped && hasColumns) {\n item += '';\n }\n\n return item + \"
  • \";\n },\n\n _renderColumns: function(dataItem) {\n var item = \"\";\n\n for (var i = 0; i < this.options.columns.length; i++) {\n var currentWidth = this.options.columns[i].width;\n var currentWidthInt = parseInt(currentWidth, 10);\n var widthStyle = '';\n\n if (currentWidth && !isNaN(currentWidthInt)) {\n widthStyle += \"style='width:\";\n widthStyle += currentWidthInt;\n widthStyle += percentageUnitsRegex.test(currentWidth) ? \"%\" : \"px\";\n widthStyle += \";'\";\n }\n item += \"\";\n item += this.templates[\"column\" + i](dataItem);\n item += \"\";\n }\n\n return item;\n },\n\n _render: function() {\n var html = \"\";\n\n var i = 0;\n var idx = 0;\n var context;\n var dataContext = [];\n var view = this.dataSource.view();\n var values = this.value();\n\n var group, newGroup, j;\n var isGrouped = this.isGrouped();\n\n if (isGrouped) {\n for (i = 0; i < view.length; i++) {\n group = view[i];\n newGroup = true;\n\n for (j = 0; j < group.items.length; j++) {\n context = {\n selected: this._selected(group.items[j], values),\n item: group.items[j],\n group: group.value,\n newGroup: newGroup,\n isLastGroupedItem: j === group.items.length - 1,\n index: idx };\n dataContext[idx] = context;\n idx += 1;\n\n html += this._renderItem(context);\n newGroup = false;\n }\n }\n } else {\n for (i = 0; i < view.length; i++) {\n context = { selected: this._selected(view[i], values), item: view[i], index: i };\n\n dataContext[i] = context;\n\n html += this._renderItem(context);\n }\n }\n\n this._view = dataContext;\n\n this.element[0].innerHTML = html;\n\n if (isGrouped && dataContext.length) {\n this._renderHeader();\n }\n },\n\n _selected: function(dataItem, values) {\n var select = !this.isFiltered() || this.options.selectable === \"multiple\";\n return select && this._dataItemPosition(dataItem, values) !== -1;\n },\n\n setDSFilter: function(filter) {\n this._lastDSFilter = extend({}, filter);\n },\n\n isFiltered: function() {\n if (!this._lastDSFilter) {\n this.setDSFilter(this.dataSource.filter());\n }\n\n return !kendo.data.Query.compareFilters(this.dataSource.filter(), this._lastDSFilter);\n },\n\n refresh: function(e) {\n var that = this;\n var action = e && e.action;\n var skipUpdateOnBind = that.options.skipUpdateOnBind;\n var isItemChange = action === \"itemchange\";\n var result;\n\n that.trigger(DATA_BINDING);\n that._angularItems(\"cleanup\");\n\n that._fixedHeader();\n\n that._render();\n\n that.bound(true);\n\n if (isItemChange || action === \"remove\") {\n result = mapChangedItems(that._dataItems, e.items);\n\n if (result.changed.length) {\n if (isItemChange) {\n that.trigger(SELECTED_ITEM_CHANGE, {\n items: result.changed\n });\n } else {\n that.value(that._getValues(result.unchanged));\n }\n }\n } else if (that.isFiltered() || that._skipUpdate || that._emptySearch) {\n that.focus(0);\n if (that._skipUpdate) {\n that._skipUpdate = false;\n that._selectedIndices = that._valueIndices(that._values, that._selectedIndices);\n }\n } else if (!skipUpdateOnBind && (!action || action === \"add\")) {\n that.value(that._values);\n }\n\n if (that._valueDeferred) {\n that._valueDeferred.resolve();\n }\n\n that._angularItems(\"compile\");\n that.trigger(DATA_BOUND);\n },\n\n bound: function(bound) {\n if (bound === undefined) {\n return this._bound;\n }\n\n this._bound = bound;\n },\n\n isGrouped: function() {\n return (this.dataSource.group() || []).length;\n }\n });\n\n ui.plugin(StaticList);\n\n function last(list) {\n return list[list.length - 1];\n }\n\n function getSelectedOption(select) {\n var index = select.selectedIndex;\n return index > -1 ? select.options[index] : {};\n }\n\n function mapChangedItems(selected, itemsToMatch) {\n var itemsLength = itemsToMatch.length;\n var selectedLength = selected.length;\n var dataItem;\n var found;\n var i, j;\n\n var changed = [];\n var unchanged = [];\n\n if (selectedLength) {\n for (i = 0; i < selectedLength; i++) {\n dataItem = selected[i];\n found = false;\n\n for (j = 0; j < itemsLength; j++) {\n if (dataItem === itemsToMatch[j]) {\n found = true;\n changed.push({ index: i, item: dataItem });\n break;\n }\n }\n\n if (!found) {\n unchanged.push(dataItem);\n }\n }\n }\n\n return {\n changed: changed,\n unchanged: unchanged\n };\n }\n\n function isValidFilterExpr(expression) {\n if (!expression || $.isEmptyObject(expression)) {\n return false;\n }\n\n if (expression.filters && !expression.filters.length) {\n return false;\n }\n\n return true;\n }\n\n function removeFiltersForField(expression, field) {\n var filters;\n var found = false;\n\n if (expression.filters) {\n filters = $.grep(expression.filters, function(filter) {\n found = removeFiltersForField(filter, field);\n if (filter.filters) {\n return filter.filters.length;\n } else {\n return filter.field != field;\n }\n });\n\n if (!found && expression.filters.length !== filters.length) {\n found = true;\n }\n\n expression.filters = filters;\n }\n\n return found;\n }\n\n kendo.cssProperties.registerPrefix(\"List\", \"k-list-\");\n\n})(window.kendo.jQuery);\n\nreturn window.kendo;\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3) { (a3 || a2)(); });\n\n(function(f, define){\n define('kendo.calendar',[ \"./kendo.core\", \"./kendo.selectable\" ], f);\n})(function(){\n\nvar __meta__ = { // jshint ignore:line\n id: \"calendar\",\n name: \"Calendar\",\n category: \"web\",\n description: \"The Calendar widget renders a graphical calendar that supports navigation and selection.\",\n depends: [ \"core\", \"selectable\" ]\n};\n\n(function($, undefined) {\n var kendo = window.kendo,\n support = kendo.support,\n ui = kendo.ui,\n Widget = ui.Widget,\n keys = kendo.keys,\n parse = kendo.parseDate,\n adjustDST = kendo.date.adjustDST,\n weekInYear = kendo.date.weekInYear,\n Selectable = kendo.ui.Selectable,\n extractFormat = kendo._extractFormat,\n template = kendo.template,\n getCulture = kendo.getCulture,\n transitions = kendo.support.transitions,\n transitionOrigin = transitions ? transitions.css + \"transform-origin\" : \"\",\n cellTemplate = template('#=data.value#', { useWithBlock: false }),\n emptyCellTemplate = template('', { useWithBlock: false }),\n otherMonthCellTemplate = template(' ', { useWithBlock: false }),\n weekNumberTemplate = template('#= data.weekNumber #', { useWithBlock: false }),\n outerWidth = kendo._outerWidth,\n ns = \".kendoCalendar\",\n CLICK = \"click\" + ns,\n KEYDOWN_NS = \"keydown\" + ns,\n ID = \"id\",\n MIN = \"min\",\n LEFT = \"left\",\n SLIDE = \"slideIn\",\n MONTH = \"month\",\n CENTURY = \"century\",\n CHANGE = \"change\",\n NAVIGATE = \"navigate\",\n VALUE = \"value\",\n HOVER = \"k-state-hover\",\n DISABLED = \"k-state-disabled\",\n FOCUSED = \"k-state-focused\",\n OTHERMONTH = \"k-other-month\",\n OUTOFRANGE = \"k-out-of-range\",\n TODAY = \"k-nav-today\",\n CELLSELECTOR = \"td:has(.k-link)\",\n CELLSELECTORVALID = \"td:has(.k-link):not(.\" + DISABLED + \"):not(.\" + OUTOFRANGE + \")\",\n WEEKCOLUMNSELECTOR = \"td:not(:has(.k-link))\",\n SELECTED = \"k-state-selected\",\n BLUR = \"blur\" + ns,\n FOCUS = \"focus\",\n FOCUS_WITH_NS = FOCUS + ns,\n MOUSEENTER = support.touch ? \"touchstart\" : \"mouseenter\",\n MOUSEENTER_WITH_NS = support.touch ? \"touchstart\" + ns : \"mouseenter\" + ns,\n MOUSELEAVE = support.touch ? \"touchend\" + ns + \" touchmove\" + ns : \"mouseleave\" + ns,\n MS_PER_MINUTE = 60000,\n MS_PER_DAY = 86400000,\n PREVARROW = \"_prevArrow\",\n NEXTARROW = \"_nextArrow\",\n ARIA_DISABLED = \"aria-disabled\",\n ARIA_SELECTED = \"aria-selected\",\n ARIA_LABEL = \"aria-label\",\n proxy = $.proxy,\n extend = $.extend,\n DATE = Date,\n views = {\n month: 0,\n year: 1,\n decade: 2,\n century: 3\n },\n HEADERSELECTOR = '.k-header, .k-calendar-header',\n CLASSIC_HEADER_TEMPLATE = '
    ' +\n '' +\n '' +\n '' +\n '
    ',\n MODERN_HEADER_TEMPLATE = '
    ' +\n '' +\n '' +\n '' +\n '' +\n '' +\n '' +\n '#=messages.today#' +\n '' +\n '' +\n '' +\n '' +\n '
    ';\n\n var Calendar = Widget.extend({\n init: function(element, options) {\n var that = this, value, id;\n options = options || {};\n options.componentType = options.componentType || \"classic\";\n Widget.fn.init.call(that, element, options);\n\n element = that.wrapper = that.element;\n options = that.options;\n\n options.url = kendo.unescape(options.url);\n\n that.options.disableDates = getDisabledExpr(that.options.disableDates);\n\n that._templates();\n\n that._selectable();\n\n that._header();\n\n that._viewWrapper();\n\n if (that.options.hasFooter) {\n that._footer(that.footer);\n } else {\n that._today = that.element.find('a.k-nav-today');\n that._toggle();\n }\n\n id = element\n .addClass(\"k-widget k-calendar \" + (options.weekNumber ? \" k-week-number\" : \"\"))\n .on(MOUSEENTER_WITH_NS + \" \" + MOUSELEAVE, CELLSELECTOR, mousetoggle)\n .on(KEYDOWN_NS, \"table.k-content\", proxy(that._move, that))\n .on(CLICK + \" touchend\", CELLSELECTOR, function(e) {\n var link = e.currentTarget.firstChild,\n value = toDateObject(link);\n\n if (link.href.indexOf(\"#\") != -1) {\n e.preventDefault();\n }\n\n if (that._view.name == \"month\" && that.options.disableDates(value)) {\n return;\n }\n if (that._view.name != \"month\" || options.selectable == \"single\") {\n that._click($(link));\n }\n })\n .on(\"mouseup\" + ns, \"table.k-content, .k-footer\", function() {\n that._focusView(that.options.focusOnNav !== false);\n })\n .attr(ID);\n\n if (that._isMultipleSelection() && that.options.weekNumber) {\n element.on(CLICK, WEEKCOLUMNSELECTOR, function(e) {\n var first = $(e.currentTarget).closest(\"tr\").find(CELLSELECTORVALID).first(),\n last = that.selectable._lastActive = $(e.currentTarget).closest(\"tr\").find(CELLSELECTORVALID).last();\n that.selectable.selectRange(first, last, { event: e});\n that._current = that._value = toDateObject(last.find(\"a\"));\n that._setCurrent(that._current);\n });\n }\n\n normalize(options);\n value = parse(options.value, options.format, options.culture);\n that._selectDates = [];\n\n that._index = views[options.start];\n\n that._current = new DATE(+restrictValue(value, options.min, options.max));\n\n that._addClassProxy = function() {\n that._active = true;\n\n if (that._cell.hasClass(DISABLED)) {\n var todayString = that._view.toDateString(getToday());\n that._cell = that._cellByDate(todayString);\n }\n\n that._cell.addClass(FOCUSED);\n };\n\n that._removeClassProxy = function() {\n that._active = false;\n if (that._cell) {\n that._cell.removeClass(FOCUSED);\n }\n };\n\n that.value(value);\n\n if (that._isMultipleSelection() && options.selectDates.length > 0) {\n that.selectDates(options.selectDates);\n }\n kendo.notify(that);\n },\n\n options: {\n name: \"Calendar\",\n value: null,\n min: new DATE(1900, 0, 1),\n max: new DATE(2099, 11, 31),\n dates: [],\n disableDates: null,\n url: \"\",\n culture: \"\",\n footer : \"\",\n format : \"\",\n month : {},\n weekNumber: false,\n selectable: \"single\",\n selectDates: [],\n start: MONTH,\n depth: MONTH,\n size: \"medium\",\n animation: {\n horizontal: {\n effects: SLIDE,\n reverse: true,\n duration: 500,\n divisor: 2\n },\n vertical: {\n effects: \"zoomIn\",\n duration: 400\n }\n },\n messages: {\n weekColumnHeader: \"\",\n today: \"Today\"\n },\n componentType: \"classic\"\n },\n\n events: [\n CHANGE,\n NAVIGATE\n ],\n\n componentTypes: {\n \"classic\": {\n header: {\n template: CLASSIC_HEADER_TEMPLATE\n },\n hasFooter: true,\n linksSelector: \".k-button\",\n contentClasses: \"k-calendar-table k-content\"\n },\n \"modern\": {\n header: {\n template: MODERN_HEADER_TEMPLATE\n },\n hasFooter: false,\n linksSelector: \".k-button\",\n contentClasses: \"k-calendar-table k-content k-calendar-content\"\n }\n },\n\n setOptions: function(options) {\n var that = this;\n\n normalize(options);\n\n options.disableDates = getDisabledExpr(options.disableDates);\n that._destroySelectable();\n\n Widget.fn.setOptions.call(that, options);\n\n that._templates();\n\n that._selectable();\n\n that._viewWrapper();\n\n if (that.options.hasFooter) {\n that._footer(that.footer);\n } else {\n that.element.find(\".k-footer\").hide();\n that._toggle();\n }\n that._index = views[that.options.start];\n\n that.navigate();\n\n if (options.weekNumber) {\n that.element.addClass('k-week-number');\n }\n },\n\n destroy: function() {\n var that = this,\n today = that._today;\n\n that.element.off(ns);\n that._title.off(ns);\n that[PREVARROW].off(ns);\n that[NEXTARROW].off(ns);\n that._destroySelectable();\n kendo.destroy(that._table);\n\n if (today) {\n kendo.destroy(today.off(ns));\n }\n\n Widget.fn.destroy.call(that);\n },\n\n current: function() {\n return this._current;\n },\n\n view: function() {\n return this._view;\n },\n\n focus: function(table) {\n table = table || this._table;\n this._bindTable(table);\n table.trigger(\"focus\");\n },\n\n min: function(value) {\n return this._option(MIN, value);\n },\n\n max: function(value) {\n return this._option(\"max\", value);\n },\n\n navigateToPast: function() {\n this._navigate(PREVARROW, -1);\n },\n\n navigateToFuture: function() {\n this._navigate(NEXTARROW, 1);\n },\n\n navigateUp: function() {\n var that = this,\n index = that._index;\n\n if (that._title.hasClass(DISABLED)) {\n return;\n }\n\n that.navigate(that._current, ++index);\n },\n\n navigateDown: function(value) {\n var that = this,\n index = that._index,\n depth = that.options.depth;\n\n if (!value) {\n return;\n }\n\n if (index === views[depth]) {\n if (!isEqualDate(that._value, that._current) || !isEqualDate(that._value, value)) {\n that.value(value);\n that.trigger(CHANGE);\n }\n return;\n }\n\n that.navigate(value, --index);\n },\n\n navigate: function(value, view) {\n view = isNaN(view) ? views[view] : view;\n\n var that = this,\n options = that.options,\n culture = options.culture,\n min = options.min,\n max = options.max,\n title = that._title,\n from = that._table,\n old = that._oldTable,\n currentValue = that._current,\n future = value && +value > +currentValue,\n vertical = view !== undefined && view !== that._index,\n to, currentView, compare,\n disabled,\n viewWrapper = that.element.children(\".k-calendar-view\");\n\n if (!value) {\n value = currentValue;\n }\n\n that._current = value = new DATE(+restrictValue(value, min, max));\n\n if (view === undefined) {\n view = that._index;\n } else {\n that._index = view;\n }\n\n that._view = currentView = calendar.views[view];\n compare = currentView.compare;\n\n disabled = view === views[CENTURY];\n title.toggleClass(DISABLED, disabled).attr(ARIA_DISABLED, disabled);\n\n disabled = compare(value, min) < 1;\n that[PREVARROW].toggleClass(DISABLED, disabled).attr(ARIA_DISABLED, disabled);\n\n disabled = compare(value, max) > -1;\n that[NEXTARROW].toggleClass(DISABLED, disabled).attr(ARIA_DISABLED, disabled);\n\n if (from && old && old.data(\"animating\")) {\n old.kendoStop(true, true);\n from.kendoStop(true, true);\n }\n\n that._oldTable = from;\n\n if (!from || that._changeView) {\n title.html(currentView.title(value, min, max, culture));\n\n that._table = to = $(currentView.content(extend({\n min: min,\n max: max,\n date: value,\n url: options.url,\n dates: options.dates,\n format: options.format,\n otherMonth : true,\n culture: culture,\n disableDates: options.disableDates,\n isWeekColumnVisible: options.weekNumber,\n messages: options.messages,\n contentClasses: that.options.contentClasses\n }, that[currentView.name])));\n\n addClassToViewContainer(to, currentView.name);\n var replace = from && from.data(\"start\") === to.data(\"start\");\n that._animate({\n from: from,\n to: to,\n vertical: vertical,\n future: future,\n replace: replace\n });\n\n viewWrapper.removeClass(\"k-calendar-monthview k-calendar-yearview k-calendar-decadeview k-calendar-centuryview\");\n viewWrapper.addClass(\"k-calendar-\" + currentView.name + \"view\");\n\n that.trigger(NAVIGATE);\n\n that._focus(value);\n }\n\n if (view === views[options.depth] && that._selectDates.length > 0) {\n that._visualizeSelectedDatesInView();\n }\n\n if (that.options.selectable === \"single\") {\n if (view === views[options.depth] && that._value && !that.options.disableDates(that._value)) {\n that._selectCell(that._value);\n }\n }\n\n that._setCurrent(value);\n\n if (!from && that._cell) {\n that._cell.removeClass(FOCUSED);\n }\n\n that._changeView = true;\n },\n\n selectDates: function(dates) {\n var that = this,\n validSelectedDates,\n datesUnique;\n\n if (dates === undefined) {\n return that._selectDates;\n }\n\n datesUnique = dates\n .map(function (date) { return date.getTime(); })\n .filter(function (date, position, array) {\n return array.indexOf(date) === position;\n })\n .map(function (time) { return new Date(time); });\n\n validSelectedDates = $.grep(datesUnique, function(value) {\n if (value) {\n return +that._validateValue(new Date(value.setHours(0, 0, 0, 0))) === +value;\n }\n });\n that._selectDates = validSelectedDates.length > 0 ? validSelectedDates : (datesUnique.length === 0 ? datesUnique : that._selectDates);\n that._visualizeSelectedDatesInView();\n },\n\n value: function(value) {\n var that = this,\n old = that._view,\n view = that._view;\n\n if (value === undefined) {\n return that._value;\n }\n\n value = that._validateValue(value);\n if (value && that._isMultipleSelection()) {\n var date = new Date(+value);\n date.setHours(0, 0, 0, 0);\n that._selectDates = [date];\n that.selectable._lastActive = null;\n }\n if (old && value === null && that._cell) {\n that._cell.removeClass(SELECTED);\n } else {\n that._changeView = !value || view && view.compare(value, that._current) !== 0;\n that.navigate(value);\n }\n },\n\n _validateValue: function(value) {\n var that = this,\n options = that.options,\n min = options.min,\n max = options.max;\n\n if (value === null) {\n that._current = createDate(that._current.getFullYear(), that._current.getMonth(), that._current.getDate());\n }\n\n value = parse(value, options.format, options.culture);\n\n if (value !== null) {\n value = new DATE(+value);\n\n if (!isInRange(value, min, max)) {\n value = null;\n }\n }\n\n if (value === null || !that.options.disableDates(new Date(+value))) {\n that._value = value;\n } else if (that._value === undefined) {\n that._value = null;\n }\n\n return that._value;\n },\n\n _visualizeSelectedDatesInView: function() {\n var that = this;\n var selectedDates = {};\n $.each(that._selectDates, function(index, value) {\n selectedDates[kendo.calendar.views[0].toDateString(value)] = value;\n });\n that.selectable.clear();\n var cells = that._table\n .find(CELLSELECTOR)\n .filter(function(index, element) {\n return selectedDates[$(element.firstChild).attr(kendo.attr(VALUE))];\n });\n if (cells.length > 0) {\n that.selectable._selectElement(cells, true);\n }\n },\n\n _isMultipleSelection: function() {\n var that = this;\n return that.options.selectable === \"multiple\";\n },\n\n _selectable: function() {\n var that = this;\n if (!that._isMultipleSelection()) {\n return;\n }\n\n var selectable = that.options.selectable,\n selectableOptions = Selectable.parseOptions(selectable);\n\n if (selectableOptions.multiple) {\n that.element.attr(\"aria-multiselectable\", \"true\");\n }\n that.selectable = new Selectable(that.wrapper, {\n aria: true,\n //excludes the anchor element\n inputSelectors: \"input,textarea,.k-multiselect-wrap,select,button,.k-button>span,.k-button>img,span.k-icon.k-i-arrow-60-down,span.k-icon.k-i-arrow-60-up\",\n multiple: selectableOptions.multiple,\n filter: \"table.k-month:eq(0) \" + CELLSELECTORVALID,\n change: proxy(that._onSelect, that),\n relatedTarget: proxy(that._onRelatedTarget, that)\n });\n },\n\n _onRelatedTarget: function(target) {\n var that = this;\n\n if (that.selectable.options.multiple && target.is(CELLSELECTORVALID)) {\n that._current = toDateObject(target.find(\"a\"));\n that._setCurrent(that._current);\n }\n\n },\n\n _onSelect: function(e) {\n var that = this,\n eventArgs = e,\n selectableOptions = Selectable.parseOptions(that.options.selectable);\n\n if (!selectableOptions.multiple) {\n if ($(eventArgs.event.currentTarget).is(\"td\") && !$(eventArgs.event.currentTarget).hasClass(\"k-state-selected\")) {\n $(eventArgs.event.currentTarget).addClass(\"k-state-selected\");\n }\n else {\n that._click($(eventArgs.event.currentTarget).find(\"a\"));\n }\n return;\n }\n\n if (eventArgs.event.ctrlKey || eventArgs.event.metaKey) {\n if ($(eventArgs.event.currentTarget).is(CELLSELECTORVALID)) {\n that._toggleSelection($(eventArgs.event.currentTarget));\n }\n else {\n that._cellsBySelector(CELLSELECTORVALID).each(function(index, element){\n var value = toDateObject($(element).find(\"a\"));\n that._deselect(value);\n });\n that._addSelectedCellsToArray();\n }\n }\n else if (eventArgs.event.shiftKey) {\n that._rangeSelection(that._cell);\n }\n else if ($(eventArgs.event.currentTarget).is(CELLSELECTOR)) {\n that.value(toDateObject($(eventArgs.event.currentTarget).find(\"a\")));\n }\n else {\n that._selectDates = [];\n that._addSelectedCellsToArray();\n }\n that.trigger(CHANGE);\n },\n\n _destroySelectable: function() {\n var that = this;\n\n if (that.selectable) {\n that.selectable.destroy();\n that.selectable = null;\n }\n },\n\n //when ctrl key is clicked\n _toggleSelection: function(currentCell) {\n var that = this,\n date = toDateObject(currentCell.find(\"a\"));\n if (currentCell.hasClass(\"k-state-selected\")) {\n that._selectDates.push(date);\n }\n else {\n that._deselect(date);\n }\n },\n\n //shift selection\n _rangeSelection: function(toDateCell, startDate) {\n var that = this,\n fromDate = startDate || toDateObject(that.selectable.value().first().find(\"a\")),\n toDate = toDateObject(toDateCell.find(\"a\")),\n daysDifference;\n\n if (that.selectable._lastActive || that._value) {\n fromDate = that.selectable._lastActive? toDateObject(that.selectable._lastActive.find(\"a\")): new Date(+that._value);\n } else {\n that.selectable._lastActive = startDate? that._cellByDate(that._view.toDateString(startDate), CELLSELECTORVALID): that.selectable.value().first();\n }\n\n that._selectDates = [];\n daysDifference = daysBetweenTwoDates(fromDate, toDate);\n addDaysToArray(that._selectDates, daysDifference, fromDate, that.options.disableDates);\n\n that._visualizeSelectedDatesInView();\n },\n\n _cellsBySelector: function(selector) {\n var that = this;\n return that._table.find(selector);\n },\n\n _addSelectedCellsToArray: function() {\n var that = this;\n that.selectable.value().each(function(index, item) {\n var date = toDateObject($(item.firstChild));\n if (!that.options.disableDates(date)) {\n that._selectDates.push(date);\n }\n });\n },\n\n _deselect: function(date) {\n var that = this;\n var currentDateIndex = that._selectDates.map(Number).indexOf(+date);\n if (currentDateIndex != -1) {\n that._selectDates.splice(currentDateIndex, 1);\n }\n },\n\n _dateInView: function(date) {\n var that = this,\n firstDateInView = toDateObject(that._cellsBySelector(CELLSELECTORVALID).first().find(\"a\")),\n lastDateInView = toDateObject(that._cellsBySelector(CELLSELECTORVALID).last().find(\"a\"));\n\n return +date <= +lastDateInView && +date >= +firstDateInView;\n },\n\n _isNavigatable: function(currentValue, cellIndex) {\n var that = this;\n var isDisabled = that.options.disableDates;\n var cell;\n var index;\n\n if (that._view.name == \"month\") {\n return !isDisabled(currentValue);\n } else {\n index = that.wrapper.find(\".\"+FOCUSED).index();\n cell = that.wrapper.find(\".k-content td\").eq(index + cellIndex);\n return cell.is(CELLSELECTORVALID) || !isDisabled(currentValue);\n }\n },\n\n _move: function(e) {\n var that = this,\n options = that.options,\n key = e.keyCode,\n view = that._view,\n index = that._index,\n min = that.options.min,\n max = that.options.max,\n currentValue = new DATE(+that._current),\n isRtl = kendo.support.isRtl(that.wrapper),\n isDisabled = that.options.disableDates,\n value, prevent, method, temp;\n\n if (e.target === that._table[0]) {\n that._active = true;\n }\n\n if (key == keys.RIGHT && !isRtl || key == keys.LEFT && isRtl) {\n value = 1;\n prevent = true;\n } else if (key == keys.LEFT && !isRtl || key == keys.RIGHT && isRtl) {\n value = -1;\n prevent = true;\n } else if (key == keys.UP) {\n value = index === 0 ? -7 : -4;\n prevent = true;\n } else if (key == keys.DOWN) {\n value = index === 0 ? 7 : 4;\n prevent = true;\n }\n else if (key == keys.SPACEBAR) {\n value = 0;\n prevent = true;\n }\n else if (key == keys.HOME || key == keys.END) {\n method = key == keys.HOME ? \"first\" : \"last\";\n temp = view[method](currentValue);\n currentValue = new DATE(temp.getFullYear(), temp.getMonth(), temp.getDate(), currentValue.getHours(), currentValue.getMinutes(), currentValue.getSeconds(), currentValue.getMilliseconds());\n currentValue.setFullYear(temp.getFullYear());\n prevent = true;\n }\n\n if (e.ctrlKey || e.metaKey) {\n if (key == keys.RIGHT && !isRtl || key == keys.LEFT && isRtl) {\n that.navigateToFuture();\n prevent = true;\n } else if (key == keys.LEFT && !isRtl || key == keys.RIGHT && isRtl) {\n that.navigateToPast();\n prevent = true;\n } else if (key == keys.UP) {\n that.navigateUp();\n prevent = true;\n } else if (key == keys.DOWN) {\n that._click($(that._cell[0].firstChild));\n prevent = true;\n }\n else if ((key == keys.ENTER || key == keys.SPACEBAR) && that._isMultipleSelection()) {\n that._keyboardToggleSelection(e);\n\n var focusedDate = toDateObject($(that._cell[0]).find(\"a\"));\n that._setCurrent(focusedDate);\n\n }\n } else if (e.shiftKey) {\n if (value !== undefined || method) {\n if (!method) {\n view.setDate(currentValue, value);\n }\n\n if (!isInRange(currentValue, min, max)) {\n currentValue = restrictValue(currentValue, options.min, options.max);\n }\n\n if (isDisabled(currentValue)) {\n currentValue = that._nextNavigatable(currentValue, value);\n }\n\n min = createDate(min.getFullYear(), min.getMonth(), min.getDate());\n if (that._isMultipleSelection()) {\n that._keyboardRangeSelection(e, currentValue);\n }\n else {\n that._focus(currentValue);\n }\n }\n } else {\n if (key == keys.ENTER || key == keys.SPACEBAR) {\n if (view.name == \"month\" && that._isMultipleSelection()) {\n that.value(toDateObject($(that._cell.find(\"a\"))));\n that.selectable._lastActive = $(that._cell[0]);\n that.trigger(CHANGE);\n }\n else {\n that._click($(that._cell[0].firstChild));\n }\n prevent = true;\n } else if (key == keys.PAGEUP) {\n prevent = true;\n that.navigateToPast();\n } else if (key == keys.PAGEDOWN) {\n prevent = true;\n that.navigateToFuture();\n }\n\n if (value || method) {\n if (!method) {\n view.setDate(currentValue, value);\n }\n\n min = createDate(min.getFullYear(), min.getMonth(), min.getDate());\n\n if (!isInRange(currentValue, min, max)) {\n currentValue = restrictValue(currentValue, options.min, options.max);\n }\n\n if (!that._isNavigatable(currentValue, value)) {\n currentValue = that._nextNavigatable(currentValue, value);\n }\n\n if (that._isMultipleSelection()) {\n if (!that._dateInView(currentValue)) {\n that.navigate(currentValue);\n }\n else {\n that._current = currentValue;\n that._setCurrent(currentValue);\n }\n }\n else {\n that._focus(currentValue);\n }\n }\n }\n\n if (prevent) {\n e.preventDefault();\n }\n\n return that._current;\n },\n\n _keyboardRangeSelection: function(event, currentValue) {\n var that = this,\n fromDate,\n daysDifference;\n\n if (!that._dateInView(currentValue)) {\n that._selectDates = [];\n\n fromDate = that.selectable._lastActive? toDateObject(that.selectable._lastActive.find(\"a\")): currentValue;\n daysDifference = daysBetweenTwoDates(fromDate, new Date(+currentValue));\n\n addDaysToArray(that._selectDates, daysDifference, fromDate, that.options.disableDates);\n\n that.navigate(currentValue);\n that._current = currentValue;\n that.selectable._lastActive = that.selectable._lastActive || that._cellByDate(that._view.toDateString(currentValue), CELLSELECTORVALID);\n that.trigger(CHANGE);\n return;\n }\n that.selectable.options.filter = that.wrapper.find(\"table\").length > 1 && +currentValue > +that._current? \"table.k-month:eq(1) \" + CELLSELECTORVALID: \"table.k-month:eq(0) \" + CELLSELECTORVALID;\n that._setCurrent(currentValue);\n that._current = currentValue;\n\n that._rangeSelection(that._cellByDate(that._view.toDateString(currentValue), CELLSELECTORVALID), currentValue);\n\n that.trigger(CHANGE);\n\n that.selectable.options.filter = \"table.k-month:eq(0) \" + CELLSELECTORVALID;\n },\n\n _keyboardToggleSelection: function(event) {\n var that = this;\n\n event.currentTarget = that._cell[0];\n that.selectable._lastActive = $(that._cell[0]);\n\n if ($(that._cell[0]).hasClass(SELECTED)) {\n that.selectable._unselect($(that._cell[0]));\n that.selectable.trigger(CHANGE, { event: event});\n }\n else {\n that.selectable.value($(that._cell[0]), { event: event});\n }\n },\n\n _nextNavigatable: function(currentValue, value) {\n var that = this,\n disabled = true,\n view = that._view,\n min = that.options.min,\n max = that.options.max,\n isDisabled = that.options.disableDates,\n navigatableDate = new Date(currentValue.getTime());\n\n view.setDate(navigatableDate, -value);\n\n while (disabled) {\n view.setDate(currentValue, value);\n\n if (!isInRange(currentValue, min, max)) {\n currentValue = navigatableDate;\n break;\n }\n disabled = isDisabled(currentValue);\n }\n return currentValue;\n },\n\n _animate: function(options) {\n var that = this;\n var from = options.from;\n var to = options.to;\n var active = that._active;\n var viewWrapper = that.element.children(\".k-calendar-view\");\n\n if (!from) {\n viewWrapper.append(to);\n that._bindTable(to);\n } else if (from.parent().data(\"animating\")) {\n from.off(ns);\n from.parent().kendoStop(true, true).remove();\n from.remove();\n\n viewWrapper.append(to);\n that._focusView(active);\n } else if (!from.is(\":visible\") || that.options.animation === false || options.replace) {\n to.insertAfter(from);\n from.off(ns).remove();\n\n that._focusView(active);\n } else {\n that[options.vertical ? \"_vertical\" : \"_horizontal\"](from, to, options.future);\n }\n },\n\n _horizontal: function(from, to, future) {\n var that = this,\n active = that._active,\n horizontal = that.options.animation.horizontal,\n effects = horizontal.effects,\n viewWidth = outerWidth(from);\n\n if (effects && effects.indexOf(SLIDE) != -1) {\n from.add(to).css({ width: viewWidth });\n\n from.wrap(\"
    \");\n\n that._focusView(active, from);\n\n from.parent()\n .css({\n position: \"relative\",\n width: viewWidth * 2,\n \"float\": LEFT,\n \"margin-left\": future ? 0 : -viewWidth\n });\n\n to[future ? \"insertAfter\" : \"insertBefore\"](from);\n\n extend(horizontal, {\n effects: SLIDE + \":\" + (future ? \"right\" : LEFT),\n complete: function() {\n from.off(ns).remove();\n that._oldTable = null;\n\n to.unwrap();\n\n that._focusView(active);\n\n }\n });\n\n from.parent().kendoStop(true, true).kendoAnimate(horizontal);\n }\n },\n\n _vertical: function(from, to) {\n var that = this,\n vertical = that.options.animation.vertical,\n effects = vertical.effects,\n active = that._active, //active state before from's blur\n cell, position;\n\n if (effects && effects.indexOf(\"zoom\") != -1) {\n to.insertBefore(from);\n\n from.css({\n position: \"absolute\",\n width: to.width()\n });\n\n if (transitionOrigin) {\n cell = that._cellByDate(that._view.toDateString(that._current));\n position = cell.position();\n position = (position.left + parseInt(cell.width() / 2, 10)) + \"px\" + \" \" + (position.top + parseInt(cell.height() / 2, 10) + \"px\");\n to.css(transitionOrigin, position);\n }\n\n from.kendoStop(true, true).kendoAnimate({\n effects: \"fadeOut\",\n duration: 600,\n complete: function() {\n from.off(ns).remove();\n that._oldTable = null;\n\n that._focusView(active);\n }\n });\n\n to.kendoStop(true, true).kendoAnimate(vertical);\n }\n },\n\n _cellByDate: function(value, selector) {\n return this._table.find(selector ? selector : \"td:not(.\" + OTHERMONTH + \")\")\n .filter(function() {\n return $(this.firstChild).attr(kendo.attr(VALUE)) === value;\n });\n },\n\n _selectCell: function (date) {\n var that = this,\n cell = that._selectedCell,\n value = that._view.toDateString(date);\n\n if (cell && cell[0]) {\n cell[0].removeAttribute(ARIA_SELECTED);\n cell.removeClass(SELECTED);\n }\n\n cell = that._cellByDate(value, that.options.selectable == \"multiple\" ? CELLSELECTOR: \"td:not(.\" + OTHERMONTH + \")\");\n\n that._selectedCell = cell;\n cell.addClass(SELECTED)\n .attr(ARIA_SELECTED, true);\n },\n\n _setCurrent: function (date) {\n var that = this,\n id = kendo.guid(),\n cell = that._cell,\n value = that._view.toDateString(date);\n\n if (cell && cell[0]) {\n cell.removeClass(FOCUSED);\n cell[0].removeAttribute(ARIA_LABEL);\n cell[0].removeAttribute(ID);\n }\n\n cell = that._cellByDate(value, that.options.selectable == \"multiple\" ? CELLSELECTOR: \"td:not(.\" + OTHERMONTH + \")\");\n\n that._cell = cell;\n\n cell.attr(ID, id)\n .addClass(FOCUSED);\n\n if (that._table[0]) {\n that._table[0].removeAttribute(\"aria-activedescendant\");\n that._table.attr(\"aria-activedescendant\", id);\n }\n },\n\n _bindTable: function (table) {\n table\n .on(FOCUS_WITH_NS, this._addClassProxy)\n .on(BLUR, this._removeClassProxy);\n },\n\n _click: function(link) {\n var that = this,\n options = that.options,\n currentValue = new Date(+that._current),\n value = toDateObject(link);\n\n adjustDST(value, 0);\n\n if (that._view.name == \"month\" && that.options.disableDates(value)) {\n value = that._value;\n }\n\n that._view.setDate(currentValue, value);\n\n that.navigateDown(restrictValue(currentValue, options.min, options.max));\n },\n\n _focus: function(value) {\n var that = this,\n view = that._view;\n\n if (view.compare(value, that._current) !== 0) {\n that.navigate(value);\n } else {\n that._current = value;\n that._setCurrent(value);\n }\n },\n\n _focusView: function(active, table) {\n if (active) {\n this.focus(table);\n }\n },\n\n _viewWrapper: function() {\n var that = this;\n var element = that.element;\n var viewWrapper = element.children(\".k-calendar-view\");\n\n if (!viewWrapper[0]) {\n viewWrapper = $(\"
    \").insertAfter(element.find(HEADERSELECTOR));\n }\n },\n\n _footer: function(template) {\n var that = this,\n today = getToday(),\n element = that.element,\n footer = element.find(\".k-footer\");\n\n if (!template) {\n that._toggle(false);\n footer.hide();\n return;\n }\n\n if (!footer[0]) {\n footer = $('
    ').appendTo(element);\n }\n\n that._today = footer.show()\n .find(\".k-link\")\n .html(template(today))\n .attr(\"title\", kendo.toString(today, \"D\", that.options.culture));\n\n that._toggle();\n },\n\n _header: function() {\n var that = this,\n element = that.element,\n linksSelector = that.options.linksSelector;\n\n if (!element.find(HEADERSELECTOR)[0]) {\n element.html(kendo.template(that.options.header.template)($.extend(true,{}, that.options, {actionAttr: kendo.attr(\"action\"), size: kendo.getValidCssClass(\"k-button-\", \"size\", that.options.size)})));\n }\n\n element.find(linksSelector)\n .on(CLICK + \" touchend\" + ns, function() { return false; } );\n\n that._title = element.find('[' + kendo.attr(\"action\") + '=\"nav-up\"]').on(CLICK + \" touchend\" + ns, function () {\n that._active = that.options.focusOnNav !== false;\n that.navigateUp();\n });\n that[PREVARROW] = element.find('[' + kendo.attr(\"action\") + '=\"prev\"]').on(CLICK + \" touchend\" + ns, function () {\n that._active = that.options.focusOnNav !== false;\n that.navigateToPast();\n });\n that[NEXTARROW] = element.find('[' + kendo.attr(\"action\") + '=\"next\"]').on(CLICK + \" touchend\" + ns, function () {\n that._active = that.options.focusOnNav !== false;\n that.navigateToFuture();\n });\n element.find('[' + kendo.attr(\"action\") + '=\"today\"]').on(CLICK + \" touchend\" + ns, proxy(that._todayClick, that));\n\n },\n\n _navigate: function(arrow, modifier) {\n var that = this,\n index = that._index + 1,\n currentValue = new DATE(+that._current);\n\n if (that._isMultipleSelection()) {\n var firstDayCurrentMonth = that._table.find(\"td:not(.k-other-month):not(.k-out-of-range)\").has(\".k-link\").first();\n currentValue = toDateObject(firstDayCurrentMonth.find(\"a\"));\n that._current = new Date(+currentValue);\n }\n\n arrow = that[arrow];\n\n if (!arrow.hasClass(DISABLED)) {\n if (index > 3) {\n currentValue.setFullYear(currentValue.getFullYear() + 100 * modifier);\n } else {\n calendar.views[index].setDate(currentValue, modifier);\n }\n\n that.navigate(currentValue);\n }\n },\n\n _option: function(option, value) {\n var that = this,\n options = that.options,\n currentValue = that._value || that._current,\n isBigger;\n\n if (value === undefined) {\n return options[option];\n }\n\n value = parse(value, options.format, options.culture);\n\n if (!value) {\n return;\n }\n\n options[option] = new DATE(+value);\n\n if (option === MIN) {\n isBigger = value > currentValue;\n } else {\n isBigger = currentValue > value;\n }\n\n if (isBigger || isEqualMonth(currentValue, value)) {\n if (isBigger) {\n that._value = null;\n }\n that._changeView = true;\n }\n\n if (!that._changeView) {\n that._changeView = !!(options.month.content || options.month.empty);\n }\n\n that.navigate(that._value);\n\n that._toggle();\n },\n\n _toggle: function(toggle) {\n var that = this,\n options = that.options,\n isTodayDisabled = that.options.disableDates(getToday()),\n link = that._today,\n todayClass = that._todayClass();\n\n if (toggle === undefined) {\n toggle = isInRange(getToday(), options.min, options.max);\n }\n\n if (link) {\n link.off(CLICK);\n\n if (toggle && !isTodayDisabled) {\n link.addClass(todayClass)\n .removeClass(DISABLED)\n .on(CLICK, proxy(that._todayClick, that));\n } else {\n link.removeClass(todayClass)\n .addClass(DISABLED)\n .on(CLICK, prevent);\n }\n }\n },\n\n _todayClass: function() {\n return TODAY;\n },\n\n _todayClick: function(e) {\n var that = this,\n depth = views[that.options.depth],\n disabled = that.options.disableDates,\n today = getToday();\n\n e.preventDefault();\n\n if (disabled(today)) {\n return;\n }\n\n if (that._view.compare(that._current, today) === 0 && that._index == depth) {\n that._changeView = false;\n }\n\n if (that._isMultipleSelection()) {\n that._selectDates = [today];\n that.selectable._lastActive = null;\n }\n\n that._value = today;\n that.navigate(today, depth);\n\n that.trigger(CHANGE);\n },\n\n _templates: function() {\n var that = this,\n options = that.options,\n footer = options.footer,\n month = options.month,\n content = month.content,\n weekNumber = month.weekNumber,\n empty = month.empty,\n footerTemplate = '#= kendo.toString(data,\"D\",\"' + options.culture +'\") #';\n\n that.month = {\n content: template('' + (content || \"#=data.value#\") + '', { useWithBlock: !!content }),\n empty: template('' + (empty || \" \") + \"\", { useWithBlock: !!empty }),\n weekNumber: template('' + (weekNumber || \"#= data.weekNumber #\") + \"\", { useWithBlock: !!weekNumber })\n };\n\n if (footer && footer !== true) {\n footerTemplate = footer;\n }\n\n that.footer = footer !== false ? template(footerTemplate, { useWithBlock: false }) : null;\n },\n\n _updateAria: function (ariaTemplate, date) {\n var that = this;\n var cell = that._cell;\n var valueType = that.view().valueType();\n var current = date || that.current();\n var text;\n\n if (valueType === \"month\") {\n text = kendo.toString(current, \"MMMM\");\n } else if (valueType === \"date\") {\n text = kendo.toString(current, \"D\");\n } else {\n text = cell.text();\n }\n\n cell.attr(\"aria-label\", ariaTemplate({ current: current, valueType: valueType, text: text }));\n\n return cell.attr(\"id\");\n }\n });\n\n ui.plugin(Calendar);\n\n var calendar = {\n firstDayOfMonth: function (date) {\n return createDate(\n date.getFullYear(),\n date.getMonth(),\n 1\n );\n },\n\n firstVisibleDay: function (date, calendarInfo) {\n calendarInfo = calendarInfo || kendo.culture().calendar;\n\n var firstDay = calendarInfo.firstDay,\n firstVisibleDay = new DATE(date.getFullYear(), date.getMonth(), 1, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());\n firstVisibleDay.setFullYear(date.getFullYear());\n\n while (firstVisibleDay.getDay() != firstDay) {\n calendar.setTime(firstVisibleDay, -1 * MS_PER_DAY);\n }\n\n return firstVisibleDay;\n },\n\n setTime: function (date, time) {\n var tzOffsetBefore = date.getTimezoneOffset(),\n resultDATE = new DATE(date.getTime() + time),\n tzOffsetDiff = resultDATE.getTimezoneOffset() - tzOffsetBefore;\n\n date.setTime(resultDATE.getTime() + tzOffsetDiff * MS_PER_MINUTE);\n },\n views: [{\n name: MONTH,\n title: function(date, min, max, culture) {\n return getCalendarInfo(culture).months.names[date.getMonth()] + \" \" + date.getFullYear();\n },\n content: function(options) {\n var that = this,\n idx = 0,\n min = options.min,\n max = options.max,\n date = options.date,\n dates = options.dates,\n format = options.format,\n culture = options.culture,\n navigateUrl = options.url,\n showHeader = options.showHeader,\n otherMonth = options.otherMonth,\n isWeekColumnVisible = options.isWeekColumnVisible,\n hasUrl = navigateUrl && dates[0],\n currentCalendar = getCalendarInfo(culture),\n firstDayIdx = currentCalendar.firstDay,\n days = currentCalendar.days,\n names = shiftArray(days.names, firstDayIdx),\n shortNames = shiftArray(days.namesShort, firstDayIdx),\n start = calendar.firstVisibleDay(date, currentCalendar),\n firstDayOfMonth = that.first(date),\n lastDayOfMonth = that.last(date),\n toDateString = that.toDateString,\n today = getToday(),\n contentClasses = options.contentClasses,\n html = '';\n\n if (showHeader) {\n html += '';\n }\n\n html += '';\n\n if (isWeekColumnVisible) {\n html += '';\n }\n\n for (; idx < 7; idx++) {\n html += '';\n }\n\n adjustDST(today, 0);\n today = +today;\n\n return view({\n cells: 42,\n perRow: 7,\n html: html += '',\n start: start,\n isWeekColumnVisible: isWeekColumnVisible,\n weekNumber: options.weekNumber,\n min: createDate(min.getFullYear(), min.getMonth(), min.getDate()),\n max: createDate(max.getFullYear(), max.getMonth(), max.getDate()),\n otherMonth : otherMonth,\n content: options.content,\n lastDayOfMonth : lastDayOfMonth,\n empty: options.empty,\n setter: that.setDate,\n disableDates: options.disableDates,\n build: function(date, idx, disableDates) {\n var cssClass = [ \"k-calendar-td\" ],\n day = date.getDay(),\n linkClass = \"\",\n url = \"#\";\n\n if (date < firstDayOfMonth || date > lastDayOfMonth) {\n cssClass.push(OTHERMONTH);\n }\n\n if (disableDates(date)) {\n cssClass.push(DISABLED);\n }\n\n if (+date === today) {\n cssClass.push(\"k-today\");\n }\n\n if (day === 0 || day === 6) {\n cssClass.push(\"k-weekend\");\n }\n\n if (hasUrl && inArray(+date, dates)) {\n url = navigateUrl.replace(\"{0}\", kendo.toString(date, format, culture));\n linkClass = \" k-action-link\";\n }\n\n return {\n date: date,\n dates: dates,\n ns: kendo.ns,\n title: kendo.toString(date, \"D\", culture),\n value: date.getDate(),\n dateString: toDateString(date),\n cssClass: cssClass.join(\" \"),\n linkClass: linkClass,\n url: url\n };\n },\n weekNumberBuild: function(date) {\n return {\n weekNumber: weekInYear(date, kendo.culture().calendar.firstDay),\n currentDate: date\n };\n }\n });\n },\n first: function(date) {\n return calendar.firstDayOfMonth(date);\n },\n last: function(date) {\n var last = createDate(date.getFullYear(), date.getMonth() + 1, 0),\n first = calendar.firstDayOfMonth(date),\n timeOffset = Math.abs(last.getTimezoneOffset() - first.getTimezoneOffset());\n\n if (timeOffset) {\n last.setHours(first.getHours() + (timeOffset / 60));\n }\n\n return last;\n },\n compare: function(date1, date2) {\n var result,\n month1 = date1.getMonth(),\n year1 = date1.getFullYear(),\n month2 = date2.getMonth(),\n year2 = date2.getFullYear();\n\n if (year1 > year2) {\n result = 1;\n } else if (year1 < year2) {\n result = -1;\n } else {\n result = month1 == month2 ? 0 : month1 > month2 ? 1 : -1;\n }\n\n return result;\n },\n setDate: function(date, value) {\n var hours = date.getHours();\n if (value instanceof DATE) {\n date.setFullYear(value.getFullYear(), value.getMonth(), value.getDate());\n } else {\n calendar.setTime(date, value * MS_PER_DAY);\n }\n adjustDST(date, hours);\n },\n toDateString: function(date) {\n return date.getFullYear() + \"/\" + date.getMonth() + \"/\" + date.getDate();\n },\n valueType: function () {\n return \"date\";\n }\n },\n {\n name: \"year\",\n title: function(date) {\n return date.getFullYear();\n },\n content: function(options) {\n var namesAbbr = getCalendarInfo(options.culture).months.namesAbbr,\n toDateString = this.toDateString,\n min = options.min,\n max = options.max,\n html = \"\";\n\n if (options.showHeader) {\n html += '
    ' + this.title(date, min, max, culture) + '
    ' + options.messages.weekColumnHeader + '' + shortNames[idx] + '
    ';\n html += '';\n html += '';\n html += '';\n }\n\n return view({\n min: createDate(min.getFullYear(), min.getMonth(), 1),\n max: createDate(max.getFullYear(), max.getMonth(), 1),\n start: createDate(options.date.getFullYear(), 0, 1),\n html: html,\n setter: this.setDate,\n build: function(date) {\n var cssClass = [ \"k-calendar-td\" ];\n\n return {\n value: namesAbbr[date.getMonth()],\n ns: kendo.ns,\n dateString: toDateString(date),\n cssClass: cssClass.join(\" \")\n };\n }\n });\n },\n first: function(date) {\n return createDate(date.getFullYear(), 0, date.getDate());\n },\n last: function(date) {\n return createDate(date.getFullYear(), 11, date.getDate());\n },\n compare: function(date1, date2){\n return compare(date1, date2);\n },\n setDate: function(date, value) {\n var month,\n hours = date.getHours();\n\n if (value instanceof DATE) {\n month = value.getMonth();\n\n date.setFullYear(value.getFullYear(), month, date.getDate());\n\n if (month !== date.getMonth()) {\n date.setDate(0);\n }\n } else {\n month = date.getMonth() + value;\n\n date.setMonth(month);\n\n if (month > 11) {\n month -= 12;\n }\n\n if (month > 0 && date.getMonth() != month) {\n date.setDate(0);\n }\n }\n\n adjustDST(date, hours);\n },\n toDateString: function(date) {\n return date.getFullYear() + \"/\" + date.getMonth() + \"/1\";\n },\n valueType: function () {\n return \"month\";\n }\n },\n {\n name: \"decade\",\n title: function(date, min, max) {\n return title(date, min, max, 10);\n },\n content: function(options) {\n var year = options.date.getFullYear(),\n toDateString = this.toDateString,\n html = \"\";\n\n if (options.showHeader) {\n html += '
    ';\n html += this.title(options.date);\n html += '
    ';\n html += '';\n html += '';\n html += '';\n }\n\n return view({\n start: createDate(year - year % 10 - 1, 0, 1),\n min: createDate(options.min.getFullYear(), 0, 1),\n max: createDate(options.max.getFullYear(), 0, 1),\n otherMonth : options.otherMonth,\n html : html,\n setter: this.setDate,\n build: function(date, idx) {\n var cssClass = [ \"k-calendar-td\" ];\n\n if (idx === 0 || idx === 11) {\n cssClass.push(OTHERMONTH);\n }\n\n return {\n value: date.getFullYear(),\n ns: kendo.ns,\n dateString: toDateString(date),\n cssClass: cssClass.join(\" \")\n };\n }\n });\n },\n first: function(date) {\n var year = date.getFullYear();\n return createDate(year - year % 10, date.getMonth(), date.getDate());\n },\n last: function(date) {\n var year = date.getFullYear();\n return createDate(year - year % 10 + 9, date.getMonth(), date.getDate());\n },\n compare: function(date1, date2) {\n return compare(date1, date2, 10);\n },\n setDate: function(date, value) {\n setDate(date, value, 1);\n },\n toDateString: function(date) {\n return date.getFullYear() + \"/0/1\";\n },\n valueType: function () {\n return \"year\";\n }\n },\n {\n name: CENTURY,\n title: function(date, min, max) {\n return title(date, min, max, 100);\n },\n content: function(options) {\n var year = options.date.getFullYear(),\n min = options.min.getFullYear(),\n max = options.max.getFullYear(),\n toDateString = this.toDateString,\n minYear = min,\n maxYear = max,\n html = \"\";\n\n minYear = minYear - minYear % 10;\n maxYear = maxYear - maxYear % 10;\n\n if (maxYear - minYear < 10) {\n maxYear = minYear + 9;\n }\n\n if (options.showHeader) {\n html += '
    ';\n html += this.title(options.date, options.min, options.max);\n html += '
    ';\n html += '';\n html += '';\n html += '';\n }\n\n return view({\n start: createDate(year - year % 100 - 10, 0, 1),\n min: createDate(minYear, 0, 1),\n max: createDate(maxYear, 0, 1),\n otherMonth : options.otherMonth,\n html : html,\n setter: this.setDate,\n build: function(date, idx) {\n var cssClass = [ \"k-calendar-td\" ];\n var start = date.getFullYear(),\n end = start + 9;\n\n if (idx === 0 || idx === 11) {\n cssClass.push(OTHERMONTH);\n }\n\n if (start < min) {\n start = min;\n }\n\n if (end > max) {\n end = max;\n }\n\n return {\n ns: kendo.ns,\n value: start + \" - \" + end,\n dateString: toDateString(date),\n cssClass: cssClass.join(\" \")\n };\n }\n });\n },\n first: function(date) {\n var year = date.getFullYear();\n return createDate(year - year % 100, date.getMonth(), date.getDate());\n },\n last: function(date) {\n var year = date.getFullYear();\n return createDate(year - year % 100 + 99, date.getMonth(), date.getDate());\n },\n compare: function(date1, date2) {\n return compare(date1, date2, 100);\n },\n setDate: function(date, value) {\n setDate(date, value, 10);\n },\n toDateString: function(date) {\n var year = date.getFullYear();\n return (year - year % 10) + \"/0/1\";\n },\n valueType: function () {\n return \"decade\";\n }\n }]\n };\n\n function title(date, min, max, modular) {\n var start = date.getFullYear(),\n minYear = min.getFullYear(),\n maxYear = max.getFullYear(),\n end;\n\n start = start - start % modular;\n end = start + (modular - 1);\n\n if (start < minYear) {\n start = minYear;\n }\n if (end > maxYear) {\n end = maxYear;\n }\n\n return start + \"-\" + end;\n }\n\n function view(options) {\n var idx = 0,\n data,\n min = options.min,\n max = options.max,\n start = options.start,\n setter = options.setter,\n build = options.build,\n weekNumberBuild = options.weekNumberBuild,\n length = options.cells || 12,\n isWeekColumnVisible = options.isWeekColumnVisible,\n cellsPerRow = options.perRow || 4,\n otherMonth = options.otherMonth,\n lastDayOfMonth = options.lastDayOfMonth,\n weekNumber = options.weekNumber || weekNumberTemplate,\n content = options.content || cellTemplate,\n empty = options.empty || emptyCellTemplate,\n otherMonthTemplate = options.otherMonthCellTemplate || otherMonthCellTemplate,\n html = options.html || '
    ';\n html += this.title(options.date, options.min, options.max);\n html += '
    ';\n\n if (isWeekColumnVisible) {\n html += weekNumber(weekNumberBuild(start));\n }\n\n\n for (; idx < length; idx++) {\n if (idx > 0 && idx % cellsPerRow === 0) {\n html += '';\n if (isWeekColumnVisible) {\n html += otherMonth || (+start <= +lastDayOfMonth) ? weekNumber(weekNumberBuild(start)) : weekNumber({ weekNumber : \" \"});\n }\n }\n\n start = createDate(start.getFullYear(), start.getMonth(), start.getDate());\n adjustDST(start, 0);\n\n data = build(start, idx, options.disableDates);\n\n html += (data.cssClass.indexOf(OTHERMONTH) !== -1 && !otherMonth) ? otherMonthTemplate(data) : isInRange(start, min, max) ? content(data) : empty(data);\n\n setter(start, 1);\n }\n\n return html + \"
    \";\n }\n\n function compare(date1, date2, modifier) {\n var year1 = date1.getFullYear(),\n start = date2.getFullYear(),\n end = start,\n result = 0;\n\n if (modifier) {\n start = start - start % modifier;\n end = start - start % modifier + modifier - 1;\n }\n\n if (year1 > end) {\n result = 1;\n } else if (year1 < start) {\n result = -1;\n }\n\n return result;\n }\n\n function getToday() {\n var today = new DATE();\n return new DATE(today.getFullYear(), today.getMonth(), today.getDate());\n }\n\n function restrictValue (value, min, max) {\n var today = getToday();\n\n if (value) {\n today = new DATE(+value);\n }\n\n if (min > today) {\n today = new DATE(+min);\n } else if (max < today) {\n today = new DATE(+max);\n }\n return today;\n }\n\n function isInRange(date, min, max) {\n return +date >= +min && +date <= +max;\n }\n\n function shiftArray(array, idx) {\n return array.slice(idx).concat(array.slice(0, idx));\n }\n\n function setDate(date, value, multiplier) {\n value = value instanceof DATE ? value.getFullYear() : date.getFullYear() + multiplier * value;\n date.setFullYear(value);\n }\n\n function daysBetweenTwoDates(startDate, endDate) {\n if (+endDate < +startDate) {\n var temp = +startDate;\n calendar.views[0].setDate(startDate, endDate);\n calendar.views[0].setDate(endDate, new Date(temp));\n }\n var fromDateUTC = Date.UTC(startDate.getFullYear(), startDate.getMonth(), startDate.getDate());\n var endDateUTC = Date.UTC(endDate.getFullYear(), endDate.getMonth(), endDate.getDate());\n\n return Math.ceil((+endDateUTC - +fromDateUTC) / kendo.date.MS_PER_DAY);\n }\n\n function addDaysToArray(array, numberOfDays, fromDate, disableDates) {\n for (var i = 0; i <= numberOfDays; i++) {\n var nextDay = new Date(fromDate.getTime());\n nextDay = new Date(nextDay.setDate(nextDay.getDate() + i));\n if (!disableDates(nextDay)) {\n array.push(nextDay);\n }\n }\n }\n\n function mousetoggle(e) {\n var disabled = $(this).hasClass(\"k-state-disabled\");\n\n if (!disabled) {\n $(this).toggleClass(HOVER, MOUSEENTER.indexOf(e.type) > -1 || e.type == FOCUS);\n }\n }\n\n function prevent (e) {\n e.preventDefault();\n }\n\n // creates date with full year\n function createDate(year, month, date) {\n var dateObject = new DATE(year, month, date);\n dateObject.setFullYear(year, month, date);\n return dateObject;\n }\n\n function getCalendarInfo(culture) {\n return getCulture(culture).calendars.standard;\n }\n\n function normalize(options) {\n var start = views[options.start],\n depth = views[options.depth],\n culture = getCulture(options.culture);\n\n options.format = extractFormat(options.format || culture.calendars.standard.patterns.d);\n\n if (isNaN(start)) {\n start = 0;\n options.start = MONTH;\n }\n\n if (depth === undefined || depth > start) {\n options.depth = MONTH;\n }\n\n if (options.dates === null) {\n options.dates = [];\n }\n }\n\n function addClassToViewContainer(element, currentView) {\n element.addClass(\"k-\" + currentView);\n }\n\n function inArray(date, dates) {\n for (var i = 0, length = dates.length; i < length; i++) {\n if (date === +dates[i]) {\n return true;\n }\n }\n return false;\n }\n\n function isEqualDatePart(value1, value2) {\n if (value1) {\n return value1.getFullYear() === value2.getFullYear() &&\n value1.getMonth() === value2.getMonth() &&\n value1.getDate() === value2.getDate();\n }\n\n return false;\n }\n\n function isEqualMonth(value1, value2) {\n if (value1) {\n return value1.getFullYear() === value2.getFullYear() &&\n value1.getMonth() === value2.getMonth();\n }\n\n return false;\n }\n\n\n function getDisabledExpr(option) {\n if (kendo.isFunction(option)) {\n return option;\n }\n\n if (Array.isArray(option)) {\n return createDisabledExpr(option);\n }\n return $.noop;\n }\n\n function convertDatesArray(dates) {\n var result = [];\n for (var i = 0; i < dates.length; i++) {\n result.push(dates[i].setHours(0, 0, 0, 0));\n }\n return result;\n }\n\n function createDisabledExpr(dates) {\n var body, callback,\n disabledDates = [],\n days = [\"su\", \"mo\", \"tu\", \"we\", \"th\", \"fr\", \"sa\"],\n searchExpression = \"if (found) {\"+\n \" return true \" +\n \"} else {\" +\n \"return false\" +\n \"}\";\n\n if (dates[0] instanceof DATE) {\n disabledDates = convertDatesArray(dates);\n body = \"var clonedDate = new Date(date); var found = date && window.kendo.jQuery.inArray(clonedDate.setHours(0, 0, 0, 0),[\"+ disabledDates +\"]) > -1;\" + searchExpression;\n } else {\n for (var i = 0; i < dates.length; i++) {\n var day = dates[i].slice(0,2).toLowerCase();\n var index = $.inArray(day, days);\n if (index > -1) {\n disabledDates.push(index);\n }\n }\n body = \"var clonedDate = new Date(date); var found = date && window.kendo.jQuery.inArray(clonedDate.getDay(),[\"+ disabledDates +\"]) > -1;\" + searchExpression;\n }\n\n callback = new Function(\"date\", body); //jshint ignore:line\n\n return callback;\n }\n\n function isEqualDate(oldValue, newValue) {\n if (oldValue instanceof Date && newValue instanceof Date) {\n oldValue = oldValue.getTime();\n newValue = newValue.getTime();\n }\n\n return oldValue === newValue;\n }\n\n function toDateObject(link) {\n var value = $(link).attr(kendo.attr(VALUE)).split(\"/\");\n //Safari cannot create correctly date from \"1/1/2090\"\n value = createDate(value[0], value[1], value[2]);\n\n return value;\n }\n\n calendar.isEqualDatePart = isEqualDatePart;\n calendar.isEqualDate = isEqualDate;\n calendar.restrictValue = restrictValue;\n calendar.isInRange = isInRange;\n calendar.addClassToViewContainer = addClassToViewContainer;\n calendar.normalize = normalize;\n calendar.viewsEnum = views;\n calendar.disabled = getDisabledExpr;\n calendar.toDateObject = toDateObject;\n calendar.getToday = getToday;\n calendar.createDate = createDate;\n\n kendo.calendar = calendar;\n})(window.kendo.jQuery);\n\nreturn window.kendo;\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n\n(function(f, define){\n define('kendo.dateinput',[ \"./kendo.core\" ], f);\n})(function(){\n\nvar __meta__ = { // jshint ignore:line\n id: \"dateinput\",\n name: \"DateInput\",\n category: \"web\",\n description: \"The DateInput widget allows to edit date by typing.\",\n depends: [ \"core\" ]\n};\n\n(function ($, undefined) {\n var global = window;\n var kendo = global.kendo;\n var caret = kendo.caret;\n var ui = kendo.ui;\n var Widget = ui.Widget;\n var keys = kendo.keys;\n var ns = \".kendoDateInput\";\n var proxy = $.proxy;\n var objectToString = {}.toString;\n\n var INPUT_EVENT_NAME = (kendo.support.propertyChangeEvent ? \"propertychange.kendoDateInput input\" : \"input\") + ns;\n\n var FOCUSED = \"k-focus\";\n var STATEDISABLED = \"k-disabled\";\n var STATEINVALID = \"k-invalid\";\n\n var DISABLED = \"disabled\";\n var READONLY = \"readonly\";\n var CHANGE = \"change\";\n\n var knownSymbols = \"dMyHhmftsz\";\n\n var DateInput = Widget.extend({\n init: function (element, options) {\n var that = this;\n\n Widget.fn.init.call(that, element, options);\n element = that.element;\n\n options = that.options;\n options.format = kendo._extractFormat(options.format || kendo.getCulture(options.culture).calendars.standard.patterns.d);\n options.min = kendo.parseDate(element.attr(\"min\")) || kendo.parseDate(options.min);\n options.max = kendo.parseDate(element.attr(\"max\")) || kendo.parseDate(options.max);\n\n var wrapperClass = (element.parent().attr(\"class\") || \"\");\n var skipWrapping = wrapperClass.indexOf(\"picker\") >= 0 && wrapperClass.indexOf(\"rangepicker\") < 0;\n\n if (skipWrapping) {\n that.wrapper = element.parent();\n } else {\n that.wrapper = element.wrap(\"\").parent();\n that.wrapper.addClass(element[0].className).removeClass('input-validation-error');\n that.wrapper[0].style.cssText = element[0].style.cssText;\n element.css({\n height: element[0].style.height\n });\n }\n\n that._validationIcon = $(\"\").insertAfter(element);\n\n that._form();\n\n that.element\n .addClass(skipWrapping ? \" \" : \"k-input-inner\")\n .attr(\"autocomplete\", \"off\")\n .on(\"focus\" + ns, function() {\n that.wrapper.addClass(FOCUSED);\n })\n .on(\"focusout\" + ns, function () {\n that.wrapper.removeClass(FOCUSED);\n that._change();\n });\n\n try {\n element[0].setAttribute(\"type\", \"text\");\n } catch (e) {\n element[0].type = \"text\";\n }\n\n var disabled = element.is(\"[disabled]\") || $(that.element).parents(\"fieldset\").is(':disabled');\n\n if (disabled) {\n that.enable(false);\n } else {\n that.readonly(element.is(\"[readonly]\"));\n }\n\n that.value(that.options.value || element.val());\n that._applyCssClasses();\n\n kendo.notify(that);\n },\n\n options: {\n name: \"DateInput\",\n culture: \"\",\n value: \"\",\n format: \"\",\n min: new Date(1900, 0, 1),\n max: new Date(2099, 11, 31),\n messages: {\n \"year\": \"year\",\n \"month\": \"month\",\n \"day\": \"day\",\n \"weekday\": \"day of the week\",\n \"hour\": \"hours\",\n \"minute\": \"minutes\",\n \"second\": \"seconds\",\n \"dayperiod\": \"AM/PM\"\n },\n size: \"medium\",\n fillMode: \"solid\",\n rounded: \"medium\"\n },\n\n events: [\n CHANGE\n ],\n\n min: function (value) {\n if (value !== undefined) {\n this.options.min = value;\n } else {\n return this.options.min;\n }\n },\n\n max: function (value) {\n if (value !== undefined) {\n this.options.max = value;\n } else {\n return this.options.max;\n }\n },\n\n setOptions: function (options) {\n var that = this;\n Widget.fn.setOptions.call(that, options);\n this._unbindInput();\n this._bindInput();\n this._updateElementValue();\n },\n\n destroy: function () {\n var that = this;\n that.element.off(ns);\n\n if (that._formElement) {\n that._formElement.off(\"reset\", that._resetHandler);\n }\n\n Widget.fn.destroy.call(that);\n },\n\n value: function (value) {\n if (value === undefined) {\n return this._dateTime.getDateObject();\n }\n\n if (value === null) {\n value = \"\";\n }\n\n if (objectToString.call(value) !== \"[object Date]\") {\n value = kendo.parseDate(value, this.options.format, this.options.culture);\n }\n\n if (value && !value.getTime()) {\n value = null;\n }\n\n this._dateTime = new customDateTime(value, this.options.format, this.options.culture, this.options.messages);\n\n this._updateElementValue();\n this._oldValue = value;\n },\n\n _updateElementValue: function () {\n var stringAndFromat = this._dateTime.toPair(this.options.format, this.options.culture, this.options.messages);\n this.element.val(stringAndFromat[0]);\n this._oldText = stringAndFromat[0];\n this._format = stringAndFromat[1];\n },\n\n readonly: function (readonly) {\n this._editable({\n readonly: readonly === undefined ? true : readonly,\n disable: false\n });\n },\n\n enable: function (enable) {\n this._editable({\n readonly: false,\n disable: !(enable = enable === undefined ? true : enable)\n });\n },\n\n _bindInput: function () {\n var that = this;\n that.element\n .on(\"focus\" + ns, function() {\n that.wrapper.addClass(FOCUSED);\n })\n .on(\"focusout\" + ns, function () {\n that.wrapper.removeClass(FOCUSED);\n that._change();\n })\n .on(\"paste\" + ns, proxy(that._paste, that))\n .on(\"keydown\" + ns, proxy(that._keydown, that))\n .on(INPUT_EVENT_NAME, proxy(that._input, that))\n .on(\"mouseup\" + ns, proxy(that._mouseUp, that))\n .on(\"DOMMouseScroll\" + ns + \" mousewheel\" + ns, proxy(that._scroll, that));\n },\n\n _unbindInput: function () {\n this.element\n .off(\"keydown\" + ns)\n .off(\"paste\" + ns)\n .off(\"focus\" + ns)\n .off(\"focusout\" + ns)\n .off(INPUT_EVENT_NAME)\n .off(\"mouseup\" + ns)\n .off(\"DOMMouseScroll\" + ns + \" mousewheel\" + ns);\n },\n\n _editable: function (options) {\n var that = this;\n var element = that.element;\n var disable = options.disable;\n var readonly = options.readonly;\n var wrapper = that.wrapper;\n\n that._unbindInput();\n\n if (!readonly && !disable) {\n wrapper.removeClass(STATEDISABLED);\n if(element && element.length) {\n element[0].removeAttribute(DISABLED);\n element[0].removeAttribute(READONLY);\n }\n\n that._bindInput();\n } else {\n if (disable) {\n wrapper.addClass(STATEDISABLED);\n element.attr(DISABLED, disable);\n if(element && element.length) {\n element[0].removeAttribute(READONLY);\n }\n }\n if (readonly) {\n element.attr(READONLY, readonly);\n }\n }\n },\n\n _change: function () {\n var that = this;\n var oldValue = that._oldValue;\n var value = that.value();\n\n if (value && that.min() && value < that.min()) {\n that.value(that.min());\n value = that.value();\n }\n if (value && that.max() && value > that.max()) {\n that.value(that.max());\n value = that.value();\n }\n\n if (oldValue && value && value.getTime() !== oldValue.getTime() ||\n oldValue && !value ||\n !oldValue && value\n ) {\n that._oldValue = value;\n that.trigger(CHANGE);\n that.element.trigger(CHANGE);\n }\n },\n\n _input: function () {\n var that = this;\n var element = that.element[0];\n var blinkInvalid = false;\n\n if (kendo._activeElement() !== element) {\n return;\n }\n\n var diff = approximateStringMatching(\n this._oldText,\n this._format,\n this.element[0].value,\n caret(this.element[0])[0]);\n\n var navigationOnly = (diff.length === 1 && diff[0][1] === \" \");\n if (!navigationOnly) {\n for (var i = 0; i < diff.length; i++) {\n var valid = this._dateTime.parsePart(diff[i][0], diff[i][1]);\n blinkInvalid = blinkInvalid || !valid;\n }\n }\n this._updateElementValue();\n\n if (diff.length && diff[0][0] !== \" \") {\n this._selectSegment(diff[0][0]);\n\n //android fix\n if (!navigationOnly) {\n var difSym = diff[0][0];\n setTimeout(function () { that._selectSegment(difSym); });\n }\n }\n if (navigationOnly) {\n var newEvent = { keyCode: 39, preventDefault: function () { } };\n this._keydown(newEvent);\n }\n if (blinkInvalid) {\n that._blinkInvalidState();\n }\n },\n\n _blinkInvalidState: function () {\n var that = this;\n\n that._addInvalidState();\n clearTimeout(that._invalidStateTimeout);\n that._invalidStateTimeout = setTimeout(proxy(that._removeInvalidState, that), 100);\n },\n\n _addInvalidState: function() {\n var that = this;\n\n that.wrapper.addClass(STATEINVALID);\n that._validationIcon.removeClass(\"k-hidden\");\n },\n\n _removeInvalidState: function () {\n var that = this;\n\n that.wrapper.removeClass(STATEINVALID);\n that._validationIcon.addClass(\"k-hidden\");\n that._invalidStateTimeout = null;\n },\n\n _mouseUp: function () {\n var selection = caret(this.element[0]);\n if (selection[0] === selection[1]) {\n this._selectNearestSegment();\n }\n },\n\n _scroll: function (e) {\n if (kendo._activeElement() !== this.element[0] || this.element.is(\"[readonly]\")) {\n return;\n }\n e = window.event || e;\n\n var newEvent = { keyCode: 37, preventDefault: function () { } };\n\n if (e.shiftKey) {\n newEvent.keyCode = (e.wheelDelta || -e.detail) > 0 ? 37 : 39;\n } else {\n newEvent.keyCode = (e.wheelDelta || -e.detail) > 0 ? 38 : 40;\n }\n this._keydown(newEvent);\n e.returnValue = false;\n if (e.preventDefault) {\n e.preventDefault();\n }\n if (e.stopPropagation) {\n e.stopPropagation();\n }\n },\n\n _form: function () {\n var that = this;\n var element = that.element;\n var formId = element.attr(\"form\");\n var form = formId ? $(\"#\" + formId) : element.closest(\"form\");\n var initialValue = element[0].value;\n\n if (!initialValue && that.options.value) {\n initialValue = that.options.value;\n }\n\n if (form[0]) {\n that._resetHandler = function () {\n setTimeout(function () {\n that.value(initialValue);\n });\n };\n\n that._formElement = form.on(\"reset\", that._resetHandler);\n }\n },\n\n _paste: function (e) {\n e.preventDefault();\n },\n\n _keydown: function (e) {\n var key = e.keyCode;\n var selection;\n if (key == 37 || key == 39) { //left/right\n e.preventDefault();\n selection = caret(this.element[0]);\n if (selection[0] != selection[1]) {\n this._selectNearestSegment();\n }\n var dir = (key == 37) ? -1 : 1;\n var index = (dir == -1) ? caret(this.element[0])[0] - 1 : caret(this.element[0])[1] + 1;\n while (index >= 0 && index < this._format.length) {\n if (knownSymbols.indexOf(this._format[index]) >= 0) {\n this._selectSegment(this._format[index]);\n break;\n }\n index += dir;\n }\n }\n if (key == 38 || key == 40) { //up/down\n e.preventDefault();\n selection = caret(this.element[0]);\n var symbol = this._format[selection[0]];\n if (knownSymbols.indexOf(symbol) >= 0) {\n var interval = 1;\n if (symbol == 'm') {\n interval = this.options.interval || 1;\n }\n this._dateTime.modifyPart(symbol, key == 38 ? interval * 1 : interval * -1);\n this._updateElementValue();\n this._selectSegment(symbol);\n this.element.trigger(CHANGE);\n }\n }\n if (kendo.support.browser.msie && kendo.support.browser.version < 10) {\n var keycode = e.keyCode ? e.keyCode : e.which;\n if (keycode === 8 || keycode === 46) {\n var that = this;\n setTimeout(function () {\n that._input();\n }, 0);\n }\n }\n if (key === keys.ENTER){\n this._change();\n }\n },\n\n _selectNearestSegment: function () {\n var selection = caret(this.element[0]);\n var start = selection[0];\n for (var i = start, j = start - 1; i < this._format.length || j >= 0; i++ , j--) {\n if (i < this._format.length && knownSymbols.indexOf(this._format[i]) !== -1) {\n this._selectSegment(this._format[i]);\n return;\n }\n if (j >= 0 && knownSymbols.indexOf(this._format[j]) !== -1) {\n this._selectSegment(this._format[j]);\n return;\n }\n }\n },\n\n _selectSegment: function (symbol) {\n var begin = -1, end = 0;\n for (var i = 0; i < this._format.length; i++) {\n if (this._format[i] === symbol) {\n end = i + 1;\n if (begin === -1) {\n begin = i;\n }\n }\n }\n if (begin < 0) {\n begin = 0;\n }\n caret(this.element, begin, end);\n }\n\n });\n\n kendo.cssProperties.registerPrefix(\"DateInput\", \"k-input-\");\n\n kendo.cssProperties.registerValues(\"DateInput\", [{\n prop: \"rounded\",\n values: kendo.cssProperties.roundedValues.concat([['full', 'full']])\n }]);\n\n ui.plugin(DateInput);\n\n var customDateTime = function (initDate, initFormat, initCulture, initMessages) {\n\n var value = null;\n var year = true, month = true, date = true, hours = true, minutes = true, seconds = true, milliseconds = true;\n var typedMonthPart = \"\";\n var typedDayPeriodPart = \"\";\n var placeholders = {};\n\n //TODO: rewrite pad method\n var zeros = [\"\", \"0\", \"00\", \"000\", \"0000\"];\n function pad(number, digits, end) {\n number = number + \"\";\n digits = digits || 2;\n end = digits - number.length;\n\n if (end) {\n return zeros[digits].substring(0, end) + number;\n }\n\n return number;\n }\n var dateFormatRegExp = /dddd|ddd|dd|d|MMMM|MMM|MM|M|yyyy|yy|HH|H|hh|h|mm|m|fff|ff|f|tt|ss|s|zzz|zz|z|\"[^\"]*\"|'[^']*'/g;\n var months = null, calendar = null, days = null, returnsFormat = false;\n var matcher = function (match) {\n var mins, sign;\n var result;\n\n switch (match) {\n case (\"d\"): result = date ? value.getDate() : placeholders.day; break;\n case (\"dd\"): result = date ? pad(value.getDate()) : placeholders.day; break;\n case (\"ddd\"): result = date && month && year ? days.namesAbbr[value.getDay()] : placeholders.weekday; break;\n case (\"dddd\"): result = date && month && year ? days.names[value.getDay()] : placeholders.weekday; break;\n\n case (\"M\"): result = month ? value.getMonth() + 1 : placeholders.month; break;\n case (\"MM\"): result = month ? pad(value.getMonth() + 1) : placeholders.month; break;\n case (\"MMM\"): result = month ? months.namesAbbr[value.getMonth()] : placeholders.month; break;\n case (\"MMMM\"): result = month ? months.names[value.getMonth()] : placeholders.month; break;\n\n case (\"yy\"): result = year ? pad(value.getFullYear() % 100) : placeholders.year; break;\n case (\"yyyy\"): result = year ? pad(value.getFullYear(), 4) : placeholders.year; break;\n\n case (\"h\"): result = hours ? value.getHours() % 12 || 12 : placeholders.hour; break;\n case (\"hh\"): result = hours ? pad(value.getHours() % 12 || 12) : placeholders.hour; break;\n case (\"H\"): result = hours ? value.getHours() : placeholders.hour; break;\n case (\"HH\"): result = hours ? pad(value.getHours()) : placeholders.hour; break;\n\n case (\"m\"): result = minutes ? value.getMinutes() : placeholders.minute; break;\n case (\"mm\"): result = minutes ? pad(value.getMinutes()) : placeholders.minute; break;\n case (\"s\"): result = seconds ? value.getSeconds() : placeholders.second; break;\n case (\"ss\"): result = seconds ? pad(value.getSeconds()) : placeholders.second; break;\n case (\"f\"): result = milliseconds ? Math.floor(value.getMilliseconds() / 100) : milliseconds; break;\n case (\"ff\"):\n result = value.getMilliseconds();\n if (result > 99) {\n result = Math.floor(result / 10);\n }\n result = milliseconds ? pad(result) : match;\n break;\n case (\"fff\"): result = milliseconds ? pad(value.getMilliseconds(), 3) : match; break;\n case (\"tt\"): result = hours ? (value.getHours() < 12 ? calendar.AM[0] : calendar.PM[0]) : placeholders.dayperiod; break;\n case (\"zzz\"):\n mins = value.getTimezoneOffset();\n sign = mins < 0;\n result = Math.abs(mins / 60).toString().split(\".\")[0];\n mins = Math.abs(mins) - (result * 60);\n result = (sign ? \"+\" : \"-\") + pad(result);\n result += \":\" + pad(mins);\n break;\n case (\"z\"):\n case (\"zz\"):\n result = value.getTimezoneOffset() / 60;\n sign = result < 0;\n result = Math.abs(result).toString().split(\".\")[0];\n result = (sign ? \"+\" : \"-\") + (match === \"zz\" ? pad(result) : result);\n break;\n }\n result = (result !== undefined ? result : match.slice(1, match.length - 1));\n\n if (returnsFormat) {\n result = \"\" + result;\n var formatResult = \"\";\n if (match == \"ddd\") { match = \"EEE\"; }\n if (match == \"dddd\") { match = \"EEEE\"; }\n for (var i = 0; i < result.length; i++) {\n formatResult += match[0];\n }\n return formatResult;\n } else {\n return result;\n }\n };\n\n function generateMatcher(retFormat) {\n returnsFormat = retFormat;\n return matcher;\n }\n\n function setExisting(symbol, val) {\n switch (symbol) {\n case \"y\": year = val; break;\n case \"M\": month = val;\n if (!val) {\n value.setMonth(0);\n typedMonthPart = \"\";\n }\n break;\n case \"d\": date = val; break;\n case \"H\":\n case \"h\": hours = val;\n if (!val) {\n typedDayPeriodPart = \"\";\n }\n break;\n case \"m\": minutes = val; break;\n case \"s\": seconds = val; break;\n default: return;\n }\n }\n\n this.setValue = function (val) {\n date = val;\n };\n\n this.getValue = function () {\n return date;\n };\n\n this.modifyPart = function (symbol, offset) {\n var newValue = new Date((value && value.getTime) ? value.getTime() : value);\n switch (symbol) {\n case \"y\": newValue.setFullYear(newValue.getFullYear() + offset); break;\n case \"M\":\n var newMonth = newValue.getMonth() + offset;\n newValue.setMonth(newMonth);\n if (newValue.getMonth() % 12 !== (newMonth + 12) % 12) {\n //handle case when new month does not have such date\n newValue.setDate(1);\n newValue.setMonth(newMonth);\n }\n break;\n case \"d\":\n case \"E\": newValue.setDate(newValue.getDate() + offset); break;\n case \"H\":\n case \"h\": newValue.setHours(newValue.getHours() + offset); break;\n case \"m\": newValue.setMinutes(newValue.getMinutes() + offset); break;\n case \"s\": newValue.setSeconds(newValue.getSeconds() + offset); break;\n case \"t\": newValue.setHours((newValue.getHours() + 12) % 24); break;\n default: break;\n }\n if (newValue.getFullYear() > 0) {\n setExisting(symbol, true);\n value = newValue;\n }\n };\n\n this.parsePart = function (symbol, currentChar) {\n if (!currentChar) {\n setExisting(symbol, false);\n return true;\n }\n var newValue = new Date((value && value.getTime) ? value.getTime() : value);\n var lastDateOfMonth = new Date(newValue.getFullYear(), newValue.getMonth() + 1, 0).getDate();\n var newHours;\n switch (symbol) {\n case \"d\":\n var newDate = (date ? newValue.getDate() * 10 : 0) + parseInt(currentChar, 10);\n if (isNaN(newDate)) { return; }\n while (newDate > lastDateOfMonth) {\n newDate = parseInt(newDate.toString().slice(1), 10);\n }\n if (newDate < 1) {\n date = false;\n } else {\n newValue.setDate(newDate);\n if (newValue.getMonth() !== value.getMonth()) {\n return;\n }\n date = true;\n }\n break;\n case \"M\":\n var newMonth = (month ? (newValue.getMonth() + 1) * 10 : 0) + parseInt(currentChar, 10);\n if (!isNaN(newMonth)) {\n while (newMonth > 12) {\n newMonth = parseInt(newMonth.toString().slice(1), 10);\n }\n if (newMonth < 1) {\n month = false;\n } else {\n newValue.setMonth(newMonth - 1);\n if (newValue.getMonth() !== newMonth - 1) {\n newValue.setDate(1);\n newValue.setMonth(newMonth - 1);\n }\n month = true;\n }\n }\n else {\n var monthNames = calendar.months.names;\n typedMonthPart += currentChar.toLowerCase();\n\n while (typedMonthPart.length > 0) {\n for (var i = 0; i < monthNames.length; i++) {\n if (monthNames[i].toLowerCase().indexOf(typedMonthPart) === 0) {\n newValue.setMonth(i);\n month = true;\n value = newValue;\n return true;\n }\n }\n typedMonthPart = typedMonthPart.substring(1, typedMonthPart.length);\n }\n return false;\n }\n break;\n case \"y\":\n var newYear = (year ? (newValue.getFullYear()) * 10 : 0) + parseInt(currentChar, 10);\n if (isNaN(newYear)) {return;}\n while (newYear > 9999) {\n newYear = parseInt(newYear.toString().slice(1), 10);\n }\n if (newYear < 1) {\n year = false;\n } else {\n newValue.setFullYear(newYear);\n year = true;\n }\n break;\n case \"h\":\n newHours = (hours ? (newValue.getHours() % 12 || 12) * 10 : 0) + parseInt(currentChar, 10);\n if (isNaN(newHours)) { return; }\n while (newHours > 12) {\n newHours = parseInt(newHours.toString().slice(1), 10);\n }\n newValue.setHours(Math.floor(newValue.getHours() / 12) * 12 + newHours % 12);\n hours = true;\n break;\n case \"H\":\n newHours = (hours ? (newValue.getHours()) * 10 : 0) + parseInt(currentChar, 10);\n if (isNaN(newHours)) { return; }\n while (newHours > 23) {\n newHours = parseInt(newHours.toString().slice(1), 10);\n }\n newValue.setHours(newHours);\n hours = true;\n break;\n case \"m\":\n var newMinutes = (minutes ? (newValue.getMinutes()) * 10 : 0) + parseInt(currentChar, 10);\n if (isNaN(newMinutes)) { return; }\n while (newMinutes > 59) {\n newMinutes = parseInt(newMinutes.toString().slice(1), 10);\n }\n newValue.setMinutes(newMinutes);\n minutes = true;\n break;\n case \"s\":\n var newSeconds = (seconds ? (newValue.getSeconds()) * 10 : 0) + parseInt(currentChar, 10);\n if (isNaN(newSeconds)) { return; }\n while (newSeconds > 59) {\n newSeconds = parseInt(newSeconds.toString().slice(1), 10);\n }\n newValue.setSeconds(newSeconds);\n seconds = true;\n break;\n case \"t\":\n if (hours) {\n typedDayPeriodPart += currentChar.toLowerCase();\n while (typedDayPeriodPart.length > 0) {\n if (calendar.AM[0].toLowerCase().indexOf(typedDayPeriodPart) === 0 && newValue.getHours() >= 12 ||\n calendar.PM[0].toLowerCase().indexOf(typedDayPeriodPart) === 0 && newValue.getHours() < 12) {\n newValue.setHours((newValue.getHours() + 12) % 24);\n value = newValue;\n return true;\n }\n typedDayPeriodPart = typedDayPeriodPart.substring(1, typedDayPeriodPart.length);\n }\n return false;\n }\n break;\n default: break;\n }\n value = newValue;\n return true;\n };\n\n this.toPair = function (format, culture , messages) {\n if (!format) {\n return [\"\", \"\"];\n }\n culture = kendo.getCulture(culture);\n calendar = culture.calendars.standard;\n format = calendar.patterns[format] || format;\n days = calendar.days;\n months = calendar.months;\n placeholders = messages;\n return [\n format.replace(dateFormatRegExp, generateMatcher(false)),\n format.replace(dateFormatRegExp, generateMatcher(true))\n ];\n };\n\n this.getDateObject = function () {\n return (year && month && date && hours && minutes && seconds && milliseconds) ?\n new Date(value.getTime()) : null;\n };\n\n if (!initDate) {\n value = new Date();\n var sampleFormat = this.toPair(initFormat, initCulture, initMessages)[1];\n for (var i = 0; i < sampleFormat.length; i++) {\n setExisting(sampleFormat[i], false);\n }\n } else {\n value = new Date(initDate.getTime());\n }\n };\n\n function approximateStringMatching(oldText, oldFormat, newText, caret){\n var oldTextSeparator = oldText[caret + oldText.length - newText.length];\n oldText = oldText.substring(0, caret + oldText.length - newText.length);\n newText = newText.substring(0, caret);\n var diff = [];\n var i;\n //handle typing single character over the same selection\n if (oldText === newText && caret > 0) {\n diff.push([oldFormat[caret - 1], newText[caret - 1]]);\n return diff;\n }\n if (oldText.indexOf(newText) === 0 && (newText.length === 0 || oldFormat[newText.length - 1] !== oldFormat[newText.length])) {\n //handle delete/backspace\n var deletedSymbol = \"\";\n for (i = newText.length; i < oldText.length; i++) {\n if (oldFormat[i] !== deletedSymbol && knownSymbols.indexOf(oldFormat[i]) >= 0) {\n deletedSymbol = oldFormat[i];\n diff.push([deletedSymbol, \"\"]);\n }\n }\n return diff;\n }\n\n //handle entering space or separator, for nagivation to next item\n if (newText[newText.length - 1] === \" \" || newText[newText.length - 1] === oldTextSeparator) {\n return [[oldFormat[caret - 1], \" \"]];\n }\n\n //handle inserting text (new text is longer than previous)\n //handle typing over literal as well\n if (newText.indexOf(oldText) === 0 || knownSymbols.indexOf(oldFormat[caret - 1]) === -1) {\n var symbol = oldFormat[0];\n for (i = Math.max(0, oldText.length - 1); i < oldFormat.length; i++) {\n if (knownSymbols.indexOf(oldFormat[i]) >= 0) {\n symbol = oldFormat[i];\n break;\n }\n }\n return [[symbol, newText[caret - 1]]];\n }\n //handle typing over correctly selected part\n return [[oldFormat[caret - 1], newText[caret - 1]]];\n}\n\n})(window.kendo.jQuery);\n\nreturn window.kendo;\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n\n(function(f, define){\n define('kendo.datepicker',[ \"./kendo.calendar\", \"./kendo.popup\", \"./kendo.dateinput\", \"./kendo.html.button\"], f);\n})(function(){\n\nvar __meta__ = { // jshint ignore:line\n id: \"datepicker\",\n name: \"DatePicker\",\n category: \"web\",\n description: \"The DatePicker widget allows the user to select a date from a calendar or by direct input.\",\n depends: [ \"calendar\", \"popup\", \"html.button\" ]\n};\n\n(function($, undefined) {\n var kendo = window.kendo,\n ui = kendo.ui,\n html = kendo.html,\n Widget = ui.Widget,\n parse = kendo.parseDate,\n keys = kendo.keys,\n support = kendo.support,\n template = kendo.template,\n activeElement = kendo._activeElement,\n DIV = \"
    \",\n SPAN = \"\",\n ns = \".kendoDatePicker\",\n CLICK = \"click\" + ns,\n UP = support.mouseAndTouchPresent ? kendo.applyEventMap(\"up\", ns.slice(1)) : CLICK,\n OPEN = \"open\",\n CLOSE = \"close\",\n CHANGE = \"change\",\n DISABLED = \"disabled\",\n READONLY = \"readonly\",\n FOCUSED = \"k-focus\",\n SELECTED = \"k-state-selected\",\n STATEDISABLED = \"k-disabled\",\n HOVER = \"k-hover\",\n HOVEREVENTS = \"mouseenter\" + ns + \" mouseleave\" + ns,\n MOUSEDOWN = \"mousedown\" + ns,\n ID = \"id\",\n MIN = \"min\",\n MAX = \"max\",\n MONTH = \"month\",\n ARIA_DISABLED = \"aria-disabled\",\n ARIA_READONLY = \"aria-readonly\",\n ARIA_EXPANDED = \"aria-expanded\",\n ARIA_HIDDEN = \"aria-hidden\",\n calendar = kendo.calendar,\n isInRange = calendar.isInRange,\n restrictValue = calendar.restrictValue,\n isEqualDatePart = calendar.isEqualDatePart,\n extend = $.extend,\n proxy = $.proxy,\n DATE = Date;\n\n function normalize(options) {\n var parseFormats = options.parseFormats,\n format = options.format;\n\n calendar.normalize(options);\n\n\n parseFormats = Array.isArray(parseFormats) ? parseFormats : [parseFormats];\n\n if (!parseFormats.length) {\n parseFormats.push(\"yyyy-MM-dd\");\n }\n\n if ($.inArray(format, parseFormats) === -1) {\n parseFormats.splice(0, 0, options.format);\n }\n\n options.parseFormats = parseFormats;\n }\n\n function preventDefault(e) {\n e.preventDefault();\n }\n\n var DateView = function(options) {\n var that = this, id,\n body = document.body,\n div = $(DIV).attr(ARIA_HIDDEN, \"true\")\n .addClass(\"k-calendar-container\");\n\n that.options = options = options || {};\n id = options.id;\n\n if(!options.omitPopup){\n div.appendTo(body);\n that.popup = new ui.Popup(div, extend(options.popup, options, { name: \"Popup\", isRtl: kendo.support.isRtl(options.anchor) }));\n } else {\n div = options.dateDiv;\n }\n if (id) {\n id += \"_dateview\";\n\n div.attr(ID, id);\n that._dateViewID = id;\n }\n that.div = div;\n\n that.value(options.value);\n };\n\n DateView.prototype = {\n _calendar: function() {\n var that = this;\n var calendar = that.calendar;\n var options = that.options;\n var div;\n\n if (!calendar) {\n div = $(DIV).attr(ID, kendo.guid())\n .appendTo(options.omitPopup ? options.dateDiv : that.popup.element)\n .on(MOUSEDOWN, preventDefault)\n .on(CLICK, \"td:has(.k-link)\", proxy(that._click, that));\n\n\n that.calendar = calendar = new ui.Calendar(div, { componentType: options.componentType, size: options.size, messages: options.messages });\n that._setOptions(options);\n\n div.addClass(kendo.getValidCssClass(\"k-calendar-\", \"size\", options.size));\n\n calendar.navigate(that._value || that._current, options.start);\n\n that.value(that._value);\n }\n },\n\n _setOptions: function(options) {\n this.calendar.setOptions({\n focusOnNav: false,\n change: options.change,\n culture: options.culture,\n dates: options.dates,\n depth: options.depth,\n footer: options.footer,\n format: options.format,\n max: options.max,\n min: options.min,\n month: options.month,\n weekNumber: options.weekNumber,\n start: options.start,\n messages: options.messages,\n disableDates: options.disableDates\n });\n },\n\n setOptions: function(options) {\n var old = this.options;\n var disableDates = options.disableDates;\n\n if (disableDates) {\n options.disableDates = calendar.disabled(disableDates);\n }\n\n this.options = extend(old, options, {\n change: old.change,\n close: old.close,\n open: old.open\n });\n\n if (this.calendar) {\n this._setOptions(this.options);\n }\n },\n\n destroy: function() {\n if(this.popup){\n this.popup.destroy();\n }\n },\n\n open: function() {\n var that = this;\n var popupHovered;\n\n that._calendar();\n\n // In some cases when the popup is opened resize is triggered which will cause it to close\n // Setting the below flag will prevent this from happening\n // Reference: https://github.com/telerik/kendo/pull/7553\n popupHovered = that.popup._hovered;\n that.popup._hovered = true;\n\n that.popup.open();\n\n setTimeout(function() {\n that.popup._hovered = popupHovered;\n }, 1);\n },\n\n close: function() {\n if (this.popup) {\n this.popup.close();\n }\n },\n\n min: function(value) {\n this._option(MIN, value);\n },\n\n max: function(value) {\n this._option(MAX, value);\n },\n\n toggle: function() {\n var that = this;\n\n that[that.popup.visible() ? CLOSE : OPEN]();\n },\n\n move: function(e) {\n var that = this,\n key = e.keyCode,\n calendar = that.calendar,\n selectIsClicked = e.ctrlKey && key == keys.DOWN || key == keys.ENTER,\n handled = false;\n\n if (e.altKey) {\n if (key == keys.DOWN) {\n that.open();\n e.preventDefault();\n handled = true;\n } else if (key == keys.UP) {\n that.close();\n e.preventDefault();\n handled = true;\n }\n\n } else if (that.popup && that.popup.visible()) {\n\n if (key == keys.ESC || (selectIsClicked && calendar._cell.hasClass(SELECTED))) {\n that.close();\n e.preventDefault();\n return true;\n }\n //spacebar selects a date in the calendar\n if (key != keys.SPACEBAR) {\n that._current = calendar._move(e);\n }\n\n handled = true;\n }\n\n return handled;\n },\n\n current: function(date) {\n this._current = date;\n if (this.calendar) {\n this.calendar._focus(date);\n }\n },\n\n value: function(value) {\n var that = this,\n calendar = that.calendar,\n options = that.options,\n disabledDate = options.disableDates;\n\n if (disabledDate && disabledDate(value)) {\n value = null;\n }\n\n that._value = value;\n that._current = new DATE(+restrictValue(value, options.min, options.max));\n\n if (calendar) {\n calendar.value(value);\n }\n },\n\n _click: function(e) {\n\n if (e.currentTarget.className.indexOf(SELECTED) !== -1) {\n this.calendar.trigger(\"change\");\n this.close();\n }\n },\n\n _option: function(option, value) {\n var that = this;\n var calendar = that.calendar;\n\n that.options[option] = value;\n\n if (calendar) {\n calendar[option](value);\n }\n }\n };\n\n DateView.normalize = normalize;\n\n kendo.DateView = DateView;\n\n var DatePicker = Widget.extend({\n init: function(element, options) {\n var that = this,\n initialValue,\n disabled,\n div;\n\n Widget.fn.init.call(that, element, options);\n element = that.element;\n options = that.options;\n\n options.disableDates = kendo.calendar.disabled(options.disableDates);\n\n options.min = parse(element.attr(\"min\")) || parse(options.min);\n options.max = parse(element.attr(\"max\")) || parse(options.max);\n\n normalize(options);\n\n that._initialOptions = extend({}, options);\n\n that._wrapper();\n\n that.dateView = new DateView(extend({}, options, {\n id: element.attr(ID),\n anchor: that.wrapper,\n change: function() {\n // calendar is the current scope\n that._change(this.value());\n that.close();\n },\n close: function(e) {\n if (that.trigger(CLOSE)) {\n e.preventDefault();\n } else {\n element.attr(ARIA_EXPANDED, false);\n div.attr(ARIA_HIDDEN, true);\n }\n },\n open: function(e) {\n var options = that.options,\n date;\n\n if (that.trigger(OPEN)) {\n e.preventDefault();\n } else {\n if (that.element.val() !== that._oldText) {\n date = parse(element.val(), options.parseFormats, options.culture);\n\n that.dateView[date ? \"current\" : \"value\"](date);\n }\n\n element.attr(ARIA_EXPANDED, true);\n div.attr(ARIA_HIDDEN, false);\n\n that._updateARIA(date);\n\n }\n }\n }));\n div = that.dateView.div;\n\n that._icon();\n\n try {\n element[0].setAttribute(\"type\", \"text\");\n } catch(e) {\n element[0].type = \"text\";\n }\n\n element\n .addClass(\"k-input-inner\")\n .attr({\n role: \"combobox\",\n \"aria-expanded\": false,\n \"aria-haspopup\": \"grid\",\n \"aria-owns\": that.dateView._dateViewID,\n \"autocomplete\": \"off\"\n });\n that._reset();\n that._template();\n\n disabled = element.is(\"[disabled]\") || $(that.element).parents(\"fieldset\").is(':disabled');\n if (disabled) {\n that.enable(false);\n } else {\n that.readonly(element.is(\"[readonly]\"));\n }\n\n initialValue = parse(options.value || that.element.val(), options.parseFormats, options.culture);\n\n that._createDateInput(options);\n\n that._old = that._update(initialValue || that.element.val());\n that._oldText = element.val();\n that._applyCssClasses();\n\n kendo.notify(that);\n },\n events: [\n OPEN,\n CLOSE,\n CHANGE],\n options: {\n name: \"DatePicker\",\n value: null,\n footer: \"\",\n format: \"\",\n culture: \"\",\n parseFormats: [],\n min: new Date(1900, 0, 1),\n max: new Date(2099, 11, 31),\n start: MONTH,\n depth: MONTH,\n animation: {},\n month: {},\n dates: [],\n disableDates: null,\n ARIATemplate: 'Current focused #=data.valueType# is #=data.text#',\n dateInput: false,\n weekNumber: false,\n messages: {\n weekColumnHeader: \"\"\n },\n componentType: \"classic\",\n size: \"medium\",\n fillMode: \"solid\",\n rounded: \"medium\"\n },\n\n setOptions: function(options) {\n var that = this;\n var value = that._value;\n\n Widget.fn.setOptions.call(that, options);\n\n options = that.options;\n\n options.min = parse(options.min);\n options.max = parse(options.max);\n\n normalize(options);\n\n that._dateIcon.off(ns);\n that._dateIcon.remove();\n\n that.dateView.setOptions(options);\n that._icon();\n that._editable(options);\n that._createDateInput(options);\n\n if (!that._dateInput) {\n that.element.val(kendo.toString(value, options.format, options.culture));\n }\n\n if (value) {\n that._updateARIA(value);\n }\n },\n\n _editable: function(options) {\n var that = this,\n icon = that._dateIcon.off(ns),\n element = that.element.off(ns),\n wrapper = that.wrapper.off(ns),\n readonly = options.readonly,\n disable = options.disable;\n\n if (!readonly && !disable) {\n wrapper\n .removeClass(STATEDISABLED)\n .on(HOVEREVENTS, that._toggleHover);\n if(element && element.length) {\n element[0].removeAttribute(DISABLED);\n element[0].removeAttribute(READONLY);\n }\n element.attr(ARIA_DISABLED, false)\n .attr(ARIA_READONLY, false)\n .on(\"keydown\" + ns, proxy(that._keydown, that))\n .on(\"focusout\" + ns, proxy(that._blur, that))\n .on(\"focus\" + ns, function() {\n that.wrapper.addClass(FOCUSED);\n });\n\n icon.on(UP, proxy(that._click, that))\n .on(MOUSEDOWN, preventDefault);\n } else {\n wrapper\n .addClass(disable ? STATEDISABLED : \"\")\n .removeClass(disable ? \"\" : STATEDISABLED);\n\n element.attr(DISABLED, disable)\n .attr(READONLY, readonly)\n .attr(ARIA_DISABLED, disable)\n .attr(ARIA_READONLY, readonly);\n }\n },\n\n readonly: function(readonly) {\n this._editable({\n readonly: readonly === undefined ? true : readonly,\n disable: false\n });\n if (this._dateInput) {\n this._dateInput._editable({\n readonly: readonly === undefined ? true : readonly,\n disable: false\n });\n }\n },\n\n enable: function(enable) {\n this._editable({\n readonly: false,\n disable: !(enable = enable === undefined ? true : enable)\n });\n if (this._dateInput) {\n this._dateInput._editable({\n readonly: false,\n disable: !(enable = enable === undefined ? true : enable)\n });\n }\n },\n\n destroy: function() {\n var that = this;\n\n Widget.fn.destroy.call(that);\n\n that.dateView.destroy();\n\n that.element.off(ns);\n that._dateIcon.off(ns);\n\n if (that._form) {\n that._form.off(\"reset\", that._resetHandler);\n }\n },\n\n open: function() {\n this.dateView.open();\n },\n\n close: function() {\n this.dateView.close();\n },\n\n min: function(value) {\n return this._option(MIN, value);\n },\n\n max: function(value) {\n return this._option(MAX, value);\n },\n\n value: function(value) {\n var that = this;\n\n if (value === undefined) {\n return that._value;\n }\n\n that._old = that._update(value);\n\n if (that._old === null) {\n if (that._dateInput) {\n that._dateInput.value(that._old);\n } else {\n that.element.val(\"\");\n }\n }\n\n that._oldText = that.element.val();\n },\n\n _toggleHover: function(e) {\n $(e.currentTarget).toggleClass(HOVER, e.type === \"mouseenter\");\n },\n\n _blur: function() {\n var that = this,\n value = that.element.val();\n\n that.close();\n if (value !== that._oldText) {\n that._change(value);\n if (!value) {\n that.dateView.current(kendo.calendar.getToday());\n }\n }\n\n that.wrapper.removeClass(FOCUSED);\n },\n\n _click: function(e) {\n var that = this;\n\n that.dateView.toggle();\n that._focusElement(e.type);\n },\n\n _focusElement: function(eventType) {\n var element = this.element;\n\n if ((!support.touch || (support.mouseAndTouchPresent && !(eventType || \"\").match(/touch/i))) && element[0] !== activeElement()) {\n element.trigger(\"focus\");\n }\n },\n\n _change: function(value) {\n var that = this,\n oldValue = that.element.val(),\n dateChanged;\n\n value = that._update(value);\n dateChanged = !kendo.calendar.isEqualDate(that._old, value);\n\n var valueUpdated = dateChanged && !that._typing;\n var textFormatted = oldValue !== that.element.val();\n\n if (valueUpdated || textFormatted) {\n that.element.trigger(CHANGE);\n }\n\n if (dateChanged) {\n that._old = value;\n that._oldText = that.element.val();\n\n that.trigger(CHANGE);\n }\n\n that._typing = false;\n },\n\n _keydown: function(e) {\n var that = this,\n dateView = that.dateView,\n value = that.element.val(),\n handled = false;\n\n if (!dateView.popup.visible() && e.keyCode == keys.ENTER && value !== that._oldText) {\n that._change(value);\n } else {\n handled = dateView.move(e);\n that._updateARIA(dateView._current);\n\n if (!handled) {\n that._typing = true;\n } else if (that._dateInput && e.stopImmediatePropagation) {\n e.stopImmediatePropagation();\n }\n }\n },\n\n _icon: function() {\n var that = this,\n element = that.element,\n options = that.options,\n icon;\n\n icon = element.next(\"button.k-input-button\");\n\n if (!icon[0]) {\n icon = $(html.renderButton('', {\n icon: \"calendar\",\n size: options.size,\n fillMode: options.fillMode,\n shape: null,\n rounded: null\n })).insertAfter(element);\n }\n\n that._dateIcon = icon.attr({\n \"role\": \"button\",\n \"aria-controls\": that.dateView._dateViewID\n });\n },\n\n _option: function(option, value) {\n var that = this,\n options = that.options;\n\n if (value === undefined) {\n return options[option];\n }\n\n value = parse(value, options.parseFormats, options.culture);\n\n if (!value) {\n return;\n }\n\n options[option] = new DATE(+value);\n that.dateView[option](value);\n },\n\n _update: function(value) {\n var that = this,\n options = that.options,\n min = options.min,\n max = options.max,\n current = that._value,\n date = parse(value, options.parseFormats, options.culture),\n isSameType = (date === null && current === null) || (date instanceof Date && current instanceof Date),\n formattedValue;\n\n if (options.disableDates(date)) {\n date = null;\n if (!that._old && !that.element.val()) {\n value = null;\n }\n }\n\n if (+date === +current && isSameType) {\n formattedValue = kendo.toString(date, options.format, options.culture);\n\n if (formattedValue !== value && !(that._dateInput && !date)) {\n that.element.val(date === null ? value : formattedValue);\n }\n\n return date;\n }\n\n if (date !== null && isEqualDatePart(date, min)) {\n date = restrictValue(date, min, max);\n } else if (!isInRange(date, min, max)) {\n date = null;\n }\n\n that._value = date;\n that.dateView.value(date);\n if (that._dateInput && date) {\n that._dateInput.value(date || value);\n } else {\n that.element.val(kendo.toString(date || value, options.format, options.culture));\n }\n that._updateARIA(date);\n\n return date;\n },\n\n _wrapper: function() {\n var that = this,\n element = that.element,\n wrapper;\n\n wrapper = element.parents(\".k-datepicker\");\n\n if (!wrapper[0]) {\n wrapper = element.wrap(SPAN).parent();\n }\n\n wrapper[0].style.cssText = element[0].style.cssText;\n element.css({\n height: element[0].style.height\n });\n\n that.wrapper = wrapper.addClass(\"k-datepicker k-input\")\n .addClass(element[0].className).removeClass('input-validation-error');\n },\n\n _reset: function() {\n var that = this,\n element = that.element,\n formId = element.attr(\"form\"),\n options = that.options,\n disabledDate = options.disableDates,\n parseFormats = options.parseFormats.length ? options.parseFormats : null,\n optionsValue = that._initialOptions.value,\n form = formId ? $(\"#\" + formId) : element.closest(\"form\"),\n initialValue = element[0].defaultValue;\n\n if (optionsValue && (disabledDate && disabledDate(optionsValue))) {\n optionsValue = null;\n }\n\n if ((!initialValue || !kendo.parseDate(initialValue, parseFormats, options.culture)) && optionsValue) {\n element.attr(\"value\", kendo.toString(optionsValue, options.format, options.culture));\n }\n\n if (form[0]) {\n that._resetHandler = function() {\n that.value(optionsValue || element[0].defaultValue);\n that.max(that._initialOptions.max);\n that.min(that._initialOptions.min);\n };\n\n that._form = form.on(\"reset\", that._resetHandler);\n }\n },\n\n _template: function() {\n this._ariaTemplate = proxy(template(this.options.ARIATemplate), this);\n },\n\n _createDateInput: function(options) {\n if (this._dateInput) {\n this._dateInput.destroy();\n this._dateInput = null;\n }\n\n if (options.dateInput ) {\n this._dateInput = new ui.DateInput(this.element, {\n culture: options.culture,\n format: options.format,\n size: options.size,\n fillMode: options.fillMode,\n rounded: options.rounded,\n min: options.min,\n max: options.max\n });\n }\n },\n\n _updateARIA: function(date) {\n var that = this;\n var calendar = that.dateView.calendar;\n\n if (that.element && that.element.length) {\n that.element[0].removeAttribute(\"aria-activedescendant\");\n }\n\n if (calendar) {\n that.element.attr(\"aria-activedescendant\", calendar._updateAria(that._ariaTemplate, date));\n }\n }\n });\n\n kendo.cssProperties.registerPrefix(\"DatePicker\", \"k-input-\");\n\n kendo.cssProperties.registerValues(\"DatePicker\", [{\n prop: \"rounded\",\n values: kendo.cssProperties.roundedValues.concat([['full', 'full']])\n }]);\n\n ui.plugin(DatePicker);\n\n})(window.kendo.jQuery);\n\nreturn window.kendo;\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n\n(function(f, define){\n define('kendo.drawer',[ \"./kendo.userevents\" ], f);\n})(function(){\n\nvar __meta__ = { // jshint ignore:line\n id: \"drawer\",\n name: \"Drawer\",\n category: \"web\",\n description: \"The Kendo Drawer widget provides slide to reveal sidebar\",\n depends: [ \"userevents\" ]\n};\n\n(function ($, undefined) {\n var kendo = window.kendo,\n ui = kendo.ui,\n Widget = ui.Widget,\n SHOW = \"show\",\n HIDE = \"hide\",\n NS = \".kendoDrawer\",\n FOCUSED = \"k-state-focused\",\n keys = kendo.keys,\n ITEMCLICK = \"itemClick\",\n TABINDEX = \"tabIndex\",\n proxy = $.proxy,\n PUSH = \"push\",\n OVERLAY = \"overlay\",\n LEFT = \"left\",\n RIGHT =\"right\";\n\n var Drawer = kendo.ui.Widget.extend({\n init: function(element, options) {\n var that = this;\n var userEvents;\n\n Widget.fn.init.call(this, element, options);\n\n options = that.options;\n\n that._element(element);\n\n that._wrapper(element);\n\n that._navigatable();\n\n that.position();\n\n that._mode();\n\n if (options.mini) {\n that._miniMode();\n }\n\n that._initDrawerItems();\n\n if (options.mini && options.mode != PUSH) {\n that._setBodyOffset();\n }\n\n userEvents = this.userEvents = new kendo.UserEvents(options.mode != PUSH ? $(document.body) : this.drawerContainer, { fastTap: true, allowSelection: true });\n\n that.tap = function(e) {\n if ($.contains(that.drawerItemsWrapper[0], e.event.target)) {\n that._itemClick(e);\n }\n if (options.autoCollapse && that.visible && !that.trigger(\"hide\", { sender: this})) {\n that.hide();\n e.preventDefault();\n }\n };\n\n if (this.options.swipeToOpen) {\n userEvents.bind(\"start\", function(e) { that._start(e); });\n userEvents.bind(\"move\", function(e) { that._update(e); });\n userEvents.bind(\"end\", function(e) { that._end(e); });\n userEvents.bind(\"tap\", that.tap);\n } else {\n userEvents.bind(\"press\", that.tap);\n }\n\n if (options.minHeight && options.mode == PUSH) {\n that.drawerContainer.css(\"min-height\", options.minHeight);\n }\n },\n\n _element: function() {\n var that = this;\n\n var element = that.element;\n var options = that.options;\n var contentElement = that.contentElement = element.children().first();\n that.drawerElement = $(options.template);\n\n contentElement.addClass(\"k-drawer-content\");\n element.addClass(\"k-widget k-drawer\");\n },\n\n _navigatable: function () {\n\n if (!this.options.navigatable) {\n return;\n }\n\n var that = this;\n var element = that.element;\n var drawerItems = element.find(\"[data-role='drawer-item']\");\n\n element.find(\"[data-role='drawer-separator']\").attr(\"aria-hidden\", true);\n\n drawerItems.attr(\"role\",\"tab\");\n\n drawerItems.first().parent()\n .attr(\"role\", \"tablist\")\n .attr(\"aria-orientation\", \"vertical\");\n\n element\n .attr(TABINDEX, 0)\n .on(\"focus\" + NS, proxy(that._focus, that))\n .on(\"focusout\" + NS, proxy(that._blur, that))\n .on(\"keydown\" + NS, that, proxy(that._keyDown, that));\n },\n\n _blur: function () {\n var that = this;\n\n if (that._current) {\n that._current.removeClass(FOCUSED);\n }\n },\n\n _focus: function () {\n var that = this;\n\n that._setCurrent(that._current ? that._current : that.drawerItemsWrapper.find(\"[data-role='drawer-item']\").eq(0));\n },\n\n _setCurrent: function (current) {\n var that = this;\n var id = kendo.guid();\n var next = $(current);\n\n if (that._current) {\n $(that._current)\n .removeClass(FOCUSED)\n .removeAttr(\"id\");\n\n that.element.removeAttr(\"aria-activedescendant\");\n }\n\n next\n .attr(\"id\", id)\n .addClass(FOCUSED);\n\n that.element.attr(\"aria-activedescendant\", id);\n\n that._current = next;\n },\n\n _keyDown: function (e) {\n var that = this;\n var handled = false;\n var current = that._current;\n var next;\n\n if (e.keyCode == keys.UP) {\n handled = true;\n next = current.prevAll(\"[data-role='drawer-item']\").first();\n\n if (next.length) {\n that._setCurrent(next);\n } else {\n that._setCurrent(current.parent().find(\"[data-role='drawer-item']\").last());\n }\n\n }\n\n if (e.keyCode == keys.DOWN) {\n handled = true;\n next = current.nextAll(\"[data-role='drawer-item']\").first();\n\n if (next.length) {\n that._setCurrent(next);\n } else {\n that._setCurrent(current.parent().find(\"[data-role='drawer-item']\").first());\n }\n }\n\n if (e.keyCode == keys.HOME) {\n handled = true;\n that._setCurrent(that.drawerItemsWrapper.find(\"[data-role='drawer-item']\").eq(0));\n }\n\n if (e.keyCode == keys.END) {\n handled = true;\n that._setCurrent(that.drawerItemsWrapper.find(\"[data-role='drawer-item']\").last());\n }\n\n if (e.keyCode == keys.SPACEBAR || e.keyCode == keys.ENTER) {\n handled = true;\n that.tap({\n event: { target: current[0]},\n preventDefault: $.noop\n });\n }\n\n if (e.keyCode == keys.ESC) {\n handled = true;\n that.hide();\n }\n\n if (handled) {\n //prevent scrolling while pressing the keys\n e.preventDefault();\n }\n },\n\n _wrapper: function() {\n var options = this.options;\n var drawerElement = this.drawerElement;\n var element = this.element;\n var contentElement = this.contentElement;\n var drawerItemsWrapper = this.drawerItemsWrapper = drawerElement.wrapAll(\"
    \").parent();\n var drawerWrapper = this.drawerWrapper = drawerItemsWrapper.wrap(\"
    \").parent();\n var drawerContainer = this.drawerContainer = element.wrap(\"
    \").parent();\n\n if (options.mini) {\n if (options.mini.width) {\n drawerWrapper.width(options.mini.width);\n }\n } else {\n drawerWrapper.width(0);\n }\n\n\n if (options.mode === PUSH) {\n drawerContainer.append(contentElement);\n }\n else if (options.mode === OVERLAY) {\n drawerContainer.after(contentElement);\n $(document.body).prepend(drawerContainer);\n }\n\n element.append( drawerWrapper );\n },\n\n _setBodyOffset: function() {\n var overlayMiniOffset = this.element.outerWidth();\n\n if (this.leftPositioned) {\n $(document.body).css(\"padding-left\", overlayMiniOffset);\n }\n else {\n $(document.body).css(\"padding-right\", overlayMiniOffset);\n }\n },\n\n _initDrawerItems: function() {\n var drawerItemsWrapper = this.drawerItemsWrapper;\n var drawerItems = drawerItemsWrapper.find(\"[data-role='drawer-item']\");\n var separatorItems = drawerItemsWrapper.find(\"[data-role='drawer-separator']\");\n\n drawerItems.addClass(\"k-drawer-item\");\n separatorItems.addClass(\"k-drawer-item k-drawer-separator\");\n\n if (this._selectedItemIndex >= 0) {\n drawerItems.removeClass(\"k-state-selected\");\n drawerItems.eq(this._selectedItemIndex).addClass(\"k-state-selected\");\n }\n\n if (this.options.navigatable) {\n drawerItems.attr(\"aria-selected\", false);\n }\n\n },\n\n _mode: function() {\n var options = this.options;\n var drawerContainer = this.drawerContainer;\n var overlayContainer;\n\n if (options.mode == PUSH) {\n drawerContainer.addClass('k-drawer-' + PUSH);\n }\n else {\n drawerContainer.addClass('k-drawer-' + OVERLAY);\n overlayContainer = this.overlayContainer = $('
    ');\n overlayContainer.hide();\n drawerContainer.prepend(overlayContainer);\n }\n },\n\n _miniMode: function() {\n var options = this.options;\n var drawerContainer = this.drawerContainer;\n var miniWidth = options.mini.width;\n var miniTemplate = this._miniTemplate = options.mini.template && $(options.mini.template);\n var drawerItemsWrapper = this.drawerItemsWrapper;\n var drawerWrapper = this.drawerWrapper;\n\n drawerContainer.addClass(\"k-drawer-mini\");\n\n if (miniTemplate) {\n drawerItemsWrapper.html(miniTemplate);\n }\n\n if (miniWidth) {\n drawerWrapper.width(miniWidth);\n }\n\n this.minWidth = options.mini.width || this.drawerWrapper.width();\n },\n\n show: function() {\n var drawerWrapper = this.drawerWrapper;\n var drawerContainer = this.drawerContainer;\n var options = this.options;\n var isExpanded = drawerContainer.hasClass(\"k-drawer-expanded\");\n var miniTemplate = this._miniTemplate;\n var drawerElement = this.drawerElement;\n var drawerItemsWrapper = this.drawerItemsWrapper;\n\n if (!isExpanded) {\n drawerContainer.addClass('k-drawer-expanded');\n this.visible = true;\n }\n\n if (miniTemplate) {\n drawerItemsWrapper.html(drawerElement);\n this._initDrawerItems();\n this._selectItem();\n }\n\n drawerWrapper.width(options.width);\n\n if (options.mode === OVERLAY) {\n this.overlayContainer.show();\n this.visible = true;\n }\n },\n\n hide: function() {\n var that = this;\n var drawerWrapper = that.drawerWrapper;\n var drawerContainer = that.drawerContainer;\n var options = this.options;\n var drawerItemsWrapper = this.drawerItemsWrapper;\n var miniTemplate = this._miniTemplate;\n var miniWidth = options.mini && options.mini.width;\n\n if (this._miniTemplate) {\n drawerItemsWrapper.html(miniTemplate);\n that._initDrawerItems();\n this._selectItem();\n }\n\n if(options.mini) {\n if (miniWidth) {\n drawerWrapper.width(miniWidth);\n } else {\n drawerWrapper.width(\"\");\n }\n } else {\n drawerWrapper.width(0);\n }\n\n if (this.visible) {\n drawerContainer.removeClass('k-drawer-expanded');\n this.visible = false;\n }\n\n if (options.mode === OVERLAY) {\n this.overlayContainer.hide();\n }\n },\n\n position: function(value) {\n var that = this;\n var options = that.options;\n var position = value || options.position;\n var drawerContainer = that.drawerContainer;\n\n if (position == RIGHT) {\n drawerContainer.removeClass('k-drawer-'+ LEFT);\n drawerContainer.addClass('k-drawer-'+ RIGHT);\n }\n else {\n drawerContainer.removeClass('k-drawer-'+ RIGHT);\n drawerContainer.addClass('k-drawer-'+ LEFT);\n }\n\n this.leftPositioned = position === LEFT;\n },\n\n _start: function(e) {\n var that = this;\n var options = this.options;\n var drawerWrapper = this.drawerWrapper;\n var drawerItemsWrapper = this.drawerItemsWrapper;\n var userEvents = e.sender;\n\n\n // ignore non-horizontal swipes\n if (Math.abs(e.x.velocity) < Math.abs(e.y.velocity) || kendo.triggeredByInput(e.event)) {\n userEvents.cancel();\n return;\n }\n\n\n if (this.drawerMini) {\n drawerItemsWrapper.html(that.drawerElement);\n }\n\n drawerWrapper.css(\"transition\", \"none\");\n\n if (options.mode != PUSH) {\n this.overlayContainer.show();\n }\n },\n\n _update: function(e) {\n var options = this.options;\n var mode = options.mode;\n\n if (mode == PUSH) {\n this._push(e);\n }\n else {\n this._overlay(e);\n }\n },\n\n _end: function(e) {\n var velocity = e.x.velocity;\n var options = this.options;\n var drawerWrapper = this.drawerWrapper;\n var elementWidth = drawerWrapper.width();\n var pastHalf = elementWidth > options.width / 2;\n var velocityThreshold = 0.8;\n var shouldShow;\n\n drawerWrapper.css(\"transition\", \"all .3s ease-out\");\n\n if (this.leftPositioned) {\n shouldShow = velocity > -velocityThreshold && (velocity > velocityThreshold || pastHalf);\n }\n else {\n shouldShow = velocity < velocityThreshold && (velocity < -velocityThreshold || pastHalf);\n }\n\n if(shouldShow) {\n if (this.trigger(\"show\", { sender: this})) {\n e.preventDefault();\n this.hide();\n } else {\n this.show();\n }\n } else {\n if (this.trigger(\"hide\", { sender: this})) {\n e.preventDefault();\n this.show();\n } else {\n this.hide();\n }\n }\n },\n\n _overlay: function(moveEventArgs) {\n var options = this.options;\n var minWidth = (options.mini && options.mini.width) || this.minWidth || 0;\n var drawerWrapper = this.drawerWrapper;\n var elementWidth = drawerWrapper.width();\n var limitedPosition;\n var updatedPosition;\n\n updatedPosition = elementWidth + (this.leftPositioned ? moveEventArgs.x.delta : -moveEventArgs.x.delta);\n\n limitedPosition = Math.min(Math.max(updatedPosition, minWidth), options.width);\n\n moveEventArgs.event.preventDefault();\n moveEventArgs.event.stopPropagation();\n\n drawerWrapper.width(limitedPosition);\n },\n\n _push: function(moveEventArgs) {\n var options = this.options;\n var minWidth = (options.mini && options.mini.width) || this.minWidth || 0;\n var drawerWrapper = this.drawerWrapper;\n var elementWidth = drawerWrapper.width();\n var limitedPosition;\n var updatedPosition;\n\n updatedPosition = elementWidth + (this.leftPositioned ? moveEventArgs.x.delta : -moveEventArgs.x.delta);\n\n limitedPosition = Math.min(Math.max(updatedPosition, minWidth), options.width);\n\n moveEventArgs.event.preventDefault();\n moveEventArgs.event.stopPropagation();\n\n drawerWrapper.width(limitedPosition);\n },\n\n _selectItem: function(item) {\n var selectedItemIndex;\n\n if (item) {\n item.addClass(\"k-state-selected\");\n this.trigger(\"itemClick\", {item: item, sender: this});\n this._selectedItemIndex = item.index();\n return;\n }\n\n selectedItemIndex = this._selectedItemIndex;\n\n if (selectedItemIndex) {\n this.drawerItemsWrapper.find(\"[data-role='drawer-item']\").eq(selectedItemIndex).addClass(\"k-state-selected\");\n }\n },\n\n _itemClick: function(e) {\n var that = this;\n var item;\n var items;\n\n if ($(e.event.target).find(\".k-drawer-item\").length > 0) {\n item = $(e.event.target).find(\".k-drawer-item\");\n }\n else if ($(e.event.target).closest(\".k-drawer-item\").length > 0) {\n item = $(e.event.target).closest(\".k-drawer-item\");\n }\n else if ($(e.event.target).hasClass(\".k-drawer-item\")) {\n item = $(e.event.target);\n }\n items = that.drawerItemsWrapper.find(\".k-drawer-item\").removeClass(\"k-state-selected\");\n that._selectItem(item);\n\n if (that.options.navigatable) {\n items.attr(\"aria-selected\", false);\n item.attr(\"aria-selected\", true);\n that._setCurrent(item);\n }\n },\n\n destroy: function() {\n var options = this.options;\n\n if (options.mode != PUSH) {\n if (this.leftPositioned) {\n $(document.body).css(\"padding-left\", 0);\n }\n else {\n $(document.body).css(\"padding-right\", 0);\n }\n }\n\n Widget.fn.destroy.call(this);\n\n this.userEvents.destroy();\n\n kendo.destroy(this.element);\n this.element = this.drawerWrapper = this.drawerElement = this.drawerContainer = this.drawerItemsWrapper = this._miniTemplate = null;\n },\n\n options: {\n name: \"Drawer\",\n autoCollapse: true,\n position: LEFT,\n mode: \"overlay\",\n swipeToOpen: true,\n width: 280,\n mini: false,\n navigatable: false,\n template: \"\"\n },\n\n events: [\n HIDE,\n SHOW,\n ITEMCLICK\n ]\n\n });\n kendo.ui.plugin(Drawer);\n})(window.kendo.jQuery);\n\nreturn window.kendo;\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n\n(function(f, define){\n define('kendo.multiviewcalendar',[ \"./kendo.core\", \"./kendo.selectable\", \"./kendo.calendar\" ], f);\n})(function(){\n\nvar __meta__ = { // jshint ignore:line\n id: \"multiviewcalendar\",\n name: \"MultiViewCalendar\",\n category: \"web\",\n description: \"Multi-view calendar.\",\n depends: [ \"core\", \"selectable\", \"calendar\" ]\n};\n\n(function($, undefined) {\n var kendo = window.kendo,\n calendar = kendo.calendar,\n support = kendo.support,\n isInRange = calendar.isInRange,\n toDateObject = calendar.toDateObject,\n createDate = calendar.createDate,\n isEqualDate = calendar.isEqualDate,\n getToday = calendar.getToday,\n keys = kendo.keys,\n ui = kendo.ui,\n Widget = ui.Widget,\n Selectable = ui.Selectable,\n template = kendo.template,\n mobileOS = support.mobileOS,\n ns = \".kendoMultiViewCalendar\",\n CLICK = \"click\",\n KEYDOWN = \"keydown\",\n ID = \"id\",\n MIN = \"min\",\n MONTH = \"month\",\n DOT = \".\",\n CENTURY = \"century\",\n DECADE = \"decade\",\n CHANGE = \"change\",\n NAVIGATE = \"navigate\",\n VALUE = \"value\",\n FOCUSED = \"k-state-focused\",\n SELECTED = \"k-state-selected\",\n MID = \"k-range-mid\",\n SPLITEND = \"k-range-split-end\",\n SPLITSTART = \"k-range-split-start\",\n START = \"k-range-start\",\n END = \"k-range-end\",\n HOVER = \"k-state-hover\",\n DISABLED = \"k-state-disabled\",\n TODAY = \"k-nav-today\",\n OTHERMONTH = \"k-other-month\",\n OUTOFRANGE = \"k-out-of-range\",\n CELLSELECTOR = \"td:has(.k-link):not(.\" + OUTOFRANGE + \")\",\n CELLSELECTORVALID = \"td:has(.k-link):not(.\" + DISABLED + \"):not(.\" + OUTOFRANGE + \")\",\n BLUR = \"blur\",\n FOCUS = \"focus\",\n MOUSEENTER = support.touch ? \"touchstart\" : \"mouseenter\",\n MOUSELEAVE_NS = support.touch ? \"touchend\" + ns + \" touchmove\" + ns : \"mouseleave\" + ns,\n PREVARROW = \"_prevArrow\",\n NEXTARROW = \"_nextArrow\",\n ARIA_SELECTED = \"aria-selected\",\n INPUTSELECTOR = \"input,a,textarea,.k-multiselect-wrap,select,button,.k-button>span,.k-button>img,span.k-icon.k-i-arrow-60-down,span.k-icon.k-i-arrow-60-up\",\n ARIA_DISABLED = \"aria-disabled\",\n ARIA_LABEL = \"aria-label\",\n proxy = $.proxy,\n DATE = Date,\n views = {\n month: 0,\n year: 1,\n decade: 2,\n century: 3\n };\n\n var RangeSelectable = Widget.extend({\n init: function(element, options) {\n var that = this;\n\n Widget.fn.init.call(that, element, options);\n\n that.calendar = options.calendar;\n\n that.userEvents = new kendo.UserEvents(that.element, {\n global: true,\n allowSelection: true,\n filter: that.options.filter,\n tap: proxy(that._tap, that),\n touchAction: \"none\"\n });\n },\n\n events: [CHANGE],\n\n options: {\n name: \"RangeSelectable\",\n filter: \">*\",\n inputSelectors: INPUTSELECTOR,\n multiple: false,\n dragToSelect: true,\n relatedTarget: $.noop\n },\n\n destroy: function () {\n var that = this;\n\n Widget.fn.destroy.call(that);\n\n that.userEvents.destroy();\n that.calendar = null;\n\n that._lastActive = that.element = that.userEvents = that._start = that._end = null;\n },\n\n _allowSelection: function(target) {\n if ($(target).is(this.options.inputSelectors)) {\n this.userEvents.cancel();\n return false;\n }\n\n return true;\n },\n\n start: function (element) {\n if (element === undefined) {\n return this._start;\n }\n element.addClass(START + \" \" + SELECTED);\n this._start = element;\n },\n\n end: function(element) {\n if (element === undefined) {\n return this._start;\n }\n element.addClass(END + \" \" + SELECTED);\n this._end = element;\n },\n\n mid: function(elements) {\n var tables = this.element.find(\"table.k-month\");\n\n elements.addClass(MID);\n tables.each(function() {\n var that = $(this);\n var lastCell = that.find(CELLSELECTORVALID).last();\n var firstCell = that.find(CELLSELECTORVALID).first();\n\n if (lastCell.hasClass(MID)) {\n lastCell.addClass(SPLITEND);\n }\n\n if (firstCell.hasClass(MID)) {\n firstCell.addClass(SPLITSTART);\n }\n });\n },\n\n clear: function(clearVariables) {\n this.element.find(CELLSELECTOR).removeClass(END + \" \" + SELECTED + \" \" + START + \" \" + MID + \" \" + SPLITEND + \" \" + SPLITSTART);\n\n if (clearVariables) {\n this._start = this._end = null;\n }\n },\n\n selectFrom: function(start) {\n var that = this;\n var items;\n var startIdx;\n\n items = that.element.find(CELLSELECTOR);\n\n startIdx = $.inArray($(start)[0], items);\n\n that.clear();\n that.start(start);\n\n items = items.filter(function (index) {\n return index > startIdx;\n });\n that.mid(items);\n },\n\n selectTo: function(end) {\n var that = this;\n var items;\n var endIdx;\n\n items = that.element.find(CELLSELECTOR);\n\n endIdx = $.inArray($(end)[0], items);\n\n that.clear();\n\n items = items.filter(function (index) {\n return index < endIdx;\n });\n that.mid(items);\n that.end($(end));\n },\n\n range: function(start, end) {\n var that = this;\n var items;\n var startIdx;\n var endIdx;\n var temp;\n\n if (start === undefined) {\n return { start: that._start, end: that._end };\n }\n\n items = that.element.find(CELLSELECTOR);\n\n startIdx = $.inArray($(start)[0], items);\n endIdx = $.inArray($(end)[0], items);\n\n if (endIdx == -1) {\n endIdx = items.length;\n }\n\n if (startIdx > endIdx) {\n temp = end;\n end = start;\n start = temp;\n temp = startIdx;\n startIdx = endIdx;\n endIdx = temp;\n }\n that.clear();\n start.addClass(START + \" \" + SELECTED);\n that._start = start;\n\n items = items.filter(function (index) {\n return index > startIdx && index < endIdx;\n });\n that.mid(items);\n\n if (end) {\n that.end($(end));\n } else {\n that._useEnd = true;\n }\n },\n\n change: function() {\n this.trigger(CHANGE);\n },\n\n _clearFlags: function () {\n this._useStart = this._useEnd = false;\n },\n\n _tap: function(e) {\n var target = $(e.target),\n range = this.calendar.selectRange() || {},\n start = range.start,\n end = range.end,\n that = this,\n currentDate = toDateObject($(target).find(\"a\")),\n items,\n startIdx,\n endIdx;\n\n\n that._lastActive = target;\n\n if (!start || +start > +currentDate) {\n that.clear(true);\n that.start(target);\n that._clearFlags();\n that.trigger(CHANGE);\n return;\n }\n\n if (start && !end) {\n items = that.element.find(CELLSELECTOR);\n\n startIdx = $.inArray($(that._start)[0], items);\n endIdx = $.inArray($(target)[0], items);\n\n if (start) {\n that._useStart = true;\n }\n\n items = items.filter(function (index) {\n return index > startIdx && index < endIdx;\n });\n that.mid(items);\n that.end($(target));\n that.trigger(CHANGE);\n that._clearFlags();\n return;\n }\n\n if (start && end) {\n if (target.hasClass(MID)) {\n if (!that._toggling) {\n that.range(target, that._end);\n } else {\n that.range(that._start, target);\n }\n that._toggling = !that._toggling;\n that.trigger(CHANGE);\n that._clearFlags();\n return;\n }\n that._toggling = false;\n that._end = null;\n that.clear();\n that.start(target);\n that.trigger(CHANGE);\n that._clearFlags();\n }\n }\n });\n\n\n var MultiViewCalendar = Widget.extend({\n init: function(element, options) {\n var that = this;\n var id;\n var culture;\n\n Widget.fn.init.call(that, element, options);\n\n element = that.wrapper = that.element;\n options = that.options;\n\n that.options.disableDates = calendar.disabled(that.options.disableDates);\n\n culture = kendo.getCulture(options.culture);\n options.format = kendo._extractFormat(options.format || culture.calendars.standard.patterns.d);\n\n that._templates();\n\n that._header();\n\n that._wrapper();\n\n id = element\n .addClass(\"k-widget k-calendar k-calendar-range\" + (options.weekNumber ? \" k-week-number\" : \"\"))\n .on(KEYDOWN + ns, \"table.k-content\", proxy(that._move, that))\n .on(BLUR + ns, \"table\", proxy(that._blur, that))\n .on(CLICK + ns, CELLSELECTORVALID, function(e) {\n var link = e.currentTarget.firstChild;\n\n if (link.href.indexOf(\"#\") != -1) {\n e.preventDefault();\n }\n\n that._click($(link));\n })\n .on(MOUSEENTER + ns, CELLSELECTORVALID, proxy(that._mouseEnter, that))\n .on(MOUSELEAVE_NS, CELLSELECTORVALID, function() {\n $(this).removeClass(HOVER);\n })\n .attr(ID);\n\n if (id) {\n that._cellID = id + \"_cell_selected\";\n }\n\n that._calendarWidth = that.element.width();\n\n that._range = options.range;\n\n that._initViews({ viewName: options.start, value: options.value});\n that._selectable();\n\n that._footer(that.footer);\n that._selectDates = [];\n that.value(options.value);\n\n if (options.selectable == \"multiple\") {\n that._selectDates = options.selectDates.length ? options.selectDates : that._selectDates;\n that._restoreSelection();\n }\n\n if (options.selectable == \"range\") {\n that.selectRange(that._range);\n }\n\n kendo.notify(that);\n },\n\n options: {\n name: \"MultiViewCalendar\",\n value: null,\n min: new DATE(1900, 0, 1),\n max: new DATE(2099, 11, 31),\n dates: [],\n disableDates: null,\n culture: \"\",\n footer : \"\",\n format : \"\",\n month : {},\n range : { start: null, end: null },\n weekNumber: false,\n views: 2,\n showViewHeader: false,\n selectable: \"single\",\n selectDates: [],\n start: MONTH,\n depth: MONTH,\n messages: {\n weekColumnHeader: \"\"\n }\n },\n\n events: [\n CHANGE,\n NAVIGATE\n ],\n\n setOptions: function(options) {\n var that = this;\n\n calendar.normalize(options);\n\n options.disableDates = calendar.disabled(options.disableDates);\n\n Widget.fn.setOptions.call(that, options);\n\n that._selectable();\n\n that._templates();\n\n that._footer(that.footer);\n\n for (var i = 0; i < that._views.length; i++) {\n that._views[i].off(ns).remove();\n }\n\n that._initViews({ viewName: options.start, value: options.value});\n\n that._range = options.range || { start: null, end: null };\n\n that._restoreSelection();\n },\n\n destroy: function() {\n var that = this;\n\n that._cell = null;\n that._currentView = null;\n that._current = null;\n\n if (that._views) {\n for (var i = 0; i < that._views.length; i++) {\n that._views[i].off(ns).remove();\n }\n }\n\n that.element.off(ns);\n\n if (that.header) {\n that.header.off(ns);\n that._title = null;\n that.header = null;\n }\n\n if (that.selectable) {\n that.selectable.destroy();\n that.selectable = null;\n }\n\n if (that.rangeSelectable) {\n that.rangeSelectable.destroy();\n that.rangeSelectable = null;\n }\n\n if (that._today) {\n kendo.destroy(that._today.off(ns));\n }\n\n that._views = null;\n\n Widget.fn.destroy.call(that);\n },\n\n current: function() {\n return this._current;\n },\n\n focus: function() {\n var table;\n\n if (this._cell) {\n this._cell.closest(\"table\").trigger(\"focus\");\n } else if (this._current && this._dateInViews(this._current)) {\n this._cell = this._cellByDate(this._current);\n this._cell.closest(\"table\").trigger(\"focus\");\n } else {\n table = this.element.find(\"table\").first().trigger(\"focus\");\n this._cell = table.find(CELLSELECTORVALID).first();\n this._current = toDateObject(this._cell.find(\"a\"));\n }\n this._cell.addClass(FOCUSED);\n },\n\n min: function(value) {\n return this._option(MIN, value);\n },\n\n max: function(value) {\n return this._option(\"max\", value);\n },\n\n view: function() {\n return this._currentView;\n },\n\n navigateToPast: function() {\n this._navigate(PREVARROW, -1);\n },\n\n navigateToFuture: function() {\n this._navigate(NEXTARROW, 1);\n },\n\n navigateUp: function() {\n var that = this,\n index = that._index;\n\n if (that._title.hasClass(DISABLED)) {\n return;\n }\n\n that.navigate(that._current, ++index);\n },\n\n navigateDown: function(value) {\n var that = this,\n index = that._index,\n depth = that.options.depth;\n\n if (!value) {\n return;\n }\n\n if (index === views[depth]) {\n if (!isEqualDate(that._value, that._current) || !isEqualDate(that._value, value)) {\n that.value(value);\n that.trigger(CHANGE);\n }\n return;\n }\n\n that.navigate(value, --index);\n },\n\n navigate: function(value, view) {\n view = isNaN(view) ? calendar.views[calendar.viewsEnum[view]] : calendar.views[view];\n\n var that = this;\n var options = that.options;\n var min = options.min;\n var max = options.max;\n\n if (!value) {\n that._current = value = new DATE(+calendar.restrictValue(value, min, max));\n } else {\n that._current = value;\n }\n\n if (view === undefined) {\n view = that._currentView;\n }\n\n that._currentView = view;\n\n for (var i = 0; i < that._views.length; i++) {\n that._views[i].off(ns).remove();\n }\n\n that._initViews({ viewName: view.name, value: value });\n\n that._restoreSelection();\n },\n\n _updateHeader: function() {\n var that = this;\n var view = that._currentView;\n var title = that._title;\n var value = that._firstViewValue;\n var options = that.options;\n var visibleRange = that._visibleRange();\n var culture = options.culture;\n var min = options.min;\n var max = options.max;\n var lastDate;\n var disabled;\n var prevDisabled;\n var nextDisabled;\n\n\n if (view.name === DECADE || view.name === CENTURY) {\n lastDate = shiftDate(value, view.name, options.views - 1);\n if (!isInRange(lastDate, min, max)) {\n lastDate = max;\n }\n\n title.html(view.first(value).getFullYear() + \" - \" + view.last(lastDate).getFullYear());\n } else {\n title.html(view.title(value, min, max, culture) + \" - \" + view.title(shiftDate(value, view.name, options.views - 1), min, max, culture));\n }\n\n disabled = view.name === CENTURY;\n title.toggleClass(DISABLED, disabled).attr(ARIA_DISABLED, disabled);\n\n prevDisabled = view.compare(visibleRange.start, that.options.min) < 1;\n nextDisabled = view.compare(visibleRange.end, that.options.max) > -1;\n\n if (prevDisabled && nextDisabled) {\n if (that._navContainer) {\n that._navContainer.remove();\n that._navContainer = null;\n }\n } else {\n if (!that._navContainer) {\n that._navContainer = $('' +\n '' +\n '' +\n '').appendTo(that.header);\n that[PREVARROW] = that._navContainer.find(\".k-prev-view\");\n that[NEXTARROW] = that._navContainer.find(\".k-next-view\");\n }\n\n that[PREVARROW].toggleClass(DISABLED, prevDisabled).attr(ARIA_DISABLED, prevDisabled);\n if (that[PREVARROW].hasClass(DISABLED)) {\n that[PREVARROW].removeClass(HOVER);\n }\n\n that[NEXTARROW].toggleClass(DISABLED, nextDisabled).attr(ARIA_DISABLED, nextDisabled);\n if (that[NEXTARROW].hasClass(DISABLED)) {\n that[NEXTARROW].removeClass(HOVER);\n }\n }\n },\n\n _mouseEnter: function(e) {\n var that = this;\n var cell = $(e.currentTarget);\n var range;\n var items;\n var startIdx;\n var endIdx;\n\n cell.addClass(HOVER);\n\n if (that.rangeSelectable && that._currentView.name === \"month\") {\n range = that.selectRange();\n if (range.start && !range.end) {\n if (that._dateInViews(that.selectRange().start)) {\n items = that.element.find(that.rangeSelectable.options.filter);\n startIdx = $.inArray($(that.rangeSelectable._start)[0], items);\n endIdx = $.inArray($(cell)[0], items);\n if (startIdx > endIdx) {\n return;\n }\n that.rangeSelectable.range(that.rangeSelectable._start, cell);\n } else if(+toDateObject(that.element.find(CELLSELECTOR).first().find(\"a\")) > +range.start) {\n that.rangeSelectable.selectTo(cell);\n }\n that.rangeSelectable._end = null;\n }\n }\n },\n\n _move: function(e, preventFocus) {\n var that = this;\n var options = that.options;\n var key = e.keyCode;\n var index = that._index;\n var min = options.min;\n var max = options.max;\n var focusedCell = that.element.find(DOT+FOCUSED);\n var table = focusedCell.closest(\"table\");\n var currentValue = new DATE(+(that._current || toDateObject(focusedCell.find(\"a\"))));\n var isRtl = kendo.support.isRtl(that.wrapper);\n var navigate = false;\n var value, prevent, method, cell, lastActive, cellIndex;\n\n if (key == keys.RIGHT && !isRtl || key == keys.LEFT && isRtl) {\n value = 1;\n prevent = true;\n } else if (key == keys.LEFT && !isRtl || key == keys.RIGHT && isRtl) {\n value = -1;\n prevent = true;\n } else if (key == keys.UP) {\n value = index === 0 ? -7 : -4;\n prevent = true;\n } else if (key == keys.DOWN) {\n value = index === 0 ? 7 : 4;\n prevent = true;\n }\n else if (key == keys.SPACEBAR) {\n value = 0;\n prevent = true;\n }\n else if (key == keys.HOME) {\n prevent = true;\n cell = table.find(CELLSELECTORVALID).eq(0);\n if (cell.hasClass(FOCUSED)) {\n table = table.prev();\n if (table.length) {\n that._focusCell(table.find(CELLSELECTORVALID).eq(0));\n } else {\n navigate = that[PREVARROW] && !that[PREVARROW].hasClass(DISABLED);\n that._navigate(PREVARROW, -1, preventFocus);\n that._focusCell(that.element.find(\"table\").first().find(CELLSELECTORVALID).first());\n }\n } else {\n that._focusCell(cell);\n }\n } else if(key == keys.END) {\n prevent = true;\n cell = table.find(CELLSELECTORVALID).last();\n if (cell.hasClass(FOCUSED)) {\n table = table.next();\n if (table.length) {\n that._focusCell(table.find(CELLSELECTORVALID).last());\n } else {\n navigate = that[NEXTARROW] && !that[NEXTARROW].hasClass(DISABLED);\n that._navigate(NEXTARROW, 1, preventFocus);\n that._focusCell(that.element.find(\"table\").last().find(CELLSELECTORVALID).last());\n }\n } else {\n that._focusCell(cell);\n }\n }\n\n if (e.ctrlKey || e.metaKey) {\n if (key == keys.RIGHT && !isRtl || key == keys.LEFT && isRtl) {\n navigate = that[NEXTARROW] && !that[NEXTARROW].hasClass(DISABLED);\n that._navigate(NEXTARROW, 1, preventFocus);\n prevent = true;\n } else if (key == keys.LEFT && !isRtl || key == keys.RIGHT && isRtl) {\n navigate = that[PREVARROW] && !that[PREVARROW].hasClass(DISABLED);\n that._navigate(PREVARROW, -1, preventFocus);\n prevent = true;\n } else if (key == keys.UP) {\n navigate = !that._title.hasClass(DISABLED);\n that.navigateUp();\n that._focusCell(that._cellByDate(that._current), !preventFocus);\n prevent = true;\n } else if (key == keys.DOWN) {\n if (that._currentView.name === \"month\") {\n that.value(currentValue);\n } else {\n that.navigateDown(currentValue);\n that._focusCell(that._cellByDate(that._current), !preventFocus);\n navigate = true;\n }\n prevent = true;\n } else if ((key == keys.ENTER || key == keys.SPACEBAR)) {\n if (options.selectable === \"multiple\") {\n that._toggleSelection(e);\n }\n }\n } else if (e.shiftKey && options.selectable !== \"single\") {\n if (value !== undefined || method) {\n if (!method) {\n that._currentView.setDate(currentValue, value);\n }\n\n if (that._currentView.name !== \"month\") {\n return;\n }\n\n if (options.disableDates(currentValue)) {\n currentValue = that._nextNavigatable(currentValue, value);\n }\n\n min = createDate(min.getFullYear(), min.getMonth(), min.getDate());\n\n if (isInRange(currentValue, min, max)) {\n if (!that._dateInViews(currentValue)) {\n if (value > 0) {\n navigate = that[NEXTARROW] && !that[NEXTARROW].hasClass(DISABLED);\n that._navigate(NEXTARROW, 1, preventFocus);\n } else {\n navigate = that[PREVARROW] && !that[PREVARROW].hasClass(DISABLED);\n that._navigate(PREVARROW, -1, preventFocus);\n }\n }\n cell = that._cellByDate(currentValue);\n that._current = currentValue;\n\n if (that.selectable) {\n that._selectRange(toDateObject((that.selectable._lastActive || focusedCell).find(\"a\")), currentValue);\n if (!that.selectable._lastActive) {\n that.selectable._lastActive = focusedCell;\n }\n that.trigger(CHANGE);\n that._focusCell(cell);\n }\n\n if (that.rangeSelectable) {\n lastActive = toDateObject((that.rangeSelectable._lastActive || focusedCell).find(\"a\"));\n if (!that._dateInViews(lastActive)) {\n if (+lastActive > +currentValue) {\n that.rangeSelectable._end = that.rangeSelectable._lastActive;\n that.rangeSelectable.selectFrom(cell);\n } else {\n that.rangeSelectable.selectTo(cell);\n }\n } else {\n if (that.rangeSelectable._end && that.rangeSelectable._end.is(DOT+FOCUSED)) {\n that.rangeSelectable._lastActive = that.rangeSelectable._start;\n } else {\n that.rangeSelectable._lastActive = that._cellByDate(lastActive);\n }\n that.rangeSelectable.range(that.rangeSelectable._lastActive, cell);\n }\n that.rangeSelectable.change();\n that._focusCell(cell);\n }\n }\n }\n } else {\n if (key == keys.ENTER || key == keys.SPACEBAR) {\n if (that._currentView.name === \"month\") {\n if (that.selectable) {\n that.selectable._lastActive = that._cellByDate(currentValue);\n }\n that.value(currentValue);\n if (that.rangeSelectable) {\n that.rangeSelectable.change();\n }\n } else {\n that._click($(that._cell[0].firstChild), preventFocus);\n }\n prevent = true;\n } else if (key == keys.PAGEUP || key == keys.PAGEDOWN) {\n prevent = true;\n cellIndex = table.find(CELLSELECTORVALID).index(focusedCell);\n table = key == keys.PAGEUP ? table.prev() : table.next();\n if (!table.length) {\n if (key == keys.PAGEUP) {\n navigate = that[PREVARROW] && !that[PREVARROW].hasClass(DISABLED);\n that.navigateToPast();\n table = that.element.find(\"table\").first();\n } else {\n navigate = that[NEXTARROW] && !that[NEXTARROW].hasClass(DISABLED);\n that.navigateToFuture();\n table = that.element.find(\"table\").last();\n }\n }\n cell = table.find(CELLSELECTORVALID).eq(cellIndex);\n if (cell.length) {\n that._focusCell(cell);\n } else {\n that._focusCell(table.find(CELLSELECTORVALID).last());\n }\n }\n\n if (value || method) {\n if (!method) {\n that._currentView.setDate(currentValue, value);\n }\n\n min = createDate(min.getFullYear(), min.getMonth(), min.getDate());\n\n if (isInRange(currentValue, min, max)) {\n if (that.selectable && options.disableDates(currentValue)) {\n currentValue = that._nextNavigatable(currentValue, value);\n }\n if (!that._dateInViews(currentValue)) {\n if (value > 0) {\n navigate = that[NEXTARROW] && !that[NEXTARROW].hasClass(DISABLED);\n that._navigate(NEXTARROW, 1, preventFocus);\n } else {\n navigate = that[PREVARROW] && !that[PREVARROW].hasClass(DISABLED);\n that._navigate(NEXTARROW, -1, preventFocus);\n }\n }\n cell = that._cellByDate(currentValue);\n that._current = currentValue;\n that._focusCell(cell, !preventFocus);\n }\n }\n }\n\n if (navigate) {\n that.trigger(NAVIGATE);\n }\n\n if (prevent) {\n e.preventDefault();\n }\n\n return that._current;\n\n },\n\n _visualizeSelectedDatesInView: function() {\n var that = this;\n var selectedDates = {};\n var cells;\n\n $.each(that._selectDates, function(index, value) {\n selectedDates[kendo.calendar.views[0].toDateString(value)] = value;\n });\n that.selectable.clear();\n cells = that.element.find(\"table\")\n .find(CELLSELECTOR)\n .filter(function(index, element) {\n return selectedDates[$(element.firstChild).attr(kendo.attr(VALUE))];\n });\n\n if (cells.length > 0) {\n that.selectable._selectElement(cells, true);\n }\n },\n\n _nextNavigatable: function(currentValue, value) {\n var that = this;\n var disabled = true;\n var view = that._currentView;\n var min = that.options.min;\n var max = that.options.max;\n var isDisabled = that.options.disableDates;\n var navigatableDate = new Date(currentValue.getTime());\n\n view.setDate(navigatableDate, -value);\n while (disabled) {\n view.setDate(currentValue, value);\n if (!isInRange(currentValue, min, max)) {\n currentValue = navigatableDate;\n break;\n }\n disabled = isDisabled(currentValue);\n }\n return currentValue;\n },\n\n _toggleSelection: function (event) {\n var that = this;\n\n that.selectable._lastActive = $(that._cell[0]);\n\n if ($(that._cell[0]).hasClass(SELECTED)) {\n that.selectable._unselect($(that._cell[0]));\n that.selectable.trigger(CHANGE, { event: event});\n }\n else {\n that.selectable.value($(that._cell[0]), { event: event});\n }\n },\n\n _option: function(option, value) {\n var that = this;\n var options = that.options;\n var currentValue = that._value || that._current;\n var isBigger;\n\n if (value === undefined) {\n return options[option];\n }\n\n value = kendo.parseDate(value, options.format, options.culture);\n\n if (!value) {\n return;\n }\n\n options[option] = new DATE(+value);\n\n if (option === MIN) {\n isBigger = value > currentValue;\n } else {\n isBigger = currentValue > value;\n }\n\n if (isBigger) {\n that._value = null;\n }\n\n that.navigate(that._value);\n\n that._toggle();\n },\n\n _cellByDate: function(value) {\n if (value instanceof Date) {\n value = this._currentView.toDateString(value);\n }\n return this.element.find(\"table\").find(\"td:not(.\" + OTHERMONTH + \")\")\n .filter(function() {\n return $(this.firstChild).attr(kendo.attr(VALUE)) === value;\n });\n },\n\n _selectable: function () {\n var that = this;\n var selectable = that.options.selectable;\n\n if (that.selectable) {\n that.selectable.destroy();\n that.selectable = null;\n }\n\n if (that.rangeSelectable) {\n that.rangeSelectable.destroy();\n that.rangeSelectable = null;\n }\n\n if (selectable.toLowerCase() === \"range\") {\n that.rangeSelectable = new RangeSelectable(that.wrapper, {\n calendar: that,\n filter: \"table.k-month \" + CELLSELECTORVALID,\n change: proxy(that._rangeSelection, that)\n });\n } else {\n that.selectable = new Selectable(that.wrapper, {\n aria: true,\n dragToSelect: false,\n inputSelectors: \"input,textarea,.k-multiselect-wrap,select,button,.k-button>span,.k-button>img,span.k-icon.k-i-arrow-60-down,span.k-icon.k-i-arrow-60-up\",\n multiple: Selectable.parseOptions(selectable).multiple,\n filter: \"table.k-content \" + CELLSELECTORVALID,\n change: proxy(that._selection, that),\n relatedTarget: proxy(that._onRelatedTarget, that),\n unselect: proxy(that._unselecting, that)\n });\n }\n },\n\n _onRelatedTarget: function(target) {\n var that = this;\n\n if (that.selectable.options.multiple && target.is(CELLSELECTORVALID) && target.length > 1) {\n that._focusCell(target.first(), true);\n }\n },\n\n _getFirstViewDate: function(currentView) {\n var that = this;\n var options = that.options;\n var ranges = [];\n var start;\n var end;\n var current = new Date(+that._current);\n var i;\n\n for (i = 0; i < options.views; i++) {\n start = currentView.first(current);\n end = currentView.last(current);\n\n if (+end > +options.max) {\n if (+start <= +options.max) {\n ranges.push({start: start, end: new Date(+options.max)});\n }\n break;\n }\n\n ranges.push({start: start, end: end});\n\n current = new Date(+shiftDate(end, currentView.name, 1));\n }\n\n current = new Date(+that._current);\n\n for (i = 0; i < options.views; i++) {\n start = currentView.first(current);\n end = currentView.last(current);\n\n if (+start < +options.min) {\n if (+end >= +options.min) {\n ranges.push({start: new Date(+options.min), end: end});\n }\n break;\n }\n\n ranges.push({start: start, end: end});\n\n current = new Date(+shiftDate(start, currentView.name, -1));\n }\n\n start = ranges[0].start;\n\n for (i = 0; i < options.views + 1; i++) {\n if (!ranges[i]) {\n break;\n }\n\n if (+start > +ranges[i].start) {\n start = ranges[i].start;\n }\n }\n\n return new Date(+start);\n },\n\n _canRenderNextView: function(viewDate) {\n var fullYear = viewDate.getFullYear();\n var month = viewDate.getMonth();\n var date = viewDate.getDate();\n var max = this.options.max;\n var maxYear = max.getFullYear();\n var maxMonth = max.getMonth();\n\n\n if (fullYear < maxYear) {\n return true;\n }\n\n if (fullYear === maxYear && month < maxMonth) {\n return true;\n }\n\n if (fullYear === maxYear && month === maxMonth && date < max.getDate()) {\n return true;\n }\n\n if (fullYear === maxYear && month === maxMonth && date === max.getDate()) {\n return true;\n }\n\n return false;\n },\n\n _initViews: function(viewOptions) {\n var that = this;\n var options = that.options;\n var index = calendar.viewsEnum[viewOptions.viewName];\n var currentView = calendar.views[index];\n var viewDate;\n\n that._current = new DATE(+calendar.restrictValue(viewOptions.value, options.min, options.max));\n that._views = [];\n that._index = index;\n viewDate = that._getFirstViewDate(currentView);\n viewDate.setDate(1);\n\n that._firstViewValue = new Date(+viewDate);\n\n for (var i = 0; i < options.views; i++) {\n viewDate = i ? shiftDate(viewDate, currentView.name, 1): viewDate;\n viewDate.setDate(1);\n\n if (!that._canRenderNextView(viewDate)) {\n break;\n }\n\n that._table = $(currentView.content($.extend({\n min: options.min,\n max: options.max,\n date: viewDate,\n url: options.url,\n dates: options.dates,\n format: options.format,\n culture: options.culture,\n disableDates: options.disableDates,\n showHeader: options.showViewHeader,\n isWeekColumnVisible: options.weekNumber,\n otherMonth: options.otherMonth,\n messages: options.messages,\n contentClasses: \"k-content\"\n }, that[currentView.name])));\n\n that._table.appendTo(that.tablesWrapper).addClass(\"k-\" + currentView.name);\n that._views.push(that._table);\n }\n\n // that.wrapper.width(visibleViews * that._calendarWidth);\n\n that._currentView = currentView;\n\n that.tablesWrapper.attr(\"class\", \"k-calendar-view k-calendar-\" + currentView.name + \"view k-hstack k-align-items-start k-justify-content-center\");\n\n that._updateHeader();\n },\n\n _rangeSelection: function(e) {\n var that = this;\n var range = e.sender.range();\n var useEnd = e.sender._useEnd;\n var useStart = e.sender._useStart;\n var initialRange = that.selectRange() || {};\n var start;\n var end;\n\n if (range.start) {\n start = toDateObject(range.start.find(\"a\"));\n }\n\n if (range.end) {\n end = toDateObject(range.end.find(\"a\"));\n }\n\n that._range = { start: useStart ? initialRange.start : start, end: useEnd ? initialRange.end : end };\n\n if (!that._preventChange) {\n that.trigger(CHANGE);\n }\n },\n\n _selection: function(e) {\n var that = this;\n var selectElements = e.sender.value();\n var domEvent = e.event;\n var currentTarget = $(domEvent && domEvent.currentTarget);\n var isCell = currentTarget.is(\"td\");\n var currentValue;\n\n if (that.options.selectable === \"single\") {\n that._validateValue(selectElements[0] ? toDateObject(selectElements.first().find(\"a\")) : e.sender._lastActive ? toDateObject(e.sender._lastActive.find(\"a\")) : that.value());\n }\n\n if (that.options.selectable == \"multiple\") {\n\n if (isCell) {\n currentValue = toDateObject(currentTarget.find(\"a\"));\n }\n\n if (domEvent && domEvent.ctrlKey) {\n if (isCell) {\n if (currentTarget.hasClass(SELECTED)) {\n that._selectDates.push(currentValue);\n } else {\n that._deselect(currentValue);\n }\n } else {\n that.element.find(\"table \" + CELLSELECTORVALID).each(function(index, element){\n var value = toDateObject($(element).find(\"a\"));\n that._deselect(value);\n });\n that._addSelectedCellsToArray();\n }\n } else if (domEvent && domEvent.shiftKey) {\n that._selectRange(toDateObject(e.sender._lastActive ? e.sender._lastActive.find(\"a\") : selectElements.first().find(\"a\")), currentValue);\n } else if (isCell) {\n that._selectDates = [];\n that._selectDates.push(currentValue);\n } else {\n that._selectDates = [];\n that._addSelectedCellsToArray();\n }\n }\n\n if (!that._preventChange) {\n that.trigger(CHANGE);\n }\n },\n\n _addSelectedCellsToArray: function() {\n var that = this;\n that.selectable.value().each(function(index, item) {\n var date = toDateObject($(item.firstChild));\n if (!that.options.disableDates(date)) {\n that._selectDates.push(date);\n }\n });\n },\n\n _deselect: function(date) {\n var that = this;\n var currentDateIndex = that._selectDates.map(Number).indexOf(+date);\n if (currentDateIndex != -1) {\n that._selectDates.splice(currentDateIndex, 1);\n }\n },\n\n _unselecting: function(e) {\n var that = this;\n var element = e.element;\n\n if (that.options.selectable === \"single\" && !mobileOS && element.hasClass(FOCUSED)) {\n e.preventDefault();\n }\n },\n\n _visibleRange: function () {\n var tables = this.element.find(\".k-calendar-view table\");\n var firstDateInView = toDateObject(tables.first().find(CELLSELECTOR).first().find(\"a\"));\n var lastDateInView = toDateObject(tables.last().find(CELLSELECTOR).last().find(\"a\"));\n return { start : firstDateInView, end: lastDateInView };\n },\n\n _dateInViews: function(date) {\n var that = this;\n var tables = that.element.find(\".k-calendar-view table\");\n var firstDateInView = toDateObject(tables.first().find(CELLSELECTOR).first().find(\"a\"));\n var lastDateInView = toDateObject(tables.last().find(CELLSELECTOR).last().find(\"a\"));\n\n date = new Date(date.toDateString());\n\n return +date <= +lastDateInView && +date >= +firstDateInView;\n },\n\n _fillRange: function(start, end) {\n var that = this;\n var daysDifference;\n\n that._selectDates = [];\n daysDifference = daysBetweenTwoDates(start, end);\n addDaysToArray(that._selectDates, daysDifference, start, that.options.disableDates);\n },\n\n _selectRange: function(start, end) {\n var that = this;\n var current;\n\n if (+end < +start) {\n current = end;\n end = start;\n start = current;\n }\n\n that._fillRange(start, end);\n that._visualizeSelectedDatesInView();\n },\n\n _header: function() {\n var that = this;\n var element = that.element;\n var buttons;\n var header = element.find(\".k-calendar-header\");\n\n if (!header.length) {\n header = $('
    ' +\n '' +\n '' +\n '' +\n '' +\n '' +\n '' +\n '
    ').prependTo(element);\n }\n\n that.header = header;\n\n header.on(MOUSEENTER + ns + \" \" + MOUSELEAVE_NS + \" \" + FOCUS + ns + \" \" + BLUR + ns, \".k-button\", mousetoggle).on(\"click\", function() { return false; })\n .on(CLICK + ns, \".k-button.k-calendar-title\", function() { that.navigateUp(); that._focusCell(that._cellByDate(that._current), true); that.trigger(NAVIGATE); })\n .on(CLICK + ns, \".k-button.k-prev-view\", function(e) { e.preventDefault(); that.navigateToPast(); that.trigger(NAVIGATE); })\n .on(CLICK + ns, \".k-button.k-next-view\", function(e) { e.preventDefault(); that.navigateToFuture(); that.trigger(NAVIGATE); });\n\n buttons = header.find(\".k-button\");\n\n that._title = buttons.filter(\".k-calendar-title\");\n that._navContainer= header.find(\".k-calendar-nav\");\n that[PREVARROW] = buttons.filter(\".k-prev-view\");\n that[NEXTARROW] = buttons.filter(\".k-next-view\");\n },\n\n _wrapper: function() {\n this.tablesWrapper = $('
    ').insertAfter(this.element[0].firstChild);\n },\n\n _templates: function() {\n var that = this;\n var options = that.options;\n var month = options.month;\n var content = month.content;\n var weekNumber = month.weekNumber;\n var empty = month.empty;\n\n that.month = {\n content: template('' + (content || \"#=data.value#\") + '', { useWithBlock: !!content }),\n empty: template('' : ' class=\"k-calendar-td k-out-of-range\">') + (empty || \"\") + \"\", { useWithBlock: !!empty }),\n weekNumber: template('' + (weekNumber || \"#= data.weekNumber #\") + \"\", { useWithBlock: !!weekNumber })\n };\n },\n\n _footer: function() {\n var that = this;\n var options = that.options;\n var template = options.footer !== false ? kendo.template(that.options.footer || '#= kendo.toString(data,\"D\",\"' + options.culture +'\") #', { useWithBlock: false }) : null;\n var today = getToday();\n var element = that.element;\n var footer = element.find(\".k-footer\");\n\n if (!template) {\n that._toggle(false);\n footer.hide();\n return;\n }\n\n if (!footer[0]) {\n footer = $('
    ').appendTo(element);\n }\n\n that._today = footer.show()\n .find(\".k-link\")\n .html(template(today))\n .attr(\"title\", kendo.toString(today, \"D\", that.options.culture));\n\n that._toggle();\n },\n\n _navigate: function(arrow, modifier, preventFocus) {\n var that = this;\n var index = that._index + 1;\n var currentValue = new DATE(+that._current);\n var originaValue = new DATE(+that._current);\n var offset;\n\n arrow = that[arrow];\n\n offset = that._cellByDate(currentValue).closest(\"table\").index();\n\n if (modifier > 0) {\n offset = 1 - offset;\n } else {\n offset = offset + 1;\n }\n\n if (!arrow || !arrow.hasClass(DISABLED)) {\n if (index > 3) {\n currentValue.setFullYear(currentValue.getFullYear() + 100 * (modifier * offset));\n } else {\n calendar.views[index].setDate(currentValue, (modifier * offset));\n }\n\n that.navigate(currentValue);\n\n if (that._dateInViews(originaValue)) {\n that._focusCell(that._cellByDate(originaValue), !preventFocus);\n that._current = originaValue;\n } else {\n if (index > 3) {\n originaValue.setFullYear(originaValue.getFullYear() + 100 * modifier);\n } else {\n calendar.views[index].setDate(originaValue, modifier);\n }\n that._focusCell(that._cellByDate(originaValue), !preventFocus);\n that._current = originaValue;\n }\n }\n },\n\n _toggle: function(toggle) {\n var that = this;\n var options = that.options;\n var isTodayDisabled = options.selectable !== \"range\" && that.options.disableDates(getToday());\n var link = that._today;\n\n if (toggle === undefined) {\n toggle = isInRange(getToday(), options.min, options.max);\n }\n\n if (link) {\n link.off(CLICK + ns);\n\n if (toggle && !isTodayDisabled) {\n link.addClass(TODAY)\n .removeClass(DISABLED)\n .on(CLICK + ns, proxy(that._todayClick, that));\n } else {\n link.removeClass(TODAY)\n .addClass(DISABLED)\n .on(CLICK + ns, function prevent (e) {\n e.preventDefault();\n });\n }\n }\n },\n\n _click: function(link, preventFocus) {\n var that = this;\n var options = that.options;\n var currentValue = new Date(+that._current);\n var value = toDateObject(link);\n\n kendo.date.adjustDST(value, 0);\n\n that._currentView.setDate(currentValue, value);\n that._current = value;\n\n if (that._currentView.name !== options.depth) {\n that.navigateDown(calendar.restrictValue(currentValue, options.min, options.max));\n that._focusCell(that._cellByDate(that._current), !preventFocus);\n that.trigger(NAVIGATE);\n } else {\n that._focusCell(link.closest(\"td\"), !preventFocus);\n }\n },\n\n _blur: function() {\n var that = this;\n\n if (that._cell) {\n that._cell.removeClass(FOCUSED);\n }\n },\n\n _focus: function(e) {\n var that = this;\n var table = $(e.currentTarget);\n var cell = that._cell;\n\n if (!cell || !$.contains(table[0], cell[0])) {\n cell = table.find(CELLSELECTORVALID).first();\n }\n\n that._focusCell(cell);\n },\n\n _focusCell: function(cell, focusTable) {\n var that = this;\n var cellId = that._cellID;\n var table = cell.closest(\"table\");\n\n if (that._cell && that._cell.length) {\n that._cell[0].removeAttribute(ARIA_SELECTED);\n that._cell[0].removeAttribute(ARIA_LABEL);\n that._cell.removeClass(FOCUSED);\n that._cell[0].removeAttribute(ID);\n that._cell.closest(\"table\")[0].removeAttribute(\"aria-activedescendant\");\n }\n\n that._cell = cell;\n\n if (focusTable) {\n table.trigger(\"focus\");\n }\n\n if (cellId) {\n cell.attr(ID, cellId);\n table.attr(\"aria-activedescendant\", cellId);\n }\n\n cell.attr(ARIA_SELECTED, true).addClass(FOCUSED);\n\n if (cell.length && that._currentView.name == \"month\") {\n that._current = toDateObject(cell.find(\"a\"));\n }\n },\n\n _todayClick: function(e) {\n var that = this;\n var disabled = that.options.disableDates;\n var today = getToday();\n var navigate = false;\n\n e.preventDefault();\n\n if (disabled(today)) {\n return;\n }\n\n that._value = today;\n\n if (that.options.selectable === \"multiple\") {\n that._selectDates = [today];\n }\n\n if (that.options.selectable === \"range\") {\n that.rangeSelectable.clear(true);\n that._range = { start: today, end: null };\n }\n\n if (that._currentView.name != \"month\" || !that._dateInViews(today)) {\n navigate = true;\n }\n\n that.navigate(today, that.options.depth);\n\n if (that.options.selectable === \"single\") {\n that.selectable._lastActive = null;\n }\n\n if (navigate) {\n that.trigger(NAVIGATE);\n }\n\n that.trigger(CHANGE);\n },\n\n _validateValue: function(value) {\n var that = this;\n var options = that.options;\n var min = options.min;\n var max = options.max;\n\n value = kendo.parseDate(value, options.format, options.culture);\n\n if (value !== null) {\n value = new DATE(+value);\n\n if (!isInRange(value, min, max)) {\n value = null;\n }\n }\n\n if (value === null || !that.options.disableDates(new Date(+value))) {\n that._value = value;\n } else if (that._value === undefined) {\n that._value = null;\n }\n\n return that._value;\n },\n\n _updateAria: function (ariaTemplate, date) {\n var that = this;\n var cell = that._cellByDate(date || that.current());\n var valueType = that.view().valueType();\n var current = date || that.current();\n var text;\n\n that._focusCell(cell);\n\n if (valueType === \"month\") {\n text = kendo.toString(current, \"MMMM\");\n } else if (valueType === \"date\") {\n text = kendo.toString(current, \"D\");\n } else {\n text = cell.text();\n }\n\n cell.attr(\"aria-label\", ariaTemplate({ current: current, valueType: valueType, text: text }));\n return cell.attr(\"id\");\n },\n\n clearSelection: function () {\n var that = this;\n\n if (that.selectable) {\n that.element.find(DOT+SELECTED).removeClass(SELECTED);\n }\n\n if (that.rangeSelectable) {\n that.rangeSelectable.clear(true);\n }\n },\n\n _restoreSelection: function() {\n var that = this;\n var range;\n var selectable = that.options.selectable;\n\n if (that._currentView.name !== that.options.depth) {\n return;\n }\n\n that._preventChange = true;\n\n if (selectable === \"range\") {\n range = that.selectRange();\n\n if (!range || !range.start) {\n that._preventChange = false;\n return;\n }\n\n that.selectRange(range);\n }\n\n if (selectable === \"single\" && that.value()) {\n that.selectable.value(that._cellByDate(that.value()));\n }\n\n if (selectable === \"multiple\") {\n that._visualizeSelectedDatesInView();\n }\n\n that._preventChange = false;\n },\n\n value: function(value) {\n var that = this;\n var cell;\n\n if (value === undefined) {\n return that._value;\n }\n\n value = that._validateValue(value);\n\n that.clearSelection();\n\n if (value && !that._dateInViews(value)) {\n that.navigate(value);\n }\n\n if (value !== null && that._currentView.name === MONTH) {\n cell = that._cellByDate(value);\n\n if (that.selectable) {\n that.selectable.value(cell);\n }\n\n if (that.rangeSelectable) {\n that.rangeSelectable.start(cell);\n that.rangeSelectable._lastActive = cell;\n }\n }\n },\n\n selectDates: function(dates) {\n var that = this;\n var validSelectedDates;\n var datesUnique;\n\n if(dates === undefined) {\n return that._selectDates;\n }\n\n datesUnique = dates\n .map(function (date) { return date.getTime(); })\n .filter(function (date, position, array) {\n return array.indexOf(date) === position;\n })\n .map(function (time) { return new Date(time); });\n\n validSelectedDates = $.grep(datesUnique, function(value) {\n if(value) {\n return +that._validateValue(new Date(value.setHours(0, 0, 0, 0))) === +value;\n }\n });\n that._selectDates = validSelectedDates.length > 0 ? validSelectedDates : (datesUnique.length === 0 ? datesUnique : that._selectDates);\n that._visualizeSelectedDatesInView();\n },\n\n selectRange: function(range) {\n var that = this;\n var startInRange;\n var endInRange;\n var visibleRange;\n\n if (range === undefined) {\n return that._range;\n }\n\n that._range = range;\n\n if (!range.start) {\n return;\n }\n\n visibleRange = that._visibleRange();\n\n startInRange = that._dateInViews(range.start);\n endInRange = range.end && that._dateInViews(range.end);\n\n if (!startInRange && endInRange) {\n that.rangeSelectable.selectTo(that._cellByDate(range.end));\n }\n\n if (startInRange && endInRange) {\n that.rangeSelectable.range(that._cellByDate(range.start), that._cellByDate(range.end));\n }\n\n if (range.end && startInRange && !endInRange) {\n that.rangeSelectable.selectFrom(that._cellByDate(range.start));\n }\n\n if (!range.end && startInRange) {\n that.rangeSelectable.start(that._cellByDate(range.start));\n }\n\n if (+visibleRange.start > +range.start && +visibleRange.end < +range.end) {\n that.rangeSelectable.mid(that.element.find(CELLSELECTORVALID));\n }\n }\n });\n\n kendo.ui.plugin(MultiViewCalendar);\n\n function mousetoggle(e) {\n var disabled = $(this).hasClass(\"k-state-disabled\");\n\n if (!disabled) {\n $(this).toggleClass(HOVER, MOUSEENTER.indexOf(e.type) > -1 || e.type == FOCUS);\n }\n }\n\n function addDaysToArray(array, numberOfDays, fromDate, disableDates) {\n for(var i = 0; i <= numberOfDays; i++) {\n var nextDay = new Date(fromDate.getTime());\n nextDay = new Date(nextDay.setDate(nextDay.getDate() + i));\n if(!disableDates(nextDay)) {\n array.push(nextDay);\n }\n }\n }\n\n function daysBetweenTwoDates(startDate, endDate) {\n if(+endDate < +startDate) {\n var temp = +startDate;\n calendar.views[0].setDate(startDate, endDate);\n calendar.views[0].setDate(endDate, new Date(temp));\n }\n var fromDateUTC = Date.UTC(startDate.getFullYear(), startDate.getMonth(), startDate.getDate());\n var endDateUTC = Date.UTC(endDate.getFullYear(), endDate.getMonth(), endDate.getDate());\n\n return Math.ceil((+endDateUTC - +fromDateUTC) / kendo.date.MS_PER_DAY);\n }\n\n function shiftDate(value, dimension, numberOfViews) {\n var current;\n if (dimension === \"month\") {\n current = new DATE(value.getFullYear(), value.getMonth() + numberOfViews, value.getDate());\n current.setFullYear(value.getFullYear());\n if (Math.abs(current.getMonth() - value.getMonth()) > numberOfViews || numberOfViews > 10) {\n current.setMonth(value.getMonth() + numberOfViews);\n current = calendar.views[0].last(current);\n }\n return current;\n } else if (dimension === \"year\") {\n current = new DATE(1, value.getMonth(), value.getDate());\n current.setFullYear(value.getFullYear() + numberOfViews);\n if (Math.abs(current.getFullYear() - value.getFullYear()) > numberOfViews) {\n current = new DATE(1, value.getMonth(), 1);\n current.setFullYear(value.getFullYear() + numberOfViews);\n current = calendar.views[1].last(current);\n }\n return current;\n } else if (dimension === \"decade\") {\n current = new DATE(1, value.getMonth(), value.getDate());\n current.setFullYear(value.getFullYear() + 10*numberOfViews);\n if (Math.abs(current.getFullYear() - value.getFullYear()) > 10*numberOfViews) {\n current = new DATE(1, value.getMonth(), 1);\n current.setFullYear(value.getFullYear() + 10*numberOfViews);\n current = calendar.views[2].last(current);\n }\n return current;\n } else if (dimension === \"century\") {\n current = new DATE(1, value.getMonth(), value.getDate());\n current.setFullYear(value.getFullYear() + 100*numberOfViews);\n if (Math.abs(current.getFullYear() - value.getFullYear()) > 100*numberOfViews) {\n current = new DATE(1, value.getMonth(), 1);\n current.setFullYear(value.getFullYear() + 100*numberOfViews);\n current = calendar.views[3].last(current);\n }\n return current;\n }\n }\n\n})(window.kendo.jQuery);\n\nreturn window.kendo;\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n\n(function(f, define){\n define('kendo.virtuallist',[ \"./kendo.data\" ], f);\n})(function(){\n\nvar __meta__ = { // jshint ignore:line\n id: \"virtuallist\",\n name: \"VirtualList\",\n category: \"framework\",\n depends: [ \"data\" ],\n hidden: true\n};\n\n(function($, undefined) {\n var kendo = window.kendo,\n ui = kendo.ui,\n Widget = ui.Widget,\n DataBoundWidget = ui.DataBoundWidget,\n proxy = $.proxy,\n percentageUnitsRegex = /^\\d+(\\.\\d+)?%$/i,\n LIST_CONTENT = \"k-list-content k-virtual-content\",\n TABLE_CONTENT = \"k-table-body k-table-scroller\",\n HEADER = \"k-list-group-sticky-header\",\n LIST_ITEM = \"k-list-item\",\n TABLE_ITEM = \"k-table-row\",\n HEIGHTCONTAINER = \"k-height-container\",\n GROUPITEM = \"k-list-item-group-label\",\n LIST_UL = \"k-list-ul\",\n TABLE_LIST = \"k-table-list\",\n\n SELECTED = \"k-selected\",\n FOCUSED = \"k-focus\",\n HOVER = \"k-hover\",\n CHANGE = \"change\",\n CLICK = \"click\",\n LISTBOUND = \"listBound\",\n ITEMCHANGE = \"itemChange\",\n\n ACTIVATE = \"activate\",\n DEACTIVATE = \"deactivate\",\n\n GROUP_ROW_SEL = \".k-table-group-row\",\n\n VIRTUAL_LIST_NS = \".VirtualList\";\n\n function lastFrom(array) {\n return array[array.length - 1];\n }\n\n function toArray(value) {\n return value instanceof Array ? value : [value];\n }\n\n function isPrimitive(dataItem) {\n return typeof dataItem === \"string\" || typeof dataItem === \"number\" || typeof dataItem === \"boolean\";\n }\n\n function getItemCount(screenHeight, listScreens, itemHeight) {\n return Math.ceil(screenHeight * listScreens / itemHeight);\n }\n\n function appendChild(parent, className, tagName) {\n var element = document.createElement(tagName || \"div\");\n if (className) {\n element.className = className;\n }\n parent.appendChild(element);\n\n return element;\n }\n\n function getDefaultItemHeight(listSize) {\n var mockList = $('
    ' +\n '
    ' +\n '
      ' +\n '
    • ' +\n 'test' +\n '
    • ' +\n '
    ' +\n '
    ' +\n '
    ');\n var lineHeight;\n\n mockList.css({\n position: \"absolute\",\n left: \"-200000px\",\n visibility: \"hidden\"\n });\n mockList.appendTo(document.body);\n lineHeight = parseFloat(kendo.getComputedStyles(mockList.find(\".k-list-item\")[0], [\"height\"]).height);\n mockList.remove();\n\n return lineHeight;\n }\n\n function bufferSizes(screenHeight, listScreens, opposite) { //in pixels\n return {\n down: screenHeight * opposite,\n up: screenHeight * (listScreens - 1 - opposite)\n };\n }\n\n function listValidator(options, screenHeight) {\n var downThreshold = (options.listScreens - 1 - options.threshold) * screenHeight;\n var upThreshold = options.threshold * screenHeight;\n\n return function(list, scrollTop, lastScrollTop) {\n if (scrollTop > lastScrollTop) {\n return scrollTop - list.top < downThreshold;\n } else {\n return list.top === 0 || scrollTop - list.top > upThreshold;\n }\n };\n }\n\n function scrollCallback(element, callback) {\n return function(force) {\n return callback(element.scrollTop, force);\n };\n }\n\n function syncList(reorder) {\n return function(list, force) {\n reorder(list.items, list.index, force);\n return list;\n };\n }\n\n function position(element, y) {\n element.style.webkitTransform = 'translateY(' + y + \"px)\";\n element.style.transform = 'translateY(' + y + \"px)\";\n }\n\n function map2(callback, templates) {\n return function(arr1, arr2) {\n for (var i = 0, len = arr1.length; i < len; i++) {\n callback(arr1[i], arr2[i], templates);\n if (arr2[i].item) {\n this.trigger(ITEMCHANGE, { item: $(arr1[i]), data: arr2[i].item, ns: kendo.ui });\n }\n }\n };\n }\n\n function reshift(items, diff) {\n var range;\n\n if (diff > 0) { // down\n range = items.splice(0, diff);\n items.push.apply(items, range);\n } else { // up\n range = items.splice(diff, -diff);\n items.unshift.apply(items, range);\n }\n\n return range;\n }\n\n function render(element, data, templates) {\n var itemTemplate = templates.template,\n hasColumns = this.options.columns && this.options.columns.length,\n altRow = data.index % 2 === 1 ? \"k-table-alt-row\" : \"\";\n\n element = $(element);\n\n if (!data.item) {\n itemTemplate = templates.placeholderTemplate;\n }\n\n if (data.index === 0 && this.header && data.group) {\n this.header.html(templates.fixedGroupTemplate(data.group));\n }\n\n this.angular(\"cleanup\", function() {\n return { elements: [ element ]};\n });\n\n element\n .attr(\"data-uid\", data.item ? data.item.uid : \"\")\n .attr(\"data-offset-index\", data.index);\n\n if (hasColumns && data.item) {\n if (altRow.length > 0) {\n element.addClass(altRow);\n } else {\n element.removeClass(\"k-table-alt-row\");\n }\n element.html(renderColumns(this.options, data.item, templates));\n } else {\n element.find(\".\" + GROUPITEM).remove();\n element.find(\".k-list-item-text\").html(itemTemplate(data.item || {}));\n }\n\n element.toggleClass(FOCUSED, data.current);\n element.toggleClass(SELECTED, data.selected);\n element.toggleClass(\"k-first\", data.newGroup);\n element.toggleClass(\"k-last\", data.isLastGroupedItem);\n element.toggleClass(\"k-loading-item\", !data.item);\n\n if (data.index !== 0 && data.newGroup) {\n if (hasColumns) {\n $('' + templates.groupTemplate(data.group) + '')\n .appendTo(element);\n } else {\n $(\"
    \")\n .appendTo(element)\n .html(templates.groupTemplate(data.group));\n }\n } else if (data.group && hasColumns) {\n element.append($(''));\n }\n\n if (data.top !== undefined) {\n position(element[0], data.top);\n }\n\n this.angular(\"compile\", function() {\n return { elements: [ element ], data: [ { dataItem: data.item, group: data.group, newGroup: data.newGroup } ]};\n });\n }\n\n function renderColumns(options, dataItem, templates) {\n var item = \"\";\n\n for (var i = 0; i < options.columns.length; i++) {\n var currentWidth = options.columns[i].width;\n var currentWidthInt = parseInt(currentWidth, 10);\n var widthStyle = '';\n\n if(currentWidth){\n widthStyle += \"style='width:\";\n widthStyle += currentWidthInt;\n widthStyle += percentageUnitsRegex.test(currentWidth) ? \"%\" : \"px\";\n widthStyle += \";'\";\n }\n item += \"\";\n item += templates[\"column\"+ i](dataItem);\n item += \"\";\n }\n\n return item;\n }\n\n function mapChangedItems(selected, itemsToMatch) {\n var itemsLength = itemsToMatch.length;\n var selectedLength = selected.length;\n var dataItem;\n var found;\n var i, j;\n\n var changed = [];\n var unchanged = [];\n\n if (selectedLength) {\n for (i = 0; i < selectedLength; i++) {\n dataItem = selected[i];\n found = false;\n\n for (j = 0; j < itemsLength; j++) {\n if (dataItem === itemsToMatch[j]) {\n found = true;\n changed.push({ index: i, item: dataItem });\n break;\n }\n }\n\n if (!found) {\n unchanged.push(dataItem);\n }\n }\n }\n\n return {\n changed: changed,\n unchanged: unchanged\n };\n }\n\n function isActivePromise(promise) {\n return promise && promise.state() !== \"resolved\";\n }\n\n var VirtualList = DataBoundWidget.extend({\n init: function(element, options) {\n var that = this,\n contentClasses = options.columns && options.columns.length ? TABLE_CONTENT : LIST_CONTENT;\n\n that.bound(false);\n that._fetching = false;\n\n Widget.fn.init.call(that, element, options);\n\n if (!that.options.itemHeight) {\n that.options.itemHeight = getDefaultItemHeight(options.listSize);\n }\n\n options = that.options;\n\n that.element.attr(\"role\", \"listbox\");\n\n that.content = that.wrapper = that.element.wrap(\"
    \").parent();\n\n if(that.options.columns && that.options.columns.length) {\n var thead = that.element.closest(\".k-data-table\").find('.k-table-thead');\n var row = $('' +\n '' +\n '');\n\n thead.append(row);\n\n that.header = row.find(\".k-table-th\");\n that.element.addClass(TABLE_LIST + \" k-virtual-table\");\n } else {\n that.header = that.content.before(\"
    \").prev();\n that.element.addClass(LIST_UL);\n }\n\n if(options.ariaLabel) {\n this.element.attr(\"aria-label\", options.ariaLabel);\n } else if(options.ariaLabelledBy) {\n this.element.attr(\"aria-labelledby\", options.ariaLabelledBy);\n }\n\n that.element.on(\"mouseenter\" + VIRTUAL_LIST_NS, \"li:not(.k-loading-item)\", function() { $(this).addClass(HOVER); })\n .on(\"mouseleave\" + VIRTUAL_LIST_NS, \"li\", function() { $(this).removeClass(HOVER); });\n\n that._values = toArray(that.options.value);\n that._selectedDataItems = [];\n that._selectedIndexes = [];\n that._rangesList = {};\n that._promisesList = [];\n that._optionID = kendo.guid();\n\n that._templates();\n\n that.setDataSource(options.dataSource);\n\n that.content.on(\"scroll\" + VIRTUAL_LIST_NS, kendo.throttle(function() {\n that._renderItems();\n that._triggerListBound();\n }, options.delay));\n\n that._selectable();\n },\n\n options: {\n name: \"VirtualList\",\n autoBind: true,\n delay: 100,\n height: null,\n listScreens: 4,\n threshold: 0.5,\n itemHeight: null,\n oppositeBuffer: 1,\n type: \"flat\",\n selectable: false,\n value: [],\n dataValueField: null,\n template: \"#:data#\",\n placeholderTemplate: \"loading...\",\n groupTemplate: \"#:data#\",\n fixedGroupTemplate: \"#:data#\",\n mapValueTo: \"index\",\n valueMapper: null,\n ariaLabel: null,\n ariaLabelledBy: null\n },\n\n events: [\n CHANGE,\n CLICK,\n LISTBOUND,\n ITEMCHANGE,\n ACTIVATE,\n DEACTIVATE\n ],\n\n setOptions: function(options) {\n var itemClass = this.options.columns && this.options.columns.length ? TABLE_ITEM : LIST_ITEM;\n\n Widget.fn.setOptions.call(this, options);\n\n if (this._selectProxy && this.options.selectable === false) {\n this.element.off(CLICK, \".\" + itemClass, this._selectProxy);\n } else if (!this._selectProxy && this.options.selectable) {\n this._selectable();\n }\n\n this._templates();\n this.refresh();\n },\n\n items: function() {\n return $(this._items);\n },\n\n destroy: function() {\n this.wrapper.off(VIRTUAL_LIST_NS);\n this.dataSource.unbind(CHANGE, this._refreshHandler);\n Widget.fn.destroy.call(this);\n },\n\n setDataSource: function(source) {\n var that = this;\n var dataSource = source || {};\n var value;\n\n dataSource = Array.isArray(dataSource) ? {data: dataSource} : dataSource;\n dataSource = kendo.data.DataSource.create(dataSource);\n\n if (that.dataSource) {\n that.dataSource.unbind(CHANGE, that._refreshHandler);\n\n that._clean();\n that.bound(false);\n\n that._deferValueSet = true;\n value = that.value();\n\n that.value([]);\n that.mute(function() {\n that.value(value);\n });\n } else {\n that._refreshHandler = $.proxy(that.refresh, that);\n }\n\n that.dataSource = dataSource.bind(CHANGE, that._refreshHandler);\n\n that.setDSFilter(dataSource.filter());\n\n if (dataSource.view().length !== 0) {\n that.refresh();\n } else if (that.options.autoBind) {\n dataSource.fetch();\n }\n },\n\n skip: function() {\n return this.dataSource.currentRangeStart();\n },\n\n _triggerListBound: function () {\n var that = this;\n var skip = that.skip();\n\n if (that.bound() && !that._selectingValue && that._skip !== skip) {\n that._skip = skip;\n that.trigger(LISTBOUND);\n }\n },\n\n _getValues: function(dataItems) {\n var getter = this._valueGetter;\n\n return $.map(dataItems, function(dataItem) {\n return getter(dataItem);\n });\n },\n\n _highlightSelectedItems: function () {\n for (var i = 0; i < this._selectedDataItems.length; i++) {\n var item = this._getElementByDataItem(this._selectedDataItems[i]);\n if(item.length){\n item.addClass(SELECTED);\n }\n }\n },\n\n refresh: function(e) {\n var that = this;\n var action = e && e.action;\n var isItemChange = action === \"itemchange\";\n var filtered = this.isFiltered();\n var result;\n\n if (that._mute) { return; }\n\n that._deferValueSet = false;\n\n if (!that._fetching) {\n if (filtered) {\n that.focus(0);\n }\n\n that._createList();\n if (!action && that._values.length && !filtered &&\n !that.options.skipUpdateOnBind && !that._emptySearch) {\n that._selectingValue = true;\n\n that.bound(true);\n that.value(that._values, true).done(function () {\n that._selectingValue = false;\n that._triggerListBound();\n });\n } else {\n that.bound(true);\n that._highlightSelectedItems();\n that._triggerListBound();\n }\n } else {\n if (that._renderItems) {\n that._renderItems(true);\n }\n\n that._triggerListBound();\n }\n\n if (isItemChange || action === \"remove\") {\n result = mapChangedItems(that._selectedDataItems, e.items);\n if (result.changed.length) {\n if (isItemChange) {\n that.trigger(\"selectedItemChange\", {\n items: result.changed\n });\n } else {\n that.value(that._getValues(result.unchanged));\n }\n }\n }\n\n that._fetching = false;\n },\n\n removeAt: function(position) {\n var value = this._values.splice(position, 1)[0];\n\n return {\n position: position,\n dataItem: this._removeSelectedDataItem(value)\n };\n },\n\n _removeSelectedDataItem: function (value) {\n var that = this,\n valueGetter = that._valueGetter;\n\n for (var idx in that._selectedDataItems) {\n if(valueGetter(that._selectedDataItems[idx]) === value) {\n that._selectedIndexes.splice(idx, 1);\n return that._selectedDataItems.splice(idx, 1)[0];\n }\n }\n },\n\n setValue: function(value) {\n this._values = toArray(value);\n },\n\n value: function(value, _forcePrefetch) {\n var that = this;\n\n if (value === undefined) {\n return that._values.slice();\n }\n\n if (value === null) {\n value = [];\n }\n\n value = toArray(value);\n\n if (!that._valueDeferred || that._valueDeferred.state() === \"resolved\") {\n that._valueDeferred = $.Deferred();\n }\n\n var shouldClear = that.options.selectable === \"multiple\" && that.select().length && value.length;\n\n if (shouldClear || !value.length) {\n that.select(-1);\n }\n\n that._values = value;\n\n if ((that.bound() && !that._mute && !that._deferValueSet) || _forcePrefetch) {\n that._prefetchByValue(value);\n }\n\n return that._valueDeferred;\n },\n\n _checkValuesOrder: function (value) {\n if (this._removedAddedIndexes &&\n this._removedAddedIndexes.length === value.length) {\n var newValue = this._removedAddedIndexes.slice();\n this._removedAddedIndexes = null;\n return newValue;\n }\n\n return value;\n },\n\n _prefetchByValue: function(value) {\n var that = this,\n dataView = that._dataView,\n valueGetter = that._valueGetter,\n mapValueTo = that.options.mapValueTo,\n item, match = false,\n forSelection = [];\n\n //try to find the items in the loaded data\n for (var i = 0; i < value.length; i++) {\n for (var idx = 0; idx < dataView.length; idx++) {\n item = dataView[idx].item;\n if (item) {\n match = isPrimitive(item) ? value[i] === item : value[i] === valueGetter(item);\n\n if (match) {\n forSelection.push(dataView[idx].index);\n }\n }\n }\n }\n\n if (forSelection.length === value.length) {\n that._values = [];\n that.select(forSelection);\n return;\n }\n\n //prefetch the items\n if (typeof that.options.valueMapper === \"function\") {\n that.options.valueMapper({\n value: (this.options.selectable === \"multiple\") ? value : value[0],\n success: function(response) {\n if (mapValueTo === \"index\") {\n that.mapValueToIndex(response);\n } else if (mapValueTo === \"dataItem\") {\n that.mapValueToDataItem(response);\n }\n }\n });\n } else {\n if (!that.value()[0]) {\n that.select([-1]);\n } else {\n that._selectingValue = false;\n that._triggerListBound();\n }\n }\n },\n\n mapValueToIndex: function(indexes) {\n if (indexes === undefined || indexes === -1 || indexes === null) {\n indexes = [];\n } else {\n indexes = toArray(indexes);\n }\n\n if (!indexes.length) {\n indexes = [-1];\n } else {\n var removed = this._deselect([]).removed;\n if (removed.length) {\n this._triggerChange(removed, []);\n }\n }\n\n this.select(indexes);\n },\n\n mapValueToDataItem: function(dataItems) {\n var removed, added;\n\n if (dataItems === undefined || dataItems === null) {\n dataItems = [];\n } else {\n dataItems = toArray(dataItems);\n }\n\n if (!dataItems.length) {\n this.select([-1]);\n } else {\n removed = $.map(this._selectedDataItems, function(item, index) {\n return { index: index, dataItem: item };\n });\n\n added = $.map(dataItems, function(item, index) {\n return { index: index, dataItem: item };\n });\n\n this._selectedDataItems = dataItems;\n\n this._selectedIndexes = [];\n\n for (var i = 0; i < this._selectedDataItems.length; i++) {\n var item = this._getElementByDataItem(this._selectedDataItems[i]);\n this._selectedIndexes.push(this._getIndecies(item)[0]);\n item.addClass(SELECTED);\n }\n\n this._triggerChange(removed, added);\n\n if (this._valueDeferred) {\n this._valueDeferred.resolve();\n }\n }\n },\n\n deferredRange: function(index) {\n var dataSource = this.dataSource;\n var take = this.itemCount;\n var ranges = this._rangesList;\n var result = $.Deferred();\n var defs = [];\n\n var low = Math.floor(index / take) * take;\n var high = Math.ceil(index / take) * take;\n\n var pages = high === low ? [ high ] : [ low, high ];\n\n $.each(pages, function(_, skip) {\n var end = skip + take;\n var existingRange = ranges[skip];\n var deferred;\n\n if (!existingRange || (existingRange.end !== end)) {\n deferred = $.Deferred();\n ranges[skip] = { end: end, deferred: deferred };\n\n dataSource._multiplePrefetch(skip, take, function() {\n deferred.resolve();\n });\n } else {\n deferred = existingRange.deferred;\n }\n\n defs.push(deferred);\n });\n\n $.when.apply($, defs).then(function() {\n result.resolve();\n });\n\n return result;\n },\n\n prefetch: function(indexes) {\n var that = this,\n take = this.itemCount,\n isEmptyList = !that._promisesList.length;\n\n if (!isActivePromise(that._activeDeferred)) {\n that._activeDeferred = $.Deferred();\n that._promisesList = [];\n }\n\n $.each(indexes, function(_, index) {\n that._promisesList.push(that.deferredRange(that._getSkip(index, take)));\n });\n\n if (isEmptyList) {\n $.when.apply($, that._promisesList).done(function() {\n that._promisesList = [];\n that._activeDeferred.resolve();\n });\n }\n\n return that._activeDeferred;\n },\n\n _findDataItem: function(view, index) {\n var group;\n\n //find in grouped view\n if (this.options.type === \"group\") {\n for (var i = 0; i < view.length; i++) {\n group = view[i].items;\n if (group.length <= index) {\n index = index - group.length;\n } else {\n return group[index];\n }\n }\n }\n\n //find in flat view\n return view[index];\n },\n\n _getRange: function(skip, take) {\n return this.dataSource._findRange(skip, Math.min(skip + take, this.dataSource.total()));\n },\n\n dataItemByIndex: function(index) {\n var that = this;\n var take = that.itemCount;\n var skip = that._getSkip(index, take);\n var view = this._getRange(skip, take);\n\n //should not return item if data is not loaded\n if (!that._getRange(skip, take).length) {\n return null;\n }\n\n if (that.options.type === \"group\") {\n kendo.ui.progress($(that.wrapper), true);\n that.mute(function() {\n that.dataSource.range(skip, take, function () {\n kendo.ui.progress($(that.wrapper), false);\n });\n view = that.dataSource.view();\n });\n }\n\n return that._findDataItem(view, [index - skip]);\n },\n\n selectedDataItems: function() {\n return this._selectedDataItems.slice();\n },\n\n scrollWith: function(value) {\n this.content.scrollTop(this.content.scrollTop() + value);\n },\n\n scrollTo: function(y) {\n this.content.scrollTop(y); //works only if the element is visible\n },\n\n scrollToIndex: function(index) {\n this.scrollTo(index * this.options.itemHeight);\n },\n\n focus: function(candidate) {\n var element,\n index,\n data,\n current,\n itemHeight = this.options.itemHeight,\n id = this._optionID,\n triggerEvent = true;\n\n if (candidate === undefined) {\n current = this.element.find(\".\" + FOCUSED);\n return current.length ? current : null;\n }\n\n if (typeof candidate === \"function\") {\n data = this.dataSource.flatView();\n for (var idx = 0; idx < data.length; idx++) {\n if (candidate(data[idx])) {\n candidate = idx;\n break;\n }\n }\n }\n\n if (candidate instanceof Array) {\n candidate = lastFrom(candidate);\n }\n\n if (isNaN(candidate)) {\n element = $(candidate);\n index = parseInt($(element).attr(\"data-offset-index\"), 10);\n } else {\n index = candidate;\n element = this._getElementByIndex(index);\n }\n\n if (index === -1) {\n this.element.find(\".\" + FOCUSED).removeClass(FOCUSED);\n this._focusedIndex = undefined;\n return;\n }\n\n if (element.length) { /*focus rendered item*/\n if (element.hasClass(FOCUSED)) {\n triggerEvent = false;\n }\n if (this._focusedIndex !== undefined) {\n current = this._getElementByIndex(this._focusedIndex);\n current\n .removeClass(FOCUSED)\n .removeAttr(\"id\");\n\n if (triggerEvent) {\n this.trigger(DEACTIVATE);\n }\n }\n\n this._focusedIndex = index;\n\n element\n .addClass(FOCUSED)\n .attr(\"id\", id);\n\n var position = this._getElementLocation(index);\n\n if (position === \"top\") {\n this.scrollTo(index * itemHeight);\n } else if (position === \"bottom\") {\n this.scrollTo((index * itemHeight + itemHeight) - this._screenHeight);\n } else if (position === \"outScreen\") {\n this.scrollTo(index * itemHeight);\n }\n\n if (triggerEvent) {\n this.trigger(ACTIVATE);\n }\n } else { /*focus non rendered item*/\n this._focusedIndex = index;\n this.items().removeClass(FOCUSED);\n this.scrollToIndex(index);\n }\n },\n\n focusIndex: function() {\n return this._focusedIndex;\n },\n\n focusFirst: function() {\n this.scrollTo(0);\n this.focus(0);\n },\n\n focusLast: function() {\n var lastIndex = this.dataSource.total();\n this.scrollTo(this.heightContainer.offsetHeight);\n this.focus(lastIndex - 1);\n },\n\n focusPrev: function() {\n var index = this._focusedIndex;\n var current;\n\n if (!isNaN(index) && index > 0) {\n index -= 1;\n this.focus(index);\n\n current = this.focus();\n if (current && current.hasClass(\"k-loading-item\")) {\n index += 1;\n this.focus(index);\n }\n\n return index;\n } else {\n index = this.dataSource.total() - 1;\n this.focus(index);\n return index;\n }\n },\n\n focusNext: function() {\n var index = this._focusedIndex;\n var lastIndex = this.dataSource.total() - 1;\n var current;\n\n if (!isNaN(index) && index < lastIndex) {\n index += 1;\n this.focus(index);\n\n current = this.focus();\n if (current && current.hasClass(\"k-loading-item\")) {\n index -= 1;\n this.focus(index);\n }\n\n return index;\n } else {\n index = 0;\n this.focus(index);\n return index;\n }\n },\n\n _triggerChange: function(removed, added) {\n removed = removed || [];\n added = added || [];\n\n if (removed.length || added.length) {\n this.trigger(CHANGE, {\n removed: removed,\n added: added\n });\n }\n },\n\n select: function(candidate) {\n var that = this,\n indices,\n initialIndices,\n singleSelection = that.options.selectable !== \"multiple\",\n prefetchStarted = isActivePromise(that._activeDeferred),\n filtered = this.isFiltered(),\n isAlreadySelected,\n deferred,\n result,\n removed = [];\n\n if (candidate === undefined) {\n return that._selectedIndexes.slice();\n }\n\n if (!that._selectDeferred || that._selectDeferred.state() === \"resolved\") {\n that._selectDeferred = $.Deferred();\n }\n\n indices = that._getIndecies(candidate);\n isAlreadySelected = singleSelection && !filtered && lastFrom(indices) === lastFrom(this._selectedIndexes);\n removed = that._deselectCurrentValues(indices);\n\n if (removed.length || !indices.length || isAlreadySelected) {\n that._triggerChange(removed);\n\n if (that._valueDeferred) {\n that._valueDeferred.resolve().promise();\n }\n\n return that._selectDeferred.resolve().promise();\n }\n\n if (indices.length === 1 && indices[0] === -1) {\n indices = [];\n }\n\n initialIndices = indices;\n result = that._deselect(indices);\n removed = result.removed;\n indices = result.indices;\n\n if (singleSelection) {\n prefetchStarted = false;\n if (indices.length) {\n indices = [lastFrom(indices)];\n }\n }\n\n var done = function() {\n var added = that._select(indices);\n\n if (initialIndices.length === indices.length || singleSelection) {\n that.focus(indices);\n }\n\n that._triggerChange(removed, added);\n\n if (that._valueDeferred) {\n that._valueDeferred.resolve();\n }\n\n that._selectDeferred.resolve();\n };\n\n deferred = that.prefetch(indices);\n\n if (!prefetchStarted) {\n if (deferred) {\n deferred.done(done);\n } else {\n done();\n }\n }\n\n return that._selectDeferred.promise();\n },\n\n bound: function(bound) {\n if (bound === undefined) {\n return this._listCreated;\n }\n\n this._listCreated = bound;\n },\n\n mute: function(callback) {\n this._mute = true;\n proxy(callback(), this);\n this._mute = false;\n },\n\n setDSFilter: function(filter) {\n this._lastDSFilter = $.extend({}, filter);\n },\n\n isFiltered: function() {\n if (!this._lastDSFilter) {\n this.setDSFilter(this.dataSource.filter());\n }\n\n return !kendo.data.Query.compareFilters(this.dataSource.filter(), this._lastDSFilter);\n },\n\n skipUpdate: $.noop,\n\n _getElementByIndex: function(index) {\n return this.items().filter(function(idx, element) {\n return index === parseInt($(element).attr(\"data-offset-index\"), 10);\n });\n },\n\n _getElementByDataItem: function(dataItem) {\n var dataView = this._dataView,\n valueGetter = this._valueGetter,\n element, match;\n\n for (var i = 0; i < dataView.length; i++) {\n match = dataView[i].item && isPrimitive(dataView[i].item) ? dataView[i].item === dataItem : dataView[i].item && dataItem && valueGetter(dataView[i].item) == valueGetter(dataItem);\n if (match) {\n element = dataView[i];\n break;\n }\n }\n\n return element ? this._getElementByIndex(element.index) : $();\n },\n\n _clean: function() {\n this.result = undefined;\n this._lastScrollTop = undefined;\n this._skip = undefined;\n $(this.heightContainer).remove();\n this.heightContainer = undefined;\n this.element.empty();\n },\n\n _height: function() {\n var hasData = !!this.dataSource.view().length,\n height = this.options.height,\n itemHeight = this.options.itemHeight,\n total = this.dataSource.total();\n\n if (!hasData) {\n height = 0;\n } else if (height/itemHeight > total) {\n height = total * itemHeight;\n }\n\n return height;\n },\n\n setScreenHeight: function() {\n var height = this._height();\n\n this.content.height(height);\n this._screenHeight = height;\n },\n\n screenHeight: function() {\n return this._screenHeight;\n },\n\n _getElementLocation: function(index) {\n var scrollTop = this.content.scrollTop(),\n screenHeight = this._screenHeight,\n itemHeight = this.options.itemHeight,\n yPosition = index * itemHeight,\n yDownPostion = yPosition + itemHeight,\n screenEnd = scrollTop + screenHeight,\n position;\n\n if (yPosition === (scrollTop - itemHeight) || (yDownPostion > scrollTop && yPosition < scrollTop)) {\n position = \"top\";\n } else if (yPosition === screenEnd || (yPosition < screenEnd && screenEnd < yDownPostion)) {\n position = \"bottom\";\n } else if ((yPosition >= scrollTop) && (yPosition <= scrollTop + (screenHeight - itemHeight))) {\n position = \"inScreen\";\n } else {\n position = \"outScreen\";\n }\n\n return position;\n },\n\n _templates: function() {\n var options = this.options;\n var templates = {\n template: options.template,\n placeholderTemplate: options.placeholderTemplate,\n groupTemplate: options.groupTemplate,\n fixedGroupTemplate: options.fixedGroupTemplate\n };\n\n if (options.columns) {\n for (var i = 0; i < options.columns.length; i++) {\n var currentColumn = options.columns[i];\n var templateText = currentColumn.field ? currentColumn.field.toString(): \"text\";\n\n templates[\"column\"+ i] = currentColumn.template || \"#: \" + templateText + \"#\";\n }\n }\n\n for (var key in templates) {\n if (typeof templates[key] !== \"function\") {\n templates[key] = kendo.template(templates[key] || \"\");\n }\n }\n\n this.templates = templates;\n },\n\n _generateItems: function(element, count) {\n var items = [],\n item, text,\n itemHeight = this.options.itemHeight + \"px\",\n itemClass = this.options.columns && this.options.columns.length ? TABLE_ITEM : LIST_ITEM;\n\n while(count-- > 0) {\n text = document.createElement(\"span\");\n text.className = \"k-list-item-text\";\n\n item = document.createElement(\"li\");\n item.tabIndex = -1;\n item.className = itemClass;\n item.setAttribute(\"role\", \"option\");\n item.style.height = itemHeight;\n item.style.minHeight = itemHeight;\n item.appendChild(text);\n\n element.appendChild(item);\n\n items.push(item);\n }\n\n return items;\n },\n\n _saveInitialRanges: function() {\n var ranges = this.dataSource._ranges;\n var deferred = $.Deferred();\n deferred.resolve();\n\n this._rangesList = {};\n for (var i = 0; i < ranges.length; i++) {\n this._rangesList[ranges[i].start] = { end: ranges[i].end, deferred: deferred };\n }\n },\n\n _createList: function() {\n var that = this,\n content = that.content.get(0),\n options = that.options,\n dataSource = that.dataSource;\n\n if (that.bound()) {\n that._clean();\n }\n\n that._saveInitialRanges();\n that._buildValueGetter();\n that.setScreenHeight();\n that.itemCount = getItemCount(that._screenHeight, options.listScreens, options.itemHeight);\n\n if (that.itemCount > dataSource.total()) {\n that.itemCount = dataSource.total();\n }\n\n that._items = that._generateItems(that.element[0], that.itemCount);\n\n that._setHeight(options.itemHeight * dataSource.total());\n that.options.type = (dataSource.group() || []).length ? \"group\" : \"flat\";\n\n if (that.options.type === \"flat\") {\n if (that.header.closest(GROUP_ROW_SEL).length) {\n that.header.closest(GROUP_ROW_SEL).hide();\n } else {\n that.header.hide();\n }\n } else {\n if (that.header.closest(GROUP_ROW_SEL).length) {\n that.header.closest(GROUP_ROW_SEL).show();\n } else {\n that.header.show();\n }\n }\n\n that.getter = that._getter(function() {\n that._renderItems(true);\n });\n\n that._onScroll = function(scrollTop, force) {\n var getList = that._listItems(that.getter);\n return that._fixedHeader(scrollTop, getList(scrollTop, force));\n };\n\n that._renderItems = that._whenChanged(\n scrollCallback(content, that._onScroll),\n syncList(that._reorderList(that._items, $.proxy(render, that)))\n );\n\n that._renderItems();\n that._calculateGroupPadding(that._screenHeight);\n that._calculateColumnsHeaderPadding();\n },\n\n _setHeight: function(height) {\n var currentHeight,\n heightContainer = this.heightContainer;\n\n if (!heightContainer) {\n heightContainer = this.heightContainer = appendChild(this.content[0], HEIGHTCONTAINER);\n } else {\n currentHeight = heightContainer.offsetHeight;\n }\n\n if (height !== currentHeight) {\n heightContainer.innerHTML = \"\";\n\n while (height > 0) {\n var padHeight = Math.min(height, 250000); //IE workaround, should not create elements with height larger than 250000px\n appendChild(heightContainer).style.height = padHeight + \"px\";\n height -= padHeight;\n }\n }\n },\n\n _getter: function() {\n var lastRequestedRange = null,\n dataSource = this.dataSource,\n lastRangeStart = dataSource.skip(),\n type = this.options.type,\n pageSize = this.itemCount,\n flatGroups = {};\n\n if (dataSource.pageSize() < pageSize) {\n this.mute(function() {\n dataSource.pageSize(pageSize);\n });\n }\n\n return function(index, rangeStart) {\n var that = this;\n if (!dataSource.inRange(rangeStart, pageSize)) {\n if (lastRequestedRange !== rangeStart) {\n lastRequestedRange = rangeStart;\n lastRangeStart = rangeStart;\n\n if (that._getterDeferred) {\n that._getterDeferred.reject();\n }\n\n that._getterDeferred = that.deferredRange(rangeStart);\n that._getterDeferred.then(function() {\n var firstItemIndex = that._indexConstraint(that.content[0].scrollTop);\n\n that._getterDeferred = null;\n\n if (rangeStart <= firstItemIndex && firstItemIndex <= (rangeStart + pageSize)) {\n that._fetching = true;\n dataSource.range(rangeStart, pageSize);\n }\n });\n }\n\n return null;\n } else {\n if (lastRangeStart !== rangeStart) {\n this.mute(function() {\n dataSource.range(rangeStart, pageSize);\n lastRangeStart = rangeStart;\n });\n }\n\n var result;\n if (type === \"group\") { //grouped list\n if (!flatGroups[rangeStart]) {\n var flatGroup = flatGroups[rangeStart] = [];\n var groups = dataSource.view();\n for (var i = 0, len = groups.length; i < len; i++) {\n var group = groups[i];\n for (var j = 0, groupLength = group.items.length; j < groupLength; j++) {\n flatGroup.push({ item: group.items[j], group: group.value });\n }\n }\n }\n\n result = flatGroups[rangeStart][index - rangeStart];\n } else { //flat list\n result = dataSource.view()[index - rangeStart];\n }\n\n return result;\n }\n };\n },\n\n _fixedHeader: function(scrollTop, list) {\n var group = this.currentVisibleGroup,\n itemHeight = this.options.itemHeight,\n firstVisibleDataItemIndex = Math.floor((scrollTop - list.top) / itemHeight),\n firstVisibleDataItem = list.items[firstVisibleDataItemIndex];\n\n if (firstVisibleDataItem && firstVisibleDataItem.item) {\n var firstVisibleGroup = firstVisibleDataItem.group;\n\n if (firstVisibleGroup !== group) {\n var fixedGroupText = firstVisibleGroup || \"\";\n this.header.html(this.templates.fixedGroupTemplate(fixedGroupText));\n this.currentVisibleGroup = firstVisibleGroup;\n }\n }\n\n return list;\n },\n\n _itemMapper: function(item, index, value) {\n var listType = this.options.type,\n itemHeight = this.options.itemHeight,\n currentIndex = this._focusedIndex,\n selected = false,\n current = false,\n newGroup = false,\n group = null,\n match = false,\n valueGetter = this._valueGetter;\n\n if (listType === \"group\") {\n if (item) {\n newGroup = index === 0 || (this._currentGroup !== false && this._currentGroup !== item.group);\n this._currentGroup = item.group;\n }\n\n group = item ? item.group : null;\n item = item ? item.item : null;\n }\n\n if (this.options.mapValueTo === \"dataItem\" && this._selectedDataItems.length && item) {\n for (var i = 0; i < this._selectedDataItems.length; i++) {\n match = valueGetter(this._selectedDataItems[i]) === valueGetter(item);\n if (match) {\n selected = true;\n break;\n }\n }\n } else if (!this.isFiltered() && value.length && item) {\n for (var j = 0; j < value.length; j++) {\n match = isPrimitive(item) ? value[j] === item : value[j] === valueGetter(item);\n if (match) {\n value.splice(j , 1);\n selected = true;\n break;\n }\n }\n }\n\n if (currentIndex === index) {\n current = true;\n }\n\n return {\n item: item ? item : null,\n group: group,\n newGroup: newGroup,\n selected: selected,\n current: current,\n index: index,\n top: index * itemHeight\n };\n },\n\n _range: function(index) {\n var itemCount = this.itemCount,\n value = this._values.slice(),\n items = [],\n item;\n\n this._view = {};\n this._currentGroup = false;\n\n for (var i = index, length = index + itemCount; i < length; i++) {\n item = this._itemMapper(this.getter(i, index), i, value);\n if(items[items.length - 1]){\n items[items.length - 1].isLastGroupedItem = item.newGroup;\n }\n items.push(item);\n this._view[item.index] = item;\n }\n\n this._dataView = items;\n return items;\n },\n\n _getDataItemsCollection: function(scrollTop, lastScrollTop) {\n var items = this._range(this._listIndex(scrollTop, lastScrollTop));\n return {\n index: items.length ? items[0].index : 0,\n top: items.length ? items[0].top : 0,\n items: items\n };\n },\n\n _listItems: function() {\n var screenHeight = this._screenHeight,\n options = this.options;\n\n var theValidator = listValidator(options, screenHeight);\n\n return $.proxy(function(value, force) {\n var result = this.result,\n lastScrollTop = this._lastScrollTop;\n\n if (force || !result || !theValidator(result, value, lastScrollTop)) {\n result = this._getDataItemsCollection(value, lastScrollTop);\n }\n\n this._lastScrollTop = value;\n this.result = result;\n\n return result;\n }, this);\n },\n\n _whenChanged: function(getter, callback) {\n var current;\n\n return function(force) {\n var theNew = getter(force);\n\n if (theNew !== current) {\n current = theNew;\n callback(theNew, force);\n }\n };\n },\n\n _reorderList: function(list, reorder) {\n var that = this;\n var length = list.length;\n var currentOffset = -Infinity;\n reorder = $.proxy(map2(reorder, this.templates), this);\n\n return function(list2, offset, force) {\n var diff = offset - currentOffset;\n var range, range2;\n\n if (force || Math.abs(diff) >= length) { // full reorder\n range = list;\n range2 = list2;\n } else { // partial reorder\n range = reshift(list, diff);\n range2 = diff > 0 ? list2.slice(-diff) : list2.slice(0, -diff);\n }\n\n reorder(range, range2, that.bound());\n\n currentOffset = offset;\n };\n },\n\n _bufferSizes: function() {\n var options = this.options;\n\n return bufferSizes(this._screenHeight, options.listScreens, options.oppositeBuffer);\n },\n\n _indexConstraint: function(position) {\n var itemCount = this.itemCount,\n itemHeight = this.options.itemHeight,\n total = this.dataSource.total();\n\n return Math.min(Math.max(total - itemCount, 0), Math.max(0, Math.floor(position / itemHeight )));\n },\n\n _listIndex: function(scrollTop, lastScrollTop) {\n var buffers = this._bufferSizes(),\n position;\n\n position = scrollTop - ((scrollTop > lastScrollTop) ? buffers.down : buffers.up);\n\n return this._indexConstraint(position);\n },\n\n _selectable: function() {\n var itemClass = this.options.columns && this.options.columns.length ? TABLE_ITEM : LIST_ITEM;\n\n if (this.options.selectable) {\n this._selectProxy = $.proxy(this, \"_clickHandler\");\n this.element.on(CLICK + VIRTUAL_LIST_NS, \".\" + itemClass, this._selectProxy);\n }\n },\n\n getElementIndex: function(element) {\n if (!(element instanceof jQuery)) {\n return undefined;\n }\n\n return parseInt(element.attr(\"data-offset-index\"), 10);\n },\n\n _getIndecies: function(candidate) {\n var result = [], data;\n\n if (typeof candidate === \"function\") {\n data = this.dataSource.flatView();\n for (var idx = 0; idx < data.length; idx++) {\n if (candidate(data[idx])) {\n result.push(idx);\n break;\n }\n }\n }\n\n if (typeof candidate === \"number\") {\n result.push(candidate);\n }\n\n var elementIndex = this.getElementIndex(candidate);\n if (!isNaN(elementIndex)) {\n result.push(elementIndex);\n }\n\n if (candidate instanceof Array) {\n result = candidate;\n }\n\n return result;\n },\n\n _deselect: function(indices) {\n var removed = [],\n selectedIndex,\n dataItem,\n selectedIndexes = this._selectedIndexes,\n selectedDataItems = this._selectedDataItems,\n position = 0,\n selectable = this.options.selectable,\n removedindexesCounter = 0,\n valueGetter = this._valueGetter,\n item, match,\n result = null;\n\n indices = indices.slice();\n\n if (selectable === true || !indices.length) { //deselect everything\n for (var idx = 0; idx < selectedIndexes.length; idx++) {\n if (selectedIndexes[idx] !== undefined) {\n this._getElementByIndex(selectedIndexes[idx]).removeClass(SELECTED);\n } else if (selectedDataItems[idx]) {\n this._getElementByDataItem(selectedDataItems[idx]).removeClass(SELECTED);\n }\n\n removed.push({\n index: selectedIndexes[idx],\n position: idx,\n dataItem: selectedDataItems[idx]\n });\n }\n\n this._values = [];\n this._selectedDataItems = [];\n this._selectedIndexes = [];\n } else if (selectable === \"multiple\") {\n for (var i = 0; i < indices.length; i++) {\n result = null;\n position = $.inArray(indices[i], selectedIndexes);\n dataItem = this.dataItemByIndex(indices[i]);\n\n if (position === -1 && dataItem) {\n for (var j = 0; j < selectedDataItems.length; j++) {\n match = isPrimitive(dataItem) ? selectedDataItems[j] === dataItem : valueGetter(selectedDataItems[j]) === valueGetter(dataItem);\n if (match) {\n item = this._getElementByIndex(indices[i]);\n result = this._deselectSingleItem(item, j, indices[i], removedindexesCounter);\n }\n }\n } else {\n selectedIndex = selectedIndexes[position];\n\n if (selectedIndex !== undefined) {\n item = this._getElementByIndex(selectedIndex);\n result = this._deselectSingleItem(item, position, selectedIndex, removedindexesCounter);\n }\n }\n\n if (result) {\n indices.splice(i, 1);\n removed.push(result);\n\n removedindexesCounter++;\n i--;\n }\n }\n }\n\n return {\n indices: indices,\n removed: removed\n };\n },\n\n _deselectSingleItem: function(item, position, selectedIndex, removedindexesCounter) {\n var dataItem;\n\n if (!item.hasClass(SELECTED)) {\n return;\n }\n\n item.removeClass(SELECTED);\n this._values.splice(position, 1);\n this._selectedIndexes.splice(position, 1);\n dataItem = this._selectedDataItems.splice(position, 1)[0];\n\n return {\n index: selectedIndex,\n position: position + removedindexesCounter,\n dataItem: dataItem\n };\n },\n\n _deselectCurrentValues: function(indices) {\n var children = this.element[0].children;\n var value, index, position;\n var values = this._values;\n var removed = [];\n var idx = 0;\n var j;\n\n if (this.options.selectable !== \"multiple\" || !this.isFiltered()) {\n return [];\n }\n\n if (indices[0] === -1) {\n $(children).removeClass(SELECTED);\n removed = $.map(this._selectedDataItems.slice(0), function(dataItem, idx) {\n return {\n dataItem: dataItem,\n position: idx\n };\n });\n this._selectedIndexes = [];\n this._selectedDataItems = [];\n this._values = [];\n return removed;\n }\n\n for (; idx < indices.length; idx++) {\n position = -1;\n index = indices[idx];\n if (this.dataItemByIndex(index)) {\n value = this._valueGetter(this.dataItemByIndex(index));\n }\n\n for (j = 0; j < values.length; j++) {\n if (value == values[j]) {\n position = j;\n break;\n }\n }\n\n if (position > -1) {\n removed.push(this.removeAt(position));\n $(children[index]).removeClass(SELECTED);\n }\n }\n\n return removed;\n },\n\n _getSkip: function(index, take) {\n var page = index < take ? 1 : Math.floor(index / take) + 1;\n\n return (page - 1) * take;\n },\n\n _select: function(indexes) {\n var that = this,\n singleSelection = this.options.selectable !== \"multiple\",\n dataSource = this.dataSource,\n dataItem, oldSkip,\n take = this.itemCount,\n valueGetter = this._valueGetter,\n added = [];\n\n if (singleSelection) {\n that._selectedIndexes = [];\n that._selectedDataItems = [];\n that._values = [];\n }\n\n oldSkip = dataSource.skip();\n\n $.each(indexes, function(_, index) {\n var skip = that._getSkip(index, take);\n\n that.mute(function() {\n dataSource.range(skip, take); //switch the range to get the dataItem\n\n dataItem = that._findDataItem(dataSource.view(), [index - skip]);\n that._selectedIndexes.push(index);\n that._selectedDataItems.push(dataItem);\n that._values.push(isPrimitive(dataItem) ? dataItem : valueGetter(dataItem));\n\n added.push({\n index: index,\n dataItem: dataItem\n });\n\n that._getElementByIndex(index).addClass(SELECTED);\n\n dataSource.range(oldSkip, take); //switch back the range\n });\n });\n\n that._values = that._checkValuesOrder(that._values);\n\n return added;\n },\n\n _clickHandler: function(e) {\n var item = $(e.currentTarget);\n\n if (!e.isDefaultPrevented() && item.attr(\"data-uid\")) {\n this.trigger(CLICK, { item: item });\n }\n },\n\n _buildValueGetter: function() {\n this._valueGetter = kendo.getter(this.options.dataValueField);\n },\n\n _calculateGroupPadding: function (height) {\n var firstItem = this.items().first(),\n groupHeader = this.header,\n padding = 0;\n\n if (groupHeader[0] && groupHeader[0].style.display !== \"none\") {\n if (height !== \"auto\") {\n padding = kendo.support.scrollbar();\n }\n\n padding += parseFloat(firstItem.css(\"border-right-width\"), 10) + parseFloat(firstItem.children(\".k-group\").css(\"right\"), 10);\n\n groupHeader.css(\"padding-right\", padding);\n }\n },\n\n _calculateColumnsHeaderPadding: function () {\n if(this.options.columns && this.options.columns.length){\n var isRtl = kendo.support.isRtl(this.wrapper);\n var scrollbar = kendo.support.scrollbar();\n var columnsHeader = this.content.parent().parent().find(\".k-table-header\");\n var total = this.dataSource.total();\n\n columnsHeader.css((isRtl ? \"padding-left\" : \"padding-right\"), total ? scrollbar : 0);\n }\n }\n\n });\n\n kendo.ui.VirtualList = VirtualList;\n kendo.ui.plugin(VirtualList);\n\n})(window.kendo.jQuery);\n\nreturn window.kendo;\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n\n(function(f, define){\n define('kendo.autocomplete',[ \"./kendo.list\", \"./kendo.mobile.scroller\", \"./kendo.virtuallist\" ], f);\n})(function(){\n\nvar __meta__ = { // jshint ignore:line\n id: \"autocomplete\",\n name: \"AutoComplete\",\n category: \"web\",\n description: \"The AutoComplete widget provides suggestions depending on the typed text.It also allows multiple value entries.\",\n depends: [ \"list\" ],\n features: [ {\n id: \"mobile-scroller\",\n name: \"Mobile scroller\",\n description: \"Support for kinetic scrolling in mobile device\",\n depends: [ \"mobile.scroller\" ]\n }, {\n id: \"virtualization\",\n name: \"VirtualList\",\n description: \"Support for virtualization\",\n depends: [ \"virtuallist\" ]\n } ]\n};\n\n(function ($, undefined) {\n var kendo = window.kendo,\n support = kendo.support,\n caret = kendo.caret,\n activeElement = kendo._activeElement,\n placeholderSupported = support.placeholder,\n ui = kendo.ui,\n List = ui.List,\n keys = kendo.keys,\n DataSource = kendo.data.DataSource,\n ARIA_DISABLED = \"aria-disabled\",\n ARIA_READONLY = \"aria-readonly\",\n CHANGE = \"change\",\n DISABLED = \"disabled\",\n READONLY = \"readonly\",\n FOCUSED = \"k-focus\",\n SELECTED = \"k-selected\",\n HIDDENCLASS = \"k-hidden\",\n STATEDISABLED = \"k-disabled\",\n AUTOCOMPLETEVALUE = \"off\",\n HOVER = \"k-hover\",\n ns = \".kendoAutoComplete\",\n HOVEREVENTS = \"mouseenter\" + ns + \" mouseleave\" + ns,\n proxy = $.proxy;\n\n function indexOfWordAtCaret(caretIdx, text, separator) {\n return separator ? text.substring(0, caretIdx).split(separator).length - 1 : 0;\n }\n\n function wordAtCaret(caretIdx, text, separator) {\n return text.split(separator)[indexOfWordAtCaret(caretIdx, text, separator)];\n }\n\n function replaceWordAtCaret(caretIdx, text, word, separator, defaultSeparator) {\n var words = text.split(separator);\n\n words.splice(indexOfWordAtCaret(caretIdx, text, separator), 1, word);\n\n if (separator && words[words.length - 1] !== \"\") {\n words.push(\"\");\n }\n\n return words.join(defaultSeparator);\n }\n\n var AutoComplete = List.extend({\n init: function (element, options) {\n var that = this, wrapper, disabled;\n\n that.ns = ns;\n options = Array.isArray(options) ? { dataSource: options} : options;\n\n List.fn.init.call(that, element, options);\n\n element = that.element;\n options = that.options;\n\n options.placeholder = options.placeholder || element.attr(\"placeholder\");\n if (placeholderSupported) {\n element.attr(\"placeholder\", options.placeholder);\n }\n\n that._wrapper();\n that._loader();\n that._clearButton();\n\n that._dataSource();\n that._ignoreCase();\n\n element[0].type = \"text\";\n wrapper = that.wrapper;\n\n that._popup();\n\n element\n .addClass(\"k-input-inner\")\n .on(\"keydown\" + ns, proxy(that._keydown, that))\n .on(\"keypress\" + ns, proxy(that._keypress, that))\n .on(\"input\" + ns, proxy(that._search, that))\n .on(\"paste\" + ns, proxy(that._search, that))\n .on(\"focus\" + ns, function () {\n that._prev = that._accessor();\n that._oldText = that._prev;\n that._placeholder(false);\n wrapper.addClass(FOCUSED);\n })\n .on(\"focusout\" + ns, function () {\n that._change();\n that._placeholder();\n that.close();\n wrapper.removeClass(FOCUSED);\n })\n .attr({\n autocomplete: AUTOCOMPLETEVALUE,\n role: \"combobox\",\n \"aria-expanded\": false\n });\n\n that._clear.on(\"click\" + ns + \" touchend\" + ns, proxy(that._clearValue, that));\n that._enable();\n\n that._old = that._accessor();\n\n if (element[0].id) {\n element.attr(\"aria-owns\", that.ul[0].id);\n }\n\n that._aria();\n\n that._placeholder();\n\n that._initList();\n\n disabled = $(that.element).parents(\"fieldset\").is(':disabled');\n\n if (disabled) {\n that.enable(false);\n }\n\n that.listView.bind(\"click\", function(e) { e.preventDefault(); });\n\n that._resetFocusItemHandler = $.proxy(that._resetFocusItem, that);\n\n kendo.notify(that);\n that._toggleCloseVisibility();\n that._applyCssClasses();\n },\n\n options: {\n name: \"AutoComplete\",\n enabled: true,\n suggest: false,\n template: \"\",\n groupTemplate: \"#:data#\",\n fixedGroupTemplate: \"#:data#\",\n dataTextField: \"\",\n minLength: 1,\n enforceMinLength: false,\n delay: 200,\n height: 200,\n filter: \"startswith\",\n ignoreCase: true,\n highlightFirst: false,\n separator: null,\n placeholder: \"\",\n animation: {},\n virtual: false,\n value: null,\n clearButton: true,\n autoWidth: false,\n popup: null,\n size: \"medium\",\n fillMode: \"solid\",\n rounded: \"medium\"\n },\n\n _dataSource: function() {\n var that = this;\n\n if (that.dataSource && that._refreshHandler) {\n that._unbindDataSource();\n } else {\n that._progressHandler = proxy(that._showBusy, that);\n that._errorHandler = proxy(that._hideBusy, that);\n }\n\n that.dataSource = DataSource.create(that.options.dataSource)\n .bind(\"progress\", that._progressHandler)\n .bind(\"error\", that._errorHandler);\n },\n\n setDataSource: function(dataSource) {\n this.options.dataSource = dataSource;\n this._dataSource();\n\n this.listView.setDataSource(this.dataSource);\n },\n\n events: [\n \"open\",\n \"close\",\n CHANGE,\n \"select\",\n \"filtering\",\n \"dataBinding\",\n \"dataBound\"\n ],\n\n setOptions: function(options) {\n var listOptions = this._listOptions(options);\n\n List.fn.setOptions.call(this, options);\n\n this.listView.setOptions(listOptions);\n this._accessors();\n this._aria();\n this._clearButton();\n },\n\n _listOptions: function(options) {\n var listOptions = List.fn._listOptions.call(this, $.extend(options, {\n skipUpdateOnBind: true\n }));\n\n listOptions.dataValueField = listOptions.dataTextField;\n listOptions.selectedItemChange = null;\n\n return listOptions;\n },\n\n _editable: function(options) {\n var that = this,\n element = that.element,\n wrapper = that.wrapper.off(ns),\n readonly = options.readonly,\n disable = options.disable;\n\n if (!readonly && !disable) {\n wrapper\n .removeClass(STATEDISABLED)\n .on(HOVEREVENTS, that._toggleHover);\n\n element.prop(DISABLED, false)\n .prop(READONLY, false)\n .attr(ARIA_DISABLED, false)\n .attr(ARIA_READONLY, false);\n } else {\n wrapper\n .addClass(disable ? STATEDISABLED : \"\")\n .removeClass(disable ? \"\" : STATEDISABLED);\n\n element.attr(DISABLED, disable)\n .attr(READONLY, readonly)\n .attr(ARIA_DISABLED, disable)\n .attr(ARIA_READONLY, readonly);\n }\n },\n\n close: function () {\n var that = this;\n var current = that.listView.focus();\n\n if (current) {\n current.removeClass(SELECTED);\n }\n\n that.popup.close();\n that._deactivateItem();\n },\n\n destroy: function() {\n var that = this;\n\n that.element.off(ns);\n that._clear.off(ns);\n that.wrapper.off(ns);\n\n List.fn.destroy.call(that);\n },\n\n refresh: function() {\n this.listView.refresh();\n },\n\n select: function (li) {\n this._select(li);\n },\n\n search: function (word) {\n var that = this,\n options = that.options,\n ignoreCase = options.ignoreCase,\n separator = that._separator(),\n length,\n accentFoldingFiltering = that.dataSource.options.accentFoldingFiltering;\n\n word = word || that._accessor();\n\n clearTimeout(that._typingTimeout);\n\n if (separator) {\n word = wordAtCaret(caret(that.element)[0], word, separator);\n }\n\n length = word.length;\n\n if ((!options.enforceMinLength && !length) || length >= options.minLength) {\n that._open = true;\n\n that._mute(function() {\n this.listView.value([]);\n });\n\n that._filterSource({\n value: ignoreCase ? (accentFoldingFiltering ? word.toLocaleLowerCase(accentFoldingFiltering) : word.toLowerCase()) : word,\n operator: options.filter,\n field: options.dataTextField,\n ignoreCase: ignoreCase\n });\n\n that.one(\"close\", $.proxy(that._unifySeparators, that));\n }\n that._toggleCloseVisibility();\n },\n\n suggest: function (word) {\n var that = this,\n key = that._last,\n value = that._accessor(),\n element = that.element[0],\n caretIdx = caret(element)[0],\n separator = that._separator(),\n words = value.split(separator),\n wordIndex = indexOfWordAtCaret(caretIdx, value, separator),\n selectionEnd = caretIdx,\n idx,\n accentFoldingFiltering = that.dataSource.options.accentFoldingFiltering;\n\n if (key == keys.BACKSPACE || key == keys.DELETE) {\n that._last = undefined;\n return;\n }\n\n word = word || \"\";\n\n if (typeof word !== \"string\") {\n if (word[0]) {\n word = that.dataSource.view()[List.inArray(word[0], that.ul[0])];\n }\n\n word = word ? that._text(word) : \"\";\n }\n\n if (caretIdx <= 0) {\n caretIdx = (accentFoldingFiltering ? value.toLocaleLowerCase(accentFoldingFiltering) : value.toLowerCase()).indexOf(accentFoldingFiltering ? word.toLocaleLowerCase(accentFoldingFiltering) : word.toLowerCase()) + 1;\n }\n\n idx = value.substring(0, caretIdx).lastIndexOf(separator);\n idx = idx > -1 ? caretIdx - (idx + separator.length) : caretIdx;\n value = words[wordIndex].substring(0, idx);\n\n if (word) {\n word = word.toString();\n idx = (accentFoldingFiltering ? word.toLocaleLowerCase(accentFoldingFiltering) : word.toLowerCase()).indexOf(accentFoldingFiltering ? value.toLocaleLowerCase(accentFoldingFiltering) : value.toLowerCase());\n if (idx > -1) {\n word = word.substring(idx + value.length);\n\n selectionEnd = caretIdx + word.length;\n\n value += word;\n }\n\n if (separator && words[words.length - 1] !== \"\") {\n words.push(\"\");\n }\n\n }\n\n words[wordIndex] = value;\n\n that._accessor(words.join(separator || \"\"));\n\n if (element === activeElement()) {\n caret(element, caretIdx, selectionEnd);\n }\n },\n\n value: function (value) {\n if (value !== undefined) {\n this.listView.value(value);\n\n this._accessor(value);\n this._old = this._accessor();\n this._oldText = this._accessor();\n } else {\n return this._accessor();\n }\n this._toggleCloseVisibility();\n },\n\n _click: function(e) {\n var item = e.item;\n var that = this;\n var element = that.element;\n var dataItem = that.listView.dataItemByIndex(that.listView.getElementIndex(item));\n\n e.preventDefault();\n\n that._active = true;\n\n if (that.trigger(\"select\", { dataItem: dataItem, item: item })) {\n that.close();\n return;\n }\n that._oldText = element.val();\n that._select(item).done(function() {\n that._blur();\n\n caret(element, element.val().length);\n });\n },\n\n _clearText: $.noop,\n\n _resetFocusItem: function() {\n var index = this.options.highlightFirst ? 0 : -1;\n\n if (this.options.virtual) {\n this.listView.scrollTo(0);\n }\n\n this.listView.focus(index);\n },\n\n _listBound: function() {\n var that = this;\n var popup = that.popup;\n var options = that.options;\n var data = that.dataSource.flatView();\n var length = data.length;\n var groupsLength = that.dataSource._group ? that.dataSource._group.length : 0;\n var isActive = that.element[0] === activeElement();\n var action;\n\n that._renderFooter();\n that._renderNoData();\n that._toggleNoData(!length);\n that._toggleHeader(!!groupsLength && !!length);\n\n that._resizePopup();\n\n popup.position();\n\n if (length) {\n if (options.suggest && isActive && that._inputValue()) {\n that.suggest(data[0]);\n }\n }\n\n if (that._open) {\n that._open = false;\n action = that._allowOpening() ? \"open\" : \"close\";\n\n if (that._typingTimeout && !isActive) {\n action = \"close\";\n }\n\n if (length) {\n that._resetFocusItem();\n\n if (options.virtual) {\n that.popup\n .unbind(\"activate\", that._resetFocusItemHandler)\n .one(\"activate\", that._resetFocusItemHandler);\n }\n }\n\n popup[action]();\n that._typingTimeout = undefined;\n }\n\n if (that._touchScroller) {\n that._touchScroller.reset();\n }\n\n that._hideBusy();\n\n that.trigger(\"dataBound\");\n },\n\n _mute: function(callback) {\n this._muted = true;\n callback.call(this);\n this._muted = false;\n },\n\n _listChange: function() {\n var isActive = this._active || this.element[0] === activeElement();\n\n if (isActive && !this._muted) {\n this._selectValue(this.listView.selectedDataItems()[0]);\n }\n },\n\n _selectValue: function(dataItem) {\n var separator = this._separator();\n var text = \"\";\n\n if (dataItem) {\n text = this._text(dataItem);\n }\n\n if (text === null) {\n text = \"\";\n }\n\n if (separator) {\n text = replaceWordAtCaret(caret(this.element)[0], this._accessor(), text, separator, this._defaultSeparator());\n }\n\n this._prev = text;\n this._accessor(text);\n this._placeholder();\n },\n\n _unifySeparators: function() {\n this._accessor(this.value().split(this._separator()).join(this._defaultSeparator()));\n return this;\n },\n\n _preselect: function(value, text) {\n this._inputValue(text);\n this._accessor(value);\n\n this._old = this.oldText = this._accessor();\n\n this.listView.setValue(value);\n this._placeholder();\n },\n\n _change: function() {\n var that = this;\n var value = that._unifySeparators().value();\n var trigger = value !== List.unifyType(that._old, typeof value);\n\n var valueUpdated = trigger && !that._typing;\n var itemSelected = that._oldText !== value;\n\n that._old = value;\n that._oldText = value;\n\n if (valueUpdated || itemSelected) {\n // trigger the DOM change event so any subscriber gets notified\n that.element.trigger(CHANGE);\n }\n\n if (trigger) {\n that.trigger(CHANGE);\n }\n\n that.typing = false;\n that._toggleCloseVisibility();\n },\n\n _accessor: function (value) {\n var that = this,\n element = that.element[0];\n\n if (value !== undefined) {\n element.value = value === null ? \"\" : value;\n that._placeholder();\n } else {\n value = element.value;\n\n if (element.className.indexOf(\"k-readonly\") > -1) {\n if (value === that.options.placeholder) {\n return \"\";\n } else {\n return value;\n }\n }\n\n return value;\n }\n },\n\n _keydown: function (e) {\n var that = this;\n var key = e.keyCode;\n var listView = that.listView;\n var visible = that.popup.visible();\n var current = listView.focus();\n\n that._last = key;\n\n if (key === keys.DOWN) {\n if (visible) {\n this._move(current ? \"focusNext\" : \"focusFirst\");\n } else if (that.value()) {\n that._filterSource({\n value: that.ignoreCase ? that.value().toLowerCase() : that.value(),\n operator: that.options.filter,\n field: that.options.dataTextField,\n ignoreCase: that.ignoreCase\n }).done(function () {\n if (that._allowOpening()) {\n that._resetFocusItem();\n that.popup.open();\n }\n });\n }\n e.preventDefault();\n } else if (key === keys.UP) {\n if (visible) {\n this._move(current ? \"focusPrev\" : \"focusLast\");\n }\n e.preventDefault();\n } else if (key === keys.HOME) {\n this._move(\"focusFirst\");\n } else if (key === keys.END) {\n this._move(\"focusLast\");\n } else if (key === keys.ENTER || key === keys.TAB) {\n\n if (key === keys.ENTER && visible) {\n e.preventDefault();\n }\n\n if (visible && current) {\n var dataItem = listView.dataItemByIndex(listView.getElementIndex(current));\n if (that.trigger(\"select\", { dataItem: dataItem, item: current })) {\n return;\n }\n\n this._select(current);\n }\n\n this._blur();\n } else if (key === keys.ESC) {\n if (visible) {\n e.preventDefault();\n } else {\n that._clearValue();\n }\n that.close();\n } else if (that.popup.visible() && (key === keys.PAGEDOWN || key === keys.PAGEUP)) {\n e.preventDefault();\n\n var direction = key === keys.PAGEDOWN ? 1 : -1;\n listView.scrollWith(direction * listView.screenHeight());\n } else {\n // In some cases when the popup is opened resize is triggered which will cause it to close\n // Setting the below flag will prevent this from happening\n that.popup._hovered = true;\n that._search();\n }\n },\n\n _keypress: function() {\n this._oldText = this.element.val();\n this._typing = true;\n },\n\n _move: function (action) {\n this.listView[action]();\n\n if (this.options.suggest) {\n this.suggest(this.listView.focus());\n }\n },\n\n _hideBusy: function () {\n var that = this;\n clearTimeout(that._busy);\n that._loading.addClass(HIDDENCLASS);\n that.element.attr(\"aria-busy\", false);\n that._busy = null;\n that._showClear();\n },\n\n _showBusy: function () {\n var that = this;\n\n if (that._busy) {\n return;\n }\n\n that._busy = setTimeout(function () {\n that.element.attr(\"aria-busy\", true);\n that._loading.removeClass(HIDDENCLASS);\n that._hideClear();\n }, 100);\n },\n\n _placeholder: function(show) {\n if (placeholderSupported) {\n return;\n }\n\n var that = this,\n element = that.element,\n placeholder = that.options.placeholder,\n value;\n\n if (placeholder) {\n value = element.val();\n\n if (show === undefined) {\n show = !value;\n }\n\n if (!show) {\n if (value !== placeholder) {\n placeholder = value;\n } else {\n placeholder = \"\";\n }\n }\n\n if (value === that._old && !show) {\n return;\n }\n\n element.toggleClass(\"k-readonly\", show)\n .val(placeholder);\n\n if (!placeholder && element[0] === document.activeElement) {\n caret(element[0], 0, 0);\n }\n }\n },\n\n _separator: function() {\n var separator = this.options.separator;\n if (separator instanceof Array) {\n return new RegExp(separator.join(\"|\"), 'gi');\n }\n return separator;\n },\n\n _defaultSeparator: function() {\n var separator = this.options.separator;\n if (separator instanceof Array) {\n return separator[0];\n }\n return separator;\n },\n\n _inputValue: function() {\n return this.element.val();\n },\n\n _search: function () {\n var that = this;\n clearTimeout(that._typingTimeout);\n\n that._typingTimeout = setTimeout(function () {\n if (that._prev !== that._accessor()) {\n that._prev = that._accessor();\n that.search();\n }\n }, that.options.delay);\n },\n\n _select: function(candidate) {\n var that = this;\n that._active = true;\n\n return that.listView.select(candidate).done(function() {\n that._active = false;\n });\n },\n\n _loader: function() {\n this._loading = $('').insertAfter(this.element);\n },\n\n _clearButton: function() {\n List.fn._clearButton.call(this);\n\n if (this.options.clearButton) {\n this._clear.insertAfter(this.element);\n this.wrapper.addClass(\"k-autocomplete-clearable\");\n }\n },\n\n _toggleHover: function(e) {\n $(e.currentTarget).toggleClass(HOVER, e.type === \"mouseenter\");\n },\n\n _toggleCloseVisibility: function() {\n if (this.value()) {\n this._showClear();\n } else {\n this._hideClear();\n }\n },\n\n _wrapper: function () {\n var that = this,\n element = that.element,\n DOMelement = element[0],\n wrapper;\n\n wrapper = element.parent();\n\n if (!wrapper.is(\"span.k-autocomplete\")) {\n wrapper = element.wrap(\"\").parent();\n }\n\n wrapper.attr(\"tabindex\", -1);\n\n wrapper[0].style.cssText = DOMelement.style.cssText;\n element.css({\n width: \"\",\n height: DOMelement.style.height\n });\n\n that._focused = that.element;\n that.wrapper = wrapper\n .addClass(\"k-autocomplete k-input\")\n .addClass(DOMelement.className)\n .removeClass('input-validation-error');\n },\n\n _clearValue: function() {\n List.fn._clearValue.call(this);\n this.element.focus();\n }\n });\n\n ui.plugin(AutoComplete);\n\n kendo.cssProperties.registerPrefix(\"AutoComplete\", \"k-input-\");\n\n kendo.cssProperties.registerValues(\"AutoComplete\", [{\n prop: \"rounded\",\n values: kendo.cssProperties.roundedValues.concat([['full', 'full']])\n }]);\n})(window.kendo.jQuery);\n\nreturn window.kendo;\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n\n(function(f, define){\n define('kendo.dropdownlist',[ \"./kendo.list\", \"./kendo.mobile.scroller\", \"./kendo.virtuallist\", \"./kendo.html.button\" ], f);\n})(function(){\n\nvar __meta__ = { // jshint ignore:line\n id: \"dropdownlist\",\n name: \"DropDownList\",\n category: \"web\",\n description: \"The DropDownList widget displays a list of values and allows the selection of a single value from the list.\",\n depends: [ \"list\", \"html.button\" ],\n features: [ {\n id: \"mobile-scroller\",\n name: \"Mobile scroller\",\n description: \"Support for kinetic scrolling in mobile device\",\n depends: [ \"mobile.scroller\" ]\n }, {\n id: \"virtualization\",\n name: \"VirtualList\",\n description: \"Support for virtualization\",\n depends: [ \"virtuallist\" ]\n } ]\n};\n\n(function($, undefined) {\n var kendo = window.kendo,\n ui = kendo.ui,\n html = kendo.html,\n List = ui.List,\n Select = ui.Select,\n support = kendo.support,\n activeElement = kendo._activeElement,\n ObservableObject = kendo.data.ObservableObject,\n keys = kendo.keys,\n ns = \".kendoDropDownList\",\n nsFocusEvent = ns + \"FocusEvent\",\n DISABLED = \"disabled\",\n READONLY = \"readonly\",\n CHANGE = \"change\",\n FOCUSED = \"k-focus\",\n STATEDISABLED = \"k-disabled\",\n ARIA_DISABLED = \"aria-disabled\",\n ARIA_READONLY = \"aria-readonly\",\n CLICKEVENTS = \"click\" + ns + \" touchend\" + ns,\n HOVEREVENTS = \"mouseenter\" + ns + \" mouseleave\" + ns,\n TABINDEX = \"tabindex\",\n STATE_FILTER = \"filter\",\n STATE_ACCEPT = \"accept\",\n MSG_INVALID_OPTION_LABEL = \"The `optionLabel` option is not valid due to missing fields. Define a custom optionLabel as shown here http://docs.telerik.com/kendo-ui/api/javascript/ui/dropdownlist#configuration-optionLabel\",\n proxy = $.proxy,\n OPEN = \"open\",\n CLOSE = \"close\";\n\n var DropDownList = Select.extend( {\n init: function(element, options) {\n var that = this;\n var index = options && options.index;\n var optionLabel, text, disabled;\n\n that.ns = ns;\n options = Array.isArray(options) ? { dataSource: options } : options;\n\n Select.fn.init.call(that, element, options);\n\n options = that.options;\n element = that.element.on(\"focus\" + ns, proxy(that._focusHandler, that));\n\n that._focusInputHandler = $.proxy(that._focusInput, that);\n\n that.optionLabel = $();\n that._optionLabel();\n\n that._inputTemplate();\n\n that._reset();\n\n that._prev = \"\";\n that._word = \"\";\n\n that._wrapper();\n\n that._tabindex();\n that.wrapper.data(TABINDEX, that.wrapper.attr(TABINDEX));\n\n that._span();\n\n that._popup();\n\n that._mobile();\n\n that._dataSource();\n\n that._ignoreCase();\n\n that._filterHeader();\n\n that._aria();\n\n //should read changed value of closed dropdownlist\n that.wrapper.attr(\"aria-live\", \"polite\");\n\n that._enable();\n\n that._attachFocusHandlers();\n\n that._oldIndex = that.selectedIndex = -1;\n\n if (index !== undefined) {\n options.index = index;\n }\n\n that._initialIndex = options.index;\n\n that.requireValueMapper(that.options);\n that._initList();\n that.listView.one(\"dataBound\", proxy(that._attachAriaActiveDescendant, that));\n\n that._cascade();\n\n that.one(\"set\", function(e) {\n if (!e.sender.listView.bound() && that.hasOptionLabel()) {\n that._textAccessor(that._optionLabelText());\n }\n });\n\n if (options.autoBind) {\n that.dataSource.fetch();\n } else if (that.selectedIndex === -1) { //selectedIndex !== -1 when cascade functionality happens instantly\n text = options.text || \"\";\n if (!text) {\n optionLabel = options.optionLabel;\n\n if (optionLabel && options.index === 0) {\n text = optionLabel;\n } else if (that._isSelect) {\n text = element.children(\":selected\").text();\n }\n }\n\n that._textAccessor(text);\n }\n\n disabled = $(that.element).parents(\"fieldset\").is(':disabled');\n\n if (disabled) {\n that.enable(false);\n }\n\n that.listView.bind(\"click\", function(e) { e.preventDefault(); });\n\n kendo.notify(that);\n that._applyCssClasses();\n },\n\n options: {\n name: \"DropDownList\",\n enabled: true,\n autoBind: true,\n index: 0,\n text: null,\n value: null,\n delay: 500,\n height: 200,\n dataTextField: \"\",\n dataValueField: \"\",\n optionLabel: \"\",\n cascadeFrom: \"\",\n cascadeFromField: \"\",\n cascadeFromParentField: \"\",\n ignoreCase: true,\n animation: {},\n filter: \"none\",\n minLength: 1,\n enforceMinLength: false,\n virtual: false,\n template: null,\n valueTemplate: null,\n optionLabelTemplate: null,\n groupTemplate: \"#:data#\",\n fixedGroupTemplate: \"#:data#\",\n autoWidth: false,\n popup: null,\n filterTitle: null,\n size: \"medium\",\n fillMode: \"solid\",\n rounded: \"medium\"\n },\n\n events: [\n \"open\",\n \"close\",\n CHANGE,\n \"select\",\n \"filtering\",\n \"dataBinding\",\n \"dataBound\",\n \"cascade\",\n \"set\",\n \"kendoKeydown\"\n ],\n\n setOptions: function(options) {\n Select.fn.setOptions.call(this, options);\n\n this.listView.setOptions(this._listOptions(options));\n\n this._optionLabel();\n this._inputTemplate();\n this._accessors();\n this._filterHeader();\n this._enable();\n this._aria();\n\n if (!this.value() && this.hasOptionLabel()) {\n this.select(0);\n }\n },\n\n destroy: function() {\n var that = this;\n\n Select.fn.destroy.call(that);\n\n that.wrapper.off(ns);\n that.wrapper.off(nsFocusEvent);\n that.element.off(ns);\n\n that._arrow.off();\n that._arrow = null;\n that._arrowIcon = null;\n\n that.optionLabel.off();\n\n if(that.filterInput){\n that.filterInput.off(nsFocusEvent);\n }\n },\n\n open: function() {\n var that = this;\n var isFiltered = that.dataSource.filter() ? that.dataSource.filter().filters.length > 0 : false;\n var listView = this.listView;\n\n if (that.popup.visible()) {\n return;\n }\n\n if (!that.listView.bound() || that._state === STATE_ACCEPT) {\n that._open = true;\n that._state = \"rebind\";\n\n if (that.filterInput) {\n that.filterInput.val(\"\");\n that._prev = \"\";\n }\n\n if (that.filterInput && that.options.minLength !== 1 && !isFiltered) {\n that.refresh();\n that.popup.one(\"activate\", that._focusInputHandler);\n that.wrapper.attr(\"aria-activedescendant\", listView._optionID);\n that.popup.open();\n that._resizeFilterInput();\n } else {\n that._filterSource();\n }\n } else if (that._allowOpening()) {\n that._focusFilter = true;\n that.popup.one(\"activate\", that._focusInputHandler);\n // In some cases when the popup is opened resize is triggered which will cause it to close\n // Setting the below flag will prevent this from happening\n that.popup._hovered = true;\n that.wrapper.attr(\"aria-activedescendant\", listView._optionID);\n that.popup.open();\n that._resizeFilterInput();\n that._focusItem();\n }\n },\n\n close: function() {\n this._attachAriaActiveDescendant();\n this.popup.close();\n },\n\n _attachAriaActiveDescendant: function() {\n var wrapper = this.wrapper,\n inputId = wrapper.find(\".k-input-inner\").attr('id');\n\n wrapper.attr(\"aria-activedescendant\", inputId);\n },\n\n _focusInput: function () {\n this._focusElement(this.filterInput);\n },\n\n _resizeFilterInput: function () {\n var filterInput = this.filterInput;\n var originalPrevent = this._prevent;\n\n if (!filterInput) {\n return;\n }\n\n var isInputActive = this.filterInput[0] === activeElement();\n var caret = kendo.caret(this.filterInput[0])[0];\n\n this._prevent = true;\n\n filterInput.addClass(\"k-hidden\");\n filterInput.closest(\".k-list-filter\").css(\"width\", this.popup.element.css(\"width\"));\n filterInput.removeClass(\"k-hidden\");\n\n if (isInputActive) {\n filterInput.trigger(\"focus\");\n kendo.caret(filterInput[0], caret);\n }\n\n this._prevent = originalPrevent;\n },\n\n _allowOpening: function() {\n return this.hasOptionLabel() || this.filterInput || Select.fn._allowOpening.call(this);\n },\n\n toggle: function(toggle) {\n this._toggle(toggle, true);\n },\n\n current: function(candidate) {\n var current;\n\n if (candidate === undefined) {\n current = this.listView.focus();\n\n if (!current && this.selectedIndex === 0 && this.hasOptionLabel()) {\n return this.optionLabel;\n }\n\n return current;\n }\n\n this._focus(candidate);\n },\n\n dataItem: function(index) {\n var that = this;\n var dataItem = null;\n\n if (index === null) { return index; }\n\n if (index === undefined) {\n dataItem = that.listView.selectedDataItems()[0];\n } else {\n if (typeof index !== \"number\") {\n if (that.options.virtual) {\n return that.dataSource.getByUid($(index).data(\"uid\"));\n }\n if (index.hasClass(\"k-list-optionlabel\")) {\n index = -1;\n } else {\n index = $(that.items()).index(index);\n }\n } else if (that.hasOptionLabel()) {\n index -= 1;\n }\n\n dataItem = that.dataSource.flatView()[index];\n }\n\n if (!dataItem) {\n dataItem = that._optionLabelDataItem();\n }\n\n return dataItem;\n },\n\n refresh: function() {\n this.listView.refresh();\n },\n\n text: function (text) {\n var that = this;\n var loweredText;\n var ignoreCase = that.options.ignoreCase;\n\n text = text === null ? \"\" : text;\n\n if (text !== undefined) {\n if (typeof text !== \"string\") {\n that._textAccessor(text);\n return;\n }\n\n loweredText = ignoreCase ? text.toLowerCase() : text;\n\n that._select(function(data) {\n data = that._text(data);\n\n if (ignoreCase) {\n data = (data + \"\").toLowerCase();\n }\n\n return data === loweredText;\n }).done(function() {\n that._textAccessor(that.dataItem() || text);\n });\n\n } else {\n return that._textAccessor();\n }\n },\n\n _clearFilter: function() {\n $(this.filterInput).val(\"\");\n Select.fn._clearFilter.call(this);\n },\n\n value: function(value) {\n var that = this;\n var listView = that.listView;\n var dataSource = that.dataSource;\n\n if (value === undefined) {\n value = that._accessor() || that.listView.value()[0];\n return value === undefined || value === null ? \"\" : value;\n }\n\n that.requireValueMapper(that.options, value);\n\n if (value || !that.hasOptionLabel()) {\n that._initialIndex = null;\n }\n\n this.trigger(\"set\", { value: value });\n\n if (that._request && that.options.cascadeFrom && that.listView.bound()) {\n if (that._valueSetter) {\n dataSource.unbind(CHANGE, that._valueSetter);\n }\n\n that._valueSetter = proxy(function() { that.value(value); }, that);\n\n dataSource.one(CHANGE, that._valueSetter);\n return;\n }\n\n if (that._isFilterEnabled() && listView.bound() && listView.isFiltered()) {\n that._clearFilter();\n } else {\n that._fetchData();\n }\n\n listView.value(value).done(function() {\n that._old = that._valueBeforeCascade = that._accessor();\n that._oldIndex = that.selectedIndex;\n });\n },\n\n hasOptionLabel: function() {\n return this.optionLabel && !!this.optionLabel[0];\n },\n\n _optionLabel: function() {\n var that = this;\n var options = that.options;\n var optionLabel = options.optionLabel;\n var template = options.optionLabelTemplate;\n\n if (!optionLabel) {\n that.optionLabel.off().remove();\n that.optionLabel = $();\n return;\n }\n\n if (!template) {\n template = \"#:\";\n\n if (typeof optionLabel === \"string\") {\n template += \"data\";\n } else {\n template += kendo.expr(options.dataTextField, \"data\");\n }\n\n template += \"#\";\n }\n\n if (typeof template !== \"function\") {\n template = kendo.template(template);\n }\n\n that.optionLabelTemplate = template;\n\n if (!that.hasOptionLabel()) {\n that.optionLabel = $('
    ').prependTo(that.list);\n }\n\n that.optionLabel.html(template(optionLabel))\n .off()\n .on(CLICKEVENTS, proxy(that._click, that))\n .on(HOVEREVENTS, that._toggleHover);\n\n that.angular(\"compile\", function() {\n return { elements: that.optionLabel, data: [{ dataItem: that._optionLabelDataItem() }] };\n });\n },\n\n _optionLabelText: function() {\n var optionLabel = this.options.optionLabel;\n return (typeof optionLabel === \"string\") ? optionLabel : this._text(optionLabel);\n },\n\n _optionLabelDataItem: function() {\n var that = this;\n var optionLabel = that.options.optionLabel;\n\n if (that.hasOptionLabel()) {\n return $.isPlainObject(optionLabel) ? new ObservableObject(optionLabel) : that._assignInstance(that._optionLabelText(), \"\");\n }\n\n return undefined;\n },\n\n _buildOptions: function(data) {\n var that = this;\n if (!that._isSelect) {\n return;\n }\n\n var value = that.listView.value()[0];\n var optionLabel = that._optionLabelDataItem();\n var optionLabelValue = optionLabel && that._value(optionLabel);\n\n if (value === undefined || value === null) {\n value = \"\";\n }\n\n if (optionLabel) {\n if (optionLabelValue === undefined || optionLabelValue === null) {\n optionLabelValue = \"\";\n }\n\n optionLabel = '\";\n }\n\n that._options(data, optionLabel, value);\n\n if (value !== List.unifyType(that._accessor(), typeof value)) {\n that._customOption = null;\n that._custom(value);\n }\n },\n\n _listBound: function() {\n\n var that = this;\n var initialIndex = that._initialIndex;\n var filtered = that._state === STATE_FILTER;\n\n var data = that.dataSource.flatView();\n var dataItem;\n\n that._presetValue = false;\n\n that._renderFooter();\n that._renderNoData();\n that._toggleNoData(!data.length);\n\n that._resizePopup(true);\n\n that.popup.position();\n\n that._buildOptions(data);\n\n if (!filtered) {\n if (that._open) {\n that.toggle(that._allowOpening());\n }\n\n that._open = false;\n\n if (!that._fetch) {\n if (data.length) {\n if (!that.listView.value().length && initialIndex > -1 && initialIndex !== null) {\n that.select(initialIndex);\n }\n\n that._initialIndex = null;\n dataItem = that.listView.selectedDataItems()[0];\n if (dataItem && that.text() !== that._text(dataItem)) {\n that._selectValue(dataItem);\n }\n } else if (that._textAccessor() !== that._optionLabelText()) {\n that.listView.value(\"\");\n that._selectValue(null);\n that._oldIndex = that.selectedIndex;\n }\n }\n }\n\n that._hideBusy();\n that.trigger(\"dataBound\");\n },\n\n _listChange: function() {\n this._selectValue(this.listView.selectedDataItems()[0]);\n\n if (this._presetValue || (this._old && this._oldIndex === -1)) {\n this._oldIndex = this.selectedIndex;\n }\n },\n\n _filterPaste: function() {\n this._search();\n },\n\n _attachFocusHandlers: function() {\n var that = this;\n var wrapper = that.wrapper;\n\n wrapper.on(\"focusin\" + nsFocusEvent, proxy(that._focusinHandler, that))\n .on(\"focusout\" + nsFocusEvent, proxy(that._focusoutHandler, that));\n if(that.filterInput) {\n that.filterInput.on(\"focusin\" + nsFocusEvent, proxy(that._focusinHandler, that))\n .on(\"focusout\" + nsFocusEvent, proxy(that._focusoutHandler, that));\n }\n },\n\n _focusHandler: function() {\n this.wrapper.trigger(\"focus\");\n },\n\n _focusinHandler: function() {\n this.wrapper.addClass(FOCUSED);\n this._prevent = false;\n },\n\n _focusoutHandler: function() {\n var that = this;\n var isIFrame = window.self !== window.top;\n\n if (!that._prevent) {\n clearTimeout(that._typingTimeout);\n\n if (support.mobileOS.ios && isIFrame) {\n that._change();\n } else {\n that._blur();\n }\n\n that.wrapper.removeClass(FOCUSED);\n that._prevent = true;\n that._open = false;\n that.element.trigger(\"blur\");\n }\n },\n\n _wrapperMousedown: function() {\n this._prevent = !!this.filterInput;\n },\n\n _wrapperClick: function(e) {\n e.preventDefault();\n this.popup.unbind(\"activate\", this._focusInputHandler);\n this._focused = this.wrapper;\n this._prevent = false;\n this._toggle();\n },\n\n _editable: function(options) {\n var that = this;\n var element = that.element;\n var disable = options.disable;\n var readonly = options.readonly;\n var wrapper = that.wrapper.add(that.filterInput).off(ns);\n var dropDownWrapper = that.wrapper.off(HOVEREVENTS);\n\n if (!readonly && !disable) {\n element.prop(DISABLED, false).prop(READONLY, false);\n\n dropDownWrapper\n .removeClass(STATEDISABLED)\n .on(HOVEREVENTS, that._toggleHover);\n\n wrapper\n .attr(TABINDEX, wrapper.data(TABINDEX))\n .attr(ARIA_DISABLED, false)\n .attr(ARIA_READONLY, false)\n .on(\"keydown\" + ns, that, proxy(that._keydown, that))\n .on(kendo.support.mousedown + ns, proxy(that._wrapperMousedown, that))\n .on(\"paste\" + ns, proxy(that._filterPaste, that));\n\n that.wrapper.on(\"click\" + ns, proxy(that._wrapperClick, that));\n\n if (!that.filterInput) {\n wrapper.on(\"keypress\" + ns, proxy(that._keypress, that));\n } else {\n wrapper.on(\"input\" + ns, proxy(that._search, that));\n }\n\n } else if (disable) {\n wrapper.removeAttr(TABINDEX);\n dropDownWrapper.addClass(STATEDISABLED);\n } else {\n dropDownWrapper.removeClass(STATEDISABLED);\n }\n\n element.attr(DISABLED, disable)\n .attr(READONLY, readonly);\n\n wrapper.attr(ARIA_DISABLED, disable)\n .attr(ARIA_READONLY, readonly);\n },\n\n _keydown: function(e) {\n var that = this;\n var key = e.keyCode;\n var altKey = e.altKey;\n var isInputActive;\n var handled;\n\n var isPopupVisible = that.popup.visible();\n\n if (that.filterInput) {\n isInputActive = that.filterInput[0] === activeElement();\n }\n\n if (key === keys.LEFT) {\n key = keys.UP;\n handled = true;\n } else if (key === keys.RIGHT) {\n key = keys.DOWN;\n handled = true;\n }\n\n if (handled && isInputActive) {\n return;\n }\n\n e.keyCode = key;\n\n if ((altKey && key === keys.UP) || key === keys.ESC) {\n that._focusElement(that.wrapper);\n }\n\n if (that._state === STATE_FILTER && key === keys.ESC) {\n that._clearFilter();\n that._open = false;\n that._state = STATE_ACCEPT;\n }\n\n if (key === keys.ENTER && that._typingTimeout && that.filterInput && isPopupVisible) {\n e.preventDefault();\n return;\n }\n\n if (key === keys.SPACEBAR && !isInputActive) {\n that.toggle(!isPopupVisible);\n e.preventDefault();\n }\n\n handled = that._move(e);\n\n if (handled) {\n return;\n }\n\n if (!isPopupVisible || !that.filterInput) {\n var current = that._focus();\n\n if (key === keys.HOME) {\n handled = true;\n that._firstItem();\n } else if (key === keys.END) {\n handled = true;\n that._lastItem();\n }\n\n if (handled) {\n if (that.trigger(\"select\", { dataItem: that._getElementDataItem(that._focus()), item: that._focus() })) {\n that._focus(current);\n return;\n }\n\n that._select(that._focus(), true).done(function() {\n if (!isPopupVisible) {\n that._blur();\n }\n });\n e.preventDefault();\n }\n }\n\n if (!altKey && !handled && that.filterInput) {\n that._search();\n }\n },\n\n _matchText: function(text, word) {\n var ignoreCase = this.options.ignoreCase;\n\n if (text === undefined || text === null) {\n return false;\n }\n\n text = text + \"\";\n\n if (ignoreCase) {\n text = text.toLowerCase();\n }\n\n return text.indexOf(word) === 0;\n },\n\n _shuffleData: function(data, splitIndex) {\n var optionDataItem = this._optionLabelDataItem();\n\n if (optionDataItem) {\n data = [optionDataItem].concat(data);\n }\n\n return data.slice(splitIndex).concat(data.slice(0, splitIndex));\n },\n\n _selectNext: function() {\n var that = this;\n var data = that.dataSource.flatView();\n var dataLength = data.length + (that.hasOptionLabel() ? 1 : 0);\n var isInLoop = sameCharsOnly(that._word, that._last);\n var startIndex = that.selectedIndex;\n var oldFocusedItem;\n var text;\n\n if (startIndex === -1) {\n startIndex = 0;\n } else {\n startIndex += isInLoop ? 1 : 0;\n startIndex = normalizeIndex(startIndex, dataLength);\n }\n\n data = data.toJSON ? data.toJSON() : data.slice();\n data = that._shuffleData(data, startIndex);\n\n for (var idx = 0; idx < dataLength; idx++) {\n text = that._text(data[idx]);\n\n if (isInLoop && that._matchText(text, that._last)) {\n break;\n } else if (that._matchText(text, that._word)) {\n break;\n }\n }\n\n if (idx !== dataLength) {\n oldFocusedItem = that._focus();\n\n that._select(normalizeIndex(startIndex + idx, dataLength)).done(function() {\n var done = function() {\n if (!that.popup.visible()) {\n that._change();\n }\n };\n\n if (that.trigger(\"select\", { dataItem: that._getElementDataItem(that._focus()), item: that._focus() })) {\n that._select(oldFocusedItem).done(done);\n } else {\n done();\n }\n });\n }\n },\n\n _keypress: function(e) {\n var that = this;\n\n if (e.which === 0 || e.keyCode === kendo.keys.ENTER) {\n return;\n }\n\n var character = String.fromCharCode(e.charCode || e.keyCode);\n\n if (that.options.ignoreCase) {\n character = character.toLowerCase();\n }\n\n if (character === \" \") {\n e.preventDefault();\n }\n\n that._word += character;\n that._last = character;\n\n that._search();\n },\n\n _popupOpen: function() {\n var popup = this.popup;\n\n popup.wrapper = kendo.wrap(popup.element);\n\n if (popup.element.closest(\".km-root\")[0]) {\n popup.wrapper.addClass(\"km-popup km-widget\");\n this.wrapper.addClass(\"km-widget\");\n }\n },\n\n _popup: function() {\n Select.fn._popup.call(this);\n this.popup.one(\"open\", proxy(this._popupOpen, this));\n },\n\n _getElementDataItem: function(element) {\n if (!element || !element[0]) {\n return null;\n }\n\n if (element[0] === this.optionLabel[0]) {\n return this._optionLabelDataItem();\n }\n\n return this.listView.dataItemByIndex(this.listView.getElementIndex(element));\n },\n\n _click: function (e) {\n var that = this;\n var item = e.item || $(e.currentTarget);\n\n e.preventDefault();\n\n if (that.trigger(\"select\", { dataItem: that._getElementDataItem(item), item: item })) {\n that.close();\n return;\n }\n\n that._userTriggered = true;\n\n that._select(item).done(function() {\n that._blur();\n that._focusElement(that.wrapper);\n });\n },\n\n _focusElement: function(element) {\n var active = activeElement();\n var wrapper = this.wrapper;\n var filterInput = this.filterInput;\n var compareElement = element === filterInput ? wrapper : filterInput;\n var touchEnabled = support.mobileOS && (support.touch || support.MSPointers || support.pointers);\n\n if (filterInput && filterInput[0] === element[0] && touchEnabled) {\n return;\n }\n\n if (filterInput && (compareElement[0] === active || this._focusFilter)) {\n this._focusFilter = false;\n this._prevent = true;\n this._focused = element.trigger(\"focus\");\n }\n },\n\n _searchByWord: function(word) {\n if (!word) {\n return;\n }\n\n var that = this;\n var ignoreCase = that.options.ignoreCase;\n\n if (ignoreCase) {\n word = word.toLowerCase();\n }\n\n that._select(function(dataItem) {\n return that._matchText(that._text(dataItem), word);\n });\n },\n\n _inputValue: function() {\n return this.text();\n },\n\n _search: function() {\n var that = this;\n var dataSource = that.dataSource;\n\n clearTimeout(that._typingTimeout);\n\n if (that._isFilterEnabled()) {\n that._typingTimeout = setTimeout(function() {\n var value = that.filterInput.val();\n\n if (that._prev !== value) {\n that._prev = value;\n that.search(value);\n that._resizeFilterInput();\n }\n\n that._typingTimeout = null;\n }, that.options.delay);\n } else {\n that._typingTimeout = setTimeout(function() {\n that._word = \"\";\n }, that.options.delay);\n\n if (!that.listView.bound()) {\n dataSource.fetch().done(function () {\n that._selectNext();\n });\n return;\n }\n\n that._selectNext();\n }\n },\n\n _get: function(candidate) {\n var data, found, idx;\n var isFunction = typeof candidate === \"function\";\n var jQueryCandidate = !isFunction ? $(candidate) : $();\n\n if (this.hasOptionLabel()) {\n if (typeof candidate === \"number\") {\n if (candidate > -1) {\n candidate -= 1;\n }\n } else if (jQueryCandidate.hasClass(\"k-list-optionlabel\")) {\n candidate = -1;\n }\n }\n\n if (isFunction) {\n data = this.dataSource.flatView();\n\n for (idx = 0; idx < data.length; idx++) {\n if (candidate(data[idx])) {\n candidate = idx;\n found = true;\n break;\n }\n }\n\n if (!found) {\n candidate = -1;\n }\n }\n\n return candidate;\n },\n\n _firstItem: function() {\n if (this.hasOptionLabel()) {\n this._focus(this.optionLabel);\n } else {\n this.listView.focusFirst();\n }\n },\n\n _lastItem: function() {\n this._resetOptionLabel();\n this.listView.focusLast();\n },\n\n _nextItem: function() {\n var focusIndex;\n\n if (this.optionLabel.hasClass(\"k-focus\")) {\n this._resetOptionLabel();\n this.listView.focusFirst();\n focusIndex = 1;\n } else {\n focusIndex = this.listView.focusNext();\n }\n\n return focusIndex;\n },\n\n _prevItem: function() {\n var focusIndex;\n\n if (this.optionLabel.hasClass(\"k-focus\")) {\n return;\n }\n\n focusIndex = this.listView.focusPrev();\n\n if (!this.listView.focus() && !this.options.virtual) {\n this._focus(this.optionLabel);\n }\n\n return focusIndex;\n },\n\n _focusItem: function() {\n var options = this.options;\n var listView = this.listView;\n var focusedItem = listView.focus();\n var index = listView.select();\n\n index = index[index.length - 1];\n\n if (index === undefined && options.highlightFirst && !focusedItem) {\n index = 0;\n }\n\n if (index !== undefined) {\n listView.focus(index);\n } else {\n if (options.optionLabel && (!options.virtual || options.virtual.mapValueTo !== \"dataItem\")) {\n this._focus(this.optionLabel);\n this._select(this.optionLabel);\n this.listView.content.scrollTop(0);\n } else {\n listView.scrollToIndex(0);\n }\n }\n },\n\n _resetOptionLabel: function(additionalClass) {\n this.optionLabel.removeClass(\"k-focus\" + (additionalClass || \"\")).removeAttr(\"id\");\n },\n\n _focus: function(candidate) {\n var listView = this.listView;\n var optionLabel = this.optionLabel;\n\n if (candidate === undefined) {\n candidate = listView.focus();\n\n if (!candidate && optionLabel.hasClass(\"k-focus\")) {\n candidate = optionLabel;\n }\n\n return candidate;\n }\n\n this._resetOptionLabel();\n\n candidate = this._get(candidate);\n\n listView.focus(candidate);\n\n if (candidate === -1) {\n optionLabel.addClass(\"k-focus\")\n .attr(\"id\", listView._optionID);\n\n this._focused.add(this.filterInput)\n .removeAttr(\"aria-activedescendant\")\n .attr(\"aria-activedescendant\", listView._optionID);\n }\n },\n\n _select: function(candidate, keepState) {\n var that = this;\n\n candidate = that._get(candidate);\n\n return that.listView.select(candidate).done(function() {\n if (!keepState && that._state === STATE_FILTER) {\n that._state = STATE_ACCEPT;\n }\n\n if (candidate === -1) {\n that._selectValue(null);\n }\n });\n },\n\n _selectValue: function(dataItem) {\n var that = this;\n var optionLabel = that.options.optionLabel;\n var idx = that.listView.select();\n\n var value = \"\";\n var text = \"\";\n\n idx = idx[idx.length - 1];\n if (idx === undefined) {\n idx = -1;\n }\n\n this._resetOptionLabel(\" k-selected\");\n\n if (dataItem || dataItem === 0) {\n text = dataItem;\n value = that._dataValue(dataItem);\n if (optionLabel) {\n idx += 1;\n }\n } else if (optionLabel) {\n that._focus(that.optionLabel.addClass(\"k-selected\"));\n\n text = that._optionLabelText();\n\n if (typeof optionLabel === \"string\") {\n value = \"\";\n } else {\n value = that._value(optionLabel);\n }\n\n idx = 0;\n }\n\n that.selectedIndex = idx;\n\n if (value === null) {\n value = \"\";\n }\n\n that._textAccessor(text);\n that._accessor(value, idx);\n\n that._triggerCascade();\n },\n\n _mobile: function() {\n var that = this,\n popup = that.popup,\n mobileOS = support.mobileOS,\n root = popup.element.parents(\".km-root\").eq(0);\n\n if (root.length && mobileOS) {\n popup.options.animation.open.effects = (mobileOS.android || mobileOS.meego) ? \"fadeIn\" : (mobileOS.ios || mobileOS.wp) ? \"slideIn:up\" : popup.options.animation.open.effects;\n }\n },\n\n _filterHeader: function() {\n var filterTemplate = '
    ' +\n '' +\n '' +\n '' +\n '
    ';\n\n if (this.filterInput) {\n this.filterInput\n .off(ns)\n .closest(\".k-list-filter\")\n .remove();\n\n this.filterInput = null;\n }\n\n if (this._isFilterEnabled()) {\n this.filterInput = $('')\n .attr({\n placeholder: this.element.attr(\"placeholder\"),\n title: this.options.filterTitle || this.element.attr(\"title\"),\n role: \"searchbox\",\n \"aria-label\": this.options.filterTitle,\n \"aria-haspopup\": \"listbox\",\n \"aria-autocomplete\": \"list\"\n });\n\n this.list\n .parent()\n .prepend($(filterTemplate))\n .find(\".k-searchbox\")\n .append(this.filterInput);\n }\n },\n\n _span: function() {\n var that = this,\n wrapper = that.wrapper,\n SELECTOR = \"span.k-input-value-text\",\n id = kendo.guid(),\n options = that.options,\n span, arrowBtn;\n\n span = wrapper.find(SELECTOR);\n\n if (!span[0]) {\n arrowBtn = html.renderButton('', {\n icon: \"arrow-s\",\n size: options.size,\n fillMode: options.fillMode,\n shape: null,\n rounded: null\n });\n\n wrapper.append('' +\n '' +\n '')\n .append(arrowBtn)\n .append(that.element);\n\n span = wrapper.find(SELECTOR);\n }\n\n that.span = span;\n that._arrow = wrapper.find(\".k-select\");\n that._arrowIcon = that._arrow.find(\".k-icon\");\n },\n\n _wrapper: function() {\n var that = this,\n element = that.element,\n DOMelement = element[0],\n wrapper;\n\n wrapper = element.parent();\n\n if (!wrapper.is(\"span.k-picker\")) {\n wrapper = element.wrap(\"\").parent();\n wrapper[0].style.cssText = DOMelement.style.cssText;\n wrapper[0].title = DOMelement.title;\n }\n\n that._focused = that.wrapper = wrapper\n .addClass(\"k-picker k-dropdown k-widget\")\n .addClass(DOMelement.className)\n .removeClass('input-validation-error')\n .css(\"display\", \"\")\n .attr({\n accesskey: element.attr(\"accesskey\"),\n unselectable: \"on\",\n role: \"listbox\",\n \"aria-haspopup\": \"listbox\",\n \"aria-expanded\": false\n });\n\n element.hide().removeAttr(\"accesskey\");\n },\n\n _clearSelection: function(parent) {\n this.select(parent.value() ? 0 : -1);\n },\n\n _openHandler: function(e) {\n this._adjustListWidth();\n\n if (this.trigger(OPEN)) {\n e.preventDefault();\n } else {\n this.wrapper.attr(\"aria-expanded\", true);\n this.ul.attr(\"aria-hidden\", false);\n }\n },\n\n _closeHandler: function(e) {\n if (this.trigger(CLOSE)) {\n e.preventDefault();\n } else {\n this.wrapper.attr(\"aria-expanded\", false);\n this.ul.attr(\"aria-hidden\", true);\n }\n },\n\n _inputTemplate: function() {\n var that = this,\n template = that.options.valueTemplate;\n\n\n if (!template) {\n template = $.proxy(kendo.template('#:this._text(data)#', { useWithBlock: false }), that);\n } else {\n template = kendo.template(template);\n }\n\n that.valueTemplate = template;\n\n if (that.hasOptionLabel() && !that.options.optionLabelTemplate) {\n try {\n that.valueTemplate(that._optionLabelDataItem());\n } catch(e) {\n throw new Error(MSG_INVALID_OPTION_LABEL);\n }\n }\n },\n\n _textAccessor: function(text) {\n var dataItem = null;\n var template = this.valueTemplate;\n var optionLabelText = this._optionLabelText();\n var span = this.span;\n\n if (text === undefined) {\n return span.text();\n }\n\n if ($.isPlainObject(text) || text instanceof ObservableObject) {\n dataItem = text;\n } else if (optionLabelText && optionLabelText === text) {\n dataItem = this.options.optionLabel;\n }\n\n if (!dataItem) {\n dataItem = this._assignInstance(text, this._accessor());\n }\n\n if (this.hasOptionLabel()) {\n if (dataItem === optionLabelText || this._text(dataItem) === optionLabelText) {\n template = this.optionLabelTemplate;\n\n if (typeof this.options.optionLabel === \"string\" && !this.options.optionLabelTemplate) {\n dataItem = optionLabelText;\n }\n }\n }\n\n var getElements = function(){\n return {\n elements: span.get(),\n data: [ { dataItem: dataItem } ]\n };\n };\n\n this.angular(\"cleanup\", getElements);\n\n try {\n span.html(template(dataItem));\n } catch(e) {\n //dataItem has missing fields required in custom template\n span.html(\"\");\n }\n\n this.angular(\"compile\", getElements);\n },\n\n _preselect: function(value, text) {\n if (!value && !text) {\n text = this._optionLabelText();\n }\n\n this._accessor(value);\n this._textAccessor(text);\n\n this._old = this._accessor();\n this._oldIndex = this.selectedIndex;\n\n this.listView.setValue(value);\n\n this._initialIndex = null;\n this._presetValue = true;\n },\n\n _assignInstance: function(text, value) {\n var dataTextField = this.options.dataTextField;\n var dataItem = {};\n\n if (dataTextField) {\n assign(dataItem, dataTextField.split(\".\"), text);\n assign(dataItem, this.options.dataValueField.split(\".\"), value);\n dataItem = new ObservableObject(dataItem);\n } else {\n dataItem = text;\n }\n\n return dataItem;\n }\n });\n\n function assign(instance, fields, value) {\n var idx = 0,\n lastIndex = fields.length - 1,\n field;\n\n for (; idx < lastIndex; ++idx) {\n field = fields[idx];\n\n if (!(field in instance)) {\n instance[field] = {};\n }\n\n instance = instance[field];\n }\n\n instance[fields[lastIndex]] = value;\n }\n\n function normalizeIndex(index, length) {\n if (index >= length) {\n index -= length;\n }\n return index;\n }\n\n function sameCharsOnly(word, character) {\n for (var idx = 0; idx < word.length; idx++) {\n if (word.charAt(idx) !== character) {\n return false;\n }\n }\n return true;\n }\n\n ui.plugin(DropDownList);\n\n kendo.cssProperties.registerPrefix(\"DropDownList\", \"k-picker-\");\n\n kendo.cssProperties.registerValues(\"DropDownList\", [{\n prop: \"rounded\",\n values: kendo.cssProperties.roundedValues.concat([['full', 'full']])\n }]);\n})(window.kendo.jQuery);\n\nreturn window.kendo;\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n\n(function(f, define){\n define('kendo.treeview.draganddrop',[ \"./kendo.data\", \"./kendo.draganddrop\" ], f);\n})(function(){\n\nvar __meta__ = { // jshint ignore:line\n id: \"treeview.draganddrop\",\n name: \"Hierarchical Drag & Drop\",\n category: \"framework\",\n depends: [ \"core\", \"draganddrop\" ],\n advanced: true\n};\n\n(function($, undefined){\n var kendo = window.kendo;\n var ui = kendo.ui;\n var proxy = $.proxy;\n var extend = $.extend;\n var VISIBILITY = \"visibility\";\n var KSTATEHOVER = \"k-state-hover\";\n var INPUTSELECTOR = \"input,a:not(.k-in),textarea,.k-multiselect-wrap,select,button,a.k-button>.k-icon,button.k-button>.k-icon,span.k-icon.k-i-arrow-60-right,span.k-icon.k-i-arrow-45-down-right\";\n var DROPHINTTEMPLATE = \"
    \" +\n \"
    \" +\n \"
    \" +\n \"
    \";\n\n ui.HierarchicalDragAndDrop = kendo.Class.extend({\n init: function (element, options) {\n this.element = element;\n this.hovered = element;\n this.options = extend({\n dragstart: $.noop, drag: $.noop, drop: $.noop, dragend: $.noop\n }, options);\n\n this._draggable = new ui.Draggable(element, {\n ignore: INPUTSELECTOR,\n filter: options.filter,\n autoScroll: options.autoScroll,\n cursorOffset: {\n left: 10,\n top: kendo.support.mobileOS ? -40 / kendo.support.zoomLevel() : 10\n },\n hint: proxy(this._hint, this),\n dragstart: proxy(this.dragstart, this),\n dragcancel: proxy(this.dragcancel, this),\n drag: proxy(this.drag, this),\n dragend: proxy(this.dragend, this),\n $angular: options.$angular,\n holdToDrag: options.holdToDrag\n });\n },\n\n _hint: function(element) {\n return \"
    \" +\n \"\" +\n this.options.hintText(element) +\n \"
    \";\n },\n\n _removeTouchHover: function() {\n if (kendo.support.touch && this.hovered) {\n this.hovered.find(\".\" + KSTATEHOVER).removeClass(KSTATEHOVER);\n this.hovered = false;\n }\n },\n\n _hintStatus: function(newStatus) {\n var statusElement = this._draggable.hint.find(\".k-drag-status\")[0];\n\n if (newStatus) {\n statusElement.className = \"k-icon k-drag-status \" + newStatus;\n } else {\n return kendo.trim(statusElement.className.replace(/(p|k)-(icon|drag-status)/g, \"\"));\n }\n },\n\n dragstart: function (e) {\n this.source = e.currentTarget.closest(this.options.itemSelector);\n\n if (this.options.dragstart(this.source)) {\n e.preventDefault();\n }\n\n if (this.options.reorderable) {\n this.dropHint = $(DROPHINTTEMPLATE)\n .css(VISIBILITY, \"hidden\")\n .appendTo(this.element);\n } else {\n this.dropHint = $();\n }\n },\n\n drag: function (e) {\n var options = this.options;\n var source = this.source;\n var target = this.dropTarget = $(kendo.eventTarget(e));\n var container = target.closest(options.allowedContainers);\n var hoveredItem, itemHeight, itemTop, itemContent, delta;\n var insertOnTop, insertOnBottom, addChild;\n var itemData, position, status;\n\n if (!container.length) {\n // dragging outside of allowed elements\n status = \"k-i-cancel\";\n this._removeTouchHover();\n } else if (source[0] == target[0] || options.contains(source[0], target[0])) {\n // dragging item within itself\n status = \"k-i-cancel\";\n } else {\n // moving or reordering item\n status = \"k-i-insert-middle\";\n\n itemData = options.itemFromTarget(target);\n hoveredItem = itemData.item;\n\n if (hoveredItem.length) {\n this._removeTouchHover();\n itemHeight = kendo._outerHeight(hoveredItem);\n itemContent = itemData.content;\n\n if (options.reorderable) {\n delta = itemHeight / (itemContent.length > 0 ? 4 : 2);\n itemTop = kendo.getOffset(hoveredItem).top;\n\n insertOnTop = e.y.location < (itemTop + delta);\n insertOnBottom = (itemTop + itemHeight - delta) < e.y.location;\n addChild = itemContent.length && !insertOnTop && !insertOnBottom;\n } else {\n addChild = true;\n insertOnTop = false;\n insertOnBottom = false;\n }\n\n this.hovered = addChild ? container : false;\n\n this.dropHint.css(VISIBILITY, addChild ? \"hidden\" : \"visible\");\n\n if (this._lastHover && this._lastHover[0] != itemContent[0]) {\n this._lastHover.removeClass(KSTATEHOVER);\n }\n\n this._lastHover = itemContent.toggleClass(KSTATEHOVER, addChild);\n\n if (addChild) {\n status = \"k-i-plus\";\n } else {\n position = hoveredItem.position();\n position.top += insertOnTop ? 0 : itemHeight;\n\n this.dropHint.css(position)\n [insertOnTop ? \"prependTo\" : \"appendTo\"]\n (options.dropHintContainer(hoveredItem));\n\n if (insertOnTop && itemData.first) {\n status = \"k-i-insert-up\";\n }\n\n if (insertOnBottom && itemData.last) {\n status = \"k-i-insert-down\";\n }\n }\n } else if (target[0] != this.dropHint[0]) {\n if (this._lastHover) {\n this._lastHover.removeClass(KSTATEHOVER);\n }\n\n if (!$.contains(this.element[0], container[0])) {\n // moving node to different element\n status = \"k-i-plus\";\n } else {\n status = \"k-i-cancel\";\n }\n }\n }\n\n this.options.drag({\n originalEvent: e.originalEvent,\n source: source,\n target: target,\n pageY: e.y.location,\n pageX: e.x.location,\n status: status.substring(2),\n setStatus: function(value) {\n status = value;\n }\n });\n\n if (status.indexOf(\"k-i-insert\") !== 0) {\n this.dropHint.css(VISIBILITY, \"hidden\");\n }\n\n this._hintStatus(status);\n },\n\n dragcancel: function() {\n this.dropHint.remove();\n },\n\n dragend: function (e) {\n var position = \"over\",\n source = this.source,\n destination,\n dropHint = this.dropHint,\n dropTarget = this.dropTarget,\n eventArgs, dropPrevented;\n\n if (dropHint.css(VISIBILITY) == \"visible\") {\n position = this.options.dropPositionFrom(dropHint);\n destination = dropHint.closest(this.options.itemSelector);\n } else if (dropTarget) {\n destination = dropTarget.closest(this.options.itemSelector);\n\n // moving node to root element\n if (!destination.length) {\n destination = dropTarget.closest(this.options.allowedContainers);\n }\n }\n\n eventArgs = {\n originalEvent: e.originalEvent,\n source: source[0],\n destination: destination[0],\n valid: this._hintStatus() != \"k-i-cancel\",\n setValid: function(newValid) {\n this.valid = newValid;\n },\n dropTarget: dropTarget[0],\n position: position\n };\n\n dropPrevented = this.options.drop(eventArgs);\n\n dropHint.remove();\n this._removeTouchHover();\n if (this._lastHover) {\n this._lastHover.removeClass(KSTATEHOVER);\n }\n\n if (!eventArgs.valid || dropPrevented) {\n this._draggable.dropped = eventArgs.valid;\n return;\n }\n\n this._draggable.dropped = true;\n\n this.options.dragend({\n originalEvent: e.originalEvent,\n source: source,\n destination: destination,\n position: position\n });\n },\n\n destroy: function() {\n this._lastHover = this.hovered = null;\n this._draggable.destroy();\n }\n });\n\n})(window.kendo.jQuery);\n\nreturn window.kendo;\n\n}, typeof define == 'function' && define.amd ? define : function(a1, a2, a3){ (a3 || a2)(); });\n\n(function(f, define){\n define('kendo.html.input',[\n \"./kendo.html.base\"\n ], f);\n})(function(){\n\nvar __meta__ = { // jshint ignore:line\n id: \"html.input\",\n name: \"Html.Input\",\n category: \"web\",\n description: \"HTML rendering utility for Kendo UI for jQuery.\",\n depends: [ \"html.base\" ],\n features: []\n};\n\n(function ($, undefined) {\n var kendo = window.kendo,\n HTMLBase = kendo.html.HTMLBase;\n\n var renderCheckBox = function (element, options) {\n if (arguments[0] === undefined || $.isPlainObject(arguments[0])) {\n options = element;\n element = $(\"\");\n }\n\n return (new HTMLCheckBox(element, options)).html();\n };\n\n var renderRadioButton = function (element, options) {\n if (arguments[0] === undefined || $.isPlainObject(arguments[0])) {\n options = element;\n element = $(\"\");\n }\n\n return (new HTMLRadioButton(element, options)).html();\n };\n\n var HTMLInput = HTMLBase.extend({\n init: function (element, options) {\n var that = this;\n HTMLBase.fn.init.call(that, element, options);\n that._wrapper();\n that._addClasses();\n },\n options: {\n label: null,\n labelPosition: \"after\",\n encoded: true\n },\n _wrapper: function () {\n var that = this,\n element = that.element[0],\n options = that.options,\n elementId = element.id;\n\n that.wrapper = that.element\n .addClass(options.inputClass)\n .prop(\"type\", options.type);\n\n if(!elementId && !!options.label) {\n element.id = elementId = kendo.guid();\n }\n\n if(!!options.label) {\n that.labelEl = $(\"