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()"
|
---|
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 |
|
---|
20 | private var closeListener : Function = null;
|
---|
21 |
|
---|
22 | public static const YES:uint = 0x0001;
|
---|
23 | public static const NO:uint = 0x0002;
|
---|
24 |
|
---|
25 |
|
---|
26 | public static function show(message:String,
|
---|
27 | title:String = "Alert",
|
---|
28 | closeListener:Function = null,
|
---|
29 | invokerComponent:UIComponent = null) : void {
|
---|
30 | var dialog:YesNoDialog = YesNoDialog(PopUpManager.createPopUp(Application.application as DisplayObject, YesNoDialog, true));
|
---|
31 | if (title != null && title.length > 0)
|
---|
32 | dialog.title = title;
|
---|
33 | dialog.message = message;
|
---|
34 | if (closeListener != null)
|
---|
35 | dialog.addEventListener(CloseEvent.CLOSE, closeListener);
|
---|
36 | dialog.invoker = invokerComponent;
|
---|
37 |
|
---|
38 | //Dispatch the event for get clear background
|
---|
39 | Application.application.dispatchEvent(new ModalDialogEvent(ModalDialogEvent.OPEN));
|
---|
40 |
|
---|
41 | PopUpManager.centerPopUp(dialog);
|
---|
42 | }
|
---|
43 |
|
---|
44 | private function creationCompleteHandler() : void {
|
---|
45 | var focusTimer: Timer = new Timer(500, 1);
|
---|
46 | focusTimer.addEventListener(TimerEvent.TIMER, moveFocus);
|
---|
47 | focusTimer.start();
|
---|
48 |
|
---|
49 | }
|
---|
50 |
|
---|
51 | private function yesButtonHandler() : void {
|
---|
52 | dispatchEvent(new CloseEvent(CloseEvent.CLOSE,false,false,YES));
|
---|
53 | removePopUp();
|
---|
54 | }
|
---|
55 |
|
---|
56 | private function noButtonHandler() : void {
|
---|
57 | dispatchEvent(new CloseEvent(CloseEvent.CLOSE,false,false,NO));
|
---|
58 | removePopUp();
|
---|
59 | }
|
---|
60 |
|
---|
61 | private function removePopUp(): void
|
---|
62 | {
|
---|
63 | //Dispatch the event for remove clear background
|
---|
64 | Application.application.dispatchEvent(new ModalDialogEvent(ModalDialogEvent.CLOSE));
|
---|
65 | PopUpManager.removePopUp(this);
|
---|
66 |
|
---|
67 | if (invoker != null){
|
---|
68 | callLater(setUIComponentFocus);
|
---|
69 | }
|
---|
70 |
|
---|
71 | }
|
---|
72 |
|
---|
73 |
|
---|
74 | private function setUIComponentFocus(): void
|
---|
75 | {
|
---|
76 | invoker.setFocus();
|
---|
77 | }
|
---|
78 |
|
---|
79 | private function moveFocus(e: TimerEvent): void
|
---|
80 | {
|
---|
81 | if (AccessibilityTools.isAccessibilityActive()) {
|
---|
82 | messageBox.setFocus();
|
---|
83 | } else {
|
---|
84 | messageBox.editable = false;
|
---|
85 | nobtn.setFocus();
|
---|
86 | }
|
---|
87 | }
|
---|
88 |
|
---|
89 |
|
---|
90 | ]]>
|
---|
91 | </mx:Script>
|
---|
92 |
|
---|
93 | <accessibility:AccessibilityProperties name="Info Dialog {this.title}" id="accessibleMessage"/>
|
---|
94 |
|
---|
95 |
|
---|
96 | <mx:VBox id="contentBox" width="100%" height="100%">
|
---|
97 | <mx:TextArea restrict="*~_" id="messageBox" text="{message}" width="100%" height="100%" borderThickness="0" tabIndex="1" accessibilityProperties="{accessibleMessage}"/>
|
---|
98 | </mx:VBox>
|
---|
99 | <mx:ControlBar width="100%" horizontalAlign="right">
|
---|
100 | <mx:Spacer width="100%"/>
|
---|
101 | <mx:Button label="Yes" click="yesButtonHandler()" tabIndex="2"/>
|
---|
102 | <mx:Button label="No" id="nobtn" click="noButtonHandler()" tabIndex="3"/>
|
---|
103 | </mx:ControlBar>
|
---|
104 | </mx:TitleWindow>
|
---|