Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
typo3
qfq
Commits
5d315ac0
Commit
5d315ac0
authored
Feb 17, 2020
by
Marc Egger
Browse files
Merge branch '10115TypeAheadStaticList' into '10115ThypeAheadStaticList2'
merge changes into fixes See merge request
!254
parents
b2b18e21
cb20b815
Pipeline
#3294
passed with stages
in 3 minutes and 28 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
javascript/src/TypeAhead.js
View file @
5d315ac0
...
...
@@ -158,22 +158,42 @@ var QfqNS = QfqNS || {};
hint
:
n
.
TypeAhead
.
getHint
(
$element
),
highlight
:
n
.
TypeAhead
.
getHighlight
(
$element
),
minLength
:
n
.
TypeAhead
.
getMinLength
(
$element
)
},
{
},
{
display
:
'
value
'
,
source
:
suggestions
,
limit
:
n
.
TypeAhead
.
getLimit
(
$element
),
templates
:
{
header
:
'
<h3 class="league-name">API</h3>
'
,
suggestion
:
function
(
obj
)
{
return
"
<div>
"
+
n
.
TypeAhead
.
htmlEncode
(
obj
.
value
)
+
"
</div>
"
;
},
// No message if field is not set to pedantic.
notFound
:
(
function
(
$_
)
{
return
function
(
obj
)
{
if
(
!!
$element
.
data
(
'
typeahead-pedantic
'
))
return
"
<div>'
"
+
n
.
TypeAhead
.
htmlEncode
(
obj
.
query
)
+
"
' not found
"
;
if
(
!!
$element
.
data
(
'
typeahead-pedantic
'
)
&&
typeaheadList
.
length
===
0
)
return
"
<div>'
"
+
n
.
TypeAhead
.
htmlEncode
(
obj
.
query
)
+
"
' not found
"
+
JSON
.
stringify
(
typeaheadList
)
;
};
})(
$inputField
)
}
},
{
display
:
'
value
'
,
source
:
n
.
TypeAhead
.
substringMatcher
([
'
one
'
,
'
two
'
,
'
three
'
,
'
four
'
,
'
five
'
,
'
six
'
,
'
seven
'
,
'
eight
'
,
'
nine
'
]),
// suggestions,
limit
:
n
.
TypeAhead
.
getLimit
(
$element
),
templates
:
{
header
:
'
<h3 class="league-name">List</h3>
'
,
suggestion
:
function
(
obj
)
{
return
"
<div>
"
+
n
.
TypeAhead
.
htmlEncode
(
obj
.
value
)
+
"
</div>
"
;
}
// ,
// // No message if field is not set to pedantic.
// notFound: (function ($_) {
// return function (obj) {
// if (!!$element.data('typeahead-pedantic'))
// return "<div>'" + n.TypeAhead.htmlEncode(obj.query) + "' not found";
// };
// })($inputField)
}
});
// directly add tag when clicked on in typahead menu
...
...
@@ -286,6 +306,27 @@ var QfqNS = QfqNS || {};
}
};
n
.
TypeAhead
.
substringMatcher
=
function
(
strs
)
{
return
function
findMatches
(
q
,
cb
)
{
var
matches
,
substringRegex
;
// an array that will be populated with substring matches
matches
=
[];
// regex used to determine if a string contains the substring `q`
var
substrRegex
=
new
RegExp
(
q
,
'
i
'
);
// iterate through the pool of strings and for any string that
// contains the substring `q`, add it to the `matches` array
$
.
each
(
strs
,
function
(
i
,
str
)
{
if
(
substrRegex
.
test
(
str
))
{
matches
.
push
({
key
:
str
,
value
:
str
});
}
});
cb
(
matches
);
};
};
n
.
TypeAhead
.
makePedanticHandler
=
function
(
bloodhound
)
{
return
function
(
event
)
{
...
...
mockup/typeahead.php
View file @
5d315ac0
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment