| @@ 4568-4631 (lines=64) @@ | ||
| 4565 | OK_CANCEL: 2, |
|
| 4566 | YES_NO: 3, |
|
| 4567 | YES_NO_CANCEL: 4, |
|
| 4568 | msgBox: function (settings) { |
|
| 4569 | var buttons; |
|
| 4570 | var callback = settings.callback || function () { |
|
| 4571 | }; |
|
| 4572 | function createButton(text, status$$1, primary) { |
|
| 4573 | return { |
|
| 4574 | type: 'button', |
|
| 4575 | text: text, |
|
| 4576 | subtype: primary ? 'primary' : '', |
|
| 4577 | onClick: function (e) { |
|
| 4578 | e.control.parents()[1].close(); |
|
| 4579 | callback(status$$1); |
|
| 4580 | } |
|
| 4581 | }; |
|
| 4582 | } |
|
| 4583 | switch (settings.buttons) { |
|
| 4584 | case MessageBox.OK_CANCEL: |
|
| 4585 | buttons = [ |
|
| 4586 | createButton('Ok', true, true), |
|
| 4587 | createButton('Cancel', false) |
|
| 4588 | ]; |
|
| 4589 | break; |
|
| 4590 | case MessageBox.YES_NO: |
|
| 4591 | case MessageBox.YES_NO_CANCEL: |
|
| 4592 | buttons = [ |
|
| 4593 | createButton('Yes', 1, true), |
|
| 4594 | createButton('No', 0) |
|
| 4595 | ]; |
|
| 4596 | if (settings.buttons === MessageBox.YES_NO_CANCEL) { |
|
| 4597 | buttons.push(createButton('Cancel', -1)); |
|
| 4598 | } |
|
| 4599 | break; |
|
| 4600 | default: |
|
| 4601 | buttons = [createButton('Ok', true, true)]; |
|
| 4602 | break; |
|
| 4603 | } |
|
| 4604 | return new Window$$1({ |
|
| 4605 | padding: 20, |
|
| 4606 | x: settings.x, |
|
| 4607 | y: settings.y, |
|
| 4608 | minWidth: 300, |
|
| 4609 | minHeight: 100, |
|
| 4610 | layout: 'flex', |
|
| 4611 | pack: 'center', |
|
| 4612 | align: 'center', |
|
| 4613 | buttons: buttons, |
|
| 4614 | title: settings.title, |
|
| 4615 | role: 'alertdialog', |
|
| 4616 | items: { |
|
| 4617 | type: 'label', |
|
| 4618 | multiline: true, |
|
| 4619 | maxWidth: 500, |
|
| 4620 | maxHeight: 200, |
|
| 4621 | text: settings.text |
|
| 4622 | }, |
|
| 4623 | onPostRender: function () { |
|
| 4624 | this.aria('describedby', this.items()[0]._id); |
|
| 4625 | }, |
|
| 4626 | onClose: settings.onClose, |
|
| 4627 | onCancel: function () { |
|
| 4628 | callback(false); |
|
| 4629 | } |
|
| 4630 | }).renderTo(document.body).reflow(); |
|
| 4631 | }, |
|
| 4632 | alert: function (settings, callback) { |
|
| 4633 | if (typeof settings === 'string') { |
|
| 4634 | settings = { text: settings }; |
|
| @@ 4046-4109 (lines=64) @@ | ||
| 4043 | OK_CANCEL: 2, |
|
| 4044 | YES_NO: 3, |
|
| 4045 | YES_NO_CANCEL: 4, |
|
| 4046 | msgBox: function (settings) { |
|
| 4047 | var buttons; |
|
| 4048 | var callback = settings.callback || function () { |
|
| 4049 | }; |
|
| 4050 | function createButton(text, status$$1, primary) { |
|
| 4051 | return { |
|
| 4052 | type: 'button', |
|
| 4053 | text: text, |
|
| 4054 | subtype: primary ? 'primary' : '', |
|
| 4055 | onClick: function (e) { |
|
| 4056 | e.control.parents()[1].close(); |
|
| 4057 | callback(status$$1); |
|
| 4058 | } |
|
| 4059 | }; |
|
| 4060 | } |
|
| 4061 | switch (settings.buttons) { |
|
| 4062 | case MessageBox.OK_CANCEL: |
|
| 4063 | buttons = [ |
|
| 4064 | createButton('Ok', true, true), |
|
| 4065 | createButton('Cancel', false) |
|
| 4066 | ]; |
|
| 4067 | break; |
|
| 4068 | case MessageBox.YES_NO: |
|
| 4069 | case MessageBox.YES_NO_CANCEL: |
|
| 4070 | buttons = [ |
|
| 4071 | createButton('Yes', 1, true), |
|
| 4072 | createButton('No', 0) |
|
| 4073 | ]; |
|
| 4074 | if (settings.buttons === MessageBox.YES_NO_CANCEL) { |
|
| 4075 | buttons.push(createButton('Cancel', -1)); |
|
| 4076 | } |
|
| 4077 | break; |
|
| 4078 | default: |
|
| 4079 | buttons = [createButton('Ok', true, true)]; |
|
| 4080 | break; |
|
| 4081 | } |
|
| 4082 | return new Window$$1({ |
|
| 4083 | padding: 20, |
|
| 4084 | x: settings.x, |
|
| 4085 | y: settings.y, |
|
| 4086 | minWidth: 300, |
|
| 4087 | minHeight: 100, |
|
| 4088 | layout: 'flex', |
|
| 4089 | pack: 'center', |
|
| 4090 | align: 'center', |
|
| 4091 | buttons: buttons, |
|
| 4092 | title: settings.title, |
|
| 4093 | role: 'alertdialog', |
|
| 4094 | items: { |
|
| 4095 | type: 'label', |
|
| 4096 | multiline: true, |
|
| 4097 | maxWidth: 500, |
|
| 4098 | maxHeight: 200, |
|
| 4099 | text: settings.text |
|
| 4100 | }, |
|
| 4101 | onPostRender: function () { |
|
| 4102 | this.aria('describedby', this.items()[0]._id); |
|
| 4103 | }, |
|
| 4104 | onClose: settings.onClose, |
|
| 4105 | onCancel: function () { |
|
| 4106 | callback(false); |
|
| 4107 | } |
|
| 4108 | }).renderTo(document.body).reflow(); |
|
| 4109 | }, |
|
| 4110 | alert: function (settings, callback) { |
|
| 4111 | if (typeof settings === 'string') { |
|
| 4112 | settings = { text: settings }; |
|