<script>
var current;
var currentIndex=0;
var element;
var topPos;
function showParamsDdl(id)
{
if ( event.which == 123 ) {
topPos=$('#'+id).offset().top;
current = $(event.target);;
$(".custom-combobox-input").focus();
update(id)
}
}
function update(id) {
element= document.getElementById(id);
currentIndex= element.selectionEnd;
var coordinates = getCaretCoordinates(element, element.selectionEnd);
console.log('(top, left) = (%s, %s)', topPos, coordinates.left);
$("#paramsList").css({"margin-left":coordinates.left+20+ 'px', "top":topPos-43+'px'})
$("#paramsList").show().focus();
}
$(document).ready(function(){
/*
$("textarea").keypress(function( event ) {
if ( event.which ==123 ) {
current = $(event.target);
$("#paramsList").show().focus();
$(".custom-combobox-input").focus();
['textarea'].forEach(function (selector) {
var element = document.querySelector(selector);
currentIndex= element.selectionEnd;
['keyup'].forEach(function (event) {
element.addEventListener(event, update);
});
function update() {
var coordinates = getCaretCoordinates(element, element.selectionEnd);
console.log('(top, left) = (%s, %s)', coordinates.top, coordinates.left);
$("#paramsList").css({"margin-left":coordinates.left+20+ 'px', "margin-top":coordinates.top -300+'px'})
}
});
}
});
$( document ).on( 'keydown', function ( e ) {
if ( e.keyCode == 125 ) { // ESC
$("#paramsList").hide()
current.focus().val(current.val().substr(0,(current.val().length -1)));
}
});
*/
// Calling the combobox autocomplete function
$( "#_notifparamconfigs_WAR_ePaymentportlet_combobox" ).combobox();
$(".ui-autocomplete").on("click", function () {
//alert(current.val().substr(0,currentIndex+1) + ($(".custom-combobox-input").val().replace(/^\s\s*/, '').replace(/\s\s*$/, ''))+current.val().substr(currentIndex+2)+"} ");
// alert(($(".custom-combobox-input").val().replace(/^\s\s*/, '').replace(/\s\s*$/, '')));
var content = current.val().substr(0,currentIndex+1) + ($(".custom-combobox-input").val().replace(/^\s\s*/, '').replace(/\s\s*$/, ''))+"} "+current.val().substr(currentIndex+2);//current.val()+($(".custom-combobox-input").val().replace(/^\s\s*/, '').replace(/\s\s*$/, ''))+"} ";
// alert(content)
current.focus().val('').val(content);
$(".custom-combobox-input").val('');
$("#paramsList").hide();
});
});
</script>
<div id="paramsList" style="display:none;">
<h3><i class="fa fa-search-plus"></i> Select Paramter</h3>
<div class="list_cont">
<aui:select name="notifParam" cssClass="combobox" id="combobox" label="">
<% for (NotifParam np: notifParams) { %>
<aui:option label="<%=np.getNameEn() %>" value="<%=np.getParamName() %>" />
<% } %>
</aui:select>
</div>
</div>