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

Side by Side Diff: chrome/browser/resources/file_manager/js/image_editor/gallery.js

Issue 8773008: Photo Editor: Fix the Share button (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 /* 5 /*
6 * Base class that Ribbon uses to display photos. 6 * Base class that Ribbon uses to display photos.
7 */ 7 */
8 8
9 function RibbonClient() {} 9 function RibbonClient() {}
10 10
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 this.editBarModeWrapper_, 151 this.editBarModeWrapper_,
152 Gallery.editorModes, 152 Gallery.editorModes,
153 this.displayStringFunction_); 153 this.displayStringFunction_);
154 154
155 this.imageView_ = this.editor_.getImageView(); 155 this.imageView_ = this.editor_.getImageView();
156 156
157 this.editor_.trackWindow(doc.defaultView); 157 this.editor_.trackWindow(doc.defaultView);
158 158
159 if (shareActions.length > 0) { 159 if (shareActions.length > 0) {
160 this.shareMode_ = new ShareMode( 160 this.shareMode_ = new ShareMode(
161 this.container_, this.toolbar_, shareActions, 161 this.editor_, this.container_, this.toolbar_, shareActions,
162 this.onShare_.bind(this), this.onActionExecute_.bind(this), 162 this.onShare_.bind(this), this.onActionExecute_.bind(this),
163 this.displayStringFunction_); 163 this.displayStringFunction_);
164
165 } else { 164 } else {
166 this.shareMode_ = null; 165 this.shareMode_ = null;
167 } 166 }
168 }; 167 };
169 168
170 Gallery.prototype.load = function(parentDirEntry, items, selectedItem) { 169 Gallery.prototype.load = function(parentDirEntry, items, selectedItem) {
171 this.parentDirEntry_ = parentDirEntry; 170 this.parentDirEntry_ = parentDirEntry;
172 171
173 var urls = []; 172 var urls = [];
174 var selectedIndex = -1; 173 var selectedIndex = -1;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 this.editor_.closeSession(this.saveItem_.bind(this, item, null)); 253 this.editor_.closeSession(this.saveItem_.bind(this, item, null));
255 }; 254 };
256 255
257 Gallery.prototype.isEditing_ = function() { 256 Gallery.prototype.isEditing_ = function() {
258 return this.container_.hasAttribute('editing'); 257 return this.container_.hasAttribute('editing');
259 }; 258 };
260 259
261 Gallery.prototype.onEdit_ = function() { 260 Gallery.prototype.onEdit_ = function() {
262 ImageUtil.setAttribute(this.container_, 'editing', !this.isEditing_()); 261 ImageUtil.setAttribute(this.container_, 'editing', !this.isEditing_());
263 262
263 // The user has just clicked on the Edit button. Dismiss the Share menu.
264 if (this.isSharing_()) {
265 this.onShare_();
266 }
267
264 // isEditing_ has just been flipped to a new value. 268 // isEditing_ has just been flipped to a new value.
265 if (this.isEditing_()) { 269 if (this.isEditing_()) {
266 this.cancelFading_(); 270 this.cancelFading_();
267 } else if (!this.isSharing_()) { 271 } else {
268 var item = this.ribbon_.getSelectedItem(); 272 var item = this.ribbon_.getSelectedItem();
269 this.editor_.requestImage(item.updateThumbnail.bind(item)); 273 this.editor_.requestImage(item.updateThumbnail.bind(item));
270 this.initiateFading_(); 274 this.initiateFading_();
271 } 275 }
272 276
273 ImageUtil.setAttribute(this.editButton_, 'pressed', this.isEditing_()); 277 ImageUtil.setAttribute(this.editButton_, 'pressed', this.isEditing_());
274 }; 278 };
275 279
276 Gallery.prototype.isSharing_ = function(event) { 280 Gallery.prototype.isSharing_ = function(event) {
277 return this.shareMode_ && this.shareMode_ == this.editor_.getMode(); 281 return this.shareMode_ && this.shareMode_ == this.editor_.getMode();
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 image.style.maxHeight = ''; 936 image.style.maxHeight = '';
933 resizeToFill(image, image.width / image.height); 937 resizeToFill(image, image.width / image.height);
934 } 938 }
935 img.onload = onLoad.bind(null, img); 939 img.onload = onLoad.bind(null, img);
936 } 940 }
937 941
938 img.setAttribute('src', url); 942 img.setAttribute('src', url);
939 } 943 }
940 }; 944 };
941 945
942 function ShareMode(container, toolbar, shareActions, 946 function ShareMode(editor, container, toolbar, shareActions,
943 onClick, actionCallback, displayStringFunction) { 947 onClick, actionCallback, displayStringFunction) {
944 ImageEditor.Mode.call(this, 'share'); 948 ImageEditor.Mode.call(this, 'share');
945 949
946 this.message_ = null; 950 this.message_ = null;
947 951
948 var doc = container.ownerDocument; 952 var doc = container.ownerDocument;
949 this.button_ = doc.createElement('div'); 953 var button = doc.createElement('div');
950 this.button_.className = 'button share'; 954 button.className = 'button share';
951 this.button_.textContent = displayStringFunction('share'); 955 button.textContent = displayStringFunction('share');
952 this.button_.addEventListener('click', onClick); 956 button.addEventListener('click', onClick);
953 toolbar.appendChild(this.button_); 957 toolbar.appendChild(button);
958
959 this.bind(editor, button);
954 960
955 this.menu_ = doc.createElement('div'); 961 this.menu_ = doc.createElement('div');
956 this.menu_.className = 'share-menu'; 962 this.menu_.className = 'share-menu';
957 this.menu_.setAttribute('hidden', 'hidden'); 963 this.menu_.setAttribute('hidden', 'hidden');
958 for (var index = 0; index < shareActions.length; index++) { 964 for (var index = 0; index < shareActions.length; index++) {
959 var action = shareActions[index]; 965 var action = shareActions[index];
960 var row = doc.createElement('div'); 966 var row = doc.createElement('div');
961 var img = doc.createElement('img'); 967 var img = doc.createElement('img');
962 img.src = action.iconUrl; 968 img.src = action.iconUrl;
963 row.appendChild(img); 969 row.appendChild(img);
(...skipping 12 matching lines...) Expand all
976 ShareMode.prototype.setUp = function() { 982 ShareMode.prototype.setUp = function() {
977 ImageEditor.Mode.prototype.setUp.apply(this, arguments); 983 ImageEditor.Mode.prototype.setUp.apply(this, arguments);
978 ImageUtil.setAttribute(this.menu_, 'hidden', false); 984 ImageUtil.setAttribute(this.menu_, 'hidden', false);
979 ImageUtil.setAttribute(this.button_, 'pressed', false); 985 ImageUtil.setAttribute(this.button_, 'pressed', false);
980 }; 986 };
981 987
982 ShareMode.prototype.cleanUpUI = function() { 988 ShareMode.prototype.cleanUpUI = function() {
983 ImageEditor.Mode.prototype.cleanUpUI.apply(this, arguments); 989 ImageEditor.Mode.prototype.cleanUpUI.apply(this, arguments);
984 ImageUtil.setAttribute(this.menu_, 'hidden', true); 990 ImageUtil.setAttribute(this.menu_, 'hidden', true);
985 }; 991 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698