WordPress.org

Make WordPress Core

Ticket #42677: cropper.diff

File cropper.diff, 2.7 KB (added by manuelaugustin, 3 years ago)
  • src/wp-includes/js/media/controllers/cropper.js

    diff --git src/wp-includes/js/media/controllers/cropper.js src/wp-includes/js/media/controllers/cropper.js
    index bfcaf11c9..be4b7bc53 100644
    var l10n = wp.media.view.l10n, 
    44/**
    55 * wp.media.controller.Cropper
    66 *
    7  * A state for cropping an image.
     7 * A class for cropping an image when called from the header media customization panel.
    88 *
    99 * @memberOf wp.media.controller
    1010 *
    Cropper = wp.media.controller.State.extend(/** @lends wp.media.controller.Croppe 
    2626                doCropArgs: {}
    2727        },
    2828
     29        /**
     30         * @summary Opens the crop image window.
     31         *
     32         * Shows the crop image window when called from the Add new image button.
     33         *
     34         * @since 4.2.0
     35         *
     36         * @returns {void}
     37         */
    2938        activate: function() {
    3039                this.frame.on( 'content:create:crop', this.createCropContent, this );
    3140                this.frame.on( 'close', this.removeCropper, this );
    3241                this.set('selection', new Backbone.Collection(this.frame._selection.single));
    3342        },
    3443
     44        /**
     45         * @summary Changes the state of the toolbar window to browse mode.
     46         *
     47         * @since 4.2.0
     48         *
     49         * @returns {void}
     50         */
    3551        deactivate: function() {
    3652                this.frame.toolbar.mode('browse');
    3753        },
    3854
     55        /**
     56         * @summary Creates the crop image window.
     57         *
     58         * Initialized when clicking on the Select and Crop button.
     59         *
     60         * @since 4.2.0
     61         *
     62         * @fires crop window
     63         *
     64         * @returns {void}
     65         */
    3966        createCropContent: function() {
    4067                this.cropperView = new wp.media.view.Cropper({
    4168                        controller: this,
    Cropper = wp.media.controller.State.extend(/** @lends wp.media.controller.Croppe 
    4572                this.frame.content.set(this.cropperView);
    4673
    4774        },
     75
     76        /**
     77         * @summary Removes the image selection and closes the cropping window.
     78         *
     79         * @since 4.2.0
     80         *
     81         * @returns {void}
     82         */
    4883        removeCropper: function() {
    4984                this.imgSelect.cancelSelection();
    5085                this.imgSelect.setOptions({remove: true});
    5186                this.imgSelect.update();
    5287                this.cropperView.remove();
    5388        },
     89
     90        /**
     91         * @summary Checks if cropping can be skipped and creates crop toolbar accordingly.
     92         *
     93         * @since 4.2.0
     94         *
     95         * @returns {void}
     96         */
    5497        createCropToolbar: function() {
    5598                var canSkipCrop, toolbarOptions;
    5699
    Cropper = wp.media.controller.State.extend(/** @lends wp.media.controller.Croppe 
    106149                this.frame.toolbar.set( new wp.media.view.Toolbar(toolbarOptions) );
    107150        },
    108151
     152        /**
     153         * @summary Creates an object with the image attachment and crop properties.
     154         *
     155         * @since 4.2.0
     156         *
     157         * @returns {$.promise} A jQuery promise with the custom header crop details.
     158         */
    109159        doCrop: function( attachment ) {
    110160                return wp.ajax.post( 'custom-header-crop', _.extend(
    111161                        {},