Dotclear


Ignore:
Timestamp:
09/18/18 20:22:10 (7 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Use let and const rather than var (ES2015/ES6), use template string where is more efficient

Location:
plugins/dcLegacyEditor/js/jsToolBar
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • plugins/dcLegacyEditor/js/jsToolBar/jsToolBar.dotclear.js

    r3735 r3880  
    1313 
    1414  this.elements.link.data = {}; 
    15   var url = this.elements.link.open_url + args; 
     15  const url = this.elements.link.open_url + args; 
    1616 
    1717  window.open(url, 'dc_popup', 
     
    2424}; 
    2525jsToolBar.prototype.elements.link.fncall.wiki = function() { 
    26   var data = this.elements.link.data; 
     26  const data = this.elements.link.data; 
    2727 
    2828  if (data.href == '') { 
     
    3030  } 
    3131 
    32   var etag = '|' + data.href; 
     32  let etag = '|' + data.href; 
    3333  if (data.hreflang) { 
    3434    etag += '|' + data.hreflang; 
     
    4343 
    4444  if (data.content) { 
    45     this.encloseSelection('[' + data.content, etag + ']'); 
     45    this.encloseSelection(`[${data.content}`, `${etag}]`); 
    4646  } else { 
    47     this.encloseSelection('[', etag + ']'); 
     47    this.encloseSelection('[', `${etag}]`); 
    4848  } 
    4949}; 
    5050 
    5151jsToolBar.prototype.elements.link.fn.xhtml = function() { 
    52   this.elements.link.popup.call(this, '&hreflang=' + this.elements.link.default_hreflang); 
     52  this.elements.link.popup.call(this, `&hreflang=${this.elements.link.default_hreflang}`); 
    5353}; 
    5454jsToolBar.prototype.elements.link.fncall.xhtml = function() { 
    55   var data = this.elements.link.data; 
     55  const data = this.elements.link.data; 
    5656 
    5757  if (data.href == '') { 
     
    5959  } 
    6060 
    61   var stag = '<a href="' + data.href + '"'; 
     61  let stag = `<a href="${data.href}"`; 
    6262 
    6363  if (data.hreflang) { 
    64     stag += ' hreflang="' + data.hreflang + '"'; 
     64    stag += ` hreflang="${data.hreflang}"`; 
    6565  } 
    6666  if (data.title) { 
    67     stag += ' title="' + data.title + '"'; 
     67    stag += ` title="${data.title}"`; 
    6868  } 
    6969  stag += '>'; 
    70   var etag = '</a>'; 
     70  const etag = '</a>'; 
    7171 
    7272  if (data.content) { 
     
    8080 
    8181jsToolBar.prototype.elements.link.fn.wysiwyg = function() { 
    82   var href, title, hreflang; 
     82  let href; 
     83  let title; 
     84  let hreflang; 
    8385  href = title = hreflang = ''; 
    8486  hreflang = this.elements.link.default_hreflang; 
     
    9294  } 
    9395 
    94   this.elements.link.popup.call(this, '&href=' + href + '&hreflang=' + hreflang + '&title=' + title); 
     96  this.elements.link.popup.call(this, `&href=${href}&hreflang=${hreflang}&title=${title}`); 
    9597}; 
    9698jsToolBar.prototype.elements.link.fncall.wysiwyg = function() { 
    97   var data = this.elements.link.data; 
    98  
    99   var a = this.getAncestor(); 
     99  const data = this.elements.link.data; 
     100 
     101  let a = this.getAncestor(); 
    100102 
    101103  if (a.tagName == 'a') { 
     
    123125 
    124126  // Create link 
    125   var n; 
     127  let n; 
    126128  if (data.content) { 
    127129    n = document.createTextNode(data.content); 
     
    137139}; 
    138140jsToolBar.prototype.getAncestor = function() { 
    139   var res = {}; 
    140   var range, commonAncestorContainer; 
     141  let res = {}; 
     142  let range; 
     143  let commonAncestorContainer; 
    141144 
    142145  if (this.iwin.getSelection) { //gecko 
    143     var selection = this.iwin.getSelection(); 
     146    const selection = this.iwin.getSelection(); 
    144147    range = selection.getRangeAt(0); 
    145148    commonAncestorContainer = range.commonAncestorContainer; 
     
    152155  } 
    153156 
    154   var ancestorTagName = commonAncestorContainer.tagName.toLowerCase(); 
     157  let ancestorTagName = commonAncestorContainer.tagName.toLowerCase(); 
    155158  while (ancestorTagName != 'a' && ancestorTagName != 'body') { 
    156159    commonAncestorContainer = commonAncestorContainer.parentNode; 
     
    193196 
    194197  this.encloseSelection('', '', function(str) { 
    195     var alt = (str) ? str : d.title; 
    196     var res = '((' + d.src + '|' + alt; 
     198    const alt = (str) ? str : d.title; 
     199    let res = `((${d.src}|${alt}`; 
    197200 
    198201    if (d.alignment == 'left') { 
     
    207210 
    208211    if (d.description) { 
    209       res += '|' + d.description; 
     212      res += `|${d.description}`; 
    210213    } 
    211214 
     
    213216 
    214217    if (d.link) { 
    215       var ltitle = (alt) ? '||' + alt : ''; 
    216       res = '[' + res + '|' + d.url + ltitle + ']'; 
     218      res = `[${res}|${d.url}${(alt) ? `||${alt}` : ''}]`; 
    217219    } 
    218220 
     
    224226}; 
    225227jsToolBar.prototype.elements.img_select.fncall.xhtml = function() { 
    226   var d = this.elements.img_select.data; 
     228  const d = this.elements.img_select.data; 
    227229  if (d.src == undefined) { 
    228230    return; 
     
    230232 
    231233  this.encloseSelection('', '', function(str) { 
    232     var alt = (str) ? str : d.title; 
    233     var res = '<img src="' + d.src + '" alt="' + alt.replace('&', '&amp;').replace('>', '&gt;').replace('<', '&lt;').replace('"', '&quot;') + '"'; 
     234    const alt = (str) ? str : d.title; 
     235    let res = `<img src="${d.src}" alt="${alt.replace('&', '&amp;').replace('>', '&gt;').replace('<', '&lt;').replace('"', '&quot;')}"`; 
    234236 
    235237    if (d.alignment == 'left') { 
     
    242244 
    243245    if (d.description) { 
    244       res += ' title="' + d.description.replace('&', '&amp;').replace('>', '&gt;').replace('<', '&lt;').replace('"', '&quot;') + '"'; 
     246      res += ` title="${d.description.replace('&', '&amp;').replace('>', '&gt;').replace('<', '&lt;').replace('"', '&quot;')}"`; 
    245247    } 
    246248 
     
    248250 
    249251    if (d.link) { 
    250       var ltitle = (alt) ? ' title="' + alt.replace('&', '&amp;').replace('>', '&gt;').replace('<', '&lt;').replace('"', '&quot;') + '"' : ''; 
    251       res = '<a href="' + d.url + '"' + ltitle + '>' + res + '</a>'; 
     252      const ltitle = (alt) ? ` title="${alt.replace('&', '&amp;').replace('>', '&gt;').replace('<', '&lt;').replace('"', '&quot;')}"` : ''; 
     253      res = `<a href="${d.url}"${ltitle}>${res}</a>`; 
    252254    } 
    253255 
     
    257259 
    258260jsToolBar.prototype.elements.img.fn.wysiwyg = function() { 
    259   var src = this.elements.img.prompt.call(this); 
     261  const src = this.elements.img.prompt.call(this); 
    260262  if (!src) { 
    261263    return; 
    262264  } 
    263265 
    264   var img = this.iwin.document.createElement('img'); 
     266  const img = this.iwin.document.createElement('img'); 
    265267  img.src = src; 
    266268  img.setAttribute('alt', this.getSelectedText()); 
     
    273275}; 
    274276jsToolBar.prototype.elements.img_select.fncall.wysiwyg = function() { 
    275   var d = this.elements.img_select.data; 
    276   var alt = (this.getSelectedText()) ? this.getSelectedText() : d.title; 
     277  const d = this.elements.img_select.data; 
     278  const alt = (this.getSelectedText()) ? this.getSelectedText() : d.title; 
    277279  if (d.src == undefined) { 
    278280    return; 
    279281  } 
    280282 
    281   var img = this.iwin.document.createElement('img'); 
     283  const img = this.iwin.document.createElement('img'); 
    282284  img.src = d.src; 
    283285  img.setAttribute('alt', alt); 
     
    316318 
    317319  if (d.link) { 
    318     var a = this.iwin.document.createElement('a'); 
     320    const a = this.iwin.document.createElement('a'); 
    319321    a.href = d.url; 
    320322    if (alt) { 
     
    334336}; 
    335337jsToolBar.prototype.elements.mp3_insert.fncall.wiki = function() { 
    336   var d = this.elements.mp3_insert.data; 
     338  const d = this.elements.mp3_insert.data; 
    337339  if (d.player == undefined) { 
    338340    return; 
     
    344346}; 
    345347jsToolBar.prototype.elements.mp3_insert.fncall.xhtml = function() { 
    346   var d = this.elements.mp3_insert.data; 
     348  const d = this.elements.mp3_insert.data; 
    347349  if (d.player == undefined) { 
    348350    return; 
     
    363365}; 
    364366jsToolBar.prototype.elements.flv_insert.fncall.wiki = function() { 
    365   var d = this.elements.flv_insert.data; 
     367  const d = this.elements.flv_insert.data; 
    366368  if (d.player == undefined) { 
    367369    return; 
     
    373375}; 
    374376jsToolBar.prototype.elements.flv_insert.fncall.xhtml = function() { 
    375   var d = this.elements.flv_insert.data; 
     377  const d = this.elements.flv_insert.data; 
    376378  if (d.player == undefined) { 
    377379    return; 
  • plugins/dcLegacyEditor/js/jsToolBar/jsToolBar.js

    r3735 r3880  
    2424 */ 
    2525 
    26 var jsToolBar = function(textarea) { 
     26const jsToolBar = function(textarea) { 
    2727  if (!document.createElement) { 
    2828    return; 
     
    5959      this.handle = document.createElement('div'); 
    6060      this.handle.className = 'jstHandle'; 
    61       var dragStart = this.resizeDragStart; 
    62       var This = this; 
     61      const dragStart = this.resizeDragStart; 
     62      const This = this; 
    6363      this.handle.addEventListener('mousedown', function(event) { 
    6464        dragStart.call(This, event); 
     
    7373}; 
    7474 
    75 var jsButton = function(title, fn, scope, className, accesskey) { 
     75const jsButton = function(title, fn, scope, className, accesskey) { 
    7676  this.title = title || null; 
    7777  this.fn = fn || function() {}; 
     
    8383  if (!this.scope) return null; 
    8484 
    85   var button = document.createElement('button'); 
     85  const button = document.createElement('button'); 
    8686  button.setAttribute('type', 'button'); 
    8787  if (this.className) button.className = this.className; 
    8888  button.title = this.title; 
    8989  if (this.accesskey) button.accessKey = this.accesskey; 
    90   var span = document.createElement('span'); 
     90  const span = document.createElement('span'); 
    9191  span.appendChild(document.createTextNode(this.title)); 
    9292  button.appendChild(span); 
     
    9696  } 
    9797  if (typeof(this.fn) == 'function') { 
    98     var This = this; 
     98    const This = this; 
    9999    button.onclick = function() { 
    100100      try { 
     
    107107}; 
    108108 
    109 var jsSpace = function(id) { 
     109const jsSpace = function(id) { 
    110110  this.id = id || null; 
    111111  this.width = null; 
    112112}; 
    113113jsSpace.prototype.draw = function() { 
    114   var span = document.createElement('span'); 
     114  const span = document.createElement('span'); 
    115115  if (this.id) span.id = this.id; 
    116116  span.appendChild(document.createTextNode(String.fromCharCode(160))); 
     
    121121}; 
    122122 
    123 var jsCombo = function(title, options, scope, fn, className) { 
     123const jsCombo = function(title, options, scope, fn, className) { 
    124124  this.title = title || null; 
    125125  this.options = options || null; 
     
    131131  if (!this.scope || !this.options) return null; 
    132132 
    133   var select = document.createElement('select'); 
     133  const select = document.createElement('select'); 
    134134  if (this.className) select.className = this.className; 
    135135  select.title = this.title; 
    136136 
    137   for (var o in this.options) { 
     137  for (let o in this.options) { 
    138138    //var opt = this.options[o]; 
    139     var option = document.createElement('option'); 
     139    const option = document.createElement('option'); 
    140140    option.value = o; 
    141141    option.appendChild(document.createTextNode(this.options[o])); 
     
    143143  } 
    144144 
    145   var This = this; 
     145  const This = this; 
    146146  select.onchange = function() { 
    147147    try { 
     
    177177 
    178178  button: function(toolName) { 
    179     var tool = this.elements[toolName]; 
     179    const tool = this.elements[toolName]; 
    180180    if (typeof tool.fn[this.mode] != 'function') return null; 
    181     var b = new jsButton(tool.title, tool.fn[this.mode], this, 'jstb_' + toolName, tool.accesskey); 
     181    const b = new jsButton(tool.title, tool.fn[this.mode], this, 'jstb_' + toolName, tool.accesskey); 
    182182    if (tool.icon != undefined) { 
    183183      b.icon = tool.icon; 
     
    186186  }, 
    187187  space: function(toolName) { 
    188     var tool = new jsSpace(toolName); 
     188    const tool = new jsSpace(toolName); 
    189189    if (this.elements[toolName].format != undefined && !this.elements[toolName].format[this.mode]) return null; 
    190190    if (this.elements[toolName].width !== undefined) { 
     
    194194  }, 
    195195  combo: function(toolName) { 
    196     var tool = this.elements[toolName]; 
     196    const tool = this.elements[toolName]; 
    197197 
    198198    if (tool[this.mode] != undefined) { 
    199199 
    200       var length = tool[this.mode].list.length; 
     200      const length = tool[this.mode].list.length; 
    201201 
    202202      if (typeof tool[this.mode].fn != 'function' || length == 0) { 
    203203        return null; 
    204204      } else { 
    205         var options = {}; 
    206         for (var i = 0; i < length; i++) { 
    207           var opt = tool[this.mode].list[i]; 
     205        let options = {}; 
     206        for (let i = 0; i < length; i++) { 
     207          const opt = tool[this.mode].list[i]; 
    208208          options[opt] = tool.options[opt]; 
    209209        } 
     
    224224 
    225225    // Draw toolbar elements 
    226     var b, tool, newTool; 
    227  
    228     for (var i in this.elements) { 
     226    let b; 
     227    let tool; 
     228    let newTool; 
     229 
     230    for (let i in this.elements) { 
    229231      b = this.elements[i]; 
    230232 
    231       var disabled = 
     233      const disabled = 
    232234        b.type == undefined || b.type == '' || 
    233235        (b.disabled != undefined && b.disabled) || 
     
    262264    suffix = suffix || ''; 
    263265 
    264     var start, end, sel, scrollPos, subst, res; 
     266    let start; 
     267    let end; 
     268    let sel; 
     269    let scrollPos; 
     270    let subst; 
     271    let res; 
    265272 
    266273    if (typeof(document.selection) != "undefined") { 
     
    305312  stripBaseURL: function(url) { 
    306313    if (this.base_url != '') { 
    307       var pos = url.indexOf(this.base_url); 
     314      const pos = url.indexOf(this.base_url); 
    308315      if (pos == 0) { 
    309316        url = url.substr(this.base_url.length); 
     
    321328}; 
    322329jsToolBar.prototype.resizeDragStart = function(event) { 
    323   var This = this; 
     330  const This = this; 
    324331  this.dragStartY = event.clientY; 
    325332  this.resizeSetStartH(); 
     
    364371      else 
    365372        try { 
    366           this.singleTag('<' + opt + '>', '</' + opt + '>'); 
     373          this.singleTag(`<${opt}>`, `</${opt}>`); 
    367374        } catch (e) {} 
    368375      this.toolNodes.blocks.value = 'nonebis'; 
     
    688695    this.encloseSelection('', '', function(str) { 
    689696      if (str) { 
    690         return '<img src="' + src + '" alt="' + str + '" />'; 
     697        return `<img src="${src}" alt="${str}" />`; 
    691698      } else { 
    692         return '<img src="' + src + '" alt="" />'; 
     699        return `<img src="${src}" alt="" />`; 
    693700      } 
    694701    }); 
     
    700707    this.encloseSelection('', '', function(str) { 
    701708      if (str) { 
    702         return '((' + src + '|' + str + '))'; 
     709        return `((${src}|${str}))`; 
    703710      } else { 
    704         return '((' + src + '))'; 
     711        return `((${src}))`; 
    705712      } 
    706713    }); 
  • plugins/dcLegacyEditor/js/jsToolBar/jsToolBar.wysiwyg.js

    r3736 r3880  
    6464jsToolBar.prototype.syncContents = function(from) { 
    6565  from = from || 'textarea'; 
    66   var This = this; 
     66  const This = this; 
    6767  if (from == 'textarea') { 
    6868    initContent(); 
    6969  } else { 
    7070    this.validBlockquote(); 
    71     var html = this.applyHtmlFilters(this.ibody.innerHTML); 
     71    let html = this.applyHtmlFilters(this.ibody.innerHTML); 
    7272    if (html == '<br />') { 
    7373      html = '<p></p>'; 
     
    8686      This.ibody.innerHTML = This.applyWysiwygFilters(This.textarea.value); 
    8787      if (This.ibody.createTextRange) { //cursor at the begin for IE 
    88         var IErange = This.ibody.createTextRange(); 
     88        const IErange = This.ibody.createTextRange(); 
    8989        IErange.execCommand("SelectAll"); 
    9090        IErange.collapse(); 
     
    9292      } 
    9393    } else { 
    94       var idoc = This.iwin.document; 
    95       var para = idoc.createElement('p'); 
     94      const idoc = This.iwin.document; 
     95      const para = idoc.createElement('p'); 
    9696      para.appendChild(idoc.createElement('br')); 
    9797      while (idoc.body.hasChildNodes()) { 
     
    108108}; 
    109109jsToolBar.prototype.applyHtmlFilters = function(str) { 
    110   for (var fn in this.htmlFilters) { 
     110  for (let fn in this.htmlFilters) { 
    111111    str = this.htmlFilters[fn].call(this, str); 
    112112  } 
     
    115115jsToolBar.prototype.wysiwygFilters = {}; 
    116116jsToolBar.prototype.applyWysiwygFilters = function(str) { 
    117   for (var fn in this.wysiwygFilters) { 
     117  for (let fn in this.wysiwygFilters) { 
    118118    str = this.wysiwygFilters[fn].call(this, str); 
    119119  } 
     
    143143 */ 
    144144jsToolBar.prototype.initWindow = function() { 
    145   var This = this; 
     145  const This = this; 
    146146 
    147147  this.iframe = document.createElement('iframe'); 
     
    160160 
    161161  function initIframe() { 
    162     var doc = This.iframe.contentWindow.document; 
     162    const doc = This.iframe.contentWindow.document; 
    163163    if (!doc) { 
    164164      setTimeout(initIframe, 1); 
     
    167167 
    168168    doc.open(); 
    169     var html = 
    170       '<html>\n' + 
    171       '<head>\n' + 
    172       '<link rel="stylesheet" href="style/default.css" type="text/css" media="screen" />' + 
    173       '<style type="text/css">' + This.iframe_css + '</style>\n' + 
    174       (This.base_url != '' ? '<base href="' + This.base_url + '" />' : '') + 
    175       '</head>\n' + 
    176       '<body>\n' + 
    177       '</body>\n' + 
    178       '</html>'; 
     169    const html = 
     170`<html> 
     171  <head> 
     172    <link rel="stylesheet" href="style/default.css" type="text/css" media="screen" /> 
     173    <style type="text/css">${This.iframe_css}</style> 
     174    ${This.base_url != '' ? `<base href="${This.base_url}" />` : ''} 
     175  </head> 
     176  <body></body> 
     177</html>`; 
    179178 
    180179    doc.write(html); 
     
    212211    } 
    213212 
    214     for (var evt in This.iwinEvents) { 
    215       var event = This.iwinEvents[evt]; 
     213    for (let evt in This.iwinEvents) { 
     214      const event = This.iwinEvents[evt]; 
    216215      This.addIwinEvent(This.iframe.contentWindow.document, event.type, event.fn, This); 
    217216    } 
     
    227226}; 
    228227jsToolBar.prototype.addIwinEvent = function(target, type, fn, scope) { 
    229   var myFn = function(e) { 
     228  const myFn = function(e) { 
    230229    fn.call(scope, e); 
    231230  }; 
     
    260259  } 
    261260 
    262   var This = this; 
     261  const This = this; 
    263262 
    264263  function setLink(title, link) { 
    265     var li = document.createElement('li'); 
    266     var a; 
     264    const li = document.createElement('li'); 
     265    let a; 
    267266    if (link) { 
    268267      a = document.createElement('a'); 
     
    307306      this.iwin.document.designMode = 'on'; 
    308307    } catch (e) {} // Firefox needs this 
    309     var This = this; 
     308    const This = this; 
    310309    setTimeout(function() { 
    311310      This.iframe.contentWindow.focus(); 
     
    326325}; 
    327326jsToolBar.prototype.resizeDragMove = function(event) { 
    328   var new_height = (this.dragStartH + event.clientY - this.dragStartY) + 'px'; 
     327  const new_height = `${this.dragStartH + event.clientY - this.dragStartY}px`; 
    329328  if (this.iframe != undefined) { 
    330329    this.iframe.style.height = new_height; 
     
    338337 */ 
    339338jsToolBar.prototype.insertNode = function(node) { 
    340   var range; 
     339  let range; 
    341340 
    342341  if (this.iwin.getSelection) { // Gecko 
    343     var sel = this.iwin.getSelection(); 
     342    const sel = this.iwin.getSelection(); 
    344343    range = sel.getRangeAt(0); 
    345344 
     
    366365  } else { // IE 
    367366    // lambda element 
    368     var p = this.iwin.document.createElement('div'); 
     367    const p = this.iwin.document.createElement('div'); 
    369368    p.appendChild(node); 
    370369    range = this.iwin.document.selection.createRange(); 
     
    381380 */ 
    382381jsToolBar.prototype.getSelectedNode = function() { 
    383   var sel; 
     382  let sel; 
    384383  var content; 
    385384  if (this.iwin.getSelection) { // Gecko 
    386385    sel = this.iwin.getSelection(); 
    387     var range = sel.getRangeAt(0); 
     386    const range = sel.getRangeAt(0); 
    388387    content = range.cloneContents(); 
    389388  } else { // IE 
    390389    sel = this.iwin.document.selection; 
    391     var d = this.iwin.document.createElement('div'); 
     390    const d = this.iwin.document.createElement('div'); 
    392391    d.innerHTML = sel.createRange().htmlText; 
    393392    content = this.iwin.document.createDocumentFragment(); 
    394     for (var i = 0; i < d.childNodes.length; i++) { 
     393    for (let i = 0; i < d.childNodes.length; i++) { 
    395394      content.appendChild(d.childNodes[i].cloneNode(true)); 
    396395    } 
     
    405404    return this.iwin.getSelection().toString(); 
    406405  } else { // IE 
    407     var range = this.iwin.document.selection.createRange(); 
     406    const range = this.iwin.document.selection.createRange(); 
    408407    return range.text; 
    409408  } 
     
    411410 
    412411jsToolBar.prototype.replaceNodeByContent = function(node) { 
    413   var content = this.iwin.document.createDocumentFragment(); 
    414   for (var i = 0; i < node.childNodes.length; i++) { 
     412  const content = this.iwin.document.createDocumentFragment(); 
     413  for (let i = 0; i < node.childNodes.length; i++) { 
    415414    content.appendChild(node.childNodes[i].cloneNode(true)); 
    416415  } 
     
    419418 
    420419jsToolBar.prototype.getBlockLevel = function() { 
    421   var blockElts = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6']; 
    422  
    423   var range, commonAncestorContainer; 
     420  const blockElts = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6']; 
     421 
     422  let range; 
     423  let commonAncestorContainer; 
    424424  if (this.iwin.getSelection) { //gecko 
    425     var selection = this.iwin.getSelection(); 
     425    const selection = this.iwin.getSelection(); 
    426426    range = selection.getRangeAt(0); 
    427427    commonAncestorContainer = range.commonAncestorContainer; 
     
    434434  } 
    435435 
    436   var ancestorTagName = commonAncestorContainer.tagName.toLowerCase(); 
     436  let ancestorTagName = commonAncestorContainer.tagName.toLowerCase(); 
    437437  while (arrayIndexOf(blockElts, ancestorTagName) == -1 && ancestorTagName != 'body') { 
    438438    commonAncestorContainer = commonAncestorContainer.parentNode; 
     
    443443}; 
    444444jsToolBar.prototype.adjustBlockLevelCombo = function() { 
    445   var blockLevel = this.getBlockLevel(); 
     445  const blockLevel = this.getBlockLevel(); 
    446446  if (blockLevel !== null) 
    447447    this.toolNodes.blocks.value = blockLevel.tagName.toLowerCase(); 
     
    471471 */ 
    472472jsToolBar.prototype.tagsoup2xhtml = function(html) { 
    473   for (var reg in this.simpleCleanRegex) { 
     473  for (let reg in this.simpleCleanRegex) { 
    474474    html = html.replace(this.simpleCleanRegex[reg][0], this.simpleCleanRegex[reg][1]); 
    475475  } 
     
    488488 
    489489  /* IE laisse souvent des attributs sans guillemets */ 
    490   var myRegexp = /<[^>]+((\s+\w+\s*=\s*)([^"'][\w~@+$,%\/:.#?=&;!*()-]*))[^>]*?>/; 
    491   var myQuoteFn = function(str, val1, val2, val3) { 
    492     var tamponRegex = new RegExp(regexpEscape(val1)); 
     490  const myRegexp = /<[^>]+((\s+\w+\s*=\s*)([^"'][\w~@+$,%\/:.#?=&;!*()-]*))[^>]*?>/; 
     491  const myQuoteFn = function(str, val1, val2, val3) { 
     492    const tamponRegex = new RegExp(regexpEscape(val1)); 
    493493    return str.replace(tamponRegex, val2 + '"' + val3 + '"'); 
    494494  }; 
     
    508508 
    509509  /* Trim only if there's no pre tag */ 
    510   var pattern_pre = /<pre>[\s\S]*<\/pre>/gi; 
     510  const pattern_pre = /<pre>[\s\S]*<\/pre>/gi; 
    511511  if (!pattern_pre.test(html)) { 
    512512    html = html.replace(/^\s+/gm, ''); 
     
    517517}; 
    518518jsToolBar.prototype.validBlockquote = function() { 
    519   var blockElts = ['address', 'blockquote', 'dl', 'div', 'fieldset', 'form', 'h1', 
     519  const blockElts = ['address', 'blockquote', 'dl', 'div', 'fieldset', 'form', 'h1', 
    520520    'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'ol', 'p', 'pre', 'table', 'ul' 
    521521  ]; 
    522   var BQs = this.iwin.document.getElementsByTagName('blockquote'); 
    523   var bqChilds; 
    524   var p; 
    525  
    526   for (var bq = 0; bq < BQs.length; bq++) { 
     522  const BQs = this.iwin.document.getElementsByTagName('blockquote'); 
     523  let bqChilds; 
     524  let p; 
     525 
     526  for (let bq = 0; bq < BQs.length; bq++) { 
    527527    bqChilds = BQs[bq].childNodes; 
    528     var frag = this.iwin.document.createDocumentFragment(); 
    529     for (var i = (bqChilds.length - 1); i >= 0; i--) { 
     528    let frag = this.iwin.document.createDocumentFragment(); 
     529    for (let i = (bqChilds.length - 1); i >= 0; i--) { 
    530530      if (bqChilds[i].nodeType == 1 && // Node.ELEMENT_NODE 
    531531        arrayIndexOf(blockElts, bqChilds[i].tagName.toLowerCase()) >= 0) { 
     
    561561 
    562562jsToolBar.prototype.removeTextFormating = function(html) { 
    563   for (var reg in this.removeFormatRegexp) { 
     563  for (let reg in this.removeFormatRegexp) { 
    564564    html = html.replace(this.removeFormatRegexp[reg][0], this.removeFormatRegexp[reg][1]); 
    565565  } 
     
    576576  fn: function(opt) { 
    577577    if (opt == 'none') { 
    578       var blockLevel = this.getBlockLevel(); 
     578      const blockLevel = this.getBlockLevel(); 
    579579      if (blockLevel !== null) { 
    580580        this.replaceNodeByContent(blockLevel); 
     
    611611 
    612612jsToolBar.prototype.elements.quote.fn.wysiwyg = function() { 
    613   var n = this.getSelectedNode(); 
    614   var q = this.iwin.document.createElement('q'); 
     613  const n = this.getSelectedNode(); 
     614  const q = this.iwin.document.createElement('q'); 
    615615  q.appendChild(n); 
    616616  this.insertNode(q); 
     
    618618 
    619619jsToolBar.prototype.elements.code.fn.wysiwyg = function() { 
    620   var n = this.getSelectedNode(); 
    621   var code = this.iwin.document.createElement('code'); 
     620  const n = this.getSelectedNode(); 
     621  const code = this.iwin.document.createElement('code'); 
    622622  code.appendChild(n); 
    623623  this.insertNode(code); 
     
    625625 
    626626jsToolBar.prototype.elements.mark.fn.wysiwyg = function() { 
    627   var n = this.getSelectedNode(); 
    628   var mark = this.iwin.document.createElement('mark'); 
     627  const n = this.getSelectedNode(); 
     628  const mark = this.iwin.document.createElement('mark'); 
    629629  mark.appendChild(n); 
    630630  this.insertNode(mark); 
     
    632632 
    633633jsToolBar.prototype.elements.br.fn.wysiwyg = function() { 
    634   var n = this.iwin.document.createElement('br'); 
     634  const n = this.iwin.document.createElement('br'); 
    635635  this.insertNode(n); 
    636636}; 
    637637 
    638638jsToolBar.prototype.elements.blockquote.fn.wysiwyg = function() { 
    639   var n = this.getSelectedNode(); 
    640   var q = this.iwin.document.createElement('blockquote'); 
     639  const n = this.getSelectedNode(); 
     640  const q = this.iwin.document.createElement('blockquote'); 
    641641  q.appendChild(n); 
    642642  this.insertNode(q); 
     
    659659 
    660660jsToolBar.prototype.elements.link.fn.wysiwyg = function() { 
    661   var href, hreflang; 
    662   var range, commonAncestorContainer; 
     661  let href; 
     662  let hreflang; 
     663  let range; 
     664  let commonAncestorContainer; 
    663665  if (this.iwin.getSelection) { //gecko 
    664     var selection = this.iwin.getSelection(); 
     666    const selection = this.iwin.getSelection(); 
    665667    range = selection.getRangeAt(0); 
    666668    commonAncestorContainer = range.commonAncestorContainer; 
     
    673675  } 
    674676 
    675   var ancestorTagName = commonAncestorContainer.tagName.toLowerCase(); 
     677  let ancestorTagName = commonAncestorContainer.tagName.toLowerCase(); 
    676678  while (ancestorTagName != 'a' && ancestorTagName != 'body') { 
    677679    commonAncestorContainer = commonAncestorContainer.parentNode; 
     
    707709 
    708710  // Create link 
    709   var n = this.getSelectedNode(); 
    710   var a = this.iwin.document.createElement('a'); 
     711  const n = this.getSelectedNode(); 
     712  const a = this.iwin.document.createElement('a'); 
    711713  a.href = href; 
    712714  if (hreflang) a.setAttribute('hreflang', hreflang); 
     
    723725jsToolBar.prototype.elements.removeFormat.disabled = !jsToolBar.prototype.can_wwg; 
    724726jsToolBar.prototype.elements.removeFormat.fn.xhtml = function() { 
    725   var html = this.textarea.value; 
     727  let html = this.textarea.value; 
    726728  html = this.removeTextFormating(html); 
    727729  this.textarea.value = html; 
    728730}; 
    729731jsToolBar.prototype.elements.removeFormat.fn.wysiwyg = function() { 
    730   var html = this.iwin.document.body.innerHTML; 
     732  let html = this.iwin.document.body.innerHTML; 
    731733  html = this.removeTextFormating(html); 
    732734  this.iwin.document.body.innerHTML = html; 
     
    738740    return aArray.indexOf(aValue); 
    739741  } else { 
    740     var index = -1; 
    741     var l = aArray.length; 
    742     for (var i = 0; i < l; i++) { 
     742    let index = -1; 
     743    const l = aArray.length; 
     744    for (let i = 0; i < l; i++) { 
    743745      if (aArray[i] === aValue) { 
    744746        index = i; 
     
    755757    return true; 
    756758  } else if (obj.attachEvent) { 
    757     var r = obj.attachEvent("on" + evType, fn); 
     759    const r = obj.attachEvent("on" + evType, fn); 
    758760    return r; 
    759761  } else { 
     
    767769    return true; 
    768770  } else if (obj.detachEvent) { 
    769     var r = obj.detachEvent("on" + evType, fn); 
     771    const r = obj.detachEvent("on" + evType, fn); 
    770772    return r; 
    771773  } else { 
  • plugins/dcLegacyEditor/js/jsToolBar/popup_link.js

    r3735 r3880  
    1313 
    1414     function sendClose() { 
    15           var insert_form = $('#link-insert-form').get(0); 
     15          const insert_form = $('#link-insert-form').get(0); 
    1616          if (insert_form == undefined) { return; } 
    1717 
    18           var tb = window.opener.the_toolbar; 
    19           var data = tb.elements.link.data; 
     18          const tb = window.opener.the_toolbar; 
     19          const data = tb.elements.link.data; 
    2020 
    2121          data.href = tb.stripBaseURL(insert_form.elements.href.value); 
     
    2323          data.hreflang = insert_form.elements.hreflang.value; 
    2424          tb.elements.link.fncall[tb.mode].call(tb); 
    25      }; 
     25     } 
    2626}); 
  • plugins/dcLegacyEditor/js/jsToolBar/popup_media.js

    r3725 r3880  
    1515 
    1616  function sendClose() { 
    17     var insert_form = $('#media-insert-form').get(0); 
     17    const insert_form = $('#media-insert-form').get(0); 
    1818    if (insert_form == undefined) { 
    1919      return; 
    2020    } 
    2121 
    22     var tb = window.opener.the_toolbar; 
    23     var type = insert_form.elements.type.value; 
    24     var media_align_grid = { 
     22    const tb = window.opener.the_toolbar; 
     23    const type = insert_form.elements.type.value; 
     24    const media_align_grid = { 
    2525      left: 'float: left; margin: 0 1em 1em 0;', 
    2626      right: 'float: right; margin: 0 0 1em 1em;', 
    2727      center: 'text-align: center;' 
    2828    }; 
    29     var align, player; 
     29    let align; 
     30    let player; 
    3031 
    3132    if (type == 'image') { 
     
    3839      tb.elements.img_select.data.url = tb.stripBaseURL(insert_form.elements.url.value); 
    3940 
    40       var media_legend = $('input[name="legend"]:checked', insert_form).val(); 
     41      let media_legend = $('input[name="legend"]:checked', insert_form).val(); 
    4142      if (media_legend != '' && media_legend != 'title' && media_legend != 'none') { 
    4243        media_legend = 'legend'; 
     
    5556 
    5657      if (align != undefined && align != 'none') { 
    57         player = '<div style="' + media_align_grid[align] + '">' + player + '</div>'; 
     58        player = `<div style="${media_align_grid[align]}">${player}</div>`; 
    5859      } 
    5960 
     
    6263    } else if (type == 'flv') // may be all video media, not only flv 
    6364    { 
    64       var oplayer = $('<div>' + $('#public_player').val() + '</div>'); 
     65      var oplayer = $(`<div>${$('#public_player').val()}</div>`); 
    6566      var flashvars = $('[name=FlashVars]', oplayer).val(); 
    6667 
     
    9899 
    99100      if (align != undefined && align != 'none') { 
    100         player = '<div style="' + media_align_grid[align] + '">' + player + '</div>'; 
     101        player = `<div style="${media_align_grid[align]}">${player}</div>`; 
    101102      } 
    102103 
  • plugins/dcLegacyEditor/js/jsToolBar/popup_posts.js

    r3735 r3880  
    99     $('#form-entries tr>td.maximal>a').click(function() { 
    1010          // Get post_id 
    11           var tb = window.opener.the_toolbar; 
    12           var data = tb.elements.link.data; 
     11          const tb = window.opener.the_toolbar; 
     12          const data = tb.elements.link.data; 
    1313 
    1414          data.href = tb.stripBaseURL($(this).attr('title')); 
Note: See TracChangeset for help on using the changeset viewer.

Sites map