Dotclear

source: plugins/dcCKEditor/js/ckeditor-plugins/dclink/plugin.js @ 3880:e6d1f6d9d7df

Revision 3880:e6d1f6d9d7df, 1.6 KB checked in by franck <carnet.franck.paul@…>, 7 years ago (diff)

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

Line 
1/*global CKEDITOR, dotclear, $ */
2'use strict';
3
4(function() {
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      });
16
17      editor.ui.addButton('dcLink', {
18        label: dotclear.msg.link_title,
19        command: 'dcLinkCommand',
20        toolbar: 'insert'
21      });
22
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
29
30            editor.getSelection().selectElement(element);
31
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            }
42
43            $.toolbarPopup(popup_url);
44            return false;
45          }
46        }
47      });
48    }
49  });
50})();
Note: See TracBrowser for help on using the repository browser.

Sites map