Commit 77607d7e authored by Jerome Chauveau's avatar Jerome Chauveau
Browse files

dépendances = suppression de la lib jquery, upgrade bootstrap, + premières...

dépendances = suppression de la lib jquery, upgrade bootstrap, + premières substitutions des appels jquery par vanillajs
parent 8d4eeeb4
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -10,11 +10,10 @@
  "scripts": {},
  "dependencies": {
    "babel-polyfill": "^6.26.0",
    "bootstrap": "^4.3.1",
    "bootstrap": "^5.0.2",
    "child_process": "^1.0.2",
    "fs": "0.0.1-security",
    "install": "^0.12.1",
    "jquery": "^3.3.1",
    "mathjax": "^2.7.7",
    "openseadragon": "^2.4.2",
    "popper.js": "^1.14.7",
+4 −4
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ class ApparatPlugin extends Plugin{
  run(){
      //si le fragment courant ne contient pas d'apparat
      if(!this.docWithApparat()){
         $(".apparat-witnesses").hide();
         document.querySelectorAll(".apparat-witnesses").forEach((e) => e.style.display = 'none');
         return;
      }
      this.showWitness("lem");
@@ -17,8 +17,8 @@ class ApparatPlugin extends Plugin{
  }
  
  showWitness(witnessClass){
    $(".apparat").hide();
    $("."+witnessClass).show();
    document.querySelectorAll(".apparat").each((e) => e.style.display = 'none');
    document.querySelectorAll("." + witnessClass).each((e) => e.style.display = 'inline');
    this.hideLacunas(witnessClass);
  }

@@ -106,7 +106,7 @@ class ApparatPlugin extends Plugin{


  docWithApparat(){
    return ($("#text .apparat").length + $("#text .lacunaStart").length + $("#text .lacunaEnd").length) > 0
    return document.querySelectorAll("#text .apparat, #text .lacunaStart, #text .lacunaEnd").length > 0
  }

}
+36 −10
Original line number Diff line number Diff line
@@ -33,12 +33,23 @@ class CorrectionPlugin extends Plugin{
      this.off();
     }

    $("#options-list").append("<li><a><input id='toggle_corr' type='checkbox' "
    const parser = new DOMParser();
    let node =
        parser.parseFromString(
            "<li><a><input id='toggle_corr' type='checkbox' "
            +checkAttr
          +" name='toggle_corr'>"+corrI18n[lang]['display']+"</a></li>");
    let self = this;      
    $('#toggle_corr').change(function(){
      self.setCorrVisible()
            +" name='toggle_corr'>"+corrI18n[lang]['display']+"</a></li>",
            "text/html")
            .documentElement.querySelector('li');
    document.getElementById('options-list').append(
        document.importNode(node, true)
    );
    // $("#options-list").append("<li><a><input id='toggle_corr' type='checkbox' "
    //       +checkAttr
    //       +" name='toggle_corr'>"+corrI18n[lang]['display']+"</a></li>");
    // let self = this;
    document.getElementById('toggle_corr').addEventListener('change',() => {
      this.setCorrVisible()
    })       
  }
  
@@ -57,13 +68,28 @@ class CorrectionPlugin extends Plugin{
  
  /*corr visibles*/
  on(){
    $("." + SIC_CLASS).hide(); 
    $("." + CORR_CLASS).show(); 
    document.querySelectorAll("." + SIC_CLASS).forEach((e) => {
      e.style.display = 'none';
    });

    document.querySelectorAll("." + CORR_CLASS).forEach((e) => {
      e.style.display = 'inline';
    });

    // $("." + SIC_CLASS).hide();
    // $("." + CORR_CLASS).show();
  }
  /*corr hidden (sic visibles)*/
  off(){
    $("." + SIC_CLASS).show(); 
    $("." + CORR_CLASS).hide();
    document.querySelectorAll("." + SIC_CLASS).forEach((e) => {
      e.style.display = 'inline';
    });

    document.querySelectorAll("." + CORR_CLASS).forEach((e) => {
      e.style.display = 'none';
    });
    // $("." + SIC_CLASS).show();
    // $("." + CORR_CLASS).hide();
  }
}

+87 −73
Original line number Diff line number Diff line
@@ -3,12 +3,18 @@ import {Plugin} from '../../core/ui/js/Plugin.js';
class ImageViewer extends Plugin {
    constructor(name) {
        super(name);

    var viewables = document.querySelectorAll('#text .img_viewer_link'); //img + pb
    var images = document.querySelectorAll('#text img');//img only
        const parser = new DOMParser();
        let viewables = document.querySelectorAll('#text .img_viewer_link'); //img + pb
        let images = document.querySelectorAll('#text img');//img only
        if (viewables.length > 0) {
      $('body').append('<script type="text/javascript" src="' +baseURI + 'plugins/img_viewer/openseadragon.min.js"></script>');
      $('body').prepend('<div id="img_dialog_wrap" class="modal" tabindex="-1" role="dialog">'+
            let scriptNode = document.createElement('script');
            scriptNode.setAttribute('type', 'text/javascript');
            scriptNode.setAttribute('src',baseURI + 'plugins/img_viewer/openseadragon.min.js');
            document.getElementsByTagName('head')[0].appendChild(scriptNode);

            let node =
                parser.parseFromString(
                '<div id="img_dialog_wrap" class="modal" tabindex="-1" role="dialog">' +
                '<div>' +
                '<div class="modal-content">' +
                '<div class="modal-header">' +
@@ -22,15 +28,23 @@ class ImageViewer extends Plugin{
                '</div>' +
                '</div>' +
                '</div>' +
              '</div>');
                '</div>',
                "text/html")
                .documentElement.querySelector('#img_dialog_wrap');

            document.body.append(document.importNode(node, true));
            document.getElementById('img_dialog_wrap').style.display = 'none';
      //$('.viewable').css('cursor', 'pointer');

         if(images.length > 1)
              $('#main-max-container').append('<div>'

            if (images.length > 1) {
                let gnode =
                    parser.parseFromString('<div id="gallery-wrap">'
                        + '<button id="all-images-btn" class="btn btn-secondary" onclick="MAX.plugins[\'img_viewer\'].openImagesInDialog()">'
                        + '<img alt="voir la galerie d\'images de la page" title="voir la galerie d\'images de la page" src="' + baseURI + 'plugins/img_viewer/images/gallery.png"/>'
              +'</button></div>')
                        + '</button></div>', "text/html").documentElement.querySelector('#gallery-wrap');
                document.getElementById('main-max-container').append(document.importNode(gnode, true))

            }
        }
    }

@@ -50,7 +64,8 @@ class ImageViewer extends Plugin{

        let tabImages = []

	this.getData(resource).then((tiles) => { tabImages = tiles['images'];
        this.getData(resource).then((tiles) => {
            tabImages = tiles['images'];
            document.querySelector('#img_dialog_wrap .modal-body').innerHTML = '<div id="osd-viewer" style="display: flex;"></div>'
            OpenSeadragon({
                id: "osd-viewer",
@@ -86,5 +101,4 @@ class ImageViewer extends Plugin{
}


MAX.addPlugin(new ImageViewer('img_viewer'));
console.log(MAX.plugins);
 No newline at end of file
+48 −35
Original line number Diff line number Diff line
@@ -26,8 +26,10 @@ class MaxTEI extends AbstractMax {
                this.scrollToID((targets[0]).getAttribute('id'),0)
            }
            //affiche le bas de page si non vide
            if ($("#bas_de_page .footnote").length > 0)
                $("#bas_de_page").show();
            let footnotes = document.querySelectorAll('#bas_de_page .footnote');
            if(footnotes.length > 0){
                document.getElementById("bas_de_page").style.display = 'block';
            }
        }
    }

@@ -58,49 +60,60 @@ class MaxTEI extends AbstractMax {

    textOptions() {
        //shows option's button if needed
        if ($("#options-list li").length > 0) {
            $("#txt_options").show();
        if (document.querySelectorAll("#options-list li").length > 0) {
            document.getElementById("txt_options").style.display = 'block';
        }

        //checkbox options (load from localstorage)
        $(".visibility_toggle").each(function () {
            let optionName = $(this).data('option');
        document.querySelectorAll(".visibility_toggle").forEach(function (e) {
            let optionName = e.dataset.option;//$(this).data('option');
            if (localStorage.getItem(window.MAX_LOCAL_STORAGE_PREFIX + optionName) === window.MAX_VISIBLE_PROPERTY_STRING) {
                $(this).attr("checked", "checked");
                e.setAttribute("checked", "checked");
                //updates visibility
                $("." + optionName).show();
                document.querySelectorAll("." + optionName).forEach((e) => {
                    e.style.display = 'inline';
                })
                //$("." + optionName).show();
            } else {
                $(this).removeAttr("checked");
                e.removeAttribute('checked');
                //updates visibility
                $("." + optionName).hide();
                document.querySelectorAll("." + optionName).forEach((e) => {
                    e.style.display = 'hidden';
                })
                //$("." + optionName).hide();
            }

        });
    }

    manageMarginNotes() {
        let mainContainer = $("#main-max-container");
        let leftBloc = mainContainer.children(":first");
        leftBloc.addClass("row");
        $("#text").addClass("col-sm-8");
        leftBloc.append("<div id='margin_notes' class='col-sm-2'></div>");
        let mainContainer = document.getElementById("main-max-container");
        let leftBloc = mainContainer.childNodes[0];
        leftBloc.classList.add("row");
        document.getElementById("text").classList.add("col-sm-8");
        let marginNode = document.createElement('div');
        marginNode.setAttribute('id', 'margin_notes');
        marginNode.classList.add('col-sm-2')
        leftBloc.append(marginNode);

        let previousNote = null;
        $(".manchette_droite").each(function () {
        document.querySelectorAll(".manchette_droite").forEach((manchette) =>{
            //stocke le top original avant de déplacer la note
            let originalTop = $(this).position().top;
            let originalTop = manchette.offsetTop//$(this).position().top;
            //déplacement de la note dans la colonne prévue
            $(this).appendTo("#margin_notes");
            marginNode.append(manchette);
            //$(this).appendTo("#margin_notes");
            //mise à jour top (+anti-chevauchement)
            let newTop = originalTop;
            if (previousNote != null && previousNote.position() != null) {
                let bottomPrevious = previousNote.position().top + previousNote.height();
            if (previousNote != null && previousNote.offsetTop) {
                let bottomPrevious = previousNote.offsetTop + previousNote.offsetHeight;
                if (bottomPrevious + 5 > newTop) {
                    newTop = bottomPrevious + 5;
                }
            }
            $(this).css("top", newTop + "px");
            previousNote = $(this);
            manchette.style.top = newTop + "px";
            //$(this).css("top", newTop + "px");
            previousNote = manchette;//$(this);
        });

    }
@@ -118,17 +131,17 @@ class MaxTEI extends AbstractMax {
            window.location.href = $(nextOrPrevious).find('a').attr("href");
        };

        if ($('#nav_previous').length) {
            $('#nav_previous').click(
                function () {
        let navPrev = document.getElementById('nav_previous');
        let navNext = document.getElementById('nav_next');
        if(navPrev){
            navPrev.addEventListener('click', () => {
                nextOrPrevious(-1);
                });
            })
        }
        if ($('#nav_next').length) {
            $('#nav_next').click(
                function () {
        if(navNext){
            navNext.addEventListener('click', () => {
                nextOrPrevious(1);
                });
            })
        }
    }

@@ -159,7 +172,7 @@ class MaxTEI extends AbstractMax {


    isWithNotes() {
        return $(".appel_note_marge").length > 0;
        return document.querySelectorAll('.appel_note_marge').length > 0
    }

    /*Affichage / masquage des éléments d'une classe CSS depuis un checkBox
@@ -183,8 +196,8 @@ class MaxTEI extends AbstractMax {

window.MAX = new MaxTEI(projectId, baseURI, fragmentId);

$(document).ready(function () {
    "use strict";
window.addEventListener('DOMContentLoaded', (event) => {
    MAX.run();
});

Loading