[1240] | 1 | <?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:widget="gov.va.med.edp.widget.*" paddingTop="0"
|
---|
| 3 | borderThicknessTop="0" creationComplete="creationCompleteHandler()" maxHeight="500" maxWidth="700"
|
---|
| 4 | minWidth="280" minHeight="180" horizontalAlign="center" verticalAlign="top" layout="vertical"
|
---|
| 5 | xmlns:accessibility="flash.accessibility.*">
|
---|
| 6 | <mx:Script>
|
---|
| 7 | <![CDATA[
|
---|
| 8 | import gov.va.med.edp.util.AccessibilityTools;
|
---|
| 9 | import gov.va.med.edp.control.ModalDialogEvent;
|
---|
| 10 | import mx.events.CloseEvent;
|
---|
| 11 | import mx.core.UIComponent;
|
---|
| 12 | import mx.core.Application;
|
---|
| 13 | import mx.managers.PopUpManager;
|
---|
| 14 |
|
---|
| 15 | [Bindable]
|
---|
| 16 | private var message : String;
|
---|
| 17 | private var invoker : UIComponent;
|
---|
| 18 |
|
---|
| 19 | private var closeListener : Function = null;
|
---|
| 20 |
|
---|
| 21 | public static const OK:uint = 0x0004;
|
---|
| 22 | public static const CANCEL:uint= 0x0008;
|
---|
| 23 |
|
---|
| 24 |
|
---|
| 25 | public static function show(message:String,
|
---|
| 26 | title:String = "Alert",
|
---|
| 27 | closeListener:Function = null, invokerComponent:UIComponent = null) : void {
|
---|
| 28 | var dialog:OkCancelDialog = OkCancelDialog(PopUpManager.createPopUp(Application.application as DisplayObject, OkCancelDialog, true));
|
---|
| 29 | if (title != null && title.length > 0)
|
---|
| 30 | dialog.title = title;
|
---|
| 31 | dialog.message = message;
|
---|
| 32 | if (closeListener != null)
|
---|
| 33 | dialog.addEventListener(CloseEvent.CLOSE, closeListener);
|
---|
| 34 |
|
---|
| 35 | dialog.invoker = invokerComponent;
|
---|
| 36 | //Dispatch the event for get clear background
|
---|
| 37 | Application.application.dispatchEvent(new ModalDialogEvent(ModalDialogEvent.OPEN));
|
---|
| 38 | PopUpManager.centerPopUp(dialog);
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | private function creationCompleteHandler() : void {
|
---|
| 42 | var focusTimer: Timer = new Timer(500, 1);
|
---|
| 43 | focusTimer.addEventListener(TimerEvent.TIMER, moveFocus);
|
---|
| 44 | focusTimer.start();
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | private function okButtonHandler() : void {
|
---|
| 48 | dispatchEvent(new CloseEvent(CloseEvent.CLOSE,false,false,OK));
|
---|
| 49 | removePopUp();
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | private function cancelButtonHandler() : void {
|
---|
| 53 | dispatchEvent(new CloseEvent(CloseEvent.CLOSE,false,false,CANCEL));
|
---|
| 54 | removePopUp();
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | private function removePopUp(): void
|
---|
| 58 | {
|
---|
| 59 | //Dispatch the event for remove clear background
|
---|
| 60 | Application.application.dispatchEvent(new ModalDialogEvent(ModalDialogEvent.CLOSE));
|
---|
| 61 | PopUpManager.removePopUp(this);
|
---|
| 62 |
|
---|
| 63 | if (invoker != null){
|
---|
| 64 | callLater(setUIComponentFocus);
|
---|
| 65 | }
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | private function setUIComponentFocus(): void
|
---|
| 69 | {
|
---|
| 70 | invoker.setFocus();
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | private function moveFocus(e: TimerEvent): void
|
---|
| 74 | {
|
---|
| 75 | if (AccessibilityTools.isAccessibilityActive()) {
|
---|
| 76 | messageBox.setFocus();
|
---|
| 77 | } else {
|
---|
| 78 | messageBox.editable = false;
|
---|
| 79 | cancelBtn.setFocus();
|
---|
| 80 | }
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 |
|
---|
| 84 | ]]>
|
---|
| 85 | </mx:Script>
|
---|
| 86 |
|
---|
| 87 | <accessibility:AccessibilityProperties name="Info Dialog {this.title}" id="accessibleMessage"/>
|
---|
| 88 |
|
---|
| 89 |
|
---|
| 90 | <mx:VBox id="contentBox" width="100%" height="100%">
|
---|
| 91 | <mx:TextArea restrict="*~_" id="messageBox" text="{message}" width="100%" height="100%" borderThickness="0" tabIndex="1" accessibilityProperties="{accessibleMessage}"/>
|
---|
| 92 | </mx:VBox>
|
---|
| 93 | <mx:ControlBar width="100%" horizontalAlign="right">
|
---|
| 94 | <mx:Spacer width="100%"/>
|
---|
| 95 | <mx:Button label="OK" click="okButtonHandler()" tabIndex="2"/>
|
---|
| 96 | <mx:Button label="Cancel" id="cancelBtn" click="cancelButtonHandler()" tabIndex="3"/>
|
---|
| 97 | </mx:ControlBar>
|
---|
| 98 | </mx:TitleWindow>
|
---|