diff --git a/assets/javascripts/initializers/discourse-math.js.es6 b/assets/javascripts/initializers/discourse-math.js.es6 index ec47847..c1237c3 100644 --- a/assets/javascripts/initializers/discourse-math.js.es6 +++ b/assets/javascripts/initializers/discourse-math.js.es6 @@ -2,18 +2,27 @@ import { withPluginApi } from 'discourse/lib/plugin-api'; import loadScript from 'discourse/lib/load-script'; let initializedMathJax = false; +let zoom_on_hover, enable_accessibility; function initMathJax() { if (initializedMathJax) { return; } - window.MathJax = { + var extensions = ["toMathML.js", "Safe.js"]; + if(enable_accessibility) { + extensions.push("[a11y]/accessibility-menu.js") + } + var settings = { jax: ['input/TeX', 'input/AsciiMath', 'input/MathML', 'output/CommonHTML'], TeX: {extensions: ["AMSmath.js", "AMSsymbols.js", "autoload-all.js"]}, - extensions: ["toMathML.js"], + extensions: extensions, showProcessingMessages: false, root: '/plugins/discourse-math/mathjax' - }; - + } + if(zoom_on_hover) { + settings.menuSettings = {zoom: "Hover"}; + settings.MathEvents = {hover: 750}; + } + window.MathJax = settings; initializedMathJax = true; } @@ -72,6 +81,8 @@ export default { name: "apply-math", initialize(container) { const siteSettings = container.lookup('site-settings:main'); + zoom_on_hover = siteSettings.discourse_math_zoom_on_hover; + enable_accessibility = siteSettings.discourse_math_enable_accessibility; if (siteSettings.discourse_math_enabled) { withPluginApi('0.5', initializeMath); } diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index d525015..0b8ee7d 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -4,3 +4,5 @@ en: site_settings: discourse_math_enabled: 'Enable Discourse Math plugin (will add special processing to $ and $$ blocks)' + discourse_math_zoom_on_hover: 'Zoom 200% on hover' + discourse_math_enable_accessibility: 'Enable accessibility features' diff --git a/config/locales/server.es.yml b/config/locales/server.es.yml index d2a544b..4d67472 100644 --- a/config/locales/server.es.yml +++ b/config/locales/server.es.yml @@ -4,3 +4,5 @@ es: site_settings: discourse_math_enabled: 'Habilitar plugin Discourse Math (agregará procesamiento especial para los bloques con $ y $$)' + discourse_math_zoom_on_hover: 'Zoom 200% en hover' + discourse_math_enable_accessibility: 'Habilitar las funciones de accesibilidad' diff --git a/config/locales/server.fi.yml b/config/locales/server.fi.yml index e602da1..823fdf3 100644 --- a/config/locales/server.fi.yml +++ b/config/locales/server.fi.yml @@ -4,3 +4,5 @@ fi: site_settings: discourse_math_enabled: 'Ota käyttöön Discoursen matematiikkalisäosa ($ ja $$ blokit käsitellään erityisellä tavalla)' + discourse_math_zoom_on_click: 'Zoomaa 200% hoverissa' + discourse_math_enable_accessibility: 'Ota käyttöön esteettömyysominaisuudet' diff --git a/config/settings.yml b/config/settings.yml index 307681d..ef43242 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -2,3 +2,9 @@ plugins: discourse_math_enabled: default: false client: true + discourse_math_zoom_on_hover: + default: false + client: true + discourse_math_enable_accessibility: + default: false + client: true