Changeset 27015 for main/trunk
- Timestamp:
- 2013-03-07T10:01:15+13:00 (11 years ago)
- Location:
- main/trunk/greenstone3/web
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/web/WEB-INF/classes/interface_default.properties
r26579 r27015 12 12 page_icon_image=interfaces/__INTERFACE_NAME__/images/itext.gif 13 13 trash_full_image=interfaces/__INTERFACE_NAME__/images/trash-full.png 14 trash_empty_image=interfaces/__INTERFACE_NAME__/images/trash-empty.png 14 15 blank_image=interfaces/__INTERFACE_NAME__/images/blankImage.png 15 16 next_image=interfaces/__INTERFACE_NAME__/images/next.png -
main/trunk/greenstone3/web/interfaces/default/js/debug_scripts.js
r27013 r27015 38 38 var _styleFunctions = new Array(); 39 39 40 var partialPageReload = function( )40 var partialPageReload = function(callback) 41 41 { 42 42 $.ajax(document.URL) … … 70 70 alert("There was an error reloading the page, please reload manually."); 71 71 }); 72 73 if(callback) 74 { 75 callback(); 76 } 72 77 } 73 78 … … 166 171 if(_isVisualEditor) 167 172 { 173 _vEditor.savePendingEdits(); 168 174 xmlString = new XMLSerializer().serializeToString(_vEditor.getXML()); 169 175 } … … 190 196 if(_currentMatch && _currentMatch.length > 0){parameters["s1.match"] = _currentMatch;} 191 197 192 _saveButton.button("option", "label", "Saving...");193 198 _saveButton.button("option", "disabled", true); 199 $.blockUI({message:'<div class="ui-state-active">Saving, please wait...</div>'}); 194 200 195 201 $.post(url, parameters) … … 199 205 .success(function() 200 206 { 201 alert("The template has been saved successfully.");207 partialPageReload(function(){$.unblockUI();}); 202 208 }) 203 209 .error(function() 204 210 { 211 $.unblockUI(); 205 212 alert("Error reloading collection."); 206 213 }) 207 214 .complete(function() 208 215 { 209 _saveButton.button("option", "label", "Save changes");210 216 _saveButton.button("option", "disabled", false); 211 partialPageReload();212 217 }); 213 218 }) … … 227 232 if(_isVisualEditor) 228 233 { 234 _vEditor.savePendingEdits(); 229 235 _vEditor.getMainDiv().hide(); 230 236 var containerNode = _vEditor.getXML().firstChild; -
main/trunk/greenstone3/web/interfaces/default/js/visual-xml-editor.js
r27011 r27015 6 6 function visualXMLEditor(xmlString) 7 7 { 8 var thisEditor = this; 9 8 10 var _globalID = 0; 9 11 … … 27 29 var _origDDPosition; 28 30 31 var _editingNodes = new Array(); 32 29 33 var _overList = new Array(); 30 34 _overList.freeSpaces = new Array(); … … 82 86 } 83 87 resizeAll(); 88 89 //Check if we need to change the recycle bin icon 90 var found = false; 91 for(var i = 0; i < _transactions.length; i++) 92 { 93 if(_transactions[i].type == "remMvElem"){found = true; break;} 94 } 95 96 if(!found) 97 { 98 $("#veTrash").children("img").attr("src", gs.imageURLs.trashEmpty); 99 } 84 100 } 85 101 //Undo an added attribute … … 162 178 var placeTrashBin = function() 163 179 { 164 var bin = $("<div id=\"veTrash\">Recycle Bin</div>"); 180 var binImage = $("<img src=\"" + gs.imageURLs.trashEmpty + "\"/>"); 181 var bin = $("<div id=\"veTrash\">"); 182 bin.append(binImage); 165 183 bin.addClass("ui-state-default"); 166 184 bin.addClass("ui-corner-all"); … … 183 201 var elemList = 184 202 { 185 html:["a", "br", "div", "li", "link", " script", "span", "table", "td", "tr", "ul"],203 html:["a", "br", "div", "li", "link", "p", "script", "span", "table", "td", "tr", "ul"], 186 204 xsl: 187 205 [ … … 343 361 } 344 362 363 this.savePendingEdits = function() 364 { 365 while(_editingNodes && _editingNodes.length > 0) 366 { 367 var attr = _editingNodes.pop(); 368 attr.saveEdits(); 369 } 370 } 371 345 372 var addToOverList = function(veElement) 346 373 { … … 475 502 _mainDiv.append($("<div>", {"style":"clear:both;"})); 476 503 } 477 504 505 // *********************************************************************** // 506 // Visual Editor Text // 507 // This inner class represents a single xml text node in the visual editor // 508 // *********************************************************************** // 509 510 var VEText = function(node) 511 { 512 var _thisNode = this; 513 var _xmlNode = node; 514 515 var _textEditor = $("<div>"); 516 var textTitle = $("<div>Text:</div>"); 517 var _nodeText = $("<div>"); 518 _nodeText.text(_xmlNode.nodeValue); 519 520 _textEditor.append(textTitle); 521 _textEditor.append(_nodeText); 522 523 var editButton = $("<button>edit text</button>"); 524 editButton.click(function() 525 { 526 if(editButton.text() == "edit text") 527 { 528 _thisNode.editMode(); 529 } 530 else 531 { 532 _thisNode.saveEdits(); 533 } 534 }); 535 _textEditor.append(editButton); 536 537 this.editMode = function() 538 { 539 _editingNodes.push(_thisNode); 540 _nodeText.data("prevTextValue", _nodeText.text()); 541 var textArea = $("<textarea>"); 542 textArea.val(_nodeText.text()); 543 _nodeText.text(""); 544 _nodeText.append(textArea); 545 editButton.text("done"); 546 } 547 548 this.saveEdits = function() 549 { 550 for(var i = 0; i < _editingNodes.length; i++) 551 { 552 if(_editingNodes[i] == _thisNode) 553 { 554 _editingNodes.splice(i, 1); 555 break; 556 } 557 } 558 559 _transactions.push({type:"editText", elem:_xmlNode, vElem: _nodeText, value:_nodeText.data("prevTextValue")}); 560 var textArea = _nodeText.find("textarea"); 561 var newValue = textArea.val(); 562 _xmlNode.nodeValue = newValue; 563 _nodeText.empty(); 564 _nodeText.text(newValue); 565 editButton.text("edit text"); 566 } 567 568 this.getDiv = function() 569 { 570 return _textEditor; 571 } 572 } 573 478 574 // *********************************************************************** // 479 575 // Visual Editor Attribute // … … 502 598 _value = attrElem.value; 503 599 } 504 505 600 var _xmlElem = xmlElem; 506 601 var _row; 507 602 603 var _thisAttr = this; 604 508 605 this.getName = function() 509 606 { … … 534 631 var cell = $("<td>", {"class":"veEditCell"}); 535 632 var link = $("<a href=\"javascript:;\">edit</a>"); 633 536 634 link.click(function() 537 635 { 538 var nameCell = _row.children("td").eq(0); 539 var valueCell = _row.children("td").eq(1); 540 if(link.text() == "edit") 541 { 542 link.text("done"); 543 544 var nameInput = $("<input type=\"text\">"); 545 nameInput.width(nameCell.width() - 5); 546 nameInput.val(_name); 547 548 var valueInput = $("<input type=\"text\">"); 549 valueInput.width(valueCell.width() - 5); 550 valueInput.val(_value); 551 552 nameCell.text(""); 553 valueCell.text(""); 554 555 nameCell.append(nameInput); 556 valueCell.append(valueInput); 557 } 558 else 559 { 560 link.text("edit"); 561 562 var nameInput = nameCell.children("input"); 563 var valueInput = valueCell.children("input"); 564 565 var name = nameInput.val(); 566 var value = valueInput.val(); 567 568 nameCell.empty(); 569 nameCell.text(name); 570 571 valueCell.empty(); 572 valueCell.text(value); 573 574 if(nameCell.data("prevName") != "") 575 { 576 _xmlElem.removeAttribute(_name); 577 } 578 _xmlElem.setAttribute(name, value); 579 580 _transactions.push({type:"editAttr", elem:_xmlElem, row:_row, newName:name, name:_name, value:_value}); 581 582 _name = name; 583 _value = value; 584 } 636 _thisAttr.editMode(); 585 637 }); 586 638 cell.append(link); … … 621 673 622 674 return tableRow; 675 } 676 677 this.editMode = function() 678 { 679 _editingNodes.push(_thisAttr); 680 681 var nameCell = _row.children("td").eq(0); 682 var valueCell = _row.children("td").eq(1); 683 var editLink = _row.children("td").eq(2).find("a"); 684 685 editLink.text("done"); 686 editLink.off("click"); 687 editLink.click(function() 688 { 689 _thisAttr.saveEdits(); 690 }); 691 692 var nameInput = $("<input type=\"text\">"); 693 nameInput.width(nameCell.width() - 5); 694 nameInput.val(_name); 695 696 var valueInput = $("<input type=\"text\">"); 697 valueInput.width(valueCell.width() - 5); 698 valueInput.val(_value); 699 700 nameCell.text(""); 701 valueCell.text(""); 702 703 nameCell.append(nameInput); 704 valueCell.append(valueInput); 705 706 nameInput.focus(); 707 } 708 709 this.saveEdits = function() 710 { 711 for(var i = 0; i < _editingNodes.length; i++) 712 { 713 if(_editingNodes[i] == _thisAttr) 714 { 715 _editingNodes.splice(i, 1); 716 break; 717 } 718 } 719 720 var nameCell = _row.children("td").eq(0); 721 var valueCell = _row.children("td").eq(1); 722 var editLink = _row.children("td").eq(2).find("a"); 723 724 editLink.text("edit"); 725 editLink.off("click"); 726 editLink.click(function() 727 { 728 _thisAttr.editMode(); 729 }); 730 731 var nameInput = nameCell.children("input"); 732 var valueInput = valueCell.children("input"); 733 734 nameInput.blur(); 735 valueInput.blur(); 736 737 var name = nameInput.val(); 738 var value = valueInput.val(); 739 740 nameCell.empty(); 741 nameCell.text(name); 742 743 valueCell.empty(); 744 valueCell.text(value); 745 746 if(nameCell.data("prevName") != "") 747 { 748 _xmlElem.removeAttribute(_name); 749 } 750 _xmlElem.setAttribute(name, value); 751 752 _transactions.push({type:"editAttr", elem:_xmlElem, row:_row, newName:name, name:_name, value:_value}); 753 754 _name = name; 755 _value = value; 623 756 } 624 757 } … … 858 991 this.populateInformationDiv = function() 859 992 { 993 thisEditor.savePendingEdits(); 860 994 _infoDiv.empty(); 861 995 … … 894 1028 var row = newAtt.getAsTableRow(); 895 1029 attributeTable.append(row); 1030 newAtt.editMode(); 896 1031 _transactions.push({type:"addAttr", row:row}) 897 1032 }); … … 901 1036 if(_xmlNode.nodeType == 3) 902 1037 { 903 var textEditor = $("<div>"); 904 var textTitle = $("<div>Text:</div>"); 905 var nodeText = $("<div>"); 906 nodeText.text(_xmlNode.nodeValue); 907 908 textEditor.append(textTitle); 909 textEditor.append(nodeText); 910 911 _infoDiv.append(textEditor); 912 913 var editButton = $("<button>edit text</button>"); 914 editButton.click(function() 915 { 916 if(editButton.text() == "edit text") 917 { 918 nodeText.data("prevTextValue", nodeText.text()); 919 var textArea = $("<textarea>"); 920 textArea.val(nodeText.text()); 921 nodeText.text(""); 922 nodeText.append(textArea); 923 editButton.text("done"); 924 } 925 else 926 { 927 _transactions.push({type:"editText", elem:_xmlNode, vElem: nodeText, value:nodeText.data("prevTextValue")}); 928 var textArea = nodeText.find("textarea"); 929 var newValue = textArea.val(); 930 _xmlNode.nodeValue = newValue; 931 nodeText.empty(); 932 nodeText.text(newValue); 933 editButton.text("edit text"); 934 } 935 }); 936 937 textEditor.append(editButton); 938 } 939 940 _infoDiv.append($("<br>")); 941 _infoDiv.append($("<br>")); 942 943 var removeButton = $("<button>Delete this element</button>"); 944 _infoDiv.append(removeButton); 945 removeButton.click(function() 946 { 947 _div.data("parentVEElement").remove(); 948 }); 1038 var textNode = new VEText(_xmlNode); 1039 _infoDiv.append(textNode.getDiv()); 1040 } 949 1041 } 950 1042 … … 962 1054 divParent.first().trigger("click"); 963 1055 } 1056 1057 $("#veTrash").children("img").attr("src", gs.imageURLs.trashFull); 964 1058 } 965 1059 -
main/trunk/greenstone3/web/interfaces/default/style/core.css
r27011 r27015 1034 1034 right:0px; 1035 1035 bottom:0px; 1036 width:5%;1037 height:20%;1038 1036 text-align:center; 1039 1037 }
Note:
See TracChangeset
for help on using the changeset viewer.