Tholam has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/97852


Change subject: Add refresh functionality on fancycaptcha for mobile
......................................................................

Add refresh functionality on fancycaptcha for mobile

Created a new module for use in mobilefrontend extension

Bug: 51482
Change-Id: Ieecf289ec5fb7307369ba8b3f1ebbe682b900383
---
M FancyCaptcha.php
A resources/ext.confirmEdit.fancyCaptchaMobile.js
2 files changed, 47 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ConfirmEdit 
refs/changes/52/97852/1

diff --git a/FancyCaptcha.php b/FancyCaptcha.php
index 46002e2..4ccab8b 100644
--- a/FancyCaptcha.php
+++ b/FancyCaptcha.php
@@ -41,7 +41,7 @@
 
 global $wgCaptchaDirectory;
 $wgCaptchaDirectory = "$wgUploadDirectory/captcha"; // bad default :D
-
+$wgCaptchaDirectory = $dir."/output"; // bad default :D
 global $wgCaptchaDirectoryLevels;
 $wgCaptchaDirectoryLevels = 0; // To break into subdirectories
 
@@ -62,6 +62,7 @@
 $wgResourceModules['ext.confirmEdit.fancyCaptcha.styles'] = array(
        'localBasePath' => $dir . '/resources',
        'remoteExtPath' => 'ConfirmEdit/resources',
+       'targets' => array('mobile','desktop'),
        'styles' => 'ext.confirmEdit.fancyCaptcha.css',
 );
 
@@ -72,5 +73,13 @@
        'dependencies' => 'mediawiki.api',
 );
 
+$wgResourceModules['ext.confirmEdit.fancyCaptchaMobile'] = array(
+       'localBasePath' => $dir . '/resources',
+       'remoteExtPath' => 'ConfirmEdit/resources',
+       'scripts' => 'ext.confirmEdit.fancyCaptchaMobile.js',
+       'targets' => array('mobile','desktop'),
+       'dependencies' => 'mobile.startup',
+);
+
 $wgAutoloadClasses['ApiFancyCaptchaReload'] = $dir . 
'/ApiFancyCaptchaReload.php';
 $wgAPIModules['fancycaptchareload'] = 'ApiFancyCaptchaReload';
diff --git a/resources/ext.confirmEdit.fancyCaptchaMobile.js 
b/resources/ext.confirmEdit.fancyCaptchaMobile.js
new file mode 100644
index 0000000..2cccf7e
--- /dev/null
+++ b/resources/ext.confirmEdit.fancyCaptchaMobile.js
@@ -0,0 +1,37 @@
+( function ( $, mw ) {
+       alert('test');
+       var api = mw.mobileFrontend.require( 'api' );
+       $( document ).on( 'click', '.fancycaptcha-reload', function () {
+               var $this = $( this ), $captchaImage;
+
+               $this.addClass( 'fancycaptcha-reload-loading' );
+               $captchaImage = $( '.fancycaptcha-image' );
+               
+
+               // AJAX request to get captcha index key
+               api.post( {
+                       action: 'fancycaptchareload',
+                       format: 'xml'
+               }, {
+                       dataType: 'xml'
+               } )
+               .done( function ( xmldata ) {
+                       var imgSrc, captchaIndex;
+                       captchaIndex = $( xmldata ).find( 'fancycaptchareload' 
).attr( 'index' );
+                       if ( typeof captchaIndex === 'string' ) {
+                               // replace index key with a new one for captcha 
image
+                               imgSrc = $captchaImage.attr( 'src' )
+                               .replace( /(wpCaptchaId=)\w+/, '$1' + 
captchaIndex );
+                               $captchaImage.attr( 'src', imgSrc );
+
+                               // replace index key with a new one for hidden 
tag
+                               $( '#wpCaptchaId' ).val( captchaIndex );
+                               $( '#wpCaptchaWord' ).val( '' ).focus();
+                       }
+               } )
+               .always( function () {
+                       $this.removeClass( 'fancycaptcha-reload-loading' );
+               } );
+               return false;
+       } );
+} )( jQuery, mediaWiki );
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/97852
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ieecf289ec5fb7307369ba8b3f1ebbe682b900383
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ConfirmEdit
Gerrit-Branch: master
Gerrit-Owner: Tholam <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to