mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 17:36:38 +02:00
Merge branch 'MDL-45983-master' of git://github.com/damyon/moodle
This commit is contained in:
commit
8d879f3928
5 changed files with 61 additions and 8 deletions
|
@ -19,3 +19,17 @@ Feature: Atto equation editor
|
||||||
And I click on "Update profile" "button"
|
And I click on "Update profile" "button"
|
||||||
Then "\infty" "text" should exist
|
Then "\infty" "text" should exist
|
||||||
|
|
||||||
|
@javascript
|
||||||
|
Scenario: Edit an equation
|
||||||
|
Given I log in as "admin"
|
||||||
|
When I navigate to "Edit profile" node in "My profile settings"
|
||||||
|
And I set the field "Description" to "<p>\( \pi \)</p>"
|
||||||
|
# Set field on the bottom of page, so equation editor dialogue is visible.
|
||||||
|
And I expand all fieldsets
|
||||||
|
And I set the field "Picture description" to "Test"
|
||||||
|
And I select the text in the "Description" Atto editor
|
||||||
|
And I click on "Show more buttons" "button"
|
||||||
|
And I click on "Equation editor" "button"
|
||||||
|
Then the field "Edit equation using" matches value " \pi "
|
||||||
|
And I click on "Save equation" "button"
|
||||||
|
And the field "Description" matches value "<p>\( \pi \)</p>"
|
||||||
|
|
|
@ -206,6 +206,9 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This needs to be done before the dialogue is opened because the focus will shift to the dialogue.
|
||||||
|
var equation = this._resolveEquation();
|
||||||
|
|
||||||
var dialogue = this.getDialogue({
|
var dialogue = this.getDialogue({
|
||||||
headerContent: M.util.get_string('pluginname', COMPONENTNAME),
|
headerContent: M.util.get_string('pluginname', COMPONENTNAME),
|
||||||
focusAfterHide: true,
|
focusAfterHide: true,
|
||||||
|
@ -227,7 +230,6 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
||||||
// Trigger any JS filters to reprocess the new nodes.
|
// Trigger any JS filters to reprocess the new nodes.
|
||||||
Y.fire(M.core.event.FILTER_CONTENT_UPDATED, {nodes: (new Y.NodeList(dialogue.get('boundingBox')))});
|
Y.fire(M.core.event.FILTER_CONTENT_UPDATED, {nodes: (new Y.NodeList(dialogue.get('boundingBox')))});
|
||||||
|
|
||||||
var equation = this._resolveEquation();
|
|
||||||
if (equation) {
|
if (equation) {
|
||||||
content.one(SELECTORS.EQUATION_TEXT).set('text', equation);
|
content.one(SELECTORS.EQUATION_TEXT).set('text', equation);
|
||||||
}
|
}
|
||||||
|
@ -250,7 +252,10 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
||||||
text,
|
text,
|
||||||
returnValue = false;
|
returnValue = false;
|
||||||
|
|
||||||
this.sourceEquation = null;
|
// Prevent resolving equations when we don't have focus.
|
||||||
|
if (!this.get('host').isActive()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Note this is a document fragment and YUI doesn't like them.
|
// Note this is a document fragment and YUI doesn't like them.
|
||||||
if (!selectedNode) {
|
if (!selectedNode) {
|
||||||
|
@ -261,6 +266,9 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
||||||
if (!selection || selection.length === 0) {
|
if (!selection || selection.length === 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.sourceEquation = null;
|
||||||
|
|
||||||
selection = selection[0];
|
selection = selection[0];
|
||||||
|
|
||||||
text = Y.one(selectedNode).get('text');
|
text = Y.one(selectedNode).get('text');
|
||||||
|
@ -326,6 +334,10 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
|
// We trim the equation when we load it and then add spaces when we save it.
|
||||||
|
if (returnValue !== false) {
|
||||||
|
returnValue = returnValue.trim();
|
||||||
|
}
|
||||||
return returnValue;
|
return returnValue;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -360,6 +372,7 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
||||||
// Replace the equation.
|
// Replace the equation.
|
||||||
selectedNode = Y.one(host.getSelectionParentNode());
|
selectedNode = Y.one(host.getSelectionParentNode());
|
||||||
text = selectedNode.get('text');
|
text = selectedNode.get('text');
|
||||||
|
value = ' ' + value + ' ';
|
||||||
newText = text.slice(0, this.sourceEquation.startInnerPosition) +
|
newText = text.slice(0, this.sourceEquation.startInnerPosition) +
|
||||||
value +
|
value +
|
||||||
text.slice(this.sourceEquation.endInnerPosition);
|
text.slice(this.sourceEquation.endInnerPosition);
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -206,6 +206,9 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This needs to be done before the dialogue is opened because the focus will shift to the dialogue.
|
||||||
|
var equation = this._resolveEquation();
|
||||||
|
|
||||||
var dialogue = this.getDialogue({
|
var dialogue = this.getDialogue({
|
||||||
headerContent: M.util.get_string('pluginname', COMPONENTNAME),
|
headerContent: M.util.get_string('pluginname', COMPONENTNAME),
|
||||||
focusAfterHide: true,
|
focusAfterHide: true,
|
||||||
|
@ -227,7 +230,6 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
||||||
// Trigger any JS filters to reprocess the new nodes.
|
// Trigger any JS filters to reprocess the new nodes.
|
||||||
Y.fire(M.core.event.FILTER_CONTENT_UPDATED, {nodes: (new Y.NodeList(dialogue.get('boundingBox')))});
|
Y.fire(M.core.event.FILTER_CONTENT_UPDATED, {nodes: (new Y.NodeList(dialogue.get('boundingBox')))});
|
||||||
|
|
||||||
var equation = this._resolveEquation();
|
|
||||||
if (equation) {
|
if (equation) {
|
||||||
content.one(SELECTORS.EQUATION_TEXT).set('text', equation);
|
content.one(SELECTORS.EQUATION_TEXT).set('text', equation);
|
||||||
}
|
}
|
||||||
|
@ -250,7 +252,10 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
||||||
text,
|
text,
|
||||||
returnValue = false;
|
returnValue = false;
|
||||||
|
|
||||||
this.sourceEquation = null;
|
// Prevent resolving equations when we don't have focus.
|
||||||
|
if (!this.get('host').isActive()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Note this is a document fragment and YUI doesn't like them.
|
// Note this is a document fragment and YUI doesn't like them.
|
||||||
if (!selectedNode) {
|
if (!selectedNode) {
|
||||||
|
@ -261,6 +266,9 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
||||||
if (!selection || selection.length === 0) {
|
if (!selection || selection.length === 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.sourceEquation = null;
|
||||||
|
|
||||||
selection = selection[0];
|
selection = selection[0];
|
||||||
|
|
||||||
text = Y.one(selectedNode).get('text');
|
text = Y.one(selectedNode).get('text');
|
||||||
|
@ -326,6 +334,10 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
|
// We trim the equation when we load it and then add spaces when we save it.
|
||||||
|
if (returnValue !== false) {
|
||||||
|
returnValue = returnValue.trim();
|
||||||
|
}
|
||||||
return returnValue;
|
return returnValue;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -360,6 +372,7 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
||||||
// Replace the equation.
|
// Replace the equation.
|
||||||
selectedNode = Y.one(host.getSelectionParentNode());
|
selectedNode = Y.one(host.getSelectionParentNode());
|
||||||
text = selectedNode.get('text');
|
text = selectedNode.get('text');
|
||||||
|
value = ' ' + value + ' ';
|
||||||
newText = text.slice(0, this.sourceEquation.startInnerPosition) +
|
newText = text.slice(0, this.sourceEquation.startInnerPosition) +
|
||||||
value +
|
value +
|
||||||
text.slice(this.sourceEquation.endInnerPosition);
|
text.slice(this.sourceEquation.endInnerPosition);
|
||||||
|
|
|
@ -204,6 +204,9 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This needs to be done before the dialogue is opened because the focus will shift to the dialogue.
|
||||||
|
var equation = this._resolveEquation();
|
||||||
|
|
||||||
var dialogue = this.getDialogue({
|
var dialogue = this.getDialogue({
|
||||||
headerContent: M.util.get_string('pluginname', COMPONENTNAME),
|
headerContent: M.util.get_string('pluginname', COMPONENTNAME),
|
||||||
focusAfterHide: true,
|
focusAfterHide: true,
|
||||||
|
@ -225,7 +228,6 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
||||||
// Trigger any JS filters to reprocess the new nodes.
|
// Trigger any JS filters to reprocess the new nodes.
|
||||||
Y.fire(M.core.event.FILTER_CONTENT_UPDATED, {nodes: (new Y.NodeList(dialogue.get('boundingBox')))});
|
Y.fire(M.core.event.FILTER_CONTENT_UPDATED, {nodes: (new Y.NodeList(dialogue.get('boundingBox')))});
|
||||||
|
|
||||||
var equation = this._resolveEquation();
|
|
||||||
if (equation) {
|
if (equation) {
|
||||||
content.one(SELECTORS.EQUATION_TEXT).set('text', equation);
|
content.one(SELECTORS.EQUATION_TEXT).set('text', equation);
|
||||||
}
|
}
|
||||||
|
@ -248,7 +250,10 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
||||||
text,
|
text,
|
||||||
returnValue = false;
|
returnValue = false;
|
||||||
|
|
||||||
this.sourceEquation = null;
|
// Prevent resolving equations when we don't have focus.
|
||||||
|
if (!this.get('host').isActive()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Note this is a document fragment and YUI doesn't like them.
|
// Note this is a document fragment and YUI doesn't like them.
|
||||||
if (!selectedNode) {
|
if (!selectedNode) {
|
||||||
|
@ -259,6 +264,9 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
||||||
if (!selection || selection.length === 0) {
|
if (!selection || selection.length === 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.sourceEquation = null;
|
||||||
|
|
||||||
selection = selection[0];
|
selection = selection[0];
|
||||||
|
|
||||||
text = Y.one(selectedNode).get('text');
|
text = Y.one(selectedNode).get('text');
|
||||||
|
@ -324,6 +332,10 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
|
// We trim the equation when we load it and then add spaces when we save it.
|
||||||
|
if (returnValue !== false) {
|
||||||
|
returnValue = returnValue.trim();
|
||||||
|
}
|
||||||
return returnValue;
|
return returnValue;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -358,6 +370,7 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
||||||
// Replace the equation.
|
// Replace the equation.
|
||||||
selectedNode = Y.one(host.getSelectionParentNode());
|
selectedNode = Y.one(host.getSelectionParentNode());
|
||||||
text = selectedNode.get('text');
|
text = selectedNode.get('text');
|
||||||
|
value = ' ' + value + ' ';
|
||||||
newText = text.slice(0, this.sourceEquation.startInnerPosition) +
|
newText = text.slice(0, this.sourceEquation.startInnerPosition) +
|
||||||
value +
|
value +
|
||||||
text.slice(this.sourceEquation.endInnerPosition);
|
text.slice(this.sourceEquation.endInnerPosition);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue