r3201 committed - [No log message]
Revision: 3201
Author: gilles0181
Date: Tue Sep 8 03:26:47 2009
Log: [No log message]
http://code.google.com/p/jquery-ui/source/detail?r=3201
Added:
/branches/labs/uploader
/branches/labs/uploader/_src
/branches/labs/uploader/_src/as3
/branches/labs/uploader/_src/as3/obj
/branches/labs/uploader/_src/as3/obj/ui.fileuploaderConfig.xml
/branches/labs/uploader/_src/as3/src
/branches/labs/uploader/_src/as3/src/com
/branches/labs/uploader/_src/as3/src/com/webunity
/branches/labs/uploader/_src/as3/src/com/webunity/FileTimer.as
/branches/labs/uploader/_src/as3/src/com/webunity/ScriptAdapter.as
/branches/labs/uploader/_src/as3/src/com/webunity/jQuery
/branches/labs/uploader/_src/as3/src/com/webunity/jQuery/BlackBird.as
/branches/labs/uploader/_src/as3/src/fileuploader.as
/branches/labs/uploader/_src/as3/ui.fileuploader.as3proj
/branches/labs/uploader/htdocs
/branches/labs/uploader/htdocs/_init.php
/branches/labs/uploader/htdocs/backend.php
/branches/labs/uploader/htdocs/css
/branches/labs/uploader/htdocs/css/img
/branches/labs/uploader/htdocs/css/img/bgUpload.gif
/branches/labs/uploader/htdocs/css/img/bgUploadActive.gif
/branches/labs/uploader/htdocs/css/img/btnBrowse.png
/branches/labs/uploader/htdocs/css/img/btnClear.png
/branches/labs/uploader/htdocs/css/img/btnUpload.png
/branches/labs/uploader/htdocs/css/img/png.zip
/branches/labs/uploader/htdocs/css/img/uploadCancel.gif
/branches/labs/uploader/htdocs/css/img/uploadDelete.gif
/branches/labs/uploader/htdocs/css/img/uploadError.gif
/branches/labs/uploader/htdocs/css/img/uploadFailed.gif
/branches/labs/uploader/htdocs/css/img/uploadRetry.gif
/branches/labs/uploader/htdocs/css/img/uploadStart.gif
/branches/labs/uploader/htdocs/css/img/uploadSuccess.gif
/branches/labs/uploader/htdocs/css/style.css
/branches/labs/uploader/htdocs/img
/branches/labs/uploader/htdocs/img/buttonSkin.png
/branches/labs/uploader/htdocs/index.php
/branches/labs/uploader/htdocs/js
/branches/labs/uploader/htdocs/js/blackbirdjs
/branches/labs/uploader/htdocs/js/blackbirdjs/blackbird.css
/branches/labs/uploader/htdocs/js/blackbirdjs/blackbird.js
/branches/labs/uploader/htdocs/js/blackbirdjs/blackbird_icons.png
/branches/labs/uploader/htdocs/js/blackbirdjs/blackbird_panel.png
/branches/labs/uploader/htdocs/js/script.js
/branches/labs/uploader/htdocs/js/ui.fileuploader
/branches/labs/uploader/htdocs/js/ui.fileuploader/ui.fileuploader-assets.js
/branches/labs/uploader/htdocs/js/ui.fileuploader/ui.fileuploader.js
/branches/labs/uploader/htdocs/js/ui.fileuploader/ui.fileuploader.swf
/branches/labs/uploader/htdocs/ui.uploader.log
/branches/labs/uploader/readme.txt
=======================================
--- /dev/null
+++ /branches/labs/uploader/_src/as3/obj/ui.fileuploaderConfig.xml Tue Sep
8 03:26:47 2009
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--This file was generated by a FDBuild.-->
+<!--Any modifications you make may be lost.-->
+<flex-config>
+ <compiler>
+ <source-path append="true">
+
<path-element>C:\xampplite\htdocs\js\jquery-ui\ui.fileuploader\_src\as3\src</path-element>
+ <path-element>C:\Program
Files\FlashDevelop\Library\AS3\classes</path-element>
+ </source-path>
+ <library-path append="true" />
+ </compiler>
+ <file-specs>
+
<path-element>C:\xampplite\htdocs\js\jquery-ui\ui.fileuploader\_src\as3\src\fileuploader.as</path-element>
+ </file-specs>
+ <default-background-color>#FFFFFF</default-background-color>
+ <default-frame-rate>30</default-frame-rate>
+ <default-size>
+ <width>1</width>
+ <height>1</height>
+ </default-size>
+</flex-config>
=======================================
--- /dev/null
+++ /branches/labs/uploader/_src/as3/src/com/webunity/FileTimer.as Tue Sep
8 03:26:47 2009
@@ -0,0 +1,39 @@
+package com.webunity
+{
+ import flash.events.*;
+ import flash.utils.Timer;
+
+ /**
+ * Custom timer class with extended properties.
+ */
+ public class FileTimer extends Timer {
+ private var _fileID:String;
+
+ /**
+ * Constructor
+ * @param delay
+ * @param repeatCount
+ */
+ public function FileTimer(delay:Number, repeatCount:int=0) {
+ super(delay, repeatCount);
+ _fileID = "";
+ }
+
+ /**
+ * fileID parameter: getter
+ * @return string
+ */
+ public function get fileID():String {
+ return _fileID;
+ }
+
+ /**
+ * fileID parameter: setter
+ * @param value string
+ */
+ public function set fileID(value:String):void {
+ _fileID = value;
+ }
+ }
+}
+
=======================================
--- /dev/null
+++ /branches/labs/uploader/_src/as3/src/com/webunity/ScriptAdapter.as Tue
Sep 8 03:26:47 2009
@@ -0,0 +1,377 @@
+package com.webunity
+{
+ //
+ // Webunity imports
+ import com.webunity.jQuery.BlackBird;
+
+ //
+ // Flash imports
+ import flash.accessibility.AccessibilityProperties;
+
+ import flash.display.DisplayObject;
+ import flash.display.Sprite;
+ import flash.display.StageAlign;
+ import flash.display.StageScaleMode;
+
+ import flash.errors.IOError;
+
+ import flash.events.Event;
+ import flash.events.TimerEvent;
+
+ import flash.external.ExternalInterface;
+
+ import flash.system.Security;
+ import flash.system.Capabilities;
+
+ import flash.text.TextField;
+ import flash.text.TextFieldAutoSize;
+ import flash.text.TextFormat;
+
+ import flash.utils.Timer;
+
+
+ /**
+ * Scriptadapter class
+ */
+ public class ScriptAdapter extends Sprite {
+ private var _component:DisplayObject;
+ private var _errorText:TextField;
+ private var _altText:String;
+ private var logging:Boolean;
+ private var elementID:String;
+ private var javaScriptEventHandler:String;
+
+ /**
+ * Constructor
+ */
+ public function ScriptAdapter() {
+ super();
+
+ this._errorText = new TextField();
+ this._errorText.defaultTextFormat = new TextFormat("_sans", 10,
0xff0000);
+ this._errorText.wordWrap = true;
+ this._errorText.autoSize = TextFieldAutoSize.LEFT;
+ this._errorText.selectable = false;
+ this._errorText.mouseEnabled = false;
+ this.addChild(this._errorText);
+
+ this.addEventListener(Event.ADDED, addedHandler);
+
+ if (ExternalInterface.available) {
+ //
+ // Used to prevent "... is unavailable"
+ var myTimer:Timer = new Timer(50, 1);
+ myTimer.addEventListener(TimerEvent.TIMER, initScriptAdapter);
+ myTimer.start();
+
+ } else {
+ throw new IOError("jQuery.uploader.swf cannot communicate with
JavaScript.");
+ }
+ }
+
+
//----------------------------------------------------------------------------------------------------
+ // Protected functions
+
//----------------------------------------------------------------------------------------------------
+
+ private function initScriptAdapter(e:TimerEvent):void {
+ if (stage) {
+ this.stage.addEventListener(Event.RESIZE, stageResizeHandler);
+ this.stage.scaleMode = StageScaleMode.NO_SCALE;
+ this.stage.align = StageAlign.TOP_LEFT;
+ init();
+ } else {
+ addEventListener(Event.ADDED_TO_STAGE, init);
+ }
+ }
+
+ /**
+ * Returns the component
+ */
+ protected function get component():DisplayObject {
+ return this._component;
+ }
+
+ /**
+ * Sets the component
+ */
+ protected function set component(value:DisplayObject):void {
+ this._component = value;
+ this.refreshComponentSize();
+ }
+
+ /**
+ * Initializes the component and enables communication with JavaScript
+ */
+ protected function init(e:Event = null):void {
+ removeEventListener(Event.ADDED_TO_STAGE, init);
+
+ //
+ // Add correct domains
+ Security.allowDomain(this.loaderInfo.parameters.alloweddomain || "*");
+
+ //
+ // Initialize base properties
+ this.elementID = this.loaderInfo.parameters.elementid;
+ this.javaScriptEventHandler = this.loaderInfo.parameters.eventhandler;
+ this.setLogging(this.loaderInfo.parameters.logging);
+
+ try {
+ ExternalInterface.addCallback("getAltText", getAltText);
+ ExternalInterface.addCallback("setAltText", setAltText);
+ } catch(error:SecurityError) {
+ //do nothing. it will be caught somewhere else.
+ }
+ }
+
+ /**
+ * Shows a fatal error to the browser
+ * @param message
+ */
+ protected function showFatalError(message:Object):void {
+ if (!message)
+ message = "";
+
+ if (this._errorText) {
+ this._errorText.appendText(message.toString());
+ this._errorText.scrollV = this._errorText.maxScrollV;
+ this._errorText.mouseEnabled = true;
+ this._errorText.selectable = true;
+ }
+ }
+
+ /**
+ * Sets a flag allowing logging yes or no?
+ *
+ * @param allow Whether to allow logging
+ */
+ protected function setLogging(allow:String): void {
+ logging = (allow === "1") ? true : false;
+
+ //show error popups
+ try {
+ ExternalInterface.marshallExceptions = logging ;
+ } catch(error:Error) {
+ //do nothing, we're in a flash player that properly displays exceptions
+ }
+ }
+
+ /**
+ * Dispatches an event object to the JavaScript wrapper element.
+ */
+ protected function dispatchEventToJavaScript(event:Object):void {
+ try {
+ ExternalInterface.call(javaScriptEventHandler, elementID,
EscapeMessage(event));
+ } catch(error:SecurityError) {
+ }
+ }
+
+ /**
+ * Sends a log message to the ScriptAdapter Logger.
+ */
+ protected function logToBrowser(message:String, category:String =
BlackBird.INFO):void {
+ if (logging == false) {
+ return;
+ }
+
+ //
+ // Log to Flash
+ if (stage)
+ trace(message);
+
+ //
+ // Log to the browser
+ try {
+ ExternalInterface.call(category, EscapeMessage(message));
+ } catch(error:Error) {
+ }
+ }
+
+ /**
+ * The size of the SWF/stage is dependant on the container it is in.
+ * The visual component will resize to match the stage size.
+ */
+ protected function stageResizeHandler(event:Event):void {
+ this.refreshComponentSize();
+
+ if(this._errorText) {
+ this._errorText.width = this.stage.stageWidth;
+ this._errorText.height = this.stage.stageHeight;
+ }
+
+ logToBrowser("resize (width: " + this.stage.stageWidth + ", height: " +
this.stage.stageHeight + ")");
+ }
+
+ /**
+ * Refreshes the component size
+ */
+ protected function refreshComponentSize():void {
+ if (this.component) {
+ this.component.x = this.component.y = 0;
+ this.component.width = this.stage.stageWidth;
+ this.component.height = this.stage.stageHeight;
+ }
+ }
+
+ /**
+ * Ensures that errorText is always on top!
+ */
+ protected function addedHandler(event:Event):void {
+ this.setChildIndex(this._errorText, this.numChildren - 1);
+ }
+
+
//----------------------------------------------------------------------------------------------------
+ // Private functions
+
//----------------------------------------------------------------------------------------------------
+
+ /**
+ * Helper function which escapes a string
+ * @param message
+ */
+ public static function EscapeString(message:String):String {
+ var replacePattern:RegExp = /\\/g; //new RegExp("/\\/", "g");
+ return message.replace(replacePattern, "\\\\");
+ }
+
+ /**
+ * Helper function which escapes an array
+ * @param message
+ */
+ public static function EscapeArray(message_array:Array):Array {
+ var length:uint = message_array.length;
+ var i:uint = 0;
+ for (i; i < length; i++) {
+ message_array[i] = EscapeMessage(message_array[i]);
+ }
+ return message_array;
+ }
+
+ /**
+ * Helper function which escapes an object
+ * @param message
+ */
+ public static function EscapeObject(message_obj:Object):Object {
+ for (var name:String in message_obj) {
+ message_obj[name] = EscapeMessage(message_obj[name]);
+ }
+ return message_obj;
+ }
+
+
//----------------------------------------------------------------------------------------------------
+ // Public functions
+
//----------------------------------------------------------------------------------------------------
+
+ /**
+ * Gets the alternative text for assistive technology.
+ */
+ public function getAltText():String {
+ return this._altText;
+ }
+
+ /**
+ * Sets the alternative text for assistive technology.
+ */
+ public function setAltText(value:String):void {
+ this._altText = value;
+ var accProps:AccessibilityProperties = new AccessibilityProperties();
+ accProps.name = this._altText;
+ accProps.forceSimple = true;
+ accProps.noAutoLabeling = true;
+ this.component.accessibilityProperties = accProps;
+ }
+
+ /**
+ * Gets the player’s version by using the flash.system.Capabilities
class.
+ */
+ public function checkFlashVersion(major:int = 9, minor:int = 0,
build:int = 44):Object {
+ var versionArray:Array = Capabilities.version.split(",");
+ var platformAndVersion:Array = versionArray[0].split(" ");
+ var flashVersion:Object = {
+ correct: false,
+ os: platformAndVersion[0],
+ major: parseInt(platformAndVersion[1]),
+ minor: parseInt(versionArray[1]),
+ build: parseInt(versionArray[2])
+ };
+
+ //
+ // Version compare
+ if (flashVersion.major > major) {
+ flashVersion.correct = true;
+ } else if (flashVersion.major == major) {
+ if (flashVersion.minor > minor) {
+ flashVersion.correct = true;
+ } else if (flashVersion.minor == minor) {
+ flashVersion.correct = (flashVersion.build >= build);
+ }
+ }
+
+ //
+ // Result
+ return flashVersion;
+ }
+
+ /**
+ * Tests to see if a value exists in an array
+ *
+ * @param input The array to search in
+ * @param test The value to search for
+ * @return
+ */
+ public function arrayContains(input:Array, test:String):Boolean {
+ var intFound:Number = 0;
+ var intCurrent:Number = 0;
+ var intCount:Number = input.length;
+
+ for(intCurrent=0; intCurrent<intCount; intCurrent++) {
+ if (input[intCurrent] == test) {
+ intFound++;
+ }
+ }
+ return (intFound > 0);
+ }
+
+ /**
+ * Determines whether an object is equivalent to an empty string
+ */
+ public function isEmptyString(toCheck:*):Boolean {
+ return ((toCheck == "null") || (toCheck == "") || (toCheck == null));
+ }
+
+ /* Escapes all the backslashes which are not translated correctly in the
Flash -> JavaScript Interface
+ *
+ * These functions had to be developed because the ExternalInterface has
a bug that simply places the
+ * value a string in quotes (except for a " which is escaped) in a
JavaScript string literal which
+ * is executed by the browser. These often results in improperly
escaped string literals if your
+ * input string has any backslash characters. For example the string:
+ * "c:\Program Files\uploadtools\"
+ * is placed in a string literal (with quotes escaped) and becomes:
+ * var __flash__temp = "\"c:\Program Files\uploadtools\\"";
+ * This statement will cause errors when executed by the JavaScript
interpreter:
+ * 1) The first \" is succesfully transformed to a "
+ * 2) \P is translated to P and the \ is lost
+ * 3) \u is interpreted as a unicode character and causes an error in IE
+ * 4) \\ is translated to \
+ * 5) leaving an unescaped " which causes an error
+ *
+ * I fixed this by escaping \ characters in all outgoing strings. The
above escaped string becomes:
+ * var __flash__temp = "\"c:\\Program Files\\uploadtools\\\"";
+ * which contains the correct string literal.
+ *
+ * Note: The "var __flash__temp = " portion of the example is part of
the ExternalInterface not part of
+ * my escaping routine.
+ */
+ public static function EscapeMessage(message:*):* {
+ if (message is String) {
+ message = EscapeString(message);
+ }
+ else if (message is Array) {
+ message = EscapeArray(message);
+ }
+ else if (message is Object) {
+ message = EscapeObject(message);
+ }
+
+ return message;
+ }
+ }
+}
=======================================
--- /dev/null
+++ /branches/labs/uploader/_src/as3/src/com/webunity/jQuery/BlackBird.as
Tue Sep 8 03:26:47 2009
@@ -0,0 +1,16 @@
+/**
+ * Constants for the blackbird logging utility
+ *
+ * @author Gilles van den Hoven (added events and queue management)
+ */
+package com.webunity.jQuery
+{
+ public class BlackBird
+ {
+ public static const COMPLETE:String = "log.debug";
+ public static const INFO:String = "log.info";
+ public static const WARN:String = "log.warn";
+ public static const ERROR:String = "log.error";
+ public static const PROFILE:String = "log.prof