OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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('alertOverlay', function() { | 5 cr.define('alertOverlay', function() { |
6 /** | 6 /** |
7 * The confirm <button>. | 7 * The confirm <button>. |
8 * @type {HTMLElement} | 8 * @type {HTMLElement} |
9 */ | 9 */ |
10 var okButton; | 10 var okButton; |
(...skipping 17 matching lines...) Expand all Loading... |
28 okButton.clickCallback = null; | 28 okButton.clickCallback = null; |
29 cancelButton.clickCallback = null; | 29 cancelButton.clickCallback = null; |
30 }); | 30 }); |
31 cancelButton.addEventListener('click', function(e) { | 31 cancelButton.addEventListener('click', function(e) { |
32 assert(cancelButton.clickCallback); | 32 assert(cancelButton.clickCallback); |
33 | 33 |
34 cancelButton.clickCallback(e); | 34 cancelButton.clickCallback(e); |
35 okButton.clickCallback = null; | 35 okButton.clickCallback = null; |
36 cancelButton.clickCallback = null; | 36 cancelButton.clickCallback = null; |
37 }); | 37 }); |
38 }; | 38 } |
39 | 39 |
40 /** | 40 /** |
41 * Updates the alert overlay with the given message, button titles, and | 41 * Updates the alert overlay with the given message, button titles, and |
42 * callbacks. | 42 * callbacks. |
43 * @param {string} title The alert title to display to the user. | 43 * @param {string} title The alert title to display to the user. |
44 * @param {string} message The alert message to display to the user. | 44 * @param {string} message The alert message to display to the user. |
45 * @param {string=} opt_okTitle The title of the OK button. If undefined or | 45 * @param {string=} opt_okTitle The title of the OK button. If undefined or |
46 * empty, no button is shown. | 46 * empty, no button is shown. |
47 * @param {string=} opt_cancelTitle The title of the cancel button. If | 47 * @param {string=} opt_cancelTitle The title of the cancel button. If |
48 * undefined or empty, no button is shown. | 48 * undefined or empty, no button is shown. |
(...skipping 16 matching lines...) Expand all Loading... |
65 | 65 |
66 if (opt_okTitle) | 66 if (opt_okTitle) |
67 okButton.textContent = opt_okTitle; | 67 okButton.textContent = opt_okTitle; |
68 okButton.hidden = !opt_okTitle; | 68 okButton.hidden = !opt_okTitle; |
69 okButton.clickCallback = opt_okCallback; | 69 okButton.clickCallback = opt_okCallback; |
70 | 70 |
71 if (opt_cancelTitle) | 71 if (opt_cancelTitle) |
72 cancelButton.textContent = opt_cancelTitle; | 72 cancelButton.textContent = opt_cancelTitle; |
73 cancelButton.hidden = !opt_cancelTitle; | 73 cancelButton.hidden = !opt_cancelTitle; |
74 cancelButton.clickCallback = opt_cancelCallback; | 74 cancelButton.clickCallback = opt_cancelCallback; |
75 }; | 75 } |
76 | 76 |
77 // Export | 77 // Export |
78 return {initialize: initialize, setValues: setValues}; | 78 return {initialize: initialize, setValues: setValues}; |
79 }); | 79 }); |
80 | 80 |
81 document.addEventListener('DOMContentLoaded', alertOverlay.initialize); | 81 document.addEventListener('DOMContentLoaded', alertOverlay.initialize); |
OLD | NEW |