comparison inkscape/firefox/content/inkscape.js @ 381:29145d2affdb

Add function to change the name of the symbol
author wycc
date Sun, 05 Apr 2009 12:28:36 +0800
parents 7d244a85dd68
children 7cbb364fd273
comparison
equal deleted inserted replaced
380:9c70de05a0b6 381:29145d2affdb
226 SOAPClient.Proxy = "http://localhost:19192/"; 226 SOAPClient.Proxy = "http://localhost:19192/";
227 SOAPClient.SendRequest(sr,function(resp,arg) {arg.refreshDocument(resp);},this); 227 SOAPClient.SendRequest(sr,function(resp,arg) {arg.refreshDocument(resp);},this);
228 this.isInProgress++; 228 this.isInProgress++;
229 } 229 }
230 230
231 Inkscape.prototype.changeSymbolName_cb = function(callback)
232 {
233 var soapBody = new SOAPObject("CHANGESYMBOL");
234 var v1 = new SOAPObject("v1");
235 v1.attr('type','string');
236 v1.val(this.v1);
237 soapBody.appendChild(v1);
238 var v2 = new SOAPObject("v2");
239 v2.val(this.v2);
240 soapBody.appendChild(v2);
241 var sr = new SOAPRequest("CHANGESYMBOL", soapBody);
242 SOAPClient.Proxy = "http://localhost:19192/";
243 SOAPClient.SendRequest(sr, function (resp,arg) {arg.refreshDocument(resp);},this);
244 this.inProgress--;
245 }
246
247 Inkscape.prototype.changeSymbolName = function(id,newname,callback)
248 {
249 var soapBody = new SOAPObject("START");
250 this.callback = callback
251 var sr = new SOAPRequest("START", soapBody);
252 SOAPClient.Proxy = "http://localhost:19192/";
253 this.v1 = id;
254 this.v2 = newname;
255 SOAPClient.SendRequest(sr,function(resp,arg) {arg.changeSymbolName_cb(resp);},this);
256 this.isInProgress++;
257 }
258
231 /* 259 /*
232 * This module is used to define a symbol for the MadButterfly. This function will search for symbol which is defined in the current select object. We will list all SVG elements 260 * This module is used to define a symbol for the MadButterfly. This function will search for symbol which is defined in the current select object. We will list all SVG elements
233 * in the left side, multiple variables can be defined at one time. When any element is selected, the defined symbol will be listed in the right side. 261 * in the left side, multiple variables can be defined at one time. When any element is selected, the defined symbol will be listed in the right side.
234 * 262 *
235 */ 263 */
236 264
237 Inkscape.prototype.MakeSymbol=function() 265 Inkscape.prototype.MakeSymbol=function()
238 { 266 {
239 function callback(mbsvg) { 267 function callback(mbsvg) {
240 this.loadSymbolScreen(mbsvg); 268 inkscape.loadSymbolScreen(mbsvg);
241 } 269 }
242 inkscape.fetchDocument(callback); 270 inkscape.fetchDocument(callback);
271 }
272
273
274 Inkscape.prototype.onChangeSymbolName=function()
275 {
276 inkscape.changeSymbolName(inkscape.current_symbol, $('#newsymbolname').val());
277 symboldialog.dialog('close')
278 }
279
280 Inkscape.prototype.refreshSymbolPanel=function(node)
281 {
282 inkscape.current_symbol = node.textContent;
243 } 283 }
244 284
245 Inkscape.prototype.loadSymbolScreen=function (mbsvg) { 285 Inkscape.prototype.loadSymbolScreen=function (mbsvg) {
246 // Swap the left side to be the SVG element tree. 286 // Swap the left side to be the SVG element tree.
247 var i,l; 287 var i,l;
259 data: { 299 data: {
260 type: "json", 300 type: "json",
261 json : jsonobj 301 json : jsonobj
262 }, 302 },
263 callback : { 303 callback : {
264 ondblclk : function(NODE,TREE_OBJ) { this.refreshSymbolPanel(TREE_OBJ); TREE_OBJ.toggle_branch.call(TREE_OBJ, NODE); TREE_OBJ.select_branch.call(TREE_OBJ, NODE);} 304 ondblclk : function(NODE,TREE_OBJ) { inkscape.refreshSymbolPanel(NODE); TREE_OBJ.toggle_branch.call(TREE_OBJ, NODE); TREE_OBJ.select_branch.call(TREE_OBJ, NODE);}
265 } 305 }
266 306
267 }); 307 });
308 var s = $('#changename');
309 s.click(this.onChangeSymbolName);
268 // Swap the right side to be the symbol editor screen. 310 // Swap the right side to be the symbol editor screen.
269 symboldialog.show(); 311 symboldialog.show();
270 } 312 }
271 313
272 jQuery(document).ready(function() { 314 jQuery(document).ready(function() {
274 symboldialog.dialog({width:500, 316 symboldialog.dialog({width:500,
275 modal: true, 317 modal: true,
276 autoOpen:false, 318 autoOpen:false,
277 title:'Please select a file'}); 319 title:'Please select a file'});
278 symboldialog.hide(); 320 symboldialog.hide();
279 symboldialog.append("<div id='symbollist'>"); 321 symboldialog.append("<div id='symbollist'/>");
280 symboldialog.append("<div id='symbol'>"); 322 symboldialog.append("<div id='symbol'><input type='text' id='newsymbolname'> <input type='submit' id='changename'></div> ");
281 }); 323 });
282 324
283 function MBSVG(file) 325 function MBSVG(file)
284 { 326 {
285 var xmlDoc=document.implementation.createDocument("http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd","",null); 327 var xmlDoc=document.implementation.createDocument("http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd","",null);