Skip to content

Commit 1276581

Browse files
committed
Make this library 'developer-friendly'
- merge pull request andyshora#31
1 parent 10827f8 commit 1276581

File tree

11 files changed

+260
-44
lines changed

11 files changed

+260
-44
lines changed

.gitignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Created by http://gitignore.io
2+
3+
### SublimeText ###
4+
*.sublime-*
5+
6+
### vim related ###
7+
*.swp
8+
*.swo
9+
10+
### OSX related ###
11+
.DS_Store
12+
.AppleDouble
13+
.LSOverride
14+
Icon
15+
16+
### IDE-related ###
17+
.idea
18+
*.iml
19+
20+
### Package folders ###
21+
bower_components/
22+
node_modules/

CONTRIBUTING.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
The stylesheet of **angular-image-crop** is written in [LESS](http://lesscss.org/).
2+
3+
#Setup
4+
1. [Fork this project](https://help.github.com/articles/fork-a-repo) and clone it on your system.
5+
2. Create a new branch out off `master` for your fix/feature. `git checkout new-feature master`
6+
7+
#Building
8+
9+
**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.
10+
11+
Also there are four additional Grunt tasks required to build the library:
12+
13+
1. [grunt-contrib-copy](https://npmjs.org/package/grunt-contrib-copy)
14+
15+
2. [grunt-contrib-less](https://www.npmjs.com/package/grunt-contrib-less)
16+
17+
3. [grunt-contrib-uglify](https://www.npmjs.com/package/grunt-contrib-uglify)
18+
19+
4. [grunt-contrib-watch](https://www.npmjs.com/package/grunt-contrib-watch)
20+
21+
To install all the dependencies, run `npm install`.
22+
23+
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.
24+
25+
#Things to remember
26+
- Before submitting a patch, rebase your branch on upstream `master` to make life easier for the merger/author.
27+
28+
- **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.

Gruntfile.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
module.exports = function (grunt) {
2+
grunt.initConfig({
3+
'pkg': grunt.file.readJSON('package.json'),
4+
'less': {
5+
'unminified': {
6+
src: ['src/<%= pkg.name %>.less'],
7+
dest: 'dist/<%= pkg.name %>.css'
8+
},
9+
'minified': {
10+
options: {
11+
compress: true
12+
},
13+
src: ['src/<%= pkg.name %>.less'],
14+
dest: 'dist/<%= pkg.name %>.min.css'
15+
}
16+
},
17+
ngAnnotate: {
18+
'js': {
19+
options: {
20+
single_quotes: true
21+
},
22+
src: 'src/<%= pkg.name %>.js',
23+
dest: 'dist/<%= pkg.name %>.js'
24+
}
25+
},
26+
uglify: {
27+
'js': {
28+
options: {
29+
toplevel: true,
30+
warnings: true,
31+
compress: true,
32+
output: {
33+
beautify: false,
34+
preamble: "/* AngularJS Directive - <%= pkg.name %> v<%= pkg.version %> (minified) - license <%= pkg.license %> */",
35+
max_line_len: 120000
36+
}
37+
},
38+
src: ['dist/<%= pkg.name %>.js'],
39+
dest: 'dist/<%= pkg.name %>.min.js'
40+
}
41+
},
42+
watch: {
43+
'js' : {
44+
files: ['src/**.js'],
45+
tasks: ['ngAnnotate', 'uglify']
46+
},
47+
'less' : {
48+
files: ['src/**.less'],
49+
tasks: ['less']
50+
}
51+
}
52+
});
53+
54+
grunt.loadNpmTasks('grunt-contrib-copy');
55+
grunt.loadNpmTasks('grunt-contrib-less');
56+
grunt.loadNpmTasks('grunt-contrib-uglify');
57+
grunt.loadNpmTasks('grunt-contrib-watch');
58+
grunt.loadNpmTasks('grunt-ng-annotate');
59+
60+
grunt.registerTask('default', ['less', 'ngAnnotate', 'uglify']);
61+
};

README.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,23 @@ I'm attempting to make a self-contained AngularJS Directive which will allow you
1414
# Browser Support
1515
* IE10+, Android 3+, iOS 6+, basically all modern browsers!
1616

17+
# Installation
18+
Get the library and its stylesheet using one of the following ways:
19+
20+
1. **Github**
21+
- [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)
22+
- [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)
23+
24+
2. **Bower**
25+
26+
```
27+
bower install angular-image-crop
28+
```
1729
# Usage
1830

19-
1. Add the dependency : `angular.module('myApp',['ImageCropper'])`
20-
2. Include the stylesheet
21-
3. Initiatlise the directive [see standalone JSBin](http://jsbin.com/fovovu/1/edit?javascript,output) for example code.
31+
1. Include both files inside the `<head>` element
32+
2. Add the dependency : `angular.module('myApp',['ImageCropper'])`
33+
3. Initialise the directive [see standalone JSBin](http://jsbin.com/fovovu/1/edit?javascript,output) for example code.
2234

2335
## Parameters
2436

@@ -37,7 +49,7 @@ I'm attempting to make a self-contained AngularJS Directive which will allow you
3749

3850
### Example markup
3951
```html
40-
<image-crop
52+
<image-crop
4153
data-height="200"
4254
data-width="150"
4355
data-shape="square"
@@ -50,7 +62,7 @@ I'm attempting to make a self-contained AngularJS Directive which will allow you
5062
crop="initCrop"
5163
padding="250"
5264
max-size="1024"
53-
></image-crop>
65+
></image-crop>
5466
```
5567

5668
# See a standalone working example

bower.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,19 @@
55
"authors": [
66
"Andy Shora <[email protected]>"
77
],
8+
"contributors": [
9+
"Ashish Bardhan <[email protected]>"
10+
],
811
"description": "A better way to crop images client-side using AngularJS",
912
"main": [
10-
"image-crop.js",
11-
"image-crop-styles.css"
13+
"dist/angular-image-crop.min.js",
14+
"dist/angular-image-crop-styles.min.css"
15+
],
16+
"ignore": [
17+
"src/*.js",
18+
"CONTRIBUTING.md",
19+
"Gruntfile.js"
1220
],
13-
"ignore": [],
1421
"keywords": [
1522
"angular",
1623
"angularjs",

index.html renamed to demo/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1">
1111
<!-- REQUIRED 1/3 - AngularJS Core -->
12-
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.11/angular.min.js"></script>
12+
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.11/angular.js"></script>
1313
<!-- REQUIRED 2/3 - styles for the image crop component -->
14-
<link rel="stylesheet" href="image-crop-styles.css">
14+
<link rel="stylesheet" href="../dist/angular-image-crop.min.css">
1515

1616
<script>
1717

@@ -50,7 +50,7 @@
5050
</script>
5151

5252
<!-- REQUIRED 3/3 - the image crop directive -->
53-
<script src="image-crop.js"></script>
53+
<script src="../dist/angular-image-crop.min.js"></script>
5454

5555
<style>
5656
/* Styles for this demo page */

index2.html renamed to demo/index2.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
<title>Test</title>
77
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1">
88
<!-- REQUIRED 1/3 - AngularJS Core -->
9-
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.11/angular.min.js"></script>
9+
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.11/angular.js"></script>
1010
<!-- REQUIRED 2/3 - styles for the image crop component -->
11-
<link rel="stylesheet" href="image-crop-styles.css">
11+
<link rel="stylesheet" href="../dist/angular-image-crop.min.css">
1212
<script>
1313
var myApp = null;
1414
(function() {
@@ -40,7 +40,7 @@
4040
})();
4141
</script>
4242
<!-- REQUIRED 3/3 - the image crop directive -->
43-
<script src="image-crop.js"></script>
43+
<script src="../dist/angular-image-crop.min.js"></script>
4444
<style>
4545
/* Styles for this demo page */
4646
body {
Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
/* Some of these styles you can override, things like colors,
1+
/*
2+
* ANGULAR-IMAGE-CROP Basic Styling
3+
* Some of these styles you can override, things like colors,
24
* however some styles are required for the structure, and are critical to this module behaving properly!
35
*/
4-
5-
/* Core component styles */
66
.ng-image-crop {
77
text-align: center;
88
margin: 0 auto;
@@ -13,49 +13,35 @@
1313
-o-user-select: none;
1414
user-select: none;
1515
}
16-
/* Each of the 3 steps in the process are contained within sections */
1716
.ng-image-crop > section {
1817
background: #ccc;
1918
}
20-
/* The cropping button */
2119
.ng-image-crop button {
2220
margin-top: 10px;
2321
}
24-
/* The dashed cropping guideline */
2522
.ng-image-crop .cropping-guide {
2623
display: block;
27-
background: rgba(255, 255, 255, .3);
24+
background: rgba(255, 255, 255, 0.3);
2825
border: 2px dashed white;
2926
position: absolute;
3027
pointer-events: none;
3128
}
32-
/* The circular themed cropping guideline */
33-
.ng-image-crop--circle .cropping-guide {
34-
border-radius: 50%;
35-
-webkit-border-radius: 50%;
36-
-moz-border-radius: 50%;
37-
-ms-border-radius: 50%;
38-
-o-border-radius: 50%;
39-
}
40-
/* The canvas where the user positions the image via dragging and zooming */
4129
.ng-image-crop .cropping-canvas {
42-
background: rgba(255, 255, 255, .3);
30+
background: rgba(255, 255, 255, 0.3);
4331
margin: 0 auto;
4432
cursor: move;
4533
}
46-
/* The overlayed draggable zoom handle in the corner of the module */
4734
.ng-image-crop .zoom-handle {
4835
display: block;
4936
position: absolute;
5037
bottom: 1px;
5138
left: 1px;
52-
background: rgba(255,255,255,0.7);
39+
background: rgba(255, 255, 255, 0.7);
5340
width: 80px;
5441
height: 80px;
5542
cursor: move;
5643
border-radius: 200px 50px;
5744
}
58-
/* The text within the zoom handle */
5945
.ng-image-crop .zoom-handle > span {
6046
color: rgba(0, 0, 0, 0.5);
6147
-webkit-transform: rotate(-45deg);
@@ -66,4 +52,11 @@
6652
display: block;
6753
position: relative;
6854
top: 32px;
69-
}
55+
}
56+
.ng-image-crop--circle .cropping-guide {
57+
-webkit-border-radius: 50%;
58+
-moz-border-radius: 50%;
59+
-ms-border-radius: 50%;
60+
-o-border-radius: 50%;
61+
border-radius: 50%;
62+
}

package.json

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
"name": "angular-image-crop",
33
"version": "2.0.0",
44
"description": "A better way to crop images client-side using AngularJS",
5-
"homepage": "http://andyshora.com/angular-image-cropper.html",
6-
"author": "Andy Shora <[email protected]>",
7-
"license": "MIT",
5+
"scripts": {
6+
"test": "echo \"Error: no test specified\" && exit 1"
7+
},
88
"repository": {
99
"type": "git",
10-
"url": "git@github.com:andyshora/angular-image-crop.git"
10+
"url": "git+https://github.com/andyshora/angular-image-crop.git"
1111
},
1212
"keywords": [
1313
"angular",
@@ -17,12 +17,27 @@
1717
"cropper",
1818
"avatar"
1919
],
20+
"authors": [
21+
"Andy Shora <[email protected]>"
22+
],
23+
"contributors": [
24+
"Ashish Bardhan <[email protected]>",
25+
"Benoit Lavenier <[email protected]>"
26+
],
27+
"license": "MIT",
28+
"bugs": {
29+
"url": "https://github.com/andyshora/angular-image-crop/issues"
30+
},
31+
"homepage": "http://andyshora.com/angular-image-cropper.html",
2032
"dependencies": {
2133
"angular": "^1.5.11"
2234
},
23-
"readmeFilename": "README.md",
24-
"bugs": {
25-
"url": "https://github.com/andyshora/angular-image-crop/issues",
26-
"new": "https://github.com/andyshora/angular-image-crop/issues/new"
35+
"devDependencies": {
36+
"grunt": "^1.1.0",
37+
"grunt-contrib-copy": "^1.0.0",
38+
"grunt-contrib-less": "^2.0.0",
39+
"grunt-contrib-uglify": "~4.0.1",
40+
"grunt-contrib-watch": "^1.1.0",
41+
"grunt-ng-annotate": "^4.0.0"
2742
}
2843
}

image-crop.js renamed to src/angular-image-crop.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* AngularJS Directive - Image Crop v1.1.0
2+
* AngularJS Directive - Image Crop v2.0.0
33
* Copyright (c) 2014 Andy Shora, [email protected], andyshora.com
44
* Licensed under the MPL License [http://www.nihilogic.dk/licenses/mpl-license.txt]
55
*/
@@ -760,6 +760,7 @@
760760

761761
angular.module('ImageCropper',[])
762762
.directive('imageCrop', function($q) {
763+
'ngInject'; // Need for ngAnnotate, before uglify
763764

764765
return {
765766
template: '<div id="image-crop-{{ rand }}" class="ng-image-crop ng-image-crop--{{ shape }}" ng-style="moduleStyles"><section ng-style="sectionStyles" ng-show="step==1"></section><section ng-style="sectionStyles" ng-show="step==2"><canvas class="cropping-canvas" width="{{ canvasWidth }}" height="{{ canvasHeight }}" ng-mousemove="onCanvasMouseMove($event)" ng-mousedown="onCanvasMouseDown($event)"></canvas><div ng-style="croppingGuideStyles" class="cropping-guide"></div><div class="zoom-handle" ng-mousemove="onHandleMouseMove($event)" ng-mousedown="onHandleMouseDown($event)" ng-mouseup="onHandleMouseUp($event)"><span>&larr; zoom &rarr;</span></div></section><section ng-style="sectionStyles" class="image-crop-section-final" ng-show="step==3"><img class="image-crop-final" ng-src="{{ croppedDataUri }}" /></section></div>',

0 commit comments

Comments
 (0)