Corentin NELHOMME hai 1 ano
achega
296dc0f222
Modificáronse 6 ficheiros con 1236 adicións e 0 borrados
  1. 62 0
      index.css
  2. 108 0
      index.html
  3. 874 0
      index.js
  4. 189 0
      nse.css
  5. 3 0
      nseImageEditorImage.js
  6. BIN=BIN
      src/image (1).png

+ 62 - 0
index.css

@@ -0,0 +1,62 @@
+img {
+    width: 400px;
+}
+
+#modalNse {
+    background-color: rgb(255, 255, 255);
+    border-radius: 10px;
+    box-shadow: rgba(100, 100, 111, 0.637) 0px 7px 29px 0px;
+}
+
+#editImageBtn {
+    padding: 1rem 1.8rem;
+    background-color: rgb(255, 255, 255);
+    color: rgb(0, 0, 0);
+    font-family: Arial, Helvetica, sans-serif;
+    border: none;
+    border-radius: 10px;
+    box-shadow: rgba(100, 100, 111, 0.267) 0px 7px 29px 0px;
+    font-weight: 700;
+    cursor: pointer;
+}
+
+#modalNseBackground {
+    display: none;
+    position: fixed;
+    left: 0;
+    top: 0;
+    height: 100vh;
+    width: 100%;
+    backdrop-filter: blur(5px);
+    justify-content: center;
+    align-items: center;
+}
+
+#cropper-modal {
+    display: none;
+    position: fixed;
+    top: 0; left: 0; right: 0; bottom: 0;
+    background: rgba(0, 0, 0, 0.7);
+    justify-content: center;
+    align-items: center;
+    z-index: 1000;
+  }
+  #cropper-modal.active {
+    display: flex;
+  }
+  #cropper-container {
+    background: white;
+    padding: 20px;
+    border-radius: 8px;
+    max-width: 90%;
+    max-height: 90%;
+    overflow: auto;
+  }
+  #cropper-container img {
+    max-width: 100%;
+    height: auto;
+  }
+  #cropper-actions {
+    margin-top: 10px;
+    text-align: right;
+  }

+ 108 - 0
index.html

@@ -0,0 +1,108 @@
+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <meta charset="UTF-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+    <title>Document</title>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-dotimeout/1.0/jquery.ba-dotimeout.min.js"></script>
+    <script src="https://unpkg.com/cropperjs@1.5.13/dist/cropper.min.js"></script>
+    <script src="https://cdn.jsdelivr.net/npm/tinymce@7.8.0/tinymce.min.js"></script>
+    <link rel="stylesheet" href="nse.css" />
+    <link
+    rel="stylesheet"
+    href="https://releases.transloadit.com/uppy/v4.12.2/uppy.min.css"
+  />
+  <script src="https://releases.transloadit.com/uppy/v4.12.2/uppy.min.js"></script>
+    <link
+      href="https://cdn.jsdelivr.net/npm/tinymce@7.8.0/skins/ui/oxide/skin.min.css"
+      rel="stylesheet"
+    />
+    <link rel="stylesheet" href="index.css" />
+
+
+  </head>
+  <body>
+    <img
+      class="imageeditor"
+      src="https://letsenhance.io/static/73136da51c245e80edc6ccfe44888a99/1015f/MainBefore.jpg"
+    />
+    <img
+      class="imageeditor"
+      src="https://images.unsplash.com/photo-1604311795833-25e1d5c128c6?fm=jpg&q=60&w=3000&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8Mnx8OSUzQTE2fGVufDB8fDB8fHww"
+    />
+    <img
+      class="imageeditor"
+      src="https://letsenhance.io/static/73136da51c245e80edc6ccfe44888a99/1015f/MainBefore.jpg"
+    />
+    <img
+      class="imageeditor"
+      src="https://letsenhance.io/static/73136da51c245e80edc6ccfe44888a99/1015f/MainBefore.jpg"
+    />
+
+    <div id="siteeditorButtons">
+      <div class="fred">
+        <div class="fred--launcher_center">
+          <div id="cropper-modal">
+            <div id="cropper-container">
+              <img id="cropper-image" src="" alt="Cropper Image" />
+              <div id="cropper-actions">
+                <button id="cropper-cancel">Annuler</button>
+                <button id="cropper-confirm">Cropper & Valider</button>
+              </div>
+            </div>
+          </div>
+
+          <div id="modalNseBackground">
+            <div id="modalNse">
+              <div id="uppy"></div>
+            </div>
+          </div>
+          <button
+            id="manager"
+            class="fred--launcher_btn fred--launcher_btn_manager"
+            role="button"
+            title="Manager"
+          ></button>
+          <button
+            id="undo"
+            onclick="document.execCommand(`undo`, ``, null)"
+            class="fred--launcher_btn fred--launcher_btn_undo"
+            role="button"
+            title="Undo"
+            style="visibility: hidden"
+          ></button>
+          <button
+            id="redo"
+            onclick="document.execCommand(`redo`, ``, null)"
+            class="fred--launcher_btn fred--launcher_btn_redo"
+            role="button"
+            title="Redo"
+            style="visibility: hidden"
+          ></button>
+          <button
+            id="view"
+            class="fred--launcher_btn fred--launcher_btn_view"
+            role="button"
+            title="Apercu"
+            style="visibility: hidden"
+          ></button>
+          <button
+            id="sidebarToggle"
+            class="fred--launcher_btn fred--launcher_btn_sidebarToggle"
+            role="button"
+            title="sidebarToggle"
+            style="visibility: hidden"
+          ></button>
+          <button
+            id="edit"
+            class="fred--launcher_btn fred--launcher_btn_edit"
+            role="button"
+            title="edit"
+          ></button>
+        </div>
+      </div>
+    </div>
+  </body>
+  <script defer src="./index.js" type="module"></script>
+</html>

+ 874 - 0
index.js

@@ -0,0 +1,874 @@
+/**
+ *
+ * newsiteeditor.js - gestion de l'interface de NewSiteEditor
+ *
+ * Modifications:
+ * - 2022/07/12 - V.1.0 0 - B.Bouaphakeo - création
+ * - 2025/04/14 - V1.0.1 - E.Podvin - fix hover when siteeditor is activated with tinymce
+ * - 2025/04/24 - V1.0.2 - C.Nelhomme - Fix prevent click problem and unclickable button + update Tinymce settings
+ *
+ * @copyright Intersel 2022
+ */
+//debugger;
+
+import {
+  Uppy,
+  Dashboard,
+  XHRUpload,
+} from "https://releases.transloadit.com/uppy/v4.13.3/uppy.min.mjs";
+let current = {};
+
+let NEWSITEEDITOR = (function () {
+  let version = "1.0.2";
+
+  //set data-data for content and title
+  function dataData(who) {
+    var obj = {};
+    var title;
+    var field = $(who).attr("field");
+    const sync = { syncsite: 1 };
+    //if(field === 'content'){
+    if (field !== "pagetitle" && field !== "longtitle") {
+      if (
+        who.innerHTML === "" ||
+        who.innerHTML.includes('<br data-mce-bogus="1">')
+      ) {
+        obj[field] = who.innerHTML;
+        //$(who).parents('.textcontent:first').hide(); //EPO: Why do we need to do that?
+      } else {
+        obj[field] = who.innerHTML;
+      }
+    } else {
+      if (
+        who.innerHTML === "" ||
+        who.innerHTML.includes('<br data-mce-bogus="1">')
+      ) {
+        title = { longtitle: "--" };
+        $(who).parents(".equalHeight:first").hide();
+      } else {
+        title = { longtitle: who.innerHTML };
+      }
+    }
+    Object.assign(obj, title);
+    Object.assign(obj, sync);
+    return $(who).attr("data-data", JSON.stringify(obj));
+  }
+
+  // REST : PUT method to put the content of the website in the manager
+  function saveContent() {
+    $(".siteeditor").blur(function () {
+      dataData(this);
+      blapyTools.ajaxSimpleAction(this);
+    });
+  }
+
+  // Settings available for the richtext editor
+  function TinyMCE() {
+    // debugger;
+    $.doTimeout("startTinyMCE", 200, function () {
+      tinymce.init({
+        selector: ".siteeditor",
+        inline: true,
+        plugins: "link, textcolor, table, preview",
+        menubar: false,
+        toolbar: [
+          "undo redo | bold italic underline | link unlink | fontselect fontsizeselect",
+          "forecolor backcolor | alignjustify alignleft aligncenter alignright alignfull | numlist bullist outdent indent |  table | styleselect",
+        ],
+        fontsize_formats: "8px 10px 12px 14px 18px 24px 26px 34px",
+
+        //,    valid_elements: 'p[style],strong,em,span[style],a[href],ul,ol,li'
+        //,    valid_styles: {'*': 'font-size,font-family,color,text-decoration,text-align'}
+        powerpaste_word_import: "clean",
+        powerpaste_html_import: "clean",
+        setup: function (editor) {
+          editor.on("click", function (el) {
+            el.preventDefault();
+            el.stopImmediatePropagation();
+          });
+          editor.on("keydown", function (el) {
+            if (
+              el.code === "ArrowRight" ||
+              el.code === "ArrowLeft" ||
+              el.code === "ArrowUp" ||
+              el.code === "ArrowDown"
+            ) {
+              el.stopPropagation();
+            }
+          });
+        },
+      }); //end init
+    }); //end dotimeout
+  }
+
+  //REST : Get method to get the title of the resource in sidebar
+  function getTitle(who) {
+    var transform = $("h2").css("text-transform");
+    $(who).prepend(
+      '<p id="resourceName" method="GET" style="text-transform:' +
+        transform +
+        ';"></p>'
+    );
+
+    hrefRestNse("#resourceName", "longtitle");
+    blapyTools.ajaxSimpleAction($("#resourceName"), function (data0) {
+      var title = data0.data.title;
+      if (title === "" || title == "--") {
+        hrefRestNse("#resourceName", "pagetitle");
+        blapyTools.ajaxSimpleAction($("#resourceName"), function (data1) {
+          var title1 = data1.data.title;
+          $("#resourceName").html(title1);
+          //console.log(title1+' '+3);
+        });
+      } else {
+        $("#resourceName").html(title);
+      }
+    });
+  }
+
+  // to put href attribut in 'who' element, with 'what' tv and the element id in the url
+  function hrefRestNse(who, what) {
+    /*var pos1 = $('[status="selected"]').attr("class").indexOf("_", $('[status="selected"]').attr("class").indexOf("_") + 1)+1;
+            var pos2 = $('[status="selected"]').attr("class").indexOf(" ") ;
+            var currentId = $('[status="selected"]').attr("class").substring(pos1, pos2);*/
+    var currentId = $('[status="selected"]').attr("data-resourceid");
+    $(who).attr("href", "/rest/newsiteeditor/" + what + "/" + currentId);
+  }
+
+  // toggle from edit mode to view mode
+  function view() {
+    $("#view").click(function () {
+      //remove attr conteneditable sinon bug avec tinyMCE
+      tinymce.remove();
+      tinymce.activeEditor.remove();
+      $(".mce-item-table").removeClass("mce-item-table");
+
+      $("#undo, #redo, #sidebarToggle, #manager, #view").css(
+        "visibility",
+        "hidden"
+      );
+      $("#wrapper").addClass("no-sidebar");
+      $("#edit").css("visibility", "");
+
+      $('[data-managerButton="true"]')
+        .removeClass("selected")
+        .removeAttr("status")
+        .attr("data-managerbutton", "false");
+
+      //Disable all contentEditable added by tinyMce
+      document.querySelectorAll("[contenteditable=true]").forEach((e) => {
+        e.removeAttribute("contenteditable");
+      });
+
+      onClickManager(false);
+      sidebar(false);
+      linkEnabled(true);
+    });
+  }
+
+  //désactiver les liens href sur sections
+  function linkEnabled(enableLink) {
+    if (enableLink) {
+      $(".siteeditor")
+        .parents("[data-hrefSave]")
+        .each(function () {
+          $(this).attr("href", $(this).attr("data-hrefSave"));
+          $(this).removeAttr("data-hrefSave");
+        });
+    } else {
+      $(".siteeditor")
+        .parents("[href]")
+        .each(function () {
+          $(this).attr("data-hrefSave", $(this).attr("href"));
+          $(this).removeAttr("href");
+        });
+    }
+  }
+
+  function preventClickEnabled(enableClick) {
+    let pointerEventsNoneClasses = document.getElementsByClassName(
+      enableClick ? "pointer-events-none" : "edit-pointer-event"
+    );
+    if (pointerEventsNoneClasses.length > 0) {
+      if (enableClick) {
+        Array.from(
+          document.getElementsByClassName("pointer-events-none")
+        ).forEach((e) => {
+          e.classList.remove("pointer-events-none");
+          e.classList.add("edit-pointer-event");
+        });
+      } else {
+        Array.from(
+          document.getElementsByClassName("edit-pointer-event")
+        ).forEach((e) => {
+          e.classList.add("pointer-events-none");
+          e.classList.remove("edit-pointer-event");
+        });
+      }
+    }
+  }
+
+  // toggle from view to edit mode
+  function edit() {
+    $("#edit").click(function () {
+      TinyMCE();
+      $(this).css("visibility", "hidden");
+
+      $("#undo, #redo, #sidebarToggle, #view, #manager").css("visibility", "");
+
+      /*$('section').each(function(){
+                          if ( $(this).attr("data-info") === "" ){
+                              var pos1 = this.getAttribute("class").indexOf("_", this.getAttribute("class").indexOf("_") + 1)+1;
+                              var pos2 = this.getAttribute("class").indexOf(" ") ;
+                              var currentId = this.getAttribute("class").substring(pos1, pos2);
+                              $(this).attr("data-info","managerButton_"+currentId);
+                          }
+                      });*/
+
+      $('[data-resourceid!=""][data-resourceid]').attr(
+        "data-managerbutton",
+        "true"
+      );
+
+      onClickManager(true);
+      preventClickEnabled(true);
+      sidebar(true);
+      linkEnabled(false);
+    });
+  }
+
+  // to set data-data after clicking undo button
+  function undo() {
+    $("#undo").click(function () {
+      $.doTimeout("TimeOut", 500, function () {
+        $(".siteeditor").each(function () {
+          var field = $(this).attr("field");
+          if (
+            $(this).attr("data-data") !=
+            '{"' + field + '":"' + this.innerHTML + '","syncsite":1}'
+          ) {
+            dataData(this);
+            blapyTools.ajaxSimpleAction(this);
+          }
+        });
+      });
+    });
+  }
+
+  // to set data-data after clicking redo button
+  function redo() {
+    $("#redo").click(function () {
+      $.doTimeout("TimeOut", 500, function () {
+        $(".siteeditor").each(function () {
+          var field = $(this).attr("field");
+          if (
+            $(this).attr("data-data") !=
+            '{"' + field + '":"' + this.innerHTML + '","syncsite":1}'
+          ) {
+            dataData(this);
+            blapyTools.ajaxSimpleAction(this);
+          }
+        });
+      });
+    });
+  }
+
+  // onHover on content you can edit
+  function onHover() {
+    $(".siteeditor").hover(
+      function () {
+        //debugger;
+        if (
+          $(this).attr("contenteditable") ==
+          "true" /*&& !($(this).is(":focus")) */
+        ) {
+          $(this)[0].style.setProperty(
+            "background-color",
+            "rgb(0, 0, 255, 0.1)",
+            "important"
+          );
+        }
+      },
+      function () {
+        if ($(this).attr("contenteditable") == "true") {
+          $(this).css("background-color", "");
+        }
+      }
+    );
+  }
+
+  // onHover on resource you can edit
+  function onHoverManager() {
+    $("section").hover(
+      function () {
+        if (
+          this.getAttribute("data-managerbutton") &&
+          this.getAttribute("data-managerbutton") == "true"
+        ) {
+          $(this).addClass("selected");
+        }
+      },
+      function () {
+        if (
+          this.getAttribute("data-managerbutton") &&
+          this.getAttribute("data-managerbutton") == "true" &&
+          !this.getAttribute("status")
+        ) {
+          $(this).removeClass("selected");
+        }
+      }
+    );
+  }
+
+  // display a manager button when clicking on a resource which redirected on the resource clicked manager
+  function onClickManager(mode) {
+    //debugger;
+    if (mode) {
+      $("#body").on("click.siteeditor", function (event) {
+        event.stopPropagation();
+        $('[status="selected"]').removeClass("selected").removeAttr("status");
+        $("#manager").css("visibility", "hidden").removeAttr("onclick");
+      });
+      $("section").on("click.siteeditor", function (event) {
+        //debugger;
+        event.stopPropagation();
+
+        $('[status="selected"]').removeClass("selected").removeAttr("status");
+        $("#manager").css("visibility", "hidden").attr("onclick", "");
+
+        if (
+          this.getAttribute("data-managerbutton") &&
+          this.getAttribute("data-managerbutton") == "true"
+        ) {
+          $(this).addClass("selected");
+          $(this).attr("status", "selected");
+          var currentId = this.getAttribute("data-resourceid");
+          $("#manager").attr(
+            "onclick",
+            "window.open('/manager/?a=resource/update&id=" + currentId + "');"
+          );
+          $("#manager").css("visibility", "visible");
+        }
+      });
+    } else {
+      $("#body").off("click.siteeditor");
+      $("section").off("click.siteeditor");
+    }
+  }
+
+  //toggle between sidebar and nosidebar
+  function sidebarDisplay(boolean) {
+    if (boolean) {
+      $("#noResourceSelected").css("display", "none");
+      $("#resourceSelected").css("display", "");
+    } else {
+      $("#noResourceSelected").css("display", "");
+      $("#resourceSelected").css("display", "none");
+    }
+  }
+
+  //When sidebar is open, display the info of the resource selected or "selectionner une ressource" if no resource selected
+  function sidebar(mode) {
+    if (mode) {
+      $("#body").on("click.sidebar", function () {
+        $("#resourceName").remove();
+        if ($("#wrapper").attr("class") !== "no-sidebar") {
+          sidebarDisplay(false);
+        }
+      });
+      $("section").on("click.sidebar", function (e) {
+        //debugger;
+        e.stopPropagation();
+        $("#resourceName").remove();
+        if (
+          $("#wrapper").attr("class") !== "no-sidebar" &&
+          this.getAttribute("data-resourceid")
+        ) {
+          getTitle("#resourceSelected");
+          getNbColumn();
+          getWidth();
+          getPadding();
+          sidebarDisplay(true);
+        } else {
+          sidebarDisplay(false);
+        }
+      });
+    } else {
+      $("#body").off("click.sidebar");
+      $("section").off("click.sidebar");
+    }
+  }
+
+  //Open the sidebar when clicking on the parameter button with the information of the current selected resource or "selectionner une resssource" if no selected resource
+  function sidebarToggle() {
+    $("#sidebarToggle").on("click", function () {
+      if ($("#wrapper").attr("class") == "no-sidebar") {
+        var compt = 0;
+        $("#resourceName").remove();
+        $("section").each(function () {
+          if ($(this).attr("status") == "selected") {
+            compt += 1;
+          }
+        });
+        if (compt > 0) {
+          getNbColumn();
+          getWidth();
+          getPadding();
+          getTitle("#resourceSelected");
+          sidebarDisplay(true);
+        } else {
+          sidebarDisplay(false);
+        }
+      }
+      $("#wrapper").toggleClass("no-sidebar");
+    });
+  }
+
+  // REST : get method to know how many column the resource already occupied
+  function getNbColumn() {
+    hrefRestNse("#column-select", "nbcolumn");
+    blapyTools.ajaxSimpleAction($("#column-select"), function (data) {
+      var bootstrap = data.data.nb;
+      var nbColumn;
+      if (bootstrap === null) {
+        nbColumn = 12;
+      } else {
+        pos3 = bootstrap.lastIndexOf("-");
+        nbColumn = bootstrap.substr(pos3 + 1);
+      }
+      $("#column-select").prop("value", nbColumn);
+    });
+  }
+
+  //REST : Method PUT when a new number of column is selected in sidebar
+  //       Change instantly the number of column on page
+  function putNbColumn() {
+    $("#column-select").change(function () {
+      var valueSelected = $("#column-select").val();
+      var bootstrap;
+      //version input number
+      if (valueSelected < 1) {
+        valueSelected = 1;
+        $("#column-select").attr("value", valueSelected);
+        bootstrap = "col-sm-1";
+      } else if (valueSelected >= 12) {
+        valueSelected = 12;
+        $("#column-select").attr("value", valueSelected);
+        bootstrap = null;
+      } else {
+        $("#column-select").attr("value", valueSelected);
+        bootstrap = "col-sm-" + valueSelected;
+      }
+      //envoyer le nombre de colonne au manager version number
+      hrefRestNse('[for="column-select"]', "nbcolumn");
+      if (bootstrap === null) {
+        $('[for="column-select"]').attr(
+          "data-data",
+          '{"tv_nbBootstrapColumn":' + bootstrap + ',"syncsite":1}'
+        );
+      } else {
+        $('[for="column-select"]').attr(
+          "data-data",
+          '{"tv_nbBootstrapColumn":"' + bootstrap + '","syncsite":1}'
+        );
+      }
+      blapyTools.ajaxSimpleAction($('[for="column-select"]'));
+      //dynamique sur la page
+      var pos3 = $('[status="selected"]').attr("class").indexOf("col-sm");
+      var pos4 = $('[status="selected"]')
+        .attr("class")
+        .indexOf(" ", pos3 + 1);
+      var currentBootstrap = $('[status="selected"]')
+        .attr("class")
+        .substr(pos3, pos4 - pos3);
+      if (currentBootstrap.startsWith("col-sm")) {
+        $('[status="selected"]')
+          .removeClass(currentBootstrap)
+          .removeClass("selected");
+      } else {
+        $('[status="selected"]').removeClass("selected");
+      }
+      $('[status="selected"]').addClass(bootstrap).addClass("selected");
+      if (bootstrap === null) {
+        $('[status="selected"]').css("clear", "");
+      } else {
+        $('[status="selected"]').css("clear", "none");
+      }
+    });
+  }
+
+  //REST : get method to get the managers width in the sidebar
+  function getWidth() {
+    hrefRestNse("#width", "width");
+    blapyTools.ajaxSimpleAction($("#width"), function (data) {
+      var percentage = data.data.width;
+      //console.log(percentage);
+      var width;
+      if (percentage === null) {
+        width = 100;
+      } else {
+        pos3 = percentage.indexOf("%");
+        width = percentage.substr(0, pos3);
+        //console.log(width);
+      }
+      $("#width").prop("value", width);
+    });
+  }
+
+  //REST : Method PUT when a new number of column is selected in sidebar
+  //       Change instantly the number of column on page
+  function putWidth() {
+    $("#width").change(function () {
+      var valueSelected = $("#width").val();
+      var percentage;
+      //version input
+      if (valueSelected < 10) {
+        valueSelected = 10;
+        $("#width").prop("value", valueSelected);
+        percentage = "10%";
+      } else if (valueSelected > 100) {
+        valueSelected = 100;
+        $("#width").prop("value", valueSelected);
+        percentage = "100%";
+      } else {
+        $("#width").prop("value", valueSelected);
+        percentage = valueSelected + "%";
+      }
+      //envoyer le nombre de colonne au manager version number
+      hrefRestNse('[for="width"]', "width");
+      if (percentage === "100%") {
+        $('[for="width"]').attr(
+          "data-data",
+          '{"tv_sectionWidth":' + null + ',"syncsite":1}'
+        );
+      } else {
+        $('[for="width"]').attr(
+          "data-data",
+          '{"tv_sectionWidth":"' + percentage + '","syncsite":1}'
+        );
+      }
+      blapyTools.ajaxSimpleAction($('[for="width"]'));
+      //dynamique sur la page
+      $('[status="selected"]').find("div:first").css("width", percentage);
+    });
+  }
+
+  //REST : get method to get the manager padding in the sidebar
+  function getPadding() {
+    hrefRestNse("#paddingTop", "padding");
+    blapyTools.ajaxSimpleAction($("#paddingTop"), function (data) {
+      var css = data.data.CSS;
+      //console.log(css);
+      var posTop1;
+      var posTop2;
+      var posTop3;
+      var paddingTop;
+      if (css !== null && css.includes("padding-top")) {
+        css = css.replace(/ /g, "");
+        posTop1 = css.indexOf("padding-top");
+        posTop2 = css.indexOf(":", posTop1 + 1);
+        posTop3 = css.indexOf(";", posTop1 + 1);
+        paddingTop = css.substr(posTop2 + 1, posTop3 - posTop2 - 1);
+        //console.log(paddingTop);
+        //$('#paddingTop').prop('value',paddingTop);
+        var paddingTop2;
+        if (paddingTop.includes("px")) {
+          $("#paddingTopUnit").prop("value", "px");
+          posTop4 = paddingTop.indexOf("px");
+          paddingTop2 = paddingTop.substr(0, posTop4);
+          //console.log(paddingTop2);
+        } else if (paddingTop.includes("%")) {
+          $("#paddingTopUnit").prop("value", "%");
+          posTop4 = paddingTop.indexOf("%");
+          paddingTop2 = paddingTop.substr(0, posTop4);
+        }
+        $("#paddingTop").prop("value", paddingTop2);
+        //console.log(paddingTop2);
+      } else {
+        $("#paddingTopUnit").prop("value", "px");
+        $("#paddingTop").prop("value", "");
+      }
+    });
+
+    hrefRestNse("#paddingBottom", "padding");
+    blapyTools.ajaxSimpleAction($("#paddingBottom"), function (data) {
+      var css = data.data.CSS;
+      //console.log(css);
+      var posBot1;
+      var posBot2;
+      var posBot3;
+      var paddingBottom;
+      if (css !== null && css.includes("padding-bottom")) {
+        css = css.replace(/ /g, "");
+        posBot1 = css.indexOf("padding-bottom");
+        posBot2 = css.indexOf(":", posBot1 + 1);
+        posBot3 = css.indexOf(";", posBot1 + 1);
+        paddingBottom = css.substr(posBot2 + 1, posBot3 - posBot2 - 1);
+        var paddingBottom2;
+        if (paddingBottom.includes("px")) {
+          posBot4 = paddingBottom.indexOf("px");
+          paddingBottom2 = paddingBottom.substr(0, posBot4);
+          $("#paddingBottomUnit").prop("value", "px");
+          //console.log(paddingTop2);
+        } else if (paddingBottom.includes("%")) {
+          posBot4 = paddingBottom.indexOf("%");
+          paddingBottom2 = paddingBottom.substr(0, posBot4);
+          $("#paddingBottomUnit").prop("value", "%");
+        }
+        $("#paddingBottom").prop("value", paddingBottom2);
+      } else {
+        $("#paddingBottomUnit").prop("value", "px");
+        $("#paddingBottom").prop("value", "");
+      }
+    });
+  }
+
+  // REST : put method to put the sidebar value in the manager
+  function putPadding() {
+    $(
+      "#paddingTop, #paddingBottom, #paddingTopUnit, #paddingBottomUnit"
+    ).change(function () {
+      let paddingTop = parseInt($("#paddingTop").val());
+      if (isNaN(paddingTop)) paddingTop = 0;
+      let unitTop = $("#paddingTopUnit").val();
+      let paddingBottom = parseInt($("#paddingBottom").val());
+      if (isNaN(paddingBottom)) paddingBottom = 0;
+      let unitBottom = $("#paddingBottomUnit").val();
+      if (paddingTop > 999) {
+        paddingTop = 999;
+        $("#paddingTop").prop("value", paddingTop);
+      } else if (paddingTop < 0) {
+        paddingTop = 0;
+        $("#paddingTop").prop("value", paddingTop);
+      }
+      if (paddingBottom > 999) {
+        paddingBottom = 999;
+        $("#paddingBottom").prop("value", paddingBottom);
+      } else if (paddingBottom < 0) {
+        paddingBottom = 0;
+        $("#paddingBottom").prop("value", paddingBottom);
+      }
+      //envoyer le nombre de colonne au manager version number
+      hrefRestNse('[for="padding"]', "padding");
+      $('[for="padding"]').attr(
+        "data-data",
+        '{"tv_sectionCSS":"padding-top:' +
+          paddingTop +
+          unitTop +
+          ";padding-bottom:" +
+          paddingBottom +
+          unitBottom +
+          ';","syncsite":1}'
+      );
+
+      if (paddingTop === 0 && paddingBottom === 0) {
+        $('[for="padding"]').attr(
+          "data-data",
+          '{"tv_sectionCSS":"","syncsite":1}'
+        );
+      } else if (paddingTop === 0) {
+        $('[for="padding"]').attr(
+          "data-data",
+          '{"tv_sectionCSS":"padding-bottom:' +
+            paddingBottom +
+            unitBottom +
+            ';","syncsite":1}'
+        );
+      }
+      blapyTools.ajaxSimpleAction($('[for="padding"]'));
+      //dynamique sur la page
+      if (
+        (paddingTop === 0 || paddingTop === "") &&
+        (paddingBottom === 0 || paddingBottom === "")
+      ) {
+        $('[status="selected"]').css("padding-top", "");
+        $('[status="selected"]').css("padding-bottom", "");
+      } else if (paddingTop === 0 || paddingTop === "") {
+        $('[status="selected"]').css("padding-top", "");
+        $('[status="selected"]').css(
+          "padding-bottom",
+          paddingBottom + unitBottom
+        );
+      } else if (paddingBottom === 0 || paddingBottom === "") {
+        $('[status="selected"]').css("padding-top", paddingTop + unitTop);
+        $('[status="selected"]').css("padding-bottom", "");
+      } else {
+        $('[status="selected"]').css("padding-top", paddingTop + unitTop);
+        $('[status="selected"]').css(
+          "padding-bottom",
+          paddingBottom + unitBottom
+        );
+      }
+    });
+  }
+
+  let cropper = null;
+  let pendingFile = null;
+  let aspectRatio;
+
+  function nseImageEditor() {
+    const uppy = new Uppy({
+      restrictions: {
+        maxNumberOfFiles: 1,
+        allowedFileTypes: ['.jpg', '.jpeg', '.png', '.gif', '.webp']
+      },
+    });
+
+    uppy.use(Dashboard, {
+      inline: true,
+      target: "#uppy",
+      showAddFilesButton: false,
+    });
+
+    uppy.on("file-added", (file) => {
+      if (file.meta.isCropped) {
+        return;
+      }
+
+      pendingFile = file;
+      openCropper(file);
+
+      return false;
+    });
+
+    uppy.on("complete", (file) => {
+      showNseModal(false);
+      uppy.cancelAll();
+      console.log(file);
+      current.element.src = "http://localhost/php/uploads/"+file.successful[0].meta.name;
+    });
+
+    //Initialiser l'endpoint pour l'upload des fichiers
+    uppy.use(XHRUpload, { endpoint: "http://localhost/php/index.php" });
+
+    const customButton = document.createElement("button");
+    customButton.innerText = "Edit";
+    customButton.style.position = "absolute";
+    customButton.style.display = "none";
+    customButton.id = "editImageBtn";
+    document.body.append(customButton);
+
+    customButton.onclick = () => showNseModal(true);
+
+    const modal = document.getElementById("modalNseBackground");
+
+    modal.addEventListener("click", (e) => {
+      if (e.target === modal) {
+        showNseModal(false);
+        closedModal();
+      }
+    });
+
+    document.querySelectorAll(".imageeditor").forEach((el) => {
+      el.addEventListener("click", (e) => {
+        el.style.border = "5px solid pink";
+
+        if (el.naturalHeight === 0) {
+            current.aspectRatio = 1;
+        } else {
+            current.aspectRatio = el.naturalWidth / el.naturalHeight;
+        }
+
+        current.element = el;
+
+        customButton.style.top = e.clientY + 10 + "px";
+        customButton.style.left = e.clientX + 10 + "px";
+        customButton.style.display = "block";
+      });
+    });
+
+    document.getElementById("cropper-cancel").addEventListener("click", () => {
+      document.getElementById("cropper-modal").classList.remove("active");
+      if (cropper) {
+        cropper.destroy();
+        cropper = null;
+      }
+      pendingFile = null;
+    });
+
+    document.getElementById("cropper-confirm").addEventListener("click", () => {
+      if (!cropper || !pendingFile) return;
+
+      cropper.getCroppedCanvas().toBlob((blob) => {
+        uppy.removeFile(pendingFile.id);
+
+
+        const ts = new Date()
+        .toISOString()
+        .replace(/[-:.]/g, '')       
+        .replace('Z', '');          
+
+        uppy.addFile({
+          name: ts+'.png',
+          type: pendingFile.type,
+          data: blob,
+          meta: {
+            isCropped: true,
+          },
+        });
+
+        // Nettoyage
+        document.getElementById("cropper-modal").classList.remove("active");
+        cropper.destroy();
+        cropper = null;
+        pendingFile = null;
+      }, pendingFile.type);
+    });
+  }
+
+  function openCropper(file) {
+    const reader = new FileReader();
+    reader.onload = (e) => {
+      const cropperImage = document.getElementById("cropper-image");
+      cropperImage.src = e.target.result;
+
+      document.getElementById("cropper-modal").classList.add("active");
+
+      if (cropper) {
+        cropper.destroy();
+      }
+
+      cropper = new Cropper(cropperImage, {
+        viewMode: 1,
+        aspectRatio: current.aspectRatio,
+        autoCropArea: 1,
+      });
+    };
+    reader.readAsDataURL(file.data);
+  }
+
+  function showNseModal(shouldShow) {
+    const modal = document.getElementById("modalNseBackground");
+    modal.style.display = shouldShow ? "flex" : "none";
+  }
+
+  // to set data-data for every element when opening the page
+  $(".siteeditor").each(function () {
+    dataData(this);
+  });
+
+  //window.addEventListener('DOMContentLoaded', newsiteeditor, false);
+  view();
+  edit();
+  onHover();
+  saveContent();
+  undo();
+  redo();
+  onHoverManager();
+  //onClickManager();
+  //sidebar();
+  sidebarToggle();
+  putNbColumn();
+  putWidth();
+  putPadding();
+  nseImageEditor();
+  //$('#body').off('click');
+  //$('section').off('click');
+
+  // define the public API
+  var API = {};
+  API.version = version;
+  // API.add = add;
+  // API.get_array = get_array;
+  return API;
+})();

