Skip to content

Commit 3d4890f

Browse files
committed
+ thumbnails example
1 parent 530a27c commit 3d4890f

File tree

10 files changed

+253
-64
lines changed

10 files changed

+253
-64
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,6 +1285,7 @@ Button like link.
12851285
<li>+ [#80](https://https://github.com/mailru/FileAPI/issues/80): FileAPI.Image.fn.overlay</li>
12861286
<li>`imageTransform` — now supports: `crop`, `type`, `quality` and `overlay` properties.</li>
12871287
<li>Improved the documentation</li>
1288+
<li>+iOS fix (https://github.com/blueimp/JavaScript-Load-Image)</li>
12881289
<li>[#121](https://github.com/mailru/FileAPI/issues/121): + FileAPI.`postNameConcat:Function(name, idx)`</li>
12891290
<li>[#116](https://github.com/mailru/FileAPI/issues/116): + `cache:false` option for FileAPI.upload</li>
12901291
</ul>

examples/_toolkit.css

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
.body {
2+
font-size: 14px;
3+
}
4+
5+
.btn, .body {
6+
font-family: "Raleway","Helvetica Neue",Helvetica,Arial,sans-serif;
7+
}
8+
9+
10+
.btn {
11+
padding: 10px 50px;
12+
color: #fff;
13+
cursor: pointer;
14+
display: inline-block;
15+
text-decoration: none;
16+
font-size: 24px;
17+
border-radius: 4px;
18+
background-color: #80BD95;
19+
box-shadow: 0 3px 0 0 #72A884;
20+
text-shadow: 0 -2px 0 rgba(0,0,0,.2);
21+
}
22+
23+
24+
.loader {
25+
width: 30px;
26+
height: 30px;
27+
margin: 50px 0 50px -15px;
28+
border: 8px solid #000;
29+
border-right-color: transparent;
30+
display: inline-block;
31+
border-radius: 50%;
32+
box-shadow: 0 0 25px 2px #eee;
33+
border-right: 0 none;
34+
-webkit-animation: spin 1s linear infinite;
35+
-moz-animation: spin 1s linear infinite;
36+
-ms-animation: spin 1s linear infinite;
37+
-o-animation: spin 1s linear infinite;
38+
animation: spin 1s linear infinite;
39+
}
40+
41+
.js-fileapi-wrapper {
42+
display: inline-block;
43+
*zoom: 1;
44+
*display: inline;
45+
}
46+
.js-fileapi-wrapper input {
47+
width: 0;
48+
height: 0;
49+
opacity: 0;
50+
overflow: 0;
51+
position: absolute;
52+
}
53+
54+
@-webkit-keyframes spin {
55+
from { -webkit-transform: rotate(0deg); opacity: 0.4; }
56+
50% { -webkit-transform: rotate(180deg); opacity: 1; }
57+
to { -webkit-transform: rotate(360deg); opacity: 0.4; }
58+
}
59+
60+
@-moz-keyframes spin {
61+
from { -moz-transform: rotate(0deg); opacity: 0.4; }
62+
50% { -moz-transform: rotate(180deg); opacity: 1; }
63+
to { -moz-transform: rotate(360deg); opacity: 0.4; }
64+
}
65+
66+
@-ms-keyframes spin {
67+
from { -ms-transform: rotate(0deg); opacity: 0.4; }
68+
50% { -ms-transform: rotate(180deg); opacity: 1; }
69+
to { -ms-transform: rotate(360deg); opacity: 0.4; }
70+
}
71+
72+
@keyframes spin {
73+
from { transform: rotate(0deg); opacity: 0.2; }
74+
50% { transform: rotate(180deg); opacity: 1; }
75+
to { transform: rotate(360deg); opacity: 0.2; }
76+
}

examples/caman.html

Lines changed: 2 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<script src="../dist/FileAPI.min.js"></script>
3030
<script src="../plugins/caman.full.min.js"></script>
3131

32+
<link rel="stylesheet" href="_toolkit.css"/>
3233
<style>
3334
body {
3435
margin: 0 auto;
@@ -56,61 +57,6 @@
5657
#PresetFilters a.Active {
5758
background-color: #e69751;
5859
}
59-
60-
.loader {
61-
width: 30px;
62-
height: 30px;
63-
margin: 50px 0 50px -15px;
64-
border: 8px solid #000;
65-
border-right-color: transparent;
66-
display: inline-block;
67-
border-radius: 50%;
68-
box-shadow: 0 0 25px 2px #eee;
69-
border-right: 0 none;
70-
-webkit-animation: spin 1s linear infinite;
71-
-moz-animation: spin 1s linear infinite;
72-
-ms-animation: spin 1s linear infinite;
73-
-o-animation: spin 1s linear infinite;
74-
animation: spin 1s linear infinite;
75-
}
76-
77-
.btn {
78-
padding: 10px 50px;
79-
color: #fff;
80-
cursor: pointer;
81-
display: inline-block;
82-
text-decoration: none;
83-
font-size: 24px;
84-
border-radius: 4px;
85-
background-color: #80BD95;
86-
box-shadow: 0 3px 0 0 #72A884;
87-
text-shadow: 0 -2px 0 rgba(0,0,0,.2);
88-
}
89-
90-
@-webkit-keyframes spin {
91-
from { -webkit-transform: rotate(0deg); opacity: 0.4; }
92-
50% { -webkit-transform: rotate(180deg); opacity: 1; }
93-
to { -webkit-transform: rotate(360deg); opacity: 0.4; }
94-
}
95-
96-
@-moz-keyframes spin {
97-
from { -moz-transform: rotate(0deg); opacity: 0.4; }
98-
50% { -moz-transform: rotate(180deg); opacity: 1; }
99-
to { -moz-transform: rotate(360deg); opacity: 0.4; }
100-
}
101-
102-
@-ms-keyframes spin {
103-
from { -ms-transform: rotate(0deg); opacity: 0.4; }
104-
50% { -ms-transform: rotate(180deg); opacity: 1; }
105-
to { -ms-transform: rotate(360deg); opacity: 0.4; }
106-
}
107-
108-
@keyframes spin {
109-
from { transform: rotate(0deg); opacity: 0.2; }
110-
50% { transform: rotate(180deg); opacity: 1; }
111-
to { transform: rotate(360deg); opacity: 0.2; }
112-
}
113-
11460
</style>
11561

11662
</head>
@@ -120,6 +66,7 @@
12066
<a href="../">&larr; index</a> |
12167
<a href="./demo.html">demo</a> -
12268
<a href="./userpic.html">userpic</a> -
69+
<a href="./thumbnails.html">thumbnails</a> -
12370
<a href="./watermark.html">watermark</a> -
12471
<a href="./webcam.html">webcam</a> -
12572
<b>caman.js</b>

examples/demo.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@
282282
<a href="../">&larr; index</a> |
283283
<b>demo</b> -
284284
<a href="./userpic.html">userpic</a> -
285+
<a href="./thumbnails.html">thumbnails</a> -
285286
<a href="./watermark.html">watermark</a> -
286287
<a href="./webcam.html">webcam</a> -
287288
<a href="./caman.html">caman.js</a>

examples/thumbnails.html

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
<!DOCTYPE html>
2+
<!--
3+
4+
5+
~~~ Thumbnails (FileAPI.Image ~~~
6+
(NativeJS + FileAPI)
7+
8+
9+
-->
10+
<html>
11+
<head>
12+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
13+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
14+
15+
<meta name="viewport" content="user-scalable=no, width=400, initial-scale=1, maximum-scale=1" />
16+
<meta name="apple-mobile-web-app-capable" content="yes" />
17+
<meta name="apple-mobile-web-app-status-bar-style" content="yes" />
18+
<meta name="format-detection" content="email=no" />
19+
<meta name="HandheldFriendly" content="true" />
20+
21+
<title>FileAPI :: Thumbnails :: example</title>
22+
23+
<script>
24+
// Settings
25+
var FileAPI = {
26+
debug: true // debug mode
27+
, staticPath: '../dist/'
28+
};
29+
</script>
30+
31+
<script src="../dist/FileAPI.js"></script>
32+
<script src="../plugins/FileAPI.exif.js"></script>
33+
34+
<link rel="stylesheet" href="_toolkit.css"/>
35+
<style>
36+
body {
37+
font-size: 15px;
38+
font-family: "Helvetica Neue";
39+
}
40+
41+
.thumb {
42+
float: left;
43+
border: 2px solid #ccc;
44+
margin: 10px;
45+
padding: 2px;
46+
position: relative;
47+
line-height: 0;
48+
z-index: -1;
49+
}
50+
.thumb label {
51+
color: #fff;
52+
text-align: center;
53+
text-shadow: 0 1px 1px #000;
54+
font-weight: bold;
55+
top: 45%;
56+
left: 0;
57+
right: 0;
58+
position: absolute;
59+
}
60+
</style>
61+
62+
</head>
63+
<body>
64+
<div style="left: 0; right: 0; bottom: 0; position: fixed; box-shadow: 0 0 5px rgba(0,0,0,.65); background-color: #f3f3f3;">
65+
<div style="padding: 5px 10px 10px">
66+
<a href="../">&larr; index</a> |
67+
<a href="./demo.html">demo</a> -
68+
<a href="./userpic.html">userpic</a> -
69+
<b>thumbnails</b> -
70+
<a href="./watermark.html">watermark</a> -
71+
<a href="./webcam.html">webcam</a> -
72+
<a href="./caman.html">caman.js</a>
73+
</div>
74+
</div>
75+
76+
<div class="body">
77+
<h2>Thumbnails</h2>
78+
79+
<div style="text-align: center">
80+
<div class="js-fileapi-wrapper">
81+
<label for="browse" class="btn">Select photo (min 480x320)</label>
82+
<input id="browse" type="file" accept="image/*"/>
83+
</div>
84+
85+
<div id="loading" class="loader" style="display: none; position: absolute; left: 45%; top: 30%"></div>
86+
<div id="thumbnails" style="margin-top: 30px;"></div>
87+
88+
<div style="clear: both">&nbsp;<br/><br/><br/></div>
89+
</div>
90+
</div>
91+
92+
<script>
93+
(function (){
94+
var processing = false;
95+
96+
if( !(FileAPI.support.html5 || FileAPI.support.flash) ){
97+
alert('Ooops, your browser does not support Flash and HTML5 :[');
98+
}
99+
100+
function thumb(file, width, height, type){
101+
var image = FileAPI.Image(file), label = width+'x'+height, callback;
102+
103+
if( type ){
104+
label += ' ('+type+')';
105+
image.resize(width, height, type);
106+
} else if( width ){
107+
image.preview(width, height);
108+
} else {
109+
label = 'original';
110+
}
111+
112+
image.get(function (err, img){
113+
var el = document.createElement('div');
114+
el.innerHTML = '<label>'+label+'</label>';
115+
el.className = 'thumb';
116+
el.appendChild(img);
117+
thumbnails.appendChild(el);
118+
callback && callback();
119+
});
120+
121+
return function (then){ callback = then; };
122+
}
123+
124+
125+
FileAPI.event.on(browse, 'change', function (evt){
126+
var file = FileAPI.getFiles(evt)[0];
127+
128+
!processing && FileAPI.getInfo(file, function (err, info){
129+
if( info.width >= 480 && info.height >= 320 ){
130+
processing = true;
131+
thumbnails.innerHTML = ''; // clear
132+
loading.style.display = '';
133+
134+
// 100x100
135+
thumb(file, 100, 100)(function (){
136+
// 320x240
137+
thumb(file, 320, 240)(function (){
138+
// 480x320 by min side
139+
thumb(file, 480, 320, 'min')(function (){
140+
// 480x320 by max side
141+
thumb(file, 480, 320, 'max')(function (){
142+
// Original
143+
thumb(file);
144+
processing = false;
145+
loading.style.display = 'none';
146+
});
147+
});
148+
});
149+
});
150+
}
151+
else {
152+
alert('Does not fit, you need more than: '+info.width+'x'+info.height);
153+
}
154+
});
155+
});
156+
})();
157+
</script>
158+
</body>
159+
</html>

examples/userpic.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115
<a href="../">&larr; index</a> |
116116
<a href="./demo.html">demo</a> -
117117
<b>userpic</b> -
118+
<a href="./thumbnails.html">thumbnails</a> -
118119
<a href="./watermark.html">watermark</a> -
119120
<a href="./webcam.html">webcam</a> -
120121
<a href="./caman.html">caman.js</a>

examples/watermark.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<meta name="format-detection" content="email=no" />
1919
<meta name="HandheldFriendly" content="true" />
2020

21-
<title>FileAPI :: Images :: example</title>
21+
<title>FileAPI :: Watermark :: example</title>
2222

2323
<script>
2424
// Settings
@@ -68,6 +68,7 @@
6868
<a href="../">&larr; index</a> |
6969
<a href="./demo.html">demo</a> -
7070
<a href="./userpic.html">userpic</a> -
71+
<a href="./thumbnails.html">thumbnails</a> -
7172
<b>watermark</b> -
7273
<a href="./webcam.html">webcam</a> -
7374
<a href="./caman.html">caman.js</a>

examples/webcam.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<meta name="format-detection" content="email=no" />
1919
<meta name="HandheldFriendly" content="true" />
2020

21-
<title>FileAPI :: Images :: example</title>
21+
<title>FileAPI :: WebCam :: example</title>
2222

2323
<script>
2424
// Settings
@@ -49,6 +49,7 @@
4949
<a href="../">&larr; index</a> |
5050
<a href="./demo.html">demo</a> -
5151
<a href="./userpic.html">userpic</a> -
52+
<a href="./thumbnails.html">thumbnails</a> -
5253
<a href="./watermark.html">watermark</a> -
5354
<b>webcam</b> -
5455
<a href="./caman.html">caman.js</a>

0 commit comments

Comments
 (0)