| 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 * Overrided metadata worker's path. | 6 * Overrided metadata worker's path. |
| 7 * @type {string} | 7 * @type {string} |
| 8 */ | 8 */ |
| 9 ContentMetadataProvider.WORKER_SCRIPT = '/js/metadata_worker.js'; | 9 ContentMetadataProvider.WORKER_SCRIPT = '/js/metadata_worker.js'; |
| 10 | 10 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 chrome.accessibilityFeatures.highContrast.onChange.addListener( | 222 chrome.accessibilityFeatures.highContrast.onChange.addListener( |
| 223 this.onGetOrChangedAccessibilityConfiguration_.bind( | 223 this.onGetOrChangedAccessibilityConfiguration_.bind( |
| 224 this, 'high-contrast')); | 224 this, 'high-contrast')); |
| 225 chrome.accessibilityFeatures.highContrast.get({}, | 225 chrome.accessibilityFeatures.highContrast.get({}, |
| 226 this.onGetOrChangedAccessibilityConfiguration_.bind( | 226 this.onGetOrChangedAccessibilityConfiguration_.bind( |
| 227 this, 'high-contrast')); | 227 this, 'high-contrast')); |
| 228 } | 228 } |
| 229 | 229 |
| 230 /** | 230 /** |
| 231 * First time tools fade-out timeout in milliseconds. | 231 * First time tools fade-out timeout in milliseconds. |
| 232 * @const | 232 * @const {number} |
| 233 * @type {number} | 233 * @private |
| 234 */ | 234 */ |
| 235 Gallery.FIRST_FADE_TIMEOUT = 1000; | 235 Gallery.FIRST_FADE_TIMEOUT_ = 1000; |
| 236 | 236 |
| 237 /** | 237 /** |
| 238 * Time until mosaic is initialized in the background. Used to make gallery | 238 * Time until mosaic is initialized in the background. Used to make gallery |
| 239 * in the slide mode load faster. In milliseconds. | 239 * in the slide mode load faster. In milliseconds. |
| 240 * @const | 240 * @const {number} |
| 241 * @type {number} | 241 * @private |
| 242 */ | 242 */ |
| 243 Gallery.MOSAIC_BACKGROUND_INIT_DELAY = 1000; | 243 Gallery.MOSAIC_BACKGROUND_INIT_DELAY_ = 1000; |
| 244 | |
| 245 /** | |
| 246 * Modes in Gallery. | |
| 247 * @enum {string} | |
| 248 */ | |
| 249 Gallery.Mode = { | |
| 250 SLIDE: 'slide', | |
| 251 THUMBNAIL: 'thumbnail' | |
| 252 }; | |
| 253 | |
| 254 /** | |
| 255 * Sub modes in Gallery. | |
| 256 * @enum {string} | |
| 257 * TODO(yawano): Remove sub modes by extracting them as modes. | |
| 258 */ | |
| 259 Gallery.SubMode = { | |
| 260 BROWSE: 'browse', | |
| 261 EDIT: 'edit', | |
| 262 SLIDESHOW: 'slideshow' | |
| 263 }; | |
| 264 | 244 |
| 265 /** | 245 /** |
| 266 * Updates attributes of container element when accessibility configuration has | 246 * Updates attributes of container element when accessibility configuration has |
| 267 * been changed. | 247 * been changed. |
| 268 * @param {string} name | 248 * @param {string} name |
| 269 * @param {Object} details | 249 * @param {Object} details |
| 270 * @private | 250 * @private |
| 271 */ | 251 */ |
| 272 Gallery.prototype.onGetOrChangedAccessibilityConfiguration_ = function( | 252 Gallery.prototype.onGetOrChangedAccessibilityConfiguration_ = function( |
| 273 name, details) { | 253 name, details) { |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 | 389 |
| 410 // Do the initialization for each mode. | 390 // Do the initialization for each mode. |
| 411 if (shouldShowThumbnail) { | 391 if (shouldShowThumbnail) { |
| 412 this.thumbnailMode_.show(); | 392 this.thumbnailMode_.show(); |
| 413 this.thumbnailMode_.focus(); | 393 this.thumbnailMode_.focus(); |
| 414 } else { | 394 } else { |
| 415 this.slideMode_.enter( | 395 this.slideMode_.enter( |
| 416 null, | 396 null, |
| 417 function() { | 397 function() { |
| 418 // Flash the toolbar briefly to show it is there. | 398 // Flash the toolbar briefly to show it is there. |
| 419 self.dimmableUIController_.kick(Gallery.FIRST_FADE_TIMEOUT); | 399 self.dimmableUIController_.kick(Gallery.FIRST_FADE_TIMEOUT_); |
| 420 }, | 400 }, |
| 421 function() {}); | 401 function() {}); |
| 422 } | 402 } |
| 423 this.initialized_ = true; | 403 this.initialized_ = true; |
| 424 } | 404 } |
| 425 loadNext(/* index */ 0).catch(function(error) { | 405 loadNext(/* index */ 0).catch(function(error) { |
| 426 console.error(error.stack || error); | 406 console.error(error.stack || error); |
| 427 }); | 407 }); |
| 428 }; | 408 }; |
| 429 | 409 |
| 430 /** | 410 /** |
| 431 * @return {boolean} True if some tool is currently active. | 411 * @return {boolean} True if some tool is currently active. |
| 432 */ | 412 */ |
| 433 Gallery.prototype.hasActiveTool = function() { | 413 Gallery.prototype.hasActiveTool = function() { |
| 434 return (this.currentMode_ && this.currentMode_.hasActiveTool()) || | 414 return (this.currentMode_ && this.currentMode_.hasActiveTool()) || |
| 435 this.isRenaming_(); | 415 this.isRenaming_(); |
| 436 }; | 416 }; |
| 437 | 417 |
| 438 /** | 418 /** |
| 439 * External user action event handler. | 419 * External user action event handler. |
| 440 * @private | 420 * @private |
| 441 */ | 421 */ |
| 442 Gallery.prototype.onUserAction_ = function() { | 422 Gallery.prototype.onUserAction_ = function() { |
| 443 // Show the toolbar and hide it after the default timeout. | 423 // Show the toolbar and hide it after the default timeout. |
| 444 this.dimmableUIController_.kick(); | 424 this.dimmableUIController_.kick(); |
| 445 }; | 425 }; |
| 446 | 426 |
| 447 /** | 427 /** |
| 448 * Returns the current mode. | 428 * Returns the current mode. |
| 449 * @return {Gallery.Mode} | 429 * @return {GalleryMode} |
| 450 */ | 430 */ |
| 451 Gallery.prototype.getCurrentMode = function() { | 431 Gallery.prototype.getCurrentMode = function() { |
| 452 switch (/** @type {(SlideMode|ThumbnailMode)} */ (this.currentMode_)) { | 432 switch (/** @type {(SlideMode|ThumbnailMode)} */ (this.currentMode_)) { |
| 453 case this.slideMode_: | 433 case this.slideMode_: |
| 454 return Gallery.Mode.SLIDE; | 434 return GalleryMode.SLIDE; |
| 455 case this.thumbnailMode_: | 435 case this.thumbnailMode_: |
| 456 return Gallery.Mode.THUMBNAIL; | 436 return GalleryMode.THUMBNAIL; |
| 457 default: | 437 default: |
| 458 assertNotReached(); | 438 assertNotReached(); |
| 459 } | 439 } |
| 460 }; | 440 }; |
| 461 | 441 |
| 462 /** | 442 /** |
| 463 * Returns sub mode of current mode. If current mode is not set yet, null is | 443 * Returns sub mode of current mode. If current mode is not set yet, null is |
| 464 * returned. | 444 * returned. |
| 465 * @return {Gallery.SubMode} | 445 * @return {GallerySubMode} |
| 466 */ | 446 */ |
| 467 Gallery.prototype.getCurrentSubMode = function() { | 447 Gallery.prototype.getCurrentSubMode = function() { |
| 468 assert(this.currentMode_); | 448 assert(this.currentMode_); |
| 469 return this.currentMode_.getSubMode(); | 449 return this.currentMode_.getSubMode(); |
| 470 }; | 450 }; |
| 471 | 451 |
| 472 /** | 452 /** |
| 473 * Sets the current mode, update the UI. | 453 * Sets the current mode, update the UI. |
| 474 * @param {!(SlideMode|ThumbnailMode)} mode Current mode. | 454 * @param {!(SlideMode|ThumbnailMode)} mode Current mode. |
| 475 * @private | 455 * @private |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 928 } | 908 } |
| 929 | 909 |
| 930 ImageUtil.setAttribute(this.filenameSpacer_, 'renaming', false); | 910 ImageUtil.setAttribute(this.filenameSpacer_, 'renaming', false); |
| 931 this.dimmableUIController_.setRenaming(false); | 911 this.dimmableUIController_.setRenaming(false); |
| 932 this.onUserAction_(); | 912 this.onUserAction_(); |
| 933 }; | 913 }; |
| 934 | 914 |
| 935 /** | 915 /** |
| 936 * Minimum width of rename field. | 916 * Minimum width of rename field. |
| 937 * @const {number} | 917 * @const {number} |
| 918 * @private |
| 938 */ | 919 */ |
| 939 Gallery.MIN_WIDTH_RENAME_FIELD = 160; // px | 920 Gallery.MIN_WIDTH_RENAME_FIELD_ = 160; // px |
| 940 | 921 |
| 941 /** | 922 /** |
| 942 * End padding for rename field. | 923 * End padding for rename field. |
| 943 * @const {number} | 924 * @const {number} |
| 925 * @private |
| 944 */ | 926 */ |
| 945 Gallery.END_PADDING_RENAME_FIELD = 20; // px | 927 Gallery.END_PADDING_RENAME_FIELD_ = 20; // px |
| 946 | 928 |
| 947 /** | 929 /** |
| 948 * Resize rename field depending on its content. | 930 * Resize rename field depending on its content. |
| 949 * @private | 931 * @private |
| 950 */ | 932 */ |
| 951 Gallery.prototype.resizeRenameField_ = function() { | 933 Gallery.prototype.resizeRenameField_ = function() { |
| 952 var size = this.filenameCanvasContext_.measureText(this.filenameEdit_.value); | 934 var size = this.filenameCanvasContext_.measureText(this.filenameEdit_.value); |
| 953 | 935 |
| 954 var width = Math.min(Math.max( | 936 var width = Math.min( |
| 955 size.width + Gallery.END_PADDING_RENAME_FIELD, | 937 Math.max( |
| 956 Gallery.MIN_WIDTH_RENAME_FIELD), window.innerWidth / 2); | 938 size.width + Gallery.END_PADDING_RENAME_FIELD_, |
| 939 Gallery.MIN_WIDTH_RENAME_FIELD_), |
| 940 window.innerWidth / 2); |
| 957 | 941 |
| 958 this.filenameEdit_.style.width = width + 'px'; | 942 this.filenameEdit_.style.width = width + 'px'; |
| 959 }; | 943 }; |
| 960 | 944 |
| 961 /** | 945 /** |
| 962 * Keydown event handler on filename edit box | 946 * Keydown event handler on filename edit box |
| 963 * @param {!Event} event A keyboard event. | 947 * @param {!Event} event A keyboard event. |
| 964 * @private | 948 * @private |
| 965 */ | 949 */ |
| 966 Gallery.prototype.onFilenameEditKeydown_ = function(event) { | 950 Gallery.prototype.onFilenameEditKeydown_ = function(event) { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1059 */ | 1043 */ |
| 1060 var initializePromise = | 1044 var initializePromise = |
| 1061 Promise.all([loadTimeDataPromise, volumeManagerPromise]). | 1045 Promise.all([loadTimeDataPromise, volumeManagerPromise]). |
| 1062 then(function(args) { | 1046 then(function(args) { |
| 1063 var volumeManager = args[1]; | 1047 var volumeManager = args[1]; |
| 1064 gallery = new Gallery(volumeManager); | 1048 gallery = new Gallery(volumeManager); |
| 1065 }); | 1049 }); |
| 1066 | 1050 |
| 1067 // Loads entries. | 1051 // Loads entries. |
| 1068 initializePromise.then(reload); | 1052 initializePromise.then(reload); |
| OLD | NEW |