cropper_rails 1.1.0 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a48cf73eef4a56b9f3e4f8ac2194e85d67081e08c69ff1e3285117a903809847
4
- data.tar.gz: cf99aed64a5e250797ee0d52c2ff0cb0085cd2f7fe2b724489170c6b6a3d5ea1
3
+ metadata.gz: 8ab611e7ba302dd3f7982af9b85106b049cf669236178793a8b1685a6a7a9e1a
4
+ data.tar.gz: 4e756fa16d29b25a37591c9e9cfd0f695d2e6482847bd2e0538a630e89142438
5
5
  SHA512:
6
- metadata.gz: 8f2bd0297ff274f2b478f23251734d2a66e64a07f4901ce8b9c6a5d528b864ca32e28af51e3b90f49b9e1e41a1f676c40402b3aba7840881e80b8a0aba164133
7
- data.tar.gz: 14bcc7f5181847b6435eb24b73bf3c2d4699cb7da97376a116f3484a97e9040a7612572021167a7a3927a1eb5542f6be28cacb806b3561f7eac0ec5271d022a3
6
+ metadata.gz: 19de1996997e63973f7124d56d62e5576c20cfa0f8fcc19bdfce5fddb41f5e49e1f28ec86b2d9b257498217be91124b00980d7fad9664051768a6018a8a23e1c
7
+ data.tar.gz: 1be45b17c79360584b4f02205f73954493844624a0eb743d41cddc18527c05fa18f252b7a78951d52a8a728344d7468782cfeec09f4ce55009278b9e09320a93
data/VERSIONS.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  | Gem | Cropper.js | jQuery Cropper |
4
4
  |--------|------------|----------------|
5
+ | 1.1.5 | 1.5.12 | 1.0.1 |
6
+ | 1.1.4 | 1.5.11 | 1.0.1 |
7
+ | 1.1.3 | 1.5.11 | 1.0.1 |
8
+ | 1.1.2 | 1.5.10 | 1.0.1 |
9
+ | 1.1.1 | 1.5.9 | 1.0.1 |
5
10
  | 1.1.0 | 1.5.6 | 1.0.1 |
6
11
  | 1.0.2 | 1.4.3 | 1.0.0 |
7
12
  | 1.0.1 | 1.4.2 | 1.0.0 |
@@ -22,5 +22,5 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_runtime_dependency 'jquery-rails', '~> 4.0'
24
24
 
25
- spec.add_development_dependency 'bundler', '~> 2.0'
25
+ spec.add_development_dependency "bundler", ">= 2.2.10"
26
26
  end
@@ -1,7 +1,7 @@
1
1
  module Cropper
2
2
  module Rails
3
- VERSION = '1.1.0'.freeze
4
- CROPPER_VERSION = '1.5.6'.freeze
3
+ VERSION = '1.1.5'.freeze
4
+ CROPPER_VERSION = '1.5.12'.freeze
5
5
  JQUERY_CROPPER_VERSION = '1.0.1'.freeze
6
6
  end
7
7
  end
@@ -1,20 +1,60 @@
1
1
  /*!
2
- * Cropper.js v1.5.6
2
+ * Cropper.js v1.5.12
3
3
  * https://fengyuanchen.github.io/cropperjs
4
4
  *
5
5
  * Copyright 2015-present Chen Fengyuan
6
6
  * Released under the MIT license
7
7
  *
8
- * Date: 2019-10-04T04:33:48.372Z
8
+ * Date: 2021-06-12T08:00:17.411Z
9
9
  */
10
10
 
