Florianschmidtwelzow has uploaded a new change for review.
https://gerrit.wikimedia.org/r/237682
Change subject: Styleing improvements of ReCaptcha NoCaptcha
......................................................................
Styleing improvements of ReCaptcha NoCaptcha
The reCaptcha widget overflows our fixed width login form, which doesn't look
very good. Transform the whole widget to fit the login form.
Also: If MobileFrontend is installed and the request was made with activated
mobile view
(mobile device or mobile view link in footer), use the compact widget, instead
of the normal one (which could be to big for a small screen).
Change-Id: I2670e49a5e7002b3c3d825e06202606b6daa1b4b
---
M ReCaptchaNoCaptcha/ReCaptchaNoCaptcha.class.php
M ReCaptchaNoCaptcha/extension.json
A ReCaptchaNoCaptcha/resources/ext.confirmEdit.reCaptchaNoCaptcha.less
M SimpleCaptcha/Captcha.php
4 files changed, 59 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ConfirmEdit
refs/changes/82/237682/1
diff --git a/ReCaptchaNoCaptcha/ReCaptchaNoCaptcha.class.php
b/ReCaptchaNoCaptcha/ReCaptchaNoCaptcha.class.php
index 7631b82..03a56d9 100644
--- a/ReCaptchaNoCaptcha/ReCaptchaNoCaptcha.class.php
+++ b/ReCaptchaNoCaptcha/ReCaptchaNoCaptcha.class.php
@@ -14,12 +14,17 @@
'g-recaptchascript',
'<script src="https://www.google.com/recaptcha/api.js"
async defer></script>'
);
+
+ $out->addModuleStyles( array(
'ext.confirmEdit.reCaptchaNoCaptcha.styles' ) );
$output = Html::element( 'div', array(
'class' => array(
'g-recaptcha',
'mw-confirmedit-captcha-fail' => !!$this->error,
+ 'mw-confirmedit-captcha-nomobile' =>
!$this->isMobileRequest(),
+ 'mw-confirmedit-captcha-mobile' =>
$this->isMobileRequest(),
),
- 'data-sitekey' => $wgReCaptchaSiteKey
+ 'data-sitekey' => $wgReCaptchaSiteKey,
+ 'data-size' => $this->isMobileRequest() ? 'compact' :
'normal',
) );
$htmlUrlencoded = htmlspecialchars( urlencode(
$wgReCaptchaSiteKey ) );
$output .= <<<HTML
diff --git a/ReCaptchaNoCaptcha/extension.json
b/ReCaptchaNoCaptcha/extension.json
index 25379bc..e8e9274 100644
--- a/ReCaptchaNoCaptcha/extension.json
+++ b/ReCaptchaNoCaptcha/extension.json
@@ -13,5 +13,19 @@
"ReCaptchaSiteKey": "",
"ReCaptchaSecretKey": "",
"ReCaptchaSendRemoteIP": false
+ },
+ "ResourceModules": {
+ "ext.confirmEdit.reCaptchaNoCaptcha.styles": {
+ "position": "top",
+ "styles": "ext.confirmEdit.reCaptchaNoCaptcha.less",
+ "targets": [
+ "mobile",
+ "desktop"
+ ]
+ }
+ },
+ "ResourceFileModulePaths": {
+ "localBasePath": "resources",
+ "remoteExtPath": "ConfirmEdit/ReCaptchaNoCaptcha/resources"
}
}
diff --git
a/ReCaptchaNoCaptcha/resources/ext.confirmEdit.reCaptchaNoCaptcha.less
b/ReCaptchaNoCaptcha/resources/ext.confirmEdit.reCaptchaNoCaptcha.less
new file mode 100644
index 0000000..ab83418
--- /dev/null
+++ b/ReCaptchaNoCaptcha/resources/ext.confirmEdit.reCaptchaNoCaptcha.less
@@ -0,0 +1,19 @@
+.mw-confirmedit-captcha-nomobile {
+ /*
+ * Source:
https://www.geekgoddess.com/how-to-resize-the-google-nocaptcha-recaptcha/
+ */
+ &#rc-imageselect,
+ &.g-recaptcha {
+ transform: scale(0.955);
+ transform-origin: 0;
+ -webkit-transform: scale(0.955);
+ transform: scale(0.955);
+ }
+}
+
+.mw-confirmedit-captcha-mobile {
+ div {
+ margin-right: auto;
+ margin-left: auto;
+ }
+}
diff --git a/SimpleCaptcha/Captcha.php b/SimpleCaptcha/Captcha.php
index ce5f0a7..eb9b1fa 100755
--- a/SimpleCaptcha/Captcha.php
+++ b/SimpleCaptcha/Captcha.php
@@ -5,6 +5,8 @@
class SimpleCaptcha {
/** @var boolean|null Was the CAPTCHA already passed and if yes, with
which result? */
private $captchaSolved = null;
+ /** @var bool|null Holds a value, if this request was made from a
mobile device or not */
+ protected $isMobileRequest = null;
function getCaptcha() {
$a = mt_rand( 0, 100 );
@@ -994,4 +996,22 @@
}
return true;
}
+
+ /**
+ * If MobileFrontend is installed, returns, if the request will be
displayed
+ * on a mobile device or on a device with activated mobile view.
+ *
+ * @return bool
+ */
+ protected function isMobileRequest() {
+ if ( !$this->isMobileRequest ) {
+ $isMobile = false;
+ // FIXME: convert to ExtensionRegistration after MF
converted to it
+ if ( class_exists( 'MobileContext' ) ) {
+ $isMobile =
MobileContext::singleton()->shouldDisplayMobileView();
+ }
+ $this->isMobileRequest = $isMobile;
+ }
+ return $this->isMobileRequest;
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/237682
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2670e49a5e7002b3c3d825e06202606b6daa1b4b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ConfirmEdit
Gerrit-Branch: master
Gerrit-Owner: Florianschmidtwelzow <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits