jenkins-bot has submitted this change and it was merged.
Change subject: Story 578: Allow photo uploads on pages with infoboxes
......................................................................
Story 578: Allow photo uploads on pages with infoboxes
Allow site to configure when to show photo uploader
This allows us to turn off the feature and tweak it easily
Follow advice in bug 44133 and add variable to startup module
Change-Id: I08f91aa6b960d642802463424f83c93f6387f0d1
---
M MobileFrontend.php
M includes/skins/SkinMinerva.php
M javascripts/modules/mf-photo.js
M tests/javascripts/modules/test_mf-photo.js
4 files changed, 24 insertions(+), 1 deletion(-)
Approvals:
awjrichards: Verified; Looks good to me, approved
jenkins-bot: Verified
diff --git a/MobileFrontend.php b/MobileFrontend.php
index 520ab68..2435803 100644
--- a/MobileFrontend.php
+++ b/MobileFrontend.php
@@ -943,3 +943,10 @@
* Whether or not anonymous (not logged in) users should be able to edit.
*/
$wgMFAnonymousEditing = false;
+
+/**
+ * A css selector which is used by mf-photo.js to test whether to prompt the
user photo uploads on
+ * the current page. When the selector matches no elements the photo uploader
will show.
+ * This is an advanced config variable so use caution in editing.
+ */
+$wgMFLeadPhotoUploadCssSelector = 'img, .navbox';
diff --git a/includes/skins/SkinMinerva.php b/includes/skins/SkinMinerva.php
index 3b7239f..6b0e337 100644
--- a/includes/skins/SkinMinerva.php
+++ b/includes/skins/SkinMinerva.php
@@ -21,6 +21,18 @@
'mobile.stable.universal',
);
$out->addModules( $modules );
+ $out->addJsConfigVars( $this->getSkinConfigVariables() );
+ }
+
+ /**
+ * Returns array of config variables that should be added only to this
skin for use in javascript
+ * @return Array
+ */
+ public function getSkinConfigVariables() {
+ global $wgMFLeadPhotoUploadCssSelector;
+ return array(
+ 'wgMFLeadPhotoUploadCssSelector' =>
$wgMFLeadPhotoUploadCssSelector,
+ );
}
/**
diff --git a/javascripts/modules/mf-photo.js b/javascripts/modules/mf-photo.js
index 361eb47..7bbff1b 100644
--- a/javascripts/modules/mf-photo.js
+++ b/javascripts/modules/mf-photo.js
@@ -31,7 +31,7 @@
$container = $content_0;
}
- return $container.find( 'img, .navbox, .infobox' ).length === 0;
+ return $container.find( mw.config.get(
'wgMFLeadPhotoUploadCssSelector' ) ).length === 0;
}
function isSupported() {
diff --git a/tests/javascripts/modules/test_mf-photo.js
b/tests/javascripts/modules/test_mf-photo.js
index afbc220..433bd48 100644
--- a/tests/javascripts/modules/test_mf-photo.js
+++ b/tests/javascripts/modules/test_mf-photo.js
@@ -1,6 +1,7 @@
( function ( $, M ) {
var photo = M.require( 'photo' ),
+ _wgMFLeadPhotoUploadCssSelector,
articles = [
// blank #content_0
[ $( '<div><div id="content_0"></div></div>' ), true ],
@@ -28,9 +29,12 @@
QUnit.module( 'MobileFrontend photo', {
setup: function() {
+ _wgMFLeadPhotoUploadCssSelector = mw.config.get(
'wgMFLeadPhotoUploadCssSelector' );
+ mw.config.set( 'wgMFLeadPhotoUploadCssSelector', 'img, .navbox,
.infobox' );
this.clock = sinon.useFakeTimers();
},
tearDown: function () {
+ mw.config.set( 'wgMFLeadPhotoUploadCssSelector',
_wgMFLeadPhotoUploadCssSelector );
this.clock.restore();
}
} );
--
To view, visit https://gerrit.wikimedia.org/r/63002
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I08f91aa6b960d642802463424f83c93f6387f0d1
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: JGonera <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: awjrichards <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits