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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/dcCKEditor/js/ckeditor-plugins/dclink/plugin.js

    r2962 r3880  
     1/*global CKEDITOR, dotclear, $ */ 
     2'use strict'; 
     3 
    14(function() { 
    2      CKEDITOR.plugins.add('dclink', { 
    3           icons: 'dclink', 
    4           init: function(editor) { 
    5                editor.addCommand('dcLinkCommand', { 
    6                     exec: function(editor) { 
    7                          if (editor.getSelection().getSelectedElement()!=null 
    8                              || editor.getSelection().getNative().toString().replace(/\s*/,'')!='') { 
    9                               $.toolbarPopup('popup_link.php?plugin_id=dcCKEditor'); 
    10                          } 
    11                     } 
    12                }); 
     5  CKEDITOR.plugins.add('dclink', { 
     6    icons: 'dclink', 
     7    init: function(editor) { 
     8      editor.addCommand('dcLinkCommand', { 
     9        exec: function(editor) { 
     10          if (editor.getSelection().getSelectedElement() != null || 
     11            editor.getSelection().getNative().toString().replace(/\s*/, '') != '') { 
     12            $.toolbarPopup('popup_link.php?plugin_id=dcCKEditor'); 
     13          } 
     14        } 
     15      }); 
    1316 
    14                editor.ui.addButton('dcLink', { 
    15                     label: dotclear.msg.link_title, 
    16                     command: 'dcLinkCommand', 
    17                     toolbar: 'insert' 
    18                }); 
     17      editor.ui.addButton('dcLink', { 
     18        label: dotclear.msg.link_title, 
     19        command: 'dcLinkCommand', 
     20        toolbar: 'insert' 
     21      }); 
    1922 
    20                editor.on('doubleclick',function(e) { 
    21                     var element = CKEDITOR.plugins.link.getSelectedLink(editor) || e.data.element; 
    22                     if (!element.isReadOnly()) { 
    23                          if (element.is('a') 
    24                              && !element.hasClass('media-link') // link to original media @see js/popup_media.js 
    25                              && !element.hasClass('ref-post')) {    // link to an entry @see js/popup_posts.js 
     23      editor.on('doubleclick', function(e) { 
     24        const element = CKEDITOR.plugins.link.getSelectedLink(editor) || e.data.element; 
     25        if (!element.isReadOnly()) { 
     26          if (element.is('a') && 
     27            !element.hasClass('media-link') && // link to original media @see js/popup_media.js 
     28            !element.hasClass('ref-post')) { // link to an entry @see js/popup_posts.js 
    2629 
    27                               editor.getSelection().selectElement(element); 
     30            editor.getSelection().selectElement(element); 
    2831 
    29                               var popup_url = 'popup_link.php?plugin_id=dcCKEditor'; 
    30                               if (element.getAttribute('href')) { 
    31                                    popup_url += '&href='+element.getAttribute('href'); 
    32                               } 
    33                               if (element.getAttribute('hreflang')) { 
    34                                    popup_url += '&hreflang='+element.getAttribute('hreflang'); 
    35                               } 
    36                               if (element.getAttribute('title')) { 
    37                                    popup_url += '&title='+element.getAttribute('title'); 
    38                               } 
     32            let popup_url = 'popup_link.php?plugin_id=dcCKEditor'; 
     33            if (element.getAttribute('href')) { 
     34              popup_url += '&href=' + element.getAttribute('href'); 
     35            } 
     36            if (element.getAttribute('hreflang')) { 
     37              popup_url += '&hreflang=' + element.getAttribute('hreflang'); 
     38            } 
     39            if (element.getAttribute('title')) { 
     40              popup_url += '&title=' + element.getAttribute('title'); 
     41            } 
    3942 
    40                               $.toolbarPopup(popup_url); 
    41                               return false; 
    42                          } 
    43                     } 
    44                }); 
    45           } 
    46      }); 
     43            $.toolbarPopup(popup_url); 
     44            return false; 
     45          } 
     46        } 
     47      }); 
     48    } 
     49  }); 
    4750})(); 
Note: See TracChangeset for help on using the changeset viewer.

Sites map