diff --git a/.npmignore b/.npmignore index 9d0a93ac..a8c29772 100644 --- a/.npmignore +++ b/.npmignore @@ -2,6 +2,8 @@ src/ lib/ dist/all.min.js dist/all.min.js.gz +dist/fabric.min.js +dist/fabric.min.js.gz .DS_Store HEADER.js -build.js \ No newline at end of file +build.js diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 650c3ab0..bc8e9f2f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -34,7 +34,7 @@ If you are sure that it's a bug in Fabric.js or a suggestion, open a new [issue] perfect, but even a simple script demonstrating the error would suffice. You could use [this jsfiddle template](http://jsfiddle.net/fabricjs/Da7SP/) as a starting point. -- **Fabric.js version:** Make sure to specify which version of Fabric.js you are using. The version can be found in [all.js file](https://github.com/kangax/fabric.js/blob/master/dist/all.js#L5) or just by executing `fabric.version` in the browser console. +- **Fabric.js version:** Make sure to specify which version of Fabric.js you are using. The version can be found in [fabric.js file](https://github.com/kangax/fabric.js/blob/master/dist/fabric.js#L5) or just by executing `fabric.version` in the browser console. ## Pull requests diff --git a/README.md b/README.md index cd1a4744..3bc5453c 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ Fabric.js started as a foundation for design editor on [printio.ru](http://print If you use google closure compiler you have to add `sourceMappingURL` manually at the end of the minified file all.min.js (see issue https://code.google.com/p/closure-compiler/issues/detail?id=941). - //# sourceMappingURL=all.min.js.map + //# sourceMappingURL=fabric.min.js.map ### Demos @@ -137,11 +137,11 @@ These are the optional modules that could be specified for inclusion, when build Additional flags for build script are: -- **requirejs** — Makes fabric requirejs AMD-compatible in `dist/all.js`. *Note:* an unminified, requirejs-compatible version is always created in `dist/all.require.js` +- **requirejs** — Makes fabric requirejs AMD-compatible in `dist/fabric.js`. *Note:* an unminified, requirejs-compatible version is always created in `dist/fabric.require.js` - **no-strict** — Strips "use strict" directives from source - **no-svg-export** — Removes svg exporting functionality - **no-es5-compat** - Removes ES5 compat methods (Array.prototype.*, String.prototype.*, Function.prototype.*) -- **sourcemap** - Generates a sourceMap file and adds the `sourceMappingURL` (only if uglifyjs is used) to `dist/all.min.js` +- **sourcemap** - Generates a sourceMap file and adds the `sourceMappingURL` (only if uglifyjs is used) to `dist/fabric.min.js` For example: @@ -158,11 +158,11 @@ For example: - + -``` +``` ### Helping Fabric diff --git a/build.js b/build.js index 8d8daee3..f813b7c5 100644 --- a/build.js +++ b/build.js @@ -43,17 +43,17 @@ if (sourceMap) { console.log('[notice]: sourceMap support requires uglifyjs or google closure compiler as minifier; changed minifier to uglifyjs.'); minifier = 'uglifyjs'; } - sourceMapFlags = minifier === 'uglifyjs' ? ' --source-map all.min.js.map' : ' --create_source_map all.min.js.map --source_map_format=V3'; + sourceMapFlags = minifier === 'uglifyjs' ? ' --source-map fabric.min.js.map' : ' --create_source_map fabric.min.js.map --source_map_format=V3'; } if (minifier === 'yui') { - mininfierCmd = 'java -jar ' + rootPath + '/lib/yuicompressor-2.4.6.jar all.js -o all.min.js'; + mininfierCmd = 'java -jar ' + rootPath + '/lib/yuicompressor-2.4.6.jar fabric.js -o fabric.min.js'; } else if (minifier === 'closure') { - mininfierCmd = 'java -jar ' + rootPath + '/lib/google_closure_compiler.jar --js all.js --js_output_file all.min.js' + sourceMapFlags; + mininfierCmd = 'java -jar ' + rootPath + '/lib/google_closure_compiler.jar --js fabric.js --js_output_file fabric.min.js' + sourceMapFlags; } else if (minifier === 'uglifyjs') { - mininfierCmd = 'uglifyjs ' + amdUglifyFlags + ' --output all.min.js all.js' + sourceMapFlags; + mininfierCmd = 'uglifyjs ' + amdUglifyFlags + ' --output fabric.min.js fabric.js' + sourceMapFlags; } var buildSh = 'build-sh' in buildArgsAsObject; @@ -285,7 +285,7 @@ else { process.chdir(distributionPath); appendFileContents(filesToInclude, function() { - fs.writeFile('all.js', distFileContents, function (err) { + fs.writeFile('fabric.js', distFileContents, function (err) { if (err) { console.log(err); throw err; @@ -293,13 +293,13 @@ else { // add js wrapping in AMD closure for requirejs if necessary if (amdLib !== false) { - exec('uglifyjs all.js ' + amdUglifyFlags + ' -b --output all.js'); + exec('uglifyjs fabric.js ' + amdUglifyFlags + ' -b --output fabric.js'); } if (amdLib !== false) { - console.log('Built distribution to ' + distributionPath + 'all.js (' + amdLib + '-compatible)'); + console.log('Built distribution to ' + distributionPath + 'fabric.js (' + amdLib + '-compatible)'); } else { - console.log('Built distribution to ' + distributionPath + 'all.js'); + console.log('Built distribution to ' + distributionPath + 'fabric.js'); } exec(mininfierCmd, function (error, output) { @@ -307,18 +307,18 @@ else { console.error('Minification failed using', minifier, 'with', mininfierCmd); process.exit(1); } - console.log('Minified using', minifier, 'to ' + distributionPath + 'all.min.js'); + console.log('Minified using', minifier, 'to ' + distributionPath + 'fabric.min.js'); if (sourceMapFlags) { - console.log('Built sourceMap to ' + distributionPath + 'all.min.js.map'); + console.log('Built sourceMap to ' + distributionPath + 'fabric.min.js.map'); } - exec('gzip -c all.min.js > all.min.js.gz', function (error, output) { - console.log('Gzipped to ' + distributionPath + 'all.min.js.gz'); + exec('gzip -c fabric.min.js > fabric.min.js.gz', function (error, output) { + console.log('Gzipped to ' + distributionPath + 'fabric.min.js.gz'); }); }); - // Always build requirejs AMD module in all.require.js + // Always build requirejs AMD module in fabric.require.js // add necessary requirejs footer code to filesToInclude if we haven't before if (amdLib === false) { amdLib = "requirejs"; @@ -326,13 +326,13 @@ else { } appendFileContents(filesToInclude, function() { - fs.writeFile('all.require.js', distFileContents, function (err) { + fs.writeFile('fabric.require.js', distFileContents, function (err) { if (err) { console.log(err); throw err; } - exec('uglifyjs all.require.js ' + amdUglifyFlags + ' -b --output all.require.js'); - console.log('Built distribution to ' + distributionPath + 'all.require.js (requirejs-compatible)'); + exec('uglifyjs fabric.require.js ' + amdUglifyFlags + ' -b --output fabric.require.js'); + console.log('Built distribution to ' + distributionPath + 'fabric.require.js (requirejs-compatible)'); }); }); diff --git a/component.json b/component.json index a0b73bbf..bf19c973 100644 --- a/component.json +++ b/component.json @@ -8,6 +8,6 @@ "development": {}, "license": "MIT", "scripts": [ - "./dist/all.js" + "./dist/fabric.js" ] } diff --git a/dist/all.js b/dist/fabric.js similarity index 99% rename from dist/all.js rename to dist/fabric.js index 1f41db98..24c78a0b 100644 --- a/dist/all.js +++ b/dist/fabric.js @@ -3764,167 +3764,167 @@ fabric.ElementsParser = { })(typeof exports !== 'undefined' ? exports : this); -(function(global) { - - "use strict"; - - /* Adaptation of work of Kevin Lindsey (kevin@kevlindev.com) */ - - var fabric = global.fabric || (global.fabric = { }); - - if (fabric.Intersection) { - fabric.warn('fabric.Intersection is already defined'); - return; - } - - /** - * Intersection class - * @class fabric.Intersection - * @memberOf fabric - * @constructor - */ - function Intersection(status) { - this.status = status; - this.points = []; - } - - fabric.Intersection = Intersection; - - fabric.Intersection.prototype = /** @lends fabric.Intersection.prototype */ { - - /** - * Appends a point to intersection - * @param {fabric.Point} point - */ - appendPoint: function (point) { - this.points.push(point); - }, - - /** - * Appends points to intersection - * @param {Array} points - */ - appendPoints: function (points) { - this.points = this.points.concat(points); - } - }; - - /** - * Checks if one line intersects another - * @static - * @param {fabric.Point} a1 - * @param {fabric.Point} a2 - * @param {fabric.Point} b1 - * @param {fabric.Point} b2 - * @return {fabric.Intersection} - */ - fabric.Intersection.intersectLineLine = function (a1, a2, b1, b2) { - var result, - ua_t = (b2.x - b1.x) * (a1.y - b1.y) - (b2.y - b1.y) * (a1.x - b1.x), - ub_t = (a2.x - a1.x) * (a1.y - b1.y) - (a2.y - a1.y) * (a1.x - b1.x), - u_b = (b2.y - b1.y) * (a2.x - a1.x) - (b2.x - b1.x) * (a2.y - a1.y); - if (u_b !== 0) { - var ua = ua_t / u_b, - ub = ub_t / u_b; - if (0 <= ua && ua <= 1 && 0 <= ub && ub <= 1) { - result = new Intersection("Intersection"); - result.points.push(new fabric.Point(a1.x + ua * (a2.x - a1.x), a1.y + ua * (a2.y - a1.y))); - } - else { - result = new Intersection(); - } - } - else { - if (ua_t === 0 || ub_t === 0) { - result = new Intersection("Coincident"); - } - else { - result = new Intersection("Parallel"); - } - } - return result; - }; - - /** - * Checks if line intersects polygon - * @static - * @param {fabric.Point} a1 - * @param {fabric.Point} a2 - * @param {Array} points - * @return {fabric.Intersection} - */ - fabric.Intersection.intersectLinePolygon = function(a1,a2,points){ - var result = new Intersection(), - length = points.length; - - for (var i = 0; i < length; i++) { - var b1 = points[i], - b2 = points[(i+1) % length], - inter = Intersection.intersectLineLine(a1, a2, b1, b2); - - result.appendPoints(inter.points); - } - if (result.points.length > 0) { - result.status = "Intersection"; - } - return result; - }; - - /** - * Checks if polygon intersects another polygon - * @static - * @param {Array} points1 - * @param {Array} points2 - * @return {fabric.Intersection} - */ - fabric.Intersection.intersectPolygonPolygon = function (points1, points2) { - var result = new Intersection(), - length = points1.length; - - for (var i = 0; i < length; i++) { - var a1 = points1[i], - a2 = points1[(i+1) % length], - inter = Intersection.intersectLinePolygon(a1, a2, points2); - - result.appendPoints(inter.points); - } - if (result.points.length > 0) { - result.status = "Intersection"; - } - return result; - }; - - /** - * Checks if polygon intersects rectangle - * @static - * @param {Array} points - * @param {Number} r1 - * @param {Number} r2 - * @return {fabric.Intersection} - */ - fabric.Intersection.intersectPolygonRectangle = function (points, r1, r2) { - var min = r1.min(r2), - max = r1.max(r2), - topRight = new fabric.Point(max.x, min.y), - bottomLeft = new fabric.Point(min.x, max.y), - inter1 = Intersection.intersectLinePolygon(min, topRight, points), - inter2 = Intersection.intersectLinePolygon(topRight, max, points), - inter3 = Intersection.intersectLinePolygon(max, bottomLeft, points), - inter4 = Intersection.intersectLinePolygon(bottomLeft, min, points), - result = new Intersection(); - - result.appendPoints(inter1.points); - result.appendPoints(inter2.points); - result.appendPoints(inter3.points); - result.appendPoints(inter4.points); - - if (result.points.length > 0) { - result.status = "Intersection"; - } - return result; - }; - -})(typeof exports !== 'undefined' ? exports : this); +(function(global) { + + "use strict"; + + /* Adaptation of work of Kevin Lindsey (kevin@kevlindev.com) */ + + var fabric = global.fabric || (global.fabric = { }); + + if (fabric.Intersection) { + fabric.warn('fabric.Intersection is already defined'); + return; + } + + /** + * Intersection class + * @class fabric.Intersection + * @memberOf fabric + * @constructor + */ + function Intersection(status) { + this.status = status; + this.points = []; + } + + fabric.Intersection = Intersection; + + fabric.Intersection.prototype = /** @lends fabric.Intersection.prototype */ { + + /** + * Appends a point to intersection + * @param {fabric.Point} point + */ + appendPoint: function (point) { + this.points.push(point); + }, + + /** + * Appends points to intersection + * @param {Array} points + */ + appendPoints: function (points) { + this.points = this.points.concat(points); + } + }; + + /** + * Checks if one line intersects another + * @static + * @param {fabric.Point} a1 + * @param {fabric.Point} a2 + * @param {fabric.Point} b1 + * @param {fabric.Point} b2 + * @return {fabric.Intersection} + */ + fabric.Intersection.intersectLineLine = function (a1, a2, b1, b2) { + var result, + ua_t = (b2.x - b1.x) * (a1.y - b1.y) - (b2.y - b1.y) * (a1.x - b1.x), + ub_t = (a2.x - a1.x) * (a1.y - b1.y) - (a2.y - a1.y) * (a1.x - b1.x), + u_b = (b2.y - b1.y) * (a2.x - a1.x) - (b2.x - b1.x) * (a2.y - a1.y); + if (u_b !== 0) { + var ua = ua_t / u_b, + ub = ub_t / u_b; + if (0 <= ua && ua <= 1 && 0 <= ub && ub <= 1) { + result = new Intersection("Intersection"); + result.points.push(new fabric.Point(a1.x + ua * (a2.x - a1.x), a1.y + ua * (a2.y - a1.y))); + } + else { + result = new Intersection(); + } + } + else { + if (ua_t === 0 || ub_t === 0) { + result = new Intersection("Coincident"); + } + else { + result = new Intersection("Parallel"); + } + } + return result; + }; + + /** + * Checks if line intersects polygon + * @static + * @param {fabric.Point} a1 + * @param {fabric.Point} a2 + * @param {Array} points + * @return {fabric.Intersection} + */ + fabric.Intersection.intersectLinePolygon = function(a1,a2,points){ + var result = new Intersection(), + length = points.length; + + for (var i = 0; i < length; i++) { + var b1 = points[i], + b2 = points[(i+1) % length], + inter = Intersection.intersectLineLine(a1, a2, b1, b2); + + result.appendPoints(inter.points); + } + if (result.points.length > 0) { + result.status = "Intersection"; + } + return result; + }; + + /** + * Checks if polygon intersects another polygon + * @static + * @param {Array} points1 + * @param {Array} points2 + * @return {fabric.Intersection} + */ + fabric.Intersection.intersectPolygonPolygon = function (points1, points2) { + var result = new Intersection(), + length = points1.length; + + for (var i = 0; i < length; i++) { + var a1 = points1[i], + a2 = points1[(i+1) % length], + inter = Intersection.intersectLinePolygon(a1, a2, points2); + + result.appendPoints(inter.points); + } + if (result.points.length > 0) { + result.status = "Intersection"; + } + return result; + }; + + /** + * Checks if polygon intersects rectangle + * @static + * @param {Array} points + * @param {Number} r1 + * @param {Number} r2 + * @return {fabric.Intersection} + */ + fabric.Intersection.intersectPolygonRectangle = function (points, r1, r2) { + var min = r1.min(r2), + max = r1.max(r2), + topRight = new fabric.Point(max.x, min.y), + bottomLeft = new fabric.Point(min.x, max.y), + inter1 = Intersection.intersectLinePolygon(min, topRight, points), + inter2 = Intersection.intersectLinePolygon(topRight, max, points), + inter3 = Intersection.intersectLinePolygon(max, bottomLeft, points), + inter4 = Intersection.intersectLinePolygon(bottomLeft, min, points), + result = new Intersection(); + + result.appendPoints(inter1.points); + result.appendPoints(inter2.points); + result.appendPoints(inter3.points); + result.appendPoints(inter4.points); + + if (result.points.length > 0) { + result.status = "Intersection"; + } + return result; + }; + +})(typeof exports !== 'undefined' ? exports : this); (function(global) { diff --git a/dist/all.min.js b/dist/fabric.min.js similarity index 100% rename from dist/all.min.js rename to dist/fabric.min.js diff --git a/dist/all.min.js.gz b/dist/fabric.min.js.gz similarity index 99% rename from dist/all.min.js.gz rename to dist/fabric.min.js.gz index aa9456a6..2272798d 100644 Binary files a/dist/all.min.js.gz and b/dist/fabric.min.js.gz differ diff --git a/dist/all.require.js b/dist/fabric.require.js similarity index 100% rename from dist/all.require.js rename to dist/fabric.require.js diff --git a/package.json b/package.json index efb8d684..228ffe91 100644 --- a/package.json +++ b/package.json @@ -26,5 +26,5 @@ "plato": "0.6.x" }, "engines": { "node": ">=0.4.0 && <1.0.0" }, - "main": "./dist/all.js" + "main": "./dist/fabric.js" } diff --git a/test.js b/test.js index cb9589b9..8791e129 100644 --- a/test.js +++ b/test.js @@ -6,7 +6,7 @@ testrunner.options.log.assertions = false; testrunner.run({ deps: "./test/fixtures/test_script.js", - code: "./dist/all.js", + code: "./dist/fabric.js", tests: [ './test/unit/rect.js', './test/unit/ellipse.js',