Werdna has uploaded a new change for review.
https://gerrit.wikimedia.org/r/192794
Change subject: Turn config variables starting with $ into jQuery objects on
the client side
......................................................................
Turn config variables starting with $ into jQuery objects on the client side
Change-Id: Idf0495e79c904945b6f0c8f7e635f70c07434c5b
---
M resources/defer.js
1 file changed, 23 insertions(+), 9 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/OOUIPlayground
refs/changes/94/192794/1
diff --git a/resources/defer.js b/resources/defer.js
index a2476ae..88b0e03 100644
--- a/resources/defer.js
+++ b/resources/defer.js
@@ -11,6 +11,21 @@
.text( 'Unable to load ' + className );
}
+ preprocessConfig( config );
+
+ // Pass out errors
+ if ( error ) {
+ return error;
+ }
+
+ if ( className === 'FieldLayout' ) {
+ return new OO.ui[className]( config.items.shift(),
config );
+ } else {
+ return new OO.ui[className]( config );
+ }
+ }
+
+ function preprocessConfig( config ) {
if ( config.items ) {
newItems = [];
$.each( config.items, function( index, item ) {
@@ -27,16 +42,15 @@
config.items = newItems;
}
- // Pass out errors
- if ( error ) {
- return error;
- }
+ $.each( config, function( name, value ) {
+ if ( String(name).substr( 0, 1 ) === '$' ) {
+ config[name] = $( value );
+ }
- if ( className === 'FieldLayout' ) {
- return new OO.ui[className]( config.items.shift(),
config );
- } else {
- return new OO.ui[className]( config );
- }
+ if ( typeof value === 'object' ) {
+ preprocessConfig( value );
+ }
+ } );
}
$( '.ooui-deferred' ).each( function() {
--
To view, visit https://gerrit.wikimedia.org/r/192794
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idf0495e79c904945b6f0c8f7e635f70c07434c5b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/OOUIPlayground
Gerrit-Branch: master
Gerrit-Owner: Werdna <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits