incubator-flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erikdebr...@apache.org
Subject svn commit: r1376607 - in /incubator/flex/utilities/trunk: common/src/assets/images/ common/src/org/apache/flex/utilities/common/ installerBadge/ installerBadge/html-template/ installerBadge/src/ installerBadge/src/org/apache/flex/installApacheFlexBadg...
Date Thu, 23 Aug 2012 17:31:33 GMT
Author: erikdebruin
Date: Thu Aug 23 17:31:32 2012
New Revision: 1376607

URL: http://svn.apache.org/viewvc?rev=1376607&view=rev
Log:
- added a conditional to check if the badge is running on the same domain as where the config.xml
is hosted; if not, the app will use PHP/cURL to get at that XML file, to avoid sandboxing
issues;
- introduced 2 sizes of the badge, so the embedding page (using an iframe) can decide how
to present the app: regular or small (check README for instructions on how to embed);

Added:
    incubator/flex/utilities/trunk/common/src/assets/images/logoSmall.png   (with props)
    incubator/flex/utilities/trunk/installerBadge/README
    incubator/flex/utilities/trunk/installerBadge/html-template/badgeConfigService.php
      - copied unchanged from r1376072, incubator/flex/utilities/trunk/installerBadge/html-template/service.php
Modified:
    incubator/flex/utilities/trunk/common/src/org/apache/flex/utilities/common/InternetUtil.as
    incubator/flex/utilities/trunk/installerBadge/html-template/index.template.html
    incubator/flex/utilities/trunk/installerBadge/src/InstallApacheFlexBadge.mxml
    incubator/flex/utilities/trunk/installerBadge/src/org/apache/flex/installApacheFlexBadge/resources/EmbeddedMedia.as

Added: incubator/flex/utilities/trunk/common/src/assets/images/logoSmall.png
URL: http://svn.apache.org/viewvc/incubator/flex/utilities/trunk/common/src/assets/images/logoSmall.png?rev=1376607&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/flex/utilities/trunk/common/src/assets/images/logoSmall.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: incubator/flex/utilities/trunk/common/src/org/apache/flex/utilities/common/InternetUtil.as
URL: http://svn.apache.org/viewvc/incubator/flex/utilities/trunk/common/src/org/apache/flex/utilities/common/InternetUtil.as?rev=1376607&r1=1376606&r2=1376607&view=diff
==============================================================================
--- incubator/flex/utilities/trunk/common/src/org/apache/flex/utilities/common/InternetUtil.as
(original)
+++ incubator/flex/utilities/trunk/common/src/org/apache/flex/utilities/common/InternetUtil.as
Thu Aug 23 17:31:32 2012
@@ -51,6 +51,31 @@ public class InternetUtil
 	
 	//--------------------------------------------------------------------------
 	//
+	//    Class methods
+	//
+	//--------------------------------------------------------------------------
+	
+	//----------------------------------
+	//    getTLDFromURL
+	//----------------------------------
+	
+	public static function getTLDFromURL(url:String):String
+	{
+		var array:Array;
+		
+		var result:String = url;
+		
+		if (result.indexOf(Constants.URL_PREFIX) > -1)
+			result = result.split("/")[2];
+
+		array = result.split(".");
+		array.shift();
+
+		return array.join(".");;
+	}
+	
+	//--------------------------------------------------------------------------
+	//
 	//    Constructor
 	//
 	//--------------------------------------------------------------------------
@@ -132,7 +157,7 @@ public class InternetUtil
 	//    fetch
 	//----------------------------------
 	
-	public function fetch(fetchURL:String, fetchCompleteHandler:Function):void
+	public function fetch(fetchURL:String, fetchCompleteHandler:Function, args:String = null):void
 	{
 		_callback = fetchCompleteHandler;
 		
@@ -144,7 +169,7 @@ public class InternetUtil
 		_urlLoader.dataFormat = URLLoaderDataFormat.TEXT;
 		_urlLoader.addEventListener(Event.COMPLETE, fetchResultHandler);
 		_urlLoader.addEventListener(IOErrorEvent.IO_ERROR, fetchResultHandler);
-		_urlLoader.load(new URLRequest(fetchURL));
+		_urlLoader.load(new URLRequest(fetchURL + ((args) ? "?" + args : "")));
 	}
 	
 }

