| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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('cr.ui.dialogs', function() { | 5 cr.define('cr.ui.dialogs', function() { |
| 6 | 6 |
| 7 function BaseDialog(parentNode) { | 7 function BaseDialog(parentNode) { |
| 8 this.parentNode_ = parentNode; | 8 this.parentNode_ = parentNode; |
| 9 this.document_ = parentNode.ownerDocument; | 9 this.document_ = parentNode.ownerDocument; |
| 10 | 10 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 this.container_.appendChild(this.frame_); | 45 this.container_.appendChild(this.frame_); |
| 46 | 46 |
| 47 this.text_ = doc.createElement('div'); | 47 this.text_ = doc.createElement('div'); |
| 48 this.text_.className = 'cr-dialog-text'; | 48 this.text_.className = 'cr-dialog-text'; |
| 49 this.frame_.appendChild(this.text_); | 49 this.frame_.appendChild(this.text_); |
| 50 | 50 |
| 51 var buttons = doc.createElement('div'); | 51 var buttons = doc.createElement('div'); |
| 52 buttons.className = 'cr-dialog-buttons'; | 52 buttons.className = 'cr-dialog-buttons'; |
| 53 this.frame_.appendChild(buttons); | 53 this.frame_.appendChild(buttons); |
| 54 | 54 |
| 55 this.okButton_ = doc.createElement('button'); |
| 56 this.okButton_.className = 'cr-dialog-ok'; |
| 57 this.okButton_.textContent = BaseDialog.OK_LABEL; |
| 58 this.okButton_.addEventListener('click', this.onOkClick_.bind(this)); |
| 59 buttons.appendChild(this.okButton_); |
| 60 |
| 55 this.cancelButton_ = doc.createElement('button'); | 61 this.cancelButton_ = doc.createElement('button'); |
| 56 this.cancelButton_.className = 'cr-dialog-cancel'; | 62 this.cancelButton_.className = 'cr-dialog-cancel'; |
| 57 this.cancelButton_.textContent = BaseDialog.CANCEL_LABEL; | 63 this.cancelButton_.textContent = BaseDialog.CANCEL_LABEL; |
| 58 this.cancelButton_.addEventListener('click', | 64 this.cancelButton_.addEventListener('click', |
| 59 this.onCancelClick_.bind(this)); | 65 this.onCancelClick_.bind(this)); |
| 60 buttons.appendChild(this.cancelButton_); | 66 buttons.appendChild(this.cancelButton_); |
| 61 | 67 |
| 62 this.okButton_ = doc.createElement('button'); | |
| 63 this.okButton_.className = 'cr-dialog-ok'; | |
| 64 this.okButton_.textContent = BaseDialog.OK_LABEL; | |
| 65 this.okButton_.addEventListener('click', this.onOkClick_.bind(this)); | |
| 66 buttons.appendChild(this.okButton_); | |
| 67 | |
| 68 this.initialFocusElement_ = this.okButton_; | 68 this.initialFocusElement_ = this.okButton_; |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 BaseDialog.prototype.onOk_ = null; | 71 BaseDialog.prototype.onOk_ = null; |
| 72 BaseDialog.prototype.onCancel_ = null; | 72 BaseDialog.prototype.onCancel_ = null; |
| 73 | 73 |
| 74 BaseDialog.prototype.onContainerKeyDown_ = function(event) { | 74 BaseDialog.prototype.onContainerKeyDown_ = function(event) { |
| 75 switch (event.keyCode) { | 75 switch (event.keyCode) { |
| 76 case 13: // Enter | 76 case 13: // Enter |
| 77 if (!this.okButton_.disabled) { | 77 if (!this.okButton_.disabled) { |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 this.onOk_(this.getValue()); | 226 this.onOk_(this.getValue()); |
| 227 }; | 227 }; |
| 228 | 228 |
| 229 return { | 229 return { |
| 230 BaseDialog: BaseDialog, | 230 BaseDialog: BaseDialog, |
| 231 AlertDialog: AlertDialog, | 231 AlertDialog: AlertDialog, |
| 232 ConfirmDialog: ConfirmDialog, | 232 ConfirmDialog: ConfirmDialog, |
| 233 PromptDialog: PromptDialog | 233 PromptDialog: PromptDialog |
| 234 }; | 234 }; |
| 235 }); | 235 }); |
| OLD | NEW |