Dotclear

source: plugins/dcCKEditor/js/ckeditor-plugins/dclink/plugin.js @ 2738:d6b4c5ac9b33

Revision 2738:d6b4c5ac9b33, 1.3 KB checked in by Nicolas <nikrou77@…>, 11 years ago (diff)

Integrate dcCKEditor to distribution

Line 
1(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().getNative().toString().replace(/\s*/,'')!='') {
8                              $.toolbarPopup('popup_link.php?editor='+editor.name);
9                         }
10                    }
11               });
12
13               editor.ui.addButton('dcLink', {
14                    label: 'Link',
15                    command: 'dcLinkCommand',
16                    toolbar: 'insert'
17               });
18               
19               editor.on('doubleclick',function(e) {
20                    var element = CKEDITOR.plugins.link.getSelectedLink(editor) || e.data.element;
21                    if (!element.isReadOnly()) {
22                         if (element.is('a') 
23                             && !element.hasClass('media-link') // link to original media @see js/popup_media.js
24                             && !element.hasClass('post')) {    // link to an entry @see js/popup_posts.js
25
26                              editor.getSelection().selectElement(element);
27
28                              var popup_url = 'popup_link.php?editor='+editor.name;
29                              if (element.getAttribute('href')) {
30                                   popup_url += '&href='+element.getAttribute('href');
31                              }
32                              if (element.getAttribute('hreflang')) {
33                                   popup_url += '&hreflang='+element.getAttribute('hreflang');
34                              }
35                              if (element.getAttribute('title')) {
36                                   popup_url += '&title='+element.getAttribute('title');
37                              }
38
39                              $.toolbarPopup(popup_url);
40                              return false;
41                         } 
42                    }
43               });
44          }
45     });
46})();
Note: See TracBrowser for help on using the repository browser.

Sites map