Merge pull request #1496 from Kienz/jsdocFixes

JSDoc + JSCS tweaks - Part 1
This commit is contained in:
Juriy Zaytsev 2014-07-17 18:52:54 +02:00
commit 2c6cafe34f
15 changed files with 61 additions and 56 deletions

View file

@ -444,8 +444,8 @@
/**
* Translates object by "setting" its left/top
* @private
* @param x {Number} pointer's x coordinate
* @param y {Number} pointer's y coordinate
* @param {Number} x pointer's x coordinate
* @param {Number} y pointer's y coordinate
*/
_translateObject: function (x, y) {
var target = this._currentTransform.target;
@ -461,9 +461,9 @@
/**
* Scales object by invoking its scaleX/scaleY methods
* @private
* @param x {Number} pointer's x coordinate
* @param y {Number} pointer's y coordinate
* @param by {String} Either 'x' or 'y' - specifies dimension constraint by which to scale an object.
* @param {Number} x pointer's x coordinate
* @param {Number} y pointer's y coordinate
* @param {String} by Either 'x' or 'y' - specifies dimension constraint by which to scale an object.
* When not provided, an object is scaled by both dimensions equally
*/
_scaleObject: function (x, y, by) {
@ -843,7 +843,6 @@
/**
* @private
* @param {HTMLElement|String} canvasEl Canvas element
* @throws {CANVAS_INIT_ERROR} If canvas can not be initialized
*/
_createUpperCanvas: function () {
@ -871,8 +870,6 @@
/**
* @private
* @param {Number} width
* @param {Number} height
*/
_initWrapperElement: function () {
this.wrapperEl = fabric.util.wrapElement(this.lowerCanvasEl, 'div', {
@ -888,7 +885,7 @@
/**
* @private
* @param {Element} element
* @param {HTMLElement} element canvas element to apply styles on
*/
_applyCanvasStyle: function (element) {
var width = this.getWidth() || element.width,

View file

@ -367,28 +367,32 @@
* @private
*/
function parseUseDirectives(doc) {
var nodelist = doc.querySelectorAll("use");
for (var i = 0; i < nodelist.length; i++) {
var el = nodelist[i];
var xlink = el.getAttribute('xlink:href').substr(1);
var x = el.getAttribute('x') || 0;
var y = el.getAttribute('y') || 0;
var el2 = doc.getElementById(xlink).cloneNode(true);
var currentTrans = (el.getAttribute('transform') || '') + ' translate(' + x + ', ' + y + ')';
var nodelist = doc.querySelectorAll('use');
for (var i = 0, len = nodelist.length; i < len; i++) {
var el = nodelist[i],
xlink = el.getAttribute('xlink:href').substr(1),
x = el.getAttribute('x') || 0,
y = el.getAttribute('y') || 0,
el2 = doc.getElementById(xlink).cloneNode(true),
currentTrans = (el.getAttribute('transform') || '') + ' translate(' + x + ', ' + y + ')',
parentNode;
for (var j = 0, attrs = el.attributes, l = attrs.length; j < l; j++) {
var attr = attrs.item(j);
if (attr.nodeName !== 'x' && attr.nodeName !== 'y' && attr.nodeName !== 'xlink:href') {
if (attr.nodeName === 'transform') {
currentTrans = currentTrans + ' ' + attr.nodeValue;
} else {
el2.setAttribute(attr.nodeName, attr.nodeValue);
}
if (attr.nodeName === 'x' || attr.nodeName === 'y' || attr.nodeName === 'xlink:href') continue;
if (attr.nodeName === 'transform') {
currentTrans = currentTrans + ' ' + attr.nodeValue;
}
else {
el2.setAttribute(attr.nodeName, attr.nodeValue);
}
}
el2.setAttribute('transform', currentTrans);
el2.removeAttribute('id');
var pNode=el.parentNode;
pNode.replaceChild(el2, el);
parentNode = el.parentNode;
parentNode.replaceChild(el2, el);
}
}
@ -519,18 +523,10 @@
callback(false);
},
/**
* @param {String} url
* @param {Function} callback
*/
get: function () {
/* NOOP */
},
/**
* @param {String} url
* @param {Object} object
*/
set: function () {
/* NOOP */
}
@ -704,7 +700,7 @@
* Parses "points" attribute, returning an array of values
* @static
* @memberOf fabric
* @param points {String} points attribute string
* @param {String} points points attribute string
* @return {Array} array of points
*/
parsePointsAttribute: function(points) {

View file

@ -63,7 +63,7 @@
/**
* Adds value to this point
* @param {Number} scalar
* @param {fabric.Point} thisArg
* @return {fabric.Point} thisArg
*/
scalarAddEquals: function (scalar) {
this.x += scalar;

View file

@ -96,7 +96,8 @@
/**
* @private
* @param ctx {CanvasRenderingContext2D} context to render on
* @param {CanvasRenderingContext2D} ctx context to render on
* @param {Boolean} [noTransform] When true, context is not transformed
*/
_render: function(ctx, noTransform) {
ctx.beginPath();

View file

@ -94,8 +94,8 @@
/**
* Renders this instance on a given context
* @param ctx {CanvasRenderingContext2D} context to render on
* @param noTransform {Boolean} context is not transformed when set to true
* @param {CanvasRenderingContext2D} ctx context to render on
* @param {Boolean} [noTransform] When true, context is not transformed
*/
render: function(ctx, noTransform) {
// do not use `get` for perf. reasons
@ -105,7 +105,8 @@
/**
* @private
* @param ctx {CanvasRenderingContext2D} context to render on
* @param {CanvasRenderingContext2D} ctx context to render on
* @param {Boolean} [noTransform] When true, context is not transformed
*/
_render: function(ctx, noTransform) {
ctx.beginPath();

View file

@ -523,7 +523,7 @@
* @static
* @memberOf fabric.Group
* @param {Object} object Object to create a group from
* @param {Object} [options] Options object
* @param {Function} [callback] Callback to invoke when an group instance is created
* @return {fabric.Group} An instance of fabric.Group
*/
fabric.Group.fromObject = function(object, callback) {

View file

@ -635,7 +635,9 @@
* @private
* @param {String} method
* @param {CanvasRenderingContext2D} ctx Context to render on
* @param {String} line
* @param {String} line Content of the line
* @param {Number} left Left coordinate
* @param {Number} top Top coordinate
*/
_renderCharsFast: function(method, ctx, line, left, top) {
this.skipTextAlign = false;
@ -650,7 +652,14 @@
/**
* @private
* @param {String} method
* @param {CanvasRenderingContext2D} ctx Context to render on
* @param {Number} lineIndex
* @param {Number} i
* @param {String} _char
* @param {Number} left Left coordinate
* @param {Number} top Top coordinate
* @param {Number} lineHeight Height of the line
*/
_renderChar: function(method, ctx, lineIndex, i, _char, left, top, lineHeight) {
var decl, charWidth, charHeight;
@ -1069,6 +1078,7 @@
/**
* @private
* @param {CanvasRenderingContext2D} ctx Context to render on
* @param {Array} textLines Array of all text lines
*/
_getTextHeight: function(ctx, textLines) {
var height = 0;
@ -1080,7 +1090,6 @@
/**
* @private
* @param {CanvasRenderingContext2D} ctx Context to render on
*/
_getTopOffset: function() {
var topOffset = fabric.Text.prototype._getTopOffset.call(this);

View file

@ -1125,7 +1125,7 @@
/**
* Creates an instance of fabric.Image out of an object
* @param callback {Function} callback, invoked with an instance as a first argument
* @param {Function} callback callback, invoked with an instance as a first argument
* @return {fabric.Object} thisArg
*/
cloneAsImage: function(callback) {
@ -1195,7 +1195,7 @@
/**
* Returns true if specified type is identical to the type of an instance
* @param type {String} type Type to check against
* @param {String} type Type to check against
* @return {Boolean}
*/
isType: function(type) {

View file

@ -142,7 +142,8 @@
/**
* @private
* @param {Boolean} positionSet When false, path offset is returned otherwise 0
* @param {Number} origLeft Original left position
* @param {Number} origTop Original top position
*/
_calculatePathOffset: function (origLeft, origTop) {
return {

View file

@ -77,7 +77,7 @@
ctx.save();
var m = this.transformMatrix;
if (m) {
ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
}

View file

@ -197,7 +197,7 @@
* Returns fabric.Polygon instance from an object representation
* @static
* @memberOf fabric.Polygon
* @param object {Object} object Object to create an instance from
* @param {Object} object Object to create an instance from
* @return {fabric.Polygon} Instance of fabric.Polygon
*/
fabric.Polygon.fromObject = function(object) {

View file

@ -179,7 +179,7 @@
* Returns fabric.Polyline instance from an object representation
* @static
* @memberOf fabric.Polyline
* @param object {Object} object Object to create an instance from
* @param {Object} object Object to create an instance from
* @return {fabric.Polyline} Instance of fabric.Polyline
*/
fabric.Polyline.fromObject = function(object) {

View file

@ -98,7 +98,7 @@
/**
* @private
* @param ctx {CanvasRenderingContext2D} context to render on
* @param {CanvasRenderingContext2D} ctx Context to render on
*/
_render: function(ctx) {
@ -154,7 +154,7 @@
/**
* @private
* @param ctx {CanvasRenderingContext2D} context to render on
* @param {CanvasRenderingContext2D} ctx Context to render on
*/
_renderDashedStroke: function(ctx) {
var x = -this.width / 2,
@ -280,7 +280,7 @@
* Returns {@link fabric.Rect} instance from an object representation
* @static
* @memberOf fabric.Rect
* @param object {Object} object to create an instance from
* @param {Object} object Object to create an instance from
* @return {Object} instance of fabric.Rect
*/
fabric.Rect.fromObject = function(object) {

View file

@ -484,7 +484,7 @@
* @private
* @param {String} method Method name ("fillText" or "strokeText")
* @param {CanvasRenderingContext2D} ctx Context to render on
* @param {String} line Chars to render
* @param {String} chars Chars to render
* @param {Number} left Left position of text
* @param {Number} top Top position of text
*/
@ -1107,7 +1107,7 @@
* Returns fabric.Text instance from an object representation
* @static
* @memberOf fabric.Text
* @param object {Object} object Object to create an instance from
* @param {Object} object Object to create an instance from
* @return {fabric.Text} Instance of fabric.Text
*/
fabric.Text.fromObject = function(object) {

View file

@ -41,7 +41,7 @@
/**
* @private
* @param ctx {CanvasRenderingContext2D} Context to render on
* @param {CanvasRenderingContext2D} ctx Context to render on
*/
_render: function(ctx) {
var widthBy2 = this.width / 2,
@ -59,7 +59,7 @@
/**
* @private
* @param ctx {CanvasRenderingContext2D} Context to render on
* @param {CanvasRenderingContext2D} ctx Context to render on
*/
_renderDashedStroke: function(ctx) {
var widthBy2 = this.width / 2,
@ -114,7 +114,7 @@
* Returns fabric.Triangle instance from an object representation
* @static
* @memberOf fabric.Triangle
* @param object {Object} object to create an instance from
* @param {Object} object Object to create an instance from
* @return {Object} instance of Canvas.Triangle
*/
fabric.Triangle.fromObject = function(object) {