diff --git src/wp-includes/js/media-models.js src/wp-includes/js/media-models.js
index 53eefdf..d3009b1 100644
|
|
|
window.wp = window.wp || {}; |
| 322 | 322 | }, data ) ).done( function( resp, status, xhr ) { |
| 323 | 323 | model.set( model.parse( resp, xhr ), options ); |
| 324 | 324 | }); |
| | 325 | }, |
| | 326 | crop: function( cropDetails ) { |
| | 327 | var model = this; |
| | 328 | |
| | 329 | return wp.ajax.post( 'custom-header-crop', { |
| | 330 | nonce: this.get('nonces').edit, |
| | 331 | id: this.get('id'), |
| | 332 | cropDetails: cropDetails |
| | 333 | } ).done( function( resp, status, xhr ) { |
| | 334 | model.set( model.parse( resp, xhr ) ); |
| | 335 | }); |
| 325 | 336 | } |
| 326 | 337 | }, { |
| 327 | 338 | /** |
diff --git src/wp-includes/js/media-views.js src/wp-includes/js/media-views.js
index 97dd232..9724db6 100644
|
|
|
|
| 1299 | 1299 | activate: function() { |
| 1300 | 1300 | this.frame.on( 'content:create:crop', this.createCropContent, this ); |
| 1301 | 1301 | this.frame.on( 'close', this.removeCropper, this ); |
| 1302 | | this.set('selection', new Backbone.Collection(this.frame._selection.single)); |
| | 1302 | this.set('selection', new media.model.Selection(this.frame._selection.single)); |
| 1303 | 1303 | }, |
| 1304 | 1304 | |
| 1305 | 1305 | deactivate: function() { |
| … |
… |
|
| 1308 | 1308 | |
| 1309 | 1309 | createCropContent: function() { |
| 1310 | 1310 | this.cropperView = new wp.media.view.Cropper({controller: this, |
| 1311 | | attachment: this.get('selection').first() }); |
| | 1311 | attachment: this.get('selection').single() }); |
| 1312 | 1312 | this.cropperView.on('image-loaded', this.createCropToolbar, this); |
| 1313 | 1313 | this.frame.content.set(this.cropperView); |
| 1314 | 1314 | |
| … |
… |
|
| 1335 | 1335 | |
| 1336 | 1336 | click: function() { |
| 1337 | 1337 | var self = this, |
| 1338 | | selection = this.controller.state().get('selection').first(); |
| 1339 | | |
| 1340 | | selection.set({cropDetails: this.controller.state().imgSelect.getSelection()}); |
| | 1338 | cropDetails = this.controller.state().imgSelect.getSelection(), |
| | 1339 | selection = this.controller.state().get('selection').single(); |
| 1341 | 1340 | |
| 1342 | 1341 | this.$el.text(l10n.cropping); |
| 1343 | 1342 | this.$el.attr('disabled', true); |
| 1344 | | this.controller.state().doCrop( selection ).done( function( croppedImage ) { |
| | 1343 | selection.crop(cropDetails).done( function( croppedImage ) { |
| 1345 | 1344 | self.controller.trigger('cropped', croppedImage ); |
| 1346 | 1345 | self.controller.close(); |
| 1347 | 1346 | }).fail( function() { |
| … |
… |
|
| 1360 | 1359 | priority: 70, |
| 1361 | 1360 | requires: { library: false, selection: false }, |
| 1362 | 1361 | click: function() { |
| 1363 | | var selection = this.controller.state().get('selection').first(); |
| | 1362 | var selection = this.controller.state().get('selection').single(); |
| 1364 | 1363 | this.controller.state().cropperView.remove(); |
| 1365 | 1364 | this.controller.trigger('skippedcrop', selection); |
| 1366 | 1365 | this.controller.close(); |
| … |
… |
|
| 1370 | 1369 | } |
| 1371 | 1370 | |
| 1372 | 1371 | this.frame.toolbar.set( new wp.media.view.Toolbar(toolbarOptions) ); |
| 1373 | | }, |
| 1374 | | |
| 1375 | | doCrop: function( attachment ) { |
| 1376 | | return wp.ajax.post( 'custom-header-crop', { |
| 1377 | | nonce: attachment.get('nonces').edit, |
| 1378 | | id: attachment.get('id'), |
| 1379 | | cropDetails: attachment.get('cropDetails') |
| 1380 | | } ); |
| 1381 | 1372 | } |
| 1382 | 1373 | }); |
| 1383 | 1374 | |