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

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

Issue 1304883005: Make |context| passed to queryRequiredElement optional (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: whoops Created 5 years, 3 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
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 * 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
11 /** 11 /**
12 * Gallery for viewing and editing image files. 12 * Gallery for viewing and editing image files.
13 * 13 *
14 * @param {!VolumeManagerWrapper} volumeManager 14 * @param {!VolumeManagerWrapper} volumeManager
15 * @constructor 15 * @constructor
16 * @struct 16 * @struct
17 */ 17 */
18 function Gallery(volumeManager) { 18 function Gallery(volumeManager) {
19 /** 19 /**
20 * @type {{appWindow: chrome.app.window.AppWindow, readonlyDirName: string, 20 * @type {{appWindow: chrome.app.window.AppWindow, readonlyDirName: string,
21 * displayStringFunction: function(), loadTimeData: Object}} 21 * displayStringFunction: function(), loadTimeData: Object}}
22 * @private 22 * @private
23 */ 23 */
24 this.context_ = { 24 this.context_ = {
25 appWindow: chrome.app.window.current(), 25 appWindow: chrome.app.window.current(),
26 readonlyDirName: '', 26 readonlyDirName: '',
27 displayStringFunction: function() { return ''; }, 27 displayStringFunction: function() { return ''; },
28 loadTimeData: {}, 28 loadTimeData: {},
29 }; 29 };
30 this.container_ = queryRequiredElement(document, '.gallery'); 30 this.container_ = queryRequiredElement('.gallery');
31 this.document_ = document; 31 this.document_ = document;
32 this.volumeManager_ = volumeManager; 32 this.volumeManager_ = volumeManager;
33 /** 33 /**
34 * @private {!MetadataModel} 34 * @private {!MetadataModel}
35 * @const 35 * @const
36 */ 36 */
37 this.metadataModel_ = MetadataModel.create(volumeManager); 37 this.metadataModel_ = MetadataModel.create(volumeManager);
38 /** 38 /**
39 * @private {!ThumbnailModel} 39 * @private {!ThumbnailModel}
40 * @const 40 * @const
(...skipping 26 matching lines...) Expand all
67 */ 67 */
68 this.changingMode_ = false; 68 this.changingMode_ = false;
69 69
70 // ----------------------------------------------------------------- 70 // -----------------------------------------------------------------
71 // Initializes the UI. 71 // Initializes the UI.
72 72
73 // Initialize the dialog label. 73 // Initialize the dialog label.
74 cr.ui.dialogs.BaseDialog.OK_LABEL = str('GALLERY_OK_LABEL'); 74 cr.ui.dialogs.BaseDialog.OK_LABEL = str('GALLERY_OK_LABEL');
75 cr.ui.dialogs.BaseDialog.CANCEL_LABEL = str('GALLERY_CANCEL_LABEL'); 75 cr.ui.dialogs.BaseDialog.CANCEL_LABEL = str('GALLERY_CANCEL_LABEL');
76 76
77 var content = queryRequiredElement(document, '#content'); 77 var content = getRequiredElement('content');
78 content.addEventListener('click', this.onContentClick_.bind(this)); 78 content.addEventListener('click', this.onContentClick_.bind(this));
79 79
80 this.topToolbar_ = queryRequiredElement(document, '#top-toolbar'); 80 this.topToolbar_ = getRequiredElement('top-toolbar');
81 this.bottomToolbar_ = queryRequiredElement(document, '#bottom-toolbar'); 81 this.bottomToolbar_ = getRequiredElement('bottom-toolbar');
82 82
83 this.filenameSpacer_ = queryRequiredElement(this.topToolbar_, 83 this.filenameSpacer_ = queryRequiredElement('.filename-spacer',
84 '.filename-spacer'); 84 this.topToolbar_);
85 85
86 /** 86 /**
87 * @private {HTMLInputElement} 87 * @private {HTMLInputElement}
88 * @const 88 * @const
89 */ 89 */
90 this.filenameEdit_ = /** @type {HTMLInputElement} */ 90 this.filenameEdit_ = /** @type {HTMLInputElement} */
91 (queryRequiredElement(this.filenameSpacer_, 'input')); 91 (queryRequiredElement('input', this.filenameSpacer_));
92 92
93 this.filenameCanvas_ = document.createElement('canvas'); 93 this.filenameCanvas_ = document.createElement('canvas');
94 this.filenameCanvasContext_ = this.filenameCanvas_.getContext('2d'); 94 this.filenameCanvasContext_ = this.filenameCanvas_.getContext('2d');
95 95
96 // Set font style of canvas context to same font style with rename field. 96 // Set font style of canvas context to same font style with rename field.
97 var filenameEditComputedStyle = window.getComputedStyle(this.filenameEdit_); 97 var filenameEditComputedStyle = window.getComputedStyle(this.filenameEdit_);
98 this.filenameCanvasContext_.font = filenameEditComputedStyle.font; 98 this.filenameCanvasContext_.font = filenameEditComputedStyle.font;
99 99
100 this.filenameEdit_.addEventListener('blur', 100 this.filenameEdit_.addEventListener('blur',
101 this.onFilenameEditBlur_.bind(this)); 101 this.onFilenameEditBlur_.bind(this));
102 this.filenameEdit_.addEventListener('focus', 102 this.filenameEdit_.addEventListener('focus',
103 this.onFilenameFocus_.bind(this)); 103 this.onFilenameFocus_.bind(this));
104 this.filenameEdit_.addEventListener('input', 104 this.filenameEdit_.addEventListener('input',
105 this.resizeRenameField_.bind(this)); 105 this.resizeRenameField_.bind(this));
106 this.filenameEdit_.addEventListener('keydown', 106 this.filenameEdit_.addEventListener('keydown',
107 this.onFilenameEditKeydown_.bind(this)); 107 this.onFilenameEditKeydown_.bind(this));
108 108
109 var buttonSpacer = queryRequiredElement(this.topToolbar_, '.button-spacer'); 109 var buttonSpacer = queryRequiredElement('.button-spacer', this.topToolbar_);
110 110
111 this.prompt_ = new ImageEditor.Prompt(this.container_, strf); 111 this.prompt_ = new ImageEditor.Prompt(this.container_, strf);
112 112
113 this.errorBanner_ = new ErrorBanner(this.container_); 113 this.errorBanner_ = new ErrorBanner(this.container_);
114 114
115 /** 115 /**
116 * @private {!HTMLElement} 116 * @private {!HTMLElement}
117 * @const 117 * @const
118 */ 118 */
119 this.modeSwitchButton_ = queryRequiredElement(this.topToolbar_, 119 this.modeSwitchButton_ = queryRequiredElement('button.mode',
120 'button.mode'); 120 this.topToolbar_);
121 GalleryUtil.decorateMouseFocusHandling(this.modeSwitchButton_); 121 GalleryUtil.decorateMouseFocusHandling(this.modeSwitchButton_);
122 this.modeSwitchButton_.addEventListener('click', 122 this.modeSwitchButton_.addEventListener('click',
123 this.onModeSwitchButtonClicked_.bind(this)); 123 this.onModeSwitchButtonClicked_.bind(this));
124 124
125 /** 125 /**
126 * @private {!PaperRipple} 126 * @private {!PaperRipple}
127 */ 127 */
128 this.modeSwitchButtonRipple_ = /** @type {!PaperRipple} */ 128 this.modeSwitchButtonRipple_ = /** @type {!PaperRipple} */
129 (queryRequiredElement(this.modeSwitchButton_, 'paper-ripple')); 129 (queryRequiredElement('paper-ripple', this.modeSwitchButton_));
130 130
131 /** 131 /**
132 * @private {!DimmableUIController} 132 * @private {!DimmableUIController}
133 * @const 133 * @const
134 */ 134 */
135 this.dimmableUIController_ = new DimmableUIController(this.container_); 135 this.dimmableUIController_ = new DimmableUIController(this.container_);
136 136
137 this.thumbnailMode_ = new ThumbnailMode( 137 this.thumbnailMode_ = new ThumbnailMode(
138 assertInstanceof(document.querySelector('.thumbnail-view'), HTMLElement), 138 assertInstanceof(document.querySelector('.thumbnail-view'), HTMLElement),
139 this.errorBanner_, 139 this.errorBanner_,
(...skipping 19 matching lines...) Expand all
159 this.dimmableUIController_); 159 this.dimmableUIController_);
160 this.slideMode_.addEventListener('image-displayed', function() { 160 this.slideMode_.addEventListener('image-displayed', function() {
161 cr.dispatchSimpleEvent(this, 'image-displayed'); 161 cr.dispatchSimpleEvent(this, 'image-displayed');
162 }.bind(this)); 162 }.bind(this));
163 163
164 /** 164 /**
165 * @private {!HTMLElement} 165 * @private {!HTMLElement}
166 * @const 166 * @const
167 */ 167 */
168 this.deleteButton_ = queryRequiredElement( 168 this.deleteButton_ = queryRequiredElement(
169 this.topToolbar_, 'paper-button.delete'); 169 'paper-button.delete', this.topToolbar_);
170 this.deleteButton_.addEventListener('click', this.delete_.bind(this)); 170 this.deleteButton_.addEventListener('click', this.delete_.bind(this));
171 171
172 /** 172 /**
173 * @private {!HTMLElement} 173 * @private {!HTMLElement}
174 * @const 174 * @const
175 */ 175 */
176 this.slideshowButton_ = queryRequiredElement(this.topToolbar_, 176 this.slideshowButton_ = queryRequiredElement('paper-button.slideshow',
177 'paper-button.slideshow'); 177 this.topToolbar_);
178 178
179 /** 179 /**
180 * @private {!HTMLElement} 180 * @private {!HTMLElement}
181 * @const 181 * @const
182 */ 182 */
183 this.shareButton_ = queryRequiredElement( 183 this.shareButton_ = queryRequiredElement(
184 this.topToolbar_, 'paper-button.share'); 184 'paper-button.share', this.topToolbar_);
185 this.shareButton_.addEventListener( 185 this.shareButton_.addEventListener(
186 'click', this.onShareButtonClick_.bind(this)); 186 'click', this.onShareButtonClick_.bind(this));
187 187
188 this.dataModel_.addEventListener('splice', this.onSplice_.bind(this)); 188 this.dataModel_.addEventListener('splice', this.onSplice_.bind(this));
189 this.dataModel_.addEventListener('content', this.onContentChange_.bind(this)); 189 this.dataModel_.addEventListener('content', this.onContentChange_.bind(this));
190 190
191 this.selectionModel_.addEventListener('change', this.onSelection_.bind(this)); 191 this.selectionModel_.addEventListener('change', this.onSelection_.bind(this));
192 this.slideMode_.addEventListener('useraction', this.onUserAction_.bind(this)); 192 this.slideMode_.addEventListener('useraction', this.onUserAction_.bind(this));
193 193
194 this.shareDialog_ = new ShareDialog(this.container_); 194 this.shareDialog_ = new ShareDialog(this.container_);
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 */ 969 */
970 var initializePromise = 970 var initializePromise =
971 Promise.all([loadTimeDataPromise, volumeManagerPromise]). 971 Promise.all([loadTimeDataPromise, volumeManagerPromise]).
972 then(function(args) { 972 then(function(args) {
973 var volumeManager = args[1]; 973 var volumeManager = args[1];
974 gallery = new Gallery(volumeManager); 974 gallery = new Gallery(volumeManager);
975 }); 975 });
976 976
977 // Loads entries. 977 // Loads entries.
978 initializePromise.then(reload); 978 initializePromise.then(reload);
OLDNEW
« no previous file with comments | « ui/file_manager/file_manager/foreground/js/ui/search_box.js ('k') | ui/file_manager/gallery/js/image_editor/image_editor.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698