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

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

Issue 792733002: Add type annotations to gallery/js/image_editor/image_view.js. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 6 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
« no previous file with comments | « ui/file_manager/gallery/js/image_editor/image_view.js ('k') | 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 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 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 // in the cache longer. 776 // in the cache longer.
777 this.imageView_.prefetch(selectedItem); 777 this.imageView_.prefetch(selectedItem);
778 } 778 }
779 779
780 function shouldPrefetch(loadType, step, sequenceLength) { 780 function shouldPrefetch(loadType, step, sequenceLength) {
781 // Never prefetch when selecting out of sequence. 781 // Never prefetch when selecting out of sequence.
782 if (Math.abs(step) != 1) 782 if (Math.abs(step) != 1)
783 return false; 783 return false;
784 784
785 // Always prefetch if the previous load was from cache. 785 // Always prefetch if the previous load was from cache.
786 if (loadType === ImageView.LOAD_TYPE_CACHED_FULL) 786 if (loadType === ImageView.LoadType.CACHED_FULL)
787 return true; 787 return true;
788 788
789 // Prefetch if we have been going in the same direction for long enough. 789 // Prefetch if we have been going in the same direction for long enough.
790 return sequenceLength >= 3; 790 return sequenceLength >= 3;
791 } 791 }
792 792
793 this.currentUniqueKey_++; 793 this.currentUniqueKey_++;
794 var selectedUniqueKey = this.currentUniqueKey_; 794 var selectedUniqueKey = this.currentUniqueKey_;
795 795
796 // Discard, since another load has been invoked after this one. 796 // Discard, since another load has been invoked after this one.
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 * @param {number} delay Delay. 976 * @param {number} delay Delay.
977 * @param {*=} opt_error Error. 977 * @param {*=} opt_error Error.
978 * @private 978 * @private
979 */ 979 */
980 SlideMode.prototype.itemLoaded_ = function( 980 SlideMode.prototype.itemLoaded_ = function(
981 item, loadCallback, loadType, delay, opt_error) { 981 item, loadCallback, loadType, delay, opt_error) {
982 var entry = item.getEntry(); 982 var entry = item.getEntry();
983 var metadata = item.getMetadata(); 983 var metadata = item.getMetadata();
984 984
985 this.showSpinner_(false); 985 this.showSpinner_(false);
986 if (loadType === ImageView.LOAD_TYPE_ERROR) { 986 if (loadType === ImageView.LoadType.ERROR) {
987 // if we have a specific error, then display it 987 // if we have a specific error, then display it
988 if (opt_error) { 988 if (opt_error) {
989 this.errorBanner_.show(/** @type {string} */ (opt_error)); 989 this.errorBanner_.show(/** @type {string} */ (opt_error));
990 } else { 990 } else {
991 // otherwise try to infer general error 991 // otherwise try to infer general error
992 this.errorBanner_.show('GALLERY_IMAGE_ERROR'); 992 this.errorBanner_.show('GALLERY_IMAGE_ERROR');
993 } 993 }
994 } else if (loadType === ImageView.LOAD_TYPE_OFFLINE) { 994 } else if (loadType === ImageView.LoadType.OFFLINE) {
995 this.errorBanner_.show('GALLERY_IMAGE_OFFLINE'); 995 this.errorBanner_.show('GALLERY_IMAGE_OFFLINE');
996 } 996 }
997 997
998 ImageUtil.metrics.recordUserAction(ImageUtil.getMetricName('View')); 998 ImageUtil.metrics.recordUserAction(ImageUtil.getMetricName('View'));
999 999
1000 var toMillions = function(number) { 1000 var toMillions = function(number) {
1001 return Math.round(number / (1000 * 1000)); 1001 return Math.round(number / (1000 * 1000));
1002 }; 1002 };
1003 1003
1004 ImageUtil.metrics.recordSmallCount(ImageUtil.getMetricName('Size.MB'), 1004 ImageUtil.metrics.recordSmallCount(ImageUtil.getMetricName('Size.MB'),
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after
1859 var event = assertInstanceof(event, MouseEvent); 1859 var event = assertInstanceof(event, MouseEvent);
1860 var viewport = this.slideMode_.getViewport(); 1860 var viewport = this.slideMode_.getViewport();
1861 if (!this.enabled_ || !viewport.isZoomed()) 1861 if (!this.enabled_ || !viewport.isZoomed())
1862 return; 1862 return;
1863 this.stopOperation(); 1863 this.stopOperation();
1864 viewport.setOffset( 1864 viewport.setOffset(
1865 viewport.getOffsetX() + event.wheelDeltaX, 1865 viewport.getOffsetX() + event.wheelDeltaX,
1866 viewport.getOffsetY() + event.wheelDeltaY); 1866 viewport.getOffsetY() + event.wheelDeltaY);
1867 this.slideMode_.applyViewportChange(); 1867 this.slideMode_.applyViewportChange();
1868 }; 1868 };
OLDNEW
« no previous file with comments | « ui/file_manager/gallery/js/image_editor/image_view.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698