1// https://froala.com/wysiwyg-editor/docs/concepts/custom/popup/ 2 3 4// Utilisé pour les extranets. En gros, on ne peut insérer que des images stockées ailleurs sur le net 5 6 7// Define popup template. 8Object.assign(FroalaEditor.POPUP_TEMPLATES, { 9 'organonInsertLite.popup': '[_BUTTONS_][_CUSTOM_LAYER_]' 10}); 11 12// Utilisé principalement dans les extranet 13// Vérifier les traductions : 14if (tradInsererLientExt===undefined) var tradInsererLientExt = "Insérer un lien externe" 15if (tradInsererImageExt===undefined) var tradInsererImageExt = "Insérer une image externe" 16if (tradTexte===undefined) var tradTexte = "Texte" 17if (tradOuvrirDansOnglet===undefined) var tradOuvrirDansOnglet = "Ouvrir dans un nouvel onglet" 18if (tradInsererLien===undefined) var tradInsererLien = "Insérer le lien" 19if (tradUrlImage===undefined) var tradUrlImage = "URL de l'image" 20if (tradInsererImage===undefined) var tradInsererImage = "Insérer l'image" 21if (tradInsererDepuisVotrePC===undefined) var tradInsererDepuisVotrePC = "Insérer depuis votre PC" 22if (tradInsererUnLien===undefined) var tradInsererUnLien = "Insérer un lien" 23 24var myFrEditor=null; 25FroalaEditor.PLUGINS.organonInsertLite = function (editor) { 26 27 function initPopup () { 28 29 var readonlyStyle=" style='background-color: #efefef !important;' " 30 var hidePopupButton='<button class="fr-command fr-submit fr-btn-bottom" role="button" data-cmd="hidePopupLite" href="#" type="button" tabindex="4">Annuler</button>' 31 32 33 // Popup buttons. 34 var popup_buttons = ''; 35 36 popup_buttons += '<div class="fr-buttons fr-tabs">'; 37 popup_buttons+='<button id="insertUrlLite" type="button" role="button" class="fr-command fr-btn fr-org-active" data-cmd="orgTabUrlLite" data-title="'+tradInsererLientExt+'" aria-selected="false"><svg class="fr-svg" focusable="false" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M11,17H7A5,5,0,0,1,7,7h4V9H7a3,3,0,0,0,0,6h4ZM17,7H13V9h4a3,3,0,0,1,0,6H13v2h4A5,5,0,0,0,17,7Zm-1,4H8v2h8Z"></path></svg></button>' 38 popup_buttons += '<button id="insertUrlImgLite" type="button" role="button" class="fr-command fr-btn" data-cmd="orgTabUrlImgLite" data-title="'+tradInsererImageExt+'" aria-selected="true"><svg class="fr-svg" focusable="false" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M14.2,11l3.8,5H6l3-3.9l2.1,2.7L14,11H14.2z M8.5,11c0.8,0,1.5-0.7,1.5-1.5S9.3,8,8.5,8S7,8.7,7,9.5C7,10.3,7.7,11,8.5,11z M22,6v12c0,1.1-0.9,2-2,2H4c-1.1,0-2-0.9-2-2V6c0-1.1,0.9-2,2-2h16C21.1,4,22,4.9,22,6z M20,8.8V6H4v12h16V8.8z"></path></svg></button>'; 39 popup_buttons+='</div>'; 40 41 var popup_body='<div class="custom-layer">' 42 43 popup_body+="<div id='fr-OrgInsertLinkLite' class='fr-active fr-layer'>" 44 if (true) { // Url 45 popup_body+='<div class="fr-input-line">' 46 popup_body+='<input id="fr-OrgInsertLink-url-lite" type="text" class="fr-link-attr" tabindex="1" dir="ltr"><label for="fr-OrgInsertLink-url-lite">Url</label>' 47 popup_body+='</div>' 48 popup_body+='<div class="fr-input-line">' 49 popup_body+='<input id="fr-OrgInsertLink-text-lite" type="text" class="fr-link-attr" tabindex="1" dir="ltr"><label for="fr-OrgInsertLink-text-lite">'+tradTexte+'</label>' 50 popup_body+='</div>' 51 popup_body+='<div class="fr-checkbox-line">' 52 popup_body+='<span class="fr-checkbox"><input name="target" class="fr-link-attr fr-not-empty" data-checked="_blank" type="checkbox" checked id="fr-OrgInsertLink-check-lite" tabindex="3" dir="ltr"><span><svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="10" height="10" viewBox="0 0 32 32"><path d="M27 4l-15 15-7-7-5 5 12 12 20-20z" fill="#FFF"></path></svg></span></span><label id="fr-label-target-1">'+tradOuvrirDansOnglet+'</label>' 53 popup_body+='</div>' 54 55 insertButton='<button class="fr-command fr-submit fr-btn-bottom" role="button" data-cmd="linkInsertLite" href="#" tabindex="4" type="button">'+tradInsererLien+'</button>' 56 popup_body+="<div class='fr-action-buttons'>" 57 popup_body+=hidePopupButton+insertButton 58 popup_body+="</div>" 59 } 60 popup_body+="</div>" // #fr-OrgInsertLink 61 62 popup_body+="<div id='fr-OrgInsertLinkImgLite' class='fr-layer'>" 63 if(true){ // Img 64 popup_body+='<div class="fr-input-line">' 65 popup_body+='<input id="fr-OrgInsertLinkImg-url-lite" type="text" class="fr-link-attr" tabindex="1" dir="ltr"><label for="fr-OrgInsertLinkImg-url-lite">'+tradUrlImage+'</label>' 66 popup_body+='</div>' // #fr-input-line 67 insertButton='<button class="fr-command fr-submit fr-btn-bottom" role="button" data-cmd="linkImgInsertLite" href="#" tabindex="4" type="button">'+tradInsererImage+'</button>' 68 popup_body+="<div class='fr-action-buttons'>" 69 popup_body+=hidePopupButton+insertButton 70 popup_body+="</div>" 71 } 72 popup_body+="</div>" // #fr-OrgInsertLinkImg 73 74 popup_body+="</div>" // .custom-layer 75 // Create popup. 76 var template = { 77 buttons: popup_buttons, 78 custom_layer: popup_body 79 }; 80 var $popup = editor.popups.create('organonInsertLite.popup', template); 81 return $popup; 82 83 } 84 85 // Show the popup 86 function showPopup () { 87 myFrEditor=editor; 88 89 var $popup = editor.popups.get('organonInsertLite.popup'); 90 91 if (!$popup) $popup = initPopup(); 92 93 editor.popups.setContainer('organonInsertLite.popup', editor.$tb);
94 var $btn = editor.$tb.find('.fr-command[data-cmd="orgInsertLite"]'); 95 96 var left = $btn.offset().left - $btn.outerWidth() / 2; 97 var w = window.innerWidth; 98 if ((left+500) > w) { // 500 => width du plugin 99 left=w-500-90 // 90 => width de #fonctionsdroite 100 } 101 var top = $btn.offset().top + (editor.opts.toolbarBottom ? 10 : $btn.outerHeight() - 10); 102 103 editor.popups.show('organonInsertLite.popup', left, top, $btn.outerHeight()); 104 } 105 106 // Hide the custom popup. 107 function hidePopup () { 108 myFrEditor=null; 109 editor.popups.hide('organonInsertLite.popup'); 110 // Reset les champs 111 $("#fr-OrgInsertLink-url-lite").val(""); 112 $("#fr-OrgInsertLink-text-lite").val(""); 113 $("#fr-OrgInsertLinkImg-url-lite").val(""); 114 // premier tab par defaut 115 orgTabUrl(); 116 } 117 118 119 // URL 120 function linkInsert(){ 121 var orgLink=$("#fr-OrgInsertLink-url-lite").val() ?? ""; 122 var orgText=$("#fr-OrgInsertLink-text-lite").val() ?? ""; 123 var target = ($('#fr-OrgInsertLink-check-lite').prop("checked")) ? '_blank' : '_self'; 124 125 console.log("Inserer lien " + orgLink + " " + orgText) 126 127 if(orgLink!="" && orgText!="") { 128 editor.link.insert(orgLink, orgText, {'target': target, 'rel': 'nofollow'}); 129 $("#fr-OrgInsertLink-url-lite").val(""); 130 $("#fr-OrgInsertLink-text-lite").val(""); 131 } 132 } 133 function linkImgInsert() { 134 var orgLink=$("#fr-OrgInsertLinkImg-url-lite").val(); 135 if(orgLink!="") { 136 editor.image.insert(orgLink, true, {'name':orgLink, 'id':orgLink}); 137 $("#fr-OrgInsertLinkImg-url-lite").val(""); 138 } 139 } 140 141 // Tabulation 142 function orgTabUrl() { 143 if(!$('#fr-OrgInsertLinkLite').hasClass('fr-active')) { 144 $('#fr-OrgInsertLinkLite').addClass('fr-active'); 145 $('#fr-OrgInsertLinkImgLite').removeClass('fr-active') 146 147 $('button#insertUrlLite').addClass('fr-org-active'); 148 $('button#insertUrlImgLite').removeClass('fr-org-active'); 149 } 150 } 151 function orgTabUrlImg() { 152 if(!$('#fr-OrgInsertLinkImgLite').hasClass('fr-active')) { 153 $('#fr-OrgInsertLinkImgLite').addClass('fr-active'); 154 $('#fr-OrgInsertLinkLite').removeClass('fr-active') 155 156 $('button#insertUrlImgLite').addClass('fr-org-active'); 157 $('button#insertUrlLite').removeClass('fr-org-active'); 158 } 159 } 160 161 // Methods visible outside the plugin. 162 return { 163 showPopup: showPopup, 164 hidePopup: hidePopup, 165 166 linkInsert: linkInsert, 167 linkImgInsert: linkImgInsert, 168 169 orgTabUrl: orgTabUrl, 170 orgTabUrlImg: orgTabUrlImg 171 } 172 } 173 174FroalaEditor.DefineIconTemplate('material_design', '<i class="zmdi zmdi-[NAME] fr-org-icon"></i>'); 175FroalaEditor.DefineIcon('orgDocIcon', {NAME: 'attachment-alt', template: 'material_design'}); 176FroalaEditor.RegisterCommand('orgInsertLite', { 177 title: tradInsererUnLien, 178 icon: 'orgDocIcon', 179 undo: false, 180 focus: false, 181 popup: true, 182 // Buttons which are included in the editor toolbar should have the plugin property set. 183 plugin: 'organonInsertLite', 184 callback: function () { 185 if (!this.popups.isVisible('organonInsertLite.popup')) { 186 this.organonInsertLite.showPopup(); 187 } 188 else { 189 if (this.$el.find('.fr-marker')) { 190 this.events.disableBlur(); 191 this.selection.restore(); 192 } 193 this.popups.hide('organonInsertLite.popup'); 194 } 195 } 196}); 197FroalaEditor.RegisterQuickInsertButton('orgInsertLite', { 198 icon: 'orgDocIcon', 199 title: tradInsererUnLien, 200 callback: function () { 201 if (!this.popups.isVisible('organonInsertLite.popup')) { 202 this.organonInsertLite.showPopup(); 203 } 204 else { 205 if (this.$el.find('.fr-marker')) { 206 this.events.disableBlur(); 207 this.selection.restore(); 208 } 209 this.popups.hide('organonInsertLite.popup'); 210 } 211 }, 212 undo: false 213}); 214 215 216 FroalaEditor.RegisterCommand('hidePopupLite', { 217 title: 'hidePopup', 218 undo: false, 219 focus: false, 220 plugin: 'organonInsertLite', 221 callback: function () { 222 this.organonInsertLite.hidePopup(); 223 } 224 }); 225 226 // Insert 227 FroalaEditor.RegisterCommand('linkInsertLite', { 228 title: 'linkInsert', 229 undo: true, 230 focus: false, 231 plugin: 'organonInsertLite', 232 callback: function () { 233 this.organonInsertLite.linkInsert(); 234 } 235 }); 236 FroalaEditor.RegisterCommand('linkImgInsertLite', { 237 title: 'linkImgInsert', 238 undo: true,
239 focus: false, 240 plugin: 'organonInsertLite', 241 callback: function () { 242 this.organonInsertLite.linkImgInsert(); 243 } 244 }); 245 246 247 // Tabulations 248 FroalaEditor.RegisterCommand('orgTabUrlLite', { 249 title: 'orgTabUrl', 250 undo: false, 251 focus: false, 252 callback: function () { 253 this.organonInsertLite.orgTabUrl(); 254 } 255 }); 256 FroalaEditor.RegisterCommand('orgTabUrlImgLite', { 257 title: 'orgTabUrlImg', 258 undo: false, 259 focus: false, 260 callback: function () { 261 this.organonInsertLite.orgTabUrlImg(); 262 } 263 }); 264 265 266 267 268 269 270
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.