ezdz-rails 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -6
- data/lib/ezdz-rails/version.rb +1 -1
- data/vendor/assets/javascripts/jquery.ezdz.js +152 -120
- data/vendor/assets/stylesheets/jquery.ezdz.css +4 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11892a10ef2af7031c2d3aa65e589a2c450003e4
|
4
|
+
data.tar.gz: 92df16969845147fcb55f6fe5e9ed52a9d891a65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b19e4b806e5cdafb579e1aaf8a9b04a8636a4b944633750517d002a5cd9493c201c716a4cbe06cc103a8b69b56097874b66663576feb737a907137e0a6d81e37
|
7
|
+
data.tar.gz: 73b78ca7dce27fbef6a5813bd2d6093ba0f6ac441ae754a8b80d606f9f679874a712f78aa268bedcf2138f8479fca2da96f271a6901ec48d537a34eb6479c94a
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Ezdz-Rails
|
2
2
|
|
3
|
-
This Gem integrates [Jay Salvat's Ezdz](https://github.com/
|
3
|
+
This Gem integrates [Jay Salvat's Ezdz](https://github.com/jaysalvat/ezdz)
|
4
4
|
to the Rails assets pipeline.
|
5
5
|
|
6
6
|
## Installation
|
@@ -39,15 +39,15 @@ In the case you'd like to create a new release when [Jay Salvat](https://github.
|
|
39
39
|
|
40
40
|
```
|
41
41
|
$ ./make_new_release.sh
|
42
|
-
Ensuring Docker image zedtux/
|
43
|
-
Updating library code to version
|
44
|
-
Downlading
|
42
|
+
Ensuring Docker image zedtux/ezdz-rails exists ...
|
43
|
+
Updating library code to version 0.2.0 ...
|
44
|
+
Downlading ezdz-slider 0.2.0 ...
|
45
45
|
% Total % Received % Xferd Average Speed Time Time Time Current
|
46
46
|
Dload Upload Total Spent Left Speed
|
47
|
-
100
|
47
|
+
100 11471 100 11471 0 0 1977 0 0:00:05 0:00:05 --:--:-- 2673
|
48
48
|
% Total % Received % Xferd Average Speed Time Time Time Current
|
49
49
|
Dload Upload Total Spent Left Speed
|
50
|
-
100
|
50
|
+
100 2100 100 2100 0 0 6389 0 --:--:-- --:--:-- --:--:-- 6382
|
51
51
|
Done!
|
52
52
|
Committing new version ...
|
53
53
|
Releasing gem ...
|
data/lib/ezdz-rails/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/* ----------------------------------------------------------------------------
|
2
|
-
// Ezdz [izy-dizy]
|
3
|
-
// v0.2.
|
2
|
+
// Ezdz [izy-dizy]
|
3
|
+
// v0.2.1 - released 2013-10-16 00:41
|
4
4
|
// Licensed under the MIT license.
|
5
5
|
// https://github.com/jaysalvat/ezdz
|
6
6
|
// ----------------------------------------------------------------------------
|
@@ -8,7 +8,15 @@
|
|
8
8
|
// http://jaysalvat.com/
|
9
9
|
// ---------------------------------------------------------------------------*/
|
10
10
|
|
11
|
-
(function(
|
11
|
+
(function (factory) {
|
12
|
+
if (typeof define === 'function' && define.amd) {
|
13
|
+
define(['jquery'], factory);
|
14
|
+
} else if (typeof exports === 'object') {
|
15
|
+
factory(require('jquery'));
|
16
|
+
} else {
|
17
|
+
factory(jQuery);
|
18
|
+
}
|
19
|
+
}(function ($) {
|
12
20
|
// Default settings
|
13
21
|
var defaults = {
|
14
22
|
className: '',
|
@@ -43,9 +51,12 @@
|
|
43
51
|
|
44
52
|
// Main plugin
|
45
53
|
$.ezdz = function(element, options) {
|
46
|
-
|
47
|
-
|
48
|
-
|
54
|
+
this.settings = $.extend(true, {}, defaults, $.ezdz.defaults, options);
|
55
|
+
this.$input = $(element);
|
56
|
+
|
57
|
+
var self = this,
|
58
|
+
settings = self.settings,
|
59
|
+
$input = self.$input;
|
49
60
|
|
50
61
|
if (!$input.is('input[type="file"]')) {
|
51
62
|
$.error('Ezdz error - Must be apply to inputs type file.');
|
@@ -57,48 +68,6 @@
|
|
57
68
|
return;
|
58
69
|
}
|
59
70
|
|
60
|
-
// Public: Inject a file or image in the preview
|
61
|
-
self.preview = function(path, callback) {
|
62
|
-
var basename = path.replace(/\\/g,'/').replace( /.*\//, ''),
|
63
|
-
formatted = settings.format(basename),
|
64
|
-
$ezdz = $input.parent('.' + settings.classes.main);
|
65
|
-
|
66
|
-
var img = new Image();
|
67
|
-
img.src = path;
|
68
|
-
|
69
|
-
// Is an image
|
70
|
-
img.onload = function() {
|
71
|
-
$ezdz.find('div').html($(img).fadeIn());
|
72
|
-
|
73
|
-
if ($.isFunction(callback)) {
|
74
|
-
callback.apply(this);
|
75
|
-
}
|
76
|
-
};
|
77
|
-
|
78
|
-
// Is not an image
|
79
|
-
img.onerror = function() {
|
80
|
-
$ezdz.find('div').html('<span>' + formatted + '</span>');
|
81
|
-
|
82
|
-
if ($.isFunction(callback)) {
|
83
|
-
callback.apply(this);
|
84
|
-
}
|
85
|
-
};
|
86
|
-
|
87
|
-
$ezdz.addClass(settings.classes.accept);
|
88
|
-
};
|
89
|
-
|
90
|
-
// Public: Destroy ezdz
|
91
|
-
self.destroy = function() {
|
92
|
-
$input.parent('.' + settings.classes.main).replaceWith($input);
|
93
|
-
$input.off('*.ezdz');
|
94
|
-
$input.data('ezdz', '');
|
95
|
-
};
|
96
|
-
|
97
|
-
// Public: Extend settings
|
98
|
-
self.options = function(values) {
|
99
|
-
$.extend(true, settings, values);
|
100
|
-
};
|
101
|
-
|
102
71
|
// private: Init the plugin
|
103
72
|
var init = function() {
|
104
73
|
var $ezdz, $container, value;
|
@@ -123,7 +92,7 @@
|
|
123
92
|
})
|
124
93
|
|
125
94
|
.addClass(settings.className);
|
126
|
-
|
95
|
+
|
127
96
|
// Build the whole dropzone
|
128
97
|
$input
|
129
98
|
.wrap($container)
|
@@ -140,7 +109,7 @@
|
|
140
109
|
|
141
110
|
// Trigger the init callback
|
142
111
|
if ($.isFunction(settings.init)) {
|
143
|
-
settings.init.apply($
|
112
|
+
settings.init.apply($input, [ value ]);
|
144
113
|
}
|
145
114
|
|
146
115
|
// Events on the input
|
@@ -226,91 +195,95 @@
|
|
226
195
|
|
227
196
|
// Trigger the reject callback
|
228
197
|
if ($.isFunction(settings.reject)) {
|
229
|
-
settings.reject.apply($
|
198
|
+
settings.reject.apply($input, [ file, errors ]);
|
230
199
|
}
|
231
200
|
return false;
|
232
201
|
}
|
233
202
|
|
234
203
|
// Read the added file
|
235
|
-
var reader = new FileReader(file)
|
236
|
-
img = new Image();
|
204
|
+
var reader = new FileReader(file);
|
237
205
|
|
238
206
|
reader.readAsDataURL(file);
|
239
207
|
|
240
208
|
reader.onload = function(e) {
|
209
|
+
var img = new Image(),
|
210
|
+
isImage;
|
211
|
+
|
241
212
|
file.data = e.target.result;
|
242
213
|
img.src = file.data;
|
243
214
|
|
244
|
-
|
215
|
+
setTimeout(function() {
|
216
|
+
isImage = (img.width && img.height);
|
245
217
|
|
246
|
-
|
247
|
-
|
248
|
-
valid = false;
|
249
|
-
errors.maxSize = true;
|
250
|
-
}
|
251
|
-
|
252
|
-
if (isImage) {
|
253
|
-
file.width = img.width;
|
254
|
-
file.height = img.height;
|
255
|
-
|
256
|
-
if (settings.validators.width && img.width != settings.validators.width) {
|
218
|
+
// Validator
|
219
|
+
if (settings.validators.maxSize && file.size > settings.validators.maxSize) {
|
257
220
|
valid = false;
|
258
|
-
errors.
|
221
|
+
errors.maxSize = true;
|
259
222
|
}
|
260
223
|
|
261
|
-
if (
|
262
|
-
|
263
|
-
|
264
|
-
}
|
224
|
+
if (isImage) {
|
225
|
+
file.width = img.width;
|
226
|
+
file.height = img.height;
|
265
227
|
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
228
|
+
if (settings.validators.width && img.width != settings.validators.width) {
|
229
|
+
valid = false;
|
230
|
+
errors.width = true;
|
231
|
+
}
|
270
232
|
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
233
|
+
if (settings.validators.maxWidth && img.width > settings.validators.maxWidth) {
|
234
|
+
valid = false;
|
235
|
+
errors.maxWidth = true;
|
236
|
+
}
|
275
237
|
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
238
|
+
if (settings.validators.minWidth && img.width < settings.validators.minWidth) {
|
239
|
+
valid = false;
|
240
|
+
errors.minWidth = true;
|
241
|
+
}
|
280
242
|
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
}
|
243
|
+
if (settings.validators.height && img.height != settings.validators.height) {
|
244
|
+
valid = false;
|
245
|
+
errors.height = true;
|
246
|
+
}
|
286
247
|
|
287
|
-
|
288
|
-
|
289
|
-
|
248
|
+
if (settings.validators.maxHeight && img.height > settings.validators.maxHeight) {
|
249
|
+
valid = false;
|
250
|
+
errors.maxHeight = true;
|
251
|
+
}
|
290
252
|
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
253
|
+
if (settings.validators.minHeight && img.height < settings.validators.minHeight) {
|
254
|
+
valid = false;
|
255
|
+
errors.minHeight = true;
|
256
|
+
}
|
295
257
|
}
|
296
258
|
|
297
|
-
|
259
|
+
// The file is validated, so added to input
|
260
|
+
if (valid === true) {
|
261
|
+
$ezdz.find('img').remove();
|
298
262
|
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
263
|
+
if (isImage && settings.previewImage === true) {
|
264
|
+
$ezdz.find('div').html($(img).fadeIn());
|
265
|
+
} else {
|
266
|
+
$ezdz.find('div').html('<span>' + formatted + '</span>');
|
267
|
+
}
|
268
|
+
|
269
|
+
$ezdz.addClass(settings.classes.accept);
|
306
270
|
|
307
|
-
|
271
|
+
// Trigger the accept callback
|
272
|
+
if ($.isFunction(settings.accept)) {
|
273
|
+
settings.accept.apply($input, [ file ]);
|
274
|
+
}
|
275
|
+
// The file is invalidated, so rejected
|
276
|
+
} else {
|
277
|
+
$input.val('');
|
308
278
|
|
309
|
-
|
310
|
-
|
311
|
-
|
279
|
+
$ezdz.addClass(settings.classes.reject);
|
280
|
+
|
281
|
+
// Trigger the reject callback
|
282
|
+
if ($.isFunction(settings.reject)) {
|
283
|
+
settings.reject.apply($input, [ file, errors ]);
|
284
|
+
}
|
312
285
|
}
|
313
|
-
}
|
286
|
+
}, 1);
|
314
287
|
};
|
315
288
|
});
|
316
289
|
};
|
@@ -318,22 +291,81 @@
|
|
318
291
|
init();
|
319
292
|
};
|
320
293
|
|
321
|
-
|
322
|
-
|
294
|
+
// Inject a file or image in the preview
|
295
|
+
$.ezdz.prototype.preview = function(path, callback) {
|
296
|
+
var settings = this.settings,
|
297
|
+
$input = this.$input,
|
298
|
+
$ezdz = $input.parent('.' + settings.classes.main);
|
299
|
+
basename = path.replace(/\\/g,'/').replace( /.*\//, ''),
|
300
|
+
formatted = settings.format(basename);
|
301
|
+
|
302
|
+
var img = new Image();
|
303
|
+
img.src = path;
|
304
|
+
|
305
|
+
// Is an image
|
306
|
+
img.onload = function() {
|
307
|
+
$ezdz.find('div').html($(img).fadeIn());
|
308
|
+
|
309
|
+
if ($.isFunction(callback)) {
|
310
|
+
callback.apply(this);
|
311
|
+
}
|
312
|
+
};
|
323
313
|
|
324
|
-
|
325
|
-
|
314
|
+
// Is not an image
|
315
|
+
img.onerror = function() {
|
316
|
+
$ezdz.find('div').html('<span>' + formatted + '</span>');
|
326
317
|
|
327
|
-
if (
|
328
|
-
|
329
|
-
} if (plugin[options]) {
|
330
|
-
return plugin[options].apply(this, Array.prototype.slice.call(args, 1));
|
331
|
-
} else {
|
332
|
-
$.error('Ezdz error - Method ' + options + ' does not exist.');
|
318
|
+
if ($.isFunction(callback)) {
|
319
|
+
callback.apply(this);
|
333
320
|
}
|
334
|
-
}
|
321
|
+
};
|
322
|
+
|
323
|
+
$ezdz.addClass(settings.classes.accept);
|
335
324
|
};
|
336
325
|
|
337
|
-
|
326
|
+
// Destroy ezdz
|
327
|
+
$.ezdz.prototype.destroy = function() {
|
328
|
+
var settings = this.settings,
|
329
|
+
$input = this.$input;
|
330
|
+
|
331
|
+
$input.parent('.' + settings.classes.main).replaceWith($input);
|
332
|
+
$input.off('*.ezdz');
|
333
|
+
$input.data('ezdz', '');
|
334
|
+
};
|
338
335
|
|
339
|
-
|
336
|
+
// Extend settings
|
337
|
+
$.ezdz.prototype.options = function(options) {
|
338
|
+
var settings = this.settings;
|
339
|
+
|
340
|
+
if (!options) {
|
341
|
+
return settings;
|
342
|
+
}
|
343
|
+
|
344
|
+
$.extend(true, this.settings, options);
|
345
|
+
};
|
346
|
+
|
347
|
+
// Get input container
|
348
|
+
$.ezdz.prototype.container = function() {
|
349
|
+
var settings = this.settings,
|
350
|
+
$input = this.$input;
|
351
|
+
|
352
|
+
return $input.parent('.' + settings.classes.main);
|
353
|
+
};
|
354
|
+
|
355
|
+
// Default options
|
356
|
+
$.ezdz.prototype.defaults = defaults;
|
357
|
+
|
358
|
+
// jQuery plugin
|
359
|
+
$.fn.ezdz = function(options) {
|
360
|
+
var args = arguments,
|
361
|
+
plugin = $(this).data('ezdz');
|
362
|
+
|
363
|
+
if (!plugin) {
|
364
|
+
return $(this).data('ezdz', new $.ezdz(this, options));
|
365
|
+
} if (plugin[options]) {
|
366
|
+
return plugin[options].apply(plugin, Array.prototype.slice.call(args, 1));
|
367
|
+
} else {
|
368
|
+
$.error('Ezdz error - Method ' + options + ' does not exist.');
|
369
|
+
}
|
370
|
+
};
|
371
|
+
}));
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/* ----------------------------------------------------------------------------
|
2
|
-
// Ezdz [izy-dizy]
|
3
|
-
// v0.2.
|
2
|
+
// Ezdz [izy-dizy]
|
3
|
+
// v0.2.1 - released 2013-10-16 00:41
|
4
4
|
// Licensed under the MIT license.
|
5
5
|
// https://github.com/jaysalvat/ezdz
|
6
6
|
// ----------------------------------------------------------------------------
|
@@ -23,7 +23,7 @@
|
|
23
23
|
|
24
24
|
.ezdz-dropzone div {
|
25
25
|
/* */
|
26
|
-
}
|
26
|
+
}
|
27
27
|
|
28
28
|
.ezdz-dropzone span {
|
29
29
|
border-radius: 20px;
|
@@ -68,7 +68,7 @@
|
|
68
68
|
border: 10px dotted darkgray;
|
69
69
|
color: darkgray;
|
70
70
|
}
|
71
|
-
|
71
|
+
|
72
72
|
.ezdz-enter {
|
73
73
|
border: 10px solid black;
|
74
74
|
color: black;
|