This repository has been archived on 2023-02-21. You can view files and clone it, but cannot push or open issues or pull requests.
pfwb_thesaurus/pfwb_thesaurus/templates/thesaurus/plone_popup.html

61 lines
2.0 KiB
HTML

{% extends "thesaurus/term_list.html" %}
{% block aftercontent %}
<script>
function thesaurus_popup_init() {
$('#term-content a, #thesaurus-terms a, #thesaurus-quick-search a').unbind('click').click(function() {
$.ajax({
url: $(this).attr('href'),
success: function(data, status) {
$('#thesaurus-quick-search').hide();
$('#entry-points').hide();
$('#term-content').empty();
$(data).find('table').appendTo($('#term-content'));
$('#term-content').find('button').show().click(function() {
var orig_link = $('a[rel=#' + $(this).parents('.overlay-ajax').attr('id') + ']');
var orig_input = $(orig_link).parent().find('input')[0];
var orig_ac_input = $(orig_link).parent().find('input')[1];
$(orig_input).val($(orig_input).val() + ' ' + $(this).attr('data-term-id'));
var labelbox = create_labelbox(
orig_ac_input,
$(this).attr('data-term-id'),
$(this).parent().find('h2').text());
$(orig_link).before(labelbox);
$('.close').click();
});
thesaurus_popup_init();
$('#term-content').show();
}
});
return false;
});
}
$('.pb-ajax').click(function() {
var $search_result_ul = $('#thesaurus-quick-search ul');
$search_result_ul.empty().hide();
});
$('#thesaurus-quick-search input').keyup(function() {
var q = $(this).val();
var $search_result_ul = $('#thesaurus-quick-search ul');
$search_result_ul.empty();
if (q.length == 0) {
$search_result.hide();
return;
}
$.getJSON($(this).data('autocomplete-json'), {'q': q},
function(response) {
$search_result_ul.empty().show();
$(response.data).each(function(idx, elem) {
var new_elem = '<li><a href="' + elem.url + '">' + elem.title + '</a></li>';
$(new_elem).appendTo($search_result_ul);
});
thesaurus_popup_init();
});
});
thesaurus_popup_init();
</script>
{% endblock %}