Skip to content

Commit

Permalink
4.60 Stable version
Browse files Browse the repository at this point in the history
  • Loading branch information
mcagigas-at-wiris authored Aug 8, 2017
1 parent 8dc0f88 commit 225396a
Show file tree
Hide file tree
Showing 11 changed files with 128 additions and 97 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.5.0.1372
4.6.0.1373
114 changes: 92 additions & 22 deletions core/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ var _wrs_staticNodeLengths = {
'BR': 1
}

// Translated languages.
var _wrs_languages = 'ar,ca,cs,da,de,en,es,et,eu,fi,fr,gl,he,hr,hu,it,ja,ko,nl,no,pl,pt,pt_br,ru,sv,tr,zh,el';

// Backwards compatibily.

if (!(window._wrs_conf_imageClassName)) {
Expand Down Expand Up @@ -574,6 +577,12 @@ function wrs_createObject(objectCode, creator) {
* @ignore
*/
function wrs_createObjectCode(object) {

// In case that the image was not created, the object can be null or undefined.
if (typeof object == 'undefined' || object == null) {
return;
}

if (object.nodeType == 1) { // ELEMENT_NODE.
var output = '<' + object.tagName;

Expand Down Expand Up @@ -1996,7 +2005,13 @@ function wrs_mathmlToImgObject(creator, mathml, wirisProperties, language) {
var result = JSON.parse(wrs_createShowImageSrc(mathml, data, language));
if (result["status"] == 'warning') {
// POST call.
result = JSON.parse(wrs_getContent(_wrs_conf_showimagePath, data));
// if the mathml is malformed, this function will throw an exception
try {
result = JSON.parse(wrs_getContent(_wrs_conf_showimagePath, data));
}
catch (e) {
return;
}
}
result = result.result;
if (result['format'] == 'png') {
Expand Down Expand Up @@ -2667,22 +2682,55 @@ function wrs_initSetSize() {
_wrs_conf_setSize = _wrs_conf_setSize || _wrs_conf_saveMode == 'xml' || _wrs_conf_saveMode == 'safeXml' || (_wrs_conf_saveMode == 'base64' && _wrs_conf_editMode == 'default');
}

/**
* Loads a set of global variables containing server configuration.
* This method calls to configurationjs service, converting the response
* JSON into javascript variables
* @ignore
*/
function wrs_loadConfiguration() {
if (typeof _wrs_conf_path == 'undefined') {
_wrs_conf_path = wrs_getCorePath();
}

var script = document.createElement('script');
script.type = 'text/javascript';
// Sometimes _wrs_conf_path contains a final "/" because is obtained using some editor's API.
// With this variable we avoid URL's with doubles //.
var newConfPath = _wrs_conf_path.lastIndexOf("/") == _wrs_conf_path.length - 1 ? _wrs_conf_path + _wrs_int_conf_file : _wrs_conf_path + "/" + _wrs_int_conf_file;
var configUrl = _wrs_int_conf_file.indexOf("/") == 0 || _wrs_int_conf_file.indexOf("http") == 0 ? _wrs_int_conf_file : newConfPath;
configUrl = configUrl.replace(/([^:]\/)\/+/g, "$1");
script.src = configUrl;
document.getElementsByTagName('head')[0].appendChild(script); // Asynchronous load of configuration.
var httpRequest = typeof XMLHttpRequest != 'undefined' ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
var configUrl = _wrs_int_conf_file.indexOf("/") == 0 || _wrs_int_conf_file.indexOf("http") == 0 ? _wrs_int_conf_file : wrs_concatenateUrl(_wrs_conf_path, _wrs_int_conf_file);
httpRequest.open('GET', configUrl, false);
httpRequest.send(null);

var jsonConfiguration = JSON.parse(httpRequest.responseText);

// JSON structure: {{jsVariableName, jsVariableValue}}.

variables = Object.keys(jsonConfiguration);

for (variable in variables) {
window[variables[variable]] = jsonConfiguration[variables[variable]];
}

// Services path (tech dependant).
wrs_loadServicePaths(configUrl);

// End configuration.
_wrs_conf_configuration_loaded = true;
if (typeof _wrs_conf_core_loaded != 'undefined') {
_wrs_conf_plugin_loaded = true;
}
}

function wrs_loadServicePaths(url) {
// Services path (tech dependant).
_wrs_conf_createimagePath = url.replace('configurationjs', 'createimage');
_wrs_conf_showimagePath = url.replace('configurationjs', 'showimage');
_wrs_conf_editorPath = url.replace('configurationjs', 'editor');
_wrs_conf_CASPath = url.replace('configurationjs', 'cas');
_wrs_conf_createcasimagePath = url.replace('configurationjs', 'createcasimage');
_wrs_conf_getmathmlPath = url.replace('configurationjs', 'getmathml');
_wrs_conf_servicePath = url.replace('configurationjs', 'service');
}

_wrs_conf_plugin_loaded = true;

function wrs_getCorePath() {
var scriptName = "core/core.js";
var col = document.getElementsByTagName("script");
Expand All @@ -2700,21 +2748,42 @@ function wrs_getCorePath() {
}

function wrs_loadLangFile() {
// When a language is not defined, put english (en) as default.
if (typeof _wrs_int_langCode == 'undefined' || _wrs_int_langCode == null) {
_wrs_int_langCode = 'en';
}

langArray = _wrs_languages.split(',');

if (langArray.indexOf(_wrs_int_langCode) == -1) {
_wrs_int_langCode = _wrs_int_langCode.substr(0,2);
}

if (langArray.indexOf(_wrs_int_langCode) == -1) {
_wrs_int_langCode = 'en';
}

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");
var separator = "";
if ((path1.indexOf("/") != path1.length) && (path2.indexOf("/") != 0)) {
separator = "/";
}
return (path1 + separator + path2).replace(/([^:]\/)\/+/g, "$1");
}

var _wrs_conf_core_loaded = true;

// Loading javascript configuration.
if (typeof _wrs_conf_configuration_loaded == 'undefined') {
wrs_loadConfiguration();
} else {
var configUrl = _wrs_int_conf_file.indexOf("/") == 0 || _wrs_int_conf_file.indexOf("http") == 0 ? _wrs_int_conf_file : wrs_concatenateUrl(_wrs_conf_path, _wrs_int_conf_file);
// If javascript configuration is loaded we need to load service paths manually.
wrs_loadServicePaths(configUrl);
_wrs_conf_plugin_loaded = true;
}

Expand Down Expand Up @@ -4219,7 +4288,8 @@ ModalWindow.prototype.create = function() {

ModalWindow.prototype.open = function() {

this.hideKeyboard();
// Due to editor configurations we need to wait a few time.
setTimeout(function() {_wrs_modalWindow.hideKeyboard(), 300});

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

Expand Down Expand Up @@ -4247,12 +4317,10 @@ ModalWindow.prototype.open = function() {

// 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) {
this.setMathML('<math><semantics><annotation encoding="application/json">[]</annotation></semantics></math>"');
} else {
this.setMathML('<math/>');
}
if (self.properties.deviceProperties.isAndroid || self.properties.deviceProperties.isIOS) {
self.setMathML('<math><semantics><annotation encoding="application/json">[]</annotation></semantics></math>"');
} else {
self.setMathML('<math/>');
}
};

Expand All @@ -4270,7 +4338,7 @@ ModalWindow.prototype.open = function() {
else {
this.containerDiv.style.visibility = '';
this.overlayDiv.style.visibility = '';
this.containerDiv.style.display = '';
this.containerDiv.style.opacity = '';
this.overlayDiv.style.display = '';

this.properties.open = true;
Expand All @@ -4284,7 +4352,6 @@ ModalWindow.prototype.open = function() {
this.setMathML(wrs_mathmlDecode(_wrs_temporalImage.getAttribute('data-mathml')));
this.lastImageWasNew = false;
}
console.log("focusing");
this.focus();

if (!this.properties.deviceProperties.isAndroid && !this.properties.deviceProperties.isIOS) {
Expand All @@ -4311,6 +4378,7 @@ ModalWindow.prototype.close = function() {
this.setMathML('<math/>');
this.overlayDiv.style.visibility = 'hidden';
this.containerDiv.style.visibility = 'hidden';
this.containerDiv.style.opacity = '0';
this.overlayDiv.style.display = 'none';
this.properties.open = false;
wrs_int_disableCustomEditors();
Expand Down Expand Up @@ -4687,3 +4755,5 @@ ModalWindow.prototype.focus = function() {
ModalWindow.prototype.fireEditorEvent = function(eventName) {
_wrs_popupWindow.postMessage({'objectName' : 'editorEvent', 'eventName' : eventName, 'arguments': null}, this.iframeOrigin);
}

var _wrs_conf_core_loaded = true;
2 changes: 1 addition & 1 deletion core/editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
padding-left: 6px;
}

..wrs_buttonContainer.wrs_modalDesktop {
.wrs_buttonContainer.wrs_modalDesktop {
padding-left: 0px;
}

Expand Down
8 changes: 2 additions & 6 deletions core/modal.css
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@
z-index: 99999;
}


.wrs_modal_dialogContainer.wrs_modal_desktop {
font-size: 14px;
}
Expand All @@ -177,6 +176,7 @@
width: 250px;
margin-right: 10px;
}

.wrs_modal_dialogContainer.wrs_modal_desktop.wrs_minimized.wrs_drag {
}

Expand All @@ -188,7 +188,7 @@
box-shadow: rgba(0,0,0,0.5) 0px 2px 8px
}

.wrs_modal_dialogContainer.wrs_drag. {
.wrs_modal_dialogContainer.wrs_drag {
box-shadow: rgba(0,0,0,0.5) 0px 2px 8px;
}

Expand Down Expand Up @@ -218,8 +218,6 @@
left: 50%;
}



.wrs_modal_iframeContainer.wrs_maximized {
}

Expand All @@ -232,7 +230,6 @@
height: 100%;
}


.wrs_modal_iframe.wrs_modal_android {
margin : auto;
}
Expand Down Expand Up @@ -269,7 +266,6 @@
}
}


@media all and (orientation : landscape) {

.wrs_modal_dialogContainer.wrs_modal_mobile {
Expand Down
12 changes: 11 additions & 1 deletion lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,15 @@ function atto_wiris_strings_for_js() {
* Set parameters to be passed to the js plugin constructor.
*/
function atto_wiris_params_for_js() {
return array('lang' => current_language());
global $COURSE;
// We need to know if WIRIS filter are active in the context of the course.
// If not WIRIS plugin should be disabled.
$filterwirisactive = true;
if (!get_config('filter_wiris', 'allow_editorplugin_active_course')) {
$context = context_course::instance($COURSE->id);
$activefilters = filter_get_active_in_context($context);
$filterwirisactive = array_key_exists('wiris', $activefilters);
}
// Atto js plugin checks if the filter is - or not - active.
return array('lang' => current_language(), 'filter_enabled' => $filterwirisactive);
}
6 changes: 3 additions & 3 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2017070900;
$plugin->release = '4.5.0.1372';
$plugin->version = 2017080800;
$plugin->release = '4.6.0.1373';
$plugin->requires = 2014050800;
$plugin->component = 'atto_wiris';
$plugin->dependencies = array ('filter_wiris' => 2017070900);
$plugin->dependencies = array ('filter_wiris' => 2017080800);
$plugin->maturity = MATURITY_STABLE;
Loading

0 comments on commit 225396a

Please sign in to comment.