- Timestamp:
- 2013-03-21T16:52:48+13:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/web/interfaces/default/js/visual-xml-editor.js
r27072 r27110 6 6 function visualXMLEditor(xmlString) 7 7 { 8 var thisEditor = this; 8 var _thisEditor = this; 9 var _greenbug; 9 10 10 11 var _globalID = 0; … … 89 90 }; 90 91 92 this.setGreenbug = function(gb) 93 { 94 _greenbug = gb; 95 } 96 91 97 this.getXML = function() 92 98 { … … 243 249 var retrieveGSLIBTemplates = function(callback) 244 250 { 245 var url = gs.xsltParams.library_name + "?a=g&rt=r&s=Get GSLIBElementsFromFile&s1.interfaceName=" + gs.xsltParams.interface_name;251 var url = gs.xsltParams.library_name + "?a=g&rt=r&s=GetTemplateListFromFile&s1.locationName=interface&s1.interfaceName=" + gs.xsltParams.interface_name + "&s1.fileName=gslib.xsl"; 246 252 247 253 $.ajax(url) … … 253 259 var listString = response.substring(startIndex, endIndex); 254 260 var list = eval(listString.replace(/"/g, "\"")); 255 256 _elemList["gslib"] = list; 261 var modifiedList = new Array(); 262 263 for(var i = 0; i < list.length; i++) 264 { 265 var current = list[i]; 266 if(current.name) 267 { 268 modifiedList.push(current.name); 269 } 270 } 271 272 _elemList["gslib"] = modifiedList; 257 273 258 274 if(callback) … … 569 585 570 586 var _textEditor = $("<div>"); 571 var _textTitle = $("<div>Text:</div>");572 587 var _nodeText = $("<div>"); 573 588 _nodeText.text(_xmlNode.nodeValue); 574 589 575 _textEditor.append(_textTitle);576 590 _textEditor.append(_nodeText); 577 591 … … 1068 1082 this.populateInformationDiv = function() 1069 1083 { 1070 thisEditor.savePendingEdits();1084 _thisEditor.savePendingEdits(); 1071 1085 _infoDiv.empty(); 1072 1086 1073 var nameElement = $("<p>");1074 1087 if(_xmlNode.nodeType == 1) 1075 1088 { 1076 nameElement.text("Name: " + _xmlNode.nodeName); 1089 var nameElementTitle = $("<div>", {"class":"ui-state-default ui-corner-all veInfoDivTitle"}).text("Element name:"); 1090 _infoDiv.append(nameElementTitle); 1091 _infoDiv.append($("<p>").text(_xmlNode.nodeName)); 1077 1092 } 1078 1093 else 1079 1094 { 1080 nameElement.text("[text node]");1081 }1082 _infoDiv.append(nameElement);1095 var textElementTitle = $("<div>", {"class":"ui-state-default ui-corner-all veInfoDivTitle"}).text("Text node:"); 1096 _infoDiv.append(textElementTitle); 1097 } 1083 1098 1084 1099 if(_xmlNode.nodeType == 1) 1085 1100 { 1086 var attributeTableTitle = $("<p>Attributes:<p/>"); 1101 var attributeTableTitle = $("<div>", {"class":"ui-state-default ui-corner-all veInfoDivTitle"}); 1102 attributeTableTitle.text("Attributes:"); 1087 1103 var attributeTable = $("<table>"); 1088 1104 attributeTable.addClass("veAttributeTableContainer"); … … 1099 1115 _infoDiv.append(attributeTable); 1100 1116 1117 var addDiv = $("<div>", {"class":"veInfoDivTitle"}); 1101 1118 var addSelect = $("<select>"); 1102 1119 addSelect.append("<option>[blank]</option>", {value:"[blank]"}); … … 1149 1166 _transactions.push({type:"addAttr", row:row}) 1150 1167 }); 1151 _infoDiv.append(addSelect); 1152 _infoDiv.append(addButton); 1168 addDiv.append(addSelect); 1169 addDiv.append(addButton); 1170 _infoDiv.append(addDiv); 1153 1171 addButton.button(); 1172 1173 /* 1174 if(_xmlNode.tagName == "xsl:call-template" && _xmlNode.getAttribute("name").length > 0) 1175 { 1176 var extraOptionsTitle = $("<div>", {"class":"ui-state-default ui-corner-all veInfoDivTitle"}).text("Additional options:"); 1177 var visitTemplateOption = $("<button>View called template</button>"); 1178 1179 _infoDiv.append(extraOptionsTitle); 1180 _infoDiv.append(visitTemplateOption); 1181 1182 visitTemplateOption.button(); 1183 visitTemplateOption.click(function() 1184 { 1185 var template = ""; 1186 template += '<xsl:template match="/">'; 1187 template += '<calledTemplate>'; 1188 var params = $(_xmlNode).children("xsl\\:with-param"); 1189 if(!params.length) 1190 { 1191 template += '<xsl:call-template name="' + _xmlNode.getAttribute("name") + '"/>'; 1192 } 1193 else 1194 { 1195 template += '<xsl:call-template name="' + _xmlNode.getAttribute("name") + '">'; 1196 for(var i = 0; i < params.length; i++) 1197 { 1198 var param = params.eq(i); 1199 template += "<xsl:with-param"; 1200 for(var j = 0; j < param[0].attributes.length; j++) 1201 { 1202 var attr = param[0].attributes[j]; 1203 template += " " + attr.name + "=\"" + attr.value + "\""; 1204 } 1205 template += "/>"; 1206 } 1207 template += '</xsl:call-template>'; 1208 } 1209 template += '</calledTemplate>'; 1210 template += '</xsl:template>'; 1211 template = template.replace(" ", "%20"); 1212 1213 var url = document.URL; 1214 if(url.indexOf("?") == url.length - 1) 1215 { 1216 url += "ilt=" + template; 1217 } 1218 else if(url.indexOf("?") != -1) 1219 { 1220 url += "&ilt=" + template; 1221 } 1222 else 1223 { 1224 url += "?ilt=" + template; 1225 } 1226 1227 $.ajax(url) 1228 .success(function(response) 1229 { 1230 var xml = $.parseXML(response); 1231 var debug = $(xml).find("calledTemplate debug"); 1232 1233 _greenbug.changeCurrentTemplate(debug[0].getAttribute("filename"), "template", "xsl", debug[0].getAttribute("name"), null); 1234 $(".gbTemplateContainer").css("border", "1px dashed #AAAAAA"); 1235 }); 1236 }); 1237 } 1238 */ 1154 1239 } 1155 1240 … … 1159 1244 _infoDiv.append(textNode.getDiv()); 1160 1245 } 1161 }1162 1163 this.remove = function()1164 {1165 var divParent = _div.parents(".veElement");1166 _transactions.push({type:"remMvElem", vElemParent:_div.parent(), vElemPos:_div.index(), vElem:_div});1167 _div.data("expanded", "normal");1168 $(_xmlNode).remove();1169 _div.detach();1170 _infoDiv.empty();1171 1172 if(divParent.length)1173 {1174 divParent.first().trigger("click");1175 }1176 1177 $("#veTrash").children("img").attr("src", gs.imageURLs.trashFull);1178 1246 } 1179 1247 … … 1247 1315 return false; 1248 1316 } 1317 1318 this.remove = function() 1319 { 1320 var divParent = _div.parents(".veElement"); 1321 _transactions.push({type:"remMvElem", vElemParent:_div.parent(), vElemPos:_div.index(), vElem:_div}); 1322 _div.data("expanded", "normal"); 1323 $(_xmlNode).remove(); 1324 _div.detach(); 1325 _infoDiv.empty(); 1326 1327 if(divParent.length) 1328 { 1329 divParent.first().trigger("click"); 1330 } 1331 1332 $("#veTrash").children("img").attr("src", gs.imageURLs.trashFull); 1333 } 1249 1334 1250 1335 this.expand = function()
Note:
See TracChangeset
for help on using the changeset viewer.