Index: ui/file_manager/gallery/js/gallery.js |
diff --git a/ui/file_manager/gallery/js/gallery.js b/ui/file_manager/gallery/js/gallery.js |
index 4d97d06665ffc2327166848d297fffb1e0e20868..c12c4a7d018821896f0776b89becc8f09f32526c 100644 |
--- a/ui/file_manager/gallery/js/gallery.js |
+++ b/ui/file_manager/gallery/js/gallery.js |
@@ -29,6 +29,15 @@ function Gallery(volumeManager) { |
*/ |
this.context_ = { |
appWindow: chrome.app.window.current(), |
+ onClose: function() { window.close(); }, |
+ onMaximize: function() { |
+ var appWindow = chrome.app.window.current(); |
+ if (appWindow.isMaximized()) |
+ appWindow.restore(); |
+ else |
+ appWindow.maximize(); |
+ }, |
+ onMinimize: function() { chrome.app.window.current().minimize(); }, |
onAppRegionChanged: function() {}, |
readonlyDirName: '', |
displayStringFunction: function() { return ''; }, |
@@ -90,6 +99,29 @@ function Gallery(volumeManager) { |
this.topToolbar_ = queryRequiredElement(document, '#top-toolbar'); |
this.bottomToolbar_ = queryRequiredElement(document, '#bottom-toolbar'); |
+ var preventDefault = function(event) { event.preventDefault(); }; |
+ |
+ var minimizeButton = util.createChild(this.header_, |
+ 'minimize-button tool dimmable', |
+ 'button'); |
+ minimizeButton.tabIndex = -1; |
+ minimizeButton.addEventListener('click', this.onMinimize_.bind(this)); |
+ minimizeButton.addEventListener('mousedown', preventDefault); |
+ |
+ var maximizeButton = util.createChild(this.header_, |
+ 'maximize-button tool dimmable', |
+ 'button'); |
+ maximizeButton.tabIndex = -1; |
+ maximizeButton.addEventListener('click', this.onMaximize_.bind(this)); |
+ maximizeButton.addEventListener('mousedown', preventDefault); |
+ |
+ var closeButton = util.createChild(this.header_, |
+ 'close-button tool dimmable', |
+ 'button'); |
+ closeButton.tabIndex = -1; |
+ closeButton.addEventListener('click', this.onClose_.bind(this)); |
+ closeButton.addEventListener('mousedown', preventDefault); |
+ |
this.filenameSpacer_ = queryRequiredElement(this.topToolbar_, |
'.filename-spacer'); |
this.filenameEdit_ = util.createChild(this.filenameSpacer_, |
@@ -388,6 +420,45 @@ Gallery.prototype.loadInternal_ = function(entries, selectedEntries) { |
}; |
/** |
+ * Handles user's 'Close' action. |
+ * @private |
+ */ |
+Gallery.prototype.onClose_ = function() { |
+ this.executeWhenReady(this.context_.onClose); |
+}; |
+ |
+/** |
+ * Handles user's 'Maximize' action (Escape or a click on the X icon). |
+ * @private |
+ */ |
+Gallery.prototype.onMaximize_ = function() { |
+ this.executeWhenReady(this.context_.onMaximize); |
+}; |
+ |
+/** |
+ * Handles user's 'Maximize' action (Escape or a click on the X icon). |
+ * @private |
+ */ |
+Gallery.prototype.onMinimize_ = function() { |
+ this.executeWhenReady(this.context_.onMinimize); |
+}; |
+ |
+/** |
+ * Executes a function when the editor is done with the modifications. |
+ * @param {function()} callback Function to execute. |
+ */ |
+Gallery.prototype.executeWhenReady = function(callback) { |
+ this.currentMode_.executeWhenReady(callback); |
+}; |
+ |
+/** |
+ * @return {!Object} File manager private API. |
+ */ |
+Gallery.getFileManagerPrivate = function() { |
+ return chrome.fileManagerPrivate || window.top.chrome.fileManagerPrivate; |
+}; |
+ |
+/** |
* @return {boolean} True if some tool is currently active. |
*/ |
Gallery.prototype.hasActiveTool = function() { |