11
11
  (function (global, factory) {
12
12
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
13
13
  typeof define === 'function' && define.amd ? define(factory) :
14
- (global = global || self, global.Cropper = factory());
15
- }(this, function () { 'use strict';
14
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Cropper = factory());
15
+ }(this, (function () { 'use strict';
16
+
17
+ function ownKeys(object, enumerableOnly) {
18
+ var keys = Object.keys(object);
19
+
20
+ if (Object.getOwnPropertySymbols) {
21
+ var symbols = Object.getOwnPropertySymbols(object);
22
+
23
+ if (enumerableOnly) {
24
+ symbols = symbols.filter(function (sym) {
25
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
26
+ });
27
+ }
28
+
29
+ keys.push.apply(keys, symbols);
30
+ }
31
+
32
+ return keys;
33
+ }
34
+
35
+ function _objectSpread2(target) {
36
+ for (var i = 1; i < arguments.length; i++) {
37
+ var source = arguments[i] != null ? arguments[i] : {};
38
+
39
+ if (i % 2) {
40
+ ownKeys(Object(source), true).forEach(function (key) {
41
+ _defineProperty(target, key, source[key]);
42
+ });
43
+ } else if (Object.getOwnPropertyDescriptors) {
44
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
45
+ } else {
46
+ ownKeys(Object(source)).forEach(function (key) {
47
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
48
+ });
49
+ }
50
+ }
51
+
52
+ return target;
53
+ }
16
54
 
17
55
  function _typeof(obj) {
56
+ "@babel/helpers - typeof";
57
+
18
58
  if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
19
59
  _typeof = function (obj) {
20
60
  return typeof obj;
@@ -65,63 +105,42 @@
65
105
  return obj;
66
106
  }
67
107
 
68
- function ownKeys(object, enumerableOnly) {
69
- var keys = Object.keys(object);
70
-
71
- if (Object.getOwnPropertySymbols) {
72
- var symbols = Object.getOwnPropertySymbols(object);
73
- if (enumerableOnly) symbols = symbols.filter(function (sym) {
74
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
75
- });
76
- keys.push.apply(keys, symbols);
77
- }
78
-
79
- return keys;
108
+ function _toConsumableArray(arr) {
109
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
80
110
  }
81
111
 
82
- function _objectSpread2(target) {
83
- for (var i = 1; i < arguments.length; i++) {
84
- var source = arguments[i] != null ? arguments[i] : {};
85
-
86
- if (i % 2) {
87
- ownKeys(source, true).forEach(function (key) {
88
- _defineProperty(target, key, source[key]);
89
- });
90
- } else if (Object.getOwnPropertyDescriptors) {
91
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
92
- } else {
93
- ownKeys(source).forEach(function (key) {
94
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
95
- });
96
- }
97
- }
112
+ function _arrayWithoutHoles(arr) {
113
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
114
+ }
98
115
 
99
- return target;
116
+ function _iterableToArray(iter) {
117
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
100
118
  }
101
119
 
102
- function _toConsumableArray(arr) {
103
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
120
+ function _unsupportedIterableToArray(o, minLen) {
121
+ if (!o) return;
122
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
123
+ var n = Object.prototype.toString.call(o).slice(8, -1);
124
+ if (n === "Object" && o.constructor) n = o.constructor.name;
125
+ if (n === "Map" || n === "Set") return Array.from(o);
126
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
104
127
  }
105
128
 
106
- function _arrayWithoutHoles(arr) {
107
- if (Array.isArray(arr)) {
108
- for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
129
+ function _arrayLikeToArray(arr, len) {
130
+ if (len == null || len > arr.length) len = arr.length;
109
131
 
110
- return arr2;
111
- }
112
- }
132
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
113
133
 
114
- function _iterableToArray(iter) {
115
- if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
134
+ return arr2;
116
135
  }
117
136
 
118
137
  function _nonIterableSpread() {
119
- throw new TypeError("Invalid attempt to spread non-iterable instance");
138
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
120
139
  }
121
140
 
122
141
  var IS_BROWSER = typeof window !== 'undefined' && typeof window.document !== 'undefined';
123
142
  var WINDOW = IS_BROWSER ? window : {};
124
- var IS_TOUCH_DEVICE = IS_BROWSER ? 'ontouchstart' in WINDOW.document.documentElement : false;
143
+ var IS_TOUCH_DEVICE = IS_BROWSER && WINDOW.document.documentElement ? 'ontouchstart' in WINDOW.document.documentElement : false;
125
144
  var HAS_POINTER_EVENT = IS_BROWSER ? 'PointerEvent' in WINDOW : false;
126
145
  var NAMESPACE = 'cropper'; // Actions
127
146
 
@@ -242,8 +261,8 @@
242
261
  minCanvasHeight: 0,
243
262
  minCropBoxWidth: 0,
244
263
  minCropBoxHeight: 0,
245
- minContainerWidth: 200,
246
- minContainerHeight: 100,
264
+ minContainerWidth: MIN_CONTAINER_WIDTH,
265
+ minContainerHeight: MIN_CONTAINER_HEIGHT,
247
266
  // Shortcuts of events
248
267
  ready: null,
249
268
  cropstart: null,
@@ -386,7 +405,7 @@
386
405
  var REGEXP_DECIMALS = /\.\d*(?:0|9){12}\d*$/;
387
406
  /**
388
407
  * Normalize decimal number.
389
- * Check out {@link http://0.30000000000000004.com/}
408
+ * Check out {@link https://0.30000000000000004.com/}
390
409
  * @param {number} value - The value to normalize.
391
410
  * @param {number} [times=100000000000] - The times for normalizing.
392
411
  * @returns {number} Returns the normalized number.
@@ -791,7 +810,7 @@
791
810
  function getMaxZoomRatio(pointers) {
792
811
  var pointers2 = _objectSpread2({}, pointers);
793
812
 
794
- var ratios = [];
813
+ var maxRatio = 0;
795
814
  forEach(pointers, function (pointer, pointerId) {
796
815
  delete pointers2[pointerId];
797
816
  forEach(pointers2, function (pointer2) {
@@ -802,13 +821,13 @@
802
821
  var z1 = Math.sqrt(x1 * x1 + y1 * y1);
803
822
  var z2 = Math.sqrt(x2 * x2 + y2 * y2);
804
823
  var ratio = (z2 - z1) / z1;
805
- ratios.push(ratio);
824
+
825
+ if (Math.abs(ratio) > Math.abs(maxRatio)) {
826
+ maxRatio = ratio;
827
+ }
806
828
  });
807
829
  });
808
- ratios.sort(function (a, b) {
809
- return Math.abs(a) < Math.abs(b);
810
- });
811
- return ratios[0];
830
+ return maxRatio;
812
831
  }
813
832
  /**
814
833
  * Get a pointer from an event object.
@@ -1187,8 +1206,6 @@
1187
1206
  case 8:
1188
1207
  rotate = -90;
1189
1208
  break;
1190
-
1191
- default:
1192
1209
  }
1193
1210
 
1194
1211
  return {
@@ -1214,11 +1231,13 @@
1214
1231
  options = this.options,
1215
1232
  container = this.container,
1216
1233
  cropper = this.cropper;
1234
+ var minWidth = Number(options.minContainerWidth);
1235
+ var minHeight = Number(options.minContainerHeight);
1217
1236
  addClass(cropper, CLASS_HIDDEN);
1218
1237
  removeClass(element, CLASS_HIDDEN);
1219
1238
  var containerData = {
1220
- width: Math.max(container.offsetWidth, Number(options.minContainerWidth) || 200),
1221
- height: Math.max(container.offsetHeight, Number(options.minContainerHeight) || 100)
1239
+ width: Math.max(container.offsetWidth, minWidth >= 0 ? minWidth : MIN_CONTAINER_WIDTH),
1240
+ height: Math.max(container.offsetHeight, minHeight >= 0 ? minHeight : MIN_CONTAINER_HEIGHT)
1222
1241
  };
1223
1242
  this.containerData = containerData;
1224
1243
  setStyle(cropper, {
@@ -1259,14 +1278,15 @@
1259
1278
  width: canvasWidth,
1260
1279
  height: canvasHeight
1261
1280
  };
1262
- canvasData.left = (containerData.width - canvasWidth) / 2;
1263
- canvasData.top = (containerData.height - canvasHeight) / 2;
1264
- canvasData.oldLeft = canvasData.left;
1265
- canvasData.oldTop = canvasData.top;
1266
1281
  this.canvasData = canvasData;
1267
1282
  this.limited = viewMode === 1 || viewMode === 2;
1268
1283
  this.limitCanvas(true, true);
1269
- this.initialImageData = assign({}, imageData);
1284
+ canvasData.width = Math.min(Math.max(canvasData.width, canvasData.minWidth), canvasData.maxWidth);
1285
+ canvasData.height = Math.min(Math.max(canvasData.height, canvasData.minHeight), canvasData.maxHeight);
1286
+ canvasData.left = (containerData.width - canvasData.width) / 2;
1287
+ canvasData.top = (containerData.height - canvasData.height) / 2;
1288
+ canvasData.oldLeft = canvasData.left;
1289
+ canvasData.oldTop = canvasData.top;
1270
1290
  this.initialCanvasData = assign({}, canvasData);
1271
1291
  },
1272
1292
  limitCanvas: function limitCanvas(sizeLimited, positionLimited) {
@@ -1793,19 +1813,18 @@
1793
1813
 
1794
1814
  var handlers = {
1795
1815
  resize: function resize() {
1796
- var options = this.options,
1797
- container = this.container,
1798
- containerData = this.containerData;
1799
- var minContainerWidth = Number(options.minContainerWidth) || MIN_CONTAINER_WIDTH;
1800
- var minContainerHeight = Number(options.minContainerHeight) || MIN_CONTAINER_HEIGHT;
1801
-
1802
- if (this.disabled || containerData.width <= minContainerWidth || containerData.height <= minContainerHeight) {
1816
+ if (this.disabled) {
1803
1817
  return;
1804
1818
  }
1805
1819
 
1806
- var ratio = container.offsetWidth / containerData.width; // Resize when width changed or height changed
1820
+ var options = this.options,
1821
+ container = this.container,
1822
+ containerData = this.containerData;
1823
+ var ratioX = container.offsetWidth / containerData.width;
1824
+ var ratioY = container.offsetHeight / containerData.height;
1825
+ var ratio = Math.abs(ratioX - 1) > Math.abs(ratioY - 1) ? ratioX : ratioY; // Resize when width changed or height changed
1807
1826
 
1808
- if (ratio !== 1 || container.offsetHeight !== containerData.height) {
1827
+ if (ratio !== 1) {
1809
1828
  var canvasData;
1810
1829
  var cropBoxData;
1811
1830
 
@@ -2050,8 +2069,6 @@
2050
2069
  }
2051
2070
 
2052
2071
  break;
2053
-
2054
- default:
2055
2072
  }
2056
2073
  };
2057
2074
 
@@ -2416,8 +2433,6 @@
2416
2433
  }
2417
2434
 
2418
2435
  break;
2419
-
2420
- default:
2421
2436
  }
2422
2437
 
2423
2438
  if (renderable) {
@@ -3199,9 +3214,7 @@
3199
3214
 
3200
3215
  var AnotherCropper = WINDOW.Cropper;
3201
3216
 
3202
- var Cropper =
3203
- /*#__PURE__*/
3204
- function () {
3217
+ var Cropper = /*#__PURE__*/function () {
3205
3218
  /**
3206
3219
  * Create a new Cropper.
3207
3220
  * @param {Element} element - The target element for cropping.
@@ -3250,7 +3263,7 @@
3250
3263
 
3251
3264
  if (!url) {
3252
3265
  return;
3253
- } // e.g.: "http://example.com/img/picture.jpg"
3266
+ } // e.g.: "https://example.com/img/picture.jpg"
3254
3267
 
3255
3268
 
3256
3269
  url = element.src;
@@ -3331,9 +3344,10 @@
3331
3344
 
3332
3345
  if (options.checkCrossOrigin && isCrossOriginURL(url) && element.crossOrigin) {
3333
3346
  url = addTimestamp(url);
3334
- }
3347
+ } // The third parameter is required for avoiding side-effect (#682)
3348
+
3335
3349
 
3336
- xhr.open('GET', url);
3350
+ xhr.open('GET', url, true);
3337
3351
  xhr.responseType = 'arraybuffer';
3338
3352
  xhr.withCredentials = element.crossOrigin === 'use-credentials';
3339
3353
  xhr.send();
@@ -3424,6 +3438,7 @@
3424
3438
  naturalHeight: naturalHeight,
3425
3439
  aspectRatio: naturalWidth / naturalHeight
3426
3440
  });
3441
+ _this2.initialImageData = assign({}, _this2.imageData);
3427
3442
  _this2.sizing = false;
3428
3443
  _this2.sized = true;
3429
3444
 
@@ -3613,4 +3628,4 @@
3613
3628
 
3614
3629
  return Cropper;
3615
3630
 
3616
- }));
3631
+ })));
@@ -1,11 +1,11 @@
1
1
  /*!
2
- * Cropper.js v1.5.6
2
+ * Cropper.js v1.5.12
3
3
  * https://fengyuanchen.github.io/cropperjs
4
4
  *
5
5
  * Copyright 2015-present Chen Fengyuan
6
6
  * Released under the MIT license
7
7
  *
8
- * Date: 2019-10-04T04:33:44.164Z
8
+ * Date: 2021-06-12T08:00:11.623Z
9
9
  */
10
10
 
11
11
  .cropper-container {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cropper_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - D1ceWard
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-11 00:00:00.000000000 Z
11
+ date: 2021-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jquery-rails
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '2.0'
33
+ version: 2.2.10
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '2.0'
40
+ version: 2.2.10
41
41
  description: Cropper is a simple image cropping library. This gem integrates Cropper
42
42
  with Rails asset pipeline for ease of use.
43
43
  email:
@@ -66,7 +66,7 @@ homepage: https://github.com/D1ceWard/cropper_rails
66
66
  licenses:
67
67
  - MIT
68
68
  metadata: {}
69
- post_install_message:
69
+ post_install_message:
70
70
  rdoc_options: []
71
71
  require_paths:
72
72
  - lib
@@ -81,8 +81,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  requirements: []
84
- rubygems_version: 3.1.2
85
- signing_key:
84
+ rubygems_version: 3.1.6
85
+ signing_key:
86
86
  specification_version: 4
87
87
  summary: Integrate Cropper library with Rails asset pipeline
88
88
  test_files: []