Dotclear

source: plugins/dcCKEditor/js/popup_link.js @ 3000:c253e82bd552

Revision 3000:c253e82bd552, 1.3 KB checked in by Nicolas <nikrou77@…>, 10 years ago (diff)

Fix #2062 - quotes were not encoded in attributes

Line 
1$(function() {
2     $('#link-insert-cancel').click(function() {
3          window.close();
4     });
5
6     $('#link-insert-ok').click(function() {
7          var insert_form = $('#link-insert-form').get(0);
8          if (insert_form == undefined) {
9               return;
10          }
11
12          var editor_name = window.opener.$.getEditorName(),
13          editor = window.opener.CKEDITOR.instances[editor_name],
14          link = '',
15          selected_element;
16          if (editor.getSelection().getSelectedElement()!=null) {
17               selected_element = editor.getSelection().getSelectedElement();
18          } else {
19               selected_element = editor.getSelection().getNative().toString();
20          }
21
22          if (editor.mode=='wysiwyg') {
23               var link = editor.document.createElement('a');
24               link.setAttribute('href', insert_form.elements.href.value);
25               if (insert_form.elements.title.value!='') {
26                    link.setAttribute(
27                         'title',
28                         window.opener.CKEDITOR.tools.htmlEncodeAttr(insert_form.elements.title.value)
29                    );
30               }
31               if (insert_form.elements.hreflang.value!='') {
32                    link.setAttribute(
33                         'hreflang',
34                         window.opener.CKEDITOR.tools.htmlEncodeAttr(insert_form.elements.hreflang.value)
35                    );
36               }
37               if (editor.getSelection().getSelectedElement()!=null) {
38                    selected_element.appendTo(link);
39               } else {
40                    link.appendText(selected_element);
41               }
42               editor.insertElement(link);
43          }
44          window.close();
45     });
46});
Note: See TracBrowser for help on using the repository browser.

Sites map