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

Merge branch 'ag/pluginAjoutDiplo' into 'dev'

xsl pour le plugin ajout et nouveau plugin diplomatique

See merge request pdn-certic/MaX!34
parents 075ec4e3 ee63bf8d
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -4,4 +4,6 @@
.add[title] {
cursor:default;
}
.del{
  text-decoration:line-through;
}
+22 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<!--
 For conditions of distribution and use, see the accompanying legal.txt file.
-->

<xsl:stylesheet	version="2.0" 
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:tei="http://www.tei-c.org/ns/1.0"
                exclude-result-prefixes="tei xsl">


  <xsl:template match="//tei:subst"><xsl:apply-templates/></xsl:template> 
   
  <xsl:template match="//tei:del | //tei:add">
    <span>
      <xsl:attribute name="class">
        <xsl:value-of select="local-name(.)"/>
      </xsl:attribute><xsl:apply-templates/>
    </span>
  </xsl:template>
    
</xsl:stylesheet>
 No newline at end of file
+27 −0
Original line number Diff line number Diff line
.sic{
  color:brown;
  display:none;
}

.corr{
  color:pink;
}

.reg{
  color:red;
  display:none;
}

.orig{
  color:green;
}

.am{
  color:black;
  display:none;
}

.ex{
  color:blue;

}
 No newline at end of file
+79 −0
Original line number Diff line number Diff line
import {Plugin} from '../../core/ui/js/Plugin.js';

const CORR_CLASS = "corr";
const SIC_CLASS = "sic";
const ORIG_CLASS = "orig";
const REG_CLASS = "reg";
const EX_CLASS = "ex";
const AM_CLASS = "am";

class DiplomatiquePlugin extends Plugin{
  constructor(name) {
    super(name);
  }

  run(){
    console.log("plugin diplomatque running")
    var checkAttr = "";
    if(localStorage.
           getItem(MAX_LOCAL_STORAGE_PREFIX + CORR_CLASS) === MAX_VISIBLE_PROPERTY_STRING &&  localStorage.
           getItem(MAX_LOCAL_STORAGE_PREFIX + REG_CLASS) === MAX_VISIBLE_PROPERTY_STRING && localStorage.
           getItem(MAX_LOCAL_STORAGE_PREFIX + EX_CLASS) === MAX_VISIBLE_PROPERTY_STRING)
    {    
      checkAttr = "checked='checked' ";
      //updates visibility
      this.on();
    }
    else{  
      //updates visibility 
      this.off();
     }

    $("#options-list").append("<li><a><input id='toggle_diplo' type='checkbox' "
          +checkAttr
          +" name='toggle_diplo'>Affichage régularisé</a></li>");
    let self = this;      
    $('#toggle_diplo').change(function(){
      self.setCorrVisible()
    })       
  }
  
  setCorrVisible(){
    if($('#toggle_diplo').is(":checked"))
    {
      this.on();
      localStorage.setItem(MAX_LOCAL_STORAGE_PREFIX + CORR_CLASS, MAX_VISIBLE_PROPERTY_STRING);
      localStorage.setItem(MAX_LOCAL_STORAGE_PREFIX + REG_CLASS, MAX_VISIBLE_PROPERTY_STRING);
      localStorage.setItem(MAX_LOCAL_STORAGE_PREFIX + EX_CLASS, MAX_VISIBLE_PROPERTY_STRING);
    }

    else{ 
      this.off(); 
      localStorage.removeItem(MAX_LOCAL_STORAGE_PREFIX + CORR_CLASS);
      localStorage.removeItem(MAX_LOCAL_STORAGE_PREFIX + REG_CLASS);
      localStorage.removeItem(MAX_LOCAL_STORAGE_PREFIX + EX_CLASS);
    }    
  }
  
  
  /*corr visibles*/
  on(){
    $("." + SIC_CLASS).hide(); 
    $("." + CORR_CLASS).show();
    $("." + ORIG_CLASS).hide(); 
    $("." + REG_CLASS).show();
    $("." + AM_CLASS).hide(); 
    $("." + EX_CLASS).show(); 
  }
  /*corr hidden (sic visibles)*/
  off(){
    $("." + SIC_CLASS).show(); 
    $("." + CORR_CLASS).hide();
    $("." + ORIG_CLASS).show(); 
    $("." + REG_CLASS).hide();
    $("." + AM_CLASS).show(); 
    $("." + EX_CLASS).hide();
  }
}

MAX.addPlugin(new DiplomatiquePlugin('Diplomatique'));
+51 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<!--
 For conditions of distribution and use, see the accompanying legal.txt file.
-->

<xsl:stylesheet	version="2.0" 
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:tei="http://www.tei-c.org/ns/1.0"
                exclude-result-prefixes="tei xsl">


  <xsl:template match="//tei:choice"><xsl:apply-templates/></xsl:template> 
   
  <xsl:template match="//tei:sic | //tei:corr">
    <span>
      <xsl:attribute name="class">
        <xsl:value-of select="local-name(.)"/>
      </xsl:attribute><xsl:apply-templates/>
    </span>
  </xsl:template>

   <xsl:template match="//tei:orig | //tei:reg">
    <span>
      <xsl:attribute name="class">
        <xsl:value-of select="local-name(.)"/>
      </xsl:attribute><xsl:apply-templates/>
    </span>
  </xsl:template>

  <xsl:template match="//tei:am | //tei:ex">
    <span>
      <xsl:attribute name="class">
        <xsl:value-of select="local-name(.)"/>
      </xsl:attribute>
      <xsl:apply-templates/>
    </span>
  </xsl:template>
  
  
  <xsl:template match="//tei:abbr">
    <span class="am">
      <xsl:apply-templates/>
    </span>
  </xsl:template>
  <xsl:template match="//tei:expan">
    <span class="ex">
      <xsl:apply-templates/>
    </span>
  </xsl:template>
    
</xsl:stylesheet>
 No newline at end of file