Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #25236 from justindarc/bug1064600
Browse files Browse the repository at this point in the history
Bug 1064600 - [Gallery] preliminary modularization before full gallery refresh
  • Loading branch information
justindarc committed Nov 5, 2014
2 parents fea23e5 + 47d2c31 commit bfafc5a
Show file tree
Hide file tree
Showing 24 changed files with 1,258 additions and 575 deletions.
6 changes: 6 additions & 0 deletions apps/gallery/index.html
Expand Up @@ -45,10 +45,14 @@

<!-- Specific code -->
<script defer src="js/config.js"></script>
<script defer src="js/utils.js"></script>
<script defer src="js/thumbnail_item.js"></script>
<script defer src="js/thumbnail_date_group.js"></script>
<script defer src="js/thumbnail_list.js"></script>
<script defer src="js/ensure_file_backed_blob.js"></script>
<script defer src="js/spinner.js"></script>
<script defer src="js/overlay.js"></script>
<script defer src="js/nfc.js"></script>
<script defer src="js/gallery.js"></script>
</head>

Expand Down Expand Up @@ -233,10 +237,12 @@ <h1 id="edit-title" data-l10n-id="edit"></h1>
<div id="throbber"></div>
</div>

<!-- See spinner.js -->
<!-- a spinner that we display in the center of the screen when -->
<!-- doing time-consuming operations like rotating images -->
<progress id="spinner" class="hidden"></progress>

<!-- See overlay.js -->
<!-- display messages like "No Photos" and "No SD Card" here -->
<form id="overlay" role="dialog" data-type="confirm" class="hidden">
<section id="overlay-content">
Expand Down
4 changes: 2 additions & 2 deletions apps/gallery/js/ImageEditor.js
Expand Up @@ -84,11 +84,11 @@ function editPhoto(n) {
var maxsize = CONFIG_MAX_EDIT_PIXEL_SIZE || CONFIG_MAX_IMAGE_PIXEL_SIZE;

if (metadata.rotation || metadata.mirrored || imagesize > maxsize) {
showSpinner();
Spinner.show();
cropResizeRotate(file, null, maxsize || null,
null, metadata,
function(error, rotatedBlob) {
hideSpinner();
Spinner.hide();
if (error) {
console.error('Error while rotating image:', error);
rotatedBlob = file;
Expand Down
31 changes: 16 additions & 15 deletions apps/gallery/js/frames.js
Expand Up @@ -44,21 +44,22 @@ fullscreenButtons.delete.onclick = deleteSingleItem;

// Clicking the Edit button while viewing a photo switches to edit mode
fullscreenButtons.edit.onclick = function() {
loader.load(['js/ImageEditor.js', 'shared/js/media/crop_resize_rotate.js'],
function() {
editPhotoIfCardNotFull(currentFileIndex);
});
LazyLoader.load(['js/ImageEditor.js',
'shared/js/media/crop_resize_rotate.js'],
function() {
editPhotoIfCardNotFull(currentFileIndex);
});
};

// In fullscreen mode, the share button shares the current item
fullscreenButtons.share.onclick = shareSingleItem;

// Clicking the information button will display information about the photo.
fullscreenButtons.info.onclick = function() {
loader.load(['js/info.js', 'shared/style/confirm.css', 'style/info.css'],
function() {
showFileInformation(files[currentFileIndex]);
});
LazyLoader.load(['js/info.js', 'shared/style/confirm.css', 'style/info.css'],
function() {
showFileInformation(files[currentFileIndex]);
});
};

// Use the GestureDetector.js library to handle gestures.
Expand Down Expand Up @@ -133,7 +134,7 @@ function deleteSingleItem() {
msg = 'delete-photo?';
}
// We need to disable NFC sharing when showing delete confirmation dialog
setNFCSharing(false);
NFC.unshare();

Dialogs.confirm({
messageId: msg,
Expand All @@ -149,10 +150,10 @@ function deleteSingleItem() {

deleteFile(currentFileIndex);
// Enable NFC sharing when done deleting and returns to fullscreen view
setNFCSharing(true);
NFC.share(getCurrentFile);
}, function() { // onCancel
// Enable NFC sharing when cancels delete and returns to fullscreen view
setNFCSharing(true);
NFC.share(getCurrentFile);
});
}

Expand All @@ -178,16 +179,16 @@ function shareSingleItem() {
// This is only tricky case. If we are sharing an image that uses
// EXIF orientation for correct display, rotate it before sharing
// so that the recieving app doesn't have to know about EXIF
loader.load(['shared/js/media/crop_resize_rotate.js'],
shareModifiedImage);
LazyLoader.load(['shared/js/media/crop_resize_rotate.js'],
shareModifiedImage);
}
}

function shareModifiedImage() {
var metadata = fileinfo.metadata;
var button = fullscreenButtons.share;
button.classList.add('disabled');
showSpinner();
Spinner.show();
var maxsize = CONFIG_MAX_PICK_PIXEL_SIZE || CONFIG_MAX_IMAGE_PIXEL_SIZE;
cropResizeRotate(currentFrame.imageblob, null,
maxsize || null, null, metadata,
Expand All @@ -197,7 +198,7 @@ function shareSingleItem() {
rotatedBlob = currentFrame.imageblob;
}
ensureFileBackedBlob(rotatedBlob, function(file) {
hideSpinner();
Spinner.hide();
button.classList.remove('disabled');
share([file], currentFrame.imageblob.name);
});
Expand Down

0 comments on commit bfafc5a

Please sign in to comment.