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, |
| 4 | 4 | /** |
| 5 | 5 | * wp.media.controller.Cropper |
| 6 | 6 | * |
| 7 | | * A state for cropping an image. |
| | 7 | * A class for cropping an image when called from the header media customization panel. |
| 8 | 8 | * |
| 9 | 9 | * @memberOf wp.media.controller |
| 10 | 10 | * |
| … |
… |
Cropper = wp.media.controller.State.extend(/** @lends wp.media.controller.Croppe |
| 26 | 26 | doCropArgs: {} |
| 27 | 27 | }, |
| 28 | 28 | |
| | 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 | */ |
| 29 | 38 | activate: function() { |
| 30 | 39 | this.frame.on( 'content:create:crop', this.createCropContent, this ); |
| 31 | 40 | this.frame.on( 'close', this.removeCropper, this ); |
| 32 | 41 | this.set('selection', new Backbone.Collection(this.frame._selection.single)); |
| 33 | 42 | }, |
| 34 | 43 | |
| | 44 | /** |
| | 45 | * @summary Changes the state of the toolbar window to browse mode. |
| | 46 | * |
| | 47 | * @since 4.2.0 |
| | 48 | * |
| | 49 | * @returns {void} |
| | 50 | */ |
| 35 | 51 | deactivate: function() { |
| 36 | 52 | this.frame.toolbar.mode('browse'); |
| 37 | 53 | }, |
| 38 | 54 | |
| | 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 | */ |
| 39 | 66 | createCropContent: function() { |
| 40 | 67 | this.cropperView = new wp.media.view.Cropper({ |
| 41 | 68 | controller: this, |
| … |
… |
Cropper = wp.media.controller.State.extend(/** @lends wp.media.controller.Croppe |
| 45 | 72 | this.frame.content.set(this.cropperView); |
| 46 | 73 | |
| 47 | 74 | }, |
| | 75 | |
| | 76 | /** |
| | 77 | * @summary Removes the image selection and closes the cropping window. |
| | 78 | * |
| | 79 | * @since 4.2.0 |
| | 80 | * |
| | 81 | * @returns {void} |
| | 82 | */ |
| 48 | 83 | removeCropper: function() { |
| 49 | 84 | this.imgSelect.cancelSelection(); |
| 50 | 85 | this.imgSelect.setOptions({remove: true}); |
| 51 | 86 | this.imgSelect.update(); |
| 52 | 87 | this.cropperView.remove(); |
| 53 | 88 | }, |
| | 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 | */ |
| 54 | 97 | createCropToolbar: function() { |
| 55 | 98 | var canSkipCrop, toolbarOptions; |
| 56 | 99 | |
| … |
… |
Cropper = wp.media.controller.State.extend(/** @lends wp.media.controller.Croppe |
| 106 | 149 | this.frame.toolbar.set( new wp.media.view.Toolbar(toolbarOptions) ); |
| 107 | 150 | }, |
| 108 | 151 | |
| | 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 | */ |
| 109 | 159 | doCrop: function( attachment ) { |
| 110 | 160 | return wp.ajax.post( 'custom-header-crop', _.extend( |
| 111 | 161 | {}, |