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 /** | 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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 * @private | 196 * @private |
197 */ | 197 */ |
198 this.slideShowTimeout_ = null; | 198 this.slideShowTimeout_ = null; |
199 | 199 |
200 /** | 200 /** |
201 * @type {?number} | 201 * @type {?number} |
202 * @private | 202 * @private |
203 */ | 203 */ |
204 this.spinnerTimer_ = null; | 204 this.spinnerTimer_ = null; |
205 | 205 |
206 this.context_.appWindow.onRestored.addListener(this.onRestored_.bind(this)); | |
207 window.addEventListener('resize', this.onResize_.bind(this)); | 206 window.addEventListener('resize', this.onResize_.bind(this)); |
208 | 207 |
209 // ---------------------------------------------------------------- | 208 // ---------------------------------------------------------------- |
210 // Initializes the UI. | 209 // Initializes the UI. |
211 | 210 |
212 /** | 211 /** |
213 * Container for displayed image. | 212 * Container for displayed image. |
214 * @type {!HTMLElement} | 213 * @type {!HTMLElement} |
215 * @private | 214 * @private |
216 * @const | 215 * @const |
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1107 * Keydown handler. | 1106 * Keydown handler. |
1108 * | 1107 * |
1109 * @param {!Event} event Event. | 1108 * @param {!Event} event Event. |
1110 * @return {boolean} True if handled. | 1109 * @return {boolean} True if handled. |
1111 */ | 1110 */ |
1112 SlideMode.prototype.onKeyDown = function(event) { | 1111 SlideMode.prototype.onKeyDown = function(event) { |
1113 var keyID = util.getKeyModifiers(event) + event.keyIdentifier; | 1112 var keyID = util.getKeyModifiers(event) + event.keyIdentifier; |
1114 | 1113 |
1115 if (this.isSlideshowOn_()) { | 1114 if (this.isSlideshowOn_()) { |
1116 switch (keyID) { | 1115 switch (keyID) { |
1117 // Escape key is captured by the platform to exit full screen. We handle | 1116 case 'U+001B': // Escape exits the slideshow. |
1118 // it by onRestored event. | |
1119 | |
1120 case 'MediaStop': | 1117 case 'MediaStop': |
1121 this.stopSlideshow_(event); | 1118 this.stopSlideshow_(event); |
1122 break; | 1119 break; |
1123 | 1120 |
1124 case 'U+0020': // Space pauses/resumes the slideshow. | 1121 case 'U+0020': // Space pauses/resumes the slideshow. |
1125 case 'MediaPlayPause': | 1122 case 'MediaPlayPause': |
1126 this.toggleSlideshowPause_(); | 1123 this.toggleSlideshowPause_(); |
1127 break; | 1124 break; |
1128 | 1125 |
1129 case 'Up': | 1126 case 'Up': |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1214 this.touchHandlers_.stopOperation(); | 1211 this.touchHandlers_.stopOperation(); |
1215 this.imageView_.applyViewportChange(); | 1212 this.imageView_.applyViewportChange(); |
1216 } | 1213 } |
1217 break; | 1214 break; |
1218 } | 1215 } |
1219 | 1216 |
1220 return true; | 1217 return true; |
1221 }; | 1218 }; |
1222 | 1219 |
1223 /** | 1220 /** |
1224 * Restored event handler. | |
1225 * @private | |
1226 */ | |
1227 SlideMode.prototype.onRestored_ = function() { | |
1228 // Leave slide show since the window should not be in full screen when | |
1229 // onRestored event is dispatched. | |
1230 if (this.isSlideshowOn_()) | |
1231 this.stopSlideshow_(); | |
1232 }; | |
1233 | |
1234 /** | |
1235 * Resize handler. | 1221 * Resize handler. |
1236 * @private | 1222 * @private |
1237 */ | 1223 */ |
1238 SlideMode.prototype.onResize_ = function() { | 1224 SlideMode.prototype.onResize_ = function() { |
1239 this.viewport_.setScreenSize( | 1225 this.viewport_.setScreenSize( |
1240 this.container_.clientWidth, this.container_.clientHeight); | 1226 this.container_.clientWidth, this.container_.clientHeight); |
1241 this.touchHandlers_.stopOperation(); | 1227 this.touchHandlers_.stopOperation(); |
1242 this.editor_.getBuffer().draw(); | 1228 this.editor_.getBuffer().draw(); |
1243 }; | 1229 }; |
1244 | 1230 |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1870 var event = assertInstanceof(event, MouseEvent); | 1856 var event = assertInstanceof(event, MouseEvent); |
1871 var viewport = this.slideMode_.getViewport(); | 1857 var viewport = this.slideMode_.getViewport(); |
1872 if (!this.enabled_ || !viewport.isZoomed()) | 1858 if (!this.enabled_ || !viewport.isZoomed()) |
1873 return; | 1859 return; |
1874 this.stopOperation(); | 1860 this.stopOperation(); |
1875 viewport.setOffset( | 1861 viewport.setOffset( |
1876 viewport.getOffsetX() + event.wheelDeltaX, | 1862 viewport.getOffsetX() + event.wheelDeltaX, |
1877 viewport.getOffsetY() + event.wheelDeltaY); | 1863 viewport.getOffsetY() + event.wheelDeltaY); |
1878 this.slideMode_.applyViewportChange(); | 1864 this.slideMode_.applyViewportChange(); |
1879 }; | 1865 }; |
OLD | NEW |