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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** | 7 /** |
8 * Called from the main frame when unloading. | 8 * Called from the main frame when unloading. |
9 * @param {boolean=} opt_exiting True if the app is exiting. | 9 * @param {boolean=} opt_exiting True if the app is exiting. |
10 */ | 10 */ |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 | 261 |
262 /** | 262 /** |
263 * Initializes DOM UI | 263 * Initializes DOM UI |
264 * @private | 264 * @private |
265 */ | 265 */ |
266 Gallery.prototype.initDom_ = function() { | 266 Gallery.prototype.initDom_ = function() { |
267 // Initialize the dialog label. | 267 // Initialize the dialog label. |
268 cr.ui.dialogs.BaseDialog.OK_LABEL = str('GALLERY_OK_LABEL'); | 268 cr.ui.dialogs.BaseDialog.OK_LABEL = str('GALLERY_OK_LABEL'); |
269 cr.ui.dialogs.BaseDialog.CANCEL_LABEL = str('GALLERY_CANCEL_LABEL'); | 269 cr.ui.dialogs.BaseDialog.CANCEL_LABEL = str('GALLERY_CANCEL_LABEL'); |
270 | 270 |
271 var content = util.createChild(this.container_, 'content'); | 271 var content = document.querySelector('#content'); |
272 content.addEventListener('click', this.onContentClick_.bind(this)); | 272 content.addEventListener('click', this.onContentClick_.bind(this)); |
273 | 273 |
274 this.header_ = util.createChild(this.container_, 'header tool dimmable'); | 274 this.header_ = document.querySelector('#header'); |
275 this.toolbar_ = util.createChild(this.container_, 'toolbar tool dimmable'); | 275 this.toolbar_ = document.querySelector('#toolbar'); |
276 | 276 |
277 var preventDefault = function(event) { event.preventDefault(); }; | 277 var preventDefault = function(event) { event.preventDefault(); }; |
278 | 278 |
279 var minimizeButton = util.createChild(this.header_, | 279 var minimizeButton = util.createChild(this.header_, |
280 'minimize-button tool dimmable', | 280 'minimize-button tool dimmable', |
281 'button'); | 281 'button'); |
282 minimizeButton.tabIndex = -1; | 282 minimizeButton.tabIndex = -1; |
283 minimizeButton.addEventListener('click', this.onMinimize_.bind(this)); | 283 minimizeButton.addEventListener('click', this.onMinimize_.bind(this)); |
284 minimizeButton.addEventListener('mousedown', preventDefault); | 284 minimizeButton.addEventListener('mousedown', preventDefault); |
285 | 285 |
286 var maximizeButton = util.createChild(this.header_, | 286 var maximizeButton = util.createChild(this.header_, |
287 'maximize-button tool dimmable', | 287 'maximize-button tool dimmable', |
288 'button'); | 288 'button'); |
289 maximizeButton.tabIndex = -1; | 289 maximizeButton.tabIndex = -1; |
290 maximizeButton.addEventListener('click', this.onMaximize_.bind(this)); | 290 maximizeButton.addEventListener('click', this.onMaximize_.bind(this)); |
291 maximizeButton.addEventListener('mousedown', preventDefault); | 291 maximizeButton.addEventListener('mousedown', preventDefault); |
292 | 292 |
293 var closeButton = util.createChild(this.header_, | 293 var closeButton = util.createChild(this.header_, |
294 'close-button tool dimmable', | 294 'close-button tool dimmable', |
295 'button'); | 295 'button'); |
296 closeButton.tabIndex = -1; | 296 closeButton.tabIndex = -1; |
297 closeButton.addEventListener('click', this.onClose_.bind(this)); | 297 closeButton.addEventListener('click', this.onClose_.bind(this)); |
298 closeButton.addEventListener('mousedown', preventDefault); | 298 closeButton.addEventListener('mousedown', preventDefault); |
299 | 299 |
300 this.filenameSpacer_ = util.createChild(this.toolbar_, 'filename-spacer'); | 300 this.filenameSpacer_ = this.toolbar_.querySelector('.filename-spacer'); |
301 this.filenameEdit_ = util.createChild(this.filenameSpacer_, | 301 this.filenameEdit_ = util.createChild(this.filenameSpacer_, |
302 'namebox', 'input'); | 302 'namebox', 'input'); |
303 | 303 |
304 this.filenameEdit_.setAttribute('type', 'text'); | 304 this.filenameEdit_.setAttribute('type', 'text'); |
305 this.filenameEdit_.addEventListener('blur', | 305 this.filenameEdit_.addEventListener('blur', |
306 this.onFilenameEditBlur_.bind(this)); | 306 this.onFilenameEditBlur_.bind(this)); |
307 | 307 |
308 this.filenameEdit_.addEventListener('focus', | 308 this.filenameEdit_.addEventListener('focus', |
309 this.onFilenameFocus_.bind(this)); | 309 this.onFilenameFocus_.bind(this)); |
310 | 310 |
311 this.filenameEdit_.addEventListener('keydown', | 311 this.filenameEdit_.addEventListener('keydown', |
312 this.onFilenameEditKeydown_.bind(this)); | 312 this.onFilenameEditKeydown_.bind(this)); |
313 | 313 |
314 util.createChild(this.toolbar_, 'button-spacer'); | 314 var middleSpacer = this.filenameSpacer_ = |
| 315 this.toolbar_.querySelector('.middle-spacer'); |
| 316 var buttonSpacer = this.toolbar_.querySelector('button-spacer'); |
315 | 317 |
316 this.prompt_ = new ImageEditor.Prompt(this.container_, str); | 318 this.prompt_ = new ImageEditor.Prompt(this.container_, str); |
317 | 319 |
318 this.modeButton_ = util.createChild(this.toolbar_, 'button mode', 'button'); | 320 this.modeButton_ = this.toolbar_.querySelector('button.mode'); |
319 this.modeButton_.addEventListener('click', | 321 this.modeButton_.addEventListener('click', this.toggleMode_.bind(this, null)); |
320 this.toggleMode_.bind(this, null)); | |
321 | 322 |
322 this.mosaicMode_ = new MosaicMode(content, | 323 this.mosaicMode_ = new MosaicMode(content, |
323 this.dataModel_, | 324 this.dataModel_, |
324 this.selectionModel_, | 325 this.selectionModel_, |
325 this.volumeManager_, | 326 this.volumeManager_, |
326 this.toggleMode_.bind(this, null)); | 327 this.toggleMode_.bind(this, null)); |
327 | 328 |
328 this.slideMode_ = new SlideMode(this.container_, | 329 this.slideMode_ = new SlideMode(this.container_, |
329 content, | 330 content, |
330 this.toolbar_, | 331 this.toolbar_, |
331 this.prompt_, | 332 this.prompt_, |
332 this.dataModel_, | 333 this.dataModel_, |
333 this.selectionModel_, | 334 this.selectionModel_, |
334 this.context_, | 335 this.context_, |
335 this.toggleMode_.bind(this), | 336 this.toggleMode_.bind(this), |
336 str); | 337 str); |
337 | 338 |
338 this.slideMode_.addEventListener('image-displayed', function() { | 339 this.slideMode_.addEventListener('image-displayed', function() { |
339 cr.dispatchSimpleEvent(this, 'image-displayed'); | 340 cr.dispatchSimpleEvent(this, 'image-displayed'); |
340 }.bind(this)); | 341 }.bind(this)); |
341 this.slideMode_.addEventListener('image-saved', function() { | 342 this.slideMode_.addEventListener('image-saved', function() { |
342 cr.dispatchSimpleEvent(this, 'image-saved'); | 343 cr.dispatchSimpleEvent(this, 'image-saved'); |
343 }.bind(this)); | 344 }.bind(this)); |
344 | 345 |
345 var deleteButton = this.createToolbarButton_('delete', 'GALLERY_DELETE'); | 346 var deleteButton = this.initToolbarButton_('delete', 'GALLERY_DELETE'); |
346 deleteButton.addEventListener('click', this.delete_.bind(this)); | 347 deleteButton.addEventListener('click', this.delete_.bind(this)); |
347 | 348 |
348 this.shareButton_ = this.createToolbarButton_('share', 'GALLERY_SHARE'); | 349 this.shareButton_ = this.initToolbarButton_('share', 'GALLERY_SHARE'); |
349 this.shareButton_.setAttribute('disabled', ''); | 350 this.shareButton_.setAttribute('disabled', ''); |
350 this.shareButton_.addEventListener('click', this.toggleShare_.bind(this)); | 351 this.shareButton_.addEventListener('click', this.toggleShare_.bind(this)); |
351 | 352 |
352 this.shareMenu_ = util.createChild(this.container_, 'share-menu'); | 353 this.shareMenu_ = util.createChild(this.container_, 'share-menu'); |
353 this.shareMenu_.hidden = true; | 354 this.shareMenu_.hidden = true; |
354 util.createChild(this.shareMenu_, 'bubble-point'); | 355 util.createChild(this.shareMenu_, 'bubble-point'); |
355 | 356 |
356 this.dataModel_.addEventListener('splice', this.onSplice_.bind(this)); | 357 this.dataModel_.addEventListener('splice', this.onSplice_.bind(this)); |
357 this.dataModel_.addEventListener('content', this.onContentChange_.bind(this)); | 358 this.dataModel_.addEventListener('content', this.onContentChange_.bind(this)); |
358 | 359 |
359 this.selectionModel_.addEventListener('change', this.onSelection_.bind(this)); | 360 this.selectionModel_.addEventListener('change', this.onSelection_.bind(this)); |
360 this.slideMode_.addEventListener('useraction', this.onUserAction_.bind(this)); | 361 this.slideMode_.addEventListener('useraction', this.onUserAction_.bind(this)); |
361 }; | 362 }; |
362 | 363 |
363 /** | 364 /** |
364 * Creates toolbar button. | 365 * Initializes a toolbar button. |
365 * | 366 * |
366 * @param {string} className Class to add. | 367 * @param {string} className Class to add. |
367 * @param {string} title Button title. | 368 * @param {string} title Button title. |
368 * @return {!HTMLElement} Newly created button. | 369 * @return {!HTMLElement} Newly created button. |
369 * @private | 370 * @private |
370 */ | 371 */ |
371 Gallery.prototype.createToolbarButton_ = function(className, title) { | 372 Gallery.prototype.initToolbarButton_ = function(className, title) { |
372 var button = util.createChild(this.toolbar_, className, 'button'); | 373 var button = this.toolbar_.querySelector('button.' + className); |
373 button.title = str(title); | 374 button.title = str(title); |
374 return button; | 375 return button; |
375 }; | 376 }; |
376 | 377 |
377 /** | 378 /** |
378 * Loads the content. | 379 * Loads the content. |
379 * | 380 * |
380 * @param {!Array.<Entry>} entries Array of entries. | 381 * @param {!Array.<Entry>} entries Array of entries. |
381 * @param {!Array.<Entry>} selectedEntries Array of selected entries. | 382 * @param {!Array.<Entry>} selectedEntries Array of selected entries. |
382 */ | 383 */ |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
968 window.loadTimeData.data = backgroundComponents.stringData; | 969 window.loadTimeData.data = backgroundComponents.stringData; |
969 gallery = new Gallery(backgroundComponents.volumeManager); | 970 gallery = new Gallery(backgroundComponents.volumeManager); |
970 }; | 971 }; |
971 | 972 |
972 /** | 973 /** |
973 * Loads entries. | 974 * Loads entries. |
974 */ | 975 */ |
975 window.loadEntries = function(entries, selectedEntries) { | 976 window.loadEntries = function(entries, selectedEntries) { |
976 gallery.load(entries, selectedEntries); | 977 gallery.load(entries, selectedEntries); |
977 }; | 978 }; |
OLD | NEW |