Code Duplication    Length = 1-33 lines in 2 locations

resources/assets/yuncms-user/src/js/cropper.js 1 location

@@ 35-67 (lines=33) @@
32
    $image.cropper(options);
33
34
    // Methods
35
    jQuery('.docs-buttons').on('click', '[data-method]', function () {
36
        var $this = jQuery(this);
37
        var data = $this.data();
38
        var $target;
39
        var result;
40
41
        if ($this.prop('disabled') || $this.hasClass('disabled')) {
42
            return;
43
        }
44
45
        if ($image.data('cropper') && data.method) {
46
            data = jQuery.extend({}, data); // Clone a new one
47
            if (typeof data.target !== 'undefined') {
48
                $target = jQuery(data.target);
49
                if (typeof data.option === 'undefined') {
50
                    try {
51
                        data.option = JSON.parse($target.val());
52
                    } catch (e) {
53
                        console.log(e.message);
54
                    }
55
                }
56
            }
57
            result = $image.cropper(data.method, data.option, data.secondOption);
58
            if ($.isPlainObject(result) && $target) {
59
                try {
60
                    $target.val(JSON.stringify(result));
61
                } catch (e) {
62
                    console.log(e.message);
63
                }
64
            }
65
        }
66
        return false;
67
    });
68
69
70
    // Keyboard

resources/assets/yuncms-user/dist/js/cropper.min.js 1 location

@@ 1-1 (lines=1) @@
1
jQuery(function(){"use strict";var e=jQuery("#image"),r=jQuery("#x"),o=jQuery("#y"),t=jQuery("#height"),a=jQuery("#width"),i={viewMode:1,dragMode:"move",autoCropArea:1,restore:!1,highlight:!1,cropBoxMovable:!1,cropBoxResizable:!1,aspectRatio:1,preview:".img-preview",crop:function(e){r.val(Math.round(e.x)),o.val(Math.round(e.y)),t.val(Math.round(e.height)),a.val(Math.round(e.width)),jQuery("#inputImage").val()||(jQuery(".btn-group button").attr("disabled",!0),jQuery(".cropper-view-box").hide(),jQuery(".cropper-wrap-box").hide())}};e.cropper(i),jQuery(".docs-buttons").on("click","[data-method]",function(){var r,o,t=jQuery(this),a=t.data();if(!t.prop("disabled")&&!t.hasClass("disabled")){if(e.data("cropper")&&a.method){if(void 0!==(a=jQuery.extend({},a)).target&&(r=jQuery(a.target),void 0===a.option))try{a.option=JSON.parse(r.val())}catch(e){console.log(e.message)}if(o=e.cropper(a.method,a.option,a.secondOption),$.isPlainObject(o)&&r)try{r.val(JSON.stringify(o))}catch(e){console.log(e.message)}}return!1}}),jQuery(document.body).on("keydown",function(r){if(e.data("cropper")&&!(this.scrollTop>300))switch(r.which){case 37:r.preventDefault(),e.cropper("move",-1,0);break;case 38:r.preventDefault(),e.cropper("move",0,-1);break;case 39:r.preventDefault(),e.cropper("move",1,0);break;case 40:r.preventDefault(),e.cropper("move",0,1)}});var p,c=jQuery("#inputImage"),n=window.URL||window.webkitURL;n?c.change(function(){var r,o=this.files;e.data("cropper")&&(o&&o.length&&(r=o[0],/^image\/\w+$/.test(r.type)?(p=n.createObjectURL(r),e.one("built.cropper",function(){n.revokeObjectURL(p)}).cropper("reset").cropper("replace",p)):window.alert("Please choose an image file.")),jQuery(".btn-group button").removeAttr("disabled"))}):c.prop("disabled",!0).parent().addClass("disabled")});
2
//# sourceMappingURL=cropper.min.js.map