jenkins-bot has submitted this change and it was merged.
Change subject: mediawiki.page.ready: Use wikipage.content instead of domready
......................................................................
mediawiki.page.ready: Use wikipage.content instead of domready
Restructure mediawiki.page.ready to add to the "wikipage.content"
hook instead of using document-ready.
Except for parts that aren't inside the wikipage content.
Portlet links are outside content entirely and should run only
once from document-ready still. Inputs with placeholders can be
both inside and outside (inside with e.g. InputBox extension,
outside in e.g. search bar of skin) so it needs to be in both.
The one in document-ready needs to exclude ones in content to
avoid applying the placeholder polyfill twice.
This also opens up the doors for extensions and gadgets to
reliably both fire and add to this hook:
- Code can fire this hook when rendering a new DOM (such as
LivePreview, VisualEditor, ..).
- Code can add to this hook to enhance page content and have it
properly re-run when there is a new DOM (e.g. gadgets like
Navigation popups, Reference Tooltips, ..).
Also added release notes for 2e97025.
Bug: 30713
Bug: 33399
Bug: 51565
Change-Id: Icb0eda9edf2aeb3d612ff1d9bfea4859d33e1fbb
---
M RELEASE-NOTES-1.22
M maintenance/jsduck/config.json
M resources/mediawiki.page/mediawiki.page.ready.js
M resources/mediawiki.page/mediawiki.page.startup.js
M resources/mediawiki/mediawiki.js
5 files changed, 36 insertions(+), 13 deletions(-)
Approvals:
Ori.livneh: Looks good to me, approved
jenkins-bot: Verified
diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22
index 0b1cc17..1d5ccae 100644
--- a/RELEASE-NOTES-1.22
+++ b/RELEASE-NOTES-1.22
@@ -158,6 +158,8 @@
titles. Given a list of articles named Bug1, Bug2, you can now transclude the
list of bug numbers using: {{Special:PrefixIndex/Bug|stripprefix=1}}.
The special page form received a new checkbox matching that option.
+* (bug 23580) Implement javascript callback interface "mw.hook".
+* (bug 30713) New mw.hook "wikipage.content".
=== Bug fixes in 1.22 ===
* Disable Special:PasswordReset when $wgEnableEmail is false. Previously one
diff --git a/maintenance/jsduck/config.json b/maintenance/jsduck/config.json
index 6d97900..5cce68d 100644
--- a/maintenance/jsduck/config.json
+++ b/maintenance/jsduck/config.json
@@ -18,6 +18,7 @@
"../../resources/mediawiki/mediawiki.user.js",
"../../resources/mediawiki.action/mediawiki.action.edit.js",
"../../resources/mediawiki.action/mediawiki.action.view.postEdit.js",
+ "../../resources/mediawiki.page/mediawiki.page.startup.js",
"../../resources/mediawiki.api",
"../../resources/jquery/jquery.localize.js"
]
diff --git a/resources/mediawiki.page/mediawiki.page.ready.js
b/resources/mediawiki.page/mediawiki.page.ready.js
index 684f582..ee416d6 100644
--- a/resources/mediawiki.page/mediawiki.page.ready.js
+++ b/resources/mediawiki.page/mediawiki.page.ready.js
@@ -1,28 +1,40 @@
-( function ( mw, $ ) {
- $( function () {
+( function ( mw , $ ) {
+ var supportsPlaceholder = 'placeholder' in document.createElement(
'input' );
+
+ mw.hook( 'wikipage.content' ).add( function ( $content ) {
var $sortableTables;
- /* Emulate placeholder if not supported by browser */
- if ( !( 'placeholder' in document.createElement( 'input' ) ) ) {
- $( 'input[placeholder]' ).placeholder();
+ // Run jquery.placeholder polyfill if placeholder is not
supported
+ if ( !supportsPlaceholder ) {
+ $content.find( 'input[placeholder]' ).placeholder();
}
- /* Enable makeCollapsible */
- $( '.mw-collapsible' ).makeCollapsible();
+ // Run jquery.makeCollapsible
+ $content.find( '.mw-collapsible' ).makeCollapsible();
- /* Lazy load jquery.tablesorter */
- $sortableTables = $( 'table.sortable' );
+ // Lazy load jquery.tablesorter
+ $sortableTables = $content.find( 'table.sortable' );
if ( $sortableTables.length ) {
mw.loader.using( 'jquery.tablesorter', function () {
$sortableTables.tablesorter();
- });
+ } );
}
- /* Enable CheckboxShiftClick */
- $( 'input[type=checkbox]:not(.noshiftselect)'
).checkboxShiftClick();
+ // Run jquery.checkboxShiftClick
+ $content.find( 'input[type="checkbox"]:not(.noshiftselect)'
).checkboxShiftClick();
+ } );
- /* Add accesskey hints to the tooltips */
+ // Things outside the wikipage content
+ $( function () {
+
+ if ( !supportsPlaceholder ) {
+ // Exclude content to avoid hitting it twice for the
(first) wikipage content
+ $( 'input[placeholder]' ).not( '#mw-content-text input'
).placeholder();
+ }
+
+ // Add accesskey hints to the tooltips
mw.util.updateTooltipAccessKeys();
} );
+
}( mediaWiki, jQuery ) );
diff --git a/resources/mediawiki.page/mediawiki.page.startup.js
b/resources/mediawiki.page/mediawiki.page.startup.js
index 1337576..7457e8f 100644
--- a/resources/mediawiki.page/mediawiki.page.startup.js
+++ b/resources/mediawiki.page/mediawiki.page.startup.js
@@ -16,6 +16,11 @@
// mw.util.init), is defined for them.
mw.util.init();
+ /**
+ * @event wikpage_content
+ * @member mw.hook
+ * @param {jQuery} $content
+ */
mw.hook( 'wikipage.content' ).fire( $( '#mw-content-text' ) );
} );
diff --git a/resources/mediawiki/mediawiki.js b/resources/mediawiki/mediawiki.js
index e36d9d0..46b74f1 100644
--- a/resources/mediawiki/mediawiki.js
+++ b/resources/mediawiki/mediawiki.js
@@ -1839,6 +1839,9 @@
* var h = mw.hook( 'bar.ready' );
* new mw.Foo( .. ).fetch( { callback: h.fire } );
*
+ * Note: Events are documented with an underscore instead of a
dot in the event
+ * name due to jsduck not supporting dots in that position.
+ *
* @class mw.hook
*/
hook: ( function () {
--
To view, visit https://gerrit.wikimedia.org/r/74313
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Icb0eda9edf2aeb3d612ff1d9bfea4859d33e1fbb
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>
Gerrit-Reviewer: Daniel Friesen <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: MarkTraceur <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits