Commit 789641ab authored by Jerome Chauveau's avatar Jerome Chauveau
Browse files

Merge branch 'ag/pluginAjout' into 'dev'

mise à jour code js

See merge request pdn-certic/MaX!32
parents 18084eb7 a40dae9a
Loading
Loading
Loading
Loading
+31 −24
Original line number Diff line number Diff line
const ADD_CLASS = "add";
const DEL_CLASS = "del";

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

var ajoutOptions = new Object();
  
const ADD_CLASS = "add";
const DEL_CLASS = "del";

ajoutOptions['onTextChange'] = function() { 
class AjoutPlugin extends Plugin{
  constructor(name) {
    super(name);
  }

  run(){
    console.log("Plugin ajout running")
    var checkAttr = "";
    if(localStorage.
           getItem(MAX_LOCAL_STORAGE_PREFIX + ADD_CLASS) === MAX_VISIBLE_PROPERTY_STRING)
    {
      checkAttr = "checked='checked' ";
      //updates visibility
    onAjout();
      this.on();
    }
    else{
      //updates visibility
    offAjout();
      this.off();
     }

  $("#options-list").append("<li><a><input id='toggle_add' type='checkbox' onchange='setAjoutVisible()' "+checkAttr+" name='toggle_add'>Afficher les interventions</a></li>");
    $("#options-list").append("<li><a><input id='toggle_add' type='checkbox' "
          +checkAttr
          +" name='toggle_add'>Afficher les interventions</a></li>");
    let self = this;
    $('#toggle_add').change(function(){
      self.setExVisible()
    })
  }


function setAjoutVisible(){

  setExVisible(){
    if($('#toggle_add').is(":checked"))
    {
    onAjout();
      this.on();
      localStorage.setItem(MAX_LOCAL_STORAGE_PREFIX + ADD_CLASS, MAX_VISIBLE_PROPERTY_STRING);
    }
    else{
    offAjout(); 
      this.off();
      localStorage.removeItem(MAX_LOCAL_STORAGE_PREFIX + ADD_CLASS);
    }

  }

/*add en vert*/
function onAjout(){
  $("." + ADD_CLASS).css("color","green"); 
  $("." + DEL_CLASS).show(); 

}
/*add en noir*/
function offAjout(){ 
  $("." + ADD_CLASS).css("color","inherit");
  /*ex visibles*/
  on(){
    $("." + DEL_CLASS).hide();
  
    $("." + ADD_CLASS).show();
  }
  /*corr hidden (sic visibles)*/
  off(){
    $("." + DEL_CLASS).show();
    $("." + ADD_CLASS).hide();
  }
}

MAX.addModule(ajoutOptions);
 No newline at end of file
MAX.addPlugin(new AjoutPlugin('Ajout'));
 No newline at end of file