Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
typo3
qfq
Commits
a0d1a575
Commit
a0d1a575
authored
Feb 13, 2020
by
Marc Egger
Browse files
Revert "refs #10117" This makes me sad
This reverts commit
4e0a1025
parent
4e0a1025
Pipeline
#3281
passed with stages
in 3 minutes and 29 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
javascript/src/ElementUpdate.js
View file @
a0d1a575
...
...
@@ -79,7 +79,6 @@ var QfqNS = QfqNS || {};
$element
.
attr
(
attributeName
,
attributeValue
);
if
(
attributeName
.
toLowerCase
()
===
"
value
"
)
{
$element
.
val
(
attributeValue
);
$element
.
trigger
(
'
qfqChange
'
);
}
};
...
...
javascript/src/TypeAhead.js
View file @
a0d1a575
...
...
@@ -62,16 +62,9 @@ var QfqNS = QfqNS || {};
var
suggestions
=
new
Bloodhound
(
bloodhoundConfiguration
);
suggestions
.
initialize
();
// create actual input field
var
$inputField
=
$
(
'
<input/>
'
,
{
type
:
'
text
'
,
class
:
$element
.
attr
(
'
class
'
)
});
$element
.
after
(
$inputField
);
// prevent form submit when enter key is pressed
$
inputField
.
off
(
'
keyup
'
);
$
inputField
.
on
(
'
keypress keyup
'
,
function
(
e
)
{
$
element
.
off
(
'
keyup
'
);
$
element
.
on
(
'
keypress keyup
'
,
function
(
e
)
{
var
code
=
e
.
keyCode
||
e
.
which
;
if
(
code
===
13
)
{
e
.
preventDefault
();
...
...
@@ -98,9 +91,9 @@ var QfqNS = QfqNS || {};
};
// initialize tagsManager
var
tagApi
=
$
inputField
.
tagsManager
({
var
tagApi
=
$
element
.
tagsManager
({
deleteTagsOnBackspace
:
false
,
hiddenTagListName
:
''
,
hiddenTagListName
:
$element
.
attr
(
'
name
'
)
,
tagClass
:
'
qfq-typeahead-tag
'
,
delimiters
:
delimiters
,
validator
:
!!
$element
.
data
(
'
typeahead-pedantic
'
)
?
pedanticValidator
:
null
,
...
...
@@ -117,21 +110,13 @@ var QfqNS = QfqNS || {};
});
// when the hidden input field changes, overwrite value with tag object list
tagApi
.
bind
(
'
tm:hiddenUpdate
'
,
function
(
e
,
tags
)
{
tagApi
.
bind
(
'
tm:hiddenUpdate
'
,
function
(
e
,
tags
,
hiddenInput
)
{
var
tagObjects
=
$
.
map
(
tags
,
function
(
t
)
{
return
existingTags
.
filter
(
function
(
tt
)
{
return
tt
.
value
===
t
;})[
0
];
});
$element
.
val
(
JSON
.
stringify
(
tagObjects
));
});
// if value of hidden field is changed externally, update tagManager
$element
.
on
(
'
qfqChange
'
,
function
()
{
existingTags
=
$element
.
val
()
!==
''
?
JSON
.
parse
(
$element
.
val
())
:
[];
tagApi
.
tagsManager
(
'
empty
'
);
$
.
each
(
existingTags
,
function
(
i
,
tag
)
{
tagApi
.
tagsManager
(
'
pushTag
'
,
tag
.
value
);
});
hiddenInput
.
val
(
JSON
.
stringify
(
tagObjects
));
});
$element
.
removeAttr
(
'
name
'
);
// add existing tags
$
.
each
(
existingTags
,
function
(
i
,
tag
)
{
...
...
@@ -139,7 +124,7 @@ var QfqNS = QfqNS || {};
});
// add typahead
$
inputField
.
typeahead
({
$
element
.
typeahead
({
// options
hint
:
n
.
TypeAhead
.
getHint
(
$element
),
highlight
:
n
.
TypeAhead
.
getHighlight
(
$element
),
...
...
@@ -155,20 +140,20 @@ var QfqNS = QfqNS || {};
// No message if field is not set to pedantic.
notFound
:
(
function
(
$_
)
{
return
function
(
obj
)
{
if
(
!!
$
element
.
data
(
'
typeahead-pedantic
'
))
if
(
!!
$
_
.
data
(
'
typeahead-pedantic
'
))
return
"
<div>'
"
+
n
.
TypeAhead
.
htmlEncode
(
obj
.
query
)
+
"
' not found
"
;
};
})(
$
inputField
)
})(
$
element
)
}
});
// directly add tag when clicked on in typahead menu
$
inputField
.
bind
(
'
typeahead:selected
'
,
function
(
event
,
sugg
)
{
$
element
.
bind
(
'
typeahead:selected
'
,
function
(
event
,
sugg
)
{
tagApi
.
tagsManager
(
"
pushTag
"
,
sugg
.
value
);
});
// update typahead list when typahead changes
$
inputField
.
bind
(
'
typeahead:render
'
,
function
(
event
,
sugg
)
{
$
element
.
bind
(
'
typeahead:render
'
,
function
(
event
,
sugg
)
{
typeaheadList
.
length
=
0
;
typeaheadList
.
push
.
apply
(
typeaheadList
,
sugg
);
});
...
...
mockup/typeahead.php
View file @
a0d1a575
...
...
@@ -141,7 +141,7 @@
</div>
<div
class=
"col-md-6"
>
<input
id=
"tags1"
type=
"
hidden
"
class=
"form-control qfq-typeahead"
name=
"tags1"
<input
id=
"tags1"
type=
"
text
"
class=
"form-control qfq-typeahead"
name=
"tags1"
data-typeahead-sip=
"abcdef"
data-typeahead-limit=
"10"
data-typeahead-minlength=
"1"
...
...
@@ -160,7 +160,7 @@
</div>
<div
class=
"col-md-6"
>
<input
id=
"tags2"
type=
"
hidden
"
class=
"form-control qfq-typeahead"
name=
"tags2"
<input
id=
"tags2"
type=
"
text
"
class=
"form-control qfq-typeahead"
name=
"tags2"
data-typeahead-sip=
"abcdef"
data-typeahead-limit=
"10"
data-typeahead-minlength=
"1"
...
...
Marc Egger
@megger
mentioned in commit
2890924b
·
Feb 14, 2020
mentioned in commit
2890924b
mentioned in commit 2890924bd5bc5d402d1259016a250554d9fbd616
Toggle commit list
Write
Preview
Markdown
is supported
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