Robmoen has uploaded a new change for review.
https://gerrit.wikimedia.org/r/240921
Change subject: Final tweaks to QuickSurvey panel placement.
......................................................................
Final tweaks to QuickSurvey panel placement.
* On mobile, places panel after the first p element with content
* On desktop, places panel before first infobox, thumb, or heading
* Otherwise, places panel at the end of the article
Bug: T113651
Change-Id: Iad47e72ff5eaae82ec51546255d8c6ba274fad8e
---
M resources/ext.quicksurveys.init/init.js
1 file changed, 19 insertions(+), 8 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/QuickSurveys
refs/changes/21/240921/1
diff --git a/resources/ext.quicksurveys.init/init.js
b/resources/ext.quicksurveys.init/init.js
index 08d2bc8..cf1adbc 100644
--- a/resources/ext.quicksurveys.init/init.js
+++ b/resources/ext.quicksurveys.init/init.js
@@ -26,20 +26,31 @@
/**
* Insert the quick survey panel into the article either (in priority
order)
- * before the first instance of a thumbnail,
- * before the first instance of a heading
- * or at the end of the article when no headings nor thumbnails exist
+ * On mobile: after the first p element with content
+ * On desktop: before the first instance of a infobox, thumb, or heading
+ * Or after the article when no infobox, thumbnails or headings exist
+ *
* @param {jQuery.Object} $panel
*/
function insertPanel( $panel ) {
var $bodyContent = $( '.mw-content-ltr, .mw-content-rtl' ),
- $place = $bodyContent
- .find( '.infobox, > .thumb, > h1, > h2, > h3, >
h4, > h5, > h6' )
- .eq( 0 );
+ $place;
- if ( $place.length ) {
- $panel.insertBefore( $place );
+ if ( window.innerWidth <= 768 ) {
+ $bodyContent.find( '> div > p' ).each( function() {
+ if ( $.trim( $( this ).text() ).length > 0 ) {
+ $panel.insertAfter( $( this ) );
+ return false;
+ }
+ } );
} else {
+ $panel.insertBefore( $bodyContent
+ .find( '.infobox, .thumb, > h1, > h2, > h3, >
h4, > h5, > h6' )
+ .eq( 0 )
+ );
+ }
+
+ if ( $panel.length === 0 ) {
$panel.appendTo( $bodyContent );
}
}
--
To view, visit https://gerrit.wikimedia.org/r/240921
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iad47e72ff5eaae82ec51546255d8c6ba274fad8e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/QuickSurveys
Gerrit-Branch: dev
Gerrit-Owner: Robmoen <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits