Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 * Slide mode displays a single image and has a set of controls to navigate | 8 * Slide mode displays a single image and has a set of controls to navigate |
| 9 * between the images and to edit an image. | 9 * between the images and to edit an image. |
| 10 * | 10 * |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 this.savedLabel_ = util.createChild(this.options_, 'saved'); | 121 this.savedLabel_ = util.createChild(this.options_, 'saved'); |
| 122 this.savedLabel_.textContent = this.displayStringFunction_('GALLERY_SAVED'); | 122 this.savedLabel_.textContent = this.displayStringFunction_('GALLERY_SAVED'); |
| 123 | 123 |
| 124 var overwriteOriginalBox = | 124 var overwriteOriginalBox = |
| 125 util.createChild(this.options_, 'overwrite-original'); | 125 util.createChild(this.options_, 'overwrite-original'); |
| 126 | 126 |
| 127 this.overwriteOriginal_ = util.createChild( | 127 this.overwriteOriginal_ = util.createChild( |
| 128 overwriteOriginalBox, '', 'input'); | 128 overwriteOriginalBox, '', 'input'); |
| 129 this.overwriteOriginal_.type = 'checkbox'; | 129 this.overwriteOriginal_.type = 'checkbox'; |
| 130 this.overwriteOriginal_.id = 'overwrite-checkbox'; | 130 this.overwriteOriginal_.id = 'overwrite-checkbox'; |
| 131 util.platform.getPreference(SlideMode.OVERWRITE_KEY, function(value) { | 131 chrome.storage.local.get([SlideMode.OVERWRITE_KEY], function(values) { |
|
hirono
2014/09/10 13:03:40
We can pass a single key as a string.
| |
| 132 var value = values[SlideMode.OVERWRITE_KEY]; | |
| 132 // Out-of-the box default is 'true' | 133 // Out-of-the box default is 'true' |
| 133 this.overwriteOriginal_.checked = | 134 this.overwriteOriginal_.checked = |
| 134 (typeof value !== 'string' || value === 'true'); | 135 (value === undefined || value) ? true : false; |
|
hirono
2014/09/10 13:03:40
It looks the value can be 'false'. Could you doubl
mtomasz
2014/09/11 03:30:50
Done.
| |
| 135 }.bind(this)); | 136 }.bind(this)); |
| 136 this.overwriteOriginal_.addEventListener('click', | 137 this.overwriteOriginal_.addEventListener('click', |
| 137 this.onOverwriteOriginalClick_.bind(this)); | 138 this.onOverwriteOriginalClick_.bind(this)); |
| 138 | 139 |
| 139 var overwriteLabel = util.createChild(overwriteOriginalBox, '', 'label'); | 140 var overwriteLabel = util.createChild(overwriteOriginalBox, '', 'label'); |
| 140 overwriteLabel.textContent = | 141 overwriteLabel.textContent = |
| 141 this.displayStringFunction_('GALLERY_OVERWRITE_ORIGINAL'); | 142 this.displayStringFunction_('GALLERY_OVERWRITE_ORIGINAL'); |
| 142 overwriteLabel.setAttribute('for', 'overwrite-checkbox'); | 143 overwriteLabel.setAttribute('for', 'overwrite-checkbox'); |
| 143 | 144 |
| 144 this.bubble_ = util.createChild(this.toolbar_, 'bubble'); | 145 this.bubble_ = util.createChild(this.toolbar_, 'bubble'); |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 722 this.printButton_.setAttribute('disabled', ''); | 723 this.printButton_.setAttribute('disabled', ''); |
| 723 } else { | 724 } else { |
| 724 this.editButton_.removeAttribute('disabled'); | 725 this.editButton_.removeAttribute('disabled'); |
| 725 this.printButton_.removeAttribute('disabled'); | 726 this.printButton_.removeAttribute('disabled'); |
| 726 } | 727 } |
| 727 | 728 |
| 728 // For once edited image, disallow the 'overwrite' setting change. | 729 // For once edited image, disallow the 'overwrite' setting change. |
| 729 ImageUtil.setAttribute(this.options_, 'saved', | 730 ImageUtil.setAttribute(this.options_, 'saved', |
| 730 !this.getSelectedItem().isOriginal()); | 731 !this.getSelectedItem().isOriginal()); |
| 731 | 732 |
| 732 util.platform.getPreference(SlideMode.OVERWRITE_BUBBLE_KEY, | 733 chrome.storage.local.get([SlideMode.OVERWRITE_BUBBLE_KEY], |
|
hirono
2014/09/10 13:03:40
We can pass a single key as a string.
mtomasz
2014/09/11 03:30:50
Done.
| |
| 733 function(value) { | 734 function(values) { |
| 734 var times = typeof value === 'string' ? parseInt(value, 10) : 0; | 735 var times = values[SlideMode.OVERWRITE_BUBBLE_KEY] || 0; |
| 735 if (times < SlideMode.OVERWRITE_BUBBLE_MAX_TIMES) { | 736 if (times < SlideMode.OVERWRITE_BUBBLE_MAX_TIMES) { |
| 736 this.bubble_.hidden = false; | 737 this.bubble_.hidden = false; |
| 737 if (this.isEditing()) { | 738 if (this.isEditing()) { |
| 738 util.platform.setPreference( | 739 var items = {}; |
| 739 SlideMode.OVERWRITE_BUBBLE_KEY, times + 1); | 740 items[SlideMode.OVERWRITE_BUBBLE_KEY] = times + 1; |
| 741 chrome.storage.local.set(items); | |
| 740 } | 742 } |
| 741 } | 743 } |
| 742 }.bind(this)); | 744 }.bind(this)); |
| 743 | 745 |
| 744 loadCallback(loadType, delay); | 746 loadCallback(loadType, delay); |
| 745 }.bind(this); | 747 }.bind(this); |
| 746 | 748 |
| 747 var displayDone = function() { | 749 var displayDone = function() { |
| 748 cr.dispatchSimpleEvent(this, 'image-displayed'); | 750 cr.dispatchSimpleEvent(this, 'image-displayed'); |
| 749 displayCallback(); | 751 displayCallback(); |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1033 SlideMode.prototype.shouldOverwriteOriginal_ = function() { | 1035 SlideMode.prototype.shouldOverwriteOriginal_ = function() { |
| 1034 return this.overwriteOriginal_.checked; | 1036 return this.overwriteOriginal_.checked; |
| 1035 }; | 1037 }; |
| 1036 | 1038 |
| 1037 /** | 1039 /** |
| 1038 * 'Overwrite original' checkbox handler. | 1040 * 'Overwrite original' checkbox handler. |
| 1039 * @param {Event} event Event. | 1041 * @param {Event} event Event. |
| 1040 * @private | 1042 * @private |
| 1041 */ | 1043 */ |
| 1042 SlideMode.prototype.onOverwriteOriginalClick_ = function(event) { | 1044 SlideMode.prototype.onOverwriteOriginalClick_ = function(event) { |
| 1043 util.platform.setPreference(SlideMode.OVERWRITE_KEY, event.target.checked); | 1045 var items = {}; |
| 1046 items[SlideMode.OVERWRITE_KEY] = event.target.checked; | |
| 1047 chrome.storage.local.set(items); | |
| 1044 }; | 1048 }; |
| 1045 | 1049 |
| 1046 /** | 1050 /** |
| 1047 * Overwrite info bubble close handler. | 1051 * Overwrite info bubble close handler. |
| 1048 * @private | 1052 * @private |
| 1049 */ | 1053 */ |
| 1050 SlideMode.prototype.onCloseBubble_ = function() { | 1054 SlideMode.prototype.onCloseBubble_ = function() { |
| 1051 this.bubble_.hidden = true; | 1055 this.bubble_.hidden = true; |
| 1052 util.platform.setPreference(SlideMode.OVERWRITE_BUBBLE_KEY, | 1056 var items = {}; |
| 1053 SlideMode.OVERWRITE_BUBBLE_MAX_TIMES); | 1057 items[SlideMode.OVERWRITE_BUBBLE_KEY] = |
| 1058 SlideMode.OVERWRITE_BUBBLE_MAX_TIMES; | |
| 1059 chrome.storage.local.set(items); | |
| 1054 }; | 1060 }; |
| 1055 | 1061 |
| 1056 // Slideshow | 1062 // Slideshow |
| 1057 | 1063 |
| 1058 /** | 1064 /** |
| 1059 * Slideshow interval in ms. | 1065 * Slideshow interval in ms. |
| 1060 */ | 1066 */ |
| 1061 SlideMode.SLIDESHOW_INTERVAL = 5000; | 1067 SlideMode.SLIDESHOW_INTERVAL = 5000; |
| 1062 | 1068 |
| 1063 /** | 1069 /** |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1566 TouchHandler.prototype.onMouseWheel_ = function(event) { | 1572 TouchHandler.prototype.onMouseWheel_ = function(event) { |
| 1567 var viewport = this.slideMode_.getViewport(); | 1573 var viewport = this.slideMode_.getViewport(); |
| 1568 if (!this.enabled_ || !viewport.isZoomed()) | 1574 if (!this.enabled_ || !viewport.isZoomed()) |
| 1569 return; | 1575 return; |
| 1570 this.stopOperation(); | 1576 this.stopOperation(); |
| 1571 viewport.setOffset( | 1577 viewport.setOffset( |
| 1572 viewport.getOffsetX() + event.wheelDeltaX, | 1578 viewport.getOffsetX() + event.wheelDeltaX, |
| 1573 viewport.getOffsetY() + event.wheelDeltaY); | 1579 viewport.getOffsetY() + event.wheelDeltaY); |
| 1574 this.slideMode_.applyViewportChange(); | 1580 this.slideMode_.applyViewportChange(); |
| 1575 }; | 1581 }; |
| OLD | NEW |