From 56ebb82d10d066d9f36019ca9a1e555a96755e2f Mon Sep 17 00:00:00 2001 From: Manuel Date: Wed, 1 Mar 2017 11:15:25 +0100 Subject: [PATCH] 4.1.0.1357 Stable version --- VERSION | 2 +- core/core.js | 957 ++++++++++++------ core/editor.css | 73 +- core/editor.js | 45 +- core/icons/general/close_icon.png | Bin 0 -> 524 bytes core/icons/general/fulls_icon.png | Bin 0 -> 442 bytes core/icons/general/max_icon.png | Bin 0 -> 266 bytes core/icons/general/min_icon.png | Bin 0 -> 235 bytes core/icons/general/mins_icon.png | Bin 0 -> 464 bytes core/icons/hover/close_icon_h.png | Bin 0 -> 550 bytes core/icons/hover/fulls_icon_h.png | Bin 0 -> 423 bytes core/icons/hover/max_icon_h.png | Bin 0 -> 267 bytes core/icons/hover/min_icon_h.png | Bin 0 -> 244 bytes core/icons/hover/mins_icon_h.png | Bin 0 -> 462 bytes core/modal.css | 231 ++++- settings.php | 2 + version.php | 6 +- wirisplugin-generic.js | 24 +- .../moodle-atto_wiris-button-debug.js | 4 +- .../moodle-atto_wiris-button-min.js | 2 +- .../moodle-atto_wiris-button.js | 4 +- yui/src/button/js/button.js | 4 +- 22 files changed, 964 insertions(+), 390 deletions(-) create mode 100644 core/icons/general/close_icon.png create mode 100644 core/icons/general/fulls_icon.png create mode 100644 core/icons/general/max_icon.png create mode 100644 core/icons/general/min_icon.png create mode 100644 core/icons/general/mins_icon.png create mode 100644 core/icons/hover/close_icon_h.png create mode 100644 core/icons/hover/fulls_icon_h.png create mode 100644 core/icons/hover/max_icon_h.png create mode 100644 core/icons/hover/min_icon_h.png create mode 100644 core/icons/hover/mins_icon_h.png diff --git a/VERSION b/VERSION index 5baf4c83..88b68c3d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.64.0.1325 +4.1.0.1357 diff --git a/core/core.js b/core/core.js index 13a4f5e1..8118910d 100644 --- a/core/core.js +++ b/core/core.js @@ -29,18 +29,13 @@ var _wrs_temporalImage; var _wrs_temporalFocusElement; var _wrs_androidRange; var _wrs_iosRange; -// We need to keep the main window height scroll value to restore it -// when we close a modalwindow. -var _wrs_mainwindow_scroll; -// We need a variable to send device properties to editor.js on modal mode. -var _wrs_deviceProperties = {} -// Dragable options. -var _wrs_dragDataObject; -var _wrs_dragObject; // LaTex client cache. var _wrs_int_LatexCache = {}; +// Accessible client cache +var _wrs_int_AccessibleCache = {}; + var _wrs_xmlCharacters = { 'tagOpener': '<', // Hex: \x3C. 'tagCloser': '>', // Hex: \x3E. @@ -109,6 +104,12 @@ if (typeof MutationObserver != 'undefined') { // can be setted by the user using wrs_addPluginListener. var wrs_pluginListeners = []; +var _wrs_css_loaded = false; + +var _wrs_modalWindowProperties = typeof _wrs_modalWindowProperties != 'undefined' ? _wrs_modalWindowProperties : {}; +var _wrs_editor = typeof _wrs_editor != 'undefined' ? _wrs_editor : null; +var _wrs_modalWindow = typeof _wrs_modalWindow != 'undefined' ? _wrs_modalWindow : null; + /** * Adds element events. * @param {object} target Target @@ -239,6 +240,18 @@ function wrs_arrayContains(stack, element) { return -1; } +/** + * Adds a specific className to given element + * @param {object} element + * @param {string} className + * @ignore + */ +function wrs_addClass(element, className) { + if (!wrs_containsClass(element, className)) { + element.className += " " + className; + } +} + /** * Checks if an element contains a class. * @param {object} element @@ -247,7 +260,7 @@ function wrs_arrayContains(stack, element) { * @ignore */ function wrs_containsClass(element, className) { - if (!('className' in element)){ + if (!('className' in element)) { return false; } @@ -262,6 +275,24 @@ function wrs_containsClass(element, className) { return false; } +/** + * Remove a specific class + * @param {object} element + * @param {string} className + * @ignore + */ +function wrs_removeClass(element, className) { + var newClassName = ''; + var classes = element.className.split(" "); + + for (var i = 0; i < classes.length; i++) { + if(classes[i] != className) { + newClassName += classes[i] + " "; + } + } + element.className = newClassName.trim(); +} + /** * Converts old xmlinitialtext attribute (with «») to the correct one(with §lt;§gt;) * @param {string} text String containtg safeXml characters @@ -428,6 +459,7 @@ function wrs_createShowImageSrc(mathml, data, language) { } dataObject.formula = com.wiris.js.JsPluginTools.md5encode(wrs_propertiesToString(dataMd5)); dataObject.lang = (typeof language == 'undefined') ? 'en' : language; + dataObject.version = _wrs_conf_version; var result = wrs_getContent(_wrs_conf_showimagePath + '?' + wrs_httpBuildQuery(dataObject)); return result; @@ -1675,10 +1707,10 @@ 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); + // 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; } @@ -1785,9 +1817,18 @@ function wrs_fixedCharCodeAt(str, idx) { * @ignore */ function wrs_mathmlToAccessible(mathml, language, data) { - data['service'] = 'mathml2accessible'; + var accessibleText; + + if (_wrs_int_AccessibleCache.hasOwnProperty(mathml)) { + accessibleText = _wrs_int_AccessibleCache[mathml]; + } + else { + data['service'] = 'mathml2accessible'; + var accessibleText = wrs_getContent(_wrs_conf_servicePath, data); + } + + return accessibleText; - return wrs_getContent(_wrs_conf_servicePath, data); } /** @@ -1925,22 +1966,38 @@ function wrs_mathmlToImgObject(creator, mathml, wirisProperties, language) { // Experimental settings. if (_wrs_conf_wirisPluginPerformance && (_wrs_conf_saveMode == 'xml' || _wrs_conf_saveMode == 'safeXml')) { + // Internet Explorer 6-11 + // http://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser + var isIE = /*@cc_on!@*/false || !!document.documentMode; + if (isIE) { + data['useragent'] = 'IE'; + _wrs_conf_imageFormat = 'png'; + } + else { + data['useragent'] = 'other browser'; + _wrs_conf_imageFormat = 'svg'; + } + var result = JSON.parse(wrs_createShowImageSrc(mathml, data, language)); if (result["status"] == 'warning') { // POST call. result = JSON.parse(wrs_getContent(_wrs_conf_showimagePath, data)); } result = result.result; - imgObject.src = result['format'] == 'svg' ? 'data:image/svg+xml;base64,' : 'data:image/png;base64,'; - imgObject.src = imgObject.src + result["base64"]; + if (result['format'] == 'png') { + imgObject.src = 'data:image/png;base64,' + result['content']; + } else { + imgObject.src = 'data:image/svg+xml;charset=utf8,' + wrs_urlencode(result['content']); + } imgObject.setAttribute(_wrs_conf_imageMathmlAttribute, wrs_mathmlEncode(mathml)); if (_wrs_conf_setSize) { - wrs_setImgSize(imgObject,result, true); + wrs_setImgSize(imgObject, result['content'], true); } if (window._wrs_conf_enableAccessibility && _wrs_conf_enableAccessibility) { if (typeof result.alt == 'undefined') { imgObject.alt = wrs_mathmlToAccessible(mathml, language, data); + wrs_populateAccessibleCache(mathml, imgObject.alt); } else { imgObject.alt = result.alt; @@ -1963,6 +2020,7 @@ function wrs_mathmlToImgObject(creator, mathml, wirisProperties, language) { } if (window._wrs_conf_enableAccessibility && _wrs_conf_enableAccessibility) { imgObject.alt = wrs_mathmlToAccessible(mathml, language, data); + wrs_populateAccessibleCache(mathml, imgObject.alt); } } /* if (_wrs_conf_setSize) { @@ -2055,7 +2113,7 @@ function wrs_openEditorWindow(language, target, isIframe) { } // Avoid double slashes. - var path = _wrs_conf_path.lastIndexOf('/') == _wrs_conf_path.length - 1 ? _wrs_conf_path + "core/editor.html" : _wrs_conf_path + "/core/editor.html"; + var path = _wrs_conf_path.lastIndexOf('/') == _wrs_conf_path.length - 1 ? _wrs_conf_path + "core/editor.html" : _wrs_conf_path + "/core/editor.html"; if (language) { path = wrs_addArgument(path, "lang", language); @@ -2130,35 +2188,25 @@ function wrs_openEditorWindow(language, target, isIframe) { } } + var title = wrs_int_getCustomEditorEnabled() != null ? wrs_int_getCustomEditorEnabled().title : 'WIRIS EDITOR math'; if (!_wrs_conf_modalWindow) { - _wrs_popupWindow = window.open(path, 'WIRISeditor', _wrs_conf_editorAttributes); + _wrs_popupWindow = window.open(path, title, _wrs_conf_editorAttributes); return _wrs_popupWindow; } else { - var deviceWidth = window.outerWidth; - var deviceHeight = window.outerHeight; - - var landscape = deviceWidth > deviceHeight; - var portrait = deviceWidth < deviceHeight; - - var iframeAttributes = {}; - iframeAttributes['width'] = _wrs_conf_editorAttributes.split(' ').join('').split(',')[0].split("=")[1]; - iframeAttributes['height'] = _wrs_conf_editorAttributes.split(' ').join('').split(',')[1].split("=")[1]; - iframeAttributes['src'] = path; - - var isMobile = (landscape && iframeAttributes['height'] > deviceHeight) || (portrait && iframeAttributes['width'] > deviceWidth) ? true : false; - - // Device object properties. - _wrs_deviceProperties['orientation'] = landscape ? 'landscape' : 'portait'; - _wrs_deviceProperties['isAndroid'] = isAndroid ? true : false; - _wrs_deviceProperties['isIOS'] = isIOS ? true : false; - _wrs_deviceProperties['isMobile'] = isMobile; - - // Modal properties. - var _wrs_modalProperties = { - draggable : true - }; - wrs_createModalWindow('WIRIS editor', iframeAttributes, _wrs_deviceProperties, _wrs_modalProperties); + if (_wrs_modalWindow == null) { + _wrs_modalWindow = new ModalWindow(path, _wrs_conf_editorAttributes); + } + if (!_wrs_css_loaded) { + 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'); + document.getElementsByTagName("head")[0].appendChild(fileref); + _wrs_css_loaded = true; + } + _wrs_modalWindow.setTitle(title); + _wrs_modalWindow.open(); } } @@ -2308,7 +2356,7 @@ function wrs_parseSafeAppletsToObjects(content) { */ function wrs_removeEvent(element, event, func) { if (element.removeEventListener) { - element.removeEventListener(event, func, false); + element.removeEventListener(event, func, true); } else if (element.detachEvent) { element.detachEvent('on' + event, func); @@ -2538,14 +2586,14 @@ function wrs_urlToAssArray(url) { } } -function wrs_setImgSize(img, url, base64) { +function wrs_setImgSize(img, url, json) { - if (base64) { + if (json) { // Cleaning data:image/png;base64. - var base64String = img.src.substr( img.src.indexOf('base64,') + 7, img.src.length); if (_wrs_conf_imageFormat == 'svg') { - var ar = getMetricsFromSvgString(atob(base64String)); + var ar = getMetricsFromSvgString(url); } else { + var base64String = img.src.substr( img.src.indexOf('base64,') + 7, img.src.length); bytes = wrs_b64ToByteArray(base64String, 88); var ar = wrs_getMetricsFromBytes(bytes); } @@ -2574,8 +2622,16 @@ function wrs_fixAfterResize(img) { img.removeAttribute('width'); img.removeAttribute('height'); if (_wrs_conf_setSize) { - if (img.src.indexOf("base64") != -1) { - wrs_setImgSize(img,'', true); + if (img.src.indexOf("data:image") != -1) { + if (_wrs_conf_imageFormat == 'svg') { + // 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 + var base64 = img.src.substring(22,img.src.length); + wrs_setImgSize(img, base64, true); + } } else { wrs_setImgSize(img,img.src); } @@ -2612,6 +2668,7 @@ function wrs_loadConfiguration() { // 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. } @@ -2636,201 +2693,28 @@ if (typeof _wrs_conf_configuration_loaded == 'undefined') { * @ignore */ -function wrs_createModalWindow(title, iframeParams, deviceProperties, modalProperties) { - // Keep the scroll to restore when the modal window is closed. - _wrs_mainwindow_scroll = window.scrollY; +function wrs_createModalWindow() { // Adding css stylesheet. - 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'); - - document.getElementsByTagName("head")[0].appendChild(fileref); - - var attributes = {}; - - attributes['class'] = 'wrs_modal_overlay'; - var modalDiv = wrs_createElement('div', attributes); - - attributes['class'] = 'wrs_modal_title_bar'; - var barModalDiv = wrs_createElement('div', attributes); - - attributes = {}; - attributes['class'] = 'wrs_modal_title'; - var titleModalDiv = wrs_createElement('div', attributes); - titleModalDiv.innerHTML = title; - - attributes = {}; - attributes['class'] = 'wrs_modal_close_button' - var closeDiv = wrs_createElement('div', attributes); - closeDiv.innerHTML = "X"; - - attributes = {}; - attributes['class'] = 'wrs_modal_dialogContainer'; - var containerDiv = wrs_createElement('div', attributes); - containerDiv.style.overflow = 'hidden'; - - attributes = {}; - attributes['class'] = 'wrs_modal_iframe'; - attributes['src'] = iframeParams['src']; - attributes['frameBorder'] = "0"; - - var iframe = wrs_createElement('iframe', attributes); - - barModalDiv.appendChild(closeDiv); - barModalDiv.appendChild(titleModalDiv); - modalDiv.appendChild(containerDiv); - - if (!deviceProperties['isMobile']) { - containerDiv.appendChild(barModalDiv); + if (!_wrs_css_loaded) { + 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'); + document.getElementsByTagName("head")[0].appendChild(fileref); + _wrs_css_loaded = true; } - containerDiv.appendChild(iframe); - - document.body.className = !(document.body.className) ? "wrs_modal_open" : document.body.className + " wrs_modal_open"; - - if (!deviceProperties['isMobile'] && !deviceProperties['isIOS'] && !deviceProperties['isAndroid']) { // Desktop. - wrs_createModalWindowDesktop(modalDiv, containerDiv, iframe, iframeParams); - } - else if (deviceProperties['isAndroid'] && !deviceProperties['isMobile']) { - wrs_createModalWindowAndroid(modalDiv, containerDiv, iframe, iframeParams); - } - else if (deviceProperties['isIOS'] && !deviceProperties['isMobile']) { - wrs_createModalWindowIos(modalDiv, containerDiv, iframe, iframeParams); - } - else if (deviceProperties['isMobile']) { - if (!wrs_isBadStockAndroid()) { - wrs_createModalWindowMobile(modalDiv, containerDiv, iframe, iframeParams); - } else { - wrs_createModalWindowBadStockAndroid(modalDiv, containerDiv, iframe, iframeParams); - } - } - - document.body.appendChild(modalDiv); - if (modalProperties.draggable) { - wrs_addModalListeners(); - } - - wrs_addEvent(closeDiv, 'click', function() { - wrs_closeModalWindow(); - }); - _wrs_popupWindow = iframe.contentWindow; + _wrs_modalWindow.open(); } /** - * Makes an object draggable adding mouse and touch events. - * - * @param {object} draggable object (for example modal dialog). - * @param {target} target to add the events (for example de titlebar of a modal dialog) - * @ignore + * Closes modal window */ -function wrs_addModalListeners(object, target) { - _wrs_dragObject = document.getElementsByClassName('wrs_modal_dialogContainer')[0]; - - // Mouse events. - wrs_addEvent(document.body, 'mousedown', wrs_startDrag); - wrs_addEvent(window, 'mouseup', wrs_stopDrag); - wrs_addEvent(document, 'mouseup', wrs_stopDrag); - wrs_addEvent(document.getElementsByClassName("wrs_modal_iframe")[0], 'mouseup', wrs_stopDrag); - wrs_addEvent(document.body, 'mousemove', wrs_drag); - - // Touch Events. - // Don't add touch events on modal window for mobile. - if (typeof(document.getElementsByClassName('wrs_modal_title')[0]) != 'undefined') { - wrs_addEvent(document.getElementsByClassName('wrs_modal_title')[0], 'touchstart', wrs_startDrag); - wrs_addEvent(document.body, 'touchmove', wrs_drag); - wrs_addEvent(window, 'touchend', wrs_stopDrag); - } -} - -/** - * Returns mouse or touch coordinates (on touch events ev.ClientX doesn't exists) - * @param {event} ev mnouse or touch event - * @return {object} with the X and Y coordinates. - * @ignore - */ -function wrs_eventClient(ev) { - if (typeof(ev.clientX) == 'undefined') { - var client = { - X : ev.changedTouches[0].clientX, - Y : ev.changedTouches[0].clientY - }; - return client; - } else { - client = { - X : ev.clientX, - Y : ev.clientY - }; - return client; - } -} - -/** - * Start drag function: set the object _wrs_dragDataObject with the draggable object offsets coordinates. - * when drag starts (on touchstart or mousedown events). - * - * @param {event} ev touchstart or mousedown event. - * @ignore - */ -function wrs_startDrag(ev) { - if (ev.target.className == 'wrs_modal_title') { - if(!_wrs_dragDataObject) { - ev = ev || event; - _wrs_dragDataObject = { - x: wrs_eventClient(ev).X - (isNaN(parseInt(window.getComputedStyle(_wrs_dragObject)).left && parseInt(window.getComputedStyle(_wrs_dragObject).left > 0 )) ? _wrs_dragObject.offsetLeft : parseInt(window.getComputedStyle(_wrs_dragObject).left)), - y: wrs_eventClient(ev).Y - (isNaN(parseInt(window.getComputedStyle(_wrs_dragObject).top)) ? _wrs_dragObject.offsetTop : parseInt(window.getComputedStyle(_wrs_dragObject).top)) - }; - }; - } -} - -/** - * Updates_wrs_dragDataObject with the draggable object coordinates when the draggable object is being moved. - * - * @param {event} ev touchmouve or mousemove events. - * @ignore - */ -function wrs_drag(ev) { - if(_wrs_dragDataObject) { - ev.preventDefault(); - ev = ev || event; - _wrs_dragObject.style.left = wrs_eventClient(ev).X - _wrs_dragDataObject.x + "px"; - _wrs_dragObject.style.top = wrs_eventClient(ev).Y - _wrs_dragDataObject.y + "px"; - _wrs_dragObject.style.position = 'absolute'; - } -} - -/** - * Set the _wrs_dragDataObject to null when the drag finish (touchend or mouseup events). - * - * @param {event} ev touchend or mouseup event. - * @ignore - */ -function wrs_stopDrag(ev) { - _wrs_dragDataObject = null; -} - -/** - * Create modal dialog for desktop OS. - * @param {modalDiv} modal overlay div. - * @param {containerDiv} modal window div. - * @param {iframe} embedded iframe. - * @param {iframeParams} embedded iframe params (height, width). - * @ignore - */ - -function wrs_createModalWindowDesktop(modalDiv, containerDiv, iframe, iframeParams) { - modalDiv.className = modalDiv.className + " wrs_modal_desktop"; - containerDiv.className = containerDiv.className + " wrs_modal_desktop"; - iframe.className = iframe.className + " wrs_modal_android" - var modalHeight = parseInt(iframeParams['height']) + 30; - var modalWidth = parseInt(iframeParams['width']) + 10; - - containerDiv.style.width = modalWidth + 'px'; - containerDiv.style.height = modalHeight + 'px'; - iframe.style.width = iframeParams['width'] + 'px'; - iframe.style.height = iframeParams['height'] + 'px'; - iframe.style.margin = '6px'; +function wrs_closeModalWindow() { + wrs_int_disableCustomEditors(); + wrs_int_notifyWindowClosed(); + _wrs_editMode = (window._wrs_conf_defaultEditMode) ? _wrs_conf_defaultEditMode : 'images'; + _wrs_modalWindow.close(); } /** @@ -2842,51 +2726,12 @@ function wrs_createModalWindowDesktop(modalDiv, containerDiv, iframe, iframePara * @ignore */ -function wrs_createModalWindowAndroid(modalDiv, containerDiv, iframe, iframeParams) { - modalDiv.className = modalDiv.className + " wrs_modal_android"; - containerDiv.className = containerDiv.className + " wrs_modal_android"; - iframe.className = iframe.className + " wrs_modal_android"; - - // Android portrait. - if (window.outerWidth < window.outerHeight) { - - var modalHeight = parseInt(iframeParams['height']) + 30; - var modalWidth = parseInt(iframeParams['width']) + 10; - - containerDiv.style.width = modalWidth + 'px'; - containerDiv.style.height = modalHeight + 'px'; - - iframe.style.width = iframeParams['width'] + 'px'; - iframe.style.height = iframeParams['height'] + 'px'; - } - - else { - var modalHeight = parseInt(iframeParams['height']) + 30; - var modalWidth = parseInt(iframeParams['width']) + 10; - - containerDiv.style.width = modalWidth + 'px'; - containerDiv.style.height = modalHeight + 'px'; - - iframe.style.width = iframeParams['width'] + 'px'; - iframe.style.height = iframeParams['height'] + 'px'; - iframe.style.margin = '6px'; - } - - if (window.outerWidth < window.outerHeight) { - var portraitZoom = (window.outerWidth / modalWidth).toFixed(2); - wrs_addMetaViewport("device-width", portraitZoom, portraitZoom, portraitZoom); - } else { - wrs_addMetaViewport("device-width", 1.0, 1.0, 1.0); - } - - window.addEventListener('orientationchange', function() { - if (window.outerWidth > window.outerHeight) { // Portrait --> landscape. - wrs_addMetaViewport("device-width", 1.0, 1.0, 1.0); - } else { // Landscape --> portrait. - var portraitZoom = (window.outerWidth / modalWidth).toFixed(2); - wrs_addMetaViewport("device-width", portraitZoom, portraitZoom, portraitZoom); - } - }); +function wrs_createModalWindowAndroid() { + _wrs_modalWindowProperties.device = 'android'; + wrs_addClass(_wrs_modalWindow.iframeContainer, 'wrs_modal_android'); + _wrs_modalWindow.overlayDiv.className = _wrs_modalWindow.overlayDiv.className + " wrs_modal_android"; + _wrs_modalWindow.containerDiv.className = _wrs_modalWindow.containerDiv.className + " wrs_modal_android"; + _wrs_modalWindow.iframe.className = _wrs_modalWindow.iframe.className + " wrs_modal_android"; } /** @@ -2897,26 +2742,15 @@ function wrs_createModalWindowAndroid(modalDiv, containerDiv, iframe, iframePara * @param {iframeParams} embedded iframe params (height, width). * @ignore */ - -function wrs_createModalWindowIos(modalDiv, containerDiv, iframe, iframeParams) { - modalDiv.className = modalDiv.className + " wrs_modal_ios"; +function wrs_createModalWindowIos() { + wrs_addClass(iframeContainer, 'wrs_modal_ios'); + _wrs_modalWindow.overlayDiv.className = _wrs_modalWindow.overlayDiv.className + " wrs_modal_ios"; if (typeof _wrs_isMoodle24 != 'undefined') { - modalDiv.className = modalDiv.className + " moodle"; + _wrs_modalWindow.overlayDiv.className = _wrs_modalWindow.overlayDiv.className + " moodle"; } - containerDiv.className = containerDiv.className + " wrs_modal_ios"; - iframe.className = iframe.className + " wrs_modal_ios"; - - wrs_addMetaViewport("device-width", 1.0, 1.0, 1.0); - - var modalHeight = parseInt(iframeParams['height']) + 30; - var modalWidth = parseInt(iframeParams['width']) + 10; - - containerDiv.style.width = modalWidth + 'px'; - containerDiv.style.height = modalHeight + 'px'; - - iframe.style.width = iframeParams['width'] + 'px'; - iframe.style.height = iframeParams['height'] + 'px'; + _wrs_modalWindow.containerDiv.className = _wrs_modalWindow.containerDiv.className + " wrs_modal_ios"; + _wrs_modalWindow.iframe.className = _wrs_modalWindow.iframe.className + " wrs_modal_ios"; } /** @@ -2929,11 +2763,12 @@ function wrs_createModalWindowIos(modalDiv, containerDiv, iframe, iframeParams) * @ignore */ -function wrs_createModalWindowMobile(modalDiv, containerDiv, iframe, iframeParams) { +function wrs_createModalWindowMobile(modalDiv, containerDiv, iframe, iframeParams, iframeContainer) { - modalDiv.className = modalDiv.className + " wrs_modal_mobile"; - containerDiv.className = containerDiv.className + " wrs_modal_mobile"; - iframe.className = iframe.className + " wrs_modal_mobile"; + wrs_addClass(_wrs_modalWindow.iframeContainer, 'wrs_modal_mobile'); + _wrs_modalWindow.overlayDiv.className = _wrs_modalWindow.overlayDiv.className + " wrs_modal_mobile"; + _wrs_modalWindow.containerDiv.className = _wrs_modalWindow.containerDiv.className + " wrs_modal_mobile"; + _wrs_modalWindow.iframe.className = _wrs_modalWindow.iframe.className + " wrs_modal_mobile"; wrs_addMetaViewport("device-width", 1.0, 1.0, 1.0); @@ -2954,24 +2789,24 @@ function wrs_createModalWindowMobile(modalDiv, containerDiv, iframe, iframeParam * @ignore */ function wrs_createModalWindowBadStockAndroid(modalDiv, containerDiv, iframe, iframeParams) { - modalDiv.className = modalDiv.className + " wrs_modal_badStock"; - containerDiv.className = containerDiv.className + " wrs_modal_badStock"; - iframe.className = iframe.className + " wrs_modal_badStock"; + _wrs_modalWindow.overlayDiv.className = _wrs_modalWindow.overlayDiv.className + " wrs_modal_badStock"; + _wrs_modalWindow.containerDiv.className = _wrs_modalWindow.containerDiv.className + " wrs_modal_badStock"; + _wrs_modalWindow.iframe.className = _wrs_modalWindow.iframe.className + " wrs_modal_badStock"; - if (window.outerWidth < parseInt(iframeParams['width'])) { - var modalWidth = parseInt(iframeParams['width']) + 10; - containerDiv.style.width = iframeParams['width'] + 'px'; - iframe.style.width = iframeParams['width'] + 'px'; + if (window.outerWidth < parseInt(_wrs_modalWindowProperties.iframeAttributes['width'])) { + var modalWidth = parseInt(_wrs_modalWindowProperties.iframeAttributes['width']) + 10; + _wrs_modalWindow.containerDiv.style.width = _wrs_modalWindowProperties.iframeAttributes['width'] + 'px'; + _wrs_modalWindow.iframe.style.width = _wrs_modalWindowProperties.iframeAttributes['width'] + 'px'; } window.addEventListener('orientationchange', function() { - if (window.outerWidth > parseInt(iframeParams['width']) + 10) { - var modalWidth = parseInt(iframeParams['width']) + 10; - containerDiv.style.width = modalWidth + 'px'; - iframe.style.width = iframeParams['width'] + 'px'; + if (window.outerWidth > parseInt(_wrs_modalWindowProperties.iframeAttributes['width']) + 10) { + var modalWidth = parseInt(_wrs_modalWindowProperties.iframeAttributes['width']) + 10; + _wrs_modalWindow.containerDiv.style.width = modalWidth + 'px'; + _wrs_modalWindow.iframe.style.width = _wrs_modalWindowProperties.iframeAttributes['width'] + 'px'; } else { - containerDiv.style.width = null; - iframe.style.width = null; + _wrs_modalWindow.containerDiv.style.width = null; + _wrs_modalWindow.iframe.style.width = null; } }); @@ -3000,22 +2835,6 @@ function wrs_addMetaViewport(width, initialScale, minimumScale, maximumScale) { } } -/** - * Closes modal window and restores viewport header. - * @ignore - */ -function wrs_closeModalWindow() { - if (document.querySelector('meta[name=viewport]')) { - document.querySelector('meta[name=viewport]').content = ""; - } - - // Due to this line, the scroll is set to 0 on the main window, so that we need to restore it with the previous value. - document.body.className = document.body.className != 'wrs_modal_open' ? document.body.className.replace(' wrs_modal_open', '') : document.body.className = ""; - window.scrollTo(0, _wrs_mainwindow_scroll); - - var modalDiv = document.getElementsByClassName('wrs_modal_overlay')[0]; - closeFunction = document.body.removeChild(modalDiv); -} /** * Android stock browser test @@ -3059,6 +2878,19 @@ function wrs_populateLatexCache(latex, mathml) { } } +/** + * Puts into _wrs_int_AccessibleCache global variable dictionary the pair mathml=>accessibleText. + * + * @param {string} mathml MatML text. + * @param {string} accessibleText Image accessible text + * @ignore + */ +function wrs_populateAccessibleCache(mathml, accessibleText) { + if (!_wrs_int_AccessibleCache.hasOwnProperty(mathml)) { + _wrs_int_AccessibleCache[mathml] = accessibleText; + } +} + /** * Add annotation tag to mathml without it (mathml comes from LaTeX string) * @param {string} mathml MathML code generated by a LaTeX string. @@ -4149,3 +3981,460 @@ if(typeof window != "undefined") { com.wiris.js.JsPluginTools.main(); delete Array.prototype.__class__; }()); // @codingStandardsIgnoreEnd +/** + * Modal window constructor + * @param {string} path Iframe src + * @param {string} title Modal window title + * @param {Object} editorAttributes Editor attributes (width, height)... + * @ignore + */ +function ModalWindow(path, editorAttributes) { + + var ua = navigator.userAgent.toLowerCase(); + var isAndroid = ua.indexOf("android") > -1; + var isIOS = ((ua.indexOf("ipad") > -1) || (ua.indexOf("iphone") > -1)); + + var deviceWidth = window.outerWidth; + var deviceHeight = window.outerHeight; + + var landscape = deviceWidth > deviceHeight; + var portrait = deviceWidth < deviceHeight; + + var iframeAttributes = {}; + iframeAttributes['width'] = editorAttributes.split(' ').join('').split(',')[0].split("=")[1]; + iframeAttributes['height'] = editorAttributes.split(' ').join('').split(',')[1].split("=")[1]; + iframeAttributes['src'] = path; + + var isMobile = (landscape && iframeAttributes['height'] > deviceHeight) || (portrait && iframeAttributes['width'] > deviceWidth) ? true : false; + + // Device object properties. + + var deviceProperties = {}; + deviceProperties['orientation'] = landscape ? 'landscape' : 'portait'; + deviceProperties['isAndroid'] = isAndroid ? true : false; + deviceProperties['isIOS'] = isIOS ? true : false; + deviceProperties['isMobile'] = isMobile; + + this.deviceProperties = deviceProperties; + this.properties = { + created : false, + state : '', + previousState : '', + deviceProperties: deviceProperties + } + + this.properties.iframeAttributes = iframeAttributes; + + this.title = ''; + + var attributes = {}; + + attributes['class'] = 'wrs_modal_overlay'; + var modalOverlayDiv = wrs_createElement('div', attributes); + this.overlayDiv = modalOverlayDiv; + + attributes['class'] = 'wrs_modal_title_bar'; + var barModalDiv = wrs_createElement('div', attributes); + this.titleBardDiv = barModalDiv; + + attributes = {}; + attributes['class'] = 'wrs_modal_title'; + var titleModalDiv = wrs_createElement('div', attributes); + titleModalDiv.innerHTML = this.title; + this.titleDiv = titleModalDiv; + + attributes = {}; + attributes['class'] = 'wrs_modal_close_button'; + var closeModalDiv = wrs_createElement('div', attributes); + // closeModalDiv.innerHTML = '×'; + this.closeDiv = closeModalDiv; + + attributes = {}; + attributes['class'] = 'wrs_modal_stack_button'; + var stackModalDiv = wrs_createElement('div', attributes); + // stackModalDiv.innerHTML = '/'; + this.stackDiv = stackModalDiv; + + attribyutes = {}; + attributes['class'] = 'wrs_modal_minimize_button'; + var minimizeModalDiv = wrs_createElement('div', attributes); + // minimizeModalDiv.innerHTML = "_"; + this.minimizeDiv = minimizeModalDiv; + + attributes = {}; + attributes['class'] = 'wrs_modal_dialogContainer'; + var containerDiv = wrs_createElement('div', attributes); + containerDiv.style.overflow = 'hidden'; + this.containerDiv = containerDiv; + + attributes = {}; + attributes['class'] = 'wrs_modal_iframe'; + attributes['src'] = iframeAttributes['src']; + attributes['frameBorder'] = "0"; + var iframeModal = wrs_createElement('iframe', attributes); + this.iframe = iframeModal; + + attributes = {}; + attributes['class'] = 'wrs_modal_iframeContainer'; + var iframeModalContainer = wrs_createElement('div', attributes); + this.iframeContainer = iframeModalContainer; + + this.editor = null; + +} + +ModalWindow.prototype.create = function() { + this.titleBardDiv.appendChild(this.closeDiv); + this.titleBardDiv.appendChild(this.stackDiv); + this.titleBardDiv.appendChild(this.minimizeDiv); + this.titleBardDiv.appendChild(this.titleDiv); + this.iframeContainer.appendChild(this.iframe); + + if (!this.deviceProperties['isMobile'] && !this.deviceProperties['isAndroid'] && !this.deviceProperties['isIOS']) { + this.containerDiv.appendChild(this.titleBardDiv); + } + this.containerDiv.appendChild(this.iframeContainer); + + document.body.appendChild(this.containerDiv); + document.body.appendChild(this.overlayDiv); + + wrs_addEvent(this.closeDiv, 'click', this.close.bind(this)); + + if (!this.deviceProperties['isMobile'] && !this.deviceProperties['isIOS'] && !this.deviceProperties['isAndroid']) { // Desktop. + this.stackDiv.addEventListener('click', this.stackModalWindow.bind(this), true); + this.minimizeDiv.addEventListener('click', this.minimizeModalWindow.bind(this), true); + this.createModalWindowDesktop(); + } + else if (this.deviceProperties['isAndroid']) { + this.createModalWindowAndroid(); + } + else if (this.deviceProperties['isIOS'] && !this.deviceProperties['isMobile']) { + this.createModalWindowIos(); + } + this.addListeners(); + _wrs_popupWindow = this.iframe.contentWindow; + this.properties.open = true; + this.properties.created = true; +} + +ModalWindow.prototype.open = function() { + if (this.properties.open == true) { + this.iframe.contentWindow._wrs_modalWindowProperties.editor.setMathML(wrs_mathmlDecode(_wrs_temporalImage.getAttribute('data-mathml'))); + } else if (this.properties.created) { + + this.containerDiv.style.visibility = ''; + this.overlayDiv.style.visibility = ''; + this.containerDiv.style.display = ''; + this.overlayDiv.style.display = ''; + + var editor = this.iframe.contentWindow._wrs_modalWindowProperties.editor; + + this.properties.open = true; + if (customEditor = wrs_int_getCustomEditorEnabled()) { + toolbar = customEditor.toolbar ? customEditor.toolbar : wrs_attributes['toolbar']; + if (typeof editor.params.toolbar == 'undefined' || editor.params.toolbar != toolbar) { + editor.setParams({'toolbar' : toolbar}); + } + } else { + if (typeof editor.params.toolbar != 'undefined' && editor.params.toolbar != 'general') { + var properties = {'toolbar' : 'general'}; + // Client properties. + properties = typeof _wrs_int_wirisProperties != 'undefined' ? _wrs_int_wirisProperties : properties; + // Server side properties. + properties = typeof _wrs_conf_editorAttributes != 'undefined' ? _wrs_conf_editorAttributes : properties; + editor.setParams(properties); + } + + } + + if (_wrs_isNewElement) { + if (this.properties.deviceProperties.isAndroid || this.properties.deviceProperties.isIOS) { + editor.setMathML('[]"'); + } else { + editor.setMathML(''); + } + } else { + editor.setMathML(wrs_mathmlDecode(_wrs_temporalImage.getAttribute('data-mathml'))); + } + + editor.focus(); + if (!this.properties.deviceProperties.isAndroid && !this.properties.deviceProperties.isIOS) { + this.stackModalWindow(); + } + } else { + this.create(); + } +} + +/** + * Closes modal window and restores viewport header. + * @ignore + */ +ModalWindow.prototype.close = function() { + 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(''); + // Properties to initial state + this.properties.state = ''; + this.properties.previousState = ''; +} + +ModalWindow.prototype.addClass = function(cls) { + wrs_addClass(this.overlayDiv, cls); + wrs_addClass(this.titleBardDiv, cls); + wrs_addClass(this.overlayDiv, cls); + wrs_addClass(this.containerDiv, cls); + wrs_addClass(this.iframeContainer, cls); + wrs_addClass(this.iframe, cls); + wrs_addClass(this.stackDiv, cls); + wrs_addClass(this.minimizeDiv, cls); +} + +ModalWindow.prototype.removeClass = function(cls) { + wrs_removeClass(this.overlayDiv, cls); + wrs_removeClass(this.titleBardDiv, cls); + wrs_removeClass(this.overlayDiv, cls); + wrs_removeClass(this.containerDiv, cls); + wrs_removeClass(this.iframeContainer, cls); + wrs_removeClass(this.iframe, cls); + wrs_removeClass(this.stackDiv, cls); + wrs_removeClass(this.minimizeDiv, cls); +} + +ModalWindow.prototype.setTitle = function(title) { + this.titleDiv.innerHTML = title; + this.title = title; + +} +/** + * Create modal dialog for desktop OS. + * @param {modalDiv} modal overlay div. + * @param {containerDiv} modal window div. + * @param {iframe} embedded iframe. + * @param {iframeParams} embedded iframe params (height, width). + * @ignore + */ +ModalWindow.prototype.createModalWindowDesktop = function() { + this.addClass('wrs_modal_desktop'); + this.stackModalWindow(); +} + +/** + * Create modal dialog for non mobile android devices. + * @param {modalDiv} modal overlay div. + * @param {containerDiv} modal window div. + * @param {iframe} embedded iframe. + * @param {iframeParams} embedded iframe params (height, width). + * @ignore + */ + +ModalWindow.prototype.createModalWindowAndroid = function() { + this.addClass('wrs_modal_android'); +} + +/** + * Create modal dialog for iOS devices. + * @ignore + */ + +ModalWindow.prototype.createModalWindowIos = function() { + + this.addClass('wrs_modal_ios'); +} + +ModalWindow.prototype.stackModalWindow = function () { + if (this.properties.state == 'stack' || (this.properties.state == 'minimized') && !this.properties.previousState == 'stack') { + this.maximizeModalWindow(); + } else { + this.properties.previousState = this.properties.state; + this.properties.state = 'stack'; + + // We need to remove "width" manually because is calculated by javascript. + // containerDiv.style.width = null; + // containerDiv.style.left = null; + this.containerDiv.style.top = null; + // this.containerDiv.style.width = null; + this.containerDiv.style.rifgh = null; + this.containerDiv.style.left = null; + this.containerDiv.style.position = null; + + var modalWidth = parseInt(this.properties.iframeAttributes['width']); + this.iframeContainer.style.width = modalWidth + 'px'; + this.iframeContainer.style.height = 300 + 'px'; + this.containerDiv.style.width = (modalWidth + 12) + 'px'; + this.iframe.style.width = this.properties.iframeAttributes['width'] + 'px'; + this.iframe.style.height = (parseInt(300) + 3) + 'px'; + this.iframe.style.margin = '6px'; + this.removeClass('wrs_maximized'); + this.removeClass('wrs_minimized'); + this.addClass('wrs_stack'); + } +} + +ModalWindow.prototype.minimizeModalWindow = function() { + if (this.properties.state == 'minimized' && this.properties.previousState == 'stack') { + this.stackModalWindow(); + } + else if (this.properties.state == 'minimized' && this.properties.previousState == 'maximized') { + this.maximizeModalWindow(); + } + else { + this.removeListeners(); + this.properties.previousState = this.properties.state; + this.properties.state = "minimized"; + this.containerDiv.style.width = null; + this.containerDiv.style.left = null; + this.containerDiv.style.top = null; + this.containerDiv.style.position = null; + + if (wrs_containsClass(this.overlayDiv, 'wrs_stack')) { + this.removeClass('wrs_stack'); + } + else { + this.removeClass('wrs_maximized'); + } + + this.addClass('wrs_minimized'); + } +} + +/** + * Minimizes modal window. + * @ignore + */ +ModalWindow.prototype.maximizeModalWindow = function() { + this.properties.previousState = this.properties.state; + this.properties.state = 'maximized'; + + var modalHeight = parseInt(this.properties.iframeAttributes['height']); + var modalWidth = parseInt(this.properties.iframeAttributes['width']); + this.iframeContainer.style.width = modalWidth + 'px'; + this.iframeContainer.style.height = modalHeight + 'px'; + this.containerDiv.style.width = (modalWidth + 12) + 'px'; + this.iframe.style.width = this.properties.iframeAttributes['width'] + 'px'; + this.iframe.style.height = (parseInt(this.properties.iframeAttributes['height']) + 3) + 'px'; + this.iframe.style.margin = '6px'; + this.removeClass('wrs_drag'); + if (wrs_containsClass(this.overlayDiv, 'wrs_minimized')) { + this.removeClass('wrs_minimized'); + } else if (wrs_containsClass(this.overlayDiv, 'wrs_stack')) { + this.containerDiv.style.left = null; + this.containerDiv.style.top = null; + this.removeClass('wrs_stack'); + } + this.addClass('wrs_maximized'); +} + +/** + * Makes an object draggable adding mouse and touch events. + * + * @param {object} draggable object (for example modal dialog). + * @param {target} target to add the events (for example de titlebar of a modal dialog) + * @ignore + */ +ModalWindow.prototype.addListeners = function() { + // Mouse events. + wrs_addEvent(document.body, 'mousedown', this.startDrag.bind(this)); + 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(document.body, 'mousemove', this.drag.bind(this)); +} + +/** + * Removes draggable events from an object. + * + * @param {object} draggable object (for example modal dialog). + * @param {target} target to add the events (for example de titlebar of a modal dialog) + * @ignore + */ +ModalWindow.prototype.removeListeners = function() { + // Mouse events. + wrs_removeEvent(document.body, 'mousedown', this.startDrag); + wrs_removeEvent(window, 'mouseup', this.stopDrag); + wrs_removeEvent(document, 'mouseup', this.stopDrag); + wrs_removeEvent(document.getElementsByClassName("wrs_modal_iframe")[0], 'mouseup', this.stopDrag); + wrs_removeEvent(document.body, 'mousemove', this.drag); +} + + +/** + * Returns mouse or touch coordinates (on touch events ev.ClientX doesn't exists) + * @param {event} ev mnouse or touch event + * @return {object} with the X and Y coordinates. + * @ignore + */ +ModalWindow.prototype.eventClient = function(ev) { + if (typeof(ev.clientX) == 'undefined') { + var client = { + X : ev.changedTouches[0].clientX, + Y : ev.changedTouches[0].clientY + }; + return client; + } else { + client = { + X : ev.clientX, + Y : ev.clientY + }; + return client; + } +} + +/** + * Start drag function: set the object _wrs_dragDataObject with the draggable object offsets coordinates. + * when drag starts (on touchstart or mousedown events). + * + * @param {event} ev touchstart or mousedown event. + * @ignore + */ +ModalWindow.prototype.startDrag = function(ev) { + if (this.properties.state == 'minimized') { + return; + } + if (ev.target.className == 'wrs_modal_title') { + if(!this.dragDataobject) { + ev = ev || event; + this.dragDataObject = { + x: this.eventClient(ev).X - (isNaN(parseInt(window.getComputedStyle(this.containerDiv)).left && parseInt(window.getComputedStyle(this.containerDiv).left > 0 )) ? this.containerDiv.offsetLeft : parseInt(window.getComputedStyle(this.containerDiv).left)), + y: this.eventClient(ev).Y - (isNaN(parseInt(window.getComputedStyle(this.containerDiv).top)) ? this.containerDiv.offsetTop : parseInt(window.getComputedStyle(this.containerDiv).top)) + }; + }; + } + + if (typeof dialogContainerDiv != 'undefined') { + this.addClass('wrs_drag'); + } +} + +/** + * Updates_wrs_dragDataObject with the draggable object coordinates when the draggable object is being moved. + * + * @param {event} ev touchmouve or mousemove events. + * @ignore + */ +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.position = 'absolute'; + this.containerDiv.style.bottom = null; + wrs_removeClass(this.containerDiv, 'wrs_stack'); + } +} + +/** + * Set the _wrs_dragDataObject to null when the drag finish (touchend or mouseup events). + * + * @param {event} ev touchend or mouseup event. + * @ignore + */ +ModalWindow.prototype.stopDrag = function(ev) { + wrs_addClass(this.containerDiv, 'wrs_drag'); + this.dragDataObject = null; +} diff --git a/core/editor.css b/core/editor.css index 330d5126..aae34966 100644 --- a/core/editor.css +++ b/core/editor.css @@ -49,10 +49,13 @@ } .wrs_buttonContainer { display: inline; +} + +.wrs_buttonContainer.wrs_modalAndroid { padding-left: 6px; } -.wrs_modal_open .wrs_buttonContainer { +..wrs_buttonContainer.wrs_modalDesktop { padding-left: 0px; } @@ -61,3 +64,71 @@ width : 140%; } } + + +/*iPad and iPad Mini*/ +@media only screen +and (min-device-width : 768px) +and (max-device-width : 1024px) +and (orientation : portrait) { + + .wrs_container.wrs_modalIos { + width: 100vw !important; + height: 100vh !important; + } + + .wrs_editorContainer.wrs_modalIos { + width: 100vw !important; + height: 89vh !important; + } + + .wrs_controls.wrs_modalIos { + width: 100vw !important; + height: 11vh !important; + } + +} + +@media only screen +and (min-device-width : 768px) +and (max-device-width : 1024px) +and (orientation : landscape) { + .wrs_container.wrs_modalIos { + width: 100vw !important; + height: 100vh !important; + } + + .wrs_editorContainer.wrs_modalIos { + width: 100vw !important; + height: 87vh !important; + } + + .wrs_controls.wrs_modalIos { + width: 100vw !important; + height: 13vh !important; + } +} + +/*iPhone 5*/ +@media only screen +and (min-device-width : 320px) +and (max-device-width : 568px) +and (orientation : portrait) { + + .wrs_container.wrs_modalIos { + display: inline; + width: 320px !important; + height: 100vh !important; + } + + .wrs_editorContainer.wrs_modalIos { + width: 320px !important; + height: 79vh !important; + } + + .wrs_controls.wrs_modalIos { + width: 320px !important; + height: 21vh !important; + vertical-align: middle; + } +} diff --git a/core/editor.js b/core/editor.js index 1dc68c6e..41632868 100644 --- a/core/editor.js +++ b/core/editor.js @@ -18,6 +18,8 @@ var _wrs_isNewElement; // Unfortunately we need this variabels as global variabl '_wrs_int_path' , '_wrs_int_wirisProperties', '_wrs_int_customEditors', + '_wrs_modalWindowProperties', + '_wrs_int_langCode' ]; // Sometimes (yes, sometimes) internet explorer security policies hides popups @@ -160,8 +162,6 @@ var _wrs_isNewElement; // Unfortunately we need this variabels as global variabl function wrs_waitForCore() { if (typeof _wrs_conf_core_loaded != 'undefined' && typeof _wrs_conf_configuration_loaded != 'undefined' && _wrs_conf_configuration_loaded == true) { // Insert editor. - var lang = new RegExp("lang=([^&]*)","i").exec(window.location); - lang = (lang != null && lang.length > 1) ? lang[1] : "en"; var script = document.createElement('script'); script.type = 'text/javascript'; var editorUrl = _wrs_conf_editorUrl; @@ -178,13 +178,13 @@ var _wrs_isNewElement; // Unfortunately we need this variabels as global variabl statSaveMode = _wrs_conf_saveMode; statVersion = _wrs_conf_version; - script.src = editorUrl + "?lang=" + lang + '&stats-editor=' + statEditor + '&stats-mode=' + statSaveMode + '&stats-version=' + statVersion; + script.src = editorUrl + "?lang=" + _wrs_int_langCode + '&stats-editor=' + statEditor + '&stats-mode=' + statSaveMode + '&stats-version=' + statVersion; document.getElementsByTagName('head')[0].appendChild(script); // Insert strings. var script = document.createElement('script'); script.type = 'text/javascript'; - script.src = "../lang/" + lang + "/strings.js"; + script.src = "../lang/" + _wrs_int_langCode + "/strings.js"; document.getElementsByTagName('head')[0].appendChild(script); } else { setTimeout(wrs_waitForCore, 200); @@ -208,10 +208,6 @@ var _wrs_isNewElement; // Unfortunately we need this variabels as global variabl wrs_addEvent(window, 'load', function () { function wrs_waitForEditor() { if ((typeof _wrs_conf_core_loaded != 'undefined') && ('com' in window && 'wiris' in window.com && 'jsEditor' in window.com.wiris)) { - // Class for modal dialog. - if (_wrs_conf_modalWindow) { - document.body.className = !(document.body.className) ? "wrs_modal_open" : document.body.className + " wrs_modal_open"; - } var queryParams = wrs_getQueryParams(window); var customEditor; @@ -235,15 +231,26 @@ var _wrs_isNewElement; // Unfortunately we need this variabels as global variabl } } } + if (com.wiris.jsEditor.defaultBasePath) { editor = com.wiris.jsEditor.JsEditor.newInstance(wrs_attributes); } else { 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; + var isIOS = ((ua.indexOf("ipad") > -1) || (ua.indexOf("iphone") > -1)); var editorElement = editor.getElement(); var editorContainer = document.getElementById('editorContainer'); + if (isIOS) { + editorContainer.className += ' wrs_editorContainer wrs_modalIos'; + } editor.insertInto(editorContainer); // Mathml content. @@ -269,8 +276,17 @@ var _wrs_isNewElement; // Unfortunately we need this variabels as global variabl strings = new Object(); } + if (isIOS) { + // Editor and controls container + var editorAndControlsContainer = document.getElementById('container'); + editorAndControlsContainer.className += ' wrs_container wrs_modalIos'; + } + // Submit button. var controls = document.getElementById('controls'); + if (isIOS) { + controls.className += ' wrs_controls wrs_modalIos'; + } var submitButton = document.createElement('input'); submitButton.type = 'button'; submitButton.className = 'wrs_button_accept'; @@ -321,9 +337,9 @@ var _wrs_isNewElement; // Unfortunately we need this variabels as global variabl cancelButton.type = 'button'; cancelButton.className = 'wrs_button_cancel'; - if (strings['cancel'] != null){ + if (strings['cancel'] != null) { cancelButton.value = strings['cancel']; - }else{ + } else { cancelButton.value = 'Cancel'; } @@ -333,6 +349,15 @@ var _wrs_isNewElement; // Unfortunately we need this variabels as global variabl buttonContainer.appendChild(cancelButton); + // Class for modal dialog. + if (_wrs_conf_modalWindow) { + if (_wrs_modalWindowProperties.device == 'android') { + buttonContainer.className = buttonContainer.className + ' wrs_modalAndroid'; + } else { + buttonContainer.className = buttonContainer.className + ' wrs_modalDesktop'; + } + } + /*var manualLink = document.getElementById('a_manual'); if (typeof manualLink != 'undefined' && strings['manual'] != null){ manualLink.innerHTML = strings['manual']; diff --git a/core/icons/general/close_icon.png b/core/icons/general/close_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ff52273a058a7780866264c52c2bf8e05f6384d6 GIT binary patch literal 524 zcmV+n0`vWeP)gXrk#qoh05|BR2Qb+qm^OkW0KWh}0DJ>D z3nNeVOZc+a87hZxFE|Dbf=i*L z;8ds=ya$>K&V{<*&c(j)z8EFw9CEQE?~hS}&e>dNbMpqkc-GMoz|+pL?`}~b1+Wwp z0ItiTKrEMw&`;0y#_yOJ&7wCT0MDo=p8$rrXIRcz1K_C)<+iW~SxL$km& zK$F3>K$E~VL8IW>pqt<}@JL6h!3-ZfI~>sF(cX2}9n5I=qlI7!RWPFnEdf)k+!{q_4wzDV z1EUB{0aI?*WfY-XUIk(00p>p1<rbkb_@6fWVq815gT~ zC3C_Ini`<(yJIC#1y%-SW2I0gRt{xhlR#P6It7%4t&pe~*u5tkJ^>5wfWK-mbL*0W z*-b$TRjV-J8&u61Ywy-nRD-teg2|q}7oalJ0 zNjOBLdNQ+W3i}M28a#Z@F^f2q)Cm?{;~nzfZm{O`qyh(b?8jSI2jCWQ%wvOtzn@Pn zFxEH_p5frHPt}px!A>g@zRXHg)NYqP5?{WEg8$fj&W#Man(^Ww)Q{?tV`;)Ky^)cC zl~_7hjirK9U}@k~*kOnG7;GIo!8QT%X=i$uWNA<}mI_s3=};9`0##sTP{pb10^nQV k>;V*Ptm0qF&O^A~0fNn>ne-&ojsO4v07*qoM6N<$f^b8(rvLx| literal 0 HcmV?d00001 diff --git a/core/icons/general/max_icon.png b/core/icons/general/max_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..d7a30495848abbbd6cd8c81f79c1ee55071ccd19 GIT binary patch literal 266 zcmeAS@N?(olHy`uVBq!ia0vp^T0pGL!3HGx=1ctpQk(@Ik;M!QddeWoSh3W;3@EtA z)5S3);_%y>-n>kPBCQYi3x88!W$$60U?5h|&@$1$LV~@4xqyN1)q@S1(oEb!Mmt-J z&3wz_Z{7PcRVC0_O3TyqLS&}61A7kBO(O#)W`{{zSo#jwyhw;^F!PjZEd4O^zS`Bm zZ|dQD7q&@dy(s_oEBq$&^-f#e4ZlRJrWhZXa&vEURj*Xm3Xn92kowwE|Dofb)t9hF zWAmp%;{*&BYnsoQnzNlS{%i9*}KZwXKV0_o>B)|K8@n+ND=KAJrSucO-W9El5 W4#%#4k;VvgD1)b~pUXO@geCx=U0L@4 literal 0 HcmV?d00001 diff --git a/core/icons/general/mins_icon.png b/core/icons/general/mins_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..cb18cc9a56f02ce1585e602e3c0a4e01a9856eca GIT binary patch literal 464 zcmV;>0WbcEP)u88NnS`E zSB#x(CNQHX@AVUaKH{^t0NwyRAVbUqG!~o{>SHD7QgC*tk3B88Rst7+`q+qWa%29G)CCHhW~<93pNvd>cD2E-$pEJyJK5-f>Mtyy5MiY zs)I^cmCz7YEp&`k4F!P8J%ionCK{a9zTh6nkGgXMSo5ZE2i^mF z#md^6*#X+QBk2$gPF;^8*$K6;i!0%;t*v#XX7*dynPLhlml893CRxvnnVVrtGW*Y9 z33Lu@Z`b6+#y};o_4{*R8+X%s<@i1XC5ar*U@6juPG3I)_Zm2n!c0{F00000@?kEP)1*wFJ1*t8s`&m6=mXcl0{8(o!iK*7Z1nFh zTo<-HceW1b z8x`PH1hm)CGee`mDg$URSY-kY0;`Omm0*<_)C*P_LY-jM5OgNIr|X#5Cqd{$ zW5Q|%bHUqlmGw#07*qoM6N<$f==G;`v3p{ literal 0 HcmV?d00001 diff --git a/core/icons/hover/fulls_icon_h.png b/core/icons/hover/fulls_icon_h.png new file mode 100644 index 0000000000000000000000000000000000000000..033283e644d2e979f942d15072083b277a456120 GIT binary patch literal 423 zcmV;Y0a*TtP)3cPCxfkzx+a&_)aFRLQ34x&jvH;{e>Ml0_O( z7j&&m7=~AW4Be@*RX`nB8&r+8LX}uMRD~@9RbjU!pepPog+hT{qzYICwisCX>#~E@ zMZpSolv^9P5B30TfY-6X(F3{$p3`+yaGX$?+D!1=js2~J=76_?5ncipkx}d0!c$@e zTm$Ek*_4z5e_9*HfbPi+{8+i{I2(&)DFDCj@vO#K^f+=$f!?FYsv4qYqOVSvs*gUF5`~(FrDu~=| zEuVVY-|nQHy}GfoQ)*L)#EYyg>l)S?-~TIH#ni`VzKLDWVfL9dj8f0%0+sA$%6@)9 zkKKVO#A+UkXh?u#z4;WMb!$Hc7zEeuId`?nkrgBeCie23Gu<%z=H~xwRROQ3^Sx!V z$e%gs#kanR{B1`hz3SqFjsElsKPawPx1GWBzt4ZJT1Mq!g=G@wGaP^(VeoYIb6Mw< G&;$T)!CoT( literal 0 HcmV?d00001 diff --git a/core/icons/hover/min_icon_h.png b/core/icons/hover/min_icon_h.png new file mode 100644 index 0000000000000000000000000000000000000000..88f79f90bbf9182d71a8f56b3db1d9c0d8c6aa77 GIT binary patch literal 244 zcmeAS@N?(olHy`uVBq!ia0vp^+91rq1|%QG79IdnoCO|{#S9F3${@^GvDCf{D7ehi z#W5t}@Y|cZd`yM{Z4b9gi@d(xd_VY2;11U12M&ii=*!)W*4Z|ri>*<4rrP`GujYM8 zS9`f6h-+`kg2f%8+F@%VHYOeILNI!tiUwzeBCUQ!KvGk@dGYa3rw@@<_O+w3gw;CJ>y9^148-X!L* g2YeH%W*O8moQaX$l^mdKI;Vst05v&XV*mgE literal 0 HcmV?d00001 diff --git a/core/icons/hover/mins_icon_h.png b/core/icons/hover/mins_icon_h.png new file mode 100644 index 0000000000000000000000000000000000000000..af6e78843a9aeb3fe2b91cd08ebf9b59f5c0640a GIT binary patch literal 462 zcmV;<0WtoGP)plXvv9UdL z1(f=AD7Xgh^);elO=usX;2OA#y$o#7P;gYJiETVTn-3fvYGRiYKI;M}ftuJS;4lN6 z3<^*fdA8D!a>Dlxz?Wy~yz3Dq8?=FUctzqk&a)w45hs{fuyVXF60An%#DSG(zSX<_ zUtsGTyM7KfX~I7RD-H^!3K&vuB zr-J)hVXrbnec^>0c0uQRM!toDd&Zuversion = 2017010500; -$plugin->release = '3.64.0.1325'; +$plugin->version = 2017030100; +$plugin->release = '4.1.0.1357'; $plugin->requires = 2014050800; $plugin->component = 'atto_wiris'; -$plugin->dependencies = array ('filter_wiris' => 2017010500); +$plugin->dependencies = array ('filter_wiris' => 2017030100); $plugin->maturity = MATURITY_STABLE; diff --git a/wirisplugin-generic.js b/wirisplugin-generic.js index a17939b5..f3d5f992 100644 --- a/wirisplugin-generic.js +++ b/wirisplugin-generic.js @@ -42,19 +42,19 @@ var _wrs_int_temporalIframe; var _wrs_int_window; var _wrs_int_window_opened = false; var _wrs_int_temporalImageResizing; -var _wrs_int_language; +var _wrs_int_langCode; var _wrs_int_directionality = ''; // Custom Editors. -var _wrs_int_customEditors = {chemistry : {name: 'Chemistry', toolbar : 'chemistry', icon : 'chem.png', enabled : false, confVariable : '_wrs_conf_chemEnabled'}} +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_language = navigator.userLanguage; + _wrs_int_langCode = navigator.userLanguage; } else if (navigator.language) { - _wrs_int_language = navigator.language.substring(0, 2); + _wrs_int_langCode = navigator.language.substring(0, 2); } else { - _wrs_int_language = 'en'; + _wrs_int_langCode = 'en'; } // Including core.js. @@ -107,7 +107,7 @@ function wrs_int_init_handler(target,toolbar) { formulaButton.style.cursor = 'pointer'; wrs_addEvent(formulaButton, 'click', function () { - wrs_int_openNewFormulaEditor(target, _wrs_int_language); + wrs_int_openNewFormulaEditor(target, _wrs_int_langCode); }); toolbar.appendChild(formulaButton); @@ -120,7 +120,7 @@ function wrs_int_init_handler(target,toolbar) { CASButton.style.cursor = 'pointer'; wrs_addEvent(CASButton, 'click', function () { - wrs_int_openNewCAS(target, _wrs_int_language); + wrs_int_openNewCAS(target, _wrs_int_langCode); }); toolbar.appendChild(CASButton); @@ -137,7 +137,7 @@ function wrs_int_init_handler(target,toolbar) { wrs_addEvent(customEditorButton, 'click', function () { wrs_int_enableCustomEditor(key); - wrs_int_openNewFormulaEditor(target, _wrs_int_language); + wrs_int_openNewFormulaEditor(target, _wrs_int_langCode); }); toolbar.appendChild(customEditorButton); @@ -153,7 +153,7 @@ function wrs_int_init_handler(target,toolbar) { * @param object iframe Target */ function wrs_int_openNewFormulaEditor(iframe, language) { - if (_wrs_int_window_opened) { + if (_wrs_int_window_opened && !_wrs_conf_modalWindow) { _wrs_int_window.focus(); } else { @@ -191,9 +191,9 @@ function wrs_int_doubleClickHandler(iframe, element) { wrs_int_enableCustomEditor(customEditor); } if (wrs_containsClass(element, 'Wirisformula')) { - if (!_wrs_int_window_opened) { + if (!_wrs_int_window_opened || _wrs_conf_modalWindow) { _wrs_temporalImage = element; - wrs_int_openExistingFormulaEditor(iframe, _wrs_int_language); + wrs_int_openExistingFormulaEditor(iframe, _wrs_int_langCode); } else { _wrs_int_window.focus(); @@ -202,7 +202,7 @@ function wrs_int_doubleClickHandler(iframe, element) { else if (wrs_containsClass(element, 'Wiriscas')) { if (!_wrs_int_window_opened) { _wrs_temporalImage = element; - wrs_int_openExistingCAS(iframe, _wrs_int_language); + wrs_int_openExistingCAS(iframe, _wrs_int_langCode); } else { _wrs_int_window.focus(); 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 af8f9d7e..4671e89b 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 @@ -49,6 +49,7 @@ Y.namespace('M.atto_wiris').Button = Y.Base.create('button', Y.M.editor_atto.Edi **/ initializer: function(config) { this._lang = config.lang; + window._wrs_int_langCode = config.lang; // Add global-scope callback functions and properties. // Popup closed callback. @@ -97,7 +98,8 @@ Y.namespace('M.atto_wiris').Button = Y.Base.create('button', Y.M.editor_atto.Edi toolbar : 'chemistry', icon : 'chem.gif', enabled : false, - confVariable : '_wrs_conf_chemEnabled'}}; + confVariable : '_wrs_conf_chemEnabled', + title: 'WIRIS EDITOR chemistry'}}; // Load WIRIS plugin core javascript file only once. if (!window._wrs_int_coreLoading) { 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 5abc21cd..400e6fb9 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_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"}},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),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 01d0464c..d87163d7 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 @@ -49,6 +49,7 @@ Y.namespace('M.atto_wiris').Button = Y.Base.create('button', Y.M.editor_atto.Edi **/ initializer: function(config) { this._lang = config.lang; + window._wrs_int_langCode = config.lang; // Add global-scope callback functions and properties. // Popup closed callback. @@ -97,7 +98,8 @@ Y.namespace('M.atto_wiris').Button = Y.Base.create('button', Y.M.editor_atto.Edi toolbar : 'chemistry', icon : 'chem.gif', enabled : false, - confVariable : '_wrs_conf_chemEnabled'}}; + confVariable : '_wrs_conf_chemEnabled', + title: 'WIRIS EDITOR chemistry'}}; // Load WIRIS plugin core javascript file only once. if (!window._wrs_int_coreLoading) { diff --git a/yui/src/button/js/button.js b/yui/src/button/js/button.js index 3a98ae72..504a5319 100644 --- a/yui/src/button/js/button.js +++ b/yui/src/button/js/button.js @@ -47,6 +47,7 @@ Y.namespace('M.atto_wiris').Button = Y.Base.create('button', Y.M.editor_atto.Edi **/ initializer: function(config) { this._lang = config.lang; + window._wrs_int_langCode = config.lang; // Add global-scope callback functions and properties. // Popup closed callback. @@ -95,7 +96,8 @@ Y.namespace('M.atto_wiris').Button = Y.Base.create('button', Y.M.editor_atto.Edi toolbar : 'chemistry', icon : 'chem.gif', enabled : false, - confVariable : '_wrs_conf_chemEnabled'}}; + confVariable : '_wrs_conf_chemEnabled', + title: 'WIRIS EDITOR chemistry'}}; // Load WIRIS plugin core javascript file only once. if (!window._wrs_int_coreLoading) {