- Timestamp:
- 2013-04-23T16:56:08+12:00 (11 years ago)
- Location:
- main/trunk/greenstone3/web/interfaces/default/js
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/web/interfaces/default/js/debug_scripts.js
r27218 r27256 527 527 } 528 528 529 var getURL = gs.xsltParams.library_name + "?a=g&rt=r&s=GetTemplateListFromFile&s1.fileName=" + selectedItem.data("fileItem").path + "&s1.locationName=" + selectedItem.data("fileItem").location + "&s1.interfaceName=" + gs.xsltParams.interface_name + "&s1.siteName=" + gs.xsltParams.site_name + "&s1.collectionName=" + gs.cgiParams.c; 530 $.ajax(getURL) 531 .success(function(templateResponse) 532 { 533 var templateListStart = templateResponse.indexOf("<templateList>") + "<templateList>".length; 534 var templateListEnd = templateResponse.indexOf("</templateList>"); 535 var templateListString = templateResponse.substring(templateListStart, templateListEnd).replace(/"/g, "\""); 536 var templateList = eval(templateListString); 537 538 _templateSelector.children("select").empty(); 539 if(templateList.length == 0) 540 { 541 _templateSelector.children("select").append($("<option>-- No templates --</option>").data("index", -1)); 542 } 543 544 for(var i = 0; i < templateList.length; i++) 545 { 546 var filename = selectedItem.data("fileItem").path; 547 var location = selectedItem.data("fileItem").location; 548 var namespace = templateList[i].namespace; 549 var nodename = "template"; 550 var name = templateList[i].name; 551 var match = templateList[i].match; 552 553 if(name) 554 { 555 name = templateList[i].name.replace(/'/g, "'").replace(/"/g, "\"").replace(/&/g, "&"); 556 } 557 if(match) 558 { 559 match = templateList[i].match.replace(/'/g, "'").replace(/"/g, "\"").replace(/&/g, "&"); 560 } 561 562 var infoContainer = $("<option>"); 563 564 _elements.push(infoContainer); 565 566 addChangeEventToInfoContainer(infoContainer, filename, location, nodename, namespace, name, match); 567 568 if(name && name.length > 0) 569 { 570 infoContainer.text(name); 571 } 572 if(match && match.length > 0) 573 { 574 infoContainer.text(match); 575 } 576 577 infoContainer.data("index", i); 578 _templateSelector.children("select").append(infoContainer); 579 } 580 581 _templateSelector.children("select").trigger("change"); 582 }); 529 _greenbug.populateTemplateSelectorFromFile(selectedItem.data("fileItem").path, selectedItem.data("fileItem").location, function(){_templateSelector.children("select").trigger("change")}); 583 530 }); 584 531 }) … … 654 601 _elements.push(rightBorderDiv); 655 602 } 603 604 this.populateTemplateSelectorFromFile = function(filename, location, callback) 605 { 606 var getURL = gs.xsltParams.library_name + "?a=g&rt=r&s=GetTemplateListFromFile&s1.fileName=" + filename + "&s1.locationName=" + location + "&s1.interfaceName=" + gs.xsltParams.interface_name + "&s1.siteName=" + gs.xsltParams.site_name + "&s1.collectionName=" + gs.cgiParams.c; 607 $.ajax(getURL) 608 .success(function(templateResponse) 609 { 610 var templateListStart = templateResponse.indexOf("<templateList>") + "<templateList>".length; 611 var templateListEnd = templateResponse.indexOf("</templateList>"); 612 var templateListString = templateResponse.substring(templateListStart, templateListEnd).replace(/"/g, "\""); 613 var templateList = eval(templateListString); 614 615 _templateSelector.children("select").empty(); 616 if(templateList.length == 0) 617 { 618 _templateSelector.children("select").append($("<option>-- No templates --</option>").data("index", -1)); 619 } 620 621 for(var i = 0; i < templateList.length; i++) 622 { 623 var namespace = templateList[i].namespace; 624 var nodename = "template"; 625 var name = templateList[i].name; 626 var match = templateList[i].match; 627 628 if(name) 629 { 630 name = templateList[i].name.replace(/'/g, "'").replace(/"/g, "\"").replace(/&/g, "&"); 631 } 632 if(match) 633 { 634 match = templateList[i].match.replace(/'/g, "'").replace(/"/g, "\"").replace(/&/g, "&"); 635 } 636 637 var infoContainer = $("<option>"); 638 639 _elements.push(infoContainer); 640 641 addChangeEventToInfoContainer(infoContainer, filename, location, nodename, namespace, name, match); 642 643 if(name && name.length > 0) 644 { 645 infoContainer.text(name); 646 } 647 if(match && match.length > 0) 648 { 649 infoContainer.text(match); 650 } 651 652 infoContainer.data("index", i); 653 _templateSelector.children("select").append(infoContainer); 654 } 655 656 if(callback) 657 { 658 callback(); 659 } 660 }); 661 } 656 662 657 663 //Change the current template in the XML and Visual editor … … 750 756 } 751 757 758 this.getTemplateTracker = function() 759 { 760 return _templateTracker; 761 } 762 752 763 //Turns a filename into it's location (i.e. interface/site/collection) and name 753 764 this.fileNameToLocationAndName = function(filepath) … … 776 787 filename = filepath.replace(/.*[\/\\]sites[\/\\].*[\/\\]transform[\/\\]/, ""); 777 788 } 789 790 filename = filename.replace(/\\/g, "/"); 778 791 779 792 return {location:location, filename:filename}; -
main/trunk/greenstone3/web/interfaces/default/js/visual-xml-editor.js
r27218 r27256 1146 1146 { 1147 1147 return _id; 1148 } 1149 1150 var visitCalledTemplate = function() 1151 { 1152 var url = gs.xsltParams.library_name + "?a=g&rt=r&s=ResolveCallTemplate&s1.interfaceName=" + gs.xsltParams.interface_name + "&s1.siteName=" + gs.xsltParams.site_name + "&s1.collectionName=" + gs.cgiParams.c + "&s1.fileName=" + _fileName + "&s1.templateName=" + _xmlNode.getAttribute("name"); 1153 $.ajax(url) 1154 .success(function(response) 1155 { 1156 var startIndex = response.indexOf("<requestedTemplate>") + ("<requestedTemplate>").length; 1157 var endIndex = response.indexOf("</requestedTemplate>"); 1158 1159 if(endIndex != -1) 1160 { 1161 var templateFileName = response.substring(startIndex, endIndex); 1162 var file = _greenbug.fileNameToLocationAndName(templateFileName); 1163 1164 var fileTemplateName = file.filename.replace(/\\/g, "/") + " (" + file.location + ")"; 1165 $("#veFileSelector").find("option").filter(function(){return $(this).text() == fileTemplateName}).prop("selected", true); 1166 _greenbug.populateTemplateSelectorFromFile(file.filename, file.location); 1167 _greenbug.changeCurrentTemplate(file.location, file.filename, "template", "xsl", _xmlNode.getAttribute("name"), null); 1168 } 1169 else 1170 { 1171 _greenbug.changeCurrentTemplate("interface", "gslib.xsl", "template", "xsl", _xmlNode.getAttribute("name"), null); 1172 } 1173 }); 1148 1174 } 1149 1175 … … 1249 1275 1250 1276 visitTemplateOption.button(); 1251 visitTemplateOption.click(function() 1252 { 1253 var url = gs.xsltParams.library_name + "?a=g&rt=r&s=ResolveCallTemplate&s1.interfaceName=" + gs.xsltParams.interface_name + "&s1.siteName=" + gs.xsltParams.site_name + "&s1.collectionName=" + gs.cgiParams.c + "&s1.fileName=" + _fileName + "&s1.templateName=" + _xmlNode.getAttribute("name"); 1254 $.ajax(url) 1255 .success(function(response) 1256 { 1257 var startIndex = response.indexOf("<requestedTemplate>") + ("<requestedTemplate>").length; 1258 var endIndex = response.indexOf("</requestedTemplate>"); 1259 1260 if(endIndex != -1) 1261 { 1262 var templateFileName = response.substring(startIndex, endIndex); 1263 var file = _greenbug.fileNameToLocationAndName(templateFileName); 1264 _greenbug.changeCurrentTemplate(file.location, file.filename, "template", "xsl", _xmlNode.getAttribute("name"), null); 1265 } 1266 else 1267 { 1268 _greenbug.changeCurrentTemplate("interface", "gslib.xsl", "template", "xsl", _xmlNode.getAttribute("name"), null); 1269 } 1270 }); 1271 }); 1277 visitTemplateOption.click(visitCalledTemplate); 1272 1278 } 1273 1279 } … … 1286 1292 { 1287 1293 event.stopPropagation(); 1288 _div.css("border", "1px solid orange"); 1294 if(!_selectedElement || _id != _selectedElement.data("parentVEElement").getID()) 1295 { 1296 _div.css("border", "1px solid orange"); 1297 } 1298 1289 1299 var titleString = " "; 1290 1300 if(_xmlNode.nodeType == 1) … … 1307 1317 _div.mouseout(function(event) 1308 1318 { 1309 _div.css("border", "1px solid black"); 1319 if(!_selectedElement || _id != _selectedElement.data("parentVEElement").getID()) 1320 { 1321 _div.css("border", "1px solid black"); 1322 } 1310 1323 event.stopPropagation(); 1311 1324 }); 1312 1325 _div.click(function(event) 1313 1326 { 1327 event.stopPropagation(); 1314 1328 if(_selectedElement) 1315 1329 { 1316 1330 _selectedElement.css("border", _selectedElement.prevBorder); 1331 if(_selectedElement.children("a").length) 1332 { 1333 _selectedElement.children("a").replaceWith(_selectedElement.children("a").children(".veTitleElement")); 1334 } 1317 1335 } 1318 1336 _selectedElement = _div; … … 1322 1340 _div.data("parentVEElement").focus(); 1323 1341 _div.data("parentVEElement").populateInformationDiv(); 1324 1325 event.stopPropagation(); 1342 1343 if(_xmlNode.tagName == "xsl:call-template" && _xmlNode.getAttribute("name").length > 0) 1344 { 1345 var link = $("<a>"); 1346 link.attr("href", "javascript:;"); 1347 link.click(visitCalledTemplate); 1348 link.append(_div.children(".veTitleElement")); 1349 _div.append(link); 1350 } 1326 1351 }); 1327 1352 }
Note:
See TracChangeset
for help on using the changeset viewer.