$(document).ready(function() {
var textInput;
var textToInput;
var inputText;
var ui = $(window).adaptTo("foundation-ui");
var s = $(document).on("dialog-ready", function() {
textInput = $('.js-coral-pathbrowser-button').parent().prev();
textToInput = $('.js-coral-pathbrowser-button').parent().parent().parent().parent().parent().parent().parent().find("input[name='./page'].coral-Form-field");
$(document).on("click", ".js-coral-pathbrowser-confirm", function() {
setTimeout(function() {
inputText = $(textInput).val();
//$(textToInput).val(inputText.substring(inputText.lastIndexOf("/")+1).split('.')[0]);
if (!$(textToInput).val()) {
$(textToInput).val(inputText.substring(inputText.lastIndexOf("/") + 1));
}
}, 1000);
})
$(document).on('click', '.js-coral-pathbrowser-button', function() {
textInput = $(this).parent().prev();
textToInput = $(this).parent().parent().parent().parent().parent().parent().parent().find("input[name='./page'].coral-Form-field");
})
$(document).on("change", " .js-coral-pathbrowser-input", function() {
inputText = $(this).val();
if (inputText.indexOf("/content") > 0) {
textToInput = $(this).parent().parent().parent().parent().parent().parent().parent().find("input[name='./page'].coral-Form-field");
if (!$(textToInput).val()) {
$(textToInput).val(inputText.substring(inputText.lastIndexOf("/") + 1));
}
}
});
});
});
Change the field selector input[name='./page'].coral-Form-field as per your dialog configuration where the title value is to be auto-populated.
You need to put the above code in a clientlibs JS file with the category "cq.authoring.dialog".
var textInput;
var textToInput;
var inputText;
var ui = $(window).adaptTo("foundation-ui");
var s = $(document).on("dialog-ready", function() {
textInput = $('.js-coral-pathbrowser-button').parent().prev();
textToInput = $('.js-coral-pathbrowser-button').parent().parent().parent().parent().parent().parent().parent().find("input[name='./page'].coral-Form-field");
$(document).on("click", ".js-coral-pathbrowser-confirm", function() {
setTimeout(function() {
inputText = $(textInput).val();
//$(textToInput).val(inputText.substring(inputText.lastIndexOf("/")+1).split('.')[0]);
if (!$(textToInput).val()) {
$(textToInput).val(inputText.substring(inputText.lastIndexOf("/") + 1));
}
}, 1000);
})
$(document).on('click', '.js-coral-pathbrowser-button', function() {
textInput = $(this).parent().prev();
textToInput = $(this).parent().parent().parent().parent().parent().parent().parent().find("input[name='./page'].coral-Form-field");
})
$(document).on("change", " .js-coral-pathbrowser-input", function() {
inputText = $(this).val();
if (inputText.indexOf("/content") > 0) {
textToInput = $(this).parent().parent().parent().parent().parent().parent().parent().find("input[name='./page'].coral-Form-field");
if (!$(textToInput).val()) {
$(textToInput).val(inputText.substring(inputText.lastIndexOf("/") + 1));
}
}
});
});
});
Change the field selector input[name='./page'].coral-Form-field as per your dialog configuration where the title value is to be auto-populated.
You need to put the above code in a clientlibs JS file with the category "cq.authoring.dialog".
No comments:
Post a Comment
If you have any doubts or questions, please let us know.