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

Unified Diff: ui/file_manager/gallery/js/ribbon.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/file_manager/gallery/js/gallery.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/gallery/js/ribbon.js
diff --git a/ui/file_manager/gallery/js/ribbon.js b/ui/file_manager/gallery/js/ribbon.js
index ef61140122b78a3cd4ddcdab6978f9bbb166d27c..4fc44b6c58d63bc97a6596e764356785f2218345 100644
--- a/ui/file_manager/gallery/js/ribbon.js
+++ b/ui/file_manager/gallery/js/ribbon.js
@@ -96,11 +96,27 @@ Ribbon.prototype.disable = function() {
* @private
*/
Ribbon.prototype.onSplice_ = function(event) {
- if (event.removed.length == 0)
+ if (event.removed.length > 1) {
+ console.error('Cannot remove multiple items.');
return;
+ }
- if (event.removed.length > 1) {
- console.error('Cannot remove multiple items');
+ if (event.removed.length > 0 && event.added.length > 0) {
+ console.error('Replacing is not implemented.');
+ return;
+ }
+
+ if (event.added.length > 0) {
+ for (var i = 0; i < event.added.length; i++) {
+ var index = this.dataModel_.indexOf(event.added[i]);
+ if (index === -1)
+ continue;
+ var element = this.renderThumbnail_(index);
+ var nextItem = this.dataModel_.item(index + 1);
+ var nextElement =
+ nextItem && this.renderCache_[nextItem.getEntry().toURL()];
+ this.insertBefore(element, nextElement);
yoshiki 2014/07/09 03:49:01 if nextElement is null, it may fail.
hirono 2014/07/09 04:04:54 The reference element can be null. https://develop
+ }
return;
}
@@ -160,8 +176,7 @@ Ribbon.prototype.onSelection_ = function() {
// TODO(dgozman): use margin instead of 2 here.
var itemWidth = this.clientHeight - 2;
- var fullItems = Ribbon.ITEMS_COUNT;
- fullItems = Math.min(fullItems, length);
+ var fullItems = Math.min(Ribbon.ITEMS_COUNT, length);
var right = Math.floor((fullItems - 1) / 2);
var fullWidth = fullItems * itemWidth;
@@ -242,11 +257,13 @@ Ribbon.prototype.onSelection_ = function() {
}
var oldSelected = this.querySelector('[selected]');
- if (oldSelected) oldSelected.removeAttribute('selected');
+ if (oldSelected)
+ oldSelected.removeAttribute('selected');
var newSelected =
this.renderCache_[this.dataModel_.item(selectedIndex).getEntry().toURL()];
- if (newSelected) newSelected.setAttribute('selected', true);
+ if (newSelected)
+ newSelected.setAttribute('selected', true);
};
/**
« no previous file with comments | « ui/file_manager/gallery/js/gallery.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698