[ Index ] |
PHP Cross Reference of MediaWiki-1.24.0 |
[Summary view] [Print] [Text view]
1 /*! 2 * JavaScript for Special:UnwatchedPages 3 */ 4 ( function ( mw, $ ) { 5 $( function () { 6 $( 'a.mw-watch-link' ).click( function ( e ) { 7 var promise, 8 api = new mw.Api(), 9 $link = $( this ), 10 $subjectLink = $link.closest( 'li' ).children( 'a' ).eq( 0 ), 11 title = mw.util.getParamValue( 'title', $link.attr( 'href' ) ); 12 // nice format 13 title = mw.Title.newFromText( title ).toText(); 14 // Disable link whilst we're busy to avoid double handling 15 if ( $link.data( 'mwDisabled' ) ) { 16 // mw-watch-link-disabled disables pointer-events which prevents the click event 17 // from happening in the first place. In older browsers we kill the event here. 18 return false; 19 } 20 $link.data( 'mwDisabled', true ).addClass( 'mw-watch-link-disabled' ); 21 22 // Use the class to determine whether to watch or unwatch 23 if ( !$subjectLink.hasClass( 'mw-watched-item' ) ) { 24 $link.text( mw.msg( 'watching' ) ); 25 promise = api.watch( title ).done( function () { 26 $subjectLink.addClass( 'mw-watched-item' ); 27 $link.text( mw.msg( 'unwatch' ) ); 28 mw.notify( mw.msg( 'addedwatchtext-short', title ) ); 29 } ).fail( function () { 30 $link.text( mw.msg( 'watch' ) ); 31 mw.notify( mw.msg( 'watcherrortext', title ) ); 32 } ); 33 } else { 34 $link.text( mw.msg( 'unwatching' ) ); 35 promise = api.unwatch( title ).done( function () { 36 $subjectLink.removeClass( 'mw-watched-item' ); 37 $link.text( mw.msg( 'watch' ) ); 38 mw.notify( mw.msg( 'removedwatchtext-short', title ) ); 39 } ).fail( function () { 40 $link.text( mw.msg( 'unwatch' ) ); 41 mw.notify( mw.msg( 'watcherrortext', title ) ); 42 } ); 43 } 44 45 promise.always( function () { 46 $link.data( 'mwDisabled', false ).removeClass( 'mw-watch-link-disabled' ); 47 } ); 48 49 e.preventDefault(); 50 } ); 51 } ); 52 }( mediaWiki, jQuery ) );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 14:03:12 2014 | Cross-referenced by PHPXref 0.7.1 |