strict.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. $(function () {
  2. 'use strict';
  3. var $image = $(window.createCropperImage());
  4. $image.cropper({
  5. built: function () {
  6. var canvasData,
  7. cropBoxData;
  8. QUnit.test('options.strict: true', function (assert) {
  9. $image.cropper('zoom', -0.5); // Zoom out
  10. canvasData = $image.cropper('getCanvasData');
  11. cropBoxData = $image.cropper('getCropBoxData');
  12. assert.equal(Math.round(canvasData.width), Math.round(cropBoxData.width));
  13. assert.equal(Math.round(canvasData.height), Math.round(cropBoxData.height));
  14. assert.equal(Math.round(canvasData.left), Math.round(cropBoxData.left));
  15. assert.equal(Math.round(canvasData.top), Math.round(cropBoxData.top));
  16. });
  17. }
  18. });
  19. (function () {
  20. var $image = $(window.createCropperImage());
  21. $image.cropper({
  22. strict: false,
  23. built: function () {
  24. var canvasData = {
  25. left: 100,
  26. top: 100,
  27. width: 160,
  28. height: 90
  29. };
  30. QUnit.test('options.strict: false', function (assert) {
  31. $image.cropper('setCanvasData', canvasData);
  32. assert.deepEqual($image.cropper('getCanvasData'), canvasData);
  33. });
  34. }
  35. });
  36. })();
  37. });