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 #18799 from justindarc/bug988670-v1.4
Browse files Browse the repository at this point in the history
Bug 988670 - [Camera][Madai] Behavior when leaving camera while in previ...
  • Loading branch information
justindarc committed Apr 29, 2014
2 parents 82915bc + c5091c6 commit e66d30c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
9 changes: 4 additions & 5 deletions apps/camera/js/controllers/preview-gallery.js
Expand Up @@ -77,6 +77,7 @@ PreviewGalleryController.prototype.openPreview = function() {

this.app.set('previewGalleryOpen', true);
this.previewItem();
this.app.emit('previewgallery:opened');
};

PreviewGalleryController.prototype.closePreview = function() {
Expand Down Expand Up @@ -223,8 +224,8 @@ PreviewGalleryController.prototype.updatePreviewGallery = function(index) {
this.currentItemIndex = this.items.length - 1;
}

var isPreviewOpened = this.view.isPreviewOpened();
if (isPreviewOpened) {
var isOpened = this.view ? true : false;
if (isOpened) {
this.previewItem();
}
}
Expand Down Expand Up @@ -292,8 +293,6 @@ PreviewGalleryController.prototype.previewItem = function() {
} else {
this.view.showImage(item);
}

this.app.emit('previewgallery:opened');
};

/**
Expand Down Expand Up @@ -330,10 +329,10 @@ PreviewGalleryController.prototype.onItemDeleted = function(data) {
*/
PreviewGalleryController.prototype.onBlur = function() {
if (this.app.inSecureMode) {
this.closePreview();
this.configure(); // Forget all stored images
this.updateThumbnail(); // Get rid of any thumbnail
}
this.closePreview();
};

PreviewGalleryController.prototype.updateThumbnail = function() {
Expand Down
4 changes: 0 additions & 4 deletions apps/camera/js/views/preview-gallery.js
Expand Up @@ -233,10 +233,6 @@ return View.extend({
this.frame.clear();
},

isPreviewOpened: function() {
return !this.el.classList.contains('offscreen');
},

updateCountText: function(current, total) {
this.currentIndex = current;
this.lastIndex = total;
Expand Down
10 changes: 9 additions & 1 deletion apps/camera/test/unit/controllers/preview-gallery_test.js
Expand Up @@ -252,12 +252,20 @@ suite('controllers/preview-gallery', function() {
});

test('Should close the preview on blur', function() {
this.previewGalleryController.closePreview = sinon.spy();
this.previewGalleryController.onBlur();
assert.ok(this.previewGalleryController.closePreview.called);
});

test('Should close the preview on blur if in \'secureMode\'', function() {
this.app.inSecureMode = true;
this.previewGalleryController.closePreview = sinon.spy();
this.previewGalleryController.configure = sinon.spy();
this.previewGalleryController.updateThumbnail = sinon.spy();
this.previewGalleryController.onBlur();
assert.ok(this.previewGalleryController.closePreview.called);
assert.ok(this.previewGalleryController.configure.called);
assert.ok(this.previewGalleryController.updateThumbnail.called);
assert.ok(this.previewGalleryController.closePreview.calledAfter(this.previewGalleryController.updateThumbnail));
});

// XXX: this is really a view test, but we don't have tests for the view yet
Expand Down

0 comments on commit e66d30c

Please sign in to comment.