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();
$(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 {