diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d14edf8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,22 @@ +# Created by http://gitignore.io + +### SublimeText ### +*.sublime-* + +### vim related ### +*.swp +*.swo + +### OSX related ### +.DS_Store +.AppleDouble +.LSOverride +Icon + +### IDE-related ### +.idea +*.iml + +### Package folders ### +bower_components/ +node_modules/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..db9c526 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,28 @@ +The stylesheet of **angular-image-crop** is written in [LESS](http://lesscss.org/). + +#Setup +1. [Fork this project](https://help.github.com/articles/fork-a-repo) and clone it on your system. +2. Create a new branch out off `master` for your fix/feature. `git checkout new-feature master` + +#Building + +**angular-image-crop.js** and **angular-image-crop.css** uses [Grunt](http://gruntjs.com/) for the build process which you need to have installed on your system. + +Also there are four additional Grunt tasks required to build the library: + +1. [grunt-contrib-copy](https://npmjs.org/package/grunt-contrib-copy) + +2. [grunt-contrib-less](https://www.npmjs.com/package/grunt-contrib-less) + +3. [grunt-contrib-uglify](https://www.npmjs.com/package/grunt-contrib-uglify) + +4. [grunt-contrib-watch](https://www.npmjs.com/package/grunt-contrib-watch) + +To install all the dependencies, run `npm install`. + +Once you have the dependencies installed, run `grunt` from the project directory. This will run the default grunt task which compiles the files in `src` folder and stores them (and their minified forms) into `dist` folder. + +#Things to remember +- Before submitting a patch, rebase your branch on upstream `master` to make life easier for the merger/author. + +- **DO NOT** add the final build files (compiled in `dist` folder) into your commits. It will be compiled again and updated later, once your patch has been merged by the merger/author. diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..0f6e47c --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,64 @@ +module.exports = function (grunt) { + grunt.initConfig({ + 'pkg': grunt.file.readJSON('package.json'), + 'less': { + 'unminified': { + src: ['src/<%= pkg.name %>.less'], + dest: 'dist/<%= pkg.name %>.css' + }, + 'minified': { + options: { + compress: true + }, + src: ['src/<%= pkg.name %>.less'], + dest: 'dist/<%= pkg.name %>.min.css' + } + }, + ngAnnotate: { + 'js': { + options: { + single_quotes: true + }, + src: 'src/<%= pkg.name %>.js', + dest: 'dist/<%= pkg.name %>.js' + } + }, + uglify: { + 'js': { + options: { + toplevel: true, + warnings: true, + compress: true, + mangle: { + reserved: ['BinaryFile', 'EXIF'] + }, + output: { + beautify: false, + preamble: "/* AngularJS Directive - <%= pkg.name %> v<%= pkg.version %> (minified) - license <%= pkg.license %> */", + max_line_len: 120000 + } + }, + src: ['dist/<%= pkg.name %>.js'], + dest: 'dist/<%= pkg.name %>.min.js' + } + }, + watch: { + 'js' : { + files: ['src/**.js'], + tasks: ['ngAnnotate', 'uglify'] + }, + 'less' : { + files: ['src/**.less'], + tasks: ['less'] + } + } + }); + + grunt.loadNpmTasks('grunt-contrib-copy'); + grunt.loadNpmTasks('grunt-contrib-less'); + grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-contrib-watch'); + grunt.loadNpmTasks('grunt-ng-annotate'); + + grunt.registerTask('default', ['less', 'ngAnnotate', 'uglify']); +}; diff --git a/README.md b/README.md index 3737809..2e63709 100644 --- a/README.md +++ b/README.md @@ -14,11 +14,23 @@ I'm attempting to make a self-contained AngularJS Directive which will allow you # Browser Support * IE10+, Android 3+, iOS 6+, basically all modern browsers! +# Installation +Get the library and its stylesheet using one of the following ways: + +1. **Github** + - [unminified] : [angular-angular-image-crop.js](https://raw.githubusercontent.com/andyshora/angular-image-crop/master/dist/angular-image-crop.js) and [angular-image-crop.css](https://raw.githubusercontent.com/andyshora/angular-image-crop/master/dist/angular-image-crop.css) + - [minified] : [angular-image-crop.min.js](https://raw.githubusercontent.com/andyshora/angular-image-crop/master/dist/angular-image-crop.min.js) and [angular-image-crop.min.css](https://raw.githubusercontent.com/andyshora/angular-image-crop/master/dist/angular-image-crop.min.css) + +2. **Bower** + + ``` + bower install angular-image-crop + ``` # Usage -1. Add the dependency : `angular.module('myApp',['ImageCropper'])` -2. Include the stylesheet -3. Initiatlise the directive [see standalone JSBin](http://jsbin.com/fovovu/1/edit?javascript,output) for example code. +1. Include both files inside the `` element +2. Add the dependency : `angular.module('myApp',['ImageCropper'])` +3. Initialise the directive [see standalone JSBin](http://jsbin.com/fovovu/1/edit?javascript,output) for example code. ## Parameters @@ -28,25 +40,31 @@ I'm attempting to make a self-contained AngularJS Directive which will allow you * max-size (integer) - max size of the image, in pixels * shape (string) - the cropping guideline shape (circle/square) * step (bound integer) - the variable which dictates which step the user will see (used for resetting purposes) +* safe-move(string true/false) - allow moving the image under the cropping area without restrictions +* fill-color(string color name / HEX) - the color to fill with the empty space (used with safe-move) * src (bound Blob or base64 string) - scope variable that will be the source image for the crop * result (bound string) - the variable which will have the resulting data uri bound to it * result-blob (bound Blob) - the variable which will have the resulting data as a Blob object * crop (bound boolean) - scope variable that must be set to true when the image is ready to be cropped +* result-format - setting the result file format if different from default "image/png", optional ### Example markup ```html - +> ``` # See a standalone working example diff --git a/bower.json b/bower.json index 1d5da56..12b149f 100644 --- a/bower.json +++ b/bower.json @@ -1,16 +1,23 @@ { "name": "angular-image-crop", - "version": "2.0.0", + "version": "2.0.2", "homepage": "http://andyshora.com/angular-image-cropper.html", "authors": [ "Andy Shora " ], + "contributors": [ + "Ashish Bardhan " + ], "description": "A better way to crop images client-side using AngularJS", "main": [ - "image-crop.js", - "image-crop-styles.css" + "dist/angular-image-crop.min.js", + "dist/angular-image-crop-styles.min.css" + ], + "ignore": [ + "src/*.js", + "CONTRIBUTING.md", + "Gruntfile.js" ], - "ignore": [], "keywords": [ "angular", "angularjs", diff --git a/index.html b/demo/index.html similarity index 87% rename from index.html rename to demo/index.html index 0853b2a..5c63458 100644 --- a/index.html +++ b/demo/index.html @@ -9,49 +9,49 @@ - + - - + + - + - - + +