Added: incubator/flex/utilities/trunk/installerBadge/README
URL: http://svn.apache.org/viewvc/incubator/flex/utilities/trunk/installerBadge/README?rev=1376607&view=auto
==============================================================================
--- incubator/flex/utilities/trunk/installerBadge/README (added)
+++ incubator/flex/utilities/trunk/installerBadge/README Thu Aug 23 17:31:32 2012
@@ -0,0 +1,7 @@
+The code implements functionality to be viewed through an iframe on another domain. Please
use one of these to embed the badge on your site or communications:
+
+Regular size (302 x 302)
+<iframe name="afSDKInstallBadgeRegular" src="[domain + path to]/InstallApacheFlexBadge.html"
frameborder="0" height="302" marginheight="0" marginwidth="0" scrolling="no" width="302"></iframe>
+
+Small size (402 x 84)
+<iframe name="afSDKInstallBadgeSmall" src="[domain + path to]/InstallApacheFlexBadge.html"
frameborder="0" height="84" marginheight="0" marginwidth="0" scrolling="no" width="402"></iframe>
\ No newline at end of file

Modified: incubator/flex/utilities/trunk/installerBadge/html-template/index.template.html
URL: http://svn.apache.org/viewvc/incubator/flex/utilities/trunk/installerBadge/html-template/index.template.html?rev=1376607&r1=1376606&r2=1376607&view=diff
==============================================================================
--- incubator/flex/utilities/trunk/installerBadge/html-template/index.template.html (original)
+++ incubator/flex/utilities/trunk/installerBadge/html-template/index.template.html Thu Aug
23 17:31:32 2012
@@ -14,84 +14,78 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> 
-<head>
 
-    <title>${title}</title>
+<!DOCTYPE html>
 
-    <meta name="google" value="notranslate" />         
+<html> 
+<head>
+    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 
-    <style type="text/css" media="screen"> 
-        html, body { height: 100%; }
-        body { background-color: ${bgcolor}; margin: 0; overflow: auto;  padding: 0; text-align:
center; }   
+    <title>${title}</title>
+    
+    <style type="text/css"> 
+        body { margin: 0; padding: 0; }   
         object:focus { outline: none; }
         #flashContent { display: none; }
+        #${application} { border: 1px solid #172647; }
     </style>
     
     <!-- 
         SWFObject v2.2 <http://code.google.com/p/swfobject/> 
         is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>

     -->
-    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
+    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
+    
     <script type="text/javascript">
-        var swfVersionStr = "${version_major}.${version_minor}.${version_revision}";
-        var xiSwfUrlStr = "";
-        var flashvars = {};
-        var params = {};
-        params.quality = "high";
-        params.bgcolor = "${bgcolor}";
-        params.allowscriptaccess = "sameDomain";
-        params.allowfullscreen = "true";
-        var attributes = {};
-        attributes.id = "${application}";
-        attributes.name = "${application}";
-        attributes.align = "middle";
-        swfobject.embedSWF("${swf}.swf", "flashContent", "${width}", "${height}", swfVersionStr,
xiSwfUrlStr, flashvars, params, attributes);
-        swfobject.createCSS("#flashContent", "display: block; text-align: left;");
+        /* use strict */
+        
+        var swfVersionStr, params, attributes;
+        
+        function displayType() {
+            if ((window.top != window.self) && window.parent)
+                return window.name;
+                
+            return "";
+        }
+        
+        function init() {
+            var prefix, theElement, theHeight, theWidth, widget;
+            
+    		if (typeof window.innerWidth === 'number') {
+    			theHeight = window.innerHeight;
+    			theWidth = window.innerWidth;
+    		} else {
+        		theElement = window.document.documentElement;
+
+    			theHeight = theElement.clientHeight;
+    			theWidth = theElement.clientWidth;
+    		}
+
+            widget = document.getElementById("${application}");
+            widget.style.height = (theHeight - 2) + "px";
+            widget.style.width = (theWidth - 2) + "px";
+        }
+        
+        swfVersionStr = "${version_major}.${version_minor}.${version_revision}";
+        params = { quality: "high", bgcolor: "${bgcolor}", allowscriptaccess: "sameDomain",
+            allowfullscreen: "true" };
+        attributes = { id: "${application}", name: "${application}" };
+        
+        swfobject.embedSWF("${swf}.swf", "flashContent", "0", "0", 
+            swfVersionStr, "", {}, params, attributes);
+        
+        swfobject.createCSS("#flashContent", "display: block;");
     </script>
