From 39278364414bc1590f2fc0ac38eb6e651bfa2940 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Tue, 8 Mar 2011 17:19:02 +0000 Subject: [PATCH] Declare functions that work both as getters for beans and also as callalble functions with optional parameters differently, since they do not inject beans anymore if they declare parameters. --- src/basic/Point.js | 26 ++++++++++++++------------ src/path/Path.js | 12 ++++++++---- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/basic/Point.js b/src/basic/Point.js index ab9c1df9..7e384a72 100644 --- a/src/basic/Point.js +++ b/src/basic/Point.js @@ -227,8 +227,9 @@ var Point = this.Point = Base.extend({ * * @param point */ - getAngle: function(point) { - return this.getAngleInRadians(point) * 180 / Math.PI; + getAngle: function(/* point */) { + // Hide point from Bootstrap so it injects bean too + return this.getAngleInRadians(arguments[0]) * 180 / Math.PI; }, setAngle: function(angle) { @@ -241,24 +242,25 @@ var Point = this.Point = Base.extend({ return this; }, - getAngleInRadians: function(point) { - if (point != undefined) { - point = Point.read(arguments); - var div = this.getLength() * point.getLength(); + getAngleInRadians: function(/* point */) { + // Hide point from Bootstrap so it injects bean too + if (arguments[0] === undefined) { + if (this._angle == null) + this._angle = Math.atan2(this.y, this.x); + return this._angle; + } else { + var point = Point.read(arguments), + div = this.getLength() * point.getLength(); if (div == 0) { return NaN; } else { return Math.acos(this.dot(point) / div); } - } else { - if (this._angle == null) - this._angle = Math.atan2(this.y, this.x); - return this._angle; } }, - getAngleInDegrees: function(point) { - return this.getAngle(point); + getAngleInDegrees: function(/* point */) { + return this.getAngle(arguments[0]); }, /** diff --git a/src/path/Path.js b/src/path/Path.js index 5c81ab6b..152f7755 100644 --- a/src/path/Path.js +++ b/src/path/Path.js @@ -693,16 +693,20 @@ var Path = this.Path = PathItem.extend({ /** * The bounding rectangle of the item excluding stroke width. + * @param matrix optional */ - getBounds: function(matrix) { - return getBounds(this, matrix); + getBounds: function(/* matrix */) { + // Pass the matrix hidden from Bootstrap, so it still inject + // getBounds as bean too. + return getBounds(this, arguments[0]); }, /** * The bounding rectangle of the item including stroke width. */ - getStrokeBounds: function(matrix) { - var width = this.getStrokeWidth(), + getStrokeBounds: function(/* matrix */) { + var matrix = arguments[0], // set #getBounds() + width = this.getStrokeWidth(), radius = width / 2, padding = getPenPadding(radius, matrix), join = this.getStrokeJoin(),