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

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

Issue 1053653003: Gallery: Support RAW files in Gallery. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix the second bind. Created 5 years, 8 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
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 /** 5 /**
6 * Slide mode displays a single image and has a set of controls to navigate 6 * Slide mode displays a single image and has a set of controls to navigate
7 * between the images and to edit an image. 7 * between the images and to edit an image.
8 * 8 *
9 * @param {!HTMLElement} container Main container element. 9 * @param {!HTMLElement} container Main container element.
10 * @param {!HTMLElement} content Content container element. 10 * @param {!HTMLElement} content Content container element.
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 /** 225 /**
226 * @type {!HTMLElement} 226 * @type {!HTMLElement}
227 * @private 227 * @private
228 * @const 228 * @const
229 */ 229 */
230 this.savedLabel_ = util.createChild(this.options_, 'saved'); 230 this.savedLabel_ = util.createChild(this.options_, 'saved');
231 this.savedLabel_.textContent = this.displayStringFunction_('GALLERY_SAVED'); 231 this.savedLabel_.textContent = this.displayStringFunction_('GALLERY_SAVED');
232 232
233 /** 233 /**
234 * @type {!HTMLElement} 234 * @type {!HTMLElement}
235 * @private
235 * @const 236 * @const
236 */ 237 */
237 var overwriteOriginalBox = util.createChild( 238 this.overwriteOriginalBox_ = util.createChild(
238 this.options_, 'overwrite-original'); 239 this.options_, 'overwrite-original');
239 240
240 /** 241 /**
241 * @type {!HTMLElement} 242 * @type {!HTMLElement}
242 * @private 243 * @private
243 * @const 244 * @const
244 */ 245 */
245 this.overwriteOriginal_ = util.createChild( 246 this.overwriteOriginal_ = util.createChild(
246 overwriteOriginalBox, '', 'input'); 247 this.overwriteOriginalBox_, '', 'input');
247 this.overwriteOriginal_.type = 'checkbox'; 248 this.overwriteOriginal_.type = 'checkbox';
248 this.overwriteOriginal_.id = 'overwrite-checkbox'; 249 this.overwriteOriginal_.id = 'overwrite-checkbox';
249 chrome.storage.local.get(SlideMode.OVERWRITE_KEY, function(values) { 250 chrome.storage.local.get(SlideMode.OVERWRITE_KEY, function(values) {
250 var value = values[SlideMode.OVERWRITE_KEY]; 251 var value = values[SlideMode.OVERWRITE_KEY];
251 // Out-of-the box default is 'true' 252 // Out-of-the box default is 'true'
252 this.overwriteOriginal_.checked = 253 this.overwriteOriginal_.checked =
253 (value === 'false' || value === false) ? false : true; 254 (value === 'false' || value === false) ? false : true;
254 }.bind(this)); 255 }.bind(this));
255 this.overwriteOriginal_.addEventListener('click', 256 this.overwriteOriginal_.addEventListener('click',
256 this.onOverwriteOriginalClick_.bind(this)); 257 this.onOverwriteOriginalClick_.bind(this));
257 258
258 /** 259 /**
259 * @type {!HTMLElement} 260 * @type {!HTMLElement}
260 * @const 261 * @const
261 */ 262 */
262 var overwriteLabel = util.createChild(overwriteOriginalBox, '', 'label'); 263 var overwriteLabel = util.createChild(
264 this.overwriteOriginalBox_, '', 'label');
263 overwriteLabel.textContent = 265 overwriteLabel.textContent =
264 this.displayStringFunction_('GALLERY_OVERWRITE_ORIGINAL'); 266 this.displayStringFunction_('GALLERY_OVERWRITE_ORIGINAL');
265 overwriteLabel.setAttribute('for', 'overwrite-checkbox'); 267 overwriteLabel.setAttribute('for', 'overwrite-checkbox');
266 268
267 /** 269 /**
268 * @type {!HTMLElement} 270 * @type {!HTMLElement}
269 * @private 271 * @private
270 * @const 272 * @const
271 */ 273 */
272 this.bubble_ = util.createChild(this.toolbar_, 'bubble'); 274 this.bubble_ = util.createChild(this.toolbar_, 'bubble');
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 // Enable or disable buttons for editing and printing. 1030 // Enable or disable buttons for editing and printing.
1029 if (opt_error) { 1031 if (opt_error) {
1030 this.editButton_.disabled = true; 1032 this.editButton_.disabled = true;
1031 this.printButton_.disabled = true; 1033 this.printButton_.disabled = true;
1032 } else { 1034 } else {
1033 this.editButton_.disabled = false; 1035 this.editButton_.disabled = false;
1034 this.printButton_.disabled = false; 1036 this.printButton_.disabled = false;
1035 } 1037 }
1036 1038
1037 // For once edited image, disallow the 'overwrite' setting change. 1039 // For once edited image, disallow the 'overwrite' setting change.
1038 ImageUtil.setAttribute(this.options_, 'saved', 1040 ImageUtil.setAttribute(this.overwriteOriginalBox_, 'disabled',
1039 !this.getSelectedItem().isOriginal()); 1041 !this.getSelectedItem().isOriginal() || FileType.isRaw(item.getEntry()));
1040 1042
1041 chrome.storage.local.get(SlideMode.OVERWRITE_BUBBLE_KEY, 1043 var keys = {};
1044 keys[SlideMode.OVERWRITE_BUBBLE_KEY] = 0;
1045 keys[SlideMode.OVERWRITE_KEY] = true;
1046 chrome.storage.local.get(keys,
1042 function(values) { 1047 function(values) {
1043 var times = values[SlideMode.OVERWRITE_BUBBLE_KEY] || 0; 1048 var times = values[SlideMode.OVERWRITE_BUBBLE_KEY];
1044 if (times < SlideMode.OVERWRITE_BUBBLE_MAX_TIMES) { 1049 if (times < SlideMode.OVERWRITE_BUBBLE_MAX_TIMES) {
1045 this.bubble_.hidden = false; 1050 this.bubble_.hidden = false;
1046 if (this.isEditing()) { 1051 if (this.isEditing()) {
1047 var items = {}; 1052 var items = {};
1048 items[SlideMode.OVERWRITE_BUBBLE_KEY] = times + 1; 1053 items[SlideMode.OVERWRITE_BUBBLE_KEY] = times + 1;
1049 chrome.storage.local.set(items); 1054 chrome.storage.local.set(items);
1050 } 1055 }
1051 } 1056 }
1057 if (FileType.isRaw(item.getEntry()))
1058 this.overwriteOriginal_.checked = false;
1059 else
1060 this.overwriteOriginal_.checked = values[SlideMode.OVERWRITE_KEY];
1052 }.bind(this)); 1061 }.bind(this));
1053 1062
1054 loadCallback(loadType, delay); 1063 loadCallback(loadType, delay);
1055 }; 1064 };
1056 1065
1057 /** 1066 /**
1058 * Commit changes to the current item and reset all messages/indicators. 1067 * Commit changes to the current item and reset all messages/indicators.
1059 * 1068 *
1060 * @param {function()} callback Callback. 1069 * @param {function()} callback Callback.
1061 * @private 1070 * @private
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 this.imageView_.getCanvas(), 1275 this.imageView_.getCanvas(),
1267 this.shouldOverwriteOriginal_()); 1276 this.shouldOverwriteOriginal_());
1268 1277
1269 savedPromise.then(function() { 1278 savedPromise.then(function() {
1270 this.showSpinner_(false); 1279 this.showSpinner_(false);
1271 this.flashSavedLabel_(); 1280 this.flashSavedLabel_();
1272 1281
1273 // Allow changing the 'Overwrite original' setting only if the user 1282 // Allow changing the 'Overwrite original' setting only if the user
1274 // used Undo to restore the original image AND it is not a copy. 1283 // used Undo to restore the original image AND it is not a copy.
1275 // Otherwise lock the setting in its current state. 1284 // Otherwise lock the setting in its current state.
1276 var mayChangeOverwrite = !this.editor_.canUndo() && item.isOriginal(); 1285 var mayChangeOverwrite = !this.editor_.canUndo() && item.isOriginal() &&
1277 ImageUtil.setAttribute(this.options_, 'saved', !mayChangeOverwrite); 1286 !FileType.isRaw(item.getEntry());
1287 ImageUtil.setAttribute(
1288 this.overwriteOriginalBox_, 'disabled', !mayChangeOverwrite);
1278 1289
1279 // Record UMA for the first edit. 1290 // Record UMA for the first edit.
1280 if (this.imageView_.getContentRevision() === 1) 1291 if (this.imageView_.getContentRevision() === 1)
1281 ImageUtil.metrics.recordUserAction(ImageUtil.getMetricName('Edit')); 1292 ImageUtil.metrics.recordUserAction(ImageUtil.getMetricName('Edit'));
1282 1293
1283 callback(); 1294 callback();
1284 }.bind(this)).catch(function(error) { 1295 }.bind(this)).catch(function(error) {
1285 console.error(error.stack || error); 1296 console.error(error.stack || error);
1286 1297
1287 this.showSpinner_(false); 1298 this.showSpinner_(false);
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
1865 var event = assertInstanceof(event, MouseEvent); 1876 var event = assertInstanceof(event, MouseEvent);
1866 var viewport = this.slideMode_.getViewport(); 1877 var viewport = this.slideMode_.getViewport();
1867 if (!this.enabled_ || !viewport.isZoomed()) 1878 if (!this.enabled_ || !viewport.isZoomed())
1868 return; 1879 return;
1869 this.stopOperation(); 1880 this.stopOperation();
1870 viewport.setOffset( 1881 viewport.setOffset(
1871 viewport.getOffsetX() + event.wheelDeltaX, 1882 viewport.getOffsetX() + event.wheelDeltaX,
1872 viewport.getOffsetY() + event.wheelDeltaY); 1883 viewport.getOffsetY() + event.wheelDeltaY);
1873 this.slideMode_.applyViewportChange(); 1884 this.slideMode_.applyViewportChange();
1874 }; 1885 };
OLDNEW
« no previous file with comments | « ui/file_manager/gallery/js/image_editor/image_util.js ('k') | ui/file_manager/gallery/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698