| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 cr.define('options', function() { | 5 cr.define('options', function() { |
| 6 var OptionsPage = options.OptionsPage; | 6 var Page = cr.ui.pageManager.Page; |
| 7 var PageManager = cr.ui.pageManager.PageManager; |
| 7 | 8 |
| 8 /** | 9 /** |
| 9 * Encapsulated handling of the 'DisplayOverscan' page. | 10 * Encapsulated handling of the 'DisplayOverscan' page. |
| 10 * @constructor | 11 * @constructor |
| 11 */ | 12 */ |
| 12 function DisplayOverscan() { | 13 function DisplayOverscan() { |
| 13 OptionsPage.call(this, 'displayOverscan', | 14 Page.call(this, 'displayOverscan', |
| 14 loadTimeData.getString('displayOverscanPageTabTitle'), | 15 loadTimeData.getString('displayOverscanPageTabTitle'), |
| 15 'display-overscan-page'); | 16 'display-overscan-page'); |
| 16 } | 17 } |
| 17 | 18 |
| 18 cr.addSingletonGetter(DisplayOverscan); | 19 cr.addSingletonGetter(DisplayOverscan); |
| 19 | 20 |
| 20 DisplayOverscan.prototype = { | 21 DisplayOverscan.prototype = { |
| 21 __proto__: OptionsPage.prototype, | 22 __proto__: Page.prototype, |
| 22 | 23 |
| 23 /** | 24 /** |
| 24 * The ID of the target display. | 25 * The ID of the target display. |
| 25 * @private | 26 * @private |
| 26 */ | 27 */ |
| 27 id_: null, | 28 id_: null, |
| 28 | 29 |
| 29 /** | 30 /** |
| 30 * The keyboard event handler function. | 31 * The keyboard event handler function. |
| 31 * @private | 32 * @private |
| 32 */ | 33 */ |
| 33 keyHandler_: null, | 34 keyHandler_: null, |
| 34 | 35 |
| 35 /** | 36 /** |
| 36 * Initialize the page. | 37 * Initialize the page. |
| 37 */ | 38 */ |
| 38 initializePage: function() { | 39 initializePage: function() { |
| 39 OptionsPage.prototype.initializePage.call(this); | 40 Page.prototype.initializePage.call(this); |
| 40 | 41 |
| 41 this.keyHandler_ = this.handleKeyevent_.bind(this); | 42 this.keyHandler_ = this.handleKeyevent_.bind(this); |
| 42 $('display-overscan-operation-reset').onclick = function() { | 43 $('display-overscan-operation-reset').onclick = function() { |
| 43 chrome.send('reset'); | 44 chrome.send('reset'); |
| 44 }; | 45 }; |
| 45 $('display-overscan-operation-ok').onclick = function() { | 46 $('display-overscan-operation-ok').onclick = function() { |
| 46 chrome.send('commit'); | 47 chrome.send('commit'); |
| 47 OptionsPage.closeOverlay(); | 48 PageManager.closeOverlay(); |
| 48 }; | 49 }; |
| 49 $('display-overscan-operation-cancel').onclick = function() { | 50 $('display-overscan-operation-cancel').onclick = function() { |
| 50 OptionsPage.cancelOverlay(); | 51 PageManager.cancelOverlay(); |
| 51 }; | 52 }; |
| 52 }, | 53 }, |
| 53 | 54 |
| 54 /** @override */ | 55 /** @override */ |
| 55 handleCancel: function() { | 56 handleCancel: function() { |
| 56 // signals the cancel event. | 57 // signals the cancel event. |
| 57 chrome.send('cancel'); | 58 chrome.send('cancel'); |
| 58 OptionsPage.closeOverlay(); | 59 PageManager.closeOverlay(); |
| 59 }, | 60 }, |
| 60 | 61 |
| 61 /** @override */ | 62 /** @override */ |
| 62 didShowPage: function() { | 63 didShowPage: function() { |
| 63 if (this.id_ == null) { | 64 if (this.id_ == null) { |
| 64 OptionsPage.cancelOverlay(); | 65 PageManager.cancelOverlay(); |
| 65 return; | 66 return; |
| 66 } | 67 } |
| 67 | 68 |
| 68 window.addEventListener('keydown', this.keyHandler_); | 69 window.addEventListener('keydown', this.keyHandler_); |
| 69 // Sets up the size of the overscan dialog based on DisplayOptions dialog. | 70 // Sets up the size of the overscan dialog based on DisplayOptions dialog. |
| 70 var displayOptionsPage = $('display-options-page'); | 71 var displayOptionsPage = $('display-options-page'); |
| 71 var displayOverscanPage = $('display-overscan-page'); | 72 var displayOverscanPage = $('display-overscan-page'); |
| 72 displayOverscanPage.style.width = | 73 displayOverscanPage.style.width = |
| 73 displayOptionsPage.offsetWidth - 20 + 'px'; | 74 displayOptionsPage.offsetWidth - 20 + 'px'; |
| 74 displayOverscanPage.style.minWidth = displayOverscanPage.style.width; | 75 displayOverscanPage.style.minWidth = displayOverscanPage.style.width; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 90 didClosePage: function() { | 91 didClosePage: function() { |
| 91 window.removeEventListener('keydown', this.keyHandler_); | 92 window.removeEventListener('keydown', this.keyHandler_); |
| 92 }, | 93 }, |
| 93 | 94 |
| 94 /** | 95 /** |
| 95 * Called when the overscan calibration is canceled at the system level, | 96 * Called when the overscan calibration is canceled at the system level, |
| 96 * such like the display is disconnected. | 97 * such like the display is disconnected. |
| 97 * @private | 98 * @private |
| 98 */ | 99 */ |
| 99 onOverscanCanceled_: function() { | 100 onOverscanCanceled_: function() { |
| 100 if (OptionsPage.getTopmostVisiblePage() == this) | 101 if (PageManager.getTopmostVisiblePage() == this) |
| 101 OptionsPage.cancelOverlay(); | 102 PageManager.cancelOverlay(); |
| 102 }, | 103 }, |
| 103 | 104 |
| 104 /** | 105 /** |
| 105 * Sets the target display id. This method has to be called before | 106 * Sets the target display id. This method has to be called before |
| 106 * navigating to this page. | 107 * navigating to this page. |
| 107 * @param {string} id The target display id. | 108 * @param {string} id The target display id. |
| 108 */ | 109 */ |
| 109 setDisplayId: function(id) { | 110 setDisplayId: function(id) { |
| 110 this.id_ = id; | 111 this.id_ = id; |
| 111 }, | 112 }, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 152 |
| 152 DisplayOverscan.onOverscanCanceled = function() { | 153 DisplayOverscan.onOverscanCanceled = function() { |
| 153 DisplayOverscan.getInstance().onOverscanCanceled_(); | 154 DisplayOverscan.getInstance().onOverscanCanceled_(); |
| 154 }; | 155 }; |
| 155 | 156 |
| 156 // Export | 157 // Export |
| 157 return { | 158 return { |
| 158 DisplayOverscan: DisplayOverscan | 159 DisplayOverscan: DisplayOverscan |
| 159 }; | 160 }; |
| 160 }); | 161 }); |
| OLD | NEW |