mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-44225 atto_equation: Set focus after adding equation from toolbar
This commit is contained in:
parent
a279604330
commit
9ee8a359c9
@ -322,8 +322,21 @@ M.atto_equation = M.atto_equation || {
|
||||
value = value.substring(0, this.lastcursorpos) + tex + value.substring(this.lastcursorpos, value.length);
|
||||
|
||||
input.set('value', value);
|
||||
M.atto_equation.update_preview(false, elementid);
|
||||
input.focus();
|
||||
|
||||
var focusPoint = this.lastcursorpos + tex.length,
|
||||
realInput = input.getDOMNode();
|
||||
if (typeof realInput.selectionStart === "number") {
|
||||
// Modern browsers have selectionStart and selectionEnd to control the cursor position.
|
||||
realInput.selectionStart = realInput.selectionEnd = focusPoint;
|
||||
} else if (typeof realInput.createTextRange !== "undefined") {
|
||||
// Legacy browsers (IE<=9) use createTextRange().
|
||||
var range = realInput.createTextRange();
|
||||
range.moveToPoint(focusPoint);
|
||||
range.select();
|
||||
}
|
||||
// Focus must be set before updating the preview for the cursor box to be in the correct location.
|
||||
M.atto_equation.update_preview(false, elementid);
|
||||
},
|
||||
|
||||
/**
|
||||
|
File diff suppressed because one or more lines are too long
@ -322,8 +322,21 @@ M.atto_equation = M.atto_equation || {
|
||||
value = value.substring(0, this.lastcursorpos) + tex + value.substring(this.lastcursorpos, value.length);
|
||||
|
||||
input.set('value', value);
|
||||
M.atto_equation.update_preview(false, elementid);
|
||||
input.focus();
|
||||
|
||||
var focusPoint = this.lastcursorpos + tex.length,
|
||||
realInput = input.getDOMNode();
|
||||
if (typeof realInput.selectionStart === "number") {
|
||||
// Modern browsers have selectionStart and selectionEnd to control the cursor position.
|
||||
realInput.selectionStart = realInput.selectionEnd = focusPoint;
|
||||
} else if (typeof realInput.createTextRange !== "undefined") {
|
||||
// Legacy browsers (IE<=9) use createTextRange().
|
||||
var range = realInput.createTextRange();
|
||||
range.moveToPoint(focusPoint);
|
||||
range.select();
|
||||
}
|
||||
// Focus must be set before updating the preview for the cursor box to be in the correct location.
|
||||
M.atto_equation.update_preview(false, elementid);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -320,8 +320,21 @@ M.atto_equation = M.atto_equation || {
|
||||
value = value.substring(0, this.lastcursorpos) + tex + value.substring(this.lastcursorpos, value.length);
|
||||
|
||||
input.set('value', value);
|
||||
M.atto_equation.update_preview(false, elementid);
|
||||
input.focus();
|
||||
|
||||
var focusPoint = this.lastcursorpos + tex.length,
|
||||
realInput = input.getDOMNode();
|
||||
if (typeof realInput.selectionStart === "number") {
|
||||
// Modern browsers have selectionStart and selectionEnd to control the cursor position.
|
||||
realInput.selectionStart = realInput.selectionEnd = focusPoint;
|
||||
} else if (typeof realInput.createTextRange !== "undefined") {
|
||||
// Legacy browsers (IE<=9) use createTextRange().
|
||||
var range = realInput.createTextRange();
|
||||
range.moveToPoint(focusPoint);
|
||||
range.select();
|
||||
}
|
||||
// Focus must be set before updating the preview for the cursor box to be in the correct location.
|
||||
M.atto_equation.update_preview(false, elementid);
|
||||
},
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user