card-mod-script 0.13.3 → 0.14.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/assets/script/decko/components.js.coffee +3 -0
  3. data/assets/script/decko/decko.js.coffee +0 -15
  4. data/assets/script/decko/editor.js.coffee +3 -1
  5. data/assets/script/decko/filter.js.coffee +13 -6
  6. data/assets/script/decko/mod.js.coffee +2 -8
  7. data/assets/script/{script_pointer_config.js.coffee → decko/pointer_config.js.coffee} +1 -2
  8. data/assets/script/{script_pointer_list_editor.js.coffee → decko/pointer_list_editor.js.coffee} +0 -0
  9. data/assets/script/decko/slot.js.coffee +2 -2
  10. data/assets/script/decko/slot_ready.js.coffee +1 -0
  11. data/assets/script/decko/slotter.js.coffee +23 -31
  12. data/assets/script/decko/type_editor.js.coffee +21 -0
  13. data/assets/script/decko/upload.js.coffee +12 -5
  14. data/assets/script/manifest.yml +15 -2
  15. data/set/abstract/00_script.rb +30 -31
  16. data/set/abstract/01_asset_script.rb +0 -16
  17. data/set/abstract/{script_asset_list.rb → script_group.rb} +12 -13
  18. data/set/all/head_javascript.rb +4 -5
  19. data/set/right/script.rb +1 -14
  20. data/set/type/local_script_folder_group.rb +2 -2
  21. data/set/type/local_script_manifest_group.rb +1 -1
  22. data/set/type_plus_right/mod/script.rb +56 -0
  23. data/set/type_plus_right/set/script.rb +7 -0
  24. data/vendor/jquery_file_upload/LICENSE.txt +11 -12
  25. data/vendor/jquery_file_upload/README.md +189 -72
  26. data/vendor/jquery_file_upload/SECURITY.md +227 -0
  27. data/vendor/jquery_file_upload/VULNERABILITIES.md +118 -0
  28. data/vendor/jquery_file_upload/cors/postmessage.html +68 -58
  29. data/vendor/jquery_file_upload/cors/result.html +12 -10
  30. data/vendor/jquery_file_upload/css/jquery.fileupload-ui.css +24 -13
  31. data/vendor/jquery_file_upload/css/jquery.fileupload.css +3 -4
  32. data/vendor/jquery_file_upload/docker-compose.yml +55 -0
  33. data/vendor/jquery_file_upload/index.html +332 -230
  34. data/vendor/jquery_file_upload/js/cors/jquery.postmessage-transport.js +109 -109
  35. data/vendor/jquery_file_upload/js/cors/jquery.xdr-transport.js +81 -73
  36. data/vendor/jquery_file_upload/js/demo.js +75 -0
  37. data/vendor/jquery_file_upload/js/jquery.fileupload-audio.js +82 -94
  38. data/vendor/jquery_file_upload/js/jquery.fileupload-image.js +321 -300
  39. data/vendor/jquery_file_upload/js/jquery.fileupload-process.js +138 -146
  40. data/vendor/jquery_file_upload/js/jquery.fileupload-ui.js +737 -692
  41. data/vendor/jquery_file_upload/js/jquery.fileupload-validate.js +91 -97
  42. data/vendor/jquery_file_upload/js/jquery.fileupload-video.js +82 -94
  43. data/vendor/jquery_file_upload/js/jquery.fileupload.js +1569 -1451
  44. data/vendor/jquery_file_upload/js/jquery.iframe-transport.js +208 -205
  45. data/vendor/jquery_file_upload/js/vendor/jquery.ui.widget.js +397 -340
  46. data/vendor/jquery_file_upload/package-lock.json +6853 -0
  47. data/vendor/jquery_file_upload/package.json +71 -10
  48. data/vendor/jquery_file_upload/server/gae-python/app.yaml +11 -10
  49. data/vendor/jquery_file_upload/server/php/Dockerfile +23 -17
  50. data/vendor/jquery_file_upload/server/php/UploadHandler.php +206 -137
  51. data/vendor/jquery_file_upload/server/php/php.ini +5 -0
  52. data/vendor/jquery_file_upload/test/index.html +36 -159
  53. data/vendor/jquery_file_upload/test/unit.js +989 -0
  54. data/vendor/jquery_file_upload/test/vendor/chai.js +10854 -0
  55. data/vendor/jquery_file_upload/test/vendor/mocha.css +325 -0
  56. data/vendor/jquery_file_upload/test/vendor/mocha.js +18178 -0
  57. data/vendor/jquery_file_upload/wdio/LICENSE.txt +20 -0
  58. data/vendor/jquery_file_upload/wdio/assets/black+white-3x2.jpg +0 -0
  59. data/vendor/jquery_file_upload/wdio/assets/black+white-60x40.gif +0 -0
  60. data/vendor/jquery_file_upload/wdio/conf/chrome.js +40 -0
  61. data/vendor/jquery_file_upload/wdio/conf/firefox.js +25 -0
  62. data/vendor/jquery_file_upload/wdio/hooks/index.js +36 -0
  63. data/vendor/jquery_file_upload/wdio/test/pages/file-upload.js +79 -0
  64. data/vendor/jquery_file_upload/wdio/test/specs/01-file-upload.js +25 -0
  65. data/vendor/jquery_file_upload/wdio/wdio.conf.js +4 -0
  66. metadata +34 -52
  67. data/file/mod_script_script_decko_machine_output/file.js +0 -2685
  68. data/file/mod_script_script_jquery_machine_output/file.js +0 -12924
  69. data/lib/javascript/script_html5shiv_printshiv.js +0 -1
  70. data/set/self/script_html5shiv_printshiv.rb +0 -11
  71. data/set/self/script_mods.rb +0 -1
  72. data/set/type/mod_script_assets.rb +0 -21
  73. data/vendor/jquery_file_upload/CONTRIBUTING.md +0 -15
  74. data/vendor/jquery_file_upload/angularjs.html +0 -211
  75. data/vendor/jquery_file_upload/basic-plus.html +0 -226
  76. data/vendor/jquery_file_upload/basic.html +0 -136
  77. data/vendor/jquery_file_upload/bower-version-update.js +0 -16
  78. data/vendor/jquery_file_upload/bower.json +0 -64
  79. data/vendor/jquery_file_upload/css/jquery-ui-demo-ie8.css +0 -21
  80. data/vendor/jquery_file_upload/css/jquery-ui-demo.css +0 -67
  81. data/vendor/jquery_file_upload/css/style.css +0 -15
  82. data/vendor/jquery_file_upload/jquery-ui.html +0 -252
  83. data/vendor/jquery_file_upload/js/app.js +0 -101
  84. data/vendor/jquery_file_upload/js/jquery.fileupload-angular.js +0 -437
  85. data/vendor/jquery_file_upload/js/jquery.fileupload-jquery-ui.js +0 -161
  86. data/vendor/jquery_file_upload/js/main.js +0 -75
  87. data/vendor/jquery_file_upload/server/gae-go/app/main.go +0 -361
  88. data/vendor/jquery_file_upload/server/gae-go/app.yaml +0 -12
  89. data/vendor/jquery_file_upload/server/gae-go/static/favicon.ico +0 -0
  90. data/vendor/jquery_file_upload/server/gae-go/static/robots.txt +0 -2
  91. data/vendor/jquery_file_upload/server/php/docker-compose.yml +0 -9
  92. data/vendor/jquery_file_upload/test/test.js +0 -1292
@@ -9,318 +9,339 @@
9
9
  * https://opensource.org/licenses/MIT
10
10
  */
11
11
 
12
- /* jshint nomen:false */
13
- /* global define, require, window, Blob */
12
+ /* global define, require */
14
13
 
15
- ;(function (factory) {
16
- 'use strict';
17
- if (typeof define === 'function' && define.amd) {
18
- // Register as an anonymous AMD module:
19
- define([
20
- 'jquery',
21
- 'load-image',
22
- 'load-image-meta',
23
- 'load-image-scale',
24
- 'load-image-exif',
25
- 'canvas-to-blob',
26
- './jquery.fileupload-process'
27
- ], factory);
28
- } else if (typeof exports === 'object') {
29
- // Node/CommonJS:
30
- factory(
31
- require('jquery'),
32
- require('blueimp-load-image/js/load-image'),
33
- require('blueimp-load-image/js/load-image-meta'),
34
- require('blueimp-load-image/js/load-image-scale'),
35
- require('blueimp-load-image/js/load-image-exif'),
36
- require('blueimp-canvas-to-blob'),
37
- require('./jquery.fileupload-process')
38
- );
39
- } else {
40
- // Browser globals:
41
- factory(
42
- window.jQuery,
43
- window.loadImage
44
- );
45
- }
46
- }(function ($, loadImage) {
47
- 'use strict';
48
-
49
- // Prepend to the default processQueue:
50
- $.blueimp.fileupload.prototype.options.processQueue.unshift(
51
- {
52
- action: 'loadImageMetaData',
53
- disableImageHead: '@',
54
- disableExif: '@',
55
- disableExifThumbnail: '@',
56
- disableExifSub: '@',
57
- disableExifGps: '@',
58
- disabled: '@disableImageMetaDataLoad'
59
- },
60
- {
61
- action: 'loadImage',
62
- // Use the action as prefix for the "@" options:
63
- prefix: true,
64
- fileTypes: '@',
65
- maxFileSize: '@',
66
- noRevoke: '@',
67
- disabled: '@disableImageLoad'
68
- },
69
- {
70
- action: 'resizeImage',
71
- // Use "image" as prefix for the "@" options:
72
- prefix: 'image',
73
- maxWidth: '@',
74
- maxHeight: '@',
75
- minWidth: '@',
76
- minHeight: '@',
77
- crop: '@',
78
- orientation: '@',
79
- forceResize: '@',
80
- disabled: '@disableImageResize'
81
- },
82
- {
83
- action: 'saveImage',
84
- quality: '@imageQuality',
85
- type: '@imageType',
86
- disabled: '@disableImageResize'
87
- },
88
- {
89
- action: 'saveImageMetaData',
90
- disabled: '@disableImageMetaDataSave'
91
- },
92
- {
93
- action: 'resizeImage',
94
- // Use "preview" as prefix for the "@" options:
95
- prefix: 'preview',
96
- maxWidth: '@',
97
- maxHeight: '@',
98
- minWidth: '@',
99
- minHeight: '@',
100
- crop: '@',
101
- orientation: '@',
102
- thumbnail: '@',
103
- canvas: '@',
104
- disabled: '@disableImagePreview'
105
- },
106
- {
107
- action: 'setImage',
108
- name: '@imagePreviewName',
109
- disabled: '@disableImagePreview'
110
- },
111
- {
112
- action: 'deleteImageReferences',
113
- disabled: '@disableImageReferencesDeletion'
114
- }
14
+ (function (factory) {
15
+ 'use strict';
16
+ if (typeof define === 'function' && define.amd) {
17
+ // Register as an anonymous AMD module:
18
+ define([
19
+ 'jquery',
20
+ 'load-image',
21
+ 'load-image-meta',
22
+ 'load-image-scale',
23
+ 'load-image-exif',
24
+ 'load-image-orientation',
25
+ 'canvas-to-blob',
26
+ './jquery.fileupload-process'
27
+ ], factory);
28
+ } else if (typeof exports === 'object') {
29
+ // Node/CommonJS:
30
+ factory(
31
+ require('jquery'),
32
+ require('blueimp-load-image/js/load-image'),
33
+ require('blueimp-load-image/js/load-image-meta'),
34
+ require('blueimp-load-image/js/load-image-scale'),
35
+ require('blueimp-load-image/js/load-image-exif'),
36
+ require('blueimp-load-image/js/load-image-orientation'),
37
+ require('blueimp-canvas-to-blob'),
38
+ require('./jquery.fileupload-process')
115
39
  );
40
+ } else {
41
+ // Browser globals:
42
+ factory(window.jQuery, window.loadImage);
43
+ }
44
+ })(function ($, loadImage) {
45
+ 'use strict';
116
46
 
117
- // The File Upload Resize plugin extends the fileupload widget
118
- // with image resize functionality:
119
- $.widget('blueimp.fileupload', $.blueimp.fileupload, {
120
-
121
- options: {
122
- // The regular expression for the types of images to load:
123
- // matched against the file type:
124
- loadImageFileTypes: /^image\/(gif|jpeg|png|svg\+xml)$/,
125
- // The maximum file size of images to load:
126
- loadImageMaxFileSize: 10000000, // 10MB
127
- // The maximum width of resized images:
128
- imageMaxWidth: 1920,
129
- // The maximum height of resized images:
130
- imageMaxHeight: 1080,
131
- // Defines the image orientation (1-8) or takes the orientation
132
- // value from Exif data if set to true:
133
- imageOrientation: false,
134
- // Define if resized images should be cropped or only scaled:
135
- imageCrop: false,
136
- // Disable the resize image functionality by default:
137
- disableImageResize: true,
138
- // The maximum width of the preview images:
139
- previewMaxWidth: 80,
140
- // The maximum height of the preview images:
141
- previewMaxHeight: 80,
142
- // Defines the preview orientation (1-8) or takes the orientation
143
- // value from Exif data if set to true:
144
- previewOrientation: true,
145
- // Create the preview using the Exif data thumbnail:
146
- previewThumbnail: true,
147
- // Define if preview images should be cropped or only scaled:
148
- previewCrop: false,
149
- // Define if preview images should be resized as canvas elements:
150
- previewCanvas: true
151
- },
152
-
153
- processActions: {
154
-
155
- // Loads the image given via data.files and data.index
156
- // as img element, if the browser supports the File API.
157
- // Accepts the options fileTypes (regular expression)
158
- // and maxFileSize (integer) to limit the files to load:
159
- loadImage: function (data, options) {
160
- if (options.disabled) {
161
- return data;
162
- }
163
- var that = this,
164
- file = data.files[data.index],
165
- dfd = $.Deferred();
166
- if (($.type(options.maxFileSize) === 'number' &&
167
- file.size > options.maxFileSize) ||
168
- (options.fileTypes &&
169
- !options.fileTypes.test(file.type)) ||
170
- !loadImage(
171
- file,
172
- function (img) {
173
- if (img.src) {
174
- data.img = img;
175
- }
176
- dfd.resolveWith(that, [data]);
177
- },
178
- options
179
- )) {
180
- return data;
181
- }
182
- return dfd.promise();
183
- },
184
-
185
- // Resizes the image given as data.canvas or data.img
186
- // and updates data.canvas or data.img with the resized image.
187
- // Also stores the resized image as preview property.
188
- // Accepts the options maxWidth, maxHeight, minWidth,
189
- // minHeight, canvas and crop:
190
- resizeImage: function (data, options) {
191
- if (options.disabled || !(data.canvas || data.img)) {
192
- return data;
193
- }
194
- options = $.extend({canvas: true}, options);
195
- var that = this,
196
- dfd = $.Deferred(),
197
- img = (options.canvas && data.canvas) || data.img,
198
- resolve = function (newImg) {
199
- if (newImg && (newImg.width !== img.width ||
200
- newImg.height !== img.height ||
201
- options.forceResize)) {
202
- data[newImg.getContext ? 'canvas' : 'img'] = newImg;
203
- }
204
- data.preview = newImg;
205
- dfd.resolveWith(that, [data]);
206
- },
207
- thumbnail;
208
- if (data.exif) {
209
- if (options.orientation === true) {
210
- options.orientation = data.exif.get('Orientation');
211
- }
212
- if (options.thumbnail) {
213
- thumbnail = data.exif.get('Thumbnail');
214
- if (thumbnail) {
215
- loadImage(thumbnail, resolve, options);
216
- return dfd.promise();
217
- }
218
- }
219
- // Prevent orienting the same image twice:
220
- if (data.orientation) {
221
- delete options.orientation;
222
- } else {
223
- data.orientation = options.orientation;
224
- }
225
- }
226
- if (img) {
227
- resolve(loadImage.scale(img, options));
228
- return dfd.promise();
229
- }
230
- return data;
231
- },
47
+ // Prepend to the default processQueue:
48
+ $.blueimp.fileupload.prototype.options.processQueue.unshift(
49
+ {
50
+ action: 'loadImageMetaData',
51
+ maxMetaDataSize: '@',
52
+ disableImageHead: '@',
53
+ disableMetaDataParsers: '@',
54
+ disableExif: '@',
55
+ disableExifOffsets: '@',
56
+ includeExifTags: '@',
57
+ excludeExifTags: '@',
58
+ disableIptc: '@',
59
+ disableIptcOffsets: '@',
60
+ includeIptcTags: '@',
61
+ excludeIptcTags: '@',
62
+ disabled: '@disableImageMetaDataLoad'
63
+ },
64
+ {
65
+ action: 'loadImage',
66
+ // Use the action as prefix for the "@" options:
67
+ prefix: true,
68
+ fileTypes: '@',
69
+ maxFileSize: '@',
70
+ noRevoke: '@',
71
+ disabled: '@disableImageLoad'
72
+ },
73
+ {
74
+ action: 'resizeImage',
75
+ // Use "image" as prefix for the "@" options:
76
+ prefix: 'image',
77
+ maxWidth: '@',
78
+ maxHeight: '@',
79
+ minWidth: '@',
80
+ minHeight: '@',
81
+ crop: '@',
82
+ orientation: '@',
83
+ forceResize: '@',
84
+ disabled: '@disableImageResize',
85
+ imageSmoothingQuality: '@imageSmoothingQuality'
86
+ },
87
+ {
88
+ action: 'saveImage',
89
+ quality: '@imageQuality',
90
+ type: '@imageType',
91
+ disabled: '@disableImageResize'
92
+ },
93
+ {
94
+ action: 'saveImageMetaData',
95
+ disabled: '@disableImageMetaDataSave'
96
+ },
97
+ {
98
+ action: 'resizeImage',
99
+ // Use "preview" as prefix for the "@" options:
100
+ prefix: 'preview',
101
+ maxWidth: '@',
102
+ maxHeight: '@',
103
+ minWidth: '@',
104
+ minHeight: '@',
105
+ crop: '@',
106
+ orientation: '@',
107
+ thumbnail: '@',
108
+ canvas: '@',
109
+ disabled: '@disableImagePreview'
110
+ },
111
+ {
112
+ action: 'setImage',
113
+ name: '@imagePreviewName',
114
+ disabled: '@disableImagePreview'
115
+ },
116
+ {
117
+ action: 'deleteImageReferences',
118
+ disabled: '@disableImageReferencesDeletion'
119
+ }
120
+ );
232
121
 
233
- // Saves the processed image given as data.canvas
234
- // inplace at data.index of data.files:
235
- saveImage: function (data, options) {
236
- if (!data.canvas || options.disabled) {
237
- return data;
238
- }
239
- var that = this,
240
- file = data.files[data.index],
241
- dfd = $.Deferred();
242
- if (data.canvas.toBlob) {
243
- data.canvas.toBlob(
244
- function (blob) {
245
- if (!blob.name) {
246
- if (file.type === blob.type) {
247
- blob.name = file.name;
248
- } else if (file.name) {
249
- blob.name = file.name.replace(
250
- /\.\w+$/,
251
- '.' + blob.type.substr(6)
252
- );
253
- }
254
- }
255
- // Don't restore invalid meta data:
256
- if (file.type !== blob.type) {
257
- delete data.imageHead;
258
- }
259
- // Store the created blob at the position
260
- // of the original file in the files list:
261
- data.files[data.index] = blob;
262
- dfd.resolveWith(that, [data]);
263
- },
264
- options.type || file.type,
265
- options.quality
266
- );
267
- } else {
268
- return data;
269
- }
270
- return dfd.promise();
271
- },
122
+ // The File Upload Resize plugin extends the fileupload widget
123
+ // with image resize functionality:
124
+ $.widget('blueimp.fileupload', $.blueimp.fileupload, {
125
+ options: {
126
+ // The regular expression for the types of images to load:
127
+ // matched against the file type:
128
+ loadImageFileTypes: /^image\/(gif|jpeg|png|svg\+xml)$/,
129
+ // The maximum file size of images to load:
130
+ loadImageMaxFileSize: 10000000, // 10MB
131
+ // The maximum width of resized images:
132
+ imageMaxWidth: 1920,
133
+ // The maximum height of resized images:
134
+ imageMaxHeight: 1080,
135
+ // Defines the image orientation (1-8) or takes the orientation
136
+ // value from Exif data if set to true:
137
+ imageOrientation: true,
138
+ // Define if resized images should be cropped or only scaled:
139
+ imageCrop: false,
140
+ // Disable the resize image functionality by default:
141
+ disableImageResize: true,
142
+ // The maximum width of the preview images:
143
+ previewMaxWidth: 80,
144
+ // The maximum height of the preview images:
145
+ previewMaxHeight: 80,
146
+ // Defines the preview orientation (1-8) or takes the orientation
147
+ // value from Exif data if set to true:
148
+ previewOrientation: true,
149
+ // Create the preview using the Exif data thumbnail:
150
+ previewThumbnail: true,
151
+ // Define if preview images should be cropped or only scaled:
152
+ previewCrop: false,
153
+ // Define if preview images should be resized as canvas elements:
154
+ previewCanvas: true
155
+ },
272
156
 
273
- loadImageMetaData: function (data, options) {
274
- if (options.disabled) {
275
- return data;
276
- }
277
- var that = this,
278
- dfd = $.Deferred();
279
- loadImage.parseMetaData(data.files[data.index], function (result) {
280
- $.extend(data, result);
281
- dfd.resolveWith(that, [data]);
282
- }, options);
283
- return dfd.promise();
157
+ processActions: {
158
+ // Loads the image given via data.files and data.index
159
+ // as img element, if the browser supports the File API.
160
+ // Accepts the options fileTypes (regular expression)
161
+ // and maxFileSize (integer) to limit the files to load:
162
+ loadImage: function (data, options) {
163
+ if (options.disabled) {
164
+ return data;
165
+ }
166
+ var that = this,
167
+ file = data.files[data.index],
168
+ // eslint-disable-next-line new-cap
169
+ dfd = $.Deferred();
170
+ if (
171
+ ($.type(options.maxFileSize) === 'number' &&
172
+ file.size > options.maxFileSize) ||
173
+ (options.fileTypes && !options.fileTypes.test(file.type)) ||
174
+ !loadImage(
175
+ file,
176
+ function (img) {
177
+ if (img.src) {
178
+ data.img = img;
179
+ }
180
+ dfd.resolveWith(that, [data]);
284
181
  },
182
+ options
183
+ )
184
+ ) {
185
+ return data;
186
+ }
187
+ return dfd.promise();
188
+ },
285
189
 
286
- saveImageMetaData: function (data, options) {
287
- if (!(data.imageHead && data.canvas &&
288
- data.canvas.toBlob && !options.disabled)) {
289
- return data;
290
- }
291
- var file = data.files[data.index],
292
- blob = new Blob([
293
- data.imageHead,
294
- // Resized images always have a head size of 20 bytes,
295
- // including the JPEG marker and a minimal JFIF header:
296
- this._blobSlice.call(file, 20)
297
- ], {type: file.type});
298
- blob.name = file.name;
299
- data.files[data.index] = blob;
300
- return data;
301
- },
190
+ // Resizes the image given as data.canvas or data.img
191
+ // and updates data.canvas or data.img with the resized image.
192
+ // Also stores the resized image as preview property.
193
+ // Accepts the options maxWidth, maxHeight, minWidth,
194
+ // minHeight, canvas and crop:
195
+ resizeImage: function (data, options) {
196
+ if (options.disabled || !(data.canvas || data.img)) {
197
+ return data;
198
+ }
199
+ // eslint-disable-next-line no-param-reassign
200
+ options = $.extend({ canvas: true }, options);
201
+ var that = this,
202
+ // eslint-disable-next-line new-cap
203
+ dfd = $.Deferred(),
204
+ img = (options.canvas && data.canvas) || data.img,
205
+ resolve = function (newImg) {
206
+ if (
207
+ newImg &&
208
+ (newImg.width !== img.width ||
209
+ newImg.height !== img.height ||
210
+ options.forceResize)
211
+ ) {
212
+ data[newImg.getContext ? 'canvas' : 'img'] = newImg;
213
+ }
214
+ data.preview = newImg;
215
+ dfd.resolveWith(that, [data]);
216
+ },
217
+ thumbnail,
218
+ thumbnailBlob;
219
+ if (data.exif && options.thumbnail) {
220
+ thumbnail = data.exif.get('Thumbnail');
221
+ thumbnailBlob = thumbnail && thumbnail.get('Blob');
222
+ if (thumbnailBlob) {
223
+ options.orientation = data.exif.get('Orientation');
224
+ loadImage(thumbnailBlob, resolve, options);
225
+ return dfd.promise();
226
+ }
227
+ }
228
+ if (data.orientation) {
229
+ // Prevent orienting the same image twice:
230
+ delete options.orientation;
231
+ } else {
232
+ data.orientation = options.orientation || loadImage.orientation;
233
+ }
234
+ if (img) {
235
+ resolve(loadImage.scale(img, options, data));
236
+ return dfd.promise();
237
+ }
238
+ return data;
239
+ },
302
240
 
303
- // Sets the resized version of the image as a property of the
304
- // file object, must be called after "saveImage":
305
- setImage: function (data, options) {
306
- if (data.preview && !options.disabled) {
307
- data.files[data.index][options.name || 'preview'] = data.preview;
241
+ // Saves the processed image given as data.canvas
242
+ // inplace at data.index of data.files:
243
+ saveImage: function (data, options) {
244
+ if (!data.canvas || options.disabled) {
245
+ return data;
246
+ }
247
+ var that = this,
248
+ file = data.files[data.index],
249
+ // eslint-disable-next-line new-cap
250
+ dfd = $.Deferred();
251
+ if (data.canvas.toBlob) {
252
+ data.canvas.toBlob(
253
+ function (blob) {
254
+ if (!blob.name) {
255
+ if (file.type === blob.type) {
256
+ blob.name = file.name;
257
+ } else if (file.name) {
258
+ blob.name = file.name.replace(
259
+ /\.\w+$/,
260
+ '.' + blob.type.substr(6)
261
+ );
308
262
  }
309
- return data;
263
+ }
264
+ // Don't restore invalid meta data:
265
+ if (file.type !== blob.type) {
266
+ delete data.imageHead;
267
+ }
268
+ // Store the created blob at the position
269
+ // of the original file in the files list:
270
+ data.files[data.index] = blob;
271
+ dfd.resolveWith(that, [data]);
310
272
  },
273
+ options.type || file.type,
274
+ options.quality
275
+ );
276
+ } else {
277
+ return data;
278
+ }
279
+ return dfd.promise();
280
+ },
311
281
 
312
- deleteImageReferences: function (data, options) {
313
- if (!options.disabled) {
314
- delete data.img;
315
- delete data.canvas;
316
- delete data.preview;
317
- delete data.imageHead;
318
- }
319
- return data;
320
- }
282
+ loadImageMetaData: function (data, options) {
283
+ if (options.disabled) {
284
+ return data;
285
+ }
286
+ var that = this,
287
+ // eslint-disable-next-line new-cap
288
+ dfd = $.Deferred();
289
+ loadImage.parseMetaData(
290
+ data.files[data.index],
291
+ function (result) {
292
+ $.extend(data, result);
293
+ dfd.resolveWith(that, [data]);
294
+ },
295
+ options
296
+ );
297
+ return dfd.promise();
298
+ },
321
299
 
300
+ saveImageMetaData: function (data, options) {
301
+ if (
302
+ !(
303
+ data.imageHead &&
304
+ data.canvas &&
305
+ data.canvas.toBlob &&
306
+ !options.disabled
307
+ )
308
+ ) {
309
+ return data;
310
+ }
311
+ var that = this,
312
+ file = data.files[data.index],
313
+ // eslint-disable-next-line new-cap
314
+ dfd = $.Deferred();
315
+ if (data.orientation === true && data.exifOffsets) {
316
+ // Reset Exif Orientation data:
317
+ loadImage.writeExifData(data.imageHead, data, 'Orientation', 1);
322
318
  }
319
+ loadImage.replaceHead(file, data.imageHead, function (blob) {
320
+ blob.name = file.name;
321
+ data.files[data.index] = blob;
322
+ dfd.resolveWith(that, [data]);
323
+ });
324
+ return dfd.promise();
325
+ },
323
326
 
324
- });
327
+ // Sets the resized version of the image as a property of the
328
+ // file object, must be called after "saveImage":
329
+ setImage: function (data, options) {
330
+ if (data.preview && !options.disabled) {
331
+ data.files[data.index][options.name || 'preview'] = data.preview;
332
+ }
333
+ return data;
334
+ },
325
335
 
326
- }));
336
+ deleteImageReferences: function (data, options) {
337
+ if (!options.disabled) {
338
+ delete data.img;
339
+ delete data.canvas;
340
+ delete data.preview;
341
+ delete data.imageHead;
342
+ }
343
+ return data;
344
+ }
345
+ }
346
+ });
347
+ });