jquery-cropper.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*!
  2. * jQuery Cropper v1.0.1
  3. * https://fengyuanchen.github.io/jquery-cropper
  4. *
  5. * Copyright 2018-present Chen Fengyuan
  6. * Released under the MIT license
  7. *
  8. * Date: 2019-10-19T08:48:33.062Z
  9. */
  10. (function (global, factory) {
  11. typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('jquery'), require('cropperjs')) :
  12. typeof define === 'function' && define.amd ? define(['jquery', 'cropperjs'], factory) :
  13. (global = global || self, factory(global.jQuery, global.Cropper));
  14. }(this, function ($, Cropper) { 'use strict';
  15. $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
  16. Cropper = Cropper && Cropper.hasOwnProperty('default') ? Cropper['default'] : Cropper;
  17. if ($ && $.fn && Cropper) {
  18. var AnotherCropper = $.fn.cropper;
  19. var NAMESPACE = 'cropper';
  20. $.fn.cropper = function jQueryCropper(option) {
  21. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  22. args[_key - 1] = arguments[_key];
  23. }
  24. var result;
  25. this.each(function (i, element) {
  26. var $element = $(element);
  27. var isDestroy = option === 'destroy';
  28. var cropper = $element.data(NAMESPACE);
  29. if (!cropper) {
  30. if (isDestroy) {
  31. return;
  32. }
  33. var options = $.extend({}, $element.data(), $.isPlainObject(option) && option);
  34. cropper = new Cropper(element, options);
  35. $element.data(NAMESPACE, cropper);
  36. }
  37. if (typeof option === 'string') {
  38. var fn = cropper[option];
  39. if ($.isFunction(fn)) {
  40. result = fn.apply(cropper, args);
  41. if (result === cropper) {
  42. result = undefined;
  43. }
  44. if (isDestroy) {
  45. $element.removeData(NAMESPACE);
  46. }
  47. }
  48. }
  49. });
  50. return result !== undefined ? result : this;
  51. };
  52. $.fn.cropper.Constructor = Cropper;
  53. $.fn.cropper.setDefaults = Cropper.setDefaults;
  54. $.fn.cropper.noConflict = function noConflict() {
  55. $.fn.cropper = AnotherCropper;
  56. return this;
  57. };
  58. }
  59. }));