+ 189 - 0
nse.css

@@ -0,0 +1,189 @@
+.fred .fred--launcher_center {
+    position: fixed;
+    width: 100%;
+    z-index: 04012002;
+    display: inline-block;
+    display: flex;
+    justify-content: center;
+    bottom: 3vh;
+}
+
+
+.fred .fred--launcher_btn {
+    border-radius: 50%;
+    border: none;
+    background: #b1b1b1 50% no-repeat;
+    background-size: 60%;
+    padding: 0;
+    height: 48px;
+    width: 48px;
+    box-shadow: 0 4px 8px rgba(39,39,39,.34);
+    transition: .3s;
+}
+
+.fred .fred--launcher_btn:hover {
+    transform: scale(1.05)
+}
+
+.fred .fred--launcher_btn_manager {
+    background-color: #549c89;
+    background-image: url("../images/860814.png");
+    position: absolute;
+    bottom: 65px;
+    left: 132px;
+    visibility : hidden;
+}/*visibility : hidden;*/
+
+/* Pour le bouton manager si message dans le bouton
+border-radius: 11px;
+    height: 48px;
+    width: 210px;
+    color: white;
+    font-size: 1.5vh;
+*/
+.fred .fred--launcher_btn_undo {
+    background-color: #ed673e;
+    background-image: url("../images/back1.png");
+    position: absolute;
+    bottom: 5px;
+    left: 73px;
+}
+
+.fred .fred--launcher_btn_redo {
+    background-color: #0132b5;
+    background-image: url("../images/back2.png");
+    position: absolute;
+    bottom: 5px;
+    left: 132px;
+}
+
+.fred .fred--launcher_btn_view {
+    background-color: #549c89;
+    background-image: url("../images/symbole-de-l-oeil-noir.png");
+    position: absolute;
+    bottom: 125px;
+    left: 73px;
+}
+
+.fred .fred--launcher_btn_edit {
+    background-color: #549c89;
+    background-image: url("../images/650143.png");
+    position: absolute;
+    bottom: 5px;
+}
+
+.fred .fred--launcher_btn_sidebarToggle {
+    position: absolute;
+    bottom: 65px ;
+    left: 73px ;
+    background-image: url("../images/Settings-icon-symbol-vector.png");
+    background-color : grey;
+}
+
+/*.selected{
+    box-shadow: 3px 6px 50px rgb(171 168 168 / 29%) !important;
+    border: 1mm solid #d8e6ef !important;
+}*/
+
+.selected{
+    box-shadow: 1px 2px 30px #b8c6ce !important;
+}
+
+#wrapper {
+    /*display: flex;*/
+    width: 100%;
+}
+
+#sidebarNewSiteEditor  {
+    position: fixed;
+    width: 250px;
+    /*background-image: linear-gradient(to right, #3f4850 0%, #365462 46%, #3e5554 60%, #42554d 68%, #573d4e 100%);*/
+    height : 100vh;
+    z-index: 04012001;
+    background-image: linear-gradient(to right, #3f4850 10%, #365462 100%);
+    box-shadow: 0 2px 0 #e4e4e4;
+}
+
+#body{
+    position: absolute;
+    right: 0;
+    width: calc(100% - 250px);
+}
+
+/*
+#topmenu {
+    position: absolute;
+    right: 0;
+}
+*/
+
+.no-sidebar #sidebarNewSiteEditor {
+    display: none;
+}
+
+.no-sidebar #body{
+    width: 100%;
+}
+
+/*
+.no-sidebar #topmenu{
+    width: 100%;
+} */
+
+#noResourceSelected{
+    margin-top: 30vh;
+    text-align: center;
+}
+
+#noResourceSelected p{
+    color: white;
+    font-family: "Helvetica Neue", Helvetica, Arial, Tahoma, sans-serif;
+}
+
+/*
+#noResource{
+    margin-top: 30vh;
+    text-align: center;
+    font-size: 37px;
+    font-weight: bold;
+    color: white;
+}*/
+
+#resourceName{
+    color: white;
+    overflow: hidden;
+    text-align: center;
+    margin-top: 6vh;
+    font: normal 24px "Helvetica Neue", Helvetica, Arial, Tahoma, sans-serif;
+}
+
+/*
+.listeDeroulante{
+    margin-left: 1vh;
+}
+*/
+
+.parametre{
+    padding: 12px;
+    font-size: 2vh;
+    margin-top: 4vh;
+}
+
+.labelInput{
+    color:white;
+    font: 16px "Helvetica Neue", Helvetica, Arial, Tahoma, sans-serif
+}
+
+.inputBox {
+    background-color: #FBFBFB;
+    background-image: none;
+    border-radius: 3px;
+    border: 1px solid #E4E4E4;
+    position: relative;
+    transition: border-color 0.25s;
+    font: 16px "Helvetica Neue", Helvetica, Arial, Tahoma, sans-serif
+}
+
+label[for="paddingTop"],[for="paddingBottom"]{
+    width:100%;
+}

+ 3 - 0
nseImageEditorImage.js

@@ -0,0 +1,3 @@
+
+
+

BIN=BIN
src/image (1).png