Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:zanata/zanata
Browse files Browse the repository at this point in the history
  • Loading branch information
seanf committed Jun 24, 2011
2 parents f3f964b + 2e25938 commit 75c8966
Showing 1 changed file with 38 additions and 4 deletions.
Expand Up @@ -206,6 +206,7 @@ public void onFocus(FocusEvent event)
public void onKeyUp(KeyUpEvent event)
{
eventBus.fireEvent(new EditTransUnitEvent());

// NB: if you change these, please change NavigationConsts too!
if (event.isControlKeyDown() && event.getNativeKeyCode() == KeyCodes.KEY_ENTER)
{
Expand Down Expand Up @@ -253,6 +254,17 @@ else if (event.isAltKeyDown() && event.getNativeKeyCode() == 78)
else
toggleFuzzy.setValue(true);
}
else if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER)
{
autoTextAreaSize();
}
else
{
// Remove fuzzy state for fuzzy entry when start typing
if (toggleFuzzy.getValue())
toggleFuzzy.setValue(false);

}
// these shortcuts disabled because they conflict with basic text editing:
// else if (event.isControlKeyDown() && event.getNativeKeyCode() == KeyCodes.KEY_HOME)
// { // ctrl-home
Expand Down Expand Up @@ -388,25 +400,47 @@ public void editCell(CellEditInfo cellEditInfo, TransUnit cellValue, Callback<Tr

cellViewWidget = table.getWidget(curRow, curCol);

int height = table.getWidget(curRow, curCol - 1).getOffsetHeight();
// int height = table.getWidget(curRow, curCol - 1).getOffsetHeight();

int realHeight = height > MIN_HEIGHT ? height : MIN_HEIGHT;

textArea.setHeight(realHeight + "px");
// int realHeight = height > MIN_HEIGHT ? height : MIN_HEIGHT;

//Disable it for autosize
// textArea.setHeight(realHeight + "px");
int width = table.getWidget(curRow, curCol - 1).getOffsetWidth() - 10;
// layoutTable.setHeight(realHeight + "px");
textArea.setWidth(width + "px");

table.setWidget(curRow, curCol, layoutTable);

textArea.setText(cellValue.getTarget());

autoTextAreaSize();

this.cellValue = cellValue;
textArea.setFocus(true);
DOM.scrollIntoView(table.getCellFormatter().getElement(curRow, curCol));
toggleFuzzy.setValue(cellValue.getStatus() == ContentState.NeedReview);
// refreshStateImage();
}

private void autoTextAreaSize()
{
int initLines = 2;
int growLines = 1;

Log.debug("autosize TextArea");
int rows = textArea.getVisibleLines();

while (rows > initLines)
{
textArea.setVisibleLines(--rows);
}

while (textArea.getElement().getScrollHeight() > textArea.getElement().getClientHeight())
{
textArea.setVisibleLines(textArea.getVisibleLines() + growLines);
}
}
// private void refreshStateImage()
// {
// if (cellValue.getStatus() == ContentState.New)
Expand Down

0 comments on commit 75c8966

Please sign in to comment.