UNPKG

@progress/kendo-ui

Version:

This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.

1,426 lines (1,266 loc) 1.18 MB
require('./kendo.core.js'); require('./kendo.excel.js'); require('./kendo.progressbar.js'); require('./kendo.pdf.js'); require('./kendo.binder.js'); require('./kendo.window.js'); require('./kendo.list.js'); require('./kendo.tabstrip.js'); require('./kendo.icons.js'); require('./kendo.color.js'); require('./kendo.sortable.js'); require('./kendo.menu.js'); require('./kendo.popup.js'); require('./kendo.calendar.js'); require('./kendo.listview.js'); require('./kendo.data.js'); require('./kendo.dom.js'); require('./kendo.toolbar.js'); require('./kendo.colorpicker.js'); require('./kendo.combobox.js'); require('./kendo.dropdownlist.js'); require('./kendo.togglebutton.js'); require('./kendo.validator.js'); require('./kendo.treeview.js'); require('./kendo.numerictextbox.js'); require('./kendo.datepicker.js'); require('./kendo.datetimepicker.js'); (function(kendo) { var UndoRedoStack = kendo.Observable.extend({ init: function(options) { kendo.Observable.fn.init.call(this, options); this.clear(); }, events: [ "undo", "redo" ], push: function (command) { this.stack = this.stack.slice(0, this.currentCommandIndex + 1); this.currentCommandIndex = this.stack.push(command) - 1; }, undo: function () { if (this.canUndo()) { var command = this.stack[this.currentCommandIndex--]; command.undo(); this.trigger("undo", { command: command }); } }, redo: function () { if (this.canRedo()) { var command = this.stack[++this.currentCommandIndex]; command.redo(); this.trigger("redo", { command: command }); } }, clear: function() { this.stack = []; this.currentCommandIndex = -1; }, canUndo: function () { return this.currentCommandIndex >= 0; }, canRedo: function () { return this.currentCommandIndex != this.stack.length - 1; } }); kendo.deepExtend(kendo, { util: { UndoRedoStack: UndoRedoStack } }); })(kendo); /*********************************************************************** * WARNING: this file is auto-generated. If you change it directly, * your modifications will eventually be lost. The source code is in * `kendo-drawing` repository, you should make your changes there and * run `src-modules/sync.sh` in this repository. */ (function($) { /* eslint-disable space-before-blocks, space-before-function-paren */ window.kendo.util = window.kendo.util || {}; var LRUCache = kendo.Class.extend({ init: function(size) { this._size = size; this._length = 0; this._map = {}; }, put: function(key, value) { var map = this._map; var entry = { key: key, value: value }; map[key] = entry; if (!this._head) { this._head = this._tail = entry; } else { this._tail.newer = entry; entry.older = this._tail; this._tail = entry; } if (this._length >= this._size) { map[this._head.key] = null; this._head = this._head.newer; this._head.older = null; } else { this._length++; } }, get: function(key) { var entry = this._map[key]; if (entry) { if (entry === this._head && entry !== this._tail) { this._head = entry.newer; this._head.older = null; } if (entry !== this._tail) { if (entry.older) { entry.older.newer = entry.newer; entry.newer.older = entry.older; } entry.older = this._tail; entry.newer = null; this._tail.newer = entry; this._tail = entry; } return entry.value; } } }); var REPLACE_REGEX = /\r?\n|\r|\t/g; var SPACE = ' '; function normalizeText(text) { return String(text).replace(REPLACE_REGEX, SPACE); } function objectKey(object) { var parts = []; for (var key in object) { parts.push(key + object[key]); } return parts.sort().join(""); } // Computes FNV-1 hash // See http://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function function hashKey(str) { // 32-bit FNV-1 offset basis // See http://isthe.com/chongo/tech/comp/fnv/#FNV-param var hash = 0x811C9DC5; for (var i = 0; i < str.length; ++i) { hash += (hash << 1) + (hash << 4) + (hash << 7) + (hash << 8) + (hash << 24); hash ^= str.charCodeAt(i); } return hash >>> 0; } function zeroSize() { return { width: 0, height: 0, baseline: 0 }; } var DEFAULT_OPTIONS = { baselineMarkerSize: 1 }; var defaultMeasureBox; if (typeof document !== "undefined") { defaultMeasureBox = document.createElement("div"); defaultMeasureBox.style.cssText = "position: absolute !important; top: -4000px !important; width: auto !important; height: auto !important;" + "padding: 0 !important; margin: 0 !important; border: 0 !important;" + "line-height: normal !important; visibility: hidden !important; white-space: pre!important;"; } var TextMetrics = kendo.Class.extend({ init: function(options) { this._cache = new LRUCache(1000); this.options = $.extend({}, DEFAULT_OPTIONS, options); }, measure: function(text, style, options) { if (options === void 0) { options = {}; } if (typeof text === 'undefined' || text === null) { return zeroSize(); } var styleKey = objectKey(style); var cacheKey = hashKey(text + styleKey); var cachedResult = this._cache.get(cacheKey); if (cachedResult) { return cachedResult; } var size = zeroSize(); var measureBox = options.box || defaultMeasureBox; var baselineMarker = this._baselineMarker().cloneNode(false); for (var key in style) { var value = style[key]; if (typeof value !== "undefined") { measureBox.style[key] = value; } } var textStr = options.normalizeText !== false ? normalizeText(text) : String(text); measureBox.textContent = textStr; measureBox.appendChild(baselineMarker); document.body.appendChild(measureBox); if (textStr.length) { size.width = measureBox.offsetWidth - this.options.baselineMarkerSize; size.height = measureBox.offsetHeight; size.baseline = baselineMarker.offsetTop + this.options.baselineMarkerSize; } if (size.width > 0 && size.height > 0) { this._cache.put(cacheKey, size); } measureBox.parentNode.removeChild(measureBox); return size; }, _baselineMarker: function() { var marker = document.createElement("div"); marker.style.cssText = "display: inline-block; vertical-align: baseline;width: " + this.options.baselineMarkerSize + "px; height: " + this.options.baselineMarkerSize + "px;overflow: hidden;"; return marker; } }); TextMetrics.current = new TextMetrics(); function measureText(text, style, measureBox) { return TextMetrics.current.measure(text, style, measureBox); } kendo.deepExtend(kendo.util, { LRUCache: LRUCache, TextMetrics: TextMetrics, measureText: measureText, objectKey: objectKey, hashKey: hashKey, normalizeText: normalizeText }); })(window.kendo.jQuery); (function () { // Imports ================================================================ var kendo = window.kendo, deepExtend = kendo.deepExtend; function sqr(value) { return value * value; } var now = Date.now; if (!now) { now = function() { return new Date().getTime(); }; } // Template helpers ======================================================= function renderSize(size) { if (typeof size !== "string") { size += "px"; } return size; } function renderPos(pos) { var result = []; if (pos) { var parts = kendo.toHyphens(pos).split("-"); for (var i = 0; i < parts.length; i++) { result.push("k-pos-" + parts[i]); } } return result.join(" "); } function arabicToRoman(n) { var literals = { 1 : "i", 10 : "x", 100 : "c", 2 : "ii", 20 : "xx", 200 : "cc", 3 : "iii", 30 : "xxx", 300 : "ccc", 4 : "iv", 40 : "xl", 400 : "cd", 5 : "v", 50 : "l", 500 : "d", 6 : "vi", 60 : "lx", 600 : "dc", 7 : "vii", 70 : "lxx", 700 : "dcc", 8 : "viii", 80 : "lxxx", 800 : "dccc", 9 : "ix", 90 : "xc", 900 : "cm", 1000 : "m" }; var values = [ 1000, 900 , 800, 700, 600, 500, 400, 300, 200, 100, 90 , 80 , 70 , 60 , 50 , 40 , 30 , 20 , 10 , 9 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 ]; var roman = ""; while (n > 0) { if (n < values[0]) { values.shift(); } else { roman += literals[values[0]]; n -= values[0]; } } return roman; } function romanToArabic(r) { r = r.toLowerCase(); var digits = { i: 1, v: 5, x: 10, l: 50, c: 100, d: 500, m: 1000 }; var value = 0, prev = 0; for (var i = 0; i < r.length; ++i) { var v = digits[r.charAt(i)]; if (!v) { return null; } value += v; if (v > prev) { value -= 2 * prev; } prev = v; } return value; } function memoize(f) { var cache = Object.create(null); return function() { var id = ""; for (var i = arguments.length; --i >= 0;) { id += ":" + arguments[i]; } return id in cache ? cache[id] : (cache[id] = f.apply(this, arguments)); }; } function isUnicodeLetter(ch) { return RX_UNICODE_LETTER.test(ch); } function withExit(f, obj) { try { return f.call(obj, function(value){ throw new Return(value); }); } catch(ex) { if (ex instanceof Return) { return ex.value; } throw ex; } function Return(value) { this.value = value; } } // Exports ================================================================ deepExtend(kendo, { util: { now: now, renderPos: renderPos, renderSize: renderSize, sqr: sqr, romanToArabic: romanToArabic, arabicToRoman: arabicToRoman, memoize: memoize, isUnicodeLetter: isUnicodeLetter, withExit: withExit } }); var RX_UNICODE_LETTER = new RegExp("[\\u0041-\\u005A\\u0061-\\u007A\\u00AA\\u00B5\\u00BA\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0620-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0840-\\u0858\\u08A0-\\u08B2\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\\u0980\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D\\u0C58\\u0C59\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0\\u0CE1\\u0CF1\\u0CF2\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D\\u0D4E\\u0D60\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1CE9-\\u1CEC\\u1CEE-\\u1CF1\\u1CF5\\u1CF6\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u209C\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CEE\\u2CF2\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA66E\\uA67F-\\uA69D\\uA6A0-\\uA6EF\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uA9CF\\uA9E0-\\uA9E4\\uA9E6-\\uA9EF\\uA9FA-\\uA9FE\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA76\\uAA7A\\uAA7E-\\uAAAF\\uAAB1\\uAAB5\\uAAB6\\uAAB9-\\uAABD\\uAAC0\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEA\\uAAF2-\\uAAF4\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABE2\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]"); })(); "use strict"; // SAX-style XML parser ==================================================== var STRING = String.fromCharCode; // XXX: add more here? var ENTITIES = { "amp" : 38, "lt" : 60, "gt" : 62, "quot" : 34, "apos" : 39, "nbsp" : 160 }; function CODE(str) { var out = []; for (var i = 0; i < str.length; ++i) { out.push(str.charCodeAt(i)); } return out; } function UCS2(out, code) { if (code > 0xFFFF) { code -= 0x10000; out.push(code >>> 10 & 0x3FF | 0xD800, 0xDC00 | code & 0x3FF); } else { out.push(code); } } var START_CDATA = CODE("<![CDATA["); var END_CDATA = CODE("]]>"); var END_COMMENT = CODE("-->"); var START_COMMENT = CODE("!--"); var END_SHORT_TAG = CODE("/>"); var END_TAG = CODE("</"); var END_DECLARATION = CODE("?>"); var QUESTION_MARK = CODE("?"); var LESS_THAN = CODE("<"); var GREATER_THAN = CODE(">"); var SEMICOLON = CODE(";"); var EQUAL = CODE("="); var AMPERSAND = CODE("&"); var QUOTE = CODE('"'); var APOSTROPHE = CODE("'"); var SHARP = CODE("#"); var LOWERCASE_X = CODE("x"); var UPPERCASE_X = CODE("X"); var EXIT = {}; function parse$2(data, callbacks) { var index = 0; var stack = []; var object = { is: function(selector) { var i = stack.length, j = selector.length; while (--i >= 0 && --j >= 0) { if (stack[i].$tag != selector[j] && selector[j] != "*") { return false; } } return j < 0 ? stack[stack.length - 1] : null; }, exit: function() { throw EXIT; }, stack: stack }; function readChar(body) { var code = data[index++]; if (!(code & 0xF0 ^ 0xF0)) {// 4 bytes UCS2(body, ((code & 0x03) << 18) | ((data[index++] & 0x3F) << 12) | ((data[index++] & 0x3F) << 6) | (data[index++] & 0x3F)); } else if (!(code & 0xE0 ^ 0xE0)) {// 3 bytes UCS2(body, ((code & 0x0F) << 12) | ((data[index++] & 0x3F) << 6) | (data[index++] & 0x3F)); } else if (!(code & 0xC0 ^ 0xC0)) {// 2 bytes UCS2(body, ((code & 0x1F) << 6) | (data[index++] & 0x3F)); } else { body.push(code); } } function croak(msg) { throw new Error(msg + ", at " + index); } function readWhile(pred) { var a = []; while (index < data.length && pred(data[index])) { a.push(data[index++]); } return a; } function readAsciiWhile(pred) { return STRING.apply(0, readWhile(pred)); } function skipWhitespace() { readWhile(isWhitespace); } function eat(a) { var save = index; for (var i = 0; i < a.length; ++i) { if (data[index++] != a[i]) { index = save; return false; } } return a; } function skip(code) { if (!eat(code)) { croak("Expecting " + code.join(", ")); } } function isWhitespace(code) { return code == 9 || code == 10 || code == 13 || code == 32; } function isDigit(code) { return code >= 48 && code <= 57; } function isHexDigit(code) { return (code >= 48 && code <= 57) || ((code|=32) >= 97 && code <= 102); // a..f or A..F } function isNameStart(code) { return code == 58 || // : code == 95 || // _ ((code|=32) >= 97 && code <= 122); // a..z or A..Z } function isName(code) { return code == 45 || // - isDigit(code) || isNameStart(code); } function xmlComment() { var body = []; while (index < data.length) { if (eat(END_COMMENT)) { return call("comment", STRING.apply(0, body)); } readChar(body); } } function xmlTag() { var name, attrs; if (eat(QUESTION_MARK)) { xmlDecl(); } else if (eat(START_COMMENT)) { xmlComment(); } else { name = xmlName(); attrs = xmlAttrs(name); stack.push(attrs); if (eat(END_SHORT_TAG)) { call("enter", name, attrs, true); } else { skip(GREATER_THAN); call("enter", name, attrs); xmlContent(name); if (name != xmlName()) { croak("Bad closing tag"); } call("leave", name, attrs); skipWhitespace(); skip(GREATER_THAN); } stack.pop(); } } function xmlContent(name) { var body = []; while (index < data.length) { if (eat(END_TAG)) { return body.length && call("text", STRING.apply(0, body)); } else if (eat(START_CDATA)) { while (index < data.length && !eat(END_CDATA)) { readChar(body); } } else if (eat(LESS_THAN)) { if (body.length) { call("text", STRING.apply(0, body)); } xmlTag(); body = []; } else if (eat(AMPERSAND)) { xmlEntity(body); } else { readChar(body); } } croak("Unclosed tag " + name); } function xmlName() { if (!isNameStart(data[index])) { croak("Expecting XML name"); } return readAsciiWhile(isName); } function xmlString() { var quote = eat(QUOTE) || eat(APOSTROPHE); if (!quote) { croak("Expecting string"); } var body = []; while (index < data.length) { if (eat(quote)) { return STRING.apply(0, body); } else if (eat(AMPERSAND)) { xmlEntity(body); } else { readChar(body); } } croak("Unfinished string"); } function xmlEntity(body) { var code; if (eat(SHARP)) { if (eat(LOWERCASE_X) || eat(UPPERCASE_X)) { code = parseInt(readAsciiWhile(isHexDigit), 16); } else { code = parseInt(readAsciiWhile(isDigit), 10); } if (isNaN(code)) { croak("Bad numeric entity"); } } else { var name = xmlName(); code = ENTITIES[name]; if (code === undefined) { croak("Unknown entity " + name); } } UCS2(body, code); skip(SEMICOLON); } function xmlDecl() { call("decl", xmlName(), xmlAttrs()); skip(END_DECLARATION); } function xmlAttrs(name) { var map = { $tag: name }; while (index < data.length) { skipWhitespace(); var code = data[index]; if (code == 63 || code == 62 || code == 47) { // ?, > or / break; } map[xmlName()] = ( skip(EQUAL), xmlString() ); } return map; } function call(what, thing, arg1, arg2) { var f = callbacks && callbacks[what]; if (f) { f.call(object, thing, arg1, arg2); } } // skip BOM var tmp = []; readChar(tmp); if (tmp[0] != 65279) { index = 0; } while (index < data.length) { skipWhitespace(); skip(LESS_THAN); xmlTag(); skipWhitespace(); } } // Exports ================================================================ kendo.util.parseXML = function parseXML() { try { return parse$2.apply(this, arguments); } catch(ex) { if (ex !== EXIT) { throw ex; } } }; (function(kendo) { var $ = kendo.jQuery; var COMMAND_TYPES = { AUTO_FILL: "autoFill", CLEAR: "clear", CUT: "cut", EDIT: "edit", PASTE: "paste", VALIDATION: "validation" }; var Command = kendo.spreadsheet.Command = kendo.Class.extend({ init: function(options) { this.options = options; this._workbook = options.workbook; this._property = options && options.property; this._state = {}; }, range: function(range) { if (range !== undefined) { this._setRange(range); } return this._range; }, _setRange: function(range) { this._range = range; }, redo: function() { this.range().select(); this.exec(); }, undo: function() { this.setState(this._state); }, getState: function() { this._state = this.range().getState(this._property); }, setState: function(state) { this.range().setState(state); }, rejectState: function(validationState) { this.undo(); return { title: validationState.title, body: validationState.message, reason: "error", type: "validationError" }; }, _forEachCell: function(callback) { var range = this.range(); var ref = range._ref; ref.forEach(function(ref) { range.sheet().forEach(ref.toRangeRef(), callback.bind(this)); }.bind(this)); }, usesImage: function(/* image id from workbook._images */) { return false; } }); kendo.spreadsheet.DrawingUpdateCommand = Command.extend({ init: function(options) { this._sheet = options.sheet; this._drawing = options.drawing; this._orig = this._drawing.clone(); this._previous = options.previous; }, exec: function() {}, undo: function() { this._drawing.reset(this._previous); this._sheet._activeDrawing = this._drawing; this._sheet.triggerChange({ layout: true }); }, redo: function() { this._drawing.reset(this._orig); this._sheet._activeDrawing = this._drawing; this._sheet.triggerChange({ layout: true }); }, usesImage: function(img) { return this._drawing.image === img || this._orig.image === img || this._previous.image === img; } }); var DrawingCommand = Command.extend({ init: function(options) { Command.fn.init.call(this, options); this._drawing = options.drawing; }, usesImage: function(img) { return this._drawing.image === img; } }); kendo.spreadsheet.InsertImageCommand = DrawingCommand.extend({ init: function(options) { DrawingCommand.fn.init.call(this, options); this._blob = options.blob; this._width = options.width; this._height = options.height; }, exec: function() { var range = this.range(); var sheet = range.sheet(); var width = this._width; var height = this._height; var aspect = width / height; if (width > height) { width = Math.min(width, 300); height = width / aspect; } else { height = Math.min(height, 300); width = height * aspect; } this._drawing = sheet.addDrawing({ topLeftCell : range.topLeft(), offsetX : 5, offsetY : 5, width : width, height : height, opacity : 1, image : this._workbook.addImage(this._blob) }, true); this._blob = null; }, undo: function() { var sheet = this.range().sheet(); sheet._activeDrawing = null; sheet.removeDrawing(this._drawing); }, redo: function() { var sheet = this.range().sheet(); sheet._activeDrawing = this._drawing; sheet.addDrawing(this._drawing); } }); kendo.spreadsheet.DeleteDrawingCommand = DrawingCommand.extend({ exec: function() { var sheet = this.range().sheet(); sheet._activeDrawing = null; sheet.removeDrawing(this._drawing); }, undo: function() { var sheet = this.range().sheet(); sheet._activeDrawing = this._drawing; sheet.addDrawing(this._drawing); }, redo: function() { this.exec(); } }); var ReorderDrawingsCommand = DrawingCommand.extend({ exec: function() { var sheet = this.range().sheet(); this._origIndex = sheet._drawings.indexOf(this._drawing); sheet._drawings.splice(this._origIndex, 1); this._newIndex = this._reorder(); sheet._drawings.splice(this._newIndex, 0, this._drawing); sheet.triggerChange({ drawings: true }); }, undo: function() { var sheet = this.range().sheet(); sheet._drawings.splice(this._newIndex, 1); sheet._drawings.splice(this._origIndex, 0, this._drawing); sheet.triggerChange({ drawings: true }); } }); kendo.spreadsheet.BringToFrontCommand = ReorderDrawingsCommand.extend({ _reorder: function() { return this.range().sheet()._drawings.length; } }); kendo.spreadsheet.SendToBackCommand = ReorderDrawingsCommand.extend({ _reorder: function() { return 0; } }); var TargetValueCommand = Command.extend({ init: function(options) { Command.fn.init.call(this, options); this._target = options.target; this._value = options.value; }, exec: function() { this.getState(); this.setState(this._value); } }); kendo.spreadsheet.ColumnWidthCommand = TargetValueCommand.extend({ getState: function() { this._state = this.range().sheet().columnWidth(this._target); }, setState: function(state) { this.range().sheet().columnWidth(this._target, state); } }); kendo.spreadsheet.RowHeightCommand = TargetValueCommand.extend({ getState: function() { this._state = this.range().sheet().rowHeight(this._target); }, setState: function(state) { this.range().sheet().rowHeight(this._target, state); } }); kendo.spreadsheet.HyperlinkCommand = Command.extend({ init: function(options) { Command.fn.init.call(this, options); this._link = options.link; }, exec: function() { var range = this.range(); this._prevLink = range.link(); this._prevUnderline = range.underline(); range.link(this._link); range.underline(true); if (range.value() == null) { this._hasSetValue = true; range.value(this._link); } }, undo: function() { var range = this.range(); range.link(this._prevLink); range.underline(this._prevUnderline); if (this._hasSetValue) { range.value(null); } } }); kendo.spreadsheet.GridLinesChangeCommand = TargetValueCommand.extend({ getState: function() { this._state = this._range.sheet().showGridLines(); }, setState: function(v) { this._range.sheet().showGridLines(v); } }); var PropertyChangeCommand = kendo.spreadsheet.PropertyChangeCommand = Command.extend({ _setRange: function(range) { Command.prototype._setRange.call(this, range.skipHiddenCells()); }, init: function(options) { Command.fn.init.call(this, options); this._value = options.value; }, exec: function() { var range = this.range(); if (range.enable()) { this.getState(); if (this.options.property === "format") { this._workbook.trigger("changeFormat", { range: range }); } range[this._property](this._value); } } }); kendo.spreadsheet.ClearContentCommand = Command.extend({ exec: function() { var values = [], range, rowValues, nullValues, validationState, currentRange; if (!this.range().enable()) { return { reason: "error", type: "cannotModifyDisabled" }; } if (!this.range().canEditArrayFormula()) { return { reason: "error", type: "intersectsArray" }; } this.getState(); range = this.range().skipHiddenCells(); if(range._ref.refs && range._ref.refs.length > 1) { range._ref.refs.forEach(function(ref) { currentRange = range.sheet().range(ref); values = values.concat(currentRange.values()); }); } else { values = range.values(); } nullValues = []; values.forEach(function(row) { rowValues = []; row.forEach(function() { rowValues.push(null); }); nullValues.push(rowValues); }); if (range.sheet().trigger("changing", { data: nullValues, range: range, changeType: COMMAND_TYPES.CLEAR })) { return; } range.clearContent(); validationState = range._getValidationState(); if (validationState) { return this.rejectState(validationState); } }, undo: function() { var range = this.range().skipHiddenCells(); var sheet = range.sheet(); var data = this._state.data; var values = []; var rowValues; data.forEach(function(row) { rowValues = []; row.forEach(function(cell) { rowValues.push(cell.value); }); values.push(rowValues); }); if (sheet.trigger("changing", { data: values, range: range, changeType: COMMAND_TYPES.CLEAR })) { return; } this.setState(this._state); } }); kendo.spreadsheet.EditCommand = PropertyChangeCommand.extend({ init: function(options) { options.property = options.property || "input"; PropertyChangeCommand.fn.init.call(this, options); }, _setRange: function(range) { PropertyChangeCommand.prototype._setRange.apply(this, arguments); this._editRange = this.options.arrayFormula ? range : range.sheet().activeCellSelection(); }, getState: function() { this._state = this.range().getState(); }, exec: function() { return this.range().sheet().withCultureDecimals(this._exec.bind(this)); }, undo: function() { var editRange = this._editRange; var state = this._state; if (editRange.sheet().trigger("changing", { data: state.data[0][0].value, range: editRange, changeType: COMMAND_TYPES.EDIT })) { return; } this.setState(this._state); }, _exec: function() { var arrayFormula = this.options.arrayFormula; var editRange = this._editRange; if (!editRange.enable()) { return { reason: "error", type: "rangeDisabled" }; } if (!editRange.canEditArrayFormula()) { return { reason: "error", type: "intersectsArray" }; } var value = this._value; this.getState(); if (this.range().sheet().trigger("changing", { data: value, range: this._editRange, changeType: COMMAND_TYPES.EDIT })) { return; } if (this._property == "value") { editRange.value(value); return; } try { editRange.link(null); if (value === "") { editRange.value(null); } else { editRange.input(value, { arrayFormula: arrayFormula }); if (/\n/.test(editRange.value())) { editRange.wrap(true); } } editRange._adjustRowHeight(); var validationState = editRange._getValidationState(); if (validationState) { return this.rejectState(validationState); } } catch(ex) { if (ex instanceof kendo.spreadsheet.calc.ParseError) { return { title : "Error in formula", body : ex+"", reason: "error" }; } else { throw ex; } } } }); kendo.spreadsheet.InsertCommentCommand = PropertyChangeCommand.extend({ init: function(options) { options.property = "comment"; PropertyChangeCommand.fn.init.call(this, options); } }); kendo.spreadsheet.TextWrapCommand = PropertyChangeCommand.extend({ init: function(options) { options.property = "wrap"; PropertyChangeCommand.fn.init.call(this, options); this._value = options.value; }, getState: function() { var rowHeight = {}; this.range().forEachRow(function(range) { var index = range.topLeft().row; rowHeight[index] = range.sheet().rowHeight(index); }); this._state = this.range().getState(this._property); this._rowHeight = rowHeight; }, undo: function() { var sheet = this.range().sheet(); var rowHeight = this._rowHeight; this.range().setState(this._state); for (var row in rowHeight) { sheet.rowHeight(row, rowHeight[row]); } } }); kendo.spreadsheet.AdjustDecimalsCommand = Command.extend({ init: function(options) { this._delta = options.value; options.property = "format"; Command.fn.init.call(this, options); }, exec: function() { var sheet = this.range().sheet(); var delta = this._delta; var formatting = kendo.spreadsheet.formatting; this.getState(); sheet.batch(function() { this.range().forEachCell(function(row, col, cell) { var format = cell.format; if (!format) { var value = cell.value; if (typeof value == "number" && /\./.test(value)) { format = "0." + String(value).split(".")[1].replace(/\d/g, "0"); } } if (format || delta > 0) { format = formatting.adjustDecimals(format || "0", delta); sheet.range(row, col).format(format); } }); }.bind(this)); } }); kendo.spreadsheet.BorderChangeCommand = Command.extend({ init: function(options) { options.property = "border"; Command.fn.init.call(this, options); this._type = options.border || options.value.type; this._style = options.style || { color: options.value.color, size: 1 }; }, _batch: function(f) { return this.range().sheet().batch(f, {}); }, exec: function() { var self = this; if (!self._type) { return; } self.getState(); self._batch(function(){ self[self._type](self._style); }); }, noBorders: function() { this.range().insideBorders(null); this.outsideBorders(null); }, allBorders: function(style) { this.range().insideBorders(style); this.outsideBorders(style); }, leftBorder: function(style) { this.range().leftColumn().borderLeft(style); }, rightBorder: function(style) { this.range().rightColumn().borderRight(style); }, topBorder: function(style) { this.range().topRow().borderTop(style); }, bottomBorder: function(style) { this.range().bottomRow().borderBottom(style); }, outsideBorders: function(style) { var range = this.range(); range.leftColumn().borderLeft(style); range.topRow().borderTop(style); range.rightColumn().borderRight(style); range.bottomRow().borderBottom(style); }, insideBorders: function(style) { this.range().insideBorders(style); this.outsideBorders(null); }, insideHorizontalBorders: function(style) { this.range().insideHorizontalBorders(style); }, insideVerticalBorders: function(style) { this.range().insideVerticalBorders(style); } }); kendo.spreadsheet.MergeCellCommand = Command.extend({ init: function(options) { Command.fn.init.call(this, options); this._type = options.value; }, exec: function() { this.getState(); this[this._type](); this.range().sheet().triggerChange({ recalc: true }); }, activate: function(ref) { this.range().sheet().activeCell(ref); }, getState: function() { this._state = this.range().getState(); }, undo: function() { if (this._type !== "unmerge") { this.range().unmerge(); this.activate(this.range().topLeft()); } this.range().setState(this._state); }, cells: function() { var range = this.range(); var ref = range._ref; range.merge(); this.activate(ref); }, horizontally: function() { var ref = this.range().topRow()._ref; this.range().forEachRow(function(range) { range.merge(); }); this.activate(ref); }, vertically: function() { var ref = this.range().leftColumn()._ref; this.range().forEachColumn(function(range) { range.merge(); }); this.activate(ref); }, unmerge: function() { var range = this.range(); var ref = range._ref.topLeft; range.unmerge(); this.activate(ref); } }); kendo.spreadsheet.FreezePanesCommand = Command.extend({ init: function(options) { Command.fn.init.call(this, options); this._type = options.value; }, exec: function() { this.getState(); this._topLeft = this.range().topLeft(); this[this._type](); }, getState: function() { this._state = this.range().sheet().getState(); }, undo: function() { this.range().sheet().setState(this._state); }, panes: function() { var topLeft = this._topLeft; var sheet = this.range().sheet(); sheet.frozenColumns(topLeft.col).frozenRows(topLeft.row); }, rows: function() { var topLeft = this._topLeft; var sheet = this.range().sheet(); sheet.frozenRows(topLeft.row); }, columns: function() { var topLeft = this._topLeft; var sheet = this.range().sheet(); sheet.frozenColumns(topLeft.col); }, unfreeze: function() { var sheet = this.range().sheet(); sheet.frozenRows(0).frozenColumns(0); } }); kendo.spreadsheet.PasteCommand = Command.extend({ init: function(options) { Command.fn.init.call(this, options); this._clipboard = options.workbook.clipboard(); this._clipboard.parse(); this._event = options.event; this._clipboardContent = this._clipboard._content; this._sheet = this._workbook.activeSheet(); this._range = this._sheet.selection ? this._sheet.selection() : this._sheet.range(this._clipboard.pasteRef()); this._state = this._range.getState(); this._targetRangeRefs = (this._range._ref instanceof kendo.spreadsheet.UnionRef ? this._range._ref.refs : [this._range._ref]).map(function(ref){ return ref.toRangeRef(); }); }, exec: function() { return this.range().sheet().withCultureDecimals(this._exec.bind(this)); }, undo: function() { var sheet = this._sheet; var range = this._range; if (sheet.trigger("changing", { data: this._state.data, range: range, changeType: COMMAND_TYPES.PASTE })) { return; } this.setState(this._state); }, _exec: function() { var status = this._clipboard.canPaste(); if (!status.canPaste) { if (status.menuInvoked) { return { reason: "error", type: "useKeyboard" }; } if (status.pasteOnMerged) { return { reason: "error", type: "modifyMerged" }; } if (status.pasteOnDisabled) { this._event.preventDefault(); return { reason: "error", type: "cannotModifyDisabled" }; } return { reason: "error" }; } var sheet = this._sheet; var range = this._range; if(this._workbook.trigger("paste", {range: range, clipboardContent: this._clipboardContent}) || sheet.trigger("changing", { data: this._clipboardContent.data, range: range, changeType: COMMAND_TYPES.PASTE })) { this._event.preventDefault(); return; } else { this._processPaste(); } }, _adjustPasteTarget: function(multipliers, sourceRows, sourceCols) { var that = this; var targetRangeRefs = that._targetRangeRefs; var sheet = that._sheet;