http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d33fe63c/examples/flexjs/MobileTrader/src/views/StockView.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileTrader/src/views/StockView.mxml b/examples/flexjs/MobileTrader/src/views/StockView.mxml new file mode 100755 index 0000000..e1dfb24 --- /dev/null +++ b/examples/flexjs/MobileTrader/src/views/StockView.mxml @@ -0,0 +1,98 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +--> +<basic:View xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:basic="library://ns.apache.org/flexjs/basic" + xmlns:apache="org.apache.flex.html.beads.*" + xmlns:local="*" + className="StockView"> + + <fx:Script> + <![CDATA[ + import models.Stock; + + import org.apache.flex.events.Event; + import org.apache.flex.mobile.StackedViewManager; + + private var _stock:Stock; + + [Bindable("stockChanged")] + public function get stock():Stock + { + return _stock; + } + public function set stock(value:Stock):void + { + _stock = value; + dispatchEvent(new org.apache.flex.events.Event("stockChanged")); + } + + private function onBackClick() : void + { + (viewManager as StackedViewManager).pop(); + } + + override public function addedToParent():void + { + super.addedToParent(); + + stockSymbol.text = stock.symbol; + stockName.text = stock.name; + lastPrice.text = String(stock.last); + openPrice.text = String(stock.open); + lowPrice.text = String(stock.low); + highPrice.text = String(stock.high); + changeAmount.text = String(stock.change); + } + + private function removeFromList():void + { + dispatchEvent(new org.apache.flex.events.Event("removeFromList")); + } + ]]> + </fx:Script> + + <basic:Container> + <basic:beads> + <basic:VerticalLayout /> + </basic:beads> + <basic:style> + <basic:SimpleCSSStyles top="10px" left="10px" /> + </basic:style> + + <basic:Label id="stockSymbol" text="{stock.symbol}" className="ViewTitle" /> + <basic:Label id="stockName" text="{stock.name}" className="StockName" /> + + <basic:Container className="StockDetailArea"> + <basic:beads> + <basic:VerticalColumnLayout numColumns="2" /> + </basic:beads> + + <basic:Label text="Last Price:" className="StockLabel" /> <basic:Label id="lastPrice" className="StockValue" /> + <basic:Label text="Open Price:" className="StockLabel" /> <basic:Label id="openPrice" className="StockValue" /> + <basic:Label text="Low Price:" className="StockLabel" /> <basic:Label id="lowPrice" className="StockValue" /> + <basic:Label text="High Price:" className="StockLabel" /> <basic:Label id="highPrice" className="StockValue" /> + <basic:Label text="Change: " className="StockLabel" /> <basic:Label id="changeAmount" className="StockValue" /> + </basic:Container> + + <basic:Container className="StockDetailArea"> + <basic:TextButton text="Remove From List" width="200" className="StockRemoveButton" click="removeFromList()" /> + </basic:Container> + </basic:Container> +</basic:View> \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d33fe63c/examples/flexjs/MobileTrader/src/views/WatchListView.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileTrader/src/views/WatchListView.mxml b/examples/flexjs/MobileTrader/src/views/WatchListView.mxml new file mode 100755 index 0000000..b12fc73 --- /dev/null +++ b/examples/flexjs/MobileTrader/src/views/WatchListView.mxml @@ -0,0 +1,150 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +--> +<js:View xmlns:fx="http://ns.adobe.com/mxml/2009" + title="Watch List" + xmlns:js="library://ns.apache.org/flexjs/basic" + xmlns:controller="controller.*" + xmlns:local="*" + className="WatchListView" + xmlns:renderers="renderers.*"> + + <fx:Script> + <![CDATA[ + import controller.WatchListController; + + import models.ProductsModel; + import models.Stock; + + import org.apache.flex.binding.SimpleBinding; + import org.apache.flex.core.IBeadController; + import org.apache.flex.core.IBeadModel; + import org.apache.flex.events.Event; + import org.apache.flex.mobile.IViewManager; + import org.apache.flex.mobile.StackedViewManager; + + public function set dataModel(value:IBeadModel):void + { + var cm:IBeadController = controller; + (cm as WatchListController).model = value; + } + public function get dataModel():IBeadModel + { + var cm:IBeadController = controller; + return (cm as WatchListController).model; + } + + private function onSelectStock():void + { + var stockView:StockView = new StockView(); + var svm:IViewManager = viewManager; + (viewManager as StackedViewManager).push(stockView); + } + + private function addSymbol():void + { + dispatchEvent(new org.apache.flex.events.Event("addSymbol")); + } + + public var selectedStockIndex:Number; + + private function selectRow():void + { + selectedStockIndex = dataGrid.selectedIndex; + dispatchEvent(new org.apache.flex.events.Event("stockSelected")); + } + + public function showStockDetails(stock:Stock):StockView + { + var stockView:StockView = new StockView(); + stockView.stock = stock; + (viewManager as StackedViewManager).push(stockView); + + var cm:IBeadController = controller; + + return stockView; + } + + public function popView():void + { + (viewManager as StackedViewManager).pop(); + } + ]]> + </fx:Script> + + <js:beads> + <js:VerticalLayout /> + </js:beads> + + <js:HContainer className="WatchListInputArea" width="100%" height="10%"> + <js:Label text="Symbol:" /> + <js:TextInput id="symbolName" /> + <js:TextButton text="Add" click="addSymbol()" /> + </js:HContainer> + + <js:Spacer height="10" /> + + <js:DataGrid id="dataGrid" width="50%" height="90%" change="selectRow()" className="WatchListDataGrid"> + <js:beads> + <js:SimpleBinding + eventName="update" + sourceID="dataModel" + sourcePropertyName="watchList" + destinationPropertyName="dataProvider" /> + </js:beads> + <js:columns> + <js:DataGridColumn label="Symbol" dataField="symbol"> + <js:itemRenderer> + <fx:Component> + <js:StringItemRenderer /> + </fx:Component> + </js:itemRenderer> + </js:DataGridColumn> + <js:DataGridColumn label="Open" dataField="open"> + <js:itemRenderer> + <fx:Component> + <renderers:StockRenderer /> + </fx:Component> + </js:itemRenderer> + </js:DataGridColumn> + <js:DataGridColumn label="Last" dataField="last" > + <js:itemRenderer> + <fx:Component> + <renderers:StockRenderer /> + </fx:Component> + </js:itemRenderer> + </js:DataGridColumn> + <js:DataGridColumn label="High" dataField="high" > + <js:itemRenderer> + <fx:Component> + <renderers:StockRenderer /> + </fx:Component> + </js:itemRenderer> + </js:DataGridColumn> + <js:DataGridColumn label="Low" dataField="low" > + <js:itemRenderer> + <fx:Component> + <renderers:StockRenderer /> + </fx:Component> + </js:itemRenderer> + </js:DataGridColumn> + </js:columns> + </js:DataGrid> + +</js:View> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d33fe63c/examples/flexjs/TodoListSampleApp/build.xml ---------------------------------------------------------------------- diff --git a/examples/flexjs/TodoListSampleApp/build.xml b/examples/flexjs/TodoListSampleApp/build.xml new file mode 100644 index 0000000..d416664 --- /dev/null +++ b/examples/flexjs/TodoListSampleApp/build.xml @@ -0,0 +1,73 @@ +<?xml version="1.0"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<project name="todoListSampleApp" default="main" basedir="."> + <property name="FLEXJS_HOME" location="../.."/> + <property name="example" value="TodoListSampleApp" /> + + <property file="${FLEXJS_HOME}/env.properties"/> + <property environment="env"/> + <property file="${FLEXJS_HOME}/build.properties"/> + <property name="FLEX_HOME" value="${FLEXJS_HOME}"/> + <available file="${env.FALCON_HOME}/lib/falcon-mxmlc.jar" + type="file" + property="FALCON_HOME" + value="${env.FALCON_HOME}"/> + + <available file="${FLEXJS_HOME}/../flex-falcon/compiler/generated/dist/sdk/lib/falcon-mxmlc.jar" + type="file" + property="FALCON_HOME" + value="${FLEXJS_HOME}/../flex-falcon/compiler/generated/dist/sdk"/> + + <available file="${env.FALCONJX_HOME}/lib/jsc.jar" + type="file" + property="FALCONJX_HOME" + value="${env.FALCONJX_HOME}"/> + + <available file="${FLEXJS_HOME}/../flex-falcon/compiler.jx/lib/jsc.jar" + type="file" + property="FALCONJX_HOME" + value="${FLEXJS_HOME}/../flex-falcon/compiler.jx"/> + + <available file="${env.GOOG_HOME}/closure/goog/base.js" + type="file" + property="GOOG_HOME" + value="${env.GOOG_HOME}"/> + + <available file="${FLEXJS_HOME}/js/lib/google/closure-library/closure/goog/base.js" + type="file" + property="GOOG_HOME" + value="${FLEXJS_HOME}/js/lib/google/closure-library"/> + + <include file="${basedir}/../build_example.xml" /> + + <target name="main" depends="clean,build_example.compile,build_example.compilejs" description="Clean build of ${example}"> + </target> + <!-- Uncomment to reproduce cross-compilation error in compilejs step + <target name="main" depends="clean,build_example.compile,build_example.compilejs" description="Clean build of ${example}"> + </target> + --> + + <target name="clean"> + <delete dir="${basedir}/bin" failonerror="false" /> + <delete dir="${basedir}/bin-debug" failonerror="false" /> + <delete dir="${basedir}/bin-release" failonerror="false" /> + </target> +</project> + http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d33fe63c/examples/flexjs/TodoListSampleApp/src/README.txt ---------------------------------------------------------------------- diff --git a/examples/flexjs/TodoListSampleApp/src/README.txt b/examples/flexjs/TodoListSampleApp/src/README.txt new file mode 100644 index 0000000..b3d96b9 --- /dev/null +++ b/examples/flexjs/TodoListSampleApp/src/README.txt @@ -0,0 +1,22 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +DESCRIPTION + +This sample is currently under construction. http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d33fe63c/examples/flexjs/TodoListSampleApp/src/TodoListSampleApp.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/TodoListSampleApp/src/TodoListSampleApp.mxml b/examples/flexjs/TodoListSampleApp/src/TodoListSampleApp.mxml new file mode 100644 index 0000000..e734026 --- /dev/null +++ b/examples/flexjs/TodoListSampleApp/src/TodoListSampleApp.mxml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="utf-8"?> +<!--- +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +--> +<js:Application xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:js="library://ns.apache.org/flexjs/basic" + xmlns:controllers="sample.todo.controllers.*" + xmlns:models="sample.todo.models.*" + xmlns:views="sample.todo.views.*"> + + <js:valuesImpl> + <js:SimpleCSSValuesImpl/> + </js:valuesImpl> + + <js:controller> + <controllers:TodoListController/> + </js:controller> + + <js:model> + <models:TodoListModel/> + </js:model> + + <js:initialView> + <views:TodoListView/> + </js:initialView> + +</js:Application> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d33fe63c/examples/flexjs/TodoListSampleApp/src/sample/todo/controllers/TodoListController.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/TodoListSampleApp/src/sample/todo/controllers/TodoListController.as b/examples/flexjs/TodoListSampleApp/src/sample/todo/controllers/TodoListController.as new file mode 100644 index 0000000..cbc4b1e --- /dev/null +++ b/examples/flexjs/TodoListSampleApp/src/sample/todo/controllers/TodoListController.as @@ -0,0 +1,62 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package sample.todo.controllers { + import sample.todo.events.TodoListEvent; + import sample.todo.models.TodoListModel; + + import org.apache.flex.core.Application; + import org.apache.flex.core.IDocument; + import org.apache.flex.events.Event; + + public class TodoListController implements IDocument { + private var app:TodoListSampleApp; + + public function TodoListController(app:Application = null) { + if (app != null) { + app = app as TodoListSampleApp; + } + } + + /** + * + */ + public function setDocument(document:Object, id:String = null):void { + app = document as TodoListSampleApp; + app.addEventListener("viewChanged", viewChangeHandler); + } + + /** + * + * @param event + */ + private function viewChangeHandler(event:Event):void { + app.initialView.addEventListener(TodoListEvent.LOG_TODO, logTodo); + } + + /** + * log todo + * @param event + */ + public function logTodo(evt:TodoListEvent):void { + // still need to change model a view get the changes + var todoModel:TodoListModel = app.model as TodoListModel; + //todoModel.todos.push({title: evt.todo, selected: false}); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d33fe63c/examples/flexjs/TodoListSampleApp/src/sample/todo/events/TodoListEvent.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/TodoListSampleApp/src/sample/todo/events/TodoListEvent.as b/examples/flexjs/TodoListSampleApp/src/sample/todo/events/TodoListEvent.as new file mode 100644 index 0000000..c4d5fd1 --- /dev/null +++ b/examples/flexjs/TodoListSampleApp/src/sample/todo/events/TodoListEvent.as @@ -0,0 +1,35 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package sample.todo.events { + import org.apache.flex.events.Event; + + public class TodoListEvent extends Event { + + public static const LOG_TODO:String = "logTodoEvent"; + + /** + * the todo to log + */ + public var todo:String = null; + + public function TodoListEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false) { + super(type, bubbles, cancelable); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d33fe63c/examples/flexjs/TodoListSampleApp/src/sample/todo/models/TodoListModel.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/TodoListSampleApp/src/sample/todo/models/TodoListModel.as b/examples/flexjs/TodoListSampleApp/src/sample/todo/models/TodoListModel.as new file mode 100644 index 0000000..e4d06b1 --- /dev/null +++ b/examples/flexjs/TodoListSampleApp/src/sample/todo/models/TodoListModel.as @@ -0,0 +1,42 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package sample.todo.models { + import org.apache.flex.events.EventDispatcher; + + public class TodoListModel extends EventDispatcher { + public function TodoListModel() { + super(); + } + + private var _todos:Array = [ + {title: "Get something", selected: true}, + {title: "Do this", selected: true}, + {title: "Do that", selected: false} + ]; + + [Bindable] + public function get todos():Array { + return _todos; + } + + public function set todos(value:Array):void { + _todos = value; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d33fe63c/examples/flexjs/TodoListSampleApp/src/sample/todo/renderers/TodoItemRenderer.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/TodoListSampleApp/src/sample/todo/renderers/TodoItemRenderer.as b/examples/flexjs/TodoListSampleApp/src/sample/todo/renderers/TodoItemRenderer.as new file mode 100644 index 0000000..a4fa9f1 --- /dev/null +++ b/examples/flexjs/TodoListSampleApp/src/sample/todo/renderers/TodoItemRenderer.as @@ -0,0 +1,69 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package sample.todo.renderers { + import org.apache.flex.html.Button; + import org.apache.flex.html.CheckBox; + import org.apache.flex.html.Label; + import org.apache.flex.html.supportClasses.DataItemRenderer; + + public class TodoItemRenderer extends DataItemRenderer { + public function TodoItemRenderer() { + super(); + } + + private var checkbox:CheckBox; + private var title:Label; + private var removeButton:Button; + + override public function addedToParent():void { + super.addedToParent(); + + checkbox = new CheckBox(); + addElement(checkbox); + + title = new Label(); + addElement(title); + + removeButton = new Button(); + addElement(removeButton); + } + + override public function set data(value:Object):void { + super.data = value; + + checkbox.selected = data.selected; + title.text = data.title; + } + + override public function adjustSize():void { + var cy:Number = this.height / 2; + + checkbox.x = 10; + checkbox.y = cy; + + title.x = 60; + title.y = cy; + + removeButton.x = 300; + removeButton.y = cy; + + updateRenderer(); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d33fe63c/examples/flexjs/TodoListSampleApp/src/sample/todo/views/TodoListView.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/TodoListSampleApp/src/sample/todo/views/TodoListView.mxml b/examples/flexjs/TodoListSampleApp/src/sample/todo/views/TodoListView.mxml new file mode 100644 index 0000000..153fb76 --- /dev/null +++ b/examples/flexjs/TodoListSampleApp/src/sample/todo/views/TodoListView.mxml @@ -0,0 +1,109 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +--> +<js:ViewBase xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:js="library://ns.apache.org/flexjs/basic" + xmlns:svg="library://ns.apache.org/flexjs/svg"> + + <fx:Script> + <![CDATA[ + import sample.todo.events.TodoListEvent; + + /** + * add to the list the text entered by the user, in the text box, + * as a new todo list item + */ + public function logTodo():void { + var logEvent:TodoListEvent = new TodoListEvent(TodoListEvent.LOG_TODO); + logEvent.todo = todoInput.text; + dispatchEvent(logEvent); + + //todoList.width = Math.random() * 200; // to show changes vÃa ENTER key + } + + /** + * show all todos + */ + private function showAll():void { + } + + /** + * show active todos + */ + private function showActive():void { + } + + /** + * show completed todos + */ + private function showCompleted():void { + } + ]]> + </fx:Script> + + <js:Panel title="FlexJS TODO List" width="600"> + <js:beads> + <js:VerticalLayout/> + </js:beads> + + <js:TextInput id="todoInput" + width="300" + change="logTodo()"/> + + <js:List id="todoList" + itemRenderer="sample.todo.renderers.TodoItemRenderer" + width="300" height="400"> + <!-- dataProvider="{TodoListModel(applicationModel).todos}" --> + <js:beads> + <js:ConstantBinding sourceID="applicationModel" + sourcePropertyName="todos" + destinationPropertyName="dataProvider"/> + </js:beads> + </js:List> + + <js:Container> + <js:beads> + <js:HorizontalLayout/> + </js:beads> + <js:Label id="statusLabel" text="N items left"/> + <svg:TextButton text="All" width="100" height="30" click="showAll()" /> + <svg:TextButton text="Active" width="100" height="30" click="showActive()" /> + <svg:TextButton text="Completed" width="100" height="30" click="showCompleted()" /> + </js:Container> + </js:Panel> + + <fx:Style> + @namespace basic "library://ns.apache.org/flexjs/basic"; + @namespace renderers "sample.todo.renderers.*"; + + /* use className="todoList" on the List element in place of itemRenderer if you want to specify + * the itemRenderer in a style definition along with other settings. + */ + .todoList { + IDataProviderItemRendererMapper: ClassReference("org.apache.flex.html.beads.DataItemRendererFactoryForArrayData"); + IItemRenderer: ClassReference("sample.todo.renderers.TodoItemRenderer"); + } + + renderers|TodoItemRenderer { + height: 40; + IBeadController: ClassReference("org.apache.flex.html.beads.controllers.ItemRendererMouseController"); + } + </fx:Style> + +</js:ViewBase>
