mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
Merge branch 'MDL-45867-master' of https://github.com/dthies/moodle
This commit is contained in:
commit
1d9eb92ff3
4 changed files with 74 additions and 26 deletions
|
@ -423,7 +423,6 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
|||
var textarea = this._content.one(SELECTORS.EQUATION_TEXT),
|
||||
equation = textarea.get('value'),
|
||||
url,
|
||||
preview,
|
||||
currentPos = textarea.get('selectionStart'),
|
||||
prefix = '',
|
||||
cursorLatex = '\\Downarrow ',
|
||||
|
@ -455,7 +454,6 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
|||
this._lastCursorPos = currentPos;
|
||||
equation = prefix + equation.substring(0, currentPos) + cursorLatex + equation.substring(currentPos);
|
||||
|
||||
var previewNode = this._content.one(SELECTORS.EQUATION_PREVIEW);
|
||||
equation = DELIMITERS.START + ' ' + equation + ' ' + DELIMITERS.END;
|
||||
// Make an ajax request to the filter.
|
||||
url = M.cfg.wwwroot + '/lib/editor/atto/plugins/equation/ajax.php';
|
||||
|
@ -466,13 +464,30 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
|||
text: equation
|
||||
};
|
||||
|
||||
preview = Y.io(url, {
|
||||
sync: true,
|
||||
data: params
|
||||
Y.io(url, {
|
||||
context: this,
|
||||
data: params,
|
||||
timeout: 500,
|
||||
on: {
|
||||
complete: this._loadPreview
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Load returned preview text into preview
|
||||
*
|
||||
* @param {String} id
|
||||
* @param {EventFacade} e
|
||||
* @method _loadPreview
|
||||
* @private
|
||||
*/
|
||||
_loadPreview: function(id, preview) {
|
||||
var previewNode = this._content.one(SELECTORS.EQUATION_PREVIEW);
|
||||
|
||||
if (preview.status === 200) {
|
||||
previewNode.setHTML(preview.responseText);
|
||||
|
||||
Y.fire(M.core.event.FILTER_CONTENT_UPDATED, {nodes: (new Y.NodeList(previewNode))});
|
||||
}
|
||||
},
|
||||
|
@ -487,6 +502,7 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
|||
*/
|
||||
_getDialogueContent: function() {
|
||||
var library = this._getLibraryContent(),
|
||||
throttledUpdate = this._throttle(this._updatePreview, 500),
|
||||
template = Y.Handlebars.compile(TEMPLATES.FORM);
|
||||
|
||||
this._content = Y.Node.create(template({
|
||||
|
@ -509,9 +525,9 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
|||
this._content.delegate('key', this._groupNavigation, 'down:37,39', SELECTORS.LIBRARY_BUTTON, this);
|
||||
|
||||
this._content.one(SELECTORS.SUBMIT).on('click', this._setEquation, this);
|
||||
this._content.one(SELECTORS.EQUATION_TEXT).on('valuechange', this._throttle(this._updatePreview, 500), this);
|
||||
this._content.one(SELECTORS.EQUATION_TEXT).on('mouseup', this._throttle(this._updatePreview, 500), this);
|
||||
this._content.one(SELECTORS.EQUATION_TEXT).on('keyup', this._throttle(this._updatePreview, 500), this);
|
||||
this._content.one(SELECTORS.EQUATION_TEXT).on('valuechange', throttledUpdate, this);
|
||||
this._content.one(SELECTORS.EQUATION_TEXT).on('mouseup', throttledUpdate, this);
|
||||
this._content.one(SELECTORS.EQUATION_TEXT).on('keyup', throttledUpdate, this);
|
||||
this._content.delegate('click', this._selectLibraryItem, SELECTORS.LIBRARY_BUTTON, this);
|
||||
|
||||
return this._content;
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -423,7 +423,6 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
|||
var textarea = this._content.one(SELECTORS.EQUATION_TEXT),
|
||||
equation = textarea.get('value'),
|
||||
url,
|
||||
preview,
|
||||
currentPos = textarea.get('selectionStart'),
|
||||
prefix = '',
|
||||
cursorLatex = '\\Downarrow ',
|
||||
|
@ -455,7 +454,6 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
|||
this._lastCursorPos = currentPos;
|
||||
equation = prefix + equation.substring(0, currentPos) + cursorLatex + equation.substring(currentPos);
|
||||
|
||||
var previewNode = this._content.one(SELECTORS.EQUATION_PREVIEW);
|
||||
equation = DELIMITERS.START + ' ' + equation + ' ' + DELIMITERS.END;
|
||||
// Make an ajax request to the filter.
|
||||
url = M.cfg.wwwroot + '/lib/editor/atto/plugins/equation/ajax.php';
|
||||
|
@ -466,13 +464,30 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
|||
text: equation
|
||||
};
|
||||
|
||||
preview = Y.io(url, {
|
||||
sync: true,
|
||||
data: params
|
||||
Y.io(url, {
|
||||
context: this,
|
||||
data: params,
|
||||
timeout: 500,
|
||||
on: {
|
||||
complete: this._loadPreview
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Load returned preview text into preview
|
||||
*
|
||||
* @param {String} id
|
||||
* @param {EventFacade} e
|
||||
* @method _loadPreview
|
||||
* @private
|
||||
*/
|
||||
_loadPreview: function(id, preview) {
|
||||
var previewNode = this._content.one(SELECTORS.EQUATION_PREVIEW);
|
||||
|
||||
if (preview.status === 200) {
|
||||
previewNode.setHTML(preview.responseText);
|
||||
|
||||
Y.fire(M.core.event.FILTER_CONTENT_UPDATED, {nodes: (new Y.NodeList(previewNode))});
|
||||
}
|
||||
},
|
||||
|
@ -487,6 +502,7 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
|||
*/
|
||||
_getDialogueContent: function() {
|
||||
var library = this._getLibraryContent(),
|
||||
throttledUpdate = this._throttle(this._updatePreview, 500),
|
||||
template = Y.Handlebars.compile(TEMPLATES.FORM);
|
||||
|
||||
this._content = Y.Node.create(template({
|
||||
|
@ -509,9 +525,9 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
|||
this._content.delegate('key', this._groupNavigation, 'down:37,39', SELECTORS.LIBRARY_BUTTON, this);
|
||||
|
||||
this._content.one(SELECTORS.SUBMIT).on('click', this._setEquation, this);
|
||||
this._content.one(SELECTORS.EQUATION_TEXT).on('valuechange', this._throttle(this._updatePreview, 500), this);
|
||||
this._content.one(SELECTORS.EQUATION_TEXT).on('mouseup', this._throttle(this._updatePreview, 500), this);
|
||||
this._content.one(SELECTORS.EQUATION_TEXT).on('keyup', this._throttle(this._updatePreview, 500), this);
|
||||
this._content.one(SELECTORS.EQUATION_TEXT).on('valuechange', throttledUpdate, this);
|
||||
this._content.one(SELECTORS.EQUATION_TEXT).on('mouseup', throttledUpdate, this);
|
||||
this._content.one(SELECTORS.EQUATION_TEXT).on('keyup', throttledUpdate, this);
|
||||
this._content.delegate('click', this._selectLibraryItem, SELECTORS.LIBRARY_BUTTON, this);
|
||||
|
||||
return this._content;
|
||||
|
|
|
@ -421,7 +421,6 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
|||
var textarea = this._content.one(SELECTORS.EQUATION_TEXT),
|
||||
equation = textarea.get('value'),
|
||||
url,
|
||||
preview,
|
||||
currentPos = textarea.get('selectionStart'),
|
||||
prefix = '',
|
||||
cursorLatex = '\\Downarrow ',
|
||||
|
@ -453,7 +452,6 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
|||
this._lastCursorPos = currentPos;
|
||||
equation = prefix + equation.substring(0, currentPos) + cursorLatex + equation.substring(currentPos);
|
||||
|
||||
var previewNode = this._content.one(SELECTORS.EQUATION_PREVIEW);
|
||||
equation = DELIMITERS.START + ' ' + equation + ' ' + DELIMITERS.END;
|
||||
// Make an ajax request to the filter.
|
||||
url = M.cfg.wwwroot + '/lib/editor/atto/plugins/equation/ajax.php';
|
||||
|
@ -464,13 +462,30 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
|||
text: equation
|
||||
};
|
||||
|
||||
preview = Y.io(url, {
|
||||
sync: true,
|
||||
data: params
|
||||
Y.io(url, {
|
||||
context: this,
|
||||
data: params,
|
||||
timeout: 500,
|
||||
on: {
|
||||
complete: this._loadPreview
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Load returned preview text into preview
|
||||
*
|
||||
* @param {String} id
|
||||
* @param {EventFacade} e
|
||||
* @method _loadPreview
|
||||
* @private
|
||||
*/
|
||||
_loadPreview: function(id, preview) {
|
||||
var previewNode = this._content.one(SELECTORS.EQUATION_PREVIEW);
|
||||
|
||||
if (preview.status === 200) {
|
||||
previewNode.setHTML(preview.responseText);
|
||||
|
||||
Y.fire(M.core.event.FILTER_CONTENT_UPDATED, {nodes: (new Y.NodeList(previewNode))});
|
||||
}
|
||||
},
|
||||
|
@ -485,6 +500,7 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
|||
*/
|
||||
_getDialogueContent: function() {
|
||||
var library = this._getLibraryContent(),
|
||||
throttledUpdate = this._throttle(this._updatePreview, 500),
|
||||
template = Y.Handlebars.compile(TEMPLATES.FORM);
|
||||
|
||||
this._content = Y.Node.create(template({
|
||||
|
@ -507,9 +523,9 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
|||
this._content.delegate('key', this._groupNavigation, 'down:37,39', SELECTORS.LIBRARY_BUTTON, this);
|
||||
|
||||
this._content.one(SELECTORS.SUBMIT).on('click', this._setEquation, this);
|
||||
this._content.one(SELECTORS.EQUATION_TEXT).on('valuechange', this._throttle(this._updatePreview, 500), this);
|
||||
this._content.one(SELECTORS.EQUATION_TEXT).on('mouseup', this._throttle(this._updatePreview, 500), this);
|
||||
this._content.one(SELECTORS.EQUATION_TEXT).on('keyup', this._throttle(this._updatePreview, 500), this);
|
||||
this._content.one(SELECTORS.EQUATION_TEXT).on('valuechange', throttledUpdate, this);
|
||||
this._content.one(SELECTORS.EQUATION_TEXT).on('mouseup', throttledUpdate, this);
|
||||
this._content.one(SELECTORS.EQUATION_TEXT).on('keyup', throttledUpdate, this);
|
||||
this._content.delegate('click', this._selectLibraryItem, SELECTORS.LIBRARY_BUTTON, this);
|
||||
|
||||
return this._content;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue