Commit 267615f9 authored by Jerome Chauveau's avatar Jerome Chauveau
Browse files

Merge branch 'ag/pluginsSansJquery' into 'dev'

suppression du jquery

See merge request pdn-certic/MaX!76
parents 11756369 e27aaad8
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -4,6 +4,6 @@
}

.ex{
  color:black;
  color:blue;

}
 No newline at end of file
+48 −28
Original line number Diff line number Diff line

import { Plugin } from '../../core/ui/js/Plugin.js';

const EX_CLASS = "ex";
const AM_CLASS = "am";

const corrI18n = {
  'fr': {
    'display': 'Développer les abréviations'
  },
  'en': {
    'display': 'Expand abbreviations'
  }
}

class AbreviationPlugin extends Plugin {
  constructor(name) {
    super(name);
@@ -13,8 +21,7 @@ class AbreviationPlugin extends Plugin{
    console.log("Plugin abréviation running")
    var checkAttr = "";
    if (localStorage.
           getItem(MAX_LOCAL_STORAGE_PREFIX + EX_CLASS) === MAX_VISIBLE_PROPERTY_STRING)
    {
      getItem(MAX_LOCAL_STORAGE_PREFIX + EX_CLASS) === MAX_VISIBLE_PROPERTY_STRING) {
      checkAttr = "checked='checked' ";
      //updates visibility
      this.on();
@@ -24,18 +31,24 @@ class AbreviationPlugin extends Plugin{
      this.off();
    }

    $("#options-list").append("<li><a><input id='toggle_ex' type='checkbox' "
    const parser = new DOMParser();
    let node =
      parser.parseFromString(
        "<li><a><input id='toggle_ex' type='checkbox' "
        + checkAttr
          +" name='toggle_ex'>Développer les abréviations</a></li>");
    let self = this;
    $('#toggle_ex').change(function(){
      self.setExVisible()
        + " name='toggle_ex'>" + corrI18n[lang]['display'] + "</a></li>",
        "text/html")
        .documentElement.querySelector('li');
    document.getElementById('options-list').append(
      document.importNode(node, true)
    );
    document.getElementById('toggle_ex').addEventListener('change', () => {
      this.setExVisible()
    })
  }

  setExVisible() {
    if($('#toggle_ex').is(":checked"))
    {
    if (document.getElementById('toggle_ex').checked) {
      this.on();
      localStorage.setItem(MAX_LOCAL_STORAGE_PREFIX + EX_CLASS, MAX_VISIBLE_PROPERTY_STRING);
    }
@@ -45,16 +58,23 @@ class AbreviationPlugin extends Plugin{
    }
  }


  /*ex visibles*/
  on() {
    $("." + AM_CLASS).hide();
    $("." + EX_CLASS).show();
    document.querySelectorAll("." + AM_CLASS).forEach((e) => {
      e.style.display = 'none';
    });
    document.querySelectorAll("." + EX_CLASS).forEach((e) => {
      e.style.display = 'inline';
    });

  }
  /*corr hidden (sic visibles)*/

  off() {
    $("." + AM_CLASS).show();
    $("." + EX_CLASS).hide();
    document.querySelectorAll("." + AM_CLASS).forEach((e) => {
      e.style.display = 'inline';
    });
    document.querySelectorAll("." + EX_CLASS).forEach((e) => {
      e.style.display = 'none';
    });
  }
}

+5 −6
Original line number Diff line number Diff line
@@ -7,11 +7,9 @@
                exclude-result-prefixes="tei xsl">


  <xsl:template match="//tei:choice">
    <xsl:apply-templates/>
  </xsl:template> 

  <xsl:template match="//tei:am | //tei:ex">
   
  <xsl:template match="tei:am | tei:ex">
    <span>
      <xsl:attribute name="class">
        <xsl:value-of select="local-name(.)"/>
@@ -21,12 +19,13 @@
  </xsl:template>
	
	
	<xsl:template match="//tei:abbr">
	<xsl:template match="tei:abbr">
		<span class="am">
      <xsl:apply-templates/>
    </span>
	</xsl:template>
	<xsl:template match="//tei:expan">

	<xsl:template match="tei:expan">
		<span class="ex">
      <xsl:apply-templates/>
    </span>
+1 −3
Original line number Diff line number Diff line
.add{
  color:#1b9044;
}

.add[title] {
cursor:default;
}
+49 −29
Original line number Diff line number Diff line

import { Plugin } from '../../core/ui/js/Plugin.js';

const ADD_CLASS = "add";
const DEL_CLASS = "del";

const corrI18n = {
  'fr': {
    'display': 'Afficher les interventions'
  },
  'en': {
    'display': 'Display interventions'
  }
}

class AjoutPlugin extends Plugin {
  constructor(name) {
    super(name);
@@ -13,8 +21,7 @@ class AjoutPlugin extends Plugin{
    console.log("Plugin ajout running")
    var checkAttr = "";
    if (localStorage.
           getItem(MAX_LOCAL_STORAGE_PREFIX + ADD_CLASS) === MAX_VISIBLE_PROPERTY_STRING)
    {
      getItem(MAX_LOCAL_STORAGE_PREFIX + ADD_CLASS) === MAX_VISIBLE_PROPERTY_STRING) {
      checkAttr = "checked='checked' ";
      //updates visibility
      this.on();
@@ -24,18 +31,24 @@ class AjoutPlugin extends Plugin{
      this.off();
    }

    $("#options-list").append("<li><a><input id='toggle_add' type='checkbox' "
    const parser = new DOMParser();
    let node =
      parser.parseFromString(
        "<li><a><input id='toggle_ajout' type='checkbox' "
        + checkAttr
          +" name='toggle_add'>Afficher les interventions</a></li>");
    let self = this;
    $('#toggle_add').change(function(){
      self.setExVisible()
        + " name='toggle_ajout'>" + corrI18n[lang]['display'] + "</a></li>",
        "text/html")
        .documentElement.querySelector('li');
    document.getElementById('options-list').append(
      document.importNode(node, true)
    );
    document.getElementById('toggle_ajout').addEventListener('change', () => {
      this.setAjoutVisible()
    })
  }

  setExVisible(){
    if($('#toggle_add').is(":checked"))
    {
  setAjoutVisible() {
    if (document.getElementById('toggle_ajout').checked) {
      this.on();
      localStorage.setItem(MAX_LOCAL_STORAGE_PREFIX + ADD_CLASS, MAX_VISIBLE_PROPERTY_STRING);
    }
@@ -45,17 +58,24 @@ class AjoutPlugin extends Plugin{
    }
  }


  /*la balise add est mise en vert et la balise del est affichée*/
  on() {
  $("." + ADD_CLASS).css("color","green");
   $("." + DEL_CLASS).show();
    $("." + DEL_CLASS).css("color","initial");
    document.querySelectorAll("." + ADD_CLASS).forEach((e) => {
      e.style.color = '#1b9044';
    });
    document.querySelectorAll("." + DEL_CLASS).forEach((e) => {
      e.style.display = 'inline';
    });

  }
  /* la balise add est affichée mais la balise del est masquée */
  /* la balise add est affichée avec sa couleur initiale mais la balise del est masquée */
  off() {
     $("." + ADD_CLASS).css("color","inherit");
     $("." + DEL_CLASS).hide();
    document.querySelectorAll("." + ADD_CLASS).forEach((e) => {
      e.style.color = 'initial';
    });
    document.querySelectorAll("." + DEL_CLASS).forEach((e) => {
      e.style.display = 'none';
    });
  }
}

Loading