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
8c6ae374
Commit
8c6ae374
authored
Feb 15, 2017
by
Rafael Ostertag
Browse files
Retain placeholders when expanding template. This allows for re-expand.
parent
2fbe6110
Changes
1
Show whitespace changes
Inline
Side-by-side
javascript/src/FieldTemplate.js
View file @
8c6ae374
...
...
@@ -25,14 +25,15 @@ var QfqNS = QfqNS || {};
return
;
}
var
expandedTemplate
=
n
.
replacePlaceholder
(
$template
.
text
(),
lines
);
var
deserializedTemplate
=
n
.
deserializeTemplateAndRetainPlaceholders
(
$template
.
text
());
n
.
expandRetainedPlaceholders
(
deserializedTemplate
,
lines
);
$target
.
append
(
expand
edTemplate
);
$target
.
append
(
deserializ
edTemplate
);
};
n
.
initializeFields
=
function
(
element
,
templateSelectorData
)
{
var
$element
=
$
(
element
);
var
templateSelector
,
escapedTemplateSelector
,
$template
,
$
deserializedTemplate
,
expandedTemplate
;
var
templateSelector
,
escapedTemplateSelector
,
$template
,
deserializedTemplate
;
if
(
$element
.
children
().
length
>
0
)
{
// already initialized
...
...
@@ -44,18 +45,52 @@ var QfqNS = QfqNS || {};
$template
=
$
(
escapedTemplateSelector
);
expandedTemplate
=
n
.
replacePlaceholder
(
$template
.
text
(),
0
);
deserializedTemplate
=
n
.
deserializeTemplateAndRetainPlaceholders
(
$template
.
text
());
n
.
expandRetainedPlaceholders
(
deserializedTemplate
,
0
);
$deserializedTemplate
=
$
(
expandedTemplate
);
$deserializedTemplate
.
find
(
'
.qfq-delete-button
'
).
remove
();
$element
.
append
(
$deserializedTemplate
);
deserializedTemplate
.
find
(
'
.qfq-delete-button
'
).
remove
();
$element
.
append
(
deserializedTemplate
);
};
n
.
removeFields
=
function
(
target
)
{
$
(
target
).
closest
(
'
.qfq-line
'
).
remove
();
};
/**
* @private
* @param template
*/
n
.
deserializeTemplateAndRetainPlaceholders
=
function
(
template
)
{
var
$deserializedTemplate
=
$
(
template
);
$deserializedTemplate
.
find
(
"
*
"
).
each
(
function
()
{
var
$element
=
$
(
this
);
$
.
each
(
this
.
attributes
,
function
()
{
if
(
this
.
value
.
indexOf
(
'
%d
'
)
!==
-
1
)
{
$element
.
data
(
this
.
name
,
this
.
value
);
}
});
});
return
$deserializedTemplate
;
};
/**
* @private
* @param
*/
n
.
expandRetainedPlaceholders
=
function
(
$elements
,
value
)
{
$elements
.
find
(
'
*
'
).
each
(
function
()
{
var
$element
=
$
(
this
);
$
.
each
(
this
.
attributes
,
function
()
{
var
retainedPlaceholder
=
$element
.
data
(
this
.
name
);
if
(
retainedPlaceholder
)
{
this
.
value
=
n
.
replacePlaceholder
(
retainedPlaceholder
,
value
);
}
});
});
};
/**
* @private
* @param targetSelector
...
...
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