jenkins-bot has submitted this change and it was merged.
Change subject: Add a placeholder into an empty transclusion
......................................................................
Add a placeholder into an empty transclusion
If a template was setup without a default output and returns an empty result
to the transclusion, the user could not access the template dialog because
there was nowhere to hover over to get it visible. This commit checks the
output from the template after it was rendered with the given parameters
and if it returns empty, it adds a placeholder to the output so to give
the users way to access that template's transclusion dialog and edit
or remove it.
Bug: 55810
Change-Id: Ib842b401e74d79b6382cada6bb7c6048b713977c
---
M modules/ve-mw/ce/nodes/ve.ce.MWTransclusionNode.js
1 file changed, 14 insertions(+), 1 deletion(-)
Approvals:
Trevor Parscal: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/ve-mw/ce/nodes/ve.ce.MWTransclusionNode.js
b/modules/ve-mw/ce/nodes/ve.ce.MWTransclusionNode.js
index d6763d4..cb72535 100644
--- a/modules/ve-mw/ce/nodes/ve.ce.MWTransclusionNode.js
+++ b/modules/ve-mw/ce/nodes/ve.ce.MWTransclusionNode.js
@@ -91,7 +91,7 @@
* @param {Object} response Response data
*/
ve.ce.MWTransclusionNode.prototype.onParseSuccess = function ( deferred,
response ) {
- var contentNodes;
+ var contentNodes, $placeHolder;
if ( !response || response.error || !response.visualeditor ||
response.visualeditor.result !== 'success' ) {
return this.onParseError.call( this, deferred );
@@ -104,6 +104,19 @@
if ( contentNodes.length === 1 &&
contentNodes[0].nodeName.toLowerCase() === 'p' ) {
contentNodes = Array.prototype.slice.apply(
contentNodes[0].childNodes );
}
+
+ // Check if the final result of the imported template is empty.
+ // If it is empty, put an inline placeholder inside it so that it can
+ // be accessible to users (either to remove or edit)
+ if ( contentNodes.length === 0 ) {
+ $placeHolder = $( '<span>' )
+ .css( { 'display': 'block' } )
+ // adapted from ve.ce.BranchNode.$blockSlugTemplate
+ // IE support may require using
+ .html( '' );
+
+ contentNodes.push( $placeHolder[0] );
+ }
deferred.resolve( contentNodes );
};
--
To view, visit https://gerrit.wikimedia.org/r/90210
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib842b401e74d79b6382cada6bb7c6048b713977c
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Mooeypoo <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Mooeypoo <[email protected]>
Gerrit-Reviewer: Trevor Parscal <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits