Skip to content

Commit

Permalink
4.8.1 Stable version
Browse files Browse the repository at this point in the history
  • Loading branch information
mcagigas-at-wiris authored Oct 23, 2017
1 parent 30059d9 commit b8f5e6e
Show file tree
Hide file tree
Showing 10 changed files with 310 additions and 65 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.8.0.1376
4.8.1.1377
3 changes: 3 additions & 0 deletions core/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -4777,6 +4777,9 @@ ModalWindow.prototype.setToolbar = function(toolbar) {
* @ignore
*/
ModalWindow.prototype.focus = function() {
// Focus on iframe explicit
// We add this focus in iframe beacuse tiny3 have a problem with focus in chrome and it can't focus iframe automaticly
this.iframe.focus();
_wrs_popupWindow.postMessage({'objectName' : 'editor', 'methodName' : 'focus', 'arguments': null}, this.iframeOrigin);
}

Expand Down
15 changes: 13 additions & 2 deletions core/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,22 @@ var _wrs_isNewElement; // Unfortunately we need this variabels as global variabl
script.type = 'text/javascript';
var editorUrl = _wrs_conf_editorUrl;
// Change to https if necessary.
// We create an object url for parse url string and work more efficiently.
var urlObject = document.createElement('a');
urlObject.href = editorUrl;

if (window.location.href.indexOf("https://") == 0) {
if (editorUrl.indexOf("http://") == 0) {
editorUrl = "https" + editorUrl.substring(4);
// It check if browser is https and configuration is http. If this is so, we will replace protocol.
if (urlObject.protocol == 'http:') {
urlObject.protocol = 'https:';
}
}
// Check protocol and remove port if it's standard.
if(urlObject.port == '80' || urlObject.port == '443'){
editorUrl = urlObject.protocol + '//' + urlObject.hostname + urlObject.pathname;
}else{
editorUrl = urlObject.protocol + '//' + urlObject.hostname + urlObject.port + urlObject.pathname;
}

// Editor stats.
statEditor = _wrs_conf_editor;
Expand Down
1 change: 1 addition & 0 deletions lang/en/atto_wiris.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
$string['wiris_editor_title'] = 'Math editor';
$string['wiris_cas_title'] = 'Calculator';
$string['wiris_chem_editor_title'] = 'Chemistry editor';
$string['error_connection'] = 'An error occurred while loading WIRIS PLUGIN';
21 changes: 19 additions & 2 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ function atto_wiris_strings_for_js() {
'wiris_editor_title',
'wiris_cas_title',
'wiris_chem_editor_title',
'error_connection'
),
'atto_wiris');
}
Expand All @@ -43,9 +44,25 @@ function atto_wiris_strings_for_js() {
* Set parameters to be passed to the js plugin constructor.
*/
function atto_wiris_params_for_js() {
global $COURSE, $PAGE;
global $COURSE, $PAGE, $CFG;
// We need to know if WIRIS filter are active in the context of the course.
// If not WIRIS plugin should be disabled.
$host = get_config('filter_wiris', 'imageservicehost');
$servicepath = get_config('filter_wiris', 'imageservicepath');
$servicepath = str_replace('/editor/render', '/editor/status', $servicepath);
$port = get_config('filter_wiris', 'imageserviceport');
$protocol = get_config('filter_wiris', 'imageserviceprotocol');
if ($protocol == 'http' && $port == '443') {
$port = '';
}
if ($protocol == 'https' && $port == '80') {
$port = '';
}
if ($port != '') {
$port = ':'.$port;
}
// URL FOR CHECK AVAILABLE SERVICE
$urlstatus = $protocol . "://" . $host . $port . $servicepath;
$filterwirisactive = true;
// Filter disabled at course level.
if (!get_config('filter_wiris', 'allow_editorplugin_active_course')) {
Expand All @@ -67,5 +84,5 @@ function atto_wiris_params_for_js() {
}

// Atto js plugin checks if the filter is - or not - active.
return array('lang' => current_language(), 'filter_enabled' => $filterwirisactive);
return array('lang' => current_language(), 'filter_enabled' => $filterwirisactive, 'url_status' => $urlstatus, 'platform_version' => $CFG->version);
}
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 = 2017101400;
$plugin->release = '4.8.0.1376';
$plugin->version = 2017102300;
$plugin->release = '4.8.1.1377';
$plugin->requires = 2014050800;
$plugin->component = 'atto_wiris';
$plugin->dependencies = array ('filter_wiris' => 2017101400);
$plugin->dependencies = array ('filter_wiris' => 2017102300);
$plugin->maturity = MATURITY_STABLE;
109 changes: 90 additions & 19 deletions yui/build/moodle-atto_wiris-button/moodle-atto_wiris-button-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ Y.namespace('M.atto_wiris').Button = Y.Base.create('button', Y.M.editor_atto.Edi
if (!config.filter_enabled) {
return;
}
this._platform_version = config.platform_version;
if(this._serviceAvailable(config.url_status) === false){
window._wrs_service_available = false;
}else{
window._wrs_service_available = true;
}
this._lang = config.lang;
window._wrs_int_langCode = config.lang;
// Add global-scope callback functions and properties.
Expand Down Expand Up @@ -91,7 +97,14 @@ Y.namespace('M.atto_wiris').Button = Y.Base.create('button', Y.M.editor_atto.Edi
window._wrs_int_path = window._wrs_int_conf_file.split("/");
window._wrs_int_path.pop();
window._wrs_int_path = window._wrs_int_path.join("/");
window._wrs_int_path = window._wrs_int_path.indexOf("/") === 0 || window._wrs_int_path.indexOf("http") === 0 ? window._wrs_int_path : window._wrs_int_conf_path + "/" + window._wrs_int_path;

// Here we choose the correct integration path.
// We need to know if the integration path is an absolute path
// or an absolute URL.
var wrs_int_path_cond = window._wrs_int_path.indexOf("/") === 0 || window._wrs_int_path.indexOf("http");

// Here we construct the final integration path.
window._wrs_int_path = wrs_int_path_cond ? window._wrs_int_path : window._wrs_int_conf_path + "/" + window._wrs_int_path;

// Moodle.
window._wrs_isMoodle24 = true;
Expand Down Expand Up @@ -120,9 +133,11 @@ Y.namespace('M.atto_wiris').Button = Y.Base.create('button', Y.M.editor_atto.Edi
var host = this.get('host');
var wirisplugin = this;
window._wrs_int_currentPlugin = this;
window._wrs_int_editors_elements = typeof window._wrs_int_editors_elements == "undefined" ? {} : window._wrs_int_editors_elements;
// check if elements of editor exists and return elements
var wrs_editors_elements_cond = typeof window._wrs_int_editors_elements == "undefined";
window._wrs_int_editors_elements = wrs_editors_elements_cond ? {} : window._wrs_int_editors_elements;
// Update textarea value on change.
host.on('change', function(e) {
host.on('change', function() {
wirisplugin._unparseContent();
});
// Override updateFromTextArea to update the content editable element.
Expand All @@ -138,7 +153,7 @@ Y.namespace('M.atto_wiris').Button = Y.Base.create('button', Y.M.editor_atto.Edi
// Add WIRIS buttons to the toolbar.
this._addButtons();

// Adding submit event
// Adding submit event.
var form = host.textarea.ancestor('form');

if (form) {
Expand Down Expand Up @@ -206,25 +221,30 @@ Y.namespace('M.atto_wiris').Button = Y.Base.create('button', Y.M.editor_atto.Edi
* WIRIS editor button callback.
**/
_editorButton: function() {
if (_wrs_int_popup) {
_wrs_int_popup.focus();
}
else {
var host = this.get('host');
_wrs_int_currentPlugin = this;
_wrs_int_popup = wrs_openEditorWindow(this._lang, host.editor.getDOMNode(), false);
if(window._wrs_service_available === true){
if (_wrs_int_popup) {
_wrs_int_popup.focus();
}
else {
var chemistryEditor = false;
this._connectEditor(chemistryEditor);
}
}else{
this._notify('error_connection');
}
},

_chemEditorButton: function() {
if (_wrs_int_popup) {
_wrs_int_popup.focus();
}
else {
var host = this.get('host');
_wrs_int_currentPlugin = this;
wrs_int_enableCustomEditor('chemistry');
_wrs_int_popup = wrs_openEditorWindow(this._lang, host.editor.getDOMNode(), false);
if(window._wrs_service_available === true){
if (_wrs_int_popup) {
_wrs_int_popup.focus();
}
else {
var chemistryEditor = true;
this._connectEditor(chemistryEditor);
}
}else{
this._notify('error_connection');
}
},
/**
Expand Down Expand Up @@ -314,7 +334,58 @@ Y.namespace('M.atto_wiris').Button = Y.Base.create('button', Y.M.editor_atto.Edi
img.detachAll('dblclick');
img.on('dblclick', this._handleCasDoubleClick, this);
}, this);
},
_serviceAvailable: function(urlChecker) {
if (window.location.href.indexOf("https://") === 0) {
var a = document.createElement('a');
a.href = urlChecker;
// It check if browser is https and configuration is http. If this is so, we will replace protocol.
if (a.protocol == 'http:') {
a.protocol = 'https:';
}
// check protocol and remove port if it's standar
if(a.port == '80' || a.port == '443'){
urlChecker = a.protocol + '//' + a.hostname + a.pathname;
}else{
urlChecker = a.protocol + '//' + a.hostname + a.port + a.pathname;
}
}
var xhttp = new XMLHttpRequest();
xhttp.open("GET", urlChecker, false);
try{
xhttp.send();
}catch(e){
xhttp.abort();
return false;
}
if (xhttp.status == 200) {
xhttp.abort();
return true;
}
xhttp.abort();
return false;
},
_connectEditor: function(chemistry){
var host = this.get('host');
wrs_int_currentPlugin = this;
if(chemistry === true){
wrs_int_enableCustomEditor('chemistry');
}else{
wrs_int_enableCustomEditor();
}
_wrs_int_popup = wrs_openEditorWindow(this._lang, host.editor.getDOMNode(), false);
},
_notify: function(message){
if(this._platform_version > 2016052300){
require(['core/notification'], function(notification) {
notification.addNotification({
message:M.util.get_string(message, 'atto_wiris'),
type: "danger"
});
});
}
}
});


}, '@VERSION@', {"requires": ["moodle-editor_atto-plugin", "get"]});
Loading

0 comments on commit b8f5e6e

Please sign in to comment.