Florianschmidtwelzow has uploaded a new change for review.
https://gerrit.wikimedia.org/r/249220
Change subject: Hide Username input field, if it's not required
......................................................................
Hide Username input field, if it's not required
Change-Id: I02409149137919e36a231243f4ed043903e19f86
---
M GoogleLogin.php
M includes/specials/SpecialGoogleLogin.php
A javascripts/specialpages/ext.GoogleLogin.specialGoogleLogin.chooseown.js
3 files changed, 54 insertions(+), 27 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GoogleLogin
refs/changes/20/249220/1
diff --git a/GoogleLogin.php b/GoogleLogin.php
index 8a4e660..5dfd914 100644
--- a/GoogleLogin.php
+++ b/GoogleLogin.php
@@ -102,30 +102,41 @@
),
);
-$wgResourceModules['ext.GoogleLogin.specialManage.scripts'] =
$wgGLResourcePath + array(
- 'dependencies' => array(
- 'mediawiki.api',
- 'oojs-ui'
+$wgResourceModules += array(
+ 'ext.GoogleLogin.specialManage.scripts' => $wgGLResourcePath + array(
+ 'dependencies' => array(
+ 'mediawiki.api',
+ 'oojs-ui'
+ ),
+ 'scripts' => array(
+
'javascripts/specialpages/ext.GoogleLogin.specialManage.js'
+ ),
+ 'styles' => array(
+ 'style/ext.GoogleLogin.specialManage.css'
+ ),
+ 'messages' => array(
+ 'googlelogin-googleuser',
+ 'googlelogin-manage-isplusser',
+ 'googlelogin-manage-orgname',
+ 'googlelogin-manage-orgtitle',
+ 'googlelogin-manage-orgsince',
+ 'googlelogin-manage-yes',
+ 'googlelogin-manage-no',
+ 'googlelogin-manage-errorloading',
+ 'googlelogin-manage-dismiss',
+ 'googlelogin-manage-openpluslink',
+ 'googlelogin-manage-unknownerror',
+ 'googlelogin-manage-plusinfo-title',
+ ),
),
- 'scripts' => array(
- 'javascripts/specialpages/ext.GoogleLogin.specialManage.js'
- ),
- 'styles' => array(
- 'style/ext.GoogleLogin.specialManage.css'
- ),
- 'messages' => array(
- 'googlelogin-googleuser',
- 'googlelogin-manage-isplusser',
- 'googlelogin-manage-orgname',
- 'googlelogin-manage-orgtitle',
- 'googlelogin-manage-orgsince',
- 'googlelogin-manage-yes',
- 'googlelogin-manage-no',
- 'googlelogin-manage-errorloading',
- 'googlelogin-manage-dismiss',
- 'googlelogin-manage-openpluslink',
- 'googlelogin-manage-unknownerror',
- 'googlelogin-manage-plusinfo-title',
+ 'ext.GoogleLogin.specialGoogleLogin.chooseown' => $wgGLResourcePath +
array(
+ 'dependencies' => array(
+ 'oojs-ui',
+ ),
+ 'scripts' => array(
+
'javascripts/specialpages/ext.GoogleLogin.specialGoogleLogin.chooseown.js',
+ ),
+ 'targets' => array( 'desktop', 'mobile' ),
),
);
diff --git a/includes/specials/SpecialGoogleLogin.php
b/includes/specials/SpecialGoogleLogin.php
index 7bdf61d..3142c0b 100644
--- a/includes/specials/SpecialGoogleLogin.php
+++ b/includes/specials/SpecialGoogleLogin.php
@@ -272,7 +272,10 @@
*/
private function createGoogleUserForm( array $userInfo ) {
$request = $this->getRequest();
- $this->getOutput()->setPageTitle( $this->msg(
'googlelogin-form-choosename-title' )->text() );
+ $out = $this->getOutput();
+
+ $out->addModules( array(
'ext.GoogleLogin.specialGoogleLogin.chooseown' ) );
+ $out->setPageTitle( $this->msg(
'googlelogin-form-choosename-title' )->text() );
// create an array of possible usernames
$names = array(
@@ -287,21 +290,24 @@
// "Choose own", so the user can pass it's own username
$names[$this->msg( 'googlelogin-form-chooseown' )->text() .
':'] = 'wpOwn';
+ $co = $request->getVal( 'wpChooseName' );
+
$formElements = array(
'ChooseName' => array(
'type' => 'radio',
'options' => $names,
- 'default' => ( $request->getVal( 'wpChooseName'
) !== null ?
- $request->getVal( 'wpChooseName' ) :
'wpOwn' ),
+ 'default' => ( $co !== null ? $co : 'wpOwn' ),
),
'ChooseOwn' => array(
'class' => 'HTMLTextField',
- 'default' => $request->getVal( 'wpChooseOwn' ),
+ 'default' => $co,
+ 'cssclass' => 'mw-googlelogin-wpOwninput ' . (
$co === 'wpOwn' || $co === null ? '' : 'hidden' ),
'placeholder' => $this->msg(
'googlelogin-form-choosename-placeholder' )->text()
),
);
$htmlForm = HTMLForm::factory( 'ooui', $formElements,
$this->getContext(), 'googlelogin-form' );
+ $htmlForm->setId( 'googlelogin-createform' );
$htmlForm->addHiddenField( 'action', 'Create' );
$htmlForm->addHiddenField( 'wpSecureHash',
$this->mGoogleLogin->getRequestToken() );
$htmlForm->setWrapperLegendMsg( 'googlelogin-form-choosename' );
diff --git
a/javascripts/specialpages/ext.GoogleLogin.specialGoogleLogin.chooseown.js
b/javascripts/specialpages/ext.GoogleLogin.specialGoogleLogin.chooseown.js
new file mode 100644
index 0000000..1b9a9b8
--- /dev/null
+++ b/javascripts/specialpages/ext.GoogleLogin.specialGoogleLogin.chooseown.js
@@ -0,0 +1,10 @@
+$( function ( $ ) {
+ // make sure, the form is infused before adding event listeners
+ $( '#googlelogin-createform [data-ooui]' ).each( function () {
+ OO.ui.infuse( this );
+ } );
+
+ $( '.oo-ui-radioSelectInputWidget input:radio' ).click( function () {
+ $( '.mw-googlelogin-wpOwninput' ).toggleClass( 'hidden',
this.value !== 'wpOwn' );
+ } );
+}( jQuery ) );
\ No newline at end of file
--
To view, visit https://gerrit.wikimedia.org/r/249220
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I02409149137919e36a231243f4ed043903e19f86
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GoogleLogin
Gerrit-Branch: master
Gerrit-Owner: Florianschmidtwelzow <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits