Skip to content

Commit

Permalink
7.1.0 stable version
Browse files Browse the repository at this point in the history
  • Loading branch information
mcagigas-at-wiris authored Apr 5, 2018
1 parent 1e5bf50 commit 09e5e3c
Show file tree
Hide file tree
Showing 11 changed files with 416 additions and 295 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.0.0.1386
7.1.0.1387
321 changes: 221 additions & 100 deletions core/core.js

Large diffs are not rendered by default.

102 changes: 31 additions & 71 deletions core/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var _wrs_isNewElement; // Unfortunately we need this variabels as global variabl
// For popup window opener is window.opener. For modal window window.parent.
var wrs_int_opener = window.opener ? window.opener : window.parent;
var _wrs_closeFunction = window.opener ? window.close : function() {getMethod(null, 'wrs_closeModalWindow', [], null)};
var _wrs_showPopUpFunction = function() {getMethod(null, 'wrs_showPopUpMessage', [], null)};
var _wrs_callbacks = [];
var _wrs_callId = 0;
var _wrs_int_loaded = false;
Expand Down Expand Up @@ -307,8 +308,6 @@ var _wrs_isNewElement; // Unfortunately we need this variabels as global variabl
strings = new Object();
}

var popup = new PopUpMessage(strings);

// Submit button.
var controls = document.getElementById('controls');
var submitButton = document.createElement('input');
Expand Down Expand Up @@ -386,9 +385,13 @@ var _wrs_isNewElement; // Unfortunately we need this variabels as global variabl
}

wrs_addEvent(cancelButton, 'click', function () {
_wrs_closeFunction();
// Control buttons need to cause a editor blur in order to reset the state for the next time that it is opened.
editor.blur();
if (editor.isFormulaEmpty() || window.editorListener.getIsContentChanged() === false) {
_wrs_closeFunction();
// Control buttons need to cause a editor blur in order to reset the state for the next time that it is opened.
editor.blur();
}else{
_wrs_showPopUpFunction();
}
});

buttonContainer.appendChild(cancelButton);
Expand Down Expand Up @@ -435,6 +438,14 @@ var _wrs_isNewElement; // Unfortunately we need this variabels as global variabl
window.editorListener.setIsContentChanged(false);
}else if (e.data.objectName != 'undefined' && e.data.objectName == 'editorResize') {
editor.getElement().style.height = (e.data.arguments[0] - controls.offsetHeight) + "px";
}else if (e.data.objectName != 'undefined' && e.data.objectName == 'checkCloseCondition') {
if (editor.isFormulaEmpty() || window.editorListener.getIsContentChanged() === false) {
_wrs_closeFunction();
}else{
_wrs_showPopUpFunction();
}
}else if (e.data.objectName != 'undefined' && e.data.objectName == 'blur') {
document.activeElement.blur();
}
});

Expand Down Expand Up @@ -469,14 +480,22 @@ var _wrs_isNewElement; // Unfortunately we need this variabels as global variabl
getMethod('_wrs_modalWindow', 'closedIosSoftkeyboard', [], null);
}

// Event for close window and trap focus
// Event manager code
wrs_addEvent(window, 'keydown', function(e) {
if (_wrs_conf_modalWindow) {
if (e.keyCode !== undefined && e.keyCode === 27 && e.repeat === false) {
if (editor.isFormulaEmpty() || window.editorListener.getIsContentChanged() === false) {
_wrs_closeFunction();
}else{
popup.show();
if (e.key !== undefined && e.repeat === false) {
// Code for detect Esc event
if (e.key === "Escape" || e.key === 'Esc') {
if (editor.isFormulaEmpty() || window.editorListener.getIsContentChanged() === false) {
_wrs_closeFunction();
}else{
_wrs_showPopUpFunction();
}
}
// Code for detect Tab event
if (e.key === "Tab") {
submitButton.focus();
e.preventDefault();
}
}
}
Expand All @@ -486,7 +505,7 @@ var _wrs_isNewElement; // Unfortunately we need this variabels as global variabl
// Due to IOS use soft keyboard, we don't want to move the cursor to MathType.
editor.focus();
// Set initial editor height.
editorElement.style.height = (document.getElementById('container').offsetHeight - controls.offsetHeight - 20) + 'px';
editorElement.style.height = (document.getElementById('container').offsetHeight - controls.offsetHeight - 10) + 'px';
}
} else {
setTimeout(wrs_waitForEditor, 100);
Expand All @@ -499,63 +518,4 @@ var _wrs_isNewElement; // Unfortunately we need this variabels as global variabl
getMethod(null, 'wrs_int_notifyWindowClosed', [], function(wrs_int_notifyWindowClosed){
});
});
// PopUpMessageClass definition
// This class generate a modal message to show information to user
// We should send a language strings to show messages
function PopUpMessage(strings)
{
this.strings = strings;
this.overlayEnvolture = document.body.appendChild(document.createElement("DIV"));
this.overlayEnvolture.setAttribute("style", "display: none;");

this.message = this.overlayEnvolture.appendChild(document.createElement("DIV"));
this.message.setAttribute("style", "margin: auto;position: absolute;top: 0;left: 0;bottom: 0;right: 0;background: white;width: 65%;height: 69px;border-radius: 2px;padding: 20px;font-family: sans-serif;font-size: 15px;text-align: left;color: #2e2e2e;z-index: 5;");

var overlay = this.overlayEnvolture.appendChild(document.createElement("DIV"));
overlay.setAttribute("style", "position: fixed; width: 100%; height: 100%; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 4; cursor: pointer;");
self = this;
// We create a overlay that close popup message on click in there
overlay.addEventListener("click", function(){self.close();});

this.buttonArea = this.message.appendChild(document.createElement('p'));
// By default, popupwindow give close modal message with close and cancel buttons
// You can set other message with other buttons
this.setOptions('close_modal_warning','close,cancel');
}
PopUpMessage.prototype.setOptions = function(messageKey,values){
this.message.removeChild(this.buttonArea);
if(typeof this.strings[messageKey] != 'undefined'){
this.message.innerHTML = this.strings[messageKey];
}
this.buttonArea = this.message.appendChild(document.createElement('p'));
var types = values.split(',');
self = this;
// This is definition of buttons. You can create others.
types.forEach(function(type){
if(type == "close"){
var buttonClose = self.buttonArea.appendChild(document.createElement("BUTTON"));
buttonClose.setAttribute("style","margin: 0px;border: 0px;background: #567e93;border-radius: 4px;padding: 7px 11px;color: white;");
buttonClose.addEventListener('click',function(){self.close();_wrs_closeFunction();})
if(typeof this.strings['close'] != 'undefined'){
buttonClose.innerHTML = this.strings['close'];
}
}
if(type == 'cancel'){
var buttonCancel = self.buttonArea.appendChild(document.createElement("BUTTON"));
buttonCancel.setAttribute("style","margin: 0px;border: 0px;border-radius: 4px;padding: 7px 11px;color: white;color: black;border: 1px solid silver;margin: 0px 5px;");
buttonCancel.addEventListener("click", function(){self.close();});
if(typeof this.strings['cancel'] != 'undefined'){
buttonCancel.innerHTML = this.strings['cancel'];
}
}
});
}
// This method show popup message.
PopUpMessage.prototype.show = function(){
this.overlayEnvolture.setAttribute('style','display: block;')
}
// This method hide popup message
PopUpMessage.prototype.close = function(){
this.overlayEnvolture.setAttribute('style','display: none;')
}
})();
77 changes: 77 additions & 0 deletions core/popup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// PopUpMessageClass definition
// This class generate a modal message to show information to user
// We should send a language strings to show messages
function PopUpMessage(strings)
{
this.strings = strings;
this.overlayEnvolture = document.getElementsByClassName('wrs_modal_iframeContainer')[0].appendChild(document.createElement("DIV"));
this.overlayEnvolture.setAttribute("style", "display: none;width: 100%;");

this.message = this.overlayEnvolture.appendChild(document.createElement("DIV"));
this.message.setAttribute("style", "margin: auto;position: absolute;top: 0;left: 0;bottom: 0;right: 0;background: white;width: 75%;height: 130px;border-radius: 2px;padding: 20px;font-family: sans-serif;font-size: 15px;text-align: left;color: #2e2e2e;z-index: 5;");

var overlay = this.overlayEnvolture.appendChild(document.createElement("DIV"));
overlay.setAttribute("style", "position: absolute; width: 100%; height: 100%; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 4; cursor: pointer;");
self = this;
// We create a overlay that close popup message on click in there
overlay.addEventListener("click", function(){self.close();});

this.buttonArea = this.message.appendChild(document.createElement('p'));
// By default, popupwindow give close modal message with close and cancel buttons
// You can set other message with other buttons
this.setOptions('close_modal_warning','close,cancel');
document.addEventListener('keydown',function(e) {
if (e.key !== undefined && e.repeat === false) {
if (e.key == "Escape" || e.key === 'Esc') {
_wrs_popupWindow.postMessage({'objectName' : 'checkCloseCondition'}, _wrs_modalWindow.iframeOrigin);
}
}
});
}
PopUpMessage.prototype.setOptions = function(messageKey,values){
this.message.removeChild(this.buttonArea);
if(typeof this.strings[messageKey] != 'undefined'){
this.message.innerHTML = this.strings[messageKey];
}
this.buttonArea = this.message.appendChild(document.createElement('p'));
var types = values.split(',');
self = this;
// This is definition of buttons. You can create others.
types.forEach(function(type){
if(type == "close"){
var buttonClose = self.buttonArea.appendChild(document.createElement("BUTTON"));
buttonClose.setAttribute("style","margin: 0px;border: 0px;background: #567e93;border-radius: 4px;padding: 7px 11px;color: white;");
buttonClose.addEventListener('click',function(){self.close();wrs_closeModalWindow();})
if(typeof this.strings['close'] != 'undefined'){
buttonClose.innerHTML = this.strings['close'];
}
}
if(type == 'cancel'){
var buttonCancel = self.buttonArea.appendChild(document.createElement("BUTTON"));
buttonCancel.setAttribute("style","margin: 0px;border: 0px;border-radius: 4px;padding: 7px 11px;color: white;color: black;border: 1px solid silver;margin: 0px 5px;");
buttonCancel.addEventListener("click", function(){self.close();});
if(typeof this.strings['cancel'] != 'undefined'){
buttonCancel.innerHTML = this.strings['cancel'];
}
}
});
}
// This method show popup message.
PopUpMessage.prototype.show = function(){
if (this.overlayEnvolture.style.display != 'block') {
// Clear focus with blur for prevent press anykey
document.activeElement.blur();
_wrs_popupWindow.postMessage({'objectName' : 'blur'}, _wrs_modalWindow.iframeOrigin);
// For works with Safari
window.focus();
this.overlayEnvolture.style.display = 'block';
}else{
this.overlayEnvolture.style.display = 'none';
_wrs_modalWindow.focus();
}
}
// This method hide popup message
PopUpMessage.prototype.close = function(){
this.overlayEnvolture.style.display = 'none';
_wrs_modalWindow.focus();
}
10 changes: 9 additions & 1 deletion lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ function atto_wiris_params_for_js() {
// We need to know if MathType filter are active in the context of the course.
// If not MathType for Atto should be disabled.
$filterwirisactive = true;
// Get MathType and Chemistry buttons enabled configuration.
$editorisactive = get_config('filter_wiris', 'editor_enable');
$chemistryisactive = get_config('filter_wiris', 'chem_editor_enable');
// Filter disabled at course level.
if (!get_config('filter_wiris', 'allow_editorplugin_active_course')) {
$context = context_course::instance($COURSE->id);
Expand All @@ -63,9 +66,14 @@ function atto_wiris_params_for_js() {
$activefilters = filter_get_active_in_context($PAGE->context);
$filterwirisactive = array_key_exists('wiris', $activefilters);
}
} else {
// If filter is deactivated and allowalways is disabled we don't add buttons.
$editorisactive = false;
$chemistryisactive = false;
}
}

// Atto js plugin checks if the filter is - or not - active.
return array('lang' => current_language(), 'filter_enabled' => $filterwirisactive, 'version' => get_config('atto_wiris', 'version'));
return array('lang' => current_language(), 'filter_enabled' => $filterwirisactive, 'version' => get_config('atto_wiris', 'version'),
'editor_is_active' => $editorisactive, 'chemistry_is_active' => $chemistryisactive);
}
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 = 2018030600;
$plugin->release = '7.0.0.1386';
$plugin->version = 2018040400;
$plugin->release = '7.1.0.1387';
$plugin->requires = 2014050800;
$plugin->component = 'atto_wiris';
$plugin->dependencies = array ('filter_wiris' => 2018030600);
$plugin->dependencies = array ('filter_wiris' => 2018040400);
$plugin->maturity = MATURITY_STABLE;
2 changes: 1 addition & 1 deletion wirisplugin-generic.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Configuration.
var _wrs_int_conf_file = "" + M.cfg.wwwroot + "/filter/wiris/integration/configurationjs.php";
var _wrs_plugin_version = "7.0.0.1386";
var _wrs_plugin_version = "7.1.0.1387";
var _wrs_int_conf_async = true;

// Stats editor (needed by core/editor.js).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ Y.namespace('M.atto_wiris').Button = Y.Base.create('button', Y.M.editor_atto.Edi
this._parseContent();

// Add WIRIS buttons to the toolbar.
this._addButtons();
this._addButtons(config);

// Adding submit event.
var form = host.textarea.ancestor('form');
Expand Down Expand Up @@ -174,45 +174,30 @@ Y.namespace('M.atto_wiris').Button = Y.Base.create('button', Y.M.editor_atto.Edi
/**
* Add buttons depending on configuration.
*/
_addButtons: function() {
if (window._wrs_conf_plugin_loaded) {
if (window._wrs_conf_editorEnabled) {
this.addButton({
title: 'wiris_editor_title',
buttonName: 'wiris_editor',
icon: 'formula',
iconComponent: 'atto_wiris',
callback: this._editorButton
});
}
if (window[_wrs_int_customEditors.chemistry.confVariable]) {
this.addButton({
title: 'wiris_chem_editor_title',
buttonName: 'wiris_chem_editor',
icon:'chem',
iconComponent: 'atto_wiris',
callback: this._chemEditorButton
});
}
if (window._wrs_conf_CASEnabled) {
this.addButton({
title: 'wiris_cas_title',
buttonName: 'wiris_cas',
icon: 'cas',
iconComponent: 'atto_wiris',
callback: this._casButton
});
}
// We add the buton after the collapse plugin initially hide other
// buttons. So we recall it here.
var host = this.get('host');
if (host.plugins.collapse) {
host.plugins.collapse._setVisibility(host.plugins.collapse.buttons.collapse);
}

_addButtons: function(config) {
if (parseInt(config.editor_is_active)) {
this.addButton({
title: 'wiris_editor_title',
buttonName: 'wiris_editor',
icon: 'formula',
iconComponent: 'atto_wiris',
callback: this._editorButton
});
}
else {
Y.later(50, this, this._addButtons);
if (parseInt(config.chemistry_is_active)) {
this.addButton({
title: 'wiris_chem_editor_title',
buttonName: 'wiris_chem_editor',
icon:'chem',
iconComponent: 'atto_wiris',
callback: this._chemEditorButton
});
}
// We add the buton after the collapse plugin initially hide other
// buttons. So we recall it here.
var host = this.get('host');
if (host.plugins.collapse) {
host.plugins.collapse._setVisibility(host.plugins.collapse.buttons.collapse);
}
},
/**
Expand Down
Loading

0 comments on commit 09e5e3c

Please sign in to comment.