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 #18252 from justindarc/bug991396
Browse files Browse the repository at this point in the history
Bug 991396 - [camera][madai] delete dialogue button should be red and sa... r=djf
  • Loading branch information
David Flanagan authored and rvandermeulen committed Apr 17, 2014
1 parent 3b4f482 commit b1fba95
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 33 deletions.
4 changes: 4 additions & 0 deletions apps/camera/js/config/require.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require.config({
'VideoPlayer': '../shared/js/media/video_player',
'MediaFrame': '../shared/js/media/media_frame',
'BlobView': '../shared/js/blobview',
'CustomDialog': '../shared/js/custom_dialog',
'debug': 'vendor/debug'
},
shim: {
Expand Down Expand Up @@ -40,6 +41,9 @@ require.config({
},
'GestureDetector': {
exports: 'GestureDetector'
},
'CustomDialog': {
exports: 'CustomDialog'
}
}
});
24 changes: 20 additions & 4 deletions apps/camera/js/controllers/preview-gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var bindAll = require('lib/bind-all');
var PreviewGalleryView = require('views/preview-gallery');
var createThumbnailImage = require('lib/create-thumbnail-image');
var preparePreview = require('lib/prepare-preview-blob');
var CustomDialog = require('CustomDialog');

/**
* The size of the thumbnail images we generate.
Expand Down Expand Up @@ -154,6 +155,7 @@ PreviewGalleryController.prototype.deleteCurrentItem = function() {
var item = this.items[index];
var filepath = item.filepath;
var msg;
var self = this;

if (item.isVideo) {
msg = navigator.mozL10n.get('delete-video?');
Expand All @@ -162,14 +164,28 @@ PreviewGalleryController.prototype.deleteCurrentItem = function() {
msg = navigator.mozL10n.get('delete-photo?');
}

if (window.confirm(msg)) {
this.updatePreviewGallery(index);
CustomDialog.show('',
msg,
{ title: navigator.mozL10n.get('cancel'),
callback: closeDialog },
{ title: navigator.mozL10n.get('delete'),
callback: deleteItem,
recommend: false });

function closeDialog() {
CustomDialog.hide();
}

function deleteItem() {
CustomDialog.hide();

self.updatePreviewGallery(index);

// Actually delete the file
if (item.isVideo) {
this.storage.deleteVideo(filepath);
self.storage.deleteVideo(filepath);
} else {
this.storage.deleteImage(filepath);
self.storage.deleteImage(filepath);
}
}
};
Expand Down
2 changes: 2 additions & 0 deletions apps/camera/locales/camera.en-US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ close-button = Close

delete-photo? = Delete photo?
delete-video? = Delete video?
cancel = Cancel
delete = Delete

# LOCALIZATION NOTE(mp): MP stands for mega-pixels
mp = MP
Expand Down
28 changes: 0 additions & 28 deletions apps/camera/test/unit/controllers/preview-gallery_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,34 +138,6 @@ suite('controllers/preview-gallery', function() {
assert.ok(arg.data.filepaths[0] === item.filepath);
});

test('Should deleteCurrentItem which is image', function() {
var item = {
blob: {},
filepath: 'root/fileName',
isVideo: false
};
this.previewGalleryController.items = [item];
this.previewGalleryController.currentItemIndex = 0;
this.previewGalleryController.deleteCurrentItem();

assert.ok(this.previewGalleryController.storage.deleteImage
.calledWith('root/fileName'));
});

test('Should deleteCurrentItem which is video', function() {
var item = {
blob: {},
filepath: 'root/fileName',
isVideo: true
};
this.previewGalleryController.items = [item];
this.previewGalleryController.currentItemIndex = 0;
this.previewGalleryController.deleteCurrentItem();

assert.ok(this.previewGalleryController.storage.deleteVideo
.calledWith('root/fileName'));
});

test('Check onNewMedia callback', function() {
var item = {
blob: {},
Expand Down
7 changes: 6 additions & 1 deletion apps/camera/test/unit/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ mocha.setup({
'CONFIG_AVG_JPEG_COMPRESSION_RATIO',
'MediaFrame',
'confirm',
'MozActivity'
'MozActivity',
'CustomDialog'
]
});

Expand All @@ -40,6 +41,7 @@ requireApp('camera/js/vendor/alameda.js', function() {
'VideoPlayer': '../shared/js/media/video_player',
'MediaFrame': '../shared/js/media/media_frame',
'BlobView': '../shared/js/blobview',
'CustomDialog': '../shared/js/custom_dialog',
'debug': 'vendor/debug'
},
shim: {
Expand Down Expand Up @@ -68,6 +70,9 @@ requireApp('camera/js/vendor/alameda.js', function() {
},
'GestureDetector': {
exports: 'GestureDetector'
},
'CustomDialog': {
exports: 'CustomDialog'
}
}
});
Expand Down

0 comments on commit b1fba95

Please sign in to comment.