Merge branch 'MDL-45983-master' of git://github.com/damyon/moodle

This commit is contained in:
Marina Glancy 2014-06-24 13:51:30 +08:00
commit 8d879f3928
5 changed files with 61 additions and 8 deletions

View File

@ -19,3 +19,17 @@ Feature: Atto equation editor
And I click on "Update profile" "button"
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>"

View File

@ -206,6 +206,9 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
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({
headerContent: M.util.get_string('pluginname', COMPONENTNAME),
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.
Y.fire(M.core.event.FILTER_CONTENT_UPDATED, {nodes: (new Y.NodeList(dialogue.get('boundingBox')))});
var equation = this._resolveEquation();
if (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,
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.
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) {
return false;
}
this.sourceEquation = null;
selection = selection[0];
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);
// We trim the equation when we load it and then add spaces when we save it.
if (returnValue !== false) {
returnValue = returnValue.trim();
}
return returnValue;
},
@ -360,6 +372,7 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
// Replace the equation.
selectedNode = Y.one(host.getSelectionParentNode());
text = selectedNode.get('text');
value = ' ' + value + ' ';
newText = text.slice(0, this.sourceEquation.startInnerPosition) +
value +
text.slice(this.sourceEquation.endInnerPosition);

View File

@ -206,6 +206,9 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
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({
headerContent: M.util.get_string('pluginname', COMPONENTNAME),
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.
Y.fire(M.core.event.FILTER_CONTENT_UPDATED, {nodes: (new Y.NodeList(dialogue.get('boundingBox')))});
var equation = this._resolveEquation();
if (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,
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.
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) {
return false;
}
this.sourceEquation = null;
selection = selection[0];
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);
// We trim the equation when we load it and then add spaces when we save it.
if (returnValue !== false) {
returnValue = returnValue.trim();
}
return returnValue;
},
@ -360,6 +372,7 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
// Replace the equation.
selectedNode = Y.one(host.getSelectionParentNode());
text = selectedNode.get('text');
value = ' ' + value + ' ';
newText = text.slice(0, this.sourceEquation.startInnerPosition) +
value +
text.slice(this.sourceEquation.endInnerPosition);

View File

@ -204,6 +204,9 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
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({
headerContent: M.util.get_string('pluginname', COMPONENTNAME),
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.
Y.fire(M.core.event.FILTER_CONTENT_UPDATED, {nodes: (new Y.NodeList(dialogue.get('boundingBox')))});
var equation = this._resolveEquation();
if (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,
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.
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) {
return false;
}
this.sourceEquation = null;
selection = selection[0];
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);
// We trim the equation when we load it and then add spaces when we save it.
if (returnValue !== false) {
returnValue = returnValue.trim();
}
return returnValue;
},
@ -358,6 +370,7 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
// Replace the equation.
selectedNode = Y.one(host.getSelectionParentNode());
text = selectedNode.get('text');
value = ' ' + value + ' ';
newText = text.slice(0, this.sourceEquation.startInnerPosition) +
value +
text.slice(this.sourceEquation.endInnerPosition);