Foxtrott has submitted this change and it was merged.
Change subject: Fix calling init functions of input types
......................................................................
Fix calling init functions of input types
When the init function is in a namespace different from 'window' the name needs
to be "unpacked".
Bug: T126770
Change-Id: I6534080c56489ce405bd3de7a5a4bf608ecb98ec
---
M libs/SemanticForms.js
1 file changed, 11 insertions(+), 2 deletions(-)
Approvals:
Foxtrott: Verified; Looks good to me, approved
jenkins-bot: Checked
diff --git a/libs/SemanticForms.js b/libs/SemanticForms.js
index 523a9fa..115d886 100644
--- a/libs/SemanticForms.js
+++ b/libs/SemanticForms.js
@@ -1368,6 +1368,15 @@
inputID,
validationFunctionData;
+ function getFunctionFromName( functionName ) {
+ var func = window;
+ var namespaces = functionName.split( "." );
+ for ( var i = 0; i < namespaces.length; i++ ) {
+ func = func[ namespaces[ i ] ];
+ }
+ return func;
+ }
+
// Initialize inputs created by #forminput.
if ( $('.sfFormInput').length > 0 ) {
$('.autocompleteInput').attachAutocomplete();
@@ -1383,7 +1392,7 @@
for ( inputID in initFunctionData ) {
for ( i in initFunctionData[inputID] ) {
/*jshint -W069 */
- $( '#' + inputID ).SemanticForms_registerInputInit(
window[initFunctionData[ inputID ][ i ][ 'name' ]], initFunctionData[ inputID
][ i ][ 'param' ] );
+ $( '#' + inputID ).SemanticForms_registerInputInit(
getFunctionFromName( initFunctionData[ inputID ][ i ][ 'name' ] ),
initFunctionData[ inputID ][ i ][ 'param' ] );
/*jshint +W069 */
}
}
@@ -1393,7 +1402,7 @@
for ( inputID in validationFunctionData ) {
for ( i in validationFunctionData[inputID] ) {
/*jshint -W069 */
- $( '#' + inputID
).SemanticForms_registerInputValidation( window[validationFunctionData[ inputID
][ i ][ 'name' ]], validationFunctionData[ inputID ][ i ][ 'param' ] );
+ $( '#' + inputID
).SemanticForms_registerInputValidation( getFunctionFromName(
validationFunctionData[ inputID ][ i ][ 'name' ] ), validationFunctionData[
inputID ][ i ][ 'param' ] );
/*jshint +W069 */
}
}
--
To view, visit https://gerrit.wikimedia.org/r/270334
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I6534080c56489ce405bd3de7a5a4bf608ecb98ec
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SemanticForms
Gerrit-Branch: master
Gerrit-Owner: Foxtrott <[email protected]>
Gerrit-Reviewer: Foxtrott <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits