Update JSCS to 1.6, fix errors, hook up travis

This commit is contained in:
kangax 2014-08-30 13:18:34 +04:00
parent 392d3e9a7e
commit a3d40878d6
14 changed files with 59 additions and 51 deletions

View file

@ -35,7 +35,6 @@
"validateJSDoc": {
"checkParamNames": true,
"checkRedundantParams": true,
"requireParamTypes": true
}
}

View file

@ -1,7 +1,7 @@
language: node_js
node_js:
- "0.10.29"
script: 'npm run-script build && npm test'
script: 'npm run-script build && npm test && jscs src'
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq libgif-dev libpng-dev libjpeg8-dev libpango1.0-dev libcairo2-dev

View file

@ -40,7 +40,7 @@
"devDependencies": {
"execSync": "0.0.x",
"uglify-js": "2.4.x",
"jscs": "1.5.x",
"jscs": "1.6.x",
"jshint": "2.5.x",
"qunit": "0.7.x",
"istanbul": "0.3.x"

View file

@ -44,7 +44,7 @@ fabric.ElementsParser.prototype._createObject = function(klass, el, index) {
else {
var obj = klass.fromElement(el, this.options);
this.resolveGradient(obj, 'fill');
this.resolveGradient(obj, 'stroke');
this.resolveGradient(obj, 'stroke');
this.reviver && this.reviver(el, obj);
this.instances[index] = obj;
this.checkIfDone();
@ -55,7 +55,7 @@ fabric.ElementsParser.prototype.createCallback = function(index, el) {
var _this = this;
return function(obj) {
_this.resolveGradient(obj, 'fill');
_this.resolveGradient(obj, 'stroke');
_this.resolveGradient(obj, 'stroke');
_this.reviver && _this.reviver(el, obj);
_this.instances[index] = obj;
_this.checkIfDone();
@ -63,16 +63,16 @@ fabric.ElementsParser.prototype.createCallback = function(index, el) {
};
fabric.ElementsParser.prototype.resolveGradient = function(obj, property) {
var instanceFillValue = obj.get(property);
if (!(/^url\(/).test(instanceFillValue)) {
return;
}
var gradientId = instanceFillValue.slice(5, instanceFillValue.length - 1);
if (fabric.gradientDefs[gradientId]) {
obj.set(property,
fabric.Gradient.fromElement(fabric.gradientDefs[gradientId], obj));
}
var instanceFillValue = obj.get(property);
if (!(/^url\(/).test(instanceFillValue)) {
return;
}
var gradientId = instanceFillValue.slice(5, instanceFillValue.length - 1);
if (fabric.gradientDefs[gradientId]) {
obj.set(property,
fabric.Gradient.fromElement(fabric.gradientDefs[gradientId], obj));
}
};
fabric.ElementsParser.prototype.checkIfDone = function() {

View file

@ -100,9 +100,9 @@
data[i + 2] = Math.abs(b - tb);
break;
case 'subtract':
var _r = r-tr;
var _g = g-tg;
var _b = b-tb;
var _r = r - tr,
_g = g - tg,
_b = b - tb;
data[i] = (_r < 0) ? 0 : _r;
data[i + 1] = (_g < 0) ? 0 : _g;

View file

@ -182,10 +182,10 @@
else if (this.gradientUnits === 'objectBoundingBox') {
_convertValuesToPercentUnits(object, coords);
}
commonAttributes = 'id="SVGID_' + this.id +
commonAttributes = 'id="SVGID_' + this.id +
'" gradientUnits="' + this.gradientUnits + '"';
if (this.gradientTransform) {
commonAttributes += ' gradientTransform="matrix(' + this.gradientTransform.join(' ') + ')" ';
commonAttributes += ' gradientTransform="matrix(' + this.gradientTransform.join(' ') + ')" ';
}
if (this.type === 'linear') {
markup = [

View file

@ -45,7 +45,9 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
* @return {String}
*/
getSvgTransform: function() {
if (this.group) return '';
if (this.group) {
return '';
}
var toFixed = fabric.util.toFixed,
angle = this.getAngle(),
vpt = !this.canvas || this.canvas.svgViewportTransformation ? this.getViewportTransform() : [1, 0, 0, 1, 0, 0],
@ -70,9 +72,13 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
' ' +
toFixed(this.scaleY * vpt[3], NUM_FRACTION_DIGITS) +
')'),
addTranslateX = this.type === 'path-group' ? this.width * vpt[0] : 0,
flipXPart = this.flipX ? ' matrix(-1 0 0 1 ' + addTranslateX + ' 0) ' : '',
addTranslateY = this.type === 'path-group' ? this.height * vpt[3] : 0,
flipYPart = this.flipY ? ' matrix(1 0 0 -1 0 ' + addTranslateY + ')' : '';
return [

View file

@ -81,8 +81,8 @@
toSVG: function(reviver) {
var markup = this._createBaseSVGMarkup(), x = 0, y = 0;
if (this.group) {
x = this.left + this.radius;
y = this.top + this.radius;
x = this.left + this.radius;
y = this.top + this.radius;
}
markup.push(
'<circle ',

View file

@ -79,8 +79,8 @@
toSVG: function(reviver) {
var markup = this._createBaseSVGMarkup(), x = 0, y = 0;
if (this.group) {
x = this.left + this.rx;
y = this.top + this.ry;
x = this.left + this.rx;
y = this.top + this.ry;
}
markup.push(
'<ellipse ',
@ -145,7 +145,7 @@
parsedAttributes.left = parsedAttributes.left || 0;
parsedAttributes.top = parsedAttributes.top || 0;
var ellipse = new fabric.Ellipse(extend(parsedAttributes, options));
ellipse.top -= ellipse.ry;

View file

@ -1091,7 +1091,7 @@
if (this.fill.gradientTransform) {
var g = this.fill.gradientTransform;
ctx.transform.apply(ctx, g);
}
}
if (this.fillRule === 'destination-over') {
ctx.fill('evenodd');
}
@ -1133,7 +1133,7 @@
if (this.stroke.gradientTransform) {
var g = this.stroke.gradientTransform;
ctx.transform.apply(ctx, g);
}
}
this._stroke ? this._stroke(ctx) : ctx.stroke();
}
this._removeShadow(ctx);

View file

@ -545,7 +545,7 @@
var path = chunks.join(' ');
markup.push(
//jscs:disable validateIndentation
//jscs:disable validateIndentation
'<path ',
'd="', path,
'" style="', this.getSvgStyles(),

View file

@ -173,7 +173,7 @@
if (points === null) {
return null;
}
return new fabric.Polyline(points, fabric.util.object.extend(parsedAttributes, options), true);
};
/* _FROM_SVG_END_ */

View file

@ -50,7 +50,6 @@
*/
ry: 0,
/**
* Used to specify dash pattern for stroke on this object
* @type Array
@ -175,7 +174,7 @@
if (!this.group) {
x = -this.width / 2;
y = -this.height / 2;
}
}
markup.push(
'<rect ',
'x="', x, '" y="', y,
@ -221,12 +220,12 @@
return null;
}
options = options || { };
var parsedAttributes = fabric.parseAttributes(element, fabric.Rect.ATTRIBUTE_NAMES);
parsedAttributes.left = parsedAttributes.left || 0;
parsedAttributes.top = parsedAttributes.top || 0;
return new fabric.Rect(extend((options ? fabric.util.object.clone(options) : { }), parsedAttributes));
};
/* _FROM_SVG_END_ */

View file

@ -6,7 +6,7 @@
/* Adapted from http://dxr.mozilla.org/mozilla-central/source/content/svg/content/src/nsSVGPathDataParser.cpp
* by Andrea Bogazzi code is under MPL. if you don't have a copy of the license you can take it here
* http://mozilla.org/MPL/2.0/
* http://mozilla.org/MPL/2.0/
*/
function arcToSegments(toX, toY, rx, ry, large, sweep, rotateX) {
var argsString = _join.call(arguments);
@ -32,7 +32,8 @@
var s = Math.sqrt(1 - 0.25 * pl/(rx2 * ry2));
rx *= s;
ry *= s;
} else {
}
else {
root = (large === sweep ? -0.5 : 0.5) *
Math.sqrt( pl /(rx2 * py2 + ry2 * px2));
}
@ -42,11 +43,12 @@
cx1 = cosTh * cx - sinTh * cy + toX / 2,
cy1 = sinTh * cx + cosTh * cy + toY / 2,
mTheta = calcVectorAngle(1, 0, (px - cx) / rx, (py - cy) / ry),
dtheta = calcVectorAngle((px - cx) / rx, (py - cy) / ry, (-px -cx) / rx, (-py -cy) / ry);
dtheta = calcVectorAngle((px - cx) / rx, (py - cy) / ry, (-px - cx) / rx, (-py - cy) / ry);
if (sweep === 0 && dtheta > 0) {
dtheta -= 2 * PI;
} else if (sweep === 1 && dtheta < 0) {
}
else if (sweep === 1 && dtheta < 0) {
dtheta += 2 * PI;
}
@ -72,7 +74,7 @@
if (segmentToBezierCache[argsString2]) {
return segmentToBezierCache[argsString2];
}
var costh2 = Math.cos(th2),
sinth2 = Math.sin(th2),
costh3 = Math.cos(th3),
@ -100,7 +102,8 @@
tb = Math.atan2(vy, vx);
if (tb >= ta) {
return tb - ta;
} else {
}
else {
return 2 * Math.PI - (ta - tb);
}
}
@ -108,8 +111,8 @@
/**
* Draws arc
* @param {CanvasRenderingContext2D} ctx
* @param {Number} x
* @param {Number} y
* @param {Number} fx
* @param {Number} fy
* @param {Array} coords
*/
fabric.util.drawArc = function(ctx, fx, fy, coords) {
@ -121,14 +124,15 @@
tx = coords[5],
ty = coords[6],
segs = [[ ], [ ], [ ], [ ]],
segs_norm = arcToSegments(tx - fx, ty - fy, rx, ry, large, sweep, rot);
for (var i = 0; i < segs_norm.length; i++) {
segs[i][0] = segs_norm[i][0] + fx;
segs[i][1] = segs_norm[i][1] + fy;
segs[i][2] = segs_norm[i][2] + fx;
segs[i][3] = segs_norm[i][3] + fy;
segs[i][4] = segs_norm[i][4] + fx;
segs[i][5] = segs_norm[i][5] + fy;
segsNorm = arcToSegments(tx - fx, ty - fy, rx, ry, large, sweep, rot);
for (var i = 0, len = segsNorm.length; i < len; i++) {
segs[i][0] = segsNorm[i][0] + fx;
segs[i][1] = segsNorm[i][1] + fy;
segs[i][2] = segsNorm[i][2] + fx;
segs[i][3] = segsNorm[i][3] + fy;
segs[i][4] = segsNorm[i][4] + fx;
segs[i][5] = segsNorm[i][5] + fy;
ctx.bezierCurveTo.apply(ctx, segs[i]);
}
};