Ticket #11477: ticket-11477-parts1-3-ver1.patch
File ticket-11477-parts1-3-ver1.patch, 2.2 KB (added by , 15 years ago) |
---|
-
image-edit.dev.js
299 299 }, 300 300 301 301 initCrop : function(postid, image, parent) { 302 var t = this, selW = $('#imgedit-sel-width-' + postid), 303 selH = $('#imgedit-sel-height-' + postid); 302 var t = this; 304 303 305 304 t.iasapi = $(image).imgAreaSelect({ 306 305 parent: parent, … … 335 334 }, 336 335 337 336 onSelectChange: function(img, c) { 338 var sizer = imageEdit.hold.sizer; 339 selW.val( imageEdit.round(c.width / sizer) ); 340 selH.val( imageEdit.round(c.height / sizer) ); 337 imageEdit.setSelectionInputValues(c.width, c.height); 341 338 } 342 339 }); 343 340 }, 341 342 setSelectionInputValues : function(newwidth, newheight) { 343 var selW = $('#imgedit-sel-width-' + this.postid), 344 selH = $('#imgedit-sel-height-' + this.postid), 345 sizer = this.hold.sizer; 344 346 347 selW.val( this.round(newwidth / sizer) ); 348 selH.val( this.round(newheight / sizer) ); 349 }, 350 345 351 setCropSelection : function(postid, c) { 346 352 var sel, min = $('#imgedit-minthumb-' + postid).val() || '128:128', 347 353 sizer = this.hold['sizer']; … … 535 541 }, 536 542 537 543 setRatioSelection : function(postid, n, el) { 538 var sel, r, x = this.intval( $('#imgedit-crop-width-' + postid).val() ),544 var sel, r, x = parseFloat( $('#imgedit-crop-width-' + postid).val() ), 539 545 y = this.intval( $('#imgedit-crop-height-' + postid).val() ), 540 546 h = $('#image-preview-' + postid).height(); 541 547 … … 550 556 }); 551 557 552 558 if ( sel = this.iasapi.getSelection(true) ) { 553 r = Math.ceil( sel.y1 + ((sel.x2 - sel.x1) / (x / y)));559 newy2 = sel.y1 + Math.round((sel.x2 - sel.x1) / (x / y)); 554 560 555 if ( r > h ) { 556 r = h; 557 if ( n ) 558 $('#imgedit-crop-height-' + postid).val(''); 559 else 560 $('#imgedit-crop-width-' + postid).val(''); 561 if ( newy2 > h ) { 562 newy2 = h; 563 newx2 = sel.x1 + Math.round((newy2 - sel.y1) * (x / y)); 564 } else { 565 newx2 = sel.x2; 561 566 } 562 567 563 this.iasapi.setSelection( sel.x1, sel.y1, sel.x2, r);568 this.iasapi.setSelection( sel.x1, sel.y1, newx2, newy2 ); 564 569 this.iasapi.update(); 570 this.setSelectionInputValues(newx2 - sel.x1, newy2 - sel.y1); 565 571 } 566 572 } 567 573 }