Changeset 27016 for main/trunk/greenstone3
- Timestamp:
- 2013-03-07T13:15:30+13:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/web/interfaces/default/js/visual-xml-editor.js
r27015 r27016 36 36 var _transactions = new Array(); 37 37 38 var _validAttrList = 39 { 40 gsf: 41 { 42 "cgi-param":["name"], 43 "collectionText":["args", "name"], 44 "displayItem":["name"], 45 "displayText":["name"], 46 "equivlinkgs3":["name"], 47 "foreach-metadata":["name", "separator"], 48 "icon":["type"], 49 "if-metadata-exists":["name"], 50 "image":["type"], 51 "interfaceText":["name"], 52 "link":["OID", "OIDmetadata", "name", "nodeID", "target", "title", "titlekey", "type"], 53 "metadata":["format", "hidden", "name", "pos", "prefix", "separator", "suffix", "type"], 54 "script":["src"], 55 "style":["src"], 56 "switch":["preprocess", "test", "test-value"] 57 } 58 } 59 60 var _elemList = 61 { 62 html:["a", "br", "div", "li", "link", "p", "script", "span", "table", "td", "tr", "ul"], 63 xsl: 64 [ 65 "apply-imports", "apply-templates", "attribute", "attribute-set", "call-template", 66 "choose", "copy", "copy-of", "decimal-format", "element", 67 "fallback", "for-each", "if", "import", "include", 68 "key", "message", "namespace-alias", "number", "otherwise", 69 "output", "param", "preserve-space", "processing-instruction", "sort", 70 "strip-space", "stylesheet", "template", "text", "transform", 71 "value-of", "variable", "when", "with-param" 72 ], 73 gsf: 74 [ 75 "cgi-param", "choose-metadata", "collectionText", "displayItem", "displayText", 76 "equivlinkgs3", "foreach-metadata", "icon", "if-metadata-exists", "image", 77 "interfaceText", "link", "meta-value", "metadata", "script", 78 "style", "switch", "template", "text", "variable" 79 ] 80 }; 81 38 82 var _childRestrictions = 39 83 { … … 199 243 var populateToolbar = function() 200 244 { 201 var elemList =202 {203 html:["a", "br", "div", "li", "link", "p", "script", "span", "table", "td", "tr", "ul"],204 xsl:205 [206 "apply-imports", "apply-templates", "attribute", "attribute-set", "call-template",207 "choose", "copy", "copy-of", "decimal-format", "element",208 "fallback", "for-each", "if", "import", "include",209 "key", "message", "namespace-alias", "number", "otherwise",210 "output", "param", "preserve-space", "processing-instruction", "sort",211 "strip-space", "stylesheet", "template", "text", "transform",212 "value-of", "variable", "when", "with-param"213 ],214 gsf:215 [216 "cgi-param", "choose-metadata", "collectionText", "displayItem", "displayText",217 "equivlinkgs3", "foreach-metadata", "icon", "if-metadata-exists", "image",218 "interfaceText", "link", "meta-value", "metadata", "script",219 "style", "switch", "template", "text", "variable"220 ]221 };222 223 245 var tabHolder = $("<ul>"); 224 246 _toolboxDiv.append(tabHolder); 225 247 226 for(var key in elemList)227 { 228 var currentList = elemList[key];248 for(var key in _elemList) 249 { 250 var currentList = _elemList[key]; 229 251 230 252 var tab = $("<li>"); … … 675 697 } 676 698 677 this.editMode = function( )699 this.editMode = function(editValue) 678 700 { 679 701 _editingNodes.push(_thisAttr); … … 704 726 valueCell.append(valueInput); 705 727 706 nameInput.focus(); 728 if(editValue) 729 { 730 valueInput.focus(); 731 } 732 else 733 { 734 nameInput.focus(); 735 } 707 736 } 708 737 … … 1022 1051 _infoDiv.append(attributeTable); 1023 1052 1053 var addSelect = $("<select>"); 1054 addSelect.append("<option>[blank]</option>", {value:"[blank]"}); 1055 var fullName = _xmlNode.tagName; 1056 var namespace; 1057 var nodeName; 1058 if(fullName.indexOf(":") == -1) 1059 { 1060 namespace = "no namespace"; 1061 nodeName = fullName; 1062 } 1063 else 1064 { 1065 namespace = fullName.substring(0, fullName.indexOf(":")); 1066 nodeName = fullName.substring(fullName.indexOf(":") + 1); 1067 } 1068 var nameList = _validAttrList[namespace]; 1069 if(nameList) 1070 { 1071 var nameList = _validAttrList[namespace]; 1072 var attrList = nameList[nodeName]; 1073 if(attrList) 1074 { 1075 for(var i = 0; i < attrList.length; i++) 1076 { 1077 addSelect.append($("<option>" + attrList[i] + "</option>", {value:attrList[i]})); 1078 } 1079 } 1080 } 1081 1024 1082 var addButton = $("<button>Add attribute</button>"); 1025 1083 addButton.click(function() 1026 1084 { 1027 var newAtt = new VEAttribute(null, _xmlNode, "", ""); 1085 var newAtt; 1086 var editModeValue; 1087 if(addSelect.find(":selected").val() == "[blank]") 1088 { 1089 newAtt = new VEAttribute(null, _xmlNode, "", ""); 1090 editModeValue = false; 1091 } 1092 else 1093 { 1094 newAtt = new VEAttribute(null, _xmlNode, addSelect.find(":selected").val(), ""); 1095 editModeValue = true; 1096 } 1097 1028 1098 var row = newAtt.getAsTableRow(); 1029 1099 attributeTable.append(row); 1030 newAtt.editMode( );1100 newAtt.editMode(editModeValue); 1031 1101 _transactions.push({type:"addAttr", row:row}) 1032 1102 }); 1103 _infoDiv.append(addSelect); 1033 1104 _infoDiv.append(addButton); 1034 1105 }
Note:
See TracChangeset
for help on using the changeset viewer.