blob: a3631627372cc89ede0e279a8f46a4c18763aab8 [file] [log] [blame]
<?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.
-->
<windows:AnimatedPanelWindow xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:c="com.flexcapacitor.views.windows.*"
xmlns:handlers="com.flexcapacitor.handlers.*"
xmlns:fc="com.flexcapacitor.effects.popup.*"
xmlns:windows="com.flexcapacitor.views.windows.*"
title="Contact"
creationComplete="creationCompleteHandler(event)"
stateChangeComplete="stateChangeCompleteHandler(event)"
height.bug="450"
>
<fx:Style>
@namespace s "library://ns.adobe.com/flex/spark";
@namespace c "com.flexcapacitor.controls.*";
@namespace mx "library://ns.adobe.com/flex/mx";
@namespace handlers "com.flexcapacitor.handlers.*";
@namespace fc "com.flexcapacitor.effects.popup.*";
</fx:Style>
<fx:Script>
<![CDATA[
import com.flexcapacitor.controller.Radiate;
import com.flexcapacitor.status.StatusManager;
import mx.core.mx_internal;
import mx.events.FlexEvent;
import mx.events.ValidationResultEvent;
import mx.managers.PopUpManager;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.validators.EmailValidator;
use namespace mx_internal;
public static const BUG:String = "bug";
public static const FEATURE:String = "feature";
[Bindable]
public var os:String;
[Bindable]
public var browser:String;
[Bindable]
public var player:String;
[Bindable]
public var manufacturer:String;
[Bindable]
public var cpu:String;
[Bindable]
public var isDebugger:Boolean;
[Bindable]
public var language:String;
[Bindable]
public var supports32bit:String;
[Bindable]
public var supports64bit:String;
[Bindable]
public var touchscreenType:String;
[Bindable]
public var isDebugSWF:Boolean;
[Bindable]
public var flexSDK:String;
protected function getPropertiesInfo():void {
var cap:Object = Capabilities;
os = Capabilities.os;
manufacturer = Capabilities.manufacturer;
player = Capabilities.version;
isDebugger = Capabilities.isDebugger;
language = Capabilities.language;
// in the future we should load in the swf in question
// and get the sdk version and if its a debug swf
//flexSDK = mx_internal::Version;
isDebugSWF = false; //new Error().getStackTrace().search(/:[0-9]+]$/m) > -1;
if (Object(Capabilities).hasOwnProperty("cpuArchitecture")) {
cpu = Capabilities['cpuArchitecture'];
}
else {
cpu = "";
}
if (Object(Capabilities).hasOwnProperty("supports32BitProcesses")) {
supports32bit = Capabilities['supports32BitProcesses'];
supports64bit = Capabilities['supports64BitProcesses'];
}
else {
supports32bit = "";
supports64bit = "";
}
if (Object(Capabilities).hasOwnProperty("touchscreenType")) {
touchscreenType = Capabilities['touchscreenType'];
}
else {
touchscreenType = "";
}
if (ExternalInterface.available) {
browser = ExternalInterface.call("eval", "navigator.userAgent");
}
else {
browser = Capabilities.playerType;
}
}
protected function featureRadioGroup_changeHandler(event:Event):void {
if (featureRadioButton.selected) {
currentState = FEATURE;
}
else {
currentState = BUG;
}
}
protected function sendButton_clickHandler():void {
var message:Object = new Object();
var validResultEvent:ValidationResultEvent = emailValidator.validate(emailText.text);
//var validEmail:Boolean = emailValidator.validate(emailText.text);
if (validResultEvent.results && validResultEvent.results.length!=0) {
//infoLabel.text = "Please enter a valid email before sending a message.";
infoLabel.text = validResultEvent.message;
return;
}
if (messageTextArea.text=="" || messageTextArea.text.length<6) {
//StatusManager.show("Please enter a message.");
infoLabel.text = "Please enter a message";
return;
}
getPropertiesInfo();
message.os = os;
message.browser = browser;
message.player = player;
message.manufacturer = manufacturer;
message.cpu = cpu;
message.isDebugger = isDebugger;
message.language = language;
message.supports32bit = supports32bit;
message.supports64bit = supports64bit;
message.touchscreen = touchscreenType;
message.email = emailText.text=="" ? emailText.prompt : emailText.text;
if (currentState==BUG) {
message.message = bugMessageTextArea.text;
}
else if (currentState==FEATURE) {
message.message = messageTextArea.text;
}
feedbackService.send(message);
}
protected function feedbackService_resultHandler(event:ResultEvent):void {
var result:String = event.result as String;
//StatusManager.show("Message sent!", 3000, false, null, false, .75);
//nameText.text = "";
//emailText.prompt = emailText.text!="" ? emailText.text : emailText.prompt;
//emailText.text = "";
if (currentState==BUG) {
bugMessageTextArea.text = bugText;
}
else if (currentState==FEATURE) {
messageTextArea.text = "";
}
if (result && result.indexOf("Mail sent")!=-1) {
playSentSuccessfulMessage();
}
}
protected function feedbackService_faultHandler(event:FaultEvent):void {
infoLabel.text = "An error occurred! Message may not have been sent. Please email contact@radii8.com.";
//StatusManager.show("An error occurred! Message may not have been sent. \n\n" + event.fault.message);
Radiate.log.error(event.fault.message);
}
/**
* Sets the action to deleted, the label to deleted and closes the window after a second.
* */
public function playSentSuccessfulMessage():void {
//infoLabel.text = "Sent!";
//action = "Sent";
StatusManager.show("Message sent!", 1000, false, null, false, .20);
closePopUp.startDelay = 1000;
closePopUp.play();
}
protected function cancelButton_clickHandler(event:MouseEvent):void {
callLater(PopUpManager.removePopUp, [this]);
}
protected function creationCompleteHandler(event:FlexEvent):void {
radiate = Radiate.getInstance();
if (radiate.isUserLoggedIn) {
emailText.text = radiate.userEmail;
}
if (currentState==BUG) {
bugMessageTextArea.text = bugText;
//helpTextArea.text = bugExampleText;
}
else {
//messageTextArea.text = bugText;
//messageTextArea.text = bugExampleText;
}
}
protected function stateChangeCompleteHandler(event:FlexEvent):void {
if (currentState==BUG && bugMessageTextArea.text=="") {
bugMessageTextArea.text = bugText;
addMoveEffect();
PopUpManager.centerPopUp(this);
}
else {
PopUpManager.centerPopUp(this);
}
}
]]>
</fx:Script>
<fx:Declarations>
<fx:String id="action"></fx:String>
<fc:ClosePopUp id="closePopUp" popUp="{this}" />
</fx:Declarations>
<fx:Declarations>
<mx:EmailValidator id="emailValidator" />
<s:RadioButtonGroup id="featureRadioGroup"
change="featureRadioGroup_changeHandler(event)"/>
<s:HTTPService id="feedbackService"
method="POST"
fault="feedbackService_faultHandler(event)"
result="feedbackService_resultHandler(event)"
url="http://www.radii8.com/support.php"/>
<fx:String id="bugText">
<![CDATA[Summary:
Steps to reproduce:
1.
2.
3.
Expected Result:
Actual Result:
]]></fx:String>
<fx:String id="bugExampleText">
<![CDATA[Summarize the problem and list the steps to reproduce.
Steps to reproduce:
1. Add a button to the stage
2. Set color on the button to red in the properties panel
Expected Result:
Button text is red
Actual Result:
Button text is blue]]></fx:String>
</fx:Declarations>
<windows:states>
<s:State name="feature"/>
<s:State name="bug"/>
</windows:states>
<s:VGroup left="15"
top="20"
right="20"
bottom="20"
gap="10"
>
<s:HGroup left="0" right="0"
width="100%"
clipAndEnableScrolling="true"
paddingRight="10"
verticalAlign="middle"
>
<s:Label text="Send as many feature request and bug reports as you like."/>
<s:Spacer width="100%"/>
<s:RadioButton id="featureRadioButton"
label="Feature"
group="{featureRadioGroup}"
selected="true"
/>
<s:RadioButton id="booleanDisabledRadioButton"
label="Bug"
group="{featureRadioGroup}"
/>
</s:HGroup>
<s:HGroup verticalAlign="middle">
<s:Label text="Your email:"/>
<s:TextInput id="emailText"
minWidth="250"
focusAlpha="0"
borderColor="#cccccc"
/>
</s:HGroup>
<s:HGroup left="0" right="0"
width="100%" height="100%"
clipAndEnableScrolling="true"
paddingRight="10"
verticalAlign="middle"
>
<s:TextArea id="messageTextArea"
focusColor="#585858"
focusAlpha="0"
width="100%" height="100%"
borderColor="#cccccc"
paddingTop="8"
paddingBottom="8"
prompt="Enter your feature and click send"
includeIn="feature"
>
</s:TextArea>
<s:TextArea id="bugMessageTextArea"
focusColor="#585858"
focusAlpha="0"
width="100%" height="100%"
borderColor="#cccccc"
paddingTop="8"
paddingBottom="8"
includeIn="bug"
>
<s:keyFocusChange>
event.preventDefault();
event.currentTarget.insertText("\t");
</s:keyFocusChange>
<s:prompt>Summarize the problem and list the steps to reproduce.</s:prompt>
</s:TextArea>
<!--<s:TextArea id="helpTextArea"
focusColor="#585858"
focusAlpha="0"
width="50%" height="100%"
borderColor="#cccccc"
borderVisible="false"
paddingTop="8"
paddingBottom="8"
editable="false"
includeIn="bug"
fontStyle="italic"
color="#585858"
>
<s:text></s:text>
</s:TextArea>-->
</s:HGroup>
<s:HGroup width="100%" horizontalAlign="right" verticalAlign="baseline">
<s:Label id="infoLabel" text="" />
<s:Spacer width="100%"/>
<s:Button id="cancelButton" label="Cancel" click="cancelButton_clickHandler(event)" />
<s:Button label="Send" click="sendButton_clickHandler()" />
</s:HGroup>
</s:VGroup>
</windows:AnimatedPanelWindow>