|
11 | 11 |
|
12 | 12 | /* global define, require */
|
13 | 13 |
|
14 |
| -(function(factory) { |
| 14 | +(function (factory) { |
15 | 15 | 'use strict';
|
16 | 16 | if (typeof define === 'function' && define.amd) {
|
17 | 17 | // Register as an anonymous AMD module:
|
|
39 | 39 | // Browser globals:
|
40 | 40 | factory(window.jQuery, window.loadImage);
|
41 | 41 | }
|
42 |
| -})(function($, loadImage) { |
| 42 | +})(function ($, loadImage) { |
43 | 43 | 'use strict';
|
44 | 44 |
|
45 | 45 | // Prepend to the default processQueue:
|
|
150 | 150 | // as img element, if the browser supports the File API.
|
151 | 151 | // Accepts the options fileTypes (regular expression)
|
152 | 152 | // and maxFileSize (integer) to limit the files to load:
|
153 |
| - loadImage: function(data, options) { |
| 153 | + loadImage: function (data, options) { |
154 | 154 | if (options.disabled) {
|
155 | 155 | return data;
|
156 | 156 | }
|
|
164 | 164 | (options.fileTypes && !options.fileTypes.test(file.type)) ||
|
165 | 165 | !loadImage(
|
166 | 166 | file,
|
167 |
| - function(img) { |
| 167 | + function (img) { |
168 | 168 | if (img.src) {
|
169 | 169 | data.img = img;
|
170 | 170 | }
|
|
183 | 183 | // Also stores the resized image as preview property.
|
184 | 184 | // Accepts the options maxWidth, maxHeight, minWidth,
|
185 | 185 | // minHeight, canvas and crop:
|
186 |
| - resizeImage: function(data, options) { |
| 186 | + resizeImage: function (data, options) { |
187 | 187 | if (options.disabled || !(data.canvas || data.img)) {
|
188 | 188 | return data;
|
189 | 189 | }
|
|
193 | 193 | // eslint-disable-next-line new-cap
|
194 | 194 | dfd = $.Deferred(),
|
195 | 195 | img = (options.canvas && data.canvas) || data.img,
|
196 |
| - resolve = function(newImg) { |
| 196 | + resolve = function (newImg) { |
197 | 197 | if (
|
198 | 198 | newImg &&
|
199 | 199 | (newImg.width !== img.width ||
|
|
233 | 233 |
|
234 | 234 | // Saves the processed image given as data.canvas
|
235 | 235 | // inplace at data.index of data.files:
|
236 |
| - saveImage: function(data, options) { |
| 236 | + saveImage: function (data, options) { |
237 | 237 | if (!data.canvas || options.disabled) {
|
238 | 238 | return data;
|
239 | 239 | }
|
|
243 | 243 | dfd = $.Deferred();
|
244 | 244 | if (data.canvas.toBlob) {
|
245 | 245 | data.canvas.toBlob(
|
246 |
| - function(blob) { |
| 246 | + function (blob) { |
247 | 247 | if (!blob.name) {
|
248 | 248 | if (file.type === blob.type) {
|
249 | 249 | blob.name = file.name;
|
|
272 | 272 | return dfd.promise();
|
273 | 273 | },
|
274 | 274 |
|
275 |
| - loadImageMetaData: function(data, options) { |
| 275 | + loadImageMetaData: function (data, options) { |
276 | 276 | if (options.disabled) {
|
277 | 277 | return data;
|
278 | 278 | }
|
|
281 | 281 | dfd = $.Deferred();
|
282 | 282 | loadImage.parseMetaData(
|
283 | 283 | data.files[data.index],
|
284 |
| - function(result) { |
| 284 | + function (result) { |
285 | 285 | $.extend(data, result);
|
286 | 286 | dfd.resolveWith(that, [data]);
|
287 | 287 | },
|
|
290 | 290 | return dfd.promise();
|
291 | 291 | },
|
292 | 292 |
|
293 |
| - saveImageMetaData: function(data, options) { |
| 293 | + saveImageMetaData: function (data, options) { |
294 | 294 | if (
|
295 | 295 | !(
|
296 | 296 | data.imageHead &&
|
|
318 | 318 |
|
319 | 319 | // Sets the resized version of the image as a property of the
|
320 | 320 | // file object, must be called after "saveImage":
|
321 |
| - setImage: function(data, options) { |
| 321 | + setImage: function (data, options) { |
322 | 322 | if (data.preview && !options.disabled) {
|
323 | 323 | data.files[data.index][options.name || 'preview'] = data.preview;
|
324 | 324 | }
|
325 | 325 | return data;
|
326 | 326 | },
|
327 | 327 |
|
328 |
| - deleteImageReferences: function(data, options) { |
| 328 | + deleteImageReferences: function (data, options) { |
329 | 329 | if (!options.disabled) {
|
330 | 330 | delete data.img;
|
331 | 331 | delete data.canvas;
|
|
0 commit comments