{"version":3,"sources":["webpack://mfModules.[name]/./src/mobile.special.mobilediff.scripts.js"],"names":["user","mw","Icon","require","toast","tokens","exists","$","href","rcid","$patrolLinks","$spinner","name","additionalClassNames","$el","on","e","target","hide","after","this","attr","util","getParamValue","Api","postWithToken","action","then","data","title","closest","replaceWith","addClass","prop","text","remove","undefined","patrol","Title","show","msg","toText","type","error","preventDefault"],"mappings":";;;;;;;AAOA,IAAIA,EAAOC,GAAGD,KACbE,EAAOC,EAAS,gCAChBC,EAAQD,EAAS,iCA0DbH,EAAKK,OAAOC,OAAQ,gBAGxBC,EAxDD,WACC,IAKCC,EAAMC,EALHC,EAAeH,EAAG,iBACrBI,EAAa,IAAIT,GAChBU,KAAM,UACNC,qBAAsB,wBACjBC,IAGPJ,EAAaK,GAAI,QAAS,SAAWC,GAEpCT,EAAGS,EAAEC,QAASC,OAAOC,MAAOR,GAE5BH,EAAOD,EAAGa,MAAOC,KAAM,QACvBZ,EAAOR,GAAGqB,KAAKC,cAAe,OAAQf,IACzB,IAAIP,GAAGuB,KACTC,cAAe,UACzBC,OAAQ,SACRjB,KAAMA,IACHkB,KAAM,SAAWC,GACpB,IAAIC,EAGJnB,EAAaoB,QAAS,eAAgBC,YACrCxB,EAAG,YACDyB,SAAU,2BACVC,KAAM,YAAY,GAClBC,KAAMxB,EAAaoB,QAAS,eAAgBI,SAE/CvB,EAASwB,cACYC,IAAhBR,EAAKS,QAETR,EAAQ,IAAI5B,GAAGqC,MAAOV,EAAKS,OAAOR,OAClCzB,EAAMmC,KAAMtC,GAAGuC,IAAK,0BAA2BX,EAAMY,YAGrDrC,EAAMmC,KAAMtC,GAAGuC,IAAK,iCAAoCE,KAAM,WAE7D,SAAWC,GACbhC,EAASwB,SAGTzB,EAAa6B,OACE,iBAAVI,EAEJvC,EAAMmC,KAAMtC,GAAGuC,IAAK,wCAA2CE,KAAM,SAErEtC,EAAMmC,KAAMtC,GAAGuC,IAAK,iCAAoCE,KAAM,YAIhE1B,EAAE4B","file":"mobile.special.mobilediff.scripts.js","sourcesContent":["/* global $ */\n/*!\n* Animate patrol links to use asynchronous API requests to\n* patrol pages, rather than navigating to a different URI.\n*\n* @author Florian Schmidt <florian.schmidt.welzow@t-online.de>\n*/\nvar user = mw.user,\n\tIcon = require( './mobile.startup/Icon' ),\n\ttoast = require( './mobile.startup/toast' );\n\n/**\n * Initialise mobile page patrolling as provided by the PageTriage extension.\n */\nfunction init() {\n\tvar $patrolLinks = $( '.patrollink a' ),\n\t\t$spinner = ( new Icon( {\n\t\t\tname: 'spinner',\n\t\t\tadditionalClassNames: 'savespinner loading'\n\t\t} ) ).$el,\n\t\thref, rcid, apiRequest;\n\n\t$patrolLinks.on( 'click', function ( e ) {\n\t\t// Hide the link show a spinner instead.\n\t\t$( e.target ).hide().after( $spinner );\n\n\t\thref = $( this ).attr( 'href' );\n\t\trcid = mw.util.getParamValue( 'rcid', href );\n\t\tapiRequest = new mw.Api();\n\t\tapiRequest.postWithToken( 'patrol', {\n\t\t\taction: 'patrol',\n\t\t\trcid: rcid\n\t\t} ).then( function ( data ) {\n\t\t\tvar title;\n\n\t\t\t// Disable all patrollinks from the page.\n\t\t\t$patrolLinks.closest( '.patrollink' ).replaceWith(\n\t\t\t\t$( '<button>' )\n\t\t\t\t\t.addClass( 'mw-ui-button patrollink' )\n\t\t\t\t\t.prop( 'disabled', true )\n\t\t\t\t\t.text( $patrolLinks.closest( '.patrollink' ).text() )\n\t\t\t);\n\t\t\t$spinner.remove();\n\t\t\tif ( data.patrol !== undefined ) {\n\t\t\t\t// Success\n\t\t\t\ttitle = new mw.Title( data.patrol.title );\n\t\t\t\ttoast.show( mw.msg( 'markedaspatrollednotify', title.toText() ) );\n\t\t\t} else {\n\t\t\t\t// This should never happen as errors should trigger fail\n\t\t\t\ttoast.show( mw.msg( 'markedaspatrollederrornotify' ), { type: 'error' } );\n\t\t\t}\n\t\t}, function ( error ) {\n\t\t\t$spinner.remove();\n\t\t\t// Restore the patrol link. This allows the user to try again\n\t\t\t// (or open it in a new window, bypassing this ajax module).\n\t\t\t$patrolLinks.show();\n\t\t\tif ( error === 'noautopatrol' ) {\n\t\t\t\t// Can't patrol own\n\t\t\t\ttoast.show( mw.msg( 'markedaspatrollederror-noautopatrol' ), { type: 'warn' } );\n\t\t\t} else {\n\t\t\t\ttoast.show( mw.msg( 'markedaspatrollederrornotify' ), { type: 'error' } );\n\t\t\t}\n\t\t} );\n\n\t\te.preventDefault();\n\t} );\n}\nif ( user.tokens.exists( 'patrolToken' ) ) {\n\t// Current user has no patrol right, or an old cached version of user.tokens\n\t// that didn't have patrolToken yet.\n\t$( init );\n}\n"],"sourceRoot":""}