Mercurial > MadButterfly
changeset 364:a373b4743e63
Add file dialog to add a new scene file into the project.
author | wycc |
---|---|
date | Sat, 14 Mar 2009 15:35:51 +0800 |
parents | 04609111485d |
children | 6adb28388132 |
files | inkscape/firefox/content/inkscape.js inkscape/firefox/content/madbuilder.html |
diffstat | 2 files changed, 65 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/inkscape/firefox/content/inkscape.js Wed Mar 11 09:12:21 2009 +0800 +++ b/inkscape/firefox/content/inkscape.js Sat Mar 14 15:35:51 2009 +0800 @@ -544,8 +544,8 @@ 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);} + visible: function(NODE,TREE_OBJ) { if(NODE.length != 1) return false; return true;}, + action: function(NODE,TREE_OBJ) { onTree_openFile(NODE,TREE_OBJ);} }, { id: "New", @@ -567,6 +567,50 @@ }); } +function fileDialog_cb() +{ + var file = $('#filedialogsrc').attr('value'); + filedialog.dialog('close'); + filedialog_cb(file,filedialog_arg); +} + +function openFileDialog(callback,arg) +{ + filedialog_cb = callback; + filedialog_arg = arg; + filedialog.html('Please select the scene file<br>'); + filedialog.append('<input type=file value="Select the scene file" id="filedialogsrc">'); + filedialog.append('<input type=button value="Load" onclick="fileDialog_cb()">'); + filedialog.show(); + filedialog.dialog('open'); +} + + +function project_addScene(file,treeobj) +{ + if (file == '') { + return; + } + treeobj.create(false,treeobj.selected,file); +} + +function onTree_addSceneFile(node,treeobj) +{ + //treeobj.create(false,treeobj.selected,"xxx",null,"newscene"); + openFileDialog(project_addScene,treeobj); +} + + +function onTree_openFile(node,treeobj) +{ + if (node[0].id == "scenes") { + onTree_addSceneFile(node,treeobj); + } else if (node[0].id == "sources") { + onTree_addSourceFile(node,treeobj); + } +} + + function system_read(fname) { try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); @@ -599,10 +643,23 @@ prjname = $('#mbsvg').attr('value'); var prj = system_read(prjname); project_parse(prj); + filedialog.dialog('close'); } 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="project_loadFile()">'); +$('#filedialog').dialog({ width:500}); +jQuery(document).ready(function() { + filedialog = jQuery('#filedialog'); + filedialog.dialog({width:500, + modal: true, + autopen:false, + title:'Please select a file'}); + filedialog.show(); + filedialog.html('Please select the project file<br>'); + filedialog.append('<input type=file value="Select the project file" id="mbsvg" accept="image/png">'); + filedialog.append('<input type=button value="Load" onclick="project_loadFile()">'); + filedialog.dialog("open"); + }); + +
--- a/inkscape/firefox/content/madbuilder.html Wed Mar 11 09:12:21 2009 +0800 +++ b/inkscape/firefox/content/madbuilder.html Sat Mar 14 15:35:51 2009 +0800 @@ -1,12 +1,13 @@ <html> <head> <link rel="stylesheet" type="text/css" href="tree_component.css" /> + <link type="text/css" href="css/smoothness/jquery-ui-1.7.custom.css" rel="stylesheet" /> <script language="javascript" src="css.js"></script> <script language="javascript" src="jquery-1.3.1.js"></script> <script language="javascript" src="jqXMLUtils.js"></script> <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-ui-1.7.custom.min.js"></script> <script type="text/javascript" src="jquery.simplemodal-1.2.3.pack.js"></script> @@ -67,6 +68,7 @@ <table> <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><div id='editor'></div></td></tr> </table> +<div id='filedialog'></div> <script type="text/javascript" src="inkscape.js" > </script> </body>