UNPKG

@progress/kendo-ui

Version:

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

1,830 lines (1,452 loc) 309 kB
module.exports = /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) /******/ return installedModules[moduleId].exports; /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ exports: {}, /******/ id: moduleId, /******/ loaded: false /******/ }; /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ // Flag the module as loaded /******/ module.loaded = true; /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ // Load entry module and return exports /******/ return __webpack_require__(0); /******/ }) /************************************************************************/ /******/ ({ /***/ 0: /***/ (function(module, exports, __webpack_require__) { __webpack_require__(921); module.exports = __webpack_require__(921); /***/ }), /***/ 3: /***/ (function(module, exports) { module.exports = function() { throw new Error("define cannot be used indirect"); }; /***/ }), /***/ 921: /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*********************************************************************** * 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(f, define){ !(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(922), __webpack_require__(923), __webpack_require__(924) ], __WEBPACK_AMD_DEFINE_FACTORY__ = (f), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); })(function(){ (function ($) { /* jshint eqnull:true */ /* jshint -W069 */ /* jshint latedef: nofunc */ window.kendo = window.kendo || {}; var kendoDrawing = kendo.drawing; var kendoDrawingUtil = kendoDrawing.util; var Class = kendo.Class; var kendoUtil = kendo.util; var support = kendo.support; var supportBrowser = support.browser; var createPromise = kendoDrawingUtil.createPromise; var promiseAll = kendoDrawingUtil.promiseAll; var ObserversMixin = { extend: function(proto) { var this$1 = this; for (var method in this) { if (method !== "extend") { proto[method] = this$1[method]; } } }, observers: function() { this._observers = this._observers || []; return this._observers; }, addObserver: function(element) { if (!this._observers) { this._observers = [ element ]; } else { this._observers.push(element); } return this; }, removeObserver: function(element) { var observers = this.observers(); var index = observers.indexOf(element); if (index !== -1) { observers.splice(index, 1); } return this; }, trigger: function(methodName, event) { var observers = this._observers; if (observers && !this._suspended) { for (var idx = 0; idx < observers.length; idx++) { var observer = observers[idx]; if (observer[methodName]) { observer[methodName](event); } } } return this; }, optionsChange: function(e) { if (e === void 0) { e = {}; } e.element = this; this.trigger("optionsChange", e); }, geometryChange: function() { this.trigger("geometryChange", { element: this }); }, suspend: function() { this._suspended = (this._suspended || 0) + 1; return this; }, resume: function() { this._suspended = Math.max((this._suspended || 0) - 1, 0); return this; }, _observerField: function(field, value) { if (this[field]) { this[field].removeObserver(this); } this[field] = value; value.addObserver(this); } }; function append(first, second) { first.push.apply(first, second); return first; } /* eslint-disable key-spacing,no-multi-spaces,no-param-reassign */ 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" }; function arabicToRoman(n) { 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; } var UNDEFINED = "undefined"; function defined(value) { return typeof value !== UNDEFINED; } var defId = 1; function definitionId() { return "kdef" + defId++; } var DEG_TO_RAD = Math.PI / 180; var MAX_NUM = Number.MAX_VALUE; var MIN_NUM = -Number.MAX_VALUE; function deg(radians) { return radians / DEG_TO_RAD; } var KEY_STR = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; var fromCharCode = String.fromCharCode; function encodeUTF8(input) { var output = ""; for (var i = 0; i < input.length; i++) { var c = input.charCodeAt(i); if (c < 0x80) { // One byte output += fromCharCode(c); } else if (c < 0x800) { // Two bytes output += fromCharCode(0xC0 | (c >>> 6)); output += fromCharCode(0x80 | (c & 0x3f)); } else if (c < 0x10000) { // Three bytes output += fromCharCode(0xE0 | (c >>> 12)); output += fromCharCode(0x80 | (c >>> 6 & 0x3f)); output += fromCharCode(0x80 | (c & 0x3f)); } } return output; } function encodeBase64(input) { var output = ""; var i = 0; var utfInput = encodeUTF8(input); while (i < utfInput.length) { var chr1 = utfInput.charCodeAt(i++); var chr2 = utfInput.charCodeAt(i++); var chr3 = utfInput.charCodeAt(i++); var enc1 = chr1 >> 2; var enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); var enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); var enc4 = chr3 & 63; if (isNaN(chr2)) { enc3 = enc4 = 64; } else if (isNaN(chr3)) { enc4 = 64; } output = output + KEY_STR.charAt(enc1) + KEY_STR.charAt(enc2) + KEY_STR.charAt(enc3) + KEY_STR.charAt(enc4); } return output; } function eventCoordinates(e) { if (defined((e.x || {}).location)) { return { x: e.x.location, y: e.y.location }; } return { x: e.pageX || e.clientX || 0, y: e.pageY || e.clientY || 0 }; } function eventElement(e) { if (e === void 0) { e = {}; } return e.touch ? e.touch.initialTouch : e.target; } function isTransparent(color) { return color === "" || color === null || color === "none" || color === "transparent" || !defined(color); } function last(array) { if (array) { return array[array.length - 1]; } } function limitValue(value, min, max) { return Math.max(Math.min(value, max), min); } /* eslint-disable no-multi-spaces, key-spacing, indent, camelcase, space-before-blocks, eqeqeq, brace-style */ /* eslint-disable space-infix-ops, space-before-function-paren, array-bracket-spacing, object-curly-spacing */ /* eslint-disable no-nested-ternary, max-params, default-case, no-else-return, no-empty */ /* eslint-disable no-param-reassign, no-var, block-scoped-var */ // mergeSort is stable. function mergeSort(a, cmp) { if (a.length < 2) { return a.slice(); } function merge(a, b) { var r = [], ai = 0, bi = 0, i = 0; while (ai < a.length && bi < b.length) { if (cmp(a[ai], b[bi]) <= 0) { r[i++] = a[ai++]; } else { r[i++] = b[bi++]; } } if (ai < a.length) { r.push.apply(r, a.slice(ai)); } if (bi < b.length) { r.push.apply(r, b.slice(bi)); } return r; } return (function sort(a) { if (a.length <= 1) { return a; } var m = Math.floor(a.length / 2); var left = a.slice(0, m); var right = a.slice(m); left = sort(left); right = sort(right); return merge(left, right); })(a); } function rad(degrees) { return degrees * DEG_TO_RAD; } function pow(p) { if (p) { return Math.pow(10, p); } return 1; } function round(value, precision) { var power = pow(precision); return Math.round(value * power) / power; } function valueOrDefault(value, defaultValue) { return defined(value) ? value : defaultValue; } function bindEvents(element, events) { for (var eventName in events) { var eventNames = eventName.trim().split(" "); for (var idx = 0; idx < eventNames.length; idx++) { element.addEventListener(eventNames[idx], events[eventName], false); } } } function elementOffset(element) { var box = element.getBoundingClientRect(); var documentElement = document.documentElement; return { top: box.top + (window.pageYOffset || documentElement.scrollTop) - (documentElement.clientTop || 0), left: box.left + (window.pageXOffset || documentElement.scrollLeft) - (documentElement.clientLeft || 0) }; } function elementStyles(element, styles) { var result = {}; var style = window.getComputedStyle(element) || {}; var stylesArray = Array.isArray(styles) ? styles : [ styles ]; for (var idx = 0; idx < stylesArray.length; idx++) { var field = stylesArray[idx]; result[field] = style[field]; } return result; } function getPixels(value) { if (isNaN(value)) { return value; } return value + "px"; } function elementSize(element, size) { if (size) { var width = size.width; var height = size.height; if (defined(width)) { element.style.width = getPixels(width); } if (defined(height)) { element.style.height = getPixels(height); } } else { var size$1 = elementStyles(element, [ 'width', 'height' ]); return { width: parseInt(size$1.width, 10), height: parseInt(size$1.height, 10) }; } } function unbindEvents(element, events) { if (events === void 0) { events = {}; } for (var name in events) { var eventNames = name.trim().split(" "); for (var idx = 0; idx < eventNames.length; idx++) { element.removeEventListener(eventNames[idx], events[name], false); } } } var util = { append: append, arabicToRoman: arabicToRoman, createPromise: createPromise, defined: defined, definitionId: definitionId, deg: deg, encodeBase64: encodeBase64, eventCoordinates: eventCoordinates, eventElement: eventElement, isTransparent: isTransparent, last: last, limitValue: limitValue, mergeSort: mergeSort, promiseAll: promiseAll, rad: rad, round: round, valueOrDefault: valueOrDefault, bindEvents: bindEvents, elementOffset: elementOffset, elementSize: elementSize, elementStyles: elementStyles, unbindEvents: unbindEvents, DEG_TO_RAD: DEG_TO_RAD, MAX_NUM: MAX_NUM, MIN_NUM: MIN_NUM }; var toString = {}.toString; var OptionsStore = Class.extend({ init: function(options, prefix) { var this$1 = this; if (prefix === void 0) { prefix = ""; } this.prefix = prefix; for (var field in options) { var member = options[field]; member = this$1._wrap(member, field); this$1[field] = member; } }, get: function(field) { var parts = field.split("."); var result = this; while (parts.length && result) { var part = parts.shift(); result = result[part]; } return result; }, set: function(field, value) { var current = this.get(field); if (current !== value) { this._set(field, this._wrap(value, field)); this.optionsChange({ field: this.prefix + field, value: value }); } }, _set: function(field, value) { var this$1 = this; var composite = field.indexOf(".") >= 0; var parentObj = this; var fieldName = field; if (composite) { var parts = fieldName.split("."); var prefix = this.prefix; while (parts.length > 1) { fieldName = parts.shift(); prefix += fieldName + "."; var obj = parentObj[fieldName]; if (!obj) { obj = new OptionsStore({}, prefix); obj.addObserver(this$1); parentObj[fieldName] = obj; } parentObj = obj; } fieldName = parts[0]; } parentObj._clear(fieldName); parentObj[fieldName] = value; }, _clear: function(field) { var current = this[field]; if (current && current.removeObserver) { current.removeObserver(this); } }, _wrap: function(object, field) { var type = toString.call(object); var wrapped = object; if (wrapped !== null && defined(wrapped) && type === "[object Object]") { if (!(object instanceof OptionsStore) && !(object instanceof Class)) { wrapped = new OptionsStore(wrapped, this.prefix + field + "."); } wrapped.addObserver(this); } return wrapped; } }); ObserversMixin.extend(OptionsStore.prototype); function setAccessor(field) { return function(value) { if (this[field] !== value) { this[field] = value; this.geometryChange(); } return this; }; } function getAccessor(field) { return function() { return this[field]; }; } function defineAccessors(fn, fields) { for (var i = 0; i < fields.length; i++) { var name = fields[i]; var capitalized = name.charAt(0).toUpperCase() + name.substring(1, name.length); fn["set" + capitalized] = setAccessor(name); fn["get" + capitalized] = getAccessor(name); } } var Matrix = Class.extend({ init: function(a, b, c, d, e, f) { if (a === void 0) { a = 0; } if (b === void 0) { b = 0; } if (c === void 0) { c = 0; } if (d === void 0) { d = 0; } if (e === void 0) { e = 0; } if (f === void 0) { f = 0; } this.a = a; this.b = b; this.c = c; this.d = d; this.e = e; this.f = f; }, multiplyCopy: function(matrix) { return new Matrix( this.a * matrix.a + this.c * matrix.b, this.b * matrix.a + this.d * matrix.b, this.a * matrix.c + this.c * matrix.d, this.b * matrix.c + this.d * matrix.d, this.a * matrix.e + this.c * matrix.f + this.e, this.b * matrix.e + this.d * matrix.f + this.f ); }, invert: function() { var ref = this; var a = ref.a; var b = ref.b; var d = ref.c; var e = ref.d; var g = ref.e; var h = ref.f; var det = a * e - b * d; if (det === 0) { return null; } return new Matrix(e / det, -b / det, -d / det, a / det, (d * h - e * g) / det, (b * g - a * h) / det); }, clone: function() { return new Matrix(this.a, this.b, this.c, this.d, this.e, this.f); }, equals: function(other) { if (!other) { return false; } return this.a === other.a && this.b === other.b && this.c === other.c && this.d === other.d && this.e === other.e && this.f === other.f; }, round: function(precision) { this.a = round(this.a, precision); this.b = round(this.b, precision); this.c = round(this.c, precision); this.d = round(this.d, precision); this.e = round(this.e, precision); this.f = round(this.f, precision); return this; }, toArray: function(precision) { var result = [ this.a, this.b, this.c, this.d, this.e, this.f ]; if (defined(precision)) { for (var i = 0; i < result.length; i++) { result[i] = round(result[i], precision); } } return result; }, toString: function(precision, separator) { if (separator === void 0) { separator = ","; } return this.toArray(precision).join(separator); } }); Matrix.translate = function(x, y) { return new Matrix(1, 0, 0, 1, x, y); }; Matrix.unit = function() { return new Matrix(1, 0, 0, 1, 0, 0); }; Matrix.rotate = function(angle, x, y) { var matrix = new Matrix(); matrix.a = Math.cos(rad(angle)); matrix.b = Math.sin(rad(angle)); matrix.c = -matrix.b; matrix.d = matrix.a; matrix.e = (x - x * matrix.a + y * matrix.b) || 0; matrix.f = (y - y * matrix.a - x * matrix.b) || 0; return matrix; }; Matrix.scale = function(scaleX, scaleY) { return new Matrix(scaleX, 0, 0, scaleY, 0, 0); }; Matrix.IDENTITY = Matrix.unit(); function toMatrix(transformation) { if (transformation && typeof transformation.matrix === "function") { return transformation.matrix(); } return transformation; } var Point = Class.extend({ init: function(x, y) { this.x = x || 0; this.y = y || 0; }, equals: function(other) { return other && other.x === this.x && other.y === this.y; }, clone: function() { return new Point(this.x, this.y); }, rotate: function(angle, origin) { var originPoint = Point.create(origin) || Point.ZERO; return this.transform(Matrix.rotate(angle, originPoint.x, originPoint.y)); }, translate: function(x, y) { this.x += x; this.y += y; this.geometryChange(); return this; }, translateWith: function(point) { return this.translate(point.x, point.y); }, move: function(x, y) { this.x = this.y = 0; return this.translate(x, y); }, scale: function(scaleX, scaleY) { if (scaleY === void 0) { scaleY = scaleX; } this.x *= scaleX; this.y *= scaleY; this.geometryChange(); return this; }, scaleCopy: function(scaleX, scaleY) { return this.clone().scale(scaleX, scaleY); }, transform: function(transformation) { var matrix = toMatrix(transformation); var ref = this; var x = ref.x; var y = ref.y; this.x = matrix.a * x + matrix.c * y + matrix.e; this.y = matrix.b * x + matrix.d * y + matrix.f; this.geometryChange(); return this; }, transformCopy: function(transformation) { var point = this.clone(); if (transformation) { point.transform(transformation); } return point; }, distanceTo: function(point) { var dx = this.x - point.x; var dy = this.y - point.y; return Math.sqrt(dx * dx + dy * dy); }, round: function(digits) { this.x = round(this.x, digits); this.y = round(this.y, digits); this.geometryChange(); return this; }, toArray: function(digits) { var doRound = defined(digits); var x = doRound ? round(this.x, digits) : this.x; var y = doRound ? round(this.y, digits) : this.y; return [ x, y ]; }, toString: function(digits, separator) { if (separator === void 0) { separator = " "; } var ref = this; var x = ref.x; var y = ref.y; if (defined(digits)) { x = round(x, digits); y = round(y, digits); } return x + separator + y; } }); Point.create = function(arg0, arg1) { if (defined(arg0)) { if (arg0 instanceof Point) { return arg0; } else if (arguments.length === 1 && arg0.length === 2) { return new Point(arg0[0], arg0[1]); } return new Point(arg0, arg1); } }; Point.min = function() { var arguments$1 = arguments; var minX = MAX_NUM; var minY = MAX_NUM; for (var i = 0; i < arguments.length; i++) { var point = arguments$1[i]; minX = Math.min(point.x, minX); minY = Math.min(point.y, minY); } return new Point(minX, minY); }; Point.max = function() { var arguments$1 = arguments; var maxX = MIN_NUM; var maxY = MIN_NUM; for (var i = 0; i < arguments.length; i++) { var point = arguments$1[i]; maxX = Math.max(point.x, maxX); maxY = Math.max(point.y, maxY); } return new Point(maxX, maxY); }; Point.minPoint = function() { return new Point(MIN_NUM, MIN_NUM); }; Point.maxPoint = function() { return new Point(MAX_NUM, MAX_NUM); }; if (Object.defineProperties) { Object.defineProperties(Point, { ZERO: { get: function() { return new Point(0, 0); } } }); } defineAccessors(Point.prototype, [ "x", "y" ]); ObserversMixin.extend(Point.prototype); var Size = Class.extend({ init: function(width, height) { this.width = width || 0; this.height = height || 0; }, equals: function(other) { return other && other.width === this.width && other.height === this.height; }, clone: function() { return new Size(this.width, this.height); }, toArray: function(digits) { var doRound = defined(digits); var width = doRound ? round(this.width, digits) : this.width; var height = doRound ? round(this.height, digits) : this.height; return [ width, height ]; } }); Size.create = function(arg0, arg1) { if (defined(arg0)) { if (arg0 instanceof Size) { return arg0; } else if (arguments.length === 1 && arg0.length === 2) { return new Size(arg0[0], arg0[1]); } return new Size(arg0, arg1); } }; if (Object.defineProperties) { Object.defineProperties(Size, { ZERO: { get: function() { return new Size(0, 0); } } }); } defineAccessors(Size.prototype, [ "width", "height" ]); ObserversMixin.extend(Size.prototype); var Rect = Class.extend({ init: function(origin, size) { if (origin === void 0) { origin = new Point(); } if (size === void 0) { size = new Size(); } this.setOrigin(origin); this.setSize(size); }, clone: function() { return new Rect( this.origin.clone(), this.size.clone() ); }, equals: function(other) { return other && other.origin.equals(this.origin) && other.size.equals(this.size); }, setOrigin: function(value) { this._observerField("origin", Point.create(value)); this.geometryChange(); return this; }, getOrigin: function() { return this.origin; }, setSize: function(value) { this._observerField("size", Size.create(value)); this.geometryChange(); return this; }, getSize: function() { return this.size; }, width: function() { return this.size.width; }, height: function() { return this.size.height; }, topLeft: function() { return this.origin.clone(); }, bottomRight: function() { return this.origin.clone().translate(this.width(), this.height()); }, topRight: function() { return this.origin.clone().translate(this.width(), 0); }, bottomLeft: function() { return this.origin.clone().translate(0, this.height()); }, center: function() { return this.origin.clone().translate(this.width() / 2, this.height() / 2); }, bbox: function(matrix) { var tl = this.topLeft().transformCopy(matrix); var tr = this.topRight().transformCopy(matrix); var br = this.bottomRight().transformCopy(matrix); var bl = this.bottomLeft().transformCopy(matrix); return Rect.fromPoints(tl, tr, br, bl); }, transformCopy: function(m) { return Rect.fromPoints( this.topLeft().transform(m), this.bottomRight().transform(m) ); }, expand: function(x, y) { if (y === void 0) { y = x; } this.size.width += 2 * x; this.size.height += 2 * y; this.origin.translate(-x, -y); return this; }, expandCopy: function(x, y) { return this.clone().expand(x, y); }, containsPoint: function(point) { var origin = this.origin; var bottomRight = this.bottomRight(); return !(point.x < origin.x || point.y < origin.y || bottomRight.x < point.x || bottomRight.y < point.y); }, _isOnPath: function(point, width) { var rectOuter = this.expandCopy(width, width); var rectInner = this.expandCopy(-width, -width); return rectOuter.containsPoint(point) && !rectInner.containsPoint(point); } }); Rect.fromPoints = function() { var topLeft = Point.min.apply(null, arguments); var bottomRight = Point.max.apply(null, arguments); var size = new Size( bottomRight.x - topLeft.x, bottomRight.y - topLeft.y ); return new Rect(topLeft, size); }; Rect.union = function(a, b) { return Rect.fromPoints( Point.min(a.topLeft(), b.topLeft()), Point.max(a.bottomRight(), b.bottomRight()) ); }; Rect.intersect = function(a, b) { var rect1 = { left: a.topLeft().x, top: a.topLeft().y, right: a.bottomRight().x, bottom: a.bottomRight().y }; var rect2 = { left: b.topLeft().x, top: b.topLeft().y, right: b.bottomRight().x, bottom: b.bottomRight().y }; if (rect1.left <= rect2.right && rect2.left <= rect1.right && rect1.top <= rect2.bottom && rect2.top <= rect1.bottom) { return Rect.fromPoints( new Point(Math.max(rect1.left, rect2.left), Math.max(rect1.top, rect2.top)), new Point(Math.min(rect1.right, rect2.right), Math.min(rect1.bottom, rect2.bottom)) ); } }; ObserversMixin.extend(Rect.prototype); var Transformation = Class.extend({ init: function(matrix) { if (matrix === void 0) { matrix = Matrix.unit(); } this._matrix = matrix; }, clone: function() { return new Transformation( this._matrix.clone() ); }, equals: function(other) { return other && other._matrix.equals(this._matrix); }, translate: function(x, y) { this._matrix = this._matrix.multiplyCopy(Matrix.translate(x, y)); this._optionsChange(); return this; }, scale: function(scaleX, scaleY, origin) { if (scaleY === void 0) { scaleY = scaleX; } if (origin === void 0) { origin = null; } var originPoint = origin; if (originPoint) { originPoint = Point.create(originPoint); this._matrix = this._matrix.multiplyCopy(Matrix.translate(originPoint.x, originPoint.y)); } this._matrix = this._matrix.multiplyCopy(Matrix.scale(scaleX, scaleY)); if (originPoint) { this._matrix = this._matrix.multiplyCopy(Matrix.translate(-originPoint.x, -originPoint.y)); } this._optionsChange(); return this; }, rotate: function(angle, origin) { var originPoint = Point.create(origin) || Point.ZERO; this._matrix = this._matrix.multiplyCopy(Matrix.rotate(angle, originPoint.x, originPoint.y)); this._optionsChange(); return this; }, multiply: function(transformation) { var matrix = toMatrix(transformation); this._matrix = this._matrix.multiplyCopy(matrix); this._optionsChange(); return this; }, matrix: function(value) { if (value) { this._matrix = value; this._optionsChange(); return this; } return this._matrix; }, _optionsChange: function() { this.optionsChange({ field: "transform", value: this }); } }); ObserversMixin.extend(Transformation.prototype); function transform(matrix) { if (matrix === null) { return null; } if (matrix instanceof Transformation) { return matrix; } return new Transformation(matrix); } var Element$1 = Class.extend({ init: function(options) { this._initOptions(options); }, _initOptions: function(options) { if (options === void 0) { options = {}; } var clip = options.clip; var transform$$1 = options.transform; if (transform$$1) { options.transform = transform(transform$$1); } if (clip && !clip.id) { clip.id = definitionId(); } this.options = new OptionsStore(options); this.options.addObserver(this); }, transform: function(value) { if (defined(value)) { this.options.set("transform", transform(value)); } else { return this.options.get("transform"); } }, parentTransform: function() { var element = this; var parentMatrix; while (element.parent) { element = element.parent; var transformation = element.transform(); if (transformation) { parentMatrix = transformation.matrix().multiplyCopy(parentMatrix || Matrix.unit()); } } if (parentMatrix) { return transform(parentMatrix); } }, currentTransform: function(parentTransform) { if (parentTransform === void 0) { parentTransform = this.parentTransform(); } var elementTransform = this.transform(); var elementMatrix = toMatrix(elementTransform); var parentMatrix = toMatrix(parentTransform); var combinedMatrix; if (elementMatrix && parentMatrix) { combinedMatrix = parentMatrix.multiplyCopy(elementMatrix); } else { combinedMatrix = elementMatrix || parentMatrix; } if (combinedMatrix) { return transform(combinedMatrix); } }, visible: function(value) { if (defined(value)) { this.options.set("visible", value); return this; } return this.options.get("visible") !== false; }, clip: function(value) { var options = this.options; if (defined(value)) { if (value && !value.id) { value.id = definitionId(); } options.set("clip", value); return this; } return options.get("clip"); }, opacity: function(value) { if (defined(value)) { this.options.set("opacity", value); return this; } return valueOrDefault(this.options.get("opacity"), 1); }, clippedBBox: function(transformation) { var bbox = this._clippedBBox(transformation); if (bbox) { var clip = this.clip(); return clip ? Rect.intersect(bbox, clip.bbox(transformation)) : bbox; } }, containsPoint: function(point, parentTransform) { if (this.visible()) { var transform$$1 = this.currentTransform(parentTransform); var transformedPoint = point; if (transform$$1) { transformedPoint = point.transformCopy(transform$$1.matrix().invert()); } return (this._hasFill() && this._containsPoint(transformedPoint)) || (this._isOnPath && this._hasStroke() && this._isOnPath(transformedPoint)); } return false; }, _hasFill: function() { var fill = this.options.fill; return fill && !isTransparent(fill.color); }, _hasStroke: function() { var stroke = this.options.stroke; return stroke && stroke.width > 0 && !isTransparent(stroke.color); }, _clippedBBox: function(transformation) { return this.bbox(transformation); } }); Element$1.prototype.nodeType = "Element"; ObserversMixin.extend(Element$1.prototype); function ellipseExtremeAngles(center, rx, ry, matrix) { var extremeX = 0; var extremeY = 0; if (matrix) { extremeX = Math.atan2(matrix.c * ry, matrix.a * rx); if (matrix.b !== 0) { extremeY = Math.atan2(matrix.d * ry, matrix.b * rx); } } return { x: extremeX, y: extremeY }; } var PI_DIV_2 = Math.PI / 2; var Circle$2 = Class.extend({ init: function(center, radius) { if (center === void 0) { center = new Point(); } if (radius === void 0) { radius = 0; } this.setCenter(center); this.setRadius(radius); }, setCenter: function(value) { this._observerField("center", Point.create(value)); this.geometryChange(); return this; }, getCenter: function() { return this.center; }, equals: function(other) { return other && other.center.equals(this.center) && other.radius === this.radius; }, clone: function() { return new Circle$2(this.center.clone(), this.radius); }, pointAt: function(angle) { return this._pointAt(rad(angle)); }, bbox: function(matrix) { var this$1 = this; var extremeAngles = ellipseExtremeAngles(this.center, this.radius, this.radius, matrix); var minPoint = Point.maxPoint(); var maxPoint = Point.minPoint(); for (var i = 0; i < 4; i++) { var currentPointX = this$1._pointAt(extremeAngles.x + i * PI_DIV_2).transformCopy(matrix); var currentPointY = this$1._pointAt(extremeAngles.y + i * PI_DIV_2).transformCopy(matrix); var currentPoint = new Point(currentPointX.x, currentPointY.y); minPoint = Point.min(minPoint, currentPoint); maxPoint = Point.max(maxPoint, currentPoint); } return Rect.fromPoints(minPoint, maxPoint); }, _pointAt: function(angle) { var ref = this; var center = ref.center; var radius = ref.radius; return new Point( center.x + radius * Math.cos(angle), center.y + radius * Math.sin(angle) ); }, containsPoint: function(point) { var ref = this; var center = ref.center; var radius = ref.radius; var inCircle = Math.pow(point.x - center.x, 2) + Math.pow(point.y - center.y, 2) <= Math.pow(radius, 2); return inCircle; }, _isOnPath: function(point, width) { var ref = this; var center = ref.center; var radius = ref.radius; var pointDistance = center.distanceTo(point); return radius - width <= pointDistance && pointDistance <= radius + width; } }); defineAccessors(Circle$2.prototype, [ "radius" ]); ObserversMixin.extend(Circle$2.prototype); var GRADIENT = "Gradient"; var Paintable = { extend: function(proto) { proto.fill = this.fill; proto.stroke = this.stroke; }, fill: function(color, opacity) { var options = this.options; if (defined(color)) { if (color && color.nodeType !== GRADIENT) { var newFill = { color: color }; if (defined(opacity)) { newFill.opacity = opacity; } options.set("fill", newFill); } else { options.set("fill", color); } return this; } return options.get("fill"); }, stroke: function(color, width, opacity) { if (defined(color)) { this.options.set("stroke.color", color); if (defined(width)) { this.options.set("stroke.width", width); } if (defined(opacity)) { this.options.set("stroke.opacity", opacity); } return this; } return this.options.get("stroke"); } }; var IDENTITY_MATRIX_HASH = Matrix.IDENTITY.toString(); var Measurable = { extend: function(proto) { proto.bbox = this.bbox; proto.geometryChange = this.geometryChange; }, bbox: function(transformation) { var combinedMatrix = toMatrix(this.currentTransform(transformation)); var matrixHash = combinedMatrix ? combinedMatrix.toString() : IDENTITY_MATRIX_HASH; var bbox; if (this._bboxCache && this._matrixHash === matrixHash) { bbox = this._bboxCache.clone(); } else { bbox = this._bbox(combinedMatrix); this._bboxCache = bbox ? bbox.clone() : null; this._matrixHash = matrixHash; } var strokeWidth = this.options.get("stroke.width"); if (strokeWidth && bbox) { bbox.expand(strokeWidth / 2); } return bbox; }, geometryChange: function() { delete this._bboxCache; this.trigger("geometryChange", { element: this }); } }; function geometryAccessor(name) { var fieldName = "_" + name; return function(value) { if (defined(value)) { this._observerField(fieldName, value); this.geometryChange(); return this; } return this[fieldName]; }; } function defineGeometryAccessors(fn, names) { for (var i = 0; i < names.length; i++) { fn[names[i]] = geometryAccessor(names[i]); } } var DEFAULT_STROKE = "#000"; var Circle = Element$1.extend({ init: function(geometry, options) { if (geometry === void 0) { geometry = new Circle$2(); } if (options === void 0) { options = {}; } Element$1.fn.init.call(this, options); this.geometry(geometry); if (!defined(this.options.stroke)) { this.stroke(DEFAULT_STROKE); } }, rawBBox: function() { return this._geometry.bbox(); }, _bbox: function(matrix) { return this._geometry.bbox(matrix); }, _containsPoint: function(point) { return this.geometry().containsPoint(point); }, _isOnPath: function(point) { return this.geometry()._isOnPath(point, this.options.stroke.width / 2); } }); Circle.prototype.nodeType = "Circle"; Paintable.extend(Circle.prototype); Measurable.extend(Circle.prototype); defineGeometryAccessors(Circle.prototype, [ "geometry" ]); var PRECISION = 10; function close(a, b, tolerance) { if (tolerance === void 0) { tolerance = PRECISION; } return round(Math.abs(a - b), tolerance) === 0; } function closeOrLess(a, b, tolerance) { return a < b || close(a, b, tolerance); } function lineIntersection(p0, p1, p2, p3) { var s1x = p1.x - p0.x; var s2x = p3.x - p2.x; var s1y = p1.y - p0.y; var s2y = p3.y - p2.y; var nx = p0.x - p2.x; var ny = p0.y - p2.y; var d = s1x * s2y - s2x * s1y; var s = (s1x * ny - s1y * nx) / d; var t = (s2x * ny - s2y * nx) / d; if (s >= 0 && s <= 1 && t >= 0 && t <= 1) { return new Point(p0.x + t * s1x, p0.y + t * s1y); } } var MAX_INTERVAL = 45; var pow$1 = Math.pow; var Arc$2 = Class.extend({ init: function(center, options) { if (center === void 0) { center = new Point(); } if (options === void 0) { options = {}; } this.setCenter(center); this.radiusX = options.radiusX; this.radiusY = options.radiusY || options.radiusX; this.startAngle = options.startAngle; this.endAngle = options.endAngle; this.anticlockwise = options.anticlockwise || false; this.xRotation = options.xRotation; }, clone: function() { return new Arc$2(this.center, { radiusX: this.radiusX, radiusY: this.radiusY, startAngle: this.startAngle, endAngle: this.endAngle, anticlockwise: this.anticlockwise }); }, setCenter: function(value) { this._observerField("center", Point.create(value)); this.geometryChange(); return this; }, getCenter: function() { return this.center; }, pointAt: function(angle) { var center = this.center; var radian = rad(angle); return new Point( center.x + this.radiusX * Math.cos(radian), center.y + this.radiusY * Math.sin(radian) ); }, curvePoints: function() { var this$1 = this; var startAngle = this.startAngle; var dir = this.anticlockwise ? -1 : 1; var curvePoints = [ this.pointAt(startAngle) ]; var interval = this._arcInterval(); var intervalAngle = interval.endAngle - interval.startAngle; var subIntervalsCount = Math.ceil(intervalAngle / MAX_INTERVAL); var subIntervalAngle = intervalAngle / subIntervalsCount; var currentAngle = startAngle; var transformation; if (this.xRotation) { transformation = transform().rotate(this.xRotation, this.center); } for (var i = 1; i <= subIntervalsCount; i++) { var nextAngle = currentAngle + dir * subIntervalAngle; var points = this$1._intervalCurvePoints(currentAngle, nextAngle, transformation); curvePoints.push(points.cp1, points.cp2, points.p2); currentAngle = nextAngle; } return curvePoints; }, bbox: function(matrix) { var this$1 = this; var interval = this._arcInterval(); var startAngle = interval.startAngle; var endAngle = interval.endAngle; var extremeAngles = ellipseExtremeAngles(this.center, this.radiusX, this.radiusY, matrix); var extremeX = deg(extremeAngles.x); var extremeY = deg(extremeAngles.y); var endPoint = this.pointAt(endAngle).transformCopy(matrix); var currentAngleX = bboxStartAngle(extremeX, startAngle); var currentAngleY = bboxStartAngle(extremeY, startAngle); var currentPoint = this.pointAt(startAngle).transformCopy(matrix); var minPoint = Point.min(currentPoint, endPoint); var maxPoint = Point.max(currentPoint, endPoint); while (currentAngleX < endAngle || currentAngleY < endAngle) { var currentPointX = (void 0); if (currentAngleX < endAngle) { currentPointX = this$1.pointAt(currentAngleX).transformCopy(matrix); currentAngleX += 90; } var currentPointY = (void 0); if (currentAngleY < endAngle) { currentPointY = this$1.pointAt(currentAngleY).transformCopy(matrix); currentAngleY += 90; } currentPoint = new Point(currentPointX.x, currentPointY.y); minPoint = Point.min(minPoint, currentPoint); maxPoint = Point.max(maxPoint, currentPoint); } return Rect.fromPoints(minPoint, maxPoint); }, _arcInterval: function() { var ref = this; var startAngle = ref.startAngle; var endAngle = ref.endAngle; var anticlockwise = ref.anticlockwise; if (anticlockwise) { var oldStart = startAngle; startAngle = endAngle; endAngle = oldStart; } if (startAngle > endAngle || (anticlockwise && startAngle === endAngle)) { endAngle += 360; } return { startAngle: startAngle, endAngle: endAngle }; }, _intervalCurvePoints: function(startAngle, endAngle, transformation) { var p1 = this.pointAt(startAngle); var p2 = this.pointAt(endAngle); var p1Derivative = this._derivativeAt(startAngle); var p2Derivative = this._derivativeAt(endAngle); var t = (rad(endAngle) - rad(startAngle)) / 3; var cp1 = new Point(p1.x + t * p1Derivative.x, p1.y + t * p1Derivative.y); var cp2 = new Point(p2.x - t * p2Derivative.x, p2.y - t * p2Derivative.y); if (transformation) { p1.transform(transformation); p2.transform(transformation); cp1.transform(transformation); cp2.transform(transformation); } return { p1: p1, cp1: cp1, cp2: cp2, p2: p2 }; }, _derivativeAt: function(angle) { var radian = rad(angle); return new Point(-this.radiusX * Math.sin(radian), this.radiusY * Math.cos(radian)); }, containsPoint: function(point) { var interval = this._arcInterval(); var intervalAngle = interval.endAngle - interval.startAngle; var ref = this; var center = ref.center; var radiusX = ref.radiusX; var radiusY = ref.radiusY; var distance = center.distanceTo(point); var angleRad = Math.atan2(point.y - center.y, point.x - center.x); var pointRadius = (radiusX * radiusY) / Math.sqrt(pow$1(radiusX, 2) * pow$1(Math.sin(angleRad), 2) + pow$1(radiusY, 2) * pow$1(Math.cos(angleRad), 2)); var startPoint = this.pointAt(this.startAngle).round(PRECISION); var endPoint = this.pointAt(this.endAngle).round(PRECISION); var intersection = lineIntersection(center, point.round(PRECISION), startPoint, endPoint); var containsPoint; if (intervalAngle < 180) { containsPoint = intersection && closeOrLess(center.distanceTo(intersection), distance) && closeOrLess(distance, pointRadius); } else { var angle = calculateAngle(center.x, center.y, radiusX, radiusY, point.x, point.y); if (angle !== 360) { angle = (360 + angle) % 360; } var inAngleRange = interval.startAngle <= angle && angle <= interval.endAngle; containsPoint = (inAngleRange && closeOrLess(distance, pointRadius)) || (!inAngleRange && (!intersection || intersection.equals(point))); } return containsPoint; }, _isOnPath: function(point, width) { var interval = this._arcInterval(); var center = this.center; var angle = calculateAngle(cent