Werdna has uploaded a new change for review.
https://gerrit.wikimedia.org/r/92490
Change subject: Improve JS initialisation function handling.
......................................................................
Improve JS initialisation function handling.
* Move init.js to the base class.
* Instead of listening to an event handler, call a "registerInitFunction" Flow
function,
which both registers the event handler for the future *and* runs it on all
already-initialised
Flow containers.
* Hopefully fixes bug 56134, which was probably caused by inconsistent load
order meaning that
not all initialisation functions were being registered before the flow_init
event was triggered.
Change-Id: I3a7d517853a8b4993cf6918d30cfdd6b8a8fddea
---
M Resources.php
A modules/base/init.js
M modules/base/ui-functions.js
M modules/discussion/forms.js
D modules/discussion/init.js
M modules/discussion/paging.js
M modules/discussion/ui.js
M modules/header/forms.js
8 files changed, 25 insertions(+), 10 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow
refs/changes/90/92490/1
diff --git a/Resources.php b/Resources.php
index 1e3c47f..3900688 100644
--- a/Resources.php
+++ b/Resources.php
@@ -24,6 +24,7 @@
'scripts' => array(
'base/ext.flow.base.js',
'base/ui-functions.js',
+ 'base/init.js',
),
'dependencies' => array(
'mediawiki.ui',
@@ -52,7 +53,6 @@
'discussion/ui.js',
'discussion/forms.js',
'discussion/paging.js',
- 'discussion/init.js',
),
'dependencies' => array(
'jquery.ui.core',
diff --git a/modules/base/init.js b/modules/base/init.js
new file mode 100644
index 0000000..ff9519f
--- /dev/null
+++ b/modules/base/init.js
@@ -0,0 +1,9 @@
+( function ( $, mw ) {
+ $( function () {
+ $( '.flow-container' ).trigger( 'flow_init' );
+ } );
+
+ $( document ).on( 'flow_init', function(e) {
+ $( e.target ).addClass( 'flow-initialised ' );
+ } );
+} )( jQuery, mediaWiki );
diff --git a/modules/base/ui-functions.js b/modules/base/ui-functions.js
index aad66a3..b6ed885 100644
--- a/modules/base/ui-functions.js
+++ b/modules/base/ui-functions.js
@@ -13,6 +13,17 @@
},
'_flow' : {
+ 'registerInitFunction' : function( callback ) {
+ $( this ).on( 'flow_init', callback );
+
+ $( '.flow-initialised' ).each( function() {
+ callback.apply( this, [ {
+ 'type' : 'flow_init',
+ 'target' : this
+ } ] );
+ } );
+ },
+
/**
* Checks on every keyup if all fieldSelectors are
filled out and
* (if so) enabled submitSelector.
diff --git a/modules/discussion/forms.js b/modules/discussion/forms.js
index 2ee3544..1bad124 100644
--- a/modules/discussion/forms.js
+++ b/modules/discussion/forms.js
@@ -1,5 +1,5 @@
( function ( $, mw ) {
-$( document ).on( 'flow_init', function ( e ) {
+$( document ).flow( 'registerInitFunction', function(e) {
var $container = $( e.target );
$container.find( 'form.flow-reply-form' ).flow( 'setupEmptyDisabler',
['.flow-reply-content'],
diff --git a/modules/discussion/init.js b/modules/discussion/init.js
deleted file mode 100644
index 055ce90..0000000
--- a/modules/discussion/init.js
+++ /dev/null
@@ -1,5 +0,0 @@
-( function ( $, mw ) {
- $( function () {
- $( '.flow-container' ).trigger( 'flow_init' );
- } );
-} )( jQuery, mediaWiki );
diff --git a/modules/discussion/paging.js b/modules/discussion/paging.js
index 456dac8..1a25eb5 100644
--- a/modules/discussion/paging.js
+++ b/modules/discussion/paging.js
@@ -21,7 +21,7 @@
);
};
- $( document ).on( 'flow_init', function () {
+ $( document ).flow( 'registerInitFunction', function () {
$( this ).find( '.flow-paging a' ).click( function ( e ) {
e.preventDefault();
var $pagingLinkDiv = $( this ).closest( '.flow-paging' )
diff --git a/modules/discussion/ui.js b/modules/discussion/ui.js
index 703e771..39c8112 100644
--- a/modules/discussion/ui.js
+++ b/modules/discussion/ui.js
@@ -1,5 +1,5 @@
( function ( $, mw ) {
- $( document ).on( 'flow_init', function ( e ) {
+ $( document ).flow( 'registerInitFunction', function ( e ) {
var $container = $( e.target );
// Set up menus
diff --git a/modules/header/forms.js b/modules/header/forms.js
index b49e281..232ccda 100644
--- a/modules/header/forms.js
+++ b/modules/header/forms.js
@@ -1,5 +1,5 @@
( function( $, mw ) {
-$( document ).on( 'flow_init', function ( e ) {
+$( document ).flow( 'registerInitFunction', function ( e ) {
$container = $( e.target );
// Overload "edit header" link.
$container.find( '.flow-header-edit-link' )
--
To view, visit https://gerrit.wikimedia.org/r/92490
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3a7d517853a8b4993cf6918d30cfdd6b8a8fddea
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Werdna <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits