cropper_rails 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a48cf73eef4a56b9f3e4f8ac2194e85d67081e08c69ff1e3285117a903809847
4
- data.tar.gz: cf99aed64a5e250797ee0d52c2ff0cb0085cd2f7fe2b724489170c6b6a3d5ea1
3
+ metadata.gz: e8ef8308edf6f25c7415145063150d82ec824ecd4f5494cddbfe2e7e73417cf4
4
+ data.tar.gz: 6b58a399f6827655a4d68e65aacdd5e3e8e269dc8d4190d3193420b7be631f04
5
5
  SHA512:
6
- metadata.gz: 8f2bd0297ff274f2b478f23251734d2a66e64a07f4901ce8b9c6a5d528b864ca32e28af51e3b90f49b9e1e41a1f676c40402b3aba7840881e80b8a0aba164133
7
- data.tar.gz: 14bcc7f5181847b6435eb24b73bf3c2d4699cb7da97376a116f3484a97e9040a7612572021167a7a3927a1eb5542f6be28cacb806b3561f7eac0ec5271d022a3
6
+ metadata.gz: b6cbe46648b3ddc3cf689f8a187e4ec2cf55ae1b3861b149bed6ef84738fb5a8eb6991012d08312a6b255c404fe0f259f03e551fd850419b96f1e4a6337d130a
7
+ data.tar.gz: d63e1fa751231abe4955eb36f570764c9e62c361a7806be799c8d31b295dd36047eb52de2c401bc4ecfcc934e14630e8e197cb3694cd3fe0aaabcf07be6ad199
@@ -2,6 +2,7 @@
2
2
 
3
3
  | Gem | Cropper.js | jQuery Cropper |
4
4
  |--------|------------|----------------|
5
+ | 1.1.1 | 1.5.9 | 1.0.1 |
5
6
  | 1.1.0 | 1.5.6 | 1.0.1 |
6
7
  | 1.0.2 | 1.4.3 | 1.0.0 |
7
8
  | 1.0.1 | 1.4.2 | 1.0.0 |
@@ -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.1'.freeze
4
+ CROPPER_VERSION = '1.5.9'.freeze
5
5
  JQUERY_CROPPER_VERSION = '1.0.1'.freeze
6
6
  end
7
7
  end
@@ -1,20 +1,22 @@
1
1
  /*!
2
- * Cropper.js v1.5.6
2
+ * Cropper.js v1.5.9
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: 2020-09-10T13:16:26.743Z
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
16
 
17
17
  function _typeof(obj) {
18
+ "@babel/helpers - typeof";
19
+
18
20
  if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
19
21
  _typeof = function (obj) {
20
22
  return typeof obj;
@@ -84,13 +86,13 @@
84
86
  var source = arguments[i] != null ? arguments[i] : {};
85
87
 
86
88
  if (i % 2) {
87
- ownKeys(source, true).forEach(function (key) {
89
+ ownKeys(Object(source), true).forEach(function (key) {
88
90
  _defineProperty(target, key, source[key]);
89
91
  });
90
92
  } else if (Object.getOwnPropertyDescriptors) {
91
93
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
92
94
  } else {
93
- ownKeys(source).forEach(function (key) {
95
+ ownKeys(Object(source)).forEach(function (key) {
94
96
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
95
97
  });
96
98
  }
@@ -100,28 +102,41 @@
100
102
  }
101
103
 
102
104
  function _toConsumableArray(arr) {
103
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
105
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
104
106
  }
105
107
 
106
108
  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];
109
-
110
- return arr2;
111
- }
109
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
112
110
  }
113
111
 
114
112
  function _iterableToArray(iter) {
115
- if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
113
+ if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
114
+ }
115
+
116
+ function _unsupportedIterableToArray(o, minLen) {
117
+ if (!o) return;
118
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
119
+ var n = Object.prototype.toString.call(o).slice(8, -1);
120
+ if (n === "Object" && o.constructor) n = o.constructor.name;
121
+ if (n === "Map" || n === "Set") return Array.from(o);
122
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
123
+ }
124
+
125
+ function _arrayLikeToArray(arr, len) {
126
+ if (len == null || len > arr.length) len = arr.length;
127
+
128
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
129
+
130
+ return arr2;
116
131
  }
117
132
 
118
133
  function _nonIterableSpread() {
119
- throw new TypeError("Invalid attempt to spread non-iterable instance");
134
+ 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
135
  }
121
136
 
122
137
  var IS_BROWSER = typeof window !== 'undefined' && typeof window.document !== 'undefined';
123
138
  var WINDOW = IS_BROWSER ? window : {};
124
- var IS_TOUCH_DEVICE = IS_BROWSER ? 'ontouchstart' in WINDOW.document.documentElement : false;
139
+ var IS_TOUCH_DEVICE = IS_BROWSER && WINDOW.document.documentElement ? 'ontouchstart' in WINDOW.document.documentElement : false;
125
140
  var HAS_POINTER_EVENT = IS_BROWSER ? 'PointerEvent' in WINDOW : false;
126
141
  var NAMESPACE = 'cropper'; // Actions
127
142
 
@@ -242,8 +257,8 @@
242
257
  minCanvasHeight: 0,
243
258
  minCropBoxWidth: 0,
244
259
  minCropBoxHeight: 0,
245
- minContainerWidth: 200,
246
- minContainerHeight: 100,
260
+ minContainerWidth: MIN_CONTAINER_WIDTH,
261
+ minContainerHeight: MIN_CONTAINER_HEIGHT,
247
262
  // Shortcuts of events
248
263
  ready: null,
249
264
  cropstart: null,
@@ -386,7 +401,7 @@
386
401
  var REGEXP_DECIMALS = /\.\d*(?:0|9){12}\d*$/;
387
402
  /**
388
403
  * Normalize decimal number.
389
- * Check out {@link http://0.30000000000000004.com/}
404
+ * Check out {@link https://0.30000000000000004.com/}
390
405
  * @param {number} value - The value to normalize.
391
406
  * @param {number} [times=100000000000] - The times for normalizing.
392
407
  * @returns {number} Returns the normalized number.
@@ -791,7 +806,7 @@
791
806
  function getMaxZoomRatio(pointers) {
792
807
  var pointers2 = _objectSpread2({}, pointers);
793
808
 
794
- var ratios = [];
809
+ var maxRatio = 0;
795
810
  forEach(pointers, function (pointer, pointerId) {
796
811
  delete pointers2[pointerId];
797
812
  forEach(pointers2, function (pointer2) {
@@ -802,13 +817,13 @@
802
817
  var z1 = Math.sqrt(x1 * x1 + y1 * y1);
803
818
  var z2 = Math.sqrt(x2 * x2 + y2 * y2);
804
819
  var ratio = (z2 - z1) / z1;
805
- ratios.push(ratio);
820
+
821
+ if (Math.abs(ratio) > Math.abs(maxRatio)) {
822
+ maxRatio = ratio;
823
+ }
806
824
  });
807
825
  });
808
- ratios.sort(function (a, b) {
809
- return Math.abs(a) < Math.abs(b);
810
- });
811
- return ratios[0];
826
+ return maxRatio;
812
827
  }
813
828
  /**
814
829
  * Get a pointer from an event object.
@@ -1187,8 +1202,6 @@
1187
1202
  case 8:
1188
1203
  rotate = -90;
1189
1204
  break;
1190
-
1191
- default:
1192
1205
  }
1193
1206
 
1194
1207
  return {
@@ -1214,11 +1227,13 @@
1214
1227
  options = this.options,
1215
1228
  container = this.container,
1216
1229
  cropper = this.cropper;
1230
+ var minWidth = Number(options.minContainerWidth);
1231
+ var minHeight = Number(options.minContainerHeight);
1217
1232
  addClass(cropper, CLASS_HIDDEN);
1218
1233
  removeClass(element, CLASS_HIDDEN);
1219
1234
  var containerData = {
1220
- width: Math.max(container.offsetWidth, Number(options.minContainerWidth) || 200),
1221
- height: Math.max(container.offsetHeight, Number(options.minContainerHeight) || 100)
1235
+ width: Math.max(container.offsetWidth, minWidth >= 0 ? minWidth : MIN_CONTAINER_WIDTH),
1236
+ height: Math.max(container.offsetHeight, minHeight >= 0 ? minHeight : MIN_CONTAINER_HEIGHT)
1222
1237
  };
1223
1238
  this.containerData = containerData;
1224
1239
  setStyle(cropper, {
@@ -1259,14 +1274,15 @@
1259
1274
  width: canvasWidth,
1260
1275
  height: canvasHeight
1261
1276
  };
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
1277
  this.canvasData = canvasData;
1267
1278
  this.limited = viewMode === 1 || viewMode === 2;
1268
1279
  this.limitCanvas(true, true);
1269
- this.initialImageData = assign({}, imageData);
1280
+ canvasData.width = Math.min(Math.max(canvasData.width, canvasData.minWidth), canvasData.maxWidth);
1281
+ canvasData.height = Math.min(Math.max(canvasData.height, canvasData.minHeight), canvasData.maxHeight);
1282
+ canvasData.left = (containerData.width - canvasData.width) / 2;
1283
+ canvasData.top = (containerData.height - canvasData.height) / 2;
1284
+ canvasData.oldLeft = canvasData.left;
1285
+ canvasData.oldTop = canvasData.top;
1270
1286
  this.initialCanvasData = assign({}, canvasData);
1271
1287
  },
1272
1288
  limitCanvas: function limitCanvas(sizeLimited, positionLimited) {
@@ -1793,16 +1809,13 @@
1793
1809
 
1794
1810
  var handlers = {
1795
1811
  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) {
1812
+ if (this.disabled) {
1803
1813
  return;
1804
1814
  }
1805
1815
 
1816
+ var options = this.options,
1817
+ container = this.container,
1818
+ containerData = this.containerData;
1806
1819
  var ratio = container.offsetWidth / containerData.width; // Resize when width changed or height changed
1807
1820
 
1808
1821
  if (ratio !== 1 || container.offsetHeight !== containerData.height) {
@@ -2050,8 +2063,6 @@
2050
2063
  }
2051
2064
 
2052
2065
  break;
2053
-
2054
- default:
2055
2066
  }
2056
2067
  };
2057
2068
 
@@ -2416,8 +2427,6 @@
2416
2427
  }
2417
2428
 
2418
2429
  break;
2419
-
2420
- default:
2421
2430
  }
2422
2431
 
2423
2432
  if (renderable) {
@@ -3199,9 +3208,7 @@
3199
3208
 
3200
3209
  var AnotherCropper = WINDOW.Cropper;
3201
3210
 
3202
- var Cropper =
3203
- /*#__PURE__*/
3204
- function () {
3211
+ var Cropper = /*#__PURE__*/function () {
3205
3212
  /**
3206
3213
  * Create a new Cropper.
3207
3214
  * @param {Element} element - The target element for cropping.
@@ -3250,7 +3257,7 @@
3250
3257
 
3251
3258
  if (!url) {
3252
3259
  return;
3253
- } // e.g.: "http://example.com/img/picture.jpg"
3260
+ } // e.g.: "https://example.com/img/picture.jpg"
3254
3261
 
3255
3262
 
3256
3263
  url = element.src;
@@ -3424,6 +3431,7 @@
3424
3431
  naturalHeight: naturalHeight,
3425
3432
  aspectRatio: naturalWidth / naturalHeight
3426
3433
  });
3434
+ _this2.initialImageData = assign({}, _this2.imageData);
3427
3435
  _this2.sizing = false;
3428
3436
  _this2.sized = true;
3429
3437
 
@@ -3613,4 +3621,4 @@
3613
3621
 
3614
3622
  return Cropper;
3615
3623
 
3616
- }));
3624
+ })));
@@ -1,11 +1,11 @@
1
1
  /*!
2
- * Cropper.js v1.5.6
2
+ * Cropper.js v1.5.9
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: 2020-09-10T13:16:21.689Z
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.1
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: 2020-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jquery-rails
@@ -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.4
85
+ signing_key:
86
86
  specification_version: 4
87
87
  summary: Integrate Cropper library with Rails asset pipeline
88
88
  test_files: []