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

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

Issue 1408533002: Turn on verbose flag for compiling file_manager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use type cast for createElement, fix indent. Created 5 years, 2 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
« no previous file with comments | « ui/file_manager/gallery/js/ribbon.js ('k') | ui/file_manager/gallery/js/thumbnail_mode.js » ('j') | 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 */ 162 */
163 this.sequenceLength_ = 0; 163 this.sequenceLength_ = 0;
164 164
165 /** 165 /**
166 * @type {Array<number>} 166 * @type {Array<number>}
167 * @private 167 * @private
168 */ 168 */
169 this.savedSelection_ = null; 169 this.savedSelection_ = null;
170 170
171 /** 171 /**
172 * @type {Gallery.Item} 172 * @type {GalleryItem}
173 * @private 173 * @private
174 */ 174 */
175 this.displayedItem_ = null; 175 this.displayedItem_ = null;
176 176
177 /** 177 /**
178 * @type {?number} 178 * @type {?number}
179 * @private 179 * @private
180 */ 180 */
181 this.slideHint_ = null; 181 this.slideHint_ = null;
182 182
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 */ 469 */
470 SlideMode.KEY_OFFSET_MAP = { 470 SlideMode.KEY_OFFSET_MAP = {
471 'Up': [0, 20], 471 'Up': [0, 20],
472 'Down': [0, -20], 472 'Down': [0, -20],
473 'Left': [20, 0], 473 'Left': [20, 0],
474 'Right': [-20, 0] 474 'Right': [-20, 0]
475 }; 475 };
476 476
477 /** 477 /**
478 * Returns editor warning message if it should be shown. 478 * Returns editor warning message if it should be shown.
479 * @param {!Gallery.Item} item 479 * @param {!GalleryItem} item
480 * @param {string} readonlyDirName Name of read only volume. Pass empty string 480 * @param {string} readonlyDirName Name of read only volume. Pass empty string
481 * if volume is writable. 481 * if volume is writable.
482 * @param {!DirectoryEntry} fallbackSaveDirectory 482 * @param {!DirectoryEntry} fallbackSaveDirectory
483 * @return {!Promise<?string>} Warning message. null if no warning message 483 * @return {!Promise<?string>} Warning message. null if no warning message
484 * should be shown. 484 * should be shown.
485 */ 485 */
486 SlideMode.getEditorWarningMessage = function( 486 SlideMode.getEditorWarningMessage = function(
487 item, readonlyDirName, fallbackSaveDirectory) { 487 item, readonlyDirName, fallbackSaveDirectory) {
488 var isReadOnlyVolume = !!readonlyDirName; 488 var isReadOnlyVolume = !!readonlyDirName;
489 var isWritableFormat = item.isWritableFormat(); 489 var isWritableFormat = item.isWritableFormat();
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 /** 668 /**
669 * @return {number} Item count. 669 * @return {number} Item count.
670 * @private 670 * @private
671 */ 671 */
672 SlideMode.prototype.getItemCount_ = function() { 672 SlideMode.prototype.getItemCount_ = function() {
673 return this.dataModel_.length; 673 return this.dataModel_.length;
674 }; 674 };
675 675
676 /** 676 /**
677 * @param {number} index Index. 677 * @param {number} index Index.
678 * @return {Gallery.Item} Item. 678 * @return {GalleryItem} Item.
679 */ 679 */
680 SlideMode.prototype.getItem = function(index) { 680 SlideMode.prototype.getItem = function(index) {
681 var item = 681 var item =
682 /** @type {(Gallery.Item|undefined)} */ (this.dataModel_.item(index)); 682 /** @type {(GalleryItem|undefined)} */ (this.dataModel_.item(index));
683 return item === undefined ? null : item; 683 return item === undefined ? null : item;
684 }; 684 };
685 685
686 /** 686 /**
687 * @return {number} Selected index. 687 * @return {number} Selected index.
688 */ 688 */
689 SlideMode.prototype.getSelectedIndex = function() { 689 SlideMode.prototype.getSelectedIndex = function() {
690 return this.selectionModel_.selectedIndex; 690 return this.selectionModel_.selectedIndex;
691 }; 691 };
692 692
693 /** 693 /**
694 * @return {ImageRect} Screen rectangle of the selected image. 694 * @return {ImageRect} Screen rectangle of the selected image.
695 */ 695 */
696 SlideMode.prototype.getSelectedImageRect = function() { 696 SlideMode.prototype.getSelectedImageRect = function() {
697 if (this.getSelectedIndex() < 0) 697 if (this.getSelectedIndex() < 0)
698 return null; 698 return null;
699 else 699 else
700 return this.viewport_.getImageBoundsOnScreen(); 700 return this.viewport_.getImageBoundsOnScreen();
701 }; 701 };
702 702
703 /** 703 /**
704 * @return {Gallery.Item} Selected item. 704 * @return {GalleryItem} Selected item.
705 */ 705 */
706 SlideMode.prototype.getSelectedItem = function() { 706 SlideMode.prototype.getSelectedItem = function() {
707 return this.getItem(this.getSelectedIndex()); 707 return this.getItem(this.getSelectedIndex());
708 }; 708 };
709 709
710 /** 710 /**
711 * Toggles the full screen mode. 711 * Toggles the full screen mode.
712 * @private 712 * @private
713 */ 713 */
714 SlideMode.prototype.toggleFullScreen_ = function() { 714 SlideMode.prototype.toggleFullScreen_ = function() {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 } else if (this.sequenceDirection_ === step) { 775 } else if (this.sequenceDirection_ === step) {
776 // Keeping going in sequence. 776 // Keeping going in sequence.
777 this.sequenceLength_++; 777 this.sequenceLength_++;
778 } else { 778 } else {
779 // Reversed the direction. Reset the counter. 779 // Reversed the direction. Reset the counter.
780 this.sequenceDirection_ = step; 780 this.sequenceDirection_ = step;
781 this.sequenceLength_ = 1; 781 this.sequenceLength_ = 1;
782 } 782 }
783 783
784 this.displayedItem_ = this.getSelectedItem(); 784 this.displayedItem_ = this.getSelectedItem();
785 var selectedItem = assertInstanceof(this.getSelectedItem(), Gallery.Item); 785 var selectedItem = assertInstanceof(this.getSelectedItem(), GalleryItem);
786 786
787 function shouldPrefetch(loadType, step, sequenceLength) { 787 function shouldPrefetch(loadType, step, sequenceLength) {
788 // Never prefetch when selecting out of sequence. 788 // Never prefetch when selecting out of sequence.
789 if (Math.abs(step) != 1) 789 if (Math.abs(step) != 1)
790 return false; 790 return false;
791 791
792 // Always prefetch if the previous load was from cache. 792 // Always prefetch if the previous load was from cache.
793 if (loadType === ImageView.LoadType.CACHED_FULL) 793 if (loadType === ImageView.LoadType.CACHED_FULL)
794 return true; 794 return true;
795 795
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 */ 941 */
942 SlideMode.prototype.selectLast = function() { 942 SlideMode.prototype.selectLast = function() {
943 this.select(this.getItemCount_() - 1); 943 this.select(this.getItemCount_() - 1);
944 }; 944 };
945 945
946 // Loading/unloading 946 // Loading/unloading
947 947
948 /** 948 /**
949 * Load and display an item. 949 * Load and display an item.
950 * 950 *
951 * @param {!Gallery.Item} item Item. 951 * @param {!GalleryItem} item Item.
952 * @param {!ImageView.Effect} effect Transition effect object. 952 * @param {!ImageView.Effect} effect Transition effect object.
953 * @param {function()} displayCallback Called when the image is displayed 953 * @param {function()} displayCallback Called when the image is displayed
954 * (which can happen before the image load due to caching). 954 * (which can happen before the image load due to caching).
955 * @param {function(number, number)} loadCallback Called when the image is fully 955 * @param {function(number, number)} loadCallback Called when the image is fully
956 * loaded. 956 * loaded.
957 * @private 957 * @private
958 */ 958 */
959 SlideMode.prototype.loadItem_ = function( 959 SlideMode.prototype.loadItem_ = function(
960 item, effect, displayCallback, loadCallback) { 960 item, effect, displayCallback, loadCallback) {
961 this.showSpinner_(true); 961 this.showSpinner_(true);
962 962
963 var loadDone = this.itemLoaded_.bind(this, item, loadCallback); 963 var loadDone = this.itemLoaded_.bind(this, item, loadCallback);
964 964
965 var displayDone = function() { 965 var displayDone = function() {
966 cr.dispatchSimpleEvent(this, 'image-displayed'); 966 cr.dispatchSimpleEvent(this, 'image-displayed');
967 displayCallback(); 967 displayCallback();
968 }.bind(this); 968 }.bind(this);
969 969
970 this.editor_.openSession( 970 this.editor_.openSession(
971 item, 971 item,
972 effect, 972 effect,
973 this.saveCurrentImage_.bind(this, item), 973 this.saveCurrentImage_.bind(this, item),
974 displayDone, 974 displayDone,
975 loadDone); 975 loadDone);
976 }; 976 };
977 977
978 /** 978 /**
979 * A callback function when the editor opens a editing session for an image. 979 * A callback function when the editor opens a editing session for an image.
980 * @param {!Gallery.Item} item Gallery item. 980 * @param {!GalleryItem} item Gallery item.
981 * @param {function(number, number)} loadCallback Called when the image is fully 981 * @param {function(number, number)} loadCallback Called when the image is fully
982 * loaded. 982 * loaded.
983 * @param {number} loadType Load type. 983 * @param {number} loadType Load type.
984 * @param {number} delay Delay. 984 * @param {number} delay Delay.
985 * @param {*=} opt_error Error. 985 * @param {*=} opt_error Error.
986 * @private 986 * @private
987 */ 987 */
988 SlideMode.prototype.itemLoaded_ = function( 988 SlideMode.prototype.itemLoaded_ = function(
989 item, loadCallback, loadType, delay, opt_error) { 989 item, loadCallback, loadType, delay, opt_error) {
990 var entry = item.getEntry(); 990 var entry = item.getEntry();
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 this.ribbon_.reset(); 1255 this.ribbon_.reset();
1256 if (this.active_) 1256 if (this.active_)
1257 this.ribbon_.redraw(); 1257 this.ribbon_.redraw();
1258 }; 1258 };
1259 1259
1260 // Saving 1260 // Saving
1261 1261
1262 /** 1262 /**
1263 * Save the current image to a file. 1263 * Save the current image to a file.
1264 * 1264 *
1265 * @param {!Gallery.Item} item Item to save the image. 1265 * @param {!GalleryItem} item Item to save the image.
1266 * @param {function()} callback Callback. 1266 * @param {function()} callback Callback.
1267 * @private 1267 * @private
1268 */ 1268 */
1269 SlideMode.prototype.saveCurrentImage_ = function(item, callback) { 1269 SlideMode.prototype.saveCurrentImage_ = function(item, callback) {
1270 this.showSpinner_(true); 1270 this.showSpinner_(true);
1271 1271
1272 var savedPromise = this.dataModel_.saveItem( 1272 var savedPromise = this.dataModel_.saveItem(
1273 this.volumeManager_, 1273 this.volumeManager_,
1274 item, 1274 item,
1275 this.imageView_.getCanvas(), 1275 this.imageView_.getCanvas(),
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
1965 var event = assertInstanceof(event, MouseEvent); 1965 var event = assertInstanceof(event, MouseEvent);
1966 var viewport = this.slideMode_.getViewport(); 1966 var viewport = this.slideMode_.getViewport();
1967 if (!this.enabled_ || !viewport.isZoomed()) 1967 if (!this.enabled_ || !viewport.isZoomed())
1968 return; 1968 return;
1969 this.stopOperation(); 1969 this.stopOperation();
1970 viewport.setOffset( 1970 viewport.setOffset(
1971 viewport.getOffsetX() + event.wheelDeltaX, 1971 viewport.getOffsetX() + event.wheelDeltaX,
1972 viewport.getOffsetY() + event.wheelDeltaY); 1972 viewport.getOffsetY() + event.wheelDeltaY);
1973 this.slideMode_.applyViewportChange(); 1973 this.slideMode_.applyViewportChange();
1974 }; 1974 };
OLDNEW
« no previous file with comments | « ui/file_manager/gallery/js/ribbon.js ('k') | ui/file_manager/gallery/js/thumbnail_mode.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698