handle term selection from criteria (#4480)
This commit is contained in:
parent
857011677d
commit
dbf6acb98f
|
@ -51,20 +51,32 @@ function prep_thesaurus_overlay() {
|
|||
});
|
||||
$('.overlay-ajax button').click(function() {
|
||||
overlay_id = $(this).parents('.overlay-ajax').attr('id');
|
||||
field = $('a[rel="#' + overlay_id + '"]').parents('.field');
|
||||
var id = $(this).parents('.overlay-ajax').data('keyword-id');
|
||||
var title = $(this).parents('.overlay-ajax').find('h1').text();
|
||||
$(field).find('select').append('<option id="' + id + '" selected="selected" value="' + id + '"></option>');
|
||||
$(field).find('.selected-options').append('<span class="selected-option" data-term-id="' + id + '">' +
|
||||
'<span>' + title + '</span>' +
|
||||
'<span class="remove">×</span></span>\n');
|
||||
|
||||
$('span.remove').unbind('click').click(function() {
|
||||
var field = $(this).parents('.field');
|
||||
var term_id = $(this).parent().attr('data-term-id');
|
||||
$(field).find('select option[id=' + term_id + ']').remove();
|
||||
$(this).parent().remove();
|
||||
});
|
||||
/* when used as a field widget */
|
||||
field = $('a[rel="#' + overlay_id + '"]').parents('.field');
|
||||
if (field) {
|
||||
$(field).find('select').append('<option id="' + id + '" selected="selected" value="' + id + '"></option>');
|
||||
$(field).find('.selected-options').append('<span class="selected-option" data-term-id="' + id + '">' +
|
||||
'<span>' + title + '</span>' +
|
||||
'<span class="remove">×</span></span>\n');
|
||||
|
||||
$('span.remove').unbind('click').click(function() {
|
||||
var field = $(this).parents('.field');
|
||||
var term_id = $(this).parent().attr('data-term-id');
|
||||
$(field).find('select option[id=' + term_id + ']').remove();
|
||||
$(this).parent().remove();
|
||||
});
|
||||
}
|
||||
|
||||
/* when used as a criteria widget */
|
||||
criteria = $('a[rel="#' + overlay_id + '"]').parents('.criteria');
|
||||
if (criteria) {
|
||||
$(criteria).find('input.queryvalue').val(id);
|
||||
$(criteria).find('input.querylabel').val(title);
|
||||
$.querywidget.updateSearch();
|
||||
}
|
||||
|
||||
$(this).parents('.overlay-ajax').find('.close').click();
|
||||
return false;
|
||||
|
|
Reference in New Issue