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.
collective.dms.thesaurus/src/collective/dms/thesaurus/browser/dmsthesaurus_view.pt

108 lines
3.9 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
lang="en"
metal:use-macro="context/main_template/macros/master"
i18n:domain="plone.app.dexterity">
<body>
<metal:main fill-slot="main">
<tal:contents_header condition="python: 'ajax_load' not in request.form.keys()">
<h1 class="documentFirstHeading" tal:content="context/Title" />
<div tal:replace="structure provider:plone.belowcontenttitle" />
</tal:contents_header>
<div id="dmskeywords-navigation"
tal:attributes="data-thesaurus-url context/absolute_url">
<form id="thesaurus-search-form" tal:content="structure view/renderForm">
</form>
<div id="dmsthesaurus-entry-points-field"
class="field"
tal:define="widget python:view.widgets.get('entry_points')">
<label tal:content="widget/label" />
<br />
<div tal:content="structure widget/render" />
</div>
<script type="text/javascript" tal:condition="python: 'ajax_load' not in request.form.keys()">
function autocomplete_ready(event, data, formatted) {
window.location=window.location+'/'+data[1];
}
$(document).ready(function() {
$('.keyword-search').autocomplete('listKeywords', {
'cacheLength': 0, 'matchContains': true, 'scroll': true, 'max': 30}).result(autocomplete_ready);
});
</script>
<script type="text/javascript" tal:condition="python: 'ajax_load' in request.form.keys()">
function prep_thesaurus_overlay() {
$('.overlay-ajax a').click(function() {
var urlsplit = $(this).attr('href').split('/');
var keyword_id = urlsplit[urlsplit.length-1];
$(this).parents('.overlay-ajax').data('keyword-id', keyword_id);
$('.pb-ajax > div').load($(this).attr('href') + '?ajax_load=123 #content>*', prep_thesaurus_overlay);
return false;
});
$('.overlay-ajax button').click(function() {
overlay_id = $(this).parents('.overlay-ajax').attr('id');
var id = $(this).parents('.overlay-ajax').data('keyword-id');
var title = $(this).parents('.overlay-ajax').find('h1').text();
/* 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;
});
}
prep_thesaurus_overlay();
function autocomplete_ready(event, data, formatted) {
var keyword_id = data[1];
$(this).parents('.overlay-ajax').data('keyword-id', keyword_id);
thesaurus_url = $('#dmskeywords-navigation').data('thesaurus-url');
$('.pb-ajax > div').load(thesaurus_url+'/'+data[1] + '?ajax_load=123 #content>*', prep_thesaurus_overlay);
}
thesaurus_url = $('#dmskeywords-navigation').data('thesaurus-url');
$('.keyword-search').autocomplete(thesaurus_url + '/listKeywords', {
'cacheLength': 0, 'matchContains': true, 'scroll': true, 'max': 30}).result(autocomplete_ready);
</script>
</div>
</metal:main>
</body>
</html>