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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 // Initializes the UI. | 89 // Initializes the UI. |
90 | 90 |
91 // Initialize the dialog label. | 91 // Initialize the dialog label. |
92 cr.ui.dialogs.BaseDialog.OK_LABEL = str('GALLERY_OK_LABEL'); | 92 cr.ui.dialogs.BaseDialog.OK_LABEL = str('GALLERY_OK_LABEL'); |
93 cr.ui.dialogs.BaseDialog.CANCEL_LABEL = str('GALLERY_CANCEL_LABEL'); | 93 cr.ui.dialogs.BaseDialog.CANCEL_LABEL = str('GALLERY_CANCEL_LABEL'); |
94 | 94 |
95 var content = queryRequiredElement(document, '#content'); | 95 var content = queryRequiredElement(document, '#content'); |
96 content.addEventListener('click', this.onContentClick_.bind(this)); | 96 content.addEventListener('click', this.onContentClick_.bind(this)); |
97 | 97 |
98 this.header_ = queryRequiredElement(document, '#header'); | 98 this.header_ = queryRequiredElement(document, '#header'); |
99 this.topToolbar_ = queryRequiredElement(document, '#top-toolbar'); | 99 this.toolbar_ = queryRequiredElement(document, '#toolbar'); |
100 this.bottomToolbar_ = queryRequiredElement(document, '#bottom-toolbar'); | |
101 | 100 |
102 var preventDefault = function(event) { event.preventDefault(); }; | 101 var preventDefault = function(event) { event.preventDefault(); }; |
103 | 102 |
104 var minimizeButton = util.createChild(this.header_, | 103 var minimizeButton = util.createChild(this.header_, |
105 'minimize-button tool dimmable', | 104 'minimize-button tool dimmable', |
106 'button'); | 105 'button'); |
107 minimizeButton.tabIndex = -1; | 106 minimizeButton.tabIndex = -1; |
108 minimizeButton.addEventListener('click', this.onMinimize_.bind(this)); | 107 minimizeButton.addEventListener('click', this.onMinimize_.bind(this)); |
109 minimizeButton.addEventListener('mousedown', preventDefault); | 108 minimizeButton.addEventListener('mousedown', preventDefault); |
110 | 109 |
111 var maximizeButton = util.createChild(this.header_, | 110 var maximizeButton = util.createChild(this.header_, |
112 'maximize-button tool dimmable', | 111 'maximize-button tool dimmable', |
113 'button'); | 112 'button'); |
114 maximizeButton.tabIndex = -1; | 113 maximizeButton.tabIndex = -1; |
115 maximizeButton.addEventListener('click', this.onMaximize_.bind(this)); | 114 maximizeButton.addEventListener('click', this.onMaximize_.bind(this)); |
116 maximizeButton.addEventListener('mousedown', preventDefault); | 115 maximizeButton.addEventListener('mousedown', preventDefault); |
117 | 116 |
118 var closeButton = util.createChild(this.header_, | 117 var closeButton = util.createChild(this.header_, |
119 'close-button tool dimmable', | 118 'close-button tool dimmable', |
120 'button'); | 119 'button'); |
121 closeButton.tabIndex = -1; | 120 closeButton.tabIndex = -1; |
122 closeButton.addEventListener('click', this.onClose_.bind(this)); | 121 closeButton.addEventListener('click', this.onClose_.bind(this)); |
123 closeButton.addEventListener('mousedown', preventDefault); | 122 closeButton.addEventListener('mousedown', preventDefault); |
124 | 123 |
125 this.filenameSpacer_ = queryRequiredElement(this.topToolbar_, | 124 this.filenameSpacer_ = queryRequiredElement(this.toolbar_, |
126 '.filename-spacer'); | 125 '.filename-spacer'); |
127 this.filenameEdit_ = util.createChild(this.filenameSpacer_, | 126 this.filenameEdit_ = util.createChild(this.filenameSpacer_, |
128 'namebox', 'input'); | 127 'namebox', 'input'); |
129 | 128 |
130 this.filenameEdit_.setAttribute('type', 'text'); | 129 this.filenameEdit_.setAttribute('type', 'text'); |
131 this.filenameEdit_.addEventListener('blur', | 130 this.filenameEdit_.addEventListener('blur', |
132 this.onFilenameEditBlur_.bind(this)); | 131 this.onFilenameEditBlur_.bind(this)); |
133 | 132 |
134 this.filenameEdit_.addEventListener('focus', | 133 this.filenameEdit_.addEventListener('focus', |
135 this.onFilenameFocus_.bind(this)); | 134 this.onFilenameFocus_.bind(this)); |
136 | 135 |
137 this.filenameEdit_.addEventListener('keydown', | 136 this.filenameEdit_.addEventListener('keydown', |
138 this.onFilenameEditKeydown_.bind(this)); | 137 this.onFilenameEditKeydown_.bind(this)); |
139 | 138 |
140 var middleSpacer = queryRequiredElement(this.bottomToolbar_, | 139 var middleSpacer = queryRequiredElement(this.toolbar_, '.middle-spacer'); |
141 '.middle-spacer'); | 140 var buttonSpacer = queryRequiredElement(this.toolbar_, '.button-spacer'); |
142 var buttonSpacer = queryRequiredElement(this.topToolbar_, '.button-spacer'); | |
143 | 141 |
144 this.prompt_ = new ImageEditor.Prompt(this.container_, strf); | 142 this.prompt_ = new ImageEditor.Prompt(this.container_, strf); |
145 | 143 |
146 this.errorBanner_ = new ErrorBanner(this.container_); | 144 this.errorBanner_ = new ErrorBanner(this.container_); |
147 | 145 |
148 this.modeButton_ = queryRequiredElement(this.topToolbar_, 'button.mode'); | 146 this.modeButton_ = queryRequiredElement(this.toolbar_, 'button.mode'); |
149 this.modeButton_.addEventListener('click', | 147 this.modeButton_.addEventListener('click', |
150 this.toggleMode_.bind(this, undefined)); | 148 this.toggleMode_.bind(this, undefined)); |
151 | 149 |
152 this.mosaicMode_ = new MosaicMode(content, | 150 this.mosaicMode_ = new MosaicMode(content, |
153 this.errorBanner_, | 151 this.errorBanner_, |
154 this.dataModel_, | 152 this.dataModel_, |
155 this.selectionModel_, | 153 this.selectionModel_, |
156 this.volumeManager_, | 154 this.volumeManager_, |
157 this.toggleMode_.bind(this, undefined)); | 155 this.toggleMode_.bind(this, undefined)); |
158 | 156 |
159 this.slideMode_ = new SlideMode(this.container_, | 157 this.slideMode_ = new SlideMode(this.container_, |
160 content, | 158 content, |
161 this.topToolbar_, | 159 this.toolbar_, |
162 this.bottomToolbar_, | |
163 this.prompt_, | 160 this.prompt_, |
164 this.errorBanner_, | 161 this.errorBanner_, |
165 this.dataModel_, | 162 this.dataModel_, |
166 this.selectionModel_, | 163 this.selectionModel_, |
167 this.metadataModel_, | 164 this.metadataModel_, |
168 this.thumbnailModel_, | 165 this.thumbnailModel_, |
169 this.context_, | 166 this.context_, |
170 this.volumeManager_, | 167 this.volumeManager_, |
171 this.toggleMode_.bind(this), | 168 this.toggleMode_.bind(this), |
172 str); | 169 str); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 | 265 |
269 /** | 266 /** |
270 * Initializes a toolbar button. | 267 * Initializes a toolbar button. |
271 * | 268 * |
272 * @param {string} className Class to add. | 269 * @param {string} className Class to add. |
273 * @param {string} title Button title. | 270 * @param {string} title Button title. |
274 * @return {!HTMLElement} Newly created button. | 271 * @return {!HTMLElement} Newly created button. |
275 * @private | 272 * @private |
276 */ | 273 */ |
277 Gallery.prototype.initToolbarButton_ = function(className, title) { | 274 Gallery.prototype.initToolbarButton_ = function(className, title) { |
278 var button = queryRequiredElement(this.topToolbar_, 'button.' + className); | 275 var button = queryRequiredElement(this.toolbar_, 'button.' + className); |
279 button.title = str(title); | 276 button.title = str(title); |
280 return button; | 277 return button; |
281 }; | 278 }; |
282 | 279 |
283 /** | 280 /** |
284 * Loads the content. | 281 * Loads the content. |
285 * | 282 * |
286 * @param {!Array<!Entry>} selectedEntries Array of selected entries. | 283 * @param {!Array<!Entry>} selectedEntries Array of selected entries. |
287 */ | 284 */ |
288 Gallery.prototype.load = function(selectedEntries) { | 285 Gallery.prototype.load = function(selectedEntries) { |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 mosaic.transform( | 522 mosaic.transform( |
526 tileRect, this.slideMode_.getSelectedImageRect(), true /* instant */); | 523 tileRect, this.slideMode_.getSelectedImageRect(), true /* instant */); |
527 this.slideMode_.leave( | 524 this.slideMode_.leave( |
528 tileRect, | 525 tileRect, |
529 function() { | 526 function() { |
530 // Animate back to normal position. | 527 // Animate back to normal position. |
531 mosaic.transform(null, null); | 528 mosaic.transform(null, null); |
532 mosaic.show(); | 529 mosaic.show(); |
533 onModeChanged(); | 530 onModeChanged(); |
534 }.bind(this)); | 531 }.bind(this)); |
535 this.bottomToolbar_.hidden = true; | |
536 } else { | 532 } else { |
537 this.setCurrentMode_(this.slideMode_); | 533 this.setCurrentMode_(this.slideMode_); |
538 this.slideMode_.enter( | 534 this.slideMode_.enter( |
539 tileRect, | 535 tileRect, |
540 function() { | 536 function() { |
541 // Animate to zoomed position. | 537 // Animate to zoomed position. |
542 mosaic.transform(tileRect, this.slideMode_.getSelectedImageRect()); | 538 mosaic.transform(tileRect, this.slideMode_.getSelectedImageRect()); |
543 mosaic.hide(); | 539 mosaic.hide(); |
544 }.bind(this), | 540 }.bind(this), |
545 onModeChanged); | 541 onModeChanged); |
546 this.bottomToolbar_.hidden = false; | |
547 } | 542 } |
548 }; | 543 }; |
549 | 544 |
550 /** | 545 /** |
551 * Deletes the selected items. | 546 * Deletes the selected items. |
552 * @private | 547 * @private |
553 */ | 548 */ |
554 Gallery.prototype.delete_ = function() { | 549 Gallery.prototype.delete_ = function() { |
555 this.onUserAction_(); | 550 this.onUserAction_(); |
556 | 551 |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
946 initializePromise.then(reload); | 941 initializePromise.then(reload); |
947 | 942 |
948 /** | 943 /** |
949 * Enteres the debug mode. | 944 * Enteres the debug mode. |
950 */ | 945 */ |
951 window.debugMe = function() { | 946 window.debugMe = function() { |
952 initializePromise.then(function() { | 947 initializePromise.then(function() { |
953 gallery.debugMe(); | 948 gallery.debugMe(); |
954 }); | 949 }); |
955 }; | 950 }; |
OLD | NEW |