Index: plugins/dcLegacyEditor/js/jsToolBar/jsToolBar.wysiwyg.js
===================================================================
--- plugins/dcLegacyEditor/js/jsToolBar/jsToolBar.wysiwyg.js	(revision 3736)
+++ plugins/dcLegacyEditor/js/jsToolBar/jsToolBar.wysiwyg.js	(revision 3880)
@@ -64,10 +64,10 @@
 jsToolBar.prototype.syncContents = function(from) {
   from = from || 'textarea';
-  var This = this;
+  const This = this;
   if (from == 'textarea') {
     initContent();
   } else {
     this.validBlockquote();
-    var html = this.applyHtmlFilters(this.ibody.innerHTML);
+    let html = this.applyHtmlFilters(this.ibody.innerHTML);
     if (html == '<br />') {
       html = '<p></p>';
@@ -86,5 +86,5 @@
       This.ibody.innerHTML = This.applyWysiwygFilters(This.textarea.value);
       if (This.ibody.createTextRange) { //cursor at the begin for IE
-        var IErange = This.ibody.createTextRange();
+        const IErange = This.ibody.createTextRange();
         IErange.execCommand("SelectAll");
         IErange.collapse();
@@ -92,6 +92,6 @@
       }
     } else {
-      var idoc = This.iwin.document;
-      var para = idoc.createElement('p');
+      const idoc = This.iwin.document;
+      const para = idoc.createElement('p');
       para.appendChild(idoc.createElement('br'));
       while (idoc.body.hasChildNodes()) {
@@ -108,5 +108,5 @@
 };
 jsToolBar.prototype.applyHtmlFilters = function(str) {
-  for (var fn in this.htmlFilters) {
+  for (let fn in this.htmlFilters) {
     str = this.htmlFilters[fn].call(this, str);
   }
@@ -115,5 +115,5 @@
 jsToolBar.prototype.wysiwygFilters = {};
 jsToolBar.prototype.applyWysiwygFilters = function(str) {
-  for (var fn in this.wysiwygFilters) {
+  for (let fn in this.wysiwygFilters) {
     str = this.wysiwygFilters[fn].call(this, str);
   }
@@ -143,5 +143,5 @@
  */
 jsToolBar.prototype.initWindow = function() {
-  var This = this;
+  const This = this;
 
   this.iframe = document.createElement('iframe');
@@ -160,5 +160,5 @@
 
   function initIframe() {
-    var doc = This.iframe.contentWindow.document;
+    const doc = This.iframe.contentWindow.document;
     if (!doc) {
       setTimeout(initIframe, 1);
@@ -167,14 +167,13 @@
 
     doc.open();
-    var html =
-      '<html>\n' +
-      '<head>\n' +
-      '<link rel="stylesheet" href="style/default.css" type="text/css" media="screen" />' +
-      '<style type="text/css">' + This.iframe_css + '</style>\n' +
-      (This.base_url != '' ? '<base href="' + This.base_url + '" />' : '') +
-      '</head>\n' +
-      '<body>\n' +
-      '</body>\n' +
-      '</html>';
+    const html =
+`<html>
+  <head>
+    <link rel="stylesheet" href="style/default.css" type="text/css" media="screen" />
+    <style type="text/css">${This.iframe_css}</style>
+    ${This.base_url != '' ? `<base href="${This.base_url}" />` : ''}
+  </head>
+  <body></body>
+</html>`;
 
     doc.write(html);
@@ -212,6 +211,6 @@
     }
 
-    for (var evt in This.iwinEvents) {
-      var event = This.iwinEvents[evt];
+    for (let evt in This.iwinEvents) {
+      const event = This.iwinEvents[evt];
       This.addIwinEvent(This.iframe.contentWindow.document, event.type, event.fn, This);
     }
@@ -227,5 +226,5 @@
 };
 jsToolBar.prototype.addIwinEvent = function(target, type, fn, scope) {
-  var myFn = function(e) {
+  const myFn = function(e) {
     fn.call(scope, e);
   };
@@ -260,9 +259,9 @@
   }
 
-  var This = this;
+  const This = this;
 
   function setLink(title, link) {
-    var li = document.createElement('li');
-    var a;
+    const li = document.createElement('li');
+    let a;
     if (link) {
       a = document.createElement('a');
@@ -307,5 +306,5 @@
       this.iwin.document.designMode = 'on';
     } catch (e) {} // Firefox needs this
-    var This = this;
+    const This = this;
     setTimeout(function() {
       This.iframe.contentWindow.focus();
@@ -326,5 +325,5 @@
 };
 jsToolBar.prototype.resizeDragMove = function(event) {
-  var new_height = (this.dragStartH + event.clientY - this.dragStartY) + 'px';
+  const new_height = `${this.dragStartH + event.clientY - this.dragStartY}px`;
   if (this.iframe != undefined) {
     this.iframe.style.height = new_height;
@@ -338,8 +337,8 @@
  */
 jsToolBar.prototype.insertNode = function(node) {
-  var range;
+  let range;
 
   if (this.iwin.getSelection) { // Gecko
-    var sel = this.iwin.getSelection();
+    const sel = this.iwin.getSelection();
     range = sel.getRangeAt(0);
 
@@ -366,5 +365,5 @@
   } else { // IE
     // lambda element
-    var p = this.iwin.document.createElement('div');
+    const p = this.iwin.document.createElement('div');
     p.appendChild(node);
     range = this.iwin.document.selection.createRange();
@@ -381,16 +380,16 @@
  */
 jsToolBar.prototype.getSelectedNode = function() {
-  var sel;
+  let sel;
   var content;
   if (this.iwin.getSelection) { // Gecko
     sel = this.iwin.getSelection();
-    var range = sel.getRangeAt(0);
+    const range = sel.getRangeAt(0);
     content = range.cloneContents();
   } else { // IE
     sel = this.iwin.document.selection;
-    var d = this.iwin.document.createElement('div');
+    const d = this.iwin.document.createElement('div');
     d.innerHTML = sel.createRange().htmlText;
     content = this.iwin.document.createDocumentFragment();
-    for (var i = 0; i < d.childNodes.length; i++) {
+    for (let i = 0; i < d.childNodes.length; i++) {
       content.appendChild(d.childNodes[i].cloneNode(true));
     }
@@ -405,5 +404,5 @@
     return this.iwin.getSelection().toString();
   } else { // IE
-    var range = this.iwin.document.selection.createRange();
+    const range = this.iwin.document.selection.createRange();
     return range.text;
   }
@@ -411,6 +410,6 @@
 
 jsToolBar.prototype.replaceNodeByContent = function(node) {
-  var content = this.iwin.document.createDocumentFragment();
-  for (var i = 0; i < node.childNodes.length; i++) {
+  const content = this.iwin.document.createDocumentFragment();
+  for (let i = 0; i < node.childNodes.length; i++) {
     content.appendChild(node.childNodes[i].cloneNode(true));
   }
@@ -419,9 +418,10 @@
 
 jsToolBar.prototype.getBlockLevel = function() {
-  var blockElts = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
-
-  var range, commonAncestorContainer;
+  const blockElts = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
+
+  let range;
+  let commonAncestorContainer;
   if (this.iwin.getSelection) { //gecko
-    var selection = this.iwin.getSelection();
+    const selection = this.iwin.getSelection();
     range = selection.getRangeAt(0);
     commonAncestorContainer = range.commonAncestorContainer;
@@ -434,5 +434,5 @@
   }
 
-  var ancestorTagName = commonAncestorContainer.tagName.toLowerCase();
+  let ancestorTagName = commonAncestorContainer.tagName.toLowerCase();
   while (arrayIndexOf(blockElts, ancestorTagName) == -1 && ancestorTagName != 'body') {
     commonAncestorContainer = commonAncestorContainer.parentNode;
@@ -443,5 +443,5 @@
 };
 jsToolBar.prototype.adjustBlockLevelCombo = function() {
-  var blockLevel = this.getBlockLevel();
+  const blockLevel = this.getBlockLevel();
   if (blockLevel !== null)
     this.toolNodes.blocks.value = blockLevel.tagName.toLowerCase();
@@ -471,5 +471,5 @@
  */
 jsToolBar.prototype.tagsoup2xhtml = function(html) {
-  for (var reg in this.simpleCleanRegex) {
+  for (let reg in this.simpleCleanRegex) {
     html = html.replace(this.simpleCleanRegex[reg][0], this.simpleCleanRegex[reg][1]);
   }
@@ -488,7 +488,7 @@
 
   /* IE laisse souvent des attributs sans guillemets */
-  var myRegexp = /<[^>]+((\s+\w+\s*=\s*)([^"'][\w~@+$,%\/:.#?=&;!*()-]*))[^>]*?>/;
-  var myQuoteFn = function(str, val1, val2, val3) {
-    var tamponRegex = new RegExp(regexpEscape(val1));
+  const myRegexp = /<[^>]+((\s+\w+\s*=\s*)([^"'][\w~@+$,%\/:.#?=&;!*()-]*))[^>]*?>/;
+  const myQuoteFn = function(str, val1, val2, val3) {
+    const tamponRegex = new RegExp(regexpEscape(val1));
     return str.replace(tamponRegex, val2 + '"' + val3 + '"');
   };
@@ -508,5 +508,5 @@
 
   /* Trim only if there's no pre tag */
-  var pattern_pre = /<pre>[\s\S]*<\/pre>/gi;
+  const pattern_pre = /<pre>[\s\S]*<\/pre>/gi;
   if (!pattern_pre.test(html)) {
     html = html.replace(/^\s+/gm, '');
@@ -517,15 +517,15 @@
 };
 jsToolBar.prototype.validBlockquote = function() {
-  var blockElts = ['address', 'blockquote', 'dl', 'div', 'fieldset', 'form', 'h1',
+  const blockElts = ['address', 'blockquote', 'dl', 'div', 'fieldset', 'form', 'h1',
     'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'ol', 'p', 'pre', 'table', 'ul'
   ];
-  var BQs = this.iwin.document.getElementsByTagName('blockquote');
-  var bqChilds;
-  var p;
-
-  for (var bq = 0; bq < BQs.length; bq++) {
+  const BQs = this.iwin.document.getElementsByTagName('blockquote');
+  let bqChilds;
+  let p;
+
+  for (let bq = 0; bq < BQs.length; bq++) {
     bqChilds = BQs[bq].childNodes;
-    var frag = this.iwin.document.createDocumentFragment();
-    for (var i = (bqChilds.length - 1); i >= 0; i--) {
+    let frag = this.iwin.document.createDocumentFragment();
+    for (let i = (bqChilds.length - 1); i >= 0; i--) {
       if (bqChilds[i].nodeType == 1 && // Node.ELEMENT_NODE
         arrayIndexOf(blockElts, bqChilds[i].tagName.toLowerCase()) >= 0) {
@@ -561,5 +561,5 @@
 
 jsToolBar.prototype.removeTextFormating = function(html) {
-  for (var reg in this.removeFormatRegexp) {
+  for (let reg in this.removeFormatRegexp) {
     html = html.replace(this.removeFormatRegexp[reg][0], this.removeFormatRegexp[reg][1]);
   }
@@ -576,5 +576,5 @@
   fn: function(opt) {
     if (opt == 'none') {
-      var blockLevel = this.getBlockLevel();
+      const blockLevel = this.getBlockLevel();
       if (blockLevel !== null) {
         this.replaceNodeByContent(blockLevel);
@@ -611,6 +611,6 @@
 
 jsToolBar.prototype.elements.quote.fn.wysiwyg = function() {
-  var n = this.getSelectedNode();
-  var q = this.iwin.document.createElement('q');
+  const n = this.getSelectedNode();
+  const q = this.iwin.document.createElement('q');
   q.appendChild(n);
   this.insertNode(q);
@@ -618,6 +618,6 @@
 
 jsToolBar.prototype.elements.code.fn.wysiwyg = function() {
-  var n = this.getSelectedNode();
-  var code = this.iwin.document.createElement('code');
+  const n = this.getSelectedNode();
+  const code = this.iwin.document.createElement('code');
   code.appendChild(n);
   this.insertNode(code);
@@ -625,6 +625,6 @@
 
 jsToolBar.prototype.elements.mark.fn.wysiwyg = function() {
-  var n = this.getSelectedNode();
-  var mark = this.iwin.document.createElement('mark');
+  const n = this.getSelectedNode();
+  const mark = this.iwin.document.createElement('mark');
   mark.appendChild(n);
   this.insertNode(mark);
@@ -632,11 +632,11 @@
 
 jsToolBar.prototype.elements.br.fn.wysiwyg = function() {
-  var n = this.iwin.document.createElement('br');
+  const n = this.iwin.document.createElement('br');
   this.insertNode(n);
 };
 
 jsToolBar.prototype.elements.blockquote.fn.wysiwyg = function() {
-  var n = this.getSelectedNode();
-  var q = this.iwin.document.createElement('blockquote');
+  const n = this.getSelectedNode();
+  const q = this.iwin.document.createElement('blockquote');
   q.appendChild(n);
   this.insertNode(q);
@@ -659,8 +659,10 @@
 
 jsToolBar.prototype.elements.link.fn.wysiwyg = function() {
-  var href, hreflang;
-  var range, commonAncestorContainer;
+  let href;
+  let hreflang;
+  let range;
+  let commonAncestorContainer;
   if (this.iwin.getSelection) { //gecko
-    var selection = this.iwin.getSelection();
+    const selection = this.iwin.getSelection();
     range = selection.getRangeAt(0);
     commonAncestorContainer = range.commonAncestorContainer;
@@ -673,5 +675,5 @@
   }
 
-  var ancestorTagName = commonAncestorContainer.tagName.toLowerCase();
+  let ancestorTagName = commonAncestorContainer.tagName.toLowerCase();
   while (ancestorTagName != 'a' && ancestorTagName != 'body') {
     commonAncestorContainer = commonAncestorContainer.parentNode;
@@ -707,6 +709,6 @@
 
   // Create link
-  var n = this.getSelectedNode();
-  var a = this.iwin.document.createElement('a');
+  const n = this.getSelectedNode();
+  const a = this.iwin.document.createElement('a');
   a.href = href;
   if (hreflang) a.setAttribute('hreflang', hreflang);
@@ -723,10 +725,10 @@
 jsToolBar.prototype.elements.removeFormat.disabled = !jsToolBar.prototype.can_wwg;
 jsToolBar.prototype.elements.removeFormat.fn.xhtml = function() {
-  var html = this.textarea.value;
+  let html = this.textarea.value;
   html = this.removeTextFormating(html);
   this.textarea.value = html;
 };
 jsToolBar.prototype.elements.removeFormat.fn.wysiwyg = function() {
-  var html = this.iwin.document.body.innerHTML;
+  let html = this.iwin.document.body.innerHTML;
   html = this.removeTextFormating(html);
   this.iwin.document.body.innerHTML = html;
@@ -738,7 +740,7 @@
     return aArray.indexOf(aValue);
   } else {
-    var index = -1;
-    var l = aArray.length;
-    for (var i = 0; i < l; i++) {
+    let index = -1;
+    const l = aArray.length;
+    for (let i = 0; i < l; i++) {
       if (aArray[i] === aValue) {
         index = i;
@@ -755,5 +757,5 @@
     return true;
   } else if (obj.attachEvent) {
-    var r = obj.attachEvent("on" + evType, fn);
+    const r = obj.attachEvent("on" + evType, fn);
     return r;
   } else {
@@ -767,5 +769,5 @@
     return true;
   } else if (obj.detachEvent) {
-    var r = obj.detachEvent("on" + evType, fn);
+    const r = obj.detachEvent("on" + evType, fn);
     return r;
   } else {
