flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@apache.org
Subject git commit: [flex-asjs] [refs/heads/develop] - New sample demonstrating jQuery framework.
Date Fri, 10 May 2013 14:54:30 GMT
Updated Branches:
  refs/heads/develop 74e7819d2 -> b0367dde8


New sample demonstrating jQuery framework.


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/b0367dde
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/b0367dde
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/b0367dde

Branch: refs/heads/develop
Commit: b0367dde8a1721e3f2a67bea67916e48cbdfe566
Parents: 74e7819
Author: Peter Ent <pent@apache.org>
Authored: Fri May 10 10:54:20 2013 -0400
Committer: Peter Ent <pent@apache.org>
Committed: Fri May 10 10:54:20 2013 -0400

----------------------------------------------------------------------
 examples/FlexJSTest_jquery/src/ButtonImageDown.png |  Bin 0 -> 206 bytes
 examples/FlexJSTest_jquery/src/ButtonImageOver.png |  Bin 0 -> 266 bytes
 examples/FlexJSTest_jquery/src/ButtonImageUp.png   |  Bin 0 -> 236 bytes
 examples/FlexJSTest_jquery/src/MyInitialView.mxml  |  148 +++++++++++++++
 .../src/StockDataJSONItemConverter.as              |   38 ++++
 .../src/controllers/MyController.as                |   92 +++++++++
 examples/FlexJSTest_jquery/src/jQuerySample.mxml   |   64 +++++++
 examples/FlexJSTest_jquery/src/models/MyModel.as   |   59 ++++++
 8 files changed, 401 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b0367dde/examples/FlexJSTest_jquery/src/ButtonImageDown.png
