Commit 42724158 authored by Jerome Chauveau's avatar Jerome Chauveau
Browse files

Suppression totale de la dépendance à jquery. Todo : sauvegarde des...

Suppression totale de la dépendance à jquery. Todo : sauvegarde des préférences d'affichage (datastorage). #138
parent 4f8827e6
.li-equations, .li-equations input{
margin-left:0px;
padding-left: 0px;
}
.li-equations a{
color: inherit;
text-decoration: none;
}
\ No newline at end of file
import {Plugin} from '../../core/ui/js/Plugin.js';
// const MathJax = require('mathjax');
//TODO : terminer la dé-jquerylisation !
class EquationPlugin extends Plugin{
constructor(name) {
......@@ -12,51 +9,41 @@ class EquationPlugin extends Plugin{
if(!this.docWithEquation())
return;
//appends lib + conf into head element
//let mathjax = "<script type='text/x-mathjax-config'>";
let mathjax = "MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}";
mathjax+=",TeX: {Macros: {textnormal: '{}',ad: '{=}'}}});</script>";
let mathjax = "MathJax = {tex: {inlineMath: [['$', '$'], ['\\(', '\\)']]}};"
let script = document.createElement('script');
script.setAttribute('type', 'text/x-mathjax-config');
script.append(mathjax);
document.querySelector("head").appendChild(script);
let scriptImport = document.createElement('script');
scriptImport.setAttribute('type', 'text/javascript');
scriptImport.setAttribute('src',MAX.getBaseURL() + 'plugins/equations/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML');
scriptImport.setAttribute('id','MathJax-script');
scriptImport.setAttribute('src',MAX.getBaseURL() + 'plugins/equations/mathjax/es5/tex-mml-chtml.js');
document.querySelector("head").appendChild(scriptImport);
//document.querySelector("head").append('<script type="text/javascript" src="'+MAX.getBaseURL() + 'plugins/equations/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>');
//appends text options components
$("#options-list").append("<li role='separator' class='divider'></li><li><a href='#'>"
+"<input id='toggle_equations_on' type='radio' name='equations' checked>Afficher les images de l\'édition originale</a></li>");
$("#options-list").append("<li><a href='#'><input id='toggle_equations_off' type='radio' name='equations'>"+
"Afficher les équations modernisées en mode texte</a></li><li role='separator' class='divider'></li>");
this.setEquationsVisible();
let self = this;
$('#toggle_equations_on').change(function(e){
self.toggleModernEquations(true);
let pluginHtml = "<li role='separator' class='divider li-equations'></li><li class='li-equations'><a href='#'>";
pluginHtml += "<input id='toggle_equations_off' type='radio' name='equations' checked>Afficher les images de l\'édition originale</a></li>";
pluginHtml += "<li class='li-equations'><a href='#'><input id='toggle_equations_on' type='radio' name='equations'>";
pluginHtml += "Afficher les équations modernisées en mode texte</a></li><li role='separator' class='divider'></li>"
document.getElementById('options-list').innerHTML+=pluginHtml
document.getElementById('toggle_equations_on').addEventListener('change', ()=> {
this.toggleModernEquations(true);
});
document.getElementById('toggle_equations_off').addEventListener('change', ()=> {
this.toggleModernEquations(false);
});
$('#toggle_equations_off').change(function(e){
self.toggleModernEquations(false);
});
document.getElementById('toggle_equations_on').click();
}
setEquationsVisible(){
$(".tex").show();
$(".formula").hide();
}
toggleModernEquations(on){
//console.log("Set modern equations visible =" + on)
if(on){
$(".tex").show();
$(".formula").hide();
}
else{
$(".formula").show();
$(".tex").hide();
}
document.querySelectorAll('.tex').forEach((tex) => {
tex.parentElement.style.display= on ?'inline-block':'none';
})
document.querySelectorAll('.formula').forEach((formula) => {
formula.style.display= on ?'none':'inline-block';
})
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment