Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(673)

Side by Side Diff: ui/file_manager/gallery/js/gallery.js

Issue 371333002: Gallery.app: Update the ribbon control when the item is inserted. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * Called from the main frame when unloading. 8 * Called from the main frame when unloading.
9 * @param {boolean=} opt_exiting True if the app is exiting. 9 * @param {boolean=} opt_exiting True if the app is exiting.
10 */ 10 */
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 metadataEncoder, 94 metadataEncoder,
95 function(success) { 95 function(success) {
96 if (!success) { 96 if (!success) {
97 reject('Failed to save the image.'); 97 reject('Failed to save the image.');
98 return; 98 return;
99 } 99 }
100 100
101 // The item's entry is updated to the latest entry. Update metadata. 101 // The item's entry is updated to the latest entry. Update metadata.
102 item.setMetadata(newMetadata); 102 item.setMetadata(newMetadata);
103 103
104 // Current entry is updated.
105 // Dispatch an event.
106 var event = new Event('content');
107 event.item = item;
108 event.oldEntry = oldEntry;
109 event.metadata = newMetadata;
110 this.dispatchEvent(event);
111
104 if (util.isSameEntry(oldEntry, item.getEntry())) { 112 if (util.isSameEntry(oldEntry, item.getEntry())) {
105 // Current entry is updated.
106 // Dispatch an event.
107 var event = new Event('content');
108 event.item = item;
109 event.oldEntry = item.getEntry();
110 event.metadata = newMetadata;
111 this.dispatchEvent(event);
112
113 // Need an update of metdataCache. 113 // Need an update of metdataCache.
114 this.metadataCache_.set( 114 this.metadataCache_.set(
115 item.getEntry(), 115 item.getEntry(),
116 Gallery.METADATA_TYPE, 116 Gallery.METADATA_TYPE,
117 newMetadata); 117 newMetadata);
118 } else { 118 } else {
119 // New entry is added and the item now tracks it. 119 // New entry is added and the item now tracks it.
120 // Add another item for the old entry. 120 // Add another item for the old entry.
121 var anotherItem = new Gallery.Item( 121 var anotherItem = new Gallery.Item(
122 oldEntry, oldMetadata, this.metadataCache_); 122 oldEntry, oldMetadata, this.metadataCache_);
123 this.splice(this.indexOf(item), 0, anotherItem); 123 // The item must be added behind the existing item so that it does
124 // not change the index of the existing item.
125 // TODO(hirono): Update the item index of the selection model
126 // correctly.
127 this.splice(this.indexOf(item) + 1, 0, anotherItem);
124 } 128 }
125 129
126 fulfill(); 130 fulfill();
127 }.bind(this)); 131 }.bind(this));
128 }.bind(this)); 132 }.bind(this));
129 }; 133 };
130 134
131 /** 135 /**
132 * Gallery for viewing and editing image files. 136 * Gallery for viewing and editing image files.
133 * 137 *
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 window.loadTimeData.data = backgroundComponents.stringData; 964 window.loadTimeData.data = backgroundComponents.stringData;
961 gallery = new Gallery(backgroundComponents.volumeManager); 965 gallery = new Gallery(backgroundComponents.volumeManager);
962 }; 966 };
963 967
964 /** 968 /**
965 * Loads entries. 969 * Loads entries.
966 */ 970 */
967 window.loadEntries = function(entries, selectedEntries) { 971 window.loadEntries = function(entries, selectedEntries) {
968 gallery.load(entries, selectedEntries); 972 gallery.load(entries, selectedEntries);
969 }; 973 };
OLDNEW
« no previous file with comments | « no previous file | ui/file_manager/gallery/js/ribbon.js » ('j') | ui/file_manager/gallery/js/ribbon.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698