mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-09-12 07:10:07 +02:00
text editor with position done
This commit is contained in:
parent
1b7f131602
commit
3716b1a3b9
@ -182,30 +182,27 @@ mindplot.MultilineTextEditor = new Class({
|
|||||||
font.size = nodeText.getHtmlFontSize();
|
font.size = nodeText.getHtmlFontSize();
|
||||||
font.color = nodeText.getColor();
|
font.color = nodeText.getColor();
|
||||||
this._setStyle(font);
|
this._setStyle(font);
|
||||||
|
var me = this;
|
||||||
// Set editor's initial size
|
// Set editor's initial size
|
||||||
var displayFunc = function () {
|
var displayFunc = function () {
|
||||||
// Position the editor and set the size...
|
// Position the editor and set the size...
|
||||||
var textShape = topic.getTextShape();
|
var textShape = topic.getTextShape();
|
||||||
|
|
||||||
$('#textContainer').position({
|
me._containerElem.css('display', 'block');
|
||||||
my: "left top",
|
|
||||||
at: "left bottom",
|
|
||||||
of: $(textShape)[0]
|
|
||||||
// collision: "fit"
|
|
||||||
});
|
|
||||||
|
|
||||||
this._containerElem.css('display', 'block');
|
//FIXME: Im not sure if this is best way...
|
||||||
|
var shapePosition = textShape.getNativePosition();
|
||||||
|
me._containerElem.offset(shapePosition);
|
||||||
|
|
||||||
// Set editor's initial text ...
|
// Set editor's initial text ...
|
||||||
var text = $defined(defaultText) ? defaultText : topic.getText();
|
var text = $defined(defaultText) ? defaultText : topic.getText();
|
||||||
this._setText(text);
|
me._setText(text);
|
||||||
|
|
||||||
// Set the element focus and select the current text ...
|
// Set the element focus and select the current text ...
|
||||||
var inputElem = this._getTextareaElem();
|
var inputElem = me._getTextareaElem();
|
||||||
this._positionCursor(inputElem, !$defined(defaultText));
|
me._positionCursor(inputElem, !$defined(defaultText));
|
||||||
|
|
||||||
}.bind(this);
|
};
|
||||||
|
|
||||||
this._timeoutId = displayFunc.delay(10);
|
this._timeoutId = displayFunc.delay(10);
|
||||||
},
|
},
|
||||||
|
@ -147,25 +147,24 @@ mindplot.TextEditor = new Class({
|
|||||||
var text = $defined(defaultText) ? defaultText : topic.getText();
|
var text = $defined(defaultText) ? defaultText : topic.getText();
|
||||||
this._setText(text);
|
this._setText(text);
|
||||||
|
|
||||||
|
var me = this;
|
||||||
// Set editor's initial size
|
// Set editor's initial size
|
||||||
var displayFunc = function() {
|
var displayFunc = function() {
|
||||||
// Position the editor and set the size...
|
// Position the editor and set the size...
|
||||||
var textShape = this._topic.getTextShape();
|
var textShape = me._topic.getTextShape();
|
||||||
textShape.positionRelativeTo(this._containerElem, {
|
|
||||||
position: {x: 'left',y:'top'},
|
|
||||||
edge: {x: 'left', y: 'top'}
|
|
||||||
});
|
|
||||||
this._containerElem.setStyle('display', 'block');
|
|
||||||
|
|
||||||
|
me._containerElem.css('display', 'block');
|
||||||
|
|
||||||
|
me._containerElem.offset(textShape.getNativePosition());
|
||||||
// Set size ...
|
// Set size ...
|
||||||
var elemSize = topic.getSize();
|
var elemSize = topic.getSize();
|
||||||
this._setEditorSize(elemSize.width, elemSize.height);
|
me._setEditorSize(elemSize.width, elemSize.height);
|
||||||
|
|
||||||
var textareaElem = this._getTextareaElem();
|
var textareaElem = me._getTextareaElem();
|
||||||
textareaElem.focus();
|
textareaElem.focus();
|
||||||
this._positionCursor(textareaElem, !$defined(defaultText));
|
me._positionCursor(textareaElem, !$defined(defaultText));
|
||||||
|
|
||||||
}.bind(this);
|
};
|
||||||
|
|
||||||
displayFunc.delay(10);
|
displayFunc.delay(10);
|
||||||
},
|
},
|
||||||
|
@ -137,6 +137,10 @@ web2d.Element = new Class({
|
|||||||
return this._peer.getPosition();
|
return this._peer.getPosition();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getNativePosition: function() {
|
||||||
|
return this._peer.getNativePosition();
|
||||||
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Defines the element stroke properties.
|
* Defines the element stroke properties.
|
||||||
* width: stroke width
|
* width: stroke width
|
||||||
|
@ -76,6 +76,10 @@ web2d.peer.svg.TextPeer = new Class({
|
|||||||
return this._position;
|
return this._position;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getNativePosition: function() {
|
||||||
|
return $(this._native).position();
|
||||||
|
},
|
||||||
|
|
||||||
setFont: function (font, size, style, weight) {
|
setFont: function (font, size, style, weight) {
|
||||||
if ($defined(font)) {
|
if ($defined(font)) {
|
||||||
this._font = new web2d.Font(font, this);
|
this._font = new web2d.Font(font, this);
|
||||||
|
Loading…
Reference in New Issue
Block a user