Changeset 37966
- Timestamp:
- 07/05/2016 01:36:59 PM (9 years ago)
- Location:
- trunk/src/wp-admin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/image-edit.php
r37488 r37966 61 61 <div class="nowrap"> 62 62 <label><span class="screen-reader-text"><?php _e( 'scale width' ); ?></span> 63 <input type="text" id="imgedit-scale-width-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1 )" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1)" value="<?php echo isset( $meta['width'] ) ? $meta['width'] : 0; ?>" />63 <input type="text" id="imgedit-scale-width-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1, this)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1, this)" value="<?php echo isset( $meta['width'] ) ? $meta['width'] : 0; ?>" /> 64 64 </label> 65 65 <span class="imgedit-separator">×</span> 66 66 <label><span class="screen-reader-text"><?php _e( 'scale height' ); ?></span> 67 <input type="text" id="imgedit-scale-height-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0 )" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0)" value="<?php echo isset( $meta['height'] ) ? $meta['height'] : 0; ?>" />67 <input type="text" id="imgedit-scale-height-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0, this)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0, this)" value="<?php echo isset( $meta['height'] ) ? $meta['height'] : 0; ?>" /> 68 68 </label> 69 69 <span class="imgedit-scale-warn" id="imgedit-scale-warn-<?php echo $post_id; ?>">!</span> … … 117 117 <div class="nowrap"> 118 118 <label><span class="screen-reader-text"><?php _e( 'crop ratio width' ); ?></span> 119 <input type="text" id="imgedit-crop-width-<?php echo $post_id; ?>" onkeyup="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 0, this)" />119 <input type="text" id="imgedit-crop-width-<?php echo $post_id; ?>" onkeyup="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 0, this)" onblur="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 0, this)" /> 120 120 </label> 121 121 <span class="imgedit-separator">:</span> 122 122 <label><span class="screen-reader-text"><?php _e( 'crop ratio height' ); ?></span> 123 <input type="text" id="imgedit-crop-height-<?php echo $post_id; ?>" onkeyup="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 1, this)" />123 <input type="text" id="imgedit-crop-height-<?php echo $post_id; ?>" onkeyup="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 1, this)" onblur="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 1, this)" /> 124 124 </label> 125 125 </div> … … 130 130 <div class="nowrap"> 131 131 <label><span class="screen-reader-text"><?php _e( 'selection width' ); ?></span> 132 <input type="text" id="imgedit-sel-width-<?php echo $post_id; ?>" onkeyup="imageEdit.setNumSelection(<?php echo $post_id; ?> )" />132 <input type="text" id="imgedit-sel-width-<?php echo $post_id; ?>" onkeyup="imageEdit.setNumSelection(<?php echo $post_id; ?>, this)" onblur="imageEdit.setNumSelection(<?php echo $post_id; ?>, this)" /> 133 133 </label> 134 134 <span class="imgedit-separator">×</span> 135 135 <label><span class="screen-reader-text"><?php _e( 'selection height' ); ?></span> 136 <input type="text" id="imgedit-sel-height-<?php echo $post_id; ?>" onkeyup="imageEdit.setNumSelection(<?php echo $post_id; ?> )" />136 <input type="text" id="imgedit-sel-height-<?php echo $post_id; ?>" onkeyup="imageEdit.setNumSelection(<?php echo $post_id; ?>, this)" onblur="imageEdit.setNumSelection(<?php echo $post_id; ?>, this)" /> 137 137 </label> 138 138 </div> … … 225 225 </div> 226 226 <div class="imgedit-wait" id="imgedit-wait-<?php echo $post_id; ?>"></div> 227 <script type="text/javascript">jQuery( function() { imageEdit.init(<?php echo $post_id; ?>); });</script>228 227 <div class="hidden" id="imgedit-leaving-<?php echo $post_id; ?>"><?php _e("There are unsaved changes that will be lost. 'OK' to continue, 'Cancel' to return to the Image Editor."); ?></div> 229 228 </div> -
trunk/src/wp-admin/js/image-edit.js
r36223 r37966 9 9 10 10 intval : function(f) { 11 /* 12 * Bitwise OR operator: one of the obscure ways to truncate floating point figures, 13 * worth reminding JavaScript doesn't have a distinct "integer" type. 14 */ 11 15 return f | 0; 12 16 }, … … 80 84 }, 81 85 82 scaleChanged : function( postid, x) {86 scaleChanged : function( postid, x, el ) { 83 87 var w = $('#imgedit-scale-width-' + postid), h = $('#imgedit-scale-height-' + postid), 84 88 warn = $('#imgedit-scale-warn-' + postid), w1 = '', h1 = ''; 89 90 if ( false === this.validateNumeric( el ) ) { 91 return; 92 } 85 93 86 94 if ( x ) { … … 362 370 spin.removeClass( 'is-active' ); 363 371 }); 372 // Initialise the Image Editor now that everything is ready. 373 imageEdit.init( postid ); 364 374 }); 365 375 … … 587 597 }, 588 598 589 setNumSelection : function( postid) {599 setNumSelection : function( postid, el ) { 590 600 var sel, elX = $('#imgedit-sel-width-' + postid), elY = $('#imgedit-sel-height-' + postid), 591 601 x = this.intval( elX.val() ), y = this.intval( elY.val() ), 592 602 img = $('#image-preview-' + postid), imgh = img.height(), imgw = img.width(), 593 603 sizer = this.hold.sizer, x1, y1, x2, y2, ias = this.iasapi; 604 605 if ( false === this.validateNumeric( el ) ) { 606 return; 607 } 594 608 595 609 if ( x < 1 ) { … … 651 665 h = $('#image-preview-' + postid).height(); 652 666 653 if ( !this.intval( $(el).val() ) ) { 654 $(el).val(''); 667 if ( false === this.validateNumeric( el ) ) { 655 668 return; 656 669 } … … 677 690 } 678 691 } 692 }, 693 694 validateNumeric: function( el ) { 695 if ( ! this.intval( $( el ).val() ) ) { 696 $( el ).val( '' ); 697 return false; 698 } 679 699 } 680 700 };
Note: See TracChangeset
for help on using the changeset viewer.