Skip to content
Snippets Groups Projects
Commit 242f168e authored by Marc Egger's avatar Marc Egger
Browse files

experimentation

parent 0c9c9c1d
No related branches found
No related tags found
2 merge requests!375Merge dev to master,!370experimentation
Pipeline #3310 passed
...@@ -44,6 +44,11 @@ var QfqNS = QfqNS || {}; ...@@ -44,6 +44,11 @@ var QfqNS = QfqNS || {};
} }
}; };
var url = n.TypeAhead.makeUrl(typeahead_endpoint, $element);
url = url.replace('%QUERY', '');
console.log(url);
$.getJSON(url, {}, console.log); // API by hand
// initialize typeahead (either with or without tags) // initialize typeahead (either with or without tags)
if ($element.data('typeahead-tags')) { if ($element.data('typeahead-tags')) {
n.TypeAhead.installWithTags($element, bloodhoundConfiguration); n.TypeAhead.installWithTags($element, bloodhoundConfiguration);
...@@ -138,6 +143,19 @@ var QfqNS = QfqNS || {}; ...@@ -138,6 +143,19 @@ var QfqNS = QfqNS || {};
tagApi.tagsManager('pushTag', tag.value); tagApi.tagsManager('pushTag', tag.value);
}); });
console.log(JSON.parse(JSON.stringify(n.TypeAhead.getMinLength($element))));
function suggestionsWithDefaults(q, sync, async) {
if (q === '') {
sync(suggestions.index.all().slice(0, 2)); // slice(start,end)
// suggestions.search('', sync, async);
}
else {
suggestions.search(q, sync, async);
}
}
$inputField.data('bloodhound', suggestions);
// add typahead // add typahead
$inputField.typeahead({ $inputField.typeahead({
// options // options
...@@ -146,7 +164,7 @@ var QfqNS = QfqNS || {}; ...@@ -146,7 +164,7 @@ var QfqNS = QfqNS || {};
minLength: n.TypeAhead.getMinLength($element) minLength: n.TypeAhead.getMinLength($element)
}, { }, {
display: 'value', display: 'value',
source: suggestions, source: suggestionsWithDefaults,
limit: n.TypeAhead.getLimit($element), limit: n.TypeAhead.getLimit($element),
templates: { templates: {
suggestion: function (obj) { suggestion: function (obj) {
...@@ -199,7 +217,6 @@ var QfqNS = QfqNS || {}; ...@@ -199,7 +217,6 @@ var QfqNS = QfqNS || {};
}; };
})($element, suggestions)); })($element, suggestions));
$element.typeahead({ $element.typeahead({
// options // options
hint: n.TypeAhead.getHint($element), hint: n.TypeAhead.getHint($element),
...@@ -308,7 +325,7 @@ var QfqNS = QfqNS || {}; ...@@ -308,7 +325,7 @@ var QfqNS = QfqNS || {};
}; };
n.TypeAhead.getMinLength = function ($element) { n.TypeAhead.getMinLength = function ($element) {
return $element.data('typeahead-minlength') || 2; return $element.data('typeahead-minlength') !== undefined ? $element.data('typeahead-minlength') : 2;
}; };
n.TypeAhead.getHighlight = function ($element) { n.TypeAhead.getHighlight = function ($element) {
......
...@@ -144,9 +144,10 @@ ...@@ -144,9 +144,10 @@
<input id="tags1" type="hidden" class="form-control qfq-typeahead" name="tags1" <input id="tags1" type="hidden" class="form-control qfq-typeahead" name="tags1"
data-typeahead-sip="abcdef" data-typeahead-sip="abcdef"
data-typeahead-limit="10" data-typeahead-limit="10"
data-typeahead-minlength="1" data-typeahead-minlength="0"
data-typeahead-tags="true" data-typeahead-tags="true"
data-typeahead-pedantic="0"
data-typeahead-tag-delimiters="[9, 13]" data-typeahead-tag-delimiters="[9, 13]"
value="<?php echo $tagsSafeJson; ?>" value="<?php echo $tagsSafeJson; ?>"
> >
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment