Changeset 27942
- Timestamp:
- 04/04/2014 01:48:24 AM (11 years ago)
- Location:
- trunk/src/wp-includes/js
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/js/media-models.js
r27918 r27942 370 370 371 371 this.setLinkTypeFromUrl(); 372 373 this.set( 'aspectRatio', attributes.customWidth / attributes.customHeight ); 372 this.setAspectRatio(); 373 374 374 this.set( 'originalUrl', attributes.url ); 375 375 }, … … 377 377 bindAttachmentListeners: function() { 378 378 this.listenTo( this.attachment, 'sync', this.setLinkTypeFromUrl ); 379 this.listenTo( this.attachment, 'sync', this.setAspectRatio ); 379 380 this.listenTo( this.attachment, 'change', this.updateSize ); 380 381 }, … … 467 468 this.set( 'width', size.width ); 468 469 this.set( 'height', size.height ); 470 }, 471 472 setAspectRatio: function() { 473 var full; 474 475 if ( this.attachment ) { 476 full = this.attachment.get( 'sizes' ).full; 477 478 if ( full ) { 479 this.set( 'aspectRatio', full.width / full.height ); 480 return; 481 } 482 } 483 484 this.set( 'aspectRatio', this.get( 'customWidth' ) / this.get( 'customHeight' ) ); 469 485 } 470 486 }); -
trunk/src/wp-includes/js/media-views.js
r27918 r27942 6061 6061 'click .replace-attachment': 'replaceAttachment', 6062 6062 'click .advanced-toggle': 'toggleAdvanced', 6063 'change [data-setting="customWidth"]': ' syncCustomSize',6064 'change [data-setting="customHeight"]': ' syncCustomSize',6065 'keyup [data-setting="customWidth"]': ' syncCustomSize',6066 'keyup [data-setting="customHeight"]': ' syncCustomSize'6063 'change [data-setting="customWidth"]': 'onCustomSize', 6064 'change [data-setting="customHeight"]': 'onCustomSize', 6065 'keyup [data-setting="customWidth"]': 'onCustomSize', 6066 'keyup [data-setting="customHeight"]': 'onCustomSize' 6067 6067 } ), 6068 6068 initialize: function() { … … 6137 6137 }, 6138 6138 6139 syncCustomSize: function( event ) {6139 onCustomSize: function( event ) { 6140 6140 var dimension = $( event.target ).data('setting'), 6141 num = $( event.target ).val(), 6141 6142 value; 6142 6143 6144 // Ignore bogus input 6145 if ( ! /^\d+/.test( num ) || parseInt( num, 10 ) < 1 ) { 6146 event.preventDefault(); 6147 return; 6148 } 6149 6143 6150 if ( dimension === 'customWidth' ) { 6144 value = Math.round( 1 / this.model.get( 'aspectRatio' ) * $( event.target ).val());6151 value = Math.round( 1 / this.model.get( 'aspectRatio' ) * num ); 6145 6152 this.model.set( 'customHeight', value, { silent: true } ); 6146 6153 this.$( '[data-setting="customHeight"]' ).val( value ); 6147 6154 } else { 6148 value = Math.round( this.model.get( 'aspectRatio' ) * $( event.target ).val() ); 6155 value = Math.round( this.model.get( 'aspectRatio' ) * num ); 6156 this.model.set( 'customWidth', value, { silent: true } ); 6149 6157 this.$( '[data-setting="customWidth"]' ).val( value ); 6150 this.model.set( 'customWidth', value, { silent: true } ); 6158 6151 6159 } 6152 6160 }, -
trunk/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js
r27918 r27942 116 116 function extractImageData( imageNode ) { 117 117 var classes, extraClasses, metadata, captionBlock, caption, link, width, height, 118 dom = editor.dom; 118 dom = editor.dom, 119 isIntRegExp = /^\d+$/; 119 120 120 121 // default attributes 121 122 metadata = { 122 123 attachment_id: false, 123 url: false,124 height: '',125 width: '',126 customWidth: '',127 customHeight: '',128 124 size: 'custom', 129 125 caption: '', 130 alt: '',131 126 align: 'none', 132 127 extraClasses: '', … … 142 137 metadata.alt = dom.getAttrib( imageNode, 'alt' ); 143 138 metadata.title = dom.getAttrib( imageNode, 'title' ); 144 width = dom.getAttrib( imageNode, 'width' ) || imageNode.width; 145 height = dom.getAttrib( imageNode, 'height' ) || imageNode.height; 146 metadata.width = parseInt( width, 10 ); 147 metadata.height = parseInt( height, 10 ); 148 metadata.customWidth = metadata.width; 149 metadata.customHeight = metadata.height; 139 140 width = dom.getAttrib( imageNode, 'width' ); 141 height = dom.getAttrib( imageNode, 'height' ); 142 143 if ( ! isIntRegExp.test( width ) || parseInt( width, 10 ) < 1 ) { 144 width = imageNode.naturalWidth || imageNode.width; 145 } 146 147 if ( ! isIntRegExp.test( height ) || parseInt( height, 10 ) < 1 ) { 148 height = imageNode.naturalHeight || imageNode.height; 149 } 150 151 metadata.customWidth = metadata.width = width; 152 metadata.customHeight = metadata.height = height; 150 153 151 154 classes = tinymce.explode( imageNode.className, ' ' );
Note: See TracChangeset
for help on using the changeset viewer.