+    
 </head>
-<body>
+<body onload="init();">
     <div id="flashContent">
-        <p>
-            To view this page ensure that Adobe Flash Player version 
-            ${version_major}.${version_minor}.${version_revision} or greater is installed.

-        </p>
         <script type="text/javascript"> 
             var pageHost = ((document.location.protocol == "https:") ? "https://" : "http://");

             document.write("<a href='http://www.adobe.com/go/getflashplayer'><img
src='" 
                             + pageHost + "www.adobe.com/images/shared/download_buttons/get_flash_player.gif'
alt='Get Adobe Flash player' /></a>" ); 
         </script> 
     </div>
-    
-    <noscript>
-        <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="${width}"
height="${height}" id="${application}">
-            <param name="movie" value="${swf}.swf" />
-            <param name="quality" value="high" />
-            <param name="bgcolor" value="${bgcolor}" />
-            <param name="allowScriptAccess" value="sameDomain" />
-            <param name="allowFullScreen" value="true" />
-            <!--[if !IE]>-->
-            <object type="application/x-shockwave-flash" data="${swf}.swf" width="${width}"
height="${height}">
-                <param name="quality" value="high" />
-                <param name="bgcolor" value="${bgcolor}" />
-                <param name="allowScriptAccess" value="sameDomain" />
-                <param name="allowFullScreen" value="true" />
-            <!--<![endif]-->
-            <!--[if gte IE 6]>-->
-                <p> 
-                    Either scripts and active content are not permitted to run or Adobe Flash
Player version
-                    ${version_major}.${version_minor}.${version_revision} or greater is not
installed.
-                </p>
-            <!--<![endif]-->
-                <a href="http://www.adobe.com/go/getflashplayer">
-                    <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif"
alt="Get Adobe Flash Player" />
-                </a>
-            <!--[if !IE]>-->
-            </object>
-            <!--<![endif]-->
-        </object>
-    </noscript>     
 </body>
 </html>

Modified: incubator/flex/utilities/trunk/installerBadge/src/InstallApacheFlexBadge.mxml
URL: http://svn.apache.org/viewvc/incubator/flex/utilities/trunk/installerBadge/src/InstallApacheFlexBadge.mxml?rev=1376607&r1=1376606&r2=1376607&view=diff
==============================================================================
--- incubator/flex/utilities/trunk/installerBadge/src/InstallApacheFlexBadge.mxml (original)
+++ incubator/flex/utilities/trunk/installerBadge/src/InstallApacheFlexBadge.mxml Thu Aug
23 17:31:32 2012
@@ -22,8 +22,6 @@ limitations under the License.
 			   xmlns:s="library://ns.adobe.com/flex/spark" 
 			   xmlns:mx="library://ns.adobe.com/flex/mx" 
 			   xmlns:components="org.apache.flex.installApacheFlexBadge.components.*"
-			   height="300"
-			   width="300" 
 			   creationComplete="creationCompleteHandler(event)">
 	
 	<fx:Style source="/assets/styles/ApacheFlexToolsStyle.css" />
@@ -31,6 +29,7 @@ limitations under the License.
 	<fx:Script><![CDATA[
 		
 		import mx.controls.Alert;
+		import mx.core.FlexGlobals;
 		import mx.events.FlexEvent;
 		
 		import org.apache.flex.installApacheFlexBadge.resources.EmbeddedMedia;
@@ -47,6 +46,12 @@ limitations under the License.
 		//
 		//----------------------------------------------------------------------
 		
+		private const DIMENSION_HEIGHT_REGULAR:int = 300;
+		private const DIMENSION_HEIGHT_SMALL:int = 82;
+		
+		private const DIMENSION_WIDTH_REGULAR:int = 300;
+		private const DIMENSION_WIDTH_SMALL:int = 400;
+		
 		private const INFO_DISCLAIMER_XML:XML = 
 			<TextFlow xmlns="http://ns.adobe.com/textLayout/2008" fontFamily="openSansSemiBold">
 				<p>
@@ -130,10 +135,48 @@ limitations under the License.
 		
 		private function creationCompleteHandler(event:FlexEvent):void
 		{
+			var displayType:String = ExternalInterface.call("displayType"); 
+			
+			var newStateName:String;
+			switch (displayType)
+			{
+				case "afSDKInstallBadgeSmall" :
+				{
+					newStateName = "small";
+					
+					break;
+				}
+					
+				case "afSDKInstallBadgeRegular" :
+				default :
+				{
+					newStateName = "regular";
+					
+					break;
+				}
+			}
+			currentState = newStateName;
+			
 			_internetUtil = InternetUtil.instance;
 			
-			_internetUtil.fetch(
-				Constants.APACHE_FLEX_URL + Constants.CONFIG_XML_NAME, internetFetchResultHandler);
+			var localDomain:String = InternetUtil.getTLDFromURL(
+				ExternalInterface.call("function () { return window.location.hostname; }"));
+			
+			var remoteDomain:String = InternetUtil.getTLDFromURL(Constants.APACHE_FLEX_URL);
+
+			var url:String = Constants.APACHE_FLEX_URL + Constants.CONFIG_XML_NAME;
+			if (localDomain == remoteDomain)
+			{
+				_internetUtil.fetch(url, internetFetchResultHandler);
+			}
+			else
+			{
+				/*
+					Using a simple webservice (PHP + cUrl) to bypass cross domain
+					and security sandbox restrictions while developing.
+				*/
+				_internetUtil.fetch("badgeConfigService.php", internetFetchResultHandler, "url=" + escape(url));
+			}
 		}
 		
 		//----------------------------------
@@ -198,77 +241,94 @@ limitations under the License.
 	<fx:Declarations /> 
 	
 	<s:states>
-		<s:State name="normal" />
+		<s:State name="regular" />
+		<s:State name="small" />
 		<s:State name="disclaimerState" />
 	</s:states>
 
 	<s:Image id="imgBackground" source="{EmbeddedMedia.background}"
-			 height="300" width="300" />
+			 height="{DIMENSION_WIDTH_REGULAR + 10}" height.small="{DIMENSION_WIDTH_SMALL + 10}"
+			 width="{DIMENSION_WIDTH_REGULAR + 10}" width.small="{DIMENSION_WIDTH_SMALL + 10}"
+			 left="-5" top="-5"/>
 	
 	<s:Image id="imgLogo" source="{EmbeddedMedia.logo}"
 			 height="165" width="164"
 			 top="10"
-			 horizontalCenter="0" />
+			 horizontalCenter="0"
+			 includeIn="regular" />
 	
-	<s:Image id="imgHeader" source="{EmbeddedMedia.header}"
-			 height="37" width="136"
-			 top="185"
-			 left="75" />
-	
-	<s:Label text="{_sdkVersionString}"
-			 fontFamily="openSansBold"
-			 color="0x162545" fontSize="32"
-			 trackingLeft="-1" trackingRight="-1"
-			 width="137"
-			 left="163" top="194" />
+	<s:Image id="imgLogoSmall" source="{EmbeddedMedia.logoSmall}"
+			 height="72" width="72"
+			 left="5" top="5"
+			 includeIn="small" />
+	
+	<s:Group height="37" width="250"
+			 left="75" left.small="95"
+			 top.regular="185" top.small="15">
+		<s:Image id="imgHeader" source="{EmbeddedMedia.header}" />
+		
+		<s:Label text="{_sdkVersionString}"
+				 fontFamily="openSansBold"
+				 color="0x162545" fontSize="32"
+				 trackingLeft="-1" trackingRight="-1"
+				 left="87" top="9" />		
+	</s:Group>
 	
 	<s:Label text="{INFO_FOR_IDE}"
 			 width="190"
-			 left="25" top="235"
+			 left="25" left.small="228"
+			 top="235" top.small="17"
 			 color="0x162545" 
 			 fontFamily="openSansSemibold" fontSize="13"
 			 textAlign="center" />
 	
 	<s:Label text="{LABEL_DISCLAIMER}"
 			 width="60"
-			 left="190" top="236"
+			 left="190" left.small="140"
+			 top="236" top.small="60"
 			 color="0x717C91"
 			 fontFamily="openSansLightItalic" fontSize="11"
 			 textAlign="center"
 			 buttonMode="true"
-			 click="{currentState = 'disclaimerState'}" />
+			 click="{grpDisclaimer.visible = true;}" />
 	
 	<s:Button id="btnDownload" label="{LABEL_DOWNLOAD}"
-			  bottom="10"
-			  enabled="false"
 			  height="30"
-			  horizontalCenter="0"
+			  bottom="10" bottom.small="12"
+			  right.small="27"
+			  horizontalCenter.regular="0"
+			  enabled="false"
 			  buttonMode="true"
 			  useHandCursor="true"
 			  click="btnDownload_clickHandler(event)"
 			  styleName="mainBtnStyle"/>
 
-	<s:Graphic visible.normal="false">    
-		<s:Rect width="300" height="300">
-			<s:fill>
-				<s:SolidColor color="0x000000" alpha="0.5"/>
-			</s:fill>
-		</s:Rect>
-	</s:Graphic>
-	
-	<s:Button id="btnBack" label="{LABEL_BACK}"
-			  height="15"
-			  right="15" top="10"
-			  fontSize="10"
-			  buttonMode="true"
-			  click="{currentState = 'normal'}"
-			  visible.normal="false"
-			  styleName="genericBtnStyle"/>
-	
-	<s:TextArea id="disclaimerTxtArea"
-				bottom="10" left="10" right="10" top="25"
-				fontFamily="openSansSemibold"
-				editable="false"
-				textFlow="{TextFlowUtil.importFromXML(INFO_DISCLAIMER_XML)}"
-				visible.normal="false" />
+	<s:Group id="grpDisclaimer"
+			 height="{DIMENSION_HEIGHT_REGULAR}" height.small="{DIMENSION_HEIGHT_SMALL}"
+			 width="{DIMENSION_WIDTH_REGULAR}" width.small="{DIMENSION_WIDTH_SMALL}"
+			 visible="false">
+		<s:Graphic>    
+			<s:Rect height="{DIMENSION_HEIGHT_REGULAR}"
+					width="{DIMENSION_WIDTH_SMALL}">
+				<s:fill>
+					<s:SolidColor color="0x000000" alpha="0.5"/>
+				</s:fill>
+			</s:Rect>
+		</s:Graphic>
+		
+		<s:Button id="btnBack" label="{LABEL_BACK}"
+				  height="15"
+				  right="15" top="10"
+				  fontSize="10"
+				  buttonMode="true"
+				  click="{grpDisclaimer.visible = false;}"
+				  styleName="genericBtnStyle"/>
+		
+		<s:TextArea id="disclaimerTxtArea"
+					bottom="10" left="10" right="10" top="25"
+					fontFamily="openSansSemibold"
+					editable="false"
+					textFlow="{TextFlowUtil.importFromXML(INFO_DISCLAIMER_XML)}" />
+	</s:Group>
+	
 </s:Application>
\ No newline at end of file

Modified: incubator/flex/utilities/trunk/installerBadge/src/org/apache/flex/installApacheFlexBadge/resources/EmbeddedMedia.as
URL: http://svn.apache.org/viewvc/incubator/flex/utilities/trunk/installerBadge/src/org/apache/flex/installApacheFlexBadge/resources/EmbeddedMedia.as?rev=1376607&r1=1376606&r2=1376607&view=diff
==============================================================================
--- incubator/flex/utilities/trunk/installerBadge/src/org/apache/flex/installApacheFlexBadge/resources/EmbeddedMedia.as
(original)
+++ incubator/flex/utilities/trunk/installerBadge/src/org/apache/flex/installApacheFlexBadge/resources/EmbeddedMedia.as
Thu Aug 23 17:31:32 2012
@@ -52,6 +52,14 @@ public final class EmbeddedMedia
 	[Bindable]
 	public static var logo:Class;
 	
+	//----------------------------------
+	//    imageLogo
+	//----------------------------------
+	
+	[Embed(source="/assets/images/logoSmall.png")]
+	[Bindable]
+	public static var logoSmall:Class;
+	
 	//--------------------------------------------------------------------------
 	//
 	//    Constructor



Mime
View raw message