Modifications pour le document Url
Modifié par Florent Charton le 2024/08/08 18:44
Depuis la version 1.1
modifié par Florent Charton
sur 2022/06/28 18:01
sur 2022/06/28 18:01
Commentaire de modification :
Install extension [org.xwiki.contrib:application-ckeditor-ui/1.64.2]
À la version 2.1
modifié par Florent Charton
sur 2024/08/08 18:44
sur 2024/08/08 18:44
Commentaire de modification :
Install extension [org.xwiki.platform:xwiki-platform-ckeditor-ui/15.10.11]
Résumé
-
Objets (2 modifications, 0 ajouts, 0 suppressions)
Détails
- XWiki.JavaScriptExtension[0]
-
- Code
-
... ... @@ -1,10 +1,21 @@ 1 1 require(['jquery', 'imageSelector'], function($, imageSelector) { 2 - $('#urlTab input[type="text"]').on('input', function () { 3 - console.log('ON') 4 - if ($(this).val() === '') { 5 - imageSelector.updateSelectedImageReferences([]); 6 - } else { 7 - imageSelector.updateSelectedImageReferences([{type: 'url', reference: $(this).val()}]); 8 - } 2 + function init(element) { 3 + const urlField = element.find('.urlTab input[name="urlField"]') 4 + urlField.on('input', function () { 5 + if ($(this).val() === '') { 6 + imageSelector.updateSelectedImageReferences([], $(this)); 7 + } else { 8 + imageSelector.updateSelectedImageReferences([{type: 'url', reference: $(this).val()}], $(this)); 9 + } 10 + }); 11 + // Enable the field once the javascript is loaded as otherwise a value can be entered before the listener above 12 + // is attached to the element. 13 + urlField.prop( "disabled", false ); 14 + } 15 + 16 + init($(document).find('.image-selector')); 17 + 18 + $(document).on('xwiki:dom:updated', (event, data) => { 19 + data.elements.forEach(element => init($(element))); 9 9 }); 10 10 });
- XWiki.UIExtensionClass[0]
-
- Executed Content
-
... ... @@ -12,7 +12,7 @@ 12 12 </span> 13 13 </dt> 14 14 <dd> 15 - <input name="urlField" type="text" 15 + <input name="urlField" type="text" disabled="disabled" 16 16 placeholder="$escapetool.xml($services.localization.render('ckeditor.plugin.image.imageSelector.urlTab.url.placeholder'))" /> 17 17 </dd> 18 18 </dl>