apps/gallery/js/gallery.js
// Called when the user clicks on a thumbnail in pick mode
Called when the user clicks on a thumbnail in pick mode
Called when the user clicks on a thumbnail in pick mode
function cropPickedImage(fileinfo) {
  pickedFile = fileinfo;
  var nocrop = pendingPick.source.data.nocrop;
  if (nocrop) {
    $('crop-header').textContent = '';
  }
  setView(cropView);
  $('crop-done-button').disabled = true;
  photodb.getFile(pickedFile.name, function(file) {
    cropURL = URL.createObjectURL(file);
    cropEditor = new ImageEditor(cropURL, $('crop-frame'), {}, function() {
      $('crop-done-button').disabled = false;
      if (nocrop) {
        cropEditor.cropRegion.left = cropEditor.cropRegion.top = 0;
        cropEditor.cropRegion.right = cropEditor.dest.w;
        cropEditor.cropRegion.bottom = cropEditor.dest.h;
        return;
      }
      cropEditor.showCropOverlay();
      if (pickWidth)
        cropEditor.setCropAspectRatio(pickWidth, pickHeight);
      else
        cropEditor.setCropAspectRatio(); 
    });
  });
}
function cropPickedImage ( fileinfo ) { pickedFile = fileinfo ; var nocrop = pendingPick . source . data . nocrop ; if ( nocrop ) { $ ( 'crop-header' ) . textContent = '' ; } setView ( cropView ) ; $ ( 'crop-done-button' ) . disabled = true ; photodb . getFile ( pickedFile . name , function ( file ) { cropURL = URL . createObjectURL ( file ) ; cropEditor = new ImageEditor ( cropURL , $ ( 'crop-frame' ) , { } , function ( ) { $ ( 'crop-done-button' ) . disabled = false ; if ( nocrop ) { cropEditor . cropRegion . left = cropEditor . cropRegion . top = 0 ; cropEditor . cropRegion . right = cropEditor . dest . w ; cropEditor . cropRegion . bottom = cropEditor . dest . h ; return ; } cropEditor . showCropOverlay ( ) ; if ( pickWidth ) cropEditor . setCropAspectRatio ( pickWidth , pickHeight ) ; else cropEditor . setCropAspectRatio ( ) ; } ) ; } ) ; }
Called when the user clicks on a thumbnail in pick mode
Called when the user clicks on a thumbnail in pick mode
// Do we actually want to allow the user to crop the image? // If we're not cropping we don't want the word "Crop" in the title bar // XXX: UX will probably get rid of this title bar soon, anyway. // Before the picked image is loaded, the done button is disabled // to avoid users picking a black/empty image. // Enable the done button so that users are able to finish picking image. // If the initiating app doesn't want to allow the user to crop // the image, we don't display the crop overlay. But we still use // this image editor to preview the image. // Set a fake crop region even though we won't display it // so that getCroppedRegionBlob() works. // free form cropping