Changeset 3880:e6d1f6d9d7df for plugins/dcCKEditor
- Timestamp:
- 09/18/18 20:22:10 (7 years ago)
- Branch:
- default
- Location:
- plugins/dcCKEditor/js
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/dcCKEditor/js/ckeditor-plugins/dclink/plugin.js
r2962 r3880 1 /*global CKEDITOR, dotclear, $ */ 2 'use strict'; 3 1 4 (function() { 2 3 4 5 6 7 if (editor.getSelection().getSelectedElement()!=null 8 || editor.getSelection().getNative().toString().replace(/\s*/,'')!='') {9 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 }); 13 16 14 15 16 17 18 17 editor.ui.addButton('dcLink', { 18 label: dotclear.msg.link_title, 19 command: 'dcLinkCommand', 20 toolbar: 'insert' 21 }); 19 22 20 editor.on('doubleclick',function(e) {21 varelement = CKEDITOR.plugins.link.getSelectedLink(editor) || e.data.element;22 23 if (element.is('a') 24 && !element.hasClass('media-link')// link to original media @see js/popup_media.js25 && !element.hasClass('ref-post')) {// link to an entry @see js/popup_posts.js23 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 26 29 27 30 editor.getSelection().selectElement(element); 28 31 29 varpopup_url = 'popup_link.php?plugin_id=dcCKEditor';30 31 popup_url += '&href='+element.getAttribute('href');32 33 34 popup_url += '&hreflang='+element.getAttribute('hreflang');35 36 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 } 39 42 40 41 42 43 44 45 46 43 $.toolbarPopup(popup_url); 44 return false; 45 } 46 } 47 }); 48 } 49 }); 47 50 })(); -
plugins/dcCKEditor/js/ckeditor-plugins/entrylink/plugin.js
r2901 r3880 1 /*global CKEDITOR, dotclear, $ */ 2 'use strict'; 3 1 4 (function() { 2 CKEDITOR.plugins.add('entrylink', { 3 icons: 'entrylink', 4 init: function(editor) { 5 popup_params = { 'width': 760, 'height': 500}; 5 CKEDITOR.plugins.add('entrylink', { 6 icons: 'entrylink', 7 init: function(editor) { 8 const popup_params = { 9 'width': 760, 10 'height': 500 11 }; 6 12 7 8 9 if (editor.getSelection().getNative().toString().replace(/\s*/,'')!='') {10 11 12 13 13 editor.addCommand('entryLinkCommand', { 14 exec: function(editor) { 15 if (editor.getSelection().getNative().toString().replace(/\s*/, '') != '') { 16 $.toolbarPopup('popup_posts.php?popup=1&plugin_id=dcCKEditor', popup_params); 17 } 18 } 19 }); 14 20 15 16 17 18 19 21 editor.ui.addButton('EntryLink', { 22 label: dotclear.msg.post_link_title, 23 command: 'entryLinkCommand', 24 toolbar: 'insert' 25 }); 20 26 21 editor.on('doubleclick',function(e) { 22 var element = CKEDITOR.plugins.link.getSelectedLink(editor) || e.data.element; 23 if (!element.isReadOnly()) { 24 if (element.is('a') 25 && !element.hasClass('media-link') 26 && element.hasClass('ref-post')) { // link to original media @see js/popup_media.js 27 editor.getSelection().selectElement(element); 27 editor.on('doubleclick', function(e) { 28 const element = CKEDITOR.plugins.link.getSelectedLink(editor) || e.data.element; 29 if (!element.isReadOnly()) { 30 if (element.is('a') && !element.hasClass('media-link') && element.hasClass('ref-post')) { 31 // link to original media @see js/popup_media.js 32 editor.getSelection().selectElement(element); 28 33 29 30 31 32 33 34 35 34 $.toolbarPopup('popup_posts.php?popup=1&plugin_id=dcCKEditor', popup_params); 35 return false; 36 } 37 } 38 }); 39 } 40 }); 36 41 })(); -
plugins/dcCKEditor/js/ckeditor-plugins/img/plugin.js
r2869 r3880 1 /*global CKEDITOR, dotclear */ 2 'use strict'; 3 1 4 (function() { 2 3 4 5 CKEDITOR.plugins.add('img', { 6 init: function(editor) { 7 editor.addCommand('dcImgCommand', new CKEDITOR.dialogCommand('imgDialog')); 5 8 6 CKEDITOR.dialog.add('imgDialog', this.path+'dialogs/img.js');9 CKEDITOR.dialog.add('imgDialog', this.path + 'dialogs/img.js'); 7 10 8 9 10 11 12 13 14 15 11 editor.ui.addButton('img', { 12 label: dotclear.msg.img_title, 13 command: 'dcImgCommand', 14 toolbar: 'insert', 15 icon: this.path + 'icons/img.png' 16 }); 17 } 18 }); 16 19 })(); -
plugins/dcCKEditor/js/ckeditor-plugins/media/plugin.js
r2835 r3880 1 /*global CKEDITOR, dotclear, $ */ 2 'use strict'; 3 1 4 (function() { 2 CKEDITOR.plugins.add('media', { 3 icons: 'media', 4 init: function(editor) { 5 popup_params = { 'width': 760, 'height': 500}; 5 CKEDITOR.plugins.add('media', { 6 icons: 'media', 7 init: function(editor) { 8 const popup_params = { 9 'width': 760, 10 'height': 500 11 }; 6 12 7 8 exec: function(editor) {9 10 11 13 editor.addCommand('mediaCommand', { 14 exec: function() { 15 $.toolbarPopup('media.php?popup=1&plugin_id=dcCKEditor', popup_params); 16 } 17 }); 12 18 13 14 15 16 17 19 editor.ui.addButton('Media', { 20 label: dotclear.msg.img_select_title, 21 command: 'mediaCommand', 22 toolbar: 'insert' 23 }); 18 24 19 editor.on('doubleclick',function(e) {20 varelement = CKEDITOR.plugins.link.getSelectedLink(editor) || e.data.element;21 22 23 24 25 26 27 28 29 25 editor.on('doubleclick', function(e) { 26 const element = CKEDITOR.plugins.link.getSelectedLink(editor) || e.data.element; 27 if (!element.isReadOnly()) { 28 if (element.is('img') || (element.is('a') && element.hasClass('media-link'))) { 29 $.toolbarPopup('media.php?popup=1&plugin_id=dcCKEditor', popup_params); 30 return false; 31 } 32 } 33 }); 34 } 35 }); 30 36 })(); -
plugins/dcCKEditor/js/ckeditor-skins/dotclear/skin.js
r2738 r3880 1 /*global CKEDITOR */ 2 'use strict'; 3 1 4 CKEDITOR.skin.name = 'dotclear'; 2 5 -
plugins/dcCKEditor/js/popup_link.js
r3709 r3880 8 8 9 9 $('#link-insert-ok').click(function() { 10 varinsert_form = $('#link-insert-form').get(0);10 const insert_form = $('#link-insert-form').get(0); 11 11 if (insert_form == undefined) { 12 12 return; 13 13 } 14 14 15 var editor_name = window.opener.$.getEditorName(),16 editor = window.opener.CKEDITOR.instances[editor_name],17 link = '',18 15 const editor_name = window.opener.$.getEditorName(); 16 const editor = window.opener.CKEDITOR.instances[editor_name]; 17 let link = ''; 18 let selected_element; 19 19 if (editor.getSelection().getSelectedElement() != null) { 20 20 selected_element = editor.getSelection().getSelectedElement(); -
plugins/dcCKEditor/js/popup_media.js
r3725 r3880 8 8 9 9 $('#media-insert-ok').click(function() { 10 varinsert_form = $('#media-insert-form').get(0);10 const insert_form = $('#media-insert-form').get(0); 11 11 if (insert_form === undefined) { 12 12 return; 13 13 } 14 14 15 var editor_name = window.opener.$.getEditorName(),16 editor = window.opener.CKEDITOR.instances[editor_name],17 type = insert_form.elements.type.value,18 19 20 21 22 15 const editor_name = window.opener.$.getEditorName(); 16 const editor = window.opener.CKEDITOR.instances[editor_name]; 17 const type = insert_form.elements.type.value; 18 const media_align_grid = { 19 left: 'float: left; margin: 0 1em 1em 0;', 20 right: 'float: right; margin: 0 0 1em 1em;', 21 center: 'margin: 0 auto; display: table;' 22 }; 23 23 24 24 if (type == 'image') { 25 25 if (editor.mode == 'wysiwyg') { 26 26 27 varalign = $('input[name="alignment"]:checked', insert_form).val();28 varmedia_legend = $('input[name="legend"]:checked', insert_form).val();29 varimg_description = $('input[name="description"]', insert_form).val();30 varstyle = '';31 vartemplate = '';32 vartemplate_figure = [27 const align = $('input[name="alignment"]:checked', insert_form).val(); 28 let media_legend = $('input[name="legend"]:checked', insert_form).val(); 29 const img_description = $('input[name="description"]', insert_form).val(); 30 let style = ''; 31 let template = ''; 32 let template_figure = [ 33 33 '', 34 34 '' 35 35 ]; 36 vartemplate_link = [36 let template_link = [ 37 37 '', 38 38 '' 39 39 ]; 40 vartemplate_image = '';40 let template_image = ''; 41 41 42 42 if (media_legend != '' && media_legend != 'title' && media_legend != 'none') { … … 58 58 template_figure[1] = template_figure[1] + '</figure>'; 59 59 } 60 template_image = '<img class="media" src="{imgSrc}" alt="{imgAlt}"' + style + '/>';60 template_image = `<img class="media" src="{imgSrc}" alt="{imgAlt}"${style}/>`; 61 61 if ($('input[name="insertion"]:checked', insert_form).val() == 'link') { 62 62 // With a link to original … … 66 66 template = template_figure[0] + template_link[0] + template_image + template_link[1] + template_figure[1]; 67 67 68 varblock = new window.opener.CKEDITOR.template(template);69 varparams = {};68 let block = new window.opener.CKEDITOR.template(template); 69 let params = {}; 70 70 71 71 // Set parameters for template … … 86 86 87 87 // Insert element 88 varfigure = window.opener.CKEDITOR.dom.element.createFromHtml(88 const figure = window.opener.CKEDITOR.dom.element.createFromHtml( 89 89 block.output(params), editor.document 90 90 ); 91 91 editor.insertElement(figure); 92 92 } 93 93 94 } else if (type == 'mp3') { 94 95 // Audio media 95 varplayer_audio = $('#public_player').val();96 varalign_audio = $('input[name="alignment"]:checked', insert_form).val();96 let player_audio = $('#public_player').val(); 97 const align_audio = $('input[name="alignment"]:checked', insert_form).val(); 97 98 98 99 if (align_audio != undefined && align_audio != 'none') { 99 player_audio = '<div style="' + media_align_grid[align_audio] + '">' + player_audio + '</div>';100 player_audio = `<div style="${media_align_grid[align_audio]}">${player_audio}</div>`; 100 101 } 101 102 editor.insertElement(window.opener.CKEDITOR.dom.element.createFromHtml(player_audio)); 103 102 104 } else if (type == 'flv') { 103 105 // Video media 104 var oplayer = $('<div>' + $('#public_player').val() + '</div>');105 varflashvars = $('[name=FlashVars]', oplayer).val();106 const oplayer = $(`<div>${$('#public_player').val()}</div>`); 107 let flashvars = $('[name=FlashVars]', oplayer).val(); 106 108 107 varalign_video = $('input[name="alignment"]:checked', insert_form).val();109 const align_video = $('input[name="alignment"]:checked', insert_form).val(); 108 110 109 vartitle = insert_form.elements.title.value;111 const title = insert_form.elements.title.value; 110 112 if (title) { 111 flashvars = 'title=' + encodeURI(title) + '&' + flashvars;113 flashvars = `title=${encodeURI(title)}&${flashvars}`; 112 114 } 113 115 114 varvw = $('#video_w').val();115 varvh = $('#video_h').val();116 const vw = $('#video_w').val(); 117 const vh = $('#video_h').val(); 116 118 117 119 if (vw > 0) { … … 135 137 136 138 $('[name=FlashVars]', oplayer).val(flashvars); 137 varplayer_video = oplayer.html();139 let player_video = oplayer.html(); 138 140 139 141 if (align_video != undefined && align_video != 'none') { 140 player_video = '<div style="' + media_align_grid[align_video] + '">' + player_video + '</div>';142 player_video = `<div style="${media_align_grid[align_video]}">${player_video}</div>`; 141 143 } 142 144 editor.insertElement(window.opener.CKEDITOR.dom.element.createFromHtml(player_video)); 145 143 146 } else { 144 147 // Unknown media type 145 var link = '<a href="'; 146 link += window.opener.$.stripBaseURL($('input[name="url"]', insert_form).val()); 147 link += '">' + window.opener.CKEDITOR.tools.htmlEncodeAttr(insert_form.elements.title.value) + '</a>'; 148 var element = window.opener.CKEDITOR.dom.element.createFromHtml(link); 148 const url = window.opener.$.stripBaseURL($('input[name="url"]', insert_form).val()); 149 const text = window.opener.CKEDITOR.tools.htmlEncodeAttr(insert_form.elements.title.value); 150 const element = window.opener.CKEDITOR.dom.element.createFromHtml(`<a href="${url}">${text}</a>`); 149 151 150 152 editor.insertElement(element); -
plugins/dcCKEditor/js/popup_posts.js
r3709 r3880 9 9 $('#form-entries tr>td.maximal>a').click(function(e) { 10 10 e.preventDefault(); 11 var editor_name = window.opener.$.getEditorName(),12 editor = window.opener.CKEDITOR.instances[editor_name],13 link = '',14 11 const editor_name = window.opener.$.getEditorName(); 12 const editor = window.opener.CKEDITOR.instances[editor_name]; 13 let link = ''; 14 const selected_text = editor.getSelection().getNative().toString(); 15 15 16 16 if (editor.mode == 'wysiwyg') { 17 17 link = '<a class="ref-post" href="' + window.opener.$.stripBaseURL($(this).attr('title')) + '">' + selected_text + '</a>'; 18 varelement = window.opener.CKEDITOR.dom.element.createFromHtml(link);18 const element = window.opener.CKEDITOR.dom.element.createFromHtml(link); 19 19 editor.insertElement(element); 20 20 }
Note: See TracChangeset
for help on using the changeset viewer.