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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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. |
49 * @param {function()=} opt_okCallback A function to be called when the user | 49 * @param {function()=} opt_okCallback A function to be called when the user |
50 * presses the ok button. Can be undefined if |opt_okTitle| is falsey. | 50 * presses the ok button. Can be undefined if |opt_okTitle| is falsey. |
51 * @param {function()=} opt_cancelCallback A function to be called when the | 51 * @param {function()=} opt_cancelCallback A function to be called when the |
52 * user presses the cancel button. Can be undefined if |opt_cancelTitle| | 52 * user presses the cancel button. Can be undefined if |opt_cancelTitle| |
53 * is falsey. | 53 * is falsey. |
54 */ | 54 */ |
55 function setValues(title, message, opt_okTitle, opt_cancelTitle, | 55 function setValues( |
56 opt_okCallback, opt_cancelCallback) { | 56 title, message, opt_okTitle, opt_cancelTitle, opt_okCallback, |
| 57 opt_cancelCallback) { |
57 if (typeof title != 'undefined') | 58 if (typeof title != 'undefined') |
58 $('alertOverlayTitle').textContent = title; | 59 $('alertOverlayTitle').textContent = title; |
59 $('alertOverlayTitle').hidden = typeof title == 'undefined'; | 60 $('alertOverlayTitle').hidden = typeof title == 'undefined'; |
60 | 61 |
61 if (typeof message != 'undefined') | 62 if (typeof message != 'undefined') |
62 $('alertOverlayMessage').textContent = message; | 63 $('alertOverlayMessage').textContent = message; |
63 $('alertOverlayMessage').hidden = typeof message == 'undefined'; | 64 $('alertOverlayMessage').hidden = typeof message == 'undefined'; |
64 | 65 |
65 if (opt_okTitle) | 66 if (opt_okTitle) |
66 okButton.textContent = opt_okTitle; | 67 okButton.textContent = opt_okTitle; |
67 okButton.hidden = !opt_okTitle; | 68 okButton.hidden = !opt_okTitle; |
68 okButton.clickCallback = opt_okCallback; | 69 okButton.clickCallback = opt_okCallback; |
69 | 70 |
70 if (opt_cancelTitle) | 71 if (opt_cancelTitle) |
71 cancelButton.textContent = opt_cancelTitle; | 72 cancelButton.textContent = opt_cancelTitle; |
72 cancelButton.hidden = !opt_cancelTitle; | 73 cancelButton.hidden = !opt_cancelTitle; |
73 cancelButton.clickCallback = opt_cancelCallback; | 74 cancelButton.clickCallback = opt_cancelCallback; |
74 }; | 75 }; |
75 | 76 |
76 // Export | 77 // Export |
77 return { | 78 return {initialize: initialize, setValues: setValues}; |
78 initialize: initialize, | |
79 setValues: setValues | |
80 }; | |
81 }); | 79 }); |
82 | 80 |
83 document.addEventListener('DOMContentLoaded', alertOverlay.initialize); | 81 document.addEventListener('DOMContentLoaded', alertOverlay.initialize); |
OLD | NEW |