summaryrefslogtreecommitdiffstats
path: root/src/collective/dms/thesaurus/browser/dmsthesaurus_view.pt
diff options
context:
space:
mode:
Diffstat (limited to 'src/collective/dms/thesaurus/browser/dmsthesaurus_view.pt')
-rw-r--r--src/collective/dms/thesaurus/browser/dmsthesaurus_view.pt36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/collective/dms/thesaurus/browser/dmsthesaurus_view.pt b/src/collective/dms/thesaurus/browser/dmsthesaurus_view.pt
index b7cb276..f4c1897 100644
--- a/src/collective/dms/thesaurus/browser/dmsthesaurus_view.pt
+++ b/src/collective/dms/thesaurus/browser/dmsthesaurus_view.pt
@@ -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;