Revert "update to work with latest plone.formwidget.autocomplete"
Other modules are not yet ready to work with that version, so let's keep
working with the older one (pinned at 21bb71).
This reverts commit 83770551bb
.
Conflicts:
src/collective/dms/thesaurus/browser/thesaurusview.py
This commit is contained in:
parent
5fff25c340
commit
75e3a22a4e
|
@ -29,14 +29,13 @@
|
|||
</div>
|
||||
|
||||
<script type="text/javascript" tal:condition="python: 'ajax_load' not in request.form.keys()">
|
||||
function autocomplete_ready(event, ui) {
|
||||
window.location=window.location+'/'+ui.item.value;
|
||||
function autocomplete_ready(event, data, formatted) {
|
||||
window.location=window.location+'/'+data[1];
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$('.keyword-search').autocomplete({'source': 'listKeywords',
|
||||
'cacheLength': 0, 'matchContains': true, 'scroll': true, 'max': 30,
|
||||
'select': autocomplete_ready});
|
||||
$('.keyword-search').autocomplete_pfa('listKeywords', {
|
||||
'cacheLength': 0, 'matchContains': true, 'scroll': true, 'max': 30}).result(autocomplete_ready);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
@ -74,17 +73,16 @@ function prep_thesaurus_overlay() {
|
|||
|
||||
prep_thesaurus_overlay();
|
||||
|
||||
function autocomplete_ready(event, ui) {
|
||||
var keyword_id = ui.item.value;
|
||||
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+'/' + keyword_id + '?ajax_load=123 #content>*', prep_thesaurus_overlay);
|
||||
$('.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({'source': thesaurus_url + '/listKeywords',
|
||||
'cacheLength': 0, 'matchContains': true, 'scroll': true, 'max': 30,
|
||||
'select': autocomplete_ready});
|
||||
$('.keyword-search').autocomplete_pfa(thesaurus_url + '/listKeywords', {
|
||||
'cacheLength': 0, 'matchContains': true, 'scroll': true, 'max': 30}).result(autocomplete_ready);
|
||||
|
||||
|
||||
</script>
|
||||
|
|
|
@ -54,6 +54,6 @@
|
|||
padding-top: 1ex;
|
||||
}
|
||||
|
||||
ul.ui-autocomplete.ui-front {
|
||||
z-index: 12000;
|
||||
#form-widgets-keyword_search {
|
||||
width: 100%;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import json
|
||||
import re
|
||||
|
||||
from zope.interface import implementer
|
||||
|
@ -118,10 +117,9 @@ class ListKeywordsView(BrowserView):
|
|||
return self._items
|
||||
|
||||
def __call__(self):
|
||||
self.request.response.setHeader('Content-type', 'application/json')
|
||||
|
||||
query_string = unicode(self.request.form.get('term'), 'utf-8')
|
||||
self.request.response.setHeader('Content-type', 'text/plain')
|
||||
|
||||
query_string = unicode(self.request.form.get('q'), 'utf-8')
|
||||
query_terms = [normalizer.normalize(x) for x in query_string.split()]
|
||||
|
||||
startswith = []
|
||||
|
@ -134,7 +132,7 @@ class ListKeywordsView(BrowserView):
|
|||
if not term in title.lower():
|
||||
break
|
||||
else:
|
||||
item = {'label': title, 'value': id}
|
||||
item = '%s|%s' % (title, id)
|
||||
if title.lower().startswith(q):
|
||||
startswith.append((normalized, item))
|
||||
continue
|
||||
|
@ -154,8 +152,5 @@ class ListKeywordsView(BrowserView):
|
|||
for item in _list:
|
||||
result.append(item[1])
|
||||
if len(result) > 29:
|
||||
break
|
||||
else:
|
||||
continue
|
||||
break
|
||||
return json.dumps(result)
|
||||
return '\n'.join(result)
|
||||
return '\n'.join(result)
|
||||
|
|
Reference in New Issue