Changeset 27015 for main/trunk


Ignore:
Timestamp:
2013-03-07T10:01:15+13:00 (11 years ago)
Author:
sjm84
Message:

Adding a recycle bin icon that changes if there has been an element removed

Location:
main/trunk/greenstone3/web
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/web/WEB-INF/classes/interface_default.properties

    r26579 r27015  
    1212page_icon_image=interfaces/__INTERFACE_NAME__/images/itext.gif
    1313trash_full_image=interfaces/__INTERFACE_NAME__/images/trash-full.png
     14trash_empty_image=interfaces/__INTERFACE_NAME__/images/trash-empty.png
    1415blank_image=interfaces/__INTERFACE_NAME__/images/blankImage.png
    1516next_image=interfaces/__INTERFACE_NAME__/images/next.png
  • main/trunk/greenstone3/web/interfaces/default/js/debug_scripts.js

    r27013 r27015  
    3838    var _styleFunctions = new Array();
    3939   
    40     var partialPageReload = function()
     40    var partialPageReload = function(callback)
    4141    {
    4242        $.ajax(document.URL)
     
    7070            alert("There was an error reloading the page, please reload manually.");
    7171        });
     72       
     73        if(callback)
     74        {
     75            callback();
     76        }
    7277    }
    7378   
     
    166171                if(_isVisualEditor)
    167172                {
     173                    _vEditor.savePendingEdits();
    168174                    xmlString = new XMLSerializer().serializeToString(_vEditor.getXML());
    169175                }
     
    190196                if(_currentMatch && _currentMatch.length > 0){parameters["s1.match"] = _currentMatch;}
    191197
    192                 _saveButton.button("option", "label", "Saving...");
    193198                _saveButton.button("option", "disabled", true);
     199                $.blockUI({message:'<div class="ui-state-active">Saving, please wait...</div>'});
    194200
    195201                $.post(url, parameters)
     
    199205                    .success(function()
    200206                    {
    201                         alert("The template has been saved successfully.");
     207                        partialPageReload(function(){$.unblockUI();});
    202208                    })
    203209                    .error(function()
    204210                    {
     211                        $.unblockUI();
    205212                        alert("Error reloading collection.");
    206213                    })
    207214                    .complete(function()
    208215                    {
    209                         _saveButton.button("option", "label", "Save changes");
    210216                        _saveButton.button("option", "disabled", false);
    211                         partialPageReload();
    212217                    });
    213218                })
     
    227232                if(_isVisualEditor)
    228233                {
     234                    _vEditor.savePendingEdits();
    229235                    _vEditor.getMainDiv().hide();
    230236                    var containerNode = _vEditor.getXML().firstChild;
  • main/trunk/greenstone3/web/interfaces/default/js/visual-xml-editor.js

    r27011 r27015  
    66function visualXMLEditor(xmlString)
    77{
     8    var thisEditor = this;
     9
    810    var _globalID = 0;
    911
     
    2729    var _origDDPosition;
    2830   
     31    var _editingNodes = new Array();
     32   
    2933    var _overList = new Array();
    3034    _overList.freeSpaces = new Array();
     
    8286                }
    8387                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                }
    84100            }
    85101            //Undo an added attribute
     
    162178    var placeTrashBin = function()
    163179    {
    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);
    165183        bin.addClass("ui-state-default");
    166184        bin.addClass("ui-corner-all");
     
    183201        var elemList =
    184202        {
    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"],
    186204            xsl:
    187205            [
     
    343361    }
    344362   
     363    this.savePendingEdits = function()
     364    {
     365        while(_editingNodes && _editingNodes.length > 0)
     366        {
     367            var attr = _editingNodes.pop();
     368            attr.saveEdits();
     369        }
     370    }
     371   
    345372    var addToOverList = function(veElement)
    346373    {
     
    475502        _mainDiv.append($("<div>", {"style":"clear:both;"}));       
    476503    }
    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   
    478574    // *********************************************************************** //
    479575    // Visual Editor Attribute                                                 //
     
    502598            _value = attrElem.value;
    503599        }
    504        
    505600        var _xmlElem = xmlElem;
    506601        var _row;
    507602
     603        var _thisAttr = this;
     604       
    508605        this.getName = function()
    509606        {
     
    534631            var cell = $("<td>", {"class":"veEditCell"});
    535632            var link = $("<a href=\"javascript:;\">edit</a>");
     633           
    536634            link.click(function()
    537635            {
    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();
    585637            });
    586638            cell.append(link);
     
    621673
    622674            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;
    623756        }
    624757    }
     
    858991        this.populateInformationDiv = function()
    859992        {
     993            thisEditor.savePendingEdits();
    860994            _infoDiv.empty();
    861995
     
    8941028                    var row = newAtt.getAsTableRow();
    8951029                    attributeTable.append(row);
     1030                    newAtt.editMode();
    8961031                    _transactions.push({type:"addAttr", row:row})
    8971032                });
     
    9011036            if(_xmlNode.nodeType == 3)
    9021037            {
    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            }
    9491041        }
    9501042       
     
    9621054                divParent.first().trigger("click");
    9631055            }
     1056           
     1057            $("#veTrash").children("img").attr("src", gs.imageURLs.trashFull);
    9641058        }
    9651059
  • main/trunk/greenstone3/web/interfaces/default/style/core.css

    r27011 r27015  
    10341034    right:0px;
    10351035    bottom:0px;
    1036     width:5%;
    1037     height:20%;
    10381036    text-align:center;
    10391037}
Note: See TracChangeset for help on using the changeset viewer.