Florianschmidtwelzow has uploaded a new change for review.

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

Change subject: Some design to the matrol link and use ajax to patrol
......................................................................

Some design to the matrol link and use ajax to patrol

* Use a neutral button for the matrol link instead of a simple text link
* Use mediawiki.page.patrol for ajax patrolling a revision instead of 
redirecting
  to a new page

Depends on: Id09ccf60aec9b693d7df648a6dfcde629545f620

Bug: T101491
Change-Id: I08b871fb1608f8cc576cec73ef2e9864d26a9a38
---
M includes/Resources.php
M includes/diff/InlineDifferenceEngine.php
M includes/specials/SpecialMobileDiff.php
A resources/mobile.patrol.ajax/init.js
4 files changed, 60 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/28/216128/1

diff --git a/includes/Resources.php b/includes/Resources.php
index ec25274..ec07ba2 100644
--- a/includes/Resources.php
+++ b/includes/Resources.php
@@ -1413,6 +1413,16 @@
                ),
        ),
 
+       'mobile.patrol.ajax' => $wgMFResourceFileModuleBoilerplate + array(
+               'dependencies' => array(
+                       'mobile.startup',
+                       'mediawiki.page.patrol',
+               ),
+               'scripts' => array(
+                       'resources/mobile.patrol.ajax/init.js'
+               ),
+       ),
+
        // Custom ResourceLoaderModule classes
        'mobile.site' => array(
                'dependencies' => array( 'mobile.startup' ),
diff --git a/includes/diff/InlineDifferenceEngine.php 
b/includes/diff/InlineDifferenceEngine.php
index b101347..70782ad 100644
--- a/includes/diff/InlineDifferenceEngine.php
+++ b/includes/diff/InlineDifferenceEngine.php
@@ -142,6 +142,19 @@
         * @return String
         */
        public function getPatrolledLink() {
-               return $this->markPatrolledLink();
+               $linkInfo = $this->getMarkPatrolledLinkInfo( 
'mobile.patrol.ajax' );
+               if ( $linkInfo ) {
+                       return Html::linkButton(
+                               $this->msg( 'markaspatrolleddiff' )->escaped(),
+                               array(
+                                       'href' => $this->mNewPage->getLocalUrl( 
array(
+                                               'action' => 'markpatrolled',
+                                               'rcid' => $linkInfo['rcid'],
+                                               'token' => $linkInfo['token'],
+                                       ) ),
+                               )
+                       );
+               }
+               return '';
        }
 }
diff --git a/includes/specials/SpecialMobileDiff.php 
b/includes/specials/SpecialMobileDiff.php
index 9c6b5cc..1ed81ff 100644
--- a/includes/specials/SpecialMobileDiff.php
+++ b/includes/specials/SpecialMobileDiff.php
@@ -311,8 +311,15 @@
                        );
                }
 
-               if ( $this->mDiffEngine instanceof InlineDifferenceEngine ) {
-                       $output->addHtml( 
$this->mDiffEngine->getPatrolledLink() );
+               $diffEngine = $this->mDiffEngine;
+               if ( $diffEngine instanceof InlineDifferenceEngine ) {
+                       $output->addHtml( Html::rawElement(
+                               'div',
+                               array(
+                                       'class' => 'patrollink'
+                               ),
+                               $diffEngine->getPatrolledLink()
+                       ) );
                }
 
                $output->addHtml(
diff --git a/resources/mobile.patrol.ajax/init.js 
b/resources/mobile.patrol.ajax/init.js
new file mode 100644
index 0000000..f6c3b71
--- /dev/null
+++ b/resources/mobile.patrol.ajax/init.js
@@ -0,0 +1,27 @@
+/*!
+ * Animate patrol links to use asynchronous API requests to
+ * patrol pages, rather than navigating to a different URI.
+ *
+ * @author Florian Schmidt <florian.schmidt.wel...@t-online.de>
+ */
+( function ( M, $ ) {
+       if ( !mw.user.tokens.exists( 'patrolToken' ) ) {
+               // Current user has no patrol right, or an old cached version 
of user.tokens
+               // that didn't have patrolToken yet.
+               return;
+       }
+       $( function () {
+               var $patrolLinks = $( '.patrollink a' ),
+                       Icon = M.require( 'Icon' );
+
+               mw.patrol.setup( {
+                       links: $patrolLinks,
+                       // use Icon and not icons.spinner() to avoid adding 
classes (and styles) we don't
+                       // want/need
+                       spinner: $( new Icon( {
+                               name: 'spinner',
+                               additionalClassNames: 'savespinner loading'
+                       } ).toHtmlString() )
+               } );
+       } );
+}( mw.mobileFrontend, jQuery ) );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I08b871fb1608f8cc576cec73ef2e9864d26a9a38
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Florianschmidtwelzow <florian.schmidt.wel...@t-online.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to