Skip to content

Commit

Permalink
4.4.0 Stable version
Browse files Browse the repository at this point in the history
  • Loading branch information
mcagigas-at-wiris authored Jun 16, 2017
1 parent 07fa755 commit 2e85069
Show file tree
Hide file tree
Showing 40 changed files with 259 additions and 93 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ php:
- 7.0

env:
- MOODLE_BRANCH=MOODLE_33_STABLE DB=mysqli
- MOODLE_BRANCH=MOODLE_32_STABLE DB=mysqli
- MOODLE_BRANCH=MOODLE_31_STABLE DB=mysqli
- MOODLE_BRANCH=MOODLE_30_STABLE DB=pgsql
- MOODLE_BRANCH=MOODLE_29_STABLE DB=mysqli
Expand All @@ -35,6 +37,10 @@ matrix:
env: MOODLE_BRANCH=MOODLE_28_STABLE DB=pgsql
- php: 5.6
env: MOODLE_BRANCH=MOODLE_27_STABLE DB=mysqli
- php: 5.4
env: MOODLE_BRANCH=MOODLE_32_STABLE DB=mysqli
- php: 5.4
env: MOODLE_BRANCH=MOODLE_33_STABLE DB=mysqli
include:
- php: 5.4
env: MOODLE_BRANCH=MOODLE_31_STABLE DB=mysqli
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
WIRIS plugin for Moodle
==========
### Master Build Status
[![Build Status](https://travis-ci.org/wiris/moodle-tinymce_tiny_mce_wiris.svg?branch=master)](https://travis-ci.org/wiris/moodle-tinymce_tiny_mce_wiris)
### Development Build Status
[![Build Status](https://travis-ci.org/wiris/moodle-tinymce_tiny_mce_wiris.svg?branch=development)](https://travis-ci.org/wiris/moodle-tinymce_tiny_mce_wiris)

Add a fully WYSIWYG editor for scientific expressions ([WIRIS EDITOR](http://www.wiris.com/editor)) and, optionally, an advanced calculator tool ([WIRIS CAS](http://www.wiris.com/cas)). Enabled editing to STEM related topics (Science, Technology, Engineering and Mathematics).
Add a fully WYSIWYG editor for scientific expressions ([WIRIS EDITOR](http://www.wiris.com/editor)) and, optionally, an advanced calculator tool ([WIRIS CAS](http://www.wiris.com/cas)). Enabled editing to STEM related topics (Science, Technology, Engineering and Mathematics).

[WIRIS EDITOR](http://www.wiris.com/editor) is a mathematical **visual (WYSIWYG) editor**. You can use a large collection of icons nicely organized in thematic tabs in order to create formulas or equations for any web content. You can create and edit your formulas in a visual environment, just click on the WIRIS editor icon for creation or double-click on the formula for edition. It is based on JavaScript and compatible with HTML 5.

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.3.1.1366
4.4.0.1366
2 changes: 1 addition & 1 deletion tinymce/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.3.1.1366
4.4.0.1366
187 changes: 119 additions & 68 deletions tinymce/core/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ if (!(window._wrs_conf_CASClassName)) {
if (typeof MutationObserver != 'undefined') {
var wrs_observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.oldValue == _wrs_conf_imageClassName && mutation.attributeName == 'class' && mutation.target.className.indexOf(_wrs_conf_imageClassName) == -1 ) {
if (mutation.oldValue == _wrs_conf_imageClassName && mutation.attributeName == 'class' && mutation.targetpassName.indexOf(_wrs_conf_imageClassName) == -1 ) {
mutation.target.className = _wrs_conf_imageClassName;
}
});
Expand Down Expand Up @@ -894,7 +894,15 @@ function wrs_getLatexFromMathML(mathml) {
'mml': mathml
};

return wrs_getContent(_wrs_conf_servicePath, data);
var jsonResponse = JSON.parse(wrs_getContent(_wrs_conf_servicePath, data));

var latex;

if (jsonResponse.status == "ok") {
latex = jsonResponse.result.text;
}

return latex;
}

/**
Expand Down Expand Up @@ -1019,10 +1027,19 @@ function wrs_getMathMLFromLatex(latex, includeLatexOnSemantics) {
data['saveLatex'] = '';
}

var mathML = wrs_getContent(_wrs_conf_servicePath, data);
// Populate LatexCache.
wrs_populateLatexCache(latex, mathML);
return mathML.split("\r").join('').split("\n").join(' ');
var jsonResponse = JSON.parse(wrs_getContent(_wrs_conf_servicePath, data));

var output;
if (jsonResponse.status == "ok") {
var output = jsonResponse.result.text;
output = output.split("\r").join('').split("\n").join(' ');
// Populate LatexCache.
wrs_populateLatexCache(latex, output);
} else {
output = "$$" + latex + "$$";
}

return output;
}

/**
Expand Down Expand Up @@ -1504,8 +1521,6 @@ function wrs_getElementsByNameFromString(code, name, autoClosed) {
*/
function wrs_insertElementOnSelection(element, focusElement, windowTarget) {
try {
focusElement.focus();

// Integration function
// If wrs_int_insertElementOnSelection function exists on
// integration script can call focus method from the editor instance.
Expand All @@ -1515,6 +1530,9 @@ function wrs_insertElementOnSelection(element, focusElement, windowTarget) {
if (typeof wrs_int_insertElementOnSelection != 'undefined') {
wrs_int_insertElementOnSelection();
}
else {
focusElement.focus();
}

if (_wrs_isNewElement) {
if (document.selection && document.getSelection == 0) {
Expand Down Expand Up @@ -1827,7 +1845,10 @@ function wrs_mathmlToAccessible(mathml, language, data) {
}
else {
data['service'] = 'mathml2accessible';
var accessibleText = wrs_getContent(_wrs_conf_servicePath, data);
var accesibleJsonResponse = JSON.parse(wrs_getContent(_wrs_conf_servicePath, data));
if (accesibleJsonResponse.status != 'error') {
accessibleText = accesibleJsonResponse.result.text;
}
}

return accessibleText;
Expand Down Expand Up @@ -2206,7 +2227,6 @@ function wrs_openEditorWindow(language, target, isIframe) {
document.getElementsByTagName("head")[0].appendChild(fileref);
_wrs_css_loaded = true;
}
_wrs_modalWindow.setTitle(title);
_wrs_modalWindow.open();
}
}
Expand Down Expand Up @@ -2648,21 +2668,7 @@ function wrs_initSetSize() {

function wrs_loadConfiguration() {
if (typeof _wrs_conf_path == 'undefined') {
// Discover path.
var scriptName = "core/core.js";
var col = document.getElementsByTagName("script");
for (i = 0; i < col.length; i++) {
var d;
var src;
d = col[i];
src = d.src;
var j = src.lastIndexOf(scriptName);
if (j >= 0) {
// That's my script!
baseURL = src.substr(0, j - 1);
}
}
_wrs_conf_path = baseURL;
_wrs_conf_path = wrs_getCorePath();
}

var script = document.createElement('script');
Expand All @@ -2676,6 +2682,29 @@ function wrs_loadConfiguration() {
document.getElementsByTagName('head')[0].appendChild(script); // Asynchronous load of configuration.
}

function wrs_getCorePath() {
var scriptName = "core/core.js";
var col = document.getElementsByTagName("script");
for (i = 0; i < col.length; i++) {
var d;
var src;
d = col[i];
src = d.src;
var j = src.lastIndexOf(scriptName);
if (j >= 0) {
// That's my script!
return src.substr(0, j - 1);
}
}
}

function wrs_loadLangFile() {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = wrs_getCorePath() + "/lang/" + _wrs_int_langCode + "/strings.js";
document.getElementsByTagName('head')[0].appendChild(script);
}

function wrs_concatenateUrl(path1, path2) {
return (path1 + path2).replace(/([^:]\/)\/+/g, "$1");
}
Expand All @@ -2688,7 +2717,7 @@ if (typeof _wrs_conf_configuration_loaded == 'undefined') {
_wrs_conf_plugin_loaded = true;
}


wrs_loadLangFile()

/**
* Create modal window with embebbed iframe
Expand Down Expand Up @@ -3381,6 +3410,17 @@ function wrs_addPluginListener(listener) {
wrs_pluginListeners.push(listener);
}

/**
* For now its not possible comunicate directly between editor.js and ModalWindow object.
* We need to use this method to call ModalWindow prototype from editor.js
* @param {object} editor WIRIS Editor
*/
function wrs_setModalWindowEditor(editor) {
if (_wrs_conf_modalWindow) {
_wrs_modalWindow.setEditor(editor);
}
}

// Production steps of ECMA-262, Edition 5, 15.4.4.18
// Reference: http://es5.github.io/#x15.4.4.18.
if (!Array.prototype.forEach) {
Expand Down Expand Up @@ -4054,19 +4094,19 @@ function ModalWindow(path, editorAttributes) {

attributes = {};
attributes['class'] = 'wrs_modal_close_button';
attributes['title'] = 'Close';
attributes['title'] = strings['close'];
var closeModalDiv = wrs_createElement('div', attributes);
this.closeDiv = closeModalDiv;

attributes = {};
attributes['class'] = 'wrs_modal_stack_button';
attributes['title'] = 'Full-screen';
attributes['title'] = strings['fullscreen'];
var stackModalDiv = wrs_createElement('div', attributes);
this.stackDiv = stackModalDiv;

attributes = {};
attributes['class'] = 'wrs_modal_minimize_button';
attributes['title'] = 'Minimise';
attributes['title'] = strings['minimise'];
var minimizeModalDiv = wrs_createElement('div', attributes);
this.minimizeDiv = minimizeModalDiv;

Expand All @@ -4088,8 +4128,7 @@ function ModalWindow(path, editorAttributes) {
var iframeModalContainer = wrs_createElement('div', attributes);
this.iframeContainer = iframeModalContainer;

this.editor = null;

this.lastImageWasNew = true;
}

ModalWindow.prototype.create = function() {
Expand Down Expand Up @@ -4143,30 +4182,47 @@ ModalWindow.prototype.open = function() {

if (this.properties.open == true || this.properties.created) {

var editor = this.iframe.contentWindow._wrs_modalWindowProperties.editor;
var update_toolbar = function() {
var editor = this.editor;
var updateToolbar = function() {
if (customEditor = wrs_int_getCustomEditorEnabled()) {
toolbar = customEditor.toolbar ? customEditor.toolbar : wrs_attributes['toolbar'];
var toolbar = customEditor.toolbar ? customEditor.toolbar : _wrs_int_wirisProperties['toolbar'];
_wrs_modalWindow.setTitle(customEditor.title);
if (typeof editor.params.toolbar == 'undefined' || editor.params.toolbar != toolbar) {
editor.setParams({'toolbar' : toolbar});
_wrs_modalWindow.setTitle(customEditor.title);
}
} else if (typeof editor.params.toolbar != 'undefined' && editor.params.toolbar != 'general') {
editor.setParams({'toolbar' : 'general'});
} else {
var toolbar = (typeof _wrs_int_wirisProperties == 'undefined' || typeof _wrs_int_wirisProperties['toolbar'] == 'undefined') ? 'general' : _wrs_int_wirisProperties['toolbar'];
_wrs_modalWindow.setTitle('WIRIS EDITOR math');
if (typeof editor.params.toolbar == 'undefined' || editor.params.toolbar != toolbar) {
editor.setParams({'toolbar' : toolbar});
wrs_int_disableCustomEditors();
}
}
};

var self = this;

// It controls cases where is needed to set an empty mathml or copy the current mathml value.
var updateMathMLContent = function () {
if (!self.lastImageWasNew) {
if (self.properties.deviceProperties.isAndroid || self.properties.deviceProperties.isIOS) {
editor.setMathML('<math><semantics><annotation encoding="application/json">[]</annotation></semantics></math>"');
} else {
editor.setMathML('<math/>');
}
}
};

if (this.properties.open == true) {
var customEditorClass = _wrs_temporalImage.getAttribute('data-custom-editor');
if (customEditorClass) {
wrs_int_enableCustomEditor(customEditorClass);
updateToolbar();
if (_wrs_isNewElement) {
updateMathMLContent();
self.lastImageWasNew = true;
}
else {
wrs_int_disableCustomEditors();
editor.setMathML(wrs_mathmlDecode(_wrs_temporalImage.getAttribute('data-mathml')));
this.lastImageWasNew = false;
}
update_toolbar();
this.iframe.contentWindow._wrs_modalWindowProperties.editor.setMathML(wrs_mathmlDecode(_wrs_temporalImage.getAttribute('data-mathml')));
}
else {
this.containerDiv.style.visibility = '';
Expand All @@ -4176,26 +4232,18 @@ ModalWindow.prototype.open = function() {

this.properties.open = true;

updateToolbar();

if (_wrs_isNewElement) {
if (this.properties.deviceProperties.isAndroid || this.properties.deviceProperties.isIOS) {
editor.setMathML('<math><semantics><annotation encoding="application/json">[]</annotation></semantics></math>"');
} else {
editor.setMathML('<math/>');
}
update_toolbar();
updateMathMLContent();
self.lastImageWasNew = true;
} else {
var customEditorClass = _wrs_temporalImage.getAttribute('data-custom-editor');
if (customEditorClass) {
wrs_int_enableCustomEditor(customEditorClass);
}
else {
wrs_int_disableCustomEditors();
}
update_toolbar();
editor.setMathML(wrs_mathmlDecode(_wrs_temporalImage.getAttribute('data-mathml')));
this.lastImageWasNew = false;
}

editor.focus();

if (!this.properties.deviceProperties.isAndroid && !this.properties.deviceProperties.isIOS) {
this.stackModalWindow();
}
Expand All @@ -4205,6 +4253,8 @@ ModalWindow.prototype.open = function() {
this.maximizeModalWindow();
}
} else {
var title = wrs_int_getCustomEditorEnabled() != null ? wrs_int_getCustomEditorEnabled().title : 'WIRIS EDITOR math';
_wrs_modalWindow.setTitle(title);
this.create();
}

Expand All @@ -4215,13 +4265,14 @@ ModalWindow.prototype.open = function() {
* @ignore
*/
ModalWindow.prototype.close = function() {
// Is mandatory make this BEFORE hide modalwindow.
this.editor.setMathML('<math/>');
this.overlayDiv.style.visibility = 'hidden';
this.containerDiv.style.visibility = 'hidden';
this.containerDiv.style.display = 'none';
this.overlayDiv.style.display = 'none';
this.properties.open = false;
wrs_int_disableCustomEditors();
document.getElementsByClassName('wrs_modal_iframe')[0].contentWindow._wrs_modalWindowProperties.editor.setMathML('<math/>');
// Properties to initial state.
this.properties.state = '';
this.properties.previousState = '';
Expand Down Expand Up @@ -4468,9 +4519,6 @@ ModalWindow.prototype.startDrag = function(ev) {
};
}

if (typeof dialogContainerDiv != 'undefined') {
this.addClass('wrs_drag');
}
}

/**
Expand Down Expand Up @@ -4508,7 +4556,6 @@ ModalWindow.prototype.stopDrag = function(ev) {
this.containerDiv.style.top = parseInt(this.containerDiv.style.top) - window.pageYOffset + "px";
}
this.containerDiv.style.bottom = null;
wrs_addClass(this.containerDiv, 'wrs_drag');
this.dragDataObject = null;
}

Expand Down Expand Up @@ -4539,10 +4586,14 @@ ModalWindow.prototype.hideKeyboard = function() {

}, 200);
};
// ...focus function changes scroll value, so we need to restore it.
if (typeof scrollY != 'undefined') {
var keepScroll = scrollY;
field.focus();
window.scrollTo(0, keepScroll);
}
var keepScroll = window.pageYOffset;
field.focus();
window.scrollTo(0, keepScroll);
}

/**
* Set WIRIS Editor as variable
*/
ModalWindow.prototype.setEditor = function(editor) {
this.editor = editor;
}
Loading

0 comments on commit 2e85069

Please sign in to comment.