Changeset 27072 for main/trunk


Ignore:
Timestamp:
2013-03-13T10:43:08+13:00 (11 years ago)
Author:
sjm84
Message:

Various fixes and resizing will now only be done if it is necessary

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/web/interfaces/default/js/visual-xml-editor.js

    r27055 r27072  
    340340
    341341        _toolboxDiv.tabs();
     342       
     343        customCreateButton.button();
    342344    }
    343345
     
    420422    var addToOverList = function(veElement)
    421423    {
     424        if(veElement.getDiv().data("toolbar"))
     425        {
     426            return;
     427        }
     428   
    422429        for(var i = 0; i < _overList.length; i++)
    423430        {
     
    562569   
    563570        var _textEditor = $("<div>");
    564         var textTitle = $("<div>Text:</div>");
     571        var _textTitle = $("<div>Text:</div>");
    565572        var _nodeText = $("<div>");
    566573        _nodeText.text(_xmlNode.nodeValue);
    567574
    568         _textEditor.append(textTitle);
     575        _textEditor.append(_textTitle);
    569576        _textEditor.append(_nodeText);
    570577       
    571         var editButton = $("<button>edit text</button>");
    572         editButton.click(function()
    573         {
    574             if(editButton.text() == "edit text")
     578        var _editButton = $("<button>Edit text</button>");
     579        _editButton.click(function()
     580        {
     581            if(_editButton.button("option", "label") == "Edit text")
    575582            {
    576583                _thisNode.editMode();
     
    581588            }
    582589        });
    583         _textEditor.append(editButton);
     590        _textEditor.append(_editButton);
    584591       
    585592        this.editMode = function()
     
    591598            _nodeText.text("");
    592599            _nodeText.append(textArea);
    593             editButton.text("done");
     600            _editButton.button("option", "label", "Done");
    594601        }
    595602
     
    611618            _nodeText.empty();
    612619            _nodeText.text(newValue);
    613             editButton.text("edit text");
     620            _editButton.button("option", "label", "Edit text");
    614621        }
    615622
    616623        this.getDiv = function()
    617624        {
     625            //A hack to make sure the edit text button is styled correctly
     626            setTimeout(function(){_editButton.button()}, 1);
    618627            return _textEditor;
    619628        }
     
    964973                        _div.data("parentVEElement").setShortName(false);
    965974                    }
    966                    
    967                     _div.data("dragging", false);
    968                     _div.data("toolbar", false);
    969975
    970976                    _div.css("border", "1px solid black");
     
    972978                   
    973979                    //If the element was not dropped in a valid place then put it back
    974                     if(!_validDropSpot)
     980                    if(!_validDropSpot && !_div.data("toolbar"))
    975981                    {
    976982                        _div.detach();
     
    10151021                    }
    10161022                   
     1023                    _div.data("dragging", false);
     1024                    _div.data("toolbar", false);
     1025                   
    10171026                    _overList = new Array();
    10181027                    _overList.freeSpaces = new Array();
     
    11421151                _infoDiv.append(addSelect);
    11431152                _infoDiv.append(addButton);
     1153                addButton.button();
    11441154            }
    11451155
     
    12061216                _div.prevBorder = _div.css("border");
    12071217                _div.css("border", "red solid 1px");
    1208                
     1218
    12091219                _div.data("parentVEElement").focus();
    12101220                _div.data("parentVEElement").populateInformationDiv();
     
    12121222                event.stopPropagation();
    12131223            });
     1224        }
     1225       
     1226        var checkResizeNecessary = function()
     1227        {
     1228            var elemsToCheck = _div.find(".veTitleElement");
     1229            for(var i = 0; i < elemsToCheck.length; i++)
     1230            {
     1231                var titleElem = elemsToCheck.eq(i);
     1232                titleElem.html("<span>" + titleElem.html() + "</span>");
     1233                var titleSpan = titleElem.children("span");
     1234
     1235                var resizeNecessary = false;
     1236                if(titleSpan.width() >= titleElem.parent().width())
     1237                {
     1238                    resizeNecessary = true;
     1239                }
     1240                titleElem.html(titleSpan.text());
     1241               
     1242                if(resizeNecessary)
     1243                {
     1244                    return true;
     1245                }
     1246            }
     1247            return false;
    12141248        }
    12151249
     
    12441278        this.focus = function()
    12451279        {
    1246             _div.data("parentVEElement").expand();
    1247            
    1248             var parents = _div.parents(".veElement");
    1249             parents.each(function()
    1250             {
    1251                 $(this).data("parentVEElement").expand();
    1252             });
     1280            if(checkResizeNecessary())
     1281            {
     1282                _div.data("parentVEElement").expand();
     1283               
     1284                var parents = _div.parents(".veElement");
     1285                parents.each(function()
     1286                {
     1287                    $(this).data("parentVEElement").expand();
     1288                });
     1289            }
    12531290
    12541291            _div.data("parentVEElement").evenlyDistributeChildren();
Note: See TracChangeset for help on using the changeset viewer.