mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 04:30:15 +01:00
Merge branch 'MDL-45254-master' of git://github.com/andrewnicols/moodle
Conflicts: lib/editor/atto/plugins/equation/yui/build/moodle-atto_equation-button/moodle-atto_equation-button-min.js
This commit is contained in:
commit
9482292af2
@ -420,17 +420,22 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
// Move the cursor so it does not break expressions.
|
||||
// Start at the very beginning.
|
||||
if (!currentPos) {
|
||||
currentPos = 0;
|
||||
}
|
||||
// Move the cursor so it does not break expressions.
|
||||
//
|
||||
while (equation.charAt(currentPos) === '\\' && currentPos > 0) {
|
||||
|
||||
// First move back to the beginning of the line.
|
||||
while (equation.charAt(currentPos) === '\\' && currentPos >= 0) {
|
||||
currentPos -= 1;
|
||||
}
|
||||
isChar = /[a-zA-Z\{\}]/;
|
||||
while (isChar.test(equation.charAt(currentPos)) && currentPos < equation.length) {
|
||||
currentPos += 1;
|
||||
if (currentPos !== 0) {
|
||||
// Now match to the end of the line.
|
||||
while (isChar.test(equation.charAt(currentPos)) && currentPos < equation.length && isChar.test(equation.charAt(currentPos-1))) {
|
||||
currentPos += 1;
|
||||
}
|
||||
}
|
||||
// Save the cursor position - for insertion from the library.
|
||||
this._lastCursorPos = currentPos;
|
||||
@ -562,7 +567,11 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
||||
* @private
|
||||
*/
|
||||
_selectLibraryItem: function(e) {
|
||||
var tex = e.currentTarget.getAttribute('data-tex');
|
||||
var tex = e.currentTarget.getAttribute('data-tex'),
|
||||
oldValue,
|
||||
newValue,
|
||||
input,
|
||||
focusPoint = 0;
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
@ -571,15 +580,24 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
||||
|
||||
input = e.currentTarget.ancestor('.atto_form').one('textarea');
|
||||
|
||||
value = input.get('value');
|
||||
oldValue = input.get('value');
|
||||
|
||||
value = value.substring(0, this._lastCursorPos) + tex + value.substring(this._lastCursorPos, value.length);
|
||||
newValue = oldValue.substring(0, this._lastCursorPos);
|
||||
if (newValue.charAt(newValue.length - 1) !== ' ') {
|
||||
newValue += ' ';
|
||||
}
|
||||
newValue += tex;
|
||||
focusPoint = newValue.length;
|
||||
|
||||
input.set('value', value);
|
||||
if (oldValue.charAt(this._lastCursorPos) !== ' ') {
|
||||
newValue += ' ';
|
||||
}
|
||||
newValue += oldValue.substring(this._lastCursorPos, oldValue.length);
|
||||
|
||||
input.set('value', newValue);
|
||||
input.focus();
|
||||
|
||||
var focusPoint = this._lastCursorPos + tex.length,
|
||||
realInput = input.getDOMNode();
|
||||
var realInput = input.getDOMNode();
|
||||
if (typeof realInput.selectionStart === "number") {
|
||||
// Modern browsers have selectionStart and selectionEnd to control the cursor position.
|
||||
realInput.selectionStart = realInput.selectionEnd = focusPoint;
|
||||
|
File diff suppressed because one or more lines are too long
@ -420,17 +420,22 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
// Move the cursor so it does not break expressions.
|
||||
// Start at the very beginning.
|
||||
if (!currentPos) {
|
||||
currentPos = 0;
|
||||
}
|
||||
// Move the cursor so it does not break expressions.
|
||||
//
|
||||
while (equation.charAt(currentPos) === '\\' && currentPos > 0) {
|
||||
|
||||
// First move back to the beginning of the line.
|
||||
while (equation.charAt(currentPos) === '\\' && currentPos >= 0) {
|
||||
currentPos -= 1;
|
||||
}
|
||||
isChar = /[a-zA-Z\{\}]/;
|
||||
while (isChar.test(equation.charAt(currentPos)) && currentPos < equation.length) {
|
||||
currentPos += 1;
|
||||
if (currentPos !== 0) {
|
||||
// Now match to the end of the line.
|
||||
while (isChar.test(equation.charAt(currentPos)) && currentPos < equation.length && isChar.test(equation.charAt(currentPos-1))) {
|
||||
currentPos += 1;
|
||||
}
|
||||
}
|
||||
// Save the cursor position - for insertion from the library.
|
||||
this._lastCursorPos = currentPos;
|
||||
@ -561,7 +566,11 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
||||
* @private
|
||||
*/
|
||||
_selectLibraryItem: function(e) {
|
||||
var tex = e.currentTarget.getAttribute('data-tex');
|
||||
var tex = e.currentTarget.getAttribute('data-tex'),
|
||||
oldValue,
|
||||
newValue,
|
||||
input,
|
||||
focusPoint = 0;
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
@ -570,15 +579,24 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
||||
|
||||
input = e.currentTarget.ancestor('.atto_form').one('textarea');
|
||||
|
||||
value = input.get('value');
|
||||
oldValue = input.get('value');
|
||||
|
||||
value = value.substring(0, this._lastCursorPos) + tex + value.substring(this._lastCursorPos, value.length);
|
||||
newValue = oldValue.substring(0, this._lastCursorPos);
|
||||
if (newValue.charAt(newValue.length - 1) !== ' ') {
|
||||
newValue += ' ';
|
||||
}
|
||||
newValue += tex;
|
||||
focusPoint = newValue.length;
|
||||
|
||||
input.set('value', value);
|
||||
if (oldValue.charAt(this._lastCursorPos) !== ' ') {
|
||||
newValue += ' ';
|
||||
}
|
||||
newValue += oldValue.substring(this._lastCursorPos, oldValue.length);
|
||||
|
||||
input.set('value', newValue);
|
||||
input.focus();
|
||||
|
||||
var focusPoint = this._lastCursorPos + tex.length,
|
||||
realInput = input.getDOMNode();
|
||||
var realInput = input.getDOMNode();
|
||||
if (typeof realInput.selectionStart === "number") {
|
||||
// Modern browsers have selectionStart and selectionEnd to control the cursor position.
|
||||
realInput.selectionStart = realInput.selectionEnd = focusPoint;
|
||||
|
@ -418,17 +418,22 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
// Move the cursor so it does not break expressions.
|
||||
// Start at the very beginning.
|
||||
if (!currentPos) {
|
||||
currentPos = 0;
|
||||
}
|
||||
// Move the cursor so it does not break expressions.
|
||||
//
|
||||
while (equation.charAt(currentPos) === '\\' && currentPos > 0) {
|
||||
|
||||
// First move back to the beginning of the line.
|
||||
while (equation.charAt(currentPos) === '\\' && currentPos >= 0) {
|
||||
currentPos -= 1;
|
||||
}
|
||||
isChar = /[a-zA-Z\{\}]/;
|
||||
while (isChar.test(equation.charAt(currentPos)) && currentPos < equation.length) {
|
||||
currentPos += 1;
|
||||
if (currentPos !== 0) {
|
||||
// Now match to the end of the line.
|
||||
while (isChar.test(equation.charAt(currentPos)) && currentPos < equation.length && isChar.test(equation.charAt(currentPos-1))) {
|
||||
currentPos += 1;
|
||||
}
|
||||
}
|
||||
// Save the cursor position - for insertion from the library.
|
||||
this._lastCursorPos = currentPos;
|
||||
@ -560,7 +565,11 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
||||
* @private
|
||||
*/
|
||||
_selectLibraryItem: function(e) {
|
||||
var tex = e.currentTarget.getAttribute('data-tex');
|
||||
var tex = e.currentTarget.getAttribute('data-tex'),
|
||||
oldValue,
|
||||
newValue,
|
||||
input,
|
||||
focusPoint = 0;
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
@ -569,15 +578,24 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
||||
|
||||
input = e.currentTarget.ancestor('.atto_form').one('textarea');
|
||||
|
||||
value = input.get('value');
|
||||
oldValue = input.get('value');
|
||||
|
||||
value = value.substring(0, this._lastCursorPos) + tex + value.substring(this._lastCursorPos, value.length);
|
||||
newValue = oldValue.substring(0, this._lastCursorPos);
|
||||
if (newValue.charAt(newValue.length - 1) !== ' ') {
|
||||
newValue += ' ';
|
||||
}
|
||||
newValue += tex;
|
||||
focusPoint = newValue.length;
|
||||
|
||||
input.set('value', value);
|
||||
if (oldValue.charAt(this._lastCursorPos) !== ' ') {
|
||||
newValue += ' ';
|
||||
}
|
||||
newValue += oldValue.substring(this._lastCursorPos, oldValue.length);
|
||||
|
||||
input.set('value', newValue);
|
||||
input.focus();
|
||||
|
||||
var focusPoint = this._lastCursorPos + tex.length,
|
||||
realInput = input.getDOMNode();
|
||||
var realInput = input.getDOMNode();
|
||||
if (typeof realInput.selectionStart === "number") {
|
||||
// Modern browsers have selectionStart and selectionEnd to control the cursor position.
|
||||
realInput.selectionStart = realInput.selectionEnd = focusPoint;
|
||||
|
Loading…
x
Reference in New Issue
Block a user