This repository has been archived by the owner on Jan 1, 2021. It is now read-only.
forked from openstreetmap/potlatch2
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
155 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- http://blog.flexexamples.com/2010/04/09/adding-a-delete-button-in-the-hovered-state-of-a-spark-list-control-item-renderer-in-flex-4/ --> | ||
<s:ItemRenderer name="DeletableListItemRenderer" | ||
xmlns:fx="http://ns.adobe.com/mxml/2009" | ||
xmlns:s="library://ns.adobe.com/flex/spark" | ||
xmlns:mx="library://ns.adobe.com/flex/mx" | ||
autoDrawBackground="true" | ||
minHeight="24"> | ||
<s:states> | ||
<s:State name="normal" /> | ||
<s:State name="hovered" /> | ||
<s:State name="selected" /> | ||
</s:states> | ||
|
||
<fx:Script> | ||
<![CDATA[ | ||
import mx.controls.Alert; | ||
import mx.events.CloseEvent; | ||
import spark.components.List; | ||
protected function button1_clickHandler(evt:MouseEvent):void { | ||
Alert.show(data.label, | ||
"Are you sure you want to delete this item?", | ||
Alert.YES|Alert.CANCEL, | ||
null, | ||
alrt_closeHandler); | ||
} | ||
protected function alrt_closeHandler(evt:CloseEvent):void { | ||
switch (evt.detail) { | ||
case Alert.YES: | ||
case Alert.OK: | ||
Object(owner).dataProvider.removeItemAt(itemIndex); | ||
break; | ||
case Alert.CANCEL: | ||
case Alert.NO: | ||
Object(owner).selectedIndex = -1; | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
]]> | ||
</fx:Script> | ||
|
||
<s:HGroup width="100%" height="100%" | ||
verticalAlign="middle" | ||
paddingLeft="2" paddingRight="2" | ||
paddingTop="2" paddingBottom="2"> | ||
<s:Label id="lbl" text="{data.name}" width="100%" /> | ||
<s:Image id="btn" includeIn="hovered,selected" source="@Embed('../../../embedded/delete_small.svg')" click="button1_clickHandler(event)" /> | ||
</s:HGroup> | ||
|
||
</s:ItemRenderer> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<s:BorderContainer | ||
xmlns:controls="net.systemeD.controls.*" | ||
xmlns:fx="http://ns.adobe.com/mxml/2009" | ||
xmlns:s="library://ns.adobe.com/flex/spark" > | ||
|
||
<s:layout> | ||
<s:VerticalLayout | ||
paddingLeft="5" paddingRight="5" | ||
paddingTop="5" paddingBottom="5"/> | ||
</s:layout> | ||
|
||
<s:List width="100%" height="100%" id="bookmarkMenu" | ||
labelField="name" | ||
itemRenderer="net.systemeD.controls.DeletableListItemRenderer" | ||
change="FlexGlobals.topLevelApplication.bookmarkButton.close(); goToBookmark(event);" | ||
dataProvider="{bookmarks}"> | ||
<s:layout> | ||
<s:VerticalLayout requestedRowCount="{bookmarks.length}" gap="0" rowHeight="20" variableRowHeight="false" horizontalAlign="contentJustify"/> | ||
</s:layout> | ||
</s:List> | ||
|
||
<s:Button id="addButton" label="Add..." click="FlexGlobals.topLevelApplication.bookmarkButton.close(); addBookmark();" /> | ||
|
||
<fx:Script><![CDATA[ | ||
import net.systemeD.halcyon.*; | ||
import net.systemeD.halcyon.connection.*; | ||
import net.systemeD.potlatch2.*; | ||
import net.systemeD.potlatch2.collections.Stylesheets; | ||
import net.systemeD.potlatch2.dialogs.*; | ||
import net.systemeD.controls.DeletableListItemRenderer; | ||
import mx.core.*; | ||
import spark.events.IndexChangeEvent; | ||
import mx.collections.ArrayCollection; | ||
import mx.managers.PopUpManager; | ||
[Bindable] | ||
public var bookmarks:ArrayCollection = new ArrayCollection([]); | ||
// of format { name: "Bookmark 1", lat: 53, lon: 0 }, { name: "Bookmark 2", lat: 54, lon: -1 } | ||
private var userState:SharedObject=SharedObject.getLocal("user_state","/"); | ||
public function init():BookmarkSelector { | ||
if (userState.data['bookmarks']) { | ||
bookmarks = new ArrayCollection(userState.data['bookmarks']); | ||
} | ||
return this; | ||
} | ||
private function goToBookmark(event:IndexChangeEvent):void { | ||
FlexGlobals.topLevelApplication.theController.map.moveMapFromLatLon(event.currentTarget.selectedItem.lat, event.currentTarget.selectedItem.lon); | ||
} | ||
private function addBookmark():void { | ||
var dialog:BookmarkNameDialog = BookmarkNameDialog( | ||
PopUpManager.createPopUp(Application(FlexGlobals.topLevelApplication), BookmarkNameDialog, true)); | ||
PopUpManager.centerPopUp(dialog); | ||
// save to SharedObject | ||
userState.setProperty("bookmarks",bookmarks.source); | ||
try { userState.flush(); } catch (e:Error) {} | ||
} | ||
]]></fx:Script> | ||
</s:BorderContainer> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<mx:TitleWindow | ||
xmlns:fx="http://ns.adobe.com/mxml/2009" | ||
xmlns:mx="library://ns.adobe.com/flex/mx" | ||
xmlns:potlatch2="net.systemeD.potlatch2.*" | ||
title="New Bookmark" width="350" height="160" | ||
creationComplete="bookmarkName.setFocus()" | ||
showCloseButton="true" close="PopUpManager.removePopUp(this);"> | ||
|
||
<mx:HBox paddingLeft="3" paddingTop="4"> | ||
<mx:Label text="Bookmark name: " /> | ||
<mx:TextInput id="bookmarkName" enter="addBookmark();" /> | ||
</mx:HBox> | ||
<mx:ControlBar> | ||
<mx:Spacer width="100%"/> | ||
<mx:Button label="Add" click="addBookmark();" styleName="titleWindowButton" /> | ||
</mx:ControlBar> | ||
<fx:Script><![CDATA[ | ||
import net.systemeD.halcyon.*; | ||
import net.systemeD.halcyon.connection.*; | ||
import net.systemeD.potlatch2.*; | ||
import mx.managers.PopUpManager; | ||
import mx.core.FlexGlobals; | ||
public function addBookmark():void { | ||
var controller:EditController = FlexGlobals.topLevelApplication.theController; | ||
FlexGlobals.topLevelApplication.bookmarkButton.popUp.bookmarks.addItem({ name: bookmarkName.text, lat: controller.map.centre_lat, lon: controller.map.centre_lon }); | ||
PopUpManager.removePopUp(this); | ||
} | ||
]]></fx:Script> | ||
</mx:TitleWindow> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters