]> _ Git - fluidbook-toolbox.git/commitdiff
wip #7868 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 30 Jan 2026 17:37:45 +0000 (18:37 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 30 Jan 2026 17:37:45 +0000 (18:37 +0100)
resources/linkeditor-stable/js/linkeditor.form.js
resources/linkeditor-stable/style/inc/_form.sass

index 97e4ae5de2bb6d55d1718391306c099fab5a5784..d4fcf16c388eac7f4e7c296e4caff972adbb282e 100644 (file)
@@ -55,6 +55,10 @@ LinkeditorForm.prototype = {
             return true;
         });
 
+        $(document).on('change keyup keydown', '#linkeditor-panel-form [name="to"]', function () {
+            $this.updateShortLinks();
+        });
+
         setInterval(function () {
             if ($(document.activeElement).is('.sp-input')) {
                 var v = $(document.activeElement).val();
@@ -277,23 +281,37 @@ LinkeditorForm.prototype = {
         $(form).data('link', link);
         $(form).find('.init-tooltip').removeClass('init-tooltip');
         this.updateFormData(form);
-        if (SHORTENED_LINKS[$(form).find('[name="to"]').val()] !== undefined) {
-            $(form).find('[name="to"]').after('<p class="help-block">' + TRANSLATIONS['short_link'] + ': <strong>' + SHORTENED_LINKS[$(form).find('[name="to"]').val()] + '</strong></p>');
-        }
 
         container.append(form);
+
+        this.updateShortLinks();
         this.linkeditor.initTooltips();
 
         this.initSpectrum();
         $(".bunchmultiple").bunchmultiple();
         this.initSelect2();
 
-
         if ($(link).is('.new')) {
             this.focusAndSelectDestinationField();
         }
     },
 
+    updateShortLinks: function () {
+        let fto = $('#linkeditor-panel-form').find('[name="to"]');
+        console.log(fto);
+        if (fto.length === 0) {
+            return;
+        }
+        let val = $(fto).val();
+        if (SHORTENED_LINKS[val] !== undefined) {
+            $(fto).after('<p class="help-block">' + TRANSLATIONS.short_link + ': <strong><a href="' + SHORTENED_LINKS[val] + '" target="_blank">' + SHORTENED_LINKS[val].replace('https://', '') + '</a></strong></p>');
+            $(fto).addClass('short');
+        } else {
+            $(fto).next('.help-block').remove();
+            $(fto).removeClass('short');
+        }
+    },
+
     updateFormData: function (form) {
         var $this = this;
         try {
index d880237a549496e78fd6115c8df5ed5a091f3794..52c9d9ab363fb343b53b6843ad683e6f196df864 100644 (file)
@@ -135,6 +135,11 @@ button
         padding-top: 2px
         white-space: normal
 
+        a
+            color: var(--form-text-color)
+            text-decoration: underline
+
+
     .freefile-file
         position: relative