Author: jbeard
Date: Mon Jun 28 18:45:46 2010
New Revision: 958674

URL: http://svn.apache.org/viewvc?rev=958674&view=rev
Log:
New demo working in Firefox. Still need to adjust styling, though.

Modified:
    
commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/demo/drag-and-drop/drag-and-drop.xhtml
    
commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/src/javascript/scxml/cgf/SCXMLCompiler.js
    
commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/src/javascript/scxml/cgf/Transformer.js

Modified: 
commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/demo/drag-and-drop/drag-and-drop.xhtml
URL: 
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/demo/drag-and-drop/drag-and-drop.xhtml?rev=958674&r1=958673&r2=958674&view=diff
==============================================================================
--- 
commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/demo/drag-and-drop/drag-and-drop.xhtml
 (original)
+++ 
commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/demo/drag-and-drop/drag-and-drop.xhtml
 Mon Jun 28 18:45:46 2010
@@ -19,7 +19,7 @@
 <html xmlns="http://www.w3.org/1999/xhtml"; 
xmlns:svg="http://www.w3.org/2000/svg";>
        <head>
                <style type="text/css">
-                       body {
+                       html, body {
                                height:100%;
                                margin: 0;
                                padding: 0;
@@ -27,38 +27,44 @@
 
                        div{ 
                                width:100%;
-                               height:100%;
+                               min-height:100%;
                        }
                </style>
-               <script src="../../lib/js/requirejs/require.js" 
type="text/javascript"/>
+               <script src="../../lib/js/requirejs/require.js" 
type="text/javascript"></script>
+               <script src="../../lib/js/requirejs/require/text.js" 
type="text/javascript"></script>
+               <script src="../../lib/js/requirejs/require/xml.js" 
type="text/javascript"></script>
        </head>
        <body>
                <div id="svgContainer">
 
                        <svg xmlns="http://www.w3.org/2000/svg"; 
xmlns:xlink="http://www.w3.org/1999/xlink"; width="100%" height="100%">
 
-                               <rect width="100" height="100" stroke="black" 
fill="red" id="rectToTranslate">
+                               <rect width="100" height="100" stroke="black" 
fill="red" id="rectToTranslate" >
 
                                        <scxml 
                                                
xmlns="http://www.w3.org/2005/07/scxml";
                                                version="1.0"
                                                profile="ecmascript"
-                                               id="scxmlRoot">
+                                               id="scxmlRoot"
+                                               initial="initial_default">
 
                                                <script>
                                                        function 
computeTDelta(oldEvent,newEvent){
                                                                
//summary:computes the offset between two events; to be later used with 
this.translate
-                                                               var dx = 
newEvent.localX - oldEvent.localX;
-                                                               var dy = 
newEvent.localY - oldEvent.localY;
+                                                               
//console.log(oldEvent);
+                                                               
//console.log(newEvent);
+                                                               var dx = 
newEvent.clientX - oldEvent.clientX;
+                                                               var dy = 
newEvent.clientY - oldEvent.clientY;
 
                                                                return 
{'dx':dx,'dy':dy};
                                                        }
 
                                                        function 
translate(rawNode,tDelta){
+                                                               
//console.log("dx: %d,dy: %d",tDelta.dx,tDelta.dy);
                                                                var tl = 
rawNode.transform.baseVal;
-                                                               var t = 
tl.numberOfItems ? tl.getItem(0) : canvas.createSVGTransform();
+                                                               var t = 
tl.numberOfItems ? tl.getItem(0) : rawNode.ownerSVGElement.createSVGTransform();
                                                                var m = 
t.matrix;
-                                                               var newM = 
identity.translate(tDelta.dx,tDelta.dy).multiply(m);
+                                                               var newM = 
rawNode.ownerSVGElement.createSVGMatrix().translate(tDelta.dx,tDelta.dy).multiply(m);
                                                                
t.setMatrix(newM);
                                                                
tl.initialize(t);
                                                                return newM;
@@ -72,14 +78,14 @@
                                                        <data 
id="rectToTranslate"/>
                                                </datamodel>
 
-                                               <state id="default">
-                                                       <transition 
event="init">
+                                               <state id="initial_default">
+                                                       <transition 
event="init" target="idle">
                                                                <assign 
location="rectToTranslate" expr="_event.data.rectToTranslate"/>
                                                        </transition>
                                                </state>
 
                                                <state id="idle">
-                                                       <transition 
event="mousedown">
+                                                       <transition 
event="mousedown" target="dragging">
                                                                <assign 
location="firstEvent" expr="_event.data"/>
                                                                <assign 
location="eventStamp" expr="_event.data"/>
                                                        </transition>
@@ -113,17 +119,24 @@
                                function(compiler){
 
                                        //pull UI controls from DOM
-                                       var scxml_input = 
document.getElementById("scxmlRoot");
                                        var rect = 
document.getElementById("rectToTranslate");
+                                       var scxml_input = rect.children[0]; 
+
+                                       //prep scxml document to transform by 
pulling the scxml node into its own document
+                                       var scxmlns = 
"http://www.w3.org/2005/07/scxml";;
+                                       var scxmlToTransform = 
document.implementation.createDocument (scxmlns , "scxml", null);
+                                       var newNode = 
scxmlToTransform.importNode(scxml_input.cloneNode(true),true);
+                                       
scxmlToTransform.replaceChild(newNode,scxmlToTransform.documentElement);
 
                                        var compiledStatechartConstructor, 
compiledStatechartInstance; 
 
                                        compiler.compile({
-                                               inFiles:[scxml_input],
+                                               inFiles:[scxmlToTransform],
+                                               //debug:true,
                                                backend:"state",
                                                beautify:true,
                                                verbose:false,
-                                               log:true,
+                                               log:false,
                                                ie:false
                                        }, function(scArr){
                                                var transformedJs = scArr[0];

Modified: 
commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/src/javascript/scxml/cgf/SCXMLCompiler.js
URL: 
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/src/javascript/scxml/cgf/SCXMLCompiler.js?rev=958674&r1=958673&r2=958674&view=diff
==============================================================================
--- 
commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/src/javascript/scxml/cgf/SCXMLCompiler.js
 (original)
+++ 
commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/src/javascript/scxml/cgf/SCXMLCompiler.js
 Mon Jun 28 18:45:46 2010
@@ -68,8 +68,8 @@ require.def("src/javascript/scxml/cgf/SC
 
                                var toReturn = 
options.inFiles.map(function(xmlFile){
 
-                                       var ir = 
Transformer(xmlFile,backend.transformations,null,"xml");
-                                       var transformedJs = 
Transformer(ir,backend.code,options,"text");
+                                       var ir = 
Transformer(xmlFile,backend.transformations,null,"xml",options.debug);
+                                       var transformedJs = 
Transformer(ir,backend.code,options,"text",options.debug);
 
                                        //optionally beautify it
                                        if(options.beautify){

Modified: 
commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/src/javascript/scxml/cgf/Transformer.js
URL: 
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/src/javascript/scxml/cgf/Transformer.js?rev=958674&r1=958673&r2=958674&view=diff
==============================================================================
--- 
commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/src/javascript/scxml/cgf/Transformer.js
 (original)
+++ 
commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/src/javascript/scxml/cgf/Transformer.js
 Mon Jun 28 18:45:46 2010
@@ -113,7 +113,7 @@ function(xmlUtil){
                                        return toReturn;        //string or node
                                }                       :
                                //everything else
-                               
function(sourceDocument,transformList,params,output){
+                               
function(sourceDocument,transformList,params,output,debug){
                                        transformList = transformList && 
!transformList.length  ? 
                                                                [transformList] 
                :
                                                                transformList;
@@ -153,8 +153,10 @@ function(xmlUtil){
 
                                        var docToTransform  = sourceDocument;
                                        processors.forEach(function(p){
+                                               if(debug) 
console.dirxml(docToTransform); 
                                                docToTransform = 
p.transformToDocument(docToTransform);
                                        });
+                                       if(debug) 
console.dirxml(docToTransform); 
                
 
                                        var toReturn;


Reply via email to