Permalink
Browse files

swf support integration

  • Loading branch information...
1 parent bd43c30 commit c1bccf812ed650980685417b233e9b96cd0653c1 @clemos committed Jun 7, 2012
Showing with 90 additions and 38 deletions.
  1. +13 −3 index.html
  2. 0 { → lib}/swfobject.js
  3. +55 −12 src/Editor.hx
  4. +2 −3 src/Libs.hx
  5. +3 −20 src/api/Compiler.hx
  6. +17 −0 swf.css
View
@@ -59,11 +59,21 @@
<div class="tab-pane hx-options" id="hx-options">
<form id="hx-options-form" class="form-horizontal">
- <div class="control-group hx-libs">
- <label class="control-label" for="libs-checkbox">Libraries</label>
+ <div class="control-group hx-targets">
+ <label class="control-label" for="libs-checkbox">Target</label>
+
<div class="controls">
-
+ <label class="radio inline"><input type="radio" name="target" value="js" checked></input> JS</label>
+ <label class="radio inline"><input type="radio" name="target" value="swf"></input> SWF</label>
</div>
+
+ </div>
+ <div class="control-group hx-libs">
+ <label class="control-label" for="libs-checkbox">Libraries</label>
+
+ <div class="controls swf-libs"></div>
+ <div class="controls js-libs"></div>
+
</div>
</form>
</div>
File renamed without changes.
View
@@ -24,6 +24,8 @@ class Editor {
var messages : JQuery;
var compileBtn : JQuery;
var libs : JQuery;
+ var targets : JQuery;
+
var markers : Array<MarkedText>;
var lineHandles : Array<LineHandle>;
@@ -61,13 +63,16 @@ class Editor {
runner = new JQuery("iframe[name='js-run']");
messages = new JQuery(".messages");
compileBtn = new JQuery(".compile-btn");
- libs = new JQuery("#hx-options-form .hx-libs .controls");
+ libs = new JQuery("#hx-options-form .hx-libs");
+ targets = new JQuery("#hx-options-form .hx-targets");
new JQuery("body").bind("keyup", onKey );
new JQuery("a[data-toggle='tab']").bind( "shown", function(e){
jsSource.refresh();
});
+
+ targets.delegate("input[name='target']" , "change" , onTarget );
compileBtn.bind( "click" , compile );
@@ -86,24 +91,57 @@ class Editor {
initLibs();
+ setTarget( api.Program.Target.JS( "test" ) );
+
var uid = js.Lib.window.location.hash;
if (uid.length > 0){
uid = uid.substr(1);
cnx.Compiler.getProgram.call([uid], onProgram);
}
}
+ function onTarget(e : JqEvent){
+ var cb = new JQuery( e.target );
+ var name = cb.val();
+ var target = switch( name ){
+ case "swf" : api.Program.Target.SWF('test',10);
+ case "js" : api.Program.Target.JS('test');
+ }
+ setTarget(target);
+ }
+
+ function setTarget( target : api.Program.Target ){
+ program.target = target;
+ libs.find(".controls").hide();
+ var jsTab = new JQuery("a[href='#js-source']");
+ var sel :String;
+ switch( target ){
+ case JS(_):
+ sel = "js";
+ jsTab.fadeIn();
+
+ case SWF(_,_) :
+ sel = "swf";
+ jsTab.hide();
+ }
+ libs.find("."+sel+"-libs").fadeIn();
+ }
+
function initLibs(){
- for (l in Libs.getAvailableLibs(program.target)) // fill libs form
- {
- libs.append(
-
- '<label class="checkbox"><input class="lib" type="checkbox" value="' + l.name + '" '
- + ((l.checked /*|| selectedLib(l.name)*/) ? "checked='checked'" : "")
- + '" /> ' + l.name
- + "<span class='help-inline'><a href='http://lib.haxe.org/p/" + l.name +"' target='_blank'><i class='icon-question-sign'></i></a></span>"
- + "</label>"
- );
+ for( t in ["swf","js"] ){
+ var el = libs.find("."+t+"-libs");
+ var libs : Array<Libs.LibConf> = Reflect.field( Libs.available , t );
+ for( l in libs ){
+
+ el.append(
+ '<label class="checkbox"><input class="lib" type="checkbox" value="' + l.name + '" '
+ + ((Libs.defaultChecked.has(l.name) /*|| selectedLib(l.name)*/) ? "checked='checked'" : "")
+ + '" /> ' + l.name
+ + "<span class='help-inline'><a href='http://lib.haxe.org/p/" + l.name +"' target='_blank'><i class='icon-question-sign'></i></a></span>"
+ + "</label>"
+ );
+
+ }
}
}
@@ -124,6 +162,7 @@ class Editor {
}
}
}
+ setTarget( program.target );
}
}
@@ -197,7 +236,11 @@ class Editor {
program.main.source = haxeSource.getValue();
var libs = new Array();
- var inputs = new JQuery("#hx-options .hx-libs input.lib:checked");
+ var sel = switch( program.target ){
+ case JS(_): "js";
+ case SWF(_,_) : "swf";
+ }
+ var inputs = new JQuery("#hx-options .hx-libs ."+sel+"-libs input.lib:checked");
// TODO: change libs array only then need
for (i in inputs) // refill libs array, only checked libs
{
View
@@ -33,9 +33,8 @@ class Libs
{name:"modernizr"},
{name:"browserhx"}
],
- swf : [
- {name:"actuate" , args : []},
- {name:"hxSet"}
+ swf : cast [
+ {name:"actuate" , args : []}
]
};
View
@@ -188,6 +188,7 @@ class Compiler {
args.push("noEmbedJS");
html.body.push("<script src='//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script>");
html.body.push("<script src='" + outputUrl + "'></script>");
+ //html.body.push("<script src='" + outputUrl + "'></script>");
case SWF( name , version ):
@@ -199,26 +200,8 @@ class Compiler {
args.push( "-swf-version" );
args.push( Std.string( version ) );
args.push("-debug");
- html.head.push("<style>
- html {
- height: 100%;
- overflow: hidden;
- }
-
- #editorPreloader {
- height: 100%;
- }
-
- /* end hide */
-
- body {
- height: 100%;
- margin: 0;
- padding: 0;
- background-color: #FFF;
- }
- </style>");
- html.head.push("<script src='../swfobject.js'></script>");
+ html.head.push("<link rel='stylesheet' href='../swf.css' type='text/css'/>");
+ html.head.push("<script src='../lib/swfobject.js'></script>");
html.head.push('<script type="text/javascript">swfobject.embedSWF("'+outputUrl+'", "flashContent", "100%", "100%", "'+version+'.0.0")</script>');
html.body.push('<div id="flashContent"></div>');
}
View
17 swf.css
@@ -0,0 +1,17 @@
+html {
+ height: 100%;
+ overflow: hidden;
+}
+
+#editorPreloader {
+ height: 100%;
+}
+
+/* end hide */
+
+body {
+ height: 100%;
+ margin: 0;
+ padding: 0;
+ /*background-color: #FFF;*/
+}

0 comments on commit c1bccf8

Please sign in to comment.