From 1012a7040d8550d20aba86ec4299b4d1a333a09a Mon Sep 17 00:00:00 2001 From: Manuel Date: Thu, 6 Apr 2017 14:35:43 +0200 Subject: [PATCH] 4.2.0.1364 Stable version --- README.md | 1 + VERSION | 2 +- core/core.js | 131 ++++++++++++------ core/editor.css | 2 +- core/editor.js | 6 +- core/modal.css | 14 -- db/install.php | 2 + db/uninstall.php | 2 + lib.php | 2 + version.php | 6 +- wirisplugin-generic.js | 19 +-- .../moodle-atto_wiris-button-debug.js | 2 +- .../moodle-atto_wiris-button-min.js | 2 +- .../moodle-atto_wiris-button.js | 2 +- yui/src/button/js/button.js | 2 +- 15 files changed, 119 insertions(+), 76 deletions(-) diff --git a/README.md b/README.md index f0fa7393..f129fff6 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ WIRIS plugin for Moodle ========== +[![Build Status](https://travis-ci.org/wiris/moodle-atto_wiris.svg?branch=master)](https://travis-ci.org/wiris/moodle-atto_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). diff --git a/VERSION b/VERSION index 0f42559b..bd195547 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.1.1.1361 +4.2.0.1364 diff --git a/core/core.js b/core/core.js index 72a30dbf..3430ceb1 100644 --- a/core/core.js +++ b/core/core.js @@ -21,6 +21,32 @@ wrs_addEvent(window, 'message', function (e) { } }); +/** + * Fires an element event. + * @param {object} element element where event should be fired. + * @param {string} event event to fire. + * @ignore + */ +function wrs_fireEvent(element, event) { + if (document.createEvent){ + var eventObject = document.createEvent('HTMLEvents'); + eventObject.initEvent(event, true, true); + return !element.dispatchEvent(eventObject); + } + + var eventObject = document.createEventObject(); + return element.fireEvent('on' + event, eventObject) +} + +wrs_addEvent(window, 'mouseup', function (e) { + if (typeof(_wrs_modalWindow) !== 'undefined' && _wrs_modalWindow != null) { + if (_wrs_modalWindow.properties.state != "maximized") { + _wrs_modalWindow.overlayDiv.style.display = 'none'; + } + wrs_fireEvent(_wrs_modalWindow.iframe.contentDocument, 'mouseup'); + } +}); + // Vars. var _wrs_currentPath = window.location.toString().substr(0, window.location.toString().lastIndexOf('/') + 1); var _wrs_editMode = typeof _wrs_editMode != 'undefined' ? _wrs_editMode : undefined; @@ -32,7 +58,7 @@ var _wrs_range; // LaTex client cache. var _wrs_int_LatexCache = {}; -// Accessible client cache +// Accessible client cache. var _wrs_int_AccessibleCache = {}; var _wrs_xmlCharacters = { @@ -259,7 +285,7 @@ function wrs_addClass(element, className) { * @ignore */ function wrs_containsClass(element, className) { - if (!('className' in element)) { + if (element == null || !('className' in element)) { return false; } @@ -786,23 +812,6 @@ function wrs_endParseSaveMode(code) { return code; } -/** - * Fires an element event. - * @param {object} element element where event should be fired. - * @param {string} event event to fire. - * @ignore - */ -function wrs_fireEvent(element, event) { - if (document.createEvent){ - var eventObject = document.createEvent('HTMLEvents'); - eventObject.initEvent(event, true, true); - return !element.dispatchEvent(eventObject); - } - - var eventObject = document.createEventObject(); - return element.fireEvent('on' + event, eventObject) -} - /** * Gets the formula mathml or CAS appletCode using its image hash code. * @param {string} variableName Variable to send on POST query to the server. @@ -1706,11 +1715,6 @@ function wrs_mathmlEncode(input) { input = input.split(_wrs_xmlCharacters.ampersand).join(_wrs_safeXmlCharacters.ampersand); input = input.split(_wrs_xmlCharacters.quote).join(_wrs_safeXmlCharacters.quote); - // Transform ="<" --> "<". - // Transform =">" --> ">". - // input = input.split("=" + _wrs_safeXmlCharacters.doubleQuote + _wrs_safeXmlCharacters.tagOpener + _wrs_safeXmlCharacters.doubleQuote).join("=" + _wrs_safeXmlCharacters.doubleQuote + "<" + _wrs_safeXmlCharacters.doubleQuote); - // input = input.split("=" + _wrs_safeXmlCharacters.doubleQuote + _wrs_safeXmlCharacters.tagCloser + _wrs_safeXmlCharacters.doubleQuote).join("=" + _wrs_safeXmlCharacters.doubleQuote + ">" + _wrs_safeXmlCharacters.doubleQuote); - return input; } @@ -1935,6 +1939,7 @@ function wrs_mathmlToImgObject(creator, mathml, wirisProperties, language) { } data['mml'] = mathml; + data['lang'] = language; if (_wrs_conf_setSize) { // Request metrics of the generated image. @@ -1963,7 +1968,7 @@ function wrs_mathmlToImgObject(creator, mathml, wirisProperties, language) { imgObject.setAttribute('data-custom-editor', mathmlSubstring); } - // Performance enabled + // Performance enabled. if (_wrs_conf_wirisPluginPerformance && (_wrs_conf_saveMode == 'xml' || _wrs_conf_saveMode == 'safeXml')) { var result = JSON.parse(wrs_createShowImageSrc(mathml, data, language)); @@ -2120,7 +2125,12 @@ function wrs_openEditorWindow(language, target, isIframe) { _wrs_temporalRange = null; if (target) { - var selectedItem = wrs_getSelectedItem(target, isIframe); + var selectedItem; + if (typeof wrs_int_getSelectedItem != 'undefined') { + selectedItem = wrs_int_getSelectedItem(target, isIframe); + } else { + selectedItem = wrs_getSelectedItem(target, isIframe); + } if (selectedItem != null) { if (selectedItem.caretPosition === undefined) { @@ -2186,7 +2196,7 @@ function wrs_openEditorWindow(language, target, isIframe) { var fileref = document.createElement("link"); fileref.setAttribute("rel", "stylesheet"); fileref.setAttribute("type", "text/css"); - fileref.setAttribute("href", window.parent._wrs_conf_path + '/core/modal.css'); + fileref.setAttribute("href", wrs_concatenateUrl(window.parent._wrs_conf_path, '/core/modal.css')); document.getElementsByTagName("head")[0].appendChild(fileref); _wrs_css_loaded = true; } @@ -2412,13 +2422,13 @@ wrs_PluginEvent.prototype.preventDefault = function () { } /** - * Fires one WIRIS event + * Fires WIRIS plugin event listeners * @param {String} eventName event name * @param {Object} e event properties * @return {bool} false if event has been prevented. * @ignore */ -function wrs_fireEvent(eventName, e) { +function wrs_fireEventListeners(eventName, e) { for (var i = 0; i < wrs_pluginListeners.length && !e.cancelled; ++i) { if (wrs_pluginListeners[i][eventName]) { // Calling listener. @@ -2447,6 +2457,8 @@ function wrs_updateFormula(focusElement, windowTarget, mathml, wirisProperties, // - editMode (read only) // - wirisProperties // - language (read only). + + editMode = editMode !== null ? editMode : _wrs_editMode; var e = new wrs_PluginEvent(); e.mathml = mathml; @@ -2463,7 +2475,7 @@ function wrs_updateFormula(focusElement, windowTarget, mathml, wirisProperties, e.language = language; e.editMode = editMode; - if (wrs_fireEvent('onBeforeFormulaInsertion', e)) { + if (wrs_fireEventListeners('onBeforeFormulaInsertion', e)) { return; } @@ -2494,7 +2506,7 @@ function wrs_updateFormula(focusElement, windowTarget, mathml, wirisProperties, wrs_insertElementOnSelection(e.node, focusElement, windowTarget); } - if (wrs_fireEvent('onAfterFormulaInsertion', e)) { + if (wrs_fireEventListeners('onAfterFormulaInsertion', e)) { return; } } @@ -2609,11 +2621,11 @@ function wrs_fixAfterResize(img) { if (_wrs_conf_setSize) { if (img.src.indexOf("data:image") != -1) { if (_wrs_conf_imageFormat == 'svg') { - // data:image/svg+xml;charset=utf8, = 32 + // ...data:image/svg+xml;charset=utf8, = 32. var svg = wrs_urldecode(img.src.substring(32, img.src.length)) wrs_setImgSize(img, svg, true); } else { - // data:image/png;base64, == 22 + // ...data:image/png;base64, == 22. var base64 = img.src.substring(22,img.src.length); wrs_setImgSize(img, base64, true); } @@ -2658,6 +2670,10 @@ function wrs_loadConfiguration() { document.getElementsByTagName('head')[0].appendChild(script); // Asynchronous load of configuration. } +function wrs_concatenateUrl(path1, path2) { + return (path1 + path2).replace(/([^:]\/)\/+/g, "$1"); +} + var _wrs_conf_core_loaded = true; if (typeof _wrs_conf_configuration_loaded == 'undefined') { @@ -2684,7 +2700,7 @@ function wrs_createModalWindow() { var fileref = document.createElement("link"); fileref.setAttribute("rel", "stylesheet"); fileref.setAttribute("type", "text/css"); - fileref.setAttribute("href", window.parent._wrs_conf_path + '/core/modal.css'); + fileref.setAttribute("href", wrs_concatenateUrl(window.parent._wrs_conf_path, '/core/modal.css')); document.getElementsByTagName("head")[0].appendChild(fileref); _wrs_css_loaded = true; } @@ -4032,21 +4048,18 @@ function ModalWindow(path, editorAttributes) { attributes['class'] = 'wrs_modal_close_button'; attributes['title'] = 'Close'; var closeModalDiv = wrs_createElement('div', attributes); - // closeModalDiv.innerHTML = '×'; this.closeDiv = closeModalDiv; attributes = {}; attributes['class'] = 'wrs_modal_stack_button'; attributes['title'] = 'Full-screen'; var stackModalDiv = wrs_createElement('div', attributes); - // stackModalDiv.innerHTML = '/'; this.stackDiv = stackModalDiv; attributes = {}; attributes['class'] = 'wrs_modal_minimize_button'; attributes['title'] = 'Minimise'; var minimizeModalDiv = wrs_createElement('div', attributes); - // minimizeModalDiv.innerHTML = "_"; this.minimizeDiv = minimizeModalDiv; attributes = {}; @@ -4078,6 +4091,12 @@ ModalWindow.prototype.create = function() { this.titleBardDiv.appendChild(this.titleDiv); this.iframeContainer.appendChild(this.iframe); + wrs_addEvent(this.overlayDiv, 'mouseup', function (e) { + if (typeof(_wrs_modalWindow) !== 'undefined' && _wrs_modalWindow != null) { + wrs_fireEvent(_wrs_modalWindow.iframe.contentDocument, 'mouseup'); + } + }); + if (!this.deviceProperties['isMobile'] && !this.deviceProperties['isAndroid'] && !this.deviceProperties['isIOS']) { this.containerDiv.appendChild(this.titleBardDiv); } @@ -4161,7 +4180,7 @@ ModalWindow.prototype.close = function() { this.properties.open = false; wrs_int_disableCustomEditors(); document.getElementsByClassName('wrs_modal_iframe')[0].contentWindow._wrs_modalWindowProperties.editor.setMathML(''); - // Properties to initial state + // Properties to initial state. this.properties.state = ''; this.properties.previousState = ''; } @@ -4241,6 +4260,8 @@ ModalWindow.prototype.stackModalWindow = function () { this.containerDiv.style.left = null; this.containerDiv.style.position = null; + this.overlayDiv.style.background = "rgba(0,0,0,0)"; + this.stackDiv.title = "Full-screen"; var modalWidth = parseInt(this.properties.iframeAttributes['width']); @@ -4251,6 +4272,7 @@ ModalWindow.prototype.stackModalWindow = function () { this.iframe.style.height = (parseInt(300) + 3) + 'px'; this.iframe.style.margin = '6px'; this.removeClass('wrs_maximized'); + this.minimizeDiv.title = "Minimise"; this.removeClass('wrs_minimized'); this.addClass('wrs_stack'); } @@ -4271,6 +4293,8 @@ ModalWindow.prototype.minimizeModalWindow = function() { this.containerDiv.style.left = null; this.containerDiv.style.top = null; this.containerDiv.style.position = null; + this.overlayDiv.style.background = "rgba(0,0,0,0)"; + this.minimizeDiv.title = "Maximise"; if (wrs_containsClass(this.overlayDiv, 'wrs_stack')) { this.removeClass('wrs_stack'); @@ -4301,6 +4325,7 @@ ModalWindow.prototype.maximizeModalWindow = function() { this.iframe.style.margin = '6px'; this.removeClass('wrs_drag'); if (wrs_containsClass(this.overlayDiv, 'wrs_minimized')) { + this.minimizeDiv.title = "Minimise"; this.removeClass('wrs_minimized'); } else if (wrs_containsClass(this.overlayDiv, 'wrs_stack')) { this.containerDiv.style.left = null; @@ -4308,6 +4333,8 @@ ModalWindow.prototype.maximizeModalWindow = function() { this.removeClass('wrs_stack'); } this.stackDiv.title = "Exit full-screen"; + this.overlayDiv.style.background = "rgba(0,0,0,0.8)"; + this.overlayDiv.style.display = ''; this.addClass('wrs_maximized'); } @@ -4324,6 +4351,7 @@ ModalWindow.prototype.addListeners = function() { wrs_addEvent(window, 'mouseup', this.stopDrag.bind(this)); wrs_addEvent(document, 'mouseup', this.stopDrag.bind(this)); wrs_addEvent(this.iframe.contentWindow, 'mouseup', this.stopDrag.bind(this)); + wrs_addEvent(this.iframe.contentWindow, 'mousedown', this.setOverlayDiv.bind(this)); wrs_addEvent(document.body, 'mousemove', this.drag.bind(this)); } @@ -4351,7 +4379,7 @@ ModalWindow.prototype.removeListeners = function() { * @ignore */ ModalWindow.prototype.eventClient = function(ev) { - if (typeof(ev.clientX) == 'undefined') { + if (typeof(ev.clientX) == 'undefined' && ev.changedTouches) { var client = { X : ev.changedTouches[0].clientX, Y : ev.changedTouches[0].clientY @@ -4366,6 +4394,17 @@ ModalWindow.prototype.eventClient = function(ev) { } } + +/** + * Set the overlay div display + * + * @param {event} ev touchstart or mousedown event. + * @ignore + */ +ModalWindow.prototype.setOverlayDiv = function(ev) { + this.overlayDiv.style.display = ''; +} + /** * Start drag function: set the object _wrs_dragDataObject with the draggable object offsets coordinates. * when drag starts (on touchstart or mousedown events). @@ -4402,8 +4441,8 @@ ModalWindow.prototype.drag = function(ev) { if(this.dragDataObject) { ev.preventDefault(); ev = ev || event; - this.containerDiv.style.left = this.eventClient(ev).X - this.dragDataObject.x + "px"; - this.containerDiv.style.top = this.eventClient(ev).Y - this.dragDataObject.y + "px"; + this.containerDiv.style.left = this.eventClient(ev).X - this.dragDataObject.x + window.pageXOffset + "px"; + this.containerDiv.style.top = this.eventClient(ev).Y - this.dragDataObject.y + window.pageYOffset + "px"; this.containerDiv.style.position = 'absolute'; this.containerDiv.style.bottom = null; wrs_removeClass(this.containerDiv, 'wrs_stack'); @@ -4417,6 +4456,16 @@ ModalWindow.prototype.drag = function(ev) { * @ignore */ ModalWindow.prototype.stopDrag = function(ev) { + this.containerDiv.style.position = 'fixed'; + // Due to we have multiple events that call this function, we need only to execute the next modifiers one time, + // when the user stops to drag and dragDataObject is not null (the object to drag is attached). + if (this.dragDataObject) { + // Fixed position makes the coords relative to the main window. So that, we need to transform + // the absolute coords to relative removing the scroll. + this.containerDiv.style.left = parseInt(this.containerDiv.style.left) - window.pageXOffset + "px"; + 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; } diff --git a/core/editor.css b/core/editor.css index aae34966..4582658b 100644 --- a/core/editor.css +++ b/core/editor.css @@ -109,7 +109,7 @@ and (orientation : landscape) { } } -/*iPhone 5*/ +/*iPhone5*/ @media only screen and (min-device-width : 320px) and (max-device-width : 568px) diff --git a/core/editor.js b/core/editor.js index 41632868..01117979 100644 --- a/core/editor.js +++ b/core/editor.js @@ -239,8 +239,6 @@ var _wrs_isNewElement; // Unfortunately we need this variabels as global variabl editor = new com.wiris.jsEditor.JsEditor('editor', null); } _wrs_modalWindowProperties.editor = editor; - // getMethod(null, 'wrs_editorLoaded', [editor], function(editorLoaded){ - // }); var ua = navigator.userAgent.toLowerCase(); var isAndroid = ua.indexOf("android") > -1; @@ -277,7 +275,7 @@ var _wrs_isNewElement; // Unfortunately we need this variabels as global variabl } if (isIOS) { - // Editor and controls container + // Editor and controls container. var editorAndControlsContainer = document.getElementById('container'); editorAndControlsContainer.className += ' wrs_container wrs_modalIos'; } @@ -323,7 +321,7 @@ var _wrs_isNewElement; // Unfortunately we need this variabels as global variabl mathml = wrs_mathmlEntities(mathml); // Apply a parse. } - getMethod(null, 'wrs_int_updateFormula', [mathml, _wrs_editMode, queryParams['lang']], function(){ + getMethod(null, 'wrs_int_updateFormula', [mathml, null, queryParams['lang']], function(){ _wrs_closeFunction(); }); diff --git a/core/modal.css b/core/modal.css index 47c5e122..c3540c61 100644 --- a/core/modal.css +++ b/core/modal.css @@ -1,10 +1,4 @@ -/*body.wrs_modal_open { - overflow: hidden; - position: fixed; -} -*/ .wrs_modal_overlay { - /*overflow: scroll;*/ position: fixed; font-family: arial, sans-serif; top: 0; @@ -15,24 +9,18 @@ z-index: 99998; opacity:0.65; pointer-events: auto; - /*-webkit-transition: opacity 400ms ease-in; - -moz-transition: opacity 400ms ease-in; - transition: opacity 400ms ease-in;*/ } .wrs_modal_overlay.wrs_maximized{ } .wrs_modal_overlay.wrs_minimized { - display: none; } .wrs_modal_overlay.wrs_stack { - display: none; } .wrs_modal_overlay.wrs_modal_ios { - /*position: inherit;*/ } .wrs_modal_overlay.wrs_modal_ios.moodle { @@ -159,7 +147,6 @@ .wrs_modal_title_bar { display : block; background-color: #778e9a; - /*cursor: pointer;*/ } .wrs_modal_dialogContainer { @@ -191,7 +178,6 @@ margin-right: 10px; } .wrs_modal_dialogContainer.wrs_modal_desktop.wrs_minimized.wrs_drag { - /*bottom: auto;*/ } .wrs_modal_dialogContainer.wrs_modal_desktop.wrs_stack { diff --git a/db/install.php b/db/install.php index c13b4d79..58610319 100644 --- a/db/install.php +++ b/db/install.php @@ -23,6 +23,8 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +defined('MOODLE_INTERNAL') || die(); + /** * Enable WIRIS plugin buttons on installation. */ diff --git a/db/uninstall.php b/db/uninstall.php index 408ecdb2..cc95442f 100644 --- a/db/uninstall.php +++ b/db/uninstall.php @@ -23,6 +23,8 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +defined('MOODLE_INTERNAL') || die(); + function xmldb_atto_wiris_uninstall() { // Remove 'wiris' from the toolbar editor_atto config variable. $toolbar = get_config('editor_atto', 'toolbar'); diff --git a/lib.php b/lib.php index 2ebd4679..2f98f091 100644 --- a/lib.php +++ b/lib.php @@ -23,6 +23,8 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +defined('MOODLE_INTERNAL') || die(); + /** * Initialise the js strings required for this module. */ diff --git a/version.php b/version.php index 82e671a4..88f25d49 100644 --- a/version.php +++ b/version.php @@ -25,9 +25,9 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2017030900; -$plugin->release = '4.1.1.1361'; +$plugin->version = 2017040600; +$plugin->release = '4.2.0.1364'; $plugin->requires = 2014050800; $plugin->component = 'atto_wiris'; -$plugin->dependencies = array ('filter_wiris' => 2017030900); +$plugin->dependencies = array ('filter_wiris' => 2017040600); $plugin->maturity = MATURITY_STABLE; diff --git a/wirisplugin-generic.js b/wirisplugin-generic.js index f3d5f992..d8ed60f3 100644 --- a/wirisplugin-generic.js +++ b/wirisplugin-generic.js @@ -47,14 +47,17 @@ var _wrs_int_directionality = ''; // Custom Editors. var _wrs_int_customEditors = {chemistry : {name: 'Chemistry', toolbar : 'chemistry', icon : 'chem.png', enabled : false, confVariable : '_wrs_conf_chemEnabled', title: 'WIRIS EDITOR chemistry'}} -if (navigator.userLanguage) { - _wrs_int_langCode = navigator.userLanguage; -} -else if (navigator.language) { - _wrs_int_langCode = navigator.language.substring(0, 2); -} -else { - _wrs_int_langCode = 'en'; + +if (typeof _wrs_int_langCode == 'undefined') { + if (navigator.userLanguage) { + _wrs_int_langCode = navigator.userLanguage; + } + else if (navigator.language) { + _wrs_int_langCode = navigator.language.substring(0, 2); + } + else { + _wrs_int_langCode = 'en'; + } } // Including core.js. diff --git a/yui/build/moodle-atto_wiris-button/moodle-atto_wiris-button-debug.js b/yui/build/moodle-atto_wiris-button/moodle-atto_wiris-button-debug.js index 4671e89b..f682febb 100644 --- a/yui/build/moodle-atto_wiris-button/moodle-atto_wiris-button-debug.js +++ b/yui/build/moodle-atto_wiris-button/moodle-atto_wiris-button-debug.js @@ -62,7 +62,7 @@ Y.namespace('M.atto_wiris').Button = Y.Base.create('button', Y.M.editor_atto.Edi // Editor popup OK callback. window.wrs_int_updateFormula = function(mathml, editMode) { var editable = window._wrs_int_currentPlugin.get('host').editor.getDOMNode(); - wrs_updateFormula(editable, window, mathml, null, editMode); + wrs_updateFormula(editable, window, mathml, null, editMode, _wrs_int_currentPlugin._lang); window._wrs_int_currentPlugin.markUpdated(); window._wrs_int_currentPlugin._updateEditorImgHandlers(); }; diff --git a/yui/build/moodle-atto_wiris-button/moodle-atto_wiris-button-min.js b/yui/build/moodle-atto_wiris-button/moodle-atto_wiris-button-min.js index 400e6fb9..0c1f3f8b 100644 --- a/yui/build/moodle-atto_wiris-button/moodle-atto_wiris-button-min.js +++ b/yui/build/moodle-atto_wiris-button/moodle-atto_wiris-button-min.js @@ -1 +1 @@ -YUI.add("moodle-atto_wiris-button",function(e,t){e.namespace("M.atto_wiris").Button=e.Base.create("button",e.M.editor_atto.EditorPlugin,[],{_lang:"en",initializer:function(t){this._lang=t.lang,window._wrs_int_langCode=t.lang,window.wrs_int_notifyWindowClosed=function(){window._wrs_int_popup=null,window._wrs_temporalImage=null,window._wrs_isNewElement=!0},window.wrs_int_updateFormula=function(e,t){var n=window._wrs_int_currentPlugin.get("host").editor.getDOMNode();wrs_updateFormula(n,window,e,null,t),window._wrs_int_currentPlugin.markUpdated(),window._wrs_int_currentPlugin._updateEditorImgHandlers()},window.wrs_int_updateCAS=function(e,t,n,r){var i=window._wrs_int_currentPlugin.get("host").editor.getDOMNode();wrs_updateCAS(i,window,e,t,n,r),window._wrs_int_currentPlugin.markUpdated(),window._wrs_int_currentPlugin._updateCasImgHandlers()},window._wrs_int_conf_file=M.cfg.wwwroot+"/filter/wiris/integration/configurationjs.php",window._wrs_int_conf_path=M.cfg.wwwroot+"/lib/editor/atto/plugins/wiris",window._wrs_int_conf_async=!0,window._wrs_int_popup=window._wrs_int_popup||null,window._wrs_int_coreLoading=window._wrs_int_coreLoading||!1,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,window._wrs_isMoodle24=!0,window._wrs_int_customEditors={chemistry:{name:"Chemistry",toolbar:"chemistry",icon:"chem.gif",enabled:!1,confVariable:"_wrs_conf_chemEnabled",title:"WIRIS EDITOR chemistry"}},window._wrs_int_coreLoading||(window._wrs_int_coreLoading=!0,e.Get.js(window._wrs_int_conf_path+"/core/core.js",function(e){e}));var n=this.get("host"),r=this;window._wrs_int_currentPlugin=this,n.on("change",function(){r._unparseContent()}),n._wirisUpdateFromTextArea=n.updateFromTextArea,n.updateFromTextArea=function(){n._wirisUpdateFromTextArea(),r._parseContent()},this._parseContent(),this._addButtons()},_addButtons:function(){if(window._wrs_conf_plugin_loaded){window._wrs_conf_editorEnabled&&this.addButton({title:"wiris_editor_title",buttonName:"wiris_editor",icon:"formula",iconComponent:"atto_wiris",callback:this._editorButton}),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}),window._wrs_conf_CASEnabled&&this.addButton({title:"wiris_cas_title",buttonName:"wiris_cas",icon:"cas",iconComponent:"atto_wiris",callback:this._casButton});var t=this.get("host");t.plugins.collapse&&t.plugins.collapse._setVisibility(t.plugins.collapse.buttons.collapse)}else e.later(50,this,this._addButtons)},_editorButton:function(){if(_wrs_int_popup)_wrs_int_popup.focus();else{var e=this.get("host");_wrs_int_currentPlugin=this,_wrs_int_popup=wrs_openEditorWindow(this._lang,e.editor.getDOMNode(),!1)}},_chemEditorButton:function(){if(_wrs_int_popup)_wrs_int_popup.focus();else{var e=this.get("host");_wrs_int_currentPlugin=this,wrs_int_enableCustomEditor("chemistry"),_wrs_int_popup=wrs_openEditorWindow(this._lang,e.editor.getDOMNode(),!1)}},_casButton:function(){if(_wrs_int_popup)_wrs_int_popup.focus();else{var e=this.get("host");_wrs_int_currentPlugin=this,_wrs_int_popup=wrs_openCASWindow(e.editor.getDOMNode(),!1,this._lang)}},_parseContent:function(){if(window._wrs_conf_plugin_loaded){var t=this.get("host"),n=t.editor.get("innerHTML");n=wrs_initParse(n,this._lang),t.editor.set("innerHTML",n),this.markUpdated(),this._updateCasImgHandlers(),this._updateEditorImgHandlers()}else e.later(50,this,this._parseContent)},_unparseContent:function(){if(window._wrs_conf_plugin_loaded){var t=this.get("host"),n=t.textarea.get("value");n=wrs_endParse(n,null,this._lang),t.textarea.set("value",n)}else e.later(50,this,this._unparseContent)},_handleElementDoubleclick:function(e,t,n){if(t.dataset.mathml){n.stopPropagation(),window._wrs_temporalImage=t,window._wrs_isNewElement=!1;var r=window._wrs_temporalImage.getAttribute("data-custom-editor");typeof r!="undefined"&&r&&window[_wrs_int_customEditors[r].confVariable]&&wrs_int_enableCustomEditor(r),window._wrs_int_currentPlugin._editorButton()}},_handleCasDoubleClick:function(e){window._wrs_temporalImage=e.currentTarget.getDOMNode(),window._wrs_isNewElement=!1,this._casButton(),e.stopPropagation()},_updateEditorImgHandlers:function(){wrs_addElementEvents(this.get("host").editor.getDOMNode(),this._handleElementDoubleclick)},_updateCasImgHandlers:function(){this.editor.all("img.Wiriscas").each(function(e){e.detachAll("dblclick"),e.on("dblclick",this._handleCasDoubleClick,this)},this)}})},"@VERSION@",{requires:["moodle-editor_atto-plugin","get"]}); +YUI.add("moodle-atto_wiris-button",function(e,t){e.namespace("M.atto_wiris").Button=e.Base.create("button",e.M.editor_atto.EditorPlugin,[],{_lang:"en",initializer:function(t){this._lang=t.lang,window._wrs_int_langCode=t.lang,window.wrs_int_notifyWindowClosed=function(){window._wrs_int_popup=null,window._wrs_temporalImage=null,window._wrs_isNewElement=!0},window.wrs_int_updateFormula=function(e,t){var n=window._wrs_int_currentPlugin.get("host").editor.getDOMNode();wrs_updateFormula(n,window,e,null,t,_wrs_int_currentPlugin._lang),window._wrs_int_currentPlugin.markUpdated(),window._wrs_int_currentPlugin._updateEditorImgHandlers()},window.wrs_int_updateCAS=function(e,t,n,r){var i=window._wrs_int_currentPlugin.get("host").editor.getDOMNode();wrs_updateCAS(i,window,e,t,n,r),window._wrs_int_currentPlugin.markUpdated(),window._wrs_int_currentPlugin._updateCasImgHandlers()},window._wrs_int_conf_file=M.cfg.wwwroot+"/filter/wiris/integration/configurationjs.php",window._wrs_int_conf_path=M.cfg.wwwroot+"/lib/editor/atto/plugins/wiris",window._wrs_int_conf_async=!0,window._wrs_int_popup=window._wrs_int_popup||null,window._wrs_int_coreLoading=window._wrs_int_coreLoading||!1,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,window._wrs_isMoodle24=!0,window._wrs_int_customEditors={chemistry:{name:"Chemistry",toolbar:"chemistry",icon:"chem.gif",enabled:!1,confVariable:"_wrs_conf_chemEnabled",title:"WIRIS EDITOR chemistry"}},window._wrs_int_coreLoading||(window._wrs_int_coreLoading=!0,e.Get.js(window._wrs_int_conf_path+"/core/core.js",function(e){e}));var n=this.get("host"),r=this;window._wrs_int_currentPlugin=this,n.on("change",function(){r._unparseContent()}),n._wirisUpdateFromTextArea=n.updateFromTextArea,n.updateFromTextArea=function(){n._wirisUpdateFromTextArea(),r._parseContent()},this._parseContent(),this._addButtons()},_addButtons:function(){if(window._wrs_conf_plugin_loaded){window._wrs_conf_editorEnabled&&this.addButton({title:"wiris_editor_title",buttonName:"wiris_editor",icon:"formula",iconComponent:"atto_wiris",callback:this._editorButton}),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}),window._wrs_conf_CASEnabled&&this.addButton({title:"wiris_cas_title",buttonName:"wiris_cas",icon:"cas",iconComponent:"atto_wiris",callback:this._casButton});var t=this.get("host");t.plugins.collapse&&t.plugins.collapse._setVisibility(t.plugins.collapse.buttons.collapse)}else e.later(50,this,this._addButtons)},_editorButton:function(){if(_wrs_int_popup)_wrs_int_popup.focus();else{var e=this.get("host");_wrs_int_currentPlugin=this,_wrs_int_popup=wrs_openEditorWindow(this._lang,e.editor.getDOMNode(),!1)}},_chemEditorButton:function(){if(_wrs_int_popup)_wrs_int_popup.focus();else{var e=this.get("host");_wrs_int_currentPlugin=this,wrs_int_enableCustomEditor("chemistry"),_wrs_int_popup=wrs_openEditorWindow(this._lang,e.editor.getDOMNode(),!1)}},_casButton:function(){if(_wrs_int_popup)_wrs_int_popup.focus();else{var e=this.get("host");_wrs_int_currentPlugin=this,_wrs_int_popup=wrs_openCASWindow(e.editor.getDOMNode(),!1,this._lang)}},_parseContent:function(){if(window._wrs_conf_plugin_loaded){var t=this.get("host"),n=t.editor.get("innerHTML");n=wrs_initParse(n,this._lang),t.editor.set("innerHTML",n),this.markUpdated(),this._updateCasImgHandlers(),this._updateEditorImgHandlers()}else e.later(50,this,this._parseContent)},_unparseContent:function(){if(window._wrs_conf_plugin_loaded){var t=this.get("host"),n=t.textarea.get("value");n=wrs_endParse(n,null,this._lang),t.textarea.set("value",n)}else e.later(50,this,this._unparseContent)},_handleElementDoubleclick:function(e,t,n){if(t.dataset.mathml){n.stopPropagation(),window._wrs_temporalImage=t,window._wrs_isNewElement=!1;var r=window._wrs_temporalImage.getAttribute("data-custom-editor");typeof r!="undefined"&&r&&window[_wrs_int_customEditors[r].confVariable]&&wrs_int_enableCustomEditor(r),window._wrs_int_currentPlugin._editorButton()}},_handleCasDoubleClick:function(e){window._wrs_temporalImage=e.currentTarget.getDOMNode(),window._wrs_isNewElement=!1,this._casButton(),e.stopPropagation()},_updateEditorImgHandlers:function(){wrs_addElementEvents(this.get("host").editor.getDOMNode(),this._handleElementDoubleclick)},_updateCasImgHandlers:function(){this.editor.all("img.Wiriscas").each(function(e){e.detachAll("dblclick"),e.on("dblclick",this._handleCasDoubleClick,this)},this)}})},"@VERSION@",{requires:["moodle-editor_atto-plugin","get"]}); diff --git a/yui/build/moodle-atto_wiris-button/moodle-atto_wiris-button.js b/yui/build/moodle-atto_wiris-button/moodle-atto_wiris-button.js index d87163d7..5e0563c1 100644 --- a/yui/build/moodle-atto_wiris-button/moodle-atto_wiris-button.js +++ b/yui/build/moodle-atto_wiris-button/moodle-atto_wiris-button.js @@ -62,7 +62,7 @@ Y.namespace('M.atto_wiris').Button = Y.Base.create('button', Y.M.editor_atto.Edi // Editor popup OK callback. window.wrs_int_updateFormula = function(mathml, editMode) { var editable = window._wrs_int_currentPlugin.get('host').editor.getDOMNode(); - wrs_updateFormula(editable, window, mathml, null, editMode); + wrs_updateFormula(editable, window, mathml, null, editMode, _wrs_int_currentPlugin._lang); window._wrs_int_currentPlugin.markUpdated(); window._wrs_int_currentPlugin._updateEditorImgHandlers(); }; diff --git a/yui/src/button/js/button.js b/yui/src/button/js/button.js index 504a5319..a5721f2b 100644 --- a/yui/src/button/js/button.js +++ b/yui/src/button/js/button.js @@ -60,7 +60,7 @@ Y.namespace('M.atto_wiris').Button = Y.Base.create('button', Y.M.editor_atto.Edi // Editor popup OK callback. window.wrs_int_updateFormula = function(mathml, editMode) { var editable = window._wrs_int_currentPlugin.get('host').editor.getDOMNode(); - wrs_updateFormula(editable, window, mathml, null, editMode); + wrs_updateFormula(editable, window, mathml, null, editMode, _wrs_int_currentPlugin._lang); window._wrs_int_currentPlugin.markUpdated(); window._wrs_int_currentPlugin._updateEditorImgHandlers(); };