<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="480" height="350"
pageTitle="uCoz AJAX Window Generator"
preloaderChromeColor="#787070">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
private function convertBoolean(pBool:Boolean):Number
{
if (pBool == true) {
return 1;
} else {
return 0;
}
}
private function generateCode():void
{
// Validate Fields
if (winID.text == '') {
Alert.show("Please provide a unique ID for this AJAX window.","Missing Field");
} else if ((winWidth.text == '') || (winHeight.text =='')) {
Alert.show("Please provide a size for the AJAX window.","Missing Field");
} else {
// Generate Code
var tCode:String = "";
tCode = "<script type=\"text/javascript\">\n" +
"function " + winID.text + "(){\n" +
"new _uWnd('" +
winID.text + "',unescape('" +
escape(winTitle.text) + "')," +
winWidth.text + "," +
winHeight.text + ",{" +
"modal:" + convertBoolean(winModal.selected) +
",close:" + convertBoolean(winClose.selected) +
",max:" + convertBoolean(winMaximize.selected) +
",resize:" + convertBoolean(winResize.selected) +
",nomove:" + convertBoolean(winNoMove.selected) +
",shadow:" + convertBoolean(winShadow.selected) +
",header:" + convertBoolean(winHeader.selected) +
",autosize:" + convertBoolean(winAutoSize.selected);
// Conditional Stuff (Minimum and Maximum Sizes)
if (winMinWidth.text != '') {tCode = tCode + ",minw:" + winMinWidth.text;}
if (winMinHeight.text != '') {tCode = tCode + ",minh:" + winMinHeight.text;}
if (winMaxWidth.text != '') {tCode = tCode + ",maxw:" + winMaxWidth.text;}
if (winMaxHeight.text != '') {tCode = tCode + ",maxh:" + winMaxHeight.text;}
var tContent:String = winContent.text;
if (winAlignment.selectedValue.toString() != '') {
tContent = '<div align="'+winAlignment.selectedValue.toString()+'">' +
winContent.text +
'</div>';
}
tCode = tCode + "},unescape('" + escape(tContent) + "'));\n" +
"}\n" +
"</script>";
System.setClipboard(tCode);
// Generate User Alert
Alert.show("The code has been generated and copied to your clipboard!" +
"You can now paste it.\n\n" +
"To use it, you must call the JavaScript function below:\n\n" +
winID.text + "()","Copied to Clipboard");
}
}
]]>
</fx:Script>
<fx:Declarations>
<s:RadioButtonGroup id="winAlignment"/>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:controlBarContent>
<s:Label text="uCoz AJAX Window Generator v1.01" fontWeight="bold" color="#141313"/>
</s:controlBarContent>
<s:BorderContainer x="0" y="0" width="480" height="321" borderColor="#D4C5C5" backgroundAlpha="0.0">
<!--Misc-->
<s:Button y="10"
width="100" height="21"
label="About this App"
click="aboutApp()" x="284"/>
<s:Button y="10"
width="80" height="21"
label="More Info."
click="moreInfo()" x="388"/>
<!--End of Misc-->
<s:Label x="19" y="16"
text="Unique ID:"/>
<s:TextInput id="winID"
x="86" y="10"
width="178" height="21"
restrict="A-Za-z0-9_"
maxChars="100"/>
<!--First Column-->
<s:Label x="24" y="52" text="Width:"/>
<s:TextInput id="winWidth"
x="62" y="46"
width="40" height="21"
restrict="0-9"
maxChars="4"
text="300"/>
<s:Label x="109" y="52" text="Height:"/>
<s:TextInput id="winHeight"
x="152" y="46"
width="40" height="21"
restrict="0-9"
maxChars="4"
text="200"/>
<s:Label x="24" y="77" text="Min. Width:"/>
<s:TextInput id="winMinWidth"
x="87" y="71"
width="40" height="21"
restrict="0-9"
maxChars="4"/>
<s:Label x="137" y="78" text="Min. Height:"/>
<s:TextInput id="winMinHeight"
x="204" y="72"
width="40" height="21"
restrict="0-9"
maxChars="4"/>
<s:Label x="24" y="102" text="Max. Width:"/>
<s:TextInput id="winMaxWidth"
x="89" y="96"
width="40" height="21"
restrict="0-9"
maxChars="4"/>
<s:Label x="137" y="103" text="Max. Height:"/>
<s:TextInput id="winMaxHeight"
x="206" y="97"
width="40" height="21"
restrict="0-9"
maxChars="4"/>
<s:Label x="24" y="126" text="Default Alignment:"/>
<s:RadioButton x="33" y="140"
label="Left" value="left"
groupName="winAlignment"
selected="true"/>
<s:RadioButton x="83" y="140"
label="Center" value="center"
groupName="winAlignment"/>
<s:RadioButton x="149" y="140"
label="Right" value="right"
groupName="winAlignment"/>
<s:RadioButton x="209" y="140"
label="Justify" value="justify"
groupName="winAlignment"/>
<!--End of First Column-->
<!--Second Column-->
<s:CheckBox id="winModal"
x="285" y="40"
label="Modal Window? (modal)"/>
<s:CheckBox id="winClose"
x="285" y="59"
label="Closable? (close)"
selected="true"/>
<s:CheckBox id="winMaximize"
x="285" y="78"
label="Maximizable? (max)"/>
<s:CheckBox id="winResize"
x="285" y="97"
label="Resizable? (resize)"/>
<s:CheckBox id="winNoMove"
x="285" y="116"
label="Not Movable? (nomove)"/>
<s:CheckBox id="winShadow"
x="285" y="135"
label="Shadow Present? (shadow)"/>
<s:CheckBox id="winHeader"
x="285" y="154"
label="Header Present? (header)"
selected="true"/>
<s:CheckBox id="winAutoSize"
x="285" y="173"
label="Auto-size? (autosize)"/>
<!--End of Second Column-->
<!--User Content-->
<s:Label y="172" text="Window Title:" x="24"/>
<s:TextInput id="winTitle"
x="105" y="166"
width="155" height="21"
maxChars="100"/>
<s:Label x="50" y="202" text="Content:"/>
<s:Label x="11" y="217" text="(Accepts HTML)"/>
<s:TextArea id="winContent"
y="196"
width="363" height="115"
maxChars="5000" x="105"/>
<!--End of User Content-->
<s:Button x="10" y="281"
label="GENERATE"
width="87" height="30"
click="generateCode()" fontSize="10"/>
</s:BorderContainer>
</s:Application>