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 11 matching lines...) Expand all Loading... |
22 * onAppRegionChanged: function(), readonlyDirName: string, | 22 * onAppRegionChanged: function(), readonlyDirName: string, |
23 * displayStringFunction: function(), loadTimeData: Object, | 23 * displayStringFunction: function(), loadTimeData: Object, |
24 * curDirEntry: Entry, searchResults: *}} | 24 * curDirEntry: Entry, searchResults: *}} |
25 * @private | 25 * @private |
26 * | 26 * |
27 * TODO(yawano): curDirEntry and searchResults seem not to be used. | 27 * TODO(yawano): curDirEntry and searchResults seem not to be used. |
28 * Investigate them and remove them if possible. | 28 * Investigate them and remove them if possible. |
29 */ | 29 */ |
30 this.context_ = { | 30 this.context_ = { |
31 appWindow: chrome.app.window.current(), | 31 appWindow: chrome.app.window.current(), |
| 32 onClose: function() { window.close(); }, |
| 33 onMaximize: function() { |
| 34 var appWindow = chrome.app.window.current(); |
| 35 if (appWindow.isMaximized()) |
| 36 appWindow.restore(); |
| 37 else |
| 38 appWindow.maximize(); |
| 39 }, |
| 40 onMinimize: function() { chrome.app.window.current().minimize(); }, |
32 onAppRegionChanged: function() {}, | 41 onAppRegionChanged: function() {}, |
33 readonlyDirName: '', | 42 readonlyDirName: '', |
34 displayStringFunction: function() { return ''; }, | 43 displayStringFunction: function() { return ''; }, |
35 loadTimeData: {}, | 44 loadTimeData: {}, |
36 curDirEntry: null, | 45 curDirEntry: null, |
37 searchResults: null | 46 searchResults: null |
38 }; | 47 }; |
39 this.container_ = queryRequiredElement(document, '.gallery'); | 48 this.container_ = queryRequiredElement(document, '.gallery'); |
40 this.document_ = document; | 49 this.document_ = document; |
41 this.volumeManager_ = volumeManager; | 50 this.volumeManager_ = volumeManager; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 cr.ui.dialogs.BaseDialog.OK_LABEL = str('GALLERY_OK_LABEL'); | 92 cr.ui.dialogs.BaseDialog.OK_LABEL = str('GALLERY_OK_LABEL'); |
84 cr.ui.dialogs.BaseDialog.CANCEL_LABEL = str('GALLERY_CANCEL_LABEL'); | 93 cr.ui.dialogs.BaseDialog.CANCEL_LABEL = str('GALLERY_CANCEL_LABEL'); |
85 | 94 |
86 var content = queryRequiredElement(document, '#content'); | 95 var content = queryRequiredElement(document, '#content'); |
87 content.addEventListener('click', this.onContentClick_.bind(this)); | 96 content.addEventListener('click', this.onContentClick_.bind(this)); |
88 | 97 |
89 this.header_ = queryRequiredElement(document, '#header'); | 98 this.header_ = queryRequiredElement(document, '#header'); |
90 this.topToolbar_ = queryRequiredElement(document, '#top-toolbar'); | 99 this.topToolbar_ = queryRequiredElement(document, '#top-toolbar'); |
91 this.bottomToolbar_ = queryRequiredElement(document, '#bottom-toolbar'); | 100 this.bottomToolbar_ = queryRequiredElement(document, '#bottom-toolbar'); |
92 | 101 |
| 102 var preventDefault = function(event) { event.preventDefault(); }; |
| 103 |
| 104 var minimizeButton = util.createChild(this.header_, |
| 105 'minimize-button tool dimmable', |
| 106 'button'); |
| 107 minimizeButton.tabIndex = -1; |
| 108 minimizeButton.addEventListener('click', this.onMinimize_.bind(this)); |
| 109 minimizeButton.addEventListener('mousedown', preventDefault); |
| 110 |
| 111 var maximizeButton = util.createChild(this.header_, |
| 112 'maximize-button tool dimmable', |
| 113 'button'); |
| 114 maximizeButton.tabIndex = -1; |
| 115 maximizeButton.addEventListener('click', this.onMaximize_.bind(this)); |
| 116 maximizeButton.addEventListener('mousedown', preventDefault); |
| 117 |
| 118 var closeButton = util.createChild(this.header_, |
| 119 'close-button tool dimmable', |
| 120 'button'); |
| 121 closeButton.tabIndex = -1; |
| 122 closeButton.addEventListener('click', this.onClose_.bind(this)); |
| 123 closeButton.addEventListener('mousedown', preventDefault); |
| 124 |
93 this.filenameSpacer_ = queryRequiredElement(this.topToolbar_, | 125 this.filenameSpacer_ = queryRequiredElement(this.topToolbar_, |
94 '.filename-spacer'); | 126 '.filename-spacer'); |
95 this.filenameEdit_ = util.createChild(this.filenameSpacer_, | 127 this.filenameEdit_ = util.createChild(this.filenameSpacer_, |
96 'namebox', 'input'); | 128 'namebox', 'input'); |
97 | 129 |
98 this.filenameEdit_.setAttribute('type', 'text'); | 130 this.filenameEdit_.setAttribute('type', 'text'); |
99 this.filenameEdit_.addEventListener('blur', | 131 this.filenameEdit_.addEventListener('blur', |
100 this.onFilenameEditBlur_.bind(this)); | 132 this.onFilenameEditBlur_.bind(this)); |
101 | 133 |
102 this.filenameEdit_.addEventListener('focus', | 134 this.filenameEdit_.addEventListener('focus', |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 // Continue to load chunks. | 413 // Continue to load chunks. |
382 return loadChunk(/* firstChunk */ false); | 414 return loadChunk(/* firstChunk */ false); |
383 }); | 415 }); |
384 }; | 416 }; |
385 loadChunk(/* firstChunk */ true).catch(function(error) { | 417 loadChunk(/* firstChunk */ true).catch(function(error) { |
386 console.error(error.stack || error); | 418 console.error(error.stack || error); |
387 }); | 419 }); |
388 }; | 420 }; |
389 | 421 |
390 /** | 422 /** |
| 423 * Handles user's 'Close' action. |
| 424 * @private |
| 425 */ |
| 426 Gallery.prototype.onClose_ = function() { |
| 427 this.executeWhenReady(this.context_.onClose); |
| 428 }; |
| 429 |
| 430 /** |
| 431 * Handles user's 'Maximize' action (Escape or a click on the X icon). |
| 432 * @private |
| 433 */ |
| 434 Gallery.prototype.onMaximize_ = function() { |
| 435 this.executeWhenReady(this.context_.onMaximize); |
| 436 }; |
| 437 |
| 438 /** |
| 439 * Handles user's 'Maximize' action (Escape or a click on the X icon). |
| 440 * @private |
| 441 */ |
| 442 Gallery.prototype.onMinimize_ = function() { |
| 443 this.executeWhenReady(this.context_.onMinimize); |
| 444 }; |
| 445 |
| 446 /** |
| 447 * Executes a function when the editor is done with the modifications. |
| 448 * @param {function()} callback Function to execute. |
| 449 */ |
| 450 Gallery.prototype.executeWhenReady = function(callback) { |
| 451 this.currentMode_.executeWhenReady(callback); |
| 452 }; |
| 453 |
| 454 /** |
| 455 * @return {!Object} File manager private API. |
| 456 */ |
| 457 Gallery.getFileManagerPrivate = function() { |
| 458 return chrome.fileManagerPrivate || window.top.chrome.fileManagerPrivate; |
| 459 }; |
| 460 |
| 461 /** |
391 * @return {boolean} True if some tool is currently active. | 462 * @return {boolean} True if some tool is currently active. |
392 */ | 463 */ |
393 Gallery.prototype.hasActiveTool = function() { | 464 Gallery.prototype.hasActiveTool = function() { |
394 return (this.currentMode_ && this.currentMode_.hasActiveTool()) || | 465 return (this.currentMode_ && this.currentMode_.hasActiveTool()) || |
395 this.isRenaming_(); | 466 this.isRenaming_(); |
396 }; | 467 }; |
397 | 468 |
398 /** | 469 /** |
399 * External user action event handler. | 470 * External user action event handler. |
400 * @private | 471 * @private |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 initializePromise.then(reload); | 964 initializePromise.then(reload); |
894 | 965 |
895 /** | 966 /** |
896 * Enteres the debug mode. | 967 * Enteres the debug mode. |
897 */ | 968 */ |
898 window.debugMe = function() { | 969 window.debugMe = function() { |
899 initializePromise.then(function() { | 970 initializePromise.then(function() { |
900 gallery.debugMe(); | 971 gallery.debugMe(); |
901 }); | 972 }); |
902 }; | 973 }; |
OLD | NEW |