changeset 357:6fd8da22a5ef

Implement scene file load function.
author wycc
date Wed, 11 Mar 2009 01:32:09 +0800
parents 3e84458968ec
children 50d33c3987ba
files inkscape/firefox/content/inkscape.js inkscape/firefox/content/madbuilder.html
diffstat 2 files changed, 64 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/inkscape/firefox/content/inkscape.js	Mon Mar 09 23:05:57 2009 +0800
+++ b/inkscape/firefox/content/inkscape.js	Wed Mar 11 01:32:09 2009 +0800
@@ -382,11 +382,39 @@
 var currentScene = 0;
 var currentLayer = '';
 
-var last_select = null;
-inkscape = new Inkscape("scene.mbsvg");
+
+function dump(n)
+{
+	cmd = "";
+	for(k in n) {
+		cmd = cmd + k+"="+n[k]+"\n";
+	}
+	alert(cmd);
+}
 
 
-  tree = $.tree_create();
+function openFile()
+{
+	alert('bug');
+	$.modal('<div>My data</div>');
+	alert('done');
+}
+
+
+var last_select = null;
+
+$('#inkscape').html('Please select the project file<br>');
+$('#inkscape').append('<input type=file value="Select the project file" id="mbsvg" accept="image/png">');
+$('#inkscape').append('<input type=button value="Load" onclick="loadFile()">');
+
+
+function loadFile()
+{
+  ele = $('#mbsvg');
+  file = ele.attr('value');
+  inkscape = new Inkscape("file://"+file);
+
+  var tree = $.tree_create();
   file1_animation = [
 	  {
 		attributes: {id:"an1-1"},
@@ -422,11 +450,38 @@
     data: {
   	type: "json",
 	json : {
-		attributes: {id: "node0"}, state: "open", data: "Project", children: [
+		attributes: {id: "prj"}, state: "open", data: "Project", 
+			children: [
 				{ attributes:{id:"scenes"}, data:"scene", children: scenes},
 				{ attributes:{id:"sources"},data:"sources",children: sources}
 			]
 		}
-	}
+	},
+    ui : {
+		context :  [ 
+			{
+				id: "Open",
+				label: "Open",
+				icon: "open.png",
+				visible: function(NODE,TREE_OBJ) {  if(NODE.length != 1) return false; return NODE[0].id == "prj";},
+				action: function(NODE,TREE_OBJ) { openFile(TREE_OBJ);}
+			},
+			{
+				id: "New",
+				label: "New",
+				icon: "create.png",
+				visible: function(NODE,TREE_OBJ) {  if(NODE.length != 1) return false; return NODE[0].id == "prj";},
+				action: function(NODE,TREE_OBJ) { alert("open is not support yet");}
+			},
+			{
+				id: "Rename",
+				label: "Rename",
+				icon: "rename.png",
+				visible: function(NODE,TREE_OBJ) {  if(NODE.length != 1) return false; return NODE[0].id == "prj";},
+				action: function(NODE,TREE_OBJ) { alert("open is not support yet");}
+			},
+		]
+    },
+
   });
-
+}
--- a/inkscape/firefox/content/madbuilder.html	Mon Mar 09 23:05:57 2009 +0800
+++ b/inkscape/firefox/content/madbuilder.html	Wed Mar 11 01:32:09 2009 +0800
@@ -7,6 +7,8 @@
 	<script language="javascript" src="jqSOAPClient.js"></script>
 	<script language="javascript" src="tree_component.js"></script>
 	<script type="text/javascript" src="js/jquery-ui-1.7.custom.min.js"></script>
+	<script type="text/javascript" src="jquery.simplemodal-1.2.3.pack.js"></script>
+
 
 	<style type="text/css"> 
 		.normal {
@@ -63,7 +65,7 @@
 	<br/>
 </div>
 <table>
-	<tr><td width=200 height=700 valign=top><div id='filelist' valign=top> Loading...</div></td><td width=700 height=700> <div id='inkscape'></div></td></tr>
+	<tr><td width=200 height=700 valign=top><div id='filelist' valign=top></div></td><td width=700 height=700 valign=top> <div id='inkscape'></div></td></tr>
 </table>		
 <script type="text/javascript" src="inkscape.js" >
 </script>