----------------------------------------------------------------------
diff --git a/examples/FlexJSTest_jquery/src/ButtonImageDown.png b/examples/FlexJSTest_jquery/src/ButtonImageDown.png
new file mode 100644
index 0000000..0cf7f8a
Binary files /dev/null and b/examples/FlexJSTest_jquery/src/ButtonImageDown.png differ

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b0367dde/examples/FlexJSTest_jquery/src/ButtonImageOver.png
----------------------------------------------------------------------
diff --git a/examples/FlexJSTest_jquery/src/ButtonImageOver.png b/examples/FlexJSTest_jquery/src/ButtonImageOver.png
new file mode 100644
index 0000000..2f78d59
Binary files /dev/null and b/examples/FlexJSTest_jquery/src/ButtonImageOver.png differ

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b0367dde/examples/FlexJSTest_jquery/src/ButtonImageUp.png
----------------------------------------------------------------------
diff --git a/examples/FlexJSTest_jquery/src/ButtonImageUp.png b/examples/FlexJSTest_jquery/src/ButtonImageUp.png
new file mode 100644
index 0000000..927e1c8
Binary files /dev/null and b/examples/FlexJSTest_jquery/src/ButtonImageUp.png differ

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b0367dde/examples/FlexJSTest_jquery/src/MyInitialView.mxml
----------------------------------------------------------------------
diff --git a/examples/FlexJSTest_jquery/src/MyInitialView.mxml b/examples/FlexJSTest_jquery/src/MyInitialView.mxml
new file mode 100644
index 0000000..7868d10
--- /dev/null
+++ b/examples/FlexJSTest_jquery/src/MyInitialView.mxml
@@ -0,0 +1,148 @@
+<?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:ViewBase xmlns:fx="http://ns.adobe.com/mxml/2009"
+				xmlns:basic="library://ns.apache.org/flexjs/basic"
+				xmlns:jquery="library://ns.apache.org/flexjs/jquery"
+			   >
+    <fx:Script>
+        <![CDATA[            
+			import org.apache.flex.events.CustomEvent;
+			import org.apache.flex.events.Event;
+			import org.apache.flex.html.staticControls.Label;
+			import org.apache.flex.html.staticControls.TextButton;
+			import org.apache.flex.utils.Timer;
+			
+			private var timer:org.apache.flex.utils.Timer;
+			
+			private var radioXpos:int = 200;
+			
+			public function get symbol():String
+			{
+				return list.selectedItem as String;
+			}
+			
+			public function get city():String
+			{
+				return cityList.selectedItem as String;
+			}
+			
+			public function get inputText():String
+			{
+				return input.text;
+			}
+			
+			public function get comboBoxValue():String
+			{
+				return String(comboBox.selectedItem);
+			}
+			
+			public function startTimer():void
+			{
+				timer = new org.apache.flex.utils.Timer(1000);
+				timer.addEventListener('timer', timerHandler);
+				timer.start()				
+			}
+			
+			public function timerHandler(event:org.apache.flex.events.Event):void
+			{
+				timerLabel.text = timer.currentCount.toString();	
+			}
+        ]]>
+    </fx:Script>
+	<fx:Style>
+		@namespace basic "library://ns.apache.org/flexjs/basic";
+		
+		.skinned {
+			background-image: url('ButtonImageUp.png');
+			border-style: none;
+		}
+		
+		.skinned:hover {
+			background-image: url('ButtonImageOver.png');
+		}
+		
+		.skinned:active {
+			background-image: url('ButtonImageDown.png');
+		}
+
+	</fx:Style>
+	<basic:Label id="lbl" x="100" y="25" >
+		<basic:beads>
+			<basic:SimpleBinding eventName="labelTextChanged"
+								 sourceID="applicationModel"
+								 sourcePropertyName="labelText"
+								 destinationPropertyName="text" />
+		</basic:beads>
+	</basic:Label>
+	<jquery:TextButton text="Start Timer" x="100" y="75" click="startTimer()" />
+	<jquery:TextButton text="Stop Timer" x="100" y="100" click="timer.removeEventListener('timer',
timerHandler);timer.stop()" />
+	<basic:Label id="timerLabel" x="100" y="125" />
+	
+	<basic:List id="cityList"  x="200" y="75" width="100" height="75" change="dispatchEvent(new
CustomEvent('cityListChanged'))">
+		<basic:beads>
+			<basic:ConstantBinding
+				sourceID="applicationModel"
+				sourcePropertyName="cities"
+				destinationPropertyName="dataProvider" />
+		</basic:beads>
+	</basic:List>
+	
+	<basic:TextArea x="320" y="25" width="150" height="75">
+		<basic:beads>
+			<basic:SimpleBinding eventName="labelTextChanged"
+								 sourceID="applicationModel"
+								 sourcePropertyName="labelText"
+								 destinationPropertyName="text" />
+		</basic:beads>
+	</basic:TextArea>
+	<basic:TextInput id="input" x="320" y="110" />
+	<jquery:TextButton text="Transfer" x="320" y="138" click="dispatchEvent(new CustomEvent('transferClicked'))"
/>
+	
+	<jquery:CheckBox id="checkbox" x="320" y="170" text="Check Me" />
+	
+	<jquery:RadioButton groupName="group1" text="Apples" value="0" x="100" y="290" />
+	<jquery:RadioButton groupName="group1" text="Oranges" value="1" x="200" y="290" selected="true"
/>
+	<jquery:RadioButton groupName="group1" text="Grapes" value="2" x="300" y="290" />
+	
+	<jquery:RadioButton groupName="group2" text="Red" value="red" x="100" y="320" selected="true"
/>
+	<jquery:RadioButton groupName="group2" text="Green" value="green" x="200" y="320" />
+	<jquery:RadioButton groupName="group2" text="Blue" value="blue" x="300" y="320"  />
+	
+	<basic:DropDownList id="list" x="200" y="200" width="100" height="18" change="dispatchEvent(new
CustomEvent('listChanged'))">
+		<basic:beads>
+			<basic:ConstantBinding
+				sourceID="applicationModel"
+				sourcePropertyName="strings"
+				destinationPropertyName="dataProvider" />
+		</basic:beads>
+	</basic:DropDownList>
+	<jquery:TextButton text="OK" x="200" y="230" click="dispatchEvent(new CustomEvent('buttonClicked'))"
/>
+	<jquery:TextButton text="Skinned" x="200" y="260" width="80" height="24" className="skinned"
click="dispatchEvent(new CustomEvent('buttonClicked'))" />
+	
+	<basic:ComboBox id="comboBox" x="320" y="200" width="100" change="dispatchEvent(new CustomEvent('comboBoxChanged'))">
+		<basic:beads>
+			<basic:ConstantBinding
+				sourceID="applicationModel"
+				sourcePropertyName="cities"
+				destinationPropertyName="dataProvider" />
+		</basic:beads>
+	</basic:ComboBox>
+    
+</basic:ViewBase>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b0367dde/examples/FlexJSTest_jquery/src/StockDataJSONItemConverter.as
----------------------------------------------------------------------
diff --git a/examples/FlexJSTest_jquery/src/StockDataJSONItemConverter.as b/examples/FlexJSTest_jquery/src/StockDataJSONItemConverter.as
new file mode 100644
index 0000000..2483ce0
--- /dev/null
+++ b/examples/FlexJSTest_jquery/src/StockDataJSONItemConverter.as
@@ -0,0 +1,38 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+{
+    import org.apache.flex.net.JSONItemConverter;
+    
+    public class StockDataJSONItemConverter extends JSONItemConverter
+    {
+        public function StockDataJSONItemConverter()
+        {
+            super();
+        }
+        
+        override public function convertItem(data:String):Object
+        {
+            var obj:Object = super.convertItem(data);
+			if (obj['query']['results'] == null)
+				return 'No Quote Available';
+            return obj['query']['results']['quote']['Ask'];
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b0367dde/examples/FlexJSTest_jquery/src/controllers/MyController.as
----------------------------------------------------------------------
diff --git a/examples/FlexJSTest_jquery/src/controllers/MyController.as b/examples/FlexJSTest_jquery/src/controllers/MyController.as
new file mode 100644
index 0000000..3e78a2f
--- /dev/null
+++ b/examples/FlexJSTest_jquery/src/controllers/MyController.as
@@ -0,0 +1,92 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 controllers
+{
+	import org.apache.flex.core.Application;
+	import org.apache.flex.core.IDocument;
+	import org.apache.flex.events.Event;
+	
+	
+	import models.MyModel;
+	
+	public class MyController implements IDocument
+	{
+		public function MyController(app:Application = null)
+		{
+			if (app)
+			{
+				this.app = app as jQuerySample;
+				app.addEventListener("viewChanged", viewChangeHandler);
+			}
+		}
+		
+		private var queryBegin:String = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22";
+		private var queryEnd:String = "%22)%0A%09%09&env=http%3A%2F%2Fdatatables.org%2Falltables.env&format=json";
+		private var app:jQuerySample;
+		
+		private function viewChangeHandler(event:Event):void
+		{
+			app.initialView.addEventListener("buttonClicked", buttonClickHandler);
+			app.initialView.addEventListener("listChanged", listChangedHandler);
+			app.initialView.addEventListener("cityListChanged", cityListChangeHandler);
+			app.initialView.addEventListener("transferClicked", transferClickHandler);
+			app.initialView.addEventListener("comboBoxChanged", comboBoxChangeHandler);
+		}
+		
+		private function buttonClickHandler(event:Event):void
+		{
+			var sym:String = MyInitialView(app.initialView).symbol;
+			app.service.url = queryBegin + sym + queryEnd;
+			app.service.send();
+			app.service.addEventListener("complete", completeHandler);
+		}
+		
+		private function completeHandler(event:Event):void
+		{
+			MyModel(app.model).labelText = app.collection.getItemAt(0) as String;
+		}
+		
+		private function listChangedHandler(event:Event):void
+		{
+			MyModel(app.model).labelText = MyInitialView(app.initialView).symbol;
+		}
+		
+		private function cityListChangeHandler(event:Event):void
+		{
+			MyModel(app.model).labelText = MyInitialView(app.initialView).city;
+		}
+		
+		private function transferClickHandler(event:Event):void
+		{
+			MyModel(app.model).labelText = MyInitialView(app.initialView).inputText;
+		}
+		
+		private function comboBoxChangeHandler(event:Event):void
+		{
+			MyModel(app.model).labelText = MyInitialView(app.initialView).comboBoxValue;
+		}
+		
+		public function setDocument(document:Object, id:String = null):void
+		{
+			this.app = document as jQuerySample;
+			app.addEventListener("viewChanged", viewChangeHandler);
+		}
+		
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b0367dde/examples/FlexJSTest_jquery/src/jQuerySample.mxml
----------------------------------------------------------------------
diff --git a/examples/FlexJSTest_jquery/src/jQuerySample.mxml b/examples/FlexJSTest_jquery/src/jQuerySample.mxml
new file mode 100644
index 0000000..100e24b
--- /dev/null
+++ b/examples/FlexJSTest_jquery/src/jQuerySample.mxml
@@ -0,0 +1,64 @@
+<?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:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
+				   xmlns:local="*"
+				   xmlns:basic="library://ns.apache.org/flexjs/basic"
+				   xmlns:jquery="library://ns.apache.org/flexjs/jquery"
+				   xmlns:models="models.*" 
+				   xmlns:controllers="controllers.*"
+				   initialize="MyModel(model).labelText='Hello World'" 
+				   >
+	
+	<!--
+	To make this sample work, please add the following lines to the index.html
+	
+	<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css"
/>
+	<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
+	<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
+	-->
+	
+	
+	<basic:valuesImpl>
+		<basic:SimpleCSSValuesImpl />
+	</basic:valuesImpl>
+	<basic:initialView>
+		<local:MyInitialView />
+	</basic:initialView>
+	<basic:model>
+		<models:MyModel />
+	</basic:model>
+	<basic:controller>
+		<controllers:MyController />
+	</basic:controller>
+	<basic:beads>
+		<basic:HTTPService id="service">
+			<basic:LazyCollection id="collection">
+				<basic:inputParser>
+					<basic:JSONInputParser />
+				</basic:inputParser>
+				<basic:itemConverter>
+					<local:StockDataJSONItemConverter />
+				</basic:itemConverter> 
+			</basic:LazyCollection>
+		</basic:HTTPService>
+	</basic:beads>
+	
+</basic:Application>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b0367dde/examples/FlexJSTest_jquery/src/models/MyModel.as
----------------------------------------------------------------------
diff --git a/examples/FlexJSTest_jquery/src/models/MyModel.as b/examples/FlexJSTest_jquery/src/models/MyModel.as
new file mode 100644
index 0000000..1dc23e6
--- /dev/null
+++ b/examples/FlexJSTest_jquery/src/models/MyModel.as
@@ -0,0 +1,59 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 models
+{
+	import org.apache.flex.events.Event;
+	import org.apache.flex.events.EventDispatcher;
+	
+	public class MyModel extends EventDispatcher
+	{
+		public function MyModel()
+		{
+		}
+		
+		private var _labelText:String;
+		
+		public function get labelText():String
+		{
+			return _labelText;
+		}
+		
+		public function set labelText(value:String):void
+		{
+			if (value != _labelText)
+			{
+				_labelText = value;
+				dispatchEvent(new Event("labelTextChanged"));
+			}
+		}
+        
+        private var _strings:Array = ["AAPL", "ADBE", "GOOG", "MSFT", "YHOO"];
+        public function get strings():Array
+        {
+            return _strings;
+        }
+		
+		private var _cities:Array = ["London", "Miami", "Paris", "Sydney", "Tokyo"];
+		public function get cities():Array
+		{
+			return _cities;
+		}
+
+	}
+}
\ No newline at end of file


Mime
View raw message