1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
8 * Called from the main frame when unloading.
9 * @param {boolean=} opt_exiting True if the app is exiting.
11 function unload(opt_exiting) { Gallery.instance.onUnload(opt_exiting) }
14 * Gallery for viewing and editing image files.
16 * @param {Object} context Object containing the following:
17 * {function(string)} onNameChange Called every time a selected
18 * item name changes (on rename and on selection change).
19 * {AppWindow} appWindow
20 * {function(string)} onBack
21 * {function()} onClose
22 * {function()} onMaximize
23 * {function()} onMinimize
24 * {function(boolean)} onAppRegionChanged
25 * {MetadataCache} metadataCache
26 * {Array.<Object>} shareActions
27 * {string} readonlyDirName Directory name for readonly warning or null.
28 * {DirEntry} saveDirEntry Directory to save to.
29 * {function(string)} displayStringFunction.
30 * @param {VolumeManagerWrapper} volumeManager The VolumeManager instance of
35 function Gallery(context, volumeManager) {
36 this.container_ = document.querySelector('.gallery');
37 this.document_ = document;
38 this.context_ = context;
39 this.metadataCache_ = context.metadataCache;
40 this.volumeManager_ = volumeManager;
41 this.selectedEntry_ = null;
42 this.metadataCacheObserverId_ = null;
43 this.onExternallyUnmountedBound_ = this.onExternallyUnmounted_.bind(this);
45 this.dataModel_ = new cr.ui.ArrayDataModel([]);
46 this.selectionModel_ = new cr.ui.ListSelectionModel();
47 loadTimeData.data = context.loadTimeData;
50 this.initListeners_();
54 * Gallery extends cr.EventTarget.
56 Gallery.prototype.__proto__ = cr.EventTarget.prototype;
59 * Creates and initializes a Gallery object based on a context.
61 * @param {Object} context Gallery context.
62 * @param {VolumeManagerWrapper} volumeManager VolumeManager of the system.
63 * @param {Array.<Entry>} entries Array of entries.
64 * @param {Array.<Entry>} selectedEntries Array of selected entries.
66 Gallery.open = function(context, volumeManager, entries, selectedEntries) {
67 Gallery.instance = new Gallery(context, volumeManager);
68 Gallery.instance.load(entries, selectedEntries);
72 * Tools fade-out timeout im milliseconds.
76 Gallery.FADE_TIMEOUT = 3000;
79 * First time tools fade-out timeout im milliseconds.
83 Gallery.FIRST_FADE_TIMEOUT = 1000;
86 * Time until mosaic is initialized in the background. Used to make gallery
87 * in the slide mode load faster. In miiliseconds.
91 Gallery.MOSAIC_BACKGROUND_INIT_DELAY = 1000;
94 * Types of metadata Gallery uses (to query the metadata cache).
98 Gallery.METADATA_TYPE = 'thumbnail|filesystem|media|streaming|drive';
101 * Initializes listeners.
104 Gallery.prototype.initListeners_ = function() {
105 this.document_.oncontextmenu = function(e) { e.preventDefault(); };
106 this.keyDownBound_ = this.onKeyDown_.bind(this);
107 this.document_.body.addEventListener('keydown', this.keyDownBound_);
109 this.inactivityWatcher_ = new MouseInactivityWatcher(
110 this.container_, Gallery.FADE_TIMEOUT, this.hasActiveTool.bind(this));
112 // Search results may contain files from different subdirectories so
113 // the observer is not going to work.
114 if (!this.context_.searchResults && this.context_.curDirEntry) {
115 this.metadataCacheObserverId_ = this.metadataCache_.addObserver(
116 this.context_.curDirEntry,
117 MetadataCache.CHILDREN,
119 this.updateThumbnails_.bind(this));
121 this.volumeManager_.addEventListener(
122 'externally-unmounted', this.onExternallyUnmountedBound_);
126 * Closes gallery when a volume containing the selected item is unmounted.
127 * @param {Event} event The unmount event.
130 Gallery.prototype.onExternallyUnmounted_ = function(event) {
131 if (!this.selectedEntry_)
134 if (this.volumeManager_.getVolumeInfo(this.selectedEntry_) ===
141 * Unloads the Gallery.
142 * @param {boolean} exiting True if the app is exiting.
144 Gallery.prototype.onUnload = function(exiting) {
145 if (this.metadataCacheObserverId_ !== null)
146 this.metadataCache_.removeObserver(this.metadataCacheObserverId_);
147 this.volumeManager_.removeEventListener(
148 'externally-unmounted', this.onExternallyUnmountedBound_);
149 this.slideMode_.onUnload(exiting);
156 Gallery.prototype.initDom_ = function() {
157 // Initialize the dialog label.
158 cr.ui.dialogs.BaseDialog.OK_LABEL = str('GALLERY_OK_LABEL');
159 cr.ui.dialogs.BaseDialog.CANCEL_LABEL = str('GALLERY_CANCEL_LABEL');
161 var content = util.createChild(this.container_, 'content');
162 content.addEventListener('click', this.onContentClick_.bind(this));
164 this.header_ = util.createChild(this.container_, 'header tool dimmable');
165 this.toolbar_ = util.createChild(this.container_, 'toolbar tool dimmable');
167 var backButton = util.createChild(this.container_,
168 'back-button tool dimmable');
169 util.createChild(backButton);
170 backButton.addEventListener('click', this.onBack_.bind(this));
172 var preventDefault = function(event) { event.preventDefault(); };
174 var minimizeButton = util.createChild(this.header_,
175 'minimize-button tool dimmable',
177 minimizeButton.tabIndex = -1;
178 minimizeButton.addEventListener('click', this.onMinimize_.bind(this));
179 minimizeButton.addEventListener('mousedown', preventDefault);
181 var maximizeButton = util.createChild(this.header_,
182 'maximize-button tool dimmable',
184 maximizeButton.tabIndex = -1;
185 maximizeButton.addEventListener('click', this.onMaximize_.bind(this));
186 maximizeButton.addEventListener('mousedown', preventDefault);
188 var closeButton = util.createChild(this.header_,
189 'close-button tool dimmable',
191 closeButton.tabIndex = -1;
192 closeButton.addEventListener('click', this.onClose_.bind(this));
193 closeButton.addEventListener('mousedown', preventDefault);
195 this.filenameSpacer_ = util.createChild(this.toolbar_, 'filename-spacer');
196 this.filenameEdit_ = util.createChild(this.filenameSpacer_,
199 this.filenameEdit_.setAttribute('type', 'text');
200 this.filenameEdit_.addEventListener('blur',
201 this.onFilenameEditBlur_.bind(this));
203 this.filenameEdit_.addEventListener('focus',
204 this.onFilenameFocus_.bind(this));
206 this.filenameEdit_.addEventListener('keydown',
207 this.onFilenameEditKeydown_.bind(this));
209 util.createChild(this.toolbar_, 'button-spacer');
211 this.prompt_ = new ImageEditor.Prompt(this.container_, str);
213 this.modeButton_ = util.createChild(this.toolbar_, 'button mode', 'button');
214 this.modeButton_.addEventListener('click',
215 this.toggleMode_.bind(this, null));
217 this.mosaicMode_ = new MosaicMode(content,
219 this.selectionModel_,
222 this.toggleMode_.bind(this, null));
224 this.slideMode_ = new SlideMode(this.container_,
229 this.selectionModel_,
231 this.toggleMode_.bind(this),
234 this.slideMode_.addEventListener('image-displayed', function() {
235 cr.dispatchSimpleEvent(this, 'image-displayed');
237 this.slideMode_.addEventListener('image-saved', function() {
238 cr.dispatchSimpleEvent(this, 'image-saved');
241 var deleteButton = this.createToolbarButton_('delete', 'GALLERY_DELETE');
242 deleteButton.addEventListener('click', this.delete_.bind(this));
244 this.shareButton_ = this.createToolbarButton_('share', 'GALLERY_SHARE');
245 this.shareButton_.setAttribute('disabled', '');
246 this.shareButton_.addEventListener('click', this.toggleShare_.bind(this));
248 this.shareMenu_ = util.createChild(this.container_, 'share-menu');
249 this.shareMenu_.hidden = true;
250 util.createChild(this.shareMenu_, 'bubble-point');
252 this.dataModel_.addEventListener('splice', this.onSplice_.bind(this));
253 this.dataModel_.addEventListener('content', this.onContentChange_.bind(this));
255 this.selectionModel_.addEventListener('change', this.onSelection_.bind(this));
256 this.slideMode_.addEventListener('useraction', this.onUserAction_.bind(this));
260 * Creates toolbar button.
262 * @param {string} className Class to add.
263 * @param {string} title Button title.
264 * @return {HTMLElement} Newly created button.
267 Gallery.prototype.createToolbarButton_ = function(className, title) {
268 var button = util.createChild(this.toolbar_, className, 'button');
269 button.title = str(title);
276 * @param {Array.<Entry>} entries Array of entries.
277 * @param {Array.<Entry>} selectedEntries Array of selected entries.
279 Gallery.prototype.load = function(entries, selectedEntries) {
281 for (var index = 0; index < entries.length; ++index) {
282 items.push(new Gallery.Item(entries[index]));
284 this.dataModel_.push.apply(this.dataModel_, items);
286 this.selectionModel_.adjustLength(this.dataModel_.length);
288 // Comparing Entries by reference is not safe. Therefore we have to use URLs.
289 var entryIndexesByURLs = {};
290 for (var index = 0; index < entries.length; index++) {
291 entryIndexesByURLs[entries[index].toURL()] = index;
294 for (var i = 0; i !== selectedEntries.length; i++) {
295 var selectedIndex = entryIndexesByURLs[selectedEntries[i].toURL()];
296 if (selectedIndex !== undefined)
297 this.selectionModel_.setIndexSelected(selectedIndex, true);
299 console.error('Cannot select ' + selectedEntries[i]);
302 if (this.selectionModel_.selectedIndexes.length === 0)
305 var mosaic = this.mosaicMode_ && this.mosaicMode_.getMosaic();
307 // Mosaic view should show up if most of the selected files are images.
309 for (var i = 0; i !== selectedEntries.length; i++) {
310 if (FileType.getMediaType(selectedEntries[i]) === 'image')
313 var mostlyImages = imagesCount > (selectedEntries.length / 2.0);
315 var forcedMosaic = (this.context_.pageState &&
316 this.context_.pageState.gallery === 'mosaic');
318 var showMosaic = (mostlyImages && selectedEntries.length > 1) || forcedMosaic;
319 if (mosaic && showMosaic) {
320 this.setCurrentMode_(this.mosaicMode_);
323 this.inactivityWatcher_.check(); // Show the toolbar.
324 cr.dispatchSimpleEvent(this, 'loaded');
326 this.setCurrentMode_(this.slideMode_);
327 var maybeLoadMosaic = function() {
330 cr.dispatchSimpleEvent(this, 'loaded');
332 /* TODO: consider nice blow-up animation for the first image */
333 this.slideMode_.enter(null, function() {
334 // Flash the toolbar briefly to show it is there.
335 this.inactivityWatcher_.kick(Gallery.FIRST_FADE_TIMEOUT);
342 * Closes the Gallery and go to Files.app.
345 Gallery.prototype.back_ = function() {
346 if (util.isFullScreen(this.context_.appWindow)) {
347 util.toggleFullScreen(this.context_.appWindow,
348 false); // Leave the full screen mode.
350 this.context_.onBack(this.getSelectedEntries());
354 * Handles user's 'Back' action (Escape or a click on the X icon).
357 Gallery.prototype.onBack_ = function() {
358 this.executeWhenReady(this.back_.bind(this));
362 * Handles user's 'Close' action.
365 Gallery.prototype.onClose_ = function() {
366 this.executeWhenReady(this.context_.onClose);
370 * Handles user's 'Maximize' action (Escape or a click on the X icon).
373 Gallery.prototype.onMaximize_ = function() {
374 this.executeWhenReady(this.context_.onMaximize);
378 * Handles user's 'Maximize' action (Escape or a click on the X icon).
381 Gallery.prototype.onMinimize_ = function() {
382 this.executeWhenReady(this.context_.onMinimize);
386 * Executes a function when the editor is done with the modifications.
387 * @param {function} callback Function to execute.
389 Gallery.prototype.executeWhenReady = function(callback) {
390 this.currentMode_.executeWhenReady(callback);
394 * @return {Object} File browser private API.
396 Gallery.getFileBrowserPrivate = function() {
397 return chrome.fileBrowserPrivate || window.top.chrome.fileBrowserPrivate;
401 * @return {boolean} True if some tool is currently active.
403 Gallery.prototype.hasActiveTool = function() {
404 return this.currentMode_.hasActiveTool() ||
405 this.isSharing_() || this.isRenaming_();
409 * External user action event handler.
412 Gallery.prototype.onUserAction_ = function() {
413 this.closeShareMenu_();
414 // Show the toolbar and hide it after the default timeout.
415 this.inactivityWatcher_.kick();
419 * Sets the current mode, update the UI.
420 * @param {Object} mode Current mode.
423 Gallery.prototype.setCurrentMode_ = function(mode) {
424 if (mode !== this.slideMode_ && mode !== this.mosaicMode_)
425 console.error('Invalid Gallery mode');
427 this.currentMode_ = mode;
428 this.container_.setAttribute('mode', this.currentMode_.getName());
429 this.updateSelectionAndState_();
430 this.updateButtons_();
434 * Mode toggle event handler.
435 * @param {function=} opt_callback Callback.
436 * @param {Event=} opt_event Event that caused this call.
439 Gallery.prototype.toggleMode_ = function(opt_callback, opt_event) {
440 if (!this.modeButton_)
443 if (this.changingMode_) // Do not re-enter while changing the mode.
447 this.onUserAction_();
449 this.changingMode_ = true;
451 var onModeChanged = function() {
452 this.changingMode_ = false;
453 if (opt_callback) opt_callback();
456 var tileIndex = Math.max(0, this.selectionModel_.selectedIndex);
458 var mosaic = this.mosaicMode_.getMosaic();
459 var tileRect = mosaic.getTileRect(tileIndex);
461 if (this.currentMode_ === this.slideMode_) {
462 this.setCurrentMode_(this.mosaicMode_);
464 tileRect, this.slideMode_.getSelectedImageRect(), true /* instant */);
465 this.slideMode_.leave(tileRect,
467 // Animate back to normal position.
473 this.setCurrentMode_(this.slideMode_);
474 this.slideMode_.enter(tileRect,
476 // Animate to zoomed position.
477 mosaic.transform(tileRect, this.slideMode_.getSelectedImageRect());
485 * Deletes the selected items.
488 Gallery.prototype.delete_ = function() {
489 this.onUserAction_();
491 // Clone the sorted selected indexes array.
492 var indexesToRemove = this.selectionModel_.selectedIndexes.slice();
493 if (!indexesToRemove.length)
496 /* TODO(dgozman): Implement Undo delete, Remove the confirmation dialog. */
498 var itemsToRemove = this.getSelectedItems();
499 var plural = itemsToRemove.length > 1;
500 var param = plural ? itemsToRemove.length : itemsToRemove[0].getFileName();
502 function deleteNext() {
503 if (!itemsToRemove.length)
504 return; // All deleted.
506 // TODO(hirono): Use fileOperationManager.
507 var entry = itemsToRemove.pop().getEntry();
508 entry.remove(deleteNext, function() {
509 util.flog('Error deleting: ' + entry.name, deleteNext);
513 // Prevent the Gallery from handling Esc and Enter.
514 this.document_.body.removeEventListener('keydown', this.keyDownBound_);
515 var restoreListener = function() {
516 this.document_.body.addEventListener('keydown', this.keyDownBound_);
520 var confirm = new cr.ui.dialogs.ConfirmDialog(this.container_);
521 confirm.show(strf(plural ?
522 'GALLERY_CONFIRM_DELETE_SOME' : 'GALLERY_CONFIRM_DELETE_ONE', param),
525 this.selectionModel_.unselectAll();
526 this.selectionModel_.leadIndex = -1;
527 // Remove items from the data model, starting from the highest index.
528 while (indexesToRemove.length)
529 this.dataModel_.splice(indexesToRemove.pop(), 1);
530 // Delete actual files.
534 // Restore the listener after a timeout so that ESC is processed.
535 setTimeout(restoreListener, 0);
540 * @return {Array.<Gallery.Item>} Current selection.
542 Gallery.prototype.getSelectedItems = function() {
543 return this.selectionModel_.selectedIndexes.map(
544 this.dataModel_.item.bind(this.dataModel_));
548 * @return {Array.<Entry>} Array of currently selected entries.
550 Gallery.prototype.getSelectedEntries = function() {
551 return this.selectionModel_.selectedIndexes.map(function(index) {
552 return this.dataModel_.item(index).getEntry();
557 * @return {Gallery.Item} Current single selection.
559 Gallery.prototype.getSingleSelectedItem = function() {
560 var items = this.getSelectedItems();
561 if (items.length > 1)
562 throw new Error('Unexpected multiple selection');
567 * Selection change event handler.
570 Gallery.prototype.onSelection_ = function() {
571 this.updateSelectionAndState_();
572 this.updateShareMenu_();
576 * Data model splice event handler.
579 Gallery.prototype.onSplice_ = function() {
580 this.selectionModel_.adjustLength(this.dataModel_.length);
584 * Content change event handler.
585 * @param {Event} event Event.
588 Gallery.prototype.onContentChange_ = function(event) {
589 var index = this.dataModel_.indexOf(event.item);
590 if (index !== this.selectionModel_.selectedIndex)
591 console.error('Content changed for unselected item');
592 this.updateSelectionAndState_();
598 * @param {Event} event Event.
601 Gallery.prototype.onKeyDown_ = function(event) {
602 var wasSharing = this.isSharing_();
603 this.closeShareMenu_();
605 if (this.currentMode_.onKeyDown(event))
608 switch (util.getKeyModifiers(event) + event.keyIdentifier) {
609 case 'U+0008': // Backspace.
610 // The default handler would call history.back and close the Gallery.
611 event.preventDefault();
614 case 'U+001B': // Escape
615 // Swallow Esc if it closed the Share menu, otherwise close the Gallery.
620 case 'U+004D': // 'm' switches between Slide and Mosaic mode.
621 this.toggleMode_(null, event);
624 case 'U+0056': // 'v'
625 this.slideMode_.startSlideshow(SlideMode.SLIDESHOW_INTERVAL_FIRST, event);
628 case 'U+007F': // Delete
629 case 'Shift-U+0033': // Shift+'3' (Delete key might be missing).
635 // Name box and rename support.
638 * Updates the UI related to the selected item and the persistent state.
642 Gallery.prototype.updateSelectionAndState_ = function() {
643 var numSelectedItems = this.selectionModel_.selectedIndexes.length;
644 var displayName = '';
645 var selectedEntryURL = null;
647 // If it's selecting something, update the variable values.
648 if (numSelectedItems) {
650 this.dataModel_.item(this.selectionModel_.selectedIndex);
651 this.selectedEntry_ = selectedItem.getEntry();
652 selectedEntryURL = this.selectedEntry_.toURL();
654 if (numSelectedItems === 1) {
655 window.top.document.title = this.selectedEntry_.name;
656 displayName = ImageUtil.getDisplayNameFromName(this.selectedEntry_.name);
657 } else if (this.context_.curDirEntry) {
658 // If the Gallery was opened on search results the search query will not
659 // be recorded in the app state and the relaunch will just open the
660 // gallery in the curDirEntry directory.
661 window.top.document.title = this.context_.curDirEntry.name;
662 displayName = strf('GALLERY_ITEMS_SELECTED', numSelectedItems);
666 window.top.util.updateAppState(
667 null, // Keep the current directory.
668 selectedEntryURL, // Update the selection.
669 {gallery: (this.currentMode_ === this.mosaicMode_ ? 'mosaic' : 'slide')});
671 // We can't rename files in readonly directory.
672 // We can only rename a single file.
673 this.filenameEdit_.disabled = numSelectedItems !== 1 ||
674 this.context_.readonlyDirName;
675 this.filenameEdit_.value = displayName;
679 * Click event handler on filename edit box
682 Gallery.prototype.onFilenameFocus_ = function() {
683 ImageUtil.setAttribute(this.filenameSpacer_, 'renaming', true);
684 this.filenameEdit_.originalValue = this.filenameEdit_.value;
685 setTimeout(this.filenameEdit_.select.bind(this.filenameEdit_), 0);
686 this.onUserAction_();
690 * Blur event handler on filename edit box.
692 * @param {Event} event Blur event.
693 * @return {boolean} if default action should be prevented.
696 Gallery.prototype.onFilenameEditBlur_ = function(event) {
697 if (this.filenameEdit_.value && this.filenameEdit_.value[0] === '.') {
698 this.prompt_.show('GALLERY_FILE_HIDDEN_NAME', 5000);
699 this.filenameEdit_.focus();
700 event.stopPropagation();
701 event.preventDefault();
705 var item = this.getSingleSelectedItem();
706 var oldEntry = item.getEntry();
708 var onFileExists = function() {
709 this.prompt_.show('GALLERY_FILE_EXISTS', 3000);
710 this.filenameEdit_.value = name;
711 this.filenameEdit_.focus();
714 var onSuccess = function() {
715 var event = new Event('content');
717 event.oldEntry = oldEntry;
718 event.metadata = null; // Metadata unchanged.
719 this.dataModel_.dispatchEvent(event);
722 if (this.filenameEdit_.value) {
723 this.getSingleSelectedItem().rename(
724 this.filenameEdit_.value, onSuccess, onFileExists);
727 ImageUtil.setAttribute(this.filenameSpacer_, 'renaming', false);
728 this.onUserAction_();
732 * Keydown event handler on filename edit box
735 Gallery.prototype.onFilenameEditKeydown_ = function() {
736 switch (event.keyCode) {
738 this.filenameEdit_.value = this.filenameEdit_.originalValue;
739 this.filenameEdit_.blur();
743 this.filenameEdit_.blur();
746 event.stopPropagation();
750 * @return {boolean} True if file renaming is currently in progress.
753 Gallery.prototype.isRenaming_ = function() {
754 return this.filenameSpacer_.hasAttribute('renaming');
758 * Content area click handler.
761 Gallery.prototype.onContentClick_ = function() {
762 this.closeShareMenu_();
763 this.filenameEdit_.blur();
766 // Share button support.
769 * @return {boolean} True if the Share menu is active.
772 Gallery.prototype.isSharing_ = function() {
773 return !this.shareMenu_.hidden;
777 * Close Share menu if it is open.
780 Gallery.prototype.closeShareMenu_ = function() {
781 if (this.isSharing_())
786 * Share button handler.
789 Gallery.prototype.toggleShare_ = function() {
790 if (!this.shareButton_.hasAttribute('disabled'))
791 this.shareMenu_.hidden = !this.shareMenu_.hidden;
792 this.inactivityWatcher_.check();
796 * Updates available actions list based on the currently selected urls.
799 Gallery.prototype.updateShareMenu_ = function() {
800 var entries = this.getSelectedEntries();
802 function isShareAction(task) {
803 var taskParts = task.taskId.split('|');
804 return taskParts[0] !== chrome.runtime.id;
807 var api = Gallery.getFileBrowserPrivate();
808 var mimeTypes = []; // TODO(kaznacheev) Collect mime types properly.
810 var createShareMenu = function(tasks) {
811 var wasHidden = this.shareMenu_.hidden;
812 this.shareMenu_.hidden = true;
813 var items = this.shareMenu_.querySelectorAll('.item');
814 for (var i = 0; i !== items.length; i++) {
815 items[i].parentNode.removeChild(items[i]);
818 for (var t = 0; t !== tasks.length; t++) {
820 if (!isShareAction(task)) continue;
822 var item = util.createChild(this.shareMenu_, 'item');
823 item.textContent = task.title;
824 item.style.backgroundImage = 'url(' + task.iconUrl + ')';
825 item.addEventListener('click', function(taskId) {
826 this.toggleShare_(); // Hide the menu.
827 // TODO(hirono): Use entries instead of URLs.
828 this.executeWhenReady(
829 api.executeTask.bind(
832 util.entriesToURLs(entries),
835 new cr.ui.dialogs.AlertDialog(this.container_);
836 util.isTeleported(window).then(function(teleported) {
838 util.showOpenInOtherDesktopAlert(alertDialog, entries);
841 }.bind(this, task.taskId));
844 var empty = this.shareMenu_.querySelector('.item') === null;
845 ImageUtil.setAttribute(this.shareButton_, 'disabled', empty);
846 this.shareMenu_.hidden = wasHidden || empty;
849 // Create or update the share menu with a list of sharing tasks and show
850 // or hide the share button.
851 // TODO(mtomasz): Pass Entries directly, instead of URLs.
853 createShareMenu([]); // Empty list of tasks, since there is no selection.
855 api.getFileTasks(util.entriesToURLs(entries), mimeTypes, createShareMenu);
859 * Updates thumbnails.
862 Gallery.prototype.updateThumbnails_ = function() {
863 if (this.currentMode_ === this.slideMode_)
864 this.slideMode_.updateThumbnails();
866 if (this.mosaicMode_) {
867 var mosaic = this.mosaicMode_.getMosaic();
868 if (mosaic.isInitialized())
877 Gallery.prototype.updateButtons_ = function() {
878 if (this.modeButton_) {
880 this.currentMode_ === this.slideMode_ ? this.mosaicMode_ :
882 this.modeButton_.title = str(oppositeMode.getTitle());