| Index: trunk/phase3/resources/mediawiki.action/mediawiki.action.watch.ajax.js |
| — | — | @@ -1,7 +1,6 @@ |
| 2 | 2 | /** |
| 3 | 3 | * Animate watch/unwatch links to use asynchronous API requests to |
| 4 | 4 | * watch pages, rather than clicking on links. Requires jQuery. |
| 5 | | - * Uses jsMsg() from wikibits.js. |
| 6 | 5 | */ |
| 7 | 6 | |
| 8 | 7 | if ( typeof wgAjaxWatch === 'undefined' || !wgAjaxWatch ) { |
| — | — | @@ -37,16 +36,16 @@ |
| 38 | 37 | wgAjaxWatch.$links.trigger( 'mw-ajaxwatch', [response.title, 'unwatch', $link] ); |
| 39 | 38 | } else { |
| 40 | 39 | // Either we got an error code or it just plain broke. |
| 41 | | - window.location.href = $link.attr( 'href' ); |
| | 40 | + window.location.href = $link[0].href; |
| 42 | 41 | return; |
| 43 | 42 | } |
| 44 | 43 | |
| 45 | | - jsMsg( response.message, 'watch' ); |
| | 44 | + mw.util.jsMessage( response.message, 'watch' ); |
| 46 | 45 | |
| 47 | 46 | // Bug 12395 - update the watch checkbox on edit pages when the |
| 48 | 47 | // page is watched or unwatched via the tab. |
| 49 | 48 | if( response.watched !== undefined ) { |
| 50 | | - $( '#wpWatchthis' ).attr( 'checked', '1' ); |
| | 49 | + $( '#wpWatchthis' ).attr( 'checked', 'checked' ); |
| 51 | 50 | } else { |
| 52 | 51 | $( '#wpWatchthis' ).removeAttr( 'checked' ); |
| 53 | 52 | } |
| — | — | @@ -74,7 +73,7 @@ |
| 75 | 74 | $links.click( function( event ) { |
| 76 | 75 | var $link = $( this ); |
| 77 | 76 | |
| 78 | | - if( wgAjaxWatch.supported === false || !wgEnableWriteAPI || !wfSupportsAjax() ) { |
| | 77 | + if( wgAjaxWatch.supported === false || !mw.config.get( 'wgEnableWriteAPI' ) || !wfSupportsAjax() ) { |
| 79 | 78 | // Lazy initialization so we don't toss up |
| 80 | 79 | // ActiveX warnings on initial page load |
| 81 | 80 | // for IE 6 users with security settings. |
| — | — | @@ -83,8 +82,8 @@ |
| 84 | 83 | } |
| 85 | 84 | |
| 86 | 85 | wgAjaxWatch.setLinkText( $link, $link.data( 'action' ) + 'ing' ); |
| 87 | | - $.getJSON( wgScriptPath |
| 88 | | - + '/api' + wgScriptExtension + '?action=watch&format=json&title=' |
| | 86 | + $.getJSON( mw.config.get( 'wgScriptPath' ) |
| | 87 | + + '/api' + mw.config.get( 'wgScriptExtension' ) + '?action=watch&format=json&title=' |
| 89 | 88 | + encodeURIComponent( $link.data( 'target' ) ) |
| 90 | 89 | + ( $link.data( 'action' ) == 'unwatch' ? '&unwatch' : '' ), |
| 91 | 90 | function( data, textStatus, xhr ) { |
| — | — | @@ -107,8 +106,8 @@ |
| 108 | 107 | $link.data( 'action', otheraction ); |
| 109 | 108 | wgAjaxWatch.setLinkText( $link, otheraction ); |
| 110 | 109 | $link.attr( 'href', $link.attr( 'href' ).replace( '&action=' + action , '&action=' + otheraction ) ); |
| 111 | | - if( $link.parents( 'li' ).attr( 'id' ) == 'ca-' + action ) { |
| 112 | | - $link.parents( 'li' ).attr( 'id', 'ca-' + otheraction ); |
| | 110 | + if( $link.closest( 'li' ).attr( 'id' ) == 'ca-' + action ) { |
| | 111 | + $link.closest( 'li' ).attr( 'id', 'ca-' + otheraction ); |
| 113 | 112 | // update the link text with the new message |
| 114 | 113 | $link.text( mediaWiki.msg( otheraction ) ); |
| 115 | 114 | } |
| Index: trunk/phase3/resources/mediawiki.util/mediawiki.util.js |
| — | — | @@ -314,6 +314,43 @@ |
| 315 | 315 | |
| 316 | 316 | return $item.get( 0 ); |
| 317 | 317 | } |
| | 318 | + }, |
| | 319 | + |
| | 320 | + /** |
| | 321 | + * Add a little box at the top of the screen to inform the user of |
| | 322 | + * something, replacing any previous message. |
| | 323 | + * |
| | 324 | + * @param message mixed DOM-element or HTML to be put inside the message box |
| | 325 | + * @param className string Used in adding a class; should be different for each |
| | 326 | + * call to allow CSS/JS to hide different boxes. null = no class used. |
| | 327 | + * @return Boolean True on success, false on failure |
| | 328 | + */ |
| | 329 | + 'jsMessage' : function( message, className ) { |
| | 330 | + // We special-case skin structures provided by the software. Skins that |
| | 331 | + // choose to abandon or significantly modify our formatting can just define |
| | 332 | + // an mw-js-message div to start with. |
| | 333 | + var $messageDiv = $( '#mw-js-message' ); |
| | 334 | + if ( !$messageDiv.length ) { |
| | 335 | + $messageDiv = $( '<div id="mw-js-message">' ); |
| | 336 | + if ( mw.util.$content.parent().length ) { |
| | 337 | + mw.util.$content.parent().prepend( $messageDiv ); |
| | 338 | + } else { |
| | 339 | + return false; |
| | 340 | + } |
| | 341 | + } |
| | 342 | + |
| | 343 | + $messageDiv.show(); |
| | 344 | + if ( className ) { |
| | 345 | + $messageDiv.attr( 'class', 'mw-js-message-' + className ); |
| | 346 | + } |
| | 347 | + |
| | 348 | + if ( typeof message === 'object' ) { |
| | 349 | + $messageDiv.empty(); |
| | 350 | + $messageDiv.append( message ); // Append new content |
| | 351 | + } else { |
| | 352 | + $messageDiv.html( message ); |
| | 353 | + } |
| | 354 | + return true; |
| 318 | 355 | } |
| 319 | 356 | |
| 320 | 357 | }; |
| Index: trunk/phase3/resources/Resources.php |
| — | — | @@ -343,7 +343,7 @@ |
| 344 | 344 | ), |
| 345 | 345 | 'mediawiki.action.watch.ajax' => array( |
| 346 | 346 | 'scripts' => 'resources/mediawiki.action/mediawiki.action.watch.ajax.js', |
| 347 | | - 'dependencies' => 'mediawiki.util', |
| | 347 | + 'dependencies' => array( 'mediawiki.util', 'mediawiki.legacy.ajax' ), |
| 348 | 348 | ), |
| 349 | 349 | 'mediawiki.special.preferences' => array( |
| 350 | 350 | 'scripts' => 'resources/mediawiki.special/mediawiki.special.preferences.js', |