Skip to content

Commit 2c30915

Browse files
committed
+ v2.0.4a
2 parents 2b9d22b + f4c59fd commit 2c30915

33 files changed

+1657
-615
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
11
node_modules
2+
tests/files/BigJPG.jpg
3+
tests/files/big.jpg
4+
dist/FileAPI.html5ok.js
5+
dist/FileAPI.html5ok.min.js
6+
dist/FileAPI.ok.js
7+
dist/FileAPI.ok.min.js
8+

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
language: node_js
2+
node_js:
3+
- 0.10
4+
before_script:
5+
- npm install -g grunt-cli

Gruntfile.js

Lines changed: 88 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
module.exports = function (grunt){
3+
module.exports = function (grunt) {
44
// Project configuration.
55
grunt.initConfig({
66
pkg: grunt.file.readJSON('package.json'),
@@ -38,22 +38,50 @@ module.exports = function (grunt){
3838
src: 'lib/FileAPI.core.js'
3939
},
4040

41-
qunit: {
42-
options: {
43-
files: {
44-
'1px.gif': ['tests/files/1px.gif']
45-
, 'hello.txt': ['tests/files/hello.txt']
46-
, 'image.jpg': ['tests/files/image.jpg']
47-
, 'dino.png': ['tests/files/dino.png']
48-
, 'multiple': ['tests/files/1px.gif', 'tests/files/hello.txt', 'tests/files/image.jpg', 'tests/files/dino.png', 'tests/files/lebowski.json']
41+
connect: {
42+
server: {
43+
options: {
44+
port: 9001,
45+
base: '.'
4946
}
5047
},
51-
all: ['tests/*.html']
48+
standalone: {
49+
options: {
50+
hostname: '*',
51+
keepalive: true,
52+
port: 9001,
53+
base: '.'
54+
}
55+
}
56+
},
57+
58+
curl: {
59+
jpg: {
60+
src: 'https://dl.dropboxusercontent.com/u/49592745/BigJPG.jpg',
61+
dest: 'tests/files/big.jpg'
62+
}
63+
},
64+
65+
qunit: {
66+
all: {
67+
options: {
68+
timeout: 5 * 60 * 1000, // 5min
69+
files: {
70+
'1px.gif': ['tests/files/1px.gif']
71+
, 'big.jpg': ['tests/files/big.jpg']
72+
, 'hello.txt': ['tests/files/hello.txt']
73+
, 'image.jpg': ['tests/files/image.jpg']
74+
, 'dino.png': ['tests/files/dino.png']
75+
, 'multiple': ['tests/files/1px.gif', 'tests/files/hello.txt', 'tests/files/image.jpg', 'tests/files/dino.png', 'tests/files/lebowski.json']
76+
},
77+
urls: ['http://127.0.0.1:<%=connect.server.options.port%>/tests/index.html']
78+
}
79+
}
5280
},
5381

5482
concat: {
5583
options: {
56-
banner: '/*! <%= pkg.name %> <%= pkg.version %> - <%= pkg.license %> | <%= pkg.repository.url %>\n' +
84+
banner: '/*! <%= pkg.exportName %> <%= pkg.version %> - <%= pkg.license %> | <%= pkg.repository.url %>\n' +
5785
' * <%= pkg.description %>\n' +
5886
' */\n\n',
5987

@@ -70,8 +98,9 @@ module.exports = function (grunt){
7098
, 'lib/FileAPI.XHR.js'
7199
, 'lib/FileAPI.Camera.js'
72100
, 'lib/FileAPI.Flash.js'
101+
, 'lib/FileAPI.Flash.Camera.js'
73102
],
74-
dest: 'dist/<%= pkg.name %>.js'
103+
dest: 'dist/<%= pkg.exportName %>.js'
75104
},
76105

77106
html5: {
@@ -83,17 +112,47 @@ module.exports = function (grunt){
83112
, 'lib/FileAPI.Form.js'
84113
, 'lib/FileAPI.XHR.js'
85114
, 'lib/FileAPI.Camera.js'
115+
, 'lib/FileAPI.Flash.Camera.js'
86116
],
87-
dest: 'dist/<%= pkg.name %>.html5.js'
117+
dest: 'dist/<%= pkg.exportName %>.html5.js'
88118
}
89119
},
90120

91121
uglify: {
92-
options: { banner: '/*! <%= pkg.name %> <%= pkg.version %> - <%= pkg.license %> | <%= pkg.repository.url %> */\n' },
122+
options: { banner: '/*! <%= pkg.exportName %> <%= pkg.version %> - <%= pkg.license %> | <%= pkg.repository.url %> */\n' },
93123
dist: {
94124
files: {
95-
'dist/<%= pkg.name %>.min.js': ['<%= concat.all.dest %>']
96-
, 'dist/<%= pkg.name %>.html5.min.js': ['<%= concat.html5.dest %>']
125+
'dist/<%= pkg.exportName %>.min.js': ['<%= concat.all.dest %>']
126+
, 'dist/<%= pkg.exportName %>.html5.min.js': ['<%= concat.html5.dest %>']
127+
}
128+
}
129+
},
130+
131+
mxmlc: {
132+
core: {
133+
options: {
134+
rawConfig: '-static-link-runtime-shared-libraries=true -compiler.debug=true' +
135+
' -library-path+=flash/core/lib/blooddy_crypto.swc -library-path+=flash/core/lib/EnginesLibrary.swc'
136+
},
137+
files: {
138+
'dist/<%= pkg.exportName %>.flash.swf': ['flash/core/src/FileAPI_flash.as']
139+
}
140+
},
141+
image: {
142+
options: {
143+
rawConfig: '-static-link-runtime-shared-libraries=true -compiler.debug=true' +
144+
' -library-path+=flash/image/lib/blooddy_crypto.swc'
145+
},
146+
files: {
147+
'dist/<%= pkg.exportName %>.flash.image.swf': ['flash/image/src/FileAPI_flash_image.as']
148+
}
149+
},
150+
camera: {
151+
options: {
152+
rawConfig: '-static-link-runtime-shared-libraries=true -compiler.debug=true'
153+
},
154+
files: {
155+
'dist/<%= pkg.exportName %>.flash.camera.swf': ['flash/camera/src/FileAPI_flash_camera.as']
97156
}
98157
}
99158
},
@@ -107,18 +166,27 @@ module.exports = function (grunt){
107166
}
108167
});
109168

110-
111169
// These plugins provide necessary tasks.
112170
grunt.loadNpmTasks('grunt-version');
113171
grunt.loadNpmTasks('grunt-contrib-jshint');
114172
grunt.loadNpmTasks('grunt-contrib-concat');
115173
grunt.loadNpmTasks('grunt-contrib-uglify');
116174
grunt.loadNpmTasks('grunt-contrib-watch');
117-
175+
grunt.loadNpmTasks('grunt-contrib-connect');
176+
grunt.loadNpmTasks('grunt-contrib-compress');
177+
grunt.loadNpmTasks('grunt-mxmlc');
178+
grunt.loadNpmTasks('grunt-curl');
118179
// Load custom QUnit task, based on grunt-contrib-qunit, but support "files" option.
119180
grunt.loadTasks('./tests/grunt-task/');
181+
grunt.loadTasks('./custom-tasks/');
120182

121183
// "npm build" runs these tasks
122-
grunt.registerTask('build', ['version', 'concat', 'uglify', 'qunit']);
123-
grunt.registerTask('default', ['jshint', 'build']);
184+
grunt.registerTask('prepare-test-files', function (){
185+
if (!grunt.file.exists('tests/files/big.jpg')) {
186+
grunt.task.run('curl');
187+
}
188+
});
189+
grunt.registerTask('tests', ['jshint', 'concat', 'connect:server','prepare-test-files', 'qunit']);
190+
grunt.registerTask('build', ['version', 'concat', 'uglify', 'mxmlc']);
191+
grunt.registerTask('default', ['tests', 'build']);
124192
};

README.md

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<a name="FileAPI"></a>
2-
## FileAPI
2+
## FileAPI <img src="https://api.travis-ci.org/mailru/FileAPI.png?branch=master"/>
33
A set of javascript tools for working with files.
44

55
<a name="started"></a>
66
### Get started
77

8+
Download the files from the [dist](https://github.com/mailru/FileAPI/tree/master/dist) directory, and then:
9+
810
```html
911
<div>
1012
<!-- "js-fileapi-wrapper" -- required class -->
@@ -280,7 +282,7 @@ FileAPI.readAsBinaryString(file, function (evt/**Object*/){
280282
---
281283

282284
<a name="FileAPI.readAsArrayBuffer"></a>
283-
### readAsBinaryString(file`:Object`, callback`:Function`)`:void`
285+
### readAsArrayBuffer(file`:Object`, callback`:Function`)`:void`
284286
Reading the contents of the specified `File` as `ArrayBuffer`.
285287

286288
* file — file object
@@ -765,12 +767,12 @@ FileAPI.Image(imageFile)
765767
---
766768

767769
<a name="FileAPI.Image.resize"></a>
768-
### resize(width`:Number`, height`:Number`[, type`:String`])`:FileAPI.Image`
770+
### resize(width`:Number`, height`:Number`[, strategy`:String`])`:FileAPI.Image`
769771
Resize image.
770772

771773
* width — new image width
772774
* height — new image height
773-
* type — enum: `min`, `max`, `preview`. By default `undefined`.
775+
* strategy — enum: `min`, `max`, `preview`. By default `undefined`.
774776

775777
```js
776778
FileAPI.Image(imageFile)
@@ -1165,10 +1167,16 @@ Submit Query
11651167
<script>
11661168
(function (ctx, jsonp){
11671169
'use strict';
1168-
if( ctx && ctx[jsonp] ){
1169-
ctx[jsonp](200/*http.status*/, 'OK' /*http.statusText*/, "response body");
1170+
var status = {{httpStatus}}, statusText = "{{httpStatusText}}", response = "{{responseBody}}";
1171+
try {
1172+
ctx[jsonp](status, statusText, response);
1173+
} catch (e){
1174+
var data = "{\"id\":\""+jsonp+"\",\"status\":"+status+",\"statusText\":\""+statusText+"\",\"response\":\""+response.replace(/\"/g, '\\\\\"')+"\"}";
1175+
try {
1176+
ctx.postMessage(data, document.referrer);
1177+
} catch (e){}
11701178
}
1171-
})(window, '{{$request_param_callback}}');
1179+
})(window.parent, '{{request_param_callback}}');
11721180
</script>
11731181
11741182
<!-- or -->
@@ -1378,6 +1386,43 @@ Button like link.
13781386
<a name="Changelog"></a>
13791387
## Changelog
13801388
1389+
<ul>
1390+
<li>+ #207: support EXIF.Orientation == 5</li>
1391+
</ul>
1392+
1393+
1394+
### 2.0.4
1395+
<ul>
1396+
<li>+ #176: Add params to the beginning of form</li>
1397+
<li>+ #190: Add 204 as a successful response</li>
1398+
<li>+ #192: many bugfixes; + `retry` & `multipass` options; + QUnit-tests for BigSizeImage</li>
1399+
</ul>
1400+
1401+
### 2.0.3
1402+
<ul>
1403+
<li>+ QUnit-tests for iframe-transport</li>
1404+
<li>+ `postMessage` for iframe-transport</li>
1405+
<li>+ `jsonp: "callback"` option</li>
1406+
<li>* resize: `imageTransform.type` rename to `imageTransform.strategy` (!!!)</li>
1407+
<li>+ https://github.com/mailru/FileAPI/pull/165 (#140: fix)</li>
1408+
</ul>
1409+
1410+
### 2.0.2
1411+
<ul>
1412+
<li>+ test: upload headers</li>
1413+
<li>+ test: upload + camanjs</li>
1414+
<li>+ test: upload + autoOrientation</li>
1415+
<li>FileAPI.class.php: + HTTP header Content-Type: application/json</li>
1416+
<li>#143: + `FileAPI.flashWebcamUrl` option</li>
1417+
<li>* merge v1.2.7</li>
1418+
<li>+ `FileAPI.formData: true` option</li>
1419+
</ul>
1420+
1421+
### 2.0.1
1422+
<ul>
1423+
<li>+ support 'filter' prop in imageTransform</li>
1424+
</ul>
1425+
13811426
### 2.0.0
13821427
<ul>
13831428
<li>+ FileAPI.Camera (HTML5 and Flash fallback)</li>

README.ru.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ FileAPI.readAsBinaryString(file, function (evt/**Object*/){
279279
---
280280

281281
<a name="FileAPI.readAsArrayBuffer"></a>
282-
### readAsBinaryString(file`:Object`, callback`:Function`)`:void`
282+
### readAsArrayBuffer(file`:Object`, callback`:Function`)`:void`
283283
Чтение содержимого указанного файла как `ArrayBuffer`.
284284

285285
* file — файл для чтения
@@ -747,12 +747,12 @@ FileAPI.Image(imageFile)
747747
---
748748

749749
<a name="FileAPI.Image.resize"></a>
750-
### resize(width`:Number`, height`:Number`[, type`:String`])`:FileAPI.Image`
750+
### resize(width`:Number`, height`:Number`[, strategy`:String`])`:FileAPI.Image`
751751
Ресайз.
752752

753753
* width — новая ширина
754754
* height — новая высота
755-
* type — enum: `min`, `max`, `preview`. По умолчанию `undefined`.
755+
* strategy — enum: `min`, `max`, `preview`. По умолчанию `undefined`.
756756

757757
```js
758758
FileAPI.Image(imageFile)
@@ -1147,10 +1147,16 @@ Submit Query
11471147
<script>
11481148
(function (ctx, jsonp){
11491149
'use strict';
1150-
if( ctx && ctx[jsonp] ){
1151-
ctx[jsonp](200/*http.status*/, 'OK' /*http.statusText*/, "response body");
1150+
var status = {{httpStatus}}, statusText = "{{httpStatusText}}", response = "{{responseBody}}";
1151+
try {
1152+
ctx[jsonp](status, statusText, response);
1153+
} catch (e){
1154+
var data = "{\"id\":\""+jsonp+"\",\"status\":"+status+",\"statusText\":\""+statusText+"\",\"response\":\""+response.replace(/\"/g, '\\\\\"')+"\"}";
1155+
try {
1156+
ctx.postMessage(data, document.referrer);
1157+
} catch (e){}
11521158
}
1153-
})(window, '{{$request_param_callback}}');
1159+
})(window.parent, '{{request_param_callback}}');
11541160
</script>
11551161
11561162
<!-- or -->

custom-tasks/Gruntfile-ok.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
'use strict';
2+
3+
module.exports = function (grunt) {
4+
// Project configuration.
5+
grunt.config.set('concat.ok', {
6+
src: [
7+
'lib/FileAPI.header.js'
8+
, 'lib/canvas-to-blob.js'
9+
, 'lib/FileAPI.core.js'
10+
, 'lib/FileAPI.Image.js'
11+
, 'lib/load-image-ios.js'
12+
, 'lib/FileAPI.Form.js'
13+
, 'lib/FileAPI.XHR.js'
14+
, 'lib/FileAPI.Flash.js'
15+
, 'plugins/FileAPI.exif.js'
16+
],
17+
dest: 'dist/<%= pkg.exportName %>.ok.js'
18+
});
19+
grunt.config.set('concat.html5ok', {
20+
src: [
21+
'lib/FileAPI.header.js'
22+
, 'lib/canvas-to-blob.js'
23+
, 'lib/FileAPI.core.js'
24+
, 'lib/FileAPI.Image.js'
25+
, 'lib/load-image-ios.js'
26+
, 'lib/FileAPI.Form.js'
27+
, 'lib/FileAPI.XHR.js'
28+
, 'plugins/FileAPI.exif.js'
29+
],
30+
dest: 'dist/<%= pkg.exportName %>.html5ok.js'
31+
});
32+
33+
grunt.config.set('uglify.distok', {
34+
files: {
35+
'dist/<%= pkg.exportName %>.ok.min.js': ['<%= concat.ok.dest %>'], 'dist/<%= pkg.exportName %>.html5ok.min.js': ['<%= concat.html5ok.dest %>']
36+
}
37+
});
38+
39+
grunt.config.set('compress.main', {
40+
options: {
41+
archive: '<%= pkg.name %>-<%= pkg.version.replace(/\\./g,"-") %>.zip'
42+
},
43+
files: [
44+
{cwd: 'dist/', expand: true, src: ['*'], dest: '<%= pkg.version.replace(/\\./g,"-") %>/'}
45+
]
46+
});
47+
48+
49+
grunt.registerTask('build-zip', ['build', 'compress']);
50+
51+
};

dist/FileAPI.flash.camera.swf

608 Bytes
Binary file not shown.

dist/FileAPI.flash.image.swf

736 Bytes
Binary file not shown.

dist/FileAPI.flash.swf

31.9 KB
Binary file not shown.

0 commit comments

Comments
 (0)