Changeset 27918
- Timestamp:
- 04/03/2014 03:20:40 AM (11 years ago)
- Location:
- trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/css/themes.css
r27896 r27918 1284 1284 background: #fff; 1285 1285 border: 1px solid #e5e5e5; 1286 -webkit-box-shadow: 0 1px 1px rgba(0,0,0,0.04); 1286 1287 box-shadow: 0 1px 1px rgba(0,0,0,0.04); 1287 1288 font-size: 11px; -
trunk/src/wp-includes/css/media-views.css
r27898 r27918 1641 1641 1642 1642 .image-details .advanced-toggle { 1643 font-style: italic;1644 1643 color: #666; 1645 1644 text-decoration: none; 1646 margin: 20px;1647 1645 display: block; 1648 1646 } … … 1664 1662 } 1665 1663 1664 .image-details .embed-media-settings .size { 1665 margin-bottom: 4px; 1666 } 1667 1668 .image-details .custom-size span { 1669 display: block; 1670 } 1671 1672 .image-details .custom-size label { 1673 display: block; 1674 float: left; 1675 } 1676 1677 .image-details .custom-size span small { 1678 color: #999; 1679 font-size: inherit; 1680 } 1681 1682 .image-details .custom-size input { 1683 width: 5em; 1684 } 1685 1686 .image-details .custom-size .sep { 1687 float: left; 1688 margin: 26px 6px 0 6px; 1689 } 1690 1691 .image-details .custom-size::after { 1692 content: ''; 1693 display: table; 1694 clear: both; 1695 } 1696 1666 1697 .media-embed .thumbnail { 1667 1698 max-width: 100%; … … 1725 1756 1726 1757 .image-details .embed-media-settings .setting input.link-to-custom, 1727 .image-details .embed-media-settings .link-target { 1758 .image-details .embed-media-settings .link-target, 1759 .image-details .embed-media-settings .custom-size { 1728 1760 margin-left: 27%; 1729 1761 width: 70%; … … 2004 2036 } 2005 2037 2006 .image-details . link-target{2007 width: 100%;2038 .image-details .embed-media-settings .custom-size { 2039 margin-left: 20px; 2008 2040 } 2009 2041 -
trunk/src/wp-includes/js/media-models.js
r27687 r27918 370 370 371 371 this.setLinkTypeFromUrl(); 372 373 this.set( 'aspectRatio', attributes.customWidth / attributes.customHeight ); 374 this.set( 'originalUrl', attributes.url ); 372 375 }, 373 376 … … 445 448 446 449 if ( ! this.attachment ) { 450 return; 451 } 452 453 if ( this.get( 'size' ) === 'custom' ) { 454 this.set( 'width', this.get( 'customWidth' ) ); 455 this.set( 'height', this.get( 'customHeight' ) ); 456 this.set( 'url', this.get( 'originalUrl' ) ); 447 457 return; 448 458 } -
trunk/src/wp-includes/js/media-views.js
r27901 r27918 6060 6060 'click .edit-attachment': 'editAttachment', 6061 6061 'click .replace-attachment': 'replaceAttachment', 6062 'click .advanced-toggle': 'toggleAdvanced' 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 6067 } ), 6064 6068 initialize: function() { … … 6067 6071 this.listenTo( this.model, 'change:url', this.updateUrl ); 6068 6072 this.listenTo( this.model, 'change:link', this.toggleLinkSettings ); 6073 this.listenTo( this.model, 'change:size', this.toggleCustomSize ); 6069 6074 media.view.Settings.AttachmentDisplay.prototype.initialize.apply( this, arguments ); 6070 6075 }, … … 6124 6129 }, 6125 6130 6131 toggleCustomSize: function() { 6132 if ( this.model.get( 'size' ) !== 'custom' ) { 6133 this.$( '.custom-size' ).addClass('hidden'); 6134 } else { 6135 this.$( '.custom-size' ).removeClass('hidden'); 6136 } 6137 }, 6138 6139 syncCustomSize: function( event ) { 6140 var dimension = $( event.target ).data('setting'), 6141 value; 6142 6143 if ( dimension === 'customWidth' ) { 6144 value = Math.round( 1 / this.model.get( 'aspectRatio' ) * $( event.target ).val() ); 6145 this.model.set( 'customHeight', value, { silent: true } ); 6146 this.$( '[data-setting="customHeight"]' ).val( value ); 6147 } else { 6148 value = Math.round( this.model.get( 'aspectRatio' ) * $( event.target ).val() ); 6149 this.$( '[data-setting="customWidth"]' ).val( value ); 6150 this.model.set( 'customWidth', value, { silent: true } ); 6151 } 6152 }, 6153 6126 6154 toggleAdvanced: function( event ) { 6127 6155 var $advanced = $( event.target ).closest( '.advanced' ); -
trunk/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js
r27898 r27918 124 124 height: '', 125 125 width: '', 126 size: false, 126 customWidth: '', 127 customHeight: '', 128 size: 'custom', 127 129 caption: '', 128 130 alt: '', … … 140 142 metadata.alt = dom.getAttrib( imageNode, 'alt' ); 141 143 metadata.title = dom.getAttrib( imageNode, 'title' ); 142 143 144 width = dom.getAttrib( imageNode, 'width' ) || imageNode.width; 144 145 height = dom.getAttrib( imageNode, 'height' ) || imageNode.height; 145 146 146 metadata.width = parseInt( width, 10 ); 147 147 metadata.height = parseInt( height, 10 ); 148 metadata.customWidth = metadata.width; 149 metadata.customHeight = metadata.height; 148 150 149 151 classes = tinymce.explode( imageNode.className, ' ' ); … … 200 202 } 201 203 204 function hasTextContent( node ) { 205 return node && !! ( node.textContent || node.innerText ); 206 } 207 202 208 function updateImage( imageNode, imageData ) { 203 var classes, className, width, node, html, parent, wrap,204 captionNode, dd, dl, id, attrs, linkAttrs, 209 var classes, className, node, html, parent, wrap, linkNode, 210 captionNode, dd, dl, id, attrs, linkAttrs, width, height, 205 211 dom = editor.dom; 206 212 … … 217 223 if ( imageData.attachment_id ) { 218 224 classes.push( 'wp-image-' + imageData.attachment_id ); 219 if ( imageData.size ) {225 if ( imageData.size && imageData.size !== 'custom' ) { 220 226 classes.push( 'size-' + imageData.size ); 221 227 } 228 } 229 230 width = imageData.width; 231 height = imageData.height; 232 233 if ( imageData.size === 'custom' ) { 234 width = imageData.customWidth; 235 height = imageData.customHeight; 222 236 } 223 237 224 238 attrs = { 225 239 src: imageData.url, 226 width: imageData.width || null,227 height: imageData.height || null,240 width: width || null, 241 height: height || null, 228 242 alt: imageData.alt, 229 243 title: imageData.title || null, … … 240 254 }; 241 255 242 if ( imageNode.parentNode.nodeName === 'A' ) { 256 if ( imageNode.parentNode && imageNode.parentNode.nodeName === 'A' && ! hasTextContent( imageNode.parentNode ) ) { 257 // Update or remove an existing link wrapped around the image 243 258 if ( imageData.linkUrl ) { 244 259 dom.setAttribs( imageNode.parentNode, linkAttrs ); … … 247 262 } 248 263 } else if ( imageData.linkUrl ) { 249 html = dom.createHTML( 'a', linkAttrs, dom.getOuterHTML( imageNode ) ); 250 dom.outerHTML( imageNode, html ); 264 if ( linkNode = dom.getParent( imageNode, 'a' ) ) { 265 // The image is inside a link together with other nodes, 266 // or is nested in another node, move it out 267 dom.insertAfter( imageNode, linkNode ); 268 } 269 270 // Add link wrapped around the image 271 linkNode = dom.create( 'a', linkAttrs ); 272 imageNode.parentNode.insertBefore( linkNode, imageNode ); 273 linkNode.appendChild( imageNode ); 251 274 } 252 275 253 276 captionNode = editor.dom.getParent( imageNode, '.mceTemp' ); 254 277 255 if ( imageNode.parentNode .nodeName === 'A') {278 if ( imageNode.parentNode && imageNode.parentNode.nodeName === 'A' && ! hasTextContent( imageNode.parentNode ) ) { 256 279 node = imageNode.parentNode; 257 280 } else { … … 260 283 261 284 if ( imageData.caption ) { 262 width = parseInt( imageData.width, 10 ); 285 263 286 id = imageData.attachment_id ? 'attachment_' + imageData.attachment_id : null; 264 className = 'wp-caption align' + imageData.align;287 className = 'wp-caption align' + ( imageData.align || 'none' ); 265 288 266 289 if ( ! editor.getParam( 'wpeditimage_html5_captions' ) ) { 290 width = parseInt( width, 10 ); 267 291 width += 10; 268 292 } … … 313 337 314 338 editor.nodeChanged(); 315 // refresh the toolbar339 // Refresh the toolbar 316 340 addToolbar( imageNode ); 317 341 } … … 324 348 return; 325 349 } 326 327 editor.undoManager.add();328 350 329 351 frame = wp.media({ … … 334 356 335 357 callback = function( imageData ) { 336 updateImage( img, imageData );337 358 editor.focus(); 359 editor.undoManager.transact( function() { 360 updateImage( img, imageData ); 361 } ); 338 362 frame.detach(); 339 363 }; -
trunk/src/wp-includes/media-template.php
r27899 r27918 690 690 <# if ( data.attachment ) { #> 691 691 <# if ( 'undefined' !== typeof data.attachment.sizes ) { #> 692 <label class="setting ">692 <label class="setting size"> 693 693 <span><?php _e('Size'); ?></span> 694 694 <select class="size" name="size" … … 710 710 var size = data.sizes['<?php echo esc_js( $value ); ?>']; 711 711 if ( size ) { #> 712 <option value="<?php echo esc_attr( $value ); ?>" <?php selected( $value, 'full' ); ?>>712 <option value="<?php echo esc_attr( $value ); ?>"> 713 713 <?php echo esc_html( $name ); ?> – {{ size.width }} × {{ size.height }} 714 714 </option> 715 715 <# } #> 716 716 <?php endforeach; ?> 717 <option value="<?php echo esc_attr( 'custom' ); ?>"> 718 <?php _e( 'Custom Size' ); ?> 719 </option> 717 720 </select> 718 721 </label> 719 722 <# } #> 723 <div class="custom-size<# if ( data.model.size !== 'custom' ) { #> hidden<# } #>"> 724 <label><span><?php _e( 'Width' ); ?> <small>(px)</small></span> <input data-setting="customWidth" type="number" step="1" value="{{ data.model.customWidth }}" /></label><span class="sep">×</span><label><span><?php _e( 'Height' ); ?> <small>(px)</small></span><input data-setting="customHeight" type="number" step="1" value="{{ data.model.customHeight }}" /></label> 725 </div> 720 726 <# } #> 721 727 … … 745 751 </div> 746 752 <div class="advanced"> 747 < a class="advanced-toggle" href="#"><?php _e('Show advanced options'); ?></a>753 <h3><a class="advanced-toggle" href="#"><?php _e('Advanced Options'); ?></a></h3> 748 754 <div class="hidden"> 749 755 <label class="setting title-text">
Note: See TracChangeset
for help on using the changeset viewer.