Chromium Code Reviews| Index: chrome/browser/resources/file_manager/js/action_choice.js |
| =================================================================== |
| --- chrome/browser/resources/file_manager/js/action_choice.js (revision 157111) |
| +++ chrome/browser/resources/file_manager/js/action_choice.js (working copy) |
| @@ -103,21 +103,39 @@ |
| */ |
| ActionChoice.prototype.loadSource_ = function(source) { |
| var onTraversed = function(results) { |
| - this.previews_.removeAttribute('loading'); |
| + var videos = results.filter(FileType.isVideo); |
| + var videoLabel = this.dom_.querySelector('label[for=watch-single-video]'); |
| + if (videos.length == 1) { |
| + var name = videos[0].name; |
| + var extPos = name.lastIndexOf('.'); |
|
Vladislav Kaznacheev
2012/09/17 19:46:14
We have a function that does this in ImageUtil. Pl
dgozman
2012/09/18 11:28:09
Yeah, I just didn't want to include ImageUtil here
|
| + if (extPos != -1) |
| + name = name.substring(0, extPos); |
| + videoLabel.textContent = loadTimeData.getStringF( |
| + 'ACTION_CHOICE_WATCH_SINGLE_VIDEO', name); |
| + this.singleVideo_ = videos[0]; |
| + } else { |
| + videoLabel.parentNode.style.display = 'none'; |
| + } |
| + |
| var mediaFiles = results.filter(FileType.isImageOrVideo); |
| + if (mediaFiles.length == 0) { |
| + this.dom_.querySelector('#import-photos-to-drive').parentNode. |
|
Vladislav Kaznacheev
2012/09/17 19:46:14
This branch will be executed if we have a single v
dgozman
2012/09/18 11:28:09
Why not? We still can backup it from the device to
|
| + style.display = 'none'; |
| + } |
| + var previews = results; |
| if (mediaFiles.length < ActionChoice.PREVIEW_COUNT) { |
| this.counter_.textContent = loadTimeData.getStringF( |
| 'ACTION_CHOICE_COUNTER_NO_MEDIA', results.length); |
| } else { |
| this.counter_.textContent = loadTimeData.getStringF( |
| 'ACTION_CHOICE_COUNTER', results.length, mediaFiles.length); |
| - results = mediaFiles; |
| + previews = mediaFiles; |
| } |
| - |
| - var count = Math.min(results.length, ActionChoice.PREVIEW_COUNT); |
| + this.previews_.removeAttribute('loading'); |
| + var count = Math.min(previews.length, ActionChoice.PREVIEW_COUNT); |
| for (var index = 0; index < count; index++) { |
| - this.renderPreview_(results[index]); |
| + this.renderPreview_(previews[index]); |
| } |
| }.bind(this); |
| @@ -125,6 +143,7 @@ |
| this.sourceEntry_ = entry; |
| // TODO(dgozman): add icon. |
| this.title_.textContent = entry.name; |
| + this.document_.querySelector('title').textContent = entry.name; |
| util.traverseTree(entry, onTraversed, 0 /* infinite depth */); |
| }.bind(this); |
| @@ -185,6 +204,9 @@ |
| var url = chrome.extension.getURL('main.html') + |
| '#' + this.sourceEntry_.fullPath; |
| chrome.windows.create({url: url, type: 'popup'}); |
| + } else if (this.document_.querySelector('#watch-single-video').checked) { |
| + chrome.fileBrowserPrivate.viewFiles([this.singleVideo_.toURL()], 'watch', |
| + function(success) {}); |
| } |
| this.close_(); |
| }; |