Flex 设置模式窗口 不可移出 当前窗口外
程序员文章站
2022-05-05 18:47:07
...
<?xml version="1.0" encoding="utf-8"?> <s:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:parsley="http://www.spicefactory.org/parsley" title="Market Movers" width="790" height="500" xmlns:analytics="au.com.tabcorp.neo.analytics.*" xmlns:components="au.com.tabcorp.neo.common.components.*" windowMoving="onWindowMovingHandler(event)" currentState="{marketMoversPM.dataLoaded?'normal':'loading'}"> <fx:Script> <![CDATA[ import embeddedAssets.EmbeddedResourceModel; import mx.events.FlexEvent; import spark.events.TitleWindowBoundsEvent; [Bindable] public var marketMoversPM:MarketMoversPopupPM; /** * windowMovig event handler */ protected function onWindowMovingHandler(event:TitleWindowBoundsEvent):void { // code to restrict at left and right if (event.afterBounds.left < marketMoversPM.PANEL_MOVE_RESTRICTION_LEFT) { event.afterBounds.left = marketMoversPM.PANEL_MOVE_RESTRICTION_LEFT - 50; } else if (event.afterBounds.right > systemManager.stage.stageWidth + marketMoversPM.PANEL_MOVE_RESTRICTION_RIGHT) { event.afterBounds.left = systemManager.stage.stageWidth - 75; } // code to restrict at Top and Bottom if (event.afterBounds.top < 0) { event.afterBounds.top = 0; } else if (event.afterBounds.bottom > systemManager.stage.stageHeight + marketMoversPM.PANEL_MOVE_RESTRICTION_BOTTOM) { event.afterBounds.top = this.height + 75; } } ]]> </fx:Script> <fx:Declarations> <parsley:FastInject property="marketMoversPM" type="{MarketMoversPopupPM}" injectionComplete="marketMoversPM.onInjectionComplete()" /> <analytics:LocationProvider location="{marketMoversPM.marketMoversTabLocation}" > <analytics:EventListenerActivationWatcher /> </analytics:LocationProvider> </fx:Declarations> <s:states> <s:State name="normal"/> <s:State name="loading"/> </s:states> <s:Scroller id="scorllbar" width="100%" height="100%" horizontalScrollPolicy="off" verticalScrollPolicy="auto"> <s:VGroup gap="0" width="100%" height="100%" paddingLeft="{scorllbar.visible?5:0}" visible="true" visible.loading="false" includeInLayout.normal="true" includeInLayout.loading="false"> <!-- Date, Help and Print buttons--> <s:HGroup width="760" height="47" verticalAlign="middle"> <components:DateLabel id="dateLabel" date="{marketMoversPM.serverTimeModel.currentTimeDate}" dateTimePattern="EEE dd MMM yyyy" timeZoneOffset="{marketMoversPM.serverTimeModel.globalTimeZoneOffset}" styleName="header1"/> <mx:Spacer width="100%"/> <s:Button label="Print" buttonMode="true" useHandCursor="true" click="marketMoversPM.printClickHandler(this)" styleName="printButton"/> <s:Button click="marketMoversPM.helpClickHandler()" buttonMode="true" useHandCursor="true" skinClass="au.com.tabcorp.neo.common.presentation.skins.InfoButtonSkin" height="18" width="18"/> </s:HGroup> <s:Line width="760"> <s:stroke> <s:SolidColorStroke color="#DDDDDD" weight="2"/> </s:stroke> </s:Line> <s:HGroup width="100%" height="70" verticalAlign="middle" horizontalAlign="center"> <s:ButtonBar id="buttonBarMarketMovers" dataProvider="{marketMoversPM.ac}" selectedItem="{marketMoversPM.selectedRaceOption}" selectedIndex="@{marketMoversPM.selectedIndexButtonBar}" change="marketMoversPM.onChangeMarketMoversButtonBar(event)" enabled="{marketMoversPM.enableButtonBar}"/> </s:HGroup> <!-- DataGrid DataGroup --> <s:DataGroup dataProvider="{marketMoversPM.model.marketMovers}" height="100%"> <s:layout> <s:VerticalLayout /> </s:layout> <s:itemRenderer> <fx:Component> <presentation:MarketMoversIRv2 marketMoversPM="{outerDocument.marketMoversPM}" /> </fx:Component> </s:itemRenderer> </s:DataGroup> </s:VGroup> </s:Scroller> <s:HGroup width="100%" height="100%" horizontalAlign="center" verticalAlign="middle" visible="false" visible.loading="true" includeInLayout="false" includeInLayout.loading="true"> <mx:SWFLoader source="{EmbeddedResourceModel.loadingIcon}" /> </s:HGroup> </s:TitleWindow>
package au.com.tabcorp.neo.racing.marketmovers.presentation { import flash.display.DisplayObject; import flash.events.Event; import flash.net.URLRequest; import flash.net.navigateToURL; import mx.collections.ArrayCollection; import mx.collections.ListCollectionView; import mx.core.FlexGlobals; import mx.core.IFlexDisplayObject; import mx.core.UIComponent; import mx.managers.PopUpManager; import org.spicefactory.lib.reflect.types.Void; import spark.collections.Sort; import spark.collections.SortField; import spark.events.IndexChangeEvent; import spark.events.TitleWindowBoundsEvent; public class MarketMoversPopupPM extends Broadcaster { [Inject] [Bindable] public var serverTimeModel:ServerTimeModel; [Inject] [Bindable] public var model:MarketMoversModel; /** * DG column widths so we can match footer to DG */ public const SMALL_COLUMN_WIDTH:int = 30; public const MEDIUM_COLUMN_WIDTH:int = 70; public const MEDIUM_COLUMN_WIDTH_2:int = 85; public const MEDIUM_COLUMN_WIDTH_3:int = 100; public const LARGE_COLUMN_WIDTH:int = 160; public const LARGE_COLUMN_WIDTH_2:int = 170; public const PANEL_WIDTH:int = 760; public const PANEL_MOVE_RESTRICTION_LEFT:int = -660; public const PANEL_MOVE_RESTRICTION_RIGHT:int = 660; public const PANEL_MOVE_RESTRICTION_BOTTOM:int = 450; [Bidnable] public var marketMoversListView:ListCollectionView; [Bindable] public var selectedRaceOption:Object; [Bindable] public var ac:ArrayCollection; [Bindable] public var arrRaceNos:ArrayCollection; [Bindable] public var marketMoversTabLocation : String = MARKET_MOVERS_LOCATION; [Bindable] public var dataLoaded:Boolean; private static const MARKET_MOVERS_LOCATION:String = "informational:market movers"; private static const NEXT_3_RACES_TO_GO:String = "informational:next 3 races to go"; private static const INDEX_VIEW_CURRENT_RACE : int = 0; private static const INDEX_VIEW_NEXT_THREE_RACE : int = 1; /** * variable to store the currentRace Details at PM level only - not into to model */ private var _currentRacingCode : String; private var _currentMeetingName : String; private var _currentMeetingDateRaw : Date; private var _currentRaceNumber : int; private var _enableButtonBar : Boolean; private var _todayDate:Date; private var _numberSortField:SortField; private var _numberSort:Sort; private var _runnerNameSortField : SortField; private var _runnerNameSort : Sort; private var _oddsSortField : SortField; private var _oddsSort : Sort; private var _percentChangeSortField : SortField; private var _percentChangeSort : Sort; private var _selectedIndexButtonBar : int; private var callFromExternal : Boolean = true; public function MarketMoversPopupPM() { ac = new ArrayCollection([ {value: MarketMoversModel.MARKET_MOVERS_CURRENT_VIEW, label: "CURRENT RACE"}, {value: MarketMoversModel.MARKET_MOVERS_NEXT_3_RACES, label: "NEXT 3 RACES"} ]); // sort fields _numberSortField = new SortField(); _numberSortField.name = 'runnerNumber'; _numberSortField.numeric = true; _numberSort = new Sort(); _numberSort.fields = [_numberSortField]; _runnerNameSortField = new SortField(); _runnerNameSortField.name = 'runnerName'; _runnerNameSort = new Sort(); _runnerNameSort.fields = [_runnerNameSortField]; _oddsSortField = new SortField(); _oddsSortField.name = RacingConstants.SORT_LABEL_OPENING_ODDS; _oddsSort = new Sort(); _oddsSort.fields = [_oddsSortField]; _percentChangeSortField = new SortField(); _percentChangeSortField.name = RacingConstants.SORT_LABEL_PERCENT_CHANGE; _percentChangeSort = new Sort(); _percentChangeSort.fields = [_percentChangeSortField]; } [Init] public function onInjectionComplete() : void { todayDate = serverTimeModel.currentTimeDate; marketMoversListView = new ListCollectionView(model.marketMovers); dataLoaded = true; } [Init] public function init():void { var source:Array = new Array(1, 2, 3); arrRaceNos = new ArrayCollection(source); if(serverTimeModel.currentTimeDate) onInjectionComplete(); } public function onWeatherIcon_clickHandler(meetingMNC3:String, meetingName:String):void { broadcast(new GetWeatherInfoMessage(meetingMNC3, meetingName)); } public function onTrackClickHandler(source:MarketMoversVO):void { var trackRequest:TrackRequest = new TrackRequest(); trackRequest.meetingCode = source.meetingCode; trackRequest.meetingName = source.meetingName; trackRequest.raceNumber = source.raceNumber; trackRequest.racingCode = source.racingCode; trackRequest.meetingDateRaw = source.raceStartTime;//race.meeting.meetingDate; broadcast(new GetTrackEvent(trackRequest)); } /////////////////////////////////////////////////////////////////////// // handlers // /////////////////////////////////////////////////////////////////////// public function onChangeMarketMoversButtonBar(event:IndexChangeEvent):void { selectedRaceOption = event.currentTarget.selectedItem; //model.changeRaceListView(selectedRaceOption.value); getMarketMoversData(selectedIndexButtonBar); // TODO : show loader - while getting new data //analytics: track the market movers/next 3 races to go location if(selectedRaceOption.value == MarketMoversModel.MARKET_MOVERS_NEXT_3_RACES) marketMoversTabLocation = NEXT_3_RACES_TO_GO; else marketMoversTabLocation = MARKET_MOVERS_LOCATION; dispatchEvent(new LocationChangeEvent()); } // ---------------------------------------------------------- // PUBLIC METHODS // ---------------------------------------------------------- private function getMarketMoversData(selectedIndex:int) : void { callFromExternal = false; if(selectedIndex == INDEX_VIEW_CURRENT_RACE) { dataLoaded = false; // call to a specific race MarketMovers ( current race ) var request:MarketMoversRequest = new MarketMoversRequest(); request.racingCode = this._currentRacingCode; request.raceNumber = this._currentRaceNumber; request.meetingName = this._currentMeetingName; request.meetingDateRaw = this._currentMeetingDateRaw; broadcast(new MarketMoversMessage(request)); } else if(selectedIndex == INDEX_VIEW_NEXT_THREE_RACE) { dataLoaded = false; // for the default market movers call - like the RacingOverview var mmRequest : MarketMoversRequest = new MarketMoversRequest(); var msg:CallMarketMoversMessage = new CallMarketMoversMessage(mmRequest); broadcast(msg); } } public function storeCurrentRaceDetails(req : MarketMoversRequest) : void { this._currentRacingCode = req.racingCode; this._currentMeetingName = req.meetingName; this._currentMeetingDateRaw = req.meetingDateRaw; this._currentRaceNumber = req.raceNumber; } public function removeCurrentRaceDetails() : void { this._currentRacingCode = null; this._currentMeetingName = null; this._currentMeetingDateRaw = new Date(); this._currentRaceNumber = 0; } public function printClickHandler(component:UIComponent):void { var printReceipt:PrintPreviewPopUp = new PrintPreviewPopUp(); PopUpManager.addPopUp(printReceipt as IFlexDisplayObject, FlexGlobals.topLevelApplication as DisplayObject, true); if(component.height>0 && component.width>0) { printReceipt.toBePrintData = component; printReceipt.x = FlexGlobals.topLevelApplication.width/2 - component.width/2; printReceipt.y = FlexGlobals.topLevelApplication.height/2 - component.height/2; PopUpManager.bringToFront(printReceipt as IFlexDisplayObject ); } } public function navigateToRacePage(marketMoversVO:MarketMoversVO) : void { var request:RaceDetailsRequestV2 = new RaceDetailsRequestV2(); request.meetingName = marketMoversVO.meetingName; request.meetingCode = marketMoversVO.meetingCode; request.meetingDateRaw = marketMoversVO.raceStartTime; request.racingCode = marketMoversVO.racingCode; request.raceNumber = String(marketMoversVO.raceNumber); broadcast(new RacingNavigatorMessage(RacingNavigatorModel.BETTING_PAGE, null, false, request)); closeMarketMovers(); } /** * to close the market movers popup */ [MessageHandler] public function messageHandlerCloseMarketMoversPopup( message : CloseMarketMoversPopupMessage) : void { // next call will be from external only callFromExternal = true; } public function closeMarketMovers() : void { callFromExternal = true; var message : CloseMarketMoversPopupMessage = new CloseMarketMoversPopupMessage( CloseMarketMoversPopupMessage.Close_Market_Movers_Popup_Message); broadcast(message); } // ---------------------------------------------------------- // SUBSCRIBE HANDLER // ---------------------------------------------------------- private var _requestedRaceNo:int; private var _marketMoversRequest:MarketMoversRequest; public function get marketMoversRequest():MarketMoversRequest { return _marketMoversRequest } public function get requestedRaceNo():int { return _requestedRaceNo; } [Subscribe] public function set marketMoversRequest(value:MarketMoversRequest):void { _marketMoversRequest = value; if (marketMoversRequest) { _requestedRaceNo = marketMoversRequest.raceNumber; broadcast(new MarketMoversMessage(marketMoversRequest)); } } public function viewToBeShown(showCurrentRace:Boolean = false) : void { if(callFromExternal) { if(showCurrentRace) { // show current race button enableButtonBar = true; callFromExternal = true; selectedIndexButtonBar = INDEX_VIEW_CURRENT_RACE; selectedRaceOption = ac.getItemAt(INDEX_VIEW_CURRENT_RACE); } else { selectedIndexButtonBar = INDEX_VIEW_NEXT_THREE_RACE; selectedRaceOption = ac.getItemAt(INDEX_VIEW_NEXT_THREE_RACE); enableButtonBar = false; } } } // Getter / Setter [Bindable(event="todayDateChanged")] public function get todayDate():Date { return _todayDate; } public function set todayDate(value:Date):void { _todayDate = value; dispatchEvent(new Event("todayDateChanged")); } [Bindable(event="selectedIndexButtonBarChange")] public function get selectedIndexButtonBar():int { return _selectedIndexButtonBar; } public function set selectedIndexButtonBar(value:int):void { _selectedIndexButtonBar = value; dispatchEvent(new Event("selectedIndexButtonBarChange")); } [Bindable(event="enableButtonBarChange")] public function get enableButtonBar():Boolean { return _enableButtonBar; } public function set enableButtonBar(value:Boolean):void { if( _enableButtonBar !== value) { _enableButtonBar = value; dispatchEvent(new Event("enableButtonBarChange")); } } } }
上一篇: 爆笑的小偷、小贩、懒汉和起名专家
下一篇: 好雷爆冷的名著乱编