jsdialog: send selection for text view
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com> Change-Id: I3d87a676a1c47ea8fc99ba523ccf960a6cbde90f
This commit is contained in:
parent
1665d6e7bc
commit
58e686deb9
1 changed files with 31 additions and 0 deletions
|
@ -21,6 +21,14 @@
|
||||||
|
|
||||||
/* global JSDialog */
|
/* global JSDialog */
|
||||||
|
|
||||||
|
function _sendSimpleSelection(edit, builder) {
|
||||||
|
var startPos = edit.selectionStart;
|
||||||
|
var endPos = edit.selectionEnd;
|
||||||
|
|
||||||
|
var selection = startPos + ';' + endPos;
|
||||||
|
builder.callback('edit', 'textselection', edit, selection, builder);
|
||||||
|
}
|
||||||
|
|
||||||
function _multiLineEditControl(parentContainer, data, builder, callback) {
|
function _multiLineEditControl(parentContainer, data, builder, callback) {
|
||||||
var controlType = 'textarea';
|
var controlType = 'textarea';
|
||||||
if (data.cursor && (data.cursor === 'false' || data.cursor === false))
|
if (data.cursor && (data.cursor === 'false' || data.cursor === false))
|
||||||
|
@ -49,6 +57,29 @@ function _multiLineEditControl(parentContainer, data, builder, callback) {
|
||||||
builder.callback('edit', 'change', edit, this.value, builder);
|
builder.callback('edit', 'change', edit, this.value, builder);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
edit.addEventListener('mouseup', function (event) {
|
||||||
|
if (edit.disabled) {
|
||||||
|
event.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_sendSimpleSelection(event.target, builder);
|
||||||
|
});
|
||||||
|
|
||||||
|
edit.addEventListener('keydown', function (event) {
|
||||||
|
if (edit.disabled) {
|
||||||
|
event.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.key === 'Left' || event.key === 'ArrowLeft'
|
||||||
|
|| event.key === 'Right' || event.key === 'ArrowRight'
|
||||||
|
|| event.key === 'Up' || event.key === 'ArrowUp'
|
||||||
|
|| event.key === 'Down' || event.key === 'ArrowDown') {
|
||||||
|
setTimeout(function () { _sendSimpleSelection(edit, builder); }, 0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (data.hidden)
|
if (data.hidden)
|
||||||
L.DomUtil.addClass(edit, 'hidden');
|
L.DomUtil.addClass(edit, 'hidden');
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue