mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-04-29 09:44:41 +00:00
Small tweaks: normalize whitespace and brackets, make initialization of "classes" consistent.
This commit is contained in:
parent
ca0df1bd15
commit
0394fb94ad
15 changed files with 67 additions and 45 deletions
|
|
@ -1,10 +1,13 @@
|
|||
(function(){
|
||||
(function() {
|
||||
|
||||
var global = this,
|
||||
Canvas = global.Canvas || (global.Canvas = { }),
|
||||
piBy2 = Math.PI * 2;
|
||||
|
||||
if (Canvas.Circle) return;
|
||||
if (Canvas.Circle) {
|
||||
console.warn('Canvas.Circle is already defined.');
|
||||
return;
|
||||
}
|
||||
|
||||
Canvas.Circle = Class.create(Canvas.Object, /** @lends Canvas.Circle.prototype */ {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,13 @@
|
|||
(function(){
|
||||
(function() {
|
||||
|
||||
var Canvas = this.Canvas || (this.Canvas = { });
|
||||
|
||||
if (Canvas.Color) {
|
||||
console.warn('Canvas.Color is already defined.');
|
||||
return;
|
||||
}
|
||||
|
||||
Canvas.Color = Color;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
|
|
@ -70,8 +79,10 @@
|
|||
|
||||
var r = source[0].toString(16);
|
||||
r = (r.length == 1) ? ('0' + r) : r;
|
||||
|
||||
var g = source[1].toString(16);
|
||||
g = (g.length == 1) ? ('0' + g) : g;
|
||||
|
||||
var b = source[2].toString(16);
|
||||
b = (b.length == 1) ? ('0' + b) : b;
|
||||
|
||||
|
|
@ -224,7 +235,7 @@
|
|||
parseInt(g, 16),
|
||||
parseInt(b, 16),
|
||||
1
|
||||
]
|
||||
];
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -238,8 +249,4 @@
|
|||
oColor.setSource(source);
|
||||
return oColor;
|
||||
};
|
||||
|
||||
if (this.Canvas && !this.Canvas.Color) {
|
||||
this.Canvas.Color = Color;
|
||||
}
|
||||
})();
|
||||
|
|
@ -282,7 +282,7 @@
|
|||
width: width + 'px',
|
||||
height: height + 'px'
|
||||
});
|
||||
this._makeElementUnselectable(wrapper);
|
||||
Element.makeUnselectable(wrapper);
|
||||
this.wrapper = wrapper;
|
||||
},
|
||||
|
||||
|
|
@ -369,7 +369,7 @@
|
|||
// if that didn't work, throw error
|
||||
throw CANVAS_INIT_ERROR;
|
||||
}
|
||||
this._makeElementUnselectable(oContainer);
|
||||
Element.makeUnselectable(oContainer);
|
||||
return oContainer;
|
||||
},
|
||||
|
||||
|
|
@ -395,16 +395,6 @@
|
|||
this._oContextBackground = canvas.getContext('2d');
|
||||
},
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @method _makeElementUnselectable
|
||||
*/
|
||||
_makeElementUnselectable: function (element) {
|
||||
if ('onselectstart' in element) {
|
||||
element.onselectstart = Prototype.falseFunction;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns canvas width
|
||||
* @method getWidth
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
(function(){
|
||||
|
||||
var Canvas = this.Canvas || (this.Canvas = { });
|
||||
if (Canvas.Ellipse) return;
|
||||
|
||||
if (Canvas.Ellipse) {
|
||||
console.warn('Canvas.Ellipse is already defined.');
|
||||
return;
|
||||
}
|
||||
|
||||
Canvas.Ellipse = Class.create(Canvas.Object, {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
(function(){
|
||||
|
||||
var Canvas = this.Canvas || (this.Canvas = { });
|
||||
if (Canvas.Group) return;
|
||||
if (Canvas.Group) {
|
||||
return;
|
||||
}
|
||||
|
||||
Canvas.Group = Class.create(Canvas.Object, {
|
||||
|
||||
|
|
@ -41,13 +43,13 @@
|
|||
* @method _updateObjectsCoords
|
||||
*/
|
||||
_updateObjectsCoords: function() {
|
||||
var groupDeltaX = this.left;
|
||||
var groupDeltaY = this.top;
|
||||
var groupDeltaX = this.left,
|
||||
groupDeltaY = this.top;
|
||||
|
||||
this.forEachObject(function(object) {
|
||||
|
||||
var objectLeft = object.get('left');
|
||||
var objectTop = object.get('top');
|
||||
var objectLeft = object.get('left'),
|
||||
objectTop = object.get('top');
|
||||
|
||||
object.set('originalLeft', objectLeft);
|
||||
object.set('originalTop', objectTop);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
(function(){
|
||||
(function() {
|
||||
|
||||
var global = this;
|
||||
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
}
|
||||
|
||||
if (global.Canvas.Image) {
|
||||
console.warn('Canvas.Image is already defined. Skipping');
|
||||
console.warn('Canvas.Image is already defined.');
|
||||
return;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
ub = ub_t / u_b;
|
||||
if (0 <= ua && ua <= 1 && 0 <= ub && ub <= 1) {
|
||||
result = new Intersection("Intersection");
|
||||
result.points.push(new Point(a1.x + ua * (a2.x - a1.x), a1.y + ua * (a2.y - a1.y)));
|
||||
result.points.push(new Canvas.Point(a1.x + ua * (a2.x - a1.x), a1.y + ua * (a2.y - a1.y)));
|
||||
}
|
||||
else {
|
||||
result = new Intersection("No Intersection");
|
||||
|
|
@ -91,8 +91,8 @@
|
|||
Intersection.intersectPolygonRectangle = function (points, r1, r2) {
|
||||
var min = r1.min(r2),
|
||||
max = r1.max(r2),
|
||||
topRight = new Point(max.x, min.y),
|
||||
bottomLeft = new Point(min.x, max.y),
|
||||
topRight = new Canvas.Point(max.x, min.y),
|
||||
bottomLeft = new Canvas.Point(min.x, max.y),
|
||||
inter1 = Intersection.intersectLinePolygon(min, topRight, points),
|
||||
inter2 = Intersection.intersectLinePolygon(topRight, max, points),
|
||||
inter3 = Intersection.intersectLinePolygon(max, bottomLeft, points),
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
(function(){
|
||||
|
||||
var Canvas = this.Canvas || (this.Canvas = { });
|
||||
|
||||
Canvas.IStub = {
|
||||
/**
|
||||
* @method initStub
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
(function(){
|
||||
|
||||
var Canvas = this.Canvas || (this.Canvas = { });
|
||||
if (Canvas.Line) return;
|
||||
if (Canvas.Line) {
|
||||
return;
|
||||
}
|
||||
|
||||
Canvas.Line = Class.create(Canvas.Object, {
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,9 @@
|
|||
* @namespace
|
||||
*/
|
||||
var Canvas = global.Canvas || (global.Canvas = { });
|
||||
if (Canvas.Object) return;
|
||||
if (Canvas.Object) {
|
||||
return;
|
||||
}
|
||||
|
||||
var _slice = Array.prototype.slice;
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,9 @@
|
|||
*/
|
||||
function parseAttributes(element, attributes) {
|
||||
|
||||
if (!element) return;
|
||||
if (!element) {
|
||||
return;
|
||||
}
|
||||
|
||||
var value,
|
||||
parsed,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
(function(){
|
||||
|
||||
var Canvas = this.Canvas || (this.Canvas = { });
|
||||
if (Canvas.PathGroup) return;
|
||||
if (Canvas.PathGroup) {
|
||||
return;
|
||||
}
|
||||
|
||||
Canvas.PathGroup = Class.create(Canvas.Path, Canvas.IStub, Enumerable, {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
(function(){
|
||||
|
||||
var Canvas = this.Canvas || (this.Canvas = { });
|
||||
if (Canvas.Polygon) return;
|
||||
if (Canvas.Polygon) {
|
||||
return;
|
||||
}
|
||||
|
||||
function byX(p) { return p.x }
|
||||
function byY(p) { return p.y }
|
||||
function byX(p) { return p.x; }
|
||||
function byY(p) { return p.y; }
|
||||
|
||||
Canvas.Polygon = Class.create(Canvas.Object, {
|
||||
|
||||
|
|
@ -51,7 +53,7 @@
|
|||
return {
|
||||
x: point.x - this.minX,
|
||||
y: point.y - this.minY
|
||||
}
|
||||
};
|
||||
}, this);
|
||||
},
|
||||
|
||||
|
|
@ -109,8 +111,8 @@
|
|||
*/
|
||||
Canvas.Polygon.fromElement = function(element, options) {
|
||||
if (!element) return null;
|
||||
var points = Canvas.parsePointsAttribute(element.getAttribute('points'));
|
||||
var parsedAttributes = Canvas.parseAttributes(element, Canvas.Polygon.ATTRIBUTE_NAMES);
|
||||
var points = Canvas.parsePointsAttribute(element.getAttribute('points')),
|
||||
parsedAttributes = Canvas.parseAttributes(element, Canvas.Polygon.ATTRIBUTE_NAMES);
|
||||
return new Canvas.Polygon(points, Object.extend(parsedAttributes, options));
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
(function(){
|
||||
|
||||
var Canvas = this.Canvas || (this.Canvas = { });
|
||||
if (Canvas.Polyline) return;
|
||||
if (Canvas.Polyline) {
|
||||
return;
|
||||
}
|
||||
|
||||
Canvas.Polyline = Class.create(Canvas.Object, {
|
||||
|
||||
|
|
@ -87,8 +89,8 @@
|
|||
*/
|
||||
Canvas.Polyline.fromElement = function(element, options) {
|
||||
if (!element) return null;
|
||||
var points = Canvas.parsePointsAttribute(element.getAttribute('points'));
|
||||
var parsedAttributes = Canvas.parseAttributes(element, ATTRIBUTE_NAMES);
|
||||
var points = Canvas.parsePointsAttribute(element.getAttribute('points')),
|
||||
parsedAttributes = Canvas.parseAttributes(element, ATTRIBUTE_NAMES);
|
||||
return new Canvas.Polyline(points, Object.extend(parsedAttributes, options));
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
(function(){
|
||||
|
||||
var Canvas = this.Canvas || (this.Canvas = { });
|
||||
if (Canvas.Rect) return;
|
||||
if (Canvas.Rect) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @class Rect
|
||||
|
|
|
|||
Loading…
Reference